composer.phar 2.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551
  1. #!/usr/bin/env php
  2. <?php
  3. /*
  4. * This file is part of Composer.
  5. *
  6. * (c) Nils Adermann <naderman@naderman.de>
  7. * Jordi Boggiano <j.boggiano@seld.be>
  8. *
  9. * For the full copyright and license information, please view
  10. * the license that is located at the bottom of this file.
  11. */
  12. // Avoid APC causing random fatal errors per https://github.com/composer/composer/issues/264
  13. if (extension_loaded('apc') && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.cache_by_default'), FILTER_VALIDATE_BOOLEAN)) {
  14. if (version_compare(phpversion('apc'), '3.0.12', '>=')) {
  15. ini_set('apc.cache_by_default', 0);
  16. } else {
  17. fwrite(STDERR, 'Warning: APC <= 3.0.12 may cause fatal errors when running composer commands.'.PHP_EOL);
  18. fwrite(STDERR, 'Update APC, or set apc.enable_cli or apc.cache_by_default to 0 in your php.ini.'.PHP_EOL);
  19. }
  20. }
  21. if (!class_exists('Phar')) {
  22. echo 'PHP\'s phar extension is missing. Composer requires it to run. Enable the extension or recompile php without --disable-phar then try again.' . PHP_EOL;
  23. exit(1);
  24. }
  25. Phar::mapPhar('composer.phar');
  26. require 'phar://composer.phar/bin/composer';
  27. __HALT_COMPILER(); ?>
  28. ´¸��l������ ���composer.phar����+���src/Composer/Autoload/AutoloadGenerator.phpæ‚��táVbæ‚��˜M¸¤������+���src/Composer/Autoload/ClassMapGenerator.php��táVb��Â’T¤������(���src/Composer/Autoload/PhpFileCleaner.php ��táVb ��)í2„¤���������src/Composer/Cache.php=��táVb=��Ô-¼é¤������%���src/Composer/Command/AboutCommand.php[��táVb[��mt5¤������'���src/Composer/Command/ArchiveCommand.phpÝ��táVbÝ��ü•7 ¤������$���src/Composer/Command/BaseCommand.phpÙ ��táVbÙ ��V2´¤������.���src/Composer/Command/BaseDependencyCommand.php*��táVb*��ŸÊ’5¤������1���src/Composer/Command/CheckPlatformReqsCommand.phpõ��táVbõ��bþ“¿¤������*���src/Composer/Command/ClearCacheCommand.php��táVb��Ï1Z‚¤������&���src/Composer/Command/ConfigCommand.php#`��táVb#`��wÉZ�¤������-���src/Composer/Command/CreateProjectCommand.phpƒF��táVbƒF��äaϤ������'���src/Composer/Command/DependsCommand.php±��táVb±��|@}¤������(���src/Composer/Command/DiagnoseCommand.phpfM��táVbfM��¼—oc¤������,���src/Composer/Command/DumpAutoloadCommand.phpß��táVbß��Uá&}¤������$���src/Composer/Command/ExecCommand.php ��táVb ��3*˜Â¤������$���src/Composer/Command/FundCommand.phpÞ��táVbÞ��  •¤������&���src/Composer/Command/GlobalCommand.php·
  29. ��táVb·
  30. ��¨èŸ¤������$���src/Composer/Command/HomeCommand.php>��táVb>��ü‚­Ý¤������$���src/Composer/Command/InitCommand.php=B��táVb=B��­Žù¤������'���src/Composer/Command/InstallCommand.phpÜ��táVbÜ��> õ´¤������(���src/Composer/Command/LicensesCommand.phpe��táVbe��²?Ÿ¤������(���src/Composer/Command/OutdatedCommand.php¹��táVb¹��»Ô4¤������.���src/Composer/Command/PackageDiscoveryTrait.phpÌ7��táVbÌ7���ÔÔF¤������)���src/Composer/Command/ProhibitsCommand.php[��táVb[��áFϤ������)���src/Composer/Command/ReinstallCommand.php'��táVb'��@{õ¤������&���src/Composer/Command/RemoveCommand.phpñ*��táVbñ*��÷Ø›÷¤������'���src/Composer/Command/RequireCommand.phpgB��táVbgB��³y¤������)���src/Composer/Command/RunScriptCommand.phpÊ��táVbÊ��¡Êîë¤������+���src/Composer/Command/ScriptAliasCommand.phpÖ��táVbÖ��ƒ&ïݤ������&���src/Composer/Command/SearchCommand.php€��táVb€��bÇÕŒ¤������*���src/Composer/Command/SelfUpdateCommand.phpYK��táVbYK��Kž÷Ƥ������$���src/Composer/Command/ShowCommand.phpÓš��táVbÓš��‡[傤������&���src/Composer/Command/StatusCommand.phpx��táVbx�� d³¤������(���src/Composer/Command/SuggestsCommand.phpÀ ��táVbÀ ��‰f€¤¤������&���src/Composer/Command/UpdateCommand.php"4��táVb"4��>X¬¤������(���src/Composer/Command/ValidateCommand.phpå ��táVbå ��±&•‰¤���������src/Composer/Composer.php ��táVb ��wú÷ø¤���������src/Composer/Config.phpÔ4��táVbÔ4��Ãç¸Þ¤������-���src/Composer/Config/ConfigSourceInterface.phpÒ��táVbÒ��ß3¤������(���src/Composer/Config/JsonConfigSource.php•��táVb•��̃ ¤������$���src/Composer/Console/Application.phpG��táVbG��2o ¤������*���src/Composer/Console/GithubActionError.php��táVb��
  31. –ؤ������,���src/Composer/Console/HtmlOutputFormatter.php2��táVb2��˜¦y½¤������-���src/Composer/DependencyResolver/Decisions.phpè��táVbè��ŸE]¤������1���src/Composer/DependencyResolver/DefaultPolicy.php°��táVb°��Úœ]¤������/���src/Composer/DependencyResolver/GenericRule.phpš��táVbš��¡?·î¤������8���src/Composer/DependencyResolver/LocalRepoTransaction.php½��táVb½��ßšHš¤������3���src/Composer/DependencyResolver/LockTransaction.phpi ��táVbi ��û ¥¤������5���src/Composer/DependencyResolver/MultiConflictRule.php/��táVb/��bqi¤������>���src/Composer/DependencyResolver/Operation/InstallOperation.php��táVb��`:{c¤������I���src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php��táVb��w —[¤������K���src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php��táVb��j^Yb¤������@���src/Composer/DependencyResolver/Operation/OperationInterface.phpø���táVbø���÷Wý¤������=���src/Composer/DependencyResolver/Operation/SolverOperation.phpJ��táVbJ��uÂŸŠ¤������@���src/Composer/DependencyResolver/Operation/UninstallOperation.phpí��táVbí��îH¸ý¤������=���src/Composer/DependencyResolver/Operation/UpdateOperation.php§��táVb§��‹•Åy¤������3���src/Composer/DependencyResolver/PolicyInterface.php¢��táVb¢��5­c¤������(���src/Composer/DependencyResolver/Pool.phpó��táVbó��ÓÆtá¤������/���src/Composer/DependencyResolver/PoolBuilder.php�A��táVb�A��UŸÐ¤������1���src/Composer/DependencyResolver/PoolOptimizer.phpf*��táVbf*��éñEi¤������+���src/Composer/DependencyResolver/Problem.phpªJ��táVbªJ��ør$…¤������+���src/Composer/DependencyResolver/Request.phpé��táVbé���íl‡¤������(���src/Composer/DependencyResolver/Rule.phpÖ0��táVbÖ0��Ø"§ä¤������1���src/Composer/DependencyResolver/Rule2Literals.php��táVb��‘þ‰¤������+���src/Composer/DependencyResolver/RuleSet.phpä ��táVbä ��ÎŽ æ¤������4���src/Composer/DependencyResolver/RuleSetGenerator.php{��táVb{��íŽ(«¤������3���src/Composer/DependencyResolver/RuleSetIterator.phpM��táVbM��rá2g¤������2���src/Composer/DependencyResolver/RuleWatchChain.php~��táVb~��d,“r¤������2���src/Composer/DependencyResolver/RuleWatchGraph.php• ��táVb• ��(R¤������1���src/Composer/DependencyResolver/RuleWatchNode.phpx��táVbx���þ~*¤������*���src/Composer/DependencyResolver/Solver.php:��táVb:��}€ÒH¤������6���src/Composer/DependencyResolver/SolverBugException.php¼��táVb¼��ô––z¤������;���src/Composer/DependencyResolver/SolverProblemsException.php…��táVb…��…®¤������/���src/Composer/DependencyResolver/Transaction.phpk��táVbk��/EuƤ������-���src/Composer/Downloader/ArchiveDownloader.php½��táVb½��'\iE¤������1���src/Composer/Downloader/ChangeReportInterface.phpõ���táVbõ���­ÃÂB¤������+���src/Composer/Downloader/DownloadManager.php­��táVb­���•OQ¤������/���src/Composer/Downloader/DownloaderInterface.phpÐ��táVbÐ��9ꑤ������3���src/Composer/Downloader/DvcsDownloaderInterface.phpú���táVbú���à%'¤������*���src/Composer/Downloader/FileDownloader.php0��táVb0��N †¤������/���src/Composer/Downloader/FilesystemException.php3��táVb3��«a ܤ������,���src/Composer/Downloader/FossilDownloader.phph ��táVbh ��OE³j¤������)���src/Composer/Downloader/GitDownloader.php„D��táVb„D��Êô������*���src/Composer/Downloader/GzipDownloader.php·��táVb·��Fë ¤������(���src/Composer/Downloader/HgDownloader.php0 ��táVb0 ��Ÿ$Lë¤������8���src/Composer/Downloader/MaxFileSizeExceededException.phpŒ���táVbŒ���ÚºÔ¤������*���src/Composer/Downloader/PathDownloader.php|��táVb|��ÙŠ£ñ¤������.���src/Composer/Downloader/PerforceDownloader.php˜ ��táVb˜ ��©cñ¤������*���src/Composer/Downloader/PharDownloader.phpª��táVbª��XÈȤ������)���src/Composer/Downloader/RarDownloader.php›��táVb›��GU¤������)���src/Composer/Downloader/SvnDownloader.phpu��táVbu��Yš,Ѥ������)���src/Composer/Downloader/TarDownloader.php¨��táVb¨��×rß‚¤������.���src/Composer/Downloader/TransportException.phpƒ��táVbƒ��omšÆ¤������9���src/Composer/Downloader/VcsCapableDownloaderInterface.phpý���táVbý���ä6¤¤������)���src/Composer/Downloader/VcsDownloader.php5��táVb5��ñtP¤������(���src/Composer/Downloader/XzDownloader.php­��táVb­��&Ør‚¤������)���src/Composer/Downloader/ZipDownloader.phpu ��táVbu ��Z#›Ô¤������&���src/Composer/EventDispatcher/Event.phpä��táVbä��³ Qé¤������0���src/Composer/EventDispatcher/EventDispatcher.phpa6��táVba6��å´þ¤������9���src/Composer/EventDispatcher/EventSubscriberInterface.phpÂ���táVbÂ���}=é¤������9���src/Composer/EventDispatcher/ScriptExecutionException.php����táVb����ɱ'¤������9���src/Composer/Exception/IrrecoverableDownloadException.php����táVb����0Þ4 ¤������)���src/Composer/Exception/NoSslException.php����táVb����ØU¦Ò¤���������src/Composer/Factory.phpÆM��táVbÆM��Ù»¤������T���src/Composer/Filter/PlatformRequirementFilter/IgnoreAllPlatformRequirementFilter.phpW��táVbW��q¡‘&¤������U���src/Composer/Filter/PlatformRequirementFilter/IgnoreListPlatformRequirementFilter.php%��táVb%��U؆«¤������X���src/Composer/Filter/PlatformRequirementFilter/IgnoreNothingPlatformRequirementFilter.php��táVb��ÆX ¤������R���src/Composer/Filter/PlatformRequirementFilter/PlatformRequirementFilterFactory.php��táVb��l³†—¤������T���src/Composer/Filter/PlatformRequirementFilter/PlatformRequirementFilterInterface.phpÃ���táVbÃ���òsc¤���������src/Composer/IO/BaseIO.php;��táVb;��¥Ë›C¤���������src/Composer/IO/BufferIO.php?��táVb?��¤õ™¤���������src/Composer/IO/ConsoleIO.phpŒ��táVbŒ��öÖ ¤���������src/Composer/IO/IOInterface.phpÐ��táVbÐ��’Üm[¤���������src/Composer/IO/NullIO.phpO��táVbO��bˆ¨s¤���������src/Composer/Installer.php¤��táVb¤��Xï¤������*���src/Composer/Installer/BinaryInstaller.phpÿ(��táVbÿ(��×C±¤������2���src/Composer/Installer/BinaryPresenceInterface.phpæ���táVbæ���®3—Œ¤������.���src/Composer/Installer/InstallationManager.php17��táVb17��Ånݹ¤������)���src/Composer/Installer/InstallerEvent.php@��táVb@��³¤¤������*���src/Composer/Installer/InstallerEvents.php¥���táVb¥���>•íǤ������-���src/Composer/Installer/InstallerInterface.phpw��táVbw��{Üaè¤������+���src/Composer/Installer/LibraryInstaller.phpŒ��táVbŒ��É‘·—¤������/���src/Composer/Installer/MetapackageInstaller.phpÏ��táVbÏ���)ˆ�¤������(���src/Composer/Installer/NoopInstaller.php^��táVb^��T¥N­¤������'���src/Composer/Installer/PackageEvent.php��táVb��ß齤������(���src/Composer/Installer/PackageEvents.phpû��táVbû��ò«K¤������*���src/Composer/Installer/PluginInstaller.phpš ��táVbš ��)í�̤������+���src/Composer/Installer/ProjectInstaller.php= ��táVb= ��ÆÀçâ¤������4���src/Composer/Installer/SuggestedPackagesReporter.phpÉ��táVbÉ��‘µUŤ���������src/Composer/Json/JsonFile.php`��táVb`��Òk¶Ÿ¤������#���src/Composer/Json/JsonFormatter.php ��táVb ��& {B¤������%���src/Composer/Json/JsonManipulator.phpˆ4��táVbˆ4��Á>f�¤������-���src/Composer/Json/JsonValidationException.phpœ��táVbœ��“¬J¤������%���src/Composer/Package/AliasPackage.phpw��táVbw��I$aü¤������7���src/Composer/Package/Archiver/ArchivableFilesFilter.php;��táVb;��Z³¤������7���src/Composer/Package/Archiver/ArchivableFilesFinder.phpM��táVbM��¹Ôæ¤������0���src/Composer/Package/Archiver/ArchiveManager.phpq��táVbq��®]õO¤������3���src/Composer/Package/Archiver/ArchiverInterface.phpX��táVbX��Îç£9¤������3���src/Composer/Package/Archiver/BaseExcludeFilter.php%��táVb%���³…ó¤������7���src/Composer/Package/Archiver/ComposerExcludeFilter.php?��táVb?��?�`^¤������2���src/Composer/Package/Archiver/GitExcludeFilter.php)��táVb)��ÓC¤������.���src/Composer/Package/Archiver/PharArchiver.phpÕ��táVbÕ��ä”” ¤������-���src/Composer/Package/Archiver/ZipArchiver.php��táVb��‚‡gã¤������$���src/Composer/Package/BasePackage.php¡��táVb¡��¬\Ã(¤������*���src/Composer/Package/Comparer/Comparer.phpÌ ��táVbÌ ��Dˤ������-���src/Composer/Package/CompleteAliasPackage.phpq
  32. ��táVbq
  33. ��ú #·¤������(���src/Composer/Package/CompletePackage.php-
  34. ��táVb-
  35. ��Z9Ú´¤������1���src/Composer/Package/CompletePackageInterface.php³��táVb³��¦YK…¤������+���src/Composer/Package/Dumper/ArrayDumper.phpU ��táVbU ��PR?¤���������src/Composer/Package/Link.php��táVb�� )\.¤������+���src/Composer/Package/Loader/ArrayLoader.phpi-��táVbi-��÷YÂѤ������7���src/Composer/Package/Loader/InvalidPackageException.php„��táVb„��èMü•¤������*���src/Composer/Package/Loader/JsonLoader.php“��táVb“��褢4¤������/���src/Composer/Package/Loader/LoaderInterface.phpž��táVbž��FB¤¤������1���src/Composer/Package/Loader/RootPackageLoader.php��táVb��Äæ?¤������5���src/Composer/Package/Loader/ValidatingArrayLoader.php6N��táVb6N��“ D@¤���������src/Composer/Package/Locker.php%��táVb%��ÿp~´¤������ ���src/Composer/Package/Package.phpÉ$��táVbÉ$��tŠf¤������)���src/Composer/Package/PackageInterface.phpü ��táVbü ��jŸIT¤������)���src/Composer/Package/RootAliasPackage.phpÛ ��táVbÛ �� ÞfV¤������$���src/Composer/Package/RootPackage.php½��táVb½��¶Ò™·¤������-���src/Composer/Package/RootPackageInterface.php£��táVb£��€¢R@¤������0���src/Composer/Package/Version/StabilityFilter.php��táVb��µêrú¤������/���src/Composer/Package/Version/VersionGuesser.phpì'��táVbì'��rO.U¤������.���src/Composer/Package/Version/VersionParser.php��táVb��@kh¤������0���src/Composer/Package/Version/VersionSelector.phpÈ��táVbÈ��Íþ¶¤������ ���src/Composer/PartialComposer.php"��táVb"��Î 3«¤������&���src/Composer/Platform/HhvmDetector.php1��táVb1��ÔT1}¤������!���src/Composer/Platform/Runtime.php!��táVb!��Nô¤������!���src/Composer/Platform/Version.phpl��táVbl��1EÅÀ¤������-���src/Composer/Plugin/Capability/Capability.phpp���táVbp���š#c;¤������2���src/Composer/Plugin/Capability/CommandProvider.php°���táVb°���FüÙ¤¤���������src/Composer/Plugin/Capable.php˜���táVb˜���û°hª¤������$���src/Composer/Plugin/CommandEvent.phpQ��táVbQ��ou>r¤������$���src/Composer/Plugin/PluginEvents.php¨��táVb¨��\K“Ö¤������'���src/Composer/Plugin/PluginInterface.php´��táVb´��†ˆ%â¤������%���src/Composer/Plugin/PluginManager.phpòJ��táVbòJ��>,ݱ¤������-���src/Composer/Plugin/PostFileDownloadEvent.phpÇ��táVbÇ��f›Ìì¤������*���src/Composer/Plugin/PreCommandRunEvent.php4��táVb4��‰\}G¤������,���src/Composer/Plugin/PreFileDownloadEvent.php´��táVb´��D&%ù¤������*���src/Composer/Plugin/PrePoolCreateEvent.php¸��táVb¸��.êö‹¤������4���src/Composer/Question/StrictConfirmationQuestion.php‹��táVb‹��Õz g¤������+���src/Composer/Repository/ArrayRepository.php|��táVb|��Š9îĤ������.���src/Composer/Repository/ArtifactRepository.phpQ ��táVbQ ��íͤ������.���src/Composer/Repository/ComposerRepository.php‡���táVb‡���Á˃S¤������/���src/Composer/Repository/CompositeRepository.phpA ��táVbA ��ˆÜ�ÿ¤������;���src/Composer/Repository/ConfigurableRepositoryInterface.php¡���táVb¡���ce*2¤������0���src/Composer/Repository/FilesystemRepository.php ��táVb ��œ‡~º¤������,���src/Composer/Repository/FilterRepository.php��táVb��n:W¤������4���src/Composer/Repository/InstalledArrayRepository.phpX��táVbX��¼,[¤������9���src/Composer/Repository/InstalledFilesystemRepository.phpJ��táVbJ��'kCè¤������/���src/Composer/Repository/InstalledRepository.php”��táVb”��y4;�¤������8���src/Composer/Repository/InstalledRepositoryInterface.phpà���táVbà���¾²ÿg¤������6���src/Composer/Repository/InvalidRepositoryException.php‡���táVb‡��� W<_¤������/���src/Composer/Repository/LockArrayRepository.phpÅ���táVbÅ���8Ì«q¤������-���src/Composer/Repository/PackageRepository.php��táVb��v2¨û¤������*���src/Composer/Repository/PathRepository.phpk��táVbk��DZÎ#¤������*���src/Composer/Repository/PearRepository.php��táVb��QuÏj¤������.���src/Composer/Repository/PlatformRepository.php
  36. T��táVb
  37. T��Œf"Ф������-���src/Composer/Repository/RepositoryFactory.phpV��táVbV��@MC¤������/���src/Composer/Repository/RepositoryInterface.php©��táVb©��êý�ɤ������-���src/Composer/Repository/RepositoryManager.php» ��táVb» ��(Ïò¤¤������7���src/Composer/Repository/RepositorySecurityException.phpˆ���táVbˆ���qœ×t¤������)���src/Composer/Repository/RepositorySet.phpÕ��táVbÕ��ÕýÀÖ¤������1���src/Composer/Repository/RootPackageRepository.phpa��táVba��|‚¹¤������,���src/Composer/Repository/Vcs/FossilDriver.phpk��táVbk��~±Ì°¤������2���src/Composer/Repository/Vcs/GitBitbucketDriver.php�(��táVb�(��\Pã¤������)���src/Composer/Repository/Vcs/GitDriver.phpx��táVbx��}ž+Þ¤������,���src/Composer/Repository/Vcs/GitHubDriver.php7��táVb7��”t†-¤������,���src/Composer/Repository/Vcs/GitLabDriver.phpl1��táVbl1��81~Ô¤������(���src/Composer/Repository/Vcs/HgDriver.phpà��táVbà��+dOã¤������.���src/Composer/Repository/Vcs/PerforceDriver.php' ��táVb' ��Ë××l¤������)���src/Composer/Repository/Vcs/SvnDriver.php��táVb��”OX¤������)���src/Composer/Repository/Vcs/VcsDriver.php% ��táVb% ��þꧤ������2���src/Composer/Repository/Vcs/VcsDriverInterface.php¾��táVb¾��TT¤������)���src/Composer/Repository/VcsRepository.phpX4��táVbX4��÷œ¦¤������1���src/Composer/Repository/VersionCacheInterface.php»���táVb»���F̘m¤������3���src/Composer/Repository/WritableArrayRepository.phpö��táVbö��tÌh¤������7���src/Composer/Repository/WritableRepositoryInterface.phpw��táVbw��Õ~¼0¤���������src/Composer/Script/Event.phpù��táVbù��0¾ë¤������$���src/Composer/Script/ScriptEvents.phpI��táVbI��¤£D4¤������ ���src/Composer/SelfUpdate/Keys.phpã��táVbã��ø È…¤������$���src/Composer/SelfUpdate/Versions.phpû��táVbû��#]dw¤������ ���src/Composer/Util/AuthHelper.phpy!��táVby!��.–|—¤���������src/Composer/Util/Bitbucket.phpí��táVbí��išÑ¤������$���src/Composer/Util/ComposerMirror.php ��táVb ��¿|Eû¤������%���src/Composer/Util/ConfigValidator.php›��táVb›��å³ë¤������"���src/Composer/Util/ErrorHandler.php��táVb��á0§2¤������ ���src/Composer/Util/Filesystem.php¸=��táVb¸=��ŠtÏ…¤���������src/Composer/Util/Git.php19��táVb19��mhª©¤���������src/Composer/Util/GitHub.phpM��táVbM��*ëÁ¤���������src/Composer/Util/GitLab.phpò��táVbò��<ÄÍa¤���������src/Composer/Util/Hg.phpm��táVbm��5� ÷¤������)���src/Composer/Util/Http/CurlDownloader.php¢H��táVb¢H��µ&#¤������'���src/Composer/Util/Http/CurlResponse.phpˆ��táVbˆ��böÙ¤������&���src/Composer/Util/Http/ProxyHelper.php¼
  38. ��táVb¼
  39. ���\úc¤������'���src/Composer/Util/Http/ProxyManager.php¢
  40. ��táVb¢
  41. ��”šä������'���src/Composer/Util/Http/RequestProxy.phpi��táVbi��Ûjbí¤������#���src/Composer/Util/Http/Response.phpî��táVbî��v]k¤������$���src/Composer/Util/HttpDownloader.php&(��táVb&(��sû@¤���������src/Composer/Util/IniHelper.php���táVb���LCø¤���������src/Composer/Util/Loop.php ��táVb ��C^¶ç¤������&���src/Composer/Util/MetadataMinifier.phpC��táVbC��d ˜¤������$���src/Composer/Util/NoProxyPattern.php—��táVb—��éTH¤������!���src/Composer/Util/PackageInfo.php„��táVb„��Ïú’¤������#���src/Composer/Util/PackageSorter.phps��táVbs��*Õ4í¤���������src/Composer/Util/Perforce.php¼4��táVb¼4��·+j1¤���������src/Composer/Util/Platform.php��táVb��'Õ ¤������%���src/Composer/Util/ProcessExecutor.php{��táVb{��ÄyV ¤������&���src/Composer/Util/RemoteFilesystem.phpA��táVbA��ÍV™Ï¤���������src/Composer/Util/Silencer.php��táVb��éˆ3¤������*���src/Composer/Util/StreamContextFactory.php ��táVb ��Lš1D¤���������src/Composer/Util/Svn.php��táVb��½`7¤������ ���src/Composer/Util/SyncHelper.phpg��táVbg��=b.¤���������src/Composer/Util/Tar.php“��táVb“��¡ Ф���������src/Composer/Util/TlsHelper.phpl ��táVbl ���öc¤���������src/Composer/Util/Url.php• ��táVb• ��”fÊ/¤���������src/Composer/Util/Zip.php��táVb��ëp–¤���������src/bootstrap.php
  42. ��táVb
  43. ��ÑÄ-Ȥ������%���src/Composer/Autoload/ClassLoader.phpÄ>��táVbÄ>��Æ5Ky¤������"���src/Composer/InstalledVersions.phpœ:��táVbœ:��º¦&l¤������#���res/composer-repository-schema.jsonñ��táVbñ��|0à„¤���������res/composer-schema.json4¶��táVb4¶��¹¤cݤ���������vendor/autoload.phps��táVbs��]z´¤���������vendor/composer/ClassLoader.php\��táVb\��ÜZuœ¤������%���vendor/composer/InstalledVersions.phpk��táVbk��ü‚Ðj¤������%���vendor/composer/autoload_classmap.php(��táVb(��A«…i¤������"���vendor/composer/autoload_files.php¶��táVb¶��h³¥-¤������'���vendor/composer/autoload_namespaces.phpZ���táVbZ���ë¦á–¤������!���vendor/composer/autoload_psr4.php¿��táVb¿��qÆËû¤������!���vendor/composer/autoload_real.phpÙ��táVbÙ��RT‚8¤������#���vendor/composer/autoload_static.php|��táVb|��©Û½u¤������!���vendor/composer/ca-bundle/LICENSE��táVb��G _¤������(���vendor/composer/ca-bundle/res/cacert.pemÁ,�táVbÁ,�½_~ޤ������*���vendor/composer/ca-bundle/src/CaBundle.php•$��táVb•$��ÛnÓ¤���������vendor/composer/installed.php<��táVb<��ÍGZˆ¤������)���vendor/composer/metadata-minifier/LICENSE��táVb��½£ëǤ������:���vendor/composer/metadata-minifier/src/MetadataMinifier.phpÐ��táVbÐ��Â0&À¤���������vendor/composer/pcre/LICENSE��táVb��½£ëǤ������+���vendor/composer/pcre/src/MatchAllResult.php��táVb��8aÇ”¤������6���vendor/composer/pcre/src/MatchAllWithOffsetsResult.php&��táVb&��‹ |¤������(���vendor/composer/pcre/src/MatchResult.phpë���táVbë���…‘¤������3���vendor/composer/pcre/src/MatchWithOffsetsResult.phpø���táVbø���<»Ó¤������*���vendor/composer/pcre/src/PcreException.phpI��táVbI��Ìà
  44. 7¤������!���vendor/composer/pcre/src/Preg.phpƒ��táVbƒ��%¤������"���vendor/composer/pcre/src/Regex.phpã ��táVbã ��@�gº¤������*���vendor/composer/pcre/src/ReplaceResult.php ��táVb ��Ön0¿¤���������vendor/composer/semver/LICENSE��táVb��ÇSRm¤������)���vendor/composer/semver/src/Comparator.php��táVb��^_E“¤������/���vendor/composer/semver/src/CompilingMatcher.phpc��táVbc��„€¦¤������/���vendor/composer/semver/src/Constraint/Bound.phpw��táVbw��W4]W¤������4���vendor/composer/semver/src/Constraint/Constraint.phpø��táVbø��’‹ˆ½¤������=���vendor/composer/semver/src/Constraint/ConstraintInterface.php¡��táVb¡��Ž5´y¤������<���vendor/composer/semver/src/Constraint/MatchAllConstraint.php¯��táVb¯��²Eú¤������=���vendor/composer/semver/src/Constraint/MatchNoneConstraint.phpÉ��táVbÉ��֯خ¤������9���vendor/composer/semver/src/Constraint/MultiConstraint.phpŠ��táVbŠ��ÍÕĤ������'���vendor/composer/semver/src/Interval.phpæ��táVbæ��=[i¤������(���vendor/composer/semver/src/Intervals.php¤+��táVb¤+��@1º«¤������%���vendor/composer/semver/src/Semver.phpù��táVbù��á-i¤������,���vendor/composer/semver/src/VersionParser.phpÐ,��táVbÐ,��ŽS«r¤������%���vendor/composer/spdx-licenses/LICENSE��táVb��ÇSRm¤������6���vendor/composer/spdx-licenses/res/spdx-exceptions.json¸ ��táVb¸ ��Â4DC¤������4���vendor/composer/spdx-licenses/res/spdx-licenses.json¾��táVb¾��eÇõ̤������2���vendor/composer/spdx-licenses/src/SpdxLicenses.php{��táVb{��ž “¤������&���vendor/composer/xdebug-handler/LICENSE+��táVb+��Öã@T¤������0���vendor/composer/xdebug-handler/src/PhpConfig.php‰��táVb‰��gÔ�v¤������.���vendor/composer/xdebug-handler/src/Process.phpÖ��táVbÖ��o7¾¤������-���vendor/composer/xdebug-handler/src/Status.phpº ��táVbº ��xf17¤������4���vendor/composer/xdebug-handler/src/XdebugHandler.phpr)��táVbr)��8Õc6¤������(���vendor/justinrainbow/json-schema/LICENSE"��táVb"�� |»™¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/BaseConstraint.php¡ ��táVb¡ ��†wÌl¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/CollectionConstraint.phpƒ
  45. ��táVbƒ
  46. ��ž¸=š¤������J���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Constraint.phpÁ ��táVbÁ ��–PFF¤������S���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ConstraintInterface.php¼��táVb¼��ÿ Qœ¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/EnumConstraint.php\��táVb\��_}ý¤������G���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Factory.phpà ��táVbà ��ë’_”¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/FormatConstraint.phps��táVbs��d Þ¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/NumberConstraint.phpƒ ��táVbƒ ��e� ¨¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ObjectConstraint.php·��táVb·��%l¬ö¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/SchemaConstraint.php& ��táVb& ��78÷¬¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/StringConstraint.phpz��táVbz��ùfÅ~¤������X���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/LooseTypeCheck.phpa��táVba�� qä������Y���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/StrictTypeCheck.php—��táVb—��4~¾ ¤������\���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/TypeCheckInterface.php‰��táVb‰��“µ+j¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeConstraint.php��táVb��ª%}¤������S���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/UndefinedConstraint.php,"��táVb,"��‰-¤������F���vendor/justinrainbow/json-schema/src/JsonSchema/Entity/JsonPointer.phpè��táVbè��{N–¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ExceptionInterface.phpI���táVbI���%|°¤������V���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidArgumentException.php•���táVb•���‹àG¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidConfigException.phpl���táVbl���A!Lפ������T���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSchemaException.phpl���táVbl���è2÷þ¤������]���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSchemaMediaTypeException.phpu���táVbu���=hç¤������W���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSourceUriException.phpw���táVbw���N-ò[¤������S���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/JsonDecodingException.phpÞ��táVbÞ��\¸
  47. ¤������W���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ResourceNotFoundException.phpo���táVbo���píÛù¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/RuntimeException.php…���táVb…���%…—¤������^���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/UnresolvableJsonPointerException.php€���táVb€���u-#1¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/UriResolverException.phpj���táVbj���å>�¤������Q���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ValidationException.phpf���táVbf���¬¤„þ¤������K���vendor/justinrainbow/json-schema/src/JsonSchema/Iterator/ObjectIterator.phpþ��táVbþ��M�„õ¤������;���vendor/justinrainbow/json-schema/src/JsonSchema/Rfc3339.php ��táVb ��f4÷³¤������A���vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.php“ ��táVb“ ��&zß^¤������J���vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorageInterface.php��táVb��oŠ+}¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/AbstractRetriever.phpá���táVbá���[þA�¤������G���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/Curl.php£��táVb£��Ç’ô¦¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/FileGetContents.php ��táVb ��£Á¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/PredefinedArray.php,��táVb,��1•5þ¤������X���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/UriRetrieverInterface.php®���táVb®���ÿ‹Áå¤������C���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriResolver.php ��táVb ��æP¤������D���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriRetriever.php@��táVb@��5Î3¤������H���vendor/justinrainbow/json-schema/src/JsonSchema/UriResolverInterface.phpƒ���táVbƒ���J€¤������I���vendor/justinrainbow/json-schema/src/JsonSchema/UriRetrieverInterface.php…���táVb…���íæe¤������=���vendor/justinrainbow/json-schema/src/JsonSchema/Validator.phps��táVbs��ßÁ‘#¤���������vendor/psr/container/LICENSE{��táVb{��ÕÓ�e¤������8���vendor/psr/container/src/ContainerExceptionInterface.phpN���táVbN���üLƒ¤������/���vendor/psr/container/src/ContainerInterface.php·���táVb·���Šã¼¤������7���vendor/psr/container/src/NotFoundExceptionInterface.phpq���táVbq���Rúõ¤���������vendor/psr/log/LICENSE?��táVb?��„ù ¤������)���vendor/psr/log/Psr/Log/AbstractLogger.php;��táVb;��ñ>3[¤������3���vendor/psr/log/Psr/Log/InvalidArgumentException.php`���táVb`��� ˆX1¤������#���vendor/psr/log/Psr/Log/LogLevel.phpû���táVbû���jðñ8¤������/���vendor/psr/log/Psr/Log/LoggerAwareInterface.php|���táVb|���$£ˆ¤������+���vendor/psr/log/Psr/Log/LoggerAwareTrait.php§���táVb§���T½úB¤������*���vendor/psr/log/Psr/Log/LoggerInterface.phpÈ��táVbÈ��šx¤������&���vendor/psr/log/Psr/Log/LoggerTrait.phpk��táVbk��£}‰’¤������%���vendor/psr/log/Psr/Log/NullLogger.phpŸ���táVbŸ����Xóª¤������)���vendor/psr/log/Psr/Log/Test/DummyTest.phpp���táVbp���Τ������3���vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php ��táVb ��$/Ò¤������*���vendor/psr/log/Psr/Log/Test/TestLogger.php<��táVb<��þ(åI¤���������vendor/react/promise/LICENSEi��táVbi��3}‹¤������8���vendor/react/promise/src/CancellablePromiseInterface.php‡���táVb‡���'¥î¤������.���vendor/react/promise/src/CancellationQueue.php9��táVb9��\Úo|¤������%���vendor/react/promise/src/Deferred.phpî��táVbî��E¤)¤������6���vendor/react/promise/src/Exception/LengthException.php^���táVb^���?q¤������5���vendor/react/promise/src/ExtendedPromiseInterface.phpÀ��táVbÀ��2U·û¤������-���vendor/react/promise/src/FulfilledPromise.php•��táVb•��­2²–¤������(���vendor/react/promise/src/LazyPromise.php(��táVb(��>!‘k¤������$���vendor/react/promise/src/Promise.phpÁ��táVbÁ��
  48. ncï¤������-���vendor/react/promise/src/PromiseInterface.phpÏ���táVbÏ���AŒƒ¤������.���vendor/react/promise/src/PromisorInterface.phpa���táVba���¬É™–¤������,���vendor/react/promise/src/RejectedPromise.php¢��táVb¢��·‹R¤������8���vendor/react/promise/src/UnhandledRejectionException.phpù��táVbù��sPç¤������&���vendor/react/promise/src/functions.php9��táVb9��™ÏŸ„¤������.���vendor/react/promise/src/functions_include.php]���táVb]���QÑ<¡¤���������vendor/seld/jsonlint/LICENSE$��táVb$��4:‡~¤������@���vendor/seld/jsonlint/src/Seld/JsonLint/DuplicateKeyException.php}��táVb}��Û…Dê¤������5���vendor/seld/jsonlint/src/Seld/JsonLint/JsonParser.phpÝ4��táVbÝ4��ñ€—¾¤������0���vendor/seld/jsonlint/src/Seld/JsonLint/Lexer.php¾��táVb¾��A`¬;¤������;���vendor/seld/jsonlint/src/Seld/JsonLint/ParsingException.php(��táVb(��>Ûv}¤������4���vendor/seld/jsonlint/src/Seld/JsonLint/Undefined.php>���táVb>���ÿqŸŸ¤���������vendor/seld/phar-utils/LICENSE$��táVb$��š,M§¤������%���vendor/seld/phar-utils/src/Linter.phpi��táVbi�� �Þ¤������)���vendor/seld/phar-utils/src/Timestamps.phpÈ ��táVbÈ ��ÿ4©¤������&���vendor/symfony/console/Application.phpÍo��táVbÍo��8ؤ������.���vendor/symfony/console/Attribute/AsCommand.phpÔ��táVbÔ��½3Üþ¤������2���vendor/symfony/console/CI/GithubActionReporter.phpé��táVbé��’ 5¤������ ���vendor/symfony/console/Color.phph��táVbh��Gbç—¤������*���vendor/symfony/console/Command/Command.phpF'��táVbF'��û¹þ¤������2���vendor/symfony/console/Command/CompleteCommand.php��táVb��ÍcTߤ������8���vendor/symfony/console/Command/DumpCompletionCommand.phpŸ��táVbŸ��?¡Z7¤������.���vendor/symfony/console/Command/HelpCommand.php ��táVb ��}—¥¤������.���vendor/symfony/console/Command/LazyCommand.php˜��táVb˜��ä~¤������.���vendor/symfony/console/Command/ListCommand.php1 ��táVb1 ��$D»|¤������0���vendor/symfony/console/Command/LockableTrait.php��táVb��.ºV¤������=���vendor/symfony/console/Command/SignalableCommandInterface.phpÓ���táVbÓ���»B`¾¤������?���vendor/symfony/console/CommandLoader/CommandLoaderInterface.phpQ��táVbQ��›žH¤������?���vendor/symfony/console/CommandLoader/ContainerCommandLoader.phpU��táVbU��Ë_ü¤������=���vendor/symfony/console/CommandLoader/FactoryCommandLoader.php¯��táVb¯��d¼"z¤������5���vendor/symfony/console/Completion/CompletionInput.php��táVb��”$„k¤������;���vendor/symfony/console/Completion/CompletionSuggestions.phpÂ��táVbÂ��A¡¤������A���vendor/symfony/console/Completion/Output/BashCompletionOutput.php��táVb��ÍE¦Ú¤������F���vendor/symfony/console/Completion/Output/CompletionOutputInterface.phpF��táVbF��Ô2nM¤������0���vendor/symfony/console/Completion/Suggestion.php3��táVb3��̆ ¤������(���vendor/symfony/console/ConsoleEvents.phpÕ��táVbÕ���gw]¤������!���vendor/symfony/console/Cursor.php� ��táVb� ��Æ«§Ž¤������D���vendor/symfony/console/DependencyInjection/AddConsoleCommandPass.php*��táVb*��»¾­¤������<���vendor/symfony/console/Descriptor/ApplicationDescription.phpÊ ��táVbÊ ��ïgöª¤������0���vendor/symfony/console/Descriptor/Descriptor.php}��táVb}��±ê3^¤������9���vendor/symfony/console/Descriptor/DescriptorInterface.php÷���táVb÷���µå@à¤������4���vendor/symfony/console/Descriptor/JsonDescriptor.phpë��táVbë��1%è�¤������8���vendor/symfony/console/Descriptor/MarkdownDescriptor.phpQ��táVbQ��t ˆv¤������4���vendor/symfony/console/Descriptor/TextDescriptor.phpç"��táVbç"��ȸÌˤ������3���vendor/symfony/console/Descriptor/XmlDescriptor.php��táVb��‡¶¤������4���vendor/symfony/console/Event/ConsoleCommandEvent.phpÆ��táVbÆ�� ¼O~¤������2���vendor/symfony/console/Event/ConsoleErrorEvent.phpü��táVbü��À©–²¤������-���vendor/symfony/console/Event/ConsoleEvent.phpÆ��táVbÆ��ÅoÛÙ¤������3���vendor/symfony/console/Event/ConsoleSignalEvent.phpG��táVbG��Žû ¤������6���vendor/symfony/console/Event/ConsoleTerminateEvent.php~��táVb~��hr½Ö¤������6���vendor/symfony/console/EventListener/ErrorListener.php&��táVb&��Xö뮤������=���vendor/symfony/console/Exception/CommandNotFoundException.phpÚ��táVbÚ��ˆwêí¤������7���vendor/symfony/console/Exception/ExceptionInterface.phpy���táVby���Ù9[&¤������=���vendor/symfony/console/Exception/InvalidArgumentException.php¦���táVb¦���Ö̽Z¤������;���vendor/symfony/console/Exception/InvalidOptionException.php¦���táVb¦���Ë×H¤������3���vendor/symfony/console/Exception/LogicException.php’���táVb’���ÍO\e¤������:���vendor/symfony/console/Exception/MissingInputException.phpœ���táVbœ���æS
  49. þ¤������?���vendor/symfony/console/Exception/NamespaceNotFoundException.php‹���táVb‹���‚ón©¤������5���vendor/symfony/console/Exception/RuntimeException.php–���táVb–���Ùí,6¤������8���vendor/symfony/console/Formatter/NullOutputFormatter.php���táVb���!& u¤������=���vendor/symfony/console/Formatter/NullOutputFormatterStyle.php ��táVb ��dÿ7¤������4���vendor/symfony/console/Formatter/OutputFormatter.php���táVb���¹ØB“¤������=���vendor/symfony/console/Formatter/OutputFormatterInterface.php£��táVb£��Y §ß¤������9���vendor/symfony/console/Formatter/OutputFormatterStyle.phpH��táVbH��‘õ2b¤������B���vendor/symfony/console/Formatter/OutputFormatterStyleInterface.php���táVb���ÌZä������>���vendor/symfony/console/Formatter/OutputFormatterStyleStack.phpƒ��táVbƒ��F—x±¤������F���vendor/symfony/console/Formatter/WrappableOutputFormatterInterface.phpÖ���táVbÖ���¡Z·¤������6���vendor/symfony/console/Helper/DebugFormatterHelper.php¸��táVb¸��¤ð6 ¤������2���vendor/symfony/console/Helper/DescriptorHelper.phpÀ��táVbÀ��¦gÌ„¤������(���vendor/symfony/console/Helper/Dumper.php��táVb��þÒܽ¤������1���vendor/symfony/console/Helper/FormatterHelper.phpi��táVbi��¤¶€w¤������(���vendor/symfony/console/Helper/Helper.php9 ��táVb9 ��;Sä¤������1���vendor/symfony/console/Helper/HelperInterface.phpå���táVbå���Š ¤������+���vendor/symfony/console/Helper/HelperSet.phpG��táVbG��›ÝË�¤������2���vendor/symfony/console/Helper/InputAwareHelper.phpc��táVbc��Ìøƒ¤������/���vendor/symfony/console/Helper/ProcessHelper.phpW ��táVbW ��eÂÑ ¤������-���vendor/symfony/console/Helper/ProgressBar.phpg/��táVbg/��w1´¤������3���vendor/symfony/console/Helper/ProgressIndicator.phpÀ��táVbÀ��‘=ÞÖ¤������0���vendor/symfony/console/Helper/QuestionHelper.phpÝ-��táVbÝ-��-Ä0¤������7���vendor/symfony/console/Helper/SymfonyQuestionHelper.php ��táVb ��à�dÿ¤������'���vendor/symfony/console/Helper/Table.php~H��táVb~H��cæu¥¤������+���vendor/symfony/console/Helper/TableCell.phpA��táVbA��èÓ ¤������0���vendor/symfony/console/Helper/TableCellStyle.phpî��táVbî��Ñ�¹_¤������+���vendor/symfony/console/Helper/TableRows.php)��táVb)��WŠ3z¤������0���vendor/symfony/console/Helper/TableSeparator.phpÅ���táVbÅ���¼õËü¤������,���vendor/symfony/console/Helper/TableStyle.phpˆ��táVbˆ��¥Ö¤������*���vendor/symfony/console/Input/ArgvInput.php)��táVb)��Àd£ï¤������+���vendor/symfony/console/Input/ArrayInput.php ��táVb �� $©¤������&���vendor/symfony/console/Input/Input.php£ ��táVb£ ��ë1¤������.���vendor/symfony/console/Input/InputArgument.php!��táVb!��‚y‚¤������4���vendor/symfony/console/Input/InputAwareInterface.php˜���táVb˜���­O°¤������0���vendor/symfony/console/Input/InputDefinition.php#��táVb#�� Œ!3¤������/���vendor/symfony/console/Input/InputInterface.phpü��táVbü��G¶ô¨¤������,���vendor/symfony/console/Input/InputOption.phpç ��táVbç ��¾ùB@¤������9���vendor/symfony/console/Input/StreamableInputInterface.phpÎ���táVbÎ���ÖÕB›¤������,���vendor/symfony/console/Input/StringInput.php?��táVb?��±’ˤ���������vendor/symfony/console/LICENSE+��táVb+��‡´Ì¤������/���vendor/symfony/console/Logger/ConsoleLogger.php ��táVb ��ãÐ=ɤ������0���vendor/symfony/console/Output/BufferedOutput.phpl��táVbl��y:¸¤������/���vendor/symfony/console/Output/ConsoleOutput.php� ��táVb� ��Âܤ������8���vendor/symfony/console/Output/ConsoleOutputInterface.php��táVb��‰ê÷´¤������6���vendor/symfony/console/Output/ConsoleSectionOutput.php“ ��táVb“ ��OÖ0ɤ������,���vendor/symfony/console/Output/NullOutput.phpB��táVbB��%#RƤ������(���vendor/symfony/console/Output/Output.phpÇ ��táVbÇ �� C,°¤������1���vendor/symfony/console/Output/OutputInterface.phpí��táVbí��ð޾¤������.���vendor/symfony/console/Output/StreamOutput.php§��táVb§��1Xòƒ¤������5���vendor/symfony/console/Output/TrimmedBufferOutput.phpÚ��táVbÚ��Å±í ¤������2���vendor/symfony/console/Question/ChoiceQuestion.phpÝ
  50. ��táVbÝ
  51. �� c䦤������8���vendor/symfony/console/Question/ConfirmationQuestion.php��táVb��îyÅ„¤������,���vendor/symfony/console/Question/Question.php ��táVb ��µ�µT¤������4���vendor/symfony/console/Resources/bin/hiddeninput.exe�$��táVb�$��•�¥v¤������8���vendor/symfony/console/SignalRegistry/SignalRegistry.php ��táVb ��ëÄÅx¤������3���vendor/symfony/console/SingleCommandApplication.php5��táVb5��Â⢤������,���vendor/symfony/console/Style/OutputStyle.phpt��táVbt��O;Ƥ������/���vendor/symfony/console/Style/StyleInterface.php ��táVb ��Ý¡ˆ¤������-���vendor/symfony/console/Style/SymfonyStyle.php-'��táVb-'���½À¿¤������#���vendor/symfony/console/Terminal.phpÃ
  52. ��táVbÃ
  53. ��gÂ}ؤ������3���vendor/symfony/console/Tester/ApplicationTester.php×��táVb×��L!¤������9���vendor/symfony/console/Tester/CommandCompletionTester.phpÚ��táVbÚ��Ê›;°¤������/���vendor/symfony/console/Tester/CommandTester.phpÙ��táVbÙ��D¶¤������@���vendor/symfony/console/Tester/Constraint/CommandIsSuccessful.phpÖ��táVbÖ��ƃ‚¤������-���vendor/symfony/console/Tester/TesterTrait.php¬ ��táVb¬ ��2'L²¤������,���vendor/symfony/deprecation-contracts/LICENSE+��táVb+��7Åâ¤������1���vendor/symfony/deprecation-contracts/function.php=��táVb=��žÁ´ ¤������:���vendor/symfony/filesystem/Exception/ExceptionInterface.php|���táVb|����éD¤������=���vendor/symfony/filesystem/Exception/FileNotFoundException.phpÎ��táVbÎ��&�ò—¤������3���vendor/symfony/filesystem/Exception/IOException.php™��táVb™��¯à\Τ������<���vendor/symfony/filesystem/Exception/IOExceptionInterface.php¦���táVb¦���jÙwM¤������@���vendor/symfony/filesystem/Exception/InvalidArgumentException.php©���táVb©����!Ǥ������8���vendor/symfony/filesystem/Exception/RuntimeException.php™���táVb™���ÝUUH¤������(���vendor/symfony/filesystem/Filesystem.phpf?��táVbf?��¦œ«è¤������!���vendor/symfony/filesystem/LICENSE+��táVb+��‡´Ì¤������"���vendor/symfony/filesystem/Path.php˜'��táVb˜'��ê]^Ƥ������/���vendor/symfony/finder/Comparator/Comparator.php3��táVb3��¿Èh¤������3���vendor/symfony/finder/Comparator/DateComparator.php��táVb��Ï%úe¤������5���vendor/symfony/finder/Comparator/NumberComparator.phpz��táVbz��+¼�h¤������9���vendor/symfony/finder/Exception/AccessDeniedException.php„���táVb„���½¾sœ¤������>���vendor/symfony/finder/Exception/DirectoryNotFoundException.php‰���táVb‰���a)ÿ¤������ ���vendor/symfony/finder/Finder.phpÖ'��táVbÖ'��Ž?ä¤������#���vendor/symfony/finder/Gitignore.php³��táVb³��s 4¤���������vendor/symfony/finder/Glob.phpÇ��táVbÇ��Db‡³¤������7���vendor/symfony/finder/Iterator/CustomFilterIterator.phpc��táVbc��7ð™¤������:���vendor/symfony/finder/Iterator/DateRangeFilterIterator.php���táVb���Pšs¤������;���vendor/symfony/finder/Iterator/DepthRangeFilterIterator.php��táVb��§Ž¤������A���vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.php/��táVb/��ÙnÃ<¤������9���vendor/symfony/finder/Iterator/FileTypeFilterIterator.phpˆ��táVbˆ��^¶"û¤������<���vendor/symfony/finder/Iterator/FilecontentFilterIterator.phpW��táVbW��ÂÅÙ¤������9���vendor/symfony/finder/Iterator/FilenameFilterIterator.php”��táVb”��=™Üô¤������/���vendor/symfony/finder/Iterator/LazyIterator.phpQ��táVbQ��n]¿¼¤������=���vendor/symfony/finder/Iterator/MultiplePcreFilterIterator.php��táVb��c£TÙ¤������5���vendor/symfony/finder/Iterator/PathFilterIterator.phpò��táVbò��g"_¤������=���vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php¹ ��táVb¹ ��¨•v2¤������:���vendor/symfony/finder/Iterator/SizeRangeFilterIterator.php|��táVb|��3ÙŸ¤������3���vendor/symfony/finder/Iterator/SortableIterator.php(
  54. ��táVb(
  55. ��Ó⮤������;���vendor/symfony/finder/Iterator/VcsIgnoredFilterIterator.phpw
  56. ��táVbw
  57. ��ŵ3¤���������vendor/symfony/finder/LICENSE+��táVb+��‡´Ì¤������%���vendor/symfony/finder/SplFileInfo.php½��táVb½��y¤������'���vendor/symfony/polyfill-ctype/Ctype.php‡
  58. ��táVb‡
  59. ��~¶d¸¤������%���vendor/symfony/polyfill-ctype/LICENSE+��táVb+��…»E:¤������+���vendor/symfony/polyfill-ctype/bootstrap.php2��táVb2��Èa­8¤������-���vendor/symfony/polyfill-ctype/bootstrap80.phph��táVbh��K¿y¸¤������2���vendor/symfony/polyfill-intl-grapheme/Grapheme.phpÙ��táVbÙ��Ì»9§¤������-���vendor/symfony/polyfill-intl-grapheme/LICENSE+��táVb+��øÛ{¤������3���vendor/symfony/polyfill-intl-grapheme/bootstrap.phpÏ��táVbÏ��ý9À|¤������5���vendor/symfony/polyfill-intl-grapheme/bootstrap80.phpY ��táVbY ��¨! ¤������/���vendor/symfony/polyfill-intl-normalizer/LICENSE+��táVb+��øÛ{¤������6���vendor/symfony/polyfill-intl-normalizer/Normalizer.phpõ��táVbõ��b©"q¤������F���vendor/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php.��táVb.��Qs$—¤������R���vendor/symfony/polyfill-intl-normalizer/Resources/unidata/canonicalComposition.php‰=��táVb‰=��*ïo?¤������T���vendor/symfony/polyfill-intl-normalizer/Resources/unidata/canonicalDecomposition.phpaˆ��táVbaˆ��çR½}¤������L���vendor/symfony/polyfill-intl-normalizer/Resources/unidata/combiningClass.phpt.��táVbt.�� q�ܤ������X���vendor/symfony/polyfill-intl-normalizer/Resources/unidata/compatibilityDecomposition.php™è��táVb™è��o”e)¤������5���vendor/symfony/polyfill-intl-normalizer/bootstrap.phpë��táVbë��Pú£D¤������7���vendor/symfony/polyfill-intl-normalizer/bootstrap80.phpé��táVbé��=år´¤������(���vendor/symfony/polyfill-mbstring/LICENSE+��táVb+��øÛ{¤������-���vendor/symfony/polyfill-mbstring/Mbstring.phpvJ��táVbvJ��ÊG¤������@���vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.phpùT��táVbùT��•±+¤������F���vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.phpã��táVbã��öy_•¤������@���vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php8[��táVb8[��+RØ*¤������.���vendor/symfony/polyfill-mbstring/bootstrap.php»��táVb»��NZ^¤������0���vendor/symfony/polyfill-mbstring/bootstrap80.phpÊ ��táVbÊ ��D› פ������%���vendor/symfony/polyfill-php73/LICENSE+��táVb+��…»E:¤������'���vendor/symfony/polyfill-php73/Php73.phpn��táVbn��Cs¥l¤������?���vendor/symfony/polyfill-php73/Resources/stubs/JsonException.php[���táVb[���M²Ü¤������+���vendor/symfony/polyfill-php73/bootstrap.phpù��táVbù��AY8Ƥ������%���vendor/symfony/polyfill-php80/LICENSE&��táVb&��þz)¤������'���vendor/symfony/polyfill-php80/Php80.php¡ ��táVb¡ ��[Âk ¤������*���vendor/symfony/polyfill-php80/PhpToken.php��táVb��M£�I¤������;���vendor/symfony/polyfill-php80/Resources/stubs/Attribute.php¾��táVb¾��¿ÜФ������:���vendor/symfony/polyfill-php80/Resources/stubs/PhpToken.php…���táVb…���}ÈGG¤������<���vendor/symfony/polyfill-php80/Resources/stubs/Stringable.phpb���táVbb���ÃÑ›<¤������E���vendor/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.phpT���táVbT���ŠÓOõ¤������<���vendor/symfony/polyfill-php80/Resources/stubs/ValueError.phpK���táVbK���вì¤������+���vendor/symfony/polyfill-php80/bootstrap.phpú��táVbú��×îå¤������7���vendor/symfony/process/Exception/ExceptionInterface.phpy���táVby���qVXJ¤������=���vendor/symfony/process/Exception/InvalidArgumentException.php¨���táVb¨���ÐÀ+_¤������3���vendor/symfony/process/Exception/LogicException.php”���táVb”��� ³ãñ¤������;���vendor/symfony/process/Exception/ProcessFailedException.phpx��táVbx��¨Ìzy¤������=���vendor/symfony/process/Exception/ProcessSignaledException.php��táVb��Yשâ¤������=���vendor/symfony/process/Exception/ProcessTimedOutException.php1��táVb1��‚'Z¤������5���vendor/symfony/process/Exception/RuntimeException.php˜���táVb˜���¢Ø:¤������+���vendor/symfony/process/ExecutableFinder.php·��táVb·��T8© ¤������&���vendor/symfony/process/InputStream.php/��táVb/��¦¹e‡¤���������vendor/symfony/process/LICENSE+��táVb+��‡´Ì¤������.���vendor/symfony/process/PhpExecutableFinder.phpC��táVbC��®“P¤������%���vendor/symfony/process/PhpProcess.phpò��táVbò��’sÿ¤������.���vendor/symfony/process/Pipes/AbstractPipes.php ��táVb ��›“Ä6¤������/���vendor/symfony/process/Pipes/PipesInterface.php™��táVb™��fQÚ ¤������*���vendor/symfony/process/Pipes/UnixPipes.php€��táVb€��¾”Vv¤������-���vendor/symfony/process/Pipes/WindowsPipes.php, ��táVb, ��xQjä������"���vendor/symfony/process/Process.phpðe��táVbðe��ÂA€d¤������'���vendor/symfony/process/ProcessUtils.php��táVb��‹g>^¤������7���vendor/symfony/service-contracts/Attribute/Required.php¨���táVb¨���xj네������@���vendor/symfony/service-contracts/Attribute/SubscribedService.php
  60. ��táVb
  61. ��1I®T¤������(���vendor/symfony/service-contracts/LICENSE+��táVb+��ËÉyó¤������3���vendor/symfony/service-contracts/ResetInterface.phpy���táVby���°·jå¤������8���vendor/symfony/service-contracts/ServiceLocatorTrait.phpã ��táVbã ��"�5é¤������=���vendor/symfony/service-contracts/ServiceProviderInterface.phpÞ���táVbÞ���úRèk¤������?���vendor/symfony/service-contracts/ServiceSubscriberInterface.php³���táVb³���—öd ¤������;���vendor/symfony/service-contracts/ServiceSubscriberTrait.phpa
  62. ��táVba
  63. ��ޏ-[¤������<���vendor/symfony/service-contracts/Test/ServiceLocatorTest.php˜��táVb˜��W7|G¤������(���vendor/symfony/string/AbstractString.phpŒ3��táVbŒ3��5>‹Ž¤������/���vendor/symfony/string/AbstractUnicodeString.php§R��táVb§R��î>L¤������$���vendor/symfony/string/ByteString.php‹+��táVb‹+��Áü›¤������)���vendor/symfony/string/CodePointString.phpñ��táVbñ��Ÿ;3ˤ������6���vendor/symfony/string/Exception/ExceptionInterface.phps���táVbs���qHV‘¤������<���vendor/symfony/string/Exception/InvalidArgumentException.php¢���táVb¢���¥A¤������4���vendor/symfony/string/Exception/RuntimeException.php’���táVb’���u‘g¤������4���vendor/symfony/string/Inflector/EnglishInflector.phpù��táVbù��…3§d¤������3���vendor/symfony/string/Inflector/FrenchInflector.phpƒ
  64. ��táVbƒ
  65. ��ˆõÄw¤������6���vendor/symfony/string/Inflector/InflectorInterface.php×���táVb×���hD£¤���������vendor/symfony/string/LICENSE+��táVb+��½ý®¤������$���vendor/symfony/string/LazyString.php ��táVb ��‹ü`£¤������<���vendor/symfony/string/Resources/data/wcswidth_table_wide.php^��táVb^��%¯o)¤������<���vendor/symfony/string/Resources/data/wcswidth_table_zero.php?��táVb?��&^¿}¤������-���vendor/symfony/string/Resources/functions.php��táVb��cÚª"¤������.���vendor/symfony/string/Slugger/AsciiSlugger.phpê��táVbê��×Ú3¤������2���vendor/symfony/string/Slugger/SluggerInterface.php��táVb��÷¯Q¤������'���vendor/symfony/string/UnicodeString.phpè%��táVbè%��Ùó פ������ ���bin/composerd ��táVbd �� qÙ¤���������LICENSE.��táVb.�� Õ¤������<?php declare(strict_types=1);
  66. namespace Composer\Autoload;
  67. use Composer\Config;
  68. use Composer\EventDispatcher\EventDispatcher;
  69. use Composer\Filter\PlatformRequirementFilter\IgnoreAllPlatformRequirementFilter;
  70. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  71. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  72. use Composer\Installer\InstallationManager;
  73. use Composer\IO\IOInterface;
  74. use Composer\Package\AliasPackage;
  75. use Composer\Package\PackageInterface;
  76. use Composer\Package\RootPackageInterface;
  77. use Composer\Pcre\Preg;
  78. use Composer\Repository\InstalledRepositoryInterface;
  79. use Composer\Semver\Constraint\Bound;
  80. use Composer\Util\Filesystem;
  81. use Composer\Util\Platform;
  82. use Composer\Script\ScriptEvents;
  83. use Composer\Util\PackageSorter;
  84. use Composer\Json\JsonFile;
  85. class AutoloadGenerator
  86. {
  87. private $eventDispatcher;
  88. private $io;
  89. private $devMode = null;
  90. private $classMapAuthoritative = false;
  91. private $apcu = false;
  92. private $apcuPrefix;
  93. private $runScripts = false;
  94. private $platformRequirementFilter;
  95. public function __construct(EventDispatcher $eventDispatcher, IOInterface $io = null)
  96. {
  97. $this->eventDispatcher = $eventDispatcher;
  98. $this->io = $io;
  99. $this->platformRequirementFilter = PlatformRequirementFilterFactory::ignoreNothing();
  100. }
  101. public function setDevMode(bool $devMode = true)
  102. {
  103. $this->devMode = $devMode;
  104. }
  105. public function setClassMapAuthoritative(bool $classMapAuthoritative)
  106. {
  107. $this->classMapAuthoritative = $classMapAuthoritative;
  108. }
  109. public function setApcu(bool $apcu, ?string $apcuPrefix = null)
  110. {
  111. $this->apcu = $apcu;
  112. $this->apcuPrefix = $apcuPrefix !== null ? $apcuPrefix : $apcuPrefix;
  113. }
  114. public function setRunScripts(bool $runScripts = true)
  115. {
  116. $this->runScripts = $runScripts;
  117. }
  118. public function setIgnorePlatformRequirements($ignorePlatformReqs)
  119. {
  120. trigger_error('AutoloadGenerator::setIgnorePlatformRequirements is deprecated since Composer 2.2, use setPlatformRequirementFilter instead.', E_USER_DEPRECATED);
  121. $this->setPlatformRequirementFilter(PlatformRequirementFilterFactory::fromBoolOrList($ignorePlatformReqs));
  122. }
  123. public function setPlatformRequirementFilter(PlatformRequirementFilterInterface $platformRequirementFilter)
  124. {
  125. $this->platformRequirementFilter = $platformRequirementFilter;
  126. }
  127. public function dump(Config $config, InstalledRepositoryInterface $localRepo, RootPackageInterface $rootPackage, InstallationManager $installationManager, string $targetDir, bool $scanPsrPackages = false, ?string $suffix = null)
  128. {
  129. if ($this->classMapAuthoritative) {
  130. $scanPsrPackages = true;
  131. }
  132. if (null === $this->devMode) {
  133. $this->devMode = false;
  134. $installedJson = new JsonFile($config->get('vendor-dir').'/composer/installed.json');
  135. if ($installedJson->exists()) {
  136. $installedJson = $installedJson->read();
  137. if (isset($installedJson['dev'])) {
  138. $this->devMode = $installedJson['dev'];
  139. }
  140. }
  141. }
  142. if ($this->runScripts) {
  143. if (!isset($_SERVER['COMPOSER_DEV_MODE'])) {
  144. Platform::putEnv('COMPOSER_DEV_MODE', $this->devMode ? '1' : '0');
  145. }
  146. $this->eventDispatcher->dispatchScript(ScriptEvents::PRE_AUTOLOAD_DUMP, $this->devMode, array(), array(
  147. 'optimize' => $scanPsrPackages,
  148. ));
  149. }
  150. $filesystem = new Filesystem();
  151. $filesystem->ensureDirectoryExists($config->get('vendor-dir'));
  152. $basePath = $filesystem->normalizePath(realpath(realpath(Platform::getCwd())));
  153. $vendorPath = $filesystem->normalizePath(realpath(realpath($config->get('vendor-dir'))));
  154. $useGlobalIncludePath = (bool) $config->get('use-include-path');
  155. $prependAutoloader = $config->get('prepend-autoloader') === false ? 'false' : 'true';
  156. $targetDir = $vendorPath.'/'.$targetDir;
  157. $filesystem->ensureDirectoryExists($targetDir);
  158. $vendorPathCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true);
  159. $vendorPathToTargetDirCode = $filesystem->findShortestPathCode($vendorPath, realpath($targetDir), true);
  160. $appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, $basePath, true);
  161. $appBaseDirCode = str_replace('__DIR__', '$vendorDir', $appBaseDirCode);
  162. $namespacesFile = <<<EOF
  163. <?php
  164. // autoload_namespaces.php @generated by Composer
  165. \$vendorDir = $vendorPathCode;
  166. \$baseDir = $appBaseDirCode;
  167. return array(
  168. EOF;
  169. $psr4File = <<<EOF
  170. <?php
  171. // autoload_psr4.php @generated by Composer
  172. \$vendorDir = $vendorPathCode;
  173. \$baseDir = $appBaseDirCode;
  174. return array(
  175. EOF;
  176. $devPackageNames = $localRepo->getDevPackageNames();
  177. $packageMap = $this->buildPackageMap($installationManager, $rootPackage, $localRepo->getCanonicalPackages());
  178. if ($this->devMode) {
  179. $filteredDevPackages = false;
  180. } else {
  181. $filteredDevPackages = $devPackageNames ?: true;
  182. }
  183. $autoloads = $this->parseAutoloads($packageMap, $rootPackage, $filteredDevPackages);
  184. foreach ($autoloads['psr-0'] as $namespace => $paths) {
  185. $exportedPaths = array();
  186. foreach ($paths as $path) {
  187. $exportedPaths[] = $this->getPathCode($filesystem, $basePath, $vendorPath, $path);
  188. }
  189. $exportedPrefix = var_export($namespace, true);
  190. $namespacesFile .= " $exportedPrefix => ";
  191. $namespacesFile .= "array(".implode(', ', $exportedPaths)."),\n";
  192. }
  193. $namespacesFile .= ");\n";
  194. foreach ($autoloads['psr-4'] as $namespace => $paths) {
  195. $exportedPaths = array();
  196. foreach ($paths as $path) {
  197. $exportedPaths[] = $this->getPathCode($filesystem, $basePath, $vendorPath, $path);
  198. }
  199. $exportedPrefix = var_export($namespace, true);
  200. $psr4File .= " $exportedPrefix => ";
  201. $psr4File .= "array(".implode(', ', $exportedPaths)."),\n";
  202. }
  203. $psr4File .= ");\n";
  204. $classmapFile = <<<EOF
  205. <?php
  206. // autoload_classmap.php @generated by Composer
  207. \$vendorDir = $vendorPathCode;
  208. \$baseDir = $appBaseDirCode;
  209. return array(
  210. EOF;
  211. $targetDirLoader = null;
  212. $mainAutoload = $rootPackage->getAutoload();
  213. if ($rootPackage->getTargetDir() && !empty($mainAutoload['psr-0'])) {
  214. $levels = substr_count($filesystem->normalizePath($rootPackage->getTargetDir()), '/') + 1;
  215. $prefixes = implode(', ', array_map(function ($prefix): string {
  216. return var_export($prefix, true);
  217. }, array_keys($mainAutoload['psr-0'])));
  218. $baseDirFromTargetDirCode = $filesystem->findShortestPathCode($targetDir, $basePath, true);
  219. $targetDirLoader = <<<EOF
  220. public static function autoload(\$class)
  221. {
  222. \$dir = $baseDirFromTargetDirCode . '/';
  223. \$prefixes = array($prefixes);
  224. foreach (\$prefixes as \$prefix) {
  225. if (0 !== strpos(\$class, \$prefix)) {
  226. continue;
  227. }
  228. \$path = \$dir . implode('/', array_slice(explode('\\\\', \$class), $levels)).'.php';
  229. if (!\$path = stream_resolve_include_path(\$path)) {
  230. return false;
  231. }
  232. require \$path;
  233. return true;
  234. }
  235. }
  236. EOF;
  237. }
  238. $excluded = null;
  239. if (!empty($autoloads['exclude-from-classmap'])) {
  240. $excluded = $autoloads['exclude-from-classmap'];
  241. }
  242. $classMap = array();
  243. $ambiguousClasses = array();
  244. $scannedFiles = array();
  245. foreach ($autoloads['classmap'] as $dir) {
  246. $classMap = $this->addClassMapCode($filesystem, $basePath, $vendorPath, $dir, $excluded, null, null, $classMap, $ambiguousClasses, $scannedFiles);
  247. }
  248. if ($scanPsrPackages) {
  249. $namespacesToScan = array();
  250. foreach (array('psr-4', 'psr-0') as $psrType) {
  251. foreach ($autoloads[$psrType] as $namespace => $paths) {
  252. $namespacesToScan[$namespace][] = array('paths' => $paths, 'type' => $psrType);
  253. }
  254. }
  255. krsort($namespacesToScan);
  256. foreach ($namespacesToScan as $namespace => $groups) {
  257. foreach ($groups as $group) {
  258. foreach ($group['paths'] as $dir) {
  259. $dir = $filesystem->normalizePath($filesystem->isAbsolutePath($dir) ? $dir : $basePath.'/'.$dir);
  260. if (!is_dir($dir)) {
  261. continue;
  262. }
  263. $classMap = $this->addClassMapCode($filesystem, $basePath, $vendorPath, $dir, $excluded, $namespace, $group['type'], $classMap, $ambiguousClasses, $scannedFiles);
  264. }
  265. }
  266. }
  267. }
  268. foreach ($ambiguousClasses as $className => $ambiguousPaths) {
  269. $cleanPath = str_replace(array('$vendorDir . \'', '$baseDir . \'', "',\n"), array($vendorPath, $basePath, ''), $classMap[$className]);
  270. $this->io->writeError(
  271. '<warning>Warning: Ambiguous class resolution, "'.$className.'"'.
  272. ' was found '. (count($ambiguousPaths) + 1) .'x: in "'.$cleanPath.'" and "'. implode('", "', $ambiguousPaths) .'", the first will be used.</warning>'
  273. );
  274. }
  275. $classMap['Composer\\InstalledVersions'] = "\$vendorDir . '/composer/InstalledVersions.php',\n";
  276. ksort($classMap);
  277. foreach ($classMap as $class => $code) {
  278. $classmapFile .= ' '.var_export($class, true).' => '.$code;
  279. }
  280. $classmapFile .= ");\n";
  281. if ('' === $suffix) {
  282. $suffix = null;
  283. }
  284. if (null === $suffix) {
  285. $suffix = $config->get('autoloader-suffix');
  286. if (null === $suffix && Filesystem::isReadable($vendorPath.'/autoload.php')) {
  287. $content = file_get_contents($vendorPath.'/autoload.php');
  288. if (Preg::isMatch('{ComposerAutoloaderInit([^:\s]+)::}', $content, $match)) {
  289. $suffix = $match[1];
  290. }
  291. }
  292. if (null === $suffix) {
  293. $suffix = md5(uniqid('', true));
  294. }
  295. }
  296. $filesystem->filePutContentsIfModified($targetDir.'/autoload_namespaces.php', $namespacesFile);
  297. $filesystem->filePutContentsIfModified($targetDir.'/autoload_psr4.php', $psr4File);
  298. $filesystem->filePutContentsIfModified($targetDir.'/autoload_classmap.php', $classmapFile);
  299. $includePathFilePath = $targetDir.'/include_paths.php';
  300. if ($includePathFileContents = $this->getIncludePathsFile($packageMap, $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)) {
  301. $filesystem->filePutContentsIfModified($includePathFilePath, $includePathFileContents);
  302. } elseif (file_exists($includePathFilePath)) {
  303. unlink($includePathFilePath);
  304. }
  305. $includeFilesFilePath = $targetDir.'/autoload_files.php';
  306. if ($includeFilesFileContents = $this->getIncludeFilesFile($autoloads['files'], $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)) {
  307. $filesystem->filePutContentsIfModified($includeFilesFilePath, $includeFilesFileContents);
  308. } elseif (file_exists($includeFilesFilePath)) {
  309. unlink($includeFilesFilePath);
  310. }
  311. $filesystem->filePutContentsIfModified($targetDir.'/autoload_static.php', $this->getStaticFile($suffix, $targetDir, $vendorPath, $basePath));
  312. $checkPlatform = $config->get('platform-check') && !($this->platformRequirementFilter instanceof IgnoreAllPlatformRequirementFilter);
  313. $platformCheckContent = null;
  314. if ($checkPlatform) {
  315. $platformCheckContent = $this->getPlatformCheck($packageMap, $config->get('platform-check'), $devPackageNames);
  316. if (null === $platformCheckContent) {
  317. $checkPlatform = false;
  318. }
  319. }
  320. if ($checkPlatform) {
  321. $filesystem->filePutContentsIfModified($targetDir.'/platform_check.php', $platformCheckContent);
  322. } elseif (file_exists($targetDir.'/platform_check.php')) {
  323. unlink($targetDir.'/platform_check.php');
  324. }
  325. $filesystem->filePutContentsIfModified($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix));
  326. $filesystem->filePutContentsIfModified($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFileContents, $targetDirLoader, (bool) $includeFilesFileContents, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $checkPlatform));
  327. $filesystem->safeCopy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');
  328. $filesystem->safeCopy(__DIR__.'/../../../LICENSE', $targetDir.'/LICENSE');
  329. if ($this->runScripts) {
  330. $this->eventDispatcher->dispatchScript(ScriptEvents::POST_AUTOLOAD_DUMP, $this->devMode, array(), array(
  331. 'optimize' => (bool) $scanPsrPackages,
  332. ));
  333. }
  334. return count($classMap);
  335. }
  336. private function addClassMapCode(Filesystem $filesystem, string $basePath, string $vendorPath, string $dir, ?array $excluded, ?string $namespaceFilter, ?string $autoloadType, array $classMap, array &$ambiguousClasses, array &$scannedFiles): array
  337. {
  338. foreach ($this->generateClassMap($dir, $excluded, $namespaceFilter, $autoloadType, true, $scannedFiles) as $class => $path) {
  339. $pathCode = $this->getPathCode($filesystem, $basePath, $vendorPath, $path).",\n";
  340. if (!isset($classMap[$class])) {
  341. $classMap[$class] = $pathCode;
  342. } elseif ($this->io && $classMap[$class] !== $pathCode && !Preg::isMatch('{/(test|fixture|example|stub)s?/}i', strtr($classMap[$class].' '.$path, '\\', '/'))) {
  343. $ambiguousClasses[$class][] = $path;
  344. }
  345. }
  346. return $classMap;
  347. }
  348. private function generateClassMap(string $dir, ?array $excluded, ?string $namespaceFilter, ?string $autoloadType, bool $showAmbiguousWarning, array &$scannedFiles): array
  349. {
  350. if ($excluded) {
  351. if (file_exists($dir)) {
  352. $dirMatch = preg_quote(strtr(realpath($dir), '\\', '/'));
  353. foreach ($excluded as $index => $pattern) {
  354. $pattern = Preg::replace('{^(([^.+*?\[^\]$(){}=!<>|:\\\\#-]+|\\\\[.+*?\[^\]$(){}=!<>|:#-])*).*}', '$1', $pattern);
  355. if (0 !== strpos($pattern, $dirMatch) && 0 !== strpos($dirMatch, $pattern)) {
  356. unset($excluded[$index]);
  357. }
  358. }
  359. }
  360. $excluded = $excluded ? '{(' . implode('|', $excluded) . ')}' : null;
  361. }
  362. return ClassMapGenerator::createMap($dir, $excluded, $showAmbiguousWarning ? $this->io : null, $namespaceFilter, $autoloadType, $scannedFiles);
  363. }
  364. public function buildPackageMap(InstallationManager $installationManager, PackageInterface $rootPackage, array $packages)
  365. {
  366. $packageMap = array(array($rootPackage, ''));
  367. foreach ($packages as $package) {
  368. if ($package instanceof AliasPackage) {
  369. continue;
  370. }
  371. $this->validatePackage($package);
  372. $packageMap[] = array(
  373. $package,
  374. $installationManager->getInstallPath($package),
  375. );
  376. }
  377. return $packageMap;
  378. }
  379. protected function validatePackage(PackageInterface $package)
  380. {
  381. $autoload = $package->getAutoload();
  382. if (!empty($autoload['psr-4']) && null !== $package->getTargetDir()) {
  383. $name = $package->getName();
  384. $package->getTargetDir();
  385. throw new \InvalidArgumentException("PSR-4 autoloading is incompatible with the target-dir property, remove the target-dir in package '$name'.");
  386. }
  387. if (!empty($autoload['psr-4'])) {
  388. foreach ($autoload['psr-4'] as $namespace => $dirs) {
  389. if ($namespace !== '' && '\\' !== substr($namespace, -1)) {
  390. throw new \InvalidArgumentException("psr-4 namespaces must end with a namespace separator, '$namespace' does not, use '$namespace\\'.");
  391. }
  392. }
  393. }
  394. }
  395. public function parseAutoloads(array $packageMap, PackageInterface $rootPackage, $filteredDevPackages = false)
  396. {
  397. $rootPackageMap = array_shift($packageMap);
  398. if (is_array($filteredDevPackages)) {
  399. $packageMap = array_filter($packageMap, function ($item) use ($filteredDevPackages): bool {
  400. return !in_array($item[0]->getName(), $filteredDevPackages, true);
  401. });
  402. } elseif ($filteredDevPackages) {
  403. $packageMap = $this->filterPackageMap($packageMap, $rootPackage);
  404. }
  405. $sortedPackageMap = $this->sortPackageMap($packageMap);
  406. $sortedPackageMap[] = $rootPackageMap;
  407. array_unshift($packageMap, $rootPackageMap);
  408. $psr0 = $this->parseAutoloadsType($packageMap, 'psr-0', $rootPackage);
  409. $psr4 = $this->parseAutoloadsType($packageMap, 'psr-4', $rootPackage);
  410. $classmap = $this->parseAutoloadsType(array_reverse($sortedPackageMap), 'classmap', $rootPackage);
  411. $files = $this->parseAutoloadsType($sortedPackageMap, 'files', $rootPackage);
  412. $exclude = $this->parseAutoloadsType($sortedPackageMap, 'exclude-from-classmap', $rootPackage);
  413. krsort($psr0);
  414. krsort($psr4);
  415. return array(
  416. 'psr-0' => $psr0,
  417. 'psr-4' => $psr4,
  418. 'classmap' => $classmap,
  419. 'files' => $files,
  420. 'exclude-from-classmap' => $exclude,
  421. );
  422. }
  423. public function createLoader(array $autoloads, ?string $vendorDir = null)
  424. {
  425. $loader = new ClassLoader($vendorDir);
  426. if (isset($autoloads['psr-0'])) {
  427. foreach ($autoloads['psr-0'] as $namespace => $path) {
  428. $loader->add($namespace, $path);
  429. }
  430. }
  431. if (isset($autoloads['psr-4'])) {
  432. foreach ($autoloads['psr-4'] as $namespace => $path) {
  433. $loader->addPsr4($namespace, $path);
  434. }
  435. }
  436. if (isset($autoloads['classmap'])) {
  437. $excluded = null;
  438. if (!empty($autoloads['exclude-from-classmap'])) {
  439. $excluded = $autoloads['exclude-from-classmap'];
  440. }
  441. $scannedFiles = array();
  442. foreach ($autoloads['classmap'] as $dir) {
  443. try {
  444. $loader->addClassMap($this->generateClassMap($dir, $excluded, null, null, false, $scannedFiles));
  445. } catch (\RuntimeException $e) {
  446. $this->io->writeError('<warning>'.$e->getMessage().'</warning>');
  447. }
  448. }
  449. }
  450. return $loader;
  451. }
  452. protected function getIncludePathsFile(array $packageMap, Filesystem $filesystem, string $basePath, string $vendorPath, string $vendorPathCode, string $appBaseDirCode)
  453. {
  454. $includePaths = array();
  455. foreach ($packageMap as $item) {
  456. list($package, $installPath) = $item;
  457. if (null !== $package->getTargetDir() && strlen($package->getTargetDir()) > 0) {
  458. $installPath = substr($installPath, 0, -strlen('/'.$package->getTargetDir()));
  459. }
  460. foreach ($package->getIncludePaths() as $includePath) {
  461. $includePath = trim($includePath, '/');
  462. $includePaths[] = empty($installPath) ? $includePath : $installPath.'/'.$includePath;
  463. }
  464. }
  465. if (!$includePaths) {
  466. return null;
  467. }
  468. $includePathsCode = '';
  469. foreach ($includePaths as $path) {
  470. $includePathsCode .= " " . $this->getPathCode($filesystem, $basePath, $vendorPath, $path) . ",\n";
  471. }
  472. return <<<EOF
  473. <?php
  474. // include_paths.php @generated by Composer
  475. \$vendorDir = $vendorPathCode;
  476. \$baseDir = $appBaseDirCode;
  477. return array(
  478. $includePathsCode);
  479. EOF;
  480. }
  481. protected function getIncludeFilesFile(array $files, Filesystem $filesystem, string $basePath, string $vendorPath, string $vendorPathCode, string $appBaseDirCode)
  482. {
  483. $filesCode = '';
  484. foreach ($files as $fileIdentifier => $functionFile) {
  485. $filesCode .= ' ' . var_export($fileIdentifier, true) . ' => '
  486. . $this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile) . ",\n";
  487. }
  488. if (!$filesCode) {
  489. return null;
  490. }
  491. return <<<EOF
  492. <?php
  493. // autoload_files.php @generated by Composer
  494. \$vendorDir = $vendorPathCode;
  495. \$baseDir = $appBaseDirCode;
  496. return array(
  497. $filesCode);
  498. EOF;
  499. }
  500. protected function getPathCode(Filesystem $filesystem, string $basePath, string $vendorPath, string $path)
  501. {
  502. if (!$filesystem->isAbsolutePath($path)) {
  503. $path = $basePath . '/' . $path;
  504. }
  505. $path = $filesystem->normalizePath($path);
  506. $baseDir = '';
  507. if (strpos($path.'/', $vendorPath.'/') === 0) {
  508. $path = (string) substr($path, strlen($vendorPath));
  509. $baseDir = '$vendorDir . ';
  510. } else {
  511. $path = $filesystem->normalizePath($filesystem->findShortestPath($basePath, $path, true));
  512. if (!$filesystem->isAbsolutePath($path)) {
  513. $baseDir = '$baseDir . ';
  514. $path = '/' . $path;
  515. }
  516. }
  517. if (strpos($path, '.phar') !== false) {
  518. $baseDir = "'phar://' . " . $baseDir;
  519. }
  520. return $baseDir . var_export($path, true);
  521. }
  522. protected function getPlatformCheck(array $packageMap, $checkPlatform, array $devPackageNames)
  523. {
  524. $lowestPhpVersion = Bound::zero();
  525. $requiredExtensions = array();
  526. $extensionProviders = array();
  527. foreach ($packageMap as $item) {
  528. $package = $item[0];
  529. foreach (array_merge($package->getReplaces(), $package->getProvides()) as $link) {
  530. if (Preg::isMatch('{^ext-(.+)$}iD', $link->getTarget(), $match)) {
  531. $extensionProviders[$match[1]][] = $link->getConstraint();
  532. }
  533. }
  534. }
  535. foreach ($packageMap as $item) {
  536. $package = $item[0];
  537. if (in_array($package->getName(), $devPackageNames, true)) {
  538. continue;
  539. }
  540. foreach ($package->getRequires() as $link) {
  541. if ($this->platformRequirementFilter->isIgnored($link->getTarget())) {
  542. continue;
  543. }
  544. if ('php' === $link->getTarget()) {
  545. $constraint = $link->getConstraint();
  546. if ($constraint->getLowerBound()->compareTo($lowestPhpVersion, '>')) {
  547. $lowestPhpVersion = $constraint->getLowerBound();
  548. }
  549. }
  550. if ($checkPlatform === true && Preg::isMatch('{^ext-(.+)$}iD', $link->getTarget(), $match)) {
  551. if (isset($extensionProviders[$match[1]])) {
  552. foreach ($extensionProviders[$match[1]] as $provided) {
  553. if ($provided->matches($link->getConstraint())) {
  554. continue 2;
  555. }
  556. }
  557. }
  558. if ($match[1] === 'zend-opcache') {
  559. $match[1] = 'zend opcache';
  560. }
  561. $extension = var_export($match[1], true);
  562. if ($match[1] === 'pcntl' || $match[1] === 'readline') {
  563. $requiredExtensions[$extension] = "PHP_SAPI !== 'cli' || extension_loaded($extension) || \$missingExtensions[] = $extension;\n";
  564. } else {
  565. $requiredExtensions[$extension] = "extension_loaded($extension) || \$missingExtensions[] = $extension;\n";
  566. }
  567. }
  568. }
  569. }
  570. ksort($requiredExtensions);
  571. $formatToPhpVersionId = function (Bound $bound): int {
  572. if ($bound->isZero()) {
  573. return 0;
  574. }
  575. if ($bound->isPositiveInfinity()) {
  576. return 99999;
  577. }
  578. $version = str_replace('-', '.', $bound->getVersion());
  579. $chunks = array_map('intval', explode('.', $version));
  580. return $chunks[0] * 10000 + $chunks[1] * 100 + $chunks[2];
  581. };
  582. $formatToHumanReadable = function (Bound $bound) {
  583. if ($bound->isZero()) {
  584. return 0;
  585. }
  586. if ($bound->isPositiveInfinity()) {
  587. return 99999;
  588. }
  589. $version = str_replace('-', '.', $bound->getVersion());
  590. $chunks = explode('.', $version);
  591. $chunks = array_slice($chunks, 0, 3);
  592. return implode('.', $chunks);
  593. };
  594. $requiredPhp = '';
  595. $requiredPhpError = '';
  596. if (!$lowestPhpVersion->isZero()) {
  597. $operator = $lowestPhpVersion->isInclusive() ? '>=' : '>';
  598. $requiredPhp = 'PHP_VERSION_ID '.$operator.' '.$formatToPhpVersionId($lowestPhpVersion);
  599. $requiredPhpError = '"'.$operator.' '.$formatToHumanReadable($lowestPhpVersion).'"';
  600. }
  601. if ($requiredPhp) {
  602. $requiredPhp = <<<PHP_CHECK
  603. if (!($requiredPhp)) {
  604. \$issues[] = 'Your Composer dependencies require a PHP version $requiredPhpError. You are running ' . PHP_VERSION . '.';
  605. }
  606. PHP_CHECK;
  607. }
  608. $requiredExtensions = implode('', $requiredExtensions);
  609. if ('' !== $requiredExtensions) {
  610. $requiredExtensions = <<<EXT_CHECKS
  611. \$missingExtensions = array();
  612. $requiredExtensions
  613. if (\$missingExtensions) {
  614. \$issues[] = 'Your Composer dependencies require the following PHP extensions to be installed: ' . implode(', ', \$missingExtensions) . '.';
  615. }
  616. EXT_CHECKS;
  617. }
  618. if (!$requiredPhp && !$requiredExtensions) {
  619. return null;
  620. }
  621. return <<<PLATFORM_CHECK
  622. <?php
  623. // platform_check.php @generated by Composer
  624. \$issues = array();
  625. ${requiredPhp}${requiredExtensions}
  626. if (\$issues) {
  627. if (!headers_sent()) {
  628. header('HTTP/1.1 500 Internal Server Error');
  629. }
  630. if (!ini_get('display_errors')) {
  631. if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
  632. fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, \$issues) . PHP_EOL.PHP_EOL);
  633. } elseif (!headers_sent()) {
  634. echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, \$issues)) . PHP_EOL.PHP_EOL;
  635. }
  636. }
  637. trigger_error(
  638. 'Composer detected issues in your platform: ' . implode(' ', \$issues),
  639. E_USER_ERROR
  640. );
  641. }
  642. PLATFORM_CHECK;
  643. }
  644. protected function getAutoloadFile(string $vendorPathToTargetDirCode, string $suffix)
  645. {
  646. $lastChar = $vendorPathToTargetDirCode[strlen($vendorPathToTargetDirCode) - 1];
  647. if ("'" === $lastChar || '"' === $lastChar) {
  648. $vendorPathToTargetDirCode = substr($vendorPathToTargetDirCode, 0, -1).'/autoload_real.php'.$lastChar;
  649. } else {
  650. $vendorPathToTargetDirCode .= " . '/autoload_real.php'";
  651. }
  652. return <<<AUTOLOAD
  653. <?php
  654. // autoload.php @generated by Composer
  655. if (PHP_VERSION_ID < 50600) {
  656. echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
  657. exit(1);
  658. }
  659. require_once $vendorPathToTargetDirCode;
  660. return ComposerAutoloaderInit$suffix::getLoader();
  661. AUTOLOAD;
  662. }
  663. protected function getAutoloadRealFile(bool $useClassMap, bool $useIncludePath, ?string $targetDirLoader, bool $useIncludeFiles, string $vendorPathCode, string $appBaseDirCode, string $suffix, bool $useGlobalIncludePath, string $prependAutoloader, bool $checkPlatform)
  664. {
  665. $file = <<<HEADER
  666. <?php
  667. // autoload_real.php @generated by Composer
  668. class ComposerAutoloaderInit$suffix
  669. {
  670. private static \$loader;
  671. public static function loadClassLoader(\$class)
  672. {
  673. if ('Composer\\Autoload\\ClassLoader' === \$class) {
  674. require __DIR__ . '/ClassLoader.php';
  675. }
  676. }
  677. /**
  678. * @return \Composer\Autoload\ClassLoader
  679. */
  680. public static function getLoader()
  681. {
  682. if (null !== self::\$loader) {
  683. return self::\$loader;
  684. }
  685. HEADER;
  686. if ($checkPlatform) {
  687. $file .= <<<'PLATFORM_CHECK'
  688. require __DIR__ . '/platform_check.php';
  689. PLATFORM_CHECK;
  690. }
  691. $file .= <<<CLASSLOADER_INIT
  692. spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'), true, $prependAutoloader);
  693. self::\$loader = \$loader = new \\Composer\\Autoload\\ClassLoader(\\dirname(__DIR__));
  694. spl_autoload_unregister(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'));
  695. CLASSLOADER_INIT;
  696. if ($useIncludePath) {
  697. $file .= <<<'INCLUDE_PATH'
  698. $includePaths = require __DIR__ . '/include_paths.php';
  699. $includePaths[] = get_include_path();
  700. set_include_path(implode(PATH_SEPARATOR, $includePaths));
  701. INCLUDE_PATH;
  702. }
  703. $file .= <<<STATIC_INIT
  704. require __DIR__ . '/autoload_static.php';
  705. call_user_func(\Composer\Autoload\ComposerStaticInit$suffix::getInitializer(\$loader));
  706. STATIC_INIT;
  707. if ($this->classMapAuthoritative) {
  708. $file .= <<<'CLASSMAPAUTHORITATIVE'
  709. $loader->setClassMapAuthoritative(true);
  710. CLASSMAPAUTHORITATIVE;
  711. }
  712. if ($this->apcu) {
  713. $apcuPrefix = var_export(($this->apcuPrefix !== null ? $this->apcuPrefix : substr(base64_encode(md5(uniqid('', true), true)), 0, -3)), true);
  714. $file .= <<<APCU
  715. \$loader->setApcuPrefix($apcuPrefix);
  716. APCU;
  717. }
  718. if ($useGlobalIncludePath) {
  719. $file .= <<<'INCLUDEPATH'
  720. $loader->setUseIncludePath(true);
  721. INCLUDEPATH;
  722. }
  723. if ($targetDirLoader) {
  724. $file .= <<<REGISTER_TARGET_DIR_AUTOLOAD
  725. spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'autoload'), true, true);
  726. REGISTER_TARGET_DIR_AUTOLOAD;
  727. }
  728. $file .= <<<REGISTER_LOADER
  729. \$loader->register($prependAutoloader);
  730. REGISTER_LOADER;
  731. if ($useIncludeFiles) {
  732. $file .= <<<INCLUDE_FILES
  733. \$includeFiles = \Composer\Autoload\ComposerStaticInit$suffix::\$files;
  734. foreach (\$includeFiles as \$fileIdentifier => \$file) {
  735. composerRequire$suffix(\$fileIdentifier, \$file);
  736. }
  737. INCLUDE_FILES;
  738. }
  739. $file .= <<<METHOD_FOOTER
  740. return \$loader;
  741. }
  742. METHOD_FOOTER;
  743. $file .= $targetDirLoader;
  744. if ($useIncludeFiles) {
  745. return $file . <<<FOOTER
  746. }
  747. /**
  748. * @param string \$fileIdentifier
  749. * @param string \$file
  750. * @return void
  751. */
  752. function composerRequire$suffix(\$fileIdentifier, \$file)
  753. {
  754. if (empty(\$GLOBALS['__composer_autoload_files'][\$fileIdentifier])) {
  755. \$GLOBALS['__composer_autoload_files'][\$fileIdentifier] = true;
  756. require \$file;
  757. }
  758. }
  759. FOOTER;
  760. }
  761. return $file . <<<FOOTER
  762. }
  763. FOOTER;
  764. }
  765. protected function getStaticFile(string $suffix, string $targetDir, string $vendorPath, string $basePath)
  766. {
  767. $file = <<<HEADER
  768. <?php
  769. // autoload_static.php @generated by Composer
  770. namespace Composer\Autoload;
  771. class ComposerStaticInit$suffix
  772. {
  773. HEADER;
  774. $loader = new ClassLoader();
  775. $map = require $targetDir . '/autoload_namespaces.php';
  776. foreach ($map as $namespace => $path) {
  777. $loader->set($namespace, $path);
  778. }
  779. $map = require $targetDir . '/autoload_psr4.php';
  780. foreach ($map as $namespace => $path) {
  781. $loader->setPsr4($namespace, $path);
  782. }
  783. $classMap = require $targetDir . '/autoload_classmap.php';
  784. if ($classMap) {
  785. $loader->addClassMap($classMap);
  786. }
  787. $filesystem = new Filesystem();
  788. $vendorPathCode = ' => ' . $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true, true) . " . '/";
  789. $vendorPharPathCode = ' => \'phar://\' . ' . $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true, true) . " . '/";
  790. $appBaseDirCode = ' => ' . $filesystem->findShortestPathCode(realpath($targetDir), $basePath, true, true) . " . '/";
  791. $appBaseDirPharCode = ' => \'phar://\' . ' . $filesystem->findShortestPathCode(realpath($targetDir), $basePath, true, true) . " . '/";
  792. $absoluteVendorPathCode = ' => ' . substr(var_export(rtrim($vendorDir, '\\/') . '/', true), 0, -1);
  793. $absoluteVendorPharPathCode = ' => ' . substr(var_export(rtrim('phar://' . $vendorDir, '\\/') . '/', true), 0, -1);
  794. $absoluteAppBaseDirCode = ' => ' . substr(var_export(rtrim($baseDir, '\\/') . '/', true), 0, -1);
  795. $absoluteAppBaseDirPharCode = ' => ' . substr(var_export(rtrim('phar://' . $baseDir, '\\/') . '/', true), 0, -1);
  796. $initializer = '';
  797. $prefix = "\0Composer\Autoload\ClassLoader\0";
  798. $prefixLen = strlen($prefix);
  799. if (file_exists($targetDir . '/autoload_files.php')) {
  800. $maps = array('files' => require $targetDir . '/autoload_files.php');
  801. } else {
  802. $maps = array();
  803. }
  804. foreach ((array) $loader as $prop => $value) {
  805. if ($value && 0 === strpos($prop, $prefix)) {
  806. $maps[substr($prop, $prefixLen)] = $value;
  807. }
  808. }
  809. foreach ($maps as $prop => $value) {
  810. $value = strtr(
  811. var_export($value, true),
  812. array(
  813. $absoluteVendorPathCode => $vendorPathCode,
  814. $absoluteVendorPharPathCode => $vendorPharPathCode,
  815. $absoluteAppBaseDirCode => $appBaseDirCode,
  816. $absoluteAppBaseDirPharCode => $appBaseDirPharCode,
  817. )
  818. );
  819. $value = ltrim(Preg::replace('/^ */m', ' $0$0', $value));
  820. $file .= sprintf(" public static $%s = %s;\n\n", $prop, $value);
  821. if ('files' !== $prop) {
  822. $initializer .= " \$loader->$prop = ComposerStaticInit$suffix::\$$prop;\n";
  823. }
  824. }
  825. return $file . <<<INITIALIZER
  826. public static function getInitializer(ClassLoader \$loader)
  827. {
  828. return \Closure::bind(function () use (\$loader) {
  829. $initializer
  830. }, null, ClassLoader::class);
  831. }
  832. }
  833. INITIALIZER;
  834. }
  835. protected function parseAutoloadsType(array $packageMap, string $type, RootPackageInterface $rootPackage)
  836. {
  837. $autoloads = array();
  838. foreach ($packageMap as $item) {
  839. list($package, $installPath) = $item;
  840. $autoload = $package->getAutoload();
  841. if ($this->devMode && $package === $rootPackage) {
  842. $autoload = array_merge_recursive($autoload, $package->getDevAutoload());
  843. }
  844. if (!isset($autoload[$type]) || !is_array($autoload[$type])) {
  845. continue;
  846. }
  847. if (null !== $package->getTargetDir() && $package !== $rootPackage) {
  848. $installPath = substr($installPath, 0, -strlen('/'.$package->getTargetDir()));
  849. }
  850. foreach ($autoload[$type] as $namespace => $paths) {
  851. foreach ((array) $paths as $path) {
  852. if (($type === 'files' || $type === 'classmap' || $type === 'exclude-from-classmap') && $package->getTargetDir() && !Filesystem::isReadable($installPath.'/'.$path)) {
  853. if ($package === $rootPackage) {
  854. $targetDir = str_replace('\\<dirsep\\>', '[\\\\/]', preg_quote(str_replace(array('/', '\\'), '<dirsep>', $package->getTargetDir())));
  855. $path = ltrim(Preg::replace('{^'.$targetDir.'}', '', ltrim($path, '\\/')), '\\/');
  856. } else {
  857. $path = $package->getTargetDir() . '/' . $path;
  858. }
  859. }
  860. if ($type === 'exclude-from-classmap') {
  861. $path = Preg::replace('{/+}', '/', preg_quote(trim(strtr($path, '\\', '/'), '/')));
  862. $path = strtr($path, array('\\*\\*' => '.+?', '\\*' => '[^/]+?'));
  863. $updir = null;
  864. $path = Preg::replaceCallback(
  865. '{^((?:(?:\\\\\\.){1,2}+/)+)}',
  866. function ($matches) use (&$updir): string {
  867. if (isset($matches[1])) {
  868. $updir = str_replace('\\.', '.', $matches[1]);
  869. }
  870. return '';
  871. },
  872. $path
  873. );
  874. if (empty($installPath)) {
  875. $installPath = strtr(Platform::getCwd(), '\\', '/');
  876. }
  877. $resolvedPath = realpath($installPath . '/' . $updir);
  878. if (false === $resolvedPath) {
  879. continue;
  880. }
  881. $autoloads[] = preg_quote(strtr($resolvedPath, '\\', '/')) . '/' . $path . '($|/)';
  882. continue;
  883. }
  884. $relativePath = empty($installPath) ? (empty($path) ? '.' : $path) : $installPath.'/'.$path;
  885. if ($type === 'files') {
  886. $autoloads[$this->getFileIdentifier($package, $path)] = $relativePath;
  887. continue;
  888. }
  889. if ($type === 'classmap') {
  890. $autoloads[] = $relativePath;
  891. continue;
  892. }
  893. $autoloads[$namespace][] = $relativePath;
  894. }
  895. }
  896. }
  897. return $autoloads;
  898. }
  899. protected function getFileIdentifier(PackageInterface $package, string $path)
  900. {
  901. return md5($package->getName() . ':' . $path);
  902. }
  903. protected function filterPackageMap(array $packageMap, RootPackageInterface $rootPackage)
  904. {
  905. $packages = array();
  906. $include = array();
  907. $replacedBy = array();
  908. foreach ($packageMap as $item) {
  909. $package = $item[0];
  910. $name = $package->getName();
  911. $packages[$name] = $package;
  912. foreach ($package->getReplaces() as $replace) {
  913. $replacedBy[$replace->getTarget()] = $name;
  914. }
  915. }
  916. $add = function (PackageInterface $package) use (&$add, $packages, &$include, $replacedBy): void {
  917. foreach ($package->getRequires() as $link) {
  918. $target = $link->getTarget();
  919. if (isset($replacedBy[$target])) {
  920. $target = $replacedBy[$target];
  921. }
  922. if (!isset($include[$target])) {
  923. $include[$target] = true;
  924. if (isset($packages[$target])) {
  925. $add($packages[$target]);
  926. }
  927. }
  928. }
  929. };
  930. $add($rootPackage);
  931. return array_filter(
  932. $packageMap,
  933. function ($item) use ($include): bool {
  934. $package = $item[0];
  935. foreach ($package->getNames() as $name) {
  936. if (isset($include[$name])) {
  937. return true;
  938. }
  939. }
  940. return false;
  941. }
  942. );
  943. }
  944. protected function sortPackageMap(array $packageMap)
  945. {
  946. $packages = array();
  947. $paths = array();
  948. foreach ($packageMap as $item) {
  949. list($package, $path) = $item;
  950. $name = $package->getName();
  951. $packages[$name] = $package;
  952. $paths[$name] = $path;
  953. }
  954. $sortedPackages = PackageSorter::sortPackages($packages);
  955. $sortedPackageMap = array();
  956. foreach ($sortedPackages as $package) {
  957. $name = $package->getName();
  958. $sortedPackageMap[] = array($packages[$name], $paths[$name]);
  959. }
  960. return $sortedPackageMap;
  961. }
  962. }
  963. function composerRequire(string $fileIdentifier, string $file): void
  964. {
  965. if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  966. $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
  967. require $file;
  968. }
  969. }
  970. <?php declare(strict_types=1);
  971. namespace Composer\Autoload;
  972. use Composer\Pcre\Preg;
  973. use Composer\Util\Platform;
  974. use Symfony\Component\Finder\Finder;
  975. use Composer\IO\IOInterface;
  976. use Composer\Util\Filesystem;
  977. class ClassMapGenerator
  978. {
  979. public static function dump(iterable $dirs, string $file): void
  980. {
  981. $maps = array();
  982. foreach ($dirs as $dir) {
  983. $maps = array_merge($maps, static::createMap($dir));
  984. }
  985. file_put_contents($file, sprintf('<?php return %s;', var_export($maps, true)));
  986. }
  987. public static function createMap($path, string $excluded = null, IOInterface $io = null, ?string $namespace = null, ?string $autoloadType = null, array &$scannedFiles = array()): array
  988. {
  989. $basePath = $path;
  990. if (is_string($path)) {
  991. if (is_file($path)) {
  992. $path = array(new \SplFileInfo($path));
  993. } elseif (is_dir($path) || strpos($path, '*') !== false) {
  994. $path = Finder::create()->files()->followLinks()->name('/\.(php|inc|hh)$/')->in($path);
  995. } else {
  996. throw new \RuntimeException(
  997. 'Could not scan for classes inside "'.$path.
  998. '" which does not appear to be a file nor a folder'
  999. );
  1000. }
  1001. } elseif (null !== $autoloadType) {
  1002. throw new \RuntimeException('Path must be a string when specifying an autoload type');
  1003. }
  1004. $map = array();
  1005. $filesystem = new Filesystem();
  1006. $cwd = realpath(Platform::getCwd());
  1007. foreach ($path as $file) {
  1008. $filePath = $file->getPathname();
  1009. if (!in_array(pathinfo($filePath, PATHINFO_EXTENSION), array('php', 'inc', 'hh'))) {
  1010. continue;
  1011. }
  1012. if (!$filesystem->isAbsolutePath($filePath)) {
  1013. $filePath = $cwd . '/' . $filePath;
  1014. $filePath = $filesystem->normalizePath($filePath);
  1015. } else {
  1016. $filePath = Preg::replace('{[\\\\/]{2,}}', '/', $filePath);
  1017. }
  1018. $realPath = realpath($filePath);
  1019. if (isset($scannedFiles[$realPath])) {
  1020. continue;
  1021. }
  1022. if ($excluded && Preg::isMatch($excluded, strtr($realPath, '\\', '/'))) {
  1023. continue;
  1024. }
  1025. if ($excluded && Preg::isMatch($excluded, strtr($filePath, '\\', '/'))) {
  1026. continue;
  1027. }
  1028. $classes = self::findClasses($filePath);
  1029. if (null !== $autoloadType) {
  1030. $classes = self::filterByNamespace($classes, $filePath, $namespace, $autoloadType, $basePath, $io);
  1031. if ($classes) {
  1032. $scannedFiles[$realPath] = true;
  1033. }
  1034. } else {
  1035. $scannedFiles[$realPath] = true;
  1036. }
  1037. foreach ($classes as $class) {
  1038. if (null === $autoloadType && null !== $namespace && '' !== $namespace && 0 !== strpos($class, $namespace)) {
  1039. continue;
  1040. }
  1041. if (!isset($map[$class])) {
  1042. $map[$class] = $filePath;
  1043. } elseif ($io && $map[$class] !== $filePath && !Preg::isMatch('{/(test|fixture|example|stub)s?/}i', strtr($map[$class].' '.$filePath, '\\', '/'))) {
  1044. $io->writeError(
  1045. '<warning>Warning: Ambiguous class resolution, "'.$class.'"'.
  1046. ' was found in both "'.$map[$class].'" and "'.$filePath.'", the first will be used.</warning>'
  1047. );
  1048. }
  1049. }
  1050. }
  1051. return $map;
  1052. }
  1053. private static function filterByNamespace(array $classes, string $filePath, string $baseNamespace, string $namespaceType, string $basePath, ?IOInterface $io): array
  1054. {
  1055. $validClasses = array();
  1056. $rejectedClasses = array();
  1057. $realSubPath = substr($filePath, strlen($basePath) + 1);
  1058. $dotPosition = strrpos($realSubPath, '.');
  1059. $realSubPath = substr($realSubPath, 0, $dotPosition === false ? PHP_INT_MAX : $dotPosition);
  1060. foreach ($classes as $class) {
  1061. if ('' !== $baseNamespace && 0 !== strpos($class, $baseNamespace)) {
  1062. continue;
  1063. }
  1064. if ('psr-0' === $namespaceType) {
  1065. $namespaceLength = strrpos($class, '\\');
  1066. if (false !== $namespaceLength) {
  1067. $namespace = substr($class, 0, $namespaceLength + 1);
  1068. $className = substr($class, $namespaceLength + 1);
  1069. $subPath = str_replace('\\', DIRECTORY_SEPARATOR, $namespace)
  1070. . str_replace('_', DIRECTORY_SEPARATOR, $className);
  1071. } else {
  1072. $subPath = str_replace('_', DIRECTORY_SEPARATOR, $class);
  1073. }
  1074. } elseif ('psr-4' === $namespaceType) {
  1075. $subNamespace = ('' !== $baseNamespace) ? substr($class, strlen($baseNamespace)) : $class;
  1076. $subPath = str_replace('\\', DIRECTORY_SEPARATOR, $subNamespace);
  1077. } else {
  1078. throw new \RuntimeException("namespaceType must be psr-0 or psr-4, $namespaceType given");
  1079. }
  1080. if ($subPath === $realSubPath) {
  1081. $validClasses[] = $class;
  1082. } else {
  1083. $rejectedClasses[] = $class;
  1084. }
  1085. }
  1086. if (empty($validClasses)) {
  1087. foreach ($rejectedClasses as $class) {
  1088. if ($io) {
  1089. $io->writeError("<warning>Class $class located in ".Preg::replace('{^'.preg_quote(Platform::getCwd()).'}', '.', $filePath, 1)." does not comply with $namespaceType autoloading standard. Skipping.</warning>");
  1090. }
  1091. }
  1092. return array();
  1093. }
  1094. return $validClasses;
  1095. }
  1096. private static function findClasses(string $path): array
  1097. {
  1098. $extraTypes = self::getExtraTypes();
  1099. $contents = @php_strip_whitespace($path);
  1100. if (!$contents) {
  1101. if (!file_exists($path)) {
  1102. $message = 'File at "%s" does not exist, check your classmap definitions';
  1103. } elseif (!Filesystem::isReadable($path)) {
  1104. $message = 'File at "%s" is not readable, check its permissions';
  1105. } elseif ('' === trim((string) file_get_contents($path))) {
  1106. return array();
  1107. } else {
  1108. $message = 'File at "%s" could not be parsed as PHP, it may be binary or corrupted';
  1109. }
  1110. $error = error_get_last();
  1111. if (isset($error['message'])) {
  1112. $message .= PHP_EOL . 'The following message may be helpful:' . PHP_EOL . $error['message'];
  1113. }
  1114. throw new \RuntimeException(sprintf($message, $path));
  1115. }
  1116. Preg::matchAll('{\b(?:class|interface|trait'.$extraTypes.')\s}i', $contents, $matches);
  1117. if (!$matches) {
  1118. return array();
  1119. }
  1120. $p = new PhpFileCleaner($contents, count($matches[0]));
  1121. $contents = $p->clean();
  1122. unset($p);
  1123. Preg::matchAll('{
  1124. (?:
  1125. \b(?<![\$:>])(?P<type>class|interface|trait'.$extraTypes.') \s++ (?P<name>[a-zA-Z_\x7f-\xff:][a-zA-Z0-9_\x7f-\xff:\-]*+)
  1126. | \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*+ [\{;]
  1127. )
  1128. }ix', $contents, $matches);
  1129. $classes = array();
  1130. $namespace = '';
  1131. for ($i = 0, $len = count($matches['type']); $i < $len; $i++) {
  1132. if (!empty($matches['ns'][$i])) {
  1133. $namespace = str_replace(array(' ', "\t", "\r", "\n"), '', (string) $matches['nsname'][$i]) . '\\';
  1134. } else {
  1135. $name = $matches['name'][$i];
  1136. if ($name === 'extends' || $name === 'implements') {
  1137. continue;
  1138. }
  1139. if ($name[0] === ':') {
  1140. $name = 'xhp'.substr(str_replace(array('-', ':'), array('_', '__'), $name), 1);
  1141. } elseif (strtolower($matches['type'][$i]) === 'enum') {
  1142. $colonPos = strrpos($name, ':');
  1143. if (false !== $colonPos) {
  1144. $name = substr($name, 0, $colonPos);
  1145. }
  1146. }
  1147. $classes[] = ltrim($namespace . $name, '\\');
  1148. }
  1149. }
  1150. return $classes;
  1151. }
  1152. private static function getExtraTypes(): string
  1153. {
  1154. static $extraTypes = null;
  1155. if (null === $extraTypes) {
  1156. $extraTypes = '';
  1157. if (PHP_VERSION_ID >= 80100 || (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '3.3', '>='))) {
  1158. $extraTypes .= '|enum';
  1159. }
  1160. PhpFileCleaner::setTypeConfig(array_merge(['class', 'interface', 'trait'], array_filter(explode('|', $extraTypes))));
  1161. }
  1162. return $extraTypes;
  1163. }
  1164. }
  1165. <?php declare(strict_types=1);
  1166. namespace Composer\Autoload;
  1167. use Composer\Pcre\Preg;
  1168. class PhpFileCleaner
  1169. {
  1170. private static $typeConfig;
  1171. private static $restPattern;
  1172. private $contents;
  1173. private $len;
  1174. private $maxMatches;
  1175. private $index = 0;
  1176. public static function setTypeConfig(array $types): void
  1177. {
  1178. foreach ($types as $type) {
  1179. self::$typeConfig[$type[0]] = array(
  1180. 'name' => $type,
  1181. 'length' => \strlen($type),
  1182. 'pattern' => '{.\b(?<![\$:>])'.$type.'\s++[a-zA-Z_\x7f-\xff:][a-zA-Z0-9_\x7f-\xff:\-]*+}Ais',
  1183. );
  1184. }
  1185. self::$restPattern = '{[^?"\'</'.implode('', array_keys(self::$typeConfig)).']+}A';
  1186. }
  1187. public function __construct(string $contents, int $maxMatches)
  1188. {
  1189. $this->contents = $contents;
  1190. $this->len = \strlen($this->contents);
  1191. $this->maxMatches = $maxMatches;
  1192. }
  1193. public function clean(): string
  1194. {
  1195. $clean = '';
  1196. while ($this->index < $this->len) {
  1197. $this->skipToPhp();
  1198. $clean .= '<?';
  1199. while ($this->index < $this->len) {
  1200. $char = $this->contents[$this->index];
  1201. if ($char === '?' && $this->peek('>')) {
  1202. $clean .= '?>';
  1203. $this->index += 2;
  1204. continue 2;
  1205. }
  1206. if ($char === '"') {
  1207. $this->skipString('"');
  1208. $clean .= 'null';
  1209. continue;
  1210. }
  1211. if ($char === "'") {
  1212. $this->skipString("'");
  1213. $clean .= 'null';
  1214. continue;
  1215. }
  1216. if ($char === "<" && $this->peek('<') && $this->match('{<<<[ \t]*+([\'"]?)([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*+)\\1(?:\r\n|\n|\r)}A', $match)) {
  1217. $this->index += \strlen($match[0]);
  1218. $this->skipHeredoc($match[2]);
  1219. $clean .= 'null';
  1220. continue;
  1221. }
  1222. if ($char === '/') {
  1223. if ($this->peek('/')) {
  1224. $this->skipToNewline();
  1225. continue;
  1226. }
  1227. if ($this->peek('*')) {
  1228. $this->skipComment();
  1229. continue;
  1230. }
  1231. }
  1232. if ($this->maxMatches === 1 && isset(self::$typeConfig[$char])) {
  1233. $type = self::$typeConfig[$char];
  1234. if (
  1235. \substr($this->contents, $this->index, $type['length']) === $type['name']
  1236. && Preg::isMatch($type['pattern'], $this->contents, $match, 0, $this->index - 1)
  1237. ) {
  1238. $clean .= $match[0];
  1239. return $clean;
  1240. }
  1241. }
  1242. $this->index += 1;
  1243. if ($this->match(self::$restPattern, $match)) {
  1244. $clean .= $char . $match[0];
  1245. $this->index += \strlen($match[0]);
  1246. } else {
  1247. $clean .= $char;
  1248. }
  1249. }
  1250. }
  1251. return $clean;
  1252. }
  1253. private function skipToPhp(): void
  1254. {
  1255. while ($this->index < $this->len) {
  1256. if ($this->contents[$this->index] === '<' && $this->peek('?')) {
  1257. $this->index += 2;
  1258. break;
  1259. }
  1260. $this->index += 1;
  1261. }
  1262. }
  1263. private function skipString(string $delimiter): void
  1264. {
  1265. $this->index += 1;
  1266. while ($this->index < $this->len) {
  1267. if ($this->contents[$this->index] === '\\' && ($this->peek('\\') || $this->peek($delimiter))) {
  1268. $this->index += 2;
  1269. continue;
  1270. }
  1271. if ($this->contents[$this->index] === $delimiter) {
  1272. $this->index += 1;
  1273. break;
  1274. }
  1275. $this->index += 1;
  1276. }
  1277. }
  1278. private function skipComment(): void
  1279. {
  1280. $this->index += 2;
  1281. while ($this->index < $this->len) {
  1282. if ($this->contents[$this->index] === '*' && $this->peek('/')) {
  1283. $this->index += 2;
  1284. break;
  1285. }
  1286. $this->index += 1;
  1287. }
  1288. }
  1289. private function skipToNewline(): void
  1290. {
  1291. while ($this->index < $this->len) {
  1292. if ($this->contents[$this->index] === "\r" || $this->contents[$this->index] === "\n") {
  1293. return;
  1294. }
  1295. $this->index += 1;
  1296. }
  1297. }
  1298. private function skipHeredoc(string $delimiter): void
  1299. {
  1300. $firstDelimiterChar = $delimiter[0];
  1301. $delimiterLength = \strlen($delimiter);
  1302. $delimiterPattern = '{'.preg_quote($delimiter).'(?![a-zA-Z0-9_\x80-\xff])}A';
  1303. while ($this->index < $this->len) {
  1304. switch ($this->contents[$this->index]) {
  1305. case "\t":
  1306. case " ":
  1307. $this->index += 1;
  1308. continue 2;
  1309. case $firstDelimiterChar:
  1310. if (
  1311. \substr($this->contents, $this->index, $delimiterLength) === $delimiter
  1312. && $this->match($delimiterPattern)
  1313. ) {
  1314. $this->index += $delimiterLength;
  1315. return;
  1316. }
  1317. break;
  1318. }
  1319. while ($this->index < $this->len) {
  1320. $this->skipToNewline();
  1321. while ($this->index < $this->len && ($this->contents[$this->index] === "\r" || $this->contents[$this->index] === "\n")) {
  1322. $this->index += 1;
  1323. }
  1324. break;
  1325. }
  1326. }
  1327. }
  1328. private function peek(string $char): bool
  1329. {
  1330. return $this->index + 1 < $this->len && $this->contents[$this->index + 1] === $char;
  1331. }
  1332. private function match($regex, array &$match = null): bool
  1333. {
  1334. return Preg::isMatch($regex, $this->contents, $match, 0, $this->index);
  1335. }
  1336. }
  1337. <?php declare(strict_types=1);
  1338. namespace Composer;
  1339. use Composer\IO\IOInterface;
  1340. use Composer\Pcre\Preg;
  1341. use Composer\Util\Filesystem;
  1342. use Composer\Util\Platform;
  1343. use Composer\Util\Silencer;
  1344. use Symfony\Component\Finder\Finder;
  1345. class Cache
  1346. {
  1347. private static $cacheCollected = null;
  1348. private $io;
  1349. private $root;
  1350. private $enabled = null;
  1351. private $allowlist;
  1352. private $filesystem;
  1353. private $readOnly;
  1354. public function __construct(IOInterface $io, string $cacheDir, string $allowlist = 'a-z0-9.', Filesystem $filesystem = null, bool $readOnly = false)
  1355. {
  1356. $this->io = $io;
  1357. $this->root = rtrim($cacheDir, '/\\') . '/';
  1358. $this->allowlist = $allowlist;
  1359. $this->filesystem = $filesystem ?: new Filesystem();
  1360. $this->readOnly = (bool) $readOnly;
  1361. if (!self::isUsable($cacheDir)) {
  1362. $this->enabled = false;
  1363. }
  1364. }
  1365. public function setReadOnly(bool $readOnly)
  1366. {
  1367. $this->readOnly = (bool) $readOnly;
  1368. }
  1369. public function isReadOnly()
  1370. {
  1371. return $this->readOnly;
  1372. }
  1373. public static function isUsable(string $path)
  1374. {
  1375. return !Preg::isMatch('{(^|[\\\\/])(\$null|nul|NUL|/dev/null)([\\\\/]|$)}', $path);
  1376. }
  1377. public function isEnabled()
  1378. {
  1379. if ($this->enabled === null) {
  1380. $this->enabled = true;
  1381. if (
  1382. (!is_dir($this->root) && !Silencer::call('mkdir', $this->root, 0777, true))
  1383. || !is_writable($this->root)
  1384. ) {
  1385. $this->io->writeError('<warning>Cannot create cache directory ' . $this->root . ', or directory is not writable. Proceeding without cache</warning>');
  1386. $this->enabled = false;
  1387. }
  1388. }
  1389. return $this->enabled;
  1390. }
  1391. public function getRoot()
  1392. {
  1393. return $this->root;
  1394. }
  1395. public function read(string $file)
  1396. {
  1397. if ($this->isEnabled()) {
  1398. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1399. if (file_exists($this->root . $file)) {
  1400. $this->io->writeError('Reading '.$this->root . $file.' from cache', true, IOInterface::DEBUG);
  1401. return file_get_contents($this->root . $file);
  1402. }
  1403. }
  1404. return false;
  1405. }
  1406. public function write(string $file, string $contents)
  1407. {
  1408. if ($this->isEnabled() && !$this->readOnly) {
  1409. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1410. $this->io->writeError('Writing '.$this->root . $file.' into cache', true, IOInterface::DEBUG);
  1411. $tempFileName = $this->root . $file . uniqid('.', true) . '.tmp';
  1412. try {
  1413. return file_put_contents($tempFileName, $contents) !== false && rename($tempFileName, $this->root . $file);
  1414. } catch (\ErrorException $e) {
  1415. $this->io->writeError('<warning>Failed to write into cache: '.$e->getMessage().'</warning>', true, IOInterface::DEBUG);
  1416. if (Preg::isMatch('{^file_put_contents\(\): Only ([0-9]+) of ([0-9]+) bytes written}', $e->getMessage(), $m)) {
  1417. unlink($tempFileName);
  1418. $message = sprintf(
  1419. '<warning>Writing %1$s into cache failed after %2$u of %3$u bytes written, only %4$u bytes of free space available</warning>',
  1420. $tempFileName,
  1421. $m[1],
  1422. $m[2],
  1423. @disk_free_space(dirname($tempFileName))
  1424. );
  1425. $this->io->writeError($message);
  1426. return false;
  1427. }
  1428. throw $e;
  1429. }
  1430. }
  1431. return false;
  1432. }
  1433. public function copyFrom(string $file, string $source)
  1434. {
  1435. if ($this->isEnabled() && !$this->readOnly) {
  1436. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1437. $this->filesystem->ensureDirectoryExists(dirname($this->root . $file));
  1438. if (!file_exists($source)) {
  1439. $this->io->writeError('<error>'.$source.' does not exist, can not write into cache</error>');
  1440. } elseif ($this->io->isDebug()) {
  1441. $this->io->writeError('Writing '.$this->root . $file.' into cache from '.$source);
  1442. }
  1443. return copy($source, $this->root . $file);
  1444. }
  1445. return false;
  1446. }
  1447. public function copyTo(string $file, string $target)
  1448. {
  1449. if ($this->isEnabled()) {
  1450. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1451. if (file_exists($this->root . $file)) {
  1452. try {
  1453. touch($this->root . $file, (int) filemtime($this->root . $file), time());
  1454. } catch (\ErrorException $e) {
  1455. Silencer::call('touch', $this->root . $file);
  1456. }
  1457. $this->io->writeError('Reading '.$this->root . $file.' from cache', true, IOInterface::DEBUG);
  1458. return copy($this->root . $file, $target);
  1459. }
  1460. }
  1461. return false;
  1462. }
  1463. public function gcIsNecessary()
  1464. {
  1465. if (self::$cacheCollected) {
  1466. return false;
  1467. }
  1468. self::$cacheCollected = true;
  1469. if (Platform::getEnv('COMPOSER_TEST_SUITE')) {
  1470. return false;
  1471. }
  1472. return !random_int(0, 50);
  1473. }
  1474. public function remove(string $file)
  1475. {
  1476. if ($this->isEnabled()) {
  1477. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1478. if (file_exists($this->root . $file)) {
  1479. return $this->filesystem->unlink($this->root . $file);
  1480. }
  1481. }
  1482. return false;
  1483. }
  1484. public function clear()
  1485. {
  1486. if ($this->isEnabled()) {
  1487. $this->filesystem->emptyDirectory($this->root);
  1488. return true;
  1489. }
  1490. return false;
  1491. }
  1492. public function getAge(string $file)
  1493. {
  1494. if ($this->isEnabled()) {
  1495. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1496. if (file_exists($this->root . $file) && ($mtime = filemtime($this->root . $file)) !== false) {
  1497. return abs(time() - $mtime);
  1498. }
  1499. }
  1500. return false;
  1501. }
  1502. public function gc(int $ttl, int $maxSize)
  1503. {
  1504. if ($this->isEnabled()) {
  1505. $expire = new \DateTime();
  1506. $expire->modify('-'.$ttl.' seconds');
  1507. $finder = $this->getFinder()->date('until '.$expire->format('Y-m-d H:i:s'));
  1508. foreach ($finder as $file) {
  1509. $this->filesystem->unlink($file->getPathname());
  1510. }
  1511. $totalSize = $this->filesystem->size($this->root);
  1512. if ($totalSize > $maxSize) {
  1513. $iterator = $this->getFinder()->sortByAccessedTime()->getIterator();
  1514. while ($totalSize > $maxSize && $iterator->valid()) {
  1515. $filepath = $iterator->current()->getPathname();
  1516. $totalSize -= $this->filesystem->size($filepath);
  1517. $this->filesystem->unlink($filepath);
  1518. $iterator->next();
  1519. }
  1520. }
  1521. self::$cacheCollected = true;
  1522. return true;
  1523. }
  1524. return false;
  1525. }
  1526. public function sha1(string $file)
  1527. {
  1528. if ($this->isEnabled()) {
  1529. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1530. if (file_exists($this->root . $file)) {
  1531. return sha1_file($this->root . $file);
  1532. }
  1533. }
  1534. return false;
  1535. }
  1536. public function sha256(string $file)
  1537. {
  1538. if ($this->isEnabled()) {
  1539. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1540. if (file_exists($this->root . $file)) {
  1541. return hash_file('sha256', $this->root . $file);
  1542. }
  1543. }
  1544. return false;
  1545. }
  1546. protected function getFinder()
  1547. {
  1548. return Finder::create()->in($this->root)->files();
  1549. }
  1550. }
  1551. <?php declare(strict_types=1);
  1552. namespace Composer\Command;
  1553. use Composer\Composer;
  1554. use Symfony\Component\Console\Input\InputInterface;
  1555. use Symfony\Component\Console\Output\OutputInterface;
  1556. class AboutCommand extends BaseCommand
  1557. {
  1558. protected function configure(): void
  1559. {
  1560. $this
  1561. ->setName('about')
  1562. ->setDescription('Shows a short information about Composer.')
  1563. ->setHelp(
  1564. <<<EOT
  1565. <info>php composer.phar about</info>
  1566. EOT
  1567. )
  1568. ;
  1569. }
  1570. protected function execute(InputInterface $input, OutputInterface $output): int
  1571. {
  1572. $composerVersion = Composer::getVersion();
  1573. $this->getIO()->write(
  1574. <<<EOT
  1575. <info>Composer - Dependency Manager for PHP - version $composerVersion</info>
  1576. <comment>Composer is a dependency manager tracking local dependencies of your projects and libraries.
  1577. See https://getcomposer.org/ for more information.</comment>
  1578. EOT
  1579. );
  1580. return 0;
  1581. }
  1582. }
  1583. <?php declare(strict_types=1);
  1584. namespace Composer\Command;
  1585. use Composer\Factory;
  1586. use Composer\IO\IOInterface;
  1587. use Composer\Config;
  1588. use Composer\Composer;
  1589. use Composer\Package\BasePackage;
  1590. use Composer\Package\CompletePackageInterface;
  1591. use Composer\Repository\CompositeRepository;
  1592. use Composer\Repository\RepositoryFactory;
  1593. use Composer\Script\ScriptEvents;
  1594. use Composer\Plugin\CommandEvent;
  1595. use Composer\Plugin\PluginEvents;
  1596. use Composer\Util\Filesystem;
  1597. use Composer\Util\Loop;
  1598. use Composer\Util\Platform;
  1599. use Composer\Util\ProcessExecutor;
  1600. use Symfony\Component\Console\Input\InputArgument;
  1601. use Symfony\Component\Console\Input\InputInterface;
  1602. use Symfony\Component\Console\Input\InputOption;
  1603. use Symfony\Component\Console\Output\OutputInterface;
  1604. class ArchiveCommand extends BaseCommand
  1605. {
  1606. protected function configure(): void
  1607. {
  1608. $this
  1609. ->setName('archive')
  1610. ->setDescription('Creates an archive of this composer package.')
  1611. ->setDefinition(array(
  1612. new InputArgument('package', InputArgument::OPTIONAL, 'The package to archive instead of the current project'),
  1613. new InputArgument('version', InputArgument::OPTIONAL, 'A version constraint to find the package to archive'),
  1614. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the resulting archive: tar, tar.gz, tar.bz2 or zip (default tar)'),
  1615. new InputOption('dir', null, InputOption::VALUE_REQUIRED, 'Write the archive to this directory'),
  1616. new InputOption('file', null, InputOption::VALUE_REQUIRED, 'Write the archive with the given file name.'
  1617. .' Note that the format will be appended.'),
  1618. new InputOption('ignore-filters', null, InputOption::VALUE_NONE, 'Ignore filters when saving package'),
  1619. ))
  1620. ->setHelp(
  1621. <<<EOT
  1622. The <info>archive</info> command creates an archive of the specified format
  1623. containing the files and directories of the Composer project or the specified
  1624. package in the specified version and writes it to the specified directory.
  1625. <info>php composer.phar archive [--format=zip] [--dir=/foo] [--file=filename] [package [version]]</info>
  1626. Read more at https://getcomposer.org/doc/03-cli.md#archive
  1627. EOT
  1628. )
  1629. ;
  1630. }
  1631. protected function execute(InputInterface $input, OutputInterface $output): int
  1632. {
  1633. $composer = $this->tryComposer();
  1634. $config = null;
  1635. if ($composer) {
  1636. $config = $composer->getConfig();
  1637. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'archive', $input, $output);
  1638. $eventDispatcher = $composer->getEventDispatcher();
  1639. $eventDispatcher->dispatch($commandEvent->getName(), $commandEvent);
  1640. $eventDispatcher->dispatchScript(ScriptEvents::PRE_ARCHIVE_CMD);
  1641. }
  1642. if (!$config) {
  1643. $config = Factory::createConfig();
  1644. }
  1645. $format = $input->getOption('format') ?? $config->get('archive-format');
  1646. $dir = $input->getOption('dir') ?? $config->get('archive-dir');
  1647. $returnCode = $this->archive(
  1648. $this->getIO(),
  1649. $config,
  1650. $input->getArgument('package'),
  1651. $input->getArgument('version'),
  1652. $format,
  1653. $dir,
  1654. $input->getOption('file'),
  1655. $input->getOption('ignore-filters'),
  1656. $composer
  1657. );
  1658. if (0 === $returnCode && $composer) {
  1659. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ARCHIVE_CMD);
  1660. }
  1661. return $returnCode;
  1662. }
  1663. protected function archive(IOInterface $io, Config $config, ?string $packageName, ?string $version, string $format, string $dest, ?string $fileName, bool $ignoreFilters, ?Composer $composer): int
  1664. {
  1665. if ($composer) {
  1666. $archiveManager = $composer->getArchiveManager();
  1667. } else {
  1668. $factory = new Factory;
  1669. $process = new ProcessExecutor();
  1670. $httpDownloader = Factory::createHttpDownloader($io, $config);
  1671. $downloadManager = $factory->createDownloadManager($io, $config, $httpDownloader, $process);
  1672. $archiveManager = $factory->createArchiveManager($config, $downloadManager, new Loop($httpDownloader, $process));
  1673. }
  1674. if ($packageName) {
  1675. $package = $this->selectPackage($io, $packageName, $version);
  1676. if (!$package) {
  1677. return 1;
  1678. }
  1679. } else {
  1680. $package = $this->requireComposer()->getPackage();
  1681. }
  1682. $io->writeError('<info>Creating the archive into "'.$dest.'".</info>');
  1683. $packagePath = $archiveManager->archive($package, $format, $dest, $fileName, $ignoreFilters);
  1684. $fs = new Filesystem;
  1685. $shortPath = $fs->findShortestPath(Platform::getCwd(), $packagePath, true);
  1686. $io->writeError('Created: ', false);
  1687. $io->write(strlen($shortPath) < strlen($packagePath) ? $shortPath : $packagePath);
  1688. return 0;
  1689. }
  1690. protected function selectPackage(IOInterface $io, string $packageName, ?string $version = null)
  1691. {
  1692. $io->writeError('<info>Searching for the specified package.</info>');
  1693. if ($composer = $this->tryComposer()) {
  1694. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  1695. $repo = new CompositeRepository(array_merge(array($localRepo), $composer->getRepositoryManager()->getRepositories()));
  1696. } else {
  1697. $defaultRepos = RepositoryFactory::defaultRepos($this->getIO());
  1698. $io->writeError('No composer.json found in the current directory, searching packages from ' . implode(', ', array_keys($defaultRepos)));
  1699. $repo = new CompositeRepository($defaultRepos);
  1700. }
  1701. $packages = $repo->findPackages($packageName, $version);
  1702. if (count($packages) > 1) {
  1703. $package = reset($packages);
  1704. $io->writeError('<info>Found multiple matches, selected '.$package->getPrettyString().'.</info>');
  1705. $io->writeError('Alternatives were '.implode(', ', array_map(function ($p): string {
  1706. return $p->getPrettyString();
  1707. }, $packages)).'.');
  1708. $io->writeError('<comment>Please use a more specific constraint to pick a different package.</comment>');
  1709. } elseif ($packages) {
  1710. $package = reset($packages);
  1711. $io->writeError('<info>Found an exact match '.$package->getPrettyString().'.</info>');
  1712. } else {
  1713. $io->writeError('<error>Could not find a package matching '.$packageName.'.</error>');
  1714. return false;
  1715. }
  1716. if (!$package instanceof CompletePackageInterface) {
  1717. throw new \LogicException('Expected a CompletePackageInterface instance but found '.get_class($package));
  1718. }
  1719. return $package;
  1720. }
  1721. }
  1722. <?php declare(strict_types=1);
  1723. namespace Composer\Command;
  1724. use Composer\Composer;
  1725. use Composer\Config;
  1726. use Composer\Console\Application;
  1727. use Composer\Factory;
  1728. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  1729. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  1730. use Composer\IO\IOInterface;
  1731. use Composer\IO\NullIO;
  1732. use Composer\Plugin\PreCommandRunEvent;
  1733. use Composer\Package\Version\VersionParser;
  1734. use Composer\Plugin\PluginEvents;
  1735. use Composer\Util\Platform;
  1736. use Symfony\Component\Console\Helper\Table;
  1737. use Symfony\Component\Console\Helper\TableSeparator;
  1738. use Symfony\Component\Console\Input\InputInterface;
  1739. use Symfony\Component\Console\Output\OutputInterface;
  1740. use Symfony\Component\Console\Command\Command;
  1741. use Symfony\Component\Console\Terminal;
  1742. abstract class BaseCommand extends Command
  1743. {
  1744. private $composer;
  1745. private $io;
  1746. public function getApplication(): Application
  1747. {
  1748. $application = parent::getApplication();
  1749. if (!$application instanceof Application) {
  1750. throw new \RuntimeException('Composer commands can only work with an '.Application::class.' instance set');
  1751. }
  1752. return $application;
  1753. }
  1754. public function getComposer(bool $required = true, ?bool $disablePlugins = null, ?bool $disableScripts = null)
  1755. {
  1756. if ($required) {
  1757. return $this->requireComposer($disablePlugins, $disableScripts);
  1758. }
  1759. return $this->tryComposer($disablePlugins, $disableScripts);
  1760. }
  1761. public function requireComposer(bool $disablePlugins = null, bool $disableScripts = null): Composer
  1762. {
  1763. if (null === $this->composer) {
  1764. $application = parent::getApplication();
  1765. if ($application instanceof Application) {
  1766. $this->composer = $application->getComposer(true, $disablePlugins, $disableScripts);
  1767. assert($this->composer instanceof Composer);
  1768. } else {
  1769. throw new \RuntimeException(
  1770. 'Could not create a Composer\Composer instance, you must inject '.
  1771. 'one if this command is not used with a Composer\Console\Application instance'
  1772. );
  1773. }
  1774. }
  1775. return $this->composer;
  1776. }
  1777. public function tryComposer(bool $disablePlugins = null, bool $disableScripts = null): ?Composer
  1778. {
  1779. if (null === $this->composer) {
  1780. $application = parent::getApplication();
  1781. if ($application instanceof Application) {
  1782. $this->composer = $application->getComposer(false, $disablePlugins, $disableScripts);
  1783. }
  1784. }
  1785. return $this->composer;
  1786. }
  1787. public function setComposer(Composer $composer)
  1788. {
  1789. $this->composer = $composer;
  1790. }
  1791. public function resetComposer()
  1792. {
  1793. $this->composer = null;
  1794. $this->getApplication()->resetComposer();
  1795. }
  1796. public function isProxyCommand()
  1797. {
  1798. return false;
  1799. }
  1800. public function getIO()
  1801. {
  1802. if (null === $this->io) {
  1803. $application = parent::getApplication();
  1804. if ($application instanceof Application) {
  1805. $this->io = $application->getIO();
  1806. } else {
  1807. $this->io = new NullIO();
  1808. }
  1809. }
  1810. return $this->io;
  1811. }
  1812. public function setIO(IOInterface $io)
  1813. {
  1814. $this->io = $io;
  1815. }
  1816. protected function initialize(InputInterface $input, OutputInterface $output)
  1817. {
  1818. $disablePlugins = $input->hasParameterOption('--no-plugins');
  1819. $disableScripts = $input->hasParameterOption('--no-scripts');
  1820. if ($this instanceof SelfUpdateCommand) {
  1821. $disablePlugins = true;
  1822. $disableScripts = true;
  1823. }
  1824. $composer = $this->tryComposer($disablePlugins, $disableScripts);
  1825. $io = $this->getIO();
  1826. if (null === $composer) {
  1827. $composer = Factory::createGlobal($this->getIO(), $disablePlugins, $disableScripts);
  1828. }
  1829. if ($composer) {
  1830. $preCommandRunEvent = new PreCommandRunEvent(PluginEvents::PRE_COMMAND_RUN, $input, $this->getName());
  1831. $composer->getEventDispatcher()->dispatch($preCommandRunEvent->getName(), $preCommandRunEvent);
  1832. }
  1833. if (true === $input->hasParameterOption(array('--no-ansi')) && $input->hasOption('no-progress')) {
  1834. $input->setOption('no-progress', true);
  1835. }
  1836. if (true === $input->hasOption('no-dev')) {
  1837. if (!$input->getOption('no-dev') && true == Platform::getEnv('COMPOSER_NO_DEV')) {
  1838. $input->setOption('no-dev', true);
  1839. }
  1840. }
  1841. if (true === $input->hasOption('ignore-platform-reqs')) {
  1842. if (!$input->getOption('ignore-platform-reqs') && true == Platform::getEnv('COMPOSER_IGNORE_PLATFORM_REQS')) {
  1843. $input->setOption('ignore-platform-reqs', true);
  1844. $io->writeError('<warning>COMPOSER_IGNORE_PLATFORM_REQS is set. You may experience unexpected errors.</warning>');
  1845. }
  1846. }
  1847. if (true === $input->hasOption('ignore-platform-req') && (!$input->hasOption('ignore-platform-reqs') || !$input->getOption('ignore-platform-reqs'))) {
  1848. $ignorePlatformReqEnv = Platform::getEnv('COMPOSER_IGNORE_PLATFORM_REQ');
  1849. if (0 === count($input->getOption('ignore-platform-req')) && is_string($ignorePlatformReqEnv) && '' !== $ignorePlatformReqEnv) {
  1850. $input->setOption('ignore-platform-req', explode(',', $ignorePlatformReqEnv));
  1851. $io->writeError('<warning>COMPOSER_IGNORE_PLATFORM_REQ is set to ignore '.$ignorePlatformReqEnv.'. You may experience unexpected errors.</warning>');
  1852. }
  1853. }
  1854. parent::initialize($input, $output);
  1855. }
  1856. protected function getPreferredInstallOptions(Config $config, InputInterface $input, bool $keepVcsRequiresPreferSource = false)
  1857. {
  1858. $preferSource = false;
  1859. $preferDist = false;
  1860. switch ($config->get('preferred-install')) {
  1861. case 'source':
  1862. $preferSource = true;
  1863. break;
  1864. case 'dist':
  1865. $preferDist = true;
  1866. break;
  1867. case 'auto':
  1868. default:
  1869. break;
  1870. }
  1871. if (!$input->hasOption('prefer-dist') || !$input->hasOption('prefer-source')) {
  1872. return [$preferSource, $preferDist];
  1873. }
  1874. if ($input->hasOption('prefer-install') && is_string($input->getOption('prefer-install'))) {
  1875. if ($input->getOption('prefer-source')) {
  1876. throw new \InvalidArgumentException('--prefer-source can not be used together with --prefer-install');
  1877. }
  1878. if ($input->getOption('prefer-dist')) {
  1879. throw new \InvalidArgumentException('--prefer-dist can not be used together with --prefer-install');
  1880. }
  1881. switch ($input->getOption('prefer-install')) {
  1882. case 'dist':
  1883. $input->setOption('prefer-dist', true);
  1884. break;
  1885. case 'source':
  1886. $input->setOption('prefer-source', true);
  1887. break;
  1888. case 'auto':
  1889. $preferDist = false;
  1890. $preferSource = false;
  1891. break;
  1892. default:
  1893. throw new \UnexpectedValueException('--prefer-install accepts one of "dist", "source" or "auto", got '.$input->getOption('prefer-install'));
  1894. }
  1895. }
  1896. if ($input->getOption('prefer-source') || $input->getOption('prefer-dist') || ($keepVcsRequiresPreferSource && $input->hasOption('keep-vcs') && $input->getOption('keep-vcs'))) {
  1897. $preferSource = $input->getOption('prefer-source') || ($keepVcsRequiresPreferSource && $input->hasOption('keep-vcs') && $input->getOption('keep-vcs'));
  1898. $preferDist = $input->getOption('prefer-dist');
  1899. }
  1900. return array($preferSource, $preferDist);
  1901. }
  1902. protected function getPlatformRequirementFilter(InputInterface $input): PlatformRequirementFilterInterface
  1903. {
  1904. if (!$input->hasOption('ignore-platform-reqs') || !$input->hasOption('ignore-platform-req')) {
  1905. throw new \LogicException('Calling getPlatformRequirementFilter from a command which does not define the --ignore-platform-req[s] flags is not permitted.');
  1906. }
  1907. if (true === $input->getOption('ignore-platform-reqs')) {
  1908. return PlatformRequirementFilterFactory::ignoreAll();
  1909. }
  1910. $ignores = $input->getOption('ignore-platform-req');
  1911. if (count($ignores) > 0) {
  1912. return PlatformRequirementFilterFactory::fromBoolOrList($ignores);
  1913. }
  1914. return PlatformRequirementFilterFactory::ignoreNothing();
  1915. }
  1916. protected function formatRequirements(array $requirements)
  1917. {
  1918. $requires = array();
  1919. $requirements = $this->normalizeRequirements($requirements);
  1920. foreach ($requirements as $requirement) {
  1921. if (!isset($requirement['version'])) {
  1922. throw new \UnexpectedValueException('Option '.$requirement['name'] .' is missing a version constraint, use e.g. '.$requirement['name'].':^1.0');
  1923. }
  1924. $requires[$requirement['name']] = $requirement['version'];
  1925. }
  1926. return $requires;
  1927. }
  1928. protected function normalizeRequirements(array $requirements)
  1929. {
  1930. $parser = new VersionParser();
  1931. return $parser->parseNameVersionPairs($requirements);
  1932. }
  1933. protected function renderTable(array $table, OutputInterface $output)
  1934. {
  1935. $renderer = new Table($output);
  1936. $renderer->setStyle('compact');
  1937. $rendererStyle = $renderer->getStyle();
  1938. $rendererStyle->setVerticalBorderChars('');
  1939. $rendererStyle->setCellRowContentFormat('%s ');
  1940. $renderer->setRows($table)->render();
  1941. }
  1942. protected function getTerminalWidth()
  1943. {
  1944. $terminal = new Terminal();
  1945. $width = $terminal->getWidth();
  1946. if (Platform::isWindows()) {
  1947. $width--;
  1948. } else {
  1949. $width = max(80, $width);
  1950. }
  1951. return $width;
  1952. }
  1953. }
  1954. <?php declare(strict_types=1);
  1955. namespace Composer\Command;
  1956. use Composer\Package\Link;
  1957. use Composer\Package\PackageInterface;
  1958. use Composer\Package\CompletePackageInterface;
  1959. use Composer\Package\RootPackage;
  1960. use Composer\Repository\InstalledArrayRepository;
  1961. use Composer\Repository\CompositeRepository;
  1962. use Composer\Repository\RootPackageRepository;
  1963. use Composer\Repository\InstalledRepository;
  1964. use Composer\Repository\PlatformRepository;
  1965. use Composer\Repository\RepositoryFactory;
  1966. use Composer\Plugin\CommandEvent;
  1967. use Composer\Plugin\PluginEvents;
  1968. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  1969. use Composer\Package\Version\VersionParser;
  1970. use Symfony\Component\Console\Input\InputInterface;
  1971. use Symfony\Component\Console\Output\OutputInterface;
  1972. abstract class BaseDependencyCommand extends BaseCommand
  1973. {
  1974. protected const ARGUMENT_PACKAGE = 'package';
  1975. protected const ARGUMENT_CONSTRAINT = 'version';
  1976. protected const OPTION_RECURSIVE = 'recursive';
  1977. protected const OPTION_TREE = 'tree';
  1978. protected $colors;
  1979. protected function doExecute(InputInterface $input, OutputInterface $output, bool $inverted = false): int
  1980. {
  1981. $composer = $this->requireComposer();
  1982. $commandEvent = new CommandEvent(PluginEvents::COMMAND, $this->getName(), $input, $output);
  1983. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  1984. $platformOverrides = $composer->getConfig()->get('platform') ?: array();
  1985. $installedRepo = new InstalledRepository(array(
  1986. new RootPackageRepository($composer->getPackage()),
  1987. $composer->getRepositoryManager()->getLocalRepository(),
  1988. new PlatformRepository(array(), $platformOverrides),
  1989. ));
  1990. list($needle, $textConstraint) = array_pad(
  1991. explode(':', $input->getArgument(self::ARGUMENT_PACKAGE)),
  1992. 2,
  1993. $input->hasArgument(self::ARGUMENT_CONSTRAINT) ? $input->getArgument(self::ARGUMENT_CONSTRAINT) : '*'
  1994. );
  1995. $packages = $installedRepo->findPackagesWithReplacersAndProviders($needle);
  1996. if (empty($packages)) {
  1997. throw new \InvalidArgumentException(sprintf('Could not find package "%s" in your project', $needle));
  1998. }
  1999. if (!$installedRepo->findPackage($needle, $textConstraint)) {
  2000. $defaultRepos = new CompositeRepository(RepositoryFactory::defaultRepos($this->getIO()));
  2001. if ($match = $defaultRepos->findPackage($needle, $textConstraint)) {
  2002. $installedRepo->addRepository(new InstalledArrayRepository(array(clone $match)));
  2003. }
  2004. }
  2005. $needles = array($needle);
  2006. if ($inverted) {
  2007. foreach ($packages as $package) {
  2008. $needles = array_merge($needles, array_map(function (Link $link): string {
  2009. return $link->getTarget();
  2010. }, $package->getReplaces()));
  2011. }
  2012. }
  2013. if ('*' !== $textConstraint) {
  2014. $versionParser = new VersionParser();
  2015. $constraint = $versionParser->parseConstraints($textConstraint);
  2016. } else {
  2017. $constraint = null;
  2018. }
  2019. $renderTree = $input->getOption(self::OPTION_TREE);
  2020. $recursive = $renderTree || $input->getOption(self::OPTION_RECURSIVE);
  2021. $results = $installedRepo->getDependents($needles, $constraint, $inverted, $recursive);
  2022. if (empty($results)) {
  2023. $extra = (null !== $constraint) ? sprintf(' in versions %smatching %s', $inverted ? 'not ' : '', $textConstraint) : '';
  2024. $this->getIO()->writeError(sprintf(
  2025. '<info>There is no installed package depending on "%s"%s</info>',
  2026. $needle,
  2027. $extra
  2028. ));
  2029. } elseif ($renderTree) {
  2030. $this->initStyles($output);
  2031. $root = $packages[0];
  2032. $this->getIO()->write(sprintf('<info>%s</info> %s %s', $root->getPrettyName(), $root->getPrettyVersion(), $root instanceof CompletePackageInterface ? $root->getDescription() : ''));
  2033. $this->printTree($results);
  2034. } else {
  2035. $this->printTable($output, $results);
  2036. }
  2037. return 0;
  2038. }
  2039. protected function printTable(OutputInterface $output, $results): void
  2040. {
  2041. $table = array();
  2042. $doubles = array();
  2043. do {
  2044. $queue = array();
  2045. $rows = array();
  2046. foreach ($results as $result) {
  2047. list($package, $link, $children) = $result;
  2048. $unique = (string) $link;
  2049. if (isset($doubles[$unique])) {
  2050. continue;
  2051. }
  2052. $doubles[$unique] = true;
  2053. $version = $package->getPrettyVersion() === RootPackage::DEFAULT_PRETTY_VERSION ? '-' : $package->getPrettyVersion();
  2054. $rows[] = array($package->getPrettyName(), $version, $link->getDescription(), sprintf('%s (%s)', $link->getTarget(), $link->getPrettyConstraint()));
  2055. if ($children) {
  2056. $queue = array_merge($queue, $children);
  2057. }
  2058. }
  2059. $results = $queue;
  2060. $table = array_merge($rows, $table);
  2061. } while (!empty($results));
  2062. $this->renderTable($table, $output);
  2063. }
  2064. protected function initStyles(OutputInterface $output): void
  2065. {
  2066. $this->colors = array(
  2067. 'green',
  2068. 'yellow',
  2069. 'cyan',
  2070. 'magenta',
  2071. 'blue',
  2072. );
  2073. foreach ($this->colors as $color) {
  2074. $style = new OutputFormatterStyle($color);
  2075. $output->getFormatter()->setStyle($color, $style);
  2076. }
  2077. }
  2078. protected function printTree(array $results, string $prefix = '', int $level = 1): void
  2079. {
  2080. $count = count($results);
  2081. $idx = 0;
  2082. foreach ($results as $result) {
  2083. list($package, $link, $children) = $result;
  2084. $color = $this->colors[$level % count($this->colors)];
  2085. $prevColor = $this->colors[($level - 1) % count($this->colors)];
  2086. $isLast = (++$idx == $count);
  2087. $versionText = $package->getPrettyVersion() === RootPackage::DEFAULT_PRETTY_VERSION ? '' : $package->getPrettyVersion();
  2088. $packageText = rtrim(sprintf('<%s>%s</%1$s> %s', $color, $package->getPrettyName(), $versionText));
  2089. $linkText = sprintf('%s <%s>%s</%2$s> %s', $link->getDescription(), $prevColor, $link->getTarget(), $link->getPrettyConstraint());
  2090. $circularWarn = $children === false ? '(circular dependency aborted here)' : '';
  2091. $this->writeTreeLine(rtrim(sprintf("%s%s%s (%s) %s", $prefix, $isLast ? '└──' : '├──', $packageText, $linkText, $circularWarn)));
  2092. if ($children) {
  2093. $this->printTree($children, $prefix . ($isLast ? ' ' : '│ '), $level + 1);
  2094. }
  2095. }
  2096. }
  2097. private function writeTreeLine(string $line): void
  2098. {
  2099. $io = $this->getIO();
  2100. if (!$io->isDecorated()) {
  2101. $line = str_replace(array('└', '├', '──', '│'), array('`-', '|-', '-', '|'), $line);
  2102. }
  2103. $io->write($line);
  2104. }
  2105. }
  2106. <?php declare(strict_types=1);
  2107. namespace Composer\Command;
  2108. use Composer\Package\Link;
  2109. use Composer\Semver\Constraint\Constraint;
  2110. use Symfony\Component\Console\Input\InputInterface;
  2111. use Symfony\Component\Console\Input\InputOption;
  2112. use Symfony\Component\Console\Output\OutputInterface;
  2113. use Composer\Repository\PlatformRepository;
  2114. use Composer\Repository\RootPackageRepository;
  2115. use Composer\Repository\InstalledRepository;
  2116. class CheckPlatformReqsCommand extends BaseCommand
  2117. {
  2118. protected function configure(): void
  2119. {
  2120. $this->setName('check-platform-reqs')
  2121. ->setDescription('Check that platform requirements are satisfied.')
  2122. ->setDefinition(array(
  2123. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables checking of require-dev packages requirements.'),
  2124. new InputOption('lock', null, InputOption::VALUE_NONE, 'Checks requirements only from the lock file, not from installed packages.'),
  2125. ))
  2126. ->setHelp(
  2127. <<<EOT
  2128. Checks that your PHP and extensions versions match the platform requirements of the installed packages.
  2129. Unlike update/install, this command will ignore config.platform settings and check the real platform packages so you can be certain you have the required platform dependencies.
  2130. <info>php composer.phar check-platform-reqs</info>
  2131. EOT
  2132. );
  2133. }
  2134. protected function execute(InputInterface $input, OutputInterface $output): int
  2135. {
  2136. $composer = $this->requireComposer();
  2137. $requires = array();
  2138. $removePackages = array();
  2139. if ($input->getOption('lock')) {
  2140. $this->getIO()->writeError('<info>Checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements using the lock file</info>');
  2141. $installedRepo = $composer->getLocker()->getLockedRepository(!$input->getOption('no-dev'));
  2142. } else {
  2143. $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
  2144. if (!$installedRepo->getPackages()) {
  2145. $this->getIO()->writeError('<warning>No vendor dir present, checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements from the lock file</warning>');
  2146. $installedRepo = $composer->getLocker()->getLockedRepository(!$input->getOption('no-dev'));
  2147. } else {
  2148. if ($input->getOption('no-dev')) {
  2149. $removePackages = $installedRepo->getDevPackageNames();
  2150. }
  2151. $this->getIO()->writeError('<info>Checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements for packages in the vendor dir</info>');
  2152. }
  2153. }
  2154. if (!$input->getOption('no-dev')) {
  2155. $requires += $composer->getPackage()->getDevRequires();
  2156. }
  2157. foreach ($requires as $require => $link) {
  2158. $requires[$require] = array($link);
  2159. }
  2160. $installedRepo = new InstalledRepository(array($installedRepo, new RootPackageRepository($composer->getPackage())));
  2161. foreach ($installedRepo->getPackages() as $package) {
  2162. if (in_array($package->getName(), $removePackages, true)) {
  2163. continue;
  2164. }
  2165. foreach ($package->getRequires() as $require => $link) {
  2166. $requires[$require][] = $link;
  2167. }
  2168. }
  2169. ksort($requires);
  2170. $installedRepo->addRepository(new PlatformRepository(array(), array()));
  2171. $results = array();
  2172. $exitCode = 0;
  2173. foreach ($requires as $require => $links) {
  2174. if (PlatformRepository::isPlatformPackage($require)) {
  2175. $candidates = $installedRepo->findPackagesWithReplacersAndProviders($require);
  2176. if ($candidates) {
  2177. $reqResults = array();
  2178. foreach ($candidates as $candidate) {
  2179. $candidateConstraint = null;
  2180. if ($candidate->getName() === $require) {
  2181. $candidateConstraint = new Constraint('=', $candidate->getVersion());
  2182. $candidateConstraint->setPrettyString($candidate->getPrettyVersion());
  2183. } else {
  2184. foreach (array_merge($candidate->getProvides(), $candidate->getReplaces()) as $link) {
  2185. if ($link->getTarget() === $require) {
  2186. $candidateConstraint = $link->getConstraint();
  2187. break;
  2188. }
  2189. }
  2190. }
  2191. if (!$candidateConstraint) {
  2192. continue;
  2193. }
  2194. foreach ($links as $link) {
  2195. if (!$link->getConstraint()->matches($candidateConstraint)) {
  2196. $reqResults[] = array(
  2197. $candidate->getName() === $require ? $candidate->getPrettyName() : $require,
  2198. $candidateConstraint->getPrettyString(),
  2199. $link,
  2200. '<error>failed</error>'.($candidate->getName() === $require ? '' : ' <comment>provided by '.$candidate->getPrettyName().'</comment>'),
  2201. );
  2202. continue 2;
  2203. }
  2204. }
  2205. $results[] = array(
  2206. $candidate->getName() === $require ? $candidate->getPrettyName() : $require,
  2207. $candidateConstraint->getPrettyString(),
  2208. null,
  2209. '<info>success</info>'.($candidate->getName() === $require ? '' : ' <comment>provided by '.$candidate->getPrettyName().'</comment>'),
  2210. );
  2211. continue 2;
  2212. }
  2213. $results = array_merge($results, $reqResults);
  2214. $exitCode = max($exitCode, 1);
  2215. continue;
  2216. }
  2217. $results[] = array(
  2218. $require,
  2219. 'n/a',
  2220. $links[0],
  2221. '<error>missing</error>',
  2222. );
  2223. $exitCode = max($exitCode, 2);
  2224. }
  2225. }
  2226. $this->printTable($output, $results);
  2227. return $exitCode;
  2228. }
  2229. protected function printTable(OutputInterface $output, array $results): void
  2230. {
  2231. $rows = array();
  2232. foreach ($results as $result) {
  2233. list($platformPackage, $version, $link, $status) = $result;
  2234. $rows[] = array(
  2235. $platformPackage,
  2236. $version,
  2237. $link ? sprintf('%s %s %s (%s)', $link->getSource(), $link->getDescription(), $link->getTarget(), $link->getPrettyConstraint()) : '',
  2238. $status,
  2239. );
  2240. }
  2241. $this->renderTable($rows, $output);
  2242. }
  2243. }
  2244. <?php declare(strict_types=1);
  2245. namespace Composer\Command;
  2246. use Composer\Cache;
  2247. use Composer\Factory;
  2248. use Symfony\Component\Console\Input\InputInterface;
  2249. use Symfony\Component\Console\Output\OutputInterface;
  2250. class ClearCacheCommand extends BaseCommand
  2251. {
  2252. protected function configure(): void
  2253. {
  2254. $this
  2255. ->setName('clear-cache')
  2256. ->setAliases(array('clearcache', 'cc'))
  2257. ->setDescription('Clears composer\'s internal package cache.')
  2258. ->setHelp(
  2259. <<<EOT
  2260. The <info>clear-cache</info> deletes all cached packages from composer's
  2261. cache directory.
  2262. Read more at https://getcomposer.org/doc/03-cli.md#clear-cache-clearcache-cc
  2263. EOT
  2264. )
  2265. ;
  2266. }
  2267. protected function execute(InputInterface $input, OutputInterface $output): int
  2268. {
  2269. $config = Factory::createConfig();
  2270. $io = $this->getIO();
  2271. $cachePaths = array(
  2272. 'cache-vcs-dir' => $config->get('cache-vcs-dir'),
  2273. 'cache-repo-dir' => $config->get('cache-repo-dir'),
  2274. 'cache-files-dir' => $config->get('cache-files-dir'),
  2275. 'cache-dir' => $config->get('cache-dir'),
  2276. );
  2277. foreach ($cachePaths as $key => $cachePath) {
  2278. $cachePath = realpath($cachePath);
  2279. if (!$cachePath) {
  2280. $io->writeError("<info>Cache directory does not exist ($key): $cachePath</info>");
  2281. continue;
  2282. }
  2283. $cache = new Cache($io, $cachePath);
  2284. $cache->setReadOnly($config->get('cache-read-only'));
  2285. if (!$cache->isEnabled()) {
  2286. $io->writeError("<info>Cache is not enabled ($key): $cachePath</info>");
  2287. continue;
  2288. }
  2289. $io->writeError("<info>Clearing cache ($key): $cachePath</info>");
  2290. $cache->clear();
  2291. }
  2292. $io->writeError('<info>All caches cleared.</info>');
  2293. return 0;
  2294. }
  2295. }
  2296. <?php declare(strict_types=1);
  2297. namespace Composer\Command;
  2298. use Composer\Pcre\Preg;
  2299. use Composer\Util\Filesystem;
  2300. use Composer\Util\Platform;
  2301. use Composer\Util\Silencer;
  2302. use Symfony\Component\Console\Input\InputInterface;
  2303. use Symfony\Component\Console\Input\InputArgument;
  2304. use Symfony\Component\Console\Input\InputOption;
  2305. use Symfony\Component\Console\Output\OutputInterface;
  2306. use Composer\Config;
  2307. use Composer\Config\JsonConfigSource;
  2308. use Composer\Factory;
  2309. use Composer\IO\IOInterface;
  2310. use Composer\Json\JsonFile;
  2311. use Composer\Semver\VersionParser;
  2312. use Composer\Package\BasePackage;
  2313. class ConfigCommand extends BaseCommand
  2314. {
  2315. protected $config;
  2316. protected $configFile;
  2317. protected $configSource;
  2318. protected $authConfigFile;
  2319. protected $authConfigSource;
  2320. protected function configure(): void
  2321. {
  2322. $this
  2323. ->setName('config')
  2324. ->setDescription('Sets config options.')
  2325. ->setDefinition(array(
  2326. new InputOption('global', 'g', InputOption::VALUE_NONE, 'Apply command to the global config file'),
  2327. new InputOption('editor', 'e', InputOption::VALUE_NONE, 'Open editor'),
  2328. new InputOption('auth', 'a', InputOption::VALUE_NONE, 'Affect auth config file (only used for --editor)'),
  2329. new InputOption('unset', null, InputOption::VALUE_NONE, 'Unset the given setting-key'),
  2330. new InputOption('list', 'l', InputOption::VALUE_NONE, 'List configuration settings'),
  2331. new InputOption('file', 'f', InputOption::VALUE_REQUIRED, 'If you want to choose a different composer.json or config.json'),
  2332. new InputOption('absolute', null, InputOption::VALUE_NONE, 'Returns absolute paths when fetching *-dir config values instead of relative'),
  2333. new InputOption('json', 'j', InputOption::VALUE_NONE, 'JSON decode the setting value, to be used with extra.* keys'),
  2334. new InputOption('merge', 'm', InputOption::VALUE_NONE, 'Merge the setting value with the current value, to be used with extra.* keys in combination with --json'),
  2335. new InputOption('append', null, InputOption::VALUE_NONE, 'When adding a repository, append it (lowest priority) to the existing ones instead of prepending it (highest priority)'),
  2336. new InputOption('source', null, InputOption::VALUE_NONE, 'Display where the config value is loaded from'),
  2337. new InputArgument('setting-key', null, 'Setting key'),
  2338. new InputArgument('setting-value', InputArgument::IS_ARRAY, 'Setting value'),
  2339. ))
  2340. ->setHelp(
  2341. <<<EOT
  2342. This command allows you to edit composer config settings and repositories
  2343. in either the local composer.json file or the global config.json file.
  2344. Additionally it lets you edit most properties in the local composer.json.
  2345. To set a config setting:
  2346. <comment>%command.full_name% bin-dir bin/</comment>
  2347. To read a config setting:
  2348. <comment>%command.full_name% bin-dir</comment>
  2349. Outputs: <info>bin</info>
  2350. To edit the global config.json file:
  2351. <comment>%command.full_name% --global</comment>
  2352. To add a repository:
  2353. <comment>%command.full_name% repositories.foo vcs https://bar.com</comment>
  2354. To remove a repository (repo is a short alias for repositories):
  2355. <comment>%command.full_name% --unset repo.foo</comment>
  2356. To disable packagist:
  2357. <comment>%command.full_name% repo.packagist false</comment>
  2358. You can alter repositories in the global config.json file by passing in the
  2359. <info>--global</info> option.
  2360. To add or edit suggested packages you can use:
  2361. <comment>%command.full_name% suggest.package reason for the suggestion</comment>
  2362. To add or edit extra properties you can use:
  2363. <comment>%command.full_name% extra.property value</comment>
  2364. Or to add a complex value you can use json with:
  2365. <comment>%command.full_name% extra.property --json '{"foo":true, "bar": []}'</comment>
  2366. To edit the file in an external editor:
  2367. <comment>%command.full_name% --editor</comment>
  2368. To choose your editor you can set the "EDITOR" env variable.
  2369. To get a list of configuration values in the file:
  2370. <comment>%command.full_name% --list</comment>
  2371. You can always pass more than one option. As an example, if you want to edit the
  2372. global config.json file.
  2373. <comment>%command.full_name% --editor --global</comment>
  2374. Read more at https://getcomposer.org/doc/03-cli.md#config
  2375. EOT
  2376. )
  2377. ;
  2378. }
  2379. protected function initialize(InputInterface $input, OutputInterface $output): void
  2380. {
  2381. parent::initialize($input, $output);
  2382. if ($input->getOption('global') && null !== $input->getOption('file')) {
  2383. throw new \RuntimeException('--file and --global can not be combined');
  2384. }
  2385. $io = $this->getIO();
  2386. $this->config = Factory::createConfig($io);
  2387. $configFile = $input->getOption('global')
  2388. ? ($this->config->get('home') . '/config.json')
  2389. : ($input->getOption('file') ?: Factory::getComposerFile());
  2390. if (
  2391. ($configFile === 'composer.json' || $configFile === './composer.json')
  2392. && !file_exists($configFile)
  2393. && realpath(Platform::getCwd()) === realpath($this->config->get('home'))
  2394. ) {
  2395. file_put_contents($configFile, "{\n}\n");
  2396. }
  2397. $this->configFile = new JsonFile($configFile, null, $io);
  2398. $this->configSource = new JsonConfigSource($this->configFile);
  2399. $authConfigFile = $input->getOption('global')
  2400. ? ($this->config->get('home') . '/auth.json')
  2401. : dirname($configFile) . '/auth.json';
  2402. $this->authConfigFile = new JsonFile($authConfigFile, null, $io);
  2403. $this->authConfigSource = new JsonConfigSource($this->authConfigFile, true);
  2404. if ($input->getOption('global') && !$this->configFile->exists()) {
  2405. touch($this->configFile->getPath());
  2406. $this->configFile->write(array('config' => new \ArrayObject));
  2407. Silencer::call('chmod', $this->configFile->getPath(), 0600);
  2408. }
  2409. if ($input->getOption('global') && !$this->authConfigFile->exists()) {
  2410. touch($this->authConfigFile->getPath());
  2411. $this->authConfigFile->write(array('bitbucket-oauth' => new \ArrayObject, 'github-oauth' => new \ArrayObject, 'gitlab-oauth' => new \ArrayObject, 'gitlab-token' => new \ArrayObject, 'http-basic' => new \ArrayObject, 'bearer' => new \ArrayObject));
  2412. Silencer::call('chmod', $this->authConfigFile->getPath(), 0600);
  2413. }
  2414. if (!$this->configFile->exists()) {
  2415. throw new \RuntimeException(sprintf('File "%s" cannot be found in the current directory', $configFile));
  2416. }
  2417. }
  2418. protected function execute(InputInterface $input, OutputInterface $output): int
  2419. {
  2420. if (true === $input->getOption('editor')) {
  2421. $editor = escapeshellcmd(Platform::getEnv('EDITOR'));
  2422. if (!$editor) {
  2423. if (Platform::isWindows()) {
  2424. $editor = 'notepad';
  2425. } else {
  2426. foreach (array('editor', 'vim', 'vi', 'nano', 'pico', 'ed') as $candidate) {
  2427. if (exec('which '.$candidate)) {
  2428. $editor = $candidate;
  2429. break;
  2430. }
  2431. }
  2432. }
  2433. }
  2434. $file = $input->getOption('auth') ? $this->authConfigFile->getPath() : $this->configFile->getPath();
  2435. system($editor . ' ' . $file . (Platform::isWindows() ? '' : ' > `tty`'));
  2436. return 0;
  2437. }
  2438. if (false === $input->getOption('global')) {
  2439. $this->config->merge($this->configFile->read(), $this->configFile->getPath());
  2440. $this->config->merge(array('config' => $this->authConfigFile->exists() ? $this->authConfigFile->read() : array()), $this->authConfigFile->getPath());
  2441. }
  2442. if (true === $input->getOption('list')) {
  2443. $this->listConfiguration($this->config->all(), $this->config->raw(), $output, null, $input->getOption('source'));
  2444. return 0;
  2445. }
  2446. $settingKey = $input->getArgument('setting-key');
  2447. if (!is_string($settingKey)) {
  2448. return 0;
  2449. }
  2450. if (array() !== $input->getArgument('setting-value') && $input->getOption('unset')) {
  2451. throw new \RuntimeException('You can not combine a setting value with --unset');
  2452. }
  2453. if (array() === $input->getArgument('setting-value') && !$input->getOption('unset')) {
  2454. $properties = array('name', 'type', 'description', 'homepage', 'version', 'minimum-stability', 'prefer-stable', 'keywords', 'license', 'extra');
  2455. $rawData = $this->configFile->read();
  2456. $data = $this->config->all();
  2457. if (Preg::isMatch('/^repos?(?:itories)?(?:\.(.+))?/', $settingKey, $matches)) {
  2458. if (!isset($matches[1]) || $matches[1] === '') {
  2459. $value = $data['repositories'] ?? array();
  2460. } else {
  2461. if (!isset($data['repositories'][$matches[1]])) {
  2462. throw new \InvalidArgumentException('There is no '.$matches[1].' repository defined');
  2463. }
  2464. $value = $data['repositories'][$matches[1]];
  2465. }
  2466. } elseif (strpos($settingKey, '.')) {
  2467. $bits = explode('.', $settingKey);
  2468. if ($bits[0] === 'extra') {
  2469. $data = $rawData;
  2470. } else {
  2471. $data = $data['config'];
  2472. }
  2473. $match = false;
  2474. foreach ($bits as $bit) {
  2475. $key = isset($key) ? $key.'.'.$bit : $bit;
  2476. $match = false;
  2477. if (isset($data[$key])) {
  2478. $match = true;
  2479. $data = $data[$key];
  2480. unset($key);
  2481. }
  2482. }
  2483. if (!$match) {
  2484. throw new \RuntimeException($settingKey.' is not defined.');
  2485. }
  2486. $value = $data;
  2487. } elseif (isset($data['config'][$settingKey])) {
  2488. $value = $this->config->get($settingKey, $input->getOption('absolute') ? 0 : Config::RELATIVE_PATHS);
  2489. } elseif (isset($rawData[$settingKey]) && in_array($settingKey, $properties, true)) {
  2490. $value = $rawData[$settingKey];
  2491. } else {
  2492. throw new \RuntimeException($settingKey.' is not defined');
  2493. }
  2494. if (is_array($value)) {
  2495. $value = json_encode($value);
  2496. }
  2497. $sourceOfConfigValue = '';
  2498. if ($input->getOption('source')) {
  2499. $sourceOfConfigValue = ' (' . $this->config->getSourceOfValue($settingKey) . ')';
  2500. }
  2501. $this->getIO()->write($value . $sourceOfConfigValue, true, IOInterface::QUIET);
  2502. return 0;
  2503. }
  2504. $values = $input->getArgument('setting-value');
  2505. $booleanValidator = function ($val): bool {
  2506. return in_array($val, array('true', 'false', '1', '0'), true);
  2507. };
  2508. $booleanNormalizer = function ($val): bool {
  2509. return $val !== 'false' && (bool) $val;
  2510. };
  2511. $uniqueConfigValues = array(
  2512. 'process-timeout' => array('is_numeric', 'intval'),
  2513. 'use-include-path' => array($booleanValidator, $booleanNormalizer),
  2514. 'use-github-api' => array($booleanValidator, $booleanNormalizer),
  2515. 'preferred-install' => array(
  2516. function ($val): bool {
  2517. return in_array($val, array('auto', 'source', 'dist'), true);
  2518. },
  2519. function ($val) {
  2520. return $val;
  2521. },
  2522. ),
  2523. 'gitlab-protocol' => array(
  2524. function ($val): bool {
  2525. return in_array($val, array('git', 'http', 'https'), true);
  2526. },
  2527. function ($val) {
  2528. return $val;
  2529. },
  2530. ),
  2531. 'store-auths' => array(
  2532. function ($val): bool {
  2533. return in_array($val, array('true', 'false', 'prompt'), true);
  2534. },
  2535. function ($val) {
  2536. if ('prompt' === $val) {
  2537. return 'prompt';
  2538. }
  2539. return $val !== 'false' && (bool) $val;
  2540. },
  2541. ),
  2542. 'notify-on-install' => array($booleanValidator, $booleanNormalizer),
  2543. 'vendor-dir' => array('is_string', function ($val) {
  2544. return $val;
  2545. }),
  2546. 'bin-dir' => array('is_string', function ($val) {
  2547. return $val;
  2548. }),
  2549. 'archive-dir' => array('is_string', function ($val) {
  2550. return $val;
  2551. }),
  2552. 'archive-format' => array('is_string', function ($val) {
  2553. return $val;
  2554. }),
  2555. 'data-dir' => array('is_string', function ($val) {
  2556. return $val;
  2557. }),
  2558. 'cache-dir' => array('is_string', function ($val) {
  2559. return $val;
  2560. }),
  2561. 'cache-files-dir' => array('is_string', function ($val) {
  2562. return $val;
  2563. }),
  2564. 'cache-repo-dir' => array('is_string', function ($val) {
  2565. return $val;
  2566. }),
  2567. 'cache-vcs-dir' => array('is_string', function ($val) {
  2568. return $val;
  2569. }),
  2570. 'cache-ttl' => array('is_numeric', 'intval'),
  2571. 'cache-files-ttl' => array('is_numeric', 'intval'),
  2572. 'cache-files-maxsize' => array(
  2573. function ($val): bool {
  2574. return Preg::isMatch('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $val);
  2575. },
  2576. function ($val) {
  2577. return $val;
  2578. },
  2579. ),
  2580. 'bin-compat' => array(
  2581. function ($val): bool {
  2582. return in_array($val, array('auto', 'full', 'symlink'));
  2583. },
  2584. function ($val) {
  2585. return $val;
  2586. },
  2587. ),
  2588. 'discard-changes' => array(
  2589. function ($val): bool {
  2590. return in_array($val, array('stash', 'true', 'false', '1', '0'), true);
  2591. },
  2592. function ($val) {
  2593. if ('stash' === $val) {
  2594. return 'stash';
  2595. }
  2596. return $val !== 'false' && (bool) $val;
  2597. },
  2598. ),
  2599. 'autoloader-suffix' => array('is_string', function ($val) {
  2600. return $val === 'null' ? null : $val;
  2601. }),
  2602. 'sort-packages' => array($booleanValidator, $booleanNormalizer),
  2603. 'optimize-autoloader' => array($booleanValidator, $booleanNormalizer),
  2604. 'classmap-authoritative' => array($booleanValidator, $booleanNormalizer),
  2605. 'apcu-autoloader' => array($booleanValidator, $booleanNormalizer),
  2606. 'prepend-autoloader' => array($booleanValidator, $booleanNormalizer),
  2607. 'disable-tls' => array($booleanValidator, $booleanNormalizer),
  2608. 'secure-http' => array($booleanValidator, $booleanNormalizer),
  2609. 'cafile' => array(
  2610. function ($val): bool {
  2611. return file_exists($val) && Filesystem::isReadable($val);
  2612. },
  2613. function ($val) {
  2614. return $val === 'null' ? null : $val;
  2615. },
  2616. ),
  2617. 'capath' => array(
  2618. function ($val): bool {
  2619. return is_dir($val) && Filesystem::isReadable($val);
  2620. },
  2621. function ($val) {
  2622. return $val === 'null' ? null : $val;
  2623. },
  2624. ),
  2625. 'github-expose-hostname' => array($booleanValidator, $booleanNormalizer),
  2626. 'htaccess-protect' => array($booleanValidator, $booleanNormalizer),
  2627. 'lock' => array($booleanValidator, $booleanNormalizer),
  2628. 'allow-plugins' => array($booleanValidator, $booleanNormalizer),
  2629. 'platform-check' => array(
  2630. function ($val): bool {
  2631. return in_array($val, array('php-only', 'true', 'false', '1', '0'), true);
  2632. },
  2633. function ($val) {
  2634. if ('php-only' === $val) {
  2635. return 'php-only';
  2636. }
  2637. return $val !== 'false' && (bool) $val;
  2638. },
  2639. ),
  2640. 'use-parent-dir' => array(
  2641. function ($val): bool {
  2642. return in_array($val, array('true', 'false', 'prompt'), true);
  2643. },
  2644. function ($val) {
  2645. if ('prompt' === $val) {
  2646. return 'prompt';
  2647. }
  2648. return $val !== 'false' && (bool) $val;
  2649. },
  2650. ),
  2651. );
  2652. $multiConfigValues = array(
  2653. 'github-protocols' => array(
  2654. function ($vals) {
  2655. if (!is_array($vals)) {
  2656. return 'array expected';
  2657. }
  2658. foreach ($vals as $val) {
  2659. if (!in_array($val, array('git', 'https', 'ssh'))) {
  2660. return 'valid protocols include: git, https, ssh';
  2661. }
  2662. }
  2663. return true;
  2664. },
  2665. function ($vals) {
  2666. return $vals;
  2667. },
  2668. ),
  2669. 'github-domains' => array(
  2670. function ($vals) {
  2671. if (!is_array($vals)) {
  2672. return 'array expected';
  2673. }
  2674. return true;
  2675. },
  2676. function ($vals) {
  2677. return $vals;
  2678. },
  2679. ),
  2680. 'gitlab-domains' => array(
  2681. function ($vals) {
  2682. if (!is_array($vals)) {
  2683. return 'array expected';
  2684. }
  2685. return true;
  2686. },
  2687. function ($vals) {
  2688. return $vals;
  2689. },
  2690. ),
  2691. );
  2692. if ($input->getOption('unset') && (isset($uniqueConfigValues[$settingKey]) || isset($multiConfigValues[$settingKey]))) {
  2693. if ($settingKey === 'disable-tls' && $this->config->get('disable-tls')) {
  2694. $this->getIO()->writeError('<info>You are now running Composer with SSL/TLS protection enabled.</info>');
  2695. }
  2696. $this->configSource->removeConfigSetting($settingKey);
  2697. return 0;
  2698. }
  2699. if (isset($uniqueConfigValues[$settingKey])) {
  2700. $this->handleSingleValue($settingKey, $uniqueConfigValues[$settingKey], $values, 'addConfigSetting');
  2701. return 0;
  2702. }
  2703. if (isset($multiConfigValues[$settingKey])) {
  2704. $this->handleMultiValue($settingKey, $multiConfigValues[$settingKey], $values, 'addConfigSetting');
  2705. return 0;
  2706. }
  2707. if (Preg::isMatch('/^preferred-install\.(.+)/', $settingKey, $matches)) {
  2708. if ($input->getOption('unset')) {
  2709. $this->configSource->removeConfigSetting($settingKey);
  2710. return 0;
  2711. }
  2712. list($validator) = $uniqueConfigValues['preferred-install'];
  2713. if (!$validator($values[0])) {
  2714. throw new \RuntimeException('Invalid value for '.$settingKey.'. Should be one of: auto, source, or dist');
  2715. }
  2716. $this->configSource->addConfigSetting($settingKey, $values[0]);
  2717. return 0;
  2718. }
  2719. if (Preg::isMatch('{^allow-plugins\.([a-zA-Z0-9/*-]+)}', $settingKey, $matches)) {
  2720. if ($input->getOption('unset')) {
  2721. $this->configSource->removeConfigSetting($settingKey);
  2722. return 0;
  2723. }
  2724. if (true !== $booleanValidator($values[0])) {
  2725. throw new \RuntimeException(sprintf(
  2726. '"%s" is an invalid value',
  2727. $values[0]
  2728. ));
  2729. }
  2730. $normalizedValue = $booleanNormalizer($values[0]);
  2731. $this->configSource->addConfigSetting($settingKey, $normalizedValue);
  2732. return 0;
  2733. }
  2734. $uniqueProps = array(
  2735. 'name' => array('is_string', function ($val) {
  2736. return $val;
  2737. }),
  2738. 'type' => array('is_string', function ($val) {
  2739. return $val;
  2740. }),
  2741. 'description' => array('is_string', function ($val) {
  2742. return $val;
  2743. }),
  2744. 'homepage' => array('is_string', function ($val) {
  2745. return $val;
  2746. }),
  2747. 'version' => array('is_string', function ($val) {
  2748. return $val;
  2749. }),
  2750. 'minimum-stability' => array(
  2751. function ($val): bool {
  2752. return isset(BasePackage::$stabilities[VersionParser::normalizeStability($val)]);
  2753. },
  2754. function ($val): string {
  2755. return VersionParser::normalizeStability($val);
  2756. },
  2757. ),
  2758. 'prefer-stable' => array($booleanValidator, $booleanNormalizer),
  2759. );
  2760. $multiProps = array(
  2761. 'keywords' => array(
  2762. function ($vals) {
  2763. if (!is_array($vals)) {
  2764. return 'array expected';
  2765. }
  2766. return true;
  2767. },
  2768. function ($vals) {
  2769. return $vals;
  2770. },
  2771. ),
  2772. 'license' => array(
  2773. function ($vals) {
  2774. if (!is_array($vals)) {
  2775. return 'array expected';
  2776. }
  2777. return true;
  2778. },
  2779. function ($vals) {
  2780. return $vals;
  2781. },
  2782. ),
  2783. );
  2784. if ($input->getOption('global') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]) || strpos($settingKey, 'extra.') === 0)) {
  2785. 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');
  2786. }
  2787. if ($input->getOption('unset') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]))) {
  2788. $this->configSource->removeProperty($settingKey);
  2789. return 0;
  2790. }
  2791. if (isset($uniqueProps[$settingKey])) {
  2792. $this->handleSingleValue($settingKey, $uniqueProps[$settingKey], $values, 'addProperty');
  2793. return 0;
  2794. }
  2795. if (isset($multiProps[$settingKey])) {
  2796. $this->handleMultiValue($settingKey, $multiProps[$settingKey], $values, 'addProperty');
  2797. return 0;
  2798. }
  2799. if (Preg::isMatch('/^repos?(?:itories)?\.(.+)/', $settingKey, $matches)) {
  2800. if ($input->getOption('unset')) {
  2801. $this->configSource->removeRepository($matches[1]);
  2802. return 0;
  2803. }
  2804. if (2 === count($values)) {
  2805. $this->configSource->addRepository($matches[1], array(
  2806. 'type' => $values[0],
  2807. 'url' => $values[1],
  2808. ), $input->getOption('append'));
  2809. return 0;
  2810. }
  2811. if (1 === count($values)) {
  2812. $value = strtolower($values[0]);
  2813. if (true === $booleanValidator($value)) {
  2814. if (false === $booleanNormalizer($value)) {
  2815. $this->configSource->addRepository($matches[1], false, $input->getOption('append'));
  2816. return 0;
  2817. }
  2818. } else {
  2819. $value = JsonFile::parseJson($values[0]);
  2820. $this->configSource->addRepository($matches[1], $value, $input->getOption('append'));
  2821. return 0;
  2822. }
  2823. }
  2824. throw new \RuntimeException('You must pass the type and a url. Example: php composer.phar config repositories.foo vcs https://bar.com');
  2825. }
  2826. if (Preg::isMatch('/^extra\.(.+)/', $settingKey, $matches)) {
  2827. if ($input->getOption('unset')) {
  2828. $this->configSource->removeProperty($settingKey);
  2829. return 0;
  2830. }
  2831. $value = $values[0];
  2832. if ($input->getOption('json')) {
  2833. $value = JsonFile::parseJson($value);
  2834. if ($input->getOption('merge')) {
  2835. $currentValue = $this->configFile->read();
  2836. $bits = explode('.', $settingKey);
  2837. foreach ($bits as $bit) {
  2838. $currentValue = $currentValue[$bit] ?? null;
  2839. }
  2840. if (is_array($currentValue)) {
  2841. $value = array_merge($currentValue, $value);
  2842. }
  2843. }
  2844. }
  2845. $this->configSource->addProperty($settingKey, $value);
  2846. return 0;
  2847. }
  2848. if (Preg::isMatch('/^suggest\.(.+)/', $settingKey, $matches)) {
  2849. if ($input->getOption('unset')) {
  2850. $this->configSource->removeProperty($settingKey);
  2851. return 0;
  2852. }
  2853. $this->configSource->addProperty($settingKey, implode(' ', $values));
  2854. return 0;
  2855. }
  2856. if (in_array($settingKey, array('suggest', 'extra'), true) && $input->getOption('unset')) {
  2857. $this->configSource->removeProperty($settingKey);
  2858. return 0;
  2859. }
  2860. if (Preg::isMatch('/^platform\.(.+)/', $settingKey, $matches)) {
  2861. if ($input->getOption('unset')) {
  2862. $this->configSource->removeConfigSetting($settingKey);
  2863. return 0;
  2864. }
  2865. $this->configSource->addConfigSetting($settingKey, $values[0] === 'false' ? false : $values[0]);
  2866. return 0;
  2867. }
  2868. if ($settingKey === 'platform' && $input->getOption('unset')) {
  2869. $this->configSource->removeConfigSetting($settingKey);
  2870. return 0;
  2871. }
  2872. if (Preg::isMatch('/^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|http-basic|bearer)\.(.+)/', $settingKey, $matches)) {
  2873. if ($input->getOption('unset')) {
  2874. $this->authConfigSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2875. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2876. return 0;
  2877. }
  2878. if ($matches[1] === 'bitbucket-oauth') {
  2879. if (2 !== count($values)) {
  2880. throw new \RuntimeException('Expected two arguments (consumer-key, consumer-secret), got '.count($values));
  2881. }
  2882. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2883. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('consumer-key' => $values[0], 'consumer-secret' => $values[1]));
  2884. } elseif ($matches[1] === 'gitlab-token' && 2 === count($values)) {
  2885. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2886. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('username' => $values[0], 'token' => $values[1]));
  2887. } elseif (in_array($matches[1], array('github-oauth', 'gitlab-oauth', 'gitlab-token', 'bearer'), true)) {
  2888. if (1 !== count($values)) {
  2889. throw new \RuntimeException('Too many arguments, expected only one token');
  2890. }
  2891. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2892. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], $values[0]);
  2893. } elseif ($matches[1] === 'http-basic') {
  2894. if (2 !== count($values)) {
  2895. throw new \RuntimeException('Expected two arguments (username, password), got '.count($values));
  2896. }
  2897. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2898. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('username' => $values[0], 'password' => $values[1]));
  2899. }
  2900. return 0;
  2901. }
  2902. if (Preg::isMatch('/^scripts\.(.+)/', $settingKey, $matches)) {
  2903. if ($input->getOption('unset')) {
  2904. $this->configSource->removeProperty($settingKey);
  2905. return 0;
  2906. }
  2907. $this->configSource->addProperty($settingKey, count($values) > 1 ? $values : $values[0]);
  2908. return 0;
  2909. }
  2910. throw new \InvalidArgumentException('Setting '.$settingKey.' does not exist or is not supported by this command');
  2911. }
  2912. protected function handleSingleValue(string $key, array $callbacks, array $values, string $method): void
  2913. {
  2914. list($validator, $normalizer) = $callbacks;
  2915. if (1 !== count($values)) {
  2916. throw new \RuntimeException('You can only pass one value. Example: php composer.phar config process-timeout 300');
  2917. }
  2918. if (true !== $validation = $validator($values[0])) {
  2919. throw new \RuntimeException(sprintf(
  2920. '"%s" is an invalid value'.($validation ? ' ('.$validation.')' : ''),
  2921. $values[0]
  2922. ));
  2923. }
  2924. $normalizedValue = $normalizer($values[0]);
  2925. if ($key === 'disable-tls') {
  2926. if (!$normalizedValue && $this->config->get('disable-tls')) {
  2927. $this->getIO()->writeError('<info>You are now running Composer with SSL/TLS protection enabled.</info>');
  2928. } elseif ($normalizedValue && !$this->config->get('disable-tls')) {
  2929. $this->getIO()->writeError('<warning>You are now running Composer with SSL/TLS protection disabled.</warning>');
  2930. }
  2931. }
  2932. call_user_func(array($this->configSource, $method), $key, $normalizedValue);
  2933. }
  2934. protected function handleMultiValue(string $key, array $callbacks, array $values, string $method): void
  2935. {
  2936. list($validator, $normalizer) = $callbacks;
  2937. if (true !== $validation = $validator($values)) {
  2938. throw new \RuntimeException(sprintf(
  2939. '%s is an invalid value'.($validation ? ' ('.$validation.')' : ''),
  2940. json_encode($values)
  2941. ));
  2942. }
  2943. call_user_func(array($this->configSource, $method), $key, $normalizer($values));
  2944. }
  2945. protected function listConfiguration(array $contents, array $rawContents, OutputInterface $output, ?string $k = null, bool $showSource = false): void
  2946. {
  2947. $origK = $k;
  2948. $io = $this->getIO();
  2949. foreach ($contents as $key => $value) {
  2950. if ($k === null && !in_array($key, array('config', 'repositories'))) {
  2951. continue;
  2952. }
  2953. $rawVal = $rawContents[$key] ?? null;
  2954. if (is_array($value) && (!is_numeric(key($value)) || ($key === 'repositories' && null === $k))) {
  2955. $k .= Preg::replace('{^config\.}', '', $key . '.');
  2956. $this->listConfiguration($value, $rawVal, $output, $k, $showSource);
  2957. $k = $origK;
  2958. continue;
  2959. }
  2960. if (is_array($value)) {
  2961. $value = array_map(function ($val) {
  2962. return is_array($val) ? json_encode($val) : $val;
  2963. }, $value);
  2964. $value = '['.implode(', ', $value).']';
  2965. }
  2966. if (is_bool($value)) {
  2967. $value = var_export($value, true);
  2968. }
  2969. $source = '';
  2970. if ($showSource) {
  2971. $source = ' (' . $this->config->getSourceOfValue($k . $key) . ')';
  2972. }
  2973. if (null !== $k && 0 === strpos($k, 'repositories')) {
  2974. $link = 'https://getcomposer.org/doc/05-repositories.md';
  2975. } else {
  2976. $id = Preg::replace('{\..*$}', '', $k === '' || $k === null ? (string) $key : $k);
  2977. $id = Preg::replace('{[^a-z0-9]}i', '-', strtolower(trim($id)));
  2978. $id = Preg::replace('{-+}', '-', $id);
  2979. $link = 'https://getcomposer.org/doc/06-config.md#' . $id;
  2980. }
  2981. if (is_string($rawVal) && $rawVal != $value) {
  2982. $io->write('[<fg=yellow;href=' . $link .'>' . $k . $key . '</>] <info>' . $rawVal . ' (' . $value . ')</info>' . $source, true, IOInterface::QUIET);
  2983. } else {
  2984. $io->write('[<fg=yellow;href=' . $link .'>' . $k . $key . '</>] <info>' . $value . '</info>' . $source, true, IOInterface::QUIET);
  2985. }
  2986. }
  2987. }
  2988. }
  2989. <?php declare(strict_types=1);
  2990. namespace Composer\Command;
  2991. use Composer\Config;
  2992. use Composer\Factory;
  2993. use Composer\Filter\PlatformRequirementFilter\IgnoreAllPlatformRequirementFilter;
  2994. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  2995. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  2996. use Composer\Installer;
  2997. use Composer\Installer\ProjectInstaller;
  2998. use Composer\Installer\SuggestedPackagesReporter;
  2999. use Composer\IO\IOInterface;
  3000. use Composer\Package\BasePackage;
  3001. use Composer\DependencyResolver\Operation\InstallOperation;
  3002. use Composer\Package\Version\VersionSelector;
  3003. use Composer\Package\AliasPackage;
  3004. use Composer\Pcre\Preg;
  3005. use Composer\Repository\RepositoryFactory;
  3006. use Composer\Repository\CompositeRepository;
  3007. use Composer\Repository\PlatformRepository;
  3008. use Composer\Repository\InstalledArrayRepository;
  3009. use Composer\Repository\RepositorySet;
  3010. use Composer\Script\ScriptEvents;
  3011. use Composer\Util\Silencer;
  3012. use Symfony\Component\Console\Input\InputArgument;
  3013. use Symfony\Component\Console\Input\InputInterface;
  3014. use Symfony\Component\Console\Input\InputOption;
  3015. use Symfony\Component\Console\Output\OutputInterface;
  3016. use Symfony\Component\Finder\Finder;
  3017. use Composer\Json\JsonFile;
  3018. use Composer\Config\JsonConfigSource;
  3019. use Composer\Util\Filesystem;
  3020. use Composer\Util\Platform;
  3021. use Composer\Util\ProcessExecutor;
  3022. use Composer\Package\Version\VersionParser;
  3023. class CreateProjectCommand extends BaseCommand
  3024. {
  3025. protected $suggestedPackagesReporter;
  3026. protected function configure(): void
  3027. {
  3028. $this
  3029. ->setName('create-project')
  3030. ->setDescription('Creates new project from a package into given directory.')
  3031. ->setDefinition(array(
  3032. new InputArgument('package', InputArgument::OPTIONAL, 'Package name to be installed'),
  3033. new InputArgument('directory', InputArgument::OPTIONAL, 'Directory where the files should be created'),
  3034. new InputArgument('version', InputArgument::OPTIONAL, 'Version, will default to latest'),
  3035. new InputOption('stability', 's', InputOption::VALUE_REQUIRED, 'Minimum-stability allowed (unless a version is specified).'),
  3036. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  3037. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
  3038. new InputOption('prefer-install', null, InputOption::VALUE_REQUIRED, 'Forces installation from package dist|source|auto (auto chooses source for dev versions, dist for the rest).'),
  3039. new InputOption('repository', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Add custom repositories to look the package up, either by URL or using JSON arrays'),
  3040. new InputOption('repository-url', null, InputOption::VALUE_REQUIRED, 'DEPRECATED: Use --repository instead.'),
  3041. new InputOption('add-repository', null, InputOption::VALUE_NONE, 'Add the custom repository in the composer.json. If a lock file is present it will be deleted and an update will be run instead of install.'),
  3042. new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of require-dev packages (enabled by default, only present for BC).'),
  3043. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  3044. new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'DEPRECATED: Use no-plugins instead.'),
  3045. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Whether to prevent execution of all defined scripts in the root package.'),
  3046. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  3047. 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.'),
  3048. new InputOption('keep-vcs', null, InputOption::VALUE_NONE, 'Whether to prevent deleting the vcs folder.'),
  3049. new InputOption('remove-vcs', null, InputOption::VALUE_NONE, 'Whether to force deletion of the vcs folder without prompting.'),
  3050. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Whether to skip installation of the package dependencies.'),
  3051. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  3052. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  3053. new InputOption('ask', null, InputOption::VALUE_NONE, 'Whether to ask for project directory.'),
  3054. ))
  3055. ->setHelp(
  3056. <<<EOT
  3057. The <info>create-project</info> command creates a new project from a given
  3058. package into a new directory. If executed without params and in a directory
  3059. with a composer.json file it installs the packages for the current project.
  3060. You can use this command to bootstrap new projects or setup a clean
  3061. version-controlled installation for developers of your project.
  3062. <info>php composer.phar create-project vendor/project target-directory [version]</info>
  3063. You can also specify the version with the package name using = or : as separator.
  3064. <info>php composer.phar create-project vendor/project:version target-directory</info>
  3065. To install unstable packages, either specify the version you want, or use the
  3066. --stability=dev (where dev can be one of RC, beta, alpha or dev).
  3067. To setup a developer workable version you should create the project using the source
  3068. controlled code by appending the <info>'--prefer-source'</info> flag.
  3069. To install a package from another repository than the default one you
  3070. can pass the <info>'--repository=https://myrepository.org'</info> flag.
  3071. Read more at https://getcomposer.org/doc/03-cli.md#create-project
  3072. EOT
  3073. )
  3074. ;
  3075. }
  3076. protected function execute(InputInterface $input, OutputInterface $output): int
  3077. {
  3078. $config = Factory::createConfig();
  3079. $io = $this->getIO();
  3080. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input, true);
  3081. if ($input->getOption('dev')) {
  3082. $io->writeError('<warning>You are using the deprecated option "dev". Dev packages are installed by default now.</warning>');
  3083. }
  3084. if ($input->getOption('no-custom-installers')) {
  3085. $io->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
  3086. $input->setOption('no-plugins', true);
  3087. }
  3088. if ($input->isInteractive() && $input->getOption('ask')) {
  3089. $package = $input->getArgument('package');
  3090. if (null === $package) {
  3091. throw new \RuntimeException('Not enough arguments (missing: "package").');
  3092. }
  3093. $parts = explode("/", strtolower($package), 2);
  3094. $input->setArgument('directory', $io->ask('New project directory [<comment>'.array_pop($parts).'</comment>]: '));
  3095. }
  3096. return $this->installProject(
  3097. $io,
  3098. $config,
  3099. $input,
  3100. $input->getArgument('package'),
  3101. $input->getArgument('directory'),
  3102. $input->getArgument('version'),
  3103. $input->getOption('stability'),
  3104. $preferSource,
  3105. $preferDist,
  3106. !$input->getOption('no-dev'),
  3107. $input->getOption('repository') ?: $input->getOption('repository-url'),
  3108. $input->getOption('no-plugins'),
  3109. $input->getOption('no-scripts'),
  3110. $input->getOption('no-progress'),
  3111. $input->getOption('no-install'),
  3112. $this->getPlatformRequirementFilter($input),
  3113. !$input->getOption('no-secure-http'),
  3114. $input->getOption('add-repository')
  3115. );
  3116. }
  3117. public function installProject(IOInterface $io, Config $config, InputInterface $input, ?string $packageName = null, ?string $directory = null, ?string $packageVersion = null, ?string $stability = 'stable', bool $preferSource = false, bool $preferDist = false, bool $installDevPackages = false, $repositories = null, bool $disablePlugins = false, bool $disableScripts = false, bool $noProgress = false, bool $noInstall = false, PlatformRequirementFilterInterface $platformRequirementFilter = null, bool $secureHttp = true, bool $addRepository = false): int
  3118. {
  3119. $oldCwd = Platform::getCwd();
  3120. if ($repositories !== null && !is_array($repositories)) {
  3121. $repositories = (array) $repositories;
  3122. }
  3123. $platformRequirementFilter = $platformRequirementFilter ?: PlatformRequirementFilterFactory::ignoreNothing();
  3124. $io->loadConfiguration($config);
  3125. $this->suggestedPackagesReporter = new SuggestedPackagesReporter($io);
  3126. if ($packageName !== null) {
  3127. $installedFromVcs = $this->installRootPackage($io, $config, $packageName, $platformRequirementFilter, $directory, $packageVersion, $stability, $preferSource, $preferDist, $installDevPackages, $repositories, $disablePlugins, $disableScripts, $noProgress, $secureHttp);
  3128. } else {
  3129. $installedFromVcs = false;
  3130. }
  3131. if ($repositories !== null && $addRepository && is_file('composer.lock')) {
  3132. unlink('composer.lock');
  3133. }
  3134. $composer = Factory::create($io, null, $disablePlugins, $disableScripts);
  3135. if ($repositories !== null && $addRepository) {
  3136. foreach ($repositories as $index => $repo) {
  3137. $repoConfig = RepositoryFactory::configFromString($io, $composer->getConfig(), $repo, true);
  3138. $composerJsonRepositoriesConfig = $composer->getConfig()->getRepositories();
  3139. $name = RepositoryFactory::generateRepositoryName($index, $repoConfig, $composerJsonRepositoriesConfig);
  3140. $configSource = new JsonConfigSource(new JsonFile('composer.json'));
  3141. if (
  3142. (isset($repoConfig['packagist']) && $repoConfig === array('packagist' => false))
  3143. || (isset($repoConfig['packagist.org']) && $repoConfig === array('packagist.org' => false))
  3144. ) {
  3145. $configSource->addRepository('packagist.org', false);
  3146. } else {
  3147. $configSource->addRepository($name, $repoConfig, false);
  3148. }
  3149. $composer = Factory::create($io, null, $disablePlugins);
  3150. }
  3151. }
  3152. $process = $composer->getLoop()->getProcessExecutor();
  3153. $fs = new Filesystem($process);
  3154. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ROOT_PACKAGE_INSTALL, $installDevPackages);
  3155. $config = $composer->getConfig();
  3156. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  3157. if ($noInstall === false) {
  3158. $composer->getInstallationManager()->setOutputProgress(!$noProgress);
  3159. $installer = Installer::create($io, $composer);
  3160. $installer->setPreferSource($preferSource)
  3161. ->setPreferDist($preferDist)
  3162. ->setDevMode($installDevPackages)
  3163. ->setPlatformRequirementFilter($platformRequirementFilter)
  3164. ->setSuggestedPackagesReporter($this->suggestedPackagesReporter)
  3165. ->setOptimizeAutoloader($config->get('optimize-autoloader'))
  3166. ->setClassMapAuthoritative($config->get('classmap-authoritative'))
  3167. ->setApcuAutoloader($config->get('apcu-autoloader'));
  3168. if (!$composer->getLocker()->isLocked()) {
  3169. $installer->setUpdate(true);
  3170. }
  3171. if ($disablePlugins) {
  3172. $installer->disablePlugins();
  3173. }
  3174. $status = $installer->run();
  3175. if (0 !== $status) {
  3176. return $status;
  3177. }
  3178. }
  3179. $hasVcs = $installedFromVcs;
  3180. if (
  3181. !$input->getOption('keep-vcs')
  3182. && $installedFromVcs
  3183. && (
  3184. $input->getOption('remove-vcs')
  3185. || !$io->isInteractive()
  3186. || $io->askConfirmation('<info>Do you want to remove the existing VCS (.git, .svn..) history?</info> [<comment>Y,n</comment>]? ')
  3187. )
  3188. ) {
  3189. $finder = new Finder();
  3190. $finder->depth(0)->directories()->in(Platform::getCwd())->ignoreVCS(false)->ignoreDotFiles(false);
  3191. foreach (array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg', '.fslckout', '_FOSSIL_') as $vcsName) {
  3192. $finder->name($vcsName);
  3193. }
  3194. try {
  3195. $dirs = iterator_to_array($finder);
  3196. unset($finder);
  3197. foreach ($dirs as $dir) {
  3198. if (!$fs->removeDirectory((string) $dir)) {
  3199. throw new \RuntimeException('Could not remove '.$dir);
  3200. }
  3201. }
  3202. } catch (\Exception $e) {
  3203. $io->writeError('<error>An error occurred while removing the VCS metadata: '.$e->getMessage().'</error>');
  3204. }
  3205. $hasVcs = false;
  3206. }
  3207. if (!$hasVcs) {
  3208. $package = $composer->getPackage();
  3209. $configSource = new JsonConfigSource(new JsonFile('composer.json'));
  3210. foreach (BasePackage::$supportedLinkTypes as $type => $meta) {
  3211. foreach ($package->{'get'.$meta['method']}() as $link) {
  3212. if ($link->getPrettyConstraint() === 'self.version') {
  3213. $configSource->addLink($type, $link->getTarget(), $package->getPrettyVersion());
  3214. }
  3215. }
  3216. }
  3217. }
  3218. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_CREATE_PROJECT_CMD, $installDevPackages);
  3219. chdir($oldCwd);
  3220. $vendorComposerDir = $config->get('vendor-dir').'/composer';
  3221. if (is_dir($vendorComposerDir) && $fs->isDirEmpty($vendorComposerDir)) {
  3222. Silencer::call('rmdir', $vendorComposerDir);
  3223. $vendorDir = $config->get('vendor-dir');
  3224. if (is_dir($vendorDir) && $fs->isDirEmpty($vendorDir)) {
  3225. Silencer::call('rmdir', $vendorDir);
  3226. }
  3227. }
  3228. return 0;
  3229. }
  3230. protected function installRootPackage(IOInterface $io, Config $config, string $packageName, PlatformRequirementFilterInterface $platformRequirementFilter, ?string $directory = null, ?string $packageVersion = null, ?string $stability = 'stable', bool $preferSource = false, bool $preferDist = false, bool $installDevPackages = false, array $repositories = null, bool $disablePlugins = false, bool $disableScripts = false, bool $noProgress = false, bool $secureHttp = true): bool
  3231. {
  3232. if (!$secureHttp) {
  3233. $config->merge(array('config' => array('secure-http' => false)), Config::SOURCE_COMMAND);
  3234. }
  3235. $parser = new VersionParser();
  3236. $requirements = $parser->parseNameVersionPairs(array($packageName));
  3237. $name = strtolower($requirements[0]['name']);
  3238. if (!$packageVersion && isset($requirements[0]['version'])) {
  3239. $packageVersion = $requirements[0]['version'];
  3240. }
  3241. if (null === $directory) {
  3242. $parts = explode("/", $name, 2);
  3243. $directory = Platform::getCwd() . DIRECTORY_SEPARATOR . array_pop($parts);
  3244. }
  3245. $process = new ProcessExecutor($io);
  3246. $fs = new Filesystem($process);
  3247. if (!$fs->isAbsolutePath($directory)) {
  3248. $directory = Platform::getCwd() . DIRECTORY_SEPARATOR . $directory;
  3249. }
  3250. $io->writeError('<info>Creating a "' . $packageName . '" project at "' . $fs->findShortestPath(Platform::getCwd(), $directory, true) . '"</info>');
  3251. if (file_exists($directory)) {
  3252. if (!is_dir($directory)) {
  3253. throw new \InvalidArgumentException('Cannot create project directory at "'.$directory.'", it exists as a file.');
  3254. }
  3255. if (!$fs->isDirEmpty($directory)) {
  3256. throw new \InvalidArgumentException('Project directory "'.$directory.'" is not empty.');
  3257. }
  3258. }
  3259. if (null === $stability) {
  3260. if (null === $packageVersion) {
  3261. $stability = 'stable';
  3262. } elseif (Preg::isMatch('{^[^,\s]*?@('.implode('|', array_keys(BasePackage::$stabilities)).')$}i', $packageVersion, $match)) {
  3263. $stability = $match[1];
  3264. } else {
  3265. $stability = VersionParser::parseStability($packageVersion);
  3266. }
  3267. }
  3268. $stability = VersionParser::normalizeStability($stability);
  3269. if (!isset(BasePackage::$stabilities[$stability])) {
  3270. throw new \InvalidArgumentException('Invalid stability provided ('.$stability.'), must be one of: '.implode(', ', array_keys(BasePackage::$stabilities)));
  3271. }
  3272. $composer = Factory::create($io, $config->all(), $disablePlugins);
  3273. $config = $composer->getConfig();
  3274. $rm = $composer->getRepositoryManager();
  3275. $repositorySet = new RepositorySet($stability);
  3276. if (null === $repositories) {
  3277. $repositorySet->addRepository(new CompositeRepository(RepositoryFactory::defaultRepos($io, $config, $rm)));
  3278. } else {
  3279. foreach ($repositories as $repo) {
  3280. $repoConfig = RepositoryFactory::configFromString($io, $config, $repo, true);
  3281. if (
  3282. (isset($repoConfig['packagist']) && $repoConfig === array('packagist' => false))
  3283. || (isset($repoConfig['packagist.org']) && $repoConfig === array('packagist.org' => false))
  3284. ) {
  3285. continue;
  3286. }
  3287. $repositorySet->addRepository(RepositoryFactory::createRepo($io, $config, $repoConfig, $rm));
  3288. }
  3289. }
  3290. $platformOverrides = $config->get('platform') ?: array();
  3291. $platformRepo = new PlatformRepository(array(), $platformOverrides);
  3292. $versionSelector = new VersionSelector($repositorySet, $platformRepo);
  3293. $package = $versionSelector->findBestCandidate($name, $packageVersion, $stability, $platformRequirementFilter);
  3294. if (!$package) {
  3295. $errorMessage = "Could not find package $name with " . ($packageVersion ? "version $packageVersion" : "stability $stability");
  3296. if (!($platformRequirementFilter instanceof IgnoreAllPlatformRequirementFilter) && $versionSelector->findBestCandidate($name, $packageVersion, $stability, PlatformRequirementFilterFactory::ignoreAll())) {
  3297. throw new \InvalidArgumentException($errorMessage .' in a version installable using your PHP version, PHP extensions and Composer version.');
  3298. }
  3299. throw new \InvalidArgumentException($errorMessage .'.');
  3300. }
  3301. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  3302. @mkdir($directory, 0777, true);
  3303. if ($realDir = realpath($directory)) {
  3304. pcntl_async_signals(true);
  3305. pcntl_signal(SIGINT, function () use ($realDir): void {
  3306. $fs = new Filesystem();
  3307. $fs->removeDirectory($realDir);
  3308. exit(130);
  3309. });
  3310. }
  3311. }
  3312. if (function_exists('sapi_windows_set_ctrl_handler') && PHP_SAPI === 'cli') {
  3313. @mkdir($directory, 0777, true);
  3314. if ($realDir = realpath($directory)) {
  3315. sapi_windows_set_ctrl_handler(function () use ($realDir): void {
  3316. $fs = new Filesystem();
  3317. $fs->removeDirectory($realDir);
  3318. exit(130);
  3319. });
  3320. }
  3321. }
  3322. if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  3323. $package = $package->getAliasOf();
  3324. }
  3325. $io->writeError('<info>Installing ' . $package->getName() . ' (' . $package->getFullPrettyVersion(false) . ')</info>');
  3326. if ($disablePlugins) {
  3327. $io->writeError('<info>Plugins have been disabled.</info>');
  3328. }
  3329. if ($package instanceof AliasPackage) {
  3330. $package = $package->getAliasOf();
  3331. }
  3332. $dm = $composer->getDownloadManager();
  3333. $dm->setPreferSource($preferSource)
  3334. ->setPreferDist($preferDist);
  3335. $projectInstaller = new ProjectInstaller($directory, $dm, $fs);
  3336. $im = $composer->getInstallationManager();
  3337. $im->setOutputProgress(!$noProgress);
  3338. $im->addInstaller($projectInstaller);
  3339. $im->execute(new InstalledArrayRepository(), array(new InstallOperation($package)));
  3340. $im->notifyInstalls($io);
  3341. $this->suggestedPackagesReporter->addSuggestionsFromPackage($package);
  3342. $installedFromVcs = 'source' === $package->getInstallationSource();
  3343. $io->writeError('<info>Created project in ' . $directory . '</info>');
  3344. chdir($directory);
  3345. Platform::putEnv('COMPOSER_ROOT_VERSION', $package->getPrettyVersion());
  3346. return $installedFromVcs;
  3347. }
  3348. }
  3349. <?php declare(strict_types=1);
  3350. namespace Composer\Command;
  3351. use Symfony\Component\Console\Input\InputInterface;
  3352. use Symfony\Component\Console\Output\OutputInterface;
  3353. use Symfony\Component\Console\Input\InputArgument;
  3354. use Symfony\Component\Console\Input\InputOption;
  3355. class DependsCommand extends BaseDependencyCommand
  3356. {
  3357. protected function configure(): void
  3358. {
  3359. $this
  3360. ->setName('depends')
  3361. ->setAliases(array('why'))
  3362. ->setDescription('Shows which packages cause the given package to be installed.')
  3363. ->setDefinition(array(
  3364. new InputArgument(self::ARGUMENT_PACKAGE, InputArgument::REQUIRED, 'Package to inspect'),
  3365. new InputOption(self::OPTION_RECURSIVE, 'r', InputOption::VALUE_NONE, 'Recursively resolves up to the root package'),
  3366. new InputOption(self::OPTION_TREE, 't', InputOption::VALUE_NONE, 'Prints the results as a nested tree'),
  3367. ))
  3368. ->setHelp(
  3369. <<<EOT
  3370. Displays detailed information about where a package is referenced.
  3371. <info>php composer.phar depends composer/composer</info>
  3372. Read more at https://getcomposer.org/doc/03-cli.md#depends-why-
  3373. EOT
  3374. )
  3375. ;
  3376. }
  3377. protected function execute(InputInterface $input, OutputInterface $output): int
  3378. {
  3379. return parent::doExecute($input, $output);
  3380. }
  3381. }
  3382. <?php declare(strict_types=1);
  3383. namespace Composer\Command;
  3384. use Composer\Composer;
  3385. use Composer\Factory;
  3386. use Composer\Config;
  3387. use Composer\Downloader\TransportException;
  3388. use Composer\Pcre\Preg;
  3389. use Composer\Repository\PlatformRepository;
  3390. use Composer\Plugin\CommandEvent;
  3391. use Composer\Plugin\PluginEvents;
  3392. use Composer\Util\ConfigValidator;
  3393. use Composer\Util\IniHelper;
  3394. use Composer\Util\ProcessExecutor;
  3395. use Composer\Util\HttpDownloader;
  3396. use Composer\Util\StreamContextFactory;
  3397. use Composer\Util\Platform;
  3398. use Composer\SelfUpdate\Keys;
  3399. use Composer\SelfUpdate\Versions;
  3400. use Composer\IO\NullIO;
  3401. use Composer\Package\CompletePackageInterface;
  3402. use Composer\XdebugHandler\XdebugHandler;
  3403. use Symfony\Component\Console\Input\InputInterface;
  3404. use Symfony\Component\Console\Output\OutputInterface;
  3405. use Symfony\Component\Process\ExecutableFinder;
  3406. class DiagnoseCommand extends BaseCommand
  3407. {
  3408. protected $httpDownloader;
  3409. protected $process;
  3410. protected $exitCode = 0;
  3411. protected function configure(): void
  3412. {
  3413. $this
  3414. ->setName('diagnose')
  3415. ->setDescription('Diagnoses the system to identify common errors.')
  3416. ->setHelp(
  3417. <<<EOT
  3418. The <info>diagnose</info> command checks common errors to help debugging problems.
  3419. The process exit code will be 1 in case of warnings and 2 for errors.
  3420. Read more at https://getcomposer.org/doc/03-cli.md#diagnose
  3421. EOT
  3422. )
  3423. ;
  3424. }
  3425. protected function execute(InputInterface $input, OutputInterface $output)
  3426. {
  3427. $composer = $this->tryComposer();
  3428. $io = $this->getIO();
  3429. if ($composer) {
  3430. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'diagnose', $input, $output);
  3431. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  3432. $io->write('Checking composer.json: ', false);
  3433. $this->outputResult($this->checkComposerSchema());
  3434. $this->process = $composer->getLoop()->getProcessExecutor() ?? new ProcessExecutor($io);
  3435. } else {
  3436. $this->process = new ProcessExecutor($io);
  3437. }
  3438. if ($composer) {
  3439. $config = $composer->getConfig();
  3440. } else {
  3441. $config = Factory::createConfig();
  3442. }
  3443. $config->merge(array('config' => array('secure-http' => false)), Config::SOURCE_COMMAND);
  3444. $config->prohibitUrlByConfig('http://repo.packagist.org', new NullIO);
  3445. $this->httpDownloader = Factory::createHttpDownloader($io, $config);
  3446. $io->write('Checking platform settings: ', false);
  3447. $this->outputResult($this->checkPlatform());
  3448. $io->write('Checking git settings: ', false);
  3449. $this->outputResult($this->checkGit());
  3450. $io->write('Checking http connectivity to packagist: ', false);
  3451. $this->outputResult($this->checkHttp('http', $config));
  3452. $io->write('Checking https connectivity to packagist: ', false);
  3453. $this->outputResult($this->checkHttp('https', $config));
  3454. $opts = stream_context_get_options(StreamContextFactory::getContext('http://example.org'));
  3455. if (!empty($opts['http']['proxy'])) {
  3456. $io->write('Checking HTTP proxy: ', false);
  3457. $this->outputResult($this->checkHttpProxy());
  3458. }
  3459. if ($oauth = $config->get('github-oauth')) {
  3460. foreach ($oauth as $domain => $token) {
  3461. $io->write('Checking '.$domain.' oauth access: ', false);
  3462. $this->outputResult($this->checkGithubOauth($domain, $token));
  3463. }
  3464. } else {
  3465. $io->write('Checking github.com rate limit: ', false);
  3466. try {
  3467. $rate = $this->getGithubRateLimit('github.com');
  3468. if (!is_array($rate)) {
  3469. $this->outputResult($rate);
  3470. } elseif (10 > $rate['remaining']) {
  3471. $io->write('<warning>WARNING</warning>');
  3472. $io->write(sprintf(
  3473. '<comment>Github has a rate limit on their API. '
  3474. . 'You currently have <options=bold>%u</options=bold> '
  3475. . 'out of <options=bold>%u</options=bold> requests left.' . PHP_EOL
  3476. . 'See https://developer.github.com/v3/#rate-limiting and also' . PHP_EOL
  3477. . ' https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens</comment>',
  3478. $rate['remaining'],
  3479. $rate['limit']
  3480. ));
  3481. } else {
  3482. $this->outputResult(true);
  3483. }
  3484. } catch (\Exception $e) {
  3485. if ($e instanceof TransportException && $e->getCode() === 401) {
  3486. $this->outputResult('<comment>The oauth token for github.com seems invalid, run "composer config --global --unset github-oauth.github.com" to remove it</comment>');
  3487. } else {
  3488. $this->outputResult($e);
  3489. }
  3490. }
  3491. }
  3492. $io->write('Checking disk free space: ', false);
  3493. $this->outputResult($this->checkDiskSpace($config));
  3494. if (strpos(__FILE__, 'phar:') === 0) {
  3495. $io->write('Checking pubkeys: ', false);
  3496. $this->outputResult($this->checkPubKeys($config));
  3497. $io->write('Checking composer version: ', false);
  3498. $this->outputResult($this->checkVersion($config));
  3499. }
  3500. $io->write(sprintf('Composer version: <comment>%s</comment>', Composer::getVersion()));
  3501. $platformOverrides = $config->get('platform') ?: array();
  3502. $platformRepo = new PlatformRepository(array(), $platformOverrides);
  3503. $phpPkg = $platformRepo->findPackage('php', '*');
  3504. $phpVersion = $phpPkg->getPrettyVersion();
  3505. if ($phpPkg instanceof CompletePackageInterface && false !== strpos($phpPkg->getDescription(), 'overridden')) {
  3506. $phpVersion .= ' - ' . $phpPkg->getDescription();
  3507. }
  3508. $io->write(sprintf('PHP version: <comment>%s</comment>', $phpVersion));
  3509. if (defined('PHP_BINARY')) {
  3510. $io->write(sprintf('PHP binary path: <comment>%s</comment>', PHP_BINARY));
  3511. }
  3512. $io->write('OpenSSL version: ' . (defined('OPENSSL_VERSION_TEXT') ? '<comment>'.OPENSSL_VERSION_TEXT.'</comment>' : '<error>missing</error>'));
  3513. $io->write('cURL version: ' . $this->getCurlVersion());
  3514. $finder = new ExecutableFinder;
  3515. $hasSystemUnzip = (bool) $finder->find('unzip');
  3516. $bin7zip = '';
  3517. if ($hasSystem7zip = (bool) $finder->find('7z', null, array('C:\Program Files\7-Zip'))) {
  3518. $bin7zip = '7z';
  3519. }
  3520. if (!Platform::isWindows() && !$hasSystem7zip && $hasSystem7zip = (bool) $finder->find('7zz')) {
  3521. $bin7zip = '7zz';
  3522. }
  3523. $io->write(
  3524. 'zip: ' . (extension_loaded('zip') ? '<comment>extension present</comment>' : '<comment>extension not loaded</comment>')
  3525. . ', ' . ($hasSystemUnzip ? '<comment>unzip present</comment>' : '<comment>unzip not available</comment>')
  3526. . ', ' . ($hasSystem7zip ? '<comment>7-Zip present ('.$bin7zip.')</comment>' : '<comment>7-Zip not available</comment>')
  3527. . (($hasSystem7zip || $hasSystemUnzip) && !function_exists('proc_open') ? ', <warning>proc_open is disabled or not present, unzip/7-z will not be usable</warning>' : '')
  3528. );
  3529. return $this->exitCode;
  3530. }
  3531. private function checkComposerSchema()
  3532. {
  3533. $validator = new ConfigValidator($this->getIO());
  3534. list($errors, , $warnings) = $validator->validate(Factory::getComposerFile());
  3535. if ($errors || $warnings) {
  3536. $messages = array(
  3537. 'error' => $errors,
  3538. 'warning' => $warnings,
  3539. );
  3540. $output = '';
  3541. foreach ($messages as $style => $msgs) {
  3542. foreach ($msgs as $msg) {
  3543. $output .= '<' . $style . '>' . $msg . '</' . $style . '>' . PHP_EOL;
  3544. }
  3545. }
  3546. return rtrim($output);
  3547. }
  3548. return true;
  3549. }
  3550. private function checkGit()
  3551. {
  3552. if (!function_exists('proc_open')) {
  3553. return '<comment>proc_open is not available, git cannot be used</comment>';
  3554. }
  3555. $this->process->execute('git config color.ui', $output);
  3556. if (strtolower(trim($output)) === 'always') {
  3557. 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>';
  3558. }
  3559. return true;
  3560. }
  3561. private function checkHttp(string $proto, Config $config)
  3562. {
  3563. $result = $this->checkConnectivity();
  3564. if ($result !== true) {
  3565. return $result;
  3566. }
  3567. $result = array();
  3568. if ($proto === 'https' && $config->get('disable-tls') === true) {
  3569. $tlsWarning = '<warning>Composer is configured to disable SSL/TLS protection. This will leave remote HTTPS requests vulnerable to Man-In-The-Middle attacks.</warning>';
  3570. }
  3571. try {
  3572. $this->httpDownloader->get($proto . '://repo.packagist.org/packages.json');
  3573. } catch (TransportException $e) {
  3574. $hints = HttpDownloader::getExceptionHints($e);
  3575. if (null !== $hints && count($hints) > 0) {
  3576. foreach ($hints as $hint) {
  3577. $result[] = $hint;
  3578. }
  3579. }
  3580. $result[] = '<error>[' . get_class($e) . '] ' . $e->getMessage() . '</error>';
  3581. }
  3582. if (isset($tlsWarning)) {
  3583. $result[] = $tlsWarning;
  3584. }
  3585. if (count($result) > 0) {
  3586. return $result;
  3587. }
  3588. return true;
  3589. }
  3590. private function checkHttpProxy()
  3591. {
  3592. $result = $this->checkConnectivity();
  3593. if ($result !== true) {
  3594. return $result;
  3595. }
  3596. $protocol = extension_loaded('openssl') ? 'https' : 'http';
  3597. try {
  3598. $json = $this->httpDownloader->get($protocol . '://repo.packagist.org/packages.json')->decodeJson();
  3599. $hash = reset($json['provider-includes']);
  3600. $hash = $hash['sha256'];
  3601. $path = str_replace('%hash%', $hash, key($json['provider-includes']));
  3602. $provider = $this->httpDownloader->get($protocol . '://repo.packagist.org/'.$path)->getBody();
  3603. if (hash('sha256', $provider) !== $hash) {
  3604. return 'It seems that your proxy is modifying http traffic on the fly';
  3605. }
  3606. } catch (\Exception $e) {
  3607. return $e;
  3608. }
  3609. return true;
  3610. }
  3611. private function checkGithubOauth(string $domain, string $token)
  3612. {
  3613. $result = $this->checkConnectivity();
  3614. if ($result !== true) {
  3615. return $result;
  3616. }
  3617. $this->getIO()->setAuthentication($domain, $token, 'x-oauth-basic');
  3618. try {
  3619. $url = $domain === 'github.com' ? 'https://api.'.$domain.'/' : 'https://'.$domain.'/api/v3/';
  3620. $this->httpDownloader->get($url, array(
  3621. 'retry-auth-failure' => false,
  3622. ));
  3623. return true;
  3624. } catch (\Exception $e) {
  3625. if ($e instanceof TransportException && $e->getCode() === 401) {
  3626. return '<comment>The oauth token for '.$domain.' seems invalid, run "composer config --global --unset github-oauth.'.$domain.'" to remove it</comment>';
  3627. }
  3628. return $e;
  3629. }
  3630. }
  3631. private function getGithubRateLimit(string $domain, string $token = null)
  3632. {
  3633. $result = $this->checkConnectivity();
  3634. if ($result !== true) {
  3635. return $result;
  3636. }
  3637. if ($token) {
  3638. $this->getIO()->setAuthentication($domain, $token, 'x-oauth-basic');
  3639. }
  3640. $url = $domain === 'github.com' ? 'https://api.'.$domain.'/rate_limit' : 'https://'.$domain.'/api/rate_limit';
  3641. $data = $this->httpDownloader->get($url, array('retry-auth-failure' => false))->decodeJson();
  3642. return $data['resources']['core'];
  3643. }
  3644. private function checkDiskSpace(Config $config)
  3645. {
  3646. $minSpaceFree = 1024 * 1024;
  3647. if ((($df = @disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree)
  3648. || (($df = @disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree)
  3649. ) {
  3650. return '<error>The disk hosting '.$dir.' is full</error>';
  3651. }
  3652. return true;
  3653. }
  3654. private function checkPubKeys(Config $config)
  3655. {
  3656. $home = $config->get('home');
  3657. $errors = array();
  3658. $io = $this->getIO();
  3659. if (file_exists($home.'/keys.tags.pub') && file_exists($home.'/keys.dev.pub')) {
  3660. $io->write('');
  3661. }
  3662. if (file_exists($home.'/keys.tags.pub')) {
  3663. $io->write('Tags Public Key Fingerprint: ' . Keys::fingerprint($home.'/keys.tags.pub'));
  3664. } else {
  3665. $errors[] = '<error>Missing pubkey for tags verification</error>';
  3666. }
  3667. if (file_exists($home.'/keys.dev.pub')) {
  3668. $io->write('Dev Public Key Fingerprint: ' . Keys::fingerprint($home.'/keys.dev.pub'));
  3669. } else {
  3670. $errors[] = '<error>Missing pubkey for dev verification</error>';
  3671. }
  3672. if ($errors) {
  3673. $errors[] = '<error>Run composer self-update --update-keys to set them up</error>';
  3674. }
  3675. return $errors ?: true;
  3676. }
  3677. private function checkVersion(Config $config)
  3678. {
  3679. $result = $this->checkConnectivity();
  3680. if ($result !== true) {
  3681. return $result;
  3682. }
  3683. $versionsUtil = new Versions($config, $this->httpDownloader);
  3684. try {
  3685. $latest = $versionsUtil->getLatest();
  3686. } catch (\Exception $e) {
  3687. return $e;
  3688. }
  3689. if (Composer::VERSION !== $latest['version'] && Composer::VERSION !== '@package_version@') {
  3690. return '<comment>You are not running the latest '.$versionsUtil->getChannel().' version, run `composer self-update` to update ('.Composer::VERSION.' => '.$latest['version'].')</comment>';
  3691. }
  3692. return true;
  3693. }
  3694. private function getCurlVersion(): string
  3695. {
  3696. if (extension_loaded('curl')) {
  3697. if (!HttpDownloader::isCurlEnabled()) {
  3698. return '<error>disabled via disable_functions, using php streams fallback, which reduces performance</error>';
  3699. }
  3700. $version = curl_version();
  3701. return '<comment>'.$version['version'].'</comment> '.
  3702. 'libz <comment>'.(!empty($version['libz_version']) ? $version['libz_version'] : 'missing').'</comment> '.
  3703. 'ssl <comment>'.($version['ssl_version'] ?? 'missing').'</comment>';
  3704. }
  3705. return '<error>missing, using php streams fallback, which reduces performance</error>';
  3706. }
  3707. private function outputResult($result): void
  3708. {
  3709. $io = $this->getIO();
  3710. if (true === $result) {
  3711. $io->write('<info>OK</info>');
  3712. return;
  3713. }
  3714. $hadError = false;
  3715. $hadWarning = false;
  3716. if ($result instanceof \Exception) {
  3717. $result = '<error>['.get_class($result).'] '.$result->getMessage().'</error>';
  3718. }
  3719. if (!$result) {
  3720. $hadError = true;
  3721. } else {
  3722. if (!is_array($result)) {
  3723. $result = array($result);
  3724. }
  3725. foreach ($result as $message) {
  3726. if (false !== strpos($message, '<error>')) {
  3727. $hadError = true;
  3728. } elseif (false !== strpos($message, '<warning>')) {
  3729. $hadWarning = true;
  3730. }
  3731. }
  3732. }
  3733. if ($hadError) {
  3734. $io->write('<error>FAIL</error>');
  3735. $this->exitCode = max($this->exitCode, 2);
  3736. } elseif ($hadWarning) {
  3737. $io->write('<warning>WARNING</warning>');
  3738. $this->exitCode = max($this->exitCode, 1);
  3739. }
  3740. if ($result) {
  3741. foreach ($result as $message) {
  3742. $io->write($message);
  3743. }
  3744. }
  3745. }
  3746. private function checkPlatform()
  3747. {
  3748. $output = '';
  3749. $out = function ($msg, $style) use (&$output): void {
  3750. $output .= '<'.$style.'>'.$msg.'</'.$style.'>'.PHP_EOL;
  3751. };
  3752. $errors = array();
  3753. $warnings = array();
  3754. $displayIniMessage = false;
  3755. $iniMessage = PHP_EOL.PHP_EOL.IniHelper::getMessage();
  3756. $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.';
  3757. if (!function_exists('json_decode')) {
  3758. $errors['json'] = true;
  3759. }
  3760. if (!extension_loaded('Phar')) {
  3761. $errors['phar'] = true;
  3762. }
  3763. if (!extension_loaded('filter')) {
  3764. $errors['filter'] = true;
  3765. }
  3766. if (!extension_loaded('hash')) {
  3767. $errors['hash'] = true;
  3768. }
  3769. if (!extension_loaded('iconv') && !extension_loaded('mbstring')) {
  3770. $errors['iconv_mbstring'] = true;
  3771. }
  3772. if (!filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN)) {
  3773. $errors['allow_url_fopen'] = true;
  3774. }
  3775. if (extension_loaded('ionCube Loader') && ioncube_loader_iversion() < 40009) {
  3776. $errors['ioncube'] = ioncube_loader_version();
  3777. }
  3778. if (PHP_VERSION_ID < 70205) {
  3779. $errors['php'] = PHP_VERSION;
  3780. }
  3781. if (!extension_loaded('openssl')) {
  3782. $errors['openssl'] = true;
  3783. }
  3784. if (extension_loaded('openssl') && OPENSSL_VERSION_NUMBER < 0x1000100f) {
  3785. $warnings['openssl_version'] = true;
  3786. }
  3787. if (!defined('HHVM_VERSION') && !extension_loaded('apcu') && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
  3788. $warnings['apc_cli'] = true;
  3789. }
  3790. if (!extension_loaded('zlib')) {
  3791. $warnings['zlib'] = true;
  3792. }
  3793. ob_start();
  3794. phpinfo(INFO_GENERAL);
  3795. $phpinfo = ob_get_clean();
  3796. if (Preg::isMatch('{Configure Command(?: *</td><td class="v">| *=> *)(.*?)(?:</td>|$)}m', $phpinfo, $match)) {
  3797. $configure = $match[1];
  3798. if (false !== strpos($configure, '--enable-sigchild')) {
  3799. $warnings['sigchild'] = true;
  3800. }
  3801. if (false !== strpos($configure, '--with-curlwrappers')) {
  3802. $warnings['curlwrappers'] = true;
  3803. }
  3804. }
  3805. if (filter_var(ini_get('xdebug.profiler_enabled'), FILTER_VALIDATE_BOOLEAN)) {
  3806. $warnings['xdebug_profile'] = true;
  3807. } elseif (XdebugHandler::isXdebugActive()) {
  3808. $warnings['xdebug_loaded'] = true;
  3809. }
  3810. if (defined('PHP_WINDOWS_VERSION_BUILD')
  3811. && (version_compare(PHP_VERSION, '7.2.23', '<')
  3812. || (version_compare(PHP_VERSION, '7.3.0', '>=')
  3813. && version_compare(PHP_VERSION, '7.3.10', '<')))) {
  3814. $warnings['onedrive'] = PHP_VERSION;
  3815. }
  3816. if (!empty($errors)) {
  3817. foreach ($errors as $error => $current) {
  3818. switch ($error) {
  3819. case 'json':
  3820. $text = PHP_EOL."The json extension is missing.".PHP_EOL;
  3821. $text .= "Install it or recompile php without --disable-json";
  3822. break;
  3823. case 'phar':
  3824. $text = PHP_EOL."The phar extension is missing.".PHP_EOL;
  3825. $text .= "Install it or recompile php without --disable-phar";
  3826. break;
  3827. case 'filter':
  3828. $text = PHP_EOL."The filter extension is missing.".PHP_EOL;
  3829. $text .= "Install it or recompile php without --disable-filter";
  3830. break;
  3831. case 'hash':
  3832. $text = PHP_EOL."The hash extension is missing.".PHP_EOL;
  3833. $text .= "Install it or recompile php without --disable-hash";
  3834. break;
  3835. case 'iconv_mbstring':
  3836. $text = PHP_EOL."The iconv OR mbstring extension is required and both are missing.".PHP_EOL;
  3837. $text .= "Install either of them or recompile php without --disable-iconv";
  3838. break;
  3839. case 'php':
  3840. $text = PHP_EOL."Your PHP ({$current}) is too old, you must upgrade to PHP 7.2.5 or higher.";
  3841. break;
  3842. case 'allow_url_fopen':
  3843. $text = PHP_EOL."The allow_url_fopen setting is incorrect.".PHP_EOL;
  3844. $text .= "Add the following to the end of your `php.ini`:".PHP_EOL;
  3845. $text .= " allow_url_fopen = On";
  3846. $displayIniMessage = true;
  3847. break;
  3848. case 'ioncube':
  3849. $text = PHP_EOL."Your ionCube Loader extension ($current) is incompatible with Phar files.".PHP_EOL;
  3850. $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;
  3851. $text .= " zend_extension = /usr/lib/php5/20090626+lfs/ioncube_loader_lin_5.3.so";
  3852. $displayIniMessage = true;
  3853. break;
  3854. case 'openssl':
  3855. $text = PHP_EOL."The openssl extension is missing, which means that secure HTTPS transfers are impossible.".PHP_EOL;
  3856. $text .= "If possible you should enable it or recompile php with --with-openssl";
  3857. break;
  3858. default:
  3859. throw new \InvalidArgumentException(sprintf("DiagnoseCommand: Unknown error type \"%s\". Please report at https://github.com/composer/composer/issues/new.", $error));
  3860. }
  3861. $out($text, 'error');
  3862. }
  3863. $output .= PHP_EOL;
  3864. }
  3865. if (!empty($warnings)) {
  3866. foreach ($warnings as $warning => $current) {
  3867. switch ($warning) {
  3868. case 'apc_cli':
  3869. $text = "The apc.enable_cli setting is incorrect.".PHP_EOL;
  3870. $text .= "Add the following to the end of your `php.ini`:".PHP_EOL;
  3871. $text .= " apc.enable_cli = Off";
  3872. $displayIniMessage = true;
  3873. break;
  3874. case 'zlib':
  3875. $text = 'The zlib extension is not loaded, this can slow down Composer a lot.'.PHP_EOL;
  3876. $text .= 'If possible, enable it or recompile php with --with-zlib'.PHP_EOL;
  3877. $displayIniMessage = true;
  3878. break;
  3879. case 'sigchild':
  3880. $text = "PHP was compiled with --enable-sigchild which can cause issues on some platforms.".PHP_EOL;
  3881. $text .= "Recompile it without this flag if possible, see also:".PHP_EOL;
  3882. $text .= " https://bugs.php.net/bug.php?id=22999";
  3883. break;
  3884. case 'curlwrappers':
  3885. $text = "PHP was compiled with --with-curlwrappers which will cause issues with HTTP authentication and GitHub.".PHP_EOL;
  3886. $text .= " Recompile it without this flag if possible";
  3887. break;
  3888. case 'openssl_version':
  3889. $opensslVersion = strstr(trim(strstr(OPENSSL_VERSION_TEXT, ' ')), ' ', true);
  3890. $opensslVersion = $opensslVersion ?: OPENSSL_VERSION_TEXT;
  3891. $text = "The OpenSSL library ({$opensslVersion}) used by PHP does not support TLSv1.2 or TLSv1.1.".PHP_EOL;
  3892. $text .= "If possible you should upgrade OpenSSL to version 1.0.1 or above.";
  3893. break;
  3894. case 'xdebug_loaded':
  3895. $text = "The xdebug extension is loaded, this can slow down Composer a little.".PHP_EOL;
  3896. $text .= " Disabling it when using Composer is recommended.";
  3897. break;
  3898. case 'xdebug_profile':
  3899. $text = "The xdebug.profiler_enabled setting is enabled, this can slow down Composer a lot.".PHP_EOL;
  3900. $text .= "Add the following to the end of your `php.ini` to disable it:".PHP_EOL;
  3901. $text .= " xdebug.profiler_enabled = 0";
  3902. $displayIniMessage = true;
  3903. break;
  3904. case 'onedrive':
  3905. $text = "The Windows OneDrive folder is not supported on PHP versions below 7.2.23 and 7.3.10.".PHP_EOL;
  3906. $text .= "Upgrade your PHP ({$current}) to use this location with Composer.".PHP_EOL;
  3907. break;
  3908. default:
  3909. throw new \InvalidArgumentException(sprintf("DiagnoseCommand: Unknown warning type \"%s\". Please report at https://github.com/composer/composer/issues/new.", $warning));
  3910. }
  3911. $out($text, 'comment');
  3912. }
  3913. }
  3914. if ($displayIniMessage) {
  3915. $out($iniMessage, 'comment');
  3916. }
  3917. return !$warnings && !$errors ? true : $output;
  3918. }
  3919. private function checkConnectivity()
  3920. {
  3921. if (!ini_get('allow_url_fopen')) {
  3922. return '<info>Skipped because allow_url_fopen is missing.</info>';
  3923. }
  3924. return true;
  3925. }
  3926. }
  3927. <?php declare(strict_types=1);
  3928. namespace Composer\Command;
  3929. use Composer\Plugin\CommandEvent;
  3930. use Composer\Plugin\PluginEvents;
  3931. use Symfony\Component\Console\Input\InputInterface;
  3932. use Symfony\Component\Console\Input\InputOption;
  3933. use Symfony\Component\Console\Output\OutputInterface;
  3934. class DumpAutoloadCommand extends BaseCommand
  3935. {
  3936. protected function configure()
  3937. {
  3938. $this
  3939. ->setName('dump-autoload')
  3940. ->setAliases(array('dumpautoload'))
  3941. ->setDescription('Dumps the autoloader.')
  3942. ->setDefinition(array(
  3943. new InputOption('optimize', 'o', InputOption::VALUE_NONE, 'Optimizes PSR0 and PSR4 packages to be loaded with classmaps too, good for production.'),
  3944. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize`.'),
  3945. new InputOption('apcu', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  3946. new InputOption('apcu-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu'),
  3947. new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables autoload-dev rules. Composer will by default infer this automatically according to the last install or update --no-dev state.'),
  3948. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables autoload-dev rules. Composer will by default infer this automatically according to the last install or update --no-dev state.'),
  3949. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  3950. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  3951. ))
  3952. ->setHelp(
  3953. <<<EOT
  3954. <info>php composer.phar dump-autoload</info>
  3955. Read more at https://getcomposer.org/doc/03-cli.md#dump-autoload-dumpautoload-
  3956. EOT
  3957. )
  3958. ;
  3959. }
  3960. protected function execute(InputInterface $input, OutputInterface $output)
  3961. {
  3962. $composer = $this->requireComposer();
  3963. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'dump-autoload', $input, $output);
  3964. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  3965. $installationManager = $composer->getInstallationManager();
  3966. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  3967. $package = $composer->getPackage();
  3968. $config = $composer->getConfig();
  3969. $optimize = $input->getOption('optimize') || $config->get('optimize-autoloader');
  3970. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  3971. $apcuPrefix = $input->getOption('apcu-prefix');
  3972. $apcu = $apcuPrefix !== null || $input->getOption('apcu') || $config->get('apcu-autoloader');
  3973. if ($authoritative) {
  3974. $this->getIO()->write('<info>Generating optimized autoload files (authoritative)</info>');
  3975. } elseif ($optimize) {
  3976. $this->getIO()->write('<info>Generating optimized autoload files</info>');
  3977. } else {
  3978. $this->getIO()->write('<info>Generating autoload files</info>');
  3979. }
  3980. $generator = $composer->getAutoloadGenerator();
  3981. if ($input->getOption('no-dev')) {
  3982. $generator->setDevMode(false);
  3983. }
  3984. if ($input->getOption('dev')) {
  3985. if ($input->getOption('no-dev')) {
  3986. throw new \InvalidArgumentException('You can not use both --no-dev and --dev as they conflict with each other.');
  3987. }
  3988. $generator->setDevMode(true);
  3989. }
  3990. $generator->setClassMapAuthoritative($authoritative);
  3991. $generator->setRunScripts(true);
  3992. $generator->setApcu($apcu, $apcuPrefix);
  3993. $generator->setPlatformRequirementFilter($this->getPlatformRequirementFilter($input));
  3994. $numberOfClasses = $generator->dump($config, $localRepo, $package, $installationManager, 'composer', $optimize);
  3995. if ($authoritative) {
  3996. $this->getIO()->write('<info>Generated optimized autoload files (authoritative) containing '. $numberOfClasses .' classes</info>');
  3997. } elseif ($optimize) {
  3998. $this->getIO()->write('<info>Generated optimized autoload files containing '. $numberOfClasses .' classes</info>');
  3999. } else {
  4000. $this->getIO()->write('<info>Generated autoload files</info>');
  4001. }
  4002. return 0;
  4003. }
  4004. }
  4005. <?php declare(strict_types=1);
  4006. namespace Composer\Command;
  4007. use Symfony\Component\Console\Input\InputInterface;
  4008. use Symfony\Component\Console\Input\InputOption;
  4009. use Symfony\Component\Console\Output\OutputInterface;
  4010. use Symfony\Component\Console\Input\InputArgument;
  4011. class ExecCommand extends BaseCommand
  4012. {
  4013. protected function configure()
  4014. {
  4015. $this
  4016. ->setName('exec')
  4017. ->setDescription('Executes a vendored binary/script.')
  4018. ->setDefinition(array(
  4019. new InputOption('list', 'l', InputOption::VALUE_NONE),
  4020. new InputArgument('binary', InputArgument::OPTIONAL, 'The binary to run, e.g. phpunit'),
  4021. new InputArgument(
  4022. 'args',
  4023. InputArgument::IS_ARRAY | InputArgument::OPTIONAL,
  4024. 'Arguments to pass to the binary. Use <info>--</info> to separate from composer arguments'
  4025. ),
  4026. ))
  4027. ->setHelp(
  4028. <<<EOT
  4029. Executes a vendored binary/script.
  4030. Read more at https://getcomposer.org/doc/03-cli.md#exec
  4031. EOT
  4032. )
  4033. ;
  4034. }
  4035. protected function execute(InputInterface $input, OutputInterface $output)
  4036. {
  4037. $composer = $this->requireComposer();
  4038. $binDir = $composer->getConfig()->get('bin-dir');
  4039. if ($input->getOption('list') || null === $input->getArgument('binary')) {
  4040. $bins = glob($binDir . '/*');
  4041. $bins = array_merge($bins, array_map(function ($e) {
  4042. return "$e (local)";
  4043. }, $composer->getPackage()->getBinaries()));
  4044. if (!$bins) {
  4045. throw new \RuntimeException("No binaries found in composer.json or in bin-dir ($binDir)");
  4046. }
  4047. $this->getIO()->write(
  4048. <<<EOT
  4049. <comment>Available binaries:</comment>
  4050. EOT
  4051. );
  4052. foreach ($bins as $bin) {
  4053. if (isset($previousBin) && $bin === $previousBin.'.bat') {
  4054. continue;
  4055. }
  4056. $previousBin = $bin;
  4057. $bin = basename($bin);
  4058. $this->getIO()->write(
  4059. <<<EOT
  4060. <info>- $bin</info>
  4061. EOT
  4062. );
  4063. }
  4064. return 0;
  4065. }
  4066. $binary = $input->getArgument('binary');
  4067. $dispatcher = $composer->getEventDispatcher();
  4068. $dispatcher->addListener('__exec_command', $binary);
  4069. if (getcwd() !== $this->getApplication()->getInitialWorkingDirectory() && $this->getApplication()->getInitialWorkingDirectory() !== false) {
  4070. try {
  4071. chdir($this->getApplication()->getInitialWorkingDirectory());
  4072. } catch (\Exception $e) {
  4073. throw new \RuntimeException('Could not switch back to working directory "'.$this->getApplication()->getInitialWorkingDirectory().'"', 0, $e);
  4074. }
  4075. }
  4076. return $dispatcher->dispatchScript('__exec_command', true, $input->getArgument('args'));
  4077. }
  4078. }
  4079. <?php declare(strict_types=1);
  4080. namespace Composer\Command;
  4081. use Composer\Json\JsonFile;
  4082. use Composer\Package\AliasPackage;
  4083. use Composer\Package\BasePackage;
  4084. use Composer\Package\CompletePackageInterface;
  4085. use Composer\Pcre\Preg;
  4086. use Composer\Repository\CompositeRepository;
  4087. use Composer\Semver\Constraint\MatchAllConstraint;
  4088. use Symfony\Component\Console\Formatter\OutputFormatter;
  4089. use Symfony\Component\Console\Input\InputInterface;
  4090. use Symfony\Component\Console\Input\InputOption;
  4091. use Symfony\Component\Console\Output\OutputInterface;
  4092. class FundCommand extends BaseCommand
  4093. {
  4094. protected function configure(): void
  4095. {
  4096. $this->setName('fund')
  4097. ->setDescription('Discover how to help fund the maintenance of your dependencies.')
  4098. ->setDefinition(array(
  4099. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
  4100. ))
  4101. ;
  4102. }
  4103. protected function execute(InputInterface $input, OutputInterface $output): int
  4104. {
  4105. $composer = $this->requireComposer();
  4106. $repo = $composer->getRepositoryManager()->getLocalRepository();
  4107. $remoteRepos = new CompositeRepository($composer->getRepositoryManager()->getRepositories());
  4108. $fundings = array();
  4109. $packagesToLoad = array();
  4110. foreach ($repo->getPackages() as $package) {
  4111. if ($package instanceof AliasPackage) {
  4112. continue;
  4113. }
  4114. $packagesToLoad[$package->getName()] = new MatchAllConstraint();
  4115. }
  4116. $result = $remoteRepos->loadPackages($packagesToLoad, array('dev' => BasePackage::STABILITY_DEV), array());
  4117. foreach ($result['packages'] as $package) {
  4118. if (
  4119. !$package instanceof AliasPackage
  4120. && $package instanceof CompletePackageInterface
  4121. && $package->isDefaultBranch()
  4122. && $package->getFunding()
  4123. && isset($packagesToLoad[$package->getName()])
  4124. ) {
  4125. $fundings = $this->insertFundingData($fundings, $package);
  4126. unset($packagesToLoad[$package->getName()]);
  4127. }
  4128. }
  4129. foreach ($repo->getPackages() as $package) {
  4130. if ($package instanceof AliasPackage || !isset($packagesToLoad[$package->getName()])) {
  4131. continue;
  4132. }
  4133. if ($package instanceof CompletePackageInterface && $package->getFunding()) {
  4134. $fundings = $this->insertFundingData($fundings, $package);
  4135. }
  4136. }
  4137. ksort($fundings);
  4138. $io = $this->getIO();
  4139. $format = $input->getOption('format');
  4140. if (!in_array($format, array('text', 'json'))) {
  4141. $io->writeError(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  4142. return 1;
  4143. }
  4144. if ($fundings && $format === 'text') {
  4145. $prev = null;
  4146. $io->write('The following packages were found in your dependencies which publish funding information:');
  4147. foreach ($fundings as $vendor => $links) {
  4148. $io->write('');
  4149. $io->write(sprintf("<comment>%s</comment>", $vendor));
  4150. foreach ($links as $url => $packages) {
  4151. $line = sprintf(' <info>%s</info>', implode(', ', $packages));
  4152. if ($prev !== $line) {
  4153. $io->write($line);
  4154. $prev = $line;
  4155. }
  4156. $io->write(sprintf(' <href=%s>%s</>', OutputFormatter::escape($url), $url));
  4157. }
  4158. }
  4159. $io->write("");
  4160. $io->write("Please consider following these links and sponsoring the work of package authors!");
  4161. $io->write("Thank you!");
  4162. } elseif ($format === 'json') {
  4163. $io->write(JsonFile::encode($fundings));
  4164. } else {
  4165. $io->write("No funding links were found in your package dependencies. This doesn't mean they don't need your support!");
  4166. }
  4167. return 0;
  4168. }
  4169. private function insertFundingData(array $fundings, CompletePackageInterface $package): array
  4170. {
  4171. foreach ($package->getFunding() as $fundingOption) {
  4172. list($vendor, $packageName) = explode('/', $package->getPrettyName());
  4173. if (empty($fundingOption['url'])) {
  4174. continue;
  4175. }
  4176. $url = $fundingOption['url'];
  4177. if (!empty($fundingOption['type']) && $fundingOption['type'] === 'github' && Preg::isMatch('{^https://github.com/([^/]+)$}', $url, $match)) {
  4178. $url = 'https://github.com/sponsors/'.$match[1];
  4179. }
  4180. $fundings[$vendor][$url][] = $packageName;
  4181. }
  4182. return $fundings;
  4183. }
  4184. }
  4185. <?php declare(strict_types=1);
  4186. namespace Composer\Command;
  4187. use Composer\Factory;
  4188. use Composer\Pcre\Preg;
  4189. use Composer\Util\Filesystem;
  4190. use Composer\Util\Platform;
  4191. use Symfony\Component\Console\Input\InputInterface;
  4192. use Symfony\Component\Console\Input\InputArgument;
  4193. use Symfony\Component\Console\Input\StringInput;
  4194. use Symfony\Component\Console\Output\OutputInterface;
  4195. class GlobalCommand extends BaseCommand
  4196. {
  4197. protected function configure(): void
  4198. {
  4199. $this
  4200. ->setName('global')
  4201. ->setDescription('Allows running commands in the global composer dir ($COMPOSER_HOME).')
  4202. ->setDefinition(array(
  4203. new InputArgument('command-name', InputArgument::REQUIRED, ''),
  4204. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  4205. ))
  4206. ->setHelp(
  4207. <<<EOT
  4208. Use this command as a wrapper to run other Composer commands
  4209. within the global context of COMPOSER_HOME.
  4210. You can use this to install CLI utilities globally, all you need
  4211. is to add the COMPOSER_HOME/vendor/bin dir to your PATH env var.
  4212. COMPOSER_HOME is c:\Users\<user>\AppData\Roaming\Composer on Windows
  4213. and /home/<user>/.composer on unix systems.
  4214. If your system uses freedesktop.org standards, then it will first check
  4215. XDG_CONFIG_HOME or default to /home/<user>/.config/composer
  4216. Note: This path may vary depending on customizations to bin-dir in
  4217. composer.json or the environmental variable COMPOSER_BIN_DIR.
  4218. Read more at https://getcomposer.org/doc/03-cli.md#global
  4219. EOT
  4220. )
  4221. ;
  4222. }
  4223. public function run(InputInterface $input, OutputInterface $output): int
  4224. {
  4225. if (!method_exists($input, '__toString')) {
  4226. throw new \LogicException('Expected an Input instance that is stringable, got '.get_class($input));
  4227. }
  4228. $tokens = Preg::split('{\s+}', $input->__toString());
  4229. $args = array();
  4230. foreach ($tokens as $token) {
  4231. if ($token && $token[0] !== '-') {
  4232. $args[] = $token;
  4233. if (count($args) >= 2) {
  4234. break;
  4235. }
  4236. }
  4237. }
  4238. if (count($args) < 2) {
  4239. return parent::run($input, $output);
  4240. }
  4241. if (Platform::getEnv('COMPOSER')) {
  4242. Platform::clearEnv('COMPOSER');
  4243. }
  4244. $config = Factory::createConfig();
  4245. $home = $config->get('home');
  4246. if (!is_dir($home)) {
  4247. $fs = new Filesystem();
  4248. $fs->ensureDirectoryExists($home);
  4249. if (!is_dir($home)) {
  4250. throw new \RuntimeException('Could not create home directory');
  4251. }
  4252. }
  4253. try {
  4254. chdir($home);
  4255. } catch (\Exception $e) {
  4256. throw new \RuntimeException('Could not switch to home directory "'.$home.'"', 0, $e);
  4257. }
  4258. $this->getIO()->writeError('<info>Changed current directory to '.$home.'</info>');
  4259. $input = new StringInput(Preg::replace('{\bg(?:l(?:o(?:b(?:a(?:l)?)?)?)?)?\b}', '', $input->__toString(), 1));
  4260. $this->getApplication()->resetComposer();
  4261. return $this->getApplication()->run($input, $output);
  4262. }
  4263. public function isProxyCommand(): bool
  4264. {
  4265. return true;
  4266. }
  4267. }
  4268. <?php declare(strict_types=1);
  4269. namespace Composer\Command;
  4270. use Composer\Package\CompletePackageInterface;
  4271. use Composer\Repository\RepositoryInterface;
  4272. use Composer\Repository\RootPackageRepository;
  4273. use Composer\Repository\RepositoryFactory;
  4274. use Composer\Util\Platform;
  4275. use Composer\Util\ProcessExecutor;
  4276. use Symfony\Component\Console\Input\InputArgument;
  4277. use Symfony\Component\Console\Input\InputOption;
  4278. use Symfony\Component\Console\Input\InputInterface;
  4279. use Symfony\Component\Console\Output\OutputInterface;
  4280. class HomeCommand extends BaseCommand
  4281. {
  4282. protected function configure(): void
  4283. {
  4284. $this
  4285. ->setName('browse')
  4286. ->setAliases(array('home'))
  4287. ->setDescription('Opens the package\'s repository URL or homepage in your browser.')
  4288. ->setDefinition(array(
  4289. new InputArgument('packages', InputArgument::IS_ARRAY, 'Package(s) to browse to.'),
  4290. new InputOption('homepage', 'H', InputOption::VALUE_NONE, 'Open the homepage instead of the repository URL.'),
  4291. new InputOption('show', 's', InputOption::VALUE_NONE, 'Only show the homepage or repository URL.'),
  4292. ))
  4293. ->setHelp(
  4294. <<<EOT
  4295. The home command opens or shows a package's repository URL or
  4296. homepage in your default browser.
  4297. To open the homepage by default, use -H or --homepage.
  4298. To show instead of open the repository or homepage URL, use -s or --show.
  4299. Read more at https://getcomposer.org/doc/03-cli.md#browse-home
  4300. EOT
  4301. );
  4302. }
  4303. protected function execute(InputInterface $input, OutputInterface $output): int
  4304. {
  4305. $repos = $this->initializeRepos();
  4306. $io = $this->getIO();
  4307. $return = 0;
  4308. $packages = $input->getArgument('packages');
  4309. if (count($packages) === 0) {
  4310. $io->writeError('No package specified, opening homepage for the root package');
  4311. $packages = array($this->requireComposer()->getPackage()->getName());
  4312. }
  4313. foreach ($packages as $packageName) {
  4314. $handled = false;
  4315. $packageExists = false;
  4316. foreach ($repos as $repo) {
  4317. foreach ($repo->findPackages($packageName) as $package) {
  4318. $packageExists = true;
  4319. if ($package instanceof CompletePackageInterface && $this->handlePackage($package, $input->getOption('homepage'), $input->getOption('show'))) {
  4320. $handled = true;
  4321. break 2;
  4322. }
  4323. }
  4324. }
  4325. if (!$packageExists) {
  4326. $return = 1;
  4327. $io->writeError('<warning>Package '.$packageName.' not found</warning>');
  4328. }
  4329. if (!$handled) {
  4330. $return = 1;
  4331. $io->writeError('<warning>'.($input->getOption('homepage') ? 'Invalid or missing homepage' : 'Invalid or missing repository URL').' for '.$packageName.'</warning>');
  4332. }
  4333. }
  4334. return $return;
  4335. }
  4336. private function handlePackage(CompletePackageInterface $package, bool $showHomepage, bool $showOnly): bool
  4337. {
  4338. $support = $package->getSupport();
  4339. $url = $support['source'] ?? $package->getSourceUrl();
  4340. if (!$url || $showHomepage) {
  4341. $url = $package->getHomepage();
  4342. }
  4343. if (!$url || !filter_var($url, FILTER_VALIDATE_URL)) {
  4344. return false;
  4345. }
  4346. if ($showOnly) {
  4347. $this->getIO()->write(sprintf('<info>%s</info>', $url));
  4348. } else {
  4349. $this->openBrowser($url);
  4350. }
  4351. return true;
  4352. }
  4353. private function openBrowser(string $url): void
  4354. {
  4355. $url = ProcessExecutor::escape($url);
  4356. $process = new ProcessExecutor($this->getIO());
  4357. if (Platform::isWindows()) {
  4358. $process->execute('start "web" explorer ' . $url, $output);
  4359. return;
  4360. }
  4361. $linux = $process->execute('which xdg-open', $output);
  4362. $osx = $process->execute('which open', $output);
  4363. if (0 === $linux) {
  4364. $process->execute('xdg-open ' . $url, $output);
  4365. } elseif (0 === $osx) {
  4366. $process->execute('open ' . $url, $output);
  4367. } else {
  4368. $this->getIO()->writeError('No suitable browser opening command found, open yourself: ' . $url);
  4369. }
  4370. }
  4371. private function initializeRepos(): array
  4372. {
  4373. $composer = $this->tryComposer();
  4374. if ($composer) {
  4375. return array_merge(
  4376. array(new RootPackageRepository($composer->getPackage())),
  4377. array($composer->getRepositoryManager()->getLocalRepository()),
  4378. $composer->getRepositoryManager()->getRepositories()
  4379. );
  4380. }
  4381. return RepositoryFactory::defaultRepos($this->getIO());
  4382. }
  4383. }
  4384. <?php declare(strict_types=1);
  4385. namespace Composer\Command;
  4386. use Composer\Factory;
  4387. use Composer\Json\JsonFile;
  4388. use Composer\Json\JsonValidationException;
  4389. use Composer\Package\BasePackage;
  4390. use Composer\Package\Package;
  4391. use Composer\Pcre\Preg;
  4392. use Composer\Repository\CompositeRepository;
  4393. use Composer\Repository\PlatformRepository;
  4394. use Composer\Repository\RepositoryFactory;
  4395. use Composer\Util\Filesystem;
  4396. use Composer\Util\Silencer;
  4397. use Symfony\Component\Console\Input\ArrayInput;
  4398. use Symfony\Component\Console\Input\InputInterface;
  4399. use Symfony\Component\Console\Input\InputOption;
  4400. use Symfony\Component\Console\Output\OutputInterface;
  4401. use Symfony\Component\Process\ExecutableFinder;
  4402. use Symfony\Component\Process\Process;
  4403. use Symfony\Component\Console\Helper\FormatterHelper;
  4404. class InitCommand extends BaseCommand
  4405. {
  4406. use PackageDiscoveryTrait;
  4407. private $gitConfig;
  4408. protected function configure()
  4409. {
  4410. $this
  4411. ->setName('init')
  4412. ->setDescription('Creates a basic composer.json file in current directory.')
  4413. ->setDefinition(array(
  4414. new InputOption('name', null, InputOption::VALUE_REQUIRED, 'Name of the package'),
  4415. new InputOption('description', null, InputOption::VALUE_REQUIRED, 'Description of package'),
  4416. new InputOption('author', null, InputOption::VALUE_REQUIRED, 'Author name of package'),
  4417. new InputOption('type', null, InputOption::VALUE_OPTIONAL, 'Type of package (e.g. library, project, metapackage, composer-plugin)'),
  4418. new InputOption('homepage', null, InputOption::VALUE_REQUIRED, 'Homepage of package'),
  4419. 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"'),
  4420. 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"'),
  4421. new InputOption('stability', 's', InputOption::VALUE_REQUIRED, 'Minimum stability (empty or one of: '.implode(', ', array_keys(BasePackage::$stabilities)).')'),
  4422. new InputOption('license', 'l', InputOption::VALUE_REQUIRED, 'License of package'),
  4423. new InputOption('repository', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Add custom repositories, either by URL or using JSON arrays'),
  4424. new InputOption('autoload', 'a', InputOption::VALUE_REQUIRED, 'Add PSR-4 autoload mapping. Maps your package\'s namespace to the provided directory. (Expects a relative path, e.g. src/)'),
  4425. ))
  4426. ->setHelp(
  4427. <<<EOT
  4428. The <info>init</info> command creates a basic composer.json file
  4429. in the current directory.
  4430. <info>php composer.phar init</info>
  4431. Read more at https://getcomposer.org/doc/03-cli.md#init
  4432. EOT
  4433. )
  4434. ;
  4435. }
  4436. protected function execute(InputInterface $input, OutputInterface $output)
  4437. {
  4438. $io = $this->getIO();
  4439. $allowlist = array('name', 'description', 'author', 'type', 'homepage', 'require', 'require-dev', 'stability', 'license', 'autoload');
  4440. $options = array_filter(array_intersect_key($input->getOptions(), array_flip($allowlist)));
  4441. if (isset($options['name']) && !Preg::isMatch('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}D', $options['name'])) {
  4442. throw new \InvalidArgumentException(
  4443. 'The package name '.$options['name'].' is invalid, it should be lowercase and have a vendor name, a forward slash, and a package name, matching: [a-z0-9_.-]+/[a-z0-9_.-]+'
  4444. );
  4445. }
  4446. if (isset($options['author'])) {
  4447. $options['authors'] = $this->formatAuthors($options['author']);
  4448. unset($options['author']);
  4449. }
  4450. $repositories = $input->getOption('repository');
  4451. if (count($repositories) > 0) {
  4452. $config = Factory::createConfig($io);
  4453. foreach ($repositories as $repo) {
  4454. $options['repositories'][] = RepositoryFactory::configFromString($io, $config, $repo, true);
  4455. }
  4456. }
  4457. if (isset($options['stability'])) {
  4458. $options['minimum-stability'] = $options['stability'];
  4459. unset($options['stability']);
  4460. }
  4461. $options['require'] = isset($options['require']) ? $this->formatRequirements($options['require']) : new \stdClass;
  4462. if (array() === $options['require']) {
  4463. $options['require'] = new \stdClass;
  4464. }
  4465. if (isset($options['require-dev'])) {
  4466. $options['require-dev'] = $this->formatRequirements($options['require-dev']);
  4467. if (array() === $options['require-dev']) {
  4468. $options['require-dev'] = new \stdClass;
  4469. }
  4470. }
  4471. $autoloadPath = null;
  4472. if (isset($options['autoload'])) {
  4473. $autoloadPath = $options['autoload'];
  4474. $namespace = $this->namespaceFromPackageName((string) $input->getOption('name'));
  4475. $options['autoload'] = (object) array(
  4476. 'psr-4' => array(
  4477. $namespace . '\\' => $autoloadPath,
  4478. ),
  4479. );
  4480. }
  4481. $file = new JsonFile(Factory::getComposerFile());
  4482. $json = JsonFile::encode($options);
  4483. if ($input->isInteractive()) {
  4484. $io->writeError(array('', $json, ''));
  4485. if (!$io->askConfirmation('Do you confirm generation [<comment>yes</comment>]? ')) {
  4486. $io->writeError('<error>Command aborted</error>');
  4487. return 1;
  4488. }
  4489. } else {
  4490. if (json_encode($options) === '{"require":{}}') {
  4491. throw new \RuntimeException('You have to run this command in interactive mode, or specify at least some data using --name, --require, etc.');
  4492. }
  4493. $io->writeError('Writing '.$file->getPath());
  4494. }
  4495. $file->write($options);
  4496. try {
  4497. $file->validateSchema(JsonFile::LAX_SCHEMA);
  4498. } catch (JsonValidationException $e) {
  4499. $io->writeError('<error>Schema validation error, aborting</error>');
  4500. $errors = ' - ' . implode(PHP_EOL . ' - ', $e->getErrors());
  4501. $io->writeError($e->getMessage() . ':' . PHP_EOL . $errors);
  4502. Silencer::call('unlink', $file->getPath());
  4503. return 1;
  4504. }
  4505. if ($autoloadPath) {
  4506. $filesystem = new Filesystem();
  4507. $filesystem->ensureDirectoryExists($autoloadPath);
  4508. if (!$this->hasDependencies($options)) {
  4509. $this->runDumpAutoloadCommand($output);
  4510. }
  4511. }
  4512. if ($input->isInteractive() && is_dir('.git')) {
  4513. $ignoreFile = realpath('.gitignore');
  4514. if (false === $ignoreFile) {
  4515. $ignoreFile = realpath('.') . '/.gitignore';
  4516. }
  4517. if (!$this->hasVendorIgnore($ignoreFile)) {
  4518. $question = 'Would you like the <info>vendor</info> directory added to your <info>.gitignore</info> [<comment>yes</comment>]? ';
  4519. if ($io->askConfirmation($question)) {
  4520. $this->addVendorIgnore($ignoreFile);
  4521. }
  4522. }
  4523. }
  4524. $question = 'Would you like to install dependencies now [<comment>yes</comment>]? ';
  4525. if ($input->isInteractive() && $this->hasDependencies($options) && $io->askConfirmation($question)) {
  4526. $this->updateDependencies($output);
  4527. }
  4528. if ($autoloadPath) {
  4529. $namespace = $this->namespaceFromPackageName((string) $input->getOption('name'));
  4530. $io->writeError('PSR-4 autoloading configured. Use "<comment>namespace '.$namespace.';</comment>" in '.$autoloadPath);
  4531. $io->writeError('Include the Composer autoloader with: <comment>require \'vendor/autoload.php\';</comment>');
  4532. }
  4533. return 0;
  4534. }
  4535. protected function interact(InputInterface $input, OutputInterface $output)
  4536. {
  4537. $git = $this->getGitConfig();
  4538. $io = $this->getIO();
  4539. $formatter = $this->getHelperSet()->get('formatter');
  4540. $repositories = $input->getOption('repository');
  4541. if (count($repositories) > 0) {
  4542. $config = Factory::createConfig($io);
  4543. $repos = array(new PlatformRepository);
  4544. $createDefaultPackagistRepo = true;
  4545. foreach ($repositories as $repo) {
  4546. $repoConfig = RepositoryFactory::configFromString($io, $config, $repo, true);
  4547. if (
  4548. (isset($repoConfig['packagist']) && $repoConfig === array('packagist' => false))
  4549. || (isset($repoConfig['packagist.org']) && $repoConfig === array('packagist.org' => false))
  4550. ) {
  4551. $createDefaultPackagistRepo = false;
  4552. continue;
  4553. }
  4554. $repos[] = RepositoryFactory::createRepo($io, $config, $repoConfig);
  4555. }
  4556. if ($createDefaultPackagistRepo) {
  4557. $repos[] = RepositoryFactory::createRepo($io, $config, array(
  4558. 'type' => 'composer',
  4559. 'url' => 'https://repo.packagist.org',
  4560. ));
  4561. }
  4562. $this->repos = new CompositeRepository($repos);
  4563. unset($repos, $config, $repositories);
  4564. }
  4565. $io->writeError(array(
  4566. '',
  4567. $formatter->formatBlock('Welcome to the Composer config generator', 'bg=blue;fg=white', true),
  4568. '',
  4569. ));
  4570. $io->writeError(array(
  4571. '',
  4572. 'This command will guide you through creating your composer.json config.',
  4573. '',
  4574. ));
  4575. $cwd = realpath(".");
  4576. $name = $input->getOption('name');
  4577. if (null === $name) {
  4578. $name = basename($cwd);
  4579. $name = Preg::replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name);
  4580. $name = strtolower($name);
  4581. if (!empty($_SERVER['COMPOSER_DEFAULT_VENDOR'])) {
  4582. $name = $_SERVER['COMPOSER_DEFAULT_VENDOR'] . '/' . $name;
  4583. } elseif (isset($git['github.user'])) {
  4584. $name = $git['github.user'] . '/' . $name;
  4585. } elseif (!empty($_SERVER['USERNAME'])) {
  4586. $name = $_SERVER['USERNAME'] . '/' . $name;
  4587. } elseif (!empty($_SERVER['USER'])) {
  4588. $name = $_SERVER['USER'] . '/' . $name;
  4589. } elseif (get_current_user()) {
  4590. $name = get_current_user() . '/' . $name;
  4591. } else {
  4592. $name .= '/' . $name;
  4593. }
  4594. $name = strtolower($name);
  4595. }
  4596. $name = $io->askAndValidate(
  4597. 'Package name (<vendor>/<name>) [<comment>'.$name.'</comment>]: ',
  4598. function ($value) use ($name) {
  4599. if (null === $value) {
  4600. return $name;
  4601. }
  4602. if (!Preg::isMatch('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}D', $value)) {
  4603. throw new \InvalidArgumentException(
  4604. '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_.-]+'
  4605. );
  4606. }
  4607. return $value;
  4608. },
  4609. null,
  4610. $name
  4611. );
  4612. $input->setOption('name', $name);
  4613. $description = $input->getOption('description') ?: null;
  4614. $description = $io->ask(
  4615. 'Description [<comment>'.$description.'</comment>]: ',
  4616. $description
  4617. );
  4618. $input->setOption('description', $description);
  4619. if (null === $author = $input->getOption('author')) {
  4620. if (!empty($_SERVER['COMPOSER_DEFAULT_AUTHOR'])) {
  4621. $author_name = $_SERVER['COMPOSER_DEFAULT_AUTHOR'];
  4622. } elseif (isset($git['user.name'])) {
  4623. $author_name = $git['user.name'];
  4624. }
  4625. if (!empty($_SERVER['COMPOSER_DEFAULT_EMAIL'])) {
  4626. $author_email = $_SERVER['COMPOSER_DEFAULT_EMAIL'];
  4627. } elseif (isset($git['user.email'])) {
  4628. $author_email = $git['user.email'];
  4629. }
  4630. if (isset($author_name, $author_email)) {
  4631. $author = sprintf('%s <%s>', $author_name, $author_email);
  4632. }
  4633. }
  4634. $author = $io->askAndValidate(
  4635. 'Author ['.(is_string($author) ? '<comment>'.$author.'</comment>, ' : '') . 'n to skip]: ',
  4636. function ($value) use ($author) {
  4637. if ($value === 'n' || $value === 'no') {
  4638. return;
  4639. }
  4640. $value = $value ?: $author;
  4641. $author = $this->parseAuthorString($value);
  4642. if ($author['email'] === null) {
  4643. return $author['name'];
  4644. }
  4645. return sprintf('%s <%s>', $author['name'], $author['email']);
  4646. },
  4647. null,
  4648. $author
  4649. );
  4650. $input->setOption('author', $author);
  4651. $minimumStability = $input->getOption('stability') ?: null;
  4652. $minimumStability = $io->askAndValidate(
  4653. 'Minimum Stability [<comment>'.$minimumStability.'</comment>]: ',
  4654. function ($value) use ($minimumStability) {
  4655. if (null === $value) {
  4656. return $minimumStability;
  4657. }
  4658. if (!isset(BasePackage::$stabilities[$value])) {
  4659. throw new \InvalidArgumentException(
  4660. 'Invalid minimum stability "'.$value.'". Must be empty or one of: '.
  4661. implode(', ', array_keys(BasePackage::$stabilities))
  4662. );
  4663. }
  4664. return $value;
  4665. },
  4666. null,
  4667. $minimumStability
  4668. );
  4669. $input->setOption('stability', $minimumStability);
  4670. $type = $input->getOption('type') ?: false;
  4671. $type = $io->ask(
  4672. 'Package Type (e.g. library, project, metapackage, composer-plugin) [<comment>'.$type.'</comment>]: ',
  4673. $type
  4674. );
  4675. $input->setOption('type', $type);
  4676. if (null === $license = $input->getOption('license')) {
  4677. if (!empty($_SERVER['COMPOSER_DEFAULT_LICENSE'])) {
  4678. $license = $_SERVER['COMPOSER_DEFAULT_LICENSE'];
  4679. }
  4680. }
  4681. $license = $io->ask(
  4682. 'License [<comment>'.$license.'</comment>]: ',
  4683. $license
  4684. );
  4685. $input->setOption('license', $license);
  4686. $io->writeError(array('', 'Define your dependencies.', ''));
  4687. $repos = $this->getRepos();
  4688. $preferredStability = $minimumStability ?: 'stable';
  4689. $platformRepo = null;
  4690. if ($repos instanceof CompositeRepository) {
  4691. foreach ($repos->getRepositories() as $candidateRepo) {
  4692. if ($candidateRepo instanceof PlatformRepository) {
  4693. $platformRepo = $candidateRepo;
  4694. break;
  4695. }
  4696. }
  4697. }
  4698. $question = 'Would you like to define your dependencies (require) interactively [<comment>yes</comment>]? ';
  4699. $require = $input->getOption('require');
  4700. $requirements = array();
  4701. if (count($require) > 0 || $io->askConfirmation($question)) {
  4702. $requirements = $this->determineRequirements($input, $output, $require, $platformRepo, $preferredStability);
  4703. }
  4704. $input->setOption('require', $requirements);
  4705. $question = 'Would you like to define your dev dependencies (require-dev) interactively [<comment>yes</comment>]? ';
  4706. $requireDev = $input->getOption('require-dev');
  4707. $devRequirements = array();
  4708. if (count($requireDev) > 0 || $io->askConfirmation($question)) {
  4709. $devRequirements = $this->determineRequirements($input, $output, $requireDev, $platformRepo, $preferredStability);
  4710. }
  4711. $input->setOption('require-dev', $devRequirements);
  4712. $autoload = $input->getOption('autoload') ?: 'src/';
  4713. $namespace = $this->namespaceFromPackageName((string) $input->getOption('name'));
  4714. $autoload = $io->askAndValidate(
  4715. 'Add PSR-4 autoload mapping? Maps namespace "'.$namespace.'" to the entered relative path. [<comment>'.$autoload.'</comment>, n to skip]: ',
  4716. function ($value) use ($autoload) {
  4717. if (null === $value) {
  4718. return $autoload;
  4719. }
  4720. if ($value === 'n' || $value === 'no') {
  4721. return;
  4722. }
  4723. $value = $value ?: $autoload;
  4724. if (!Preg::isMatch('{^[^/][A-Za-z0-9\-_/]+/$}', $value)) {
  4725. throw new \InvalidArgumentException(sprintf(
  4726. 'The src folder name "%s" is invalid. Please add a relative path with tailing forward slash. [A-Za-z0-9_-/]+/',
  4727. $value
  4728. ));
  4729. }
  4730. return $value;
  4731. },
  4732. null,
  4733. $autoload
  4734. );
  4735. $input->setOption('autoload', $autoload);
  4736. }
  4737. private function parseAuthorString(string $author): array
  4738. {
  4739. if (Preg::isMatch('/^(?P<name>[- .,\p{L}\p{N}\p{Mn}\'’"()]+)(?:\s+<(?P<email>.+?)>)?$/u', $author, $match)) {
  4740. $hasEmail = isset($match['email']) && '' !== $match['email'];
  4741. if ($hasEmail && !$this->isValidEmail($match['email'])) {
  4742. throw new \InvalidArgumentException('Invalid email "'.$match['email'].'"');
  4743. }
  4744. return array(
  4745. 'name' => trim($match['name']),
  4746. 'email' => $hasEmail ? $match['email'] : null,
  4747. );
  4748. }
  4749. throw new \InvalidArgumentException(
  4750. 'Invalid author string. Must be in the formats: '.
  4751. 'Jane Doe or John Smith <john@example.com>'
  4752. );
  4753. }
  4754. protected function formatAuthors(string $author): array
  4755. {
  4756. $author = $this->parseAuthorString($author);
  4757. if (null === $author['email']) {
  4758. unset($author['email']);
  4759. }
  4760. return array($author);
  4761. }
  4762. public function namespaceFromPackageName(string $packageName): ?string
  4763. {
  4764. if (!$packageName || strpos($packageName, '/') === false) {
  4765. return null;
  4766. }
  4767. $namespace = array_map(
  4768. function ($part): string {
  4769. $part = Preg::replace('/[^a-z0-9]/i', ' ', $part);
  4770. $part = ucwords($part);
  4771. return str_replace(' ', '', $part);
  4772. },
  4773. explode('/', $packageName)
  4774. );
  4775. return join('\\', $namespace);
  4776. }
  4777. protected function getGitConfig(): array
  4778. {
  4779. if (null !== $this->gitConfig) {
  4780. return $this->gitConfig;
  4781. }
  4782. $finder = new ExecutableFinder();
  4783. $gitBin = $finder->find('git');
  4784. $cmd = new Process(array($gitBin, 'config', '-l'));
  4785. $cmd->run();
  4786. if ($cmd->isSuccessful()) {
  4787. $this->gitConfig = array();
  4788. Preg::matchAll('{^([^=]+)=(.*)$}m', $cmd->getOutput(), $matches);
  4789. foreach ($matches[1] as $key => $match) {
  4790. $this->gitConfig[$match] = $matches[2][$key];
  4791. }
  4792. return $this->gitConfig;
  4793. }
  4794. return $this->gitConfig = array();
  4795. }
  4796. protected function hasVendorIgnore(string $ignoreFile, string $vendor = 'vendor'): bool
  4797. {
  4798. if (!file_exists($ignoreFile)) {
  4799. return false;
  4800. }
  4801. $pattern = sprintf('{^/?%s(/\*?)?$}', preg_quote($vendor));
  4802. $lines = file($ignoreFile, FILE_IGNORE_NEW_LINES);
  4803. foreach ($lines as $line) {
  4804. if (Preg::isMatch($pattern, $line)) {
  4805. return true;
  4806. }
  4807. }
  4808. return false;
  4809. }
  4810. protected function addVendorIgnore(string $ignoreFile, string $vendor = '/vendor/'): void
  4811. {
  4812. $contents = "";
  4813. if (file_exists($ignoreFile)) {
  4814. $contents = file_get_contents($ignoreFile);
  4815. if (strpos($contents, "\n") !== 0) {
  4816. $contents .= "\n";
  4817. }
  4818. }
  4819. file_put_contents($ignoreFile, $contents . $vendor. "\n");
  4820. }
  4821. protected function isValidEmail(string $email): bool
  4822. {
  4823. if (!function_exists('filter_var')) {
  4824. return true;
  4825. }
  4826. return false !== filter_var($email, FILTER_VALIDATE_EMAIL);
  4827. }
  4828. private function updateDependencies(OutputInterface $output): void
  4829. {
  4830. try {
  4831. $updateCommand = $this->getApplication()->find('update');
  4832. $this->getApplication()->resetComposer();
  4833. $updateCommand->run(new ArrayInput(array()), $output);
  4834. } catch (\Exception $e) {
  4835. $this->getIO()->writeError('Could not update dependencies. Run `composer update` to see more information.');
  4836. }
  4837. }
  4838. private function runDumpAutoloadCommand(OutputInterface $output): void
  4839. {
  4840. try {
  4841. $command = $this->getApplication()->find('dump-autoload');
  4842. $this->getApplication()->resetComposer();
  4843. $command->run(new ArrayInput(array()), $output);
  4844. } catch (\Exception $e) {
  4845. $this->getIO()->writeError('Could not run dump-autoload.');
  4846. }
  4847. }
  4848. private function hasDependencies(array $options): bool
  4849. {
  4850. $requires = (array) $options['require'];
  4851. $devRequires = isset($options['require-dev']) ? (array) $options['require-dev'] : array();
  4852. return !empty($requires) || !empty($devRequires);
  4853. }
  4854. }
  4855. <?php declare(strict_types=1);
  4856. namespace Composer\Command;
  4857. use Composer\Installer;
  4858. use Composer\Plugin\CommandEvent;
  4859. use Composer\Plugin\PluginEvents;
  4860. use Composer\Util\HttpDownloader;
  4861. use Symfony\Component\Console\Input\InputInterface;
  4862. use Symfony\Component\Console\Input\InputOption;
  4863. use Symfony\Component\Console\Input\InputArgument;
  4864. use Symfony\Component\Console\Output\OutputInterface;
  4865. class InstallCommand extends BaseCommand
  4866. {
  4867. protected function configure()
  4868. {
  4869. $this
  4870. ->setName('install')
  4871. ->setAliases(array('i'))
  4872. ->setDescription('Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json.')
  4873. ->setDefinition(array(
  4874. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  4875. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
  4876. new InputOption('prefer-install', null, InputOption::VALUE_REQUIRED, 'Forces installation from package dist|source|auto (auto chooses source for dev versions, dist for the rest).'),
  4877. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  4878. new InputOption('dev', null, InputOption::VALUE_NONE, 'DEPRECATED: Enables installation of require-dev packages (enabled by default, only present for BC).'),
  4879. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  4880. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  4881. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  4882. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  4883. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Do not use, only defined here to catch misuse of the install command.'),
  4884. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
  4885. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  4886. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  4887. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  4888. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  4889. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  4890. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  4891. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Should not be provided, use composer require instead to add a given package to composer.json.'),
  4892. ))
  4893. ->setHelp(
  4894. <<<EOT
  4895. The <info>install</info> command reads the composer.lock file from
  4896. the current directory, processes it, and downloads and installs all the
  4897. libraries and dependencies outlined in that file. If the file does not
  4898. exist it will look for composer.json and do the same.
  4899. <info>php composer.phar install</info>
  4900. Read more at https://getcomposer.org/doc/03-cli.md#install-i
  4901. EOT
  4902. )
  4903. ;
  4904. }
  4905. protected function execute(InputInterface $input, OutputInterface $output)
  4906. {
  4907. $io = $this->getIO();
  4908. if ($input->getOption('dev')) {
  4909. $io->writeError('<warning>You are using the deprecated option "--dev". It has no effect and will break in Composer 3.</warning>');
  4910. }
  4911. if ($input->getOption('no-suggest')) {
  4912. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  4913. }
  4914. $args = $input->getArgument('packages');
  4915. if (count($args) > 0) {
  4916. $io->writeError('<error>Invalid argument '.implode(' ', $args).'. Use "composer require '.implode(' ', $args).'" instead to add packages to your composer.json.</error>');
  4917. return 1;
  4918. }
  4919. if ($input->getOption('no-install')) {
  4920. $io->writeError('<error>Invalid option "--no-install". Use "composer update --no-install" instead if you are trying to update the composer.lock file.</error>');
  4921. return 1;
  4922. }
  4923. $composer = $this->requireComposer();
  4924. if (!$composer->getLocker()->isLocked() && !HttpDownloader::isCurlEnabled()) {
  4925. $io->writeError('<warning>Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.</warning>');
  4926. }
  4927. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'install', $input, $output);
  4928. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  4929. $install = Installer::create($io, $composer);
  4930. $config = $composer->getConfig();
  4931. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  4932. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  4933. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  4934. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  4935. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  4936. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  4937. $install
  4938. ->setDryRun($input->getOption('dry-run'))
  4939. ->setVerbose($input->getOption('verbose'))
  4940. ->setPreferSource($preferSource)
  4941. ->setPreferDist($preferDist)
  4942. ->setDevMode(!$input->getOption('no-dev'))
  4943. ->setDumpAutoloader(!$input->getOption('no-autoloader'))
  4944. ->setOptimizeAutoloader($optimize)
  4945. ->setClassMapAuthoritative($authoritative)
  4946. ->setApcuAutoloader($apcu, $apcuPrefix)
  4947. ->setPlatformRequirementFilter($this->getPlatformRequirementFilter($input))
  4948. ;
  4949. if ($input->getOption('no-plugins')) {
  4950. $install->disablePlugins();
  4951. }
  4952. return $install->run();
  4953. }
  4954. }
  4955. <?php declare(strict_types=1);
  4956. namespace Composer\Command;
  4957. use Composer\Json\JsonFile;
  4958. use Composer\Package\CompletePackageInterface;
  4959. use Composer\Plugin\CommandEvent;
  4960. use Composer\Plugin\PluginEvents;
  4961. use Composer\Package\PackageInterface;
  4962. use Composer\Repository\RepositoryInterface;
  4963. use Composer\Util\PackageInfo;
  4964. use Symfony\Component\Console\Formatter\OutputFormatter;
  4965. use Symfony\Component\Console\Helper\Table;
  4966. use Symfony\Component\Console\Input\InputInterface;
  4967. use Symfony\Component\Console\Input\InputOption;
  4968. use Symfony\Component\Console\Output\OutputInterface;
  4969. use Symfony\Component\Console\Style\SymfonyStyle;
  4970. class LicensesCommand extends BaseCommand
  4971. {
  4972. protected function configure(): void
  4973. {
  4974. $this
  4975. ->setName('licenses')
  4976. ->setDescription('Shows information about licenses of dependencies.')
  4977. ->setDefinition(array(
  4978. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text, json or summary', 'text'),
  4979. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  4980. ))
  4981. ->setHelp(
  4982. <<<EOT
  4983. The license command displays detailed information about the licenses of
  4984. the installed dependencies.
  4985. Read more at https://getcomposer.org/doc/03-cli.md#licenses
  4986. EOT
  4987. )
  4988. ;
  4989. }
  4990. protected function execute(InputInterface $input, OutputInterface $output): int
  4991. {
  4992. $composer = $this->requireComposer();
  4993. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'licenses', $input, $output);
  4994. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  4995. $root = $composer->getPackage();
  4996. $repo = $composer->getRepositoryManager()->getLocalRepository();
  4997. if ($input->getOption('no-dev')) {
  4998. $packages = $this->filterRequiredPackages($repo, $root);
  4999. } else {
  5000. $packages = $this->appendPackages($repo->getPackages(), array());
  5001. }
  5002. ksort($packages);
  5003. $io = $this->getIO();
  5004. switch ($format = $input->getOption('format')) {
  5005. case 'text':
  5006. $io->write('Name: <comment>'.$root->getPrettyName().'</comment>');
  5007. $io->write('Version: <comment>'.$root->getFullPrettyVersion().'</comment>');
  5008. $io->write('Licenses: <comment>'.(implode(', ', $root->getLicense()) ?: 'none').'</comment>');
  5009. $io->write('Dependencies:');
  5010. $io->write('');
  5011. $table = new Table($output);
  5012. $table->setStyle('compact');
  5013. $tableStyle = $table->getStyle();
  5014. $tableStyle->setVerticalBorderChars('');
  5015. $tableStyle->setCellRowContentFormat('%s ');
  5016. $table->setHeaders(array('Name', 'Version', 'Licenses'));
  5017. foreach ($packages as $package) {
  5018. $link = PackageInfo::getViewSourceOrHomepageUrl($package);
  5019. if ($link !== null) {
  5020. $name = '<href='.OutputFormatter::escape($link).'>'.$package->getPrettyName().'</>';
  5021. } else {
  5022. $name = $package->getPrettyName();
  5023. }
  5024. $table->addRow(array(
  5025. $name,
  5026. $package->getFullPrettyVersion(),
  5027. implode(', ', $package instanceof CompletePackageInterface ? $package->getLicense() : array()) ?: 'none',
  5028. ));
  5029. }
  5030. $table->render();
  5031. break;
  5032. case 'json':
  5033. $dependencies = array();
  5034. foreach ($packages as $package) {
  5035. $dependencies[$package->getPrettyName()] = array(
  5036. 'version' => $package->getFullPrettyVersion(),
  5037. 'license' => $package instanceof CompletePackageInterface ? $package->getLicense() : array(),
  5038. );
  5039. }
  5040. $io->write(JsonFile::encode(array(
  5041. 'name' => $root->getPrettyName(),
  5042. 'version' => $root->getFullPrettyVersion(),
  5043. 'license' => $root->getLicense(),
  5044. 'dependencies' => $dependencies,
  5045. )));
  5046. break;
  5047. case 'summary':
  5048. $usedLicenses = array();
  5049. foreach ($packages as $package) {
  5050. $licenses = $package instanceof CompletePackageInterface ? $package->getLicense() : array();
  5051. if (count($licenses) === 0) {
  5052. $licenses[] = 'none';
  5053. }
  5054. foreach ($licenses as $licenseName) {
  5055. if (!isset($usedLicenses[$licenseName])) {
  5056. $usedLicenses[$licenseName] = 0;
  5057. }
  5058. $usedLicenses[$licenseName]++;
  5059. }
  5060. }
  5061. arsort($usedLicenses, SORT_NUMERIC);
  5062. $rows = array();
  5063. foreach ($usedLicenses as $usedLicense => $numberOfDependencies) {
  5064. $rows[] = array($usedLicense, $numberOfDependencies);
  5065. }
  5066. $symfonyIo = new SymfonyStyle($input, $output);
  5067. $symfonyIo->table(
  5068. array('License', 'Number of dependencies'),
  5069. $rows
  5070. );
  5071. break;
  5072. default:
  5073. throw new \RuntimeException(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  5074. }
  5075. return 0;
  5076. }
  5077. private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, array $bucket = array()): array
  5078. {
  5079. $requires = array_keys($package->getRequires());
  5080. $packageListNames = array_keys($bucket);
  5081. $packages = array_filter(
  5082. $repo->getPackages(),
  5083. function ($package) use ($requires, $packageListNames): bool {
  5084. return in_array($package->getName(), $requires) && !in_array($package->getName(), $packageListNames);
  5085. }
  5086. );
  5087. $bucket = $this->appendPackages($packages, $bucket);
  5088. foreach ($packages as $package) {
  5089. $bucket = $this->filterRequiredPackages($repo, $package, $bucket);
  5090. }
  5091. return $bucket;
  5092. }
  5093. public function appendPackages(array $packages, array $bucket): array
  5094. {
  5095. foreach ($packages as $package) {
  5096. $bucket[$package->getName()] = $package;
  5097. }
  5098. return $bucket;
  5099. }
  5100. }
  5101. <?php declare(strict_types=1);
  5102. namespace Composer\Command;
  5103. use Symfony\Component\Console\Input\InputInterface;
  5104. use Symfony\Component\Console\Input\InputArgument;
  5105. use Symfony\Component\Console\Input\ArrayInput;
  5106. use Symfony\Component\Console\Input\InputOption;
  5107. use Symfony\Component\Console\Output\OutputInterface;
  5108. class OutdatedCommand extends BaseCommand
  5109. {
  5110. protected function configure(): void
  5111. {
  5112. $this
  5113. ->setName('outdated')
  5114. ->setDescription('Shows a list of installed packages that have updates available, including their latest version.')
  5115. ->setDefinition(array(
  5116. new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.'),
  5117. new InputOption('outdated', 'o', InputOption::VALUE_NONE, 'Show only packages that are outdated (this is the default, but present here for compat with `show`'),
  5118. new InputOption('all', 'a', InputOption::VALUE_NONE, 'Show all installed packages with their latest versions'),
  5119. new InputOption('locked', null, InputOption::VALUE_NONE, 'Shows updates for packages from the lock file, regardless of what is currently in vendor dir'),
  5120. new InputOption('direct', 'D', InputOption::VALUE_NONE, 'Shows only packages that are directly required by the root package'),
  5121. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code when there are outdated packages'),
  5122. new InputOption('minor-only', 'm', InputOption::VALUE_NONE, 'Show only packages that have minor SemVer-compatible updates. Use with the --outdated option.'),
  5123. new InputOption('patch-only', 'p', InputOption::VALUE_NONE, 'Show only packages that have patch SemVer-compatible updates. Use with the --outdated option.'),
  5124. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
  5125. 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.'),
  5126. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  5127. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages). Use with the --outdated option'),
  5128. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages). Use with the --outdated option'),
  5129. ))
  5130. ->setHelp(
  5131. <<<EOT
  5132. The outdated command is just a proxy for `composer show -l`
  5133. The color coding (or signage if you have ANSI colors disabled) for dependency versions is as such:
  5134. - <info>green</info> (=): Dependency is in the latest version and is up to date.
  5135. - <comment>yellow</comment> (~): Dependency has a new version available that includes backwards
  5136. compatibility breaks according to semver, so upgrade when you can but it
  5137. may involve work.
  5138. - <highlight>red</highlight> (!): Dependency has a new version that is semver-compatible and you should upgrade it.
  5139. Read more at https://getcomposer.org/doc/03-cli.md#outdated
  5140. EOT
  5141. )
  5142. ;
  5143. }
  5144. protected function execute(InputInterface $input, OutputInterface $output): int
  5145. {
  5146. $args = array(
  5147. 'command' => 'show',
  5148. '--latest' => true,
  5149. );
  5150. if (!$input->getOption('all')) {
  5151. $args['--outdated'] = true;
  5152. }
  5153. if ($input->getOption('direct')) {
  5154. $args['--direct'] = true;
  5155. }
  5156. if (null !== $input->getArgument('package')) {
  5157. $args['package'] = $input->getArgument('package');
  5158. }
  5159. if ($input->getOption('strict')) {
  5160. $args['--strict'] = true;
  5161. }
  5162. if ($input->getOption('minor-only')) {
  5163. $args['--minor-only'] = true;
  5164. }
  5165. if ($input->getOption('patch-only')) {
  5166. $args['--patch-only'] = true;
  5167. }
  5168. if ($input->getOption('locked')) {
  5169. $args['--locked'] = true;
  5170. }
  5171. if ($input->getOption('no-dev')) {
  5172. $args['--no-dev'] = true;
  5173. }
  5174. $args['--ignore-platform-req'] = $input->getOption('ignore-platform-req');
  5175. if ($input->getOption('ignore-platform-reqs')) {
  5176. $args['--ignore-platform-reqs'] = true;
  5177. }
  5178. $args['--format'] = $input->getOption('format');
  5179. $args['--ignore'] = $input->getOption('ignore');
  5180. $input = new ArrayInput($args);
  5181. return $this->getApplication()->run($input, $output);
  5182. }
  5183. public function isProxyCommand(): bool
  5184. {
  5185. return true;
  5186. }
  5187. }
  5188. <?php declare(strict_types=1);
  5189. namespace Composer\Command;
  5190. use Composer\Factory;
  5191. use Composer\Filter\PlatformRequirementFilter\IgnoreAllPlatformRequirementFilter;
  5192. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  5193. use Composer\Package\CompletePackageInterface;
  5194. use Composer\Package\PackageInterface;
  5195. use Composer\Package\Version\VersionParser;
  5196. use Composer\Package\Version\VersionSelector;
  5197. use Composer\Pcre\Preg;
  5198. use Composer\Repository\CompositeRepository;
  5199. use Composer\Repository\PlatformRepository;
  5200. use Composer\Repository\RepositoryFactory;
  5201. use Composer\Repository\RepositorySet;
  5202. use Composer\Semver\Constraint\Constraint;
  5203. use Composer\Util\Filesystem;
  5204. use Symfony\Component\Console\Input\InputInterface;
  5205. use Symfony\Component\Console\Output\OutputInterface;
  5206. trait PackageDiscoveryTrait
  5207. {
  5208. private $repos;
  5209. private $repositorySets;
  5210. protected function getRepos(): CompositeRepository
  5211. {
  5212. if (null === $this->repos) {
  5213. $this->repos = new CompositeRepository(array_merge(
  5214. array(new PlatformRepository),
  5215. RepositoryFactory::defaultRepos($this->getIO())
  5216. ));
  5217. }
  5218. return $this->repos;
  5219. }
  5220. private function getRepositorySet(InputInterface $input, ?string $minimumStability = null): RepositorySet
  5221. {
  5222. $key = $minimumStability ?? 'default';
  5223. if (!isset($this->repositorySets[$key])) {
  5224. $this->repositorySets[$key] = $repositorySet = new RepositorySet($minimumStability ?? $this->getMinimumStability($input));
  5225. $repositorySet->addRepository($this->getRepos());
  5226. }
  5227. return $this->repositorySets[$key];
  5228. }
  5229. private function getMinimumStability(InputInterface $input): string
  5230. {
  5231. if ($input->hasOption('stability')) {
  5232. return VersionParser::normalizeStability($input->getOption('stability') ?? 'stable');
  5233. }
  5234. $file = Factory::getComposerFile();
  5235. if (is_file($file) && Filesystem::isReadable($file) && is_array($composer = json_decode((string) file_get_contents($file), true))) {
  5236. if (!empty($composer['minimum-stability'])) {
  5237. return VersionParser::normalizeStability($composer['minimum-stability']);
  5238. }
  5239. }
  5240. return 'stable';
  5241. }
  5242. final protected function determineRequirements(InputInterface $input, OutputInterface $output, array $requires = array(), ?PlatformRepository $platformRepo = null, string $preferredStability = 'stable', bool $checkProvidedVersions = true, bool $fixed = false): array
  5243. {
  5244. if (count($requires) > 0) {
  5245. $requires = $this->normalizeRequirements($requires);
  5246. $result = array();
  5247. $io = $this->getIO();
  5248. foreach ($requires as $requirement) {
  5249. if (!isset($requirement['version'])) {
  5250. list($name, $version) = $this->findBestVersionAndNameForPackage($input, $requirement['name'], $platformRepo, $preferredStability, null, null, $fixed);
  5251. $requirement['version'] = $version;
  5252. $requirement['name'] = $name;
  5253. $io->writeError(sprintf(
  5254. 'Using version <info>%s</info> for <info>%s</info>',
  5255. $requirement['version'],
  5256. $requirement['name']
  5257. ));
  5258. }
  5259. $result[] = $requirement['name'] . ' ' . $requirement['version'];
  5260. }
  5261. return $result;
  5262. }
  5263. $versionParser = new VersionParser();
  5264. $composer = $this->tryComposer();
  5265. $installedRepo = null;
  5266. if (null !== $composer) {
  5267. $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
  5268. }
  5269. $existingPackages = array();
  5270. if (null !== $installedRepo) {
  5271. foreach ($installedRepo->getPackages() as $package) {
  5272. $existingPackages[] = $package->getName();
  5273. }
  5274. }
  5275. unset($composer, $installedRepo);
  5276. $io = $this->getIO();
  5277. while (null !== $package = $io->ask('Search for a package: ')) {
  5278. $matches = $this->getRepos()->search($package);
  5279. if (count($matches) > 0) {
  5280. foreach ($matches as $position => $foundPackage) {
  5281. if (in_array($foundPackage['name'], $existingPackages, true)) {
  5282. unset($matches[$position]);
  5283. }
  5284. }
  5285. $matches = array_values($matches);
  5286. $exactMatch = false;
  5287. foreach ($matches as $match) {
  5288. if ($match['name'] === $package) {
  5289. $exactMatch = true;
  5290. break;
  5291. }
  5292. }
  5293. if (!$exactMatch) {
  5294. $providers = $this->getRepos()->getProviders($package);
  5295. if (count($providers) > 0) {
  5296. array_unshift($matches, array('name' => $package, 'description' => ''));
  5297. }
  5298. $choices = array();
  5299. foreach ($matches as $position => $foundPackage) {
  5300. $abandoned = '';
  5301. if (isset($foundPackage['abandoned'])) {
  5302. if (is_string($foundPackage['abandoned'])) {
  5303. $replacement = sprintf('Use %s instead', $foundPackage['abandoned']);
  5304. } else {
  5305. $replacement = 'No replacement was suggested';
  5306. }
  5307. $abandoned = sprintf('<warning>Abandoned. %s.</warning>', $replacement);
  5308. }
  5309. $choices[] = sprintf(' <info>%5s</info> %s %s', "[$position]", $foundPackage['name'], $abandoned);
  5310. }
  5311. $io->writeError(array(
  5312. '',
  5313. sprintf('Found <info>%s</info> packages matching <info>%s</info>', count($matches), $package),
  5314. '',
  5315. ));
  5316. $io->writeError($choices);
  5317. $io->writeError('');
  5318. $validator = function (string $selection) use ($matches, $versionParser) {
  5319. if ('' === $selection) {
  5320. return false;
  5321. }
  5322. if (is_numeric($selection) && isset($matches[(int) $selection])) {
  5323. $package = $matches[(int) $selection];
  5324. return $package['name'];
  5325. }
  5326. if (Preg::isMatch('{^\s*(?P<name>[\S/]+)(?:\s+(?P<version>\S+))?\s*$}', $selection, $packageMatches)) {
  5327. if (isset($packageMatches['version'])) {
  5328. $versionParser->parseConstraints($packageMatches['version']);
  5329. return $packageMatches['name'].' '.$packageMatches['version'];
  5330. }
  5331. return $packageMatches['name'];
  5332. }
  5333. throw new \Exception('Not a valid selection');
  5334. };
  5335. $package = $io->askAndValidate(
  5336. 'Enter package # to add, or the complete package name if it is not listed: ',
  5337. $validator,
  5338. 3,
  5339. ''
  5340. );
  5341. }
  5342. if (false !== $package && false === strpos($package, ' ')) {
  5343. $validator = function (string $input) {
  5344. $input = trim($input);
  5345. return strlen($input) > 0 ? $input : false;
  5346. };
  5347. $constraint = $io->askAndValidate(
  5348. 'Enter the version constraint to require (or leave blank to use the latest version): ',
  5349. $validator,
  5350. 3,
  5351. ''
  5352. );
  5353. if (false === $constraint) {
  5354. list(, $constraint) = $this->findBestVersionAndNameForPackage($input, $package, $platformRepo, $preferredStability);
  5355. $io->writeError(sprintf(
  5356. 'Using version <info>%s</info> for <info>%s</info>',
  5357. $constraint,
  5358. $package
  5359. ));
  5360. }
  5361. $package .= ' '.$constraint;
  5362. }
  5363. if (false !== $package) {
  5364. $requires[] = $package;
  5365. $existingPackages[] = explode(' ', $package)[0];
  5366. }
  5367. }
  5368. }
  5369. return $requires;
  5370. }
  5371. private function findBestVersionAndNameForPackage(InputInterface $input, string $name, ?PlatformRepository $platformRepo = null, string $preferredStability = 'stable', ?string $requiredVersion = null, ?string $minimumStability = null, bool $fixed = false): array
  5372. {
  5373. $platformRequirementFilter = $this->getPlatformRequirementFilter($input);
  5374. $repoSet = $this->getRepositorySet($input, $minimumStability);
  5375. $versionSelector = new VersionSelector($repoSet, $platformRepo);
  5376. $effectiveMinimumStability = $minimumStability ?? $this->getMinimumStability($input);
  5377. $package = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, $platformRequirementFilter);
  5378. if (false === $package) {
  5379. if ($platformRequirementFilter->isIgnored($name)) {
  5380. return array($name, $requiredVersion ?: '*');
  5381. }
  5382. $providers = $repoSet->getProviders($name);
  5383. if (count($providers) > 0) {
  5384. $constraint = '*';
  5385. if ($input->isInteractive()) {
  5386. $constraint = $this->getIO()->askAndValidate('Package "<info>'.$name.'</info>" does not exist but is provided by '.count($providers).' packages. Which version constraint would you like to use? [<info>*</info>] ', function ($value) {
  5387. $parser = new VersionParser();
  5388. $parser->parseConstraints($value);
  5389. return $value;
  5390. }, 3, '*');
  5391. }
  5392. return array($name, $constraint);
  5393. }
  5394. if (!($platformRequirementFilter instanceof IgnoreAllPlatformRequirementFilter) && false !== ($candidate = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, PlatformRequirementFilterFactory::ignoreAll()))) {
  5395. throw new \InvalidArgumentException(sprintf(
  5396. 'Package %s%s has requirements incompatible with your PHP version, PHP extensions and Composer version' . $this->getPlatformExceptionDetails($candidate, $platformRepo),
  5397. $name,
  5398. is_string($requiredVersion) ? ' at version '.$requiredVersion : ''
  5399. ));
  5400. }
  5401. if (false !== ($package = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, $platformRequirementFilter, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES))) {
  5402. if (false !== ($allReposPackage = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, $platformRequirementFilter, RepositorySet::ALLOW_SHADOWED_REPOSITORIES))) {
  5403. throw new \InvalidArgumentException(
  5404. 'Package '.$name.' exists in '.$allReposPackage->getRepository()->getRepoName().' and '.$package->getRepository()->getRepoName().' which has a higher repository priority. The packages from the higher priority repository do not match your minimum-stability and are therefore not installable. That repository is canonical so the lower priority repo\'s packages are not installable. See https://getcomposer.org/repoprio for details and assistance.'
  5405. );
  5406. }
  5407. throw new \InvalidArgumentException(sprintf(
  5408. 'Could not find a version of package %s matching your minimum-stability (%s). Require it with an explicit version constraint allowing its desired stability.',
  5409. $name,
  5410. $effectiveMinimumStability
  5411. ));
  5412. }
  5413. if (is_string($requiredVersion) && false !== ($package = $versionSelector->findBestCandidate($name, null, $preferredStability, $platformRequirementFilter))) {
  5414. if (false !== ($allReposPackage = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, PlatformRequirementFilterFactory::ignoreNothing(), RepositorySet::ALLOW_SHADOWED_REPOSITORIES))) {
  5415. throw new \InvalidArgumentException(
  5416. 'Package '.$name.' exists in '.$allReposPackage->getRepository()->getRepoName().' and '.$package->getRepository()->getRepoName().' which has a higher repository priority. The packages from the higher priority repository do not match your constraint and are therefore not installable. That repository is canonical so the lower priority repo\'s packages are not installable. See https://getcomposer.org/repoprio for details and assistance.'
  5417. );
  5418. }
  5419. throw new \InvalidArgumentException(sprintf(
  5420. 'Could not find package %s in a version matching "%s" and a stability matching "'.$effectiveMinimumStability.'".',
  5421. $name,
  5422. $requiredVersion
  5423. ));
  5424. }
  5425. if (!$platformRequirementFilter instanceof IgnoreAllPlatformRequirementFilter && false !== ($candidate = $versionSelector->findBestCandidate($name, null, $preferredStability, PlatformRequirementFilterFactory::ignoreAll(), RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES))) {
  5426. $additional = '';
  5427. if (false === $versionSelector->findBestCandidate($name, null, $preferredStability, PlatformRequirementFilterFactory::ignoreAll())) {
  5428. $additional = PHP_EOL.PHP_EOL.'Additionally, the package was only found with a stability of "'.$candidate->getStability().'" while your minimum stability is "'.$effectiveMinimumStability.'".';
  5429. }
  5430. throw new \InvalidArgumentException(sprintf(
  5431. 'Could not find package %s in any version matching your PHP version, PHP extensions and Composer version' . $this->getPlatformExceptionDetails($candidate, $platformRepo) . '%s',
  5432. $name,
  5433. $additional
  5434. ));
  5435. }
  5436. $similar = $this->findSimilar($name);
  5437. if (count($similar) > 0) {
  5438. if (in_array($name, $similar, true)) {
  5439. throw new \InvalidArgumentException(sprintf(
  5440. "Could not find package %s. It was however found via repository search, which indicates a consistency issue with the repository.",
  5441. $name
  5442. ));
  5443. }
  5444. throw new \InvalidArgumentException(sprintf(
  5445. "Could not find package %s.\n\nDid you mean " . (count($similar) > 1 ? 'one of these' : 'this') . "?\n %s",
  5446. $name,
  5447. implode("\n ", $similar)
  5448. ));
  5449. }
  5450. throw new \InvalidArgumentException(sprintf(
  5451. '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).',
  5452. $name,
  5453. $effectiveMinimumStability
  5454. ));
  5455. }
  5456. return array(
  5457. $package->getPrettyName(),
  5458. $fixed ? $package->getPrettyVersion() : $versionSelector->findRecommendedRequireVersion($package),
  5459. );
  5460. }
  5461. private function findSimilar(string $package): array
  5462. {
  5463. try {
  5464. if (null === $this->repos) {
  5465. throw new \LogicException('findSimilar was called before $this->repos was initialized');
  5466. }
  5467. $results = $this->repos->search($package);
  5468. } catch (\Throwable $e) {
  5469. if ($e instanceof \LogicException) {
  5470. throw $e;
  5471. }
  5472. return array();
  5473. }
  5474. $similarPackages = array();
  5475. $installedRepo = $this->requireComposer()->getRepositoryManager()->getLocalRepository();
  5476. foreach ($results as $result) {
  5477. if (null !== $installedRepo->findPackage($result['name'], '*')) {
  5478. continue;
  5479. }
  5480. $similarPackages[$result['name']] = levenshtein($package, $result['name']);
  5481. }
  5482. asort($similarPackages);
  5483. return array_keys(array_slice($similarPackages, 0, 5));
  5484. }
  5485. private function getPlatformExceptionDetails(PackageInterface $candidate, ?PlatformRepository $platformRepo = null): string
  5486. {
  5487. $details = array();
  5488. if (null === $platformRepo) {
  5489. return '';
  5490. }
  5491. foreach ($candidate->getRequires() as $link) {
  5492. if (!PlatformRepository::isPlatformPackage($link->getTarget())) {
  5493. continue;
  5494. }
  5495. $platformPkg = $platformRepo->findPackage($link->getTarget(), '*');
  5496. if (null === $platformPkg) {
  5497. if ($platformRepo->isPlatformPackageDisabled($link->getTarget())) {
  5498. $details[] = $candidate->getPrettyName().' '.$candidate->getPrettyVersion().' requires '.$link->getTarget().' '.$link->getPrettyConstraint().' but it is disabled by your platform config. Enable it again with "composer config platform.'.$link->getTarget().' --unset".';
  5499. } else {
  5500. $details[] = $candidate->getPrettyName().' '.$candidate->getPrettyVersion().' requires '.$link->getTarget().' '.$link->getPrettyConstraint().' but it is not present.';
  5501. }
  5502. continue;
  5503. }
  5504. if (!$link->getConstraint()->matches(new Constraint('==', $platformPkg->getVersion()))) {
  5505. $platformPkgVersion = $platformPkg->getPrettyVersion();
  5506. $platformExtra = $platformPkg->getExtra();
  5507. if (isset($platformExtra['config.platform']) && $platformPkg instanceof CompletePackageInterface) {
  5508. $platformPkgVersion .= ' ('.$platformPkg->getDescription().')';
  5509. }
  5510. $details[] = $candidate->getPrettyName().' '.$candidate->getPrettyVersion().' requires '.$link->getTarget().' '.$link->getPrettyConstraint().' which does not match your installed version '.$platformPkgVersion.'.';
  5511. }
  5512. }
  5513. if (count($details) === 0) {
  5514. return '';
  5515. }
  5516. return ':'.PHP_EOL.' - ' . implode(PHP_EOL.' - ', $details);
  5517. }
  5518. }
  5519. <?php declare(strict_types=1);
  5520. namespace Composer\Command;
  5521. use Symfony\Component\Console\Input\InputInterface;
  5522. use Symfony\Component\Console\Output\OutputInterface;
  5523. use Symfony\Component\Console\Input\InputArgument;
  5524. use Symfony\Component\Console\Input\InputOption;
  5525. class ProhibitsCommand extends BaseDependencyCommand
  5526. {
  5527. protected function configure(): void
  5528. {
  5529. $this
  5530. ->setName('prohibits')
  5531. ->setAliases(array('why-not'))
  5532. ->setDescription('Shows which packages prevent the given package from being installed.')
  5533. ->setDefinition(array(
  5534. new InputArgument(self::ARGUMENT_PACKAGE, InputArgument::REQUIRED, 'Package to inspect'),
  5535. new InputArgument(self::ARGUMENT_CONSTRAINT, InputArgument::REQUIRED, 'Version constraint, which version you expected to be installed'),
  5536. new InputOption(self::OPTION_RECURSIVE, 'r', InputOption::VALUE_NONE, 'Recursively resolves up to the root package'),
  5537. new InputOption(self::OPTION_TREE, 't', InputOption::VALUE_NONE, 'Prints the results as a nested tree'),
  5538. ))
  5539. ->setHelp(
  5540. <<<EOT
  5541. Displays detailed information about why a package cannot be installed.
  5542. <info>php composer.phar prohibits composer/composer</info>
  5543. Read more at https://getcomposer.org/doc/03-cli.md#prohibits-why-not-
  5544. EOT
  5545. )
  5546. ;
  5547. }
  5548. protected function execute(InputInterface $input, OutputInterface $output): int
  5549. {
  5550. return parent::doExecute($input, $output, true);
  5551. }
  5552. }
  5553. <?php declare(strict_types=1);
  5554. namespace Composer\Command;
  5555. use Composer\DependencyResolver\Operation\InstallOperation;
  5556. use Composer\DependencyResolver\Operation\UninstallOperation;
  5557. use Composer\DependencyResolver\Transaction;
  5558. use Composer\Package\AliasPackage;
  5559. use Composer\Package\BasePackage;
  5560. use Composer\Pcre\Preg;
  5561. use Composer\Plugin\CommandEvent;
  5562. use Composer\Plugin\PluginEvents;
  5563. use Composer\Script\ScriptEvents;
  5564. use Composer\Util\Platform;
  5565. use Symfony\Component\Console\Input\InputInterface;
  5566. use Symfony\Component\Console\Input\InputOption;
  5567. use Symfony\Component\Console\Input\InputArgument;
  5568. use Symfony\Component\Console\Output\OutputInterface;
  5569. class ReinstallCommand extends BaseCommand
  5570. {
  5571. protected function configure(): void
  5572. {
  5573. $this
  5574. ->setName('reinstall')
  5575. ->setDescription('Uninstalls and reinstalls the given package names')
  5576. ->setDefinition(array(
  5577. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  5578. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
  5579. new InputOption('prefer-install', null, InputOption::VALUE_REQUIRED, 'Forces installation from package dist|source|auto (auto chooses source for dev versions, dist for the rest).'),
  5580. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  5581. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  5582. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  5583. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  5584. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  5585. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  5586. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  5587. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  5588. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'List of package names to reinstall, can include a wildcard (*) to match any substring.'),
  5589. ))
  5590. ->setHelp(
  5591. <<<EOT
  5592. The <info>reinstall</info> command looks up installed packages by name,
  5593. uninstalls them and reinstalls them. This lets you do a clean install
  5594. of a package if you messed with its files, or if you wish to change
  5595. the installation type using --prefer-install.
  5596. <info>php composer.phar reinstall acme/foo "acme/bar-*"</info>
  5597. Read more at https://getcomposer.org/doc/03-cli.md#reinstall
  5598. EOT
  5599. )
  5600. ;
  5601. }
  5602. protected function execute(InputInterface $input, OutputInterface $output): int
  5603. {
  5604. $io = $this->getIO();
  5605. $composer = $this->requireComposer();
  5606. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  5607. $packagesToReinstall = array();
  5608. $packageNamesToReinstall = array();
  5609. foreach ($input->getArgument('packages') as $pattern) {
  5610. $patternRegexp = BasePackage::packageNameToRegexp($pattern);
  5611. $matched = false;
  5612. foreach ($localRepo->getCanonicalPackages() as $package) {
  5613. if (Preg::isMatch($patternRegexp, $package->getName())) {
  5614. $matched = true;
  5615. $packagesToReinstall[] = $package;
  5616. $packageNamesToReinstall[] = $package->getName();
  5617. }
  5618. }
  5619. if (!$matched) {
  5620. $io->writeError('<warning>Pattern "' . $pattern . '" does not match any currently installed packages.</warning>');
  5621. }
  5622. }
  5623. if (!$packagesToReinstall) {
  5624. $io->writeError('<warning>Found no packages to reinstall, aborting.</warning>');
  5625. return 1;
  5626. }
  5627. $uninstallOperations = array();
  5628. foreach ($packagesToReinstall as $package) {
  5629. $uninstallOperations[] = new UninstallOperation($package);
  5630. }
  5631. $presentPackages = $localRepo->getPackages();
  5632. $resultPackages = $presentPackages;
  5633. foreach ($presentPackages as $index => $package) {
  5634. if (in_array($package->getName(), $packageNamesToReinstall, true)) {
  5635. unset($presentPackages[$index]);
  5636. }
  5637. }
  5638. $transaction = new Transaction($presentPackages, $resultPackages);
  5639. $installOperations = $transaction->getOperations();
  5640. $installOrder = array();
  5641. foreach ($installOperations as $index => $op) {
  5642. if ($op instanceof InstallOperation && !$op->getPackage() instanceof AliasPackage) {
  5643. $installOrder[$op->getPackage()->getName()] = $index;
  5644. }
  5645. }
  5646. usort($uninstallOperations, function ($a, $b) use ($installOrder): int {
  5647. return $installOrder[$b->getPackage()->getName()] - $installOrder[$a->getPackage()->getName()];
  5648. });
  5649. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'reinstall', $input, $output);
  5650. $eventDispatcher = $composer->getEventDispatcher();
  5651. $eventDispatcher->dispatch($commandEvent->getName(), $commandEvent);
  5652. $config = $composer->getConfig();
  5653. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  5654. $installationManager = $composer->getInstallationManager();
  5655. $downloadManager = $composer->getDownloadManager();
  5656. $package = $composer->getPackage();
  5657. $installationManager->setOutputProgress(!$input->getOption('no-progress'));
  5658. if ($input->getOption('no-plugins')) {
  5659. $installationManager->disablePlugins();
  5660. }
  5661. $downloadManager->setPreferSource($preferSource);
  5662. $downloadManager->setPreferDist($preferDist);
  5663. $devMode = $localRepo->getDevMode() !== null ? $localRepo->getDevMode() : true;
  5664. Platform::putEnv('COMPOSER_DEV_MODE', $devMode ? '1' : '0');
  5665. $eventDispatcher->dispatchScript(ScriptEvents::PRE_INSTALL_CMD, $devMode);
  5666. $installationManager->execute($localRepo, $uninstallOperations, $devMode);
  5667. $installationManager->execute($localRepo, $installOperations, $devMode);
  5668. if (!$input->getOption('no-autoloader')) {
  5669. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  5670. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  5671. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  5672. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  5673. $generator = $composer->getAutoloadGenerator();
  5674. $generator->setClassMapAuthoritative($authoritative);
  5675. $generator->setApcu($apcu, $apcuPrefix);
  5676. $generator->setPlatformRequirementFilter($this->getPlatformRequirementFilter($input));
  5677. $generator->dump($config, $localRepo, $package, $installationManager, 'composer', $optimize);
  5678. }
  5679. $eventDispatcher->dispatchScript(ScriptEvents::POST_INSTALL_CMD, $devMode);
  5680. return 0;
  5681. }
  5682. }
  5683. <?php declare(strict_types=1);
  5684. namespace Composer\Command;
  5685. use Composer\Config\JsonConfigSource;
  5686. use Composer\DependencyResolver\Request;
  5687. use Composer\Installer;
  5688. use Composer\Pcre\Preg;
  5689. use Composer\Plugin\CommandEvent;
  5690. use Composer\Plugin\PluginEvents;
  5691. use Composer\Json\JsonFile;
  5692. use Composer\Factory;
  5693. use Symfony\Component\Console\Input\InputInterface;
  5694. use Symfony\Component\Console\Input\InputOption;
  5695. use Symfony\Component\Console\Input\InputArgument;
  5696. use Symfony\Component\Console\Output\OutputInterface;
  5697. use Composer\Package\BasePackage;
  5698. class RemoveCommand extends BaseCommand
  5699. {
  5700. protected function configure()
  5701. {
  5702. $this
  5703. ->setName('remove')
  5704. ->setDescription('Removes a package from the require or require-dev.')
  5705. ->setDefinition(array(
  5706. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'Packages that should be removed.'),
  5707. new InputOption('dev', null, InputOption::VALUE_NONE, 'Removes a package from the require-dev section.'),
  5708. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  5709. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  5710. new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies (implies --no-install).'),
  5711. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  5712. new InputOption('update-no-dev', null, InputOption::VALUE_NONE, 'Run the dependency update with the --no-dev option.'),
  5713. new InputOption('update-with-dependencies', 'w', InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated with explicit dependencies. (Deprecrated, is now default behavior)'),
  5714. new InputOption('update-with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Allows all inherited dependencies to be updated, including those that are root requirements.'),
  5715. new InputOption('with-all-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-all-dependencies'),
  5716. new InputOption('no-update-with-dependencies', null, InputOption::VALUE_NONE, 'Does not allow inherited dependencies to be updated with explicit dependencies.'),
  5717. new InputOption('unused', null, InputOption::VALUE_NONE, 'Remove all packages which are locked but not required by any other package.'),
  5718. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  5719. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  5720. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  5721. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  5722. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  5723. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  5724. ))
  5725. ->setHelp(
  5726. <<<EOT
  5727. The <info>remove</info> command removes a package from the current
  5728. list of installed packages
  5729. <info>php composer.phar remove</info>
  5730. Read more at https://getcomposer.org/doc/03-cli.md#remove
  5731. EOT
  5732. )
  5733. ;
  5734. }
  5735. protected function interact(InputInterface $input, OutputInterface $output)
  5736. {
  5737. if ($input->getOption('unused')) {
  5738. $composer = $this->requireComposer();
  5739. $locker = $composer->getLocker();
  5740. if (!$locker->isLocked()) {
  5741. throw new \UnexpectedValueException('A valid composer.lock file is required to run this command with --unused');
  5742. }
  5743. $lockedPackages = $locker->getLockedRepository()->getPackages();
  5744. $required = array();
  5745. foreach (array_merge($composer->getPackage()->getRequires(), $composer->getPackage()->getDevRequires()) as $link) {
  5746. $required[$link->getTarget()] = true;
  5747. }
  5748. do {
  5749. $found = false;
  5750. foreach ($lockedPackages as $index => $package) {
  5751. foreach ($package->getNames() as $name) {
  5752. if (isset($required[$name])) {
  5753. foreach ($package->getRequires() as $link) {
  5754. $required[$link->getTarget()] = true;
  5755. }
  5756. $found = true;
  5757. unset($lockedPackages[$index]);
  5758. break;
  5759. }
  5760. }
  5761. }
  5762. } while ($found);
  5763. $unused = array();
  5764. foreach ($lockedPackages as $package) {
  5765. $unused[] = $package->getName();
  5766. }
  5767. $input->setArgument('packages', array_merge($input->getArgument('packages'), $unused));
  5768. if (count($input->getArgument('packages')) === 0) {
  5769. $this->getIO()->writeError('<info>No unused packages to remove</info>');
  5770. $this->setCode(function (): int {
  5771. return 0;
  5772. });
  5773. }
  5774. }
  5775. }
  5776. protected function execute(InputInterface $input, OutputInterface $output)
  5777. {
  5778. $packages = $input->getArgument('packages');
  5779. $packages = array_map('strtolower', $packages);
  5780. $file = Factory::getComposerFile();
  5781. $jsonFile = new JsonFile($file);
  5782. $composer = $jsonFile->read();
  5783. $composerBackup = file_get_contents($jsonFile->getPath());
  5784. $json = new JsonConfigSource($jsonFile);
  5785. $type = $input->getOption('dev') ? 'require-dev' : 'require';
  5786. $altType = !$input->getOption('dev') ? 'require-dev' : 'require';
  5787. $io = $this->getIO();
  5788. if ($input->getOption('update-with-dependencies')) {
  5789. $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>');
  5790. }
  5791. foreach (array('require', 'require-dev') as $linkType) {
  5792. if (isset($composer[$linkType])) {
  5793. foreach ($composer[$linkType] as $name => $version) {
  5794. $composer[$linkType][strtolower($name)] = $name;
  5795. }
  5796. }
  5797. }
  5798. $dryRun = $input->getOption('dry-run');
  5799. $toRemove = array();
  5800. foreach ($packages as $package) {
  5801. if (isset($composer[$type][$package])) {
  5802. if ($dryRun) {
  5803. $toRemove[$type][] = $composer[$type][$package];
  5804. } else {
  5805. $json->removeLink($type, $composer[$type][$package]);
  5806. }
  5807. } elseif (isset($composer[$altType][$package])) {
  5808. $io->writeError('<warning>' . $composer[$altType][$package] . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
  5809. if ($io->isInteractive()) {
  5810. if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [<comment>yes</comment>]? ')) {
  5811. if ($dryRun) {
  5812. $toRemove[$altType][] = $composer[$altType][$package];
  5813. } else {
  5814. $json->removeLink($altType, $composer[$altType][$package]);
  5815. }
  5816. }
  5817. }
  5818. } elseif (isset($composer[$type]) && count($matches = Preg::grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$type]))) > 0) {
  5819. foreach ($matches as $matchedPackage) {
  5820. if ($dryRun) {
  5821. $toRemove[$type][] = $matchedPackage;
  5822. } else {
  5823. $json->removeLink($type, $matchedPackage);
  5824. }
  5825. }
  5826. } elseif (isset($composer[$altType]) && count($matches = Preg::grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$altType]))) > 0) {
  5827. foreach ($matches as $matchedPackage) {
  5828. $io->writeError('<warning>' . $matchedPackage . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
  5829. if ($io->isInteractive()) {
  5830. if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [<comment>yes</comment>]? ')) {
  5831. if ($dryRun) {
  5832. $toRemove[$altType][] = $matchedPackage;
  5833. } else {
  5834. $json->removeLink($altType, $matchedPackage);
  5835. }
  5836. }
  5837. }
  5838. }
  5839. } else {
  5840. $io->writeError('<warning>'.$package.' is not required in your composer.json and has not been removed</warning>');
  5841. }
  5842. }
  5843. $io->writeError('<info>'.$file.' has been updated</info>');
  5844. if ($input->getOption('no-update')) {
  5845. return 0;
  5846. }
  5847. if ($composer = $this->tryComposer()) {
  5848. $composer->getPluginManager()->deactivateInstalledPlugins();
  5849. }
  5850. $this->resetComposer();
  5851. $composer = $this->requireComposer();
  5852. if ($dryRun) {
  5853. $rootPackage = $composer->getPackage();
  5854. $links = array(
  5855. 'require' => $rootPackage->getRequires(),
  5856. 'require-dev' => $rootPackage->getDevRequires(),
  5857. );
  5858. foreach ($toRemove as $type => $names) {
  5859. foreach ($names as $name) {
  5860. unset($links[$type][$name]);
  5861. }
  5862. }
  5863. $rootPackage->setRequires($links['require']);
  5864. $rootPackage->setDevRequires($links['require-dev']);
  5865. }
  5866. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'remove', $input, $output);
  5867. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5868. $allowPlugins = $composer->getConfig()->get('allow-plugins');
  5869. $removedPlugins = is_array($allowPlugins) ? array_intersect(array_keys($allowPlugins), $packages) : [];
  5870. if (!$dryRun && count($removedPlugins) > 0) {
  5871. if (count($allowPlugins) === count($removedPlugins)) {
  5872. $json->removeConfigSetting('allow-plugins');
  5873. } else {
  5874. foreach ($removedPlugins as $plugin) {
  5875. $json->removeConfigSetting('allow-plugins.'.$plugin);
  5876. }
  5877. }
  5878. }
  5879. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  5880. $install = Installer::create($io, $composer);
  5881. $updateDevMode = !$input->getOption('update-no-dev');
  5882. $optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader');
  5883. $authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative');
  5884. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  5885. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $composer->getConfig()->get('apcu-autoloader');
  5886. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  5887. $flags = '';
  5888. if ($input->getOption('update-with-all-dependencies') || $input->getOption('with-all-dependencies')) {
  5889. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  5890. $flags .= ' --with-all-dependencies';
  5891. } elseif ($input->getOption('no-update-with-dependencies')) {
  5892. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  5893. $flags .= ' --with-dependencies';
  5894. }
  5895. $io->writeError('<info>Running composer update '.implode(' ', $packages).$flags.'</info>');
  5896. $install
  5897. ->setVerbose($input->getOption('verbose'))
  5898. ->setDevMode($updateDevMode)
  5899. ->setOptimizeAutoloader($optimize)
  5900. ->setClassMapAuthoritative($authoritative)
  5901. ->setApcuAutoloader($apcu, $apcuPrefix)
  5902. ->setUpdate(true)
  5903. ->setInstall(!$input->getOption('no-install'))
  5904. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  5905. ->setPlatformRequirementFilter($this->getPlatformRequirementFilter($input))
  5906. ->setDryRun($dryRun)
  5907. ;
  5908. if ($composer->getLocker()->isLocked()) {
  5909. $install->setUpdateAllowList($packages);
  5910. }
  5911. $status = $install->run();
  5912. if ($status !== 0) {
  5913. $io->writeError("\n".'<error>Removal failed, reverting '.$file.' to its original content.</error>');
  5914. file_put_contents($jsonFile->getPath(), $composerBackup);
  5915. }
  5916. if (!$dryRun) {
  5917. foreach ($packages as $package) {
  5918. if ($composer->getRepositoryManager()->getLocalRepository()->findPackages($package)) {
  5919. $io->writeError('<error>Removal failed, '.$package.' is still present, it may be required by another package. See `composer why '.$package.'`.</error>');
  5920. return 2;
  5921. }
  5922. }
  5923. }
  5924. return $status;
  5925. }
  5926. }
  5927. <?php declare(strict_types=1);
  5928. namespace Composer\Command;
  5929. use Composer\DependencyResolver\Request;
  5930. use Composer\Util\Filesystem;
  5931. use Symfony\Component\Console\Input\InputInterface;
  5932. use Symfony\Component\Console\Input\InputArgument;
  5933. use Symfony\Component\Console\Input\InputOption;
  5934. use Symfony\Component\Console\Output\OutputInterface;
  5935. use Composer\Factory;
  5936. use Composer\Installer;
  5937. use Composer\Installer\InstallerEvents;
  5938. use Composer\Json\JsonFile;
  5939. use Composer\Json\JsonManipulator;
  5940. use Composer\Package\Version\VersionParser;
  5941. use Composer\Package\Loader\ArrayLoader;
  5942. use Composer\Package\BasePackage;
  5943. use Composer\Plugin\CommandEvent;
  5944. use Composer\Plugin\PluginEvents;
  5945. use Composer\Repository\CompositeRepository;
  5946. use Composer\Repository\PlatformRepository;
  5947. use Composer\IO\IOInterface;
  5948. use Composer\Util\Silencer;
  5949. class RequireCommand extends BaseCommand
  5950. {
  5951. use PackageDiscoveryTrait;
  5952. private $newlyCreated;
  5953. private $firstRequire;
  5954. private $json;
  5955. private $file;
  5956. private $composerBackup;
  5957. private $lock;
  5958. private $lockBackup;
  5959. private $dependencyResolutionCompleted = false;
  5960. protected function configure()
  5961. {
  5962. $this
  5963. ->setName('require')
  5964. ->setDescription('Adds required packages to your composer.json and installs them.')
  5965. ->setDefinition(array(
  5966. 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"'),
  5967. new InputOption('dev', null, InputOption::VALUE_NONE, 'Add requirement to require-dev.'),
  5968. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  5969. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  5970. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
  5971. new InputOption('prefer-install', null, InputOption::VALUE_REQUIRED, 'Forces installation from package dist|source|auto (auto chooses source for dev versions, dist for the rest).'),
  5972. new InputOption('fixed', null, InputOption::VALUE_NONE, 'Write fixed version to the composer.json.'),
  5973. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  5974. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  5975. new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies (implies --no-install).'),
  5976. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  5977. new InputOption('update-no-dev', null, InputOption::VALUE_NONE, 'Run the dependency update with the --no-dev option.'),
  5978. new InputOption('update-with-dependencies', 'w', InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated, except those that are root requirements.'),
  5979. new InputOption('update-with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Allows all inherited dependencies to be updated, including those that are root requirements.'),
  5980. new InputOption('with-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-dependencies'),
  5981. new InputOption('with-all-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-all-dependencies'),
  5982. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  5983. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  5984. new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies.'),
  5985. new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies.'),
  5986. new InputOption('sort-packages', null, InputOption::VALUE_NONE, 'Sorts packages when adding/updating a new dependency'),
  5987. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  5988. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  5989. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  5990. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  5991. ))
  5992. ->setHelp(
  5993. <<<EOT
  5994. The require command adds required packages to your composer.json and installs them.
  5995. If you do not specify a package, composer will prompt you to search for a package, and given results, provide a list of
  5996. matches to require.
  5997. If you do not specify a version constraint, composer will choose a suitable one based on the available package versions.
  5998. If you do not want to install the new dependencies immediately you can call it with --no-update
  5999. Read more at https://getcomposer.org/doc/03-cli.md#require
  6000. EOT
  6001. )
  6002. ;
  6003. }
  6004. protected function execute(InputInterface $input, OutputInterface $output)
  6005. {
  6006. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  6007. pcntl_async_signals(true);
  6008. pcntl_signal(SIGINT, array($this, 'revertComposerFile'));
  6009. pcntl_signal(SIGTERM, array($this, 'revertComposerFile'));
  6010. pcntl_signal(SIGHUP, array($this, 'revertComposerFile'));
  6011. }
  6012. $this->file = Factory::getComposerFile();
  6013. $io = $this->getIO();
  6014. if ($input->getOption('no-suggest')) {
  6015. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  6016. }
  6017. $this->newlyCreated = !file_exists($this->file);
  6018. if ($this->newlyCreated && !file_put_contents($this->file, "{\n}\n")) {
  6019. $io->writeError('<error>'.$this->file.' could not be created.</error>');
  6020. return 1;
  6021. }
  6022. if (!Filesystem::isReadable($this->file)) {
  6023. $io->writeError('<error>'.$this->file.' is not readable.</error>');
  6024. return 1;
  6025. }
  6026. if (filesize($this->file) === 0) {
  6027. file_put_contents($this->file, "{\n}\n");
  6028. }
  6029. $this->json = new JsonFile($this->file);
  6030. $this->lock = Factory::getLockFile($this->file);
  6031. $this->composerBackup = file_get_contents($this->json->getPath());
  6032. $this->lockBackup = file_exists($this->lock) ? file_get_contents($this->lock) : null;
  6033. if (!is_writable($this->file) && !Silencer::call('file_put_contents', $this->file, $this->composerBackup)) {
  6034. $io->writeError('<error>'.$this->file.' is not writable.</error>');
  6035. return 1;
  6036. }
  6037. if ($input->getOption('fixed') === true) {
  6038. $config = $this->json->read();
  6039. $packageType = empty($config['type']) ? 'library' : $config['type'];
  6040. if ($packageType !== 'project') {
  6041. $io->writeError('<error>"--fixed" option is allowed for "project" package types only to prevent possible misuses.</error>');
  6042. if (empty($config['type'])) {
  6043. $io->writeError('<error>If your package is not library, you should explicitly specify "type" parameter in composer.json.</error>');
  6044. }
  6045. return 1;
  6046. }
  6047. }
  6048. $composer = $this->requireComposer();
  6049. $repos = $composer->getRepositoryManager()->getRepositories();
  6050. $platformOverrides = $composer->getConfig()->get('platform');
  6051. $this->repos = new CompositeRepository(array_merge(
  6052. array($platformRepo = new PlatformRepository(array(), $platformOverrides)),
  6053. $repos
  6054. ));
  6055. if ($composer->getPackage()->getPreferStable()) {
  6056. $preferredStability = 'stable';
  6057. } else {
  6058. $preferredStability = $composer->getPackage()->getMinimumStability();
  6059. }
  6060. try {
  6061. $requirements = $this->determineRequirements(
  6062. $input,
  6063. $output,
  6064. $input->getArgument('packages'),
  6065. $platformRepo,
  6066. $preferredStability,
  6067. !$input->getOption('no-update'),
  6068. $input->getOption('fixed')
  6069. );
  6070. } catch (\Exception $e) {
  6071. if ($this->newlyCreated) {
  6072. $this->revertComposerFile(false);
  6073. throw new \RuntimeException('No composer.json present in the current directory ('.$this->file.'), this may be the cause of the following exception.', 0, $e);
  6074. }
  6075. throw $e;
  6076. }
  6077. $requireKey = $input->getOption('dev') ? 'require-dev' : 'require';
  6078. $removeKey = $input->getOption('dev') ? 'require' : 'require-dev';
  6079. $requirements = $this->formatRequirements($requirements);
  6080. $versionParser = new VersionParser();
  6081. foreach ($requirements as $package => $constraint) {
  6082. if (strtolower($package) === $composer->getPackage()->getName()) {
  6083. $io->writeError(sprintf('<error>Root package \'%s\' cannot require itself in its composer.json</error>', $package));
  6084. return 1;
  6085. }
  6086. if ($constraint === 'self.version') {
  6087. continue;
  6088. }
  6089. $versionParser->parseConstraints($constraint);
  6090. }
  6091. $inconsistentRequireKeys = $this->getInconsistentRequireKeys($requirements, $requireKey);
  6092. if (count($inconsistentRequireKeys) > 0) {
  6093. foreach ($inconsistentRequireKeys as $package) {
  6094. $io->warning(sprintf(
  6095. '%s is currently present in the %s key and you ran the command %s the --dev flag, which would move it to the %s key.',
  6096. $package,
  6097. $removeKey,
  6098. $input->getOption('dev') ? 'with' : 'without',
  6099. $requireKey
  6100. ));
  6101. }
  6102. if ($io->isInteractive()) {
  6103. if (!$io->askConfirmation(sprintf('<info>Do you want to move %s?</info> [<comment>no</comment>]? ', count($inconsistentRequireKeys) > 1 ? 'these requirements' : 'this requirement'), false)) {
  6104. if (!$io->askConfirmation(sprintf('<info>Do you want to re-run the command %s --dev?</info> [<comment>yes</comment>]? ', $input->getOption('dev') ? 'without' : 'with'), true)) {
  6105. return 0;
  6106. }
  6107. list($requireKey, $removeKey) = array($removeKey, $requireKey);
  6108. }
  6109. }
  6110. }
  6111. $sortPackages = $input->getOption('sort-packages') || $composer->getConfig()->get('sort-packages');
  6112. $this->firstRequire = $this->newlyCreated;
  6113. if (!$this->firstRequire) {
  6114. $composerDefinition = $this->json->read();
  6115. if (count($composerDefinition['require'] ?? []) === 0 && count($composerDefinition['require-dev'] ?? []) === 0) {
  6116. $this->firstRequire = true;
  6117. }
  6118. }
  6119. if (!$input->getOption('dry-run') && !$this->updateFileCleanly($this->json, $requirements, $requireKey, $removeKey, $sortPackages)) {
  6120. $composerDefinition = $this->json->read();
  6121. foreach ($requirements as $package => $version) {
  6122. $composerDefinition[$requireKey][$package] = $version;
  6123. unset($composerDefinition[$removeKey][$package]);
  6124. if (isset($composerDefinition[$removeKey]) && count($composerDefinition[$removeKey]) === 0) {
  6125. unset($composerDefinition[$removeKey]);
  6126. }
  6127. }
  6128. $this->json->write($composerDefinition);
  6129. }
  6130. $io->writeError('<info>'.$this->file.' has been '.($this->newlyCreated ? 'created' : 'updated').'</info>');
  6131. if ($input->getOption('no-update')) {
  6132. return 0;
  6133. }
  6134. $composer->getPluginManager()->deactivateInstalledPlugins();
  6135. try {
  6136. return $this->doUpdate($input, $output, $io, $requirements, $requireKey, $removeKey);
  6137. } catch (\Exception $e) {
  6138. if (!$this->dependencyResolutionCompleted) {
  6139. $this->revertComposerFile(false);
  6140. }
  6141. throw $e;
  6142. }
  6143. }
  6144. private function getInconsistentRequireKeys(array $newRequirements, string $requireKey): array
  6145. {
  6146. $requireKeys = $this->getPackagesByRequireKey();
  6147. $inconsistentRequirements = array();
  6148. foreach ($requireKeys as $package => $packageRequireKey) {
  6149. if (!isset($newRequirements[$package])) {
  6150. continue;
  6151. }
  6152. if ($requireKey !== $packageRequireKey) {
  6153. $inconsistentRequirements[] = $package;
  6154. }
  6155. }
  6156. return $inconsistentRequirements;
  6157. }
  6158. private function getPackagesByRequireKey(): array
  6159. {
  6160. $composerDefinition = $this->json->read();
  6161. $require = array();
  6162. $requireDev = array();
  6163. if (isset($composerDefinition['require'])) {
  6164. $require = $composerDefinition['require'];
  6165. }
  6166. if (isset($composerDefinition['require-dev'])) {
  6167. $requireDev = $composerDefinition['require-dev'];
  6168. }
  6169. return array_merge(
  6170. array_fill_keys(array_keys($require), 'require'),
  6171. array_fill_keys(array_keys($requireDev), 'require-dev')
  6172. );
  6173. }
  6174. private function doUpdate(InputInterface $input, OutputInterface $output, IOInterface $io, array $requirements, string $requireKey, string $removeKey): int
  6175. {
  6176. $this->resetComposer();
  6177. $composer = $this->requireComposer();
  6178. $this->dependencyResolutionCompleted = false;
  6179. $composer->getEventDispatcher()->addListener(InstallerEvents::PRE_OPERATIONS_EXEC, function (): void {
  6180. $this->dependencyResolutionCompleted = true;
  6181. }, 10000);
  6182. if ($input->getOption('dry-run')) {
  6183. $rootPackage = $composer->getPackage();
  6184. $links = array(
  6185. 'require' => $rootPackage->getRequires(),
  6186. 'require-dev' => $rootPackage->getDevRequires(),
  6187. );
  6188. $loader = new ArrayLoader();
  6189. $newLinks = $loader->parseLinks($rootPackage->getName(), $rootPackage->getPrettyVersion(), BasePackage::$supportedLinkTypes[$requireKey]['method'], $requirements);
  6190. $links[$requireKey] = array_merge($links[$requireKey], $newLinks);
  6191. foreach ($requirements as $package => $constraint) {
  6192. unset($links[$removeKey][$package]);
  6193. }
  6194. $rootPackage->setRequires($links['require']);
  6195. $rootPackage->setDevRequires($links['require-dev']);
  6196. }
  6197. $updateDevMode = !$input->getOption('update-no-dev');
  6198. $optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader');
  6199. $authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative');
  6200. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  6201. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $composer->getConfig()->get('apcu-autoloader');
  6202. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  6203. $flags = '';
  6204. if ($input->getOption('update-with-all-dependencies') || $input->getOption('with-all-dependencies')) {
  6205. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  6206. $flags .= ' --with-all-dependencies';
  6207. } elseif ($input->getOption('update-with-dependencies') || $input->getOption('with-dependencies')) {
  6208. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  6209. $flags .= ' --with-dependencies';
  6210. }
  6211. $io->writeError('<info>Running composer update '.implode(' ', array_keys($requirements)).$flags.'</info>');
  6212. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'require', $input, $output);
  6213. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  6214. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  6215. $install = Installer::create($io, $composer);
  6216. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($composer->getConfig(), $input);
  6217. $install
  6218. ->setDryRun($input->getOption('dry-run'))
  6219. ->setVerbose($input->getOption('verbose'))
  6220. ->setPreferSource($preferSource)
  6221. ->setPreferDist($preferDist)
  6222. ->setDevMode($updateDevMode)
  6223. ->setOptimizeAutoloader($optimize)
  6224. ->setClassMapAuthoritative($authoritative)
  6225. ->setApcuAutoloader($apcu, $apcuPrefix)
  6226. ->setUpdate(true)
  6227. ->setInstall(!$input->getOption('no-install'))
  6228. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  6229. ->setPlatformRequirementFilter($this->getPlatformRequirementFilter($input))
  6230. ->setPreferStable($input->getOption('prefer-stable'))
  6231. ->setPreferLowest($input->getOption('prefer-lowest'))
  6232. ;
  6233. if (!$this->firstRequire && $composer->getLocker()->isLocked()) {
  6234. $install->setUpdateAllowList(array_keys($requirements));
  6235. }
  6236. $status = $install->run();
  6237. if ($status !== 0) {
  6238. if ($status === Installer::ERROR_DEPENDENCY_RESOLUTION_FAILED) {
  6239. foreach ($this->normalizeRequirements($input->getArgument('packages')) as $req) {
  6240. if (!isset($req['version'])) {
  6241. $io->writeError('You can also try re-running composer require with an explicit version constraint, e.g. "composer require '.$req['name'].':*" to figure out if any version is installable, or "composer require '.$req['name'].':^2.1" if you know which you need.');
  6242. break;
  6243. }
  6244. }
  6245. }
  6246. $this->revertComposerFile(false);
  6247. }
  6248. return $status;
  6249. }
  6250. private function updateFileCleanly(JsonFile $json, array $new, string $requireKey, string $removeKey, bool $sortPackages): bool
  6251. {
  6252. $contents = file_get_contents($json->getPath());
  6253. $manipulator = new JsonManipulator($contents);
  6254. foreach ($new as $package => $constraint) {
  6255. if (!$manipulator->addLink($requireKey, $package, $constraint, $sortPackages)) {
  6256. return false;
  6257. }
  6258. if (!$manipulator->removeSubNode($removeKey, $package)) {
  6259. return false;
  6260. }
  6261. }
  6262. $manipulator->removeMainKeyIfEmpty($removeKey);
  6263. file_put_contents($json->getPath(), $manipulator->getContents());
  6264. return true;
  6265. }
  6266. protected function interact(InputInterface $input, OutputInterface $output): void
  6267. {
  6268. return;
  6269. }
  6270. public function revertComposerFile(bool $hardExit = true): void
  6271. {
  6272. $io = $this->getIO();
  6273. if ($this->newlyCreated) {
  6274. $io->writeError("\n".'<error>Installation failed, deleting '.$this->file.'.</error>');
  6275. unlink($this->json->getPath());
  6276. if (file_exists($this->lock)) {
  6277. unlink($this->lock);
  6278. }
  6279. } else {
  6280. $msg = ' to its ';
  6281. if ($this->lockBackup) {
  6282. $msg = ' and '.$this->lock.' to their ';
  6283. }
  6284. $io->writeError("\n".'<error>Installation failed, reverting '.$this->file.$msg.'original content.</error>');
  6285. file_put_contents($this->json->getPath(), $this->composerBackup);
  6286. if ($this->lockBackup) {
  6287. file_put_contents($this->lock, $this->lockBackup);
  6288. }
  6289. }
  6290. if ($hardExit) {
  6291. exit(1);
  6292. }
  6293. }
  6294. }
  6295. <?php declare(strict_types=1);
  6296. namespace Composer\Command;
  6297. use Composer\Script\Event as ScriptEvent;
  6298. use Composer\Script\ScriptEvents;
  6299. use Composer\Util\ProcessExecutor;
  6300. use Composer\Util\Platform;
  6301. use Symfony\Component\Console\Input\InputInterface;
  6302. use Symfony\Component\Console\Input\InputOption;
  6303. use Symfony\Component\Console\Input\InputArgument;
  6304. use Symfony\Component\Console\Output\OutputInterface;
  6305. class RunScriptCommand extends BaseCommand
  6306. {
  6307. protected $scriptEvents = array(
  6308. ScriptEvents::PRE_INSTALL_CMD,
  6309. ScriptEvents::POST_INSTALL_CMD,
  6310. ScriptEvents::PRE_UPDATE_CMD,
  6311. ScriptEvents::POST_UPDATE_CMD,
  6312. ScriptEvents::PRE_STATUS_CMD,
  6313. ScriptEvents::POST_STATUS_CMD,
  6314. ScriptEvents::POST_ROOT_PACKAGE_INSTALL,
  6315. ScriptEvents::POST_CREATE_PROJECT_CMD,
  6316. ScriptEvents::PRE_ARCHIVE_CMD,
  6317. ScriptEvents::POST_ARCHIVE_CMD,
  6318. ScriptEvents::PRE_AUTOLOAD_DUMP,
  6319. ScriptEvents::POST_AUTOLOAD_DUMP,
  6320. );
  6321. protected function configure(): void
  6322. {
  6323. $this
  6324. ->setName('run-script')
  6325. ->setAliases(array('run'))
  6326. ->setDescription('Runs the scripts defined in composer.json.')
  6327. ->setDefinition(array(
  6328. new InputArgument('script', InputArgument::OPTIONAL, 'Script name to run.'),
  6329. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  6330. new InputOption('timeout', null, InputOption::VALUE_REQUIRED, 'Sets script timeout in seconds, or 0 for never.'),
  6331. new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'),
  6332. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'),
  6333. new InputOption('list', 'l', InputOption::VALUE_NONE, 'List scripts.'),
  6334. ))
  6335. ->setHelp(
  6336. <<<EOT
  6337. The <info>run-script</info> command runs scripts defined in composer.json:
  6338. <info>php composer.phar run-script post-update-cmd</info>
  6339. Read more at https://getcomposer.org/doc/03-cli.md#run-script
  6340. EOT
  6341. )
  6342. ;
  6343. }
  6344. protected function execute(InputInterface $input, OutputInterface $output): int
  6345. {
  6346. if ($input->getOption('list')) {
  6347. return $this->listScripts($output);
  6348. }
  6349. $script = $input->getArgument('script');
  6350. if ($script === null) {
  6351. throw new \RuntimeException('Missing required argument "script"');
  6352. }
  6353. if (!in_array($script, $this->scriptEvents)) {
  6354. if (defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
  6355. throw new \InvalidArgumentException(sprintf('Script "%s" cannot be run with this command', $script));
  6356. }
  6357. }
  6358. $composer = $this->requireComposer();
  6359. $devMode = $input->getOption('dev') || !$input->getOption('no-dev');
  6360. $event = new ScriptEvent($script, $composer, $this->getIO(), $devMode);
  6361. $hasListeners = $composer->getEventDispatcher()->hasEventListeners($event);
  6362. if (!$hasListeners) {
  6363. throw new \InvalidArgumentException(sprintf('Script "%s" is not defined in this package', $script));
  6364. }
  6365. $args = $input->getArgument('args');
  6366. if (null !== $timeout = $input->getOption('timeout')) {
  6367. if (!ctype_digit($timeout)) {
  6368. throw new \RuntimeException('Timeout value must be numeric and positive if defined, or 0 for forever');
  6369. }
  6370. ProcessExecutor::setTimeout((int) $timeout);
  6371. }
  6372. Platform::putEnv('COMPOSER_DEV_MODE', $devMode ? '1' : '0');
  6373. return $composer->getEventDispatcher()->dispatchScript($script, $devMode, $args);
  6374. }
  6375. protected function listScripts(OutputInterface $output): int
  6376. {
  6377. $scripts = $this->requireComposer()->getPackage()->getScripts();
  6378. if (!count($scripts)) {
  6379. return 0;
  6380. }
  6381. $io = $this->getIO();
  6382. $io->writeError('<info>scripts:</info>');
  6383. $table = array();
  6384. foreach ($scripts as $name => $script) {
  6385. $description = '';
  6386. try {
  6387. $cmd = $this->getApplication()->find($name);
  6388. if ($cmd instanceof ScriptAliasCommand) {
  6389. $description = $cmd->getDescription();
  6390. }
  6391. } catch (\Symfony\Component\Console\Exception\CommandNotFoundException $e) {
  6392. }
  6393. $table[] = array(' '.$name, $description);
  6394. }
  6395. $this->renderTable($table, $output);
  6396. return 0;
  6397. }
  6398. }
  6399. <?php declare(strict_types=1);
  6400. namespace Composer\Command;
  6401. use Symfony\Component\Console\Input\InputInterface;
  6402. use Symfony\Component\Console\Input\InputOption;
  6403. use Symfony\Component\Console\Input\InputArgument;
  6404. use Symfony\Component\Console\Output\OutputInterface;
  6405. class ScriptAliasCommand extends BaseCommand
  6406. {
  6407. private $script;
  6408. private $description;
  6409. public function __construct(string $script, ?string $description)
  6410. {
  6411. $this->script = $script;
  6412. $this->description = $description ?? 'Runs the '.$script.' script as defined in composer.json.';
  6413. parent::__construct();
  6414. }
  6415. protected function configure(): void
  6416. {
  6417. $this
  6418. ->setName($this->script)
  6419. ->setDescription($this->description)
  6420. ->setDefinition(array(
  6421. new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'),
  6422. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'),
  6423. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  6424. ))
  6425. ->setHelp(
  6426. <<<EOT
  6427. The <info>run-script</info> command runs scripts defined in composer.json:
  6428. <info>php composer.phar run-script post-update-cmd</info>
  6429. Read more at https://getcomposer.org/doc/03-cli.md#run-script
  6430. EOT
  6431. )
  6432. ;
  6433. }
  6434. protected function execute(InputInterface $input, OutputInterface $output): int
  6435. {
  6436. $composer = $this->requireComposer();
  6437. $args = $input->getArguments();
  6438. return $composer->getEventDispatcher()->dispatchScript($this->script, $input->getOption('dev') || !$input->getOption('no-dev'), $args['args']);
  6439. }
  6440. }
  6441. <?php declare(strict_types=1);
  6442. namespace Composer\Command;
  6443. use Composer\Factory;
  6444. use Composer\Json\JsonFile;
  6445. use Symfony\Component\Console\Formatter\OutputFormatter;
  6446. use Symfony\Component\Console\Input\InputInterface;
  6447. use Symfony\Component\Console\Input\InputArgument;
  6448. use Symfony\Component\Console\Input\InputOption;
  6449. use Symfony\Component\Console\Output\OutputInterface;
  6450. use Composer\Repository\CompositeRepository;
  6451. use Composer\Repository\PlatformRepository;
  6452. use Composer\Repository\RepositoryInterface;
  6453. use Composer\Plugin\CommandEvent;
  6454. use Composer\Plugin\PluginEvents;
  6455. class SearchCommand extends BaseCommand
  6456. {
  6457. protected function configure(): void
  6458. {
  6459. $this
  6460. ->setName('search')
  6461. ->setDescription('Searches for packages.')
  6462. ->setDefinition(array(
  6463. new InputOption('only-name', 'N', InputOption::VALUE_NONE, 'Search only in package names'),
  6464. new InputOption('only-vendor', 'O', InputOption::VALUE_NONE, 'Search only for vendor / organization names, returns only "vendor" as result'),
  6465. new InputOption('type', 't', InputOption::VALUE_REQUIRED, 'Search for a specific package type'),
  6466. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
  6467. new InputArgument('tokens', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'tokens to search for'),
  6468. ))
  6469. ->setHelp(
  6470. <<<EOT
  6471. The search command searches for packages by its name
  6472. <info>php composer.phar search symfony composer</info>
  6473. Read more at https://getcomposer.org/doc/03-cli.md#search
  6474. EOT
  6475. )
  6476. ;
  6477. }
  6478. protected function execute(InputInterface $input, OutputInterface $output): int
  6479. {
  6480. $platformRepo = new PlatformRepository;
  6481. $io = $this->getIO();
  6482. $format = $input->getOption('format');
  6483. if (!in_array($format, array('text', 'json'))) {
  6484. $io->writeError(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  6485. return 1;
  6486. }
  6487. if (!($composer = $this->tryComposer())) {
  6488. $composer = Factory::create($this->getIO(), array(), $input->hasParameterOption('--no-plugins'));
  6489. }
  6490. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  6491. $installedRepo = new CompositeRepository(array($localRepo, $platformRepo));
  6492. $repos = new CompositeRepository(array_merge(array($installedRepo), $composer->getRepositoryManager()->getRepositories()));
  6493. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'search', $input, $output);
  6494. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  6495. $mode = RepositoryInterface::SEARCH_FULLTEXT;
  6496. if ($input->getOption('only-name') === true) {
  6497. if ($input->getOption('only-vendor') === true) {
  6498. throw new \InvalidArgumentException('--only-name and --only-vendor cannot be used together');
  6499. }
  6500. $mode = RepositoryInterface::SEARCH_NAME;
  6501. } elseif ($input->getOption('only-vendor') === true) {
  6502. $mode = RepositoryInterface::SEARCH_VENDOR;
  6503. }
  6504. $type = $input->getOption('type');
  6505. $query = implode(' ', $input->getArgument('tokens'));
  6506. if ($mode !== RepositoryInterface::SEARCH_FULLTEXT) {
  6507. $query = preg_quote($query);
  6508. }
  6509. $results = $repos->search($query, $mode, $type);
  6510. if ($results && $format === 'text') {
  6511. $width = $this->getTerminalWidth();
  6512. $nameLength = 0;
  6513. foreach ($results as $result) {
  6514. $nameLength = max(strlen($result['name']), $nameLength);
  6515. }
  6516. $nameLength += 1;
  6517. foreach ($results as $result) {
  6518. $description = $result['description'] ?? '';
  6519. $warning = !empty($result['abandoned']) ? '<warning>! Abandoned !</warning> ' : '';
  6520. $remaining = $width - $nameLength - strlen($warning) - 2;
  6521. if (strlen($description) > $remaining) {
  6522. $description = substr($description, 0, $remaining - 3) . '...';
  6523. }
  6524. $link = $result['url'] ?? null;
  6525. if ($link !== null) {
  6526. $io->write('<href='.OutputFormatter::escape($link).'>'.$result['name'].'</>'. str_repeat(' ', $nameLength - strlen($result['name'])) . $warning . $description);
  6527. } else {
  6528. $io->write(str_pad($result['name'], $nameLength, ' ') . $warning . $description);
  6529. }
  6530. }
  6531. } elseif ($format === 'json') {
  6532. $io->write(JsonFile::encode($results));
  6533. }
  6534. return 0;
  6535. }
  6536. }
  6537. <?php declare(strict_types=1);
  6538. namespace Composer\Command;
  6539. use Composer\Composer;
  6540. use Composer\Factory;
  6541. use Composer\Config;
  6542. use Composer\Pcre\Preg;
  6543. use Composer\Util\Filesystem;
  6544. use Composer\Util\Platform;
  6545. use Composer\SelfUpdate\Keys;
  6546. use Composer\SelfUpdate\Versions;
  6547. use Composer\IO\IOInterface;
  6548. use Composer\Downloader\FilesystemException;
  6549. use Composer\Downloader\TransportException;
  6550. use Symfony\Component\Console\Input\InputInterface;
  6551. use Symfony\Component\Console\Input\InputOption;
  6552. use Symfony\Component\Console\Input\InputArgument;
  6553. use Symfony\Component\Console\Output\OutputInterface;
  6554. use Symfony\Component\Finder\Finder;
  6555. class SelfUpdateCommand extends BaseCommand
  6556. {
  6557. private const HOMEPAGE = 'getcomposer.org';
  6558. private const OLD_INSTALL_EXT = '-old.phar';
  6559. protected function configure(): void
  6560. {
  6561. $this
  6562. ->setName('self-update')
  6563. ->setAliases(array('selfupdate'))
  6564. ->setDescription('Updates composer.phar to the latest version.')
  6565. ->setDefinition(array(
  6566. new InputOption('rollback', 'r', InputOption::VALUE_NONE, 'Revert to an older installation of composer'),
  6567. 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'),
  6568. new InputArgument('version', InputArgument::OPTIONAL, 'The version to update to'),
  6569. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  6570. new InputOption('update-keys', null, InputOption::VALUE_NONE, 'Prompt user for a key update'),
  6571. new InputOption('stable', null, InputOption::VALUE_NONE, 'Force an update to the stable channel'),
  6572. new InputOption('preview', null, InputOption::VALUE_NONE, 'Force an update to the preview channel'),
  6573. new InputOption('snapshot', null, InputOption::VALUE_NONE, 'Force an update to the snapshot channel'),
  6574. new InputOption('1', null, InputOption::VALUE_NONE, 'Force an update to the stable channel, but only use 1.x versions'),
  6575. new InputOption('2', null, InputOption::VALUE_NONE, 'Force an update to the stable channel, but only use 2.x versions'),
  6576. new InputOption('2.2', null, InputOption::VALUE_NONE, 'Force an update to the stable channel, but only use 2.2.x LTS versions'),
  6577. new InputOption('set-channel-only', null, InputOption::VALUE_NONE, 'Only store the channel as the default one and then exit'),
  6578. ))
  6579. ->setHelp(
  6580. <<<EOT
  6581. The <info>self-update</info> command checks getcomposer.org for newer
  6582. versions of composer and if found, installs the latest.
  6583. <info>php composer.phar self-update</info>
  6584. Read more at https://getcomposer.org/doc/03-cli.md#self-update-selfupdate-
  6585. EOT
  6586. )
  6587. ;
  6588. }
  6589. protected function execute(InputInterface $input, OutputInterface $output): int
  6590. {
  6591. class_exists('Composer\Util\Platform');
  6592. class_exists('Composer\Downloader\FilesystemException');
  6593. $config = Factory::createConfig();
  6594. if ($config->get('disable-tls') === true) {
  6595. $baseUrl = 'http://' . self::HOMEPAGE;
  6596. } else {
  6597. $baseUrl = 'https://' . self::HOMEPAGE;
  6598. }
  6599. $io = $this->getIO();
  6600. $httpDownloader = Factory::createHttpDownloader($io, $config);
  6601. $versionsUtil = new Versions($config, $httpDownloader);
  6602. $requestedChannel = null;
  6603. foreach (Versions::CHANNELS as $channel) {
  6604. if ($input->getOption($channel)) {
  6605. $requestedChannel = $channel;
  6606. $versionsUtil->setChannel($channel);
  6607. break;
  6608. }
  6609. }
  6610. if ($input->getOption('set-channel-only')) {
  6611. return 0;
  6612. }
  6613. $cacheDir = $config->get('cache-dir');
  6614. $rollbackDir = $config->get('data-dir');
  6615. $home = $config->get('home');
  6616. $localFilename = realpath($_SERVER['argv'][0]);
  6617. if (false === $localFilename) {
  6618. $localFilename = $_SERVER['argv'][0];
  6619. }
  6620. if ($input->getOption('update-keys')) {
  6621. $this->fetchKeys($io, $config);
  6622. return 0;
  6623. }
  6624. if (!file_exists($localFilename)) {
  6625. throw new FilesystemException('Composer update failed: the "'.$localFilename.'" is not accessible');
  6626. }
  6627. $tmpDir = is_writable(dirname($localFilename)) ? dirname($localFilename) : $cacheDir;
  6628. if (!is_writable($tmpDir)) {
  6629. throw new FilesystemException('Composer update failed: the "'.$tmpDir.'" directory used to download the temp file could not be written');
  6630. }
  6631. if (function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
  6632. $composerUser = posix_getpwuid(posix_geteuid());
  6633. $homeDirOwnerId = fileowner($home);
  6634. if (is_array($composerUser) && $homeDirOwnerId !== false) {
  6635. $homeOwner = posix_getpwuid($homeDirOwnerId);
  6636. if (is_array($homeOwner) && isset($composerUser['name'], $homeOwner['name']) && $composerUser['name'] !== $homeOwner['name']) {
  6637. $io->writeError('<warning>You are running Composer as "'.$composerUser['name'].'", while "'.$home.'" is owned by "'.$homeOwner['name'].'"</warning>');
  6638. }
  6639. }
  6640. }
  6641. if ($input->getOption('rollback')) {
  6642. return $this->rollback($output, $rollbackDir, $localFilename);
  6643. }
  6644. $latest = $versionsUtil->getLatest();
  6645. $latestStable = $versionsUtil->getLatest('stable');
  6646. try {
  6647. $latestPreview = $versionsUtil->getLatest('preview');
  6648. } catch (\UnexpectedValueException $e) {
  6649. $latestPreview = $latestStable;
  6650. }
  6651. $latestVersion = $latest['version'];
  6652. $updateVersion = $input->getArgument('version') ?? $latestVersion;
  6653. $currentMajorVersion = Preg::replace('{^(\d+).*}', '$1', Composer::getVersion());
  6654. $updateMajorVersion = Preg::replace('{^(\d+).*}', '$1', $updateVersion);
  6655. $previewMajorVersion = Preg::replace('{^(\d+).*}', '$1', $latestPreview['version']);
  6656. if ($versionsUtil->getChannel() === 'stable' && null === $input->getArgument('version')) {
  6657. if ($currentMajorVersion < $updateMajorVersion) {
  6658. $skippedVersion = $updateVersion;
  6659. $versionsUtil->setChannel($currentMajorVersion);
  6660. $latest = $versionsUtil->getLatest();
  6661. $latestStable = $versionsUtil->getLatest('stable');
  6662. $latestVersion = $latest['version'];
  6663. $updateVersion = $latestVersion;
  6664. $io->writeError('<warning>A new stable major version of Composer is available ('.$skippedVersion.'), run "composer self-update --'.$updateMajorVersion.'" to update to it. See also https://getcomposer.org/'.$updateMajorVersion.'</warning>');
  6665. } elseif ($currentMajorVersion < $previewMajorVersion) {
  6666. $io->writeError('<warning>A preview release of the next major version of Composer is available ('.$latestPreview['version'].'), run "composer self-update --preview" to give it a try. See also https://github.com/composer/composer/releases for changelogs.</warning>');
  6667. }
  6668. }
  6669. $effectiveChannel = $requestedChannel === null ? $versionsUtil->getChannel() : $requestedChannel;
  6670. if (is_numeric($effectiveChannel) && strpos($latestStable['version'], $effectiveChannel) !== 0) {
  6671. $io->writeError('<warning>Warning: You forced the install of '.$latestVersion.' via --'.$effectiveChannel.', but '.$latestStable['version'].' is the latest stable version. Updating to it via composer self-update --stable is recommended.</warning>');
  6672. }
  6673. if (isset($latest['eol'])) {
  6674. $io->writeError('<warning>Warning: Version '.$latestVersion.' is EOL / End of Life. '.$latestStable['version'].' is the latest stable version. Updating to it via composer self-update --stable is recommended.</warning>');
  6675. }
  6676. if (Preg::isMatch('{^[0-9a-f]{40}$}', $updateVersion) && $updateVersion !== $latestVersion) {
  6677. $io->writeError('<error>You can not update to a specific SHA-1 as those phars are not available for download</error>');
  6678. return 1;
  6679. }
  6680. $channelString = $versionsUtil->getChannel();
  6681. if (is_numeric($channelString)) {
  6682. $channelString .= '.x';
  6683. }
  6684. if (Composer::VERSION === $updateVersion) {
  6685. $io->writeError(
  6686. sprintf(
  6687. '<info>You are already using the latest available Composer version %s (%s channel).</info>',
  6688. $updateVersion,
  6689. $channelString
  6690. )
  6691. );
  6692. if ($input->getOption('clean-backups')) {
  6693. $this->cleanBackups($rollbackDir, $this->getLastBackupVersion($rollbackDir));
  6694. }
  6695. return 0;
  6696. }
  6697. $tempFilename = $tmpDir . '/' . basename($localFilename, '.phar').'-temp'.random_int(0, 10000000).'.phar';
  6698. $backupFile = sprintf(
  6699. '%s/%s-%s%s',
  6700. $rollbackDir,
  6701. strtr(Composer::RELEASE_DATE, ' :', '_-'),
  6702. Preg::replace('{^([0-9a-f]{7})[0-9a-f]{33}$}', '$1', Composer::VERSION),
  6703. self::OLD_INSTALL_EXT
  6704. );
  6705. $updatingToTag = !Preg::isMatch('{^[0-9a-f]{40}$}', $updateVersion);
  6706. $io->write(sprintf("Upgrading to version <info>%s</info> (%s channel).", $updateVersion, $channelString));
  6707. $remoteFilename = $baseUrl . ($updatingToTag ? "/download/{$updateVersion}/composer.phar" : '/composer.phar');
  6708. try {
  6709. $signature = $httpDownloader->get($remoteFilename.'.sig')->getBody();
  6710. } catch (TransportException $e) {
  6711. if ($e->getStatusCode() === 404) {
  6712. throw new \InvalidArgumentException('Version "'.$updateVersion.'" could not be found.', 0, $e);
  6713. }
  6714. throw $e;
  6715. }
  6716. $io->writeError(' ', false);
  6717. $httpDownloader->copy($remoteFilename, $tempFilename);
  6718. $io->writeError('');
  6719. if (!file_exists($tempFilename) || null === $signature || '' === $signature) {
  6720. $io->writeError('<error>The download of the new composer version failed for an unexpected reason</error>');
  6721. return 1;
  6722. }
  6723. if (!extension_loaded('openssl') && $config->get('disable-tls')) {
  6724. $io->writeError('<warning>Skipping phar signature verification as you have disabled OpenSSL via config.disable-tls</warning>');
  6725. } else {
  6726. if (!extension_loaded('openssl')) {
  6727. throw new \RuntimeException('The openssl extension is required for phar signatures to be verified but it is not available. '
  6728. . '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.');
  6729. }
  6730. $sigFile = 'file://'.$home.'/' . ($updatingToTag ? 'keys.tags.pub' : 'keys.dev.pub');
  6731. if (!file_exists($sigFile)) {
  6732. file_put_contents(
  6733. $home.'/keys.dev.pub',
  6734. <<<DEVPUBKEY
  6735. -----BEGIN PUBLIC KEY-----
  6736. MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAnBDHjZS6e0ZMoK3xTD7f
  6737. FNCzlXjX/Aie2dit8QXA03pSrOTbaMnxON3hUL47Lz3g1SC6YJEMVHr0zYq4elWi
  6738. i3ecFEgzLcj+pZM5X6qWu2Ozz4vWx3JYo1/a/HYdOuW9e3lwS8VtS0AVJA+U8X0A
  6739. hZnBmGpltHhO8hPKHgkJtkTUxCheTcbqn4wGHl8Z2SediDcPTLwqezWKUfrYzu1f
  6740. o/j3WFwFs6GtK4wdYtiXr+yspBZHO3y1udf8eFFGcb2V3EaLOrtfur6XQVizjOuk
  6741. 8lw5zzse1Qp/klHqbDRsjSzJ6iL6F4aynBc6Euqt/8ccNAIz0rLjLhOraeyj4eNn
  6742. 8iokwMKiXpcrQLTKH+RH1JCuOVxQ436bJwbSsp1VwiqftPQieN+tzqy+EiHJJmGf
  6743. TBAbWcncicCk9q2md+AmhNbvHO4PWbbz9TzC7HJb460jyWeuMEvw3gNIpEo2jYa9
  6744. pMV6cVqnSa+wOc0D7pC9a6bne0bvLcm3S+w6I5iDB3lZsb3A9UtRiSP7aGSo7D72
  6745. 8tC8+cIgZcI7k9vjvOqH+d7sdOU2yPCnRY6wFh62/g8bDnUpr56nZN1G89GwM4d4
  6746. r/TU7BQQIzsZgAiqOGXvVklIgAMiV0iucgf3rNBLjjeNEwNSTTG9F0CtQ+7JLwaE
  6747. wSEuAuRm+pRqi8BRnQ/GKUcCAwEAAQ==
  6748. -----END PUBLIC KEY-----
  6749. DEVPUBKEY
  6750. );
  6751. file_put_contents(
  6752. $home.'/keys.tags.pub',
  6753. <<<TAGSPUBKEY
  6754. -----BEGIN PUBLIC KEY-----
  6755. MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0Vi/2K6apCVj76nCnCl2
  6756. MQUPdK+A9eqkYBacXo2wQBYmyVlXm2/n/ZsX6pCLYPQTHyr5jXbkQzBw8SKqPdlh
  6757. vA7NpbMeNCz7wP/AobvUXM8xQuXKbMDTY2uZ4O7sM+PfGbptKPBGLe8Z8d2sUnTO
  6758. bXtX6Lrj13wkRto7st/w/Yp33RHe9SlqkiiS4MsH1jBkcIkEHsRaveZzedUaxY0M
  6759. mba0uPhGUInpPzEHwrYqBBEtWvP97t2vtfx8I5qv28kh0Y6t+jnjL1Urid2iuQZf
  6760. noCMFIOu4vksK5HxJxxrN0GOmGmwVQjOOtxkwikNiotZGPR4KsVj8NnBrLX7oGuM
  6761. nQvGciiu+KoC2r3HDBrpDeBVdOWxDzT5R4iI0KoLzFh2pKqwbY+obNPS2bj+2dgJ
  6762. rV3V5Jjry42QOCBN3c88wU1PKftOLj2ECpewY6vnE478IipiEu7EAdK8Zwj2LmTr
  6763. RKQUSa9k7ggBkYZWAeO/2Ag0ey3g2bg7eqk+sHEq5ynIXd5lhv6tC5PBdHlWipDK
  6764. tl2IxiEnejnOmAzGVivE1YGduYBjN+mjxDVy8KGBrjnz1JPgAvgdwJ2dYw4Rsc/e
  6765. TzCFWGk/HM6a4f0IzBWbJ5ot0PIi4amk07IotBXDWwqDiQTwyuGCym5EqWQ2BD95
  6766. RGv89BPD+2DLnJysngsvVaUCAwEAAQ==
  6767. -----END PUBLIC KEY-----
  6768. TAGSPUBKEY
  6769. );
  6770. }
  6771. $pubkeyid = openssl_pkey_get_public($sigFile);
  6772. if (false === $pubkeyid) {
  6773. throw new \RuntimeException('Failed loading the public key from '.$sigFile);
  6774. }
  6775. $algo = defined('OPENSSL_ALGO_SHA384') ? OPENSSL_ALGO_SHA384 : 'SHA384';
  6776. if (!in_array('sha384', array_map('strtolower', openssl_get_md_methods()), true)) {
  6777. throw new \RuntimeException('SHA384 is not supported by your openssl extension, could not verify the phar file integrity');
  6778. }
  6779. $signatureData = json_decode($signature, true);
  6780. $signatureSha384 = base64_decode($signatureData['sha384'], true);
  6781. if (false === $signatureSha384) {
  6782. throw new \RuntimeException('Failed loading the phar signature from '.$remoteFilename.'.sig, got '.$signature);
  6783. }
  6784. $verified = 1 === openssl_verify((string) file_get_contents($tempFilename), $signatureSha384, $pubkeyid, $algo);
  6785. if (PHP_VERSION_ID < 80000) {
  6786. openssl_free_key($pubkeyid);
  6787. }
  6788. if (!$verified) {
  6789. 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');
  6790. }
  6791. }
  6792. if ($input->getOption('clean-backups')) {
  6793. $this->cleanBackups($rollbackDir);
  6794. }
  6795. if (!$this->setLocalPhar($localFilename, $tempFilename, $backupFile)) {
  6796. @unlink($tempFilename);
  6797. return 1;
  6798. }
  6799. if (file_exists($backupFile)) {
  6800. $io->writeError(sprintf(
  6801. 'Use <info>composer self-update --rollback</info> to return to version <comment>%s</comment>',
  6802. Composer::VERSION
  6803. ));
  6804. } else {
  6805. $io->writeError('<warning>A backup of the current version could not be written to '.$backupFile.', no rollback possible</warning>');
  6806. }
  6807. return 0;
  6808. }
  6809. protected function fetchKeys(IOInterface $io, Config $config): void
  6810. {
  6811. if (!$io->isInteractive()) {
  6812. throw new \RuntimeException('Public keys can not be fetched in non-interactive mode, please run Composer interactively');
  6813. }
  6814. $io->write('Open <info>https://composer.github.io/pubkeys.html</info> to find the latest keys');
  6815. $validator = function ($value): string {
  6816. if (!Preg::isMatch('{^-----BEGIN PUBLIC KEY-----$}', trim($value))) {
  6817. throw new \UnexpectedValueException('Invalid input');
  6818. }
  6819. return trim($value)."\n";
  6820. };
  6821. $devKey = '';
  6822. while (!Preg::isMatch('{(-----BEGIN PUBLIC KEY-----.+?-----END PUBLIC KEY-----)}s', $devKey, $match)) {
  6823. $devKey = $io->askAndValidate('Enter Dev / Snapshot Public Key (including lines with -----): ', $validator);
  6824. while ($line = $io->ask('')) {
  6825. $devKey .= trim($line)."\n";
  6826. if (trim($line) === '-----END PUBLIC KEY-----') {
  6827. break;
  6828. }
  6829. }
  6830. }
  6831. file_put_contents($keyPath = $config->get('home').'/keys.dev.pub', $match[0]);
  6832. $io->write('Stored key with fingerprint: ' . Keys::fingerprint($keyPath));
  6833. $tagsKey = '';
  6834. while (!Preg::isMatch('{(-----BEGIN PUBLIC KEY-----.+?-----END PUBLIC KEY-----)}s', $tagsKey, $match)) {
  6835. $tagsKey = $io->askAndValidate('Enter Tags Public Key (including lines with -----): ', $validator);
  6836. while ($line = $io->ask('')) {
  6837. $tagsKey .= trim($line)."\n";
  6838. if (trim($line) === '-----END PUBLIC KEY-----') {
  6839. break;
  6840. }
  6841. }
  6842. }
  6843. file_put_contents($keyPath = $config->get('home').'/keys.tags.pub', $match[0]);
  6844. $io->write('Stored key with fingerprint: ' . Keys::fingerprint($keyPath));
  6845. $io->write('Public keys stored in '.$config->get('home'));
  6846. }
  6847. protected function rollback(OutputInterface $output, string $rollbackDir, string $localFilename): int
  6848. {
  6849. $rollbackVersion = $this->getLastBackupVersion($rollbackDir);
  6850. if (null === $rollbackVersion) {
  6851. throw new \UnexpectedValueException('Composer rollback failed: no installation to roll back to in "'.$rollbackDir.'"');
  6852. }
  6853. $oldFile = $rollbackDir . '/' . $rollbackVersion . self::OLD_INSTALL_EXT;
  6854. if (!is_file($oldFile)) {
  6855. throw new FilesystemException('Composer rollback failed: "'.$oldFile.'" could not be found');
  6856. }
  6857. if (!Filesystem::isReadable($oldFile)) {
  6858. throw new FilesystemException('Composer rollback failed: "'.$oldFile.'" could not be read');
  6859. }
  6860. $io = $this->getIO();
  6861. $io->writeError(sprintf("Rolling back to version <info>%s</info>.", $rollbackVersion));
  6862. if (!$this->setLocalPhar($localFilename, $oldFile)) {
  6863. return 1;
  6864. }
  6865. return 0;
  6866. }
  6867. protected function setLocalPhar(string $localFilename, string $newFilename, string $backupTarget = null): bool
  6868. {
  6869. $io = $this->getIO();
  6870. $perms = @fileperms($localFilename);
  6871. if ($perms !== false) {
  6872. @chmod($newFilename, $perms);
  6873. }
  6874. if (!$this->validatePhar($newFilename, $error)) {
  6875. $io->writeError('<error>The '.($backupTarget !== null ? 'update' : 'backup').' file is corrupted ('.$error.')</error>');
  6876. if ($backupTarget !== null) {
  6877. $io->writeError('<error>Please re-run the self-update command to try again.</error>');
  6878. }
  6879. return false;
  6880. }
  6881. if ($backupTarget !== null) {
  6882. @copy($localFilename, $backupTarget);
  6883. }
  6884. try {
  6885. if (Platform::isWindows()) {
  6886. copy($newFilename, $localFilename);
  6887. @unlink($newFilename);
  6888. } else {
  6889. rename($newFilename, $localFilename);
  6890. }
  6891. return true;
  6892. } catch (\Exception $e) {
  6893. if (!is_writable(dirname($localFilename))
  6894. && $io->isInteractive()
  6895. && $this->isWindowsNonAdminUser()) {
  6896. return $this->tryAsWindowsAdmin($localFilename, $newFilename);
  6897. }
  6898. @unlink($newFilename);
  6899. $action = 'Composer '.($backupTarget !== null ? 'update' : 'rollback');
  6900. throw new FilesystemException($action.' failed: "'.$localFilename.'" could not be written.'.PHP_EOL.$e->getMessage());
  6901. }
  6902. }
  6903. protected function cleanBackups(string $rollbackDir, ?string $except = null): void
  6904. {
  6905. $finder = $this->getOldInstallationFinder($rollbackDir);
  6906. $io = $this->getIO();
  6907. $fs = new Filesystem;
  6908. foreach ($finder as $file) {
  6909. if ($file->getBasename(self::OLD_INSTALL_EXT) === $except) {
  6910. continue;
  6911. }
  6912. $file = (string) $file;
  6913. $io->writeError('<info>Removing: '.$file.'</info>');
  6914. $fs->remove($file);
  6915. }
  6916. }
  6917. protected function getLastBackupVersion(string $rollbackDir): ?string
  6918. {
  6919. $finder = $this->getOldInstallationFinder($rollbackDir);
  6920. $finder->sortByName();
  6921. $files = iterator_to_array($finder);
  6922. if (count($files) > 0) {
  6923. return end($files)->getBasename(self::OLD_INSTALL_EXT);
  6924. }
  6925. return null;
  6926. }
  6927. protected function getOldInstallationFinder(string $rollbackDir): Finder
  6928. {
  6929. return Finder::create()
  6930. ->depth(0)
  6931. ->files()
  6932. ->name('*' . self::OLD_INSTALL_EXT)
  6933. ->in($rollbackDir);
  6934. }
  6935. protected function validatePhar(string $pharFile, ?string &$error): bool
  6936. {
  6937. if ((bool) ini_get('phar.readonly')) {
  6938. return true;
  6939. }
  6940. try {
  6941. $phar = new \Phar($pharFile);
  6942. unset($phar);
  6943. $result = true;
  6944. } catch (\Exception $e) {
  6945. if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) {
  6946. throw $e;
  6947. }
  6948. $error = $e->getMessage();
  6949. $result = false;
  6950. }
  6951. return $result;
  6952. }
  6953. protected function isWindowsNonAdminUser(): bool
  6954. {
  6955. if (!Platform::isWindows()) {
  6956. return false;
  6957. }
  6958. exec('fltmc.exe filters', $output, $exitCode);
  6959. return $exitCode !== 0;
  6960. }
  6961. protected function tryAsWindowsAdmin(string $localFilename, string $newFilename): bool
  6962. {
  6963. $io = $this->getIO();
  6964. $io->writeError('<error>Unable to write "'.$localFilename.'". Access is denied.</error>');
  6965. $helpMessage = 'Please run the self-update command as an Administrator.';
  6966. $question = 'Complete this operation with Administrator privileges [<comment>Y,n</comment>]? ';
  6967. if (!$io->askConfirmation($question, false)) {
  6968. $io->writeError('<warning>Operation cancelled. '.$helpMessage.'</warning>');
  6969. return false;
  6970. }
  6971. $tmpFile = tempnam(sys_get_temp_dir(), '');
  6972. if (false === $tmpFile) {
  6973. $io->writeError('<error>Operation failed.'.$helpMessage.'</error>');
  6974. return false;
  6975. }
  6976. $script = $tmpFile.'.vbs';
  6977. rename($tmpFile, $script);
  6978. $checksum = hash_file('sha256', $newFilename);
  6979. $source = str_replace('/', '\\', $newFilename);
  6980. $destination = str_replace('/', '\\', $localFilename);
  6981. $vbs = <<<EOT
  6982. Set UAC = CreateObject("Shell.Application")
  6983. UAC.ShellExecute "cmd.exe", "/c copy /b /y ""$source"" ""$destination""", "", "runas", 0
  6984. Wscript.Sleep(300)
  6985. EOT;
  6986. file_put_contents($script, $vbs);
  6987. exec('"'.$script.'"');
  6988. @unlink($script);
  6989. if ($result = Filesystem::isReadable($localFilename) && (hash_file('sha256', $localFilename) === $checksum)) {
  6990. $io->writeError('<info>Operation succeeded.</info>');
  6991. @unlink($newFilename);
  6992. } else {
  6993. $io->writeError('<error>Operation failed.'.$helpMessage.'</error>');
  6994. }
  6995. return $result;
  6996. }
  6997. }
  6998. <?php declare(strict_types=1);
  6999. namespace Composer\Command;
  7000. use Composer\Composer;
  7001. use Composer\DependencyResolver\DefaultPolicy;
  7002. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  7003. use Composer\Json\JsonFile;
  7004. use Composer\Package\BasePackage;
  7005. use Composer\Package\CompletePackageInterface;
  7006. use Composer\Package\Link;
  7007. use Composer\Package\AliasPackage;
  7008. use Composer\Package\Package;
  7009. use Composer\Package\PackageInterface;
  7010. use Composer\Package\Version\VersionParser;
  7011. use Composer\Package\Version\VersionSelector;
  7012. use Composer\Pcre\Preg;
  7013. use Composer\Plugin\CommandEvent;
  7014. use Composer\Plugin\PluginEvents;
  7015. use Composer\Repository\InstalledArrayRepository;
  7016. use Composer\Repository\ComposerRepository;
  7017. use Composer\Repository\CompositeRepository;
  7018. use Composer\Repository\FilterRepository;
  7019. use Composer\Repository\PlatformRepository;
  7020. use Composer\Repository\RepositoryFactory;
  7021. use Composer\Repository\InstalledRepository;
  7022. use Composer\Repository\RepositoryInterface;
  7023. use Composer\Repository\RepositorySet;
  7024. use Composer\Repository\RootPackageRepository;
  7025. use Composer\Semver\Constraint\ConstraintInterface;
  7026. use Composer\Semver\Semver;
  7027. use Composer\Spdx\SpdxLicenses;
  7028. use Composer\Util\PackageInfo;
  7029. use Symfony\Component\Console\Formatter\OutputFormatter;
  7030. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  7031. use Symfony\Component\Console\Input\InputArgument;
  7032. use Symfony\Component\Console\Input\InputInterface;
  7033. use Symfony\Component\Console\Input\InputOption;
  7034. use Symfony\Component\Console\Output\OutputInterface;
  7035. class ShowCommand extends BaseCommand
  7036. {
  7037. protected $versionParser;
  7038. protected $colors;
  7039. private $repositorySet;
  7040. protected function configure()
  7041. {
  7042. $this
  7043. ->setName('show')
  7044. ->setAliases(array('info'))
  7045. ->setDescription('Shows information about packages.')
  7046. ->setDefinition(array(
  7047. new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.'),
  7048. new InputArgument('version', InputArgument::OPTIONAL, 'Version or version constraint to inspect'),
  7049. new InputOption('all', null, InputOption::VALUE_NONE, 'List all packages'),
  7050. new InputOption('locked', null, InputOption::VALUE_NONE, 'List all locked packages'),
  7051. new InputOption('installed', 'i', InputOption::VALUE_NONE, 'List installed packages only (enabled by default, only present for BC).'),
  7052. new InputOption('platform', 'p', InputOption::VALUE_NONE, 'List platform packages only'),
  7053. new InputOption('available', 'a', InputOption::VALUE_NONE, 'List available packages only'),
  7054. new InputOption('self', 's', InputOption::VALUE_NONE, 'Show the root package information'),
  7055. new InputOption('name-only', 'N', InputOption::VALUE_NONE, 'List package names only'),
  7056. new InputOption('path', 'P', InputOption::VALUE_NONE, 'Show package paths'),
  7057. new InputOption('tree', 't', InputOption::VALUE_NONE, 'List the dependencies as a tree'),
  7058. new InputOption('latest', 'l', InputOption::VALUE_NONE, 'Show the latest version'),
  7059. new InputOption('outdated', 'o', InputOption::VALUE_NONE, 'Show the latest version but only for packages that are outdated'),
  7060. 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.'),
  7061. new InputOption('minor-only', 'm', InputOption::VALUE_NONE, 'Show only packages that have minor SemVer-compatible updates. Use with the --outdated option.'),
  7062. new InputOption('patch-only', null, InputOption::VALUE_NONE, 'Show only packages that have patch SemVer-compatible updates. Use with the --outdated option.'),
  7063. new InputOption('direct', 'D', InputOption::VALUE_NONE, 'Shows only packages that are directly required by the root package'),
  7064. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code when there are outdated packages'),
  7065. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
  7066. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  7067. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages). Use with the --outdated option'),
  7068. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages). Use with the --outdated option'),
  7069. ))
  7070. ->setHelp(
  7071. <<<EOT
  7072. The show command displays detailed information about a package, or
  7073. lists all packages available.
  7074. Read more at https://getcomposer.org/doc/03-cli.md#show
  7075. EOT
  7076. )
  7077. ;
  7078. }
  7079. protected function execute(InputInterface $input, OutputInterface $output)
  7080. {
  7081. $this->versionParser = new VersionParser;
  7082. if ($input->getOption('tree')) {
  7083. $this->initStyles($output);
  7084. }
  7085. $composer = $this->tryComposer();
  7086. $io = $this->getIO();
  7087. if ($input->getOption('installed')) {
  7088. $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>');
  7089. }
  7090. if ($input->getOption('outdated')) {
  7091. $input->setOption('latest', true);
  7092. } elseif (count($input->getOption('ignore')) > 0) {
  7093. $io->writeError('<warning>You are using the option "ignore" for action other than "outdated", it will be ignored.</warning>');
  7094. }
  7095. if ($input->getOption('direct') && ($input->getOption('all') || $input->getOption('available') || $input->getOption('platform'))) {
  7096. $io->writeError('The --direct (-D) option is not usable in combination with --all, --platform (-p) or --available (-a)');
  7097. return 1;
  7098. }
  7099. if ($input->getOption('tree') && ($input->getOption('all') || $input->getOption('available'))) {
  7100. $io->writeError('The --tree (-t) option is not usable in combination with --all or --available (-a)');
  7101. return 1;
  7102. }
  7103. if ($input->getOption('patch-only') && $input->getOption('minor-only')) {
  7104. $io->writeError('The --patch-only option is not usable in combination with --minor-only');
  7105. return 1;
  7106. }
  7107. if ($input->getOption('tree') && $input->getOption('latest')) {
  7108. $io->writeError('The --tree (-t) option is not usable in combination with --latest (-l)');
  7109. return 1;
  7110. }
  7111. if ($input->getOption('tree') && $input->getOption('path')) {
  7112. $io->writeError('The --tree (-t) option is not usable in combination with --path (-P)');
  7113. return 1;
  7114. }
  7115. $format = $input->getOption('format');
  7116. if (!in_array($format, array('text', 'json'))) {
  7117. $io->writeError(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  7118. return 1;
  7119. }
  7120. $platformReqFilter = $this->getPlatformRequirementFilter($input);
  7121. $platformOverrides = array();
  7122. if ($composer) {
  7123. $platformOverrides = $composer->getConfig()->get('platform') ?: array();
  7124. }
  7125. $platformRepo = new PlatformRepository(array(), $platformOverrides);
  7126. $lockedRepo = null;
  7127. if ($input->getOption('self')) {
  7128. $package = $this->requireComposer()->getPackage();
  7129. if ($input->getOption('name-only')) {
  7130. $io->write($package->getName());
  7131. return 0;
  7132. }
  7133. if ($input->getArgument('package')) {
  7134. throw new \InvalidArgumentException('You cannot use --self together with a package name');
  7135. }
  7136. $repos = $installedRepo = new InstalledRepository(array(new RootPackageRepository($package)));
  7137. } elseif ($input->getOption('platform')) {
  7138. $repos = $installedRepo = new InstalledRepository(array($platformRepo));
  7139. } elseif ($input->getOption('available')) {
  7140. $installedRepo = new InstalledRepository(array($platformRepo));
  7141. if ($composer) {
  7142. $repos = new CompositeRepository($composer->getRepositoryManager()->getRepositories());
  7143. $installedRepo->addRepository($composer->getRepositoryManager()->getLocalRepository());
  7144. } else {
  7145. $defaultRepos = RepositoryFactory::defaultRepos($io);
  7146. $repos = new CompositeRepository($defaultRepos);
  7147. $io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
  7148. }
  7149. } elseif ($input->getOption('all') && $composer) {
  7150. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  7151. $locker = $composer->getLocker();
  7152. if ($locker->isLocked()) {
  7153. $lockedRepo = $locker->getLockedRepository(true);
  7154. $installedRepo = new InstalledRepository(array($lockedRepo, $localRepo, $platformRepo));
  7155. } else {
  7156. $installedRepo = new InstalledRepository(array($localRepo, $platformRepo));
  7157. }
  7158. $repos = new CompositeRepository(array_merge(array(new FilterRepository($installedRepo, array('canonical' => false))), $composer->getRepositoryManager()->getRepositories()));
  7159. } elseif ($input->getOption('all')) {
  7160. $defaultRepos = RepositoryFactory::defaultRepos($io);
  7161. $io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
  7162. $installedRepo = new InstalledRepository(array($platformRepo));
  7163. $repos = new CompositeRepository(array_merge(array($installedRepo), $defaultRepos));
  7164. } elseif ($input->getOption('locked')) {
  7165. if (!$composer || !$composer->getLocker()->isLocked()) {
  7166. throw new \UnexpectedValueException('A valid composer.json and composer.lock files is required to run this command with --locked');
  7167. }
  7168. $locker = $composer->getLocker();
  7169. $lockedRepo = $locker->getLockedRepository(!$input->getOption('no-dev'));
  7170. $repos = $installedRepo = new InstalledRepository(array($lockedRepo));
  7171. } else {
  7172. if (!$composer) {
  7173. $composer = $this->requireComposer();
  7174. }
  7175. $rootPkg = $composer->getPackage();
  7176. $repos = $installedRepo = new InstalledRepository(array($composer->getRepositoryManager()->getLocalRepository()));
  7177. if ($input->getOption('no-dev')) {
  7178. $packages = $this->filterRequiredPackages($installedRepo, $rootPkg);
  7179. $repos = $installedRepo = new InstalledRepository(array(new InstalledArrayRepository(array_map(function ($pkg): PackageInterface {
  7180. return clone $pkg;
  7181. }, $packages))));
  7182. }
  7183. if (!$installedRepo->getPackages() && ($rootPkg->getRequires() || $rootPkg->getDevRequires())) {
  7184. $io->writeError('<warning>No dependencies installed. Try running composer install or update.</warning>');
  7185. }
  7186. }
  7187. if ($composer) {
  7188. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'show', $input, $output);
  7189. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  7190. }
  7191. if ($input->getOption('latest') && null === $composer) {
  7192. $io->writeError('No composer.json found in the current directory, disabling "latest" option');
  7193. $input->setOption('latest', false);
  7194. }
  7195. $packageFilter = $input->getArgument('package');
  7196. if (isset($package)) {
  7197. $versions = array($package->getPrettyVersion() => $package->getVersion());
  7198. } elseif (null !== $packageFilter && !str_contains($packageFilter, '*')) {
  7199. list($package, $versions) = $this->getPackage($installedRepo, $repos, $packageFilter, $input->getArgument('version'));
  7200. if (!isset($package)) {
  7201. $options = $input->getOptions();
  7202. $hint = '';
  7203. if ($input->getOption('locked')) {
  7204. $hint .= ' in lock file';
  7205. }
  7206. if (isset($options['working-dir'])) {
  7207. $hint .= ' in ' . $options['working-dir'] . '/composer.json';
  7208. }
  7209. if (PlatformRepository::isPlatformPackage($packageFilter) && !$input->getOption('platform')) {
  7210. $hint .= ', try using --platform (-p) to show platform packages';
  7211. }
  7212. if (!$input->getOption('all')) {
  7213. $hint .= ', try using --all (-a) to show all available packages';
  7214. }
  7215. throw new \InvalidArgumentException('Package "' . $packageFilter . '" not found'.$hint.'.');
  7216. }
  7217. }
  7218. if (isset($package)) {
  7219. assert(isset($versions));
  7220. $exitCode = 0;
  7221. if ($input->getOption('tree')) {
  7222. $arrayTree = $this->generatePackageTree($package, $installedRepo, $repos);
  7223. if ('json' === $format) {
  7224. $io->write(JsonFile::encode(array('installed' => array($arrayTree))));
  7225. } else {
  7226. $this->displayPackageTree(array($arrayTree));
  7227. }
  7228. return $exitCode;
  7229. }
  7230. $latestPackage = null;
  7231. if ($input->getOption('latest')) {
  7232. $latestPackage = $this->findLatestPackage($package, $composer, $platformRepo, $input->getOption('minor-only'), $input->getOption('patch-only'), $platformReqFilter);
  7233. }
  7234. if (
  7235. $input->getOption('outdated')
  7236. && $input->getOption('strict')
  7237. && null !== $latestPackage
  7238. && $latestPackage->getFullPrettyVersion() !== $package->getFullPrettyVersion()
  7239. && (!$latestPackage instanceof CompletePackageInterface || !$latestPackage->isAbandoned())
  7240. ) {
  7241. $exitCode = 1;
  7242. }
  7243. if ($input->getOption('path')) {
  7244. $io->write($package->getName(), false);
  7245. $io->write(' ' . strtok(realpath($composer->getInstallationManager()->getInstallPath($package)), "\r\n"));
  7246. return $exitCode;
  7247. }
  7248. if ('json' === $format) {
  7249. $this->printPackageInfoAsJson($package, $versions, $installedRepo, $latestPackage ?: null);
  7250. } else {
  7251. $this->printPackageInfo($package, $versions, $installedRepo, $latestPackage ?: null);
  7252. }
  7253. return $exitCode;
  7254. }
  7255. if ($input->getOption('tree')) {
  7256. $rootRequires = $this->getRootRequires();
  7257. $packages = $installedRepo->getPackages();
  7258. usort($packages, function (BasePackage $a, BasePackage $b): int {
  7259. return strcmp((string) $a, (string) $b);
  7260. });
  7261. $arrayTree = array();
  7262. foreach ($packages as $package) {
  7263. if (in_array($package->getName(), $rootRequires, true)) {
  7264. $arrayTree[] = $this->generatePackageTree($package, $installedRepo, $repos);
  7265. }
  7266. }
  7267. if ('json' === $format) {
  7268. $io->write(JsonFile::encode(array('installed' => $arrayTree)));
  7269. } else {
  7270. $this->displayPackageTree($arrayTree);
  7271. }
  7272. return 0;
  7273. }
  7274. $packages = array();
  7275. $packageFilterRegex = null;
  7276. if (null !== $packageFilter) {
  7277. $packageFilterRegex = '{^'.str_replace('\\*', '.*?', preg_quote($packageFilter)).'$}i';
  7278. }
  7279. $packageListFilter = array();
  7280. if ($input->getOption('direct')) {
  7281. $packageListFilter = $this->getRootRequires();
  7282. }
  7283. if ($input->getOption('path') && null === $composer) {
  7284. $io->writeError('No composer.json found in the current directory, disabling "path" option');
  7285. $input->setOption('path', false);
  7286. }
  7287. foreach ($repos->getRepositories() as $repo) {
  7288. if ($repo === $platformRepo) {
  7289. $type = 'platform';
  7290. } elseif ($lockedRepo !== null && $repo === $lockedRepo) {
  7291. $type = 'locked';
  7292. } elseif ($repo === $installedRepo || in_array($repo, $installedRepo->getRepositories(), true)) {
  7293. $type = 'installed';
  7294. } else {
  7295. $type = 'available';
  7296. }
  7297. if ($repo instanceof ComposerRepository) {
  7298. foreach ($repo->getPackageNames($packageFilter) as $name) {
  7299. $packages[$type][$name] = $name;
  7300. }
  7301. } else {
  7302. foreach ($repo->getPackages() as $package) {
  7303. if (!isset($packages[$type][$package->getName()])
  7304. || !is_object($packages[$type][$package->getName()])
  7305. || version_compare($packages[$type][$package->getName()]->getVersion(), $package->getVersion(), '<')
  7306. ) {
  7307. while ($package instanceof AliasPackage) {
  7308. $package = $package->getAliasOf();
  7309. }
  7310. if (!$packageFilterRegex || Preg::isMatch($packageFilterRegex, $package->getName())) {
  7311. if (!$packageListFilter || in_array($package->getName(), $packageListFilter, true)) {
  7312. $packages[$type][$package->getName()] = $package;
  7313. }
  7314. }
  7315. }
  7316. }
  7317. if ($repo === $platformRepo) {
  7318. foreach ($platformRepo->getDisabledPackages() as $name => $package) {
  7319. $packages[$type][$name] = $package;
  7320. }
  7321. }
  7322. }
  7323. }
  7324. $showAllTypes = $input->getOption('all');
  7325. $showLatest = $input->getOption('latest');
  7326. $showMinorOnly = $input->getOption('minor-only');
  7327. $showPatchOnly = $input->getOption('patch-only');
  7328. $ignoredPackages = array_map('strtolower', $input->getOption('ignore'));
  7329. $indent = $showAllTypes ? ' ' : '';
  7330. $latestPackages = array();
  7331. $exitCode = 0;
  7332. $viewData = array();
  7333. $viewMetaData = array();
  7334. foreach (array('platform' => true, 'locked' => true, 'available' => false, 'installed' => true) as $type => $showVersion) {
  7335. if (isset($packages[$type])) {
  7336. ksort($packages[$type]);
  7337. $nameLength = $versionLength = $latestLength = 0;
  7338. if ($showLatest && $showVersion) {
  7339. foreach ($packages[$type] as $package) {
  7340. if (is_object($package)) {
  7341. $latestPackage = $this->findLatestPackage($package, $composer, $platformRepo, $showMinorOnly, $showPatchOnly, $platformReqFilter);
  7342. if ($latestPackage === null) {
  7343. continue;
  7344. }
  7345. $latestPackages[$package->getPrettyName()] = $latestPackage;
  7346. }
  7347. }
  7348. }
  7349. $writePath = !$input->getOption('name-only') && $input->getOption('path');
  7350. $writeVersion = !$input->getOption('name-only') && !$input->getOption('path') && $showVersion;
  7351. $writeLatest = $writeVersion && $showLatest;
  7352. $writeDescription = !$input->getOption('name-only') && !$input->getOption('path');
  7353. $hasOutdatedPackages = false;
  7354. $viewData[$type] = array();
  7355. foreach ($packages[$type] as $package) {
  7356. $packageViewData = array();
  7357. if (is_object($package)) {
  7358. $latestPackage = null;
  7359. if ($showLatest && isset($latestPackages[$package->getPrettyName()])) {
  7360. $latestPackage = $latestPackages[$package->getPrettyName()];
  7361. }
  7362. $packageIsUpToDate = $latestPackage && $latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion() && (!$latestPackage instanceof CompletePackageInterface || !$latestPackage->isAbandoned());
  7363. $packageIsIgnored = \in_array($package->getPrettyName(), $ignoredPackages, true);
  7364. if ($input->getOption('outdated') && ($packageIsUpToDate || $packageIsIgnored)) {
  7365. continue;
  7366. }
  7367. if ($input->getOption('outdated') || $input->getOption('strict')) {
  7368. $hasOutdatedPackages = true;
  7369. }
  7370. $packageViewData['name'] = $package->getPrettyName();
  7371. if ($format !== 'json' || true !== $input->getOption('name-only')) {
  7372. $packageViewData['homepage'] = $package instanceof CompletePackageInterface ? $package->getHomepage() : null;
  7373. $packageViewData['source'] = PackageInfo::getViewSourceUrl($package);
  7374. }
  7375. $nameLength = max($nameLength, strlen($package->getPrettyName()));
  7376. if ($writeVersion) {
  7377. $packageViewData['version'] = $package->getFullPrettyVersion();
  7378. $versionLength = max($versionLength, strlen($package->getFullPrettyVersion()));
  7379. }
  7380. if ($writeLatest && $latestPackage) {
  7381. $packageViewData['latest'] = $latestPackage->getFullPrettyVersion();
  7382. $packageViewData['latest-status'] = $this->getUpdateStatus($latestPackage, $package);
  7383. $latestLength = max($latestLength, strlen($latestPackage->getFullPrettyVersion()));
  7384. }
  7385. if ($writeDescription && $package instanceof CompletePackageInterface) {
  7386. $packageViewData['description'] = $package->getDescription();
  7387. }
  7388. if ($writePath) {
  7389. $packageViewData['path'] = strtok(realpath($composer->getInstallationManager()->getInstallPath($package)), "\r\n");
  7390. }
  7391. $packageIsAbandoned = false;
  7392. if ($latestPackage instanceof CompletePackageInterface && $latestPackage->isAbandoned()) {
  7393. $replacementPackageName = $latestPackage->getReplacementPackage();
  7394. $replacement = $replacementPackageName !== null
  7395. ? 'Use ' . $latestPackage->getReplacementPackage() . ' instead'
  7396. : 'No replacement was suggested';
  7397. $packageWarning = sprintf(
  7398. 'Package %s is abandoned, you should avoid using it. %s.',
  7399. $package->getPrettyName(),
  7400. $replacement
  7401. );
  7402. $packageViewData['warning'] = $packageWarning;
  7403. $packageIsAbandoned = $replacementPackageName ?? true;
  7404. }
  7405. $packageViewData['abandoned'] = $packageIsAbandoned;
  7406. } else {
  7407. $packageViewData['name'] = $package;
  7408. $nameLength = max($nameLength, strlen($package));
  7409. }
  7410. $viewData[$type][] = $packageViewData;
  7411. }
  7412. $viewMetaData[$type] = array(
  7413. 'nameLength' => $nameLength,
  7414. 'versionLength' => $versionLength,
  7415. 'latestLength' => $latestLength,
  7416. );
  7417. if ($input->getOption('strict') && $hasOutdatedPackages) {
  7418. $exitCode = 1;
  7419. break;
  7420. }
  7421. }
  7422. }
  7423. if ('json' === $format) {
  7424. $io->write(JsonFile::encode($viewData));
  7425. } else {
  7426. if ($input->getOption('latest') && array_filter($viewData)) {
  7427. if (!$io->isDecorated()) {
  7428. $io->writeError('Legend:');
  7429. $io->writeError('! patch or minor release available - update recommended');
  7430. $io->writeError('~ major release available - update possible');
  7431. if (!$input->getOption('outdated')) {
  7432. $io->writeError('= up to date version');
  7433. }
  7434. } else {
  7435. $io->writeError('<info>Color legend:</info>');
  7436. $io->writeError('- <highlight>patch or minor</highlight> release available - update recommended');
  7437. $io->writeError('- <comment>major</comment> release available - update possible');
  7438. if (!$input->getOption('outdated')) {
  7439. $io->writeError('- <info>up to date</info> version');
  7440. }
  7441. }
  7442. }
  7443. $width = $this->getTerminalWidth();
  7444. foreach ($viewData as $type => $packages) {
  7445. $nameLength = $viewMetaData[$type]['nameLength'];
  7446. $versionLength = $viewMetaData[$type]['versionLength'];
  7447. $latestLength = $viewMetaData[$type]['latestLength'];
  7448. $writeVersion = $nameLength + $versionLength + 3 <= $width;
  7449. $writeLatest = $nameLength + $versionLength + $latestLength + 3 <= $width;
  7450. $writeDescription = $nameLength + $versionLength + $latestLength + 24 <= $width;
  7451. if ($writeLatest && !$io->isDecorated()) {
  7452. $latestLength += 2;
  7453. }
  7454. if ($showAllTypes) {
  7455. if ('available' === $type) {
  7456. $io->write('<comment>' . $type . '</comment>:');
  7457. } else {
  7458. $io->write('<info>' . $type . '</info>:');
  7459. }
  7460. }
  7461. foreach ($packages as $package) {
  7462. $link = $package['source'] ?? $package['homepage'] ?? '';
  7463. if ($link !== '') {
  7464. $io->write($indent . '<href='.OutputFormatter::escape($link).'>'.$package['name'].'</>'. str_repeat(' ', $nameLength - strlen($package['name'])), false);
  7465. } else {
  7466. $io->write($indent . str_pad($package['name'], $nameLength, ' '), false);
  7467. }
  7468. if (isset($package['version']) && $writeVersion) {
  7469. $io->write(' ' . str_pad($package['version'], $versionLength, ' '), false);
  7470. }
  7471. if (isset($package['latest']) && isset($package['latest-status']) && $writeLatest) {
  7472. $latestVersion = $package['latest'];
  7473. $updateStatus = $package['latest-status'];
  7474. $style = $this->updateStatusToVersionStyle($updateStatus);
  7475. if (!$io->isDecorated()) {
  7476. $latestVersion = str_replace(array('up-to-date', 'semver-safe-update', 'update-possible'), array('=', '!', '~'), $updateStatus) . ' ' . $latestVersion;
  7477. }
  7478. $io->write(' <' . $style . '>' . str_pad($latestVersion, $latestLength, ' ') . '</' . $style . '>', false);
  7479. }
  7480. if (isset($package['description']) && $writeDescription) {
  7481. $description = strtok($package['description'], "\r\n");
  7482. $remaining = $width - $nameLength - $versionLength - 4;
  7483. if ($writeLatest) {
  7484. $remaining -= $latestLength;
  7485. }
  7486. if (strlen($description) > $remaining) {
  7487. $description = substr($description, 0, $remaining - 3) . '...';
  7488. }
  7489. $io->write(' ' . $description, false);
  7490. }
  7491. if (isset($package['path'])) {
  7492. $io->write(' ' . $package['path'], false);
  7493. }
  7494. $io->write('');
  7495. if (isset($package['warning'])) {
  7496. $io->write('<warning>' . $package['warning'] . '</warning>');
  7497. }
  7498. }
  7499. if ($showAllTypes) {
  7500. $io->write('');
  7501. }
  7502. }
  7503. }
  7504. return $exitCode;
  7505. }
  7506. protected function getRootRequires(): array
  7507. {
  7508. $rootPackage = $this->requireComposer()->getPackage();
  7509. return array_map(
  7510. 'strtolower',
  7511. array_keys(array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires()))
  7512. );
  7513. }
  7514. protected function getVersionStyle(PackageInterface $latestPackage, PackageInterface $package)
  7515. {
  7516. return $this->updateStatusToVersionStyle($this->getUpdateStatus($latestPackage, $package));
  7517. }
  7518. protected function getPackage(InstalledRepository $installedRepo, RepositoryInterface $repos, string $name, $version = null): array
  7519. {
  7520. $name = strtolower($name);
  7521. $constraint = is_string($version) ? $this->versionParser->parseConstraints($version) : $version;
  7522. $policy = new DefaultPolicy();
  7523. $repositorySet = new RepositorySet('dev');
  7524. $repositorySet->allowInstalledRepositories();
  7525. $repositorySet->addRepository($repos);
  7526. $matchedPackage = null;
  7527. $versions = array();
  7528. if (PlatformRepository::isPlatformPackage($name)) {
  7529. $pool = $repositorySet->createPoolWithAllPackages();
  7530. } else {
  7531. $pool = $repositorySet->createPoolForPackage($name);
  7532. }
  7533. $matches = $pool->whatProvides($name, $constraint);
  7534. foreach ($matches as $index => $package) {
  7535. if ($package instanceof AliasPackage && $package->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  7536. $package = $package->getAliasOf();
  7537. }
  7538. if (null === $version && $installedRepo->hasPackage($package)) {
  7539. $matchedPackage = $package;
  7540. }
  7541. $versions[$package->getPrettyVersion()] = $package->getVersion();
  7542. $matches[$index] = $package->getId();
  7543. }
  7544. if (!$matchedPackage && $matches && $preferred = $policy->selectPreferredPackages($pool, $matches)) {
  7545. $matchedPackage = $pool->literalToPackage($preferred[0]);
  7546. }
  7547. return array($matchedPackage, $versions);
  7548. }
  7549. protected function printPackageInfo(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null): void
  7550. {
  7551. $io = $this->getIO();
  7552. $this->printMeta($package, $versions, $installedRepo, $latestPackage ?: null);
  7553. $this->printLinks($package, Link::TYPE_REQUIRE);
  7554. $this->printLinks($package, Link::TYPE_DEV_REQUIRE, 'requires (dev)');
  7555. if ($package->getSuggests()) {
  7556. $io->write("\n<info>suggests</info>");
  7557. foreach ($package->getSuggests() as $suggested => $reason) {
  7558. $io->write($suggested . ' <comment>' . $reason . '</comment>');
  7559. }
  7560. }
  7561. $this->printLinks($package, Link::TYPE_PROVIDE);
  7562. $this->printLinks($package, Link::TYPE_CONFLICT);
  7563. $this->printLinks($package, Link::TYPE_REPLACE);
  7564. }
  7565. protected function printMeta(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null): void
  7566. {
  7567. $io = $this->getIO();
  7568. $io->write('<info>name</info> : ' . $package->getPrettyName());
  7569. $io->write('<info>descrip.</info> : ' . $package->getDescription());
  7570. $io->write('<info>keywords</info> : ' . implode(', ', $package->getKeywords() ?: array()));
  7571. $this->printVersions($package, $versions, $installedRepo);
  7572. if ($latestPackage) {
  7573. $style = $this->getVersionStyle($latestPackage, $package);
  7574. $io->write('<info>latest</info> : <'.$style.'>' . $latestPackage->getPrettyVersion() . '</'.$style.'>');
  7575. } else {
  7576. $latestPackage = $package;
  7577. }
  7578. $io->write('<info>type</info> : ' . $package->getType());
  7579. $this->printLicenses($package);
  7580. $io->write('<info>homepage</info> : ' . $package->getHomepage());
  7581. $io->write('<info>source</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getSourceType(), $package->getSourceUrl(), $package->getSourceReference()));
  7582. $io->write('<info>dist</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getDistType(), $package->getDistUrl(), $package->getDistReference()));
  7583. if ($installedRepo->hasPackage($package)) {
  7584. $io->write('<info>path</info> : ' . sprintf('%s', realpath($this->requireComposer()->getInstallationManager()->getInstallPath($package))));
  7585. }
  7586. $io->write('<info>names</info> : ' . implode(', ', $package->getNames()));
  7587. if ($latestPackage instanceof CompletePackageInterface && $latestPackage->isAbandoned()) {
  7588. $replacement = ($latestPackage->getReplacementPackage() !== null)
  7589. ? ' The author suggests using the ' . $latestPackage->getReplacementPackage(). ' package instead.'
  7590. : null;
  7591. $io->writeError(
  7592. sprintf('<warning>Attention: This package is abandoned and no longer maintained.%s</warning>', $replacement)
  7593. );
  7594. }
  7595. if ($package->getSupport()) {
  7596. $io->write("\n<info>support</info>");
  7597. foreach ($package->getSupport() as $type => $value) {
  7598. $io->write('<comment>' . $type . '</comment> : '.$value);
  7599. }
  7600. }
  7601. if ($package->getAutoload()) {
  7602. $io->write("\n<info>autoload</info>");
  7603. $autoloadConfig = $package->getAutoload();
  7604. foreach ($autoloadConfig as $type => $autoloads) {
  7605. $io->write('<comment>' . $type . '</comment>');
  7606. if ($type === 'psr-0' || $type === 'psr-4') {
  7607. foreach ($autoloads as $name => $path) {
  7608. $io->write(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
  7609. }
  7610. } elseif ($type === 'classmap') {
  7611. $io->write(implode(', ', $autoloadConfig[$type]));
  7612. }
  7613. }
  7614. if ($package->getIncludePaths()) {
  7615. $io->write('<comment>include-path</comment>');
  7616. $io->write(implode(', ', $package->getIncludePaths()));
  7617. }
  7618. }
  7619. }
  7620. protected function printVersions(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo): void
  7621. {
  7622. $versions = array_keys($versions);
  7623. $versions = Semver::rsort($versions);
  7624. if ($installedPackages = $installedRepo->findPackages($package->getName())) {
  7625. foreach ($installedPackages as $installedPackage) {
  7626. $installedVersion = $installedPackage->getPrettyVersion();
  7627. $key = array_search($installedVersion, $versions);
  7628. if (false !== $key) {
  7629. $versions[$key] = '<info>* ' . $installedVersion . '</info>';
  7630. }
  7631. }
  7632. }
  7633. $versions = implode(', ', $versions);
  7634. $this->getIO()->write('<info>versions</info> : ' . $versions);
  7635. }
  7636. protected function printLinks(CompletePackageInterface $package, string $linkType, string $title = null): void
  7637. {
  7638. $title = $title ?: $linkType;
  7639. $io = $this->getIO();
  7640. if ($links = $package->{'get'.ucfirst($linkType)}()) {
  7641. $io->write("\n<info>" . $title . "</info>");
  7642. foreach ($links as $link) {
  7643. $io->write($link->getTarget() . ' <comment>' . $link->getPrettyConstraint() . '</comment>');
  7644. }
  7645. }
  7646. }
  7647. protected function printLicenses(CompletePackageInterface $package): void
  7648. {
  7649. $spdxLicenses = new SpdxLicenses();
  7650. $licenses = $package->getLicense();
  7651. $io = $this->getIO();
  7652. foreach ($licenses as $licenseId) {
  7653. $license = $spdxLicenses->getLicenseByIdentifier($licenseId);
  7654. if (!$license) {
  7655. $out = $licenseId;
  7656. } else {
  7657. if ($license[1] === true) {
  7658. $out = sprintf('%s (%s) (OSI approved) %s', $license[0], $licenseId, $license[2]);
  7659. } else {
  7660. $out = sprintf('%s (%s) %s', $license[0], $licenseId, $license[2]);
  7661. }
  7662. }
  7663. $io->write('<info>license</info> : ' . $out);
  7664. }
  7665. }
  7666. protected function printPackageInfoAsJson(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null): void
  7667. {
  7668. $json = array(
  7669. 'name' => $package->getPrettyName(),
  7670. 'description' => $package->getDescription(),
  7671. 'keywords' => $package->getKeywords() ?: array(),
  7672. 'type' => $package->getType(),
  7673. 'homepage' => $package->getHomepage(),
  7674. 'names' => $package->getNames(),
  7675. );
  7676. $json = $this->appendVersions($json, $versions);
  7677. $json = $this->appendLicenses($json, $package);
  7678. if ($latestPackage) {
  7679. $json['latest'] = $latestPackage->getPrettyVersion();
  7680. } else {
  7681. $latestPackage = $package;
  7682. }
  7683. if (null !== $package->getSourceType()) {
  7684. $json['source'] = array(
  7685. 'type' => $package->getSourceType(),
  7686. 'url' => $package->getSourceUrl(),
  7687. 'reference' => $package->getSourceReference(),
  7688. );
  7689. }
  7690. if (null !== $package->getDistType()) {
  7691. $json['dist'] = array(
  7692. 'type' => $package->getDistType(),
  7693. 'url' => $package->getDistUrl(),
  7694. 'reference' => $package->getDistReference(),
  7695. );
  7696. }
  7697. if ($installedRepo->hasPackage($package)) {
  7698. $json['path'] = realpath($this->requireComposer()->getInstallationManager()->getInstallPath($package));
  7699. if ($json['path'] === false) {
  7700. unset($json['path']);
  7701. }
  7702. }
  7703. if ($latestPackage instanceof CompletePackageInterface && $latestPackage->isAbandoned()) {
  7704. $json['replacement'] = $latestPackage->getReplacementPackage();
  7705. }
  7706. if ($package->getSuggests()) {
  7707. $json['suggests'] = $package->getSuggests();
  7708. }
  7709. if ($package->getSupport()) {
  7710. $json['support'] = $package->getSupport();
  7711. }
  7712. $json = $this->appendAutoload($json, $package);
  7713. if ($package->getIncludePaths()) {
  7714. $json['include_path'] = $package->getIncludePaths();
  7715. }
  7716. $json = $this->appendLinks($json, $package);
  7717. $this->getIO()->write(JsonFile::encode($json));
  7718. }
  7719. private function appendVersions(array $json, array $versions): array
  7720. {
  7721. uasort($versions, 'version_compare');
  7722. $versions = array_keys(array_reverse($versions));
  7723. $json['versions'] = $versions;
  7724. return $json;
  7725. }
  7726. private function appendLicenses(array $json, CompletePackageInterface $package): array
  7727. {
  7728. if ($licenses = $package->getLicense()) {
  7729. $spdxLicenses = new SpdxLicenses();
  7730. $json['licenses'] = array_map(function ($licenseId) use ($spdxLicenses) {
  7731. $license = $spdxLicenses->getLicenseByIdentifier($licenseId);
  7732. if (!$license) {
  7733. return $licenseId;
  7734. }
  7735. return array(
  7736. 'name' => $license[0],
  7737. 'osi' => $licenseId,
  7738. 'url' => $license[2],
  7739. );
  7740. }, $licenses);
  7741. }
  7742. return $json;
  7743. }
  7744. private function appendAutoload(array $json, CompletePackageInterface $package): array
  7745. {
  7746. if ($package->getAutoload()) {
  7747. $autoload = array();
  7748. foreach ($package->getAutoload() as $type => $autoloads) {
  7749. if ($type === 'psr-0' || $type === 'psr-4') {
  7750. $psr = array();
  7751. foreach ($autoloads as $name => $path) {
  7752. if (!$path) {
  7753. $path = '.';
  7754. }
  7755. $psr[$name ?: '*'] = $path;
  7756. }
  7757. $autoload[$type] = $psr;
  7758. } elseif ($type === 'classmap') {
  7759. $autoload['classmap'] = $autoloads;
  7760. }
  7761. }
  7762. $json['autoload'] = $autoload;
  7763. }
  7764. return $json;
  7765. }
  7766. private function appendLinks(array $json, CompletePackageInterface $package): array
  7767. {
  7768. foreach (Link::$TYPES as $linkType) {
  7769. $json = $this->appendLink($json, $package, $linkType);
  7770. }
  7771. return $json;
  7772. }
  7773. private function appendLink(array $json, CompletePackageInterface $package, string $linkType): array
  7774. {
  7775. $links = $package->{'get' . ucfirst($linkType)}();
  7776. if ($links) {
  7777. $json[$linkType] = array();
  7778. foreach ($links as $link) {
  7779. $json[$linkType][$link->getTarget()] = $link->getPrettyConstraint();
  7780. }
  7781. }
  7782. return $json;
  7783. }
  7784. protected function initStyles(OutputInterface $output): void
  7785. {
  7786. $this->colors = array(
  7787. 'green',
  7788. 'yellow',
  7789. 'cyan',
  7790. 'magenta',
  7791. 'blue',
  7792. );
  7793. foreach ($this->colors as $color) {
  7794. $style = new OutputFormatterStyle($color);
  7795. $output->getFormatter()->setStyle($color, $style);
  7796. }
  7797. }
  7798. protected function displayPackageTree(array $arrayTree): void
  7799. {
  7800. $io = $this->getIO();
  7801. foreach ($arrayTree as $package) {
  7802. $io->write(sprintf('<info>%s</info>', $package['name']), false);
  7803. $io->write(' ' . $package['version'], false);
  7804. $io->write(' ' . strtok($package['description'], "\r\n"));
  7805. if (isset($package['requires'])) {
  7806. $requires = $package['requires'];
  7807. $treeBar = '├';
  7808. $j = 0;
  7809. $total = count($requires);
  7810. foreach ($requires as $require) {
  7811. $requireName = $require['name'];
  7812. $j++;
  7813. if ($j === $total) {
  7814. $treeBar = 'â””';
  7815. }
  7816. $level = 1;
  7817. $color = $this->colors[$level];
  7818. $info = sprintf(
  7819. '%s──<%s>%s</%s> %s',
  7820. $treeBar,
  7821. $color,
  7822. $requireName,
  7823. $color,
  7824. $require['version']
  7825. );
  7826. $this->writeTreeLine($info);
  7827. $treeBar = str_replace('â””', ' ', $treeBar);
  7828. $packagesInTree = array($package['name'], $requireName);
  7829. $this->displayTree($require, $packagesInTree, $treeBar, $level + 1);
  7830. }
  7831. }
  7832. }
  7833. }
  7834. protected function generatePackageTree(
  7835. PackageInterface $package,
  7836. InstalledRepository $installedRepo,
  7837. RepositoryInterface $remoteRepos
  7838. ): array {
  7839. $requires = $package->getRequires();
  7840. ksort($requires);
  7841. $children = array();
  7842. foreach ($requires as $requireName => $require) {
  7843. $packagesInTree = array($package->getName(), $requireName);
  7844. $treeChildDesc = array(
  7845. 'name' => $requireName,
  7846. 'version' => $require->getPrettyConstraint(),
  7847. );
  7848. $deepChildren = $this->addTree($requireName, $require, $installedRepo, $remoteRepos, $packagesInTree);
  7849. if ($deepChildren) {
  7850. $treeChildDesc['requires'] = $deepChildren;
  7851. }
  7852. $children[] = $treeChildDesc;
  7853. }
  7854. $tree = array(
  7855. 'name' => $package->getPrettyName(),
  7856. 'version' => $package->getPrettyVersion(),
  7857. 'description' => $package instanceof CompletePackageInterface ? $package->getDescription() : '',
  7858. );
  7859. if ($children) {
  7860. $tree['requires'] = $children;
  7861. }
  7862. return $tree;
  7863. }
  7864. protected function displayTree(
  7865. $package,
  7866. array $packagesInTree,
  7867. string $previousTreeBar = '├',
  7868. int $level = 1
  7869. ): void {
  7870. $previousTreeBar = str_replace('├', '│', $previousTreeBar);
  7871. if (is_array($package) && isset($package['requires'])) {
  7872. $requires = $package['requires'];
  7873. $treeBar = $previousTreeBar . ' ├';
  7874. $i = 0;
  7875. $total = count($requires);
  7876. foreach ($requires as $require) {
  7877. $currentTree = $packagesInTree;
  7878. $i++;
  7879. if ($i === $total) {
  7880. $treeBar = $previousTreeBar . ' â””';
  7881. }
  7882. $colorIdent = $level % count($this->colors);
  7883. $color = $this->colors[$colorIdent];
  7884. $circularWarn = in_array(
  7885. $require['name'],
  7886. $currentTree,
  7887. true
  7888. ) ? '(circular dependency aborted here)' : '';
  7889. $info = rtrim(sprintf(
  7890. '%s──<%s>%s</%s> %s %s',
  7891. $treeBar,
  7892. $color,
  7893. $require['name'],
  7894. $color,
  7895. $require['version'],
  7896. $circularWarn
  7897. ));
  7898. $this->writeTreeLine($info);
  7899. $treeBar = str_replace('â””', ' ', $treeBar);
  7900. $currentTree[] = $require['name'];
  7901. $this->displayTree($require, $currentTree, $treeBar, $level + 1);
  7902. }
  7903. }
  7904. }
  7905. protected function addTree(
  7906. string $name,
  7907. Link $link,
  7908. InstalledRepository $installedRepo,
  7909. RepositoryInterface $remoteRepos,
  7910. array $packagesInTree
  7911. ): array {
  7912. $children = array();
  7913. list($package) = $this->getPackage(
  7914. $installedRepo,
  7915. $remoteRepos,
  7916. $name,
  7917. $link->getPrettyConstraint() === 'self.version' ? $link->getConstraint() : $link->getPrettyConstraint()
  7918. );
  7919. if (is_object($package)) {
  7920. $requires = $package->getRequires();
  7921. ksort($requires);
  7922. foreach ($requires as $requireName => $require) {
  7923. $currentTree = $packagesInTree;
  7924. $treeChildDesc = array(
  7925. 'name' => $requireName,
  7926. 'version' => $require->getPrettyConstraint(),
  7927. );
  7928. if (!in_array($requireName, $currentTree, true)) {
  7929. $currentTree[] = $requireName;
  7930. $deepChildren = $this->addTree($requireName, $require, $installedRepo, $remoteRepos, $currentTree);
  7931. if ($deepChildren) {
  7932. $treeChildDesc['requires'] = $deepChildren;
  7933. }
  7934. }
  7935. $children[] = $treeChildDesc;
  7936. }
  7937. }
  7938. return $children;
  7939. }
  7940. private function updateStatusToVersionStyle(string $updateStatus): string
  7941. {
  7942. return str_replace(array('up-to-date', 'semver-safe-update', 'update-possible'), array('info', 'highlight', 'comment'), $updateStatus);
  7943. }
  7944. private function getUpdateStatus(PackageInterface $latestPackage, PackageInterface $package): string
  7945. {
  7946. if ($latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion()) {
  7947. return 'up-to-date';
  7948. }
  7949. $constraint = $package->getVersion();
  7950. if (0 !== strpos($constraint, 'dev-')) {
  7951. $constraint = '^'.$constraint;
  7952. }
  7953. if ($latestPackage->getVersion() && Semver::satisfies($latestPackage->getVersion(), $constraint)) {
  7954. return 'semver-safe-update';
  7955. }
  7956. return 'update-possible';
  7957. }
  7958. private function writeTreeLine(string $line): void
  7959. {
  7960. $io = $this->getIO();
  7961. if (!$io->isDecorated()) {
  7962. $line = str_replace(array('└', '├', '──', '│'), array('`-', '|-', '-', '|'), $line);
  7963. }
  7964. $io->write($line);
  7965. }
  7966. private function findLatestPackage(PackageInterface $package, Composer $composer, PlatformRepository $platformRepo, bool $minorOnly, bool $patchOnly, PlatformRequirementFilterInterface $platformReqFilter): ?PackageInterface
  7967. {
  7968. $name = $package->getName();
  7969. $versionSelector = new VersionSelector($this->getRepositorySet($composer), $platformRepo);
  7970. $stability = $composer->getPackage()->getMinimumStability();
  7971. $flags = $composer->getPackage()->getStabilityFlags();
  7972. if (isset($flags[$name])) {
  7973. $stability = array_search($flags[$name], BasePackage::$stabilities, true);
  7974. }
  7975. $bestStability = $stability;
  7976. if ($composer->getPackage()->getPreferStable()) {
  7977. $bestStability = $package->getStability();
  7978. }
  7979. $targetVersion = null;
  7980. if (0 === strpos($package->getVersion(), 'dev-')) {
  7981. $targetVersion = $package->getVersion();
  7982. }
  7983. if ($targetVersion === null && $minorOnly) {
  7984. $targetVersion = '^' . $package->getVersion();
  7985. }
  7986. if ($targetVersion === null && $patchOnly) {
  7987. $trimmedVersion = Preg::replace('{(\.0)+$}D', '', $package->getVersion());
  7988. $partsNeeded = substr($trimmedVersion, 0, 1) === '0' ? 4 : 3;
  7989. while (substr_count($trimmedVersion, '.') + 1 < $partsNeeded) {
  7990. $trimmedVersion .= '.0';
  7991. }
  7992. $targetVersion = '~' . $trimmedVersion;
  7993. }
  7994. $candidate = $versionSelector->findBestCandidate($name, $targetVersion, $bestStability, $platformReqFilter);
  7995. while ($candidate instanceof AliasPackage) {
  7996. $candidate = $candidate->getAliasOf();
  7997. }
  7998. return $candidate !== false ? $candidate : null;
  7999. }
  8000. private function getRepositorySet(Composer $composer): RepositorySet
  8001. {
  8002. if (!$this->repositorySet) {
  8003. $this->repositorySet = new RepositorySet($composer->getPackage()->getMinimumStability(), $composer->getPackage()->getStabilityFlags());
  8004. $this->repositorySet->addRepository(new CompositeRepository($composer->getRepositoryManager()->getRepositories()));
  8005. }
  8006. return $this->repositorySet;
  8007. }
  8008. private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, array $bucket = array()): array
  8009. {
  8010. $requires = $package->getRequires();
  8011. foreach ($repo->getPackages() as $candidate) {
  8012. foreach ($candidate->getNames() as $name) {
  8013. if (isset($requires[$name])) {
  8014. if (!in_array($candidate, $bucket, true)) {
  8015. $bucket[] = $candidate;
  8016. $bucket = $this->filterRequiredPackages($repo, $candidate, $bucket);
  8017. }
  8018. break;
  8019. }
  8020. }
  8021. }
  8022. return $bucket;
  8023. }
  8024. }
  8025. <?php declare(strict_types=1);
  8026. namespace Composer\Command;
  8027. use Symfony\Component\Console\Input\InputInterface;
  8028. use Symfony\Component\Console\Input\InputOption;
  8029. use Symfony\Component\Console\Output\OutputInterface;
  8030. use Composer\Downloader\ChangeReportInterface;
  8031. use Composer\Downloader\DvcsDownloaderInterface;
  8032. use Composer\Downloader\VcsCapableDownloaderInterface;
  8033. use Composer\Package\Dumper\ArrayDumper;
  8034. use Composer\Package\Version\VersionGuesser;
  8035. use Composer\Package\Version\VersionParser;
  8036. use Composer\Plugin\CommandEvent;
  8037. use Composer\Plugin\PluginEvents;
  8038. use Composer\Script\ScriptEvents;
  8039. use Composer\Util\ProcessExecutor;
  8040. class StatusCommand extends BaseCommand
  8041. {
  8042. private const EXIT_CODE_ERRORS = 1;
  8043. private const EXIT_CODE_UNPUSHED_CHANGES = 2;
  8044. private const EXIT_CODE_VERSION_CHANGES = 4;
  8045. protected function configure(): void
  8046. {
  8047. $this
  8048. ->setName('status')
  8049. ->setDescription('Shows a list of locally modified packages.')
  8050. ->setDefinition(array(
  8051. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Show modified files for each directory that contains changes.'),
  8052. ))
  8053. ->setHelp(
  8054. <<<EOT
  8055. The status command displays a list of dependencies that have
  8056. been modified locally.
  8057. Read more at https://getcomposer.org/doc/03-cli.md#status
  8058. EOT
  8059. )
  8060. ;
  8061. }
  8062. protected function execute(InputInterface $input, OutputInterface $output): int
  8063. {
  8064. $composer = $this->requireComposer();
  8065. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'status', $input, $output);
  8066. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  8067. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::PRE_STATUS_CMD, true);
  8068. $exitCode = $this->doExecute($input);
  8069. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_STATUS_CMD, true);
  8070. return $exitCode;
  8071. }
  8072. private function doExecute(InputInterface $input): int
  8073. {
  8074. $composer = $this->requireComposer();
  8075. $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
  8076. $dm = $composer->getDownloadManager();
  8077. $im = $composer->getInstallationManager();
  8078. $errors = array();
  8079. $io = $this->getIO();
  8080. $unpushedChanges = array();
  8081. $vcsVersionChanges = array();
  8082. $parser = new VersionParser;
  8083. $guesser = new VersionGuesser($composer->getConfig(), $composer->getLoop()->getProcessExecutor() ?? new ProcessExecutor($io), $parser);
  8084. $dumper = new ArrayDumper;
  8085. foreach ($installedRepo->getCanonicalPackages() as $package) {
  8086. $downloader = $dm->getDownloaderForPackage($package);
  8087. $targetDir = $im->getInstallPath($package);
  8088. if ($downloader instanceof ChangeReportInterface) {
  8089. if (is_link($targetDir)) {
  8090. $errors[$targetDir] = $targetDir . ' is a symbolic link.';
  8091. }
  8092. if (null !== ($changes = $downloader->getLocalChanges($package, $targetDir))) {
  8093. $errors[$targetDir] = $changes;
  8094. }
  8095. }
  8096. if ($downloader instanceof VcsCapableDownloaderInterface) {
  8097. if ($downloader->getVcsReference($package, $targetDir)) {
  8098. switch ($package->getInstallationSource()) {
  8099. case 'source':
  8100. $previousRef = $package->getSourceReference();
  8101. break;
  8102. case 'dist':
  8103. $previousRef = $package->getDistReference();
  8104. break;
  8105. default:
  8106. $previousRef = null;
  8107. }
  8108. $currentVersion = $guesser->guessVersion($dumper->dump($package), $targetDir);
  8109. if ($previousRef && $currentVersion && $currentVersion['commit'] !== $previousRef) {
  8110. $vcsVersionChanges[$targetDir] = array(
  8111. 'previous' => array(
  8112. 'version' => $package->getPrettyVersion(),
  8113. 'ref' => $previousRef,
  8114. ),
  8115. 'current' => array(
  8116. 'version' => $currentVersion['pretty_version'],
  8117. 'ref' => $currentVersion['commit'],
  8118. ),
  8119. );
  8120. }
  8121. }
  8122. }
  8123. if ($downloader instanceof DvcsDownloaderInterface) {
  8124. if ($unpushed = $downloader->getUnpushedChanges($package, $targetDir)) {
  8125. $unpushedChanges[$targetDir] = $unpushed;
  8126. }
  8127. }
  8128. }
  8129. if (!$errors && !$unpushedChanges && !$vcsVersionChanges) {
  8130. $io->writeError('<info>No local changes</info>');
  8131. return 0;
  8132. }
  8133. if ($errors) {
  8134. $io->writeError('<error>You have changes in the following dependencies:</error>');
  8135. foreach ($errors as $path => $changes) {
  8136. if ($input->getOption('verbose')) {
  8137. $indentedChanges = implode("\n", array_map(function ($line): string {
  8138. return ' ' . ltrim($line);
  8139. }, explode("\n", $changes)));
  8140. $io->write('<info>'.$path.'</info>:');
  8141. $io->write($indentedChanges);
  8142. } else {
  8143. $io->write($path);
  8144. }
  8145. }
  8146. }
  8147. if ($unpushedChanges) {
  8148. $io->writeError('<warning>You have unpushed changes on the current branch in the following dependencies:</warning>');
  8149. foreach ($unpushedChanges as $path => $changes) {
  8150. if ($input->getOption('verbose')) {
  8151. $indentedChanges = implode("\n", array_map(function ($line): string {
  8152. return ' ' . ltrim($line);
  8153. }, explode("\n", $changes)));
  8154. $io->write('<info>'.$path.'</info>:');
  8155. $io->write($indentedChanges);
  8156. } else {
  8157. $io->write($path);
  8158. }
  8159. }
  8160. }
  8161. if ($vcsVersionChanges) {
  8162. $io->writeError('<warning>You have version variations in the following dependencies:</warning>');
  8163. foreach ($vcsVersionChanges as $path => $changes) {
  8164. if ($input->getOption('verbose')) {
  8165. $currentVersion = $changes['current']['version'] ?: $changes['current']['ref'];
  8166. $previousVersion = $changes['previous']['version'] ?: $changes['previous']['ref'];
  8167. if ($io->isVeryVerbose()) {
  8168. $currentVersion .= sprintf(' (%s)', $changes['current']['ref']);
  8169. $previousVersion .= sprintf(' (%s)', $changes['previous']['ref']);
  8170. }
  8171. $io->write('<info>'.$path.'</info>:');
  8172. $io->write(sprintf(' From <comment>%s</comment> to <comment>%s</comment>', $previousVersion, $currentVersion));
  8173. } else {
  8174. $io->write($path);
  8175. }
  8176. }
  8177. }
  8178. if (($errors || $unpushedChanges || $vcsVersionChanges) && !$input->getOption('verbose')) {
  8179. $io->writeError('Use --verbose (-v) to see a list of files');
  8180. }
  8181. return ($errors ? self::EXIT_CODE_ERRORS : 0) + ($unpushedChanges ? self::EXIT_CODE_UNPUSHED_CHANGES : 0) + ($vcsVersionChanges ? self::EXIT_CODE_VERSION_CHANGES : 0);
  8182. }
  8183. }
  8184. <?php declare(strict_types=1);
  8185. namespace Composer\Command;
  8186. use Composer\Repository\PlatformRepository;
  8187. use Composer\Repository\RootPackageRepository;
  8188. use Composer\Repository\InstalledRepository;
  8189. use Composer\Installer\SuggestedPackagesReporter;
  8190. use Symfony\Component\Console\Input\InputArgument;
  8191. use Symfony\Component\Console\Input\InputInterface;
  8192. use Symfony\Component\Console\Input\InputOption;
  8193. use Symfony\Component\Console\Output\OutputInterface;
  8194. class SuggestsCommand extends BaseCommand
  8195. {
  8196. protected function configure(): void
  8197. {
  8198. $this
  8199. ->setName('suggests')
  8200. ->setDescription('Shows package suggestions.')
  8201. ->setDefinition(array(
  8202. new InputOption('by-package', null, InputOption::VALUE_NONE, 'Groups output by suggesting package (default)'),
  8203. new InputOption('by-suggestion', null, InputOption::VALUE_NONE, 'Groups output by suggested package'),
  8204. new InputOption('all', 'a', InputOption::VALUE_NONE, 'Show suggestions from all dependencies, including transitive ones'),
  8205. new InputOption('list', null, InputOption::VALUE_NONE, 'Show only list of suggested package names'),
  8206. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Exclude suggestions from require-dev packages'),
  8207. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that you want to list suggestions from.'),
  8208. ))
  8209. ->setHelp(
  8210. <<<EOT
  8211. The <info>%command.name%</info> command shows a sorted list of suggested packages.
  8212. Read more at https://getcomposer.org/doc/03-cli.md#suggests
  8213. EOT
  8214. )
  8215. ;
  8216. }
  8217. protected function execute(InputInterface $input, OutputInterface $output): int
  8218. {
  8219. $composer = $this->requireComposer();
  8220. $installedRepos = array(
  8221. new RootPackageRepository(clone $composer->getPackage()),
  8222. );
  8223. $locker = $composer->getLocker();
  8224. if ($locker->isLocked()) {
  8225. $installedRepos[] = new PlatformRepository(array(), $locker->getPlatformOverrides());
  8226. $installedRepos[] = $locker->getLockedRepository(!$input->getOption('no-dev'));
  8227. } else {
  8228. $installedRepos[] = new PlatformRepository(array(), $composer->getConfig()->get('platform') ?: array());
  8229. $installedRepos[] = $composer->getRepositoryManager()->getLocalRepository();
  8230. }
  8231. $installedRepo = new InstalledRepository($installedRepos);
  8232. $reporter = new SuggestedPackagesReporter($this->getIO());
  8233. $filter = $input->getArgument('packages');
  8234. $packages = $installedRepo->getPackages();
  8235. $packages[] = $composer->getPackage();
  8236. foreach ($packages as $package) {
  8237. if (!empty($filter) && !in_array($package->getName(), $filter)) {
  8238. continue;
  8239. }
  8240. $reporter->addSuggestionsFromPackage($package);
  8241. }
  8242. $mode = SuggestedPackagesReporter::MODE_BY_PACKAGE;
  8243. if ($input->getOption('by-suggestion')) {
  8244. $mode = SuggestedPackagesReporter::MODE_BY_SUGGESTION;
  8245. }
  8246. if ($input->getOption('by-package')) {
  8247. $mode |= SuggestedPackagesReporter::MODE_BY_PACKAGE;
  8248. }
  8249. if ($input->getOption('list')) {
  8250. $mode = SuggestedPackagesReporter::MODE_LIST;
  8251. }
  8252. $reporter->output($mode, $installedRepo, empty($filter) && !$input->getOption('all') ? $composer->getPackage() : null);
  8253. return 0;
  8254. }
  8255. }
  8256. <?php declare(strict_types=1);
  8257. namespace Composer\Command;
  8258. use Composer\Composer;
  8259. use Composer\DependencyResolver\Request;
  8260. use Composer\Installer;
  8261. use Composer\IO\IOInterface;
  8262. use Composer\Package\Loader\RootPackageLoader;
  8263. use Composer\Pcre\Preg;
  8264. use Composer\Plugin\CommandEvent;
  8265. use Composer\Plugin\PluginEvents;
  8266. use Composer\Package\Version\VersionParser;
  8267. use Composer\Util\HttpDownloader;
  8268. use Composer\Semver\Constraint\MultiConstraint;
  8269. use Composer\Package\Link;
  8270. use Symfony\Component\Console\Helper\Table;
  8271. use Symfony\Component\Console\Input\InputInterface;
  8272. use Symfony\Component\Console\Input\InputOption;
  8273. use Symfony\Component\Console\Input\InputArgument;
  8274. use Symfony\Component\Console\Output\OutputInterface;
  8275. use Symfony\Component\Console\Question\Question;
  8276. class UpdateCommand extends BaseCommand
  8277. {
  8278. protected function configure()
  8279. {
  8280. $this
  8281. ->setName('update')
  8282. ->setAliases(array('u', 'upgrade'))
  8283. ->setDescription('Updates your dependencies to the latest version according to composer.json, and updates the composer.lock file.')
  8284. ->setDefinition(array(
  8285. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that should be updated, if not provided all packages are.'),
  8286. new InputOption('with', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Temporary version constraint to add, e.g. foo/bar:1.0.0 or foo/bar=1.0.0'),
  8287. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  8288. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
  8289. new InputOption('prefer-install', null, InputOption::VALUE_REQUIRED, 'Forces installation from package dist|source|auto (auto chooses source for dev versions, dist for the rest).'),
  8290. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  8291. new InputOption('dev', null, InputOption::VALUE_NONE, 'DEPRECATED: Enables installation of require-dev packages (enabled by default, only present for BC).'),
  8292. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  8293. new InputOption('lock', null, InputOption::VALUE_NONE, 'Overwrites the lock file hash to suppress warning about the lock file being out of date without updating package versions. Package metadata like mirrors and URLs are updated if they changed.'),
  8294. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  8295. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  8296. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  8297. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  8298. new InputOption('with-dependencies', 'w', InputOption::VALUE_NONE, 'Update also dependencies of packages in the argument list, except those which are root requirements.'),
  8299. new InputOption('with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Update also dependencies of packages in the argument list, including those which are root requirements.'),
  8300. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
  8301. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump.'),
  8302. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  8303. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  8304. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  8305. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  8306. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  8307. new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies.'),
  8308. new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies.'),
  8309. new InputOption('interactive', 'i', InputOption::VALUE_NONE, 'Interactive interface with autocompletion to select the packages to update.'),
  8310. new InputOption('root-reqs', null, InputOption::VALUE_NONE, 'Restricts the update to your first degree dependencies.'),
  8311. ))
  8312. ->setHelp(
  8313. <<<EOT
  8314. The <info>update</info> command reads the composer.json file from the
  8315. current directory, processes it, and updates, removes or installs all the
  8316. dependencies.
  8317. <info>php composer.phar update</info>
  8318. To limit the update operation to a few packages, you can list the package(s)
  8319. you want to update as such:
  8320. <info>php composer.phar update vendor/package1 foo/mypackage [...]</info>
  8321. You may also use an asterisk (*) pattern to limit the update operation to package(s)
  8322. from a specific vendor:
  8323. <info>php composer.phar update vendor/package1 foo/* [...]</info>
  8324. To run an update with more restrictive constraints you can use:
  8325. <info>php composer.phar update --with vendor/package:1.0.*</info>
  8326. To run a partial update with more restrictive constraints you can use the shorthand:
  8327. <info>php composer.phar update vendor/package:1.0.*</info>
  8328. To select packages names interactively with auto-completion use <info>-i</info>.
  8329. Read more at https://getcomposer.org/doc/03-cli.md#update-u
  8330. EOT
  8331. )
  8332. ;
  8333. }
  8334. protected function execute(InputInterface $input, OutputInterface $output)
  8335. {
  8336. $io = $this->getIO();
  8337. if ($input->getOption('dev')) {
  8338. $io->writeError('<warning>You are using the deprecated option "--dev". It has no effect and will break in Composer 3.</warning>');
  8339. }
  8340. if ($input->getOption('no-suggest')) {
  8341. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  8342. }
  8343. $composer = $this->requireComposer();
  8344. if (!HttpDownloader::isCurlEnabled()) {
  8345. $io->writeError('<warning>Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.</warning>');
  8346. }
  8347. $packages = $input->getArgument('packages');
  8348. $reqs = $this->formatRequirements($input->getOption('with'));
  8349. if (count($packages) > 0) {
  8350. $allowlistPackagesWithRequirements = array_filter($packages, function ($pkg): bool {
  8351. return Preg::isMatch('{\S+[ =:]\S+}', $pkg);
  8352. });
  8353. foreach ($this->formatRequirements($allowlistPackagesWithRequirements) as $package => $constraint) {
  8354. $reqs[$package] = $constraint;
  8355. }
  8356. foreach ($allowlistPackagesWithRequirements as $package) {
  8357. $packageName = Preg::replace('{^([^ =:]+)[ =:].*$}', '$1', $package);
  8358. $index = array_search($package, $packages);
  8359. $packages[$index] = $packageName;
  8360. }
  8361. }
  8362. $rootPackage = $composer->getPackage();
  8363. $rootRequires = $rootPackage->getRequires();
  8364. $rootDevRequires = $rootPackage->getDevRequires();
  8365. foreach ($reqs as $package => $constraint) {
  8366. if (isset($rootRequires[$package])) {
  8367. $rootRequires[$package] = $this->appendConstraintToLink($rootRequires[$package], $constraint);
  8368. } elseif (isset($rootDevRequires[$package])) {
  8369. $rootDevRequires[$package] = $this->appendConstraintToLink($rootDevRequires[$package], $constraint);
  8370. } else {
  8371. throw new \UnexpectedValueException('Only root package requirements can receive temporary constraints and '.$package.' is not one');
  8372. }
  8373. }
  8374. $rootPackage->setRequires($rootRequires);
  8375. $rootPackage->setDevRequires($rootDevRequires);
  8376. $rootPackage->setReferences(RootPackageLoader::extractReferences($reqs, $rootPackage->getReferences()));
  8377. $rootPackage->setStabilityFlags(RootPackageLoader::extractStabilityFlags($reqs, $rootPackage->getMinimumStability(), $rootPackage->getStabilityFlags()));
  8378. if ($input->getOption('interactive')) {
  8379. $packages = $this->getPackagesInteractively($io, $input, $output, $composer, $packages);
  8380. }
  8381. if ($input->getOption('root-reqs')) {
  8382. $requires = array_keys($rootRequires);
  8383. if (!$input->getOption('no-dev')) {
  8384. $requires = array_merge($requires, array_keys($rootDevRequires));
  8385. }
  8386. if (!empty($packages)) {
  8387. $packages = array_intersect($packages, $requires);
  8388. } else {
  8389. $packages = $requires;
  8390. }
  8391. }
  8392. $filteredPackages = array_filter($packages, function ($package): bool {
  8393. return !in_array($package, array('lock', 'nothing', 'mirrors'), true);
  8394. });
  8395. $updateMirrors = $input->getOption('lock') || count($filteredPackages) != count($packages);
  8396. $packages = $filteredPackages;
  8397. if ($updateMirrors && !empty($packages)) {
  8398. $io->writeError('<error>You cannot simultaneously update only a selection of packages and regenerate the lock file metadata.</error>');
  8399. return -1;
  8400. }
  8401. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'update', $input, $output);
  8402. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  8403. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  8404. $install = Installer::create($io, $composer);
  8405. $config = $composer->getConfig();
  8406. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  8407. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  8408. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  8409. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  8410. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  8411. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  8412. if ($input->getOption('with-all-dependencies')) {
  8413. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  8414. } elseif ($input->getOption('with-dependencies')) {
  8415. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  8416. }
  8417. $install
  8418. ->setDryRun($input->getOption('dry-run'))
  8419. ->setVerbose($input->getOption('verbose'))
  8420. ->setPreferSource($preferSource)
  8421. ->setPreferDist($preferDist)
  8422. ->setDevMode(!$input->getOption('no-dev'))
  8423. ->setDumpAutoloader(!$input->getOption('no-autoloader'))
  8424. ->setOptimizeAutoloader($optimize)
  8425. ->setClassMapAuthoritative($authoritative)
  8426. ->setApcuAutoloader($apcu, $apcuPrefix)
  8427. ->setUpdate(true)
  8428. ->setInstall(!$input->getOption('no-install'))
  8429. ->setUpdateMirrors($updateMirrors)
  8430. ->setUpdateAllowList($packages)
  8431. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  8432. ->setPlatformRequirementFilter($this->getPlatformRequirementFilter($input))
  8433. ->setPreferStable($input->getOption('prefer-stable'))
  8434. ->setPreferLowest($input->getOption('prefer-lowest'))
  8435. ;
  8436. if ($input->getOption('no-plugins')) {
  8437. $install->disablePlugins();
  8438. }
  8439. return $install->run();
  8440. }
  8441. private function getPackagesInteractively(IOInterface $io, InputInterface $input, OutputInterface $output, Composer $composer, array $packages): array
  8442. {
  8443. if (!$input->isInteractive()) {
  8444. throw new \InvalidArgumentException('--interactive cannot be used in non-interactive terminals.');
  8445. }
  8446. $requires = array_merge(
  8447. $composer->getPackage()->getRequires(),
  8448. $composer->getPackage()->getDevRequires()
  8449. );
  8450. $autocompleterValues = array();
  8451. foreach ($requires as $require) {
  8452. $target = $require->getTarget();
  8453. $autocompleterValues[strtolower($target)] = $target;
  8454. }
  8455. $installedPackages = $composer->getRepositoryManager()->getLocalRepository()->getPackages();
  8456. foreach ($installedPackages as $package) {
  8457. $autocompleterValues[$package->getName()] = $package->getPrettyName();
  8458. }
  8459. $helper = $this->getHelper('question');
  8460. $question = new Question('<comment>Enter package name: </comment>', null);
  8461. $io->writeError('<info>Press enter without value to end submission</info>');
  8462. do {
  8463. $autocompleterValues = array_diff($autocompleterValues, $packages);
  8464. $question->setAutocompleterValues($autocompleterValues);
  8465. $addedPackage = $helper->ask($input, $output, $question);
  8466. if (!is_string($addedPackage) || empty($addedPackage)) {
  8467. break;
  8468. }
  8469. $addedPackage = strtolower($addedPackage);
  8470. if (!in_array($addedPackage, $packages)) {
  8471. $packages[] = $addedPackage;
  8472. }
  8473. } while (true);
  8474. $packages = array_filter($packages);
  8475. if (!$packages) {
  8476. throw new \InvalidArgumentException('You must enter minimum one package.');
  8477. }
  8478. $table = new Table($output);
  8479. $table->setHeaders(array('Selected packages'));
  8480. foreach ($packages as $package) {
  8481. $table->addRow(array($package));
  8482. }
  8483. $table->render();
  8484. if ($io->askConfirmation(sprintf(
  8485. 'Would you like to continue and update the above package%s [<comment>yes</comment>]? ',
  8486. 1 === count($packages) ? '' : 's'
  8487. ))) {
  8488. return $packages;
  8489. }
  8490. throw new \RuntimeException('Installation aborted.');
  8491. }
  8492. private function appendConstraintToLink(Link $link, string $constraint): Link
  8493. {
  8494. $parser = new VersionParser;
  8495. $oldPrettyString = $link->getConstraint()->getPrettyString();
  8496. $newConstraint = MultiConstraint::create(array($link->getConstraint(), $parser->parseConstraints($constraint)));
  8497. $newConstraint->setPrettyString($oldPrettyString.', '.$constraint);
  8498. return new Link(
  8499. $link->getSource(),
  8500. $link->getTarget(),
  8501. $newConstraint,
  8502. $link->getDescription(),
  8503. $link->getPrettyConstraint() . ', ' . $constraint
  8504. );
  8505. }
  8506. }
  8507. <?php declare(strict_types=1);
  8508. namespace Composer\Command;
  8509. use Composer\Factory;
  8510. use Composer\IO\IOInterface;
  8511. use Composer\Package\Loader\ValidatingArrayLoader;
  8512. use Composer\Plugin\CommandEvent;
  8513. use Composer\Plugin\PluginEvents;
  8514. use Composer\Repository\InstalledRepository;
  8515. use Composer\Repository\PlatformRepository;
  8516. use Composer\Util\ConfigValidator;
  8517. use Composer\Util\Filesystem;
  8518. use Symfony\Component\Console\Input\InputArgument;
  8519. use Symfony\Component\Console\Input\InputInterface;
  8520. use Symfony\Component\Console\Input\InputOption;
  8521. use Symfony\Component\Console\Output\OutputInterface;
  8522. class ValidateCommand extends BaseCommand
  8523. {
  8524. protected function configure(): void
  8525. {
  8526. $this
  8527. ->setName('validate')
  8528. ->setDescription('Validates a composer.json and composer.lock.')
  8529. ->setDefinition(array(
  8530. new InputOption('no-check-all', null, InputOption::VALUE_NONE, 'Do not validate requires for overly strict/loose constraints'),
  8531. new InputOption('check-lock', null, InputOption::VALUE_NONE, 'Check if lock file is up to date (even when config.lock is false)'),
  8532. new InputOption('no-check-lock', null, InputOption::VALUE_NONE, 'Do not check if lock file is up to date'),
  8533. new InputOption('no-check-publish', null, InputOption::VALUE_NONE, 'Do not check for publish errors'),
  8534. new InputOption('no-check-version', null, InputOption::VALUE_NONE, 'Do not report a warning if the version field is present'),
  8535. new InputOption('with-dependencies', 'A', InputOption::VALUE_NONE, 'Also validate the composer.json of all installed dependencies'),
  8536. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code for warnings as well as errors'),
  8537. new InputArgument('file', InputArgument::OPTIONAL, 'path to composer.json file'),
  8538. ))
  8539. ->setHelp(
  8540. <<<EOT
  8541. The validate command validates a given composer.json and composer.lock
  8542. Exit codes in case of errors are:
  8543. 1 validation warning(s), only when --strict is given
  8544. 2 validation error(s)
  8545. 3 file unreadable or missing
  8546. Read more at https://getcomposer.org/doc/03-cli.md#validate
  8547. EOT
  8548. );
  8549. }
  8550. protected function execute(InputInterface $input, OutputInterface $output): int
  8551. {
  8552. $file = $input->getArgument('file') ?: Factory::getComposerFile();
  8553. $io = $this->getIO();
  8554. if (!file_exists($file)) {
  8555. $io->writeError('<error>' . $file . ' not found.</error>');
  8556. return 3;
  8557. }
  8558. if (!Filesystem::isReadable($file)) {
  8559. $io->writeError('<error>' . $file . ' is not readable.</error>');
  8560. return 3;
  8561. }
  8562. $validator = new ConfigValidator($io);
  8563. $checkAll = $input->getOption('no-check-all') ? 0 : ValidatingArrayLoader::CHECK_ALL;
  8564. $checkPublish = !$input->getOption('no-check-publish');
  8565. $checkLock = !$input->getOption('no-check-lock');
  8566. $checkVersion = $input->getOption('no-check-version') ? 0 : ConfigValidator::CHECK_VERSION;
  8567. $isStrict = $input->getOption('strict');
  8568. list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll, $checkVersion);
  8569. $lockErrors = array();
  8570. $composer = Factory::create($io, $file, $input->hasParameterOption('--no-plugins'));
  8571. $checkLock = ($checkLock && $composer->getConfig()->get('lock')) || $input->getOption('check-lock');
  8572. $locker = $composer->getLocker();
  8573. if ($locker->isLocked() && !$locker->isFresh()) {
  8574. $lockErrors[] = '- The lock file is not up to date with the latest changes in composer.json, it is recommended that you run `composer update` or `composer update <package name>`.';
  8575. }
  8576. if ($locker->isLocked()) {
  8577. $missingRequirements = false;
  8578. $sets = array(
  8579. array('repo' => $locker->getLockedRepository(false), 'method' => 'getRequires', 'description' => 'Required'),
  8580. array('repo' => $locker->getLockedRepository(true), 'method' => 'getDevRequires', 'description' => 'Required (in require-dev)'),
  8581. );
  8582. foreach ($sets as $set) {
  8583. $installedRepo = new InstalledRepository(array($set['repo']));
  8584. foreach (call_user_func(array($composer->getPackage(), $set['method'])) as $link) {
  8585. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  8586. continue;
  8587. }
  8588. if (!$installedRepo->findPackagesWithReplacersAndProviders($link->getTarget(), $link->getConstraint())) {
  8589. if ($results = $installedRepo->findPackagesWithReplacersAndProviders($link->getTarget())) {
  8590. $provider = reset($results);
  8591. $lockErrors[] = '- ' . $set['description'].' package "' . $link->getTarget() . '" is in the lock file as "'.$provider->getPrettyVersion().'" but that does not satisfy your constraint "'.$link->getPrettyConstraint().'".';
  8592. } else {
  8593. $lockErrors[] = '- ' . $set['description'].' package "' . $link->getTarget() . '" is not present in the lock file.';
  8594. }
  8595. $missingRequirements = true;
  8596. }
  8597. }
  8598. }
  8599. if ($missingRequirements) {
  8600. $lockErrors[] = 'This usually happens when composer files are incorrectly merged or the composer.json file is manually edited.';
  8601. $lockErrors[] = 'Read more about correctly resolving merge conflicts https://getcomposer.org/doc/articles/resolving-merge-conflicts.md';
  8602. $lockErrors[] = 'and prefer using the "require" command over editing the composer.json file directly https://getcomposer.org/doc/03-cli.md#require';
  8603. }
  8604. }
  8605. $this->outputResult($io, $file, $errors, $warnings, $checkPublish, $publishErrors, $checkLock, $lockErrors, true);
  8606. $exitCode = $errors ? 2 : ($isStrict && $warnings ? 1 : 0);
  8607. if ($input->getOption('with-dependencies')) {
  8608. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  8609. foreach ($localRepo->getPackages() as $package) {
  8610. $path = $composer->getInstallationManager()->getInstallPath($package);
  8611. $file = $path . '/composer.json';
  8612. if (is_dir($path) && file_exists($file)) {
  8613. list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll, $checkVersion);
  8614. $this->outputResult($io, $package->getPrettyName(), $errors, $warnings, $checkPublish, $publishErrors);
  8615. $depCode = $errors ? 2 : ($isStrict && $warnings ? 1 : 0);
  8616. $exitCode = max($depCode, $exitCode);
  8617. }
  8618. }
  8619. }
  8620. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'validate', $input, $output);
  8621. $eventCode = $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  8622. return max($eventCode, $exitCode);
  8623. }
  8624. private function outputResult(IOInterface $io, string $name, array &$errors, array &$warnings, bool $checkPublish = false, array $publishErrors = array(), bool $checkLock = false, array $lockErrors = array(), bool $printSchemaUrl = false): void
  8625. {
  8626. $doPrintSchemaUrl = false;
  8627. if ($errors) {
  8628. $io->writeError('<error>' . $name . ' is invalid, the following errors/warnings were found:</error>');
  8629. } elseif ($publishErrors) {
  8630. $io->writeError('<info>' . $name . ' is valid for simple usage with Composer but has</info>');
  8631. $io->writeError('<info>strict errors that make it unable to be published as a package</info>');
  8632. $doPrintSchemaUrl = $printSchemaUrl;
  8633. } elseif ($warnings) {
  8634. $io->writeError('<info>' . $name . ' is valid, but with a few warnings</info>');
  8635. $doPrintSchemaUrl = $printSchemaUrl;
  8636. } elseif ($lockErrors) {
  8637. $io->write('<info>' . $name . ' is valid but your composer.lock has some '.($checkLock ? 'errors' : 'warnings').'</info>');
  8638. } else {
  8639. $io->write('<info>' . $name . ' is valid</info>');
  8640. }
  8641. if ($doPrintSchemaUrl) {
  8642. $io->writeError('<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
  8643. }
  8644. if ($errors) {
  8645. $errors = array_map(function ($err): string {
  8646. return '- ' . $err;
  8647. }, $errors);
  8648. array_unshift($errors, '# General errors');
  8649. }
  8650. if ($warnings) {
  8651. $warnings = array_map(function ($err): string {
  8652. return '- ' . $err;
  8653. }, $warnings);
  8654. array_unshift($warnings, '# General warnings');
  8655. }
  8656. $extraWarnings = array();
  8657. if ($publishErrors) {
  8658. $publishErrors = array_map(function ($err): string {
  8659. return '- ' . $err;
  8660. }, $publishErrors);
  8661. if ($checkPublish) {
  8662. array_unshift($publishErrors, '# Publish errors');
  8663. $errors = array_merge($errors, $publishErrors);
  8664. } else {
  8665. array_unshift($publishErrors, '# Publish warnings');
  8666. $extraWarnings = array_merge($extraWarnings, $publishErrors);
  8667. }
  8668. }
  8669. if ($lockErrors) {
  8670. if ($checkLock) {
  8671. array_unshift($lockErrors, '# Lock file errors');
  8672. $errors = array_merge($errors, $lockErrors);
  8673. } else {
  8674. array_unshift($lockErrors, '# Lock file warnings');
  8675. $extraWarnings = array_merge($extraWarnings, $lockErrors);
  8676. }
  8677. }
  8678. $messages = array(
  8679. 'error' => $errors,
  8680. 'warning' => array_merge($warnings, $extraWarnings),
  8681. );
  8682. foreach ($messages as $style => $msgs) {
  8683. foreach ($msgs as $msg) {
  8684. if (strpos($msg, '#') === 0) {
  8685. $io->writeError('<' . $style . '>' . $msg . '</' . $style . '>');
  8686. } else {
  8687. $io->writeError($msg);
  8688. }
  8689. }
  8690. }
  8691. }
  8692. }
  8693. <?php declare(strict_types=1);
  8694. namespace Composer;
  8695. use Composer\Package\Locker;
  8696. use Composer\Pcre\Preg;
  8697. use Composer\Plugin\PluginManager;
  8698. use Composer\Downloader\DownloadManager;
  8699. use Composer\Autoload\AutoloadGenerator;
  8700. use Composer\Package\Archiver\ArchiveManager;
  8701. class Composer extends PartialComposer
  8702. {
  8703. public const VERSION = '2.3.5';
  8704. public const BRANCH_ALIAS_VERSION = '';
  8705. public const RELEASE_DATE = '2022-04-13 16:43:00';
  8706. public const SOURCE_VERSION = '';
  8707. public const RUNTIME_API_VERSION = '2.2.2';
  8708. public static function getVersion(): string
  8709. {
  8710. if (self::VERSION === '@package_version'.'@') {
  8711. return self::SOURCE_VERSION;
  8712. }
  8713. if (self::BRANCH_ALIAS_VERSION !== '' && Preg::isMatch('{^[a-f0-9]{40}$}', self::VERSION)) {
  8714. return self::BRANCH_ALIAS_VERSION.'+'.self::VERSION;
  8715. }
  8716. return self::VERSION;
  8717. }
  8718. private $locker;
  8719. private $downloadManager;
  8720. private $pluginManager;
  8721. private $autoloadGenerator;
  8722. private $archiveManager;
  8723. public function setLocker(Locker $locker): void
  8724. {
  8725. $this->locker = $locker;
  8726. }
  8727. public function getLocker(): Locker
  8728. {
  8729. return $this->locker;
  8730. }
  8731. public function setDownloadManager(DownloadManager $manager): void
  8732. {
  8733. $this->downloadManager = $manager;
  8734. }
  8735. public function getDownloadManager(): DownloadManager
  8736. {
  8737. return $this->downloadManager;
  8738. }
  8739. public function setArchiveManager(ArchiveManager $manager): void
  8740. {
  8741. $this->archiveManager = $manager;
  8742. }
  8743. public function getArchiveManager(): ArchiveManager
  8744. {
  8745. return $this->archiveManager;
  8746. }
  8747. public function setPluginManager(PluginManager $manager): void
  8748. {
  8749. $this->pluginManager = $manager;
  8750. }
  8751. public function getPluginManager(): PluginManager
  8752. {
  8753. return $this->pluginManager;
  8754. }
  8755. public function setAutoloadGenerator(AutoloadGenerator $autoloadGenerator): void
  8756. {
  8757. $this->autoloadGenerator = $autoloadGenerator;
  8758. }
  8759. public function getAutoloadGenerator(): AutoloadGenerator
  8760. {
  8761. return $this->autoloadGenerator;
  8762. }
  8763. }
  8764. <?php declare(strict_types=1);
  8765. namespace Composer;
  8766. use Composer\Config\ConfigSourceInterface;
  8767. use Composer\Downloader\TransportException;
  8768. use Composer\IO\IOInterface;
  8769. use Composer\Pcre\Preg;
  8770. use Composer\Util\Platform;
  8771. use Composer\Util\ProcessExecutor;
  8772. class Config
  8773. {
  8774. public const SOURCE_DEFAULT = 'default';
  8775. public const SOURCE_COMMAND = 'command';
  8776. public const SOURCE_UNKNOWN = 'unknown';
  8777. public const RELATIVE_PATHS = 1;
  8778. public static $defaultConfig = array(
  8779. 'process-timeout' => 300,
  8780. 'use-include-path' => false,
  8781. 'allow-plugins' => null,
  8782. 'use-parent-dir' => 'prompt',
  8783. 'preferred-install' => 'dist',
  8784. 'notify-on-install' => true,
  8785. 'github-protocols' => array('https', 'ssh', 'git'),
  8786. 'gitlab-protocol' => null,
  8787. 'vendor-dir' => 'vendor',
  8788. 'bin-dir' => '{$vendor-dir}/bin',
  8789. 'cache-dir' => '{$home}/cache',
  8790. 'data-dir' => '{$home}',
  8791. 'cache-files-dir' => '{$cache-dir}/files',
  8792. 'cache-repo-dir' => '{$cache-dir}/repo',
  8793. 'cache-vcs-dir' => '{$cache-dir}/vcs',
  8794. 'cache-ttl' => 15552000,
  8795. 'cache-files-ttl' => null,
  8796. 'cache-files-maxsize' => '300MiB',
  8797. 'cache-read-only' => false,
  8798. 'bin-compat' => 'auto',
  8799. 'discard-changes' => false,
  8800. 'autoloader-suffix' => null,
  8801. 'sort-packages' => false,
  8802. 'optimize-autoloader' => false,
  8803. 'classmap-authoritative' => false,
  8804. 'apcu-autoloader' => false,
  8805. 'prepend-autoloader' => true,
  8806. 'github-domains' => array('github.com'),
  8807. 'bitbucket-expose-hostname' => true,
  8808. 'disable-tls' => false,
  8809. 'secure-http' => true,
  8810. 'secure-svn-domains' => array(),
  8811. 'cafile' => null,
  8812. 'capath' => null,
  8813. 'github-expose-hostname' => true,
  8814. 'gitlab-domains' => array('gitlab.com'),
  8815. 'store-auths' => 'prompt',
  8816. 'platform' => array(),
  8817. 'archive-format' => 'tar',
  8818. 'archive-dir' => '.',
  8819. 'htaccess-protect' => true,
  8820. 'use-github-api' => true,
  8821. 'lock' => true,
  8822. 'platform-check' => 'php-only',
  8823. );
  8824. public static $defaultRepositories = array(
  8825. 'packagist.org' => array(
  8826. 'type' => 'composer',
  8827. 'url' => 'https://repo.packagist.org',
  8828. ),
  8829. );
  8830. private $config;
  8831. private $baseDir;
  8832. private $repositories;
  8833. private $configSource;
  8834. private $authConfigSource;
  8835. private $useEnvironment;
  8836. private $warnedHosts = array();
  8837. private $sslVerifyWarnedHosts = array();
  8838. private $sourceOfConfigValue = array();
  8839. public function __construct(bool $useEnvironment = true, ?string $baseDir = null)
  8840. {
  8841. $this->config = static::$defaultConfig;
  8842. if (strtotime('2022-07-01') < time()) {
  8843. $this->config['allow-plugins'] = array();
  8844. }
  8845. $this->repositories = static::$defaultRepositories;
  8846. $this->useEnvironment = (bool) $useEnvironment;
  8847. $this->baseDir = is_string($baseDir) && '' !== $baseDir ? $baseDir : null;
  8848. foreach ($this->config as $configKey => $configValue) {
  8849. $this->setSourceOfConfigValue($configValue, $configKey, self::SOURCE_DEFAULT);
  8850. }
  8851. foreach ($this->repositories as $configKey => $configValue) {
  8852. $this->setSourceOfConfigValue($configValue, 'repositories.' . $configKey, self::SOURCE_DEFAULT);
  8853. }
  8854. }
  8855. public function setConfigSource(ConfigSourceInterface $source): void
  8856. {
  8857. $this->configSource = $source;
  8858. }
  8859. public function getConfigSource(): ConfigSourceInterface
  8860. {
  8861. return $this->configSource;
  8862. }
  8863. public function setAuthConfigSource(ConfigSourceInterface $source): void
  8864. {
  8865. $this->authConfigSource = $source;
  8866. }
  8867. public function getAuthConfigSource(): ConfigSourceInterface
  8868. {
  8869. return $this->authConfigSource;
  8870. }
  8871. public function merge(array $config, string $source = self::SOURCE_UNKNOWN): void
  8872. {
  8873. if (!empty($config['config']) && is_array($config['config'])) {
  8874. foreach ($config['config'] as $key => $val) {
  8875. if (in_array($key, array('bitbucket-oauth', 'github-oauth', 'gitlab-oauth', 'gitlab-token', 'http-basic', 'bearer'), true) && isset($this->config[$key])) {
  8876. $this->config[$key] = array_merge($this->config[$key], $val);
  8877. $this->setSourceOfConfigValue($val, $key, $source);
  8878. } elseif (in_array($key, array('allow-plugins'), true) && isset($this->config[$key]) && is_array($this->config[$key])) {
  8879. $this->config[$key] = array_merge($val, $this->config[$key], $val);
  8880. $this->setSourceOfConfigValue($val, $key, $source);
  8881. } elseif (in_array($key, array('gitlab-domains', 'github-domains'), true) && isset($this->config[$key])) {
  8882. $this->config[$key] = array_unique(array_merge($this->config[$key], $val));
  8883. $this->setSourceOfConfigValue($val, $key, $source);
  8884. } elseif ('preferred-install' === $key && isset($this->config[$key])) {
  8885. if (is_array($val) || is_array($this->config[$key])) {
  8886. if (is_string($val)) {
  8887. $val = array('*' => $val);
  8888. }
  8889. if (is_string($this->config[$key])) {
  8890. $this->config[$key] = array('*' => $this->config[$key]);
  8891. $this->sourceOfConfigValue[$key . '*'] = $source;
  8892. }
  8893. $this->config[$key] = array_merge($this->config[$key], $val);
  8894. $this->setSourceOfConfigValue($val, $key, $source);
  8895. if (isset($this->config[$key]['*'])) {
  8896. $wildcard = $this->config[$key]['*'];
  8897. unset($this->config[$key]['*']);
  8898. $this->config[$key]['*'] = $wildcard;
  8899. }
  8900. } else {
  8901. $this->config[$key] = $val;
  8902. $this->setSourceOfConfigValue($val, $key, $source);
  8903. }
  8904. } else {
  8905. $this->config[$key] = $val;
  8906. $this->setSourceOfConfigValue($val, $key, $source);
  8907. }
  8908. }
  8909. }
  8910. if (!empty($config['repositories']) && is_array($config['repositories'])) {
  8911. $this->repositories = array_reverse($this->repositories, true);
  8912. $newRepos = array_reverse($config['repositories'], true);
  8913. foreach ($newRepos as $name => $repository) {
  8914. if (false === $repository) {
  8915. $this->disableRepoByName((string) $name);
  8916. continue;
  8917. }
  8918. if (is_array($repository) && 1 === count($repository) && false === current($repository)) {
  8919. $this->disableRepoByName((string) key($repository));
  8920. continue;
  8921. }
  8922. if (isset($repository['type'], $repository['url']) && $repository['type'] === 'composer' && Preg::isMatch('{^https?://(?:[a-z0-9-.]+\.)?packagist.org(/|$)}', $repository['url'])) {
  8923. $this->disableRepoByName('packagist.org');
  8924. }
  8925. if (is_int($name)) {
  8926. $this->repositories[] = $repository;
  8927. $this->setSourceOfConfigValue($repository, 'repositories.' . array_search($repository, $this->repositories, true), $source);
  8928. } else {
  8929. if ($name === 'packagist') {
  8930. $this->repositories[$name . '.org'] = $repository;
  8931. $this->setSourceOfConfigValue($repository, 'repositories.' . $name . '.org', $source);
  8932. } else {
  8933. $this->repositories[$name] = $repository;
  8934. $this->setSourceOfConfigValue($repository, 'repositories.' . $name, $source);
  8935. }
  8936. }
  8937. }
  8938. $this->repositories = array_reverse($this->repositories, true);
  8939. }
  8940. }
  8941. public function getRepositories(): array
  8942. {
  8943. return $this->repositories;
  8944. }
  8945. public function get(string $key, int $flags = 0)
  8946. {
  8947. switch ($key) {
  8948. case 'vendor-dir':
  8949. case 'bin-dir':
  8950. case 'process-timeout':
  8951. case 'data-dir':
  8952. case 'cache-dir':
  8953. case 'cache-files-dir':
  8954. case 'cache-repo-dir':
  8955. case 'cache-vcs-dir':
  8956. case 'cafile':
  8957. case 'capath':
  8958. $env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_'));
  8959. $val = $this->getComposerEnv($env);
  8960. if ($val !== false) {
  8961. $this->setSourceOfConfigValue($val, $key, $env);
  8962. }
  8963. $val = rtrim((string) $this->process(false !== $val ? $val : $this->config[$key], $flags), '/\\');
  8964. $val = Platform::expandPath($val);
  8965. if (substr($key, -4) !== '-dir') {
  8966. return $val;
  8967. }
  8968. return (($flags & self::RELATIVE_PATHS) == self::RELATIVE_PATHS) ? $val : $this->realpath($val);
  8969. case 'cache-read-only':
  8970. case 'htaccess-protect':
  8971. $env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_'));
  8972. $val = $this->getComposerEnv($env);
  8973. if (false === $val) {
  8974. $val = $this->config[$key];
  8975. } else {
  8976. $this->setSourceOfConfigValue($val, $key, $env);
  8977. }
  8978. return $val !== 'false' && (bool) $val;
  8979. case 'disable-tls':
  8980. case 'secure-http':
  8981. case 'use-github-api':
  8982. case 'lock':
  8983. if ($key === 'secure-http' && $this->get('disable-tls') === true) {
  8984. return false;
  8985. }
  8986. return $this->config[$key] !== 'false' && (bool) $this->config[$key];
  8987. case 'cache-ttl':
  8988. return (int) $this->config[$key];
  8989. case 'cache-files-maxsize':
  8990. if (!Preg::isMatch('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', (string) $this->config[$key], $matches)) {
  8991. throw new \RuntimeException(
  8992. "Could not parse the value of '$key': {$this->config[$key]}"
  8993. );
  8994. }
  8995. $size = $matches[1];
  8996. if (isset($matches[2])) {
  8997. switch (strtolower($matches[2])) {
  8998. case 'g':
  8999. $size *= 1024;
  9000. case 'm':
  9001. $size *= 1024;
  9002. case 'k':
  9003. $size *= 1024;
  9004. break;
  9005. }
  9006. }
  9007. return $size;
  9008. case 'cache-files-ttl':
  9009. if (isset($this->config[$key])) {
  9010. return (int) $this->config[$key];
  9011. }
  9012. return (int) $this->config['cache-ttl'];
  9013. case 'home':
  9014. return rtrim($this->process(Platform::expandPath($this->config[$key]), $flags), '/\\');
  9015. case 'bin-compat':
  9016. $value = $this->getComposerEnv('COMPOSER_BIN_COMPAT') ?: $this->config[$key];
  9017. if (!in_array($value, array('auto', 'full', 'proxy', 'symlink'))) {
  9018. throw new \RuntimeException(
  9019. "Invalid value for 'bin-compat': {$value}. Expected auto, full or proxy"
  9020. );
  9021. }
  9022. if ($value === 'symlink') {
  9023. trigger_error('config.bin-compat "symlink" is deprecated since Composer 2.2, use auto, full (for Windows compatibility) or proxy instead.', E_USER_DEPRECATED);
  9024. }
  9025. return $value;
  9026. case 'discard-changes':
  9027. if ($env = $this->getComposerEnv('COMPOSER_DISCARD_CHANGES')) {
  9028. if (!in_array($env, array('stash', 'true', 'false', '1', '0'), true)) {
  9029. throw new \RuntimeException(
  9030. "Invalid value for COMPOSER_DISCARD_CHANGES: {$env}. Expected 1, 0, true, false or stash"
  9031. );
  9032. }
  9033. if ('stash' === $env) {
  9034. return 'stash';
  9035. }
  9036. return $env !== 'false' && (bool) $env;
  9037. }
  9038. if (!in_array($this->config[$key], array(true, false, 'stash'), true)) {
  9039. throw new \RuntimeException(
  9040. "Invalid value for 'discard-changes': {$this->config[$key]}. Expected true, false or stash"
  9041. );
  9042. }
  9043. return $this->config[$key];
  9044. case 'github-protocols':
  9045. $protos = $this->config['github-protocols'];
  9046. if ($this->config['secure-http'] && false !== ($index = array_search('git', $protos))) {
  9047. unset($protos[$index]);
  9048. }
  9049. if (reset($protos) === 'http') {
  9050. throw new \RuntimeException('The http protocol for github is not available anymore, update your config\'s github-protocols to use "https", "git" or "ssh"');
  9051. }
  9052. return $protos;
  9053. case 'autoloader-suffix':
  9054. if ($this->config[$key] === '') {
  9055. return null;
  9056. }
  9057. return $this->process($this->config[$key], $flags);
  9058. default:
  9059. if (!isset($this->config[$key])) {
  9060. return null;
  9061. }
  9062. return $this->process($this->config[$key], $flags);
  9063. }
  9064. }
  9065. public function all(int $flags = 0): array
  9066. {
  9067. $all = array(
  9068. 'repositories' => $this->getRepositories(),
  9069. );
  9070. foreach (array_keys($this->config) as $key) {
  9071. $all['config'][$key] = $this->get($key, $flags);
  9072. }
  9073. return $all;
  9074. }
  9075. public function getSourceOfValue(string $key): string
  9076. {
  9077. $this->get($key);
  9078. return $this->sourceOfConfigValue[$key] ?? self::SOURCE_UNKNOWN;
  9079. }
  9080. private function setSourceOfConfigValue($configValue, string $path, string $source): void
  9081. {
  9082. $this->sourceOfConfigValue[$path] = $source;
  9083. if (is_array($configValue)) {
  9084. foreach ($configValue as $key => $value) {
  9085. $this->setSourceOfConfigValue($value, $path . '.' . $key, $source);
  9086. }
  9087. }
  9088. }
  9089. public function raw(): array
  9090. {
  9091. return array(
  9092. 'repositories' => $this->getRepositories(),
  9093. 'config' => $this->config,
  9094. );
  9095. }
  9096. public function has(string $key): bool
  9097. {
  9098. return array_key_exists($key, $this->config);
  9099. }
  9100. private function process($value, int $flags)
  9101. {
  9102. if (!is_string($value)) {
  9103. return $value;
  9104. }
  9105. return Preg::replaceCallback('#\{\$(.+)\}#', function ($match) use ($flags) {
  9106. return $this->get($match[1], $flags);
  9107. }, $value);
  9108. }
  9109. private function realpath(string $path): string
  9110. {
  9111. if (Preg::isMatch('{^(?:/|[a-z]:|[a-z0-9.]+://|\\\\\\\\)}i', $path)) {
  9112. return $path;
  9113. }
  9114. return $this->baseDir ? $this->baseDir . '/' . $path : $path;
  9115. }
  9116. private function getComposerEnv(string $var)
  9117. {
  9118. if ($this->useEnvironment) {
  9119. return Platform::getEnv($var);
  9120. }
  9121. return false;
  9122. }
  9123. private function disableRepoByName(string $name): void
  9124. {
  9125. if (isset($this->repositories[$name])) {
  9126. unset($this->repositories[$name]);
  9127. } elseif ($name === 'packagist') {
  9128. unset($this->repositories['packagist.org']);
  9129. }
  9130. }
  9131. public function prohibitUrlByConfig(string $url, IOInterface $io = null, array $repoOptions = []): void
  9132. {
  9133. if (false === filter_var($url, FILTER_VALIDATE_URL)) {
  9134. return;
  9135. }
  9136. $scheme = parse_url($url, PHP_URL_SCHEME);
  9137. $hostname = parse_url($url, PHP_URL_HOST);
  9138. if (in_array($scheme, array('http', 'git', 'ftp', 'svn'))) {
  9139. if ($this->get('secure-http')) {
  9140. if ($scheme === 'svn') {
  9141. if (in_array($hostname, $this->get('secure-svn-domains'), true)) {
  9142. return;
  9143. }
  9144. throw new TransportException("Your configuration does not allow connections to $url. See https://getcomposer.org/doc/06-config.md#secure-svn-domains for details.");
  9145. }
  9146. throw new TransportException("Your configuration does not allow connections to $url. See https://getcomposer.org/doc/06-config.md#secure-http for details.");
  9147. }
  9148. if ($io !== null) {
  9149. if (is_string($hostname)) {
  9150. if (!isset($this->warnedHosts[$hostname])) {
  9151. $io->writeError("<warning>Warning: Accessing $hostname over $scheme which is an insecure protocol.</warning>");
  9152. }
  9153. $this->warnedHosts[$hostname] = true;
  9154. }
  9155. }
  9156. }
  9157. if ($io !== null && is_string($hostname) && !isset($this->sslVerifyWarnedHosts[$hostname])) {
  9158. $warning = null;
  9159. if (isset($repoOptions['ssl']['verify_peer']) && !(bool) $repoOptions['ssl']['verify_peer']) {
  9160. $warning = 'verify_peer';
  9161. }
  9162. if (isset($repoOptions['ssl']['verify_peer_name']) && !(bool) $repoOptions['ssl']['verify_peer_name']) {
  9163. $warning = $warning === null ? 'verify_peer_name' : $warning . ' and verify_peer_name';
  9164. }
  9165. if ($warning !== null) {
  9166. $io->writeError("<warning>Warning: Accessing $hostname with $warning disabled.</warning>");
  9167. $this->sslVerifyWarnedHosts[$hostname] = true;
  9168. }
  9169. }
  9170. }
  9171. public static function disableProcessTimeout(): void
  9172. {
  9173. ProcessExecutor::setTimeout(0);
  9174. }
  9175. }
  9176. <?php declare(strict_types=1);
  9177. namespace Composer\Config;
  9178. interface ConfigSourceInterface
  9179. {
  9180. public function addRepository(string $name, $config, bool $append = true): void;
  9181. public function removeRepository(string $name): void;
  9182. public function addConfigSetting(string $name, $value): void;
  9183. public function removeConfigSetting(string $name): void;
  9184. public function addProperty(string $name, $value): void;
  9185. public function removeProperty(string $name): void;
  9186. public function addLink(string $type, string $name, string $value): void;
  9187. public function removeLink(string $type, string $name): void;
  9188. public function getName(): string;
  9189. }
  9190. <?php declare(strict_types=1);
  9191. namespace Composer\Config;
  9192. use Composer\Json\JsonFile;
  9193. use Composer\Json\JsonManipulator;
  9194. use Composer\Json\JsonValidationException;
  9195. use Composer\Pcre\Preg;
  9196. use Composer\Util\Filesystem;
  9197. use Composer\Util\Silencer;
  9198. class JsonConfigSource implements ConfigSourceInterface
  9199. {
  9200. private $file;
  9201. private $authConfig;
  9202. public function __construct(JsonFile $file, bool $authConfig = false)
  9203. {
  9204. $this->file = $file;
  9205. $this->authConfig = $authConfig;
  9206. }
  9207. public function getName(): string
  9208. {
  9209. return $this->file->getPath();
  9210. }
  9211. public function addRepository(string $name, $config, bool $append = true): void
  9212. {
  9213. $this->manipulateJson('addRepository', function (&$config, $repo, $repoConfig) use ($append): void {
  9214. if (isset($config['repositories'])) {
  9215. foreach ($config['repositories'] as $index => $val) {
  9216. if ($index === $repo) {
  9217. continue;
  9218. }
  9219. if (is_numeric($index) && ($val === array('packagist' => false) || $val === array('packagist.org' => false))) {
  9220. unset($config['repositories'][$index]);
  9221. $config['repositories']['packagist.org'] = false;
  9222. break;
  9223. }
  9224. }
  9225. }
  9226. if ($append) {
  9227. $config['repositories'][$repo] = $repoConfig;
  9228. } else {
  9229. $config['repositories'] = array($repo => $repoConfig) + $config['repositories'];
  9230. }
  9231. }, $name, $config, $append);
  9232. }
  9233. public function removeRepository(string $name): void
  9234. {
  9235. $this->manipulateJson('removeRepository', function (&$config, $repo): void {
  9236. unset($config['repositories'][$repo]);
  9237. }, $name);
  9238. }
  9239. public function addConfigSetting(string $name, $value): void
  9240. {
  9241. $authConfig = $this->authConfig;
  9242. $this->manipulateJson('addConfigSetting', function (&$config, $key, $val) use ($authConfig): void {
  9243. if (Preg::isMatch('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|bearer|http-basic|platform)\.}', $key)) {
  9244. list($key, $host) = explode('.', $key, 2);
  9245. if ($authConfig) {
  9246. $config[$key][$host] = $val;
  9247. } else {
  9248. $config['config'][$key][$host] = $val;
  9249. }
  9250. } else {
  9251. $config['config'][$key] = $val;
  9252. }
  9253. }, $name, $value);
  9254. }
  9255. public function removeConfigSetting(string $name): void
  9256. {
  9257. $authConfig = $this->authConfig;
  9258. $this->manipulateJson('removeConfigSetting', function (&$config, $key) use ($authConfig): void {
  9259. if (Preg::isMatch('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|bearer|http-basic|platform)\.}', $key)) {
  9260. list($key, $host) = explode('.', $key, 2);
  9261. if ($authConfig) {
  9262. unset($config[$key][$host]);
  9263. } else {
  9264. unset($config['config'][$key][$host]);
  9265. }
  9266. } else {
  9267. unset($config['config'][$key]);
  9268. }
  9269. }, $name);
  9270. }
  9271. public function addProperty(string $name, $value): void
  9272. {
  9273. $this->manipulateJson('addProperty', function (&$config, $key, $val): void {
  9274. if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {
  9275. $bits = explode('.', $key);
  9276. $last = array_pop($bits);
  9277. $arr = &$config[reset($bits)];
  9278. foreach ($bits as $bit) {
  9279. if (!isset($arr[$bit])) {
  9280. $arr[$bit] = array();
  9281. }
  9282. $arr = &$arr[$bit];
  9283. }
  9284. $arr[$last] = $val;
  9285. } else {
  9286. $config[$key] = $val;
  9287. }
  9288. }, $name, $value);
  9289. }
  9290. public function removeProperty(string $name): void
  9291. {
  9292. $this->manipulateJson('removeProperty', function (&$config, $key): void {
  9293. if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {
  9294. $bits = explode('.', $key);
  9295. $last = array_pop($bits);
  9296. $arr = &$config[reset($bits)];
  9297. foreach ($bits as $bit) {
  9298. if (!isset($arr[$bit])) {
  9299. return;
  9300. }
  9301. $arr = &$arr[$bit];
  9302. }
  9303. unset($arr[$last]);
  9304. } else {
  9305. unset($config[$key]);
  9306. }
  9307. }, $name);
  9308. }
  9309. public function addLink(string $type, string $name, string $value): void
  9310. {
  9311. $this->manipulateJson('addLink', function (&$config, $type, $name, $value): void {
  9312. $config[$type][$name] = $value;
  9313. }, $type, $name, $value);
  9314. }
  9315. public function removeLink(string $type, string $name): void
  9316. {
  9317. $this->manipulateJson('removeSubNode', function (&$config, $type, $name): void {
  9318. unset($config[$type][$name]);
  9319. }, $type, $name);
  9320. $this->manipulateJson('removeMainKeyIfEmpty', function (&$config, $type): void {
  9321. if (0 === count($config[$type])) {
  9322. unset($config[$type]);
  9323. }
  9324. }, $type);
  9325. }
  9326. private function manipulateJson(string $method, callable $fallback, ...$args): void
  9327. {
  9328. if ($this->file->exists()) {
  9329. if (!is_writable($this->file->getPath())) {
  9330. throw new \RuntimeException(sprintf('The file "%s" is not writable.', $this->file->getPath()));
  9331. }
  9332. if (!Filesystem::isReadable($this->file->getPath())) {
  9333. throw new \RuntimeException(sprintf('The file "%s" is not readable.', $this->file->getPath()));
  9334. }
  9335. $contents = file_get_contents($this->file->getPath());
  9336. } elseif ($this->authConfig) {
  9337. $contents = "{\n}\n";
  9338. } else {
  9339. $contents = "{\n \"config\": {\n }\n}\n";
  9340. }
  9341. $manipulator = new JsonManipulator($contents);
  9342. $newFile = !$this->file->exists();
  9343. if ($this->authConfig && $method === 'addConfigSetting') {
  9344. $method = 'addSubNode';
  9345. list($mainNode, $name) = explode('.', $args[0], 2);
  9346. $args = array($mainNode, $name, $args[1]);
  9347. } elseif ($this->authConfig && $method === 'removeConfigSetting') {
  9348. $method = 'removeSubNode';
  9349. list($mainNode, $name) = explode('.', $args[0], 2);
  9350. $args = array($mainNode, $name);
  9351. }
  9352. if (call_user_func_array(array($manipulator, $method), $args)) {
  9353. file_put_contents($this->file->getPath(), $manipulator->getContents());
  9354. } else {
  9355. $config = $this->file->read();
  9356. $this->arrayUnshiftRef($args, $config);
  9357. call_user_func_array($fallback, $args);
  9358. foreach (array('require', 'require-dev', 'conflict', 'provide', 'replace', 'suggest', 'config', 'autoload', 'autoload-dev', 'scripts', 'scripts-descriptions', 'support') as $prop) {
  9359. if (isset($config[$prop]) && $config[$prop] === array()) {
  9360. $config[$prop] = new \stdClass;
  9361. }
  9362. }
  9363. foreach (array('psr-0', 'psr-4') as $prop) {
  9364. if (isset($config['autoload'][$prop]) && $config['autoload'][$prop] === array()) {
  9365. $config['autoload'][$prop] = new \stdClass;
  9366. }
  9367. if (isset($config['autoload-dev'][$prop]) && $config['autoload-dev'][$prop] === array()) {
  9368. $config['autoload-dev'][$prop] = new \stdClass;
  9369. }
  9370. }
  9371. foreach (array('platform', 'http-basic', 'bearer', 'gitlab-token', 'gitlab-oauth', 'github-oauth', 'preferred-install') as $prop) {
  9372. if (isset($config['config'][$prop]) && $config['config'][$prop] === array()) {
  9373. $config['config'][$prop] = new \stdClass;
  9374. }
  9375. }
  9376. $this->file->write($config);
  9377. }
  9378. try {
  9379. $this->file->validateSchema(JsonFile::LAX_SCHEMA);
  9380. } catch (JsonValidationException $e) {
  9381. file_put_contents($this->file->getPath(), $contents);
  9382. throw new \RuntimeException('Failed to update composer.json with a valid format, reverting to the original content. Please report an issue to us with details (command you run and a copy of your composer.json). '.PHP_EOL.implode(PHP_EOL, $e->getErrors()), 0, $e);
  9383. }
  9384. if ($newFile) {
  9385. Silencer::call('chmod', $this->file->getPath(), 0600);
  9386. }
  9387. }
  9388. private function arrayUnshiftRef(array &$array, &$value): int
  9389. {
  9390. $return = array_unshift($array, '');
  9391. $array[0] = &$value;
  9392. return $return;
  9393. }
  9394. }
  9395. <?php declare(strict_types=1);
  9396. namespace Composer\Console;
  9397. use Composer\IO\NullIO;
  9398. use Composer\Util\Filesystem;
  9399. use Composer\Util\Platform;
  9400. use Composer\Util\Silencer;
  9401. use LogicException;
  9402. use Symfony\Component\Console\Application as BaseApplication;
  9403. use Symfony\Component\Console\Exception\CommandNotFoundException;
  9404. use Symfony\Component\Console\Helper\HelperSet;
  9405. use Symfony\Component\Console\Helper\QuestionHelper;
  9406. use Symfony\Component\Console\Input\InputDefinition;
  9407. use Symfony\Component\Console\Input\InputInterface;
  9408. use Symfony\Component\Console\Input\InputOption;
  9409. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  9410. use Symfony\Component\Console\Output\OutputInterface;
  9411. use Seld\JsonLint\ParsingException;
  9412. use Composer\Command;
  9413. use Composer\Composer;
  9414. use Composer\Factory;
  9415. use Composer\IO\IOInterface;
  9416. use Composer\IO\ConsoleIO;
  9417. use Composer\Json\JsonValidationException;
  9418. use Composer\Util\ErrorHandler;
  9419. use Composer\Util\HttpDownloader;
  9420. use Composer\EventDispatcher\ScriptExecutionException;
  9421. use Composer\Exception\NoSslException;
  9422. use Composer\XdebugHandler\XdebugHandler;
  9423. use Symfony\Component\Process\Exception\ProcessTimedOutException;
  9424. class Application extends BaseApplication
  9425. {
  9426. protected $composer;
  9427. protected $io;
  9428. private static $logo = ' ______
  9429. / ____/___ ____ ___ ____ ____ ________ _____
  9430. / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
  9431. / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
  9432. \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
  9433. /_/
  9434. ';
  9435. private $hasPluginCommands = false;
  9436. private $disablePluginsByDefault = false;
  9437. private $disableScriptsByDefault = false;
  9438. private $initialWorkingDirectory;
  9439. public function __construct()
  9440. {
  9441. static $shutdownRegistered = false;
  9442. if (function_exists('ini_set') && extension_loaded('xdebug')) {
  9443. ini_set('xdebug.show_exception_trace', '0');
  9444. ini_set('xdebug.scream', '0');
  9445. }
  9446. if (function_exists('date_default_timezone_set') && function_exists('date_default_timezone_get')) {
  9447. date_default_timezone_set(Silencer::call('date_default_timezone_get'));
  9448. }
  9449. if (!$shutdownRegistered) {
  9450. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  9451. pcntl_async_signals(true);
  9452. pcntl_signal(SIGINT, function ($sig): void {
  9453. exit(130);
  9454. });
  9455. }
  9456. $shutdownRegistered = true;
  9457. register_shutdown_function(function (): void {
  9458. $lastError = error_get_last();
  9459. if ($lastError && $lastError['message'] &&
  9460. (strpos($lastError['message'], 'Allowed memory') !== false ||
  9461. strpos($lastError['message'], 'exceeded memory') !== false )) {
  9462. echo "\n". 'Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.';
  9463. }
  9464. });
  9465. }
  9466. $this->io = new NullIO();
  9467. $this->initialWorkingDirectory = getcwd();
  9468. parent::__construct('Composer', Composer::getVersion());
  9469. }
  9470. public function run(InputInterface $input = null, OutputInterface $output = null): int
  9471. {
  9472. if (null === $output) {
  9473. $output = Factory::createOutput();
  9474. }
  9475. return parent::run($input, $output);
  9476. }
  9477. public function doRun(InputInterface $input, OutputInterface $output): int
  9478. {
  9479. $this->disablePluginsByDefault = $input->hasParameterOption('--no-plugins');
  9480. $this->disableScriptsByDefault = $input->hasParameterOption('--no-scripts');
  9481. if (Platform::getEnv('COMPOSER_NO_INTERACTION') || !Platform::isTty(defined('STDIN') ? STDIN : fopen('php://stdin', 'r'))) {
  9482. $input->setInteractive(false);
  9483. }
  9484. $io = $this->io = new ConsoleIO($input, $output, new HelperSet(array(
  9485. new QuestionHelper(),
  9486. )));
  9487. ErrorHandler::register($io);
  9488. if ($input->hasParameterOption('--no-cache')) {
  9489. $io->writeError('Disabling cache usage', true, IOInterface::DEBUG);
  9490. Platform::putEnv('COMPOSER_CACHE_DIR', Platform::isWindows() ? 'nul' : '/dev/null');
  9491. }
  9492. $newWorkDir = $this->getNewWorkingDir($input);
  9493. if (null !== $newWorkDir) {
  9494. $oldWorkingDir = Platform::getCwd(true);
  9495. chdir($newWorkDir);
  9496. $this->initialWorkingDirectory = $newWorkDir;
  9497. $cwd = Platform::getCwd(true);
  9498. $io->writeError('Changed CWD to ' . ($cwd !== '' ? $cwd : $newWorkDir), true, IOInterface::DEBUG);
  9499. }
  9500. $commandName = '';
  9501. if ($name = $this->getCommandName($input)) {
  9502. try {
  9503. $commandName = $this->find($name)->getName();
  9504. } catch (CommandNotFoundException $e) {
  9505. $commandName = false;
  9506. } catch (\InvalidArgumentException $e) {
  9507. }
  9508. }
  9509. if ($io->isInteractive() && null === $newWorkDir && !in_array($commandName, array('', 'list', 'init', 'about', 'help', 'diagnose', 'self-update', 'global', 'create-project', 'outdated'), true) && !file_exists(Factory::getComposerFile()) && ($useParentDirIfNoJsonAvailable = $this->getUseParentDirConfigValue()) !== false) {
  9510. $dir = dirname(Platform::getCwd(true));
  9511. $home = realpath(Platform::getEnv('HOME') ?: Platform::getEnv('USERPROFILE') ?: '/');
  9512. while (dirname($dir) !== $dir && $dir !== $home) {
  9513. if (file_exists($dir.'/'.Factory::getComposerFile())) {
  9514. if ($useParentDirIfNoJsonAvailable === true || $io->askConfirmation('<info>No composer.json in current directory, do you want to use the one at '.$dir.'?</info> [<comment>Y,n</comment>]? ')) {
  9515. if ($useParentDirIfNoJsonAvailable === true) {
  9516. $io->writeError('<info>No composer.json in current directory, changing working directory to '.$dir.'</info>');
  9517. } else {
  9518. $io->writeError('<info>Always want to use the parent dir? Use "composer config --global use-parent-dir true" to change the default.</info>');
  9519. }
  9520. $oldWorkingDir = Platform::getCwd(true);
  9521. chdir($dir);
  9522. }
  9523. break;
  9524. }
  9525. $dir = dirname($dir);
  9526. }
  9527. }
  9528. $mayNeedPluginCommand = false === $input->hasParameterOption(array('--version', '-V'))
  9529. && (
  9530. false === $commandName
  9531. || in_array($commandName, array('', 'list', 'help'), true)
  9532. );
  9533. if ($mayNeedPluginCommand && !$this->disablePluginsByDefault && !$this->hasPluginCommands) {
  9534. try {
  9535. foreach ($this->getPluginCommands() as $command) {
  9536. if ($this->has($command->getName())) {
  9537. $io->writeError('<warning>Plugin command '.$command->getName().' ('.get_class($command).') would override a Composer command and has been skipped</warning>');
  9538. } else {
  9539. $this->add($command);
  9540. }
  9541. }
  9542. } catch (NoSslException $e) {
  9543. } catch (ParsingException $e) {
  9544. $details = $e->getDetails();
  9545. $file = realpath(Factory::getComposerFile());
  9546. $line = null;
  9547. if ($details && isset($details['line'])) {
  9548. $line = $details['line'];
  9549. }
  9550. $ghe = new GithubActionError($this->io);
  9551. $ghe->emit($e->getMessage(), $file, $line);
  9552. throw $e;
  9553. }
  9554. $this->hasPluginCommands = true;
  9555. }
  9556. $isProxyCommand = false;
  9557. if ($name = $this->getCommandName($input)) {
  9558. try {
  9559. $command = $this->find($name);
  9560. $commandName = $command->getName();
  9561. $isProxyCommand = ($command instanceof Command\BaseCommand && $command->isProxyCommand());
  9562. } catch (\InvalidArgumentException $e) {
  9563. }
  9564. }
  9565. if (!$isProxyCommand) {
  9566. $io->writeError(sprintf(
  9567. 'Running %s (%s) with %s on %s',
  9568. Composer::getVersion(),
  9569. Composer::RELEASE_DATE,
  9570. defined('HHVM_VERSION') ? 'HHVM '.HHVM_VERSION : 'PHP '.PHP_VERSION,
  9571. function_exists('php_uname') ? php_uname('s') . ' / ' . php_uname('r') : 'Unknown OS'
  9572. ), true, IOInterface::DEBUG);
  9573. if (PHP_VERSION_ID < 70205) {
  9574. $io->writeError('<warning>Composer supports PHP 7.2.5 and above, you will most likely encounter problems with your PHP '.PHP_VERSION.'. Upgrading is strongly recommended but you can use Composer 2.2.x LTS as a fallback.</warning>');
  9575. }
  9576. if (XdebugHandler::isXdebugActive() && !Platform::getEnv('COMPOSER_DISABLE_XDEBUG_WARN')) {
  9577. $io->writeError('<warning>Composer is operating slower than normal because you have Xdebug enabled. See https://getcomposer.org/xdebug</warning>');
  9578. }
  9579. if (defined('COMPOSER_DEV_WARNING_TIME') && $commandName !== 'self-update' && $commandName !== 'selfupdate' && time() > COMPOSER_DEV_WARNING_TIME) {
  9580. $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']));
  9581. }
  9582. if (
  9583. !Platform::isWindows()
  9584. && function_exists('exec')
  9585. && !Platform::getEnv('COMPOSER_ALLOW_SUPERUSER')
  9586. && (ini_get('open_basedir') || !file_exists('/.dockerenv'))
  9587. ) {
  9588. if (function_exists('posix_getuid') && posix_getuid() === 0) {
  9589. if ($commandName !== 'self-update' && $commandName !== 'selfupdate') {
  9590. $io->writeError('<warning>Do not run Composer as root/super user! See https://getcomposer.org/root for details</warning>');
  9591. if ($io->isInteractive()) {
  9592. if (!$io->askConfirmation('<info>Continue as root/super user</info> [<comment>yes</comment>]? ')) {
  9593. return 1;
  9594. }
  9595. }
  9596. }
  9597. if ($uid = (int) Platform::getEnv('SUDO_UID')) {
  9598. Silencer::call('exec', "sudo -u \\#{$uid} sudo -K > /dev/null 2>&1");
  9599. }
  9600. }
  9601. Silencer::call('exec', 'sudo -K > /dev/null 2>&1');
  9602. }
  9603. Silencer::call(function () use ($io): void {
  9604. $tempfile = sys_get_temp_dir() . '/temp-' . md5(microtime());
  9605. if (!(file_put_contents($tempfile, __FILE__) && (file_get_contents($tempfile) == __FILE__) && unlink($tempfile) && !file_exists($tempfile))) {
  9606. $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()));
  9607. }
  9608. });
  9609. $file = Factory::getComposerFile();
  9610. if (is_file($file) && Filesystem::isReadable($file) && is_array($composer = json_decode(file_get_contents($file), true))) {
  9611. if (isset($composer['scripts']) && is_array($composer['scripts'])) {
  9612. foreach ($composer['scripts'] as $script => $dummy) {
  9613. if (!defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
  9614. if ($this->has($script)) {
  9615. $io->writeError('<warning>A script named '.$script.' would override a Composer command and has been skipped</warning>');
  9616. } else {
  9617. $description = null;
  9618. if (isset($composer['scripts-descriptions'][$script])) {
  9619. $description = $composer['scripts-descriptions'][$script];
  9620. }
  9621. $this->add(new Command\ScriptAliasCommand($script, $description));
  9622. }
  9623. }
  9624. }
  9625. }
  9626. }
  9627. }
  9628. try {
  9629. if ($input->hasParameterOption('--profile')) {
  9630. $startTime = microtime(true);
  9631. $this->io->enableDebugging($startTime);
  9632. }
  9633. $result = parent::doRun($input, $output);
  9634. if (isset($oldWorkingDir) && '' !== $oldWorkingDir) {
  9635. Silencer::call('chdir', $oldWorkingDir);
  9636. }
  9637. if (isset($startTime)) {
  9638. $io->writeError('<info>Memory usage: '.round(memory_get_usage() / 1024 / 1024, 2).'MiB (peak: '.round(memory_get_peak_usage() / 1024 / 1024, 2).'MiB), time: '.round(microtime(true) - $startTime, 2).'s');
  9639. }
  9640. return $result;
  9641. } catch (ScriptExecutionException $e) {
  9642. return $e->getCode();
  9643. } catch (\Throwable $e) {
  9644. $ghe = new GithubActionError($this->io);
  9645. $ghe->emit($e->getMessage());
  9646. $this->hintCommonErrors($e, $output);
  9647. if (!$e instanceof \Exception) {
  9648. if ($output instanceof ConsoleOutputInterface) {
  9649. $this->renderThrowable($e, $output->getErrorOutput());
  9650. } else {
  9651. $this->renderThrowable($e, $output);
  9652. }
  9653. $exitCode = $e->getCode();
  9654. if (is_numeric($exitCode)) {
  9655. $exitCode = (int) $exitCode;
  9656. if (0 === $exitCode) {
  9657. $exitCode = 1;
  9658. }
  9659. } else {
  9660. $exitCode = 1;
  9661. }
  9662. return $exitCode;
  9663. }
  9664. throw $e;
  9665. } finally {
  9666. restore_error_handler();
  9667. }
  9668. }
  9669. private function getNewWorkingDir(InputInterface $input): ?string
  9670. {
  9671. $workingDir = $input->getParameterOption(array('--working-dir', '-d'), null, true);
  9672. if (null !== $workingDir && !is_dir($workingDir)) {
  9673. throw new \RuntimeException('Invalid working directory specified, '.$workingDir.' does not exist.');
  9674. }
  9675. return $workingDir;
  9676. }
  9677. private function hintCommonErrors(\Throwable $exception, OutputInterface $output): void
  9678. {
  9679. $io = $this->getIO();
  9680. if ((get_class($exception) === LogicException::class || $exception instanceof \Error) && $output->getVerbosity() < OutputInterface::VERBOSITY_VERBOSE) {
  9681. $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
  9682. }
  9683. Silencer::suppress();
  9684. try {
  9685. $composer = $this->getComposer(false, true);
  9686. if ($composer) {
  9687. $config = $composer->getConfig();
  9688. $minSpaceFree = 1024 * 1024;
  9689. if ((($df = disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree)
  9690. || (($df = disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree)
  9691. || (($df = disk_free_space($dir = sys_get_temp_dir())) !== false && $df < $minSpaceFree)
  9692. ) {
  9693. $io->writeError('<error>The disk hosting '.$dir.' is full, this may be the cause of the following exception</error>', true, IOInterface::QUIET);
  9694. }
  9695. }
  9696. } catch (\Exception $e) {
  9697. }
  9698. Silencer::restore();
  9699. if (Platform::isWindows() && false !== strpos($exception->getMessage(), 'The system cannot find the path specified')) {
  9700. $io->writeError('<error>The following exception may be caused by a stale entry in your cmd.exe AutoRun</error>', true, IOInterface::QUIET);
  9701. $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);
  9702. }
  9703. if (false !== strpos($exception->getMessage(), 'fork failed - Cannot allocate memory')) {
  9704. $io->writeError('<error>The following exception is caused by a lack of memory or swap, or not having swap configured</error>', true, IOInterface::QUIET);
  9705. $io->writeError('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details</error>', true, IOInterface::QUIET);
  9706. }
  9707. if ($exception instanceof ProcessTimedOutException) {
  9708. $io->writeError('<error>The following exception is caused by a process timeout</error>', true, IOInterface::QUIET);
  9709. $io->writeError('<error>Check https://getcomposer.org/doc/06-config.md#process-timeout for details</error>', true, IOInterface::QUIET);
  9710. }
  9711. $hints = HttpDownloader::getExceptionHints($exception);
  9712. if (null !== $hints && count($hints) > 0) {
  9713. foreach ($hints as $hint) {
  9714. $io->writeError($hint, true, IOInterface::QUIET);
  9715. }
  9716. }
  9717. }
  9718. public function getComposer(bool $required = true, ?bool $disablePlugins = null, ?bool $disableScripts = null): ?Composer
  9719. {
  9720. if (null === $disablePlugins) {
  9721. $disablePlugins = $this->disablePluginsByDefault;
  9722. }
  9723. if (null === $disableScripts) {
  9724. $disableScripts = $this->disableScriptsByDefault;
  9725. }
  9726. if (null === $this->composer) {
  9727. try {
  9728. $this->composer = Factory::create($this->io, null, $disablePlugins, $disableScripts);
  9729. } catch (\InvalidArgumentException $e) {
  9730. if ($required) {
  9731. $this->io->writeError($e->getMessage());
  9732. if ($this->areExceptionsCaught()) {
  9733. exit(1);
  9734. }
  9735. throw $e;
  9736. }
  9737. } catch (JsonValidationException $e) {
  9738. if ($required) {
  9739. throw $e;
  9740. }
  9741. }
  9742. }
  9743. return $this->composer;
  9744. }
  9745. public function resetComposer(): void
  9746. {
  9747. $this->composer = null;
  9748. if (method_exists($this->getIO(), 'resetAuthentications')) {
  9749. $this->getIO()->resetAuthentications();
  9750. }
  9751. }
  9752. public function getIO(): IOInterface
  9753. {
  9754. return $this->io;
  9755. }
  9756. public function getHelp(): string
  9757. {
  9758. return self::$logo . parent::getHelp();
  9759. }
  9760. protected function getDefaultCommands(): array
  9761. {
  9762. $commands = array_merge(parent::getDefaultCommands(), array(
  9763. new Command\AboutCommand(),
  9764. new Command\ConfigCommand(),
  9765. new Command\DependsCommand(),
  9766. new Command\ProhibitsCommand(),
  9767. new Command\InitCommand(),
  9768. new Command\InstallCommand(),
  9769. new Command\CreateProjectCommand(),
  9770. new Command\UpdateCommand(),
  9771. new Command\SearchCommand(),
  9772. new Command\ValidateCommand(),
  9773. new Command\ShowCommand(),
  9774. new Command\SuggestsCommand(),
  9775. new Command\RequireCommand(),
  9776. new Command\DumpAutoloadCommand(),
  9777. new Command\StatusCommand(),
  9778. new Command\ArchiveCommand(),
  9779. new Command\DiagnoseCommand(),
  9780. new Command\RunScriptCommand(),
  9781. new Command\LicensesCommand(),
  9782. new Command\GlobalCommand(),
  9783. new Command\ClearCacheCommand(),
  9784. new Command\RemoveCommand(),
  9785. new Command\HomeCommand(),
  9786. new Command\ExecCommand(),
  9787. new Command\OutdatedCommand(),
  9788. new Command\CheckPlatformReqsCommand(),
  9789. new Command\FundCommand(),
  9790. new Command\ReinstallCommand(),
  9791. ));
  9792. if (strpos(__FILE__, 'phar:') === 0 || '1' === Platform::getEnv('COMPOSER_TESTS_ARE_RUNNING')) {
  9793. $commands[] = new Command\SelfUpdateCommand();
  9794. }
  9795. return $commands;
  9796. }
  9797. public function getLongVersion(): string
  9798. {
  9799. $branchAliasString = '';
  9800. if (Composer::BRANCH_ALIAS_VERSION && Composer::BRANCH_ALIAS_VERSION !== '@package_branch_alias_version'.'@') {
  9801. $branchAliasString = sprintf(' (%s)', Composer::BRANCH_ALIAS_VERSION);
  9802. }
  9803. return sprintf(
  9804. '<info>%s</info> version <comment>%s%s</comment> %s',
  9805. $this->getName(),
  9806. $this->getVersion(),
  9807. $branchAliasString,
  9808. Composer::RELEASE_DATE
  9809. );
  9810. }
  9811. protected function getDefaultInputDefinition(): InputDefinition
  9812. {
  9813. $definition = parent::getDefaultInputDefinition();
  9814. $definition->addOption(new InputOption('--profile', null, InputOption::VALUE_NONE, 'Display timing and memory usage information'));
  9815. $definition->addOption(new InputOption('--no-plugins', null, InputOption::VALUE_NONE, 'Whether to disable plugins.'));
  9816. $definition->addOption(new InputOption('--no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'));
  9817. $definition->addOption(new InputOption('--working-dir', '-d', InputOption::VALUE_REQUIRED, 'If specified, use the given directory as working directory.'));
  9818. $definition->addOption(new InputOption('--no-cache', null, InputOption::VALUE_NONE, 'Prevent use of the cache'));
  9819. return $definition;
  9820. }
  9821. private function getPluginCommands(): array
  9822. {
  9823. $commands = array();
  9824. $composer = $this->getComposer(false, false);
  9825. if (null === $composer) {
  9826. $composer = Factory::createGlobal($this->io, $this->disablePluginsByDefault, $this->disableScriptsByDefault);
  9827. }
  9828. if (null !== $composer) {
  9829. $pm = $composer->getPluginManager();
  9830. foreach ($pm->getPluginCapabilities('Composer\Plugin\Capability\CommandProvider', array('composer' => $composer, 'io' => $this->io)) as $capability) {
  9831. $newCommands = $capability->getCommands();
  9832. if (!is_array($newCommands)) {
  9833. throw new \UnexpectedValueException('Plugin capability '.get_class($capability).' failed to return an array from getCommands');
  9834. }
  9835. foreach ($newCommands as $command) {
  9836. if (!$command instanceof Command\BaseCommand) {
  9837. throw new \UnexpectedValueException('Plugin capability '.get_class($capability).' returned an invalid value, we expected an array of Composer\Command\BaseCommand objects');
  9838. }
  9839. }
  9840. $commands = array_merge($commands, $newCommands);
  9841. }
  9842. }
  9843. return $commands;
  9844. }
  9845. public function getInitialWorkingDirectory()
  9846. {
  9847. return $this->initialWorkingDirectory;
  9848. }
  9849. private function getUseParentDirConfigValue()
  9850. {
  9851. $config = Factory::createConfig($this->io);
  9852. return $config->get('use-parent-dir');
  9853. }
  9854. }
  9855. <?php declare(strict_types=1);
  9856. namespace Composer\Console;
  9857. use Composer\IO\IOInterface;
  9858. use Composer\Util\Platform;
  9859. final class GithubActionError
  9860. {
  9861. protected $io;
  9862. public function __construct(IOInterface $io)
  9863. {
  9864. $this->io = $io;
  9865. }
  9866. public function emit(string $message, ?string $file = null, ?int $line = null): void
  9867. {
  9868. if (Platform::getEnv('GITHUB_ACTIONS') && !Platform::getEnv('COMPOSER_TESTS_ARE_RUNNING')) {
  9869. $message = $this->escapeData($message);
  9870. if ($file && $line) {
  9871. $file = $this->escapeProperty($file);
  9872. $this->io->write("::error file=". $file .",line=". $line ."::". $message);
  9873. } elseif ($file) {
  9874. $file = $this->escapeProperty($file);
  9875. $this->io->write("::error file=". $file ."::". $message);
  9876. } else {
  9877. $this->io->write("::error ::". $message);
  9878. }
  9879. }
  9880. }
  9881. private function escapeData(string $data): string
  9882. {
  9883. $data = str_replace("%", '%25', $data);
  9884. $data = str_replace("\r", '%0D', $data);
  9885. $data = str_replace("\n", '%0A', $data);
  9886. return $data;
  9887. }
  9888. private function escapeProperty(string $property): string
  9889. {
  9890. $property = str_replace("%", '%25', $property);
  9891. $property = str_replace("\r", '%0D', $property);
  9892. $property = str_replace("\n", '%0A', $property);
  9893. $property = str_replace(":", '%3A', $property);
  9894. $property = str_replace(",", '%2C', $property);
  9895. return $property;
  9896. }
  9897. }
  9898. <?php declare(strict_types=1);
  9899. namespace Composer\Console;
  9900. use Closure;
  9901. use Composer\Pcre\Preg;
  9902. use Symfony\Component\Console\Formatter\OutputFormatter;
  9903. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  9904. class HtmlOutputFormatter extends OutputFormatter
  9905. {
  9906. private static $availableForegroundColors = array(
  9907. 30 => 'black',
  9908. 31 => 'red',
  9909. 32 => 'green',
  9910. 33 => 'yellow',
  9911. 34 => 'blue',
  9912. 35 => 'magenta',
  9913. 36 => 'cyan',
  9914. 37 => 'white',
  9915. );
  9916. private static $availableBackgroundColors = array(
  9917. 40 => 'black',
  9918. 41 => 'red',
  9919. 42 => 'green',
  9920. 43 => 'yellow',
  9921. 44 => 'blue',
  9922. 45 => 'magenta',
  9923. 46 => 'cyan',
  9924. 47 => 'white',
  9925. );
  9926. private static $availableOptions = array(
  9927. 1 => 'bold',
  9928. 4 => 'underscore',
  9929. );
  9930. public function __construct(array $styles = array())
  9931. {
  9932. parent::__construct(true, $styles);
  9933. }
  9934. public function format(?string $message): ?string
  9935. {
  9936. $formatted = parent::format($message);
  9937. if ($formatted === null) {
  9938. return null;
  9939. }
  9940. $clearEscapeCodes = '(?:39|49|0|22|24|25|27|28)';
  9941. return Preg::replaceCallback("{\033\[([0-9;]+)m(.*?)\033\[(?:".$clearEscapeCodes.";)*?".$clearEscapeCodes."m}s", Closure::fromCallable([$this, 'formatHtml']), $formatted);
  9942. }
  9943. private function formatHtml(array $matches): string
  9944. {
  9945. $out = '<span style="';
  9946. foreach (explode(';', $matches[1]) as $code) {
  9947. if (isset(self::$availableForegroundColors[(int) $code])) {
  9948. $out .= 'color:'.self::$availableForegroundColors[(int) $code].';';
  9949. } elseif (isset(self::$availableBackgroundColors[(int) $code])) {
  9950. $out .= 'background-color:'.self::$availableBackgroundColors[(int) $code].';';
  9951. } elseif (isset(self::$availableOptions[(int) $code])) {
  9952. switch (self::$availableOptions[(int) $code]) {
  9953. case 'bold':
  9954. $out .= 'font-weight:bold;';
  9955. break;
  9956. case 'underscore':
  9957. $out .= 'text-decoration:underline;';
  9958. break;
  9959. }
  9960. }
  9961. }
  9962. return $out.'">'.$matches[2].'</span>';
  9963. }
  9964. }
  9965. <?php declare(strict_types=1);
  9966. namespace Composer\DependencyResolver;
  9967. class Decisions implements \Iterator, \Countable
  9968. {
  9969. public const DECISION_LITERAL = 0;
  9970. public const DECISION_REASON = 1;
  9971. protected $pool;
  9972. protected $decisionMap;
  9973. protected $decisionQueue = array();
  9974. public function __construct(Pool $pool)
  9975. {
  9976. $this->pool = $pool;
  9977. $this->decisionMap = array();
  9978. }
  9979. public function decide(int $literal, int $level, Rule $why): void
  9980. {
  9981. $this->addDecision($literal, $level);
  9982. $this->decisionQueue[] = array(
  9983. self::DECISION_LITERAL => $literal,
  9984. self::DECISION_REASON => $why,
  9985. );
  9986. }
  9987. public function satisfy(int $literal): bool
  9988. {
  9989. $packageId = abs($literal);
  9990. return (
  9991. $literal > 0 && isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0 ||
  9992. $literal < 0 && isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] < 0
  9993. );
  9994. }
  9995. public function conflict(int $literal): bool
  9996. {
  9997. $packageId = abs($literal);
  9998. return (
  9999. (isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0 && $literal < 0) ||
  10000. (isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] < 0 && $literal > 0)
  10001. );
  10002. }
  10003. public function decided(int $literalOrPackageId): bool
  10004. {
  10005. return !empty($this->decisionMap[abs($literalOrPackageId)]);
  10006. }
  10007. public function undecided(int $literalOrPackageId): bool
  10008. {
  10009. return empty($this->decisionMap[abs($literalOrPackageId)]);
  10010. }
  10011. public function decidedInstall(int $literalOrPackageId): bool
  10012. {
  10013. $packageId = abs($literalOrPackageId);
  10014. return isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0;
  10015. }
  10016. public function decisionLevel(int $literalOrPackageId): int
  10017. {
  10018. $packageId = abs($literalOrPackageId);
  10019. if (isset($this->decisionMap[$packageId])) {
  10020. return abs($this->decisionMap[$packageId]);
  10021. }
  10022. return 0;
  10023. }
  10024. public function decisionRule(int $literalOrPackageId): ?Rule
  10025. {
  10026. $packageId = abs($literalOrPackageId);
  10027. foreach ($this->decisionQueue as $decision) {
  10028. if ($packageId === abs($decision[self::DECISION_LITERAL])) {
  10029. return $decision[self::DECISION_REASON];
  10030. }
  10031. }
  10032. return null;
  10033. }
  10034. public function atOffset(int $queueOffset): array
  10035. {
  10036. return $this->decisionQueue[$queueOffset];
  10037. }
  10038. public function validOffset(int $queueOffset): bool
  10039. {
  10040. return $queueOffset >= 0 && $queueOffset < \count($this->decisionQueue);
  10041. }
  10042. public function lastReason(): Rule
  10043. {
  10044. return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_REASON];
  10045. }
  10046. public function lastLiteral(): int
  10047. {
  10048. return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_LITERAL];
  10049. }
  10050. public function reset(): void
  10051. {
  10052. while ($decision = array_pop($this->decisionQueue)) {
  10053. $this->decisionMap[abs($decision[self::DECISION_LITERAL])] = 0;
  10054. }
  10055. }
  10056. public function resetToOffset(int $offset): void
  10057. {
  10058. while (\count($this->decisionQueue) > $offset + 1) {
  10059. $decision = array_pop($this->decisionQueue);
  10060. $this->decisionMap[abs($decision[self::DECISION_LITERAL])] = 0;
  10061. }
  10062. }
  10063. public function revertLast(): void
  10064. {
  10065. $this->decisionMap[abs($this->lastLiteral())] = 0;
  10066. array_pop($this->decisionQueue);
  10067. }
  10068. public function count(): int
  10069. {
  10070. return \count($this->decisionQueue);
  10071. }
  10072. public function rewind(): void
  10073. {
  10074. end($this->decisionQueue);
  10075. }
  10076. #[\ReturnTypeWillChange]
  10077. public function current()
  10078. {
  10079. return current($this->decisionQueue);
  10080. }
  10081. public function key(): ?int
  10082. {
  10083. return key($this->decisionQueue);
  10084. }
  10085. public function next(): void
  10086. {
  10087. prev($this->decisionQueue);
  10088. }
  10089. public function valid(): bool
  10090. {
  10091. return false !== current($this->decisionQueue);
  10092. }
  10093. public function isEmpty(): bool
  10094. {
  10095. return \count($this->decisionQueue) === 0;
  10096. }
  10097. protected function addDecision(int $literal, int $level): void
  10098. {
  10099. $packageId = abs($literal);
  10100. $previousDecision = $this->decisionMap[$packageId] ?? null;
  10101. if ($previousDecision != 0) {
  10102. $literalString = $this->pool->literalToPrettyString($literal, array());
  10103. $package = $this->pool->literalToPackage($literal);
  10104. throw new SolverBugException(
  10105. "Trying to decide $literalString on level $level, even though $package was previously decided as ".(int) $previousDecision."."
  10106. );
  10107. }
  10108. if ($literal > 0) {
  10109. $this->decisionMap[$packageId] = $level;
  10110. } else {
  10111. $this->decisionMap[$packageId] = -$level;
  10112. }
  10113. }
  10114. public function toString(Pool $pool = null): string
  10115. {
  10116. $decisionMap = $this->decisionMap;
  10117. ksort($decisionMap);
  10118. $str = '[';
  10119. foreach ($decisionMap as $packageId => $level) {
  10120. $str .= (($pool) ? $pool->literalToPackage($packageId) : $packageId).':'.$level.',';
  10121. }
  10122. $str .= ']';
  10123. return $str;
  10124. }
  10125. public function __toString(): string
  10126. {
  10127. return $this->toString();
  10128. }
  10129. }
  10130. <?php declare(strict_types=1);
  10131. namespace Composer\DependencyResolver;
  10132. use Composer\Package\AliasPackage;
  10133. use Composer\Package\BasePackage;
  10134. use Composer\Package\PackageInterface;
  10135. use Composer\Semver\Constraint\Constraint;
  10136. class DefaultPolicy implements PolicyInterface
  10137. {
  10138. private $preferStable;
  10139. private $preferLowest;
  10140. private $preferredPackageResultCachePerPool;
  10141. private $sortingCachePerPool;
  10142. public function __construct(bool $preferStable = false, bool $preferLowest = false)
  10143. {
  10144. $this->preferStable = $preferStable;
  10145. $this->preferLowest = $preferLowest;
  10146. }
  10147. public function versionCompare(PackageInterface $a, PackageInterface $b, string $operator): bool
  10148. {
  10149. if ($this->preferStable && ($stabA = $a->getStability()) !== ($stabB = $b->getStability())) {
  10150. return BasePackage::$stabilities[$stabA] < BasePackage::$stabilities[$stabB];
  10151. }
  10152. $constraint = new Constraint($operator, $b->getVersion());
  10153. $version = new Constraint('==', $a->getVersion());
  10154. return $constraint->matchSpecific($version, true);
  10155. }
  10156. public function selectPreferredPackages(Pool $pool, array $literals, string $requiredPackage = null): array
  10157. {
  10158. sort($literals);
  10159. $resultCacheKey = implode(',', $literals).$requiredPackage;
  10160. $poolId = spl_object_id($pool);
  10161. if (isset($this->preferredPackageResultCachePerPool[$poolId][$resultCacheKey])) {
  10162. return $this->preferredPackageResultCachePerPool[$poolId][$resultCacheKey];
  10163. }
  10164. $packages = $this->groupLiteralsByName($pool, $literals);
  10165. foreach ($packages as &$nameLiterals) {
  10166. usort($nameLiterals, function ($a, $b) use ($pool, $requiredPackage, $poolId): int {
  10167. $cacheKey = 'i'.$a.'.'.$b.$requiredPackage;
  10168. if (isset($this->sortingCachePerPool[$poolId][$cacheKey])) {
  10169. return $this->sortingCachePerPool[$poolId][$cacheKey];
  10170. }
  10171. return $this->sortingCachePerPool[$poolId][$cacheKey] = $this->compareByPriority($pool, $pool->literalToPackage($a), $pool->literalToPackage($b), $requiredPackage, true);
  10172. });
  10173. }
  10174. foreach ($packages as &$sortedLiterals) {
  10175. $sortedLiterals = $this->pruneToBestVersion($pool, $sortedLiterals);
  10176. $sortedLiterals = $this->pruneRemoteAliases($pool, $sortedLiterals);
  10177. }
  10178. $selected = \call_user_func_array('array_merge', array_values($packages));
  10179. usort($selected, function ($a, $b) use ($pool, $requiredPackage, $poolId): int {
  10180. $cacheKey = $a.'.'.$b.$requiredPackage;
  10181. if (isset($this->sortingCachePerPool[$poolId][$cacheKey])) {
  10182. return $this->sortingCachePerPool[$poolId][$cacheKey];
  10183. }
  10184. return $this->sortingCachePerPool[$poolId][$cacheKey] = $this->compareByPriority($pool, $pool->literalToPackage($a), $pool->literalToPackage($b), $requiredPackage);
  10185. });
  10186. return $this->preferredPackageResultCachePerPool[$poolId][$resultCacheKey] = $selected;
  10187. }
  10188. protected function groupLiteralsByName(Pool $pool, array $literals): array
  10189. {
  10190. $packages = array();
  10191. foreach ($literals as $literal) {
  10192. $packageName = $pool->literalToPackage($literal)->getName();
  10193. if (!isset($packages[$packageName])) {
  10194. $packages[$packageName] = array();
  10195. }
  10196. $packages[$packageName][] = $literal;
  10197. }
  10198. return $packages;
  10199. }
  10200. public function compareByPriority(Pool $pool, BasePackage $a, BasePackage $b, ?string $requiredPackage = null, bool $ignoreReplace = false): int
  10201. {
  10202. if ($a->getName() === $b->getName()) {
  10203. $aAliased = $a instanceof AliasPackage;
  10204. $bAliased = $b instanceof AliasPackage;
  10205. if ($aAliased && !$bAliased) {
  10206. return -1;
  10207. }
  10208. if (!$aAliased && $bAliased) {
  10209. return 1;
  10210. }
  10211. }
  10212. if (!$ignoreReplace) {
  10213. if ($this->replaces($a, $b)) {
  10214. return 1;
  10215. }
  10216. if ($this->replaces($b, $a)) {
  10217. return -1;
  10218. }
  10219. if ($requiredPackage && false !== ($pos = strpos($requiredPackage, '/'))) {
  10220. $requiredVendor = substr($requiredPackage, 0, $pos);
  10221. $aIsSameVendor = strpos($a->getName(), $requiredVendor) === 0;
  10222. $bIsSameVendor = strpos($b->getName(), $requiredVendor) === 0;
  10223. if ($bIsSameVendor !== $aIsSameVendor) {
  10224. return $aIsSameVendor ? -1 : 1;
  10225. }
  10226. }
  10227. }
  10228. if ($a->id === $b->id) {
  10229. return 0;
  10230. }
  10231. return ($a->id < $b->id) ? -1 : 1;
  10232. }
  10233. protected function replaces(BasePackage $source, BasePackage $target): bool
  10234. {
  10235. foreach ($source->getReplaces() as $link) {
  10236. if ($link->getTarget() === $target->getName()
  10237. ) {
  10238. return true;
  10239. }
  10240. }
  10241. return false;
  10242. }
  10243. protected function pruneToBestVersion(Pool $pool, array $literals): array
  10244. {
  10245. $operator = $this->preferLowest ? '<' : '>';
  10246. $bestLiterals = array($literals[0]);
  10247. $bestPackage = $pool->literalToPackage($literals[0]);
  10248. foreach ($literals as $i => $literal) {
  10249. if (0 === $i) {
  10250. continue;
  10251. }
  10252. $package = $pool->literalToPackage($literal);
  10253. if ($this->versionCompare($package, $bestPackage, $operator)) {
  10254. $bestPackage = $package;
  10255. $bestLiterals = array($literal);
  10256. } elseif ($this->versionCompare($package, $bestPackage, '==')) {
  10257. $bestLiterals[] = $literal;
  10258. }
  10259. }
  10260. return $bestLiterals;
  10261. }
  10262. protected function pruneRemoteAliases(Pool $pool, array $literals): array
  10263. {
  10264. $hasLocalAlias = false;
  10265. foreach ($literals as $literal) {
  10266. $package = $pool->literalToPackage($literal);
  10267. if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
  10268. $hasLocalAlias = true;
  10269. break;
  10270. }
  10271. }
  10272. if (!$hasLocalAlias) {
  10273. return $literals;
  10274. }
  10275. $selected = array();
  10276. foreach ($literals as $literal) {
  10277. $package = $pool->literalToPackage($literal);
  10278. if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
  10279. $selected[] = $literal;
  10280. }
  10281. }
  10282. return $selected;
  10283. }
  10284. }
  10285. <?php declare(strict_types=1);
  10286. namespace Composer\DependencyResolver;
  10287. class GenericRule extends Rule
  10288. {
  10289. protected $literals;
  10290. public function __construct(array $literals, $reason, $reasonData)
  10291. {
  10292. parent::__construct($reason, $reasonData);
  10293. sort($literals);
  10294. $this->literals = $literals;
  10295. }
  10296. public function getLiterals(): array
  10297. {
  10298. return $this->literals;
  10299. }
  10300. public function getHash()
  10301. {
  10302. $data = unpack('ihash', md5(implode(',', $this->literals), true));
  10303. return $data['hash'];
  10304. }
  10305. public function equals(Rule $rule): bool
  10306. {
  10307. return $this->literals === $rule->getLiterals();
  10308. }
  10309. public function isAssertion(): bool
  10310. {
  10311. return 1 === \count($this->literals);
  10312. }
  10313. public function __toString(): string
  10314. {
  10315. $result = $this->isDisabled() ? 'disabled(' : '(';
  10316. foreach ($this->literals as $i => $literal) {
  10317. if ($i != 0) {
  10318. $result .= '|';
  10319. }
  10320. $result .= $literal;
  10321. }
  10322. $result .= ')';
  10323. return $result;
  10324. }
  10325. }
  10326. <?php declare(strict_types=1);
  10327. namespace Composer\DependencyResolver;
  10328. use Composer\Repository\InstalledRepositoryInterface;
  10329. use Composer\Repository\RepositoryInterface;
  10330. class LocalRepoTransaction extends Transaction
  10331. {
  10332. public function __construct(RepositoryInterface $lockedRepository, InstalledRepositoryInterface $localRepository)
  10333. {
  10334. parent::__construct(
  10335. $localRepository->getPackages(),
  10336. $lockedRepository->getPackages()
  10337. );
  10338. }
  10339. }
  10340. <?php declare(strict_types=1);
  10341. namespace Composer\DependencyResolver;
  10342. use Composer\Package\AliasPackage;
  10343. use Composer\Package\BasePackage;
  10344. use Composer\Package\Package;
  10345. class LockTransaction extends Transaction
  10346. {
  10347. protected $presentMap;
  10348. protected $unlockableMap;
  10349. protected $resultPackages;
  10350. public function __construct(Pool $pool, array $presentMap, array $unlockableMap, Decisions $decisions)
  10351. {
  10352. $this->presentMap = $presentMap;
  10353. $this->unlockableMap = $unlockableMap;
  10354. $this->setResultPackages($pool, $decisions);
  10355. parent::__construct($this->presentMap, $this->resultPackages['all']);
  10356. }
  10357. public function setResultPackages(Pool $pool, Decisions $decisions): void
  10358. {
  10359. $this->resultPackages = array('all' => array(), 'non-dev' => array(), 'dev' => array());
  10360. foreach ($decisions as $i => $decision) {
  10361. $literal = $decision[Decisions::DECISION_LITERAL];
  10362. if ($literal > 0) {
  10363. $package = $pool->literalToPackage($literal);
  10364. $this->resultPackages['all'][] = $package;
  10365. if (!isset($this->unlockableMap[$package->id])) {
  10366. $this->resultPackages['non-dev'][] = $package;
  10367. }
  10368. }
  10369. }
  10370. }
  10371. public function setNonDevPackages(LockTransaction $extractionResult): void
  10372. {
  10373. $packages = $extractionResult->getNewLockPackages(false);
  10374. $this->resultPackages['dev'] = $this->resultPackages['non-dev'];
  10375. $this->resultPackages['non-dev'] = array();
  10376. foreach ($packages as $package) {
  10377. foreach ($this->resultPackages['dev'] as $i => $resultPackage) {
  10378. if ($package->getName() == $resultPackage->getName()) {
  10379. $this->resultPackages['non-dev'][] = $resultPackage;
  10380. unset($this->resultPackages['dev'][$i]);
  10381. }
  10382. }
  10383. }
  10384. }
  10385. public function getNewLockPackages(bool $devMode, bool $updateMirrors = false): array
  10386. {
  10387. $packages = array();
  10388. foreach ($this->resultPackages[$devMode ? 'dev' : 'non-dev'] as $package) {
  10389. if (!$package instanceof AliasPackage) {
  10390. if ($updateMirrors && !isset($this->presentMap[spl_object_hash($package)])) {
  10391. foreach ($this->presentMap as $presentPackage) {
  10392. if ($package->getName() == $presentPackage->getName() && $package->getVersion() == $presentPackage->getVersion()) {
  10393. if ($presentPackage->getSourceReference() && $presentPackage->getSourceType() === $package->getSourceType()) {
  10394. $package->setSourceDistReferences($presentPackage->getSourceReference());
  10395. }
  10396. if ($presentPackage->getReleaseDate() !== null && $package instanceof Package) {
  10397. $package->setReleaseDate($presentPackage->getReleaseDate());
  10398. }
  10399. }
  10400. }
  10401. }
  10402. $packages[] = $package;
  10403. }
  10404. }
  10405. return $packages;
  10406. }
  10407. public function getAliases(array $aliases): array
  10408. {
  10409. $usedAliases = array();
  10410. foreach ($this->resultPackages['all'] as $package) {
  10411. if ($package instanceof AliasPackage) {
  10412. foreach ($aliases as $index => $alias) {
  10413. if ($alias['package'] === $package->getName()) {
  10414. $usedAliases[] = $alias;
  10415. unset($aliases[$index]);
  10416. }
  10417. }
  10418. }
  10419. }
  10420. usort($usedAliases, function ($a, $b): int {
  10421. return strcmp($a['package'], $b['package']);
  10422. });
  10423. return $usedAliases;
  10424. }
  10425. }
  10426. <?php declare(strict_types=1);
  10427. namespace Composer\DependencyResolver;
  10428. class MultiConflictRule extends Rule
  10429. {
  10430. protected $literals;
  10431. public function __construct(array $literals, $reason, $reasonData)
  10432. {
  10433. parent::__construct($reason, $reasonData);
  10434. if (\count($literals) < 3) {
  10435. throw new \RuntimeException("multi conflict rule requires at least 3 literals");
  10436. }
  10437. sort($literals);
  10438. $this->literals = $literals;
  10439. }
  10440. public function getLiterals(): array
  10441. {
  10442. return $this->literals;
  10443. }
  10444. public function getHash()
  10445. {
  10446. $data = unpack('ihash', md5('c:'.implode(',', $this->literals), true));
  10447. return $data['hash'];
  10448. }
  10449. public function equals(Rule $rule): bool
  10450. {
  10451. if ($rule instanceof MultiConflictRule) {
  10452. return $this->literals === $rule->getLiterals();
  10453. }
  10454. return false;
  10455. }
  10456. public function isAssertion(): bool
  10457. {
  10458. return false;
  10459. }
  10460. public function disable(): void
  10461. {
  10462. throw new \RuntimeException("Disabling multi conflict rules is not possible. Please contact composer at https://github.com/composer/composer to let us debug what lead to this situation.");
  10463. }
  10464. public function __toString(): string
  10465. {
  10466. $result = $this->isDisabled() ? 'disabled(multi(' : '(multi(';
  10467. foreach ($this->literals as $i => $literal) {
  10468. if ($i != 0) {
  10469. $result .= '|';
  10470. }
  10471. $result .= $literal;
  10472. }
  10473. $result .= '))';
  10474. return $result;
  10475. }
  10476. }
  10477. <?php declare(strict_types=1);
  10478. namespace Composer\DependencyResolver\Operation;
  10479. use Composer\Package\PackageInterface;
  10480. class InstallOperation extends SolverOperation implements OperationInterface
  10481. {
  10482. protected const TYPE = 'install';
  10483. protected $package;
  10484. public function __construct(PackageInterface $package)
  10485. {
  10486. $this->package = $package;
  10487. }
  10488. public function getPackage(): PackageInterface
  10489. {
  10490. return $this->package;
  10491. }
  10492. public function show($lock): string
  10493. {
  10494. return self::format($this->package, $lock);
  10495. }
  10496. public static function format(PackageInterface $package, bool $lock = false): string
  10497. {
  10498. return ($lock ? 'Locking ' : 'Installing ').'<info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
  10499. }
  10500. }
  10501. <?php declare(strict_types=1);
  10502. namespace Composer\DependencyResolver\Operation;
  10503. use Composer\Package\AliasPackage;
  10504. class MarkAliasInstalledOperation extends SolverOperation implements OperationInterface
  10505. {
  10506. protected const TYPE = 'markAliasInstalled';
  10507. protected $package;
  10508. public function __construct(AliasPackage $package)
  10509. {
  10510. $this->package = $package;
  10511. }
  10512. public function getPackage(): AliasPackage
  10513. {
  10514. return $this->package;
  10515. }
  10516. public function show($lock): string
  10517. {
  10518. return 'Marking <info>'.$this->package->getPrettyName().'</info> (<comment>'.$this->package->getFullPrettyVersion().'</comment>) as installed, alias of <info>'.$this->package->getAliasOf()->getPrettyName().'</info> (<comment>'.$this->package->getAliasOf()->getFullPrettyVersion().'</comment>)';
  10519. }
  10520. }
  10521. <?php declare(strict_types=1);
  10522. namespace Composer\DependencyResolver\Operation;
  10523. use Composer\Package\AliasPackage;
  10524. class MarkAliasUninstalledOperation extends SolverOperation implements OperationInterface
  10525. {
  10526. protected const TYPE = 'markAliasUninstalled';
  10527. protected $package;
  10528. public function __construct(AliasPackage $package)
  10529. {
  10530. $this->package = $package;
  10531. }
  10532. public function getPackage(): AliasPackage
  10533. {
  10534. return $this->package;
  10535. }
  10536. public function show($lock): string
  10537. {
  10538. return 'Marking <info>'.$this->package->getPrettyName().'</info> (<comment>'.$this->package->getFullPrettyVersion().'</comment>) as uninstalled, alias of <info>'.$this->package->getAliasOf()->getPrettyName().'</info> (<comment>'.$this->package->getAliasOf()->getFullPrettyVersion().'</comment>)';
  10539. }
  10540. }
  10541. <?php declare(strict_types=1);
  10542. namespace Composer\DependencyResolver\Operation;
  10543. interface OperationInterface
  10544. {
  10545. public function getOperationType();
  10546. public function show(bool $lock);
  10547. public function __toString();
  10548. }
  10549. <?php declare(strict_types=1);
  10550. namespace Composer\DependencyResolver\Operation;
  10551. abstract class SolverOperation implements OperationInterface
  10552. {
  10553. protected const TYPE = '';
  10554. public function getOperationType(): string
  10555. {
  10556. return static::TYPE;
  10557. }
  10558. public function __toString()
  10559. {
  10560. return $this->show(false);
  10561. }
  10562. }
  10563. <?php declare(strict_types=1);
  10564. namespace Composer\DependencyResolver\Operation;
  10565. use Composer\Package\PackageInterface;
  10566. class UninstallOperation extends SolverOperation implements OperationInterface
  10567. {
  10568. protected const TYPE = 'uninstall';
  10569. protected $package;
  10570. public function __construct(PackageInterface $package)
  10571. {
  10572. $this->package = $package;
  10573. }
  10574. public function getPackage(): PackageInterface
  10575. {
  10576. return $this->package;
  10577. }
  10578. public function show($lock): string
  10579. {
  10580. return self::format($this->package, $lock);
  10581. }
  10582. public static function format(PackageInterface $package, bool $lock = false): string
  10583. {
  10584. return 'Removing <info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
  10585. }
  10586. }
  10587. <?php declare(strict_types=1);
  10588. namespace Composer\DependencyResolver\Operation;
  10589. use Composer\Package\PackageInterface;
  10590. use Composer\Package\Version\VersionParser;
  10591. class UpdateOperation extends SolverOperation implements OperationInterface
  10592. {
  10593. protected const TYPE = 'update';
  10594. protected $initialPackage;
  10595. protected $targetPackage;
  10596. public function __construct(PackageInterface $initial, PackageInterface $target)
  10597. {
  10598. $this->initialPackage = $initial;
  10599. $this->targetPackage = $target;
  10600. }
  10601. public function getInitialPackage(): PackageInterface
  10602. {
  10603. return $this->initialPackage;
  10604. }
  10605. public function getTargetPackage(): PackageInterface
  10606. {
  10607. return $this->targetPackage;
  10608. }
  10609. public function show($lock): string
  10610. {
  10611. return self::format($this->initialPackage, $this->targetPackage, $lock);
  10612. }
  10613. public static function format(PackageInterface $initialPackage, PackageInterface $targetPackage, bool $lock = false): string
  10614. {
  10615. $fromVersion = $initialPackage->getFullPrettyVersion();
  10616. $toVersion = $targetPackage->getFullPrettyVersion();
  10617. if ($fromVersion === $toVersion && $initialPackage->getSourceReference() !== $targetPackage->getSourceReference()) {
  10618. $fromVersion = $initialPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_SOURCE_REF);
  10619. $toVersion = $targetPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_SOURCE_REF);
  10620. } elseif ($fromVersion === $toVersion && $initialPackage->getDistReference() !== $targetPackage->getDistReference()) {
  10621. $fromVersion = $initialPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_DIST_REF);
  10622. $toVersion = $targetPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_DIST_REF);
  10623. }
  10624. $actionName = VersionParser::isUpgrade($initialPackage->getVersion(), $targetPackage->getVersion()) ? 'Upgrading' : 'Downgrading';
  10625. return $actionName.' <info>'.$initialPackage->getPrettyName().'</info> (<comment>'.$fromVersion.'</comment> => <comment>'.$toVersion.'</comment>)';
  10626. }
  10627. }
  10628. <?php declare(strict_types=1);
  10629. namespace Composer\DependencyResolver;
  10630. use Composer\Package\PackageInterface;
  10631. use Composer\Semver\Constraint\Constraint;
  10632. interface PolicyInterface
  10633. {
  10634. public function versionCompare(PackageInterface $a, PackageInterface $b, string $operator): bool;
  10635. public function selectPreferredPackages(Pool $pool, array $literals, ?string $requiredPackage = null): array;
  10636. }
  10637. <?php declare(strict_types=1);
  10638. namespace Composer\DependencyResolver;
  10639. use Composer\Package\BasePackage;
  10640. use Composer\Package\Version\VersionParser;
  10641. use Composer\Semver\CompilingMatcher;
  10642. use Composer\Semver\Constraint\ConstraintInterface;
  10643. use Composer\Semver\Constraint\Constraint;
  10644. class Pool implements \Countable
  10645. {
  10646. protected $packages = array();
  10647. protected $packageByName = array();
  10648. protected $versionParser;
  10649. protected $providerCache = array();
  10650. protected $unacceptableFixedOrLockedPackages;
  10651. protected $removedVersions = array();
  10652. protected $removedVersionsByPackage = array();
  10653. public function __construct(array $packages = array(), array $unacceptableFixedOrLockedPackages = array(), array $removedVersions = array(), array $removedVersionsByPackage = array())
  10654. {
  10655. $this->versionParser = new VersionParser;
  10656. $this->setPackages($packages);
  10657. $this->unacceptableFixedOrLockedPackages = $unacceptableFixedOrLockedPackages;
  10658. $this->removedVersions = $removedVersions;
  10659. $this->removedVersionsByPackage = $removedVersionsByPackage;
  10660. }
  10661. public function getRemovedVersions(string $name, ConstraintInterface $constraint): array
  10662. {
  10663. if (!isset($this->removedVersions[$name])) {
  10664. return array();
  10665. }
  10666. $result = array();
  10667. foreach ($this->removedVersions[$name] as $version => $prettyVersion) {
  10668. if ($constraint->matches(new Constraint('==', $version))) {
  10669. $result[$version] = $prettyVersion;
  10670. }
  10671. }
  10672. return $result;
  10673. }
  10674. public function getRemovedVersionsByPackage(string $objectHash): array
  10675. {
  10676. if (!isset($this->removedVersionsByPackage[$objectHash])) {
  10677. return array();
  10678. }
  10679. return $this->removedVersionsByPackage[$objectHash];
  10680. }
  10681. private function setPackages(array $packages): void
  10682. {
  10683. $id = 1;
  10684. foreach ($packages as $package) {
  10685. $this->packages[] = $package;
  10686. $package->id = $id++;
  10687. foreach ($package->getNames() as $provided) {
  10688. $this->packageByName[$provided][] = $package;
  10689. }
  10690. }
  10691. }
  10692. public function getPackages(): array
  10693. {
  10694. return $this->packages;
  10695. }
  10696. public function packageById(int $id): BasePackage
  10697. {
  10698. return $this->packages[$id - 1];
  10699. }
  10700. public function count(): int
  10701. {
  10702. return \count($this->packages);
  10703. }
  10704. public function whatProvides(string $name, ConstraintInterface $constraint = null): array
  10705. {
  10706. $key = (string) $constraint;
  10707. if (isset($this->providerCache[$name][$key])) {
  10708. return $this->providerCache[$name][$key];
  10709. }
  10710. return $this->providerCache[$name][$key] = $this->computeWhatProvides($name, $constraint);
  10711. }
  10712. private function computeWhatProvides(string $name, ConstraintInterface $constraint = null): array
  10713. {
  10714. if (!isset($this->packageByName[$name])) {
  10715. return array();
  10716. }
  10717. $matches = array();
  10718. foreach ($this->packageByName[$name] as $candidate) {
  10719. if ($this->match($candidate, $name, $constraint)) {
  10720. $matches[] = $candidate;
  10721. }
  10722. }
  10723. return $matches;
  10724. }
  10725. public function literalToPackage(int $literal): BasePackage
  10726. {
  10727. $packageId = abs($literal);
  10728. return $this->packageById($packageId);
  10729. }
  10730. public function literalToPrettyString(int $literal, array $installedMap): string
  10731. {
  10732. $package = $this->literalToPackage($literal);
  10733. if (isset($installedMap[$package->id])) {
  10734. $prefix = ($literal > 0 ? 'keep' : 'remove');
  10735. } else {
  10736. $prefix = ($literal > 0 ? 'install' : 'don\'t install');
  10737. }
  10738. return $prefix.' '.$package->getPrettyString();
  10739. }
  10740. public function match(BasePackage $candidate, string $name, ConstraintInterface $constraint = null): bool
  10741. {
  10742. $candidateName = $candidate->getName();
  10743. $candidateVersion = $candidate->getVersion();
  10744. if ($candidateName === $name) {
  10745. return $constraint === null || CompilingMatcher::match($constraint, Constraint::OP_EQ, $candidateVersion);
  10746. }
  10747. $provides = $candidate->getProvides();
  10748. $replaces = $candidate->getReplaces();
  10749. if (isset($replaces[0]) || isset($provides[0])) {
  10750. foreach ($provides as $link) {
  10751. if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
  10752. return true;
  10753. }
  10754. }
  10755. foreach ($replaces as $link) {
  10756. if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
  10757. return true;
  10758. }
  10759. }
  10760. return false;
  10761. }
  10762. if (isset($provides[$name]) && ($constraint === null || $constraint->matches($provides[$name]->getConstraint()))) {
  10763. return true;
  10764. }
  10765. if (isset($replaces[$name]) && ($constraint === null || $constraint->matches($replaces[$name]->getConstraint()))) {
  10766. return true;
  10767. }
  10768. return false;
  10769. }
  10770. public function isUnacceptableFixedOrLockedPackage(BasePackage $package): bool
  10771. {
  10772. return \in_array($package, $this->unacceptableFixedOrLockedPackages, true);
  10773. }
  10774. public function getUnacceptableFixedOrLockedPackages(): array
  10775. {
  10776. return $this->unacceptableFixedOrLockedPackages;
  10777. }
  10778. public function __toString(): string
  10779. {
  10780. $str = "Pool:\n";
  10781. foreach ($this->packages as $package) {
  10782. $str .= '- '.str_pad((string) $package->id, 6, ' ', STR_PAD_LEFT).': '.$package->getName()."\n";
  10783. }
  10784. return $str;
  10785. }
  10786. }
  10787. <?php declare(strict_types=1);
  10788. namespace Composer\DependencyResolver;
  10789. use Composer\EventDispatcher\EventDispatcher;
  10790. use Composer\IO\IOInterface;
  10791. use Composer\Package\AliasPackage;
  10792. use Composer\Package\BasePackage;
  10793. use Composer\Package\CompleteAliasPackage;
  10794. use Composer\Package\CompletePackage;
  10795. use Composer\Package\PackageInterface;
  10796. use Composer\Package\Version\StabilityFilter;
  10797. use Composer\Pcre\Preg;
  10798. use Composer\Plugin\PluginEvents;
  10799. use Composer\Plugin\PrePoolCreateEvent;
  10800. use Composer\Repository\PlatformRepository;
  10801. use Composer\Repository\RepositoryInterface;
  10802. use Composer\Repository\RootPackageRepository;
  10803. use Composer\Semver\CompilingMatcher;
  10804. use Composer\Semver\Constraint\Constraint;
  10805. use Composer\Semver\Constraint\ConstraintInterface;
  10806. use Composer\Semver\Constraint\MatchAllConstraint;
  10807. use Composer\Semver\Constraint\MultiConstraint;
  10808. use Composer\Semver\Intervals;
  10809. class PoolBuilder
  10810. {
  10811. private $acceptableStabilities;
  10812. private $stabilityFlags;
  10813. private $rootAliases;
  10814. private $rootReferences;
  10815. private $eventDispatcher;
  10816. private $poolOptimizer;
  10817. private $io;
  10818. private $aliasMap = array();
  10819. private $packagesToLoad = array();
  10820. private $loadedPackages = array();
  10821. private $loadedPerRepo = array();
  10822. private $packages = array();
  10823. private $unacceptableFixedOrLockedPackages = array();
  10824. private $updateAllowList = array();
  10825. private $skippedLoad = array();
  10826. private $pathRepoUnlocked = array();
  10827. private $maxExtendedReqs = array();
  10828. private $updateAllowWarned = array();
  10829. private $indexCounter = 0;
  10830. public function __construct(array $acceptableStabilities, array $stabilityFlags, array $rootAliases, array $rootReferences, IOInterface $io, EventDispatcher $eventDispatcher = null, PoolOptimizer $poolOptimizer = null)
  10831. {
  10832. $this->acceptableStabilities = $acceptableStabilities;
  10833. $this->stabilityFlags = $stabilityFlags;
  10834. $this->rootAliases = $rootAliases;
  10835. $this->rootReferences = $rootReferences;
  10836. $this->eventDispatcher = $eventDispatcher;
  10837. $this->poolOptimizer = $poolOptimizer;
  10838. $this->io = $io;
  10839. }
  10840. public function buildPool(array $repositories, Request $request): Pool
  10841. {
  10842. if ($request->getUpdateAllowList()) {
  10843. $this->updateAllowList = $request->getUpdateAllowList();
  10844. $this->warnAboutNonMatchingUpdateAllowList($request);
  10845. foreach ($request->getLockedRepository()->getPackages() as $lockedPackage) {
  10846. if (!$this->isUpdateAllowed($lockedPackage)) {
  10847. $this->skippedLoad[$lockedPackage->getName()][] = $lockedPackage;
  10848. foreach ($lockedPackage->getReplaces() as $link) {
  10849. $this->skippedLoad[$link->getTarget()][] = $lockedPackage;
  10850. }
  10851. if ($lockedPackage->getDistType() === 'path') {
  10852. $transportOptions = $lockedPackage->getTransportOptions();
  10853. if (!isset($transportOptions['symlink']) || $transportOptions['symlink'] !== false) {
  10854. $this->pathRepoUnlocked[$lockedPackage->getName()] = true;
  10855. continue;
  10856. }
  10857. }
  10858. $request->lockPackage($lockedPackage);
  10859. }
  10860. }
  10861. }
  10862. foreach ($request->getFixedOrLockedPackages() as $package) {
  10863. $this->loadedPackages[$package->getName()] = new MatchAllConstraint();
  10864. foreach ($package->getReplaces() as $link) {
  10865. $this->loadedPackages[$link->getTarget()] = new MatchAllConstraint();
  10866. }
  10867. if (
  10868. $package->getRepository() instanceof RootPackageRepository
  10869. || $package->getRepository() instanceof PlatformRepository
  10870. || StabilityFilter::isPackageAcceptable($this->acceptableStabilities, $this->stabilityFlags, $package->getNames(), $package->getStability())
  10871. ) {
  10872. $this->loadPackage($request, $repositories, $package, false);
  10873. } else {
  10874. $this->unacceptableFixedOrLockedPackages[] = $package;
  10875. }
  10876. }
  10877. foreach ($request->getRequires() as $packageName => $constraint) {
  10878. if (isset($this->loadedPackages[$packageName])) {
  10879. continue;
  10880. }
  10881. $this->packagesToLoad[$packageName] = $constraint;
  10882. $this->maxExtendedReqs[$packageName] = true;
  10883. }
  10884. foreach ($this->packagesToLoad as $name => $constraint) {
  10885. if (isset($this->loadedPackages[$name])) {
  10886. unset($this->packagesToLoad[$name]);
  10887. }
  10888. }
  10889. while (!empty($this->packagesToLoad)) {
  10890. $this->loadPackagesMarkedForLoading($request, $repositories);
  10891. }
  10892. foreach ($this->packages as $i => $package) {
  10893. if (!$package instanceof AliasPackage) {
  10894. $constraint = new Constraint('==', $package->getVersion());
  10895. $aliasedPackages = array($i => $package);
  10896. if (isset($this->aliasMap[spl_object_hash($package)])) {
  10897. $aliasedPackages += $this->aliasMap[spl_object_hash($package)];
  10898. }
  10899. $found = false;
  10900. foreach ($aliasedPackages as $packageOrAlias) {
  10901. if (CompilingMatcher::match($constraint, Constraint::OP_EQ, $packageOrAlias->getVersion())) {
  10902. $found = true;
  10903. }
  10904. }
  10905. if (!$found) {
  10906. foreach ($aliasedPackages as $index => $packageOrAlias) {
  10907. unset($this->packages[$index]);
  10908. }
  10909. }
  10910. }
  10911. }
  10912. if ($this->eventDispatcher) {
  10913. $prePoolCreateEvent = new PrePoolCreateEvent(
  10914. PluginEvents::PRE_POOL_CREATE,
  10915. $repositories,
  10916. $request,
  10917. $this->acceptableStabilities,
  10918. $this->stabilityFlags,
  10919. $this->rootAliases,
  10920. $this->rootReferences,
  10921. $this->packages,
  10922. $this->unacceptableFixedOrLockedPackages
  10923. );
  10924. $this->eventDispatcher->dispatch($prePoolCreateEvent->getName(), $prePoolCreateEvent);
  10925. $this->packages = $prePoolCreateEvent->getPackages();
  10926. $this->unacceptableFixedOrLockedPackages = $prePoolCreateEvent->getUnacceptableFixedPackages();
  10927. }
  10928. $pool = new Pool($this->packages, $this->unacceptableFixedOrLockedPackages);
  10929. $this->aliasMap = array();
  10930. $this->packagesToLoad = array();
  10931. $this->loadedPackages = array();
  10932. $this->loadedPerRepo = array();
  10933. $this->packages = array();
  10934. $this->unacceptableFixedOrLockedPackages = array();
  10935. $this->maxExtendedReqs = array();
  10936. $this->skippedLoad = array();
  10937. $this->indexCounter = 0;
  10938. $this->io->debug('Built pool.');
  10939. $pool = $this->runOptimizer($request, $pool);
  10940. Intervals::clear();
  10941. return $pool;
  10942. }
  10943. private function markPackageNameForLoading(Request $request, string $name, ConstraintInterface $constraint): void
  10944. {
  10945. if (PlatformRepository::isPlatformPackage($name)) {
  10946. return;
  10947. }
  10948. if (isset($this->maxExtendedReqs[$name])) {
  10949. return;
  10950. }
  10951. $rootRequires = $request->getRequires();
  10952. if (isset($rootRequires[$name]) && !Intervals::isSubsetOf($constraint, $rootRequires[$name])) {
  10953. $constraint = $rootRequires[$name];
  10954. }
  10955. if (!isset($this->loadedPackages[$name])) {
  10956. if (isset($this->packagesToLoad[$name])) {
  10957. if (Intervals::isSubsetOf($constraint, $this->packagesToLoad[$name])) {
  10958. return;
  10959. }
  10960. $constraint = Intervals::compactConstraint(MultiConstraint::create(array($this->packagesToLoad[$name], $constraint), false));
  10961. }
  10962. $this->packagesToLoad[$name] = $constraint;
  10963. return;
  10964. }
  10965. if (Intervals::isSubsetOf($constraint, $this->loadedPackages[$name])) {
  10966. return;
  10967. }
  10968. $this->packagesToLoad[$name] = Intervals::compactConstraint(MultiConstraint::create(array($this->loadedPackages[$name], $constraint), false));
  10969. unset($this->loadedPackages[$name]);
  10970. }
  10971. private function loadPackagesMarkedForLoading(Request $request, array $repositories): void
  10972. {
  10973. foreach ($this->packagesToLoad as $name => $constraint) {
  10974. $this->loadedPackages[$name] = $constraint;
  10975. }
  10976. $packageBatch = $this->packagesToLoad;
  10977. $this->packagesToLoad = array();
  10978. foreach ($repositories as $repoIndex => $repository) {
  10979. if (empty($packageBatch)) {
  10980. break;
  10981. }
  10982. if ($repository instanceof PlatformRepository || $repository === $request->getLockedRepository()) {
  10983. continue;
  10984. }
  10985. $result = $repository->loadPackages($packageBatch, $this->acceptableStabilities, $this->stabilityFlags, $this->loadedPerRepo[$repoIndex] ?? array());
  10986. foreach ($result['namesFound'] as $name) {
  10987. unset($packageBatch[$name]);
  10988. }
  10989. foreach ($result['packages'] as $package) {
  10990. $this->loadedPerRepo[$repoIndex][$package->getName()][$package->getVersion()] = $package;
  10991. $this->loadPackage($request, $repositories, $package, !isset($this->pathRepoUnlocked[$package->getName()]));
  10992. }
  10993. }
  10994. }
  10995. private function loadPackage(Request $request, array $repositories, BasePackage $package, bool $propagateUpdate): void
  10996. {
  10997. $index = $this->indexCounter++;
  10998. $this->packages[$index] = $package;
  10999. if ($package instanceof AliasPackage) {
  11000. $this->aliasMap[spl_object_hash($package->getAliasOf())][$index] = $package;
  11001. }
  11002. $name = $package->getName();
  11003. if (isset($this->rootReferences[$name])) {
  11004. if (!$request->isLockedPackage($package) && !$request->isFixedPackage($package)) {
  11005. $package->setSourceDistReferences($this->rootReferences[$name]);
  11006. }
  11007. }
  11008. if ($propagateUpdate && isset($this->rootAliases[$name][$package->getVersion()])) {
  11009. $alias = $this->rootAliases[$name][$package->getVersion()];
  11010. if ($package instanceof AliasPackage) {
  11011. $basePackage = $package->getAliasOf();
  11012. } else {
  11013. $basePackage = $package;
  11014. }
  11015. if ($basePackage instanceof CompletePackage) {
  11016. $aliasPackage = new CompleteAliasPackage($basePackage, $alias['alias_normalized'], $alias['alias']);
  11017. } else {
  11018. $aliasPackage = new AliasPackage($basePackage, $alias['alias_normalized'], $alias['alias']);
  11019. }
  11020. $aliasPackage->setRootPackageAlias(true);
  11021. $newIndex = $this->indexCounter++;
  11022. $this->packages[$newIndex] = $aliasPackage;
  11023. $this->aliasMap[spl_object_hash($aliasPackage->getAliasOf())][$newIndex] = $aliasPackage;
  11024. }
  11025. foreach ($package->getRequires() as $link) {
  11026. $require = $link->getTarget();
  11027. $linkConstraint = $link->getConstraint();
  11028. if (isset($this->skippedLoad[$require])) {
  11029. if ($propagateUpdate && $request->getUpdateAllowTransitiveDependencies()) {
  11030. $skippedRootRequires = $this->getSkippedRootRequires($request, $require);
  11031. if ($request->getUpdateAllowTransitiveRootDependencies() || !$skippedRootRequires) {
  11032. $this->unlockPackage($request, $repositories, $require);
  11033. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  11034. } else {
  11035. foreach ($skippedRootRequires as $rootRequire) {
  11036. if (!isset($this->updateAllowWarned[$rootRequire])) {
  11037. $this->updateAllowWarned[$rootRequire] = true;
  11038. $this->io->writeError('<warning>Dependency '.$rootRequire.' is also a root requirement. Package has not been listed as an update argument, so keeping locked at old version. Use --with-all-dependencies (-W) to include root dependencies.</warning>');
  11039. }
  11040. }
  11041. }
  11042. } elseif (isset($this->pathRepoUnlocked[$require]) && !isset($this->loadedPackages[$require])) {
  11043. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  11044. }
  11045. } else {
  11046. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  11047. }
  11048. }
  11049. if ($propagateUpdate && $request->getUpdateAllowTransitiveDependencies()) {
  11050. foreach ($package->getReplaces() as $link) {
  11051. $replace = $link->getTarget();
  11052. if (isset($this->loadedPackages[$replace], $this->skippedLoad[$replace])) {
  11053. $skippedRootRequires = $this->getSkippedRootRequires($request, $replace);
  11054. if ($request->getUpdateAllowTransitiveRootDependencies() || !$skippedRootRequires) {
  11055. $this->unlockPackage($request, $repositories, $replace);
  11056. $this->markPackageNameForLoading($request, $replace, $link->getConstraint());
  11057. } else {
  11058. foreach ($skippedRootRequires as $rootRequire) {
  11059. if (!isset($this->updateAllowWarned[$rootRequire])) {
  11060. $this->updateAllowWarned[$rootRequire] = true;
  11061. $this->io->writeError('<warning>Dependency '.$rootRequire.' is also a root requirement. Package has not been listed as an update argument, so keeping locked at old version. Use --with-all-dependencies (-W) to include root dependencies.</warning>');
  11062. }
  11063. }
  11064. }
  11065. }
  11066. }
  11067. }
  11068. }
  11069. private function isRootRequire(Request $request, string $name): bool
  11070. {
  11071. $rootRequires = $request->getRequires();
  11072. return isset($rootRequires[$name]);
  11073. }
  11074. private function getSkippedRootRequires(Request $request, string $name): array
  11075. {
  11076. if (!isset($this->skippedLoad[$name])) {
  11077. return array();
  11078. }
  11079. $rootRequires = $request->getRequires();
  11080. $matches = array();
  11081. if (isset($rootRequires[$name])) {
  11082. return array_map(function (PackageInterface $package) use ($name): string {
  11083. if ($name !== $package->getName()) {
  11084. return $package->getName() .' (via replace of '.$name.')';
  11085. }
  11086. return $package->getName();
  11087. }, $this->skippedLoad[$name]);
  11088. }
  11089. foreach ($this->skippedLoad[$name] as $packageOrReplacer) {
  11090. if (isset($rootRequires[$packageOrReplacer->getName()])) {
  11091. $matches[] = $packageOrReplacer->getName();
  11092. }
  11093. foreach ($packageOrReplacer->getReplaces() as $link) {
  11094. if (isset($rootRequires[$link->getTarget()])) {
  11095. if ($name !== $packageOrReplacer->getName()) {
  11096. $matches[] = $packageOrReplacer->getName() .' (via replace of '.$name.')';
  11097. } else {
  11098. $matches[] = $packageOrReplacer->getName();
  11099. }
  11100. break;
  11101. }
  11102. }
  11103. }
  11104. return $matches;
  11105. }
  11106. private function isUpdateAllowed(BasePackage $package): bool
  11107. {
  11108. foreach ($this->updateAllowList as $pattern => $void) {
  11109. $patternRegexp = BasePackage::packageNameToRegexp($pattern);
  11110. if (Preg::isMatch($patternRegexp, $package->getName())) {
  11111. return true;
  11112. }
  11113. }
  11114. return false;
  11115. }
  11116. private function warnAboutNonMatchingUpdateAllowList(Request $request): void
  11117. {
  11118. foreach ($this->updateAllowList as $pattern => $void) {
  11119. $patternRegexp = BasePackage::packageNameToRegexp($pattern);
  11120. foreach ($request->getLockedRepository()->getPackages() as $package) {
  11121. if (Preg::isMatch($patternRegexp, $package->getName())) {
  11122. continue 2;
  11123. }
  11124. }
  11125. foreach ($request->getRequires() as $packageName => $constraint) {
  11126. if (Preg::isMatch($patternRegexp, $packageName)) {
  11127. continue 2;
  11128. }
  11129. }
  11130. if (strpos($pattern, '*') !== false) {
  11131. $this->io->writeError('<warning>Pattern "' . $pattern . '" listed for update does not match any locked packages.</warning>');
  11132. } else {
  11133. $this->io->writeError('<warning>Package "' . $pattern . '" listed for update is not locked.</warning>');
  11134. }
  11135. }
  11136. }
  11137. private function unlockPackage(Request $request, array $repositories, string $name): void
  11138. {
  11139. foreach ($this->skippedLoad[$name] as $packageOrReplacer) {
  11140. if ($packageOrReplacer->getName() !== $name && isset($this->skippedLoad[$packageOrReplacer->getName()])) {
  11141. $replacerName = $packageOrReplacer->getName();
  11142. if ($request->getUpdateAllowTransitiveRootDependencies() || (!$this->isRootRequire($request, $name) && !$this->isRootRequire($request, $replacerName))) {
  11143. $this->unlockPackage($request, $repositories, $replacerName);
  11144. if ($this->isRootRequire($request, $replacerName)) {
  11145. $this->markPackageNameForLoading($request, $replacerName, new MatchAllConstraint);
  11146. } else {
  11147. foreach ($this->packages as $loadedPackage) {
  11148. $requires = $loadedPackage->getRequires();
  11149. if (isset($requires[$replacerName])) {
  11150. $this->markPackageNameForLoading($request, $replacerName, $requires[$replacerName]->getConstraint());
  11151. }
  11152. }
  11153. }
  11154. }
  11155. }
  11156. }
  11157. if (isset($this->pathRepoUnlocked[$name])) {
  11158. foreach ($this->packages as $index => $package) {
  11159. if ($package->getName() === $name) {
  11160. $this->removeLoadedPackage($request, $repositories, $package, $index);
  11161. }
  11162. }
  11163. }
  11164. unset($this->skippedLoad[$name], $this->loadedPackages[$name], $this->maxExtendedReqs[$name], $this->pathRepoUnlocked[$name]);
  11165. foreach ($request->getLockedPackages() as $lockedPackage) {
  11166. if (!($lockedPackage instanceof AliasPackage) && $lockedPackage->getName() === $name) {
  11167. if (false !== $index = array_search($lockedPackage, $this->packages, true)) {
  11168. $request->unlockPackage($lockedPackage);
  11169. $this->removeLoadedPackage($request, $repositories, $lockedPackage, $index);
  11170. foreach ($request->getFixedOrLockedPackages() as $fixedOrLockedPackage) {
  11171. if ($fixedOrLockedPackage === $lockedPackage) {
  11172. continue;
  11173. }
  11174. if (isset($this->skippedLoad[$fixedOrLockedPackage->getName()])) {
  11175. $requires = $fixedOrLockedPackage->getRequires();
  11176. if (isset($requires[$lockedPackage->getName()])) {
  11177. $this->markPackageNameForLoading($request, $lockedPackage->getName(), $requires[$lockedPackage->getName()]->getConstraint());
  11178. }
  11179. }
  11180. }
  11181. }
  11182. }
  11183. }
  11184. }
  11185. private function removeLoadedPackage(Request $request, array $repositories, BasePackage $package, int $index): void
  11186. {
  11187. $repoIndex = array_search($package->getRepository(), $repositories, true);
  11188. unset($this->loadedPerRepo[$repoIndex][$package->getName()][$package->getVersion()]);
  11189. unset($this->packages[$index]);
  11190. if (isset($this->aliasMap[spl_object_hash($package)])) {
  11191. foreach ($this->aliasMap[spl_object_hash($package)] as $aliasIndex => $aliasPackage) {
  11192. unset($this->loadedPerRepo[$repoIndex][$aliasPackage->getName()][$aliasPackage->getVersion()]);
  11193. unset($this->packages[$aliasIndex]);
  11194. }
  11195. unset($this->aliasMap[spl_object_hash($package)]);
  11196. }
  11197. }
  11198. private function runOptimizer(Request $request, Pool $pool): Pool
  11199. {
  11200. if (null === $this->poolOptimizer) {
  11201. return $pool;
  11202. }
  11203. $this->io->debug('Running pool optimizer.');
  11204. $before = microtime(true);
  11205. $total = \count($pool->getPackages());
  11206. $pool = $this->poolOptimizer->optimize($request, $pool);
  11207. $filtered = $total - \count($pool->getPackages());
  11208. if (0 === $filtered) {
  11209. return $pool;
  11210. }
  11211. $this->io->write(sprintf('Pool optimizer completed in %.3f seconds', microtime(true) - $before), true, IOInterface::VERY_VERBOSE);
  11212. $this->io->write(sprintf(
  11213. '<info>Found %s package versions referenced in your dependency graph. %s (%d%%) were optimized away.</info>',
  11214. number_format($total),
  11215. number_format($filtered),
  11216. round(100 / $total * $filtered)
  11217. ), true, IOInterface::VERY_VERBOSE);
  11218. return $pool;
  11219. }
  11220. }
  11221. <?php declare(strict_types=1);
  11222. namespace Composer\DependencyResolver;
  11223. use Composer\Package\AliasPackage;
  11224. use Composer\Package\BasePackage;
  11225. use Composer\Package\Version\VersionParser;
  11226. use Composer\Semver\CompilingMatcher;
  11227. use Composer\Semver\Constraint\ConstraintInterface;
  11228. use Composer\Semver\Constraint\Constraint;
  11229. use Composer\Semver\Constraint\MultiConstraint;
  11230. use Composer\Semver\Intervals;
  11231. class PoolOptimizer
  11232. {
  11233. private $policy;
  11234. private $irremovablePackages = array();
  11235. private $requireConstraintsPerPackage = array();
  11236. private $conflictConstraintsPerPackage = array();
  11237. private $packagesToRemove = array();
  11238. private $aliasesPerPackage = array();
  11239. private $removedVersionsByPackage = array();
  11240. public function __construct(PolicyInterface $policy)
  11241. {
  11242. $this->policy = $policy;
  11243. }
  11244. public function optimize(Request $request, Pool $pool): Pool
  11245. {
  11246. $this->prepare($request, $pool);
  11247. $this->optimizeByIdenticalDependencies($request, $pool);
  11248. $this->optimizeImpossiblePackagesAway($request, $pool);
  11249. $optimizedPool = $this->applyRemovalsToPool($pool);
  11250. $this->irremovablePackages = array();
  11251. $this->requireConstraintsPerPackage = array();
  11252. $this->conflictConstraintsPerPackage = array();
  11253. $this->packagesToRemove = array();
  11254. $this->aliasesPerPackage = array();
  11255. $this->removedVersionsByPackage = array();
  11256. return $optimizedPool;
  11257. }
  11258. private function prepare(Request $request, Pool $pool): void
  11259. {
  11260. $irremovablePackageConstraintGroups = array();
  11261. foreach ($request->getFixedOrLockedPackages() as $package) {
  11262. $irremovablePackageConstraintGroups[$package->getName()][] = new Constraint('==', $package->getVersion());
  11263. }
  11264. foreach ($request->getRequires() as $require => $constraint) {
  11265. $this->extractRequireConstraintsPerPackage($require, $constraint);
  11266. }
  11267. foreach ($pool->getPackages() as $package) {
  11268. foreach ($package->getRequires() as $link) {
  11269. $this->extractRequireConstraintsPerPackage($link->getTarget(), $link->getConstraint());
  11270. }
  11271. foreach ($package->getConflicts() as $link) {
  11272. $this->extractConflictConstraintsPerPackage($link->getTarget(), $link->getConstraint());
  11273. }
  11274. if ($package instanceof AliasPackage) {
  11275. $this->aliasesPerPackage[$package->getAliasOf()->id][] = $package;
  11276. }
  11277. }
  11278. $irremovablePackageConstraints = array();
  11279. foreach ($irremovablePackageConstraintGroups as $packageName => $constraints) {
  11280. $irremovablePackageConstraints[$packageName] = 1 === \count($constraints) ? $constraints[0] : new MultiConstraint($constraints, false);
  11281. }
  11282. unset($irremovablePackageConstraintGroups);
  11283. foreach ($pool->getPackages() as $package) {
  11284. if (!isset($irremovablePackageConstraints[$package->getName()])) {
  11285. continue;
  11286. }
  11287. if (CompilingMatcher::match($irremovablePackageConstraints[$package->getName()], Constraint::OP_EQ, $package->getVersion())) {
  11288. $this->markPackageIrremovable($package);
  11289. }
  11290. }
  11291. }
  11292. private function markPackageIrremovable(BasePackage $package): void
  11293. {
  11294. $this->irremovablePackages[$package->id] = true;
  11295. if ($package instanceof AliasPackage) {
  11296. $this->markPackageIrremovable($package->getAliasOf());
  11297. }
  11298. if (isset($this->aliasesPerPackage[$package->id])) {
  11299. foreach ($this->aliasesPerPackage[$package->id] as $aliasPackage) {
  11300. $this->irremovablePackages[$aliasPackage->id] = true;
  11301. }
  11302. }
  11303. }
  11304. private function applyRemovalsToPool(Pool $pool): Pool
  11305. {
  11306. $packages = array();
  11307. $removedVersions = array();
  11308. foreach ($pool->getPackages() as $package) {
  11309. if (!isset($this->packagesToRemove[$package->id])) {
  11310. $packages[] = $package;
  11311. } else {
  11312. $removedVersions[$package->getName()][$package->getVersion()] = $package->getPrettyVersion();
  11313. }
  11314. }
  11315. $optimizedPool = new Pool($packages, $pool->getUnacceptableFixedOrLockedPackages(), $removedVersions, $this->removedVersionsByPackage);
  11316. return $optimizedPool;
  11317. }
  11318. private function optimizeByIdenticalDependencies(Request $request, Pool $pool): void
  11319. {
  11320. $identicalDefinitionsPerPackage = array();
  11321. $packageIdenticalDefinitionLookup = array();
  11322. foreach ($pool->getPackages() as $package) {
  11323. if (isset($this->irremovablePackages[$package->id])) {
  11324. continue;
  11325. }
  11326. $this->markPackageForRemoval($package->id);
  11327. $dependencyHash = $this->calculateDependencyHash($package);
  11328. foreach ($package->getNames(false) as $packageName) {
  11329. if (!isset($this->requireConstraintsPerPackage[$packageName])) {
  11330. continue;
  11331. }
  11332. foreach ($this->requireConstraintsPerPackage[$packageName] as $requireConstraint) {
  11333. $groupHashParts = array();
  11334. if (CompilingMatcher::match($requireConstraint, Constraint::OP_EQ, $package->getVersion())) {
  11335. $groupHashParts[] = 'require:' . (string) $requireConstraint;
  11336. }
  11337. if ($package->getReplaces()) {
  11338. foreach ($package->getReplaces() as $link) {
  11339. if (CompilingMatcher::match($link->getConstraint(), Constraint::OP_EQ, $package->getVersion())) {
  11340. $groupHashParts[] = 'require:' . (string) $link->getConstraint();
  11341. }
  11342. }
  11343. }
  11344. if (isset($this->conflictConstraintsPerPackage[$packageName])) {
  11345. foreach ($this->conflictConstraintsPerPackage[$packageName] as $conflictConstraint) {
  11346. if (CompilingMatcher::match($conflictConstraint, Constraint::OP_EQ, $package->getVersion())) {
  11347. $groupHashParts[] = 'conflict:' . (string) $conflictConstraint;
  11348. }
  11349. }
  11350. }
  11351. if (!$groupHashParts) {
  11352. continue;
  11353. }
  11354. $groupHash = implode('', $groupHashParts);
  11355. $identicalDefinitionsPerPackage[$packageName][$groupHash][$dependencyHash][] = $package;
  11356. $packageIdenticalDefinitionLookup[$package->id][$packageName] = array('groupHash' => $groupHash, 'dependencyHash' => $dependencyHash);
  11357. }
  11358. }
  11359. }
  11360. foreach ($identicalDefinitionsPerPackage as $constraintGroups) {
  11361. foreach ($constraintGroups as $constraintGroup) {
  11362. foreach ($constraintGroup as $packages) {
  11363. if (1 === \count($packages)) {
  11364. $this->keepPackage($packages[0], $identicalDefinitionsPerPackage, $packageIdenticalDefinitionLookup);
  11365. continue;
  11366. }
  11367. $literals = array();
  11368. foreach ($packages as $package) {
  11369. $literals[] = $package->id;
  11370. }
  11371. foreach ($this->policy->selectPreferredPackages($pool, $literals) as $preferredLiteral) {
  11372. $this->keepPackage($pool->literalToPackage($preferredLiteral), $identicalDefinitionsPerPackage, $packageIdenticalDefinitionLookup);
  11373. }
  11374. }
  11375. }
  11376. }
  11377. }
  11378. private function calculateDependencyHash(BasePackage $package): string
  11379. {
  11380. $hash = '';
  11381. $hashRelevantLinks = array(
  11382. 'requires' => $package->getRequires(),
  11383. 'conflicts' => $package->getConflicts(),
  11384. 'replaces' => $package->getReplaces(),
  11385. 'provides' => $package->getProvides(),
  11386. );
  11387. foreach ($hashRelevantLinks as $key => $links) {
  11388. if (0 === \count($links)) {
  11389. continue;
  11390. }
  11391. $hash .= $key . ':';
  11392. $subhash = array();
  11393. foreach ($links as $link) {
  11394. $subhash[$link->getTarget()] = (string) $link->getConstraint();
  11395. }
  11396. ksort($subhash);
  11397. foreach ($subhash as $target => $constraint) {
  11398. $hash .= $target . '@' . $constraint;
  11399. }
  11400. }
  11401. return $hash;
  11402. }
  11403. private function markPackageForRemoval(int $id): void
  11404. {
  11405. if (isset($this->irremovablePackages[$id])) {
  11406. throw new \LogicException('Attempted removing a package which was previously marked irremovable');
  11407. }
  11408. $this->packagesToRemove[$id] = true;
  11409. }
  11410. private function keepPackage(BasePackage $package, array $identicalDefinitionsPerPackage, array $packageIdenticalDefinitionLookup): void
  11411. {
  11412. if (!isset($this->packagesToRemove[$package->id])) {
  11413. return;
  11414. }
  11415. unset($this->packagesToRemove[$package->id]);
  11416. if ($package instanceof AliasPackage) {
  11417. $this->keepPackage($package->getAliasOf(), $identicalDefinitionsPerPackage, $packageIdenticalDefinitionLookup);
  11418. }
  11419. foreach ($package->getNames(false) as $name) {
  11420. if (isset($packageIdenticalDefinitionLookup[$package->id][$name])) {
  11421. $packageGroupPointers = $packageIdenticalDefinitionLookup[$package->id][$name];
  11422. $packageGroup = $identicalDefinitionsPerPackage[$name][$packageGroupPointers['groupHash']][$packageGroupPointers['dependencyHash']];
  11423. foreach ($packageGroup as $pkg) {
  11424. if ($pkg instanceof AliasPackage && $pkg->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  11425. $pkg = $pkg->getAliasOf();
  11426. }
  11427. $this->removedVersionsByPackage[spl_object_hash($package)][$pkg->getVersion()] = $pkg->getPrettyVersion();
  11428. }
  11429. }
  11430. }
  11431. if (isset($this->aliasesPerPackage[$package->id])) {
  11432. foreach ($this->aliasesPerPackage[$package->id] as $aliasPackage) {
  11433. unset($this->packagesToRemove[$aliasPackage->id]);
  11434. foreach ($aliasPackage->getNames(false) as $name) {
  11435. if (isset($packageIdenticalDefinitionLookup[$aliasPackage->id][$name])) {
  11436. $packageGroupPointers = $packageIdenticalDefinitionLookup[$aliasPackage->id][$name];
  11437. $packageGroup = $identicalDefinitionsPerPackage[$name][$packageGroupPointers['groupHash']][$packageGroupPointers['dependencyHash']];
  11438. foreach ($packageGroup as $pkg) {
  11439. if ($pkg instanceof AliasPackage && $pkg->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  11440. $pkg = $pkg->getAliasOf();
  11441. }
  11442. $this->removedVersionsByPackage[spl_object_hash($aliasPackage)][$pkg->getVersion()] = $pkg->getPrettyVersion();
  11443. }
  11444. }
  11445. }
  11446. }
  11447. }
  11448. }
  11449. private function optimizeImpossiblePackagesAway(Request $request, Pool $pool): void
  11450. {
  11451. if (count($request->getLockedPackages()) === 0) {
  11452. return;
  11453. }
  11454. $packageIndex = array();
  11455. foreach ($pool->getPackages() as $package) {
  11456. $id = $package->id;
  11457. if (isset($this->irremovablePackages[$id])) {
  11458. continue;
  11459. }
  11460. if (isset($this->aliasesPerPackage[$id]) || $package instanceof AliasPackage) {
  11461. continue;
  11462. }
  11463. if ($request->isFixedPackage($package) || $request->isLockedPackage($package)) {
  11464. continue;
  11465. }
  11466. $packageIndex[$package->getName()][$package->id] = $package;
  11467. }
  11468. foreach ($request->getLockedPackages() as $package) {
  11469. $isUnusedPackage = true;
  11470. foreach ($package->getNames(false) as $packageName) {
  11471. if (isset($this->requireConstraintsPerPackage[$packageName])) {
  11472. $isUnusedPackage = false;
  11473. break;
  11474. }
  11475. }
  11476. if ($isUnusedPackage) {
  11477. continue;
  11478. }
  11479. foreach ($package->getRequires() as $link) {
  11480. $require = $link->getTarget();
  11481. if (!isset($packageIndex[$require])) {
  11482. continue;
  11483. }
  11484. $linkConstraint = $link->getConstraint();
  11485. foreach ($packageIndex[$require] as $id => $requiredPkg) {
  11486. if (false === CompilingMatcher::match($linkConstraint, Constraint::OP_EQ, $requiredPkg->getVersion())) {
  11487. $this->markPackageForRemoval($id);
  11488. unset($packageIndex[$require][$id]);
  11489. }
  11490. }
  11491. }
  11492. }
  11493. }
  11494. private function extractRequireConstraintsPerPackage($package, ConstraintInterface $constraint)
  11495. {
  11496. foreach ($this->expandDisjunctiveMultiConstraints($constraint) as $expanded) {
  11497. $this->requireConstraintsPerPackage[$package][(string) $expanded] = $expanded;
  11498. }
  11499. }
  11500. private function extractConflictConstraintsPerPackage($package, ConstraintInterface $constraint)
  11501. {
  11502. foreach ($this->expandDisjunctiveMultiConstraints($constraint) as $expanded) {
  11503. $this->conflictConstraintsPerPackage[$package][(string) $expanded] = $expanded;
  11504. }
  11505. }
  11506. private function expandDisjunctiveMultiConstraints(ConstraintInterface $constraint)
  11507. {
  11508. $constraint = Intervals::compactConstraint($constraint);
  11509. if ($constraint instanceof MultiConstraint && $constraint->isDisjunctive()) {
  11510. return $constraint->getConstraints();
  11511. }
  11512. return array($constraint);
  11513. }
  11514. }
  11515. <?php declare(strict_types=1);
  11516. namespace Composer\DependencyResolver;
  11517. use Composer\Package\CompletePackageInterface;
  11518. use Composer\Package\AliasPackage;
  11519. use Composer\Package\BasePackage;
  11520. use Composer\Package\Link;
  11521. use Composer\Package\PackageInterface;
  11522. use Composer\Package\RootPackageInterface;
  11523. use Composer\Pcre\Preg;
  11524. use Composer\Repository\RepositorySet;
  11525. use Composer\Repository\LockArrayRepository;
  11526. use Composer\Semver\Constraint\Constraint;
  11527. use Composer\Semver\Constraint\ConstraintInterface;
  11528. use Composer\Package\Version\VersionParser;
  11529. use Composer\Repository\PlatformRepository;
  11530. class Problem
  11531. {
  11532. protected $reasonSeen;
  11533. protected $reasons = array();
  11534. protected $section = 0;
  11535. public function addRule(Rule $rule): void
  11536. {
  11537. $this->addReason(spl_object_hash($rule), $rule);
  11538. }
  11539. public function getReasons(): array
  11540. {
  11541. return $this->reasons;
  11542. }
  11543. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, bool $isVerbose, array $installedMap = array(), array $learnedPool = array()): string
  11544. {
  11545. $reasons = call_user_func_array('array_merge', array_reverse($this->reasons));
  11546. if (count($reasons) === 1) {
  11547. reset($reasons);
  11548. $rule = current($reasons);
  11549. if (!in_array($rule->getReason(), array(Rule::RULE_ROOT_REQUIRE, Rule::RULE_FIXED), true)) {
  11550. throw new \LogicException("Single reason problems must contain a request rule.");
  11551. }
  11552. $reasonData = $rule->getReasonData();
  11553. $packageName = $reasonData['packageName'];
  11554. $constraint = $reasonData['constraint'];
  11555. if (isset($constraint)) {
  11556. $packages = $pool->whatProvides($packageName, $constraint);
  11557. } else {
  11558. $packages = array();
  11559. }
  11560. if (empty($packages)) {
  11561. return "\n ".implode(self::getMissingPackageReason($repositorySet, $request, $pool, $isVerbose, $packageName, $constraint));
  11562. }
  11563. }
  11564. return self::formatDeduplicatedRules($reasons, ' ', $repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool);
  11565. }
  11566. public static function formatDeduplicatedRules(array $rules, string $indent, RepositorySet $repositorySet, Request $request, Pool $pool, bool $isVerbose, array $installedMap = array(), array $learnedPool = array()): string
  11567. {
  11568. $messages = array();
  11569. $templates = array();
  11570. $parser = new VersionParser;
  11571. $deduplicatableRuleTypes = array(Rule::RULE_PACKAGE_REQUIRES, Rule::RULE_PACKAGE_CONFLICT);
  11572. foreach ($rules as $rule) {
  11573. $message = $rule->getPrettyString($repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool);
  11574. if (in_array($rule->getReason(), $deduplicatableRuleTypes, true) && Preg::isMatch('{^(?P<package>\S+) (?P<version>\S+) (?P<type>requires|conflicts)}', $message, $m)) {
  11575. $template = Preg::replace('{^\S+ \S+ }', '%s%s ', $message);
  11576. $messages[] = $template;
  11577. $templates[$template][$m[1]][$parser->normalize($m[2])] = $m[2];
  11578. $sourcePackage = $rule->getSourcePackage($pool);
  11579. foreach ($pool->getRemovedVersionsByPackage(spl_object_hash($sourcePackage)) as $version => $prettyVersion) {
  11580. $templates[$template][$m[1]][$version] = $prettyVersion;
  11581. }
  11582. } elseif ($message !== '') {
  11583. $messages[] = $message;
  11584. }
  11585. }
  11586. $result = array();
  11587. foreach (array_unique($messages) as $message) {
  11588. if (isset($templates[$message])) {
  11589. foreach ($templates[$message] as $package => $versions) {
  11590. uksort($versions, 'version_compare');
  11591. if (!$isVerbose) {
  11592. $versions = self::condenseVersionList($versions, 1);
  11593. }
  11594. if (count($versions) > 1) {
  11595. $message = Preg::replace('{^(%s%s (?:require|conflict))s}', '$1', $message);
  11596. $result[] = sprintf($message, $package, '['.implode(', ', $versions).']');
  11597. } else {
  11598. $result[] = sprintf($message, $package, ' '.reset($versions));
  11599. }
  11600. }
  11601. } else {
  11602. $result[] = $message;
  11603. }
  11604. }
  11605. return "\n$indent- ".implode("\n$indent- ", $result);
  11606. }
  11607. public function isCausedByLock(RepositorySet $repositorySet, Request $request, Pool $pool): bool
  11608. {
  11609. foreach ($this->reasons as $sectionRules) {
  11610. foreach ($sectionRules as $rule) {
  11611. if ($rule->isCausedByLock($repositorySet, $request, $pool)) {
  11612. return true;
  11613. }
  11614. }
  11615. }
  11616. return false;
  11617. }
  11618. protected function addReason(string $id, Rule $reason): void
  11619. {
  11620. if (!isset($this->reasonSeen[$id])) {
  11621. $this->reasonSeen[$id] = true;
  11622. $this->reasons[$this->section][] = $reason;
  11623. }
  11624. }
  11625. public function nextSection(): void
  11626. {
  11627. $this->section++;
  11628. }
  11629. public static function getMissingPackageReason(RepositorySet $repositorySet, Request $request, Pool $pool, bool $isVerbose, string $packageName, ConstraintInterface $constraint = null): array
  11630. {
  11631. if (PlatformRepository::isPlatformPackage($packageName)) {
  11632. if (0 === stripos($packageName, 'php') || $packageName === 'hhvm') {
  11633. $version = self::getPlatformPackageVersion($pool, $packageName, phpversion());
  11634. $msg = "- Root composer.json requires ".$packageName.self::constraintToText($constraint).' but ';
  11635. if (defined('HHVM_VERSION') || ($packageName === 'hhvm' && count($pool->whatProvides($packageName)) > 0)) {
  11636. return array($msg, 'your HHVM version does not satisfy that requirement.');
  11637. }
  11638. if ($packageName === 'hhvm') {
  11639. return array($msg, 'HHVM was not detected on this machine, make sure it is in your PATH.');
  11640. }
  11641. if (null === $version) {
  11642. return array($msg, 'the '.$packageName.' package is disabled by your platform config. Enable it again with "composer config platform.'.$packageName.' --unset".');
  11643. }
  11644. return array($msg, 'your '.$packageName.' version ('. $version .') does not satisfy that requirement.');
  11645. }
  11646. if (0 === stripos($packageName, 'ext-')) {
  11647. if (false !== strpos($packageName, ' ')) {
  11648. return array('- ', "PHP extension ".$packageName.' should be required as '.str_replace(' ', '-', $packageName).'.');
  11649. }
  11650. $ext = substr($packageName, 4);
  11651. $msg = "- Root composer.json requires PHP extension ".$packageName.self::constraintToText($constraint).' but ';
  11652. $version = self::getPlatformPackageVersion($pool, $packageName, phpversion($ext) ?: '0');
  11653. if (null === $version) {
  11654. if (extension_loaded($ext)) {
  11655. return array(
  11656. $msg,
  11657. 'the '.$packageName.' package is disabled by your platform config. Enable it again with "composer config platform.'.$packageName.' --unset".',
  11658. );
  11659. }
  11660. return array($msg, 'it is missing from your system. Install or enable PHP\'s '.$ext.' extension.');
  11661. }
  11662. return array($msg, 'it has the wrong version installed ('.$version.').');
  11663. }
  11664. if (0 === stripos($packageName, 'lib-')) {
  11665. if (strtolower($packageName) === 'lib-icu') {
  11666. $error = extension_loaded('intl') ? 'it has the wrong version installed, try upgrading the intl extension.' : 'it is missing from your system, make sure the intl extension is loaded.';
  11667. return array("- Root composer.json requires linked library ".$packageName.self::constraintToText($constraint).' but ', $error);
  11668. }
  11669. return array("- Root composer.json requires linked library ".$packageName.self::constraintToText($constraint).' but ', 'it has the wrong version installed or is missing from your system, make sure to load the extension providing it.');
  11670. }
  11671. }
  11672. $lockedPackage = null;
  11673. foreach ($request->getLockedPackages() as $package) {
  11674. if ($package->getName() === $packageName) {
  11675. $lockedPackage = $package;
  11676. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  11677. return array("- ", $package->getPrettyName().' is fixed to '.$package->getPrettyVersion().' (lock file version) by a partial update but that version is rejected by your minimum-stability. Make sure you list it as an argument for the update command.');
  11678. }
  11679. break;
  11680. }
  11681. }
  11682. if ($packages = $repositorySet->findPackages($packageName, $constraint)) {
  11683. $rootReqs = $repositorySet->getRootRequires();
  11684. if (isset($rootReqs[$packageName])) {
  11685. $filtered = array_filter($packages, function ($p) use ($rootReqs, $packageName): bool {
  11686. return $rootReqs[$packageName]->matches(new Constraint('==', $p->getVersion()));
  11687. });
  11688. if (0 === count($filtered)) {
  11689. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose, $pool, $constraint).' but '.(self::hasMultipleNames($packages) ? 'these conflict' : 'it conflicts').' with your root composer.json require ('.$rootReqs[$packageName]->getPrettyString().').');
  11690. }
  11691. }
  11692. if ($lockedPackage) {
  11693. $fixedConstraint = new Constraint('==', $lockedPackage->getVersion());
  11694. $filtered = array_filter($packages, function ($p) use ($fixedConstraint): bool {
  11695. return $fixedConstraint->matches(new Constraint('==', $p->getVersion()));
  11696. });
  11697. if (0 === count($filtered)) {
  11698. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose, $pool, $constraint).' but the package is fixed to '.$lockedPackage->getPrettyVersion().' (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.');
  11699. }
  11700. }
  11701. $nonLockedPackages = array_filter($packages, function ($p): bool {
  11702. return !$p->getRepository() instanceof LockArrayRepository;
  11703. });
  11704. if (!$nonLockedPackages) {
  11705. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose, $pool, $constraint).' in the lock file but not in remote repositories, make sure you avoid updating this package to keep the one from the lock file.');
  11706. }
  11707. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose, $pool, $constraint).' but these were not loaded, likely because '.(self::hasMultipleNames($packages) ? 'they conflict' : 'it conflicts').' with another require.');
  11708. }
  11709. if ($packages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES)) {
  11710. if ($allReposPackages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  11711. return self::computeCheckForLowerPrioRepo($pool, $isVerbose, $packageName, $packages, $allReposPackages, 'minimum-stability', $constraint);
  11712. }
  11713. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose, $pool, $constraint).' but '.(self::hasMultipleNames($packages) ? 'these do' : 'it does').' not match your minimum-stability.');
  11714. }
  11715. if ($packages = $repositorySet->findPackages($packageName, null, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES)) {
  11716. if ($allReposPackages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  11717. return self::computeCheckForLowerPrioRepo($pool, $isVerbose, $packageName, $packages, $allReposPackages, 'constraint', $constraint);
  11718. }
  11719. $suffix = '';
  11720. if ($constraint instanceof Constraint && $constraint->getVersion() === 'dev-master') {
  11721. foreach ($packages as $candidate) {
  11722. if (in_array($candidate->getVersion(), array('dev-default', 'dev-main'), true)) {
  11723. $suffix = ' Perhaps dev-master was renamed to '.$candidate->getPrettyVersion().'?';
  11724. break;
  11725. }
  11726. }
  11727. }
  11728. $allReposPackages = $packages;
  11729. $topPackage = reset($allReposPackages);
  11730. if ($topPackage instanceof RootPackageInterface) {
  11731. $suffix = ' See https://getcomposer.org/dep-on-root for details and assistance.';
  11732. }
  11733. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose, $pool, $constraint).' but '.(self::hasMultipleNames($packages) ? 'these do' : 'it does').' not match the constraint.' . $suffix);
  11734. }
  11735. if (!Preg::isMatch('{^[A-Za-z0-9_./-]+$}', $packageName)) {
  11736. $illegalChars = Preg::replace('{[A-Za-z0-9_./-]+}', '', $packageName);
  11737. return array("- Root composer.json requires $packageName, it ", 'could not be found, it looks like its name is invalid, "'.$illegalChars.'" is not allowed in package names.');
  11738. }
  11739. if ($providers = $repositorySet->getProviders($packageName)) {
  11740. $maxProviders = 20;
  11741. $providersStr = implode(array_map(function ($p): string {
  11742. $description = $p['description'] ? ' '.substr($p['description'], 0, 100) : '';
  11743. return " - ${p['name']}".$description."\n";
  11744. }, count($providers) > $maxProviders + 1 ? array_slice($providers, 0, $maxProviders) : $providers));
  11745. if (count($providers) > $maxProviders + 1) {
  11746. $providersStr .= ' ... and '.(count($providers) - $maxProviders).' more.'."\n";
  11747. }
  11748. return array("- Root composer.json requires $packageName".self::constraintToText($constraint).", it ", "could not be found in any version, but the following packages provide it:\n".$providersStr." Consider requiring one of these to satisfy the $packageName requirement.");
  11749. }
  11750. return array("- Root composer.json requires $packageName, it ", "could not be found in any version, there may be a typo in the package name.");
  11751. }
  11752. public static function getPackageList(array $packages, bool $isVerbose, Pool $pool = null, ConstraintInterface $constraint = null, bool $useRemovedVersionGroup = false): string
  11753. {
  11754. $prepared = array();
  11755. $hasDefaultBranch = array();
  11756. foreach ($packages as $package) {
  11757. $prepared[$package->getName()]['name'] = $package->getPrettyName();
  11758. $prepared[$package->getName()]['versions'][$package->getVersion()] = $package->getPrettyVersion().($package instanceof AliasPackage ? ' (alias of '.$package->getAliasOf()->getPrettyVersion().')' : '');
  11759. if ($pool && $constraint) {
  11760. foreach ($pool->getRemovedVersions($package->getName(), $constraint) as $version => $prettyVersion) {
  11761. $prepared[$package->getName()]['versions'][$version] = $prettyVersion;
  11762. }
  11763. }
  11764. if ($pool && $useRemovedVersionGroup) {
  11765. foreach ($pool->getRemovedVersionsByPackage(spl_object_hash($package)) as $version => $prettyVersion) {
  11766. $prepared[$package->getName()]['versions'][$version] = $prettyVersion;
  11767. }
  11768. }
  11769. if ($package->isDefaultBranch()) {
  11770. $hasDefaultBranch[$package->getName()] = true;
  11771. }
  11772. }
  11773. $preparedStrings = array();
  11774. foreach ($prepared as $name => $package) {
  11775. if (isset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS], $hasDefaultBranch[$name])) {
  11776. unset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS]);
  11777. }
  11778. uksort($package['versions'], 'version_compare');
  11779. if (!$isVerbose) {
  11780. $package['versions'] = self::condenseVersionList($package['versions'], 4);
  11781. }
  11782. $preparedStrings[] = $package['name'].'['.implode(', ', $package['versions']).']';
  11783. }
  11784. return implode(', ', $preparedStrings);
  11785. }
  11786. private static function getPlatformPackageVersion(Pool $pool, string $packageName, string $version): ?string
  11787. {
  11788. $available = $pool->whatProvides($packageName);
  11789. if (count($available)) {
  11790. $selected = null;
  11791. foreach ($available as $pkg) {
  11792. if ($pkg->getRepository() instanceof PlatformRepository) {
  11793. $selected = $pkg;
  11794. break;
  11795. }
  11796. }
  11797. if ($selected === null) {
  11798. $selected = reset($available);
  11799. }
  11800. if ($selected->getName() !== $packageName) {
  11801. foreach (array_merge(array_values($selected->getProvides()), array_values($selected->getReplaces())) as $link) {
  11802. if ($link->getTarget() === $packageName) {
  11803. return $link->getPrettyConstraint().' '.substr($link->getDescription(), 0, -1).'d by '.$selected->getPrettyString();
  11804. }
  11805. }
  11806. }
  11807. $version = $selected->getPrettyVersion();
  11808. $extra = $selected->getExtra();
  11809. if ($selected instanceof CompletePackageInterface && isset($extra['config.platform']) && $extra['config.platform'] === true) {
  11810. $version .= '; ' . str_replace('Package ', '', $selected->getDescription());
  11811. }
  11812. } else {
  11813. return null;
  11814. }
  11815. return $version;
  11816. }
  11817. private static function condenseVersionList(array $versions, int $max, int $maxDev = 16): array
  11818. {
  11819. if (count($versions) <= $max) {
  11820. return $versions;
  11821. }
  11822. $filtered = array();
  11823. $byMajor = array();
  11824. foreach ($versions as $version => $pretty) {
  11825. if (0 === stripos($version, 'dev-')) {
  11826. $byMajor['dev'][] = $pretty;
  11827. } else {
  11828. $byMajor[Preg::replace('{^(\d+)\..*}', '$1', $version)][] = $pretty;
  11829. }
  11830. }
  11831. foreach ($byMajor as $majorVersion => $versionsForMajor) {
  11832. $maxVersions = $majorVersion === 'dev' ? $maxDev : $max;
  11833. if (count($versionsForMajor) > $maxVersions) {
  11834. $filtered[] = $versionsForMajor[0];
  11835. $filtered[] = '...';
  11836. $filtered[] = $versionsForMajor[count($versionsForMajor) - 1];
  11837. } else {
  11838. $filtered = array_merge($filtered, $versionsForMajor);
  11839. }
  11840. }
  11841. return $filtered;
  11842. }
  11843. private static function hasMultipleNames(array $packages): bool
  11844. {
  11845. $name = null;
  11846. foreach ($packages as $package) {
  11847. if ($name === null || $name === $package->getName()) {
  11848. $name = $package->getName();
  11849. } else {
  11850. return true;
  11851. }
  11852. }
  11853. return false;
  11854. }
  11855. private static function computeCheckForLowerPrioRepo(Pool $pool, bool $isVerbose, string $packageName, array $higherRepoPackages, array $allReposPackages, string $reason, ConstraintInterface $constraint = null): array
  11856. {
  11857. $nextRepoPackages = array();
  11858. $nextRepo = null;
  11859. foreach ($allReposPackages as $package) {
  11860. if ($nextRepo === null || $nextRepo === $package->getRepository()) {
  11861. $nextRepoPackages[] = $package;
  11862. $nextRepo = $package->getRepository();
  11863. } else {
  11864. break;
  11865. }
  11866. }
  11867. if ($higherRepoPackages) {
  11868. $topPackage = reset($higherRepoPackages);
  11869. if ($topPackage instanceof RootPackageInterface) {
  11870. return array(
  11871. "- Root composer.json requires $packageName".self::constraintToText($constraint).', it is ',
  11872. 'satisfiable by '.self::getPackageList($nextRepoPackages, $isVerbose, $pool, $constraint).' from '.$nextRepo->getRepoName().' but '.$topPackage->getPrettyName().' is the root package and cannot be modified. See https://getcomposer.org/dep-on-root for details and assistance.',
  11873. );
  11874. }
  11875. }
  11876. if ($nextRepo instanceof LockArrayRepository) {
  11877. $singular = count($higherRepoPackages) === 1;
  11878. $suggestion = 'Make sure you either fix the '.$reason.' or avoid updating this package to keep the one present in the lock file ('.self::getPackageList($nextRepoPackages, $isVerbose, $pool, $constraint).').';
  11879. if ($nextRepoPackages[0]->getDistType() === 'path') {
  11880. $transportOptions = $nextRepoPackages[0]->getTransportOptions();
  11881. if (!isset($transportOptions['symlink']) || $transportOptions['symlink'] !== false) {
  11882. $suggestion = 'Make sure you fix the '.$reason.' as packages installed from symlinked path repos are updated even in partial updates and the one from the lock file can thus not be used.';
  11883. }
  11884. }
  11885. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ',
  11886. 'found ' . self::getPackageList($higherRepoPackages, $isVerbose, $pool, $constraint).' but ' . ($singular ? 'it does' : 'these do') . ' not match your '.$reason.' and ' . ($singular ? 'is' : 'are') . ' therefore not installable. '.$suggestion,
  11887. );
  11888. }
  11889. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', it is ', 'satisfiable by '.self::getPackageList($nextRepoPackages, $isVerbose, $pool, $constraint).' from '.$nextRepo->getRepoName().' but '.self::getPackageList($higherRepoPackages, $isVerbose, $pool, $constraint).' from '.reset($higherRepoPackages)->getRepository()->getRepoName().' has higher repository priority. The packages from the higher priority repository do not match your '.$reason.' and are therefore not installable. That repository is canonical so the lower priority repo\'s packages are not installable. See https://getcomposer.org/repoprio for details and assistance.');
  11890. }
  11891. protected static function constraintToText(ConstraintInterface $constraint = null): string
  11892. {
  11893. return $constraint ? ' '.$constraint->getPrettyString() : '';
  11894. }
  11895. }
  11896. <?php declare(strict_types=1);
  11897. namespace Composer\DependencyResolver;
  11898. use Composer\Package\BasePackage;
  11899. use Composer\Package\PackageInterface;
  11900. use Composer\Repository\LockArrayRepository;
  11901. use Composer\Semver\Constraint\ConstraintInterface;
  11902. use Composer\Semver\Constraint\MatchAllConstraint;
  11903. class Request
  11904. {
  11905. public const UPDATE_ONLY_LISTED = 0;
  11906. public const UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE = 1;
  11907. public const UPDATE_LISTED_WITH_TRANSITIVE_DEPS = 2;
  11908. protected $lockedRepository;
  11909. protected $requires = array();
  11910. protected $fixedPackages = array();
  11911. protected $lockedPackages = array();
  11912. protected $fixedLockedPackages = array();
  11913. protected $updateAllowList = array();
  11914. protected $updateAllowTransitiveDependencies = false;
  11915. public function __construct(LockArrayRepository $lockedRepository = null)
  11916. {
  11917. $this->lockedRepository = $lockedRepository;
  11918. }
  11919. public function requireName(string $packageName, ConstraintInterface $constraint = null): void
  11920. {
  11921. $packageName = strtolower($packageName);
  11922. if ($constraint === null) {
  11923. $constraint = new MatchAllConstraint();
  11924. }
  11925. if (isset($this->requires[$packageName])) {
  11926. throw new \LogicException('Overwriting requires seems like a bug ('.$packageName.' '.$this->requires[$packageName]->getPrettyString().' => '.$constraint->getPrettyString().', check why it is happening, might be a root alias');
  11927. }
  11928. $this->requires[$packageName] = $constraint;
  11929. }
  11930. public function fixPackage(BasePackage $package): void
  11931. {
  11932. $this->fixedPackages[spl_object_hash($package)] = $package;
  11933. }
  11934. public function lockPackage(BasePackage $package): void
  11935. {
  11936. $this->lockedPackages[spl_object_hash($package)] = $package;
  11937. }
  11938. public function fixLockedPackage(BasePackage $package): void
  11939. {
  11940. $this->fixedPackages[spl_object_hash($package)] = $package;
  11941. $this->fixedLockedPackages[spl_object_hash($package)] = $package;
  11942. }
  11943. public function unlockPackage(BasePackage $package): void
  11944. {
  11945. unset($this->lockedPackages[spl_object_hash($package)]);
  11946. }
  11947. public function setUpdateAllowList(array $updateAllowList, $updateAllowTransitiveDependencies): void
  11948. {
  11949. $this->updateAllowList = $updateAllowList;
  11950. $this->updateAllowTransitiveDependencies = $updateAllowTransitiveDependencies;
  11951. }
  11952. public function getUpdateAllowList(): array
  11953. {
  11954. return $this->updateAllowList;
  11955. }
  11956. public function getUpdateAllowTransitiveDependencies(): bool
  11957. {
  11958. return $this->updateAllowTransitiveDependencies !== self::UPDATE_ONLY_LISTED;
  11959. }
  11960. public function getUpdateAllowTransitiveRootDependencies(): bool
  11961. {
  11962. return $this->updateAllowTransitiveDependencies === self::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  11963. }
  11964. public function getRequires(): array
  11965. {
  11966. return $this->requires;
  11967. }
  11968. public function getFixedPackages(): array
  11969. {
  11970. return $this->fixedPackages;
  11971. }
  11972. public function isFixedPackage(BasePackage $package): bool
  11973. {
  11974. return isset($this->fixedPackages[spl_object_hash($package)]);
  11975. }
  11976. public function getLockedPackages(): array
  11977. {
  11978. return $this->lockedPackages;
  11979. }
  11980. public function isLockedPackage(PackageInterface $package): bool
  11981. {
  11982. return isset($this->lockedPackages[spl_object_hash($package)]) || isset($this->fixedLockedPackages[spl_object_hash($package)]);
  11983. }
  11984. public function getFixedOrLockedPackages(): array
  11985. {
  11986. return array_merge($this->fixedPackages, $this->lockedPackages);
  11987. }
  11988. public function getPresentMap(bool $packageIds = false): array
  11989. {
  11990. $presentMap = array();
  11991. if ($this->lockedRepository) {
  11992. foreach ($this->lockedRepository->getPackages() as $package) {
  11993. $presentMap[$packageIds ? $package->getId() : spl_object_hash($package)] = $package;
  11994. }
  11995. }
  11996. foreach ($this->fixedPackages as $package) {
  11997. $presentMap[$packageIds ? $package->getId() : spl_object_hash($package)] = $package;
  11998. }
  11999. return $presentMap;
  12000. }
  12001. public function getFixedPackagesMap(): array
  12002. {
  12003. $fixedPackagesMap = array();
  12004. foreach ($this->fixedPackages as $package) {
  12005. $fixedPackagesMap[$package->getId()] = $package;
  12006. }
  12007. return $fixedPackagesMap;
  12008. }
  12009. public function getLockedRepository(): ?LockArrayRepository
  12010. {
  12011. return $this->lockedRepository;
  12012. }
  12013. }
  12014. <?php declare(strict_types=1);
  12015. namespace Composer\DependencyResolver;
  12016. use Composer\Package\AliasPackage;
  12017. use Composer\Package\BasePackage;
  12018. use Composer\Package\Link;
  12019. use Composer\Repository\PlatformRepository;
  12020. use Composer\Repository\RepositorySet;
  12021. use Composer\Package\Version\VersionParser;
  12022. use Composer\Semver\Constraint\Constraint;
  12023. use Composer\Semver\Constraint\ConstraintInterface;
  12024. abstract class Rule
  12025. {
  12026. public const RULE_ROOT_REQUIRE = 2;
  12027. public const RULE_FIXED = 3;
  12028. public const RULE_PACKAGE_CONFLICT = 6;
  12029. public const RULE_PACKAGE_REQUIRES = 7;
  12030. public const RULE_PACKAGE_SAME_NAME = 10;
  12031. public const RULE_LEARNED = 12;
  12032. public const RULE_PACKAGE_ALIAS = 13;
  12033. public const RULE_PACKAGE_INVERSE_ALIAS = 14;
  12034. private const BITFIELD_TYPE = 0;
  12035. private const BITFIELD_REASON = 8;
  12036. private const BITFIELD_DISABLED = 16;
  12037. protected $bitfield;
  12038. protected $request;
  12039. protected $reasonData;
  12040. public function __construct($reason, $reasonData)
  12041. {
  12042. $this->reasonData = $reasonData;
  12043. $this->bitfield = (0 << self::BITFIELD_DISABLED) |
  12044. ($reason << self::BITFIELD_REASON) |
  12045. (255 << self::BITFIELD_TYPE);
  12046. }
  12047. abstract public function getLiterals(): array;
  12048. abstract public function getHash();
  12049. abstract public function __toString(): string;
  12050. abstract public function equals(Rule $rule): bool;
  12051. public function getReason(): int
  12052. {
  12053. return ($this->bitfield & (255 << self::BITFIELD_REASON)) >> self::BITFIELD_REASON;
  12054. }
  12055. public function getReasonData()
  12056. {
  12057. return $this->reasonData;
  12058. }
  12059. public function getRequiredPackage(): ?string
  12060. {
  12061. $reason = $this->getReason();
  12062. if ($reason === self::RULE_ROOT_REQUIRE) {
  12063. return $this->reasonData['packageName'];
  12064. }
  12065. if ($reason === self::RULE_FIXED) {
  12066. return $this->reasonData['package']->getName();
  12067. }
  12068. if ($reason === self::RULE_PACKAGE_REQUIRES) {
  12069. return $this->reasonData->getTarget();
  12070. }
  12071. return null;
  12072. }
  12073. public function setType($type): void
  12074. {
  12075. $this->bitfield = ($this->bitfield & ~(255 << self::BITFIELD_TYPE)) | ((255 & $type) << self::BITFIELD_TYPE);
  12076. }
  12077. public function getType(): int
  12078. {
  12079. return ($this->bitfield & (255 << self::BITFIELD_TYPE)) >> self::BITFIELD_TYPE;
  12080. }
  12081. public function disable(): void
  12082. {
  12083. $this->bitfield = ($this->bitfield & ~(255 << self::BITFIELD_DISABLED)) | (1 << self::BITFIELD_DISABLED);
  12084. }
  12085. public function enable(): void
  12086. {
  12087. $this->bitfield &= ~(255 << self::BITFIELD_DISABLED);
  12088. }
  12089. public function isDisabled(): bool
  12090. {
  12091. return (bool) (($this->bitfield & (255 << self::BITFIELD_DISABLED)) >> self::BITFIELD_DISABLED);
  12092. }
  12093. public function isEnabled(): bool
  12094. {
  12095. return !(($this->bitfield & (255 << self::BITFIELD_DISABLED)) >> self::BITFIELD_DISABLED);
  12096. }
  12097. abstract public function isAssertion(): bool;
  12098. public function isCausedByLock(RepositorySet $repositorySet, Request $request, Pool $pool): bool
  12099. {
  12100. if ($this->getReason() === self::RULE_PACKAGE_REQUIRES) {
  12101. if (PlatformRepository::isPlatformPackage($this->reasonData->getTarget())) {
  12102. return false;
  12103. }
  12104. if ($request->getLockedRepository()) {
  12105. foreach ($request->getLockedRepository()->getPackages() as $package) {
  12106. if ($package->getName() === $this->reasonData->getTarget()) {
  12107. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  12108. return true;
  12109. }
  12110. if (!$this->reasonData->getConstraint()->matches(new Constraint('=', $package->getVersion()))) {
  12111. return true;
  12112. }
  12113. if (!$request->isLockedPackage($package)) {
  12114. return true;
  12115. }
  12116. break;
  12117. }
  12118. }
  12119. }
  12120. }
  12121. if ($this->getReason() === self::RULE_ROOT_REQUIRE) {
  12122. if (PlatformRepository::isPlatformPackage($this->reasonData['packageName'])) {
  12123. return false;
  12124. }
  12125. if ($request->getLockedRepository()) {
  12126. foreach ($request->getLockedRepository()->getPackages() as $package) {
  12127. if ($package->getName() === $this->reasonData['packageName']) {
  12128. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  12129. return true;
  12130. }
  12131. if (!$this->reasonData['constraint']->matches(new Constraint('=', $package->getVersion()))) {
  12132. return true;
  12133. }
  12134. break;
  12135. }
  12136. }
  12137. }
  12138. }
  12139. return false;
  12140. }
  12141. public function getSourcePackage(Pool $pool): BasePackage
  12142. {
  12143. $literals = $this->getLiterals();
  12144. switch ($this->getReason()) {
  12145. case self::RULE_PACKAGE_CONFLICT:
  12146. $package1 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[0]));
  12147. $package2 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
  12148. if ($reasonData = $this->getReasonData()) {
  12149. if ($reasonData->getSource() === $package1->getName()) {
  12150. list($package2, $package1) = array($package1, $package2);
  12151. }
  12152. }
  12153. return $package2;
  12154. case self::RULE_PACKAGE_REQUIRES:
  12155. $sourceLiteral = array_shift($literals);
  12156. $sourcePackage = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($sourceLiteral));
  12157. return $sourcePackage;
  12158. default:
  12159. throw new \LogicException('Not implemented');
  12160. }
  12161. }
  12162. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, bool $isVerbose, array $installedMap = array(), array $learnedPool = array()): string
  12163. {
  12164. $literals = $this->getLiterals();
  12165. switch ($this->getReason()) {
  12166. case self::RULE_ROOT_REQUIRE:
  12167. $packageName = $this->reasonData['packageName'];
  12168. $constraint = $this->reasonData['constraint'];
  12169. $packages = $pool->whatProvides($packageName, $constraint);
  12170. if (!$packages) {
  12171. return 'No package found to satisfy root composer.json require '.$packageName.($constraint ? ' '.$constraint->getPrettyString() : '');
  12172. }
  12173. $packagesNonAlias = array_values(array_filter($packages, function ($p): bool {
  12174. return !($p instanceof AliasPackage);
  12175. }));
  12176. if (count($packagesNonAlias) === 1) {
  12177. $package = $packagesNonAlias[0];
  12178. if ($request->isLockedPackage($package)) {
  12179. return $package->getPrettyName().' is locked to version '.$package->getPrettyVersion()." and an update of this package was not requested.";
  12180. }
  12181. }
  12182. return 'Root composer.json requires '.$packageName.($constraint ? ' '.$constraint->getPrettyString() : '').' -> satisfiable by '.$this->formatPackagesUnique($pool, $packages, $isVerbose, $constraint).'.';
  12183. case self::RULE_FIXED:
  12184. $package = $this->deduplicateDefaultBranchAlias($this->reasonData['package']);
  12185. if ($request->isLockedPackage($package)) {
  12186. return $package->getPrettyName().' is locked to version '.$package->getPrettyVersion().' and an update of this package was not requested.';
  12187. }
  12188. return $package->getPrettyName().' is present at version '.$package->getPrettyVersion() . ' and cannot be modified by Composer';
  12189. case self::RULE_PACKAGE_CONFLICT:
  12190. $package1 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[0]));
  12191. $package2 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
  12192. $conflictTarget = $package1->getPrettyString();
  12193. if ($reasonData = $this->getReasonData()) {
  12194. assert($reasonData instanceof Link);
  12195. if ($reasonData->getSource() === $package1->getName()) {
  12196. list($package2, $package1) = array($package1, $package2);
  12197. $conflictTarget = $package1->getPrettyName().' '.$reasonData->getPrettyConstraint();
  12198. }
  12199. if ($reasonData->getTarget() !== $package1->getName()) {
  12200. $provideType = null;
  12201. $provided = null;
  12202. foreach ($package1->getProvides() as $provide) {
  12203. if ($provide->getTarget() === $reasonData->getTarget()) {
  12204. $provideType = 'provides';
  12205. $provided = $provide->getPrettyConstraint();
  12206. break;
  12207. }
  12208. }
  12209. foreach ($package1->getReplaces() as $replace) {
  12210. if ($replace->getTarget() === $reasonData->getTarget()) {
  12211. $provideType = 'replaces';
  12212. $provided = $replace->getPrettyConstraint();
  12213. break;
  12214. }
  12215. }
  12216. if (null !== $provideType) {
  12217. $conflictTarget = $reasonData->getTarget().' '.$reasonData->getPrettyConstraint().' ('.$package1->getPrettyString().' '.$provideType.' '.$reasonData->getTarget().' '.$provided.')';
  12218. }
  12219. }
  12220. }
  12221. return $package2->getPrettyString().' conflicts with '.$conflictTarget.'.';
  12222. case self::RULE_PACKAGE_REQUIRES:
  12223. $sourceLiteral = array_shift($literals);
  12224. $sourcePackage = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($sourceLiteral));
  12225. $reasonData = $this->reasonData;
  12226. $requires = array();
  12227. foreach ($literals as $literal) {
  12228. $requires[] = $pool->literalToPackage($literal);
  12229. }
  12230. $text = $reasonData->getPrettyString($sourcePackage);
  12231. if ($requires) {
  12232. $text .= ' -> satisfiable by ' . $this->formatPackagesUnique($pool, $requires, $isVerbose, $this->reasonData->getConstraint()) . '.';
  12233. } else {
  12234. $targetName = $reasonData->getTarget();
  12235. $reason = Problem::getMissingPackageReason($repositorySet, $request, $pool, $isVerbose, $targetName, $this->reasonData->getConstraint());
  12236. return $text . ' -> ' . $reason[1];
  12237. }
  12238. return $text;
  12239. case self::RULE_PACKAGE_SAME_NAME:
  12240. $packageNames = array();
  12241. foreach ($literals as $literal) {
  12242. $package = $pool->literalToPackage($literal);
  12243. $packageNames[$package->getName()] = true;
  12244. }
  12245. $replacedName = $this->reasonData;
  12246. if (count($packageNames) > 1) {
  12247. $reason = null;
  12248. if (!isset($packageNames[$replacedName])) {
  12249. $reason = 'They '.(count($literals) == 2 ? 'both' : 'all').' replace '.$replacedName.' and thus cannot coexist.';
  12250. } else {
  12251. $replacerNames = $packageNames;
  12252. unset($replacerNames[$replacedName]);
  12253. $replacerNames = array_keys($replacerNames);
  12254. if (count($replacerNames) == 1) {
  12255. $reason = $replacerNames[0] . ' replaces ';
  12256. } else {
  12257. $reason = '['.implode(', ', $replacerNames).'] replace ';
  12258. }
  12259. $reason .= $replacedName.' and thus cannot coexist with it.';
  12260. }
  12261. $installedPackages = array();
  12262. $removablePackages = array();
  12263. foreach ($literals as $literal) {
  12264. if (isset($installedMap[abs($literal)])) {
  12265. $installedPackages[] = $pool->literalToPackage($literal);
  12266. } else {
  12267. $removablePackages[] = $pool->literalToPackage($literal);
  12268. }
  12269. }
  12270. if ($installedPackages && $removablePackages) {
  12271. return $this->formatPackagesUnique($pool, $removablePackages, $isVerbose, null, true).' cannot be installed as that would require removing '.$this->formatPackagesUnique($pool, $installedPackages, $isVerbose, null, true).'. '.$reason;
  12272. }
  12273. return 'Only one of these can be installed: '.$this->formatPackagesUnique($pool, $literals, $isVerbose, null, true).'. '.$reason;
  12274. }
  12275. return 'You can only install one version of a package, so only one of these can be installed: ' . $this->formatPackagesUnique($pool, $literals, $isVerbose, null, true) . '.';
  12276. case self::RULE_LEARNED:
  12277. $learnedString = ' (conflict analysis result)';
  12278. if (count($literals) === 1) {
  12279. $ruleText = $pool->literalToPrettyString($literals[0], $installedMap);
  12280. } else {
  12281. $groups = array();
  12282. foreach ($literals as $literal) {
  12283. $package = $pool->literalToPackage($literal);
  12284. if (isset($installedMap[$package->id])) {
  12285. $group = $literal > 0 ? 'keep' : 'remove';
  12286. } else {
  12287. $group = $literal > 0 ? 'install' : 'don\'t install';
  12288. }
  12289. $groups[$group][] = $this->deduplicateDefaultBranchAlias($package);
  12290. }
  12291. $ruleTexts = array();
  12292. foreach ($groups as $group => $packages) {
  12293. $ruleTexts[] = $group . (count($packages) > 1 ? ' one of' : '').' ' . $this->formatPackagesUnique($pool, $packages, $isVerbose);
  12294. }
  12295. $ruleText = implode(' | ', $ruleTexts);
  12296. }
  12297. return 'Conclusion: '.$ruleText.$learnedString;
  12298. case self::RULE_PACKAGE_ALIAS:
  12299. $aliasPackage = $pool->literalToPackage($literals[0]);
  12300. if ($aliasPackage->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  12301. return '';
  12302. }
  12303. $package = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
  12304. return $aliasPackage->getPrettyString() .' is an alias of '.$package->getPrettyString().' and thus requires it to be installed too.';
  12305. case self::RULE_PACKAGE_INVERSE_ALIAS:
  12306. $aliasPackage = $pool->literalToPackage($literals[1]);
  12307. if ($aliasPackage->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  12308. return '';
  12309. }
  12310. $package = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[0]));
  12311. return $aliasPackage->getPrettyString() .' is an alias of '.$package->getPrettyString().' and must be installed with it.';
  12312. default:
  12313. $ruleText = '';
  12314. foreach ($literals as $i => $literal) {
  12315. if ($i != 0) {
  12316. $ruleText .= '|';
  12317. }
  12318. $ruleText .= $pool->literalToPrettyString($literal, $installedMap);
  12319. }
  12320. return '('.$ruleText.')';
  12321. }
  12322. }
  12323. protected function formatPackagesUnique(Pool $pool, array $packages, bool $isVerbose, ConstraintInterface $constraint = null, bool $useRemovedVersionGroup = false): string
  12324. {
  12325. foreach ($packages as $index => $package) {
  12326. if (!\is_object($package)) {
  12327. $packages[$index] = $pool->literalToPackage($package);
  12328. }
  12329. }
  12330. return Problem::getPackageList($packages, $isVerbose, $pool, $constraint, $useRemovedVersionGroup);
  12331. }
  12332. private function deduplicateDefaultBranchAlias(BasePackage $package): BasePackage
  12333. {
  12334. if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  12335. $package = $package->getAliasOf();
  12336. }
  12337. return $package;
  12338. }
  12339. }
  12340. <?php declare(strict_types=1);
  12341. namespace Composer\DependencyResolver;
  12342. class Rule2Literals extends Rule
  12343. {
  12344. protected $literal1;
  12345. protected $literal2;
  12346. public function __construct(int $literal1, int $literal2, $reason, $reasonData)
  12347. {
  12348. parent::__construct($reason, $reasonData);
  12349. if ($literal1 < $literal2) {
  12350. $this->literal1 = $literal1;
  12351. $this->literal2 = $literal2;
  12352. } else {
  12353. $this->literal1 = $literal2;
  12354. $this->literal2 = $literal1;
  12355. }
  12356. }
  12357. public function getLiterals(): array
  12358. {
  12359. return array($this->literal1, $this->literal2);
  12360. }
  12361. public function getHash()
  12362. {
  12363. return $this->literal1.','.$this->literal2;
  12364. }
  12365. public function equals(Rule $rule): bool
  12366. {
  12367. if ($rule instanceof self) {
  12368. if ($this->literal1 !== $rule->literal1) {
  12369. return false;
  12370. }
  12371. if ($this->literal2 !== $rule->literal2) {
  12372. return false;
  12373. }
  12374. return true;
  12375. }
  12376. $literals = $rule->getLiterals();
  12377. if (2 != \count($literals)) {
  12378. return false;
  12379. }
  12380. if ($this->literal1 !== $literals[0]) {
  12381. return false;
  12382. }
  12383. if ($this->literal2 !== $literals[1]) {
  12384. return false;
  12385. }
  12386. return true;
  12387. }
  12388. public function isAssertion(): bool
  12389. {
  12390. return false;
  12391. }
  12392. public function __toString(): string
  12393. {
  12394. $result = $this->isDisabled() ? 'disabled(' : '(';
  12395. $result .= $this->literal1 . '|' . $this->literal2 . ')';
  12396. return $result;
  12397. }
  12398. }
  12399. <?php declare(strict_types=1);
  12400. namespace Composer\DependencyResolver;
  12401. use Composer\Repository\RepositorySet;
  12402. class RuleSet implements \IteratorAggregate, \Countable
  12403. {
  12404. public const TYPE_PACKAGE = 0;
  12405. public const TYPE_REQUEST = 1;
  12406. public const TYPE_LEARNED = 4;
  12407. public $ruleById = array();
  12408. protected static $types = array(
  12409. self::TYPE_PACKAGE => 'PACKAGE',
  12410. self::TYPE_REQUEST => 'REQUEST',
  12411. self::TYPE_LEARNED => 'LEARNED',
  12412. );
  12413. protected $rules;
  12414. protected $nextRuleId = 0;
  12415. protected $rulesByHash = array();
  12416. public function __construct()
  12417. {
  12418. foreach ($this->getTypes() as $type) {
  12419. $this->rules[$type] = array();
  12420. }
  12421. }
  12422. public function add(Rule $rule, $type): void
  12423. {
  12424. if (!isset(self::$types[$type])) {
  12425. throw new \OutOfBoundsException('Unknown rule type: ' . $type);
  12426. }
  12427. $hash = $rule->getHash();
  12428. if (isset($this->rulesByHash[$hash])) {
  12429. $potentialDuplicates = $this->rulesByHash[$hash];
  12430. if (\is_array($potentialDuplicates)) {
  12431. foreach ($potentialDuplicates as $potentialDuplicate) {
  12432. if ($rule->equals($potentialDuplicate)) {
  12433. return;
  12434. }
  12435. }
  12436. } else {
  12437. if ($rule->equals($potentialDuplicates)) {
  12438. return;
  12439. }
  12440. }
  12441. }
  12442. if (!isset($this->rules[$type])) {
  12443. $this->rules[$type] = array();
  12444. }
  12445. $this->rules[$type][] = $rule;
  12446. $this->ruleById[$this->nextRuleId] = $rule;
  12447. $rule->setType($type);
  12448. $this->nextRuleId++;
  12449. if (!isset($this->rulesByHash[$hash])) {
  12450. $this->rulesByHash[$hash] = $rule;
  12451. } elseif (\is_array($this->rulesByHash[$hash])) {
  12452. $this->rulesByHash[$hash][] = $rule;
  12453. } else {
  12454. $originalRule = $this->rulesByHash[$hash];
  12455. $this->rulesByHash[$hash] = array($originalRule, $rule);
  12456. }
  12457. }
  12458. public function count(): int
  12459. {
  12460. return $this->nextRuleId;
  12461. }
  12462. public function ruleById(int $id): Rule
  12463. {
  12464. return $this->ruleById[$id];
  12465. }
  12466. public function getRules(): array
  12467. {
  12468. return $this->rules;
  12469. }
  12470. public function getIterator(): RuleSetIterator
  12471. {
  12472. return new RuleSetIterator($this->getRules());
  12473. }
  12474. public function getIteratorFor($types): RuleSetIterator
  12475. {
  12476. if (!\is_array($types)) {
  12477. $types = array($types);
  12478. }
  12479. $allRules = $this->getRules();
  12480. $rules = array();
  12481. foreach ($types as $type) {
  12482. $rules[$type] = $allRules[$type];
  12483. }
  12484. return new RuleSetIterator($rules);
  12485. }
  12486. public function getIteratorWithout($types): RuleSetIterator
  12487. {
  12488. if (!\is_array($types)) {
  12489. $types = array($types);
  12490. }
  12491. $rules = $this->getRules();
  12492. foreach ($types as $type) {
  12493. unset($rules[$type]);
  12494. }
  12495. return new RuleSetIterator($rules);
  12496. }
  12497. public function getTypes(): array
  12498. {
  12499. $types = self::$types;
  12500. return array_keys($types);
  12501. }
  12502. public function getPrettyString(RepositorySet $repositorySet = null, Request $request = null, Pool $pool = null, bool $isVerbose = false): string
  12503. {
  12504. $string = "\n";
  12505. foreach ($this->rules as $type => $rules) {
  12506. $string .= str_pad(self::$types[$type], 8, ' ') . ": ";
  12507. foreach ($rules as $rule) {
  12508. $string .= ($repositorySet && $request && $pool ? $rule->getPrettyString($repositorySet, $request, $pool, $isVerbose) : $rule)."\n";
  12509. }
  12510. $string .= "\n\n";
  12511. }
  12512. return $string;
  12513. }
  12514. public function __toString(): string
  12515. {
  12516. return $this->getPrettyString();
  12517. }
  12518. }
  12519. <?php declare(strict_types=1);
  12520. namespace Composer\DependencyResolver;
  12521. use Composer\Filter\PlatformRequirementFilter\IgnoreListPlatformRequirementFilter;
  12522. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  12523. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  12524. use Composer\Package\BasePackage;
  12525. use Composer\Package\AliasPackage;
  12526. class RuleSetGenerator
  12527. {
  12528. protected $policy;
  12529. protected $pool;
  12530. protected $rules;
  12531. protected $addedMap = array();
  12532. protected $addedPackagesByNames = array();
  12533. public function __construct(PolicyInterface $policy, Pool $pool)
  12534. {
  12535. $this->policy = $policy;
  12536. $this->pool = $pool;
  12537. $this->rules = new RuleSet;
  12538. }
  12539. protected function createRequireRule(BasePackage $package, array $providers, $reason, $reasonData = null): ?Rule
  12540. {
  12541. $literals = array(-$package->id);
  12542. foreach ($providers as $provider) {
  12543. if ($provider === $package) {
  12544. return null;
  12545. }
  12546. $literals[] = $provider->id;
  12547. }
  12548. return new GenericRule($literals, $reason, $reasonData);
  12549. }
  12550. protected function createInstallOneOfRule(array $packages, $reason, $reasonData): Rule
  12551. {
  12552. $literals = array();
  12553. foreach ($packages as $package) {
  12554. $literals[] = $package->id;
  12555. }
  12556. return new GenericRule($literals, $reason, $reasonData);
  12557. }
  12558. protected function createRule2Literals(BasePackage $issuer, BasePackage $provider, $reason, $reasonData = null): ?Rule
  12559. {
  12560. if ($issuer === $provider) {
  12561. return null;
  12562. }
  12563. return new Rule2Literals(-$issuer->id, -$provider->id, $reason, $reasonData);
  12564. }
  12565. protected function createMultiConflictRule(array $packages, $reason, $reasonData): Rule
  12566. {
  12567. $literals = array();
  12568. foreach ($packages as $package) {
  12569. $literals[] = -$package->id;
  12570. }
  12571. if (\count($literals) == 2) {
  12572. return new Rule2Literals($literals[0], $literals[1], $reason, $reasonData);
  12573. }
  12574. return new MultiConflictRule($literals, $reason, $reasonData);
  12575. }
  12576. private function addRule($type, Rule $newRule = null): void
  12577. {
  12578. if (!$newRule) {
  12579. return;
  12580. }
  12581. $this->rules->add($newRule, $type);
  12582. }
  12583. protected function addRulesForPackage(BasePackage $package, PlatformRequirementFilterInterface $platformRequirementFilter): void
  12584. {
  12585. $workQueue = new \SplQueue;
  12586. $workQueue->enqueue($package);
  12587. while (!$workQueue->isEmpty()) {
  12588. $package = $workQueue->dequeue();
  12589. if (isset($this->addedMap[$package->id])) {
  12590. continue;
  12591. }
  12592. $this->addedMap[$package->id] = $package;
  12593. if (!$package instanceof AliasPackage) {
  12594. foreach ($package->getNames(false) as $name) {
  12595. $this->addedPackagesByNames[$name][] = $package;
  12596. }
  12597. } else {
  12598. $workQueue->enqueue($package->getAliasOf());
  12599. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, array($package->getAliasOf()), Rule::RULE_PACKAGE_ALIAS, $package));
  12600. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package->getAliasOf(), array($package), Rule::RULE_PACKAGE_INVERSE_ALIAS, $package->getAliasOf()));
  12601. if (!$package->hasSelfVersionRequires()) {
  12602. continue;
  12603. }
  12604. }
  12605. foreach ($package->getRequires() as $link) {
  12606. $constraint = $link->getConstraint();
  12607. if ($platformRequirementFilter->isIgnored($link->getTarget())) {
  12608. continue;
  12609. } elseif ($platformRequirementFilter instanceof IgnoreListPlatformRequirementFilter) {
  12610. $constraint = $platformRequirementFilter->filterConstraint($link->getTarget(), $constraint);
  12611. }
  12612. $possibleRequires = $this->pool->whatProvides($link->getTarget(), $constraint);
  12613. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, $possibleRequires, Rule::RULE_PACKAGE_REQUIRES, $link));
  12614. foreach ($possibleRequires as $require) {
  12615. $workQueue->enqueue($require);
  12616. }
  12617. }
  12618. }
  12619. }
  12620. protected function addConflictRules(PlatformRequirementFilterInterface $platformRequirementFilter): void
  12621. {
  12622. foreach ($this->addedMap as $package) {
  12623. foreach ($package->getConflicts() as $link) {
  12624. if (!isset($this->addedPackagesByNames[$link->getTarget()])) {
  12625. continue;
  12626. }
  12627. $constraint = $link->getConstraint();
  12628. if ($platformRequirementFilter->isIgnored($link->getTarget())) {
  12629. continue;
  12630. } elseif ($platformRequirementFilter instanceof IgnoreListPlatformRequirementFilter) {
  12631. $constraint = $platformRequirementFilter->filterConstraint($link->getTarget(), $constraint);
  12632. }
  12633. $conflicts = $this->pool->whatProvides($link->getTarget(), $constraint);
  12634. foreach ($conflicts as $conflict) {
  12635. if (!$conflict instanceof AliasPackage || $conflict->getName() === $link->getTarget()) {
  12636. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRule2Literals($package, $conflict, Rule::RULE_PACKAGE_CONFLICT, $link));
  12637. }
  12638. }
  12639. }
  12640. }
  12641. foreach ($this->addedPackagesByNames as $name => $packages) {
  12642. if (\count($packages) > 1) {
  12643. $reason = Rule::RULE_PACKAGE_SAME_NAME;
  12644. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createMultiConflictRule($packages, $reason, $name));
  12645. }
  12646. }
  12647. }
  12648. protected function addRulesForRequest(Request $request, PlatformRequirementFilterInterface $platformRequirementFilter): void
  12649. {
  12650. foreach ($request->getFixedPackages() as $package) {
  12651. if ($package->id == -1) {
  12652. if ($this->pool->isUnacceptableFixedOrLockedPackage($package)) {
  12653. continue;
  12654. }
  12655. throw new \LogicException("Fixed package ".$package->getPrettyString()." was not added to solver pool.");
  12656. }
  12657. $this->addRulesForPackage($package, $platformRequirementFilter);
  12658. $rule = $this->createInstallOneOfRule(array($package), Rule::RULE_FIXED, array(
  12659. 'package' => $package,
  12660. ));
  12661. $this->addRule(RuleSet::TYPE_REQUEST, $rule);
  12662. }
  12663. foreach ($request->getRequires() as $packageName => $constraint) {
  12664. if ($platformRequirementFilter->isIgnored($packageName)) {
  12665. continue;
  12666. } elseif ($platformRequirementFilter instanceof IgnoreListPlatformRequirementFilter) {
  12667. $constraint = $platformRequirementFilter->filterConstraint($packageName, $constraint);
  12668. }
  12669. $packages = $this->pool->whatProvides($packageName, $constraint);
  12670. if ($packages) {
  12671. foreach ($packages as $package) {
  12672. $this->addRulesForPackage($package, $platformRequirementFilter);
  12673. }
  12674. $rule = $this->createInstallOneOfRule($packages, Rule::RULE_ROOT_REQUIRE, array(
  12675. 'packageName' => $packageName,
  12676. 'constraint' => $constraint,
  12677. ));
  12678. $this->addRule(RuleSet::TYPE_REQUEST, $rule);
  12679. }
  12680. }
  12681. }
  12682. protected function addRulesForRootAliases(PlatformRequirementFilterInterface $platformRequirementFilter): void
  12683. {
  12684. foreach ($this->pool->getPackages() as $package) {
  12685. if (!isset($this->addedMap[$package->id]) &&
  12686. $package instanceof AliasPackage &&
  12687. ($package->isRootPackageAlias() || isset($this->addedMap[$package->getAliasOf()->id]))
  12688. ) {
  12689. $this->addRulesForPackage($package, $platformRequirementFilter);
  12690. }
  12691. }
  12692. }
  12693. public function getRulesFor(Request $request, PlatformRequirementFilterInterface $platformRequirementFilter = null): RuleSet
  12694. {
  12695. $platformRequirementFilter = $platformRequirementFilter ?: PlatformRequirementFilterFactory::ignoreNothing();
  12696. $this->addRulesForRequest($request, $platformRequirementFilter);
  12697. $this->addRulesForRootAliases($platformRequirementFilter);
  12698. $this->addConflictRules($platformRequirementFilter);
  12699. $this->addedMap = $this->addedPackagesByNames = array();
  12700. $rules = $this->rules;
  12701. $this->rules = new RuleSet;
  12702. return $rules;
  12703. }
  12704. }
  12705. <?php declare(strict_types=1);
  12706. namespace Composer\DependencyResolver;
  12707. class RuleSetIterator implements \Iterator
  12708. {
  12709. protected $rules;
  12710. protected $types;
  12711. protected $currentOffset;
  12712. protected $currentType;
  12713. protected $currentTypeOffset;
  12714. public function __construct(array $rules)
  12715. {
  12716. $this->rules = $rules;
  12717. $this->types = array_keys($rules);
  12718. sort($this->types);
  12719. $this->rewind();
  12720. }
  12721. public function current(): Rule
  12722. {
  12723. return $this->rules[$this->currentType][$this->currentOffset];
  12724. }
  12725. public function key(): int
  12726. {
  12727. return $this->currentType;
  12728. }
  12729. public function next(): void
  12730. {
  12731. $this->currentOffset++;
  12732. if (!isset($this->rules[$this->currentType])) {
  12733. return;
  12734. }
  12735. if ($this->currentOffset >= \count($this->rules[$this->currentType])) {
  12736. $this->currentOffset = 0;
  12737. do {
  12738. $this->currentTypeOffset++;
  12739. if (!isset($this->types[$this->currentTypeOffset])) {
  12740. $this->currentType = -1;
  12741. break;
  12742. }
  12743. $this->currentType = $this->types[$this->currentTypeOffset];
  12744. } while (isset($this->types[$this->currentTypeOffset]) && !\count($this->rules[$this->currentType]));
  12745. }
  12746. }
  12747. public function rewind(): void
  12748. {
  12749. $this->currentOffset = 0;
  12750. $this->currentTypeOffset = -1;
  12751. $this->currentType = -1;
  12752. do {
  12753. $this->currentTypeOffset++;
  12754. if (!isset($this->types[$this->currentTypeOffset])) {
  12755. $this->currentType = -1;
  12756. break;
  12757. }
  12758. $this->currentType = $this->types[$this->currentTypeOffset];
  12759. } while (isset($this->types[$this->currentTypeOffset]) && !\count($this->rules[$this->currentType]));
  12760. }
  12761. public function valid(): bool
  12762. {
  12763. return isset($this->rules[$this->currentType], $this->rules[$this->currentType][$this->currentOffset]);
  12764. }
  12765. }
  12766. <?php declare(strict_types=1);
  12767. namespace Composer\DependencyResolver;
  12768. class RuleWatchChain extends \SplDoublyLinkedList
  12769. {
  12770. public function seek(int $offset): void
  12771. {
  12772. $this->rewind();
  12773. for ($i = 0; $i < $offset; $i++, $this->next());
  12774. }
  12775. public function remove(): void
  12776. {
  12777. $offset = $this->key();
  12778. $this->offsetUnset($offset);
  12779. $this->seek($offset);
  12780. }
  12781. }
  12782. <?php declare(strict_types=1);
  12783. namespace Composer\DependencyResolver;
  12784. class RuleWatchGraph
  12785. {
  12786. protected $watchChains = array();
  12787. public function insert(RuleWatchNode $node): void
  12788. {
  12789. if ($node->getRule()->isAssertion()) {
  12790. return;
  12791. }
  12792. if (!$node->getRule() instanceof MultiConflictRule) {
  12793. foreach (array($node->watch1, $node->watch2) as $literal) {
  12794. if (!isset($this->watchChains[$literal])) {
  12795. $this->watchChains[$literal] = new RuleWatchChain;
  12796. }
  12797. $this->watchChains[$literal]->unshift($node);
  12798. }
  12799. } else {
  12800. foreach ($node->getRule()->getLiterals() as $literal) {
  12801. if (!isset($this->watchChains[$literal])) {
  12802. $this->watchChains[$literal] = new RuleWatchChain;
  12803. }
  12804. $this->watchChains[$literal]->unshift($node);
  12805. }
  12806. }
  12807. }
  12808. public function propagateLiteral(int $decidedLiteral, int $level, Decisions $decisions): ?Rule
  12809. {
  12810. $literal = -$decidedLiteral;
  12811. if (!isset($this->watchChains[$literal])) {
  12812. return null;
  12813. }
  12814. $chain = $this->watchChains[$literal];
  12815. $chain->rewind();
  12816. while ($chain->valid()) {
  12817. $node = $chain->current();
  12818. if (!$node->getRule() instanceof MultiConflictRule) {
  12819. $otherWatch = $node->getOtherWatch($literal);
  12820. if (!$node->getRule()->isDisabled() && !$decisions->satisfy($otherWatch)) {
  12821. $ruleLiterals = $node->getRule()->getLiterals();
  12822. $alternativeLiterals = array_filter($ruleLiterals, function ($ruleLiteral) use ($literal, $otherWatch, $decisions): bool {
  12823. return $literal !== $ruleLiteral &&
  12824. $otherWatch !== $ruleLiteral &&
  12825. !$decisions->conflict($ruleLiteral);
  12826. });
  12827. if ($alternativeLiterals) {
  12828. reset($alternativeLiterals);
  12829. $this->moveWatch($literal, current($alternativeLiterals), $node);
  12830. continue;
  12831. }
  12832. if ($decisions->conflict($otherWatch)) {
  12833. return $node->getRule();
  12834. }
  12835. $decisions->decide($otherWatch, $level, $node->getRule());
  12836. }
  12837. } else {
  12838. foreach ($node->getRule()->getLiterals() as $otherLiteral) {
  12839. if ($literal !== $otherLiteral && !$decisions->satisfy($otherLiteral)) {
  12840. if ($decisions->conflict($otherLiteral)) {
  12841. return $node->getRule();
  12842. }
  12843. $decisions->decide($otherLiteral, $level, $node->getRule());
  12844. }
  12845. }
  12846. }
  12847. $chain->next();
  12848. }
  12849. return null;
  12850. }
  12851. protected function moveWatch(int $fromLiteral, int $toLiteral, RuleWatchNode $node): void
  12852. {
  12853. if (!isset($this->watchChains[$toLiteral])) {
  12854. $this->watchChains[$toLiteral] = new RuleWatchChain;
  12855. }
  12856. $node->moveWatch($fromLiteral, $toLiteral);
  12857. $this->watchChains[$fromLiteral]->remove();
  12858. $this->watchChains[$toLiteral]->unshift($node);
  12859. }
  12860. }
  12861. <?php declare(strict_types=1);
  12862. namespace Composer\DependencyResolver;
  12863. class RuleWatchNode
  12864. {
  12865. public $watch1;
  12866. public $watch2;
  12867. protected $rule;
  12868. public function __construct(Rule $rule)
  12869. {
  12870. $this->rule = $rule;
  12871. $literals = $rule->getLiterals();
  12872. $literalCount = \count($literals);
  12873. $this->watch1 = $literalCount > 0 ? $literals[0] : 0;
  12874. $this->watch2 = $literalCount > 1 ? $literals[1] : 0;
  12875. }
  12876. public function watch2OnHighest(Decisions $decisions): void
  12877. {
  12878. $literals = $this->rule->getLiterals();
  12879. if (\count($literals) < 3 || $this->rule instanceof MultiConflictRule) {
  12880. return;
  12881. }
  12882. $watchLevel = 0;
  12883. foreach ($literals as $literal) {
  12884. $level = $decisions->decisionLevel($literal);
  12885. if ($level > $watchLevel) {
  12886. $this->watch2 = $literal;
  12887. $watchLevel = $level;
  12888. }
  12889. }
  12890. }
  12891. public function getRule(): Rule
  12892. {
  12893. return $this->rule;
  12894. }
  12895. public function getOtherWatch(int $literal): int
  12896. {
  12897. if ($this->watch1 == $literal) {
  12898. return $this->watch2;
  12899. }
  12900. return $this->watch1;
  12901. }
  12902. public function moveWatch(int $from, int $to): void
  12903. {
  12904. if ($this->watch1 == $from) {
  12905. $this->watch1 = $to;
  12906. } else {
  12907. $this->watch2 = $to;
  12908. }
  12909. }
  12910. }
  12911. <?php declare(strict_types=1);
  12912. namespace Composer\DependencyResolver;
  12913. use Composer\Filter\PlatformRequirementFilter\IgnoreListPlatformRequirementFilter;
  12914. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  12915. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  12916. use Composer\IO\IOInterface;
  12917. use Composer\Package\BasePackage;
  12918. class Solver
  12919. {
  12920. private const BRANCH_LITERALS = 0;
  12921. private const BRANCH_LEVEL = 1;
  12922. protected $policy;
  12923. protected $pool;
  12924. protected $rules;
  12925. protected $watchGraph;
  12926. protected $decisions;
  12927. protected $fixedMap;
  12928. protected $propagateIndex;
  12929. protected $branches = array();
  12930. protected $problems = array();
  12931. protected $learnedPool = array();
  12932. protected $learnedWhy = array();
  12933. public $testFlagLearnedPositiveLiteral = false;
  12934. protected $io;
  12935. public function __construct(PolicyInterface $policy, Pool $pool, IOInterface $io)
  12936. {
  12937. $this->io = $io;
  12938. $this->policy = $policy;
  12939. $this->pool = $pool;
  12940. }
  12941. public function getRuleSetSize(): int
  12942. {
  12943. return \count($this->rules);
  12944. }
  12945. public function getPool(): Pool
  12946. {
  12947. return $this->pool;
  12948. }
  12949. private function makeAssertionRuleDecisions(): void
  12950. {
  12951. $decisionStart = \count($this->decisions) - 1;
  12952. $rulesCount = \count($this->rules);
  12953. for ($ruleIndex = 0; $ruleIndex < $rulesCount; $ruleIndex++) {
  12954. $rule = $this->rules->ruleById[$ruleIndex];
  12955. if (!$rule->isAssertion() || $rule->isDisabled()) {
  12956. continue;
  12957. }
  12958. $literals = $rule->getLiterals();
  12959. $literal = $literals[0];
  12960. if (!$this->decisions->decided($literal)) {
  12961. $this->decisions->decide($literal, 1, $rule);
  12962. continue;
  12963. }
  12964. if ($this->decisions->satisfy($literal)) {
  12965. continue;
  12966. }
  12967. if (RuleSet::TYPE_LEARNED === $rule->getType()) {
  12968. $rule->disable();
  12969. continue;
  12970. }
  12971. $conflict = $this->decisions->decisionRule($literal);
  12972. if ($conflict && RuleSet::TYPE_PACKAGE === $conflict->getType()) {
  12973. $problem = new Problem();
  12974. $problem->addRule($rule);
  12975. $problem->addRule($conflict);
  12976. $rule->disable();
  12977. $this->problems[] = $problem;
  12978. continue;
  12979. }
  12980. $problem = new Problem();
  12981. $problem->addRule($rule);
  12982. $problem->addRule($conflict);
  12983. foreach ($this->rules->getIteratorFor(RuleSet::TYPE_REQUEST) as $assertRule) {
  12984. if ($assertRule->isDisabled() || !$assertRule->isAssertion()) {
  12985. continue;
  12986. }
  12987. $assertRuleLiterals = $assertRule->getLiterals();
  12988. $assertRuleLiteral = $assertRuleLiterals[0];
  12989. if (abs($literal) !== abs($assertRuleLiteral)) {
  12990. continue;
  12991. }
  12992. $problem->addRule($assertRule);
  12993. $assertRule->disable();
  12994. }
  12995. $this->problems[] = $problem;
  12996. $this->decisions->resetToOffset($decisionStart);
  12997. $ruleIndex = -1;
  12998. }
  12999. }
  13000. protected function setupFixedMap(Request $request): void
  13001. {
  13002. $this->fixedMap = array();
  13003. foreach ($request->getFixedPackages() as $package) {
  13004. $this->fixedMap[$package->id] = $package;
  13005. }
  13006. }
  13007. protected function checkForRootRequireProblems(Request $request, PlatformRequirementFilterInterface $platformRequirementFilter): void
  13008. {
  13009. foreach ($request->getRequires() as $packageName => $constraint) {
  13010. if ($platformRequirementFilter->isIgnored($packageName)) {
  13011. continue;
  13012. } elseif ($platformRequirementFilter instanceof IgnoreListPlatformRequirementFilter) {
  13013. $constraint = $platformRequirementFilter->filterConstraint($packageName, $constraint);
  13014. }
  13015. if (!$this->pool->whatProvides($packageName, $constraint)) {
  13016. $problem = new Problem();
  13017. $problem->addRule(new GenericRule(array(), Rule::RULE_ROOT_REQUIRE, array('packageName' => $packageName, 'constraint' => $constraint)));
  13018. $this->problems[] = $problem;
  13019. }
  13020. }
  13021. }
  13022. public function solve(Request $request, PlatformRequirementFilterInterface $platformRequirementFilter = null): LockTransaction
  13023. {
  13024. $platformRequirementFilter = $platformRequirementFilter ?: PlatformRequirementFilterFactory::ignoreNothing();
  13025. $this->setupFixedMap($request);
  13026. $this->io->writeError('Generating rules', true, IOInterface::DEBUG);
  13027. $ruleSetGenerator = new RuleSetGenerator($this->policy, $this->pool);
  13028. $this->rules = $ruleSetGenerator->getRulesFor($request, $platformRequirementFilter);
  13029. unset($ruleSetGenerator);
  13030. $this->checkForRootRequireProblems($request, $platformRequirementFilter);
  13031. $this->decisions = new Decisions($this->pool);
  13032. $this->watchGraph = new RuleWatchGraph;
  13033. foreach ($this->rules as $rule) {
  13034. $this->watchGraph->insert(new RuleWatchNode($rule));
  13035. }
  13036. $this->makeAssertionRuleDecisions();
  13037. $this->io->writeError('Resolving dependencies through SAT', true, IOInterface::DEBUG);
  13038. $before = microtime(true);
  13039. $this->runSat();
  13040. $this->io->writeError('', true, IOInterface::DEBUG);
  13041. $this->io->writeError(sprintf('Dependency resolution completed in %.3f seconds', microtime(true) - $before), true, IOInterface::VERBOSE);
  13042. if ($this->problems) {
  13043. throw new SolverProblemsException($this->problems, $this->learnedPool);
  13044. }
  13045. return new LockTransaction($this->pool, $request->getPresentMap(), $request->getFixedPackagesMap(), $this->decisions);
  13046. }
  13047. protected function propagate(int $level): ?Rule
  13048. {
  13049. while ($this->decisions->validOffset($this->propagateIndex)) {
  13050. $decision = $this->decisions->atOffset($this->propagateIndex);
  13051. $conflict = $this->watchGraph->propagateLiteral(
  13052. $decision[Decisions::DECISION_LITERAL],
  13053. $level,
  13054. $this->decisions
  13055. );
  13056. $this->propagateIndex++;
  13057. if ($conflict) {
  13058. return $conflict;
  13059. }
  13060. }
  13061. return null;
  13062. }
  13063. private function revert(int $level): void
  13064. {
  13065. while (!$this->decisions->isEmpty()) {
  13066. $literal = $this->decisions->lastLiteral();
  13067. if ($this->decisions->undecided($literal)) {
  13068. break;
  13069. }
  13070. $decisionLevel = $this->decisions->decisionLevel($literal);
  13071. if ($decisionLevel <= $level) {
  13072. break;
  13073. }
  13074. $this->decisions->revertLast();
  13075. $this->propagateIndex = \count($this->decisions);
  13076. }
  13077. while (!empty($this->branches) && $this->branches[\count($this->branches) - 1][self::BRANCH_LEVEL] >= $level) {
  13078. array_pop($this->branches);
  13079. }
  13080. }
  13081. private function setPropagateLearn(int $level, $literal, Rule $rule): int
  13082. {
  13083. $level++;
  13084. $this->decisions->decide($literal, $level, $rule);
  13085. while (true) {
  13086. $rule = $this->propagate($level);
  13087. if (!$rule) {
  13088. break;
  13089. }
  13090. if ($level == 1) {
  13091. return $this->analyzeUnsolvable($rule);
  13092. }
  13093. list($learnLiteral, $newLevel, $newRule, $why) = $this->analyze($level, $rule);
  13094. if ($newLevel <= 0 || $newLevel >= $level) {
  13095. throw new SolverBugException(
  13096. "Trying to revert to invalid level ".$newLevel." from level ".$level."."
  13097. );
  13098. }
  13099. $level = $newLevel;
  13100. $this->revert($level);
  13101. $this->rules->add($newRule, RuleSet::TYPE_LEARNED);
  13102. $this->learnedWhy[spl_object_hash($newRule)] = $why;
  13103. $ruleNode = new RuleWatchNode($newRule);
  13104. $ruleNode->watch2OnHighest($this->decisions);
  13105. $this->watchGraph->insert($ruleNode);
  13106. $this->decisions->decide($learnLiteral, $level, $newRule);
  13107. }
  13108. return $level;
  13109. }
  13110. private function selectAndInstall(int $level, array $decisionQueue, Rule $rule): int
  13111. {
  13112. $literals = $this->policy->selectPreferredPackages($this->pool, $decisionQueue, $rule->getRequiredPackage());
  13113. $selectedLiteral = array_shift($literals);
  13114. if (\count($literals)) {
  13115. $this->branches[] = array($literals, $level);
  13116. }
  13117. return $this->setPropagateLearn($level, $selectedLiteral, $rule);
  13118. }
  13119. protected function analyze(int $level, Rule $rule): array
  13120. {
  13121. $analyzedRule = $rule;
  13122. $ruleLevel = 1;
  13123. $num = 0;
  13124. $l1num = 0;
  13125. $seen = array();
  13126. $learnedLiterals = array(null);
  13127. $decisionId = \count($this->decisions);
  13128. $this->learnedPool[] = array();
  13129. while (true) {
  13130. $this->learnedPool[\count($this->learnedPool) - 1][] = $rule;
  13131. foreach ($rule->getLiterals() as $literal) {
  13132. if ($rule instanceof MultiConflictRule && !$this->decisions->decided($literal)) {
  13133. continue;
  13134. }
  13135. if ($this->decisions->satisfy($literal)) {
  13136. continue;
  13137. }
  13138. if (isset($seen[abs($literal)])) {
  13139. continue;
  13140. }
  13141. $seen[abs($literal)] = true;
  13142. $l = $this->decisions->decisionLevel($literal);
  13143. if (1 === $l) {
  13144. $l1num++;
  13145. } elseif ($level === $l) {
  13146. $num++;
  13147. } else {
  13148. $learnedLiterals[] = $literal;
  13149. if ($l > $ruleLevel) {
  13150. $ruleLevel = $l;
  13151. }
  13152. }
  13153. }
  13154. unset($literal);
  13155. $l1retry = true;
  13156. while ($l1retry) {
  13157. $l1retry = false;
  13158. if (0 === $num && 0 === --$l1num) {
  13159. break 2;
  13160. }
  13161. while (true) {
  13162. if ($decisionId <= 0) {
  13163. throw new SolverBugException(
  13164. "Reached invalid decision id $decisionId while looking through $rule for a literal present in the analyzed rule $analyzedRule."
  13165. );
  13166. }
  13167. $decisionId--;
  13168. $decision = $this->decisions->atOffset($decisionId);
  13169. $literal = $decision[Decisions::DECISION_LITERAL];
  13170. if (isset($seen[abs($literal)])) {
  13171. break;
  13172. }
  13173. }
  13174. unset($seen[abs($literal)]);
  13175. if (0 !== $num && 0 === --$num) {
  13176. if ($literal < 0) {
  13177. $this->testFlagLearnedPositiveLiteral = true;
  13178. }
  13179. $learnedLiterals[0] = -$literal;
  13180. if (!$l1num) {
  13181. break 2;
  13182. }
  13183. foreach ($learnedLiterals as $i => $learnedLiteral) {
  13184. if ($i !== 0) {
  13185. unset($seen[abs($learnedLiteral)]);
  13186. }
  13187. }
  13188. $l1num++;
  13189. $l1retry = true;
  13190. } else {
  13191. $decision = $this->decisions->atOffset($decisionId);
  13192. $rule = $decision[Decisions::DECISION_REASON];
  13193. if ($rule instanceof MultiConflictRule) {
  13194. foreach ($rule->getLiterals() as $literal) {
  13195. if (!isset($seen[abs($literal)]) && $this->decisions->satisfy(-$literal)) {
  13196. $this->learnedPool[\count($this->learnedPool) - 1][] = $rule;
  13197. $l = $this->decisions->decisionLevel($literal);
  13198. if (1 === $l) {
  13199. $l1num++;
  13200. } elseif ($level === $l) {
  13201. $num++;
  13202. } else {
  13203. $learnedLiterals[] = $literal;
  13204. if ($l > $ruleLevel) {
  13205. $ruleLevel = $l;
  13206. }
  13207. }
  13208. $seen[abs($literal)] = true;
  13209. break;
  13210. }
  13211. }
  13212. $l1retry = true;
  13213. }
  13214. }
  13215. }
  13216. $decision = $this->decisions->atOffset($decisionId);
  13217. $rule = $decision[Decisions::DECISION_REASON];
  13218. }
  13219. $why = \count($this->learnedPool) - 1;
  13220. if (!$learnedLiterals[0]) {
  13221. throw new SolverBugException(
  13222. "Did not find a learnable literal in analyzed rule $analyzedRule."
  13223. );
  13224. }
  13225. $newRule = new GenericRule($learnedLiterals, Rule::RULE_LEARNED, $why);
  13226. return array($learnedLiterals[0], $ruleLevel, $newRule, $why);
  13227. }
  13228. private function analyzeUnsolvableRule(Problem $problem, Rule $conflictRule, array &$ruleSeen): void
  13229. {
  13230. $why = spl_object_hash($conflictRule);
  13231. $ruleSeen[$why] = true;
  13232. if ($conflictRule->getType() == RuleSet::TYPE_LEARNED) {
  13233. $learnedWhy = $this->learnedWhy[$why];
  13234. $problemRules = $this->learnedPool[$learnedWhy];
  13235. foreach ($problemRules as $problemRule) {
  13236. if (!isset($ruleSeen[spl_object_hash($problemRule)])) {
  13237. $this->analyzeUnsolvableRule($problem, $problemRule, $ruleSeen);
  13238. }
  13239. }
  13240. return;
  13241. }
  13242. if ($conflictRule->getType() == RuleSet::TYPE_PACKAGE) {
  13243. return;
  13244. }
  13245. $problem->nextSection();
  13246. $problem->addRule($conflictRule);
  13247. }
  13248. private function analyzeUnsolvable(Rule $conflictRule): int
  13249. {
  13250. $problem = new Problem();
  13251. $problem->addRule($conflictRule);
  13252. $ruleSeen = array();
  13253. $this->analyzeUnsolvableRule($problem, $conflictRule, $ruleSeen);
  13254. $this->problems[] = $problem;
  13255. $seen = array();
  13256. $literals = $conflictRule->getLiterals();
  13257. foreach ($literals as $literal) {
  13258. if ($this->decisions->satisfy($literal)) {
  13259. continue;
  13260. }
  13261. $seen[abs($literal)] = true;
  13262. }
  13263. foreach ($this->decisions as $decision) {
  13264. $literal = $decision[Decisions::DECISION_LITERAL];
  13265. if (!isset($seen[abs($literal)])) {
  13266. continue;
  13267. }
  13268. $why = $decision[Decisions::DECISION_REASON];
  13269. $problem->addRule($why);
  13270. $this->analyzeUnsolvableRule($problem, $why, $ruleSeen);
  13271. $literals = $why->getLiterals();
  13272. foreach ($literals as $literal) {
  13273. if ($this->decisions->satisfy($literal)) {
  13274. continue;
  13275. }
  13276. $seen[abs($literal)] = true;
  13277. }
  13278. }
  13279. return 0;
  13280. }
  13281. private function enableDisableLearnedRules(): void
  13282. {
  13283. foreach ($this->rules->getIteratorFor(RuleSet::TYPE_LEARNED) as $rule) {
  13284. $why = $this->learnedWhy[spl_object_hash($rule)];
  13285. $problemRules = $this->learnedPool[$why];
  13286. $foundDisabled = false;
  13287. foreach ($problemRules as $problemRule) {
  13288. if ($problemRule->isDisabled()) {
  13289. $foundDisabled = true;
  13290. break;
  13291. }
  13292. }
  13293. if ($foundDisabled && $rule->isEnabled()) {
  13294. $rule->disable();
  13295. } elseif (!$foundDisabled && $rule->isDisabled()) {
  13296. $rule->enable();
  13297. }
  13298. }
  13299. }
  13300. private function runSat(): void
  13301. {
  13302. $this->propagateIndex = 0;
  13303. $level = 1;
  13304. $systemLevel = $level + 1;
  13305. while (true) {
  13306. if (1 === $level) {
  13307. $conflictRule = $this->propagate($level);
  13308. if (null !== $conflictRule) {
  13309. if ($this->analyzeUnsolvable($conflictRule)) {
  13310. continue;
  13311. }
  13312. return;
  13313. }
  13314. }
  13315. if ($level < $systemLevel) {
  13316. $iterator = $this->rules->getIteratorFor(RuleSet::TYPE_REQUEST);
  13317. foreach ($iterator as $rule) {
  13318. if ($rule->isEnabled()) {
  13319. $decisionQueue = array();
  13320. $noneSatisfied = true;
  13321. foreach ($rule->getLiterals() as $literal) {
  13322. if ($this->decisions->satisfy($literal)) {
  13323. $noneSatisfied = false;
  13324. break;
  13325. }
  13326. if ($literal > 0 && $this->decisions->undecided($literal)) {
  13327. $decisionQueue[] = $literal;
  13328. }
  13329. }
  13330. if ($noneSatisfied && \count($decisionQueue)) {
  13331. $prunedQueue = array();
  13332. foreach ($decisionQueue as $literal) {
  13333. if (isset($this->fixedMap[abs($literal)])) {
  13334. $prunedQueue[] = $literal;
  13335. }
  13336. }
  13337. if (!empty($prunedQueue)) {
  13338. $decisionQueue = $prunedQueue;
  13339. }
  13340. }
  13341. if ($noneSatisfied && \count($decisionQueue)) {
  13342. $oLevel = $level;
  13343. $level = $this->selectAndInstall($level, $decisionQueue, $rule);
  13344. if (0 === $level) {
  13345. return;
  13346. }
  13347. if ($level <= $oLevel) {
  13348. break;
  13349. }
  13350. }
  13351. }
  13352. }
  13353. $systemLevel = $level + 1;
  13354. $iterator->next();
  13355. if ($iterator->valid()) {
  13356. continue;
  13357. }
  13358. }
  13359. if ($level < $systemLevel) {
  13360. $systemLevel = $level;
  13361. }
  13362. $rulesCount = \count($this->rules);
  13363. $pass = 1;
  13364. $this->io->writeError('Looking at all rules.', true, IOInterface::DEBUG);
  13365. for ($i = 0, $n = 0; $n < $rulesCount; $i++, $n++) {
  13366. if ($i == $rulesCount) {
  13367. if (1 === $pass) {
  13368. $this->io->writeError("Something's changed, looking at all rules again (pass #$pass)", false, IOInterface::DEBUG);
  13369. } else {
  13370. $this->io->overwriteError("Something's changed, looking at all rules again (pass #$pass)", false, null, IOInterface::DEBUG);
  13371. }
  13372. $i = 0;
  13373. $pass++;
  13374. }
  13375. $rule = $this->rules->ruleById[$i];
  13376. $literals = $rule->getLiterals();
  13377. if ($rule->isDisabled()) {
  13378. continue;
  13379. }
  13380. $decisionQueue = array();
  13381. foreach ($literals as $literal) {
  13382. if ($literal <= 0) {
  13383. if (!$this->decisions->decidedInstall($literal)) {
  13384. continue 2;
  13385. }
  13386. } else {
  13387. if ($this->decisions->decidedInstall($literal)) {
  13388. continue 2;
  13389. }
  13390. if ($this->decisions->undecided($literal)) {
  13391. $decisionQueue[] = $literal;
  13392. }
  13393. }
  13394. }
  13395. if (\count($decisionQueue) < 2) {
  13396. continue;
  13397. }
  13398. $level = $this->selectAndInstall($level, $decisionQueue, $rule);
  13399. if (0 === $level) {
  13400. return;
  13401. }
  13402. $rulesCount = \count($this->rules);
  13403. $n = -1;
  13404. }
  13405. if ($level < $systemLevel) {
  13406. continue;
  13407. }
  13408. if (\count($this->branches)) {
  13409. $lastLiteral = null;
  13410. $lastLevel = null;
  13411. $lastBranchIndex = 0;
  13412. $lastBranchOffset = 0;
  13413. for ($i = \count($this->branches) - 1; $i >= 0; $i--) {
  13414. list($literals, $l) = $this->branches[$i];
  13415. foreach ($literals as $offset => $literal) {
  13416. if ($literal && $literal > 0 && $this->decisions->decisionLevel($literal) > $l + 1) {
  13417. $lastLiteral = $literal;
  13418. $lastBranchIndex = $i;
  13419. $lastBranchOffset = $offset;
  13420. $lastLevel = $l;
  13421. }
  13422. }
  13423. }
  13424. if ($lastLiteral) {
  13425. unset($this->branches[$lastBranchIndex][self::BRANCH_LITERALS][$lastBranchOffset]);
  13426. $level = $lastLevel;
  13427. $this->revert($level);
  13428. $why = $this->decisions->lastReason();
  13429. $level = $this->setPropagateLearn($level, $lastLiteral, $why);
  13430. if ($level == 0) {
  13431. return;
  13432. }
  13433. continue;
  13434. }
  13435. }
  13436. break;
  13437. }
  13438. }
  13439. }
  13440. <?php declare(strict_types=1);
  13441. namespace Composer\DependencyResolver;
  13442. class SolverBugException extends \RuntimeException
  13443. {
  13444. public function __construct(string $message)
  13445. {
  13446. parent::__construct(
  13447. $message."\nThis exception was most likely caused by a bug in Composer.\n".
  13448. "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"
  13449. );
  13450. }
  13451. }
  13452. <?php declare(strict_types=1);
  13453. namespace Composer\DependencyResolver;
  13454. use Composer\Util\IniHelper;
  13455. use Composer\Repository\RepositorySet;
  13456. class SolverProblemsException extends \RuntimeException
  13457. {
  13458. public const ERROR_DEPENDENCY_RESOLUTION_FAILED = 2;
  13459. protected $problems;
  13460. protected $learnedPool;
  13461. public function __construct(array $problems, array $learnedPool)
  13462. {
  13463. $this->problems = $problems;
  13464. $this->learnedPool = $learnedPool;
  13465. parent::__construct('Failed resolving dependencies with '.count($problems).' problems, call getPrettyString to get formatted details', self::ERROR_DEPENDENCY_RESOLUTION_FAILED);
  13466. }
  13467. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, bool $isVerbose, bool $isDevExtraction = false): string
  13468. {
  13469. $installedMap = $request->getPresentMap(true);
  13470. $missingExtensions = array();
  13471. $isCausedByLock = false;
  13472. $problems = array();
  13473. foreach ($this->problems as $problem) {
  13474. $problems[] = $problem->getPrettyString($repositorySet, $request, $pool, $isVerbose, $installedMap, $this->learnedPool)."\n";
  13475. $missingExtensions = array_merge($missingExtensions, $this->getExtensionProblems($problem->getReasons()));
  13476. $isCausedByLock = $isCausedByLock || $problem->isCausedByLock($repositorySet, $request, $pool);
  13477. }
  13478. $i = 1;
  13479. $text = "\n";
  13480. foreach (array_unique($problems) as $problem) {
  13481. $text .= " Problem ".($i++).$problem;
  13482. }
  13483. $hints = array();
  13484. if (!$isDevExtraction && (strpos($text, 'could not be found') || strpos($text, 'no matching package found'))) {
  13485. $hints[] = "Potential causes:\n - A typo in the package name\n - The package is not available in a stable-enough version according to your minimum-stability setting\n see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.\n - It's a private package and you forgot to add a custom repository to find it\n\nRead <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.";
  13486. }
  13487. if (!empty($missingExtensions)) {
  13488. $hints[] = $this->createExtensionHint($missingExtensions);
  13489. }
  13490. if ($isCausedByLock && !$isDevExtraction && !$request->getUpdateAllowTransitiveRootDependencies()) {
  13491. $hints[] = "Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.";
  13492. }
  13493. if (strpos($text, 'found composer-plugin-api[2.0.0] but it does not match') && strpos($text, '- ocramius/package-versions')) {
  13494. $hints[] = "<warning>ocramius/package-versions only provides support for Composer 2 in 1.8+, which requires PHP 7.4.</warning>\nIf you can not upgrade PHP you can require <info>composer/package-versions-deprecated</info> to resolve this with PHP 7.0+.";
  13495. }
  13496. if (!class_exists('PHPUnit\Framework\TestCase', false)) {
  13497. if (strpos($text, 'found composer-plugin-api[2.0.0] but it does not match')) {
  13498. $hints[] = "You are using Composer 2, which some of your plugins seem to be incompatible with. Make sure you update your plugins or report a plugin-issue to ask them to support Composer 2.";
  13499. }
  13500. }
  13501. if ($hints) {
  13502. $text .= "\n" . implode("\n\n", $hints);
  13503. }
  13504. return $text;
  13505. }
  13506. public function getProblems(): array
  13507. {
  13508. return $this->problems;
  13509. }
  13510. private function createExtensionHint(array $missingExtensions): string
  13511. {
  13512. $paths = IniHelper::getAll();
  13513. if (count($paths) === 1 && empty($paths[0])) {
  13514. return '';
  13515. }
  13516. $ignoreExtensionsArguments = implode(" ", array_map(function ($extension) {
  13517. return "--ignore-platform-req=$extension";
  13518. }, $missingExtensions));
  13519. $text = "To enable extensions, verify that they are enabled in your .ini files:\n - ";
  13520. $text .= implode("\n - ", $paths);
  13521. $text .= "\nYou can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.";
  13522. $text .= "\nAlternatively, you can run Composer with `$ignoreExtensionsArguments` to temporarily ignore these required extensions.";
  13523. return $text;
  13524. }
  13525. private function getExtensionProblems(array $reasonSets): array
  13526. {
  13527. $missingExtensions = array();
  13528. foreach ($reasonSets as $reasonSet) {
  13529. foreach ($reasonSet as $rule) {
  13530. $required = $rule->getRequiredPackage();
  13531. if (null !== $required && 0 === strpos($required, 'ext-')) {
  13532. $missingExtensions[$required] = 1;
  13533. }
  13534. }
  13535. }
  13536. return array_keys($missingExtensions);
  13537. }
  13538. }
  13539. <?php declare(strict_types=1);
  13540. namespace Composer\DependencyResolver;
  13541. use Composer\Package\AliasPackage;
  13542. use Composer\Package\Link;
  13543. use Composer\Package\PackageInterface;
  13544. use Composer\Repository\PlatformRepository;
  13545. use Composer\DependencyResolver\Operation\OperationInterface;
  13546. class Transaction
  13547. {
  13548. protected $operations;
  13549. protected $presentPackages;
  13550. protected $resultPackageMap;
  13551. protected $resultPackagesByName = array();
  13552. public function __construct(array $presentPackages, array $resultPackages)
  13553. {
  13554. $this->presentPackages = $presentPackages;
  13555. $this->setResultPackageMaps($resultPackages);
  13556. $this->operations = $this->calculateOperations();
  13557. }
  13558. public function getOperations(): array
  13559. {
  13560. return $this->operations;
  13561. }
  13562. private function setResultPackageMaps(array $resultPackages): void
  13563. {
  13564. $packageSort = function (PackageInterface $a, PackageInterface $b): int {
  13565. if ($a->getName() == $b->getName()) {
  13566. if ($a instanceof AliasPackage != $b instanceof AliasPackage) {
  13567. return $a instanceof AliasPackage ? -1 : 1;
  13568. }
  13569. return strcmp($b->getVersion(), $a->getVersion());
  13570. }
  13571. return strcmp($b->getName(), $a->getName());
  13572. };
  13573. $this->resultPackageMap = array();
  13574. foreach ($resultPackages as $package) {
  13575. $this->resultPackageMap[spl_object_hash($package)] = $package;
  13576. foreach ($package->getNames() as $name) {
  13577. $this->resultPackagesByName[$name][] = $package;
  13578. }
  13579. }
  13580. uasort($this->resultPackageMap, $packageSort);
  13581. foreach ($this->resultPackagesByName as $name => $packages) {
  13582. uasort($this->resultPackagesByName[$name], $packageSort);
  13583. }
  13584. }
  13585. protected function calculateOperations(): array
  13586. {
  13587. $operations = array();
  13588. $presentPackageMap = array();
  13589. $removeMap = array();
  13590. $presentAliasMap = array();
  13591. $removeAliasMap = array();
  13592. foreach ($this->presentPackages as $package) {
  13593. if ($package instanceof AliasPackage) {
  13594. $presentAliasMap[$package->getName().'::'.$package->getVersion()] = $package;
  13595. $removeAliasMap[$package->getName().'::'.$package->getVersion()] = $package;
  13596. } else {
  13597. $presentPackageMap[$package->getName()] = $package;
  13598. $removeMap[$package->getName()] = $package;
  13599. }
  13600. }
  13601. $stack = $this->getRootPackages();
  13602. $visited = array();
  13603. $processed = array();
  13604. while (!empty($stack)) {
  13605. $package = array_pop($stack);
  13606. if (isset($processed[spl_object_hash($package)])) {
  13607. continue;
  13608. }
  13609. if (!isset($visited[spl_object_hash($package)])) {
  13610. $visited[spl_object_hash($package)] = true;
  13611. $stack[] = $package;
  13612. if ($package instanceof AliasPackage) {
  13613. $stack[] = $package->getAliasOf();
  13614. } else {
  13615. foreach ($package->getRequires() as $link) {
  13616. $possibleRequires = $this->getProvidersInResult($link);
  13617. foreach ($possibleRequires as $require) {
  13618. $stack[] = $require;
  13619. }
  13620. }
  13621. }
  13622. } elseif (!isset($processed[spl_object_hash($package)])) {
  13623. $processed[spl_object_hash($package)] = true;
  13624. if ($package instanceof AliasPackage) {
  13625. $aliasKey = $package->getName().'::'.$package->getVersion();
  13626. if (isset($presentAliasMap[$aliasKey])) {
  13627. unset($removeAliasMap[$aliasKey]);
  13628. } else {
  13629. $operations[] = new Operation\MarkAliasInstalledOperation($package);
  13630. }
  13631. } else {
  13632. if (isset($presentPackageMap[$package->getName()])) {
  13633. $source = $presentPackageMap[$package->getName()];
  13634. if ($package->getVersion() != $presentPackageMap[$package->getName()]->getVersion() ||
  13635. $package->getDistReference() !== $presentPackageMap[$package->getName()]->getDistReference() ||
  13636. $package->getSourceReference() !== $presentPackageMap[$package->getName()]->getSourceReference()
  13637. ) {
  13638. $operations[] = new Operation\UpdateOperation($source, $package);
  13639. }
  13640. unset($removeMap[$package->getName()]);
  13641. } else {
  13642. $operations[] = new Operation\InstallOperation($package);
  13643. unset($removeMap[$package->getName()]);
  13644. }
  13645. }
  13646. }
  13647. }
  13648. foreach ($removeMap as $name => $package) {
  13649. array_unshift($operations, new Operation\UninstallOperation($package));
  13650. }
  13651. foreach ($removeAliasMap as $nameVersion => $package) {
  13652. $operations[] = new Operation\MarkAliasUninstalledOperation($package);
  13653. }
  13654. $operations = $this->movePluginsToFront($operations);
  13655. $operations = $this->moveUninstallsToFront($operations);
  13656. return $this->operations = $operations;
  13657. }
  13658. protected function getRootPackages(): array
  13659. {
  13660. $roots = $this->resultPackageMap;
  13661. foreach ($this->resultPackageMap as $packageHash => $package) {
  13662. if (!isset($roots[$packageHash])) {
  13663. continue;
  13664. }
  13665. foreach ($package->getRequires() as $link) {
  13666. $possibleRequires = $this->getProvidersInResult($link);
  13667. foreach ($possibleRequires as $require) {
  13668. if ($require !== $package) {
  13669. unset($roots[spl_object_hash($require)]);
  13670. }
  13671. }
  13672. }
  13673. }
  13674. return $roots;
  13675. }
  13676. protected function getProvidersInResult(Link $link): array
  13677. {
  13678. if (!isset($this->resultPackagesByName[$link->getTarget()])) {
  13679. return array();
  13680. }
  13681. return $this->resultPackagesByName[$link->getTarget()];
  13682. }
  13683. private function movePluginsToFront(array $operations): array
  13684. {
  13685. $dlModifyingPluginsNoDeps = array();
  13686. $dlModifyingPluginsWithDeps = array();
  13687. $dlModifyingPluginRequires = array();
  13688. $pluginsNoDeps = array();
  13689. $pluginsWithDeps = array();
  13690. $pluginRequires = array();
  13691. foreach (array_reverse($operations, true) as $idx => $op) {
  13692. if ($op instanceof Operation\InstallOperation) {
  13693. $package = $op->getPackage();
  13694. } elseif ($op instanceof Operation\UpdateOperation) {
  13695. $package = $op->getTargetPackage();
  13696. } else {
  13697. continue;
  13698. }
  13699. $isDownloadsModifyingPlugin = $package->getType() === 'composer-plugin' && ($extra = $package->getExtra()) && isset($extra['plugin-modifies-downloads']) && $extra['plugin-modifies-downloads'] === true;
  13700. if ($isDownloadsModifyingPlugin || count(array_intersect($package->getNames(), $dlModifyingPluginRequires))) {
  13701. $requires = array_filter(array_keys($package->getRequires()), function ($req): bool {
  13702. return !PlatformRepository::isPlatformPackage($req);
  13703. });
  13704. if ($isDownloadsModifyingPlugin && !count($requires)) {
  13705. array_unshift($dlModifyingPluginsNoDeps, $op);
  13706. } else {
  13707. $dlModifyingPluginRequires = array_merge($dlModifyingPluginRequires, $requires);
  13708. array_unshift($dlModifyingPluginsWithDeps, $op);
  13709. }
  13710. unset($operations[$idx]);
  13711. continue;
  13712. }
  13713. $isPlugin = $package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer';
  13714. if ($isPlugin || count(array_intersect($package->getNames(), $pluginRequires))) {
  13715. $requires = array_filter(array_keys($package->getRequires()), function ($req): bool {
  13716. return !PlatformRepository::isPlatformPackage($req);
  13717. });
  13718. if ($isPlugin && !count($requires)) {
  13719. array_unshift($pluginsNoDeps, $op);
  13720. } else {
  13721. $pluginRequires = array_merge($pluginRequires, $requires);
  13722. array_unshift($pluginsWithDeps, $op);
  13723. }
  13724. unset($operations[$idx]);
  13725. }
  13726. }
  13727. return array_merge($dlModifyingPluginsNoDeps, $dlModifyingPluginsWithDeps, $pluginsNoDeps, $pluginsWithDeps, $operations);
  13728. }
  13729. private function moveUninstallsToFront(array $operations): array
  13730. {
  13731. $uninstOps = array();
  13732. foreach ($operations as $idx => $op) {
  13733. if ($op instanceof Operation\UninstallOperation || $op instanceof Operation\MarkAliasUninstalledOperation) {
  13734. $uninstOps[] = $op;
  13735. unset($operations[$idx]);
  13736. }
  13737. }
  13738. return array_merge($uninstOps, $operations);
  13739. }
  13740. }
  13741. <?php declare(strict_types=1);
  13742. namespace Composer\Downloader;
  13743. use Composer\Package\PackageInterface;
  13744. use Composer\Util\Platform;
  13745. use Symfony\Component\Finder\Finder;
  13746. use React\Promise\PromiseInterface;
  13747. use Composer\DependencyResolver\Operation\InstallOperation;
  13748. abstract class ArchiveDownloader extends FileDownloader
  13749. {
  13750. protected $cleanupExecuted = array();
  13751. public function prepare(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null): PromiseInterface
  13752. {
  13753. unset($this->cleanupExecuted[$package->getName()]);
  13754. return parent::prepare($type, $package, $path, $prevPackage);
  13755. }
  13756. public function cleanup(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null): PromiseInterface
  13757. {
  13758. $this->cleanupExecuted[$package->getName()] = true;
  13759. return parent::cleanup($type, $package, $path, $prevPackage);
  13760. }
  13761. public function install(PackageInterface $package, string $path, bool $output = true): PromiseInterface
  13762. {
  13763. if ($output) {
  13764. $this->io->writeError(" - " . InstallOperation::format($package) . $this->getInstallOperationAppendix($package, $path));
  13765. }
  13766. $vendorDir = $this->config->get('vendor-dir');
  13767. if (false === strpos($this->filesystem->normalizePath($vendorDir), $this->filesystem->normalizePath($path.DIRECTORY_SEPARATOR))) {
  13768. $this->filesystem->emptyDirectory($path);
  13769. }
  13770. do {
  13771. $temporaryDir = $vendorDir.'/composer/'.substr(md5(uniqid('', true)), 0, 8);
  13772. } while (is_dir($temporaryDir));
  13773. $this->addCleanupPath($package, $temporaryDir);
  13774. if (!is_dir($path) || realpath($path) !== Platform::getCwd()) {
  13775. $this->addCleanupPath($package, $path);
  13776. }
  13777. $this->filesystem->ensureDirectoryExists($temporaryDir);
  13778. $fileName = $this->getFileName($package, $path);
  13779. $filesystem = $this->filesystem;
  13780. $cleanup = function () use ($path, $filesystem, $temporaryDir, $package) {
  13781. $this->clearLastCacheWrite($package);
  13782. $filesystem->removeDirectory($temporaryDir);
  13783. if (is_dir($path) && realpath($path) !== Platform::getCwd()) {
  13784. $filesystem->removeDirectory($path);
  13785. }
  13786. $this->removeCleanupPath($package, $temporaryDir);
  13787. $this->removeCleanupPath($package, realpath($path));
  13788. };
  13789. try {
  13790. $promise = $this->extract($package, $fileName, $temporaryDir);
  13791. } catch (\Exception $e) {
  13792. $cleanup();
  13793. throw $e;
  13794. }
  13795. return $promise->then(function () use ($package, $filesystem, $fileName, $temporaryDir, $path): \React\Promise\PromiseInterface {
  13796. if (file_exists($fileName)) {
  13797. $filesystem->unlink($fileName);
  13798. }
  13799. $getFolderContent = function ($dir): array {
  13800. $finder = Finder::create()
  13801. ->ignoreVCS(false)
  13802. ->ignoreDotFiles(false)
  13803. ->notName('.DS_Store')
  13804. ->depth(0)
  13805. ->in($dir);
  13806. return iterator_to_array($finder);
  13807. };
  13808. $renameRecursively = null;
  13809. $renameRecursively = function ($from, $to) use ($filesystem, $getFolderContent, $package, &$renameRecursively) {
  13810. $contentDir = $getFolderContent($from);
  13811. foreach ($contentDir as $file) {
  13812. $file = (string) $file;
  13813. if (is_dir($to . '/' . basename($file))) {
  13814. if (!is_dir($file)) {
  13815. throw new \RuntimeException('Installing '.$package.' would lead to overwriting the '.$to.'/'.basename($file).' directory with a file from the package, invalid operation.');
  13816. }
  13817. $renameRecursively($file, $to . '/' . basename($file));
  13818. } else {
  13819. $filesystem->rename($file, $to . '/' . basename($file));
  13820. }
  13821. }
  13822. };
  13823. $renameAsOne = false;
  13824. if (!file_exists($path)) {
  13825. $renameAsOne = true;
  13826. } elseif ($filesystem->isDirEmpty($path)) {
  13827. try {
  13828. if ($filesystem->removeDirectoryPhp($path)) {
  13829. $renameAsOne = true;
  13830. }
  13831. } catch (\RuntimeException $e) {
  13832. }
  13833. }
  13834. $contentDir = $getFolderContent($temporaryDir);
  13835. $singleDirAtTopLevel = 1 === count($contentDir) && is_dir((string) reset($contentDir));
  13836. if ($renameAsOne) {
  13837. if ($singleDirAtTopLevel) {
  13838. $extractedDir = (string) reset($contentDir);
  13839. } else {
  13840. $extractedDir = $temporaryDir;
  13841. }
  13842. $filesystem->rename($extractedDir, $path);
  13843. } else {
  13844. $from = $temporaryDir;
  13845. if ($singleDirAtTopLevel) {
  13846. $from = (string) reset($contentDir);
  13847. }
  13848. $renameRecursively($from, $path);
  13849. }
  13850. $promise = $filesystem->removeDirectoryAsync($temporaryDir);
  13851. return $promise->then(function () use ($package, $path, $temporaryDir) {
  13852. $this->removeCleanupPath($package, $temporaryDir);
  13853. $this->removeCleanupPath($package, $path);
  13854. });
  13855. }, function ($e) use ($cleanup) {
  13856. $cleanup();
  13857. throw $e;
  13858. });
  13859. }
  13860. protected function getInstallOperationAppendix(PackageInterface $package, string $path): string
  13861. {
  13862. return ': Extracting archive';
  13863. }
  13864. abstract protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface;
  13865. }
  13866. <?php declare(strict_types=1);
  13867. namespace Composer\Downloader;
  13868. use Composer\Package\PackageInterface;
  13869. interface ChangeReportInterface
  13870. {
  13871. public function getLocalChanges(PackageInterface $package, string $path): ?string;
  13872. }
  13873. <?php declare(strict_types=1);
  13874. namespace Composer\Downloader;
  13875. use Composer\Package\PackageInterface;
  13876. use Composer\IO\IOInterface;
  13877. use Composer\Pcre\Preg;
  13878. use Composer\Util\Filesystem;
  13879. use Composer\Exception\IrrecoverableDownloadException;
  13880. use React\Promise\PromiseInterface;
  13881. class DownloadManager
  13882. {
  13883. private $io;
  13884. private $preferDist = false;
  13885. private $preferSource;
  13886. private $packagePreferences = array();
  13887. private $filesystem;
  13888. private $downloaders = array();
  13889. public function __construct(IOInterface $io, bool $preferSource = false, Filesystem $filesystem = null)
  13890. {
  13891. $this->io = $io;
  13892. $this->preferSource = $preferSource;
  13893. $this->filesystem = $filesystem ?: new Filesystem();
  13894. }
  13895. public function setPreferSource(bool $preferSource): self
  13896. {
  13897. $this->preferSource = $preferSource;
  13898. return $this;
  13899. }
  13900. public function setPreferDist(bool $preferDist): self
  13901. {
  13902. $this->preferDist = $preferDist;
  13903. return $this;
  13904. }
  13905. public function setPreferences(array $preferences): self
  13906. {
  13907. $this->packagePreferences = $preferences;
  13908. return $this;
  13909. }
  13910. public function setDownloader(string $type, DownloaderInterface $downloader): self
  13911. {
  13912. $type = strtolower($type);
  13913. $this->downloaders[$type] = $downloader;
  13914. return $this;
  13915. }
  13916. public function getDownloader(string $type): DownloaderInterface
  13917. {
  13918. $type = strtolower($type);
  13919. if (!isset($this->downloaders[$type])) {
  13920. throw new \InvalidArgumentException(sprintf('Unknown downloader type: %s. Available types: %s.', $type, implode(', ', array_keys($this->downloaders))));
  13921. }
  13922. return $this->downloaders[$type];
  13923. }
  13924. public function getDownloaderForPackage(PackageInterface $package): ?DownloaderInterface
  13925. {
  13926. $installationSource = $package->getInstallationSource();
  13927. if ('metapackage' === $package->getType()) {
  13928. return null;
  13929. }
  13930. if ('dist' === $installationSource) {
  13931. $downloader = $this->getDownloader($package->getDistType());
  13932. } elseif ('source' === $installationSource) {
  13933. $downloader = $this->getDownloader($package->getSourceType());
  13934. } else {
  13935. throw new \InvalidArgumentException(
  13936. 'Package '.$package.' does not have an installation source set'
  13937. );
  13938. }
  13939. if ($installationSource !== $downloader->getInstallationSource()) {
  13940. throw new \LogicException(sprintf(
  13941. 'Downloader "%s" is a %s type downloader and can not be used to download %s for package %s',
  13942. get_class($downloader),
  13943. $downloader->getInstallationSource(),
  13944. $installationSource,
  13945. $package
  13946. ));
  13947. }
  13948. return $downloader;
  13949. }
  13950. public function getDownloaderType(DownloaderInterface $downloader): string
  13951. {
  13952. return array_search($downloader, $this->downloaders);
  13953. }
  13954. public function download(PackageInterface $package, string $targetDir, PackageInterface $prevPackage = null): PromiseInterface
  13955. {
  13956. $targetDir = $this->normalizeTargetDir($targetDir);
  13957. $this->filesystem->ensureDirectoryExists(dirname($targetDir));
  13958. $sources = $this->getAvailableSources($package, $prevPackage);
  13959. $io = $this->io;
  13960. $download = function ($retry = false) use (&$sources, $io, $package, $targetDir, &$download, $prevPackage) {
  13961. $source = array_shift($sources);
  13962. if ($retry) {
  13963. $io->writeError(' <warning>Now trying to download from ' . $source . '</warning>');
  13964. }
  13965. $package->setInstallationSource($source);
  13966. $downloader = $this->getDownloaderForPackage($package);
  13967. if (!$downloader) {
  13968. return \React\Promise\resolve(null);
  13969. }
  13970. $handleError = function ($e) use ($sources, $source, $package, $io, $download) {
  13971. if ($e instanceof \RuntimeException && !$e instanceof IrrecoverableDownloadException) {
  13972. if (!$sources) {
  13973. throw $e;
  13974. }
  13975. $io->writeError(
  13976. ' <warning>Failed to download '.
  13977. $package->getPrettyName().
  13978. ' from ' . $source . ': '.
  13979. $e->getMessage().'</warning>'
  13980. );
  13981. return $download(true);
  13982. }
  13983. throw $e;
  13984. };
  13985. try {
  13986. $result = $downloader->download($package, $targetDir, $prevPackage);
  13987. } catch (\Exception $e) {
  13988. return $handleError($e);
  13989. }
  13990. $res = $result->then(function ($res) {
  13991. return $res;
  13992. }, $handleError);
  13993. return $res;
  13994. };
  13995. return $download();
  13996. }
  13997. public function prepare(string $type, PackageInterface $package, string $targetDir, PackageInterface $prevPackage = null): PromiseInterface
  13998. {
  13999. $targetDir = $this->normalizeTargetDir($targetDir);
  14000. $downloader = $this->getDownloaderForPackage($package);
  14001. if ($downloader) {
  14002. return $downloader->prepare($type, $package, $targetDir, $prevPackage);
  14003. }
  14004. return \React\Promise\resolve(null);
  14005. }
  14006. public function install(PackageInterface $package, string $targetDir): PromiseInterface
  14007. {
  14008. $targetDir = $this->normalizeTargetDir($targetDir);
  14009. $downloader = $this->getDownloaderForPackage($package);
  14010. if ($downloader) {
  14011. return $downloader->install($package, $targetDir);
  14012. }
  14013. return \React\Promise\resolve(null);
  14014. }
  14015. public function update(PackageInterface $initial, PackageInterface $target, string $targetDir): PromiseInterface
  14016. {
  14017. $targetDir = $this->normalizeTargetDir($targetDir);
  14018. $downloader = $this->getDownloaderForPackage($target);
  14019. $initialDownloader = $this->getDownloaderForPackage($initial);
  14020. if (!$initialDownloader && !$downloader) {
  14021. return \React\Promise\resolve(null);
  14022. }
  14023. if (!$downloader) {
  14024. return $initialDownloader->remove($initial, $targetDir);
  14025. }
  14026. $initialType = $this->getDownloaderType($initialDownloader);
  14027. $targetType = $this->getDownloaderType($downloader);
  14028. if ($initialType === $targetType) {
  14029. try {
  14030. return $downloader->update($initial, $target, $targetDir);
  14031. } catch (\RuntimeException $e) {
  14032. if (!$this->io->isInteractive()) {
  14033. throw $e;
  14034. }
  14035. $this->io->writeError('<error> Update failed ('.$e->getMessage().')</error>');
  14036. if (!$this->io->askConfirmation(' Would you like to try reinstalling the package instead [<comment>yes</comment>]? ')) {
  14037. throw $e;
  14038. }
  14039. }
  14040. }
  14041. $promise = $initialDownloader->remove($initial, $targetDir);
  14042. return $promise->then(function ($res) use ($target, $targetDir): PromiseInterface {
  14043. return $this->install($target, $targetDir);
  14044. });
  14045. }
  14046. public function remove(PackageInterface $package, string $targetDir): PromiseInterface
  14047. {
  14048. $targetDir = $this->normalizeTargetDir($targetDir);
  14049. $downloader = $this->getDownloaderForPackage($package);
  14050. if ($downloader) {
  14051. return $downloader->remove($package, $targetDir);
  14052. }
  14053. return \React\Promise\resolve(null);
  14054. }
  14055. public function cleanup(string $type, PackageInterface $package, string $targetDir, PackageInterface $prevPackage = null): PromiseInterface
  14056. {
  14057. $targetDir = $this->normalizeTargetDir($targetDir);
  14058. $downloader = $this->getDownloaderForPackage($package);
  14059. if ($downloader) {
  14060. return $downloader->cleanup($type, $package, $targetDir, $prevPackage);
  14061. }
  14062. return \React\Promise\resolve(null);
  14063. }
  14064. protected function resolvePackageInstallPreference(PackageInterface $package): string
  14065. {
  14066. foreach ($this->packagePreferences as $pattern => $preference) {
  14067. $pattern = '{^'.str_replace('\\*', '.*', preg_quote($pattern)).'$}i';
  14068. if (Preg::isMatch($pattern, $package->getName())) {
  14069. if ('dist' === $preference || (!$package->isDev() && 'auto' === $preference)) {
  14070. return 'dist';
  14071. }
  14072. return 'source';
  14073. }
  14074. }
  14075. return $package->isDev() ? 'source' : 'dist';
  14076. }
  14077. private function getAvailableSources(PackageInterface $package, PackageInterface $prevPackage = null): array
  14078. {
  14079. $sourceType = $package->getSourceType();
  14080. $distType = $package->getDistType();
  14081. $sources = array();
  14082. if ($sourceType) {
  14083. $sources[] = 'source';
  14084. }
  14085. if ($distType) {
  14086. $sources[] = 'dist';
  14087. }
  14088. if (empty($sources)) {
  14089. throw new \InvalidArgumentException('Package '.$package.' must have a source or dist specified');
  14090. }
  14091. if (
  14092. $prevPackage
  14093. && in_array($prevPackage->getInstallationSource(), $sources, true)
  14094. && !(!$prevPackage->isDev() && $prevPackage->getInstallationSource() === 'dist' && $package->isDev())
  14095. ) {
  14096. $prevSource = $prevPackage->getInstallationSource();
  14097. usort($sources, function ($a, $b) use ($prevSource): int {
  14098. return $a === $prevSource ? -1 : 1;
  14099. });
  14100. return $sources;
  14101. }
  14102. if (!$this->preferSource && ($this->preferDist || 'dist' === $this->resolvePackageInstallPreference($package))) {
  14103. $sources = array_reverse($sources);
  14104. }
  14105. return $sources;
  14106. }
  14107. private function normalizeTargetDir(string $dir): string
  14108. {
  14109. if ($dir === '\\' || $dir === '/') {
  14110. return $dir;
  14111. }
  14112. return rtrim($dir, '\\/');
  14113. }
  14114. }
  14115. <?php declare(strict_types=1);
  14116. namespace Composer\Downloader;
  14117. use Composer\Package\PackageInterface;
  14118. use React\Promise\PromiseInterface;
  14119. interface DownloaderInterface
  14120. {
  14121. public function getInstallationSource(): string;
  14122. public function download(PackageInterface $package, string $path, PackageInterface $prevPackage = null): PromiseInterface;
  14123. public function prepare(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null): PromiseInterface;
  14124. public function install(PackageInterface $package, string $path): PromiseInterface;
  14125. public function update(PackageInterface $initial, PackageInterface $target, string $path): PromiseInterface;
  14126. public function remove(PackageInterface $package, string $path): PromiseInterface;
  14127. public function cleanup(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null): PromiseInterface;
  14128. }
  14129. <?php declare(strict_types=1);
  14130. namespace Composer\Downloader;
  14131. use Composer\Package\PackageInterface;
  14132. interface DvcsDownloaderInterface
  14133. {
  14134. public function getUnpushedChanges(PackageInterface $package, string $path): ?string;
  14135. }
  14136. <?php declare(strict_types=1);
  14137. namespace Composer\Downloader;
  14138. use Composer\Config;
  14139. use Composer\Cache;
  14140. use Composer\IO\IOInterface;
  14141. use Composer\IO\NullIO;
  14142. use Composer\Exception\IrrecoverableDownloadException;
  14143. use Composer\Package\Comparer\Comparer;
  14144. use Composer\DependencyResolver\Operation\UpdateOperation;
  14145. use Composer\DependencyResolver\Operation\InstallOperation;
  14146. use Composer\DependencyResolver\Operation\UninstallOperation;
  14147. use Composer\Package\PackageInterface;
  14148. use Composer\Plugin\PluginEvents;
  14149. use Composer\Plugin\PostFileDownloadEvent;
  14150. use Composer\Plugin\PreFileDownloadEvent;
  14151. use Composer\EventDispatcher\EventDispatcher;
  14152. use Composer\Util\Filesystem;
  14153. use Composer\Util\Platform;
  14154. use Composer\Util\Silencer;
  14155. use Composer\Util\HttpDownloader;
  14156. use Composer\Util\Url as UrlUtil;
  14157. use Composer\Util\ProcessExecutor;
  14158. use React\Promise\PromiseInterface;
  14159. class FileDownloader implements DownloaderInterface, ChangeReportInterface
  14160. {
  14161. protected $io;
  14162. protected $config;
  14163. protected $httpDownloader;
  14164. protected $filesystem;
  14165. protected $cache;
  14166. protected $eventDispatcher;
  14167. protected $process;
  14168. public static $downloadMetadata = array();
  14169. private $lastCacheWrites = array();
  14170. private $additionalCleanupPaths = array();
  14171. public function __construct(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, Cache $cache = null, Filesystem $filesystem = null, ProcessExecutor $process = null)
  14172. {
  14173. $this->io = $io;
  14174. $this->config = $config;
  14175. $this->eventDispatcher = $eventDispatcher;
  14176. $this->httpDownloader = $httpDownloader;
  14177. $this->cache = $cache;
  14178. $this->process = $process ?? new ProcessExecutor($io);
  14179. $this->filesystem = $filesystem ?: new Filesystem($this->process);
  14180. if ($this->cache && $this->cache->gcIsNecessary()) {
  14181. $this->io->writeError('Running cache garbage collection', true, IOInterface::VERY_VERBOSE);
  14182. $this->cache->gc((int) $config->get('cache-files-ttl'), (int) $config->get('cache-files-maxsize'));
  14183. }
  14184. }
  14185. public function getInstallationSource(): string
  14186. {
  14187. return 'dist';
  14188. }
  14189. public function download(PackageInterface $package, string $path, PackageInterface $prevPackage = null, bool $output = true): PromiseInterface
  14190. {
  14191. if (!$package->getDistUrl()) {
  14192. throw new \InvalidArgumentException('The given package is missing url information');
  14193. }
  14194. $cacheKeyGenerator = function (PackageInterface $package, $key): string {
  14195. $cacheKey = sha1($key);
  14196. return $package->getName().'/'.$cacheKey.'.'.$package->getDistType();
  14197. };
  14198. $retries = 3;
  14199. $distUrls = $package->getDistUrls();
  14200. $urls = array();
  14201. foreach ($distUrls as $index => $url) {
  14202. $processedUrl = $this->processUrl($package, $url);
  14203. $urls[$index] = array(
  14204. 'base' => $url,
  14205. 'processed' => $processedUrl,
  14206. 'cacheKey' => $cacheKeyGenerator($package, $processedUrl),
  14207. );
  14208. }
  14209. $fileName = $this->getFileName($package, $path);
  14210. $this->filesystem->ensureDirectoryExists($path);
  14211. $this->filesystem->ensureDirectoryExists(dirname($fileName));
  14212. $io = $this->io;
  14213. $cache = $this->cache;
  14214. $httpDownloader = $this->httpDownloader;
  14215. $eventDispatcher = $this->eventDispatcher;
  14216. $filesystem = $this->filesystem;
  14217. $accept = null;
  14218. $reject = null;
  14219. $download = function () use ($io, $output, $httpDownloader, $cache, $cacheKeyGenerator, $eventDispatcher, $package, $fileName, &$urls, &$accept, &$reject) {
  14220. $url = reset($urls);
  14221. $index = key($urls);
  14222. if ($eventDispatcher) {
  14223. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $httpDownloader, $url['processed'], 'package', $package);
  14224. $eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  14225. if ($preFileDownloadEvent->getCustomCacheKey() !== null) {
  14226. $url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getCustomCacheKey());
  14227. } elseif ($preFileDownloadEvent->getProcessedUrl() !== $url['processed']) {
  14228. $url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getProcessedUrl());
  14229. }
  14230. $url['processed'] = $preFileDownloadEvent->getProcessedUrl();
  14231. }
  14232. $urls[$index] = $url;
  14233. $checksum = $package->getDistSha1Checksum();
  14234. $cacheKey = $url['cacheKey'];
  14235. if ($cache && (!$checksum || $checksum === $cache->sha1($cacheKey)) && $cache->copyTo($cacheKey, $fileName)) {
  14236. if ($output) {
  14237. $io->writeError(" - Loading <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>) from cache", true, IOInterface::VERY_VERBOSE);
  14238. }
  14239. if (!$cache->isReadOnly()) {
  14240. $this->lastCacheWrites[$package->getName()] = $cacheKey;
  14241. }
  14242. $result = \React\Promise\resolve($fileName);
  14243. } else {
  14244. if ($output) {
  14245. $io->writeError(" - Downloading <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
  14246. }
  14247. $result = $httpDownloader->addCopy($url['processed'], $fileName, $package->getTransportOptions())
  14248. ->then($accept, $reject);
  14249. }
  14250. return $result->then(function ($result) use ($fileName, $checksum, $url, $package, $eventDispatcher): string {
  14251. if (null === $result) {
  14252. return $fileName;
  14253. }
  14254. if (!file_exists($fileName)) {
  14255. throw new \UnexpectedValueException($url['base'].' could not be saved to '.$fileName.', make sure the'
  14256. .' directory is writable and you have internet connectivity');
  14257. }
  14258. if ($checksum && hash_file('sha1', $fileName) !== $checksum) {
  14259. throw new \UnexpectedValueException('The checksum verification of the file failed (downloaded from '.$url['base'].')');
  14260. }
  14261. if ($eventDispatcher) {
  14262. $postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, $fileName, $checksum, $url['processed'], 'package', $package);
  14263. $eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
  14264. }
  14265. return $fileName;
  14266. });
  14267. };
  14268. $accept = function ($response) use ($cache, $package, $fileName, &$urls): string {
  14269. $url = reset($urls);
  14270. $cacheKey = $url['cacheKey'];
  14271. FileDownloader::$downloadMetadata[$package->getName()] = @filesize($fileName) ?: $response->getHeader('Content-Length') ?: '?';
  14272. if ($cache && !$cache->isReadOnly()) {
  14273. $this->lastCacheWrites[$package->getName()] = $cacheKey;
  14274. $cache->copyFrom($cacheKey, $fileName);
  14275. }
  14276. $response->collect();
  14277. return $fileName;
  14278. };
  14279. $reject = function ($e) use ($io, &$urls, $download, $fileName, $package, &$retries, $filesystem) {
  14280. if (file_exists($fileName)) {
  14281. $filesystem->unlink($fileName);
  14282. }
  14283. $this->clearLastCacheWrite($package);
  14284. if ($e instanceof IrrecoverableDownloadException) {
  14285. throw $e;
  14286. }
  14287. if ($e instanceof MaxFileSizeExceededException) {
  14288. throw $e;
  14289. }
  14290. if ($e instanceof TransportException) {
  14291. if ((0 !== $e->getCode() && !in_array($e->getCode(), array(500, 502, 503, 504))) || !$retries) {
  14292. $retries = 0;
  14293. }
  14294. }
  14295. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  14296. $retries = 0;
  14297. $urls = array();
  14298. }
  14299. if ($retries) {
  14300. usleep(500000);
  14301. $retries--;
  14302. return $download();
  14303. }
  14304. array_shift($urls);
  14305. if ($urls) {
  14306. if ($io->isDebug()) {
  14307. $io->writeError(' Failed downloading '.$package->getName().': ['.get_class($e).'] '.$e->getCode().': '.$e->getMessage());
  14308. $io->writeError(' Trying the next URL for '.$package->getName());
  14309. } else {
  14310. $io->writeError(' Failed downloading '.$package->getName().', trying the next URL ('.$e->getCode().': '.$e->getMessage().')');
  14311. }
  14312. $retries = 3;
  14313. usleep(100000);
  14314. return $download();
  14315. }
  14316. throw $e;
  14317. };
  14318. return $download();
  14319. }
  14320. public function prepare(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null): PromiseInterface
  14321. {
  14322. return \React\Promise\resolve(null);
  14323. }
  14324. public function cleanup(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null): PromiseInterface
  14325. {
  14326. $fileName = $this->getFileName($package, $path);
  14327. if (file_exists($fileName)) {
  14328. $this->filesystem->unlink($fileName);
  14329. }
  14330. $dirsToCleanUp = array(
  14331. $this->config->get('vendor-dir').'/composer/',
  14332. $this->config->get('vendor-dir'),
  14333. $path,
  14334. );
  14335. if (isset($this->additionalCleanupPaths[$package->getName()])) {
  14336. foreach ($this->additionalCleanupPaths[$package->getName()] as $path) {
  14337. $this->filesystem->remove($path);
  14338. }
  14339. }
  14340. foreach ($dirsToCleanUp as $dir) {
  14341. if (is_dir($dir) && $this->filesystem->isDirEmpty($dir) && realpath($dir) !== Platform::getCwd()) {
  14342. $this->filesystem->removeDirectoryPhp($dir);
  14343. }
  14344. }
  14345. return \React\Promise\resolve(null);
  14346. }
  14347. public function install(PackageInterface $package, string $path, bool $output = true): PromiseInterface
  14348. {
  14349. if ($output) {
  14350. $this->io->writeError(" - " . InstallOperation::format($package));
  14351. }
  14352. $this->filesystem->emptyDirectory($path);
  14353. $this->filesystem->ensureDirectoryExists($path);
  14354. $this->filesystem->rename($this->getFileName($package, $path), $path . '/' . pathinfo(parse_url(strtr((string) $package->getDistUrl(), '\\', '/'), PHP_URL_PATH), PATHINFO_BASENAME));
  14355. if ($package->getBinaries()) {
  14356. foreach ($package->getBinaries() as $bin) {
  14357. if (file_exists($path . '/' . $bin) && !is_executable($path . '/' . $bin)) {
  14358. Silencer::call('chmod', $path . '/' . $bin, 0777 & ~umask());
  14359. }
  14360. }
  14361. }
  14362. return \React\Promise\resolve(null);
  14363. }
  14364. protected function clearLastCacheWrite(PackageInterface $package): void
  14365. {
  14366. if ($this->cache && isset($this->lastCacheWrites[$package->getName()])) {
  14367. $this->cache->remove($this->lastCacheWrites[$package->getName()]);
  14368. unset($this->lastCacheWrites[$package->getName()]);
  14369. }
  14370. }
  14371. protected function addCleanupPath(PackageInterface $package, string $path): void
  14372. {
  14373. $this->additionalCleanupPaths[$package->getName()][] = $path;
  14374. }
  14375. protected function removeCleanupPath(PackageInterface $package, string $path): void
  14376. {
  14377. if (isset($this->additionalCleanupPaths[$package->getName()])) {
  14378. $idx = array_search($path, $this->additionalCleanupPaths[$package->getName()]);
  14379. if (false !== $idx) {
  14380. unset($this->additionalCleanupPaths[$package->getName()][$idx]);
  14381. }
  14382. }
  14383. }
  14384. public function update(PackageInterface $initial, PackageInterface $target, string $path): PromiseInterface
  14385. {
  14386. $this->io->writeError(" - " . UpdateOperation::format($initial, $target) . $this->getInstallOperationAppendix($target, $path));
  14387. $promise = $this->remove($initial, $path, false);
  14388. return $promise->then(function () use ($target, $path): PromiseInterface {
  14389. return $this->install($target, $path, false);
  14390. });
  14391. }
  14392. public function remove(PackageInterface $package, string $path, bool $output = true): PromiseInterface
  14393. {
  14394. if ($output) {
  14395. $this->io->writeError(" - " . UninstallOperation::format($package));
  14396. }
  14397. $promise = $this->filesystem->removeDirectoryAsync($path);
  14398. return $promise->then(function ($result) use ($path): void {
  14399. if (!$result) {
  14400. throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
  14401. }
  14402. });
  14403. }
  14404. protected function getFileName(PackageInterface $package, string $path): string
  14405. {
  14406. return rtrim($this->config->get('vendor-dir').'/composer/tmp-'.md5($package.spl_object_hash($package)).'.'.pathinfo(parse_url(strtr((string) $package->getDistUrl(), '\\', '/'), PHP_URL_PATH), PATHINFO_EXTENSION), '.');
  14407. }
  14408. protected function getInstallOperationAppendix(PackageInterface $package, string $path): string
  14409. {
  14410. return '';
  14411. }
  14412. protected function processUrl(PackageInterface $package, string $url): string
  14413. {
  14414. if (!extension_loaded('openssl') && 0 === strpos($url, 'https:')) {
  14415. throw new \RuntimeException('You must enable the openssl extension to download files via https');
  14416. }
  14417. if ($package->getDistReference()) {
  14418. $url = UrlUtil::updateDistReference($this->config, $url, $package->getDistReference());
  14419. }
  14420. return $url;
  14421. }
  14422. public function getLocalChanges(PackageInterface $package, string $path): ?string
  14423. {
  14424. $prevIO = $this->io;
  14425. $this->io = new NullIO;
  14426. $this->io->loadConfiguration($this->config);
  14427. $e = null;
  14428. $output = '';
  14429. $targetDir = Filesystem::trimTrailingSlash($path);
  14430. try {
  14431. if (is_dir($targetDir.'_compare')) {
  14432. $this->filesystem->removeDirectory($targetDir.'_compare');
  14433. }
  14434. $this->download($package, $targetDir.'_compare', null, false);
  14435. $this->httpDownloader->wait();
  14436. $this->install($package, $targetDir.'_compare', false);
  14437. $this->process->wait();
  14438. $comparer = new Comparer();
  14439. $comparer->setSource($targetDir.'_compare');
  14440. $comparer->setUpdate($targetDir);
  14441. $comparer->doCompare();
  14442. $output = $comparer->getChangedAsString(true);
  14443. $this->filesystem->removeDirectory($targetDir.'_compare');
  14444. } catch (\Exception $e) {
  14445. }
  14446. $this->io = $prevIO;
  14447. if ($e) {
  14448. throw $e;
  14449. }
  14450. $output = trim($output);
  14451. return strlen($output) > 0 ? $output : null;
  14452. }
  14453. }
  14454. <?php declare(strict_types=1);
  14455. namespace Composer\Downloader;
  14456. class FilesystemException extends \Exception
  14457. {
  14458. public function __construct(string $message = '', int $code = 0, \Exception $previous = null)
  14459. {
  14460. parent::__construct("Filesystem exception: \n".$message, $code, $previous);
  14461. }
  14462. }
  14463. <?php declare(strict_types=1);
  14464. namespace Composer\Downloader;
  14465. use React\Promise\PromiseInterface;
  14466. use Composer\Package\PackageInterface;
  14467. use Composer\Pcre\Preg;
  14468. use Composer\Util\ProcessExecutor;
  14469. class FossilDownloader extends VcsDownloader
  14470. {
  14471. protected function doDownload(PackageInterface $package, string $path, string $url, PackageInterface $prevPackage = null): PromiseInterface
  14472. {
  14473. return \React\Promise\resolve(null);
  14474. }
  14475. protected function doInstall(PackageInterface $package, string $path, string $url): PromiseInterface
  14476. {
  14477. $this->config->prohibitUrlByConfig($url, $this->io);
  14478. $url = ProcessExecutor::escape($url);
  14479. $ref = ProcessExecutor::escape($package->getSourceReference());
  14480. $repoFile = $path . '.fossil';
  14481. $this->io->writeError("Cloning ".$package->getSourceReference());
  14482. $command = sprintf('fossil clone -- %s %s', $url, ProcessExecutor::escape($repoFile));
  14483. if (0 !== $this->process->execute($command, $ignoredOutput)) {
  14484. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  14485. }
  14486. $command = sprintf('fossil open --nested -- %s', ProcessExecutor::escape($repoFile));
  14487. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  14488. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  14489. }
  14490. $command = sprintf('fossil update -- %s', $ref);
  14491. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  14492. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  14493. }
  14494. return \React\Promise\resolve(null);
  14495. }
  14496. protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): PromiseInterface
  14497. {
  14498. $this->config->prohibitUrlByConfig($url, $this->io);
  14499. $ref = ProcessExecutor::escape($target->getSourceReference());
  14500. $this->io->writeError(" Updating to ".$target->getSourceReference());
  14501. if (!$this->hasMetadataRepository($path)) {
  14502. throw new \RuntimeException('The .fslckout file is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  14503. }
  14504. $command = sprintf('fossil pull && fossil up %s', $ref);
  14505. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  14506. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  14507. }
  14508. return \React\Promise\resolve(null);
  14509. }
  14510. public function getLocalChanges(PackageInterface $package, string $path): ?string
  14511. {
  14512. if (!$this->hasMetadataRepository($path)) {
  14513. return null;
  14514. }
  14515. $this->process->execute('fossil changes', $output, realpath($path));
  14516. $output = trim($output);
  14517. return strlen($output) > 0 ? $output : null;
  14518. }
  14519. protected function getCommitLogs(string $fromReference, string $toReference, string $path): string
  14520. {
  14521. $command = sprintf('fossil timeline -t ci -W 0 -n 0 before %s', ProcessExecutor::escape($toReference));
  14522. if (0 !== $this->process->execute($command, $output, realpath($path))) {
  14523. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  14524. }
  14525. $log = '';
  14526. $match = '/\d\d:\d\d:\d\d\s+\[' . $toReference . '\]/';
  14527. foreach ($this->process->splitLines($output) as $line) {
  14528. if (Preg::isMatch($match, $line)) {
  14529. break;
  14530. }
  14531. $log .= $line;
  14532. }
  14533. return $log;
  14534. }
  14535. protected function hasMetadataRepository(string $path): bool
  14536. {
  14537. return is_file($path . '/.fslckout') || is_file($path . '/_FOSSIL_');
  14538. }
  14539. }
  14540. <?php declare(strict_types=1);
  14541. namespace Composer\Downloader;
  14542. use Composer\Config;
  14543. use Composer\IO\IOInterface;
  14544. use Composer\Package\PackageInterface;
  14545. use Composer\Pcre\Preg;
  14546. use Composer\Util\Filesystem;
  14547. use Composer\Util\Git as GitUtil;
  14548. use Composer\Util\Url;
  14549. use Composer\Util\Platform;
  14550. use Composer\Util\ProcessExecutor;
  14551. use Composer\Cache;
  14552. use React\Promise\PromiseInterface;
  14553. class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
  14554. {
  14555. private $hasStashedChanges = array();
  14556. private $hasDiscardedChanges = array();
  14557. private $gitUtil;
  14558. private $cachedPackages = array();
  14559. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, Filesystem $fs = null)
  14560. {
  14561. parent::__construct($io, $config, $process, $fs);
  14562. $this->gitUtil = new GitUtil($this->io, $this->config, $this->process, $this->filesystem);
  14563. }
  14564. protected function doDownload(PackageInterface $package, string $path, string $url, PackageInterface $prevPackage = null): PromiseInterface
  14565. {
  14566. GitUtil::cleanEnv();
  14567. $cachePath = $this->config->get('cache-vcs-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', $url).'/';
  14568. $gitVersion = GitUtil::getVersion($this->process);
  14569. if ($gitVersion && version_compare($gitVersion, '2.3.0-rc0', '>=') && Cache::isUsable($cachePath)) {
  14570. $this->io->writeError(" - Syncing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>) into cache");
  14571. $this->io->writeError(sprintf(' Cloning to cache at %s', ProcessExecutor::escape($cachePath)), true, IOInterface::DEBUG);
  14572. $ref = $package->getSourceReference();
  14573. if ($this->gitUtil->fetchRefOrSyncMirror($url, $cachePath, $ref) && is_dir($cachePath)) {
  14574. $this->cachedPackages[$package->getId()][$ref] = true;
  14575. }
  14576. } elseif (null === $gitVersion) {
  14577. throw new \RuntimeException('git was not found in your PATH, skipping source download');
  14578. }
  14579. return \React\Promise\resolve(null);
  14580. }
  14581. protected function doInstall(PackageInterface $package, string $path, string $url): PromiseInterface
  14582. {
  14583. GitUtil::cleanEnv();
  14584. $path = $this->normalizePath($path);
  14585. $cachePath = $this->config->get('cache-vcs-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', $url).'/';
  14586. $ref = $package->getSourceReference();
  14587. $flag = Platform::isWindows() ? '/D ' : '';
  14588. if (!empty($this->cachedPackages[$package->getId()][$ref])) {
  14589. $msg = "Cloning ".$this->getShortHash($ref).' from cache';
  14590. $cloneFlags = '--dissociate --reference %cachePath% ';
  14591. $transportOptions = $package->getTransportOptions();
  14592. if (isset($transportOptions['git']['single_use_clone']) && $transportOptions['git']['single_use_clone']) {
  14593. $cloneFlags = '';
  14594. }
  14595. $command =
  14596. 'git clone --no-checkout %cachePath% %path% ' . $cloneFlags
  14597. . '&& cd '.$flag.'%path% '
  14598. . '&& git remote set-url origin -- %sanitizedUrl% && git remote add composer -- %sanitizedUrl%';
  14599. } else {
  14600. $msg = "Cloning ".$this->getShortHash($ref);
  14601. $command = 'git clone --no-checkout -- %url% %path% && cd '.$flag.'%path% && git remote add composer -- %url% && git fetch composer && git remote set-url origin -- %sanitizedUrl% && git remote set-url composer -- %sanitizedUrl%';
  14602. if (Platform::getEnv('COMPOSER_DISABLE_NETWORK')) {
  14603. throw new \RuntimeException('The required git reference for '.$package->getName().' is not in cache and network is disabled, aborting');
  14604. }
  14605. }
  14606. $this->io->writeError($msg);
  14607. $commandCallable = function (string $url) use ($path, $command, $cachePath): string {
  14608. return str_replace(
  14609. array('%url%', '%path%', '%cachePath%', '%sanitizedUrl%'),
  14610. array(
  14611. ProcessExecutor::escape($url),
  14612. ProcessExecutor::escape($path),
  14613. ProcessExecutor::escape($cachePath),
  14614. ProcessExecutor::escape(Preg::replace('{://([^@]+?):(.+?)@}', '://', $url)),
  14615. ),
  14616. $command
  14617. );
  14618. };
  14619. $this->gitUtil->runCommand($commandCallable, $url, $path, true);
  14620. $sourceUrl = $package->getSourceUrl();
  14621. if ($url !== $sourceUrl && $sourceUrl !== null) {
  14622. $this->updateOriginUrl($path, $sourceUrl);
  14623. } else {
  14624. $this->setPushUrl($path, $url);
  14625. }
  14626. if ($newRef = $this->updateToCommit($package, $path, (string) $ref, $package->getPrettyVersion())) {
  14627. if ($package->getDistReference() === $package->getSourceReference()) {
  14628. $package->setDistReference($newRef);
  14629. }
  14630. $package->setSourceReference($newRef);
  14631. }
  14632. return \React\Promise\resolve(null);
  14633. }
  14634. protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): PromiseInterface
  14635. {
  14636. GitUtil::cleanEnv();
  14637. $path = $this->normalizePath($path);
  14638. if (!$this->hasMetadataRepository($path)) {
  14639. throw new \RuntimeException('The .git directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  14640. }
  14641. $cachePath = $this->config->get('cache-vcs-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', $url).'/';
  14642. $ref = $target->getSourceReference();
  14643. if (!empty($this->cachedPackages[$target->getId()][$ref])) {
  14644. $msg = "Checking out ".$this->getShortHash($ref).' from cache';
  14645. $command = '(git rev-parse --quiet --verify %ref% || (git remote set-url composer -- %cachePath% && git fetch composer && git fetch --tags composer)) && git remote set-url composer -- %sanitizedUrl%';
  14646. } else {
  14647. $msg = "Checking out ".$this->getShortHash($ref);
  14648. $command = '(git remote set-url composer -- %url% && git rev-parse --quiet --verify %ref% || (git fetch composer && git fetch --tags composer)) && git remote set-url composer -- %sanitizedUrl%';
  14649. if (Platform::getEnv('COMPOSER_DISABLE_NETWORK')) {
  14650. throw new \RuntimeException('The required git reference for '.$target->getName().' is not in cache and network is disabled, aborting');
  14651. }
  14652. }
  14653. $this->io->writeError($msg);
  14654. $commandCallable = function ($url) use ($ref, $command, $cachePath): string {
  14655. return str_replace(
  14656. array('%url%', '%ref%', '%cachePath%', '%sanitizedUrl%'),
  14657. array(
  14658. ProcessExecutor::escape($url),
  14659. ProcessExecutor::escape($ref.'^{commit}'),
  14660. ProcessExecutor::escape($cachePath),
  14661. ProcessExecutor::escape(Preg::replace('{://([^@]+?):(.+?)@}', '://', $url)),
  14662. ),
  14663. $command
  14664. );
  14665. };
  14666. $this->gitUtil->runCommand($commandCallable, $url, $path);
  14667. if ($newRef = $this->updateToCommit($target, $path, (string) $ref, $target->getPrettyVersion())) {
  14668. if ($target->getDistReference() === $target->getSourceReference()) {
  14669. $target->setDistReference($newRef);
  14670. }
  14671. $target->setSourceReference($newRef);
  14672. }
  14673. $updateOriginUrl = false;
  14674. if (
  14675. 0 === $this->process->execute('git remote -v', $output, $path)
  14676. && Preg::isMatch('{^origin\s+(?P<url>\S+)}m', $output, $originMatch)
  14677. && Preg::isMatch('{^composer\s+(?P<url>\S+)}m', $output, $composerMatch)
  14678. ) {
  14679. if ($originMatch['url'] === $composerMatch['url'] && $composerMatch['url'] !== $target->getSourceUrl()) {
  14680. $updateOriginUrl = true;
  14681. }
  14682. }
  14683. if ($updateOriginUrl && $target->getSourceUrl() !== null) {
  14684. $this->updateOriginUrl($path, $target->getSourceUrl());
  14685. }
  14686. return \React\Promise\resolve(null);
  14687. }
  14688. public function getLocalChanges(PackageInterface $package, string $path): ?string
  14689. {
  14690. GitUtil::cleanEnv();
  14691. if (!$this->hasMetadataRepository($path)) {
  14692. return null;
  14693. }
  14694. $command = 'git status --porcelain --untracked-files=no';
  14695. if (0 !== $this->process->execute($command, $output, $path)) {
  14696. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  14697. }
  14698. $output = trim($output);
  14699. return strlen($output) > 0 ? $output : null;
  14700. }
  14701. public function getUnpushedChanges(PackageInterface $package, string $path): ?string
  14702. {
  14703. GitUtil::cleanEnv();
  14704. $path = $this->normalizePath($path);
  14705. if (!$this->hasMetadataRepository($path)) {
  14706. return null;
  14707. }
  14708. $command = 'git show-ref --head -d';
  14709. if (0 !== $this->process->execute($command, $output, $path)) {
  14710. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  14711. }
  14712. $refs = trim($output);
  14713. if (!Preg::isMatch('{^([a-f0-9]+) HEAD$}mi', $refs, $match)) {
  14714. return null;
  14715. }
  14716. $headRef = $match[1];
  14717. if (!Preg::isMatchAll('{^'.$headRef.' refs/heads/(.+)$}mi', $refs, $matches)) {
  14718. return null;
  14719. }
  14720. $candidateBranches = $matches[1];
  14721. $branch = $candidateBranches[0];
  14722. $unpushedChanges = null;
  14723. $branchNotFoundError = false;
  14724. for ($i = 0; $i <= 1; $i++) {
  14725. $remoteBranches = array();
  14726. foreach ($candidateBranches as $candidate) {
  14727. if (Preg::isMatchAll('{^[a-f0-9]+ refs/remotes/((?:[^/]+)/'.preg_quote($candidate).')$}mi', $refs, $matches)) {
  14728. foreach ($matches[1] as $match) {
  14729. $branch = $candidate;
  14730. $remoteBranches[] = $match;
  14731. }
  14732. break;
  14733. }
  14734. }
  14735. if (!$remoteBranches) {
  14736. $unpushedChanges = 'Branch ' . $branch . ' could not be found on any remote and appears to be unpushed';
  14737. $branchNotFoundError = true;
  14738. } else {
  14739. if ($branchNotFoundError) {
  14740. $unpushedChanges = null;
  14741. }
  14742. foreach ($remoteBranches as $remoteBranch) {
  14743. $command = sprintf('git diff --name-status %s...%s --', $remoteBranch, $branch);
  14744. if (0 !== $this->process->execute($command, $output, $path)) {
  14745. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  14746. }
  14747. $output = trim($output);
  14748. if ($unpushedChanges === null || strlen($output) < strlen($unpushedChanges)) {
  14749. $unpushedChanges = $output;
  14750. }
  14751. }
  14752. }
  14753. if ($unpushedChanges && $i === 0) {
  14754. $this->process->execute('git fetch --all', $output, $path);
  14755. $command = 'git show-ref --head -d';
  14756. if (0 !== $this->process->execute($command, $output, $path)) {
  14757. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  14758. }
  14759. $refs = trim($output);
  14760. }
  14761. if (!$unpushedChanges) {
  14762. break;
  14763. }
  14764. }
  14765. return $unpushedChanges;
  14766. }
  14767. protected function cleanChanges(PackageInterface $package, string $path, bool $update): PromiseInterface
  14768. {
  14769. GitUtil::cleanEnv();
  14770. $path = $this->normalizePath($path);
  14771. $unpushed = $this->getUnpushedChanges($package, $path);
  14772. if ($unpushed && ($this->io->isInteractive() || $this->config->get('discard-changes') !== true)) {
  14773. throw new \RuntimeException('Source directory ' . $path . ' has unpushed changes on the current branch: '."\n".$unpushed);
  14774. }
  14775. if (null === ($changes = $this->getLocalChanges($package, $path))) {
  14776. return \React\Promise\resolve(null);
  14777. }
  14778. if (!$this->io->isInteractive()) {
  14779. $discardChanges = $this->config->get('discard-changes');
  14780. if (true === $discardChanges) {
  14781. return $this->discardChanges($path);
  14782. }
  14783. if ('stash' === $discardChanges) {
  14784. if (!$update) {
  14785. return parent::cleanChanges($package, $path, $update);
  14786. }
  14787. return $this->stashChanges($path);
  14788. }
  14789. return parent::cleanChanges($package, $path, $update);
  14790. }
  14791. $changes = array_map(function ($elem): string {
  14792. return ' '.$elem;
  14793. }, Preg::split('{\s*\r?\n\s*}', $changes));
  14794. $this->io->writeError(' <error>'.$package->getPrettyName().' has modified files:</error>');
  14795. $this->io->writeError(array_slice($changes, 0, 10));
  14796. if (count($changes) > 10) {
  14797. $this->io->writeError(' <info>' . (count($changes) - 10) . ' more files modified, choose "v" to view the full list</info>');
  14798. }
  14799. while (true) {
  14800. switch ($this->io->ask(' <info>Discard changes [y,n,v,d,'.($update ? 's,' : '').'?]?</info> ', '?')) {
  14801. case 'y':
  14802. $this->discardChanges($path);
  14803. break 2;
  14804. case 's':
  14805. if (!$update) {
  14806. goto help;
  14807. }
  14808. $this->stashChanges($path);
  14809. break 2;
  14810. case 'n':
  14811. throw new \RuntimeException('Update aborted');
  14812. case 'v':
  14813. $this->io->writeError($changes);
  14814. break;
  14815. case 'd':
  14816. $this->viewDiff($path);
  14817. break;
  14818. case '?':
  14819. default:
  14820. help :
  14821. $this->io->writeError(array(
  14822. ' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
  14823. ' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
  14824. ' v - view modified files',
  14825. ' d - view local modifications (diff)',
  14826. ));
  14827. if ($update) {
  14828. $this->io->writeError(' s - stash changes and try to reapply them after the update');
  14829. }
  14830. $this->io->writeError(' ? - print help');
  14831. break;
  14832. }
  14833. }
  14834. return \React\Promise\resolve(null);
  14835. }
  14836. protected function reapplyChanges(string $path): void
  14837. {
  14838. $path = $this->normalizePath($path);
  14839. if (!empty($this->hasStashedChanges[$path])) {
  14840. unset($this->hasStashedChanges[$path]);
  14841. $this->io->writeError(' <info>Re-applying stashed changes</info>');
  14842. if (0 !== $this->process->execute('git stash pop', $output, $path)) {
  14843. throw new \RuntimeException("Failed to apply stashed changes:\n\n".$this->process->getErrorOutput());
  14844. }
  14845. }
  14846. unset($this->hasDiscardedChanges[$path]);
  14847. }
  14848. protected function updateToCommit(PackageInterface $package, string $path, string $reference, string $prettyVersion): ?string
  14849. {
  14850. $force = !empty($this->hasDiscardedChanges[$path]) || !empty($this->hasStashedChanges[$path]) ? '-f ' : '';
  14851. $template = 'git checkout '.$force.'%s -- && git reset --hard %1$s --';
  14852. $branch = Preg::replace('{(?:^dev-|(?:\.x)?-dev$)}i', '', $prettyVersion);
  14853. $branches = null;
  14854. if (0 === $this->process->execute('git branch -r', $output, $path)) {
  14855. $branches = $output;
  14856. }
  14857. $gitRef = $reference;
  14858. if (!Preg::isMatch('{^[a-f0-9]{40}$}', $reference)
  14859. && $branches
  14860. && Preg::isMatch('{^\s+composer/'.preg_quote($reference).'$}m', $branches)
  14861. ) {
  14862. $command = sprintf('git checkout '.$force.'-B %s %s -- && git reset --hard %2$s --', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$reference));
  14863. if (0 === $this->process->execute($command, $output, $path)) {
  14864. return null;
  14865. }
  14866. }
  14867. if (Preg::isMatch('{^[a-f0-9]{40}$}', $reference)) {
  14868. if (!Preg::isMatch('{^\s+composer/'.preg_quote($branch).'$}m', $branches) && Preg::isMatch('{^\s+composer/v'.preg_quote($branch).'$}m', $branches)) {
  14869. $branch = 'v' . $branch;
  14870. }
  14871. $command = sprintf('git checkout %s --', ProcessExecutor::escape($branch));
  14872. $fallbackCommand = sprintf('git checkout '.$force.'-B %s %s --', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$branch));
  14873. $resetCommand = sprintf('git reset --hard %s --', ProcessExecutor::escape($reference));
  14874. if (0 === $this->process->execute("($command || $fallbackCommand) && $resetCommand", $output, $path)) {
  14875. return null;
  14876. }
  14877. }
  14878. $command = sprintf($template, ProcessExecutor::escape($gitRef));
  14879. if (0 === $this->process->execute($command, $output, $path)) {
  14880. return null;
  14881. }
  14882. $exceptionExtra = '';
  14883. if (false !== strpos($this->process->getErrorOutput(), $reference)) {
  14884. $this->io->writeError(' <warning>'.$reference.' is gone (history was rewritten?)</warning>');
  14885. $exceptionExtra = "\nIt looks like the commit hash is not available in the repository, maybe ".($package->isDev() ? 'the commit was removed from the branch' : 'the tag was recreated').'? Run "composer update '.$package->getPrettyName().'" to resolve this.';
  14886. }
  14887. throw new \RuntimeException(Url::sanitize('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput() . $exceptionExtra));
  14888. }
  14889. protected function updateOriginUrl(string $path, string $url): void
  14890. {
  14891. $this->process->execute(sprintf('git remote set-url origin -- %s', ProcessExecutor::escape($url)), $output, $path);
  14892. $this->setPushUrl($path, $url);
  14893. }
  14894. protected function setPushUrl(string $path, string $url): void
  14895. {
  14896. if (Preg::isMatch('{^(?:https?|git)://'.GitUtil::getGitHubDomainsRegex($this->config).'/([^/]+)/([^/]+?)(?:\.git)?$}', $url, $match)) {
  14897. $protocols = $this->config->get('github-protocols');
  14898. $pushUrl = 'git@'.$match[1].':'.$match[2].'/'.$match[3].'.git';
  14899. if (!in_array('ssh', $protocols, true)) {
  14900. $pushUrl = 'https://' . $match[1] . '/'.$match[2].'/'.$match[3].'.git';
  14901. }
  14902. $cmd = sprintf('git remote set-url --push origin -- %s', ProcessExecutor::escape($pushUrl));
  14903. $this->process->execute($cmd, $ignoredOutput, $path);
  14904. }
  14905. }
  14906. protected function getCommitLogs(string $fromReference, string $toReference, string $path): string
  14907. {
  14908. $path = $this->normalizePath($path);
  14909. $command = sprintf('git log %s..%s --pretty=format:"%%h - %%an: %%s"'.GitUtil::getNoShowSignatureFlag($this->process), ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
  14910. if (0 !== $this->process->execute($command, $output, $path)) {
  14911. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  14912. }
  14913. return $output;
  14914. }
  14915. protected function discardChanges(string $path): PromiseInterface
  14916. {
  14917. $path = $this->normalizePath($path);
  14918. if (0 !== $this->process->execute('git clean -df && git reset --hard', $output, $path)) {
  14919. throw new \RuntimeException("Could not reset changes\n\n:".$output);
  14920. }
  14921. $this->hasDiscardedChanges[$path] = true;
  14922. return \React\Promise\resolve(null);
  14923. }
  14924. protected function stashChanges(string $path): PromiseInterface
  14925. {
  14926. $path = $this->normalizePath($path);
  14927. if (0 !== $this->process->execute('git stash --include-untracked', $output, $path)) {
  14928. throw new \RuntimeException("Could not stash changes\n\n:".$output);
  14929. }
  14930. $this->hasStashedChanges[$path] = true;
  14931. return \React\Promise\resolve(null);
  14932. }
  14933. protected function viewDiff(string $path): void
  14934. {
  14935. $path = $this->normalizePath($path);
  14936. if (0 !== $this->process->execute('git diff HEAD', $output, $path)) {
  14937. throw new \RuntimeException("Could not view diff\n\n:".$output);
  14938. }
  14939. $this->io->writeError($output);
  14940. }
  14941. protected function normalizePath(string $path): string
  14942. {
  14943. if (Platform::isWindows() && strlen($path) > 0) {
  14944. $basePath = $path;
  14945. $removed = array();
  14946. while (!is_dir($basePath) && $basePath !== '\\') {
  14947. array_unshift($removed, basename($basePath));
  14948. $basePath = dirname($basePath);
  14949. }
  14950. if ($basePath === '\\') {
  14951. return $path;
  14952. }
  14953. $path = rtrim(realpath($basePath) . '/' . implode('/', $removed), '/');
  14954. }
  14955. return $path;
  14956. }
  14957. protected function hasMetadataRepository(string $path): bool
  14958. {
  14959. $path = $this->normalizePath($path);
  14960. return is_dir($path.'/.git');
  14961. }
  14962. protected function getShortHash(string $reference): string
  14963. {
  14964. if (!$this->io->isVerbose() && Preg::isMatch('{^[0-9a-f]{40}$}', $reference)) {
  14965. return substr($reference, 0, 10);
  14966. }
  14967. return $reference;
  14968. }
  14969. }
  14970. <?php declare(strict_types=1);
  14971. namespace Composer\Downloader;
  14972. use React\Promise\PromiseInterface;
  14973. use Composer\Package\PackageInterface;
  14974. use Composer\Util\Platform;
  14975. use Composer\Util\ProcessExecutor;
  14976. class GzipDownloader extends ArchiveDownloader
  14977. {
  14978. protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface
  14979. {
  14980. $filename = pathinfo(parse_url(strtr((string) $package->getDistUrl(), '\\', '/'), PHP_URL_PATH), PATHINFO_FILENAME);
  14981. $targetFilepath = $path . DIRECTORY_SEPARATOR . $filename;
  14982. if (!Platform::isWindows()) {
  14983. $command = 'gzip -cd -- ' . ProcessExecutor::escape($file) . ' > ' . ProcessExecutor::escape($targetFilepath);
  14984. if (0 === $this->process->execute($command, $ignoredOutput)) {
  14985. return \React\Promise\resolve(null);
  14986. }
  14987. if (extension_loaded('zlib')) {
  14988. $this->extractUsingExt($file, $targetFilepath);
  14989. return \React\Promise\resolve(null);
  14990. }
  14991. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  14992. throw new \RuntimeException($processError);
  14993. }
  14994. $this->extractUsingExt($file, $targetFilepath);
  14995. return \React\Promise\resolve(null);
  14996. }
  14997. private function extractUsingExt(string $file, string $targetFilepath): void
  14998. {
  14999. $archiveFile = gzopen($file, 'rb');
  15000. $targetFile = fopen($targetFilepath, 'wb');
  15001. while ($string = gzread($archiveFile, 4096)) {
  15002. fwrite($targetFile, $string, Platform::strlen($string));
  15003. }
  15004. gzclose($archiveFile);
  15005. fclose($targetFile);
  15006. }
  15007. }
  15008. <?php declare(strict_types=1);
  15009. namespace Composer\Downloader;
  15010. use React\Promise\PromiseInterface;
  15011. use Composer\Package\PackageInterface;
  15012. use Composer\Util\ProcessExecutor;
  15013. use Composer\Util\Hg as HgUtils;
  15014. class HgDownloader extends VcsDownloader
  15015. {
  15016. protected function doDownload(PackageInterface $package, string $path, string $url, PackageInterface $prevPackage = null): PromiseInterface
  15017. {
  15018. if (null === HgUtils::getVersion($this->process)) {
  15019. throw new \RuntimeException('hg was not found in your PATH, skipping source download');
  15020. }
  15021. return \React\Promise\resolve(null);
  15022. }
  15023. protected function doInstall(PackageInterface $package, string $path, string $url): PromiseInterface
  15024. {
  15025. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  15026. $cloneCommand = function (string $url) use ($path): string {
  15027. return sprintf('hg clone -- %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($path));
  15028. };
  15029. $hgUtils->runCommand($cloneCommand, $url, $path);
  15030. $ref = ProcessExecutor::escape($package->getSourceReference());
  15031. $command = sprintf('hg up -- %s', $ref);
  15032. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  15033. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  15034. }
  15035. return \React\Promise\resolve(null);
  15036. }
  15037. protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): PromiseInterface
  15038. {
  15039. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  15040. $ref = $target->getSourceReference();
  15041. $this->io->writeError(" Updating to ".$target->getSourceReference());
  15042. if (!$this->hasMetadataRepository($path)) {
  15043. throw new \RuntimeException('The .hg directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  15044. }
  15045. $command = function ($url) use ($ref): string {
  15046. return sprintf('hg pull -- %s && hg up -- %s', ProcessExecutor::escape($url), ProcessExecutor::escape($ref));
  15047. };
  15048. $hgUtils->runCommand($command, $url, $path);
  15049. return \React\Promise\resolve(null);
  15050. }
  15051. public function getLocalChanges(PackageInterface $package, string $path): ?string
  15052. {
  15053. if (!is_dir($path.'/.hg')) {
  15054. return null;
  15055. }
  15056. $this->process->execute('hg st', $output, realpath($path));
  15057. $output = trim($output);
  15058. return strlen($output) > 0 ? $output : null;
  15059. }
  15060. protected function getCommitLogs(string $fromReference, string $toReference, string $path): string
  15061. {
  15062. $command = sprintf('hg log -r %s:%s --style compact', ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
  15063. if (0 !== $this->process->execute($command, $output, realpath($path))) {
  15064. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  15065. }
  15066. return $output;
  15067. }
  15068. protected function hasMetadataRepository(string $path): bool
  15069. {
  15070. return is_dir($path . '/.hg');
  15071. }
  15072. }
  15073. <?php declare(strict_types=1);
  15074. namespace Composer\Downloader;
  15075. class MaxFileSizeExceededException extends TransportException
  15076. {
  15077. }
  15078. <?php declare(strict_types=1);
  15079. namespace Composer\Downloader;
  15080. use React\Promise\PromiseInterface;
  15081. use Composer\Package\Archiver\ArchivableFilesFinder;
  15082. use Composer\Package\Dumper\ArrayDumper;
  15083. use Composer\Package\PackageInterface;
  15084. use Composer\Package\Version\VersionGuesser;
  15085. use Composer\Package\Version\VersionParser;
  15086. use Composer\Util\Platform;
  15087. use Composer\Util\Filesystem;
  15088. use Symfony\Component\Filesystem\Exception\IOException;
  15089. use Symfony\Component\Filesystem\Filesystem as SymfonyFilesystem;
  15090. use Composer\DependencyResolver\Operation\InstallOperation;
  15091. use Composer\DependencyResolver\Operation\UninstallOperation;
  15092. class PathDownloader extends FileDownloader implements VcsCapableDownloaderInterface
  15093. {
  15094. private const STRATEGY_SYMLINK = 10;
  15095. private const STRATEGY_MIRROR = 20;
  15096. public function download(PackageInterface $package, string $path, PackageInterface $prevPackage = null, bool $output = true): PromiseInterface
  15097. {
  15098. $path = Filesystem::trimTrailingSlash($path);
  15099. $url = $package->getDistUrl();
  15100. $realUrl = realpath($url);
  15101. if (false === $realUrl || !file_exists($realUrl) || !is_dir($realUrl)) {
  15102. throw new \RuntimeException(sprintf(
  15103. 'Source path "%s" is not found for package %s',
  15104. $url,
  15105. $package->getName()
  15106. ));
  15107. }
  15108. if (realpath($path) === $realUrl) {
  15109. return \React\Promise\resolve(null);
  15110. }
  15111. if (strpos(realpath($path) . DIRECTORY_SEPARATOR, $realUrl . DIRECTORY_SEPARATOR) === 0) {
  15112. throw new \RuntimeException(sprintf(
  15113. 'Package %s cannot install to "%s" inside its source at "%s"',
  15114. $package->getName(),
  15115. realpath($path),
  15116. $realUrl
  15117. ));
  15118. }
  15119. return \React\Promise\resolve(null);
  15120. }
  15121. public function install(PackageInterface $package, string $path, bool $output = true): PromiseInterface
  15122. {
  15123. $path = Filesystem::trimTrailingSlash($path);
  15124. $url = $package->getDistUrl();
  15125. $realUrl = realpath($url);
  15126. if (realpath($path) === $realUrl) {
  15127. if ($output) {
  15128. $this->io->writeError(" - " . InstallOperation::format($package) . $this->getInstallOperationAppendix($package, $path));
  15129. }
  15130. return \React\Promise\resolve(null);
  15131. }
  15132. $transportOptions = $package->getTransportOptions() + array('relative' => true);
  15133. list($currentStrategy, $allowedStrategies) = $this->computeAllowedStrategies($transportOptions);
  15134. $symfonyFilesystem = new SymfonyFilesystem();
  15135. $this->filesystem->removeDirectory($path);
  15136. if ($output) {
  15137. $this->io->writeError(" - " . InstallOperation::format($package).': ', false);
  15138. }
  15139. $isFallback = false;
  15140. if (self::STRATEGY_SYMLINK === $currentStrategy) {
  15141. try {
  15142. if (Platform::isWindows()) {
  15143. if ($output) {
  15144. $this->io->writeError(sprintf('Junctioning from %s', $url), false);
  15145. }
  15146. $this->filesystem->junction($realUrl, $path);
  15147. } else {
  15148. $absolutePath = $path;
  15149. if (!$this->filesystem->isAbsolutePath($absolutePath)) {
  15150. $absolutePath = Platform::getCwd() . DIRECTORY_SEPARATOR . $path;
  15151. }
  15152. $shortestPath = $this->filesystem->findShortestPath($absolutePath, $realUrl);
  15153. $path = rtrim($path, "/");
  15154. if ($output) {
  15155. $this->io->writeError(sprintf('Symlinking from %s', $url), false);
  15156. }
  15157. if ($transportOptions['relative']) {
  15158. $symfonyFilesystem->symlink($shortestPath.'/', $path);
  15159. } else {
  15160. $symfonyFilesystem->symlink($realUrl.'/', $path);
  15161. }
  15162. }
  15163. } catch (IOException $e) {
  15164. if (in_array(self::STRATEGY_MIRROR, $allowedStrategies, true)) {
  15165. if ($output) {
  15166. $this->io->writeError('');
  15167. $this->io->writeError(' <error>Symlink failed, fallback to use mirroring!</error>');
  15168. }
  15169. $currentStrategy = self::STRATEGY_MIRROR;
  15170. $isFallback = true;
  15171. } else {
  15172. throw new \RuntimeException(sprintf('Symlink from "%s" to "%s" failed!', $realUrl, $path));
  15173. }
  15174. }
  15175. }
  15176. if (self::STRATEGY_MIRROR === $currentStrategy) {
  15177. $realUrl = $this->filesystem->normalizePath($realUrl);
  15178. if ($output) {
  15179. $this->io->writeError(sprintf('%sMirroring from %s', $isFallback ? ' ' : '', $url), false);
  15180. }
  15181. $iterator = new ArchivableFilesFinder($realUrl, array());
  15182. $symfonyFilesystem->mirror($realUrl, $path, $iterator);
  15183. }
  15184. if ($output) {
  15185. $this->io->writeError('');
  15186. }
  15187. return \React\Promise\resolve(null);
  15188. }
  15189. public function remove(PackageInterface $package, string $path, bool $output = true): PromiseInterface
  15190. {
  15191. $path = Filesystem::trimTrailingSlash($path);
  15192. if (Platform::isWindows() && $this->filesystem->isJunction($path)) {
  15193. if ($output) {
  15194. $this->io->writeError(" - " . UninstallOperation::format($package).", source is still present in $path");
  15195. }
  15196. if (!$this->filesystem->removeJunction($path)) {
  15197. $this->io->writeError(" <warning>Could not remove junction at " . $path . " - is another process locking it?</warning>");
  15198. throw new \RuntimeException('Could not reliably remove junction for package ' . $package->getName());
  15199. }
  15200. return \React\Promise\resolve(null);
  15201. }
  15202. $fs = new Filesystem;
  15203. $absPath = $fs->isAbsolutePath($path) ? $path : Platform::getCwd() . '/' . $path;
  15204. $absDistUrl = $fs->isAbsolutePath($package->getDistUrl()) ? $package->getDistUrl() : Platform::getCwd() . '/' . $package->getDistUrl();
  15205. if ($fs->normalizePath($absPath) === $fs->normalizePath($absDistUrl)) {
  15206. if ($output) {
  15207. $this->io->writeError(" - " . UninstallOperation::format($package).", source is still present in $path");
  15208. }
  15209. return \React\Promise\resolve(null);
  15210. }
  15211. return parent::remove($package, $path, $output);
  15212. }
  15213. public function getVcsReference(PackageInterface $package, string $path): ?string
  15214. {
  15215. $path = Filesystem::trimTrailingSlash($path);
  15216. $parser = new VersionParser;
  15217. $guesser = new VersionGuesser($this->config, $this->process, $parser);
  15218. $dumper = new ArrayDumper;
  15219. $packageConfig = $dumper->dump($package);
  15220. if ($packageVersion = $guesser->guessVersion($packageConfig, $path)) {
  15221. return $packageVersion['commit'];
  15222. }
  15223. return null;
  15224. }
  15225. protected function getInstallOperationAppendix(PackageInterface $package, string $path): string
  15226. {
  15227. $realUrl = realpath($package->getDistUrl());
  15228. if (realpath($path) === $realUrl) {
  15229. return ': Source already present';
  15230. }
  15231. list($currentStrategy) = $this->computeAllowedStrategies($package->getTransportOptions());
  15232. if ($currentStrategy === self::STRATEGY_SYMLINK) {
  15233. if (Platform::isWindows()) {
  15234. return ': Junctioning from '.$package->getDistUrl();
  15235. }
  15236. return ': Symlinking from '.$package->getDistUrl();
  15237. }
  15238. return ': Mirroring from '.$package->getDistUrl();
  15239. }
  15240. private function computeAllowedStrategies(array $transportOptions): array
  15241. {
  15242. $currentStrategy = self::STRATEGY_SYMLINK;
  15243. $allowedStrategies = array(self::STRATEGY_SYMLINK, self::STRATEGY_MIRROR);
  15244. $mirrorPathRepos = Platform::getEnv('COMPOSER_MIRROR_PATH_REPOS');
  15245. if ($mirrorPathRepos) {
  15246. $currentStrategy = self::STRATEGY_MIRROR;
  15247. }
  15248. $symlinkOption = $transportOptions['symlink'] ?? null;
  15249. if (true === $symlinkOption) {
  15250. $currentStrategy = self::STRATEGY_SYMLINK;
  15251. $allowedStrategies = array(self::STRATEGY_SYMLINK);
  15252. } elseif (false === $symlinkOption) {
  15253. $currentStrategy = self::STRATEGY_MIRROR;
  15254. $allowedStrategies = array(self::STRATEGY_MIRROR);
  15255. }
  15256. if (Platform::isWindows() && self::STRATEGY_SYMLINK === $currentStrategy && !$this->safeJunctions()) {
  15257. if (!in_array(self::STRATEGY_MIRROR, $allowedStrategies, true)) {
  15258. throw new \RuntimeException('You are on an old Windows / old PHP combo which does not allow Composer to use junctions/symlinks and this path repository has symlink:true in its options so copying is not allowed');
  15259. }
  15260. $currentStrategy = self::STRATEGY_MIRROR;
  15261. $allowedStrategies = array(self::STRATEGY_MIRROR);
  15262. }
  15263. return array($currentStrategy, $allowedStrategies);
  15264. }
  15265. private function safeJunctions(): bool
  15266. {
  15267. return function_exists('proc_open') &&
  15268. (PHP_WINDOWS_VERSION_MAJOR > 6 ||
  15269. (PHP_WINDOWS_VERSION_MAJOR === 6 && PHP_WINDOWS_VERSION_MINOR >= 1));
  15270. }
  15271. }
  15272. <?php declare(strict_types=1);
  15273. namespace Composer\Downloader;
  15274. use React\Promise\PromiseInterface;
  15275. use Composer\Package\PackageInterface;
  15276. use Composer\Repository\VcsRepository;
  15277. use Composer\Util\Perforce;
  15278. class PerforceDownloader extends VcsDownloader
  15279. {
  15280. protected $perforce;
  15281. protected function doDownload(PackageInterface $package, string $path, string $url, PackageInterface $prevPackage = null): PromiseInterface
  15282. {
  15283. return \React\Promise\resolve(null);
  15284. }
  15285. public function doInstall(PackageInterface $package, string $path, string $url): PromiseInterface
  15286. {
  15287. $ref = $package->getSourceReference();
  15288. $label = $this->getLabelFromSourceReference((string) $ref);
  15289. $this->io->writeError('Cloning ' . $ref);
  15290. $this->initPerforce($package, $path, $url);
  15291. $this->perforce->setStream($ref);
  15292. $this->perforce->p4Login();
  15293. $this->perforce->writeP4ClientSpec();
  15294. $this->perforce->connectClient();
  15295. $this->perforce->syncCodeBase($label);
  15296. $this->perforce->cleanupClientSpec();
  15297. return \React\Promise\resolve(null);
  15298. }
  15299. private function getLabelFromSourceReference(string $ref): ?string
  15300. {
  15301. $pos = strpos($ref, '@');
  15302. if (false !== $pos) {
  15303. return substr($ref, $pos + 1);
  15304. }
  15305. return null;
  15306. }
  15307. public function initPerforce(PackageInterface $package, string $path, string $url): void
  15308. {
  15309. if (!empty($this->perforce)) {
  15310. $this->perforce->initializePath($path);
  15311. return;
  15312. }
  15313. $repository = $package->getRepository();
  15314. $repoConfig = null;
  15315. if ($repository instanceof VcsRepository) {
  15316. $repoConfig = $this->getRepoConfig($repository);
  15317. }
  15318. $this->perforce = Perforce::create($repoConfig, $url, $path, $this->process, $this->io);
  15319. }
  15320. private function getRepoConfig(VcsRepository $repository): array
  15321. {
  15322. return $repository->getRepoConfig();
  15323. }
  15324. protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): PromiseInterface
  15325. {
  15326. return $this->doInstall($target, $path, $url);
  15327. }
  15328. public function getLocalChanges(PackageInterface $package, string $path): ?string
  15329. {
  15330. $this->io->writeError('Perforce driver does not check for local changes before overriding');
  15331. return null;
  15332. }
  15333. protected function getCommitLogs(string $fromReference, string $toReference, string $path): string
  15334. {
  15335. return $this->perforce->getCommitLogs($fromReference, $toReference);
  15336. }
  15337. public function setPerforce(Perforce $perforce): void
  15338. {
  15339. $this->perforce = $perforce;
  15340. }
  15341. protected function hasMetadataRepository(string $path): bool
  15342. {
  15343. return true;
  15344. }
  15345. }
  15346. <?php declare(strict_types=1);
  15347. namespace Composer\Downloader;
  15348. use React\Promise\PromiseInterface;
  15349. use Composer\Package\PackageInterface;
  15350. class PharDownloader extends ArchiveDownloader
  15351. {
  15352. protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface
  15353. {
  15354. $archive = new \Phar($file);
  15355. $archive->extractTo($path, null, true);
  15356. return \React\Promise\resolve(null);
  15357. }
  15358. }
  15359. <?php declare(strict_types=1);
  15360. namespace Composer\Downloader;
  15361. use React\Promise\PromiseInterface;
  15362. use Composer\Util\IniHelper;
  15363. use Composer\Util\Platform;
  15364. use Composer\Util\ProcessExecutor;
  15365. use Composer\Package\PackageInterface;
  15366. use RarArchive;
  15367. class RarDownloader extends ArchiveDownloader
  15368. {
  15369. protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface
  15370. {
  15371. $processError = null;
  15372. if (!Platform::isWindows()) {
  15373. $command = 'unrar x -- ' . ProcessExecutor::escape($file) . ' ' . ProcessExecutor::escape($path) . ' >/dev/null && chmod -R u+w ' . ProcessExecutor::escape($path);
  15374. if (0 === $this->process->execute($command, $ignoredOutput)) {
  15375. return \React\Promise\resolve(null);
  15376. }
  15377. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  15378. }
  15379. if (!class_exists('RarArchive')) {
  15380. $iniMessage = IniHelper::getMessage();
  15381. $error = "Could not decompress the archive, enable the PHP rar extension or install unrar.\n"
  15382. . $iniMessage . "\n" . $processError;
  15383. if (!Platform::isWindows()) {
  15384. $error = "Could not decompress the archive, enable the PHP rar extension.\n" . $iniMessage;
  15385. }
  15386. throw new \RuntimeException($error);
  15387. }
  15388. $rarArchive = RarArchive::open($file);
  15389. if (false === $rarArchive) {
  15390. throw new \UnexpectedValueException('Could not open RAR archive: ' . $file);
  15391. }
  15392. $entries = $rarArchive->getEntries();
  15393. if (false === $entries) {
  15394. throw new \RuntimeException('Could not retrieve RAR archive entries');
  15395. }
  15396. foreach ($entries as $entry) {
  15397. if (false === $entry->extract($path)) {
  15398. throw new \RuntimeException('Could not extract entry');
  15399. }
  15400. }
  15401. $rarArchive->close();
  15402. return \React\Promise\resolve(null);
  15403. }
  15404. }
  15405. <?php declare(strict_types=1);
  15406. namespace Composer\Downloader;
  15407. use Composer\Package\PackageInterface;
  15408. use Composer\Pcre\Preg;
  15409. use Composer\Util\Svn as SvnUtil;
  15410. use Composer\Repository\VcsRepository;
  15411. use Composer\Util\ProcessExecutor;
  15412. use React\Promise\PromiseInterface;
  15413. class SvnDownloader extends VcsDownloader
  15414. {
  15415. protected $cacheCredentials = true;
  15416. protected function doDownload(PackageInterface $package, string $path, string $url, PackageInterface $prevPackage = null): PromiseInterface
  15417. {
  15418. SvnUtil::cleanEnv();
  15419. $util = new SvnUtil($url, $this->io, $this->config, $this->process);
  15420. if (null === $util->binaryVersion()) {
  15421. throw new \RuntimeException('svn was not found in your PATH, skipping source download');
  15422. }
  15423. return \React\Promise\resolve(null);
  15424. }
  15425. protected function doInstall(PackageInterface $package, string $path, string $url): PromiseInterface
  15426. {
  15427. SvnUtil::cleanEnv();
  15428. $ref = $package->getSourceReference();
  15429. $repo = $package->getRepository();
  15430. if ($repo instanceof VcsRepository) {
  15431. $repoConfig = $repo->getRepoConfig();
  15432. if (array_key_exists('svn-cache-credentials', $repoConfig)) {
  15433. $this->cacheCredentials = (bool) $repoConfig['svn-cache-credentials'];
  15434. }
  15435. }
  15436. $this->io->writeError(" Checking out ".$package->getSourceReference());
  15437. $this->execute($package, $url, "svn co", sprintf("%s/%s", $url, $ref), null, $path);
  15438. return \React\Promise\resolve(null);
  15439. }
  15440. protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): PromiseInterface
  15441. {
  15442. SvnUtil::cleanEnv();
  15443. $ref = $target->getSourceReference();
  15444. if (!$this->hasMetadataRepository($path)) {
  15445. throw new \RuntimeException('The .svn directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  15446. }
  15447. $util = new SvnUtil($url, $this->io, $this->config, $this->process);
  15448. $flags = "";
  15449. if (version_compare($util->binaryVersion(), '1.7.0', '>=')) {
  15450. $flags .= ' --ignore-ancestry';
  15451. }
  15452. $this->io->writeError(" Checking out " . $ref);
  15453. $this->execute($target, $url, "svn switch" . $flags, sprintf("%s/%s", $url, $ref), $path);
  15454. return \React\Promise\resolve(null);
  15455. }
  15456. public function getLocalChanges(PackageInterface $package, string $path): ?string
  15457. {
  15458. if (!$this->hasMetadataRepository($path)) {
  15459. return null;
  15460. }
  15461. $this->process->execute('svn status --ignore-externals', $output, $path);
  15462. return Preg::isMatch('{^ *[^X ] +}m', $output) ? $output : null;
  15463. }
  15464. protected function execute(PackageInterface $package, string $baseUrl, string $command, string $url, string $cwd = null, string $path = null): string
  15465. {
  15466. $util = new SvnUtil($baseUrl, $this->io, $this->config, $this->process);
  15467. $util->setCacheCredentials($this->cacheCredentials);
  15468. try {
  15469. return $util->execute($command, $url, $cwd, $path, $this->io->isVerbose());
  15470. } catch (\RuntimeException $e) {
  15471. throw new \RuntimeException(
  15472. $package->getPrettyName().' could not be downloaded, '.$e->getMessage()
  15473. );
  15474. }
  15475. }
  15476. protected function cleanChanges(PackageInterface $package, string $path, bool $update): PromiseInterface
  15477. {
  15478. if (null === ($changes = $this->getLocalChanges($package, $path))) {
  15479. return \React\Promise\resolve(null);
  15480. }
  15481. if (!$this->io->isInteractive()) {
  15482. if (true === $this->config->get('discard-changes')) {
  15483. return $this->discardChanges($path);
  15484. }
  15485. return parent::cleanChanges($package, $path, $update);
  15486. }
  15487. $changes = array_map(function ($elem): string {
  15488. return ' '.$elem;
  15489. }, Preg::split('{\s*\r?\n\s*}', $changes));
  15490. $countChanges = count($changes);
  15491. $this->io->writeError(sprintf(' <error>'.$package->getPrettyName().' has modified file%s:</error>', $countChanges === 1 ? '' : 's'));
  15492. $this->io->writeError(array_slice($changes, 0, 10));
  15493. if ($countChanges > 10) {
  15494. $remainingChanges = $countChanges - 10;
  15495. $this->io->writeError(
  15496. sprintf(
  15497. ' <info>'.$remainingChanges.' more file%s modified, choose "v" to view the full list</info>',
  15498. $remainingChanges === 1 ? '' : 's'
  15499. )
  15500. );
  15501. }
  15502. while (true) {
  15503. switch ($this->io->ask(' <info>Discard changes [y,n,v,?]?</info> ', '?')) {
  15504. case 'y':
  15505. $this->discardChanges($path);
  15506. break 2;
  15507. case 'n':
  15508. throw new \RuntimeException('Update aborted');
  15509. case 'v':
  15510. $this->io->writeError($changes);
  15511. break;
  15512. case '?':
  15513. default:
  15514. $this->io->writeError(array(
  15515. ' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
  15516. ' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
  15517. ' v - view modified files',
  15518. ' ? - print help',
  15519. ));
  15520. break;
  15521. }
  15522. }
  15523. return \React\Promise\resolve(null);
  15524. }
  15525. protected function getCommitLogs(string $fromReference, string $toReference, string $path): string
  15526. {
  15527. if (Preg::isMatch('{@(\d+)$}', $fromReference) && Preg::isMatch('{@(\d+)$}', $toReference)) {
  15528. $command = sprintf('svn info --non-interactive --xml -- %s', ProcessExecutor::escape($path));
  15529. if (0 !== $this->process->execute($command, $output, $path)) {
  15530. throw new \RuntimeException(
  15531. 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()
  15532. );
  15533. }
  15534. $urlPattern = '#<url>(.*)</url>#';
  15535. if (Preg::isMatch($urlPattern, $output, $matches)) {
  15536. $baseUrl = $matches[1];
  15537. } else {
  15538. throw new \RuntimeException(
  15539. 'Unable to determine svn url for path '. $path
  15540. );
  15541. }
  15542. $fromRevision = Preg::replace('{.*@(\d+)$}', '$1', $fromReference);
  15543. $toRevision = Preg::replace('{.*@(\d+)$}', '$1', $toReference);
  15544. $command = sprintf('svn log -r%s:%s --incremental', ProcessExecutor::escape($fromRevision), ProcessExecutor::escape($toRevision));
  15545. $util = new SvnUtil($baseUrl, $this->io, $this->config, $this->process);
  15546. $util->setCacheCredentials($this->cacheCredentials);
  15547. try {
  15548. return $util->executeLocal($command, $path, null, $this->io->isVerbose());
  15549. } catch (\RuntimeException $e) {
  15550. throw new \RuntimeException(
  15551. 'Failed to execute ' . $command . "\n\n".$e->getMessage()
  15552. );
  15553. }
  15554. }
  15555. return "Could not retrieve changes between $fromReference and $toReference due to missing revision information";
  15556. }
  15557. protected function discardChanges(string $path): PromiseInterface
  15558. {
  15559. if (0 !== $this->process->execute('svn revert -R .', $output, $path)) {
  15560. throw new \RuntimeException("Could not reset changes\n\n:".$this->process->getErrorOutput());
  15561. }
  15562. return \React\Promise\resolve(null);
  15563. }
  15564. protected function hasMetadataRepository(string $path): bool
  15565. {
  15566. return is_dir($path.'/.svn');
  15567. }
  15568. }
  15569. <?php declare(strict_types=1);
  15570. namespace Composer\Downloader;
  15571. use Composer\Package\PackageInterface;
  15572. use React\Promise\PromiseInterface;
  15573. class TarDownloader extends ArchiveDownloader
  15574. {
  15575. protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface
  15576. {
  15577. $archive = new \PharData($file);
  15578. $archive->extractTo($path, null, true);
  15579. return \React\Promise\resolve(null);
  15580. }
  15581. }
  15582. <?php declare(strict_types=1);
  15583. namespace Composer\Downloader;
  15584. class TransportException extends \RuntimeException
  15585. {
  15586. protected $headers;
  15587. protected $response;
  15588. protected $statusCode;
  15589. protected $responseInfo = array();
  15590. public function setHeaders(array $headers): void
  15591. {
  15592. $this->headers = $headers;
  15593. }
  15594. public function getHeaders(): ?array
  15595. {
  15596. return $this->headers;
  15597. }
  15598. public function setResponse(?string $response): void
  15599. {
  15600. $this->response = $response;
  15601. }
  15602. public function getResponse(): ?string
  15603. {
  15604. return $this->response;
  15605. }
  15606. public function setStatusCode($statusCode): void
  15607. {
  15608. $this->statusCode = $statusCode;
  15609. }
  15610. public function getStatusCode(): ?int
  15611. {
  15612. return $this->statusCode;
  15613. }
  15614. public function getResponseInfo(): array
  15615. {
  15616. return $this->responseInfo;
  15617. }
  15618. public function setResponseInfo(array $responseInfo): void
  15619. {
  15620. $this->responseInfo = $responseInfo;
  15621. }
  15622. }
  15623. <?php declare(strict_types=1);
  15624. namespace Composer\Downloader;
  15625. use Composer\Package\PackageInterface;
  15626. interface VcsCapableDownloaderInterface
  15627. {
  15628. public function getVcsReference(PackageInterface $package, string $path): ?string;
  15629. }
  15630. <?php declare(strict_types=1);
  15631. namespace Composer\Downloader;
  15632. use Composer\Config;
  15633. use Composer\Package\Dumper\ArrayDumper;
  15634. use Composer\Package\PackageInterface;
  15635. use Composer\Package\Version\VersionGuesser;
  15636. use Composer\Package\Version\VersionParser;
  15637. use Composer\Util\ProcessExecutor;
  15638. use Composer\IO\IOInterface;
  15639. use Composer\Util\Filesystem;
  15640. use React\Promise\PromiseInterface;
  15641. use Composer\DependencyResolver\Operation\UpdateOperation;
  15642. use Composer\DependencyResolver\Operation\InstallOperation;
  15643. use Composer\DependencyResolver\Operation\UninstallOperation;
  15644. abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterface, VcsCapableDownloaderInterface
  15645. {
  15646. protected $io;
  15647. protected $config;
  15648. protected $process;
  15649. protected $filesystem;
  15650. protected $hasCleanedChanges = array();
  15651. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, Filesystem $fs = null)
  15652. {
  15653. $this->io = $io;
  15654. $this->config = $config;
  15655. $this->process = $process ?? new ProcessExecutor($io);
  15656. $this->filesystem = $fs ?? new Filesystem($this->process);
  15657. }
  15658. public function getInstallationSource(): string
  15659. {
  15660. return 'source';
  15661. }
  15662. public function download(PackageInterface $package, string $path, PackageInterface $prevPackage = null): PromiseInterface
  15663. {
  15664. if (!$package->getSourceReference()) {
  15665. throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
  15666. }
  15667. $urls = $this->prepareUrls($package->getSourceUrls());
  15668. while ($url = array_shift($urls)) {
  15669. try {
  15670. return $this->doDownload($package, $path, $url, $prevPackage);
  15671. } catch (\Exception $e) {
  15672. if ($e instanceof \PHPUnit\Framework\Exception) {
  15673. throw $e;
  15674. }
  15675. if ($this->io->isDebug()) {
  15676. $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
  15677. } elseif (count($urls)) {
  15678. $this->io->writeError(' Failed, trying the next URL');
  15679. }
  15680. if (!count($urls)) {
  15681. throw $e;
  15682. }
  15683. }
  15684. }
  15685. return \React\Promise\resolve(null);
  15686. }
  15687. public function prepare(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null): PromiseInterface
  15688. {
  15689. if ($type === 'update') {
  15690. $this->cleanChanges($prevPackage, $path, true);
  15691. $this->hasCleanedChanges[$prevPackage->getUniqueName()] = true;
  15692. } elseif ($type === 'install') {
  15693. $this->filesystem->emptyDirectory($path);
  15694. } elseif ($type === 'uninstall') {
  15695. $this->cleanChanges($package, $path, false);
  15696. }
  15697. return \React\Promise\resolve(null);
  15698. }
  15699. public function cleanup(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null): PromiseInterface
  15700. {
  15701. if ($type === 'update' && isset($this->hasCleanedChanges[$prevPackage->getUniqueName()])) {
  15702. $this->reapplyChanges($path);
  15703. unset($this->hasCleanedChanges[$prevPackage->getUniqueName()]);
  15704. }
  15705. return \React\Promise\resolve(null);
  15706. }
  15707. public function install(PackageInterface $package, string $path): PromiseInterface
  15708. {
  15709. if (!$package->getSourceReference()) {
  15710. throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
  15711. }
  15712. $this->io->writeError(" - " . InstallOperation::format($package).': ', false);
  15713. $urls = $this->prepareUrls($package->getSourceUrls());
  15714. while ($url = array_shift($urls)) {
  15715. try {
  15716. $this->doInstall($package, $path, $url);
  15717. break;
  15718. } catch (\Exception $e) {
  15719. if ($e instanceof \PHPUnit\Framework\Exception) {
  15720. throw $e;
  15721. }
  15722. if ($this->io->isDebug()) {
  15723. $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
  15724. } elseif (count($urls)) {
  15725. $this->io->writeError(' Failed, trying the next URL');
  15726. }
  15727. if (!count($urls)) {
  15728. throw $e;
  15729. }
  15730. }
  15731. }
  15732. return \React\Promise\resolve(null);
  15733. }
  15734. public function update(PackageInterface $initial, PackageInterface $target, string $path): PromiseInterface
  15735. {
  15736. if (!$target->getSourceReference()) {
  15737. throw new \InvalidArgumentException('Package '.$target->getPrettyName().' is missing reference information');
  15738. }
  15739. $this->io->writeError(" - " . UpdateOperation::format($initial, $target).': ', false);
  15740. $urls = $this->prepareUrls($target->getSourceUrls());
  15741. $exception = null;
  15742. while ($url = array_shift($urls)) {
  15743. try {
  15744. $this->doUpdate($initial, $target, $path, $url);
  15745. $exception = null;
  15746. break;
  15747. } catch (\Exception $exception) {
  15748. if ($exception instanceof \PHPUnit\Framework\Exception) {
  15749. throw $exception;
  15750. }
  15751. if ($this->io->isDebug()) {
  15752. $this->io->writeError('Failed: ['.get_class($exception).'] '.$exception->getMessage());
  15753. } elseif (count($urls)) {
  15754. $this->io->writeError(' Failed, trying the next URL');
  15755. }
  15756. }
  15757. }
  15758. if (!$exception && $this->io->isVerbose() && $this->hasMetadataRepository($path)) {
  15759. $message = 'Pulling in changes:';
  15760. $logs = $this->getCommitLogs($initial->getSourceReference(), $target->getSourceReference(), $path);
  15761. if ('' === trim($logs)) {
  15762. $message = 'Rolling back changes:';
  15763. $logs = $this->getCommitLogs($target->getSourceReference(), $initial->getSourceReference(), $path);
  15764. }
  15765. if ('' !== trim($logs)) {
  15766. $logs = implode("\n", array_map(function ($line): string {
  15767. return ' ' . $line;
  15768. }, explode("\n", $logs)));
  15769. $logs = str_replace('<', '\<', $logs);
  15770. $this->io->writeError(' '.$message);
  15771. $this->io->writeError($logs);
  15772. }
  15773. }
  15774. if (!$urls && $exception) {
  15775. throw $exception;
  15776. }
  15777. return \React\Promise\resolve(null);
  15778. }
  15779. public function remove(PackageInterface $package, string $path): PromiseInterface
  15780. {
  15781. $this->io->writeError(" - " . UninstallOperation::format($package));
  15782. $promise = $this->filesystem->removeDirectoryAsync($path);
  15783. return $promise->then(function (bool $result) use ($path) {
  15784. if (!$result) {
  15785. throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
  15786. }
  15787. });
  15788. }
  15789. public function getVcsReference(PackageInterface $package, string $path): ?string
  15790. {
  15791. $parser = new VersionParser;
  15792. $guesser = new VersionGuesser($this->config, $this->process, $parser);
  15793. $dumper = new ArrayDumper;
  15794. $packageConfig = $dumper->dump($package);
  15795. if ($packageVersion = $guesser->guessVersion($packageConfig, $path)) {
  15796. return $packageVersion['commit'];
  15797. }
  15798. return null;
  15799. }
  15800. protected function cleanChanges(PackageInterface $package, string $path, bool $update): PromiseInterface
  15801. {
  15802. if (null !== $this->getLocalChanges($package, $path)) {
  15803. throw new \RuntimeException('Source directory ' . $path . ' has uncommitted changes.');
  15804. }
  15805. return \React\Promise\resolve(null);
  15806. }
  15807. protected function reapplyChanges(string $path): void
  15808. {
  15809. }
  15810. abstract protected function doDownload(PackageInterface $package, string $path, string $url, PackageInterface $prevPackage = null): PromiseInterface;
  15811. abstract protected function doInstall(PackageInterface $package, string $path, string $url): PromiseInterface;
  15812. abstract protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): PromiseInterface;
  15813. abstract protected function getCommitLogs(string $fromReference, string $toReference, string $path): string;
  15814. abstract protected function hasMetadataRepository(string $path): bool;
  15815. private function prepareUrls(array $urls): array
  15816. {
  15817. foreach ($urls as $index => $url) {
  15818. if (Filesystem::isLocalPath($url)) {
  15819. $fileProtocol = 'file://';
  15820. $isFileProtocol = false;
  15821. if (0 === strpos($url, $fileProtocol)) {
  15822. $url = substr($url, strlen($fileProtocol));
  15823. $isFileProtocol = true;
  15824. }
  15825. if (false !== strpos($url, '%')) {
  15826. $url = rawurldecode($url);
  15827. }
  15828. $urls[$index] = realpath($url);
  15829. if ($isFileProtocol) {
  15830. $urls[$index] = $fileProtocol . $urls[$index];
  15831. }
  15832. }
  15833. }
  15834. return $urls;
  15835. }
  15836. }
  15837. <?php declare(strict_types=1);
  15838. namespace Composer\Downloader;
  15839. use React\Promise\PromiseInterface;
  15840. use Composer\Package\PackageInterface;
  15841. use Composer\Util\ProcessExecutor;
  15842. class XzDownloader extends ArchiveDownloader
  15843. {
  15844. protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface
  15845. {
  15846. $command = 'tar -xJf ' . ProcessExecutor::escape($file) . ' -C ' . ProcessExecutor::escape($path);
  15847. if (0 === $this->process->execute($command, $ignoredOutput)) {
  15848. return \React\Promise\resolve(null);
  15849. }
  15850. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  15851. throw new \RuntimeException($processError);
  15852. }
  15853. }
  15854. <?php declare(strict_types=1);
  15855. namespace Composer\Downloader;
  15856. use Composer\Package\PackageInterface;
  15857. use Composer\Pcre\Preg;
  15858. use Composer\Util\IniHelper;
  15859. use Composer\Util\Platform;
  15860. use Composer\Util\ProcessExecutor;
  15861. use Symfony\Component\Process\ExecutableFinder;
  15862. use Symfony\Component\Process\Process;
  15863. use React\Promise\PromiseInterface;
  15864. use ZipArchive;
  15865. class ZipDownloader extends ArchiveDownloader
  15866. {
  15867. private static $unzipCommands;
  15868. private static $hasZipArchive;
  15869. private static $isWindows;
  15870. private $zipArchiveObject;
  15871. public function download(PackageInterface $package, string $path, PackageInterface $prevPackage = null, bool $output = true): PromiseInterface
  15872. {
  15873. if (null === self::$unzipCommands) {
  15874. self::$unzipCommands = array();
  15875. $finder = new ExecutableFinder;
  15876. if (Platform::isWindows() && ($cmd = $finder->find('7z', null, array('C:\Program Files\7-Zip')))) {
  15877. self::$unzipCommands[] = array('7z', ProcessExecutor::escape($cmd).' x -bb0 -y %s -o%s');
  15878. }
  15879. if ($cmd = $finder->find('unzip')) {
  15880. self::$unzipCommands[] = array('unzip', ProcessExecutor::escape($cmd).' -qq %s -d %s');
  15881. }
  15882. if (!Platform::isWindows() && ($cmd = $finder->find('7z'))) {
  15883. self::$unzipCommands[] = array('7z', ProcessExecutor::escape($cmd).' x -bb0 -y %s -o%s');
  15884. }
  15885. if (!Platform::isWindows() && ($cmd = $finder->find('7zz'))) {
  15886. self::$unzipCommands[] = array('7zz', ProcessExecutor::escape($cmd).' x -bb0 -y %s -o%s');
  15887. }
  15888. }
  15889. $procOpenMissing = false;
  15890. if (!function_exists('proc_open')) {
  15891. self::$unzipCommands = array();
  15892. $procOpenMissing = true;
  15893. }
  15894. if (null === self::$hasZipArchive) {
  15895. self::$hasZipArchive = class_exists('ZipArchive');
  15896. }
  15897. if (!self::$hasZipArchive && !self::$unzipCommands) {
  15898. $iniMessage = IniHelper::getMessage();
  15899. if ($procOpenMissing) {
  15900. $error = "The zip extension is missing and unzip/7z commands cannot be called as proc_open is disabled, skipping.\n" . $iniMessage;
  15901. } else {
  15902. $error = "The zip extension and unzip/7z commands are both missing, skipping.\n" . $iniMessage;
  15903. }
  15904. throw new \RuntimeException($error);
  15905. }
  15906. if (null === self::$isWindows) {
  15907. self::$isWindows = Platform::isWindows();
  15908. if (!self::$isWindows && !self::$unzipCommands) {
  15909. if ($procOpenMissing) {
  15910. $this->io->writeError("<warning>proc_open is disabled so 'unzip' and '7z' commands cannot be used, zip files are being unpacked using the PHP zip extension.</warning>");
  15911. $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>");
  15912. $this->io->writeError("<warning>Enabling proc_open and installing 'unzip' or '7z' (21.01+) may remediate them.</warning>");
  15913. } else {
  15914. $this->io->writeError("<warning>As there is no 'unzip' nor '7z' command installed zip files are being unpacked using the PHP zip extension.</warning>");
  15915. $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>");
  15916. $this->io->writeError("<warning>Installing 'unzip' or '7z' (21.01+) may remediate them.</warning>");
  15917. }
  15918. }
  15919. }
  15920. return parent::download($package, $path, $prevPackage, $output);
  15921. }
  15922. private function extractWithSystemUnzip(PackageInterface $package, string $file, string $path): PromiseInterface
  15923. {
  15924. static $warned7ZipLinux = false;
  15925. $isLastChance = !self::$hasZipArchive;
  15926. if (!self::$unzipCommands) {
  15927. return $this->extractWithZipArchive($package, $file, $path);
  15928. }
  15929. $commandSpec = reset(self::$unzipCommands);
  15930. $command = sprintf($commandSpec[1], ProcessExecutor::escape($file), ProcessExecutor::escape($path));
  15931. if (Platform::isWindows()) {
  15932. $command = sprintf($commandSpec[1], ProcessExecutor::escape(strtr($file, '/', '\\')), ProcessExecutor::escape(strtr($path, '/', '\\')));
  15933. }
  15934. $executable = $commandSpec[0];
  15935. if (!$warned7ZipLinux && !Platform::isWindows() && in_array($executable, array('7z', '7zz'), true)) {
  15936. $warned7ZipLinux = true;
  15937. if (0 === $this->process->execute($executable, $output)) {
  15938. if (Preg::isMatch('{^\s*7-Zip(?: \[64\])? ([0-9.]+)}', $output, $match) && version_compare($match[1], '21.01', '<')) {
  15939. $this->io->writeError(' <warning>Unzipping using '.$executable.' '.$match[1].' may result in incorrect file permissions. Install '.$executable.' 21.01+ or unzip to ensure you get correct permissions.</warning>');
  15940. }
  15941. }
  15942. }
  15943. $io = $this->io;
  15944. $tryFallback = function (\Throwable $processError) use ($isLastChance, $io, $file, $path, $package, $executable): \React\Promise\PromiseInterface {
  15945. if ($isLastChance) {
  15946. throw $processError;
  15947. }
  15948. if (!is_file($file)) {
  15949. $io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  15950. $io->writeError(' <warning>This most likely is due to a custom installer plugin not handling the returned Promise from the downloader</warning>');
  15951. $io->writeError(' <warning>See https://github.com/composer/installers/commit/5006d0c28730ade233a8f42ec31ac68fb1c5c9bb for an example fix</warning>');
  15952. } else {
  15953. $io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  15954. $io->writeError(' The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems)');
  15955. $io->writeError(' Unzip with '.$executable.' command failed, falling back to ZipArchive class');
  15956. }
  15957. return $this->extractWithZipArchive($package, $file, $path);
  15958. };
  15959. try {
  15960. $promise = $this->process->executeAsync($command);
  15961. return $promise->then(function (Process $process) use ($tryFallback, $command, $package, $file) {
  15962. if (!$process->isSuccessful()) {
  15963. if (isset($this->cleanupExecuted[$package->getName()])) {
  15964. throw new \RuntimeException('Failed to extract '.$package->getName().' as the installation was aborted by another package operation.');
  15965. }
  15966. $output = $process->getErrorOutput();
  15967. $output = str_replace(', '.$file.'.zip or '.$file.'.ZIP', '', $output);
  15968. return $tryFallback(new \RuntimeException('Failed to extract '.$package->getName().': ('.$process->getExitCode().') '.$command."\n\n".$output));
  15969. }
  15970. });
  15971. } catch (\Throwable $e) {
  15972. return $tryFallback($e);
  15973. }
  15974. }
  15975. private function extractWithZipArchive(PackageInterface $package, string $file, string $path): PromiseInterface
  15976. {
  15977. $processError = null;
  15978. $zipArchive = $this->zipArchiveObject ?: new ZipArchive();
  15979. try {
  15980. if (!file_exists($file) || ($filesize = filesize($file)) === false || $filesize === 0) {
  15981. $retval = -1;
  15982. } else {
  15983. $retval = $zipArchive->open($file);
  15984. }
  15985. if (true === $retval) {
  15986. $extractResult = $zipArchive->extractTo($path);
  15987. if (true === $extractResult) {
  15988. $zipArchive->close();
  15989. return \React\Promise\resolve(null);
  15990. }
  15991. $processError = new \RuntimeException(rtrim("There was an error extracting the ZIP file, it is either corrupted or using an invalid format.\n"));
  15992. } else {
  15993. $processError = new \UnexpectedValueException(rtrim($this->getErrorMessage($retval, $file)."\n"), $retval);
  15994. }
  15995. } catch (\ErrorException $e) {
  15996. $processError = new \RuntimeException('The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems): '.$e->getMessage(), 0, $e);
  15997. } catch (\Throwable $e) {
  15998. $processError = $e;
  15999. }
  16000. throw $processError;
  16001. }
  16002. protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface
  16003. {
  16004. return $this->extractWithSystemUnzip($package, $file, $path);
  16005. }
  16006. protected function getErrorMessage(int $retval, string $file): string
  16007. {
  16008. switch ($retval) {
  16009. case ZipArchive::ER_EXISTS:
  16010. return sprintf("File '%s' already exists.", $file);
  16011. case ZipArchive::ER_INCONS:
  16012. return sprintf("Zip archive '%s' is inconsistent.", $file);
  16013. case ZipArchive::ER_INVAL:
  16014. return sprintf("Invalid argument (%s)", $file);
  16015. case ZipArchive::ER_MEMORY:
  16016. return sprintf("Malloc failure (%s)", $file);
  16017. case ZipArchive::ER_NOENT:
  16018. return sprintf("No such zip file: '%s'", $file);
  16019. case ZipArchive::ER_NOZIP:
  16020. return sprintf("'%s' is not a zip archive.", $file);
  16021. case ZipArchive::ER_OPEN:
  16022. return sprintf("Can't open zip file: %s", $file);
  16023. case ZipArchive::ER_READ:
  16024. return sprintf("Zip read error (%s)", $file);
  16025. case ZipArchive::ER_SEEK:
  16026. return sprintf("Zip seek error (%s)", $file);
  16027. case -1:
  16028. return sprintf("'%s' is a corrupted zip archive (0 bytes), try again.", $file);
  16029. default:
  16030. return sprintf("'%s' is not a valid zip archive, got error code: %s", $file, $retval);
  16031. }
  16032. }
  16033. }
  16034. <?php declare(strict_types=1);
  16035. namespace Composer\EventDispatcher;
  16036. class Event
  16037. {
  16038. protected $name;
  16039. protected $args;
  16040. protected $flags;
  16041. private $propagationStopped = false;
  16042. public function __construct(string $name, array $args = array(), array $flags = array())
  16043. {
  16044. $this->name = $name;
  16045. $this->args = $args;
  16046. $this->flags = $flags;
  16047. }
  16048. public function getName(): string
  16049. {
  16050. return $this->name;
  16051. }
  16052. public function getArguments(): array
  16053. {
  16054. return $this->args;
  16055. }
  16056. public function getFlags(): array
  16057. {
  16058. return $this->flags;
  16059. }
  16060. public function isPropagationStopped(): bool
  16061. {
  16062. return $this->propagationStopped;
  16063. }
  16064. public function stopPropagation(): void
  16065. {
  16066. $this->propagationStopped = true;
  16067. }
  16068. }
  16069. <?php declare(strict_types=1);
  16070. namespace Composer\EventDispatcher;
  16071. use Composer\DependencyResolver\Transaction;
  16072. use Composer\Installer\InstallerEvent;
  16073. use Composer\IO\IOInterface;
  16074. use Composer\Composer;
  16075. use Composer\PartialComposer;
  16076. use Composer\Pcre\Preg;
  16077. use Composer\Util\Platform;
  16078. use Composer\DependencyResolver\Operation\OperationInterface;
  16079. use Composer\Repository\RepositoryInterface;
  16080. use Composer\Script;
  16081. use Composer\Installer\PackageEvent;
  16082. use Composer\Installer\BinaryInstaller;
  16083. use Composer\Util\ProcessExecutor;
  16084. use Composer\Script\Event as ScriptEvent;
  16085. use Composer\Autoload\ClassLoader;
  16086. use Symfony\Component\Process\PhpExecutableFinder;
  16087. use Symfony\Component\Process\ExecutableFinder;
  16088. class EventDispatcher
  16089. {
  16090. protected $composer;
  16091. protected $io;
  16092. protected $loader;
  16093. protected $process;
  16094. protected $listeners = array();
  16095. protected $runScripts = true;
  16096. private $eventStack;
  16097. public function __construct(PartialComposer $composer, IOInterface $io, ProcessExecutor $process = null)
  16098. {
  16099. $this->composer = $composer;
  16100. $this->io = $io;
  16101. $this->process = $process ?? new ProcessExecutor($io);
  16102. $this->eventStack = array();
  16103. }
  16104. public function setRunScripts(bool $runScripts = true): self
  16105. {
  16106. $this->runScripts = (bool) $runScripts;
  16107. return $this;
  16108. }
  16109. public function dispatch(?string $eventName, Event $event = null): int
  16110. {
  16111. if (null === $event) {
  16112. if (null === $eventName) {
  16113. throw new \InvalidArgumentException('If no $event is passed in to '.__METHOD__.' you have to pass in an $eventName, got null.');
  16114. }
  16115. $event = new Event($eventName);
  16116. }
  16117. return $this->doDispatch($event);
  16118. }
  16119. public function dispatchScript(string $eventName, bool $devMode = false, array $additionalArgs = array(), array $flags = array()): int
  16120. {
  16121. assert($this->composer instanceof Composer, new \LogicException('This should only be reached with a fully loaded Composer'));
  16122. return $this->doDispatch(new Script\Event($eventName, $this->composer, $this->io, $devMode, $additionalArgs, $flags));
  16123. }
  16124. public function dispatchPackageEvent(string $eventName, bool $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation): int
  16125. {
  16126. assert($this->composer instanceof Composer, new \LogicException('This should only be reached with a fully loaded Composer'));
  16127. return $this->doDispatch(new PackageEvent($eventName, $this->composer, $this->io, $devMode, $localRepo, $operations, $operation));
  16128. }
  16129. public function dispatchInstallerEvent(string $eventName, bool $devMode, bool $executeOperations, Transaction $transaction): int
  16130. {
  16131. assert($this->composer instanceof Composer, new \LogicException('This should only be reached with a fully loaded Composer'));
  16132. return $this->doDispatch(new InstallerEvent($eventName, $this->composer, $this->io, $devMode, $executeOperations, $transaction));
  16133. }
  16134. protected function doDispatch(Event $event)
  16135. {
  16136. if (Platform::getEnv('COMPOSER_DEBUG_EVENTS')) {
  16137. $details = null;
  16138. if ($event instanceof PackageEvent) {
  16139. $details = (string) $event->getOperation();
  16140. }
  16141. $this->io->writeError('Dispatching <info>'.$event->getName().'</info>'.($details ? ' ('.$details.')' : '').' event');
  16142. }
  16143. $listeners = $this->getListeners($event);
  16144. $this->pushEvent($event);
  16145. try {
  16146. $returnMax = 0;
  16147. foreach ($listeners as $callable) {
  16148. $return = 0;
  16149. $this->ensureBinDirIsInPath();
  16150. if (!is_string($callable)) {
  16151. if (!is_callable($callable)) {
  16152. $className = is_object($callable[0]) ? get_class($callable[0]) : $callable[0];
  16153. throw new \RuntimeException('Subscriber '.$className.'::'.$callable[1].' for event '.$event->getName().' is not callable, make sure the function is defined and public');
  16154. }
  16155. if (is_array($callable) && (is_string($callable[0]) || is_object($callable[0])) && is_string($callable[1])) {
  16156. $this->io->writeError(sprintf('> %s: %s', $event->getName(), (is_object($callable[0]) ? get_class($callable[0]) : $callable[0]).'->'.$callable[1]), true, IOInterface::VERBOSE);
  16157. }
  16158. $return = false === call_user_func($callable, $event) ? 1 : 0;
  16159. } elseif ($this->isComposerScript($callable)) {
  16160. $this->io->writeError(sprintf('> %s: %s', $event->getName(), $callable), true, IOInterface::VERBOSE);
  16161. $script = explode(' ', substr($callable, 1));
  16162. $scriptName = $script[0];
  16163. unset($script[0]);
  16164. $args = array_merge($script, $event->getArguments());
  16165. $flags = $event->getFlags();
  16166. if (strpos($callable, '@composer ') === 0) {
  16167. $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(Platform::getEnv('COMPOSER_BINARY')) . ' ' . implode(' ', $args);
  16168. if (0 !== ($exitCode = $this->executeTty($exec))) {
  16169. $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  16170. throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
  16171. }
  16172. } else {
  16173. if (!$this->getListeners(new Event($scriptName))) {
  16174. $this->io->writeError(sprintf('<warning>You made a reference to a non-existent script %s</warning>', $callable), true, IOInterface::QUIET);
  16175. }
  16176. try {
  16177. $scriptEvent = new Script\Event($scriptName, $event->getComposer(), $event->getIO(), $event->isDevMode(), $args, $flags);
  16178. $scriptEvent->setOriginatingEvent($event);
  16179. $return = $this->dispatch($scriptName, $scriptEvent);
  16180. } catch (ScriptExecutionException $e) {
  16181. $this->io->writeError(sprintf('<error>Script %s was called via %s</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  16182. throw $e;
  16183. }
  16184. }
  16185. } elseif ($this->isPhpScript($callable)) {
  16186. $className = substr($callable, 0, strpos($callable, '::'));
  16187. $methodName = substr($callable, strpos($callable, '::') + 2);
  16188. if (!class_exists($className)) {
  16189. $this->io->writeError('<warning>Class '.$className.' is not autoloadable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  16190. continue;
  16191. }
  16192. if (!is_callable($callable)) {
  16193. $this->io->writeError('<warning>Method '.$callable.' is not callable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  16194. continue;
  16195. }
  16196. try {
  16197. $return = false === $this->executeEventPhpScript($className, $methodName, $event) ? 1 : 0;
  16198. } catch (\Exception $e) {
  16199. $message = "Script %s handling the %s event terminated with an exception";
  16200. $this->io->writeError('<error>'.sprintf($message, $callable, $event->getName()).'</error>', true, IOInterface::QUIET);
  16201. throw $e;
  16202. }
  16203. } else {
  16204. $args = implode(' ', array_map(array('Composer\Util\ProcessExecutor', 'escape'), $event->getArguments()));
  16205. $exec = $callable . ($args === '' ? '' : ' '.$args);
  16206. if ($this->io->isVerbose()) {
  16207. $this->io->writeError(sprintf('> %s: %s', $event->getName(), $exec));
  16208. } elseif ($event->getName() !== '__exec_command') {
  16209. $this->io->writeError(sprintf('> %s', $exec));
  16210. }
  16211. $possibleLocalBinaries = $this->composer->getPackage()->getBinaries();
  16212. if ($possibleLocalBinaries) {
  16213. foreach ($possibleLocalBinaries as $localExec) {
  16214. if (Preg::isMatch('{\b'.preg_quote($callable).'$}', $localExec)) {
  16215. $caller = BinaryInstaller::determineBinaryCaller($localExec);
  16216. $exec = Preg::replace('{^'.preg_quote($callable).'}', $caller . ' ' . $localExec, $exec);
  16217. break;
  16218. }
  16219. }
  16220. }
  16221. if (strpos($exec, '@putenv ') === 0) {
  16222. if (false === strpos($exec, '=')) {
  16223. Platform::clearEnv(substr($exec, 8));
  16224. } else {
  16225. list($var, $value) = explode('=', substr($exec, 8), 2);
  16226. Platform::putEnv($var, $value);
  16227. }
  16228. continue;
  16229. }
  16230. if (strpos($exec, '@php ') === 0) {
  16231. $pathAndArgs = substr($exec, 5);
  16232. if (Platform::isWindows()) {
  16233. $pathAndArgs = Preg::replaceCallback('{^\S+}', function ($path) {
  16234. return str_replace('/', '\\', $path[0]);
  16235. }, $pathAndArgs);
  16236. }
  16237. $matched = Preg::isMatch('{^[^\'"\s/\\\\]+}', $pathAndArgs, $match);
  16238. if ($matched && !file_exists($match[0])) {
  16239. $finder = new ExecutableFinder;
  16240. if ($pathToExec = $finder->find($match[0])) {
  16241. $pathAndArgs = $pathToExec . substr($pathAndArgs, strlen($match[0]));
  16242. }
  16243. }
  16244. $exec = $this->getPhpExecCommand() . ' ' . $pathAndArgs;
  16245. } else {
  16246. $finder = new PhpExecutableFinder();
  16247. $phpPath = $finder->find(false);
  16248. if ($phpPath) {
  16249. Platform::putEnv('PHP_BINARY', $phpPath);
  16250. }
  16251. if (Platform::isWindows()) {
  16252. $exec = Preg::replaceCallback('{^\S+}', function ($path) {
  16253. return str_replace('/', '\\', $path[0]);
  16254. }, $exec);
  16255. }
  16256. }
  16257. if (strpos($exec, 'composer ') === 0) {
  16258. $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(Platform::getEnv('COMPOSER_BINARY')) . substr($exec, 8);
  16259. }
  16260. if (0 !== ($exitCode = $this->executeTty($exec))) {
  16261. $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  16262. throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
  16263. }
  16264. }
  16265. $returnMax = max($returnMax, $return);
  16266. if ($event->isPropagationStopped()) {
  16267. break;
  16268. }
  16269. }
  16270. } finally {
  16271. $this->popEvent();
  16272. }
  16273. return $returnMax;
  16274. }
  16275. protected function executeTty(string $exec): int
  16276. {
  16277. if ($this->io->isInteractive()) {
  16278. return $this->process->executeTty($exec);
  16279. }
  16280. return $this->process->execute($exec);
  16281. }
  16282. protected function getPhpExecCommand(): string
  16283. {
  16284. $finder = new PhpExecutableFinder();
  16285. $phpPath = $finder->find(false);
  16286. if (!$phpPath) {
  16287. throw new \RuntimeException('Failed to locate PHP binary to execute '.$phpPath);
  16288. }
  16289. $phpArgs = $finder->findArguments();
  16290. $phpArgs = $phpArgs ? ' ' . implode(' ', $phpArgs) : '';
  16291. $allowUrlFOpenFlag = ' -d allow_url_fopen=' . ProcessExecutor::escape(ini_get('allow_url_fopen'));
  16292. $disableFunctionsFlag = ' -d disable_functions=' . ProcessExecutor::escape(ini_get('disable_functions'));
  16293. $memoryLimitFlag = ' -d memory_limit=' . ProcessExecutor::escape(ini_get('memory_limit'));
  16294. return ProcessExecutor::escape($phpPath) . $phpArgs . $allowUrlFOpenFlag . $disableFunctionsFlag . $memoryLimitFlag;
  16295. }
  16296. protected function executeEventPhpScript(string $className, string $methodName, Event $event)
  16297. {
  16298. if ($this->io->isVerbose()) {
  16299. $this->io->writeError(sprintf('> %s: %s::%s', $event->getName(), $className, $methodName));
  16300. } else {
  16301. $this->io->writeError(sprintf('> %s::%s', $className, $methodName));
  16302. }
  16303. return $className::$methodName($event);
  16304. }
  16305. public function addListener(string $eventName, $listener, int $priority = 0): void
  16306. {
  16307. $this->listeners[$eventName][$priority][] = $listener;
  16308. }
  16309. public function removeListener($listener): void
  16310. {
  16311. foreach ($this->listeners as $eventName => $priorities) {
  16312. foreach ($priorities as $priority => $listeners) {
  16313. foreach ($listeners as $index => $candidate) {
  16314. if ($listener === $candidate || (is_array($candidate) && is_object($listener) && $candidate[0] === $listener)) {
  16315. unset($this->listeners[$eventName][$priority][$index]);
  16316. }
  16317. }
  16318. }
  16319. }
  16320. }
  16321. public function addSubscriber(EventSubscriberInterface $subscriber): void
  16322. {
  16323. foreach ($subscriber->getSubscribedEvents() as $eventName => $params) {
  16324. if (is_string($params)) {
  16325. $this->addListener($eventName, array($subscriber, $params));
  16326. } elseif (is_string($params[0])) {
  16327. $this->addListener($eventName, array($subscriber, $params[0]), $params[1] ?? 0);
  16328. } else {
  16329. foreach ($params as $listener) {
  16330. $this->addListener($eventName, array($subscriber, $listener[0]), $listener[1] ?? 0);
  16331. }
  16332. }
  16333. }
  16334. }
  16335. protected function getListeners(Event $event): array
  16336. {
  16337. $scriptListeners = $this->runScripts ? $this->getScriptListeners($event) : array();
  16338. if (!isset($this->listeners[$event->getName()][0])) {
  16339. $this->listeners[$event->getName()][0] = array();
  16340. }
  16341. krsort($this->listeners[$event->getName()]);
  16342. $listeners = $this->listeners;
  16343. $listeners[$event->getName()][0] = array_merge($listeners[$event->getName()][0], $scriptListeners);
  16344. return call_user_func_array('array_merge', $listeners[$event->getName()]);
  16345. }
  16346. public function hasEventListeners(Event $event): bool
  16347. {
  16348. $listeners = $this->getListeners($event);
  16349. return count($listeners) > 0;
  16350. }
  16351. protected function getScriptListeners(Event $event): array
  16352. {
  16353. $package = $this->composer->getPackage();
  16354. $scripts = $package->getScripts();
  16355. if (empty($scripts[$event->getName()])) {
  16356. return array();
  16357. }
  16358. assert($this->composer instanceof Composer, new \LogicException('This should only be reached with a fully loaded Composer'));
  16359. if ($this->loader) {
  16360. $this->loader->unregister();
  16361. }
  16362. $generator = $this->composer->getAutoloadGenerator();
  16363. if ($event instanceof ScriptEvent) {
  16364. $generator->setDevMode($event->isDevMode());
  16365. }
  16366. $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
  16367. $packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $package, $packages);
  16368. $map = $generator->parseAutoloads($packageMap, $package);
  16369. $this->loader = $generator->createLoader($map, $this->composer->getConfig()->get('vendor-dir'));
  16370. $this->loader->register(false);
  16371. return $scripts[$event->getName()];
  16372. }
  16373. protected function isPhpScript(string $callable): bool
  16374. {
  16375. return false === strpos($callable, ' ') && false !== strpos($callable, '::');
  16376. }
  16377. protected function isComposerScript(string $callable): bool
  16378. {
  16379. return strpos($callable, '@') === 0 && strpos($callable, '@php ') !== 0 && strpos($callable, '@putenv ') !== 0;
  16380. }
  16381. protected function pushEvent(Event $event): int
  16382. {
  16383. $eventName = $event->getName();
  16384. if (in_array($eventName, $this->eventStack)) {
  16385. throw new \RuntimeException(sprintf("Circular call to script handler '%s' detected", $eventName));
  16386. }
  16387. return array_push($this->eventStack, $eventName);
  16388. }
  16389. protected function popEvent(): ?string
  16390. {
  16391. return array_pop($this->eventStack);
  16392. }
  16393. private function ensureBinDirIsInPath(): void
  16394. {
  16395. $pathEnv = 'PATH';
  16396. if (!isset($_SERVER[$pathEnv]) && isset($_SERVER['Path'])) {
  16397. $pathEnv = 'Path';
  16398. }
  16399. $binDir = $this->composer->getConfig()->get('bin-dir');
  16400. if (is_dir($binDir)) {
  16401. $binDir = realpath($binDir);
  16402. $pathValue = (string) Platform::getEnv($pathEnv);
  16403. if (!Preg::isMatch('{(^|'.PATH_SEPARATOR.')'.preg_quote($binDir).'($|'.PATH_SEPARATOR.')}', $pathValue)) {
  16404. Platform::putEnv($pathEnv, $binDir.PATH_SEPARATOR.$pathValue);
  16405. }
  16406. }
  16407. }
  16408. }
  16409. <?php declare(strict_types=1);
  16410. namespace Composer\EventDispatcher;
  16411. interface EventSubscriberInterface
  16412. {
  16413. public static function getSubscribedEvents();
  16414. }
  16415. <?php declare(strict_types=1);
  16416. namespace Composer\EventDispatcher;
  16417. class ScriptExecutionException extends \RuntimeException
  16418. {
  16419. }
  16420. <?php declare(strict_types=1);
  16421. namespace Composer\Exception;
  16422. class IrrecoverableDownloadException extends \RuntimeException
  16423. {
  16424. }
  16425. <?php declare(strict_types=1);
  16426. namespace Composer\Exception;
  16427. class NoSslException extends \RuntimeException
  16428. {
  16429. }
  16430. <?php declare(strict_types=1);
  16431. namespace Composer;
  16432. use Composer\Config\JsonConfigSource;
  16433. use Composer\Json\JsonFile;
  16434. use Composer\IO\IOInterface;
  16435. use Composer\Package\Archiver;
  16436. use Composer\Package\Version\VersionGuesser;
  16437. use Composer\Package\RootPackageInterface;
  16438. use Composer\Repository\RepositoryManager;
  16439. use Composer\Repository\RepositoryFactory;
  16440. use Composer\Util\Filesystem;
  16441. use Composer\Util\Platform;
  16442. use Composer\Util\ProcessExecutor;
  16443. use Composer\Util\HttpDownloader;
  16444. use Composer\Util\Loop;
  16445. use Composer\Util\Silencer;
  16446. use Composer\Plugin\PluginEvents;
  16447. use Composer\EventDispatcher\Event;
  16448. use Phar;
  16449. use Seld\JsonLint\DuplicateKeyException;
  16450. use Symfony\Component\Console\Formatter\OutputFormatter;
  16451. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  16452. use Symfony\Component\Console\Output\ConsoleOutput;
  16453. use Composer\EventDispatcher\EventDispatcher;
  16454. use Composer\Autoload\AutoloadGenerator;
  16455. use Composer\Package\Version\VersionParser;
  16456. use Composer\Downloader\TransportException;
  16457. use Composer\Json\JsonValidationException;
  16458. use Composer\Repository\InstalledRepositoryInterface;
  16459. use Seld\JsonLint\JsonParser;
  16460. use UnexpectedValueException;
  16461. use ZipArchive;
  16462. class Factory
  16463. {
  16464. protected static function getHomeDir(): string
  16465. {
  16466. $home = Platform::getEnv('COMPOSER_HOME');
  16467. if ($home) {
  16468. return $home;
  16469. }
  16470. if (Platform::isWindows()) {
  16471. if (!Platform::getEnv('APPDATA')) {
  16472. throw new \RuntimeException('The APPDATA or COMPOSER_HOME environment variable must be set for composer to run correctly');
  16473. }
  16474. return rtrim(strtr(Platform::getEnv('APPDATA'), '\\', '/'), '/') . '/Composer';
  16475. }
  16476. $userDir = self::getUserDir();
  16477. $dirs = array();
  16478. if (self::useXdg()) {
  16479. $xdgConfig = Platform::getEnv('XDG_CONFIG_HOME');
  16480. if (!$xdgConfig) {
  16481. $xdgConfig = $userDir . '/.config';
  16482. }
  16483. $dirs[] = $xdgConfig . '/composer';
  16484. }
  16485. $dirs[] = $userDir . '/.composer';
  16486. foreach ($dirs as $dir) {
  16487. if (Silencer::call('is_dir', $dir)) {
  16488. return $dir;
  16489. }
  16490. }
  16491. return $dirs[0];
  16492. }
  16493. protected static function getCacheDir(string $home): string
  16494. {
  16495. $cacheDir = Platform::getEnv('COMPOSER_CACHE_DIR');
  16496. if ($cacheDir) {
  16497. return $cacheDir;
  16498. }
  16499. $homeEnv = Platform::getEnv('COMPOSER_HOME');
  16500. if ($homeEnv) {
  16501. return $homeEnv . '/cache';
  16502. }
  16503. if (Platform::isWindows()) {
  16504. if ($cacheDir = Platform::getEnv('LOCALAPPDATA')) {
  16505. $cacheDir .= '/Composer';
  16506. } else {
  16507. $cacheDir = $home . '/cache';
  16508. }
  16509. return rtrim(strtr($cacheDir, '\\', '/'), '/');
  16510. }
  16511. $userDir = self::getUserDir();
  16512. if (PHP_OS === 'Darwin') {
  16513. if (is_dir($home . '/cache') && !is_dir($userDir . '/Library/Caches/composer')) {
  16514. Silencer::call('rename', $home . '/cache', $userDir . '/Library/Caches/composer');
  16515. }
  16516. return $userDir . '/Library/Caches/composer';
  16517. }
  16518. if ($home === $userDir . '/.composer' && is_dir($home . '/cache')) {
  16519. return $home . '/cache';
  16520. }
  16521. if (self::useXdg()) {
  16522. $xdgCache = Platform::getEnv('XDG_CACHE_HOME') ?: $userDir . '/.cache';
  16523. return $xdgCache . '/composer';
  16524. }
  16525. return $home . '/cache';
  16526. }
  16527. protected static function getDataDir(string $home): string
  16528. {
  16529. $homeEnv = Platform::getEnv('COMPOSER_HOME');
  16530. if ($homeEnv) {
  16531. return $homeEnv;
  16532. }
  16533. if (Platform::isWindows()) {
  16534. return strtr($home, '\\', '/');
  16535. }
  16536. $userDir = self::getUserDir();
  16537. if ($home !== $userDir . '/.composer' && self::useXdg()) {
  16538. $xdgData = Platform::getEnv('XDG_DATA_HOME') ?: $userDir . '/.local/share';
  16539. return $xdgData . '/composer';
  16540. }
  16541. return $home;
  16542. }
  16543. public static function createConfig(IOInterface $io = null, ?string $cwd = null): Config
  16544. {
  16545. $cwd = $cwd ?? Platform::getCwd(true);
  16546. $config = new Config(true, $cwd);
  16547. $home = self::getHomeDir();
  16548. $config->merge(array(
  16549. 'config' => array(
  16550. 'home' => $home,
  16551. 'cache-dir' => self::getCacheDir($home),
  16552. 'data-dir' => self::getDataDir($home),
  16553. )
  16554. ), Config::SOURCE_DEFAULT);
  16555. $file = new JsonFile($config->get('home').'/config.json');
  16556. if ($file->exists()) {
  16557. if ($io instanceof IOInterface) {
  16558. $io->writeError('Loading config file ' . $file->getPath(), true, IOInterface::DEBUG);
  16559. }
  16560. self::validateJsonSchema($io, $file);
  16561. $config->merge($file->read(), $file->getPath());
  16562. }
  16563. $config->setConfigSource(new JsonConfigSource($file));
  16564. $htaccessProtect = (bool) $config->get('htaccess-protect');
  16565. if ($htaccessProtect) {
  16566. $dirs = array($config->get('home'), $config->get('cache-dir'), $config->get('data-dir'));
  16567. foreach ($dirs as $dir) {
  16568. if (!file_exists($dir . '/.htaccess')) {
  16569. if (!is_dir($dir)) {
  16570. Silencer::call('mkdir', $dir, 0777, true);
  16571. }
  16572. Silencer::call('file_put_contents', $dir . '/.htaccess', 'Deny from all');
  16573. }
  16574. }
  16575. }
  16576. $file = new JsonFile($config->get('home').'/auth.json');
  16577. if ($file->exists()) {
  16578. if ($io instanceof IOInterface) {
  16579. $io->writeError('Loading config file ' . $file->getPath(), true, IOInterface::DEBUG);
  16580. }
  16581. self::validateJsonSchema($io, $file, JsonFile::AUTH_SCHEMA);
  16582. $config->merge(array('config' => $file->read()), $file->getPath());
  16583. }
  16584. $config->setAuthConfigSource(new JsonConfigSource($file, true));
  16585. if ($composerAuthEnv = Platform::getEnv('COMPOSER_AUTH')) {
  16586. $authData = json_decode($composerAuthEnv);
  16587. if (null === $authData) {
  16588. if ($io instanceof IOInterface) {
  16589. $io->writeError('<error>COMPOSER_AUTH environment variable is malformed, should be a valid JSON object</error>');
  16590. }
  16591. } else {
  16592. if ($io instanceof IOInterface) {
  16593. $io->writeError('Loading auth config from COMPOSER_AUTH', true, IOInterface::DEBUG);
  16594. }
  16595. self::validateJsonSchema($io, $authData, JsonFile::AUTH_SCHEMA, 'COMPOSER_AUTH');
  16596. $authData = json_decode($composerAuthEnv, true);
  16597. if (null !== $authData) {
  16598. $config->merge(array('config' => $authData), 'COMPOSER_AUTH');
  16599. }
  16600. }
  16601. }
  16602. return $config;
  16603. }
  16604. public static function getComposerFile(): string
  16605. {
  16606. return trim((string) Platform::getEnv('COMPOSER')) ?: './composer.json';
  16607. }
  16608. public static function getLockFile(string $composerFile): string
  16609. {
  16610. return "json" === pathinfo($composerFile, PATHINFO_EXTENSION)
  16611. ? substr($composerFile, 0, -4).'lock'
  16612. : $composerFile . '.lock';
  16613. }
  16614. public static function createAdditionalStyles(): array
  16615. {
  16616. return array(
  16617. 'highlight' => new OutputFormatterStyle('red'),
  16618. 'warning' => new OutputFormatterStyle('black', 'yellow'),
  16619. );
  16620. }
  16621. public static function createOutput(): ConsoleOutput
  16622. {
  16623. $styles = self::createAdditionalStyles();
  16624. $formatter = new OutputFormatter(false, $styles);
  16625. return new ConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL, null, $formatter);
  16626. }
  16627. public function createComposer(IOInterface $io, $localConfig = null, bool $disablePlugins = false, ?string $cwd = null, bool $fullLoad = true, bool $disableScripts = false)
  16628. {
  16629. $cwd = $cwd ?? Platform::getCwd(true);
  16630. if (null === $localConfig) {
  16631. $localConfig = static::getComposerFile();
  16632. }
  16633. $localConfigSource = Config::SOURCE_UNKNOWN;
  16634. if (is_string($localConfig)) {
  16635. $composerFile = $localConfig;
  16636. $file = new JsonFile($localConfig, null, $io);
  16637. if (!$file->exists()) {
  16638. if ($localConfig === './composer.json' || $localConfig === 'composer.json') {
  16639. $message = 'Composer could not find a composer.json file in '.$cwd;
  16640. } else {
  16641. $message = 'Composer could not find the config file: '.$localConfig;
  16642. }
  16643. $instructions = $fullLoad ? 'To initialize a project, please create a composer.json file. See https://getcomposer.org/basic-usage' : '';
  16644. throw new \InvalidArgumentException($message.PHP_EOL.$instructions);
  16645. }
  16646. try {
  16647. $file->validateSchema(JsonFile::LAX_SCHEMA);
  16648. } catch (JsonValidationException $e) {
  16649. $errors = ' - ' . implode(PHP_EOL . ' - ', $e->getErrors());
  16650. $message = $e->getMessage() . ':' . PHP_EOL . $errors;
  16651. throw new JsonValidationException($message);
  16652. }
  16653. $localConfig = $file->read();
  16654. $localConfigSource = $file->getPath();
  16655. }
  16656. $config = static::createConfig($io, $cwd);
  16657. $config->merge($localConfig, $localConfigSource);
  16658. if (isset($composerFile)) {
  16659. $io->writeError('Loading config file ' . $composerFile .' ('.realpath($composerFile).')', true, IOInterface::DEBUG);
  16660. $config->setConfigSource(new JsonConfigSource(new JsonFile(realpath($composerFile), null, $io)));
  16661. $localAuthFile = new JsonFile(dirname(realpath($composerFile)) . '/auth.json', null, $io);
  16662. if ($localAuthFile->exists()) {
  16663. $io->writeError('Loading config file ' . $localAuthFile->getPath(), true, IOInterface::DEBUG);
  16664. $config->merge(array('config' => $localAuthFile->read()), $localAuthFile->getPath());
  16665. $config->setAuthConfigSource(new JsonConfigSource($localAuthFile, true));
  16666. }
  16667. }
  16668. $vendorDir = $config->get('vendor-dir');
  16669. $composer = $fullLoad ? new Composer() : new PartialComposer();
  16670. $composer->setConfig($config);
  16671. if ($fullLoad) {
  16672. $io->loadConfiguration($config);
  16673. if (!class_exists('Composer\InstalledVersions', false) && file_exists($installedVersionsPath = $config->get('vendor-dir').'/composer/InstalledVersions.php')) {
  16674. include $installedVersionsPath;
  16675. }
  16676. }
  16677. $httpDownloader = self::createHttpDownloader($io, $config);
  16678. $process = new ProcessExecutor($io);
  16679. $loop = new Loop($httpDownloader, $process);
  16680. $composer->setLoop($loop);
  16681. $dispatcher = new EventDispatcher($composer, $io, $process);
  16682. $dispatcher->setRunScripts(!$disableScripts);
  16683. $composer->setEventDispatcher($dispatcher);
  16684. $rm = RepositoryFactory::manager($io, $config, $httpDownloader, $dispatcher, $process);
  16685. $composer->setRepositoryManager($rm);
  16686. if (!$fullLoad && !isset($localConfig['version'])) {
  16687. $localConfig['version'] = '1.0.0';
  16688. }
  16689. $parser = new VersionParser;
  16690. $guesser = new VersionGuesser($config, $process, $parser);
  16691. $loader = $this->loadRootPackage($rm, $config, $parser, $guesser, $io);
  16692. $package = $loader->load($localConfig, 'Composer\Package\RootPackage', $cwd);
  16693. $composer->setPackage($package);
  16694. $this->addLocalRepository($io, $rm, $vendorDir, $package, $process);
  16695. $im = $this->createInstallationManager($loop, $io, $dispatcher);
  16696. $composer->setInstallationManager($im);
  16697. if ($composer instanceof Composer) {
  16698. $dm = $this->createDownloadManager($io, $config, $httpDownloader, $process, $dispatcher);
  16699. $composer->setDownloadManager($dm);
  16700. $generator = new AutoloadGenerator($dispatcher, $io);
  16701. $composer->setAutoloadGenerator($generator);
  16702. $am = $this->createArchiveManager($config, $dm, $loop);
  16703. $composer->setArchiveManager($am);
  16704. }
  16705. $this->createDefaultInstallers($im, $composer, $io, $process);
  16706. if ($composer instanceof Composer) {
  16707. $globalComposer = null;
  16708. if (realpath($config->get('home')) !== $cwd) {
  16709. $globalComposer = $this->createGlobalComposer($io, $config, $disablePlugins, $disableScripts);
  16710. }
  16711. $pm = $this->createPluginManager($io, $composer, $globalComposer, $disablePlugins);
  16712. $composer->setPluginManager($pm);
  16713. $pm->loadInstalledPlugins();
  16714. }
  16715. if ($composer instanceof Composer && isset($composerFile)) {
  16716. $lockFile = self::getLockFile($composerFile);
  16717. if (!$config->get('lock') && file_exists($lockFile)) {
  16718. $io->writeError('<warning>'.$lockFile.' is present but ignored as the "lock" config option is disabled.</warning>');
  16719. }
  16720. $locker = new Package\Locker($io, new JsonFile($config->get('lock') ? $lockFile : Platform::getDevNull(), null, $io), $im, file_get_contents($composerFile), $process);
  16721. $composer->setLocker($locker);
  16722. }
  16723. if ($fullLoad) {
  16724. $initEvent = new Event(PluginEvents::INIT);
  16725. $composer->getEventDispatcher()->dispatch($initEvent->getName(), $initEvent);
  16726. $this->purgePackages($rm->getLocalRepository(), $im);
  16727. }
  16728. return $composer;
  16729. }
  16730. public static function createGlobal(IOInterface $io, bool $disablePlugins = false, bool $disableScripts = false): ?Composer
  16731. {
  16732. $factory = new static();
  16733. $composer = $factory->createGlobalComposer($io, static::createConfig($io), $disablePlugins, $disableScripts, true);
  16734. assert(null === $composer || $composer instanceof Composer);
  16735. return $composer;
  16736. }
  16737. protected function addLocalRepository(IOInterface $io, RepositoryManager $rm, string $vendorDir, RootPackageInterface $rootPackage, ProcessExecutor $process = null): void
  16738. {
  16739. $fs = null;
  16740. if ($process) {
  16741. $fs = new Filesystem($process);
  16742. }
  16743. $rm->setLocalRepository(new Repository\InstalledFilesystemRepository(new JsonFile($vendorDir.'/composer/installed.json', null, $io), true, $rootPackage, $fs));
  16744. }
  16745. protected function createGlobalComposer(IOInterface $io, Config $config, bool $disablePlugins, bool $disableScripts, bool $fullLoad = false): ?PartialComposer
  16746. {
  16747. $composer = null;
  16748. try {
  16749. $composer = $this->createComposer($io, $config->get('home') . '/composer.json', $disablePlugins, $config->get('home'), $fullLoad, $disableScripts);
  16750. } catch (\Exception $e) {
  16751. $io->writeError('Failed to initialize global composer: '.$e->getMessage(), true, IOInterface::DEBUG);
  16752. }
  16753. return $composer;
  16754. }
  16755. public function createDownloadManager(IOInterface $io, Config $config, HttpDownloader $httpDownloader, ProcessExecutor $process, EventDispatcher $eventDispatcher = null): Downloader\DownloadManager
  16756. {
  16757. $cache = null;
  16758. if ($config->get('cache-files-ttl') > 0) {
  16759. $cache = new Cache($io, $config->get('cache-files-dir'), 'a-z0-9_./');
  16760. $cache->setReadOnly($config->get('cache-read-only'));
  16761. }
  16762. $fs = new Filesystem($process);
  16763. $dm = new Downloader\DownloadManager($io, false, $fs);
  16764. switch ($preferred = $config->get('preferred-install')) {
  16765. case 'dist':
  16766. $dm->setPreferDist(true);
  16767. break;
  16768. case 'source':
  16769. $dm->setPreferSource(true);
  16770. break;
  16771. case 'auto':
  16772. default:
  16773. break;
  16774. }
  16775. if (is_array($preferred)) {
  16776. $dm->setPreferences($preferred);
  16777. }
  16778. $dm->setDownloader('git', new Downloader\GitDownloader($io, $config, $process, $fs));
  16779. $dm->setDownloader('svn', new Downloader\SvnDownloader($io, $config, $process, $fs));
  16780. $dm->setDownloader('fossil', new Downloader\FossilDownloader($io, $config, $process, $fs));
  16781. $dm->setDownloader('hg', new Downloader\HgDownloader($io, $config, $process, $fs));
  16782. $dm->setDownloader('perforce', new Downloader\PerforceDownloader($io, $config, $process, $fs));
  16783. $dm->setDownloader('zip', new Downloader\ZipDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  16784. $dm->setDownloader('rar', new Downloader\RarDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  16785. $dm->setDownloader('tar', new Downloader\TarDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  16786. $dm->setDownloader('gzip', new Downloader\GzipDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  16787. $dm->setDownloader('xz', new Downloader\XzDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  16788. $dm->setDownloader('phar', new Downloader\PharDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  16789. $dm->setDownloader('file', new Downloader\FileDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  16790. $dm->setDownloader('path', new Downloader\PathDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  16791. return $dm;
  16792. }
  16793. public function createArchiveManager(Config $config, Downloader\DownloadManager $dm, Loop $loop)
  16794. {
  16795. $am = new Archiver\ArchiveManager($dm, $loop);
  16796. if (class_exists(ZipArchive::class)) {
  16797. $am->addArchiver(new Archiver\ZipArchiver);
  16798. }
  16799. if (class_exists(Phar::class)) {
  16800. $am->addArchiver(new Archiver\PharArchiver);
  16801. }
  16802. return $am;
  16803. }
  16804. protected function createPluginManager(IOInterface $io, Composer $composer, PartialComposer $globalComposer = null, bool $disablePlugins = false): Plugin\PluginManager
  16805. {
  16806. return new Plugin\PluginManager($io, $composer, $globalComposer, $disablePlugins);
  16807. }
  16808. public function createInstallationManager(Loop $loop, IOInterface $io, EventDispatcher $eventDispatcher = null): Installer\InstallationManager
  16809. {
  16810. return new Installer\InstallationManager($loop, $io, $eventDispatcher);
  16811. }
  16812. protected function createDefaultInstallers(Installer\InstallationManager $im, PartialComposer $composer, IOInterface $io, ProcessExecutor $process = null): void
  16813. {
  16814. $fs = new Filesystem($process);
  16815. $binaryInstaller = new Installer\BinaryInstaller($io, rtrim($composer->getConfig()->get('bin-dir'), '/'), $composer->getConfig()->get('bin-compat'), $fs, rtrim($composer->getConfig()->get('vendor-dir'), '/'));
  16816. $im->addInstaller(new Installer\LibraryInstaller($io, $composer, null, $fs, $binaryInstaller));
  16817. $im->addInstaller(new Installer\PluginInstaller($io, $composer, $fs, $binaryInstaller));
  16818. $im->addInstaller(new Installer\MetapackageInstaller($io));
  16819. }
  16820. protected function purgePackages(InstalledRepositoryInterface $repo, Installer\InstallationManager $im): void
  16821. {
  16822. foreach ($repo->getPackages() as $package) {
  16823. if (!$im->isPackageInstalled($repo, $package)) {
  16824. $repo->removePackage($package);
  16825. }
  16826. }
  16827. }
  16828. protected function loadRootPackage(RepositoryManager $rm, Config $config, VersionParser $parser, VersionGuesser $guesser, IOInterface $io): Package\Loader\RootPackageLoader
  16829. {
  16830. return new Package\Loader\RootPackageLoader($rm, $config, $parser, $guesser, $io);
  16831. }
  16832. public static function create(IOInterface $io, $config = null, bool $disablePlugins = false, bool $disableScripts = false): Composer
  16833. {
  16834. $factory = new static();
  16835. $composer = $factory->createComposer($io, $config, $disablePlugins, null, true, $disableScripts);
  16836. assert($composer instanceof Composer);
  16837. return $composer;
  16838. }
  16839. public static function createHttpDownloader(IOInterface $io, Config $config, array $options = array()): HttpDownloader
  16840. {
  16841. static $warned = false;
  16842. $disableTls = false;
  16843. if (isset($_SERVER['argv']) && in_array('disable-tls', $_SERVER['argv']) && (in_array('conf', $_SERVER['argv']) || in_array('config', $_SERVER['argv']))) {
  16844. $warned = true;
  16845. $disableTls = !extension_loaded('openssl');
  16846. } elseif ($config->get('disable-tls') === true) {
  16847. if (!$warned) {
  16848. $io->writeError('<warning>You are running Composer with SSL/TLS protection disabled.</warning>');
  16849. }
  16850. $warned = true;
  16851. $disableTls = true;
  16852. } elseif (!extension_loaded('openssl')) {
  16853. throw new Exception\NoSslException('The openssl extension is required for SSL/TLS protection but is not available. '
  16854. . '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.');
  16855. }
  16856. $httpDownloaderOptions = array();
  16857. if ($disableTls === false) {
  16858. if ($config->get('cafile')) {
  16859. $httpDownloaderOptions['ssl']['cafile'] = $config->get('cafile');
  16860. }
  16861. if ($config->get('capath')) {
  16862. $httpDownloaderOptions['ssl']['capath'] = $config->get('capath');
  16863. }
  16864. $httpDownloaderOptions = array_replace_recursive($httpDownloaderOptions, $options);
  16865. }
  16866. try {
  16867. $httpDownloader = new HttpDownloader($io, $config, $httpDownloaderOptions, $disableTls);
  16868. } catch (TransportException $e) {
  16869. if (false !== strpos($e->getMessage(), 'cafile')) {
  16870. $io->write('<error>Unable to locate a valid CA certificate file. You must set a valid \'cafile\' option.</error>');
  16871. $io->write('<error>A valid CA certificate file is required for SSL/TLS protection.</error>');
  16872. $io->write('<error>You can disable this error, at your own risk, by setting the \'disable-tls\' option to true.</error>');
  16873. }
  16874. throw $e;
  16875. }
  16876. return $httpDownloader;
  16877. }
  16878. private static function useXdg(): bool
  16879. {
  16880. foreach (array_keys($_SERVER) as $key) {
  16881. if (strpos($key, 'XDG_') === 0) {
  16882. return true;
  16883. }
  16884. }
  16885. if (Silencer::call('is_dir', '/etc/xdg')) {
  16886. return true;
  16887. }
  16888. return false;
  16889. }
  16890. private static function getUserDir(): string
  16891. {
  16892. $home = Platform::getEnv('HOME');
  16893. if (!$home) {
  16894. throw new \RuntimeException('The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly');
  16895. }
  16896. return rtrim(strtr($home, '\\', '/'), '/');
  16897. }
  16898. private static function validateJsonSchema(?IOInterface $io, $fileOrData, int $schema = JsonFile::LAX_SCHEMA, ?string $source = null): void
  16899. {
  16900. try {
  16901. if ($fileOrData instanceof JsonFile) {
  16902. $fileOrData->validateSchema($schema);
  16903. } else {
  16904. if (null === $source) {
  16905. throw new \InvalidArgumentException('$source is required to be provided if $fileOrData is arbitrary data');
  16906. }
  16907. JsonFile::validateJsonSchema($source, $fileOrData, $schema);
  16908. }
  16909. } catch (JsonValidationException $e) {
  16910. $msg = $e->getMessage().', this may result in errors and should be resolved:'.PHP_EOL.' - '.implode(PHP_EOL.' - ', $e->getErrors());
  16911. if ($io instanceof IOInterface) {
  16912. $io->writeError('<warning>'.$msg.'</>');
  16913. } else {
  16914. throw new UnexpectedValueException($msg);
  16915. }
  16916. }
  16917. }
  16918. }
  16919. <?php declare(strict_types=1);
  16920. namespace Composer\Filter\PlatformRequirementFilter;
  16921. use Composer\Repository\PlatformRepository;
  16922. final class IgnoreAllPlatformRequirementFilter implements PlatformRequirementFilterInterface
  16923. {
  16924. public function isIgnored(string $req): bool
  16925. {
  16926. return PlatformRepository::isPlatformPackage($req);
  16927. }
  16928. }
  16929. <?php declare(strict_types=1);
  16930. namespace Composer\Filter\PlatformRequirementFilter;
  16931. use Composer\Package\BasePackage;
  16932. use Composer\Pcre\Preg;
  16933. use Composer\Repository\PlatformRepository;
  16934. use Composer\Semver\Constraint\Constraint;
  16935. use Composer\Semver\Constraint\ConstraintInterface;
  16936. use Composer\Semver\Constraint\MatchAllConstraint;
  16937. use Composer\Semver\Constraint\MultiConstraint;
  16938. use Composer\Semver\Interval;
  16939. use Composer\Semver\Intervals;
  16940. final class IgnoreListPlatformRequirementFilter implements PlatformRequirementFilterInterface
  16941. {
  16942. private $ignoreRegex;
  16943. private $ignoreUpperBoundRegex;
  16944. public function __construct(array $reqList)
  16945. {
  16946. $ignoreAll = $ignoreUpperBound = array();
  16947. foreach ($reqList as $req) {
  16948. if (substr($req, -1) === '+') {
  16949. $ignoreUpperBound[] = substr($req, 0, -1);
  16950. } else {
  16951. $ignoreAll[] = $req;
  16952. }
  16953. }
  16954. $this->ignoreRegex = BasePackage::packageNamesToRegexp($ignoreAll);
  16955. $this->ignoreUpperBoundRegex = BasePackage::packageNamesToRegexp($ignoreUpperBound);
  16956. }
  16957. public function isIgnored(string $req): bool
  16958. {
  16959. if (!PlatformRepository::isPlatformPackage($req)) {
  16960. return false;
  16961. }
  16962. return Preg::isMatch($this->ignoreRegex, $req);
  16963. }
  16964. public function filterConstraint(string $req, ConstraintInterface $constraint): ConstraintInterface
  16965. {
  16966. if (!PlatformRepository::isPlatformPackage($req)) {
  16967. return $constraint;
  16968. }
  16969. if (!Preg::isMatch($this->ignoreUpperBoundRegex, $req)) {
  16970. return $constraint;
  16971. }
  16972. if (Preg::isMatch($this->ignoreRegex, $req)) {
  16973. return new MatchAllConstraint;
  16974. }
  16975. $intervals = Intervals::get($constraint);
  16976. $last = end($intervals['numeric']);
  16977. if ($last !== false && (string) $last->getEnd() !== (string) Interval::untilPositiveInfinity()) {
  16978. $constraint = new MultiConstraint(array($constraint, new Constraint('>=', $last->getEnd()->getVersion())), false);
  16979. }
  16980. return $constraint;
  16981. }
  16982. }
  16983. <?php declare(strict_types=1);
  16984. namespace Composer\Filter\PlatformRequirementFilter;
  16985. final class IgnoreNothingPlatformRequirementFilter implements PlatformRequirementFilterInterface
  16986. {
  16987. public function isIgnored(string $req): bool
  16988. {
  16989. return false;
  16990. }
  16991. }
  16992. <?php declare(strict_types=1);
  16993. namespace Composer\Filter\PlatformRequirementFilter;
  16994. final class PlatformRequirementFilterFactory
  16995. {
  16996. public static function fromBoolOrList($boolOrList): PlatformRequirementFilterInterface
  16997. {
  16998. if (is_bool($boolOrList)) {
  16999. return $boolOrList ? self::ignoreAll() : self::ignoreNothing();
  17000. }
  17001. if (is_array($boolOrList)) {
  17002. return new IgnoreListPlatformRequirementFilter($boolOrList);
  17003. }
  17004. throw new \InvalidArgumentException(
  17005. sprintf(
  17006. 'PlatformRequirementFilter: Unknown $boolOrList parameter %s. Please report at https://github.com/composer/composer/issues/new.',
  17007. gettype($boolOrList)
  17008. )
  17009. );
  17010. }
  17011. public static function ignoreAll(): PlatformRequirementFilterInterface
  17012. {
  17013. return new IgnoreAllPlatformRequirementFilter();
  17014. }
  17015. public static function ignoreNothing(): PlatformRequirementFilterInterface
  17016. {
  17017. return new IgnoreNothingPlatformRequirementFilter();
  17018. }
  17019. }
  17020. <?php declare(strict_types=1);
  17021. namespace Composer\Filter\PlatformRequirementFilter;
  17022. interface PlatformRequirementFilterInterface
  17023. {
  17024. public function isIgnored(string $req): bool;
  17025. }
  17026. <?php declare(strict_types=1);
  17027. namespace Composer\IO;
  17028. use Composer\Config;
  17029. use Composer\Pcre\Preg;
  17030. use Composer\Util\ProcessExecutor;
  17031. use Psr\Log\LogLevel;
  17032. abstract class BaseIO implements IOInterface
  17033. {
  17034. protected $authentications = array();
  17035. public function getAuthentications()
  17036. {
  17037. return $this->authentications;
  17038. }
  17039. public function resetAuthentications()
  17040. {
  17041. $this->authentications = array();
  17042. }
  17043. public function hasAuthentication($repositoryName)
  17044. {
  17045. return isset($this->authentications[$repositoryName]);
  17046. }
  17047. public function getAuthentication($repositoryName)
  17048. {
  17049. if (isset($this->authentications[$repositoryName])) {
  17050. return $this->authentications[$repositoryName];
  17051. }
  17052. return array('username' => null, 'password' => null);
  17053. }
  17054. public function setAuthentication($repositoryName, $username, $password = null)
  17055. {
  17056. $this->authentications[$repositoryName] = array('username' => $username, 'password' => $password);
  17057. }
  17058. public function writeRaw($messages, bool $newline = true, int $verbosity = self::NORMAL)
  17059. {
  17060. $this->write($messages, $newline, $verbosity);
  17061. }
  17062. public function writeErrorRaw($messages, bool $newline = true, int $verbosity = self::NORMAL)
  17063. {
  17064. $this->writeError($messages, $newline, $verbosity);
  17065. }
  17066. protected function checkAndSetAuthentication(string $repositoryName, string $username, string $password = null)
  17067. {
  17068. if ($this->hasAuthentication($repositoryName)) {
  17069. $auth = $this->getAuthentication($repositoryName);
  17070. if ($auth['username'] === $username && $auth['password'] === $password) {
  17071. return;
  17072. }
  17073. $this->writeError(
  17074. sprintf(
  17075. "<warning>Warning: You should avoid overwriting already defined auth settings for %s.</warning>",
  17076. $repositoryName
  17077. )
  17078. );
  17079. }
  17080. $this->setAuthentication($repositoryName, $username, $password);
  17081. }
  17082. public function loadConfiguration(Config $config)
  17083. {
  17084. $bitbucketOauth = $config->get('bitbucket-oauth') ?: array();
  17085. $githubOauth = $config->get('github-oauth') ?: array();
  17086. $gitlabOauth = $config->get('gitlab-oauth') ?: array();
  17087. $gitlabToken = $config->get('gitlab-token') ?: array();
  17088. $httpBasic = $config->get('http-basic') ?: array();
  17089. $bearerToken = $config->get('bearer') ?: array();
  17090. foreach ($bitbucketOauth as $domain => $cred) {
  17091. $this->checkAndSetAuthentication($domain, $cred['consumer-key'], $cred['consumer-secret']);
  17092. }
  17093. foreach ($githubOauth as $domain => $token) {
  17094. if (!Preg::isMatch('{^[.A-Za-z0-9_]+$}', $token)) {
  17095. throw new \UnexpectedValueException('Your github oauth token for '.$domain.' contains invalid characters: "'.$token.'"');
  17096. }
  17097. $this->checkAndSetAuthentication($domain, $token, 'x-oauth-basic');
  17098. }
  17099. foreach ($gitlabOauth as $domain => $token) {
  17100. $this->checkAndSetAuthentication($domain, $token, 'oauth2');
  17101. }
  17102. foreach ($gitlabToken as $domain => $token) {
  17103. $username = is_array($token) && array_key_exists("username", $token) ? $token["username"] : $token;
  17104. $password = is_array($token) && array_key_exists("token", $token) ? $token["token"] : 'private-token';
  17105. $this->checkAndSetAuthentication($domain, $username, $password);
  17106. }
  17107. foreach ($httpBasic as $domain => $cred) {
  17108. $this->checkAndSetAuthentication($domain, $cred['username'], $cred['password']);
  17109. }
  17110. foreach ($bearerToken as $domain => $token) {
  17111. $this->checkAndSetAuthentication($domain, $token, 'bearer');
  17112. }
  17113. ProcessExecutor::setTimeout((int) $config->get('process-timeout'));
  17114. }
  17115. public function emergency($message, array $context = array()): void
  17116. {
  17117. $this->log(LogLevel::EMERGENCY, $message, $context);
  17118. }
  17119. public function alert($message, array $context = array()): void
  17120. {
  17121. $this->log(LogLevel::ALERT, $message, $context);
  17122. }
  17123. public function critical($message, array $context = array()): void
  17124. {
  17125. $this->log(LogLevel::CRITICAL, $message, $context);
  17126. }
  17127. public function error($message, array $context = array()): void
  17128. {
  17129. $this->log(LogLevel::ERROR, $message, $context);
  17130. }
  17131. public function warning($message, array $context = array()): void
  17132. {
  17133. $this->log(LogLevel::WARNING, $message, $context);
  17134. }
  17135. public function notice($message, array $context = array()): void
  17136. {
  17137. $this->log(LogLevel::NOTICE, $message, $context);
  17138. }
  17139. public function info($message, array $context = array()): void
  17140. {
  17141. $this->log(LogLevel::INFO, $message, $context);
  17142. }
  17143. public function debug($message, array $context = array()): void
  17144. {
  17145. $this->log(LogLevel::DEBUG, $message, $context);
  17146. }
  17147. public function log($level, $message, array $context = array()): void
  17148. {
  17149. $message = (string) $message;
  17150. if (in_array($level, array(LogLevel::EMERGENCY, LogLevel::ALERT, LogLevel::CRITICAL, LogLevel::ERROR))) {
  17151. $this->writeError('<error>'.$message.'</error>');
  17152. } elseif ($level === LogLevel::WARNING) {
  17153. $this->writeError('<warning>'.$message.'</warning>');
  17154. } elseif ($level === LogLevel::NOTICE) {
  17155. $this->writeError('<info>'.$message.'</info>', true, self::VERBOSE);
  17156. } elseif ($level === LogLevel::INFO) {
  17157. $this->writeError('<info>'.$message.'</info>', true, self::VERY_VERBOSE);
  17158. } else {
  17159. $this->writeError($message, true, self::DEBUG);
  17160. }
  17161. }
  17162. }
  17163. <?php declare(strict_types=1);
  17164. namespace Composer\IO;
  17165. use Composer\Pcre\Preg;
  17166. use Symfony\Component\Console\Helper\QuestionHelper;
  17167. use Symfony\Component\Console\Output\StreamOutput;
  17168. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  17169. use Symfony\Component\Console\Input\StreamableInputInterface;
  17170. use Symfony\Component\Console\Input\StringInput;
  17171. use Symfony\Component\Console\Helper\HelperSet;
  17172. class BufferIO extends ConsoleIO
  17173. {
  17174. protected $input;
  17175. protected $output;
  17176. public function __construct(string $input = '', int $verbosity = StreamOutput::VERBOSITY_NORMAL, OutputFormatterInterface $formatter = null)
  17177. {
  17178. $input = new StringInput($input);
  17179. $input->setInteractive(false);
  17180. $output = new StreamOutput(fopen('php://memory', 'rw'), $verbosity, $formatter ? $formatter->isDecorated() : false, $formatter);
  17181. parent::__construct($input, $output, new HelperSet(array(
  17182. new QuestionHelper(),
  17183. )));
  17184. }
  17185. public function getOutput(): string
  17186. {
  17187. fseek($this->output->getStream(), 0);
  17188. $output = stream_get_contents($this->output->getStream());
  17189. $output = Preg::replaceCallback("{(?<=^|\n|\x08)(.+?)(\x08+)}", function ($matches): string {
  17190. $pre = strip_tags($matches[1]);
  17191. if (strlen($pre) === strlen($matches[2])) {
  17192. return '';
  17193. }
  17194. return rtrim($matches[1])."\n";
  17195. }, $output);
  17196. return $output;
  17197. }
  17198. public function setUserInputs(array $inputs): void
  17199. {
  17200. if (!$this->input instanceof StreamableInputInterface) {
  17201. throw new \RuntimeException('Setting the user inputs requires at least the version 3.2 of the symfony/console component.');
  17202. }
  17203. $this->input->setStream($this->createStream($inputs));
  17204. $this->input->setInteractive(true);
  17205. }
  17206. private function createStream(array $inputs)
  17207. {
  17208. $stream = fopen('php://memory', 'r+');
  17209. foreach ($inputs as $input) {
  17210. fwrite($stream, $input.PHP_EOL);
  17211. }
  17212. rewind($stream);
  17213. return $stream;
  17214. }
  17215. }
  17216. <?php declare(strict_types=1);
  17217. namespace Composer\IO;
  17218. use Composer\Question\StrictConfirmationQuestion;
  17219. use Symfony\Component\Console\Helper\HelperSet;
  17220. use Symfony\Component\Console\Helper\ProgressBar;
  17221. use Symfony\Component\Console\Input\InputInterface;
  17222. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  17223. use Symfony\Component\Console\Output\OutputInterface;
  17224. use Symfony\Component\Console\Question\ChoiceQuestion;
  17225. use Symfony\Component\Console\Question\Question;
  17226. class ConsoleIO extends BaseIO
  17227. {
  17228. protected $input;
  17229. protected $output;
  17230. protected $helperSet;
  17231. protected $lastMessage = '';
  17232. protected $lastMessageErr = '';
  17233. private $startTime;
  17234. private $verbosityMap;
  17235. public function __construct(InputInterface $input, OutputInterface $output, HelperSet $helperSet)
  17236. {
  17237. $this->input = $input;
  17238. $this->output = $output;
  17239. $this->helperSet = $helperSet;
  17240. $this->verbosityMap = array(
  17241. self::QUIET => OutputInterface::VERBOSITY_QUIET,
  17242. self::NORMAL => OutputInterface::VERBOSITY_NORMAL,
  17243. self::VERBOSE => OutputInterface::VERBOSITY_VERBOSE,
  17244. self::VERY_VERBOSE => OutputInterface::VERBOSITY_VERY_VERBOSE,
  17245. self::DEBUG => OutputInterface::VERBOSITY_DEBUG,
  17246. );
  17247. }
  17248. public function enableDebugging(float $startTime)
  17249. {
  17250. $this->startTime = $startTime;
  17251. }
  17252. public function isInteractive()
  17253. {
  17254. return $this->input->isInteractive();
  17255. }
  17256. public function isDecorated()
  17257. {
  17258. return $this->output->isDecorated();
  17259. }
  17260. public function isVerbose()
  17261. {
  17262. return $this->output->isVerbose();
  17263. }
  17264. public function isVeryVerbose()
  17265. {
  17266. return $this->output->isVeryVerbose();
  17267. }
  17268. public function isDebug()
  17269. {
  17270. return $this->output->isDebug();
  17271. }
  17272. public function write($messages, bool $newline = true, int $verbosity = self::NORMAL)
  17273. {
  17274. $this->doWrite($messages, $newline, false, $verbosity);
  17275. }
  17276. public function writeError($messages, bool $newline = true, int $verbosity = self::NORMAL)
  17277. {
  17278. $this->doWrite($messages, $newline, true, $verbosity);
  17279. }
  17280. public function writeRaw($messages, bool $newline = true, int $verbosity = self::NORMAL)
  17281. {
  17282. $this->doWrite($messages, $newline, false, $verbosity, true);
  17283. }
  17284. public function writeErrorRaw($messages, bool $newline = true, int $verbosity = self::NORMAL)
  17285. {
  17286. $this->doWrite($messages, $newline, true, $verbosity, true);
  17287. }
  17288. private function doWrite($messages, bool $newline, bool $stderr, int $verbosity, bool $raw = false): void
  17289. {
  17290. $sfVerbosity = $this->verbosityMap[$verbosity];
  17291. if ($sfVerbosity > $this->output->getVerbosity()) {
  17292. return;
  17293. }
  17294. if ($raw) {
  17295. if ($sfVerbosity === OutputInterface::OUTPUT_NORMAL) {
  17296. $sfVerbosity = OutputInterface::OUTPUT_RAW;
  17297. } else {
  17298. $sfVerbosity |= OutputInterface::OUTPUT_RAW;
  17299. }
  17300. }
  17301. if (null !== $this->startTime) {
  17302. $memoryUsage = memory_get_usage() / 1024 / 1024;
  17303. $timeSpent = microtime(true) - $this->startTime;
  17304. $messages = array_map(function ($message) use ($memoryUsage, $timeSpent): string {
  17305. return sprintf('[%.1fMiB/%.2fs] %s', $memoryUsage, $timeSpent, $message);
  17306. }, (array) $messages);
  17307. }
  17308. if (true === $stderr && $this->output instanceof ConsoleOutputInterface) {
  17309. $this->output->getErrorOutput()->write($messages, $newline, $sfVerbosity);
  17310. $this->lastMessageErr = implode($newline ? "\n" : '', (array) $messages);
  17311. return;
  17312. }
  17313. $this->output->write($messages, $newline, $sfVerbosity);
  17314. $this->lastMessage = implode($newline ? "\n" : '', (array) $messages);
  17315. }
  17316. public function overwrite($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL)
  17317. {
  17318. $this->doOverwrite($messages, $newline, $size, false, $verbosity);
  17319. }
  17320. public function overwriteError($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL)
  17321. {
  17322. $this->doOverwrite($messages, $newline, $size, true, $verbosity);
  17323. }
  17324. private function doOverwrite($messages, bool $newline, ?int $size, bool $stderr, int $verbosity): void
  17325. {
  17326. $messages = implode($newline ? "\n" : '', (array) $messages);
  17327. if (!isset($size)) {
  17328. $size = strlen(strip_tags($stderr ? $this->lastMessageErr : $this->lastMessage));
  17329. }
  17330. $this->doWrite(str_repeat("\x08", $size), false, $stderr, $verbosity);
  17331. $this->doWrite($messages, false, $stderr, $verbosity);
  17332. $fill = $size - strlen(strip_tags($messages));
  17333. if ($fill > 0) {
  17334. $this->doWrite(str_repeat(' ', $fill), false, $stderr, $verbosity);
  17335. $this->doWrite(str_repeat("\x08", $fill), false, $stderr, $verbosity);
  17336. }
  17337. if ($newline) {
  17338. $this->doWrite('', true, $stderr, $verbosity);
  17339. }
  17340. if ($stderr) {
  17341. $this->lastMessageErr = $messages;
  17342. } else {
  17343. $this->lastMessage = $messages;
  17344. }
  17345. }
  17346. public function getProgressBar(int $max = 0)
  17347. {
  17348. return new ProgressBar($this->getErrorOutput(), $max);
  17349. }
  17350. public function ask($question, $default = null)
  17351. {
  17352. $helper = $this->helperSet->get('question');
  17353. $question = new Question($question, $default);
  17354. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  17355. }
  17356. public function askConfirmation($question, $default = true)
  17357. {
  17358. $helper = $this->helperSet->get('question');
  17359. $question = new StrictConfirmationQuestion($question, $default);
  17360. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  17361. }
  17362. public function askAndValidate($question, $validator, $attempts = null, $default = null)
  17363. {
  17364. $helper = $this->helperSet->get('question');
  17365. $question = new Question($question, $default);
  17366. $question->setValidator($validator);
  17367. $question->setMaxAttempts($attempts);
  17368. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  17369. }
  17370. public function askAndHideAnswer($question)
  17371. {
  17372. $helper = $this->helperSet->get('question');
  17373. $question = new Question($question);
  17374. $question->setHidden(true);
  17375. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  17376. }
  17377. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  17378. {
  17379. $helper = $this->helperSet->get('question');
  17380. $question = new ChoiceQuestion($question, $choices, $default);
  17381. $question->setMaxAttempts($attempts ?: null);
  17382. $question->setErrorMessage($errorMessage);
  17383. $question->setMultiselect($multiselect);
  17384. $result = $helper->ask($this->input, $this->getErrorOutput(), $question);
  17385. if (!is_array($result)) {
  17386. return (string) array_search($result, $choices, true);
  17387. }
  17388. $results = array();
  17389. foreach ($choices as $index => $choice) {
  17390. if (in_array($choice, $result, true)) {
  17391. $results[] = (string) $index;
  17392. }
  17393. }
  17394. return $results;
  17395. }
  17396. private function getErrorOutput(): OutputInterface
  17397. {
  17398. if ($this->output instanceof ConsoleOutputInterface) {
  17399. return $this->output->getErrorOutput();
  17400. }
  17401. return $this->output;
  17402. }
  17403. }
  17404. <?php declare(strict_types=1);
  17405. namespace Composer\IO;
  17406. use Composer\Config;
  17407. use Psr\Log\LoggerInterface;
  17408. interface IOInterface extends LoggerInterface
  17409. {
  17410. public const QUIET = 1;
  17411. public const NORMAL = 2;
  17412. public const VERBOSE = 4;
  17413. public const VERY_VERBOSE = 8;
  17414. public const DEBUG = 16;
  17415. public function isInteractive();
  17416. public function isVerbose();
  17417. public function isVeryVerbose();
  17418. public function isDebug();
  17419. public function isDecorated();
  17420. public function write($messages, bool $newline = true, int $verbosity = self::NORMAL);
  17421. public function writeError($messages, bool $newline = true, int $verbosity = self::NORMAL);
  17422. public function writeRaw($messages, bool $newline = true, int $verbosity = self::NORMAL);
  17423. public function writeErrorRaw($messages, bool $newline = true, int $verbosity = self::NORMAL);
  17424. public function overwrite($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL);
  17425. public function overwriteError($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL);
  17426. public function ask(string $question, $default = null);
  17427. public function askConfirmation(string $question, bool $default = true);
  17428. public function askAndValidate(string $question, callable $validator, ?int $attempts = null, $default = null);
  17429. public function askAndHideAnswer(string $question);
  17430. public function select(string $question, array $choices, $default, $attempts = false, string $errorMessage = 'Value "%s" is invalid', bool $multiselect = false);
  17431. public function getAuthentications();
  17432. public function hasAuthentication(string $repositoryName);
  17433. public function getAuthentication(string $repositoryName);
  17434. public function setAuthentication(string $repositoryName, string $username, ?string $password = null);
  17435. public function loadConfiguration(Config $config);
  17436. }
  17437. <?php declare(strict_types=1);
  17438. namespace Composer\IO;
  17439. class NullIO extends BaseIO
  17440. {
  17441. public function isInteractive(): bool
  17442. {
  17443. return false;
  17444. }
  17445. public function isVerbose(): bool
  17446. {
  17447. return false;
  17448. }
  17449. public function isVeryVerbose(): bool
  17450. {
  17451. return false;
  17452. }
  17453. public function isDebug(): bool
  17454. {
  17455. return false;
  17456. }
  17457. public function isDecorated(): bool
  17458. {
  17459. return false;
  17460. }
  17461. public function write($messages, bool $newline = true, int $verbosity = self::NORMAL): void
  17462. {
  17463. }
  17464. public function writeError($messages, bool $newline = true, int $verbosity = self::NORMAL): void
  17465. {
  17466. }
  17467. public function overwrite($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL): void
  17468. {
  17469. }
  17470. public function overwriteError($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL): void
  17471. {
  17472. }
  17473. public function ask($question, $default = null)
  17474. {
  17475. return $default;
  17476. }
  17477. public function askConfirmation($question, $default = true): bool
  17478. {
  17479. return $default;
  17480. }
  17481. public function askAndValidate($question, $validator, $attempts = null, $default = null)
  17482. {
  17483. return $default;
  17484. }
  17485. public function askAndHideAnswer($question): ?string
  17486. {
  17487. return null;
  17488. }
  17489. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  17490. {
  17491. return $default;
  17492. }
  17493. }
  17494. <?php declare(strict_types=1);
  17495. namespace Composer;
  17496. use Composer\Autoload\AutoloadGenerator;
  17497. use Composer\Console\GithubActionError;
  17498. use Composer\DependencyResolver\DefaultPolicy;
  17499. use Composer\DependencyResolver\LocalRepoTransaction;
  17500. use Composer\DependencyResolver\LockTransaction;
  17501. use Composer\DependencyResolver\Operation\UpdateOperation;
  17502. use Composer\DependencyResolver\Operation\InstallOperation;
  17503. use Composer\DependencyResolver\Operation\UninstallOperation;
  17504. use Composer\DependencyResolver\PoolOptimizer;
  17505. use Composer\DependencyResolver\Pool;
  17506. use Composer\DependencyResolver\Request;
  17507. use Composer\DependencyResolver\Solver;
  17508. use Composer\DependencyResolver\SolverProblemsException;
  17509. use Composer\DependencyResolver\PolicyInterface;
  17510. use Composer\Downloader\DownloadManager;
  17511. use Composer\EventDispatcher\EventDispatcher;
  17512. use Composer\Filter\PlatformRequirementFilter\IgnoreListPlatformRequirementFilter;
  17513. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  17514. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  17515. use Composer\Installer\InstallationManager;
  17516. use Composer\Installer\InstallerEvents;
  17517. use Composer\Installer\SuggestedPackagesReporter;
  17518. use Composer\IO\IOInterface;
  17519. use Composer\Package\AliasPackage;
  17520. use Composer\Package\RootAliasPackage;
  17521. use Composer\Package\BasePackage;
  17522. use Composer\Package\CompletePackage;
  17523. use Composer\Package\CompletePackageInterface;
  17524. use Composer\Package\Link;
  17525. use Composer\Package\Loader\ArrayLoader;
  17526. use Composer\Package\Dumper\ArrayDumper;
  17527. use Composer\Package\Version\VersionParser;
  17528. use Composer\Package\Package;
  17529. use Composer\Repository\ArrayRepository;
  17530. use Composer\Repository\RepositorySet;
  17531. use Composer\Repository\CompositeRepository;
  17532. use Composer\Semver\Constraint\Constraint;
  17533. use Composer\Package\Locker;
  17534. use Composer\Package\RootPackageInterface;
  17535. use Composer\Repository\InstalledArrayRepository;
  17536. use Composer\Repository\InstalledRepositoryInterface;
  17537. use Composer\Repository\InstalledRepository;
  17538. use Composer\Repository\RootPackageRepository;
  17539. use Composer\Repository\PlatformRepository;
  17540. use Composer\Repository\RepositoryInterface;
  17541. use Composer\Repository\RepositoryManager;
  17542. use Composer\Repository\LockArrayRepository;
  17543. use Composer\Script\ScriptEvents;
  17544. use Composer\Util\Platform;
  17545. class Installer
  17546. {
  17547. public const ERROR_NONE = 0;
  17548. public const ERROR_GENERIC_FAILURE = 1;
  17549. public const ERROR_NO_LOCK_FILE_FOR_PARTIAL_UPDATE = 3;
  17550. public const ERROR_LOCK_FILE_INVALID = 4;
  17551. public const ERROR_DEPENDENCY_RESOLUTION_FAILED = 2;
  17552. protected $io;
  17553. protected $config;
  17554. protected $package;
  17555. protected $fixedRootPackage;
  17556. protected $downloadManager;
  17557. protected $repositoryManager;
  17558. protected $locker;
  17559. protected $installationManager;
  17560. protected $eventDispatcher;
  17561. protected $autoloadGenerator;
  17562. protected $preferSource = false;
  17563. protected $preferDist = false;
  17564. protected $optimizeAutoloader = false;
  17565. protected $classMapAuthoritative = false;
  17566. protected $apcuAutoloader = false;
  17567. protected $apcuAutoloaderPrefix = null;
  17568. protected $devMode = false;
  17569. protected $dryRun = false;
  17570. protected $verbose = false;
  17571. protected $update = false;
  17572. protected $install = true;
  17573. protected $dumpAutoloader = true;
  17574. protected $runScripts = true;
  17575. protected $preferStable = false;
  17576. protected $preferLowest = false;
  17577. protected $writeLock;
  17578. protected $executeOperations = true;
  17579. protected $updateMirrors = false;
  17580. protected $updateAllowList = null;
  17581. protected $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  17582. protected $suggestedPackagesReporter;
  17583. protected $platformRequirementFilter;
  17584. protected $additionalFixedRepository;
  17585. public function __construct(IOInterface $io, Config $config, RootPackageInterface $package, DownloadManager $downloadManager, RepositoryManager $repositoryManager, Locker $locker, InstallationManager $installationManager, EventDispatcher $eventDispatcher, AutoloadGenerator $autoloadGenerator)
  17586. {
  17587. $this->io = $io;
  17588. $this->config = $config;
  17589. $this->package = $package;
  17590. $this->downloadManager = $downloadManager;
  17591. $this->repositoryManager = $repositoryManager;
  17592. $this->locker = $locker;
  17593. $this->installationManager = $installationManager;
  17594. $this->eventDispatcher = $eventDispatcher;
  17595. $this->autoloadGenerator = $autoloadGenerator;
  17596. $this->suggestedPackagesReporter = new SuggestedPackagesReporter($this->io);
  17597. $this->platformRequirementFilter = PlatformRequirementFilterFactory::ignoreNothing();
  17598. $this->writeLock = $config->get('lock');
  17599. }
  17600. public function run(): int
  17601. {
  17602. gc_collect_cycles();
  17603. gc_disable();
  17604. if ($this->updateAllowList && $this->updateMirrors) {
  17605. throw new \RuntimeException("The installer options updateMirrors and updateAllowList are mutually exclusive.");
  17606. }
  17607. $isFreshInstall = $this->repositoryManager->getLocalRepository()->isFresh();
  17608. if (!$this->update && !$this->locker->isLocked()) {
  17609. $this->io->writeError('<warning>No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information.</warning>');
  17610. $this->update = true;
  17611. }
  17612. if ($this->dryRun) {
  17613. $this->verbose = true;
  17614. $this->runScripts = false;
  17615. $this->executeOperations = false;
  17616. $this->writeLock = false;
  17617. $this->dumpAutoloader = false;
  17618. $this->mockLocalRepositories($this->repositoryManager);
  17619. }
  17620. if ($this->update && !$this->install) {
  17621. $this->dumpAutoloader = false;
  17622. }
  17623. if ($this->runScripts) {
  17624. Platform::putEnv('COMPOSER_DEV_MODE', $this->devMode ? '1' : '0');
  17625. $eventName = $this->update ? ScriptEvents::PRE_UPDATE_CMD : ScriptEvents::PRE_INSTALL_CMD;
  17626. $this->eventDispatcher->dispatchScript($eventName, $this->devMode);
  17627. }
  17628. $this->downloadManager->setPreferSource($this->preferSource);
  17629. $this->downloadManager->setPreferDist($this->preferDist);
  17630. $localRepo = $this->repositoryManager->getLocalRepository();
  17631. try {
  17632. if ($this->update) {
  17633. $res = $this->doUpdate($localRepo, $this->install);
  17634. } else {
  17635. $res = $this->doInstall($localRepo);
  17636. }
  17637. if ($res !== 0) {
  17638. return $res;
  17639. }
  17640. } catch (\Exception $e) {
  17641. if ($this->executeOperations && $this->install && $this->config->get('notify-on-install')) {
  17642. $this->installationManager->notifyInstalls($this->io);
  17643. }
  17644. throw $e;
  17645. }
  17646. if ($this->executeOperations && $this->install && $this->config->get('notify-on-install')) {
  17647. $this->installationManager->notifyInstalls($this->io);
  17648. }
  17649. if ($this->update) {
  17650. $installedRepo = new InstalledRepository(array(
  17651. $this->locker->getLockedRepository($this->devMode),
  17652. $this->createPlatformRepo(false),
  17653. new RootPackageRepository(clone $this->package),
  17654. ));
  17655. if ($isFreshInstall) {
  17656. $this->suggestedPackagesReporter->addSuggestionsFromPackage($this->package);
  17657. }
  17658. $this->suggestedPackagesReporter->outputMinimalistic($installedRepo);
  17659. }
  17660. $lockedRepository = $this->locker->getLockedRepository(true);
  17661. foreach ($lockedRepository->getPackages() as $package) {
  17662. if (!$package instanceof CompletePackage || !$package->isAbandoned()) {
  17663. continue;
  17664. }
  17665. $replacement = is_string($package->getReplacementPackage())
  17666. ? 'Use ' . $package->getReplacementPackage() . ' instead'
  17667. : 'No replacement was suggested';
  17668. $this->io->writeError(
  17669. sprintf(
  17670. "<warning>Package %s is abandoned, you should avoid using it. %s.</warning>",
  17671. $package->getPrettyName(),
  17672. $replacement
  17673. )
  17674. );
  17675. }
  17676. if ($this->dumpAutoloader) {
  17677. if ($this->optimizeAutoloader) {
  17678. $this->io->writeError('<info>Generating optimized autoload files</info>');
  17679. } else {
  17680. $this->io->writeError('<info>Generating autoload files</info>');
  17681. }
  17682. $this->autoloadGenerator->setClassMapAuthoritative($this->classMapAuthoritative);
  17683. $this->autoloadGenerator->setApcu($this->apcuAutoloader, $this->apcuAutoloaderPrefix);
  17684. $this->autoloadGenerator->setRunScripts($this->runScripts);
  17685. $this->autoloadGenerator->setPlatformRequirementFilter($this->platformRequirementFilter);
  17686. $this->autoloadGenerator->dump($this->config, $localRepo, $this->package, $this->installationManager, 'composer', $this->optimizeAutoloader);
  17687. }
  17688. if ($this->install && $this->executeOperations) {
  17689. foreach ($localRepo->getPackages() as $package) {
  17690. $this->installationManager->ensureBinariesPresence($package);
  17691. }
  17692. }
  17693. $fundingCount = 0;
  17694. foreach ($localRepo->getPackages() as $package) {
  17695. if ($package instanceof CompletePackageInterface && !$package instanceof AliasPackage && $package->getFunding()) {
  17696. $fundingCount++;
  17697. }
  17698. }
  17699. if ($fundingCount > 0) {
  17700. $this->io->writeError(array(
  17701. sprintf(
  17702. "<info>%d package%s you are using %s looking for funding.</info>",
  17703. $fundingCount,
  17704. 1 === $fundingCount ? '' : 's',
  17705. 1 === $fundingCount ? 'is' : 'are'
  17706. ),
  17707. '<info>Use the `composer fund` command to find out more!</info>',
  17708. ));
  17709. }
  17710. if ($this->runScripts) {
  17711. $eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD;
  17712. $this->eventDispatcher->dispatchScript($eventName, $this->devMode);
  17713. }
  17714. if (!defined('HHVM_VERSION')) {
  17715. gc_enable();
  17716. }
  17717. return 0;
  17718. }
  17719. protected function doUpdate(InstalledRepositoryInterface $localRepo, bool $doInstall): int
  17720. {
  17721. $platformRepo = $this->createPlatformRepo(true);
  17722. $aliases = $this->getRootAliases(true);
  17723. $lockedRepository = null;
  17724. try {
  17725. if ($this->locker->isLocked()) {
  17726. $lockedRepository = $this->locker->getLockedRepository(true);
  17727. }
  17728. } catch (\Seld\JsonLint\ParsingException $e) {
  17729. if ($this->updateAllowList || $this->updateMirrors) {
  17730. throw $e;
  17731. }
  17732. }
  17733. if (($this->updateAllowList || $this->updateMirrors) && !$lockedRepository) {
  17734. $this->io->writeError('<error>Cannot update ' . ($this->updateMirrors ? 'lock file information' : 'only a partial set of packages') . ' without a lock file present. Run `composer update` to generate a lock file.</error>', true, IOInterface::QUIET);
  17735. return self::ERROR_NO_LOCK_FILE_FOR_PARTIAL_UPDATE;
  17736. }
  17737. $this->io->writeError('<info>Loading composer repositories with package information</info>');
  17738. $policy = $this->createPolicy(true);
  17739. $repositorySet = $this->createRepositorySet(true, $platformRepo, $aliases);
  17740. $repositories = $this->repositoryManager->getRepositories();
  17741. foreach ($repositories as $repository) {
  17742. $repositorySet->addRepository($repository);
  17743. }
  17744. if ($lockedRepository) {
  17745. $repositorySet->addRepository($lockedRepository);
  17746. }
  17747. $request = $this->createRequest($this->fixedRootPackage, $platformRepo, $lockedRepository);
  17748. $this->requirePackagesForUpdate($request, $lockedRepository, true);
  17749. if ($this->updateAllowList) {
  17750. $request->setUpdateAllowList($this->updateAllowList, $this->updateAllowTransitiveDependencies);
  17751. }
  17752. $pool = $repositorySet->createPool($request, $this->io, $this->eventDispatcher, $this->createPoolOptimizer($policy));
  17753. $this->io->writeError('<info>Updating dependencies</info>');
  17754. $solver = new Solver($policy, $pool, $this->io);
  17755. try {
  17756. $lockTransaction = $solver->solve($request, $this->platformRequirementFilter);
  17757. $ruleSetSize = $solver->getRuleSetSize();
  17758. $solver = null;
  17759. } catch (SolverProblemsException $e) {
  17760. $err = 'Your requirements could not be resolved to an installable set of packages.';
  17761. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose());
  17762. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  17763. $this->io->writeError($prettyProblem);
  17764. if (!$this->devMode) {
  17765. $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);
  17766. }
  17767. $ghe = new GithubActionError($this->io);
  17768. $ghe->emit($err."\n".$prettyProblem);
  17769. return max(self::ERROR_GENERIC_FAILURE, $e->getCode());
  17770. }
  17771. $this->io->writeError("Analyzed ".count($pool)." packages to resolve dependencies", true, IOInterface::VERBOSE);
  17772. $this->io->writeError("Analyzed ".$ruleSetSize." rules to resolve dependencies", true, IOInterface::VERBOSE);
  17773. $pool = null;
  17774. if (!$lockTransaction->getOperations()) {
  17775. $this->io->writeError('Nothing to modify in lock file');
  17776. }
  17777. $exitCode = $this->extractDevPackages($lockTransaction, $platformRepo, $aliases, $policy, $lockedRepository);
  17778. if ($exitCode !== 0) {
  17779. return $exitCode;
  17780. }
  17781. if (method_exists('Composer\Semver\CompilingMatcher', 'clear')) {
  17782. \Composer\Semver\CompilingMatcher::clear();
  17783. }
  17784. $platformReqs = $this->extractPlatformRequirements($this->package->getRequires());
  17785. $platformDevReqs = $this->extractPlatformRequirements($this->package->getDevRequires());
  17786. $installsUpdates = $uninstalls = array();
  17787. if ($lockTransaction->getOperations()) {
  17788. $installNames = $updateNames = $uninstallNames = array();
  17789. foreach ($lockTransaction->getOperations() as $operation) {
  17790. if ($operation instanceof InstallOperation) {
  17791. $installsUpdates[] = $operation;
  17792. $installNames[] = $operation->getPackage()->getPrettyName().':'.$operation->getPackage()->getFullPrettyVersion();
  17793. } elseif ($operation instanceof UpdateOperation) {
  17794. if ($this->updateMirrors
  17795. && $operation->getInitialPackage()->getName() == $operation->getTargetPackage()->getName()
  17796. && $operation->getInitialPackage()->getVersion() == $operation->getTargetPackage()->getVersion()
  17797. ) {
  17798. continue;
  17799. }
  17800. $installsUpdates[] = $operation;
  17801. $updateNames[] = $operation->getTargetPackage()->getPrettyName().':'.$operation->getTargetPackage()->getFullPrettyVersion();
  17802. } elseif ($operation instanceof UninstallOperation) {
  17803. $uninstalls[] = $operation;
  17804. $uninstallNames[] = $operation->getPackage()->getPrettyName();
  17805. }
  17806. }
  17807. $this->io->writeError(sprintf(
  17808. "<info>Lock file operations: %d install%s, %d update%s, %d removal%s</info>",
  17809. count($installNames),
  17810. 1 === count($installNames) ? '' : 's',
  17811. count($updateNames),
  17812. 1 === count($updateNames) ? '' : 's',
  17813. count($uninstalls),
  17814. 1 === count($uninstalls) ? '' : 's'
  17815. ));
  17816. if ($installNames) {
  17817. $this->io->writeError("Installs: ".implode(', ', $installNames), true, IOInterface::VERBOSE);
  17818. }
  17819. if ($updateNames) {
  17820. $this->io->writeError("Updates: ".implode(', ', $updateNames), true, IOInterface::VERBOSE);
  17821. }
  17822. if ($uninstalls) {
  17823. $this->io->writeError("Removals: ".implode(', ', $uninstallNames), true, IOInterface::VERBOSE);
  17824. }
  17825. }
  17826. $sortByName = function ($a, $b): int {
  17827. if ($a instanceof UpdateOperation) {
  17828. $a = $a->getTargetPackage()->getName();
  17829. } else {
  17830. $a = $a->getPackage()->getName();
  17831. }
  17832. if ($b instanceof UpdateOperation) {
  17833. $b = $b->getTargetPackage()->getName();
  17834. } else {
  17835. $b = $b->getPackage()->getName();
  17836. }
  17837. return strcmp($a, $b);
  17838. };
  17839. usort($uninstalls, $sortByName);
  17840. usort($installsUpdates, $sortByName);
  17841. foreach (array_merge($uninstalls, $installsUpdates) as $operation) {
  17842. if ($operation instanceof InstallOperation) {
  17843. $this->suggestedPackagesReporter->addSuggestionsFromPackage($operation->getPackage());
  17844. }
  17845. if (false === strpos($operation->getOperationType(), 'Alias') || $this->io->isDebug()) {
  17846. $this->io->writeError(' - ' . $operation->show(true));
  17847. }
  17848. }
  17849. $updatedLock = $this->locker->setLockData(
  17850. $lockTransaction->getNewLockPackages(false, $this->updateMirrors),
  17851. $lockTransaction->getNewLockPackages(true, $this->updateMirrors),
  17852. $platformReqs,
  17853. $platformDevReqs,
  17854. $lockTransaction->getAliases($aliases),
  17855. $this->package->getMinimumStability(),
  17856. $this->package->getStabilityFlags(),
  17857. $this->preferStable || $this->package->getPreferStable(),
  17858. $this->preferLowest,
  17859. $this->config->get('platform') ?: array(),
  17860. $this->writeLock && $this->executeOperations
  17861. );
  17862. if ($updatedLock && $this->writeLock && $this->executeOperations) {
  17863. $this->io->writeError('<info>Writing lock file</info>');
  17864. }
  17865. if ($this->executeOperations && count($lockTransaction->getOperations()) > 0) {
  17866. $vendorDir = $this->config->get('vendor-dir');
  17867. if (is_dir($vendorDir)) {
  17868. @touch($vendorDir);
  17869. }
  17870. }
  17871. if ($doInstall) {
  17872. return $this->doInstall($localRepo, true);
  17873. }
  17874. return 0;
  17875. }
  17876. protected function extractDevPackages(LockTransaction $lockTransaction, PlatformRepository $platformRepo, array $aliases, PolicyInterface $policy, LockArrayRepository $lockedRepository = null): int
  17877. {
  17878. if (!$this->package->getDevRequires()) {
  17879. return 0;
  17880. }
  17881. $resultRepo = new ArrayRepository(array());
  17882. $loader = new ArrayLoader(null, true);
  17883. $dumper = new ArrayDumper();
  17884. foreach ($lockTransaction->getNewLockPackages(false) as $pkg) {
  17885. $resultRepo->addPackage($loader->load($dumper->dump($pkg)));
  17886. }
  17887. $repositorySet = $this->createRepositorySet(true, $platformRepo, $aliases);
  17888. $repositorySet->addRepository($resultRepo);
  17889. $request = $this->createRequest($this->fixedRootPackage, $platformRepo);
  17890. $this->requirePackagesForUpdate($request, $lockedRepository, false);
  17891. $pool = $repositorySet->createPoolWithAllPackages();
  17892. $solver = new Solver($policy, $pool, $this->io);
  17893. try {
  17894. $nonDevLockTransaction = $solver->solve($request, $this->platformRequirementFilter);
  17895. $solver = null;
  17896. } catch (SolverProblemsException $e) {
  17897. $err = 'Unable to find a compatible set of packages based on your non-dev requirements alone.';
  17898. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose(), true);
  17899. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  17900. $this->io->writeError('Your requirements can be resolved successfully when require-dev packages are present.');
  17901. $this->io->writeError('You may need to move packages from require-dev or some of their dependencies to require.');
  17902. $this->io->writeError($prettyProblem);
  17903. $ghe = new GithubActionError($this->io);
  17904. $ghe->emit($err."\n".$prettyProblem);
  17905. return $e->getCode();
  17906. }
  17907. $lockTransaction->setNonDevPackages($nonDevLockTransaction);
  17908. return 0;
  17909. }
  17910. protected function doInstall(InstalledRepositoryInterface $localRepo, bool $alreadySolved = false): int
  17911. {
  17912. $this->io->writeError('<info>Installing dependencies from lock file'.($this->devMode ? ' (including require-dev)' : '').'</info>');
  17913. $lockedRepository = $this->locker->getLockedRepository($this->devMode);
  17914. if (!$alreadySolved) {
  17915. $this->io->writeError('<info>Verifying lock file contents can be installed on current platform.</info>');
  17916. $platformRepo = $this->createPlatformRepo(false);
  17917. $policy = $this->createPolicy(false);
  17918. $repositorySet = $this->createRepositorySet(false, $platformRepo, array(), $lockedRepository);
  17919. $repositorySet->addRepository($lockedRepository);
  17920. $request = $this->createRequest($this->fixedRootPackage, $platformRepo, $lockedRepository);
  17921. if (!$this->locker->isFresh()) {
  17922. $this->io->writeError('<warning>Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run `composer update` or `composer update <package name>`.</warning>', true, IOInterface::QUIET);
  17923. }
  17924. foreach ($lockedRepository->getPackages() as $package) {
  17925. $request->fixLockedPackage($package);
  17926. }
  17927. foreach ($this->locker->getPlatformRequirements($this->devMode) as $link) {
  17928. $request->requireName($link->getTarget(), $link->getConstraint());
  17929. }
  17930. $pool = $repositorySet->createPool($request, $this->io, $this->eventDispatcher);
  17931. $solver = new Solver($policy, $pool, $this->io);
  17932. try {
  17933. $lockTransaction = $solver->solve($request, $this->platformRequirementFilter);
  17934. $solver = null;
  17935. if (0 !== count($lockTransaction->getOperations())) {
  17936. $this->io->writeError('<error>Your lock file cannot be installed on this system without changes. Please run composer update.</error>', true, IOInterface::QUIET);
  17937. return self::ERROR_LOCK_FILE_INVALID;
  17938. }
  17939. } catch (SolverProblemsException $e) {
  17940. $err = 'Your lock file does not contain a compatible set of packages. Please run composer update.';
  17941. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose());
  17942. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  17943. $this->io->writeError($prettyProblem);
  17944. $ghe = new GithubActionError($this->io);
  17945. $ghe->emit($err."\n".$prettyProblem);
  17946. return max(self::ERROR_GENERIC_FAILURE, $e->getCode());
  17947. }
  17948. }
  17949. $localRepoTransaction = new LocalRepoTransaction($lockedRepository, $localRepo);
  17950. $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_OPERATIONS_EXEC, $this->devMode, $this->executeOperations, $localRepoTransaction);
  17951. if (!$localRepoTransaction->getOperations()) {
  17952. $this->io->writeError('Nothing to install, update or remove');
  17953. }
  17954. if ($localRepoTransaction->getOperations()) {
  17955. $installs = $updates = $uninstalls = array();
  17956. foreach ($localRepoTransaction->getOperations() as $operation) {
  17957. if ($operation instanceof InstallOperation) {
  17958. $installs[] = $operation->getPackage()->getPrettyName().':'.$operation->getPackage()->getFullPrettyVersion();
  17959. } elseif ($operation instanceof UpdateOperation) {
  17960. $updates[] = $operation->getTargetPackage()->getPrettyName().':'.$operation->getTargetPackage()->getFullPrettyVersion();
  17961. } elseif ($operation instanceof UninstallOperation) {
  17962. $uninstalls[] = $operation->getPackage()->getPrettyName();
  17963. }
  17964. }
  17965. $this->io->writeError(sprintf(
  17966. "<info>Package operations: %d install%s, %d update%s, %d removal%s</info>",
  17967. count($installs),
  17968. 1 === count($installs) ? '' : 's',
  17969. count($updates),
  17970. 1 === count($updates) ? '' : 's',
  17971. count($uninstalls),
  17972. 1 === count($uninstalls) ? '' : 's'
  17973. ));
  17974. if ($installs) {
  17975. $this->io->writeError("Installs: ".implode(', ', $installs), true, IOInterface::VERBOSE);
  17976. }
  17977. if ($updates) {
  17978. $this->io->writeError("Updates: ".implode(', ', $updates), true, IOInterface::VERBOSE);
  17979. }
  17980. if ($uninstalls) {
  17981. $this->io->writeError("Removals: ".implode(', ', $uninstalls), true, IOInterface::VERBOSE);
  17982. }
  17983. }
  17984. if ($this->executeOperations) {
  17985. $localRepo->setDevPackageNames($this->locker->getDevPackageNames());
  17986. $this->installationManager->execute($localRepo, $localRepoTransaction->getOperations(), $this->devMode, $this->runScripts);
  17987. } else {
  17988. foreach ($localRepoTransaction->getOperations() as $operation) {
  17989. if (false === strpos($operation->getOperationType(), 'Alias') || $this->io->isDebug()) {
  17990. $this->io->writeError(' - ' . $operation->show(false));
  17991. }
  17992. }
  17993. }
  17994. return 0;
  17995. }
  17996. protected function createPlatformRepo(bool $forUpdate): PlatformRepository
  17997. {
  17998. if ($forUpdate) {
  17999. $platformOverrides = $this->config->get('platform') ?: array();
  18000. } else {
  18001. $platformOverrides = $this->locker->getPlatformOverrides();
  18002. }
  18003. return new PlatformRepository(array(), $platformOverrides);
  18004. }
  18005. private function createRepositorySet(bool $forUpdate, PlatformRepository $platformRepo, array $rootAliases = array(), ?RepositoryInterface $lockedRepository = null): RepositorySet
  18006. {
  18007. if ($forUpdate) {
  18008. $minimumStability = $this->package->getMinimumStability();
  18009. $stabilityFlags = $this->package->getStabilityFlags();
  18010. $requires = array_merge($this->package->getRequires(), $this->package->getDevRequires());
  18011. } else {
  18012. $minimumStability = $this->locker->getMinimumStability();
  18013. $stabilityFlags = $this->locker->getStabilityFlags();
  18014. $requires = array();
  18015. foreach ($lockedRepository->getPackages() as $package) {
  18016. $constraint = new Constraint('=', $package->getVersion());
  18017. $constraint->setPrettyString($package->getPrettyVersion());
  18018. $requires[$package->getName()] = $constraint;
  18019. }
  18020. }
  18021. $rootRequires = array();
  18022. foreach ($requires as $req => $constraint) {
  18023. if ($constraint instanceof Link) {
  18024. $constraint = $constraint->getConstraint();
  18025. }
  18026. if ($this->platformRequirementFilter->isIgnored($req)) {
  18027. continue;
  18028. } elseif ($this->platformRequirementFilter instanceof IgnoreListPlatformRequirementFilter) {
  18029. $constraint = $this->platformRequirementFilter->filterConstraint($req, $constraint);
  18030. }
  18031. $rootRequires[$req] = $constraint;
  18032. }
  18033. $this->fixedRootPackage = clone $this->package;
  18034. $this->fixedRootPackage->setRequires(array());
  18035. $this->fixedRootPackage->setDevRequires(array());
  18036. $stabilityFlags[$this->package->getName()] = BasePackage::$stabilities[VersionParser::parseStability($this->package->getVersion())];
  18037. $repositorySet = new RepositorySet($minimumStability, $stabilityFlags, $rootAliases, $this->package->getReferences(), $rootRequires);
  18038. $repositorySet->addRepository(new RootPackageRepository($this->fixedRootPackage));
  18039. $repositorySet->addRepository($platformRepo);
  18040. if ($this->additionalFixedRepository) {
  18041. $additionalFixedRepositories = $this->additionalFixedRepository;
  18042. if ($additionalFixedRepositories instanceof CompositeRepository) {
  18043. $additionalFixedRepositories = $additionalFixedRepositories->getRepositories();
  18044. } else {
  18045. $additionalFixedRepositories = array($additionalFixedRepositories);
  18046. }
  18047. foreach ($additionalFixedRepositories as $additionalFixedRepository) {
  18048. if ($additionalFixedRepository instanceof InstalledRepository || $additionalFixedRepository instanceof InstalledRepositoryInterface) {
  18049. $repositorySet->allowInstalledRepositories();
  18050. break;
  18051. }
  18052. }
  18053. $repositorySet->addRepository($this->additionalFixedRepository);
  18054. }
  18055. return $repositorySet;
  18056. }
  18057. private function createPolicy(bool $forUpdate): DefaultPolicy
  18058. {
  18059. $preferStable = null;
  18060. $preferLowest = null;
  18061. if (!$forUpdate) {
  18062. $preferStable = $this->locker->getPreferStable();
  18063. $preferLowest = $this->locker->getPreferLowest();
  18064. }
  18065. if (null === $preferStable) {
  18066. $preferStable = $this->preferStable || $this->package->getPreferStable();
  18067. }
  18068. if (null === $preferLowest) {
  18069. $preferLowest = $this->preferLowest;
  18070. }
  18071. return new DefaultPolicy($preferStable, $preferLowest);
  18072. }
  18073. private function createRequest(RootPackageInterface $rootPackage, PlatformRepository $platformRepo, LockArrayRepository $lockedRepository = null): Request
  18074. {
  18075. $request = new Request($lockedRepository);
  18076. $request->fixPackage($rootPackage);
  18077. if ($rootPackage instanceof RootAliasPackage) {
  18078. $request->fixPackage($rootPackage->getAliasOf());
  18079. }
  18080. $fixedPackages = $platformRepo->getPackages();
  18081. if ($this->additionalFixedRepository) {
  18082. $fixedPackages = array_merge($fixedPackages, $this->additionalFixedRepository->getPackages());
  18083. }
  18084. $provided = $rootPackage->getProvides();
  18085. foreach ($fixedPackages as $package) {
  18086. if ($package->getRepository() !== $platformRepo
  18087. || !isset($provided[$package->getName()])
  18088. || !$provided[$package->getName()]->getConstraint()->matches(new Constraint('=', $package->getVersion()))
  18089. ) {
  18090. $request->fixPackage($package);
  18091. }
  18092. }
  18093. return $request;
  18094. }
  18095. private function requirePackagesForUpdate(Request $request, LockArrayRepository $lockedRepository = null, bool $includeDevRequires = true): void
  18096. {
  18097. if ($this->updateMirrors) {
  18098. $excludedPackages = array();
  18099. if (!$includeDevRequires) {
  18100. $excludedPackages = array_flip($this->locker->getDevPackageNames());
  18101. }
  18102. foreach ($lockedRepository->getPackages() as $lockedPackage) {
  18103. if (!$lockedPackage instanceof AliasPackage && !isset($excludedPackages[$lockedPackage->getName()])) {
  18104. $request->requireName($lockedPackage->getName(), new Constraint('==', $lockedPackage->getVersion()));
  18105. }
  18106. }
  18107. } else {
  18108. $links = $this->package->getRequires();
  18109. if ($includeDevRequires) {
  18110. $links = array_merge($links, $this->package->getDevRequires());
  18111. }
  18112. foreach ($links as $link) {
  18113. $request->requireName($link->getTarget(), $link->getConstraint());
  18114. }
  18115. }
  18116. }
  18117. private function getRootAliases(bool $forUpdate): array
  18118. {
  18119. if ($forUpdate) {
  18120. $aliases = $this->package->getAliases();
  18121. } else {
  18122. $aliases = $this->locker->getAliases();
  18123. }
  18124. return $aliases;
  18125. }
  18126. private function extractPlatformRequirements(array $links): array
  18127. {
  18128. $platformReqs = array();
  18129. foreach ($links as $link) {
  18130. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  18131. $platformReqs[$link->getTarget()] = $link->getPrettyConstraint();
  18132. }
  18133. }
  18134. return $platformReqs;
  18135. }
  18136. private function mockLocalRepositories(RepositoryManager $rm): void
  18137. {
  18138. $packages = array();
  18139. foreach ($rm->getLocalRepository()->getPackages() as $package) {
  18140. $packages[(string) $package] = clone $package;
  18141. }
  18142. foreach ($packages as $key => $package) {
  18143. if ($package instanceof AliasPackage) {
  18144. $alias = (string) $package->getAliasOf();
  18145. $className = get_class($package);
  18146. $packages[$key] = new $className($packages[$alias], $package->getVersion(), $package->getPrettyVersion());
  18147. }
  18148. }
  18149. $rm->setLocalRepository(
  18150. new InstalledArrayRepository($packages)
  18151. );
  18152. }
  18153. private function createPoolOptimizer(PolicyInterface $policy): ?PoolOptimizer
  18154. {
  18155. if ('0' === Platform::getEnv('COMPOSER_POOL_OPTIMIZER')) {
  18156. $this->io->write('Pool Optimizer was disabled for debugging purposes.', true, IOInterface::DEBUG);
  18157. return null;
  18158. }
  18159. return new PoolOptimizer($policy);
  18160. }
  18161. public static function create(IOInterface $io, Composer $composer): self
  18162. {
  18163. return new static(
  18164. $io,
  18165. $composer->getConfig(),
  18166. $composer->getPackage(),
  18167. $composer->getDownloadManager(),
  18168. $composer->getRepositoryManager(),
  18169. $composer->getLocker(),
  18170. $composer->getInstallationManager(),
  18171. $composer->getEventDispatcher(),
  18172. $composer->getAutoloadGenerator()
  18173. );
  18174. }
  18175. public function setAdditionalFixedRepository(RepositoryInterface $additionalFixedRepository): self
  18176. {
  18177. $this->additionalFixedRepository = $additionalFixedRepository;
  18178. return $this;
  18179. }
  18180. public function setDryRun(bool $dryRun = true): self
  18181. {
  18182. $this->dryRun = (bool) $dryRun;
  18183. return $this;
  18184. }
  18185. public function isDryRun(): bool
  18186. {
  18187. return $this->dryRun;
  18188. }
  18189. public function setPreferSource(bool $preferSource = true): self
  18190. {
  18191. $this->preferSource = (bool) $preferSource;
  18192. return $this;
  18193. }
  18194. public function setPreferDist(bool $preferDist = true): self
  18195. {
  18196. $this->preferDist = (bool) $preferDist;
  18197. return $this;
  18198. }
  18199. public function setOptimizeAutoloader(bool $optimizeAutoloader): self
  18200. {
  18201. $this->optimizeAutoloader = (bool) $optimizeAutoloader;
  18202. if (!$this->optimizeAutoloader) {
  18203. $this->setClassMapAuthoritative(false);
  18204. }
  18205. return $this;
  18206. }
  18207. public function setClassMapAuthoritative(bool $classMapAuthoritative): self
  18208. {
  18209. $this->classMapAuthoritative = (bool) $classMapAuthoritative;
  18210. if ($this->classMapAuthoritative) {
  18211. $this->setOptimizeAutoloader(true);
  18212. }
  18213. return $this;
  18214. }
  18215. public function setApcuAutoloader(bool $apcuAutoloader, ?string $apcuAutoloaderPrefix = null): self
  18216. {
  18217. $this->apcuAutoloader = $apcuAutoloader;
  18218. $this->apcuAutoloaderPrefix = $apcuAutoloaderPrefix;
  18219. return $this;
  18220. }
  18221. public function setUpdate(bool $update): self
  18222. {
  18223. $this->update = (bool) $update;
  18224. return $this;
  18225. }
  18226. public function setInstall(bool $install): self
  18227. {
  18228. $this->install = (bool) $install;
  18229. return $this;
  18230. }
  18231. public function setDevMode(bool $devMode = true): self
  18232. {
  18233. $this->devMode = (bool) $devMode;
  18234. return $this;
  18235. }
  18236. public function setDumpAutoloader(bool $dumpAutoloader = true): self
  18237. {
  18238. $this->dumpAutoloader = (bool) $dumpAutoloader;
  18239. return $this;
  18240. }
  18241. public function setRunScripts(bool $runScripts = true): self
  18242. {
  18243. $this->runScripts = (bool) $runScripts;
  18244. return $this;
  18245. }
  18246. public function setConfig(Config $config): self
  18247. {
  18248. $this->config = $config;
  18249. return $this;
  18250. }
  18251. public function setVerbose(bool $verbose = true): self
  18252. {
  18253. $this->verbose = (bool) $verbose;
  18254. return $this;
  18255. }
  18256. public function isVerbose(): bool
  18257. {
  18258. return $this->verbose;
  18259. }
  18260. public function setIgnorePlatformRequirements($ignorePlatformReqs): self
  18261. {
  18262. trigger_error('Installer::setIgnorePlatformRequirements is deprecated since Composer 2.2, use setPlatformRequirementFilter instead.', E_USER_DEPRECATED);
  18263. return $this->setPlatformRequirementFilter(PlatformRequirementFilterFactory::fromBoolOrList($ignorePlatformReqs));
  18264. }
  18265. public function setPlatformRequirementFilter(PlatformRequirementFilterInterface $platformRequirementFilter): self
  18266. {
  18267. $this->platformRequirementFilter = $platformRequirementFilter;
  18268. return $this;
  18269. }
  18270. public function setUpdateMirrors(bool $updateMirrors): self
  18271. {
  18272. $this->updateMirrors = $updateMirrors;
  18273. return $this;
  18274. }
  18275. public function setUpdateAllowList(array $packages): self
  18276. {
  18277. $this->updateAllowList = array_flip(array_map('strtolower', $packages));
  18278. return $this;
  18279. }
  18280. public function setUpdateAllowTransitiveDependencies(int $updateAllowTransitiveDependencies): self
  18281. {
  18282. if (!in_array($updateAllowTransitiveDependencies, array(Request::UPDATE_ONLY_LISTED, Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE, Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS), true)) {
  18283. throw new \RuntimeException("Invalid value for updateAllowTransitiveDependencies supplied");
  18284. }
  18285. $this->updateAllowTransitiveDependencies = $updateAllowTransitiveDependencies;
  18286. return $this;
  18287. }
  18288. public function setPreferStable(bool $preferStable = true): self
  18289. {
  18290. $this->preferStable = (bool) $preferStable;
  18291. return $this;
  18292. }
  18293. public function setPreferLowest(bool $preferLowest = true): self
  18294. {
  18295. $this->preferLowest = (bool) $preferLowest;
  18296. return $this;
  18297. }
  18298. public function setWriteLock(bool $writeLock = true): self
  18299. {
  18300. $this->writeLock = (bool) $writeLock;
  18301. return $this;
  18302. }
  18303. public function setExecuteOperations(bool $executeOperations = true): self
  18304. {
  18305. $this->executeOperations = (bool) $executeOperations;
  18306. return $this;
  18307. }
  18308. public function disablePlugins(): self
  18309. {
  18310. $this->installationManager->disablePlugins();
  18311. return $this;
  18312. }
  18313. public function setSuggestedPackagesReporter(SuggestedPackagesReporter $suggestedPackagesReporter): self
  18314. {
  18315. $this->suggestedPackagesReporter = $suggestedPackagesReporter;
  18316. return $this;
  18317. }
  18318. }
  18319. <?php declare(strict_types=1);
  18320. namespace Composer\Installer;
  18321. use Composer\IO\IOInterface;
  18322. use Composer\Package\PackageInterface;
  18323. use Composer\Pcre\Preg;
  18324. use Composer\Util\Filesystem;
  18325. use Composer\Util\Platform;
  18326. use Composer\Util\ProcessExecutor;
  18327. use Composer\Util\Silencer;
  18328. class BinaryInstaller
  18329. {
  18330. protected $binDir;
  18331. protected $binCompat;
  18332. protected $io;
  18333. protected $filesystem;
  18334. private $vendorDir;
  18335. public function __construct(IOInterface $io, string $binDir, string $binCompat, Filesystem $filesystem = null, ?string $vendorDir = null)
  18336. {
  18337. $this->binDir = $binDir;
  18338. $this->binCompat = $binCompat;
  18339. $this->io = $io;
  18340. $this->filesystem = $filesystem ?: new Filesystem();
  18341. $this->vendorDir = $vendorDir;
  18342. }
  18343. public function installBinaries(PackageInterface $package, string $installPath, bool $warnOnOverwrite = true): void
  18344. {
  18345. $binaries = $this->getBinaries($package);
  18346. if (!$binaries) {
  18347. return;
  18348. }
  18349. Platform::workaroundFilesystemIssues();
  18350. foreach ($binaries as $bin) {
  18351. $binPath = $installPath.'/'.$bin;
  18352. if (!file_exists($binPath)) {
  18353. $this->io->writeError(' <warning>Skipped installation of bin '.$bin.' for package '.$package->getName().': file not found in package</warning>');
  18354. continue;
  18355. }
  18356. if (is_dir($binPath)) {
  18357. $this->io->writeError(' <warning>Skipped installation of bin '.$bin.' for package '.$package->getName().': found a directory at that path</warning>');
  18358. continue;
  18359. }
  18360. if (!$this->filesystem->isAbsolutePath($binPath)) {
  18361. $binPath = realpath($binPath);
  18362. }
  18363. $this->initializeBinDir();
  18364. $link = $this->binDir.'/'.basename($bin);
  18365. if (file_exists($link)) {
  18366. if (!is_link($link)) {
  18367. if ($warnOnOverwrite) {
  18368. $this->io->writeError(' Skipped installation of bin '.$bin.' for package '.$package->getName().': name conflicts with an existing file');
  18369. }
  18370. continue;
  18371. }
  18372. if (realpath($link) === realpath($binPath)) {
  18373. $this->filesystem->unlink($link);
  18374. }
  18375. }
  18376. $binCompat = $this->binCompat;
  18377. if ($binCompat === "auto" && (Platform::isWindows() || Platform::isWindowsSubsystemForLinux())) {
  18378. $binCompat = 'full';
  18379. }
  18380. if ($binCompat === "full") {
  18381. $this->installFullBinaries($binPath, $link, $bin, $package);
  18382. } else {
  18383. $this->installUnixyProxyBinaries($binPath, $link);
  18384. }
  18385. Silencer::call('chmod', $binPath, 0777 & ~umask());
  18386. }
  18387. }
  18388. public function removeBinaries(PackageInterface $package): void
  18389. {
  18390. $this->initializeBinDir();
  18391. $binaries = $this->getBinaries($package);
  18392. if (!$binaries) {
  18393. return;
  18394. }
  18395. foreach ($binaries as $bin) {
  18396. $link = $this->binDir.'/'.basename($bin);
  18397. if (is_link($link) || file_exists($link)) {
  18398. $this->filesystem->unlink($link);
  18399. }
  18400. if (is_file($link.'.bat')) {
  18401. $this->filesystem->unlink($link.'.bat');
  18402. }
  18403. }
  18404. if (is_dir($this->binDir) && $this->filesystem->isDirEmpty($this->binDir)) {
  18405. Silencer::call('rmdir', $this->binDir);
  18406. }
  18407. }
  18408. public static function determineBinaryCaller(string $bin): string
  18409. {
  18410. if ('.bat' === substr($bin, -4) || '.exe' === substr($bin, -4)) {
  18411. return 'call';
  18412. }
  18413. $handle = fopen($bin, 'r');
  18414. $line = fgets($handle);
  18415. fclose($handle);
  18416. if (Preg::isMatch('{^#!/(?:usr/bin/env )?(?:[^/]+/)*(.+)$}m', $line, $match)) {
  18417. return trim($match[1]);
  18418. }
  18419. return 'php';
  18420. }
  18421. protected function getBinaries(PackageInterface $package): array
  18422. {
  18423. return $package->getBinaries();
  18424. }
  18425. protected function installFullBinaries(string $binPath, string $link, string $bin, PackageInterface $package): void
  18426. {
  18427. if ('.bat' !== substr($binPath, -4)) {
  18428. $this->installUnixyProxyBinaries($binPath, $link);
  18429. $link .= '.bat';
  18430. if (file_exists($link)) {
  18431. $this->io->writeError(' Skipped installation of bin '.$bin.'.bat proxy for package '.$package->getName().': a .bat proxy was already installed');
  18432. }
  18433. }
  18434. if (!file_exists($link)) {
  18435. file_put_contents($link, $this->generateWindowsProxyCode($binPath, $link));
  18436. Silencer::call('chmod', $link, 0777 & ~umask());
  18437. }
  18438. }
  18439. protected function installUnixyProxyBinaries(string $binPath, string $link): void
  18440. {
  18441. file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
  18442. Silencer::call('chmod', $link, 0777 & ~umask());
  18443. }
  18444. protected function initializeBinDir(): void
  18445. {
  18446. $this->filesystem->ensureDirectoryExists($this->binDir);
  18447. $this->binDir = realpath($this->binDir);
  18448. }
  18449. protected function generateWindowsProxyCode(string $bin, string $link): string
  18450. {
  18451. $binPath = $this->filesystem->findShortestPath($link, $bin);
  18452. $caller = self::determineBinaryCaller($bin);
  18453. if ($caller === 'php') {
  18454. return "@ECHO OFF\r\n".
  18455. "setlocal DISABLEDELAYEDEXPANSION\r\n".
  18456. "SET BIN_TARGET=%~dp0/".trim(ProcessExecutor::escape(basename($link, '.bat')), '"\'')."\r\n".
  18457. "SET COMPOSER_RUNTIME_BIN_DIR=%~dp0\r\n".
  18458. "{$caller} \"%BIN_TARGET%\" %*\r\n";
  18459. }
  18460. return "@ECHO OFF\r\n".
  18461. "setlocal DISABLEDELAYEDEXPANSION\r\n".
  18462. "SET BIN_TARGET=%~dp0/".trim(ProcessExecutor::escape($binPath), '"\'')."\r\n".
  18463. "SET COMPOSER_RUNTIME_BIN_DIR=%~dp0\r\n".
  18464. "{$caller} \"%BIN_TARGET%\" %*\r\n";
  18465. }
  18466. protected function generateUnixyProxyCode(string $bin, string $link): string
  18467. {
  18468. $binPath = $this->filesystem->findShortestPath($link, $bin);
  18469. $binDir = ProcessExecutor::escape(dirname($binPath));
  18470. $binFile = basename($binPath);
  18471. $binContents = file_get_contents($bin);
  18472. if (Preg::isMatch('{^(#!.*\r?\n)?[\r\n\t ]*<\?php}', $binContents, $match)) {
  18473. $proxyCode = empty($match[1]) ? '#!/usr/bin/env php' : trim($match[1]);
  18474. $binPathExported = $this->filesystem->findShortestPathCode($link, $bin, false, true);
  18475. $streamProxyCode = $streamHint = '';
  18476. $globalsCode = '$GLOBALS[\'_composer_bin_dir\'] = __DIR__;'."\n";
  18477. $phpunitHack1 = $phpunitHack2 = '';
  18478. if ($this->vendorDir) {
  18479. $globalsCode .= '$GLOBALS[\'_composer_autoload_path\'] = ' . $this->filesystem->findShortestPathCode($link, $this->vendorDir . '/autoload.php', false, true).";\n";
  18480. }
  18481. if ($this->filesystem->normalizePath($bin) === $this->filesystem->normalizePath($this->vendorDir.'/phpunit/phpunit/phpunit')) {
  18482. $globalsCode .= '$GLOBALS[\'__PHPUNIT_ISOLATION_EXCLUDE_LIST\'] = $GLOBALS[\'__PHPUNIT_ISOLATION_BLACKLIST\'] = array(realpath('.$binPathExported.'));'."\n";
  18483. $phpunitHack1 = "'phpvfscomposer://'.";
  18484. $phpunitHack2 = '
  18485. $data = str_replace(\'__DIR__\', var_export(dirname($this->realpath), true), $data);
  18486. $data = str_replace(\'__FILE__\', var_export($this->realpath, true), $data);';
  18487. }
  18488. if (trim($match[0]) !== '<?php') {
  18489. $streamHint = ' using a stream wrapper to prevent the shebang from being output on PHP<8'."\n *";
  18490. $streamProxyCode = <<<STREAMPROXY
  18491. if (PHP_VERSION_ID < 80000) {
  18492. if (!class_exists('Composer\BinProxyWrapper')) {
  18493. /**
  18494. * @internal
  18495. */
  18496. final class BinProxyWrapper
  18497. {
  18498. private \$handle;
  18499. private \$position;
  18500. private \$realpath;
  18501. public function stream_open(\$path, \$mode, \$options, &\$opened_path)
  18502. {
  18503. // get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution
  18504. \$opened_path = substr(\$path, 17);
  18505. \$this->realpath = realpath(\$opened_path) ?: \$opened_path;
  18506. \$opened_path = $phpunitHack1\$this->realpath;
  18507. \$this->handle = fopen(\$this->realpath, \$mode);
  18508. \$this->position = 0;
  18509. return (bool) \$this->handle;
  18510. }
  18511. public function stream_read(\$count)
  18512. {
  18513. \$data = fread(\$this->handle, \$count);
  18514. if (\$this->position === 0) {
  18515. \$data = preg_replace('{^#!.*\\r?\\n}', '', \$data);
  18516. }$phpunitHack2
  18517. \$this->position += strlen(\$data);
  18518. return \$data;
  18519. }
  18520. public function stream_cast(\$castAs)
  18521. {
  18522. return \$this->handle;
  18523. }
  18524. public function stream_close()
  18525. {
  18526. fclose(\$this->handle);
  18527. }
  18528. public function stream_lock(\$operation)
  18529. {
  18530. return \$operation ? flock(\$this->handle, \$operation) : true;
  18531. }
  18532. public function stream_seek(\$offset, \$whence)
  18533. {
  18534. if (0 === fseek(\$this->handle, \$offset, \$whence)) {
  18535. \$this->position = ftell(\$this->handle);
  18536. return true;
  18537. }
  18538. return false;
  18539. }
  18540. public function stream_tell()
  18541. {
  18542. return \$this->position;
  18543. }
  18544. public function stream_eof()
  18545. {
  18546. return feof(\$this->handle);
  18547. }
  18548. public function stream_stat()
  18549. {
  18550. return array();
  18551. }
  18552. public function stream_set_option(\$option, \$arg1, \$arg2)
  18553. {
  18554. return true;
  18555. }
  18556. public function url_stat(\$path, \$flags)
  18557. {
  18558. \$path = substr(\$path, 17);
  18559. if (file_exists(\$path)) {
  18560. return stat(\$path);
  18561. }
  18562. return false;
  18563. }
  18564. }
  18565. }
  18566. if (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper')) {
  18567. include("phpvfscomposer://" . $binPathExported);
  18568. exit(0);
  18569. }
  18570. }
  18571. STREAMPROXY;
  18572. }
  18573. return $proxyCode . "\n" . <<<PROXY
  18574. <?php
  18575. /**
  18576. * Proxy PHP file generated by Composer
  18577. *
  18578. * This file includes the referenced bin path ($binPath)
  18579. *$streamHint
  18580. * @generated
  18581. */
  18582. namespace Composer;
  18583. $globalsCode
  18584. $streamProxyCode
  18585. include $binPathExported;
  18586. PROXY;
  18587. }
  18588. return <<<PROXY
  18589. #!/usr/bin/env sh
  18590. # Support bash to support `source` with fallback on $0 if this does not run with bash
  18591. # https://stackoverflow.com/a/35006505/6512
  18592. selfArg="\$BASH_SOURCE"
  18593. if [ -z "\$selfArg" ]; then
  18594. selfArg="\$0"
  18595. fi
  18596. self=\$(realpath \$selfArg 2> /dev/null)
  18597. if [ -z "\$self" ]; then
  18598. self="\$selfArg"
  18599. fi
  18600. dir=\$(cd "\${self%[/\\\\]*}" > /dev/null; cd $binDir && pwd)
  18601. if [ -d /proc/cygdrive ]; then
  18602. case \$(which php) in
  18603. \$(readlink -n /proc/cygdrive)/*)
  18604. # We are in Cygwin using Windows php, so the path must be translated
  18605. dir=\$(cygpath -m "\$dir");
  18606. ;;
  18607. esac
  18608. fi
  18609. export COMPOSER_RUNTIME_BIN_DIR=\$(cd "\${self%[/\\\\]*}" > /dev/null; pwd)
  18610. # If bash is sourcing this file, we have to source the target as well
  18611. bashSource="\$BASH_SOURCE"
  18612. if [ -n "\$bashSource" ]; then
  18613. if [ "\$bashSource" != "\$0" ]; then
  18614. source "\${dir}/$binFile" "\$@"
  18615. return
  18616. fi
  18617. fi
  18618. "\${dir}/$binFile" "\$@"
  18619. PROXY;
  18620. }
  18621. }
  18622. <?php declare(strict_types=1);
  18623. namespace Composer\Installer;
  18624. use Composer\Package\PackageInterface;
  18625. interface BinaryPresenceInterface
  18626. {
  18627. public function ensureBinariesPresence(PackageInterface $package);
  18628. }
  18629. <?php declare(strict_types=1);
  18630. namespace Composer\Installer;
  18631. use Composer\IO\IOInterface;
  18632. use Composer\IO\ConsoleIO;
  18633. use Composer\Package\PackageInterface;
  18634. use Composer\Package\AliasPackage;
  18635. use Composer\Repository\InstalledRepositoryInterface;
  18636. use Composer\DependencyResolver\Operation\OperationInterface;
  18637. use Composer\DependencyResolver\Operation\InstallOperation;
  18638. use Composer\DependencyResolver\Operation\UpdateOperation;
  18639. use Composer\DependencyResolver\Operation\UninstallOperation;
  18640. use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation;
  18641. use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
  18642. use Composer\Downloader\FileDownloader;
  18643. use Composer\EventDispatcher\EventDispatcher;
  18644. use Composer\Util\Loop;
  18645. use Composer\Util\Platform;
  18646. use React\Promise\PromiseInterface;
  18647. class InstallationManager
  18648. {
  18649. private $installers = array();
  18650. private $cache = array();
  18651. private $notifiablePackages = array();
  18652. private $loop;
  18653. private $io;
  18654. private $eventDispatcher;
  18655. private $outputProgress;
  18656. public function __construct(Loop $loop, IOInterface $io, EventDispatcher $eventDispatcher = null)
  18657. {
  18658. $this->loop = $loop;
  18659. $this->io = $io;
  18660. $this->eventDispatcher = $eventDispatcher;
  18661. }
  18662. public function reset(): void
  18663. {
  18664. $this->notifiablePackages = array();
  18665. FileDownloader::$downloadMetadata = array();
  18666. }
  18667. public function addInstaller(InstallerInterface $installer): void
  18668. {
  18669. array_unshift($this->installers, $installer);
  18670. $this->cache = array();
  18671. }
  18672. public function removeInstaller(InstallerInterface $installer): void
  18673. {
  18674. if (false !== ($key = array_search($installer, $this->installers, true))) {
  18675. array_splice($this->installers, $key, 1);
  18676. $this->cache = array();
  18677. }
  18678. }
  18679. public function disablePlugins(): void
  18680. {
  18681. foreach ($this->installers as $i => $installer) {
  18682. if (!$installer instanceof PluginInstaller) {
  18683. continue;
  18684. }
  18685. unset($this->installers[$i]);
  18686. }
  18687. }
  18688. public function getInstaller(string $type): InstallerInterface
  18689. {
  18690. $type = strtolower($type);
  18691. if (isset($this->cache[$type])) {
  18692. return $this->cache[$type];
  18693. }
  18694. foreach ($this->installers as $installer) {
  18695. if ($installer->supports($type)) {
  18696. return $this->cache[$type] = $installer;
  18697. }
  18698. }
  18699. throw new \InvalidArgumentException('Unknown installer type: '.$type);
  18700. }
  18701. public function isPackageInstalled(InstalledRepositoryInterface $repo, PackageInterface $package): bool
  18702. {
  18703. if ($package instanceof AliasPackage) {
  18704. return $repo->hasPackage($package) && $this->isPackageInstalled($repo, $package->getAliasOf());
  18705. }
  18706. return $this->getInstaller($package->getType())->isInstalled($repo, $package);
  18707. }
  18708. public function ensureBinariesPresence(PackageInterface $package): void
  18709. {
  18710. try {
  18711. $installer = $this->getInstaller($package->getType());
  18712. } catch (\InvalidArgumentException $e) {
  18713. return;
  18714. }
  18715. if ($installer instanceof BinaryPresenceInterface) {
  18716. $installer->ensureBinariesPresence($package);
  18717. }
  18718. }
  18719. public function execute(InstalledRepositoryInterface $repo, array $operations, bool $devMode = true, bool $runScripts = true): void
  18720. {
  18721. $cleanupPromises = array();
  18722. $loop = $this->loop;
  18723. $io = $this->io;
  18724. $runCleanup = function () use (&$cleanupPromises, $loop): void {
  18725. $promises = array();
  18726. $loop->abortJobs();
  18727. foreach ($cleanupPromises as $cleanup) {
  18728. $promises[] = new \React\Promise\Promise(function ($resolve, $reject) use ($cleanup): void {
  18729. $promise = $cleanup();
  18730. if (!$promise instanceof PromiseInterface) {
  18731. $resolve();
  18732. } else {
  18733. $promise->then(function () use ($resolve): void {
  18734. $resolve();
  18735. });
  18736. }
  18737. });
  18738. }
  18739. if (!empty($promises)) {
  18740. $loop->wait($promises);
  18741. }
  18742. };
  18743. $handleInterruptsUnix = function_exists('pcntl_async_signals') && function_exists('pcntl_signal');
  18744. $handleInterruptsWindows = PHP_VERSION_ID >= 70400 && function_exists('sapi_windows_set_ctrl_handler') && PHP_SAPI === 'cli';
  18745. $prevHandler = null;
  18746. $windowsHandler = null;
  18747. if ($handleInterruptsUnix) {
  18748. pcntl_async_signals(true);
  18749. $prevHandler = pcntl_signal_get_handler(SIGINT);
  18750. pcntl_signal(SIGINT, function ($sig) use ($runCleanup, $prevHandler, $io): void {
  18751. $io->writeError('Received SIGINT, aborting', true, IOInterface::DEBUG);
  18752. $runCleanup();
  18753. if (!in_array($prevHandler, array(SIG_DFL, SIG_IGN), true)) {
  18754. call_user_func($prevHandler, $sig);
  18755. }
  18756. exit(130);
  18757. });
  18758. }
  18759. if ($handleInterruptsWindows) {
  18760. $windowsHandler = function ($event) use ($runCleanup, $io): void {
  18761. if ($event !== PHP_WINDOWS_EVENT_CTRL_C) {
  18762. return;
  18763. }
  18764. $io->writeError('Received CTRL+C, aborting', true, IOInterface::DEBUG);
  18765. $runCleanup();
  18766. exit(130);
  18767. };
  18768. sapi_windows_set_ctrl_handler($windowsHandler);
  18769. }
  18770. try {
  18771. $batches = array();
  18772. $batch = array();
  18773. foreach ($operations as $index => $operation) {
  18774. if ($operation instanceof UpdateOperation || $operation instanceof InstallOperation) {
  18775. $package = $operation instanceof UpdateOperation ? $operation->getTargetPackage() : $operation->getPackage();
  18776. if ($package->getType() === 'composer-plugin' && ($extra = $package->getExtra()) && isset($extra['plugin-modifies-downloads']) && $extra['plugin-modifies-downloads'] === true) {
  18777. if ($batch) {
  18778. $batches[] = $batch;
  18779. }
  18780. $batches[] = array($index => $operation);
  18781. $batch = array();
  18782. continue;
  18783. }
  18784. }
  18785. $batch[$index] = $operation;
  18786. }
  18787. if ($batch) {
  18788. $batches[] = $batch;
  18789. }
  18790. foreach ($batches as $batch) {
  18791. $this->downloadAndExecuteBatch($repo, $batch, $cleanupPromises, $devMode, $runScripts, $operations);
  18792. }
  18793. } catch (\Exception $e) {
  18794. $runCleanup();
  18795. if ($handleInterruptsUnix) {
  18796. pcntl_signal(SIGINT, $prevHandler);
  18797. }
  18798. if ($handleInterruptsWindows) {
  18799. sapi_windows_set_ctrl_handler($windowsHandler, false);
  18800. }
  18801. throw $e;
  18802. }
  18803. if ($handleInterruptsUnix) {
  18804. pcntl_signal(SIGINT, $prevHandler);
  18805. }
  18806. if ($handleInterruptsWindows) {
  18807. sapi_windows_set_ctrl_handler($windowsHandler, false);
  18808. }
  18809. $repo->write($devMode, $this);
  18810. }
  18811. private function downloadAndExecuteBatch(InstalledRepositoryInterface $repo, array $operations, array &$cleanupPromises, bool $devMode, bool $runScripts, array $allOperations): void
  18812. {
  18813. $promises = array();
  18814. foreach ($operations as $index => $operation) {
  18815. $opType = $operation->getOperationType();
  18816. if (!in_array($opType, array('update', 'install', 'uninstall'))) {
  18817. continue;
  18818. }
  18819. if ($opType === 'update') {
  18820. $package = $operation->getTargetPackage();
  18821. $initialPackage = $operation->getInitialPackage();
  18822. } else {
  18823. $package = $operation->getPackage();
  18824. $initialPackage = null;
  18825. }
  18826. $installer = $this->getInstaller($package->getType());
  18827. $cleanupPromises[$index] = function () use ($opType, $installer, $package, $initialPackage) {
  18828. if (!$package->getInstallationSource()) {
  18829. return;
  18830. }
  18831. return $installer->cleanup($opType, $package, $initialPackage);
  18832. };
  18833. if ($opType !== 'uninstall') {
  18834. $promise = $installer->download($package, $initialPackage);
  18835. if ($promise) {
  18836. $promises[] = $promise;
  18837. }
  18838. }
  18839. }
  18840. if (count($promises)) {
  18841. $this->waitOnPromises($promises);
  18842. }
  18843. $batches = array();
  18844. $batch = array();
  18845. foreach ($operations as $index => $operation) {
  18846. if ($operation instanceof InstallOperation || $operation instanceof UpdateOperation) {
  18847. $package = $operation instanceof UpdateOperation ? $operation->getTargetPackage() : $operation->getPackage();
  18848. if ($package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer') {
  18849. if ($batch) {
  18850. $batches[] = $batch;
  18851. }
  18852. $batches[] = array($index => $operation);
  18853. $batch = array();
  18854. continue;
  18855. }
  18856. }
  18857. $batch[$index] = $operation;
  18858. }
  18859. if ($batch) {
  18860. $batches[] = $batch;
  18861. }
  18862. foreach ($batches as $batch) {
  18863. $this->executeBatch($repo, $batch, $cleanupPromises, $devMode, $runScripts, $allOperations);
  18864. }
  18865. }
  18866. private function executeBatch(InstalledRepositoryInterface $repo, array $operations, array $cleanupPromises, bool $devMode, bool $runScripts, array $allOperations): void
  18867. {
  18868. $promises = array();
  18869. $postExecCallbacks = array();
  18870. foreach ($operations as $index => $operation) {
  18871. $opType = $operation->getOperationType();
  18872. if (!in_array($opType, array('update', 'install', 'uninstall'))) {
  18873. if ($this->io->isDebug()) {
  18874. $this->io->writeError(' - ' . $operation->show(false));
  18875. }
  18876. $this->$opType($repo, $operation);
  18877. continue;
  18878. }
  18879. if ($opType === 'update') {
  18880. $package = $operation->getTargetPackage();
  18881. $initialPackage = $operation->getInitialPackage();
  18882. } else {
  18883. $package = $operation->getPackage();
  18884. $initialPackage = null;
  18885. }
  18886. $installer = $this->getInstaller($package->getType());
  18887. $event = 'Composer\Installer\PackageEvents::PRE_PACKAGE_'.strtoupper($opType);
  18888. if (defined($event) && $runScripts && $this->eventDispatcher) {
  18889. $this->eventDispatcher->dispatchPackageEvent(constant($event), $devMode, $repo, $allOperations, $operation);
  18890. }
  18891. $dispatcher = $this->eventDispatcher;
  18892. $io = $this->io;
  18893. $promise = $installer->prepare($opType, $package, $initialPackage);
  18894. if (!$promise instanceof PromiseInterface) {
  18895. $promise = \React\Promise\resolve(null);
  18896. }
  18897. $promise = $promise->then(function () use ($opType, $repo, $operation) {
  18898. return $this->$opType($repo, $operation);
  18899. })->then($cleanupPromises[$index])
  18900. ->then(function () use ($devMode, $repo): void {
  18901. $repo->write($devMode, $this);
  18902. }, function ($e) use ($opType, $package, $io): void {
  18903. $io->writeError(' <error>' . ucfirst($opType) .' of '.$package->getPrettyName().' failed</error>');
  18904. throw $e;
  18905. });
  18906. $postExecCallbacks[] = function () use ($opType, $runScripts, $dispatcher, $devMode, $repo, $allOperations, $operation): void {
  18907. $event = 'Composer\Installer\PackageEvents::POST_PACKAGE_'.strtoupper($opType);
  18908. if (defined($event) && $runScripts && $dispatcher) {
  18909. $dispatcher->dispatchPackageEvent(constant($event), $devMode, $repo, $allOperations, $operation);
  18910. }
  18911. };
  18912. $promises[] = $promise;
  18913. }
  18914. if (count($promises)) {
  18915. $this->waitOnPromises($promises);
  18916. }
  18917. Platform::workaroundFilesystemIssues();
  18918. foreach ($postExecCallbacks as $cb) {
  18919. $cb();
  18920. }
  18921. }
  18922. private function waitOnPromises(array $promises): void
  18923. {
  18924. $progress = null;
  18925. if (
  18926. $this->outputProgress
  18927. && $this->io instanceof ConsoleIO
  18928. && !Platform::getEnv('CI')
  18929. && !$this->io->isDebug()
  18930. && count($promises) > 1
  18931. ) {
  18932. $progress = $this->io->getProgressBar();
  18933. }
  18934. $this->loop->wait($promises, $progress);
  18935. if ($progress) {
  18936. $progress->clear();
  18937. if (!$this->io->isDecorated()) {
  18938. $this->io->writeError('');
  18939. }
  18940. }
  18941. }
  18942. public function install(InstalledRepositoryInterface $repo, InstallOperation $operation): ?PromiseInterface
  18943. {
  18944. $package = $operation->getPackage();
  18945. $installer = $this->getInstaller($package->getType());
  18946. $promise = $installer->install($repo, $package);
  18947. $this->markForNotification($package);
  18948. return $promise;
  18949. }
  18950. public function update(InstalledRepositoryInterface $repo, UpdateOperation $operation): ?PromiseInterface
  18951. {
  18952. $initial = $operation->getInitialPackage();
  18953. $target = $operation->getTargetPackage();
  18954. $initialType = $initial->getType();
  18955. $targetType = $target->getType();
  18956. if ($initialType === $targetType) {
  18957. $installer = $this->getInstaller($initialType);
  18958. $promise = $installer->update($repo, $initial, $target);
  18959. $this->markForNotification($target);
  18960. } else {
  18961. $promise = $this->getInstaller($initialType)->uninstall($repo, $initial);
  18962. if (!$promise instanceof PromiseInterface) {
  18963. $promise = \React\Promise\resolve(null);
  18964. }
  18965. $installer = $this->getInstaller($targetType);
  18966. $promise = $promise->then(function () use ($installer, $repo, $target): PromiseInterface {
  18967. $promise = $installer->install($repo, $target);
  18968. if ($promise instanceof PromiseInterface) {
  18969. return $promise;
  18970. }
  18971. return \React\Promise\resolve(null);
  18972. });
  18973. }
  18974. return $promise;
  18975. }
  18976. public function uninstall(InstalledRepositoryInterface $repo, UninstallOperation $operation): ?PromiseInterface
  18977. {
  18978. $package = $operation->getPackage();
  18979. $installer = $this->getInstaller($package->getType());
  18980. return $installer->uninstall($repo, $package);
  18981. }
  18982. public function markAliasInstalled(InstalledRepositoryInterface $repo, MarkAliasInstalledOperation $operation): void
  18983. {
  18984. $package = $operation->getPackage();
  18985. if (!$repo->hasPackage($package)) {
  18986. $repo->addPackage(clone $package);
  18987. }
  18988. }
  18989. public function markAliasUninstalled(InstalledRepositoryInterface $repo, MarkAliasUninstalledOperation $operation): void
  18990. {
  18991. $package = $operation->getPackage();
  18992. $repo->removePackage($package);
  18993. }
  18994. public function getInstallPath(PackageInterface $package): string
  18995. {
  18996. $installer = $this->getInstaller($package->getType());
  18997. return $installer->getInstallPath($package);
  18998. }
  18999. public function setOutputProgress(bool $outputProgress): void
  19000. {
  19001. $this->outputProgress = $outputProgress;
  19002. }
  19003. public function notifyInstalls(IOInterface $io): void
  19004. {
  19005. $promises = array();
  19006. try {
  19007. foreach ($this->notifiablePackages as $repoUrl => $packages) {
  19008. if (strpos($repoUrl, '%package%')) {
  19009. foreach ($packages as $package) {
  19010. $url = str_replace('%package%', $package->getPrettyName(), $repoUrl);
  19011. $params = array(
  19012. 'version' => $package->getPrettyVersion(),
  19013. 'version_normalized' => $package->getVersion(),
  19014. );
  19015. $opts = array(
  19016. 'retry-auth-failure' => false,
  19017. 'http' => array(
  19018. 'method' => 'POST',
  19019. 'header' => array('Content-type: application/x-www-form-urlencoded'),
  19020. 'content' => http_build_query($params, '', '&'),
  19021. 'timeout' => 3,
  19022. ),
  19023. );
  19024. $promises[] = $this->loop->getHttpDownloader()->add($url, $opts);
  19025. }
  19026. continue;
  19027. }
  19028. $postData = array('downloads' => array());
  19029. foreach ($packages as $package) {
  19030. $packageNotification = array(
  19031. 'name' => $package->getPrettyName(),
  19032. 'version' => $package->getVersion(),
  19033. );
  19034. if (strpos($repoUrl, 'packagist.org/') !== false) {
  19035. if (isset(FileDownloader::$downloadMetadata[$package->getName()])) {
  19036. $packageNotification['downloaded'] = FileDownloader::$downloadMetadata[$package->getName()];
  19037. } else {
  19038. $packageNotification['downloaded'] = false;
  19039. }
  19040. }
  19041. $postData['downloads'][] = $packageNotification;
  19042. }
  19043. $opts = array(
  19044. 'retry-auth-failure' => false,
  19045. 'http' => array(
  19046. 'method' => 'POST',
  19047. 'header' => array('Content-Type: application/json'),
  19048. 'content' => json_encode($postData),
  19049. 'timeout' => 6,
  19050. ),
  19051. );
  19052. $promises[] = $this->loop->getHttpDownloader()->add($repoUrl, $opts);
  19053. }
  19054. $this->loop->wait($promises);
  19055. } catch (\Exception $e) {
  19056. }
  19057. $this->reset();
  19058. }
  19059. private function markForNotification(PackageInterface $package): void
  19060. {
  19061. if ($package->getNotificationUrl()) {
  19062. $this->notifiablePackages[$package->getNotificationUrl()][$package->getName()] = $package;
  19063. }
  19064. }
  19065. }
  19066. <?php declare(strict_types=1);
  19067. namespace Composer\Installer;
  19068. use Composer\Composer;
  19069. use Composer\DependencyResolver\Transaction;
  19070. use Composer\EventDispatcher\Event;
  19071. use Composer\IO\IOInterface;
  19072. class InstallerEvent extends Event
  19073. {
  19074. private $composer;
  19075. private $io;
  19076. private $devMode;
  19077. private $executeOperations;
  19078. private $transaction;
  19079. public function __construct(string $eventName, Composer $composer, IOInterface $io, bool $devMode, bool $executeOperations, Transaction $transaction)
  19080. {
  19081. parent::__construct($eventName);
  19082. $this->composer = $composer;
  19083. $this->io = $io;
  19084. $this->devMode = $devMode;
  19085. $this->executeOperations = $executeOperations;
  19086. $this->transaction = $transaction;
  19087. }
  19088. public function getComposer(): Composer
  19089. {
  19090. return $this->composer;
  19091. }
  19092. public function getIO(): IOInterface
  19093. {
  19094. return $this->io;
  19095. }
  19096. public function isDevMode(): bool
  19097. {
  19098. return $this->devMode;
  19099. }
  19100. public function isExecutingOperations(): bool
  19101. {
  19102. return $this->executeOperations;
  19103. }
  19104. public function getTransaction(): ?Transaction
  19105. {
  19106. return $this->transaction;
  19107. }
  19108. }
  19109. <?php declare(strict_types=1);
  19110. namespace Composer\Installer;
  19111. class InstallerEvents
  19112. {
  19113. public const PRE_OPERATIONS_EXEC = 'pre-operations-exec';
  19114. }
  19115. <?php declare(strict_types=1);
  19116. namespace Composer\Installer;
  19117. use Composer\Package\PackageInterface;
  19118. use Composer\Repository\InstalledRepositoryInterface;
  19119. use InvalidArgumentException;
  19120. use React\Promise\PromiseInterface;
  19121. interface InstallerInterface
  19122. {
  19123. public function supports(string $packageType);
  19124. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package);
  19125. public function download(PackageInterface $package, PackageInterface $prevPackage = null);
  19126. public function prepare(string $type, PackageInterface $package, PackageInterface $prevPackage = null);
  19127. public function install(InstalledRepositoryInterface $repo, PackageInterface $package);
  19128. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target);
  19129. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package);
  19130. public function cleanup(string $type, PackageInterface $package, PackageInterface $prevPackage = null);
  19131. public function getInstallPath(PackageInterface $package);
  19132. }
  19133. <?php declare(strict_types=1);
  19134. namespace Composer\Installer;
  19135. use Composer\Composer;
  19136. use Composer\IO\IOInterface;
  19137. use Composer\PartialComposer;
  19138. use Composer\Pcre\Preg;
  19139. use Composer\Repository\InstalledRepositoryInterface;
  19140. use Composer\Package\PackageInterface;
  19141. use Composer\Util\Filesystem;
  19142. use Composer\Util\Silencer;
  19143. use Composer\Util\Platform;
  19144. use React\Promise\PromiseInterface;
  19145. use Composer\Downloader\DownloadManager;
  19146. class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
  19147. {
  19148. protected $composer;
  19149. protected $vendorDir;
  19150. protected $downloadManager;
  19151. protected $io;
  19152. protected $type;
  19153. protected $filesystem;
  19154. protected $binaryInstaller;
  19155. public function __construct(IOInterface $io, PartialComposer $composer, ?string $type = 'library', Filesystem $filesystem = null, BinaryInstaller $binaryInstaller = null)
  19156. {
  19157. $this->composer = $composer;
  19158. $this->downloadManager = $composer instanceof Composer ? $composer->getDownloadManager() : null;
  19159. $this->io = $io;
  19160. $this->type = $type;
  19161. $this->filesystem = $filesystem ?: new Filesystem();
  19162. $this->vendorDir = rtrim($composer->getConfig()->get('vendor-dir'), '/');
  19163. $this->binaryInstaller = $binaryInstaller ?: new BinaryInstaller($this->io, rtrim($composer->getConfig()->get('bin-dir'), '/'), $composer->getConfig()->get('bin-compat'), $this->filesystem, $this->vendorDir);
  19164. }
  19165. public function supports(string $packageType)
  19166. {
  19167. return $packageType === $this->type || null === $this->type;
  19168. }
  19169. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  19170. {
  19171. if (!$repo->hasPackage($package)) {
  19172. return false;
  19173. }
  19174. $installPath = $this->getInstallPath($package);
  19175. if (Filesystem::isReadable($installPath)) {
  19176. return true;
  19177. }
  19178. return (Platform::isWindows() && $this->filesystem->isJunction($installPath)) || is_link($installPath);
  19179. }
  19180. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  19181. {
  19182. $this->initializeVendorDir();
  19183. $downloadPath = $this->getInstallPath($package);
  19184. return $this->getDownloadManager()->download($package, $downloadPath, $prevPackage);
  19185. }
  19186. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  19187. {
  19188. $this->initializeVendorDir();
  19189. $downloadPath = $this->getInstallPath($package);
  19190. return $this->getDownloadManager()->prepare($type, $package, $downloadPath, $prevPackage);
  19191. }
  19192. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  19193. {
  19194. $this->initializeVendorDir();
  19195. $downloadPath = $this->getInstallPath($package);
  19196. return $this->getDownloadManager()->cleanup($type, $package, $downloadPath, $prevPackage);
  19197. }
  19198. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  19199. {
  19200. $this->initializeVendorDir();
  19201. $downloadPath = $this->getInstallPath($package);
  19202. if (!Filesystem::isReadable($downloadPath) && $repo->hasPackage($package)) {
  19203. $this->binaryInstaller->removeBinaries($package);
  19204. }
  19205. $promise = $this->installCode($package);
  19206. if (!$promise instanceof PromiseInterface) {
  19207. $promise = \React\Promise\resolve(null);
  19208. }
  19209. $binaryInstaller = $this->binaryInstaller;
  19210. $installPath = $this->getInstallPath($package);
  19211. return $promise->then(function () use ($binaryInstaller, $installPath, $package, $repo): void {
  19212. $binaryInstaller->installBinaries($package, $installPath);
  19213. if (!$repo->hasPackage($package)) {
  19214. $repo->addPackage(clone $package);
  19215. }
  19216. });
  19217. }
  19218. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  19219. {
  19220. if (!$repo->hasPackage($initial)) {
  19221. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  19222. }
  19223. $this->initializeVendorDir();
  19224. $this->binaryInstaller->removeBinaries($initial);
  19225. $promise = $this->updateCode($initial, $target);
  19226. if (!$promise instanceof PromiseInterface) {
  19227. $promise = \React\Promise\resolve(null);
  19228. }
  19229. $binaryInstaller = $this->binaryInstaller;
  19230. $installPath = $this->getInstallPath($target);
  19231. return $promise->then(function () use ($binaryInstaller, $installPath, $target, $initial, $repo): void {
  19232. $binaryInstaller->installBinaries($target, $installPath);
  19233. $repo->removePackage($initial);
  19234. if (!$repo->hasPackage($target)) {
  19235. $repo->addPackage(clone $target);
  19236. }
  19237. });
  19238. }
  19239. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  19240. {
  19241. if (!$repo->hasPackage($package)) {
  19242. throw new \InvalidArgumentException('Package is not installed: '.$package);
  19243. }
  19244. $promise = $this->removeCode($package);
  19245. if (!$promise instanceof PromiseInterface) {
  19246. $promise = \React\Promise\resolve(null);
  19247. }
  19248. $binaryInstaller = $this->binaryInstaller;
  19249. $downloadPath = $this->getPackageBasePath($package);
  19250. $filesystem = $this->filesystem;
  19251. return $promise->then(function () use ($binaryInstaller, $filesystem, $downloadPath, $package, $repo): void {
  19252. $binaryInstaller->removeBinaries($package);
  19253. $repo->removePackage($package);
  19254. if (strpos($package->getName(), '/')) {
  19255. $packageVendorDir = dirname($downloadPath);
  19256. if (is_dir($packageVendorDir) && $filesystem->isDirEmpty($packageVendorDir)) {
  19257. Silencer::call('rmdir', $packageVendorDir);
  19258. }
  19259. }
  19260. });
  19261. }
  19262. public function getInstallPath(PackageInterface $package)
  19263. {
  19264. $this->initializeVendorDir();
  19265. $basePath = ($this->vendorDir ? $this->vendorDir.'/' : '') . $package->getPrettyName();
  19266. $targetDir = $package->getTargetDir();
  19267. return $basePath . ($targetDir ? '/'.$targetDir : '');
  19268. }
  19269. public function ensureBinariesPresence(PackageInterface $package)
  19270. {
  19271. $this->binaryInstaller->installBinaries($package, $this->getInstallPath($package), false);
  19272. }
  19273. protected function getPackageBasePath(PackageInterface $package)
  19274. {
  19275. $installPath = $this->getInstallPath($package);
  19276. $targetDir = $package->getTargetDir();
  19277. if ($targetDir) {
  19278. return Preg::replace('{/*'.str_replace('/', '/+', preg_quote($targetDir)).'/?$}', '', $installPath);
  19279. }
  19280. return $installPath;
  19281. }
  19282. protected function installCode(PackageInterface $package)
  19283. {
  19284. $downloadPath = $this->getInstallPath($package);
  19285. return $this->getDownloadManager()->install($package, $downloadPath);
  19286. }
  19287. protected function updateCode(PackageInterface $initial, PackageInterface $target)
  19288. {
  19289. $initialDownloadPath = $this->getInstallPath($initial);
  19290. $targetDownloadPath = $this->getInstallPath($target);
  19291. if ($targetDownloadPath !== $initialDownloadPath) {
  19292. if (strpos($initialDownloadPath, $targetDownloadPath) === 0
  19293. || strpos($targetDownloadPath, $initialDownloadPath) === 0
  19294. ) {
  19295. $promise = $this->removeCode($initial);
  19296. if (!$promise instanceof PromiseInterface) {
  19297. $promise = \React\Promise\resolve(null);
  19298. }
  19299. return $promise->then(function () use ($target): PromiseInterface {
  19300. $promise = $this->installCode($target);
  19301. if ($promise instanceof PromiseInterface) {
  19302. return $promise;
  19303. }
  19304. return \React\Promise\resolve(null);
  19305. });
  19306. }
  19307. $this->filesystem->rename($initialDownloadPath, $targetDownloadPath);
  19308. }
  19309. return $this->getDownloadManager()->update($initial, $target, $targetDownloadPath);
  19310. }
  19311. protected function removeCode(PackageInterface $package)
  19312. {
  19313. $downloadPath = $this->getPackageBasePath($package);
  19314. return $this->getDownloadManager()->remove($package, $downloadPath);
  19315. }
  19316. protected function initializeVendorDir()
  19317. {
  19318. $this->filesystem->ensureDirectoryExists($this->vendorDir);
  19319. $this->vendorDir = realpath($this->vendorDir);
  19320. }
  19321. protected function getDownloadManager(): DownloadManager
  19322. {
  19323. assert($this->downloadManager instanceof DownloadManager, new \LogicException(self::class.' should be initialized with a fully loaded Composer instance to be able to install/... packages'));
  19324. return $this->downloadManager;
  19325. }
  19326. }
  19327. <?php declare(strict_types=1);
  19328. namespace Composer\Installer;
  19329. use Composer\Repository\InstalledRepositoryInterface;
  19330. use Composer\Package\PackageInterface;
  19331. use Composer\IO\IOInterface;
  19332. use Composer\DependencyResolver\Operation\UpdateOperation;
  19333. use Composer\DependencyResolver\Operation\InstallOperation;
  19334. use Composer\DependencyResolver\Operation\UninstallOperation;
  19335. class MetapackageInstaller implements InstallerInterface
  19336. {
  19337. private $io;
  19338. public function __construct(IOInterface $io)
  19339. {
  19340. $this->io = $io;
  19341. }
  19342. public function supports(string $packageType)
  19343. {
  19344. return $packageType === 'metapackage';
  19345. }
  19346. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  19347. {
  19348. return $repo->hasPackage($package);
  19349. }
  19350. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  19351. {
  19352. return \React\Promise\resolve(null);
  19353. }
  19354. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  19355. {
  19356. return \React\Promise\resolve(null);
  19357. }
  19358. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  19359. {
  19360. return \React\Promise\resolve(null);
  19361. }
  19362. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  19363. {
  19364. $this->io->writeError(" - " . InstallOperation::format($package));
  19365. $repo->addPackage(clone $package);
  19366. return \React\Promise\resolve(null);
  19367. }
  19368. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  19369. {
  19370. if (!$repo->hasPackage($initial)) {
  19371. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  19372. }
  19373. $this->io->writeError(" - " . UpdateOperation::format($initial, $target));
  19374. $repo->removePackage($initial);
  19375. $repo->addPackage(clone $target);
  19376. return \React\Promise\resolve(null);
  19377. }
  19378. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  19379. {
  19380. if (!$repo->hasPackage($package)) {
  19381. throw new \InvalidArgumentException('Package is not installed: '.$package);
  19382. }
  19383. $this->io->writeError(" - " . UninstallOperation::format($package));
  19384. $repo->removePackage($package);
  19385. return \React\Promise\resolve(null);
  19386. }
  19387. public function getInstallPath(PackageInterface $package)
  19388. {
  19389. return '';
  19390. }
  19391. }
  19392. <?php declare(strict_types=1);
  19393. namespace Composer\Installer;
  19394. use Composer\Repository\InstalledRepositoryInterface;
  19395. use Composer\Package\PackageInterface;
  19396. class NoopInstaller implements InstallerInterface
  19397. {
  19398. public function supports(string $packageType)
  19399. {
  19400. return true;
  19401. }
  19402. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  19403. {
  19404. return $repo->hasPackage($package);
  19405. }
  19406. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  19407. {
  19408. return \React\Promise\resolve(null);
  19409. }
  19410. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  19411. {
  19412. return \React\Promise\resolve(null);
  19413. }
  19414. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  19415. {
  19416. return \React\Promise\resolve(null);
  19417. }
  19418. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  19419. {
  19420. if (!$repo->hasPackage($package)) {
  19421. $repo->addPackage(clone $package);
  19422. }
  19423. return \React\Promise\resolve(null);
  19424. }
  19425. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  19426. {
  19427. if (!$repo->hasPackage($initial)) {
  19428. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  19429. }
  19430. $repo->removePackage($initial);
  19431. if (!$repo->hasPackage($target)) {
  19432. $repo->addPackage(clone $target);
  19433. }
  19434. return \React\Promise\resolve(null);
  19435. }
  19436. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  19437. {
  19438. if (!$repo->hasPackage($package)) {
  19439. throw new \InvalidArgumentException('Package is not installed: '.$package);
  19440. }
  19441. $repo->removePackage($package);
  19442. return \React\Promise\resolve(null);
  19443. }
  19444. public function getInstallPath(PackageInterface $package)
  19445. {
  19446. $targetDir = $package->getTargetDir();
  19447. return $package->getPrettyName() . ($targetDir ? '/'.$targetDir : '');
  19448. }
  19449. }
  19450. <?php declare(strict_types=1);
  19451. namespace Composer\Installer;
  19452. use Composer\Composer;
  19453. use Composer\IO\IOInterface;
  19454. use Composer\DependencyResolver\Operation\OperationInterface;
  19455. use Composer\Repository\RepositoryInterface;
  19456. use Composer\EventDispatcher\Event;
  19457. class PackageEvent extends Event
  19458. {
  19459. private $composer;
  19460. private $io;
  19461. private $devMode;
  19462. private $localRepo;
  19463. private $operations;
  19464. private $operation;
  19465. public function __construct(string $eventName, Composer $composer, IOInterface $io, bool $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation)
  19466. {
  19467. parent::__construct($eventName);
  19468. $this->composer = $composer;
  19469. $this->io = $io;
  19470. $this->devMode = $devMode;
  19471. $this->localRepo = $localRepo;
  19472. $this->operations = $operations;
  19473. $this->operation = $operation;
  19474. }
  19475. public function getComposer(): Composer
  19476. {
  19477. return $this->composer;
  19478. }
  19479. public function getIO(): IOInterface
  19480. {
  19481. return $this->io;
  19482. }
  19483. public function isDevMode(): bool
  19484. {
  19485. return $this->devMode;
  19486. }
  19487. public function getLocalRepo(): RepositoryInterface
  19488. {
  19489. return $this->localRepo;
  19490. }
  19491. public function getOperations(): array
  19492. {
  19493. return $this->operations;
  19494. }
  19495. public function getOperation(): OperationInterface
  19496. {
  19497. return $this->operation;
  19498. }
  19499. }
  19500. <?php declare(strict_types=1);
  19501. namespace Composer\Installer;
  19502. class PackageEvents
  19503. {
  19504. public const PRE_PACKAGE_INSTALL = 'pre-package-install';
  19505. public const POST_PACKAGE_INSTALL = 'post-package-install';
  19506. public const PRE_PACKAGE_UPDATE = 'pre-package-update';
  19507. public const POST_PACKAGE_UPDATE = 'post-package-update';
  19508. public const PRE_PACKAGE_UNINSTALL = 'pre-package-uninstall';
  19509. public const POST_PACKAGE_UNINSTALL = 'post-package-uninstall';
  19510. }
  19511. <?php declare(strict_types=1);
  19512. namespace Composer\Installer;
  19513. use Composer\Composer;
  19514. use Composer\IO\IOInterface;
  19515. use Composer\PartialComposer;
  19516. use Composer\Repository\InstalledRepositoryInterface;
  19517. use Composer\Package\PackageInterface;
  19518. use Composer\Plugin\PluginManager;
  19519. use Composer\Util\Filesystem;
  19520. use Composer\Util\Platform;
  19521. use React\Promise\PromiseInterface;
  19522. class PluginInstaller extends LibraryInstaller
  19523. {
  19524. public function __construct(IOInterface $io, PartialComposer $composer, Filesystem $fs = null, BinaryInstaller $binaryInstaller = null)
  19525. {
  19526. parent::__construct($io, $composer, 'composer-plugin', $fs, $binaryInstaller);
  19527. }
  19528. public function supports(string $packageType)
  19529. {
  19530. return $packageType === 'composer-plugin' || $packageType === 'composer-installer';
  19531. }
  19532. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  19533. {
  19534. $extra = $package->getExtra();
  19535. if (empty($extra['class'])) {
  19536. throw new \UnexpectedValueException('Error while installing '.$package->getPrettyName().', composer-plugin packages should have a class defined in their extra key to be usable.');
  19537. }
  19538. return parent::download($package, $prevPackage);
  19539. }
  19540. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  19541. {
  19542. $promise = parent::install($repo, $package);
  19543. if (!$promise instanceof PromiseInterface) {
  19544. $promise = \React\Promise\resolve(null);
  19545. }
  19546. return $promise->then(function () use ($package, $repo): void {
  19547. try {
  19548. Platform::workaroundFilesystemIssues();
  19549. $this->getPluginManager()->registerPackage($package, true);
  19550. } catch (\Exception $e) {
  19551. $this->rollbackInstall($e, $repo, $package);
  19552. }
  19553. });
  19554. }
  19555. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  19556. {
  19557. $promise = parent::update($repo, $initial, $target);
  19558. if (!$promise instanceof PromiseInterface) {
  19559. $promise = \React\Promise\resolve(null);
  19560. }
  19561. return $promise->then(function () use ($initial, $target, $repo): void {
  19562. try {
  19563. Platform::workaroundFilesystemIssues();
  19564. $this->getPluginManager()->deactivatePackage($initial);
  19565. $this->getPluginManager()->registerPackage($target, true);
  19566. } catch (\Exception $e) {
  19567. $this->rollbackInstall($e, $repo, $target);
  19568. }
  19569. });
  19570. }
  19571. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  19572. {
  19573. $this->getPluginManager()->uninstallPackage($package);
  19574. return parent::uninstall($repo, $package);
  19575. }
  19576. private function rollbackInstall(\Exception $e, InstalledRepositoryInterface $repo, PackageInterface $package): void
  19577. {
  19578. $this->io->writeError('Plugin initialization failed ('.$e->getMessage().'), uninstalling plugin');
  19579. parent::uninstall($repo, $package);
  19580. throw $e;
  19581. }
  19582. protected function getPluginManager(): PluginManager
  19583. {
  19584. assert($this->composer instanceof Composer, new \LogicException(self::class.' should be initialized with a fully loaded Composer instance.'));
  19585. $pluginManager = $this->composer->getPluginManager();
  19586. return $pluginManager;
  19587. }
  19588. }
  19589. <?php declare(strict_types=1);
  19590. namespace Composer\Installer;
  19591. use React\Promise\PromiseInterface;
  19592. use Composer\Package\PackageInterface;
  19593. use Composer\Downloader\DownloadManager;
  19594. use Composer\Repository\InstalledRepositoryInterface;
  19595. use Composer\Util\Filesystem;
  19596. class ProjectInstaller implements InstallerInterface
  19597. {
  19598. private $installPath;
  19599. private $downloadManager;
  19600. private $filesystem;
  19601. public function __construct(string $installPath, DownloadManager $dm, Filesystem $fs)
  19602. {
  19603. $this->installPath = rtrim(strtr($installPath, '\\', '/'), '/').'/';
  19604. $this->downloadManager = $dm;
  19605. $this->filesystem = $fs;
  19606. }
  19607. public function supports(string $packageType): bool
  19608. {
  19609. return true;
  19610. }
  19611. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package): bool
  19612. {
  19613. return false;
  19614. }
  19615. public function download(PackageInterface $package, PackageInterface $prevPackage = null): ?PromiseInterface
  19616. {
  19617. $installPath = $this->installPath;
  19618. if (file_exists($installPath) && !$this->filesystem->isDirEmpty($installPath)) {
  19619. throw new \InvalidArgumentException("Project directory $installPath is not empty.");
  19620. }
  19621. if (!is_dir($installPath)) {
  19622. mkdir($installPath, 0777, true);
  19623. }
  19624. return $this->downloadManager->download($package, $installPath, $prevPackage);
  19625. }
  19626. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null): ?PromiseInterface
  19627. {
  19628. return $this->downloadManager->prepare($type, $package, $this->installPath, $prevPackage);
  19629. }
  19630. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null): ?PromiseInterface
  19631. {
  19632. return $this->downloadManager->cleanup($type, $package, $this->installPath, $prevPackage);
  19633. }
  19634. public function install(InstalledRepositoryInterface $repo, PackageInterface $package): ?PromiseInterface
  19635. {
  19636. return $this->downloadManager->install($package, $this->installPath);
  19637. }
  19638. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target): ?PromiseInterface
  19639. {
  19640. throw new \InvalidArgumentException("not supported");
  19641. }
  19642. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package): ?PromiseInterface
  19643. {
  19644. throw new \InvalidArgumentException("not supported");
  19645. }
  19646. public function getInstallPath(PackageInterface $package): string
  19647. {
  19648. return $this->installPath;
  19649. }
  19650. }
  19651. <?php declare(strict_types=1);
  19652. namespace Composer\Installer;
  19653. use Composer\IO\IOInterface;
  19654. use Composer\Package\PackageInterface;
  19655. use Composer\Pcre\Preg;
  19656. use Composer\Repository\InstalledRepository;
  19657. use Symfony\Component\Console\Formatter\OutputFormatter;
  19658. class SuggestedPackagesReporter
  19659. {
  19660. public const MODE_LIST = 1;
  19661. public const MODE_BY_PACKAGE = 2;
  19662. public const MODE_BY_SUGGESTION = 4;
  19663. protected $suggestedPackages = array();
  19664. private $io;
  19665. public function __construct(IOInterface $io)
  19666. {
  19667. $this->io = $io;
  19668. }
  19669. public function getPackages(): array
  19670. {
  19671. return $this->suggestedPackages;
  19672. }
  19673. public function addPackage(string $source, string $target, string $reason): SuggestedPackagesReporter
  19674. {
  19675. $this->suggestedPackages[] = array(
  19676. 'source' => $source,
  19677. 'target' => $target,
  19678. 'reason' => $reason,
  19679. );
  19680. return $this;
  19681. }
  19682. public function addSuggestionsFromPackage(PackageInterface $package): SuggestedPackagesReporter
  19683. {
  19684. $source = $package->getPrettyName();
  19685. foreach ($package->getSuggests() as $target => $reason) {
  19686. $this->addPackage(
  19687. $source,
  19688. $target,
  19689. $reason
  19690. );
  19691. }
  19692. return $this;
  19693. }
  19694. public function output(int $mode, InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null): void
  19695. {
  19696. $suggestedPackages = $this->getFilteredSuggestions($installedRepo, $onlyDependentsOf);
  19697. $suggesters = array();
  19698. $suggested = array();
  19699. foreach ($suggestedPackages as $suggestion) {
  19700. $suggesters[$suggestion['source']][$suggestion['target']] = $suggestion['reason'];
  19701. $suggested[$suggestion['target']][$suggestion['source']] = $suggestion['reason'];
  19702. }
  19703. ksort($suggesters);
  19704. ksort($suggested);
  19705. if ($mode & self::MODE_LIST) {
  19706. foreach (array_keys($suggested) as $name) {
  19707. $this->io->write(sprintf('<info>%s</info>', $name));
  19708. }
  19709. return;
  19710. }
  19711. if ($mode & self::MODE_BY_PACKAGE) {
  19712. foreach ($suggesters as $suggester => $suggestions) {
  19713. $this->io->write(sprintf('<comment>%s</comment> suggests:', $suggester));
  19714. foreach ($suggestions as $suggestion => $reason) {
  19715. $this->io->write(sprintf(' - <info>%s</info>' . ($reason ? ': %s' : ''), $suggestion, $this->escapeOutput($reason)));
  19716. }
  19717. $this->io->write('');
  19718. }
  19719. }
  19720. if ($mode & self::MODE_BY_SUGGESTION) {
  19721. if ($mode & self::MODE_BY_PACKAGE) {
  19722. $this->io->write(str_repeat('-', 78));
  19723. }
  19724. foreach ($suggested as $suggestion => $suggesters) {
  19725. $this->io->write(sprintf('<comment>%s</comment> is suggested by:', $suggestion));
  19726. foreach ($suggesters as $suggester => $reason) {
  19727. $this->io->write(sprintf(' - <info>%s</info>' . ($reason ? ': %s' : ''), $suggester, $this->escapeOutput($reason)));
  19728. }
  19729. $this->io->write('');
  19730. }
  19731. }
  19732. if ($onlyDependentsOf) {
  19733. $allSuggestedPackages = $this->getFilteredSuggestions($installedRepo);
  19734. $diff = count($allSuggestedPackages) - count($suggestedPackages);
  19735. if ($diff) {
  19736. $this->io->write('<info>'.$diff.' additional suggestions</info> by transitive dependencies can be shown with <info>--all</info>');
  19737. }
  19738. }
  19739. }
  19740. public function outputMinimalistic(InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null): void
  19741. {
  19742. $suggestedPackages = $this->getFilteredSuggestions($installedRepo, $onlyDependentsOf);
  19743. if ($suggestedPackages) {
  19744. $this->io->writeError('<info>'.count($suggestedPackages).' package suggestions were added by new dependencies, use `composer suggest` to see details.</info>');
  19745. }
  19746. }
  19747. private function getFilteredSuggestions(InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null): array
  19748. {
  19749. $suggestedPackages = $this->getPackages();
  19750. $installedNames = array();
  19751. if (null !== $installedRepo && !empty($suggestedPackages)) {
  19752. foreach ($installedRepo->getPackages() as $package) {
  19753. $installedNames = array_merge(
  19754. $installedNames,
  19755. $package->getNames()
  19756. );
  19757. }
  19758. }
  19759. $sourceFilter = array();
  19760. if ($onlyDependentsOf) {
  19761. $sourceFilter = array_map(function ($link): string {
  19762. return $link->getTarget();
  19763. }, array_merge($onlyDependentsOf->getRequires(), $onlyDependentsOf->getDevRequires()));
  19764. $sourceFilter[] = $onlyDependentsOf->getName();
  19765. }
  19766. $suggestions = array();
  19767. foreach ($suggestedPackages as $suggestion) {
  19768. if (in_array($suggestion['target'], $installedNames) || ($sourceFilter && !in_array($suggestion['source'], $sourceFilter))) {
  19769. continue;
  19770. }
  19771. $suggestions[] = $suggestion;
  19772. }
  19773. return $suggestions;
  19774. }
  19775. private function escapeOutput(string $string): string
  19776. {
  19777. return OutputFormatter::escape(
  19778. $this->removeControlCharacters($string)
  19779. );
  19780. }
  19781. private function removeControlCharacters(string $string): string
  19782. {
  19783. return Preg::replace(
  19784. '/[[:cntrl:]]/',
  19785. '',
  19786. str_replace("\n", ' ', $string)
  19787. );
  19788. }
  19789. }
  19790. <?php declare(strict_types=1);
  19791. namespace Composer\Json;
  19792. use Composer\Pcre\Preg;
  19793. use JsonSchema\Validator;
  19794. use Seld\JsonLint\JsonParser;
  19795. use Seld\JsonLint\ParsingException;
  19796. use Composer\Util\HttpDownloader;
  19797. use Composer\IO\IOInterface;
  19798. use Composer\Downloader\TransportException;
  19799. class JsonFile
  19800. {
  19801. public const LAX_SCHEMA = 1;
  19802. public const STRICT_SCHEMA = 2;
  19803. public const AUTH_SCHEMA = 3;
  19804. public const JSON_UNESCAPED_SLASHES = 64;
  19805. public const JSON_PRETTY_PRINT = 128;
  19806. public const JSON_UNESCAPED_UNICODE = 256;
  19807. public const COMPOSER_SCHEMA_PATH = __DIR__ . '/../../../res/composer-schema.json';
  19808. private $path;
  19809. private $httpDownloader;
  19810. private $io;
  19811. public function __construct(string $path, HttpDownloader $httpDownloader = null, IOInterface $io = null)
  19812. {
  19813. $this->path = $path;
  19814. if (null === $httpDownloader && Preg::isMatch('{^https?://}i', $path)) {
  19815. throw new \InvalidArgumentException('http urls require a HttpDownloader instance to be passed');
  19816. }
  19817. $this->httpDownloader = $httpDownloader;
  19818. $this->io = $io;
  19819. }
  19820. public function getPath(): string
  19821. {
  19822. return $this->path;
  19823. }
  19824. public function exists(): bool
  19825. {
  19826. return is_file($this->path);
  19827. }
  19828. public function read()
  19829. {
  19830. try {
  19831. if ($this->httpDownloader) {
  19832. $json = $this->httpDownloader->get($this->path)->getBody();
  19833. } else {
  19834. if ($this->io && $this->io->isDebug()) {
  19835. $realpathInfo = '';
  19836. $realpath = realpath($this->path);
  19837. if (false !== $realpath && $realpath !== $this->path) {
  19838. $realpathInfo = ' (' . $realpath . ')';
  19839. }
  19840. $this->io->writeError('Reading ' . $this->path . $realpathInfo);
  19841. }
  19842. $json = file_get_contents($this->path);
  19843. }
  19844. } catch (TransportException $e) {
  19845. throw new \RuntimeException($e->getMessage(), 0, $e);
  19846. } catch (\Exception $e) {
  19847. throw new \RuntimeException('Could not read '.$this->path."\n\n".$e->getMessage());
  19848. }
  19849. return static::parseJson($json, $this->path);
  19850. }
  19851. public function write(array $hash, int $options = JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)
  19852. {
  19853. if ($this->path === 'php://memory') {
  19854. file_put_contents($this->path, static::encode($hash, $options));
  19855. return;
  19856. }
  19857. $dir = dirname($this->path);
  19858. if (!is_dir($dir)) {
  19859. if (file_exists($dir)) {
  19860. throw new \UnexpectedValueException(
  19861. realpath($dir).' exists and is not a directory.'
  19862. );
  19863. }
  19864. if (!@mkdir($dir, 0777, true)) {
  19865. throw new \UnexpectedValueException(
  19866. $dir.' does not exist and could not be created.'
  19867. );
  19868. }
  19869. }
  19870. $retries = 3;
  19871. while ($retries--) {
  19872. try {
  19873. $this->filePutContentsIfModified($this->path, static::encode($hash, $options). ($options & JSON_PRETTY_PRINT ? "\n" : ''));
  19874. break;
  19875. } catch (\Exception $e) {
  19876. if ($retries > 0) {
  19877. usleep(500000);
  19878. continue;
  19879. }
  19880. throw $e;
  19881. }
  19882. }
  19883. }
  19884. private function filePutContentsIfModified(string $path, string $content)
  19885. {
  19886. $currentContent = @file_get_contents($path);
  19887. if (!$currentContent || ($currentContent != $content)) {
  19888. return file_put_contents($path, $content);
  19889. }
  19890. return 0;
  19891. }
  19892. public function validateSchema(int $schema = self::STRICT_SCHEMA, ?string $schemaFile = null): bool
  19893. {
  19894. $content = file_get_contents($this->path);
  19895. $data = json_decode($content);
  19896. if (null === $data && 'null' !== $content) {
  19897. self::validateSyntax($content, $this->path);
  19898. }
  19899. return self::validateJsonSchema($this->path, $data, $schema, $schemaFile);
  19900. }
  19901. public static function validateJsonSchema(string $source, $data, int $schema, ?string $schemaFile = null): bool
  19902. {
  19903. $isComposerSchemaFile = false;
  19904. if (null === $schemaFile) {
  19905. $isComposerSchemaFile = true;
  19906. $schemaFile = self::COMPOSER_SCHEMA_PATH;
  19907. }
  19908. if (false === strpos($schemaFile, '://')) {
  19909. $schemaFile = 'file://' . $schemaFile;
  19910. }
  19911. $schemaData = (object) array('$ref' => $schemaFile);
  19912. if ($schema === self::LAX_SCHEMA) {
  19913. $schemaData->additionalProperties = true;
  19914. $schemaData->required = array();
  19915. } elseif ($schema === self::STRICT_SCHEMA && $isComposerSchemaFile) {
  19916. $schemaData->additionalProperties = false;
  19917. $schemaData->required = array('name', 'description');
  19918. } elseif ($schema === self::AUTH_SCHEMA && $isComposerSchemaFile) {
  19919. $schemaData = (object) array('$ref' => $schemaFile.'#/properties/config', '$schema'=> "https://json-schema.org/draft-04/schema#");
  19920. }
  19921. $validator = new Validator();
  19922. $validator->check($data, $schemaData);
  19923. if (!$validator->isValid()) {
  19924. $errors = array();
  19925. foreach ((array) $validator->getErrors() as $error) {
  19926. $errors[] = ($error['property'] ? $error['property'].' : ' : '').$error['message'];
  19927. }
  19928. throw new JsonValidationException('"'.$source.'" does not match the expected JSON schema', $errors);
  19929. }
  19930. return true;
  19931. }
  19932. public static function encode($data, int $options = 448)
  19933. {
  19934. $json = json_encode($data, $options);
  19935. if (false === $json) {
  19936. self::throwEncodeError(json_last_error());
  19937. }
  19938. return $json;
  19939. }
  19940. private static function throwEncodeError(int $code): void
  19941. {
  19942. switch ($code) {
  19943. case JSON_ERROR_DEPTH:
  19944. $msg = 'Maximum stack depth exceeded';
  19945. break;
  19946. case JSON_ERROR_STATE_MISMATCH:
  19947. $msg = 'Underflow or the modes mismatch';
  19948. break;
  19949. case JSON_ERROR_CTRL_CHAR:
  19950. $msg = 'Unexpected control character found';
  19951. break;
  19952. case JSON_ERROR_UTF8:
  19953. $msg = 'Malformed UTF-8 characters, possibly incorrectly encoded';
  19954. break;
  19955. default:
  19956. $msg = 'Unknown error';
  19957. }
  19958. throw new \RuntimeException('JSON encoding failed: '.$msg);
  19959. }
  19960. public static function parseJson(?string $json, string $file = null)
  19961. {
  19962. if (null === $json) {
  19963. return null;
  19964. }
  19965. $data = json_decode($json, true);
  19966. if (null === $data && JSON_ERROR_NONE !== json_last_error()) {
  19967. self::validateSyntax($json, $file);
  19968. }
  19969. return $data;
  19970. }
  19971. protected static function validateSyntax(string $json, string $file = null): bool
  19972. {
  19973. $parser = new JsonParser();
  19974. $result = $parser->lint($json);
  19975. if (null === $result) {
  19976. if (defined('JSON_ERROR_UTF8') && JSON_ERROR_UTF8 === json_last_error()) {
  19977. throw new \UnexpectedValueException('"'.$file.'" is not UTF-8, could not parse as JSON');
  19978. }
  19979. return true;
  19980. }
  19981. throw new ParsingException('"'.$file.'" does not contain valid JSON'."\n".$result->getMessage(), $result->getDetails());
  19982. }
  19983. }
  19984. <?php declare(strict_types=1);
  19985. namespace Composer\Json;
  19986. use Composer\Pcre\Preg;
  19987. class JsonFormatter
  19988. {
  19989. public static function format(string $json, bool $unescapeUnicode, bool $unescapeSlashes): string
  19990. {
  19991. $result = '';
  19992. $pos = 0;
  19993. $strLen = strlen($json);
  19994. $indentStr = ' ';
  19995. $newLine = "\n";
  19996. $outOfQuotes = true;
  19997. $buffer = '';
  19998. $noescape = true;
  19999. for ($i = 0; $i < $strLen; $i++) {
  20000. $char = substr($json, $i, 1);
  20001. if ('"' === $char && $noescape) {
  20002. $outOfQuotes = !$outOfQuotes;
  20003. }
  20004. if (!$outOfQuotes) {
  20005. $buffer .= $char;
  20006. $noescape = '\\' === $char ? !$noescape : true;
  20007. continue;
  20008. }
  20009. if ('' !== $buffer) {
  20010. if ($unescapeSlashes) {
  20011. $buffer = str_replace('\\/', '/', $buffer);
  20012. }
  20013. if ($unescapeUnicode && function_exists('mb_convert_encoding')) {
  20014. $buffer = Preg::replaceCallback('/(\\\\+)u([0-9a-f]{4})/i', function ($match) {
  20015. $l = strlen($match[1]);
  20016. if ($l % 2) {
  20017. $code = hexdec($match[2]);
  20018. if (0xD800 <= $code && 0xDFFF >= $code) {
  20019. return $match[0];
  20020. }
  20021. return str_repeat('\\', $l - 1) . mb_convert_encoding(
  20022. pack('H*', $match[2]),
  20023. 'UTF-8',
  20024. 'UCS-2BE'
  20025. );
  20026. }
  20027. return $match[0];
  20028. }, $buffer);
  20029. }
  20030. $result .= $buffer.$char;
  20031. $buffer = '';
  20032. continue;
  20033. }
  20034. if (':' === $char) {
  20035. $char .= ' ';
  20036. } elseif ('}' === $char || ']' === $char) {
  20037. $pos--;
  20038. $prevChar = substr($json, $i - 1, 1);
  20039. if ('{' !== $prevChar && '[' !== $prevChar) {
  20040. $result .= $newLine;
  20041. for ($j = 0; $j < $pos; $j++) {
  20042. $result .= $indentStr;
  20043. }
  20044. } else {
  20045. $result = rtrim($result);
  20046. }
  20047. }
  20048. $result .= $char;
  20049. if (',' === $char || '{' === $char || '[' === $char) {
  20050. $result .= $newLine;
  20051. if ('{' === $char || '[' === $char) {
  20052. $pos++;
  20053. }
  20054. for ($j = 0; $j < $pos; $j++) {
  20055. $result .= $indentStr;
  20056. }
  20057. }
  20058. }
  20059. return $result;
  20060. }
  20061. }
  20062. <?php declare(strict_types=1);
  20063. namespace Composer\Json;
  20064. use Composer\Pcre\Preg;
  20065. use Composer\Repository\PlatformRepository;
  20066. class JsonManipulator
  20067. {
  20068. private static $DEFINES = '(?(DEFINE)
  20069. (?<number> -? (?= [1-9]|0(?!\d) ) \d++ (\.\d++)? ([eE] [+-]?+ \d++)? )
  20070. (?<boolean> true | false | null )
  20071. (?<string> " ([^"\\\\]*+ | \\\\ ["\\\\bfnrt\/] | \\\\ u [0-9A-Fa-f]{4} )* " )
  20072. (?<array> \[ (?: (?&json) \s*+ (?: , (?&json) \s*+ )*+ )?+ \s*+ \] )
  20073. (?<pair> \s*+ (?&string) \s*+ : (?&json) \s*+ )
  20074. (?<object> \{ (?: (?&pair) (?: , (?&pair) )*+ )?+ \s*+ \} )
  20075. (?<json> \s*+ (?: (?&number) | (?&boolean) | (?&string) | (?&array) | (?&object) ) )
  20076. )';
  20077. private $contents;
  20078. private $newline;
  20079. private $indent;
  20080. public function __construct(string $contents)
  20081. {
  20082. $contents = trim($contents);
  20083. if ($contents === '') {
  20084. $contents = '{}';
  20085. }
  20086. if (!Preg::isMatch('#^\{(.*)\}$#s', $contents)) {
  20087. throw new \InvalidArgumentException('The json file must be an object ({})');
  20088. }
  20089. $this->newline = false !== strpos($contents, "\r\n") ? "\r\n" : "\n";
  20090. $this->contents = $contents === '{}' ? '{' . $this->newline . '}' : $contents;
  20091. $this->detectIndenting();
  20092. }
  20093. public function getContents(): string
  20094. {
  20095. return $this->contents . $this->newline;
  20096. }
  20097. public function addLink(string $type, string $package, string $constraint, bool $sortPackages = false): bool
  20098. {
  20099. $decoded = JsonFile::parseJson($this->contents);
  20100. if (!isset($decoded[$type])) {
  20101. return $this->addMainKey($type, array($package => $constraint));
  20102. }
  20103. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  20104. '(?P<property>'.preg_quote(JsonFile::encode($type)).'\s*:\s*)(?P<value>(?&json))(?P<end>.*)}sx';
  20105. if (!Preg::isMatch($regex, $this->contents, $matches)) {
  20106. return false;
  20107. }
  20108. $links = $matches['value'];
  20109. $packageRegex = str_replace('/', '\\\\?/', preg_quote($package));
  20110. $regex = '{'.self::$DEFINES.'"(?P<package>'.$packageRegex.')"(\s*:\s*)(?&string)}ix';
  20111. if (Preg::isMatch($regex, $links, $packageMatches)) {
  20112. $existingPackage = $packageMatches['package'];
  20113. $packageRegex = str_replace('/', '\\\\?/', preg_quote($existingPackage));
  20114. $links = Preg::replaceCallback('{'.self::$DEFINES.'"'.$packageRegex.'"(?P<separator>\s*:\s*)(?&string)}ix', function ($m) use ($existingPackage, $constraint): string {
  20115. return JsonFile::encode(str_replace('\\/', '/', $existingPackage)) . $m['separator'] . '"' . $constraint . '"';
  20116. }, $links);
  20117. } else {
  20118. if (Preg::isMatch('#^\s*\{\s*\S+.*?(\s*\}\s*)$#s', $links, $match)) {
  20119. $links = Preg::replace(
  20120. '{'.preg_quote($match[1]).'$}',
  20121. addcslashes(',' . $this->newline . $this->indent . $this->indent . JsonFile::encode($package).': '.JsonFile::encode($constraint) . $match[1], '\\$'),
  20122. $links
  20123. );
  20124. } else {
  20125. $links = '{' . $this->newline .
  20126. $this->indent . $this->indent . JsonFile::encode($package).': '.JsonFile::encode($constraint) . $this->newline .
  20127. $this->indent . '}';
  20128. }
  20129. }
  20130. if (true === $sortPackages) {
  20131. $requirements = json_decode($links, true);
  20132. $this->sortPackages($requirements);
  20133. $links = $this->format($requirements);
  20134. }
  20135. $this->contents = $matches['start'] . $matches['property'] . $links . $matches['end'];
  20136. return true;
  20137. }
  20138. private function sortPackages(array &$packages = array()): void
  20139. {
  20140. $prefix = function ($requirement): string {
  20141. if (PlatformRepository::isPlatformPackage($requirement)) {
  20142. return Preg::replace(
  20143. array(
  20144. '/^php/',
  20145. '/^hhvm/',
  20146. '/^ext/',
  20147. '/^lib/',
  20148. '/^\D/',
  20149. ),
  20150. array(
  20151. '0-$0',
  20152. '1-$0',
  20153. '2-$0',
  20154. '3-$0',
  20155. '4-$0',
  20156. ),
  20157. $requirement
  20158. );
  20159. }
  20160. return '5-'.$requirement;
  20161. };
  20162. uksort($packages, function ($a, $b) use ($prefix): int {
  20163. return strnatcmp($prefix($a), $prefix($b));
  20164. });
  20165. }
  20166. public function addRepository(string $name, $config, bool $append = true): bool
  20167. {
  20168. return $this->addSubNode('repositories', $name, $config, $append);
  20169. }
  20170. public function removeRepository(string $name): bool
  20171. {
  20172. return $this->removeSubNode('repositories', $name);
  20173. }
  20174. public function addConfigSetting(string $name, $value): bool
  20175. {
  20176. return $this->addSubNode('config', $name, $value);
  20177. }
  20178. public function removeConfigSetting(string $name): bool
  20179. {
  20180. return $this->removeSubNode('config', $name);
  20181. }
  20182. public function addProperty(string $name, $value): bool
  20183. {
  20184. if (strpos($name, 'suggest.') === 0) {
  20185. return $this->addSubNode('suggest', substr($name, 8), $value);
  20186. }
  20187. if (strpos($name, 'extra.') === 0) {
  20188. return $this->addSubNode('extra', substr($name, 6), $value);
  20189. }
  20190. if (strpos($name, 'scripts.') === 0) {
  20191. return $this->addSubNode('scripts', substr($name, 8), $value);
  20192. }
  20193. return $this->addMainKey($name, $value);
  20194. }
  20195. public function removeProperty(string $name): bool
  20196. {
  20197. if (strpos($name, 'suggest.') === 0) {
  20198. return $this->removeSubNode('suggest', substr($name, 8));
  20199. }
  20200. if (strpos($name, 'extra.') === 0) {
  20201. return $this->removeSubNode('extra', substr($name, 6));
  20202. }
  20203. if (strpos($name, 'scripts.') === 0) {
  20204. return $this->removeSubNode('scripts', substr($name, 8));
  20205. }
  20206. return $this->removeMainKey($name);
  20207. }
  20208. public function addSubNode(string $mainNode, string $name, $value, bool $append = true): bool
  20209. {
  20210. $decoded = JsonFile::parseJson($this->contents);
  20211. $subName = null;
  20212. if (in_array($mainNode, array('config', 'extra', 'scripts')) && false !== strpos($name, '.')) {
  20213. list($name, $subName) = explode('.', $name, 2);
  20214. }
  20215. if (!isset($decoded[$mainNode])) {
  20216. if ($subName !== null) {
  20217. $this->addMainKey($mainNode, array($name => array($subName => $value)));
  20218. } else {
  20219. $this->addMainKey($mainNode, array($name => $value));
  20220. }
  20221. return true;
  20222. }
  20223. $nodeRegex = '{'.self::$DEFINES.'^(?P<start> \s* \{ \s* (?: (?&string) \s* : (?&json) \s* , \s* )*?'.
  20224. preg_quote(JsonFile::encode($mainNode)).'\s*:\s*)(?P<content>(?&object))(?P<end>.*)}sx';
  20225. try {
  20226. if (!Preg::isMatch($nodeRegex, $this->contents, $match)) {
  20227. return false;
  20228. }
  20229. } catch (\RuntimeException $e) {
  20230. if ($e->getCode() === PREG_BACKTRACK_LIMIT_ERROR) {
  20231. return false;
  20232. }
  20233. throw $e;
  20234. }
  20235. $children = $match['content'];
  20236. if (!@json_decode($children)) {
  20237. return false;
  20238. }
  20239. $childRegex = '{'.self::$DEFINES.'(?P<start>"'.preg_quote($name).'"\s*:\s*)(?P<content>(?&json))(?P<end>,?)}x';
  20240. if (Preg::isMatch($childRegex, $children, $matches)) {
  20241. $children = Preg::replaceCallback($childRegex, function ($matches) use ($subName, $value): string {
  20242. if ($subName !== null) {
  20243. $curVal = json_decode($matches['content'], true);
  20244. if (!is_array($curVal)) {
  20245. $curVal = array();
  20246. }
  20247. $curVal[$subName] = $value;
  20248. $value = $curVal;
  20249. }
  20250. return $matches['start'] . $this->format($value, 1) . $matches['end'];
  20251. }, $children);
  20252. } else {
  20253. Preg::match('#^{ (?P<leadingspace>\s*?) (?P<content>\S+.*?)? (?P<trailingspace>\s*) }$#sx', $children, $match);
  20254. $whitespace = '';
  20255. if (!empty($match['trailingspace'])) {
  20256. $whitespace = $match['trailingspace'];
  20257. }
  20258. if (!empty($match['content'])) {
  20259. if ($subName !== null) {
  20260. $value = array($subName => $value);
  20261. }
  20262. if ($append) {
  20263. $children = Preg::replace(
  20264. '#'.$whitespace.'}$#',
  20265. addcslashes(',' . $this->newline . $this->indent . $this->indent . JsonFile::encode($name).': '.$this->format($value, 1) . $whitespace . '}', '\\$'),
  20266. $children
  20267. );
  20268. } else {
  20269. $whitespace = '';
  20270. if (!empty($match['leadingspace'])) {
  20271. $whitespace = $match['leadingspace'];
  20272. }
  20273. $children = Preg::replace(
  20274. '#^{'.$whitespace.'#',
  20275. addcslashes('{' . $whitespace . JsonFile::encode($name).': '.$this->format($value, 1) . ',' . $this->newline . $this->indent . $this->indent, '\\$'),
  20276. $children
  20277. );
  20278. }
  20279. } else {
  20280. if ($subName !== null) {
  20281. $value = array($subName => $value);
  20282. }
  20283. $children = '{' . $this->newline . $this->indent . $this->indent . JsonFile::encode($name).': '.$this->format($value, 1) . $whitespace . '}';
  20284. }
  20285. }
  20286. $this->contents = Preg::replaceCallback($nodeRegex, function ($m) use ($children): string {
  20287. return $m['start'] . $children . $m['end'];
  20288. }, $this->contents);
  20289. return true;
  20290. }
  20291. public function removeSubNode(string $mainNode, string $name): bool
  20292. {
  20293. $decoded = JsonFile::parseJson($this->contents);
  20294. if (empty($decoded[$mainNode])) {
  20295. return true;
  20296. }
  20297. $nodeRegex = '{'.self::$DEFINES.'^(?P<start> \s* \{ \s* (?: (?&string) \s* : (?&json) \s* , \s* )*?'.
  20298. preg_quote(JsonFile::encode($mainNode)).'\s*:\s*)(?P<content>(?&object))(?P<end>.*)}sx';
  20299. try {
  20300. if (!Preg::isMatch($nodeRegex, $this->contents, $match)) {
  20301. return false;
  20302. }
  20303. } catch (\RuntimeException $e) {
  20304. if ($e->getCode() === PREG_BACKTRACK_LIMIT_ERROR) {
  20305. return false;
  20306. }
  20307. throw $e;
  20308. }
  20309. $children = $match['content'];
  20310. if (!@json_decode($children, true)) {
  20311. return false;
  20312. }
  20313. $subName = null;
  20314. if (in_array($mainNode, array('config', 'extra', 'scripts')) && false !== strpos($name, '.')) {
  20315. list($name, $subName) = explode('.', $name, 2);
  20316. }
  20317. if (!isset($decoded[$mainNode][$name]) || ($subName && !isset($decoded[$mainNode][$name][$subName]))) {
  20318. return true;
  20319. }
  20320. $keyRegex = str_replace('/', '\\\\?/', preg_quote($name));
  20321. if (Preg::isMatch('{"'.$keyRegex.'"\s*:}i', $children)) {
  20322. if (Preg::isMatchAll('{'.self::$DEFINES.'"'.$keyRegex.'"\s*:\s*(?:(?&json))}x', $children, $matches)) {
  20323. $bestMatch = '';
  20324. foreach ($matches[0] as $match) {
  20325. if (strlen($bestMatch) < strlen($match)) {
  20326. $bestMatch = $match;
  20327. }
  20328. }
  20329. $childrenClean = Preg::replace('{,\s*'.preg_quote($bestMatch).'}i', '', $children, -1, $count);
  20330. if (1 !== $count) {
  20331. $childrenClean = Preg::replace('{'.preg_quote($bestMatch).'\s*,?\s*}i', '', $childrenClean, -1, $count);
  20332. if (1 !== $count) {
  20333. return false;
  20334. }
  20335. }
  20336. }
  20337. } else {
  20338. $childrenClean = $children;
  20339. }
  20340. if (!isset($childrenClean)) {
  20341. throw new \InvalidArgumentException("JsonManipulator: \$childrenClean is not defined. Please report at https://github.com/composer/composer/issues/new.");
  20342. }
  20343. unset($match);
  20344. Preg::match('#^{ \s*? (?P<content>\S+.*?)? (?P<trailingspace>\s*) }$#sx', $childrenClean, $match);
  20345. if (empty($match['content'])) {
  20346. $newline = $this->newline;
  20347. $indent = $this->indent;
  20348. $this->contents = Preg::replaceCallback($nodeRegex, function ($matches) use ($indent, $newline): string {
  20349. return $matches['start'] . '{' . $newline . $indent . '}' . $matches['end'];
  20350. }, $this->contents);
  20351. if ($subName !== null) {
  20352. $curVal = json_decode($children, true);
  20353. unset($curVal[$name][$subName]);
  20354. $this->addSubNode($mainNode, $name, $curVal[$name]);
  20355. }
  20356. return true;
  20357. }
  20358. $this->contents = Preg::replaceCallback($nodeRegex, function ($matches) use ($name, $subName, $childrenClean): string {
  20359. if ($subName !== null) {
  20360. $curVal = json_decode($matches['content'], true);
  20361. unset($curVal[$name][$subName]);
  20362. $childrenClean = $this->format($curVal);
  20363. }
  20364. return $matches['start'] . $childrenClean . $matches['end'];
  20365. }, $this->contents);
  20366. return true;
  20367. }
  20368. public function addMainKey(string $key, $content): bool
  20369. {
  20370. $decoded = JsonFile::parseJson($this->contents);
  20371. $content = $this->format($content);
  20372. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  20373. '(?P<key>'.preg_quote(JsonFile::encode($key)).'\s*:\s*(?&json))(?P<end>.*)}sx';
  20374. if (isset($decoded[$key]) && Preg::isMatch($regex, $this->contents, $matches)) {
  20375. if (!@json_decode('{'.$matches['key'].'}')) {
  20376. return false;
  20377. }
  20378. $this->contents = $matches['start'] . JsonFile::encode($key).': '.$content . $matches['end'];
  20379. return true;
  20380. }
  20381. if (Preg::isMatch('#[^{\s](\s*)\}$#', $this->contents, $match)) {
  20382. $this->contents = Preg::replace(
  20383. '#'.$match[1].'\}$#',
  20384. addcslashes(',' . $this->newline . $this->indent . JsonFile::encode($key). ': '. $content . $this->newline . '}', '\\$'),
  20385. $this->contents
  20386. );
  20387. return true;
  20388. }
  20389. $this->contents = Preg::replace(
  20390. '#\}$#',
  20391. addcslashes($this->indent . JsonFile::encode($key). ': '.$content . $this->newline . '}', '\\$'),
  20392. $this->contents
  20393. );
  20394. return true;
  20395. }
  20396. public function removeMainKey(string $key): bool
  20397. {
  20398. $decoded = JsonFile::parseJson($this->contents);
  20399. if (!array_key_exists($key, $decoded)) {
  20400. return true;
  20401. }
  20402. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  20403. '(?P<removal>'.preg_quote(JsonFile::encode($key)).'\s*:\s*(?&json))\s*,?\s*(?P<end>.*)}sx';
  20404. if (Preg::isMatch($regex, $this->contents, $matches)) {
  20405. if (!@json_decode('{'.$matches['removal'].'}')) {
  20406. return false;
  20407. }
  20408. if (Preg::isMatch('#,\s*$#', $matches['start']) && Preg::isMatch('#^\}$#', $matches['end'])) {
  20409. $matches['start'] = rtrim(Preg::replace('#,(\s*)$#', '$1', $matches['start']), $this->indent);
  20410. }
  20411. $this->contents = $matches['start'] . $matches['end'];
  20412. if (Preg::isMatch('#^\{\s*\}\s*$#', $this->contents)) {
  20413. $this->contents = "{\n}";
  20414. }
  20415. return true;
  20416. }
  20417. return false;
  20418. }
  20419. public function removeMainKeyIfEmpty(string $key): bool
  20420. {
  20421. $decoded = JsonFile::parseJson($this->contents);
  20422. if (!array_key_exists($key, $decoded)) {
  20423. return true;
  20424. }
  20425. if (is_array($decoded[$key]) && count($decoded[$key]) === 0) {
  20426. return $this->removeMainKey($key);
  20427. }
  20428. return true;
  20429. }
  20430. public function format($data, int $depth = 0): string
  20431. {
  20432. if (is_array($data)) {
  20433. reset($data);
  20434. if (is_numeric(key($data))) {
  20435. foreach ($data as $key => $val) {
  20436. $data[$key] = $this->format($val, $depth + 1);
  20437. }
  20438. return '['.implode(', ', $data).']';
  20439. }
  20440. $out = '{' . $this->newline;
  20441. $elems = array();
  20442. foreach ($data as $key => $val) {
  20443. $elems[] = str_repeat($this->indent, $depth + 2) . JsonFile::encode($key). ': '.$this->format($val, $depth + 1);
  20444. }
  20445. return $out . implode(','.$this->newline, $elems) . $this->newline . str_repeat($this->indent, $depth + 1) . '}';
  20446. }
  20447. return JsonFile::encode($data);
  20448. }
  20449. protected function detectIndenting(): void
  20450. {
  20451. if (Preg::isMatch('{^([ \t]+)"}m', $this->contents, $match)) {
  20452. $this->indent = $match[1];
  20453. } else {
  20454. $this->indent = ' ';
  20455. }
  20456. }
  20457. }
  20458. <?php declare(strict_types=1);
  20459. namespace Composer\Json;
  20460. use Exception;
  20461. class JsonValidationException extends Exception
  20462. {
  20463. protected $errors;
  20464. public function __construct(string $message, array $errors = array(), Exception $previous = null)
  20465. {
  20466. $this->errors = $errors;
  20467. parent::__construct((string) $message, 0, $previous);
  20468. }
  20469. public function getErrors(): array
  20470. {
  20471. return $this->errors;
  20472. }
  20473. }
  20474. <?php declare(strict_types=1);
  20475. namespace Composer\Package;
  20476. use Composer\Semver\Constraint\Constraint;
  20477. use Composer\Package\Version\VersionParser;
  20478. class AliasPackage extends BasePackage
  20479. {
  20480. protected $version;
  20481. protected $prettyVersion;
  20482. protected $dev;
  20483. protected $rootPackageAlias = false;
  20484. protected $stability;
  20485. protected $hasSelfVersionRequires = false;
  20486. protected $aliasOf;
  20487. protected $requires;
  20488. protected $devRequires;
  20489. protected $conflicts;
  20490. protected $provides;
  20491. protected $replaces;
  20492. public function __construct(BasePackage $aliasOf, string $version, string $prettyVersion)
  20493. {
  20494. parent::__construct($aliasOf->getName());
  20495. $this->version = $version;
  20496. $this->prettyVersion = $prettyVersion;
  20497. $this->aliasOf = $aliasOf;
  20498. $this->stability = VersionParser::parseStability($version);
  20499. $this->dev = $this->stability === 'dev';
  20500. foreach (Link::$TYPES as $type) {
  20501. $links = $aliasOf->{'get' . ucfirst($type)}();
  20502. $this->$type = $this->replaceSelfVersionDependencies($links, $type);
  20503. }
  20504. }
  20505. public function getAliasOf()
  20506. {
  20507. return $this->aliasOf;
  20508. }
  20509. public function getVersion(): string
  20510. {
  20511. return $this->version;
  20512. }
  20513. public function getStability(): string
  20514. {
  20515. return $this->stability;
  20516. }
  20517. public function getPrettyVersion(): string
  20518. {
  20519. return $this->prettyVersion;
  20520. }
  20521. public function isDev(): bool
  20522. {
  20523. return $this->dev;
  20524. }
  20525. public function getRequires(): array
  20526. {
  20527. return $this->requires;
  20528. }
  20529. public function getConflicts(): array
  20530. {
  20531. return $this->conflicts;
  20532. }
  20533. public function getProvides(): array
  20534. {
  20535. return $this->provides;
  20536. }
  20537. public function getReplaces(): array
  20538. {
  20539. return $this->replaces;
  20540. }
  20541. public function getDevRequires(): array
  20542. {
  20543. return $this->devRequires;
  20544. }
  20545. public function setRootPackageAlias(bool $value): void
  20546. {
  20547. $this->rootPackageAlias = $value;
  20548. }
  20549. public function isRootPackageAlias(): bool
  20550. {
  20551. return $this->rootPackageAlias;
  20552. }
  20553. protected function replaceSelfVersionDependencies(array $links, $linkType): array
  20554. {
  20555. $prettyVersion = $this->prettyVersion;
  20556. if ($prettyVersion === VersionParser::DEFAULT_BRANCH_ALIAS) {
  20557. $prettyVersion = $this->aliasOf->getPrettyVersion();
  20558. }
  20559. if (\in_array($linkType, array(Link::TYPE_CONFLICT, Link::TYPE_PROVIDE, Link::TYPE_REPLACE), true)) {
  20560. $newLinks = array();
  20561. foreach ($links as $link) {
  20562. if ('self.version' === $link->getPrettyConstraint()) {
  20563. $newLinks[] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);
  20564. $constraint->setPrettyString($prettyVersion);
  20565. }
  20566. }
  20567. $links = array_merge($links, $newLinks);
  20568. } else {
  20569. foreach ($links as $index => $link) {
  20570. if ('self.version' === $link->getPrettyConstraint()) {
  20571. if ($linkType === Link::TYPE_REQUIRE) {
  20572. $this->hasSelfVersionRequires = true;
  20573. }
  20574. $links[$index] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);
  20575. $constraint->setPrettyString($prettyVersion);
  20576. }
  20577. }
  20578. }
  20579. return $links;
  20580. }
  20581. public function hasSelfVersionRequires(): bool
  20582. {
  20583. return $this->hasSelfVersionRequires;
  20584. }
  20585. public function __toString(): string
  20586. {
  20587. return parent::__toString().' ('.($this->rootPackageAlias ? 'root ' : ''). 'alias of '.$this->aliasOf->getVersion().')';
  20588. }
  20589. public function getType(): string
  20590. {
  20591. return $this->aliasOf->getType();
  20592. }
  20593. public function getTargetDir(): ?string
  20594. {
  20595. return $this->aliasOf->getTargetDir();
  20596. }
  20597. public function getExtra(): array
  20598. {
  20599. return $this->aliasOf->getExtra();
  20600. }
  20601. public function setInstallationSource(?string $type): void
  20602. {
  20603. $this->aliasOf->setInstallationSource($type);
  20604. }
  20605. public function getInstallationSource(): ?string
  20606. {
  20607. return $this->aliasOf->getInstallationSource();
  20608. }
  20609. public function getSourceType(): ?string
  20610. {
  20611. return $this->aliasOf->getSourceType();
  20612. }
  20613. public function getSourceUrl(): ?string
  20614. {
  20615. return $this->aliasOf->getSourceUrl();
  20616. }
  20617. public function getSourceUrls(): array
  20618. {
  20619. return $this->aliasOf->getSourceUrls();
  20620. }
  20621. public function getSourceReference(): ?string
  20622. {
  20623. return $this->aliasOf->getSourceReference();
  20624. }
  20625. public function setSourceReference(?string $reference): void
  20626. {
  20627. $this->aliasOf->setSourceReference($reference);
  20628. }
  20629. public function setSourceMirrors(?array $mirrors): void
  20630. {
  20631. $this->aliasOf->setSourceMirrors($mirrors);
  20632. }
  20633. public function getSourceMirrors(): ?array
  20634. {
  20635. return $this->aliasOf->getSourceMirrors();
  20636. }
  20637. public function getDistType(): ?string
  20638. {
  20639. return $this->aliasOf->getDistType();
  20640. }
  20641. public function getDistUrl(): ?string
  20642. {
  20643. return $this->aliasOf->getDistUrl();
  20644. }
  20645. public function getDistUrls(): array
  20646. {
  20647. return $this->aliasOf->getDistUrls();
  20648. }
  20649. public function getDistReference(): ?string
  20650. {
  20651. return $this->aliasOf->getDistReference();
  20652. }
  20653. public function setDistReference(?string $reference): void
  20654. {
  20655. $this->aliasOf->setDistReference($reference);
  20656. }
  20657. public function getDistSha1Checksum(): ?string
  20658. {
  20659. return $this->aliasOf->getDistSha1Checksum();
  20660. }
  20661. public function setTransportOptions(array $options): void
  20662. {
  20663. $this->aliasOf->setTransportOptions($options);
  20664. }
  20665. public function getTransportOptions(): array
  20666. {
  20667. return $this->aliasOf->getTransportOptions();
  20668. }
  20669. public function setDistMirrors(?array $mirrors): void
  20670. {
  20671. $this->aliasOf->setDistMirrors($mirrors);
  20672. }
  20673. public function getDistMirrors(): ?array
  20674. {
  20675. return $this->aliasOf->getDistMirrors();
  20676. }
  20677. public function getAutoload(): array
  20678. {
  20679. return $this->aliasOf->getAutoload();
  20680. }
  20681. public function getDevAutoload(): array
  20682. {
  20683. return $this->aliasOf->getDevAutoload();
  20684. }
  20685. public function getIncludePaths(): array
  20686. {
  20687. return $this->aliasOf->getIncludePaths();
  20688. }
  20689. public function getReleaseDate(): ?\DateTimeInterface
  20690. {
  20691. return $this->aliasOf->getReleaseDate();
  20692. }
  20693. public function getBinaries(): array
  20694. {
  20695. return $this->aliasOf->getBinaries();
  20696. }
  20697. public function getSuggests(): array
  20698. {
  20699. return $this->aliasOf->getSuggests();
  20700. }
  20701. public function getNotificationUrl(): ?string
  20702. {
  20703. return $this->aliasOf->getNotificationUrl();
  20704. }
  20705. public function isDefaultBranch(): bool
  20706. {
  20707. return $this->aliasOf->isDefaultBranch();
  20708. }
  20709. public function setDistUrl(?string $url): void
  20710. {
  20711. $this->aliasOf->setDistUrl($url);
  20712. }
  20713. public function setDistType(?string $type): void
  20714. {
  20715. $this->aliasOf->setDistType($type);
  20716. }
  20717. public function setSourceDistReferences(string $reference): void
  20718. {
  20719. $this->aliasOf->setSourceDistReferences($reference);
  20720. }
  20721. }
  20722. <?php declare(strict_types=1);
  20723. namespace Composer\Package\Archiver;
  20724. use FilterIterator;
  20725. use PharData;
  20726. class ArchivableFilesFilter extends FilterIterator
  20727. {
  20728. private $dirs = array();
  20729. public function accept(): bool
  20730. {
  20731. $file = $this->getInnerIterator()->current();
  20732. if ($file->isDir()) {
  20733. $this->dirs[] = (string) $file;
  20734. return false;
  20735. }
  20736. return true;
  20737. }
  20738. public function addEmptyDir(PharData $phar, string $sources): void
  20739. {
  20740. foreach ($this->dirs as $filepath) {
  20741. $localname = str_replace($sources . "/", '', $filepath);
  20742. $phar->addEmptyDir($localname);
  20743. }
  20744. }
  20745. }
  20746. <?php declare(strict_types=1);
  20747. namespace Composer\Package\Archiver;
  20748. use Composer\Pcre\Preg;
  20749. use Composer\Util\Filesystem;
  20750. use FilesystemIterator;
  20751. use Symfony\Component\Finder\Finder;
  20752. use Symfony\Component\Finder\SplFileInfo;
  20753. class ArchivableFilesFinder extends \FilterIterator
  20754. {
  20755. protected $finder;
  20756. public function __construct(string $sources, array $excludes, bool $ignoreFilters = false)
  20757. {
  20758. $fs = new Filesystem();
  20759. $sources = $fs->normalizePath(realpath($sources));
  20760. if ($ignoreFilters) {
  20761. $filters = array();
  20762. } else {
  20763. $filters = array(
  20764. new GitExcludeFilter($sources),
  20765. new ComposerExcludeFilter($sources, $excludes),
  20766. );
  20767. }
  20768. $this->finder = new Finder();
  20769. $filter = function (\SplFileInfo $file) use ($sources, $filters, $fs): bool {
  20770. if ($file->isLink() && ($file->getRealPath() === false || strpos($file->getRealPath(), $sources) !== 0)) {
  20771. return false;
  20772. }
  20773. $relativePath = Preg::replace(
  20774. '#^'.preg_quote($sources, '#').'#',
  20775. '',
  20776. $fs->normalizePath($file->getRealPath())
  20777. );
  20778. $exclude = false;
  20779. foreach ($filters as $filter) {
  20780. $exclude = $filter->filter($relativePath, $exclude);
  20781. }
  20782. return !$exclude;
  20783. };
  20784. if (method_exists($filter, 'bindTo')) {
  20785. $filter = $filter->bindTo(null);
  20786. }
  20787. $this->finder
  20788. ->in($sources)
  20789. ->filter($filter)
  20790. ->ignoreVCS(true)
  20791. ->ignoreDotFiles(false)
  20792. ->sortByName();
  20793. parent::__construct($this->finder->getIterator());
  20794. }
  20795. public function accept(): bool
  20796. {
  20797. $current = $this->getInnerIterator()->current();
  20798. if (!$current->isDir()) {
  20799. return true;
  20800. }
  20801. $iterator = new FilesystemIterator((string) $current, FilesystemIterator::SKIP_DOTS);
  20802. return !$iterator->valid();
  20803. }
  20804. }
  20805. <?php declare(strict_types=1);
  20806. namespace Composer\Package\Archiver;
  20807. use Composer\Downloader\DownloadManager;
  20808. use Composer\Package\RootPackageInterface;
  20809. use Composer\Pcre\Preg;
  20810. use Composer\Util\Filesystem;
  20811. use Composer\Util\Loop;
  20812. use Composer\Util\SyncHelper;
  20813. use Composer\Json\JsonFile;
  20814. use Composer\Package\CompletePackageInterface;
  20815. class ArchiveManager
  20816. {
  20817. protected $downloadManager;
  20818. protected $loop;
  20819. protected $archivers = array();
  20820. protected $overwriteFiles = true;
  20821. public function __construct(DownloadManager $downloadManager, Loop $loop)
  20822. {
  20823. $this->downloadManager = $downloadManager;
  20824. $this->loop = $loop;
  20825. }
  20826. public function addArchiver(ArchiverInterface $archiver): void
  20827. {
  20828. $this->archivers[] = $archiver;
  20829. }
  20830. public function setOverwriteFiles(bool $overwriteFiles): self
  20831. {
  20832. $this->overwriteFiles = $overwriteFiles;
  20833. return $this;
  20834. }
  20835. public function getPackageFilename(CompletePackageInterface $package): string
  20836. {
  20837. if ($package->getArchiveName()) {
  20838. $baseName = $package->getArchiveName();
  20839. } else {
  20840. $baseName = Preg::replace('#[^a-z0-9-_]#i', '-', $package->getName());
  20841. }
  20842. $nameParts = array($baseName);
  20843. if (null !== $package->getDistReference() && Preg::isMatch('{^[a-f0-9]{40}$}', $package->getDistReference())) {
  20844. array_push($nameParts, $package->getDistReference(), $package->getDistType());
  20845. } else {
  20846. array_push($nameParts, $package->getPrettyVersion(), $package->getDistReference());
  20847. }
  20848. if ($package->getSourceReference()) {
  20849. $nameParts[] = substr(sha1($package->getSourceReference()), 0, 6);
  20850. }
  20851. $name = implode('-', array_filter($nameParts, function ($p): bool {
  20852. return !empty($p);
  20853. }));
  20854. return str_replace('/', '-', $name);
  20855. }
  20856. public function archive(CompletePackageInterface $package, string $format, string $targetDir, ?string $fileName = null, bool $ignoreFilters = false): string
  20857. {
  20858. if (empty($format)) {
  20859. throw new \InvalidArgumentException('Format must be specified');
  20860. }
  20861. $usableArchiver = null;
  20862. foreach ($this->archivers as $archiver) {
  20863. if ($archiver->supports($format, $package->getSourceType())) {
  20864. $usableArchiver = $archiver;
  20865. break;
  20866. }
  20867. }
  20868. if (null === $usableArchiver) {
  20869. throw new \RuntimeException(sprintf('No archiver found to support %s format', $format));
  20870. }
  20871. $filesystem = new Filesystem();
  20872. if ($package instanceof RootPackageInterface) {
  20873. $sourcePath = realpath('.');
  20874. } else {
  20875. $sourcePath = sys_get_temp_dir().'/composer_archive'.uniqid();
  20876. $filesystem->ensureDirectoryExists($sourcePath);
  20877. try {
  20878. $promise = $this->downloadManager->download($package, $sourcePath);
  20879. SyncHelper::await($this->loop, $promise);
  20880. $promise = $this->downloadManager->install($package, $sourcePath);
  20881. SyncHelper::await($this->loop, $promise);
  20882. } catch (\Exception $e) {
  20883. $filesystem->removeDirectory($sourcePath);
  20884. throw $e;
  20885. }
  20886. if (file_exists($composerJsonPath = $sourcePath.'/composer.json')) {
  20887. $jsonFile = new JsonFile($composerJsonPath);
  20888. $jsonData = $jsonFile->read();
  20889. if (!empty($jsonData['archive']['name'])) {
  20890. $package->setArchiveName($jsonData['archive']['name']);
  20891. }
  20892. if (!empty($jsonData['archive']['exclude'])) {
  20893. $package->setArchiveExcludes($jsonData['archive']['exclude']);
  20894. }
  20895. }
  20896. }
  20897. if (null === $fileName) {
  20898. $packageName = $this->getPackageFilename($package);
  20899. } else {
  20900. $packageName = $fileName;
  20901. }
  20902. $filesystem->ensureDirectoryExists($targetDir);
  20903. $target = realpath($targetDir).'/'.$packageName.'.'.$format;
  20904. $filesystem->ensureDirectoryExists(dirname($target));
  20905. if (!$this->overwriteFiles && file_exists($target)) {
  20906. return $target;
  20907. }
  20908. $tempTarget = sys_get_temp_dir().'/composer_archive'.uniqid().'.'.$format;
  20909. $filesystem->ensureDirectoryExists(dirname($tempTarget));
  20910. $archivePath = $usableArchiver->archive($sourcePath, $tempTarget, $format, $package->getArchiveExcludes(), $ignoreFilters);
  20911. $filesystem->rename($archivePath, $target);
  20912. if (!$package instanceof RootPackageInterface) {
  20913. $filesystem->removeDirectory($sourcePath);
  20914. }
  20915. $filesystem->remove($tempTarget);
  20916. return $target;
  20917. }
  20918. }
  20919. <?php declare(strict_types=1);
  20920. namespace Composer\Package\Archiver;
  20921. interface ArchiverInterface
  20922. {
  20923. public function archive(string $sources, string $target, string $format, array $excludes = array(), bool $ignoreFilters = false): string;
  20924. public function supports(string $format, ?string $sourceType): bool;
  20925. }
  20926. <?php declare(strict_types=1);
  20927. namespace Composer\Package\Archiver;
  20928. use Composer\Pcre\Preg;
  20929. use Symfony\Component\Finder;
  20930. abstract class BaseExcludeFilter
  20931. {
  20932. protected $sourcePath;
  20933. protected $excludePatterns;
  20934. public function __construct(string $sourcePath)
  20935. {
  20936. $this->sourcePath = $sourcePath;
  20937. $this->excludePatterns = array();
  20938. }
  20939. public function filter(string $relativePath, bool $exclude): bool
  20940. {
  20941. foreach ($this->excludePatterns as $patternData) {
  20942. list($pattern, $negate, $stripLeadingSlash) = $patternData;
  20943. if ($stripLeadingSlash) {
  20944. $path = substr($relativePath, 1);
  20945. } else {
  20946. $path = $relativePath;
  20947. }
  20948. try {
  20949. if (Preg::isMatch($pattern, $path)) {
  20950. $exclude = !$negate;
  20951. }
  20952. } catch (\RuntimeException $e) {
  20953. }
  20954. }
  20955. return $exclude;
  20956. }
  20957. protected function parseLines(array $lines, callable $lineParser): array
  20958. {
  20959. return array_filter(
  20960. array_map(
  20961. function ($line) use ($lineParser) {
  20962. $line = trim($line);
  20963. if (!$line || 0 === strpos($line, '#')) {
  20964. return null;
  20965. }
  20966. return call_user_func($lineParser, $line);
  20967. },
  20968. $lines
  20969. ),
  20970. function ($pattern): bool {
  20971. return $pattern !== null;
  20972. }
  20973. );
  20974. }
  20975. protected function generatePatterns(array $rules): array
  20976. {
  20977. $patterns = array();
  20978. foreach ($rules as $rule) {
  20979. $patterns[] = $this->generatePattern($rule);
  20980. }
  20981. return $patterns;
  20982. }
  20983. protected function generatePattern(string $rule): array
  20984. {
  20985. $negate = false;
  20986. $pattern = '';
  20987. if ($rule !== '' && $rule[0] === '!') {
  20988. $negate = true;
  20989. $rule = ltrim($rule, '!');
  20990. }
  20991. $firstSlashPosition = strpos($rule, '/');
  20992. if (0 === $firstSlashPosition) {
  20993. $pattern = '^/';
  20994. } elseif (false === $firstSlashPosition || strlen($rule) - 1 === $firstSlashPosition) {
  20995. $pattern = '/';
  20996. }
  20997. $rule = trim($rule, '/');
  20998. $rule = substr(Finder\Glob::toRegex($rule), 2, -2);
  20999. return array('{'.$pattern.$rule.'(?=$|/)}', $negate, false);
  21000. }
  21001. }
  21002. <?php declare(strict_types=1);
  21003. namespace Composer\Package\Archiver;
  21004. class ComposerExcludeFilter extends BaseExcludeFilter
  21005. {
  21006. public function __construct(string $sourcePath, array $excludeRules)
  21007. {
  21008. parent::__construct($sourcePath);
  21009. $this->excludePatterns = $this->generatePatterns($excludeRules);
  21010. }
  21011. }
  21012. <?php declare(strict_types=1);
  21013. namespace Composer\Package\Archiver;
  21014. use Composer\Pcre\Preg;
  21015. class GitExcludeFilter extends BaseExcludeFilter
  21016. {
  21017. public function __construct(string $sourcePath)
  21018. {
  21019. parent::__construct($sourcePath);
  21020. if (file_exists($sourcePath.'/.gitattributes')) {
  21021. $this->excludePatterns = array_merge(
  21022. $this->excludePatterns,
  21023. $this->parseLines(
  21024. file($sourcePath.'/.gitattributes'),
  21025. array($this, 'parseGitAttributesLine')
  21026. )
  21027. );
  21028. }
  21029. }
  21030. public function parseGitAttributesLine(string $line): ?array
  21031. {
  21032. $parts = Preg::split('#\s+#', $line);
  21033. if (count($parts) == 2 && $parts[1] === 'export-ignore') {
  21034. return $this->generatePattern($parts[0]);
  21035. }
  21036. if (count($parts) == 2 && $parts[1] === '-export-ignore') {
  21037. return $this->generatePattern('!'.$parts[0]);
  21038. }
  21039. return null;
  21040. }
  21041. }
  21042. <?php declare(strict_types=1);
  21043. namespace Composer\Package\Archiver;
  21044. class PharArchiver implements ArchiverInterface
  21045. {
  21046. protected static $formats = array(
  21047. 'zip' => \Phar::ZIP,
  21048. 'tar' => \Phar::TAR,
  21049. 'tar.gz' => \Phar::TAR,
  21050. 'tar.bz2' => \Phar::TAR,
  21051. );
  21052. protected static $compressFormats = array(
  21053. 'tar.gz' => \Phar::GZ,
  21054. 'tar.bz2' => \Phar::BZ2,
  21055. );
  21056. public function archive(string $sources, string $target, string $format, array $excludes = array(), bool $ignoreFilters = false): string
  21057. {
  21058. $sources = realpath($sources);
  21059. if (file_exists($target)) {
  21060. unlink($target);
  21061. }
  21062. try {
  21063. $filename = substr($target, 0, strrpos($target, $format) - 1);
  21064. if (isset(static::$compressFormats[$format])) {
  21065. $target = $filename . '.tar';
  21066. }
  21067. $phar = new \PharData(
  21068. $target,
  21069. \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO,
  21070. '',
  21071. static::$formats[$format]
  21072. );
  21073. $files = new ArchivableFilesFinder($sources, $excludes, $ignoreFilters);
  21074. $filesOnly = new ArchivableFilesFilter($files);
  21075. $phar->buildFromIterator($filesOnly, $sources);
  21076. $filesOnly->addEmptyDir($phar, $sources);
  21077. if (isset(static::$compressFormats[$format])) {
  21078. if (!$phar->canCompress(static::$compressFormats[$format])) {
  21079. throw new \RuntimeException(sprintf('Can not compress to %s format', $format));
  21080. }
  21081. unlink($target);
  21082. $phar->compress(static::$compressFormats[$format]);
  21083. $target = $filename . '.' . $format;
  21084. }
  21085. return $target;
  21086. } catch (\UnexpectedValueException $e) {
  21087. $message = sprintf(
  21088. "Could not create archive '%s' from '%s': %s",
  21089. $target,
  21090. $sources,
  21091. $e->getMessage()
  21092. );
  21093. throw new \RuntimeException($message, $e->getCode(), $e);
  21094. }
  21095. }
  21096. public function supports(string $format, ?string $sourceType): bool
  21097. {
  21098. return isset(static::$formats[$format]);
  21099. }
  21100. }
  21101. <?php declare(strict_types=1);
  21102. namespace Composer\Package\Archiver;
  21103. use ZipArchive;
  21104. use Composer\Util\Filesystem;
  21105. class ZipArchiver implements ArchiverInterface
  21106. {
  21107. protected static $formats = array(
  21108. 'zip' => true,
  21109. );
  21110. public function archive(string $sources, string $target, string $format, array $excludes = array(), bool $ignoreFilters = false): string
  21111. {
  21112. $fs = new Filesystem();
  21113. $sources = $fs->normalizePath($sources);
  21114. $zip = new ZipArchive();
  21115. $res = $zip->open($target, ZipArchive::CREATE);
  21116. if ($res === true) {
  21117. $files = new ArchivableFilesFinder($sources, $excludes, $ignoreFilters);
  21118. foreach ($files as $file) {
  21119. $filepath = strtr($file->getPath()."/".$file->getFilename(), '\\', '/');
  21120. $localname = $filepath;
  21121. if (strpos($localname, $sources . '/') === 0) {
  21122. $localname = substr($localname, strlen($sources . '/'));
  21123. }
  21124. if ($file->isDir()) {
  21125. $zip->addEmptyDir($localname);
  21126. } else {
  21127. $zip->addFile($filepath, $localname);
  21128. }
  21129. if (method_exists($zip, 'setExternalAttributesName')) {
  21130. $perms = fileperms($filepath);
  21131. $zip->setExternalAttributesName($localname, ZipArchive::OPSYS_UNIX, $perms << 16);
  21132. }
  21133. }
  21134. if ($zip->close()) {
  21135. return $target;
  21136. }
  21137. }
  21138. $message = sprintf(
  21139. "Could not create archive '%s' from '%s': %s",
  21140. $target,
  21141. $sources,
  21142. $zip->getStatusString()
  21143. );
  21144. throw new \RuntimeException($message);
  21145. }
  21146. public function supports(string $format, ?string $sourceType): bool
  21147. {
  21148. return isset(static::$formats[$format]) && $this->compressionAvailable();
  21149. }
  21150. private function compressionAvailable(): bool
  21151. {
  21152. return class_exists('ZipArchive');
  21153. }
  21154. }
  21155. <?php declare(strict_types=1);
  21156. namespace Composer\Package;
  21157. use Composer\Repository\RepositoryInterface;
  21158. use Composer\Repository\PlatformRepository;
  21159. abstract class BasePackage implements PackageInterface
  21160. {
  21161. public static $supportedLinkTypes = array(
  21162. 'require' => array('description' => 'requires', 'method' => Link::TYPE_REQUIRE),
  21163. 'conflict' => array('description' => 'conflicts', 'method' => Link::TYPE_CONFLICT),
  21164. 'provide' => array('description' => 'provides', 'method' => Link::TYPE_PROVIDE),
  21165. 'replace' => array('description' => 'replaces', 'method' => Link::TYPE_REPLACE),
  21166. 'require-dev' => array('description' => 'requires (for development)', 'method' => Link::TYPE_DEV_REQUIRE),
  21167. );
  21168. public const STABILITY_STABLE = 0;
  21169. public const STABILITY_RC = 5;
  21170. public const STABILITY_BETA = 10;
  21171. public const STABILITY_ALPHA = 15;
  21172. public const STABILITY_DEV = 20;
  21173. public static $stabilities = array(
  21174. 'stable' => self::STABILITY_STABLE,
  21175. 'RC' => self::STABILITY_RC,
  21176. 'beta' => self::STABILITY_BETA,
  21177. 'alpha' => self::STABILITY_ALPHA,
  21178. 'dev' => self::STABILITY_DEV,
  21179. );
  21180. public $id;
  21181. protected $name;
  21182. protected $prettyName;
  21183. protected $repository = null;
  21184. public function __construct(string $name)
  21185. {
  21186. $this->prettyName = $name;
  21187. $this->name = strtolower($name);
  21188. $this->id = -1;
  21189. }
  21190. public function getName(): string
  21191. {
  21192. return $this->name;
  21193. }
  21194. public function getPrettyName(): string
  21195. {
  21196. return $this->prettyName;
  21197. }
  21198. public function getNames($provides = true): array
  21199. {
  21200. $names = array(
  21201. $this->getName() => true,
  21202. );
  21203. if ($provides) {
  21204. foreach ($this->getProvides() as $link) {
  21205. $names[$link->getTarget()] = true;
  21206. }
  21207. }
  21208. foreach ($this->getReplaces() as $link) {
  21209. $names[$link->getTarget()] = true;
  21210. }
  21211. return array_keys($names);
  21212. }
  21213. public function setId(int $id): void
  21214. {
  21215. $this->id = $id;
  21216. }
  21217. public function getId(): int
  21218. {
  21219. return $this->id;
  21220. }
  21221. public function setRepository(RepositoryInterface $repository): void
  21222. {
  21223. if ($this->repository && $repository !== $this->repository) {
  21224. throw new \LogicException('A package can only be added to one repository');
  21225. }
  21226. $this->repository = $repository;
  21227. }
  21228. public function getRepository(): ?RepositoryInterface
  21229. {
  21230. return $this->repository;
  21231. }
  21232. public function isPlatform(): bool
  21233. {
  21234. return $this->getRepository() instanceof PlatformRepository;
  21235. }
  21236. public function getUniqueName(): string
  21237. {
  21238. return $this->getName().'-'.$this->getVersion();
  21239. }
  21240. public function equals(PackageInterface $package): bool
  21241. {
  21242. $self = $this;
  21243. if ($this instanceof AliasPackage) {
  21244. $self = $this->getAliasOf();
  21245. }
  21246. if ($package instanceof AliasPackage) {
  21247. $package = $package->getAliasOf();
  21248. }
  21249. return $package === $self;
  21250. }
  21251. public function __toString(): string
  21252. {
  21253. return $this->getUniqueName();
  21254. }
  21255. public function getPrettyString(): string
  21256. {
  21257. return $this->getPrettyName().' '.$this->getPrettyVersion();
  21258. }
  21259. public function getFullPrettyVersion(bool $truncate = true, int $displayMode = PackageInterface::DISPLAY_SOURCE_REF_IF_DEV): string
  21260. {
  21261. if ($displayMode === PackageInterface::DISPLAY_SOURCE_REF_IF_DEV &&
  21262. (!$this->isDev() || !\in_array($this->getSourceType(), array('hg', 'git')))
  21263. ) {
  21264. return $this->getPrettyVersion();
  21265. }
  21266. switch ($displayMode) {
  21267. case PackageInterface::DISPLAY_SOURCE_REF_IF_DEV:
  21268. case PackageInterface::DISPLAY_SOURCE_REF:
  21269. $reference = $this->getSourceReference();
  21270. break;
  21271. case PackageInterface::DISPLAY_DIST_REF:
  21272. $reference = $this->getDistReference();
  21273. break;
  21274. default:
  21275. throw new \UnexpectedValueException('Display mode '.$displayMode.' is not supported');
  21276. }
  21277. if (null === $reference) {
  21278. return $this->getPrettyVersion();
  21279. }
  21280. if ($truncate && \strlen($reference) === 40 && $this->getSourceType() !== 'svn') {
  21281. return $this->getPrettyVersion() . ' ' . substr($reference, 0, 7);
  21282. }
  21283. return $this->getPrettyVersion() . ' ' . $reference;
  21284. }
  21285. public function getStabilityPriority(): int
  21286. {
  21287. return self::$stabilities[$this->getStability()];
  21288. }
  21289. public function __clone()
  21290. {
  21291. $this->repository = null;
  21292. $this->id = -1;
  21293. }
  21294. public static function packageNameToRegexp(string $allowPattern, string $wrap = '{^%s$}i'): string
  21295. {
  21296. $cleanedAllowPattern = str_replace('\\*', '.*', preg_quote($allowPattern));
  21297. return sprintf($wrap, $cleanedAllowPattern);
  21298. }
  21299. public static function packageNamesToRegexp(array $packageNames, string $wrap = '{^(?:%s)$}iD'): string
  21300. {
  21301. $packageNames = array_map(
  21302. function ($packageName): string {
  21303. return BasePackage::packageNameToRegexp($packageName, '%s');
  21304. },
  21305. $packageNames
  21306. );
  21307. return sprintf($wrap, implode('|', $packageNames));
  21308. }
  21309. }
  21310. <?php declare(strict_types=1);
  21311. namespace Composer\Package\Comparer;
  21312. use Composer\Util\Platform;
  21313. class Comparer
  21314. {
  21315. private $source;
  21316. private $update;
  21317. private $changed;
  21318. public function setSource(string $source): void
  21319. {
  21320. $this->source = $source;
  21321. }
  21322. public function setUpdate(string $update): void
  21323. {
  21324. $this->update = $update;
  21325. }
  21326. public function getChanged(bool $explicated = false)
  21327. {
  21328. $changed = $this->changed;
  21329. if (!count($changed)) {
  21330. return false;
  21331. }
  21332. if ($explicated) {
  21333. foreach ($changed as $sectionKey => $itemSection) {
  21334. foreach ($itemSection as $itemKey => $item) {
  21335. $changed[$sectionKey][$itemKey] = $item.' ('.$sectionKey.')';
  21336. }
  21337. }
  21338. }
  21339. return $changed;
  21340. }
  21341. public function getChangedAsString(bool $toString = false, bool $explicated = false): string
  21342. {
  21343. $changed = $this->getChanged($explicated);
  21344. if (false === $changed) {
  21345. return '';
  21346. }
  21347. $strings = array();
  21348. foreach ($changed as $sectionKey => $itemSection) {
  21349. foreach ($itemSection as $itemKey => $item) {
  21350. $strings[] = $item."\r\n";
  21351. }
  21352. }
  21353. return trim(implode("\r\n", $strings));
  21354. }
  21355. public function doCompare(): void
  21356. {
  21357. $source = array();
  21358. $destination = array();
  21359. $this->changed = array();
  21360. $currentDirectory = Platform::getCwd();
  21361. chdir($this->source);
  21362. $source = $this->doTree('.', $source);
  21363. if (!is_array($source)) {
  21364. return;
  21365. }
  21366. chdir($currentDirectory);
  21367. chdir($this->update);
  21368. $destination = $this->doTree('.', $destination);
  21369. if (!is_array($destination)) {
  21370. exit;
  21371. }
  21372. chdir($currentDirectory);
  21373. foreach ($source as $dir => $value) {
  21374. foreach ($value as $file => $hash) {
  21375. if (isset($destination[$dir][$file])) {
  21376. if ($hash !== $destination[$dir][$file]) {
  21377. $this->changed['changed'][] = $dir.'/'.$file;
  21378. }
  21379. } else {
  21380. $this->changed['removed'][] = $dir.'/'.$file;
  21381. }
  21382. }
  21383. }
  21384. foreach ($destination as $dir => $value) {
  21385. foreach ($value as $file => $hash) {
  21386. if (!isset($source[$dir][$file])) {
  21387. $this->changed['added'][] = $dir.'/'.$file;
  21388. }
  21389. }
  21390. }
  21391. }
  21392. private function doTree(string $dir, array &$array)
  21393. {
  21394. if ($dh = opendir($dir)) {
  21395. while ($file = readdir($dh)) {
  21396. if ($file !== '.' && $file !== '..') {
  21397. if (is_link($dir.'/'.$file)) {
  21398. $array[$dir][$file] = readlink($dir.'/'.$file);
  21399. } elseif (is_dir($dir.'/'.$file)) {
  21400. if (!count($array)) {
  21401. $array[0] = 'Temp';
  21402. }
  21403. if (!$this->doTree($dir.'/'.$file, $array)) {
  21404. return false;
  21405. }
  21406. } elseif (is_file($dir.'/'.$file) && filesize($dir.'/'.$file)) {
  21407. $array[$dir][$file] = md5_file($dir.'/'.$file);
  21408. }
  21409. }
  21410. }
  21411. if (count($array) > 1 && isset($array['0'])) {
  21412. unset($array['0']);
  21413. }
  21414. return $array;
  21415. }
  21416. return false;
  21417. }
  21418. }
  21419. <?php declare(strict_types=1);
  21420. namespace Composer\Package;
  21421. class CompleteAliasPackage extends AliasPackage implements CompletePackageInterface
  21422. {
  21423. protected $aliasOf;
  21424. public function __construct(CompletePackage $aliasOf, string $version, string $prettyVersion)
  21425. {
  21426. parent::__construct($aliasOf, $version, $prettyVersion);
  21427. }
  21428. public function getAliasOf()
  21429. {
  21430. return $this->aliasOf;
  21431. }
  21432. public function getScripts(): array
  21433. {
  21434. return $this->aliasOf->getScripts();
  21435. }
  21436. public function setScripts(array $scripts): void
  21437. {
  21438. $this->aliasOf->setScripts($scripts);
  21439. }
  21440. public function getRepositories(): array
  21441. {
  21442. return $this->aliasOf->getRepositories();
  21443. }
  21444. public function setRepositories(array $repositories): void
  21445. {
  21446. $this->aliasOf->setRepositories($repositories);
  21447. }
  21448. public function getLicense(): array
  21449. {
  21450. return $this->aliasOf->getLicense();
  21451. }
  21452. public function setLicense(array $license): void
  21453. {
  21454. $this->aliasOf->setLicense($license);
  21455. }
  21456. public function getKeywords(): array
  21457. {
  21458. return $this->aliasOf->getKeywords();
  21459. }
  21460. public function setKeywords(array $keywords): void
  21461. {
  21462. $this->aliasOf->setKeywords($keywords);
  21463. }
  21464. public function getDescription(): ?string
  21465. {
  21466. return $this->aliasOf->getDescription();
  21467. }
  21468. public function setDescription(?string $description): void
  21469. {
  21470. $this->aliasOf->setDescription($description);
  21471. }
  21472. public function getHomepage(): ?string
  21473. {
  21474. return $this->aliasOf->getHomepage();
  21475. }
  21476. public function setHomepage(?string $homepage): void
  21477. {
  21478. $this->aliasOf->setHomepage($homepage);
  21479. }
  21480. public function getAuthors(): array
  21481. {
  21482. return $this->aliasOf->getAuthors();
  21483. }
  21484. public function setAuthors(array $authors): void
  21485. {
  21486. $this->aliasOf->setAuthors($authors);
  21487. }
  21488. public function getSupport(): array
  21489. {
  21490. return $this->aliasOf->getSupport();
  21491. }
  21492. public function setSupport(array $support): void
  21493. {
  21494. $this->aliasOf->setSupport($support);
  21495. }
  21496. public function getFunding(): array
  21497. {
  21498. return $this->aliasOf->getFunding();
  21499. }
  21500. public function setFunding(array $funding): void
  21501. {
  21502. $this->aliasOf->setFunding($funding);
  21503. }
  21504. public function isAbandoned(): bool
  21505. {
  21506. return $this->aliasOf->isAbandoned();
  21507. }
  21508. public function getReplacementPackage(): ?string
  21509. {
  21510. return $this->aliasOf->getReplacementPackage();
  21511. }
  21512. public function setAbandoned($abandoned): void
  21513. {
  21514. $this->aliasOf->setAbandoned($abandoned);
  21515. }
  21516. public function getArchiveName(): ?string
  21517. {
  21518. return $this->aliasOf->getArchiveName();
  21519. }
  21520. public function setArchiveName(?string $name): void
  21521. {
  21522. $this->aliasOf->setArchiveName($name);
  21523. }
  21524. public function getArchiveExcludes(): array
  21525. {
  21526. return $this->aliasOf->getArchiveExcludes();
  21527. }
  21528. public function setArchiveExcludes(array $excludes): void
  21529. {
  21530. $this->aliasOf->setArchiveExcludes($excludes);
  21531. }
  21532. }
  21533. <?php declare(strict_types=1);
  21534. namespace Composer\Package;
  21535. class CompletePackage extends Package implements CompletePackageInterface
  21536. {
  21537. protected $repositories = array();
  21538. protected $license = array();
  21539. protected $keywords = array();
  21540. protected $authors = array();
  21541. protected $description = null;
  21542. protected $homepage = null;
  21543. protected $scripts = array();
  21544. protected $support = array();
  21545. protected $funding = array();
  21546. protected $abandoned = false;
  21547. protected $archiveName = null;
  21548. protected $archiveExcludes = array();
  21549. public function setScripts(array $scripts): void
  21550. {
  21551. $this->scripts = $scripts;
  21552. }
  21553. public function getScripts(): array
  21554. {
  21555. return $this->scripts;
  21556. }
  21557. public function setRepositories(array $repositories): void
  21558. {
  21559. $this->repositories = $repositories;
  21560. }
  21561. public function getRepositories(): array
  21562. {
  21563. return $this->repositories;
  21564. }
  21565. public function setLicense(array $license): void
  21566. {
  21567. $this->license = $license;
  21568. }
  21569. public function getLicense(): array
  21570. {
  21571. return $this->license;
  21572. }
  21573. public function setKeywords(array $keywords): void
  21574. {
  21575. $this->keywords = $keywords;
  21576. }
  21577. public function getKeywords(): array
  21578. {
  21579. return $this->keywords;
  21580. }
  21581. public function setAuthors(array $authors): void
  21582. {
  21583. $this->authors = $authors;
  21584. }
  21585. public function getAuthors(): array
  21586. {
  21587. return $this->authors;
  21588. }
  21589. public function setDescription(?string $description): void
  21590. {
  21591. $this->description = $description;
  21592. }
  21593. public function getDescription(): ?string
  21594. {
  21595. return $this->description;
  21596. }
  21597. public function setHomepage(?string $homepage): void
  21598. {
  21599. $this->homepage = $homepage;
  21600. }
  21601. public function getHomepage(): ?string
  21602. {
  21603. return $this->homepage;
  21604. }
  21605. public function setSupport(array $support): void
  21606. {
  21607. $this->support = $support;
  21608. }
  21609. public function getSupport(): array
  21610. {
  21611. return $this->support;
  21612. }
  21613. public function setFunding(array $funding): void
  21614. {
  21615. $this->funding = $funding;
  21616. }
  21617. public function getFunding(): array
  21618. {
  21619. return $this->funding;
  21620. }
  21621. public function isAbandoned(): bool
  21622. {
  21623. return (bool) $this->abandoned;
  21624. }
  21625. public function setAbandoned($abandoned): void
  21626. {
  21627. $this->abandoned = $abandoned;
  21628. }
  21629. public function getReplacementPackage(): ?string
  21630. {
  21631. return \is_string($this->abandoned) ? $this->abandoned : null;
  21632. }
  21633. public function setArchiveName(?string $name): void
  21634. {
  21635. $this->archiveName = $name;
  21636. }
  21637. public function getArchiveName(): ?string
  21638. {
  21639. return $this->archiveName;
  21640. }
  21641. public function setArchiveExcludes(array $excludes): void
  21642. {
  21643. $this->archiveExcludes = $excludes;
  21644. }
  21645. public function getArchiveExcludes(): array
  21646. {
  21647. return $this->archiveExcludes;
  21648. }
  21649. }
  21650. <?php declare(strict_types=1);
  21651. namespace Composer\Package;
  21652. interface CompletePackageInterface extends PackageInterface
  21653. {
  21654. public function getScripts(): array;
  21655. public function setScripts(array $scripts): void;
  21656. public function getRepositories(): array;
  21657. public function setRepositories(array $repositories): void;
  21658. public function getLicense(): array;
  21659. public function setLicense(array $license): void;
  21660. public function getKeywords(): array;
  21661. public function setKeywords(array $keywords): void;
  21662. public function getDescription(): ?string;
  21663. public function setDescription(string $description): void;
  21664. public function getHomepage(): ?string;
  21665. public function setHomepage(string $homepage): void;
  21666. public function getAuthors(): array;
  21667. public function setAuthors(array $authors): void;
  21668. public function getSupport(): array;
  21669. public function setSupport(array $support): void;
  21670. public function getFunding(): array;
  21671. public function setFunding(array $funding): void;
  21672. public function isAbandoned(): bool;
  21673. public function getReplacementPackage(): ?string;
  21674. public function setAbandoned($abandoned): void;
  21675. public function getArchiveName(): ?string;
  21676. public function setArchiveName(string $name): void;
  21677. public function getArchiveExcludes(): array;
  21678. public function setArchiveExcludes(array $excludes): void;
  21679. }
  21680. <?php declare(strict_types=1);
  21681. namespace Composer\Package\Dumper;
  21682. use Composer\Package\BasePackage;
  21683. use Composer\Package\PackageInterface;
  21684. use Composer\Package\CompletePackageInterface;
  21685. use Composer\Package\RootPackageInterface;
  21686. class ArrayDumper
  21687. {
  21688. public function dump(PackageInterface $package): array
  21689. {
  21690. $keys = array(
  21691. 'binaries' => 'bin',
  21692. 'type',
  21693. 'extra',
  21694. 'installationSource' => 'installation-source',
  21695. 'autoload',
  21696. 'devAutoload' => 'autoload-dev',
  21697. 'notificationUrl' => 'notification-url',
  21698. 'includePaths' => 'include-path',
  21699. );
  21700. $data = array();
  21701. $data['name'] = $package->getPrettyName();
  21702. $data['version'] = $package->getPrettyVersion();
  21703. $data['version_normalized'] = $package->getVersion();
  21704. if ($package->getTargetDir()) {
  21705. $data['target-dir'] = $package->getTargetDir();
  21706. }
  21707. if ($package->getSourceType()) {
  21708. $data['source']['type'] = $package->getSourceType();
  21709. $data['source']['url'] = $package->getSourceUrl();
  21710. if (null !== ($value = $package->getSourceReference())) {
  21711. $data['source']['reference'] = $value;
  21712. }
  21713. if ($mirrors = $package->getSourceMirrors()) {
  21714. $data['source']['mirrors'] = $mirrors;
  21715. }
  21716. }
  21717. if ($package->getDistType()) {
  21718. $data['dist']['type'] = $package->getDistType();
  21719. $data['dist']['url'] = $package->getDistUrl();
  21720. if (null !== ($value = $package->getDistReference())) {
  21721. $data['dist']['reference'] = $value;
  21722. }
  21723. if (null !== ($value = $package->getDistSha1Checksum())) {
  21724. $data['dist']['shasum'] = $value;
  21725. }
  21726. if ($mirrors = $package->getDistMirrors()) {
  21727. $data['dist']['mirrors'] = $mirrors;
  21728. }
  21729. }
  21730. foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
  21731. if ($links = $package->{'get'.ucfirst($opts['method'])}()) {
  21732. foreach ($links as $link) {
  21733. $data[$type][$link->getTarget()] = $link->getPrettyConstraint();
  21734. }
  21735. ksort($data[$type]);
  21736. }
  21737. }
  21738. if ($packages = $package->getSuggests()) {
  21739. ksort($packages);
  21740. $data['suggest'] = $packages;
  21741. }
  21742. if ($package->getReleaseDate() instanceof \DateTimeInterface) {
  21743. $data['time'] = $package->getReleaseDate()->format(DATE_RFC3339);
  21744. }
  21745. if ($package->isDefaultBranch()) {
  21746. $data['default-branch'] = true;
  21747. }
  21748. $data = $this->dumpValues($package, $keys, $data);
  21749. if ($package instanceof CompletePackageInterface) {
  21750. if ($package->getArchiveName()) {
  21751. $data['archive']['name'] = $package->getArchiveName();
  21752. }
  21753. if ($package->getArchiveExcludes()) {
  21754. $data['archive']['exclude'] = $package->getArchiveExcludes();
  21755. }
  21756. $keys = array(
  21757. 'scripts',
  21758. 'license',
  21759. 'authors',
  21760. 'description',
  21761. 'homepage',
  21762. 'keywords',
  21763. 'repositories',
  21764. 'support',
  21765. 'funding',
  21766. );
  21767. $data = $this->dumpValues($package, $keys, $data);
  21768. if (isset($data['keywords']) && \is_array($data['keywords'])) {
  21769. sort($data['keywords']);
  21770. }
  21771. if ($package->isAbandoned()) {
  21772. $data['abandoned'] = $package->getReplacementPackage() ?: true;
  21773. }
  21774. }
  21775. if ($package instanceof RootPackageInterface) {
  21776. $minimumStability = $package->getMinimumStability();
  21777. if ($minimumStability) {
  21778. $data['minimum-stability'] = $minimumStability;
  21779. }
  21780. }
  21781. if (\count($package->getTransportOptions()) > 0) {
  21782. $data['transport-options'] = $package->getTransportOptions();
  21783. }
  21784. return $data;
  21785. }
  21786. private function dumpValues(PackageInterface $package, array $keys, array $data): array
  21787. {
  21788. foreach ($keys as $method => $key) {
  21789. if (is_numeric($method)) {
  21790. $method = $key;
  21791. }
  21792. $getter = 'get'.ucfirst($method);
  21793. $value = $package->$getter();
  21794. if (null !== $value && !(\is_array($value) && 0 === \count($value))) {
  21795. $data[$key] = $value;
  21796. }
  21797. }
  21798. return $data;
  21799. }
  21800. }
  21801. <?php declare(strict_types=1);
  21802. namespace Composer\Package;
  21803. use Composer\Semver\Constraint\ConstraintInterface;
  21804. class Link
  21805. {
  21806. public const TYPE_REQUIRE = 'requires';
  21807. public const TYPE_DEV_REQUIRE = 'devRequires';
  21808. public const TYPE_PROVIDE = 'provides';
  21809. public const TYPE_CONFLICT = 'conflicts';
  21810. public const TYPE_REPLACE = 'replaces';
  21811. public const TYPE_DOES_NOT_REQUIRE = 'does not require';
  21812. private const TYPE_UNKNOWN = 'relates to';
  21813. public static $TYPES = array(
  21814. self::TYPE_REQUIRE,
  21815. self::TYPE_DEV_REQUIRE,
  21816. self::TYPE_PROVIDE,
  21817. self::TYPE_CONFLICT,
  21818. self::TYPE_REPLACE,
  21819. );
  21820. protected $source;
  21821. protected $target;
  21822. protected $constraint;
  21823. protected $description;
  21824. protected $prettyConstraint;
  21825. public function __construct(
  21826. string $source,
  21827. string $target,
  21828. ConstraintInterface $constraint,
  21829. $description = self::TYPE_UNKNOWN,
  21830. ?string $prettyConstraint = null
  21831. ) {
  21832. $this->source = strtolower($source);
  21833. $this->target = strtolower($target);
  21834. $this->constraint = $constraint;
  21835. $this->description = self::TYPE_DEV_REQUIRE === $description ? 'requires (for development)' : $description;
  21836. $this->prettyConstraint = $prettyConstraint;
  21837. }
  21838. public function getDescription(): string
  21839. {
  21840. return $this->description;
  21841. }
  21842. public function getSource(): string
  21843. {
  21844. return $this->source;
  21845. }
  21846. public function getTarget(): string
  21847. {
  21848. return $this->target;
  21849. }
  21850. public function getConstraint(): ConstraintInterface
  21851. {
  21852. return $this->constraint;
  21853. }
  21854. public function getPrettyConstraint(): string
  21855. {
  21856. if (null === $this->prettyConstraint) {
  21857. throw new \UnexpectedValueException(sprintf('Link %s has been misconfigured and had no prettyConstraint given.', $this));
  21858. }
  21859. return $this->prettyConstraint;
  21860. }
  21861. public function __toString(): string
  21862. {
  21863. return $this->source.' '.$this->description.' '.$this->target.' ('.$this->constraint.')';
  21864. }
  21865. public function getPrettyString(PackageInterface $sourcePackage): string
  21866. {
  21867. return $sourcePackage->getPrettyString().' '.$this->description.' '.$this->target.' '.$this->constraint->getPrettyString();
  21868. }
  21869. }
  21870. <?php declare(strict_types=1);
  21871. namespace Composer\Package\Loader;
  21872. use Composer\Package\BasePackage;
  21873. use Composer\Package\CompleteAliasPackage;
  21874. use Composer\Package\CompletePackage;
  21875. use Composer\Package\RootPackage;
  21876. use Composer\Package\PackageInterface;
  21877. use Composer\Package\CompletePackageInterface;
  21878. use Composer\Package\Link;
  21879. use Composer\Package\RootAliasPackage;
  21880. use Composer\Package\Version\VersionParser;
  21881. use Composer\Pcre\Preg;
  21882. class ArrayLoader implements LoaderInterface
  21883. {
  21884. protected $versionParser;
  21885. protected $loadOptions;
  21886. public function __construct(VersionParser $parser = null, bool $loadOptions = false)
  21887. {
  21888. if (!$parser) {
  21889. $parser = new VersionParser;
  21890. }
  21891. $this->versionParser = $parser;
  21892. $this->loadOptions = $loadOptions;
  21893. }
  21894. public function load(array $config, string $class = 'Composer\Package\CompletePackage'): BasePackage
  21895. {
  21896. if ($class !== 'Composer\Package\CompletePackage' && $class !== 'Composer\Package\RootPackage') {
  21897. trigger_error('The $class arg is deprecated, please reach out to Composer maintainers ASAP if you still need this.', E_USER_DEPRECATED);
  21898. }
  21899. $package = $this->createObject($config, $class);
  21900. foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
  21901. if (isset($config[$type])) {
  21902. $method = 'set'.ucfirst($opts['method']);
  21903. $package->{$method}(
  21904. $this->parseLinks(
  21905. $package->getName(),
  21906. $package->getPrettyVersion(),
  21907. $opts['method'],
  21908. $config[$type]
  21909. )
  21910. );
  21911. }
  21912. }
  21913. $package = $this->configureObject($package, $config);
  21914. return $package;
  21915. }
  21916. public function loadPackages(array $versions): array
  21917. {
  21918. $packages = array();
  21919. $linkCache = array();
  21920. foreach ($versions as $version) {
  21921. $package = $this->createObject($version, 'Composer\Package\CompletePackage');
  21922. $this->configureCachedLinks($linkCache, $package, $version);
  21923. $package = $this->configureObject($package, $version);
  21924. $packages[] = $package;
  21925. }
  21926. return $packages;
  21927. }
  21928. private function createObject(array $config, string $class): CompletePackage
  21929. {
  21930. if (!isset($config['name'])) {
  21931. throw new \UnexpectedValueException('Unknown package has no name defined ('.json_encode($config).').');
  21932. }
  21933. if (!isset($config['version']) || !is_scalar($config['version'])) {
  21934. throw new \UnexpectedValueException('Package '.$config['name'].' has no version defined.');
  21935. }
  21936. if (!is_string($config['version'])) {
  21937. $config['version'] = (string) $config['version'];
  21938. }
  21939. if (isset($config['version_normalized']) && is_string($config['version_normalized'])) {
  21940. $version = $config['version_normalized'];
  21941. if ($version === VersionParser::DEFAULT_BRANCH_ALIAS) {
  21942. $version = $this->versionParser->normalize($config['version']);
  21943. }
  21944. } else {
  21945. $version = $this->versionParser->normalize($config['version']);
  21946. }
  21947. return new $class($config['name'], $version, $config['version']);
  21948. }
  21949. private function configureObject(PackageInterface $package, array $config): BasePackage
  21950. {
  21951. if (!$package instanceof CompletePackage) {
  21952. throw new \LogicException('ArrayLoader expects instances of the Composer\Package\CompletePackage class to function correctly');
  21953. }
  21954. $package->setType(isset($config['type']) ? strtolower($config['type']) : 'library');
  21955. if (isset($config['target-dir'])) {
  21956. $package->setTargetDir($config['target-dir']);
  21957. }
  21958. if (isset($config['extra']) && \is_array($config['extra'])) {
  21959. $package->setExtra($config['extra']);
  21960. }
  21961. if (isset($config['bin'])) {
  21962. if (!\is_array($config['bin'])) {
  21963. $config['bin'] = array($config['bin']);
  21964. }
  21965. foreach ($config['bin'] as $key => $bin) {
  21966. $config['bin'][$key] = ltrim($bin, '/');
  21967. }
  21968. $package->setBinaries($config['bin']);
  21969. }
  21970. if (isset($config['installation-source'])) {
  21971. $package->setInstallationSource($config['installation-source']);
  21972. }
  21973. if (isset($config['default-branch']) && $config['default-branch'] === true) {
  21974. $package->setIsDefaultBranch(true);
  21975. }
  21976. if (isset($config['source'])) {
  21977. if (!isset($config['source']['type'], $config['source']['url'], $config['source']['reference'])) {
  21978. throw new \UnexpectedValueException(sprintf(
  21979. "Package %s's source key should be specified as {\"type\": ..., \"url\": ..., \"reference\": ...},\n%s given.",
  21980. $config['name'],
  21981. json_encode($config['source'])
  21982. ));
  21983. }
  21984. $package->setSourceType($config['source']['type']);
  21985. $package->setSourceUrl($config['source']['url']);
  21986. $package->setSourceReference(isset($config['source']['reference']) ? (string) $config['source']['reference'] : null);
  21987. if (isset($config['source']['mirrors'])) {
  21988. $package->setSourceMirrors($config['source']['mirrors']);
  21989. }
  21990. }
  21991. if (isset($config['dist'])) {
  21992. if (!isset($config['dist']['type'], $config['dist']['url'])) {
  21993. throw new \UnexpectedValueException(sprintf(
  21994. "Package %s's dist key should be specified as ".
  21995. "{\"type\": ..., \"url\": ..., \"reference\": ..., \"shasum\": ...},\n%s given.",
  21996. $config['name'],
  21997. json_encode($config['dist'])
  21998. ));
  21999. }
  22000. $package->setDistType($config['dist']['type']);
  22001. $package->setDistUrl($config['dist']['url']);
  22002. $package->setDistReference(isset($config['dist']['reference']) ? (string) $config['dist']['reference'] : null);
  22003. $package->setDistSha1Checksum($config['dist']['shasum'] ?? null);
  22004. if (isset($config['dist']['mirrors'])) {
  22005. $package->setDistMirrors($config['dist']['mirrors']);
  22006. }
  22007. }
  22008. if (isset($config['suggest']) && \is_array($config['suggest'])) {
  22009. foreach ($config['suggest'] as $target => $reason) {
  22010. if ('self.version' === trim($reason)) {
  22011. $config['suggest'][$target] = $package->getPrettyVersion();
  22012. }
  22013. }
  22014. $package->setSuggests($config['suggest']);
  22015. }
  22016. if (isset($config['autoload'])) {
  22017. $package->setAutoload($config['autoload']);
  22018. }
  22019. if (isset($config['autoload-dev'])) {
  22020. $package->setDevAutoload($config['autoload-dev']);
  22021. }
  22022. if (isset($config['include-path'])) {
  22023. $package->setIncludePaths($config['include-path']);
  22024. }
  22025. if (!empty($config['time'])) {
  22026. $time = Preg::isMatch('/^\d++$/D', $config['time']) ? '@'.$config['time'] : $config['time'];
  22027. try {
  22028. $date = new \DateTime($time, new \DateTimeZone('UTC'));
  22029. $package->setReleaseDate($date);
  22030. } catch (\Exception $e) {
  22031. }
  22032. }
  22033. if (!empty($config['notification-url'])) {
  22034. $package->setNotificationUrl($config['notification-url']);
  22035. }
  22036. if ($package instanceof CompletePackageInterface) {
  22037. if (!empty($config['archive']['name'])) {
  22038. $package->setArchiveName($config['archive']['name']);
  22039. }
  22040. if (!empty($config['archive']['exclude'])) {
  22041. $package->setArchiveExcludes($config['archive']['exclude']);
  22042. }
  22043. if (isset($config['scripts']) && \is_array($config['scripts'])) {
  22044. foreach ($config['scripts'] as $event => $listeners) {
  22045. $config['scripts'][$event] = (array) $listeners;
  22046. }
  22047. foreach (array('composer', 'php', 'putenv') as $reserved) {
  22048. if (isset($config['scripts'][$reserved])) {
  22049. trigger_error('The `'.$reserved.'` script name is reserved for internal use, please avoid defining it', E_USER_DEPRECATED);
  22050. }
  22051. }
  22052. $package->setScripts($config['scripts']);
  22053. }
  22054. if (!empty($config['description']) && \is_string($config['description'])) {
  22055. $package->setDescription($config['description']);
  22056. }
  22057. if (!empty($config['homepage']) && \is_string($config['homepage'])) {
  22058. $package->setHomepage($config['homepage']);
  22059. }
  22060. if (!empty($config['keywords']) && \is_array($config['keywords'])) {
  22061. $package->setKeywords($config['keywords']);
  22062. }
  22063. if (!empty($config['license'])) {
  22064. $package->setLicense(\is_array($config['license']) ? $config['license'] : array($config['license']));
  22065. }
  22066. if (!empty($config['authors']) && \is_array($config['authors'])) {
  22067. $package->setAuthors($config['authors']);
  22068. }
  22069. if (isset($config['support'])) {
  22070. $package->setSupport($config['support']);
  22071. }
  22072. if (!empty($config['funding']) && \is_array($config['funding'])) {
  22073. $package->setFunding($config['funding']);
  22074. }
  22075. if (isset($config['abandoned'])) {
  22076. $package->setAbandoned($config['abandoned']);
  22077. }
  22078. }
  22079. if ($this->loadOptions && isset($config['transport-options'])) {
  22080. $package->setTransportOptions($config['transport-options']);
  22081. }
  22082. if ($aliasNormalized = $this->getBranchAlias($config)) {
  22083. $prettyAlias = Preg::replace('{(\.9{7})+}', '.x', $aliasNormalized);
  22084. if ($package instanceof RootPackage) {
  22085. return new RootAliasPackage($package, $aliasNormalized, $prettyAlias);
  22086. }
  22087. return new CompleteAliasPackage($package, $aliasNormalized, $prettyAlias);
  22088. }
  22089. return $package;
  22090. }
  22091. private function configureCachedLinks(array &$linkCache, PackageInterface $package, array $config): void
  22092. {
  22093. $name = $package->getName();
  22094. $prettyVersion = $package->getPrettyVersion();
  22095. foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
  22096. if (isset($config[$type])) {
  22097. $method = 'set'.ucfirst($opts['method']);
  22098. $links = array();
  22099. foreach ($config[$type] as $prettyTarget => $constraint) {
  22100. $target = strtolower($prettyTarget);
  22101. if ($target === $name) {
  22102. continue;
  22103. }
  22104. if ($constraint === 'self.version') {
  22105. $links[$target] = $this->createLink($name, $prettyVersion, $opts['method'], $target, $constraint);
  22106. } else {
  22107. if (!isset($linkCache[$name][$type][$target][$constraint])) {
  22108. $linkCache[$name][$type][$target][$constraint] = array($target, $this->createLink($name, $prettyVersion, $opts['method'], $target, $constraint));
  22109. }
  22110. list($target, $link) = $linkCache[$name][$type][$target][$constraint];
  22111. $links[$target] = $link;
  22112. }
  22113. }
  22114. $package->{$method}($links);
  22115. }
  22116. }
  22117. }
  22118. public function parseLinks(string $source, string $sourceVersion, string $description, array $links): array
  22119. {
  22120. $res = array();
  22121. foreach ($links as $target => $constraint) {
  22122. $target = strtolower((string) $target);
  22123. $res[$target] = $this->createLink($source, $sourceVersion, $description, $target, $constraint);
  22124. }
  22125. return $res;
  22126. }
  22127. private function createLink(string $source, string $sourceVersion, string $description, string $target, string $prettyConstraint): Link
  22128. {
  22129. if (!\is_string($prettyConstraint)) {
  22130. throw new \UnexpectedValueException('Link constraint in '.$source.' '.$description.' > '.$target.' should be a string, got '.\gettype($prettyConstraint) . ' (' . var_export($prettyConstraint, true) . ')');
  22131. }
  22132. if ('self.version' === $prettyConstraint) {
  22133. $parsedConstraint = $this->versionParser->parseConstraints($sourceVersion);
  22134. } else {
  22135. $parsedConstraint = $this->versionParser->parseConstraints($prettyConstraint);
  22136. }
  22137. return new Link($source, $target, $parsedConstraint, $description, $prettyConstraint);
  22138. }
  22139. public function getBranchAlias(array $config): ?string
  22140. {
  22141. if (!isset($config['version']) || !is_scalar($config['version'])) {
  22142. throw new \UnexpectedValueException('no/invalid version defined');
  22143. }
  22144. if (!is_string($config['version'])) {
  22145. $config['version'] = (string) $config['version'];
  22146. }
  22147. if (strpos($config['version'], 'dev-') !== 0 && '-dev' !== substr($config['version'], -4)) {
  22148. return null;
  22149. }
  22150. if (isset($config['extra']['branch-alias']) && \is_array($config['extra']['branch-alias'])) {
  22151. foreach ($config['extra']['branch-alias'] as $sourceBranch => $targetBranch) {
  22152. $sourceBranch = (string) $sourceBranch;
  22153. if ('-dev' !== substr($targetBranch, -4)) {
  22154. continue;
  22155. }
  22156. if ($targetBranch === VersionParser::DEFAULT_BRANCH_ALIAS) {
  22157. $validatedTargetBranch = VersionParser::DEFAULT_BRANCH_ALIAS;
  22158. } else {
  22159. $validatedTargetBranch = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4));
  22160. }
  22161. if ('-dev' !== substr($validatedTargetBranch, -4)) {
  22162. continue;
  22163. }
  22164. if (strtolower($config['version']) !== strtolower($sourceBranch)) {
  22165. continue;
  22166. }
  22167. if (($sourcePrefix = $this->versionParser->parseNumericAliasPrefix($sourceBranch))
  22168. && ($targetPrefix = $this->versionParser->parseNumericAliasPrefix($targetBranch))
  22169. && (stripos($targetPrefix, $sourcePrefix) !== 0)
  22170. ) {
  22171. continue;
  22172. }
  22173. return $validatedTargetBranch;
  22174. }
  22175. }
  22176. if (
  22177. isset($config['default-branch'])
  22178. && $config['default-branch'] === true
  22179. && false === $this->versionParser->parseNumericAliasPrefix($config['version'])
  22180. ) {
  22181. return VersionParser::DEFAULT_BRANCH_ALIAS;
  22182. }
  22183. return null;
  22184. }
  22185. }
  22186. <?php declare(strict_types=1);
  22187. namespace Composer\Package\Loader;
  22188. class InvalidPackageException extends \Exception
  22189. {
  22190. private $errors;
  22191. private $warnings;
  22192. private $data;
  22193. public function __construct(array $errors, array $warnings, array $data)
  22194. {
  22195. $this->errors = $errors;
  22196. $this->warnings = $warnings;
  22197. $this->data = $data;
  22198. parent::__construct("Invalid package information: \n".implode("\n", array_merge($errors, $warnings)));
  22199. }
  22200. public function getData(): array
  22201. {
  22202. return $this->data;
  22203. }
  22204. public function getErrors(): array
  22205. {
  22206. return $this->errors;
  22207. }
  22208. public function getWarnings(): array
  22209. {
  22210. return $this->warnings;
  22211. }
  22212. }
  22213. <?php declare(strict_types=1);
  22214. namespace Composer\Package\Loader;
  22215. use Composer\Json\JsonFile;
  22216. use Composer\Package\BasePackage;
  22217. use Composer\Package\CompletePackage;
  22218. use Composer\Package\CompleteAliasPackage;
  22219. use Composer\Package\RootPackage;
  22220. use Composer\Package\RootAliasPackage;
  22221. class JsonLoader
  22222. {
  22223. private $loader;
  22224. public function __construct(LoaderInterface $loader)
  22225. {
  22226. $this->loader = $loader;
  22227. }
  22228. public function load($json): BasePackage
  22229. {
  22230. if ($json instanceof JsonFile) {
  22231. $config = $json->read();
  22232. } elseif (file_exists($json)) {
  22233. $config = JsonFile::parseJson(file_get_contents($json), $json);
  22234. } elseif (is_string($json)) {
  22235. $config = JsonFile::parseJson($json);
  22236. } else {
  22237. throw new \InvalidArgumentException(sprintf(
  22238. "JsonLoader: Unknown \$json parameter %s. Please report at https://github.com/composer/composer/issues/new.",
  22239. gettype($json)
  22240. ));
  22241. }
  22242. return $this->loader->load($config);
  22243. }
  22244. }
  22245. <?php declare(strict_types=1);
  22246. namespace Composer\Package\Loader;
  22247. use Composer\Package\CompletePackage;
  22248. use Composer\Package\CompleteAliasPackage;
  22249. use Composer\Package\RootAliasPackage;
  22250. use Composer\Package\RootPackage;
  22251. use Composer\Package\BasePackage;
  22252. interface LoaderInterface
  22253. {
  22254. public function load(array $config, string $class = 'Composer\Package\CompletePackage'): BasePackage;
  22255. }
  22256. <?php declare(strict_types=1);
  22257. namespace Composer\Package\Loader;
  22258. use Composer\Package\BasePackage;
  22259. use Composer\Config;
  22260. use Composer\IO\IOInterface;
  22261. use Composer\Package\RootAliasPackage;
  22262. use Composer\Pcre\Preg;
  22263. use Composer\Repository\RepositoryFactory;
  22264. use Composer\Package\Version\VersionGuesser;
  22265. use Composer\Package\Version\VersionParser;
  22266. use Composer\Package\RootPackage;
  22267. use Composer\Repository\RepositoryManager;
  22268. use Composer\Util\Platform;
  22269. use Composer\Util\ProcessExecutor;
  22270. class RootPackageLoader extends ArrayLoader
  22271. {
  22272. private $manager;
  22273. private $config;
  22274. private $versionGuesser;
  22275. public function __construct(RepositoryManager $manager, Config $config, VersionParser $parser = null, VersionGuesser $versionGuesser = null, IOInterface $io = null)
  22276. {
  22277. parent::__construct($parser);
  22278. $this->manager = $manager;
  22279. $this->config = $config;
  22280. $this->versionGuesser = $versionGuesser ?: new VersionGuesser($config, new ProcessExecutor($io), $this->versionParser);
  22281. }
  22282. public function load(array $config, string $class = 'Composer\Package\RootPackage', ?string $cwd = null): BasePackage
  22283. {
  22284. if ($class !== 'Composer\Package\RootPackage') {
  22285. trigger_error('The $class arg is deprecated, please reach out to Composer maintainers ASAP if you still need this.', E_USER_DEPRECATED);
  22286. }
  22287. if (!isset($config['name'])) {
  22288. $config['name'] = '__root__';
  22289. } elseif ($err = ValidatingArrayLoader::hasPackageNamingError($config['name'])) {
  22290. throw new \RuntimeException('Your package name '.$err);
  22291. }
  22292. $autoVersioned = false;
  22293. if (!isset($config['version'])) {
  22294. $commit = null;
  22295. if (Platform::getEnv('COMPOSER_ROOT_VERSION')) {
  22296. $config['version'] = Platform::getEnv('COMPOSER_ROOT_VERSION');
  22297. } else {
  22298. $versionData = $this->versionGuesser->guessVersion($config, $cwd ?? Platform::getCwd(true));
  22299. if ($versionData) {
  22300. $config['version'] = $versionData['pretty_version'];
  22301. $config['version_normalized'] = $versionData['version'];
  22302. $commit = $versionData['commit'];
  22303. }
  22304. }
  22305. if (!isset($config['version'])) {
  22306. $config['version'] = '1.0.0';
  22307. $autoVersioned = true;
  22308. }
  22309. if ($commit) {
  22310. $config['source'] = array(
  22311. 'type' => '',
  22312. 'url' => '',
  22313. 'reference' => $commit,
  22314. );
  22315. $config['dist'] = array(
  22316. 'type' => '',
  22317. 'url' => '',
  22318. 'reference' => $commit,
  22319. );
  22320. }
  22321. }
  22322. $package = parent::load($config, $class);
  22323. if ($package instanceof RootAliasPackage) {
  22324. $realPackage = $package->getAliasOf();
  22325. } else {
  22326. $realPackage = $package;
  22327. }
  22328. if (!$realPackage instanceof RootPackage) {
  22329. throw new \LogicException('Expecting a Composer\Package\RootPackage at this point');
  22330. }
  22331. if ($autoVersioned) {
  22332. $realPackage->replaceVersion($realPackage->getVersion(), RootPackage::DEFAULT_PRETTY_VERSION);
  22333. }
  22334. if (isset($config['minimum-stability'])) {
  22335. $realPackage->setMinimumStability(VersionParser::normalizeStability($config['minimum-stability']));
  22336. }
  22337. $aliases = array();
  22338. $stabilityFlags = array();
  22339. $references = array();
  22340. foreach (array('require', 'require-dev') as $linkType) {
  22341. if (isset($config[$linkType])) {
  22342. $linkInfo = BasePackage::$supportedLinkTypes[$linkType];
  22343. $method = 'get'.ucfirst($linkInfo['method']);
  22344. $links = array();
  22345. foreach ($realPackage->$method() as $link) {
  22346. $links[$link->getTarget()] = $link->getConstraint()->getPrettyString();
  22347. }
  22348. $aliases = $this->extractAliases($links, $aliases);
  22349. $stabilityFlags = self::extractStabilityFlags($links, $realPackage->getMinimumStability(), $stabilityFlags);
  22350. $references = self::extractReferences($links, $references);
  22351. if (isset($links[$config['name']])) {
  22352. throw new \RuntimeException(sprintf('Root package \'%s\' cannot require itself in its composer.json' . PHP_EOL .
  22353. 'Did you accidentally name your root package after an external package?', $config['name']));
  22354. }
  22355. }
  22356. }
  22357. foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
  22358. if (isset($config[$linkType])) {
  22359. foreach ($config[$linkType] as $linkName => $constraint) {
  22360. if ($err = ValidatingArrayLoader::hasPackageNamingError($linkName, true)) {
  22361. throw new \RuntimeException($linkType.'.'.$err);
  22362. }
  22363. }
  22364. }
  22365. }
  22366. $realPackage->setAliases($aliases);
  22367. $realPackage->setStabilityFlags($stabilityFlags);
  22368. $realPackage->setReferences($references);
  22369. if (isset($config['prefer-stable'])) {
  22370. $realPackage->setPreferStable((bool) $config['prefer-stable']);
  22371. }
  22372. if (isset($config['config'])) {
  22373. $realPackage->setConfig($config['config']);
  22374. }
  22375. $repos = RepositoryFactory::defaultRepos(null, $this->config, $this->manager);
  22376. foreach ($repos as $repo) {
  22377. $this->manager->addRepository($repo);
  22378. }
  22379. $realPackage->setRepositories($this->config->getRepositories());
  22380. return $package;
  22381. }
  22382. private function extractAliases(array $requires, array $aliases): array
  22383. {
  22384. foreach ($requires as $reqName => $reqVersion) {
  22385. if (Preg::isMatch('{^([^,\s#]+)(?:#[^ ]+)? +as +([^,\s]+)$}', $reqVersion, $match)) {
  22386. $aliases[] = array(
  22387. 'package' => strtolower($reqName),
  22388. 'version' => $this->versionParser->normalize($match[1], $reqVersion),
  22389. 'alias' => $match[2],
  22390. 'alias_normalized' => $this->versionParser->normalize($match[2], $reqVersion),
  22391. );
  22392. } elseif (strpos($reqVersion, ' as ') !== false) {
  22393. throw new \UnexpectedValueException('Invalid alias definition in "'.$reqName.'": "'.$reqVersion.'". Aliases should be in the form "exact-version as other-exact-version".');
  22394. }
  22395. }
  22396. return $aliases;
  22397. }
  22398. public static function extractStabilityFlags(array $requires, string $minimumStability, array $stabilityFlags): array
  22399. {
  22400. $stabilities = BasePackage::$stabilities;
  22401. $minimumStability = $stabilities[$minimumStability];
  22402. foreach ($requires as $reqName => $reqVersion) {
  22403. $constraints = array();
  22404. $orSplit = Preg::split('{\s*\|\|?\s*}', trim($reqVersion));
  22405. foreach ($orSplit as $orConstraint) {
  22406. $andSplit = Preg::split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $orConstraint);
  22407. foreach ($andSplit as $andConstraint) {
  22408. $constraints[] = $andConstraint;
  22409. }
  22410. }
  22411. $matched = false;
  22412. foreach ($constraints as $constraint) {
  22413. if (Preg::isMatch('{^[^@]*?@('.implode('|', array_keys($stabilities)).')$}i', $constraint, $match)) {
  22414. $name = strtolower($reqName);
  22415. $stability = $stabilities[VersionParser::normalizeStability($match[1])];
  22416. if (isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) {
  22417. continue;
  22418. }
  22419. $stabilityFlags[$name] = $stability;
  22420. $matched = true;
  22421. }
  22422. }
  22423. if ($matched) {
  22424. continue;
  22425. }
  22426. foreach ($constraints as $constraint) {
  22427. $reqVersion = Preg::replace('{^([^,\s@]+) as .+$}', '$1', $constraint);
  22428. if (Preg::isMatch('{^[^,\s@]+$}', $reqVersion) && 'stable' !== ($stabilityName = VersionParser::parseStability($reqVersion))) {
  22429. $name = strtolower($reqName);
  22430. $stability = $stabilities[$stabilityName];
  22431. if ((isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) || ($minimumStability > $stability)) {
  22432. continue;
  22433. }
  22434. $stabilityFlags[$name] = $stability;
  22435. }
  22436. }
  22437. }
  22438. return $stabilityFlags;
  22439. }
  22440. public static function extractReferences(array $requires, array $references): array
  22441. {
  22442. foreach ($requires as $reqName => $reqVersion) {
  22443. $reqVersion = Preg::replace('{^([^,\s@]+) as .+$}', '$1', $reqVersion);
  22444. if (Preg::isMatch('{^[^,\s@]+?#([a-f0-9]+)$}', $reqVersion, $match) && 'dev' === VersionParser::parseStability($reqVersion)) {
  22445. $name = strtolower($reqName);
  22446. $references[$name] = $match[1];
  22447. }
  22448. }
  22449. return $references;
  22450. }
  22451. }
  22452. <?php declare(strict_types=1);
  22453. namespace Composer\Package\Loader;
  22454. use Composer\Package\BasePackage;
  22455. use Composer\Pcre\Preg;
  22456. use Composer\Semver\Constraint\Constraint;
  22457. use Composer\Package\Version\VersionParser;
  22458. use Composer\Repository\PlatformRepository;
  22459. use Composer\Spdx\SpdxLicenses;
  22460. class ValidatingArrayLoader implements LoaderInterface
  22461. {
  22462. public const CHECK_ALL = 3;
  22463. public const CHECK_UNBOUND_CONSTRAINTS = 1;
  22464. public const CHECK_STRICT_CONSTRAINTS = 2;
  22465. private $loader;
  22466. private $versionParser;
  22467. private $errors;
  22468. private $warnings;
  22469. private $config;
  22470. private $flags;
  22471. public function __construct(LoaderInterface $loader, bool $strictName = true, VersionParser $parser = null, int $flags = 0)
  22472. {
  22473. $this->loader = $loader;
  22474. $this->versionParser = $parser ?: new VersionParser();
  22475. $this->flags = $flags;
  22476. if ($strictName !== true) {
  22477. trigger_error('$strictName must be set to true in ValidatingArrayLoader\'s constructor as of 2.2, and it will be removed in 3.0', E_USER_DEPRECATED);
  22478. }
  22479. }
  22480. public function load(array $config, string $class = 'Composer\Package\CompletePackage'): BasePackage
  22481. {
  22482. $this->errors = array();
  22483. $this->warnings = array();
  22484. $this->config = $config;
  22485. $this->validateString('name', true);
  22486. if ($err = self::hasPackageNamingError($config['name'])) {
  22487. $this->errors[] = 'name : '.$err;
  22488. }
  22489. if (!empty($this->config['version'])) {
  22490. if (!is_scalar($this->config['version'])) {
  22491. $this->validateString('version');
  22492. } else {
  22493. if (!is_string($this->config['version'])) {
  22494. $this->config['version'] = (string) $this->config['version'];
  22495. }
  22496. try {
  22497. $this->versionParser->normalize($this->config['version']);
  22498. } catch (\Exception $e) {
  22499. $this->errors[] = 'version : invalid value ('.$this->config['version'].'): '.$e->getMessage();
  22500. unset($this->config['version']);
  22501. }
  22502. }
  22503. }
  22504. if (!empty($this->config['config']['platform'])) {
  22505. foreach ((array) $this->config['config']['platform'] as $key => $platform) {
  22506. if (false === $platform) {
  22507. continue;
  22508. }
  22509. if (!is_string($platform)) {
  22510. $this->errors[] = 'config.platform.' . $key . ' : invalid value ('.gettype($platform).' '.var_export($platform, true).'): expected string or false';
  22511. continue;
  22512. }
  22513. try {
  22514. $this->versionParser->normalize($platform);
  22515. } catch (\Exception $e) {
  22516. $this->errors[] = 'config.platform.' . $key . ' : invalid value ('.$platform.'): '.$e->getMessage();
  22517. }
  22518. }
  22519. }
  22520. $this->validateRegex('type', '[A-Za-z0-9-]+');
  22521. $this->validateString('target-dir');
  22522. $this->validateArray('extra');
  22523. if (isset($this->config['bin'])) {
  22524. if (is_string($this->config['bin'])) {
  22525. $this->validateString('bin');
  22526. } else {
  22527. $this->validateFlatArray('bin');
  22528. }
  22529. }
  22530. $this->validateArray('scripts');
  22531. $this->validateString('description');
  22532. $this->validateUrl('homepage');
  22533. $this->validateFlatArray('keywords', '[\p{N}\p{L} ._-]+');
  22534. $releaseDate = null;
  22535. $this->validateString('time');
  22536. if (!empty($this->config['time'])) {
  22537. try {
  22538. $releaseDate = new \DateTime($this->config['time'], new \DateTimeZone('UTC'));
  22539. } catch (\Exception $e) {
  22540. $this->errors[] = 'time : invalid value ('.$this->config['time'].'): '.$e->getMessage();
  22541. unset($this->config['time']);
  22542. }
  22543. }
  22544. if (isset($this->config['license']) && (!$releaseDate || $releaseDate->getTimestamp() >= strtotime('-8days'))) {
  22545. if (is_array($this->config['license']) || is_string($this->config['license'])) {
  22546. $licenses = (array) $this->config['license'];
  22547. $licenseValidator = new SpdxLicenses();
  22548. foreach ($licenses as $license) {
  22549. if ('proprietary' === $license) {
  22550. continue;
  22551. }
  22552. $licenseToValidate = str_replace('proprietary', 'MIT', $license);
  22553. if (!$licenseValidator->validate($licenseToValidate)) {
  22554. if ($licenseValidator->validate(trim($licenseToValidate))) {
  22555. $this->warnings[] = sprintf(
  22556. 'License %s must not contain extra spaces, make sure to trim it.',
  22557. json_encode($license)
  22558. );
  22559. } else {
  22560. $this->warnings[] = sprintf(
  22561. 'License %s is not a valid SPDX license identifier, see https://spdx.org/licenses/ if you use an open license.' . PHP_EOL .
  22562. 'If the software is closed-source, you may use "proprietary" as license.',
  22563. json_encode($license)
  22564. );
  22565. }
  22566. }
  22567. }
  22568. }
  22569. }
  22570. if ($this->validateArray('authors') && !empty($this->config['authors'])) {
  22571. foreach ($this->config['authors'] as $key => $author) {
  22572. if (!is_array($author)) {
  22573. $this->errors[] = 'authors.'.$key.' : should be an array, '.gettype($author).' given';
  22574. unset($this->config['authors'][$key]);
  22575. continue;
  22576. }
  22577. foreach (array('homepage', 'email', 'name', 'role') as $authorData) {
  22578. if (isset($author[$authorData]) && !is_string($author[$authorData])) {
  22579. $this->errors[] = 'authors.'.$key.'.'.$authorData.' : invalid value, must be a string';
  22580. unset($this->config['authors'][$key][$authorData]);
  22581. }
  22582. }
  22583. if (isset($author['homepage']) && !$this->filterUrl($author['homepage'])) {
  22584. $this->warnings[] = 'authors.'.$key.'.homepage : invalid value ('.$author['homepage'].'), must be an http/https URL';
  22585. unset($this->config['authors'][$key]['homepage']);
  22586. }
  22587. if (isset($author['email']) && !filter_var($author['email'], FILTER_VALIDATE_EMAIL)) {
  22588. $this->warnings[] = 'authors.'.$key.'.email : invalid value ('.$author['email'].'), must be a valid email address';
  22589. unset($this->config['authors'][$key]['email']);
  22590. }
  22591. if (empty($this->config['authors'][$key])) {
  22592. unset($this->config['authors'][$key]);
  22593. }
  22594. }
  22595. if (empty($this->config['authors'])) {
  22596. unset($this->config['authors']);
  22597. }
  22598. }
  22599. if ($this->validateArray('support') && !empty($this->config['support'])) {
  22600. foreach (array('issues', 'forum', 'wiki', 'source', 'email', 'irc', 'docs', 'rss', 'chat') as $key) {
  22601. if (isset($this->config['support'][$key]) && !is_string($this->config['support'][$key])) {
  22602. $this->errors[] = 'support.'.$key.' : invalid value, must be a string';
  22603. unset($this->config['support'][$key]);
  22604. }
  22605. }
  22606. if (isset($this->config['support']['email']) && !filter_var($this->config['support']['email'], FILTER_VALIDATE_EMAIL)) {
  22607. $this->warnings[] = 'support.email : invalid value ('.$this->config['support']['email'].'), must be a valid email address';
  22608. unset($this->config['support']['email']);
  22609. }
  22610. if (isset($this->config['support']['irc']) && !$this->filterUrl($this->config['support']['irc'], array('irc', 'ircs'))) {
  22611. $this->warnings[] = 'support.irc : invalid value ('.$this->config['support']['irc'].'), must be a irc://<server>/<channel> or ircs:// URL';
  22612. unset($this->config['support']['irc']);
  22613. }
  22614. foreach (array('issues', 'forum', 'wiki', 'source', 'docs', 'chat') as $key) {
  22615. if (isset($this->config['support'][$key]) && !$this->filterUrl($this->config['support'][$key])) {
  22616. $this->warnings[] = 'support.'.$key.' : invalid value ('.$this->config['support'][$key].'), must be an http/https URL';
  22617. unset($this->config['support'][$key]);
  22618. }
  22619. }
  22620. if (empty($this->config['support'])) {
  22621. unset($this->config['support']);
  22622. }
  22623. }
  22624. if ($this->validateArray('funding') && !empty($this->config['funding'])) {
  22625. foreach ($this->config['funding'] as $key => $fundingOption) {
  22626. if (!is_array($fundingOption)) {
  22627. $this->errors[] = 'funding.'.$key.' : should be an array, '.gettype($fundingOption).' given';
  22628. unset($this->config['funding'][$key]);
  22629. continue;
  22630. }
  22631. foreach (array('type', 'url') as $fundingData) {
  22632. if (isset($fundingOption[$fundingData]) && !is_string($fundingOption[$fundingData])) {
  22633. $this->errors[] = 'funding.'.$key.'.'.$fundingData.' : invalid value, must be a string';
  22634. unset($this->config['funding'][$key][$fundingData]);
  22635. }
  22636. }
  22637. if (isset($fundingOption['url']) && !$this->filterUrl($fundingOption['url'])) {
  22638. $this->warnings[] = 'funding.'.$key.'.url : invalid value ('.$fundingOption['url'].'), must be an http/https URL';
  22639. unset($this->config['funding'][$key]['url']);
  22640. }
  22641. if (empty($this->config['funding'][$key])) {
  22642. unset($this->config['funding'][$key]);
  22643. }
  22644. }
  22645. if (empty($this->config['funding'])) {
  22646. unset($this->config['funding']);
  22647. }
  22648. }
  22649. $unboundConstraint = new Constraint('=', '10000000-dev');
  22650. $stableConstraint = new Constraint('=', '1.0.0');
  22651. foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
  22652. if ($this->validateArray($linkType) && isset($this->config[$linkType])) {
  22653. foreach ($this->config[$linkType] as $package => $constraint) {
  22654. if (0 === strcasecmp($package, $this->config['name'])) {
  22655. $this->errors[] = $linkType.'.'.$package.' : a package cannot set a '.$linkType.' on itself';
  22656. unset($this->config[$linkType][$package]);
  22657. continue;
  22658. }
  22659. if ($err = self::hasPackageNamingError($package, true)) {
  22660. $this->errors[] = $linkType.'.'.$err;
  22661. } elseif (!Preg::isMatch('{^[A-Za-z0-9_./-]+$}', $package)) {
  22662. $this->warnings[] = $linkType.'.'.$package.' : invalid key, package names must be strings containing only [A-Za-z0-9_./-]';
  22663. }
  22664. if (!is_string($constraint)) {
  22665. $this->errors[] = $linkType.'.'.$package.' : invalid value, must be a string containing a version constraint';
  22666. unset($this->config[$linkType][$package]);
  22667. } elseif ('self.version' !== $constraint) {
  22668. try {
  22669. $linkConstraint = $this->versionParser->parseConstraints($constraint);
  22670. } catch (\Exception $e) {
  22671. $this->errors[] = $linkType.'.'.$package.' : invalid version constraint ('.$e->getMessage().')';
  22672. unset($this->config[$linkType][$package]);
  22673. continue;
  22674. }
  22675. if (
  22676. ($this->flags & self::CHECK_UNBOUND_CONSTRAINTS)
  22677. && 'require' === $linkType
  22678. && $linkConstraint->matches($unboundConstraint)
  22679. && !PlatformRepository::isPlatformPackage($package)
  22680. ) {
  22681. $this->warnings[] = $linkType.'.'.$package.' : unbound version constraints ('.$constraint.') should be avoided';
  22682. } elseif (
  22683. ($this->flags & self::CHECK_STRICT_CONSTRAINTS)
  22684. && 'require' === $linkType
  22685. && $linkConstraint instanceof Constraint && in_array($linkConstraint->getOperator(), ['==', '='], true)
  22686. && (new Constraint('>=', '1.0.0.0-dev'))->matches($linkConstraint)
  22687. ) {
  22688. $this->warnings[] = $linkType.'.'.$package.' : exact version constraints ('.$constraint.') should be avoided if the package follows semantic versioning';
  22689. }
  22690. }
  22691. if ($linkType === 'conflict' && isset($this->config['replace']) && $keys = array_intersect_key($this->config['replace'], $this->config['conflict'])) {
  22692. $this->errors[] = $linkType.'.'.$package.' : you cannot conflict with a package that is also replaced, as replace already creates an implicit conflict rule';
  22693. unset($this->config[$linkType][$package]);
  22694. }
  22695. }
  22696. }
  22697. }
  22698. if ($this->validateArray('suggest') && !empty($this->config['suggest'])) {
  22699. foreach ($this->config['suggest'] as $package => $description) {
  22700. if (!is_string($description)) {
  22701. $this->errors[] = 'suggest.'.$package.' : invalid value, must be a string describing why the package is suggested';
  22702. unset($this->config['suggest'][$package]);
  22703. }
  22704. }
  22705. }
  22706. if ($this->validateString('minimum-stability') && !empty($this->config['minimum-stability'])) {
  22707. if (!isset(BasePackage::$stabilities[strtolower($this->config['minimum-stability'])]) && $this->config['minimum-stability'] !== 'RC') {
  22708. $this->errors[] = 'minimum-stability : invalid value ('.$this->config['minimum-stability'].'), must be one of '.implode(', ', array_keys(BasePackage::$stabilities));
  22709. unset($this->config['minimum-stability']);
  22710. }
  22711. }
  22712. if ($this->validateArray('autoload') && !empty($this->config['autoload'])) {
  22713. $types = array('psr-0', 'psr-4', 'classmap', 'files', 'exclude-from-classmap');
  22714. foreach ($this->config['autoload'] as $type => $typeConfig) {
  22715. if (!in_array($type, $types)) {
  22716. $this->errors[] = 'autoload : invalid value ('.$type.'), must be one of '.implode(', ', $types);
  22717. unset($this->config['autoload'][$type]);
  22718. }
  22719. if ($type === 'psr-4') {
  22720. foreach ($typeConfig as $namespace => $dirs) {
  22721. if ($namespace !== '' && '\\' !== substr($namespace, -1)) {
  22722. $this->errors[] = 'autoload.psr-4 : invalid value ('.$namespace.'), namespaces must end with a namespace separator, should be '.$namespace.'\\\\';
  22723. }
  22724. }
  22725. }
  22726. }
  22727. }
  22728. if (!empty($this->config['autoload']['psr-4']) && !empty($this->config['target-dir'])) {
  22729. $this->errors[] = 'target-dir : this can not be used together with the autoload.psr-4 setting, remove target-dir to upgrade to psr-4';
  22730. unset($this->config['autoload']['psr-4']);
  22731. }
  22732. foreach (array('source', 'dist') as $srcType) {
  22733. if ($this->validateArray($srcType) && !empty($this->config[$srcType])) {
  22734. if (!isset($this->config[$srcType]['type'])) {
  22735. $this->errors[] = $srcType . '.type : must be present';
  22736. }
  22737. if (!isset($this->config[$srcType]['url'])) {
  22738. $this->errors[] = $srcType . '.url : must be present';
  22739. }
  22740. if ($srcType === 'source' && !isset($this->config[$srcType]['reference'])) {
  22741. $this->errors[] = $srcType . '.reference : must be present';
  22742. }
  22743. if (isset($this->config[$srcType]['type']) && !is_string($this->config[$srcType]['type'])) {
  22744. $this->errors[] = $srcType . '.type : should be a string, '.gettype($this->config[$srcType]['type']).' given';
  22745. }
  22746. if (isset($this->config[$srcType]['url']) && !is_string($this->config[$srcType]['url'])) {
  22747. $this->errors[] = $srcType . '.url : should be a string, '.gettype($this->config[$srcType]['url']).' given';
  22748. }
  22749. if (isset($this->config[$srcType]['reference']) && !is_string($this->config[$srcType]['reference']) && !is_int($this->config[$srcType]['reference'])) {
  22750. $this->errors[] = $srcType . '.reference : should be a string or int, '.gettype($this->config[$srcType]['reference']).' given';
  22751. }
  22752. if (isset($this->config[$srcType]['reference']) && Preg::isMatch('{^\s*-}', (string) $this->config[$srcType]['reference'])) {
  22753. $this->errors[] = $srcType . '.reference : must not start with a "-", "'.$this->config[$srcType]['reference'].'" given';
  22754. }
  22755. if (isset($this->config[$srcType]['url']) && Preg::isMatch('{^\s*-}', (string) $this->config[$srcType]['url'])) {
  22756. $this->errors[] = $srcType . '.url : must not start with a "-", "'.$this->config[$srcType]['url'].'" given';
  22757. }
  22758. }
  22759. }
  22760. $this->validateFlatArray('include-path');
  22761. $this->validateArray('transport-options');
  22762. if (isset($this->config['extra']['branch-alias'])) {
  22763. if (!is_array($this->config['extra']['branch-alias'])) {
  22764. $this->errors[] = 'extra.branch-alias : must be an array of versions => aliases';
  22765. } else {
  22766. foreach ($this->config['extra']['branch-alias'] as $sourceBranch => $targetBranch) {
  22767. if (!is_string($targetBranch)) {
  22768. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.json_encode($targetBranch).') must be a string, "'.gettype($targetBranch).'" received.';
  22769. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  22770. continue;
  22771. }
  22772. if ('-dev' !== substr($targetBranch, -4)) {
  22773. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') must end in -dev';
  22774. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  22775. continue;
  22776. }
  22777. $validatedTargetBranch = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4));
  22778. if ('-dev' !== substr($validatedTargetBranch, -4)) {
  22779. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') must be a parseable number like 2.0-dev';
  22780. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  22781. continue;
  22782. }
  22783. if (($sourcePrefix = $this->versionParser->parseNumericAliasPrefix($sourceBranch))
  22784. && ($targetPrefix = $this->versionParser->parseNumericAliasPrefix($targetBranch))
  22785. && (stripos($targetPrefix, $sourcePrefix) !== 0)
  22786. ) {
  22787. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') is not a valid numeric alias for this version';
  22788. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  22789. }
  22790. }
  22791. }
  22792. }
  22793. if ($this->errors) {
  22794. throw new InvalidPackageException($this->errors, $this->warnings, $config);
  22795. }
  22796. $package = $this->loader->load($this->config, $class);
  22797. $this->config = array();
  22798. return $package;
  22799. }
  22800. public function getWarnings(): array
  22801. {
  22802. return $this->warnings;
  22803. }
  22804. public function getErrors(): array
  22805. {
  22806. return $this->errors;
  22807. }
  22808. public static function hasPackageNamingError(string $name, bool $isLink = false): ?string
  22809. {
  22810. if (PlatformRepository::isPlatformPackage($name)) {
  22811. return null;
  22812. }
  22813. if (!Preg::isMatch('{^[a-z0-9](?:[_.-]?[a-z0-9]+)*/[a-z0-9](?:(?:[_.]?|-{0,2})[a-z0-9]+)*$}iD', $name)) {
  22814. return $name.' is invalid, it should have a vendor name, a forward slash, and a package name. The vendor and package name can be words separated by -, . or _. The complete name should match "^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$".';
  22815. }
  22816. $reservedNames = array('nul', 'con', 'prn', 'aux', 'com1', 'com2', 'com3', 'com4', 'com5', 'com6', 'com7', 'com8', 'com9', 'lpt1', 'lpt2', 'lpt3', 'lpt4', 'lpt5', 'lpt6', 'lpt7', 'lpt8', 'lpt9');
  22817. $bits = explode('/', strtolower($name));
  22818. if (in_array($bits[0], $reservedNames, true) || in_array($bits[1], $reservedNames, true)) {
  22819. return $name.' is reserved, package and vendor names can not match any of: '.implode(', ', $reservedNames).'.';
  22820. }
  22821. if (Preg::isMatch('{\.json$}', $name)) {
  22822. return $name.' is invalid, package names can not end in .json, consider renaming it or perhaps using a -json suffix instead.';
  22823. }
  22824. if (Preg::isMatch('{[A-Z]}', $name)) {
  22825. if ($isLink) {
  22826. return $name.' is invalid, it should not contain uppercase characters. Please use '.strtolower($name).' instead.';
  22827. }
  22828. $suggestName = Preg::replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name);
  22829. $suggestName = strtolower($suggestName);
  22830. return $name.' is invalid, it should not contain uppercase characters. We suggest using '.$suggestName.' instead.';
  22831. }
  22832. return null;
  22833. }
  22834. private function validateRegex(string $property, string $regex, bool $mandatory = false): bool
  22835. {
  22836. if (!$this->validateString($property, $mandatory)) {
  22837. return false;
  22838. }
  22839. if (!Preg::isMatch('{^'.$regex.'$}u', $this->config[$property])) {
  22840. $message = $property.' : invalid value ('.$this->config[$property].'), must match '.$regex;
  22841. if ($mandatory) {
  22842. $this->errors[] = $message;
  22843. } else {
  22844. $this->warnings[] = $message;
  22845. }
  22846. unset($this->config[$property]);
  22847. return false;
  22848. }
  22849. return true;
  22850. }
  22851. private function validateString(string $property, bool $mandatory = false): bool
  22852. {
  22853. if (isset($this->config[$property]) && !is_string($this->config[$property])) {
  22854. $this->errors[] = $property.' : should be a string, '.gettype($this->config[$property]).' given';
  22855. unset($this->config[$property]);
  22856. return false;
  22857. }
  22858. if (!isset($this->config[$property]) || trim($this->config[$property]) === '') {
  22859. if ($mandatory) {
  22860. $this->errors[] = $property.' : must be present';
  22861. }
  22862. unset($this->config[$property]);
  22863. return false;
  22864. }
  22865. return true;
  22866. }
  22867. private function validateArray(string $property, bool $mandatory = false): bool
  22868. {
  22869. if (isset($this->config[$property]) && !is_array($this->config[$property])) {
  22870. $this->errors[] = $property.' : should be an array, '.gettype($this->config[$property]).' given';
  22871. unset($this->config[$property]);
  22872. return false;
  22873. }
  22874. if (!isset($this->config[$property]) || !count($this->config[$property])) {
  22875. if ($mandatory) {
  22876. $this->errors[] = $property.' : must be present and contain at least one element';
  22877. }
  22878. unset($this->config[$property]);
  22879. return false;
  22880. }
  22881. return true;
  22882. }
  22883. private function validateFlatArray(string $property, ?string $regex = null, bool $mandatory = false): bool
  22884. {
  22885. if (!$this->validateArray($property, $mandatory)) {
  22886. return false;
  22887. }
  22888. $pass = true;
  22889. foreach ($this->config[$property] as $key => $value) {
  22890. if (!is_string($value) && !is_numeric($value)) {
  22891. $this->errors[] = $property.'.'.$key.' : must be a string or int, '.gettype($value).' given';
  22892. unset($this->config[$property][$key]);
  22893. $pass = false;
  22894. continue;
  22895. }
  22896. if ($regex && !Preg::isMatch('{^'.$regex.'$}u', $value)) {
  22897. $this->warnings[] = $property.'.'.$key.' : invalid value ('.$value.'), must match '.$regex;
  22898. unset($this->config[$property][$key]);
  22899. $pass = false;
  22900. }
  22901. }
  22902. return $pass;
  22903. }
  22904. private function validateUrl(string $property, bool $mandatory = false): bool
  22905. {
  22906. if (!$this->validateString($property, $mandatory)) {
  22907. return false;
  22908. }
  22909. if (!$this->filterUrl($this->config[$property])) {
  22910. $this->warnings[] = $property.' : invalid value ('.$this->config[$property].'), must be an http/https URL';
  22911. unset($this->config[$property]);
  22912. return false;
  22913. }
  22914. return true;
  22915. }
  22916. private function filterUrl($value, array $schemes = array('http', 'https')): bool
  22917. {
  22918. if ($value === '') {
  22919. return true;
  22920. }
  22921. $bits = parse_url($value);
  22922. if (empty($bits['scheme']) || empty($bits['host'])) {
  22923. return false;
  22924. }
  22925. if (!in_array($bits['scheme'], $schemes, true)) {
  22926. return false;
  22927. }
  22928. return true;
  22929. }
  22930. }
  22931. <?php declare(strict_types=1);
  22932. namespace Composer\Package;
  22933. use Composer\Json\JsonFile;
  22934. use Composer\Installer\InstallationManager;
  22935. use Composer\Pcre\Preg;
  22936. use Composer\Repository\LockArrayRepository;
  22937. use Composer\Util\ProcessExecutor;
  22938. use Composer\Package\Dumper\ArrayDumper;
  22939. use Composer\Package\Loader\ArrayLoader;
  22940. use Composer\Package\Version\VersionParser;
  22941. use Composer\Plugin\PluginInterface;
  22942. use Composer\Util\Git as GitUtil;
  22943. use Composer\IO\IOInterface;
  22944. use Seld\JsonLint\ParsingException;
  22945. class Locker
  22946. {
  22947. private $lockFile;
  22948. private $installationManager;
  22949. private $hash;
  22950. private $contentHash;
  22951. private $loader;
  22952. private $dumper;
  22953. private $process;
  22954. private $lockDataCache = null;
  22955. private $virtualFileWritten = false;
  22956. public function __construct(IOInterface $io, JsonFile $lockFile, InstallationManager $installationManager, string $composerFileContents, ProcessExecutor $process = null)
  22957. {
  22958. $this->lockFile = $lockFile;
  22959. $this->installationManager = $installationManager;
  22960. $this->hash = md5($composerFileContents);
  22961. $this->contentHash = self::getContentHash($composerFileContents);
  22962. $this->loader = new ArrayLoader(null, true);
  22963. $this->dumper = new ArrayDumper();
  22964. $this->process = $process ?? new ProcessExecutor($io);
  22965. }
  22966. public static function getContentHash(string $composerFileContents): string
  22967. {
  22968. $content = JsonFile::parseJson($composerFileContents, 'composer.json');
  22969. $relevantKeys = array(
  22970. 'name',
  22971. 'version',
  22972. 'require',
  22973. 'require-dev',
  22974. 'conflict',
  22975. 'replace',
  22976. 'provide',
  22977. 'minimum-stability',
  22978. 'prefer-stable',
  22979. 'repositories',
  22980. 'extra',
  22981. );
  22982. $relevantContent = array();
  22983. foreach (array_intersect($relevantKeys, array_keys($content)) as $key) {
  22984. $relevantContent[$key] = $content[$key];
  22985. }
  22986. if (isset($content['config']['platform'])) {
  22987. $relevantContent['config']['platform'] = $content['config']['platform'];
  22988. }
  22989. ksort($relevantContent);
  22990. return md5(JsonFile::encode($relevantContent, 0));
  22991. }
  22992. public function isLocked(): bool
  22993. {
  22994. if (!$this->virtualFileWritten && !$this->lockFile->exists()) {
  22995. return false;
  22996. }
  22997. $data = $this->getLockData();
  22998. return isset($data['packages']);
  22999. }
  23000. public function isFresh(): bool
  23001. {
  23002. $lock = $this->lockFile->read();
  23003. if (!empty($lock['content-hash'])) {
  23004. return $this->contentHash === $lock['content-hash'];
  23005. }
  23006. if (!empty($lock['hash'])) {
  23007. return $this->hash === $lock['hash'];
  23008. }
  23009. return false;
  23010. }
  23011. public function getLockedRepository(bool $withDevReqs = false): LockArrayRepository
  23012. {
  23013. $lockData = $this->getLockData();
  23014. $packages = new LockArrayRepository();
  23015. $lockedPackages = $lockData['packages'];
  23016. if ($withDevReqs) {
  23017. if (isset($lockData['packages-dev'])) {
  23018. $lockedPackages = array_merge($lockedPackages, $lockData['packages-dev']);
  23019. } else {
  23020. throw new \RuntimeException('The lock file does not contain require-dev information, run install with the --no-dev option or delete it and run composer update to generate a new lock file.');
  23021. }
  23022. }
  23023. if (empty($lockedPackages)) {
  23024. return $packages;
  23025. }
  23026. if (isset($lockedPackages[0]['name'])) {
  23027. $packageByName = array();
  23028. foreach ($lockedPackages as $info) {
  23029. $package = $this->loader->load($info);
  23030. $packages->addPackage($package);
  23031. $packageByName[$package->getName()] = $package;
  23032. if ($package instanceof AliasPackage) {
  23033. $packageByName[$package->getAliasOf()->getName()] = $package->getAliasOf();
  23034. }
  23035. }
  23036. if (isset($lockData['aliases'])) {
  23037. foreach ($lockData['aliases'] as $alias) {
  23038. if (isset($packageByName[$alias['package']])) {
  23039. $aliasPkg = new CompleteAliasPackage($packageByName[$alias['package']], $alias['alias_normalized'], $alias['alias']);
  23040. $aliasPkg->setRootPackageAlias(true);
  23041. $packages->addPackage($aliasPkg);
  23042. }
  23043. }
  23044. }
  23045. return $packages;
  23046. }
  23047. throw new \RuntimeException('Your composer.lock is invalid. Run "composer update" to generate a new one.');
  23048. }
  23049. public function getDevPackageNames(): array
  23050. {
  23051. $names = array();
  23052. $lockData = $this->getLockData();
  23053. if (isset($lockData['packages-dev'])) {
  23054. foreach ($lockData['packages-dev'] as $package) {
  23055. $names[] = strtolower($package['name']);
  23056. }
  23057. }
  23058. return $names;
  23059. }
  23060. public function getPlatformRequirements(bool $withDevReqs = false): array
  23061. {
  23062. $lockData = $this->getLockData();
  23063. $requirements = array();
  23064. if (!empty($lockData['platform'])) {
  23065. $requirements = $this->loader->parseLinks(
  23066. '__root__',
  23067. '1.0.0',
  23068. Link::TYPE_REQUIRE,
  23069. $lockData['platform'] ?? array()
  23070. );
  23071. }
  23072. if ($withDevReqs && !empty($lockData['platform-dev'])) {
  23073. $devRequirements = $this->loader->parseLinks(
  23074. '__root__',
  23075. '1.0.0',
  23076. Link::TYPE_REQUIRE,
  23077. $lockData['platform-dev'] ?? array()
  23078. );
  23079. $requirements = array_merge($requirements, $devRequirements);
  23080. }
  23081. return $requirements;
  23082. }
  23083. public function getMinimumStability(): string
  23084. {
  23085. $lockData = $this->getLockData();
  23086. return $lockData['minimum-stability'] ?? 'stable';
  23087. }
  23088. public function getStabilityFlags(): array
  23089. {
  23090. $lockData = $this->getLockData();
  23091. return $lockData['stability-flags'] ?? array();
  23092. }
  23093. public function getPreferStable(): ?bool
  23094. {
  23095. $lockData = $this->getLockData();
  23096. return $lockData['prefer-stable'] ?? null;
  23097. }
  23098. public function getPreferLowest(): ?bool
  23099. {
  23100. $lockData = $this->getLockData();
  23101. return $lockData['prefer-lowest'] ?? null;
  23102. }
  23103. public function getPlatformOverrides(): array
  23104. {
  23105. $lockData = $this->getLockData();
  23106. return $lockData['platform-overrides'] ?? array();
  23107. }
  23108. public function getAliases(): array
  23109. {
  23110. $lockData = $this->getLockData();
  23111. return $lockData['aliases'] ?? array();
  23112. }
  23113. public function getLockData(): array
  23114. {
  23115. if (null !== $this->lockDataCache) {
  23116. return $this->lockDataCache;
  23117. }
  23118. if (!$this->lockFile->exists()) {
  23119. throw new \LogicException('No lockfile found. Unable to read locked packages');
  23120. }
  23121. return $this->lockDataCache = $this->lockFile->read();
  23122. }
  23123. public function setLockData(array $packages, ?array $devPackages, array $platformReqs, array $platformDevReqs, array $aliases, string $minimumStability, array $stabilityFlags, bool $preferStable, bool $preferLowest, array $platformOverrides, bool $write = true): bool
  23124. {
  23125. $aliases = array_map(function ($alias): array {
  23126. if (in_array($alias['version'], array('dev-master', 'dev-trunk', 'dev-default'), true)) {
  23127. $alias['version'] = VersionParser::DEFAULT_BRANCH_ALIAS;
  23128. }
  23129. return $alias;
  23130. }, $aliases);
  23131. $lock = array(
  23132. '_readme' => array('This file locks the dependencies of your project to a known state',
  23133. 'Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies',
  23134. 'This file is @gener'.'ated automatically', ),
  23135. 'content-hash' => $this->contentHash,
  23136. 'packages' => null,
  23137. 'packages-dev' => null,
  23138. 'aliases' => $aliases,
  23139. 'minimum-stability' => $minimumStability,
  23140. 'stability-flags' => $stabilityFlags,
  23141. 'prefer-stable' => $preferStable,
  23142. 'prefer-lowest' => $preferLowest,
  23143. );
  23144. $lock['packages'] = $this->lockPackages($packages);
  23145. if (null !== $devPackages) {
  23146. $lock['packages-dev'] = $this->lockPackages($devPackages);
  23147. }
  23148. $lock['platform'] = $platformReqs;
  23149. $lock['platform-dev'] = $platformDevReqs;
  23150. if ($platformOverrides) {
  23151. $lock['platform-overrides'] = $platformOverrides;
  23152. }
  23153. $lock['plugin-api-version'] = PluginInterface::PLUGIN_API_VERSION;
  23154. try {
  23155. $isLocked = $this->isLocked();
  23156. } catch (ParsingException $e) {
  23157. $isLocked = false;
  23158. }
  23159. if (!$isLocked || $lock !== $this->getLockData()) {
  23160. if ($write) {
  23161. $this->lockFile->write($lock);
  23162. $this->lockDataCache = null;
  23163. $this->virtualFileWritten = false;
  23164. } else {
  23165. $this->virtualFileWritten = true;
  23166. $this->lockDataCache = JsonFile::parseJson(JsonFile::encode($lock));
  23167. }
  23168. return true;
  23169. }
  23170. return false;
  23171. }
  23172. private function lockPackages(array $packages): array
  23173. {
  23174. $locked = array();
  23175. foreach ($packages as $package) {
  23176. if ($package instanceof AliasPackage) {
  23177. continue;
  23178. }
  23179. $name = $package->getPrettyName();
  23180. $version = $package->getPrettyVersion();
  23181. if (!$name || !$version) {
  23182. throw new \LogicException(sprintf(
  23183. 'Package "%s" has no version or name and can not be locked',
  23184. $package
  23185. ));
  23186. }
  23187. $spec = $this->dumper->dump($package);
  23188. unset($spec['version_normalized']);
  23189. $time = $spec['time'] ?? null;
  23190. unset($spec['time']);
  23191. if ($package->isDev() && $package->getInstallationSource() === 'source') {
  23192. $time = $this->getPackageTime($package) ?: $time;
  23193. }
  23194. if (null !== $time) {
  23195. $spec['time'] = $time;
  23196. }
  23197. unset($spec['installation-source']);
  23198. $locked[] = $spec;
  23199. }
  23200. usort($locked, function ($a, $b) {
  23201. $comparison = strcmp($a['name'], $b['name']);
  23202. if (0 !== $comparison) {
  23203. return $comparison;
  23204. }
  23205. return strcmp($a['version'], $b['version']);
  23206. });
  23207. return $locked;
  23208. }
  23209. private function getPackageTime(PackageInterface $package): ?string
  23210. {
  23211. if (!function_exists('proc_open')) {
  23212. return null;
  23213. }
  23214. $path = realpath($this->installationManager->getInstallPath($package));
  23215. $sourceType = $package->getSourceType();
  23216. $datetime = null;
  23217. if ($path && in_array($sourceType, array('git', 'hg'))) {
  23218. $sourceRef = $package->getSourceReference() ?: $package->getDistReference();
  23219. switch ($sourceType) {
  23220. case 'git':
  23221. GitUtil::cleanEnv();
  23222. if (0 === $this->process->execute('git log -n1 --pretty=%ct '.ProcessExecutor::escape($sourceRef).GitUtil::getNoShowSignatureFlag($this->process), $output, $path) && Preg::isMatch('{^\s*\d+\s*$}', $output)) {
  23223. $datetime = new \DateTime('@'.trim($output), new \DateTimeZone('UTC'));
  23224. }
  23225. break;
  23226. case 'hg':
  23227. if (0 === $this->process->execute('hg log --template "{date|hgdate}" -r '.ProcessExecutor::escape($sourceRef), $output, $path) && Preg::isMatch('{^\s*(\d+)\s*}', $output, $match)) {
  23228. $datetime = new \DateTime('@'.$match[1], new \DateTimeZone('UTC'));
  23229. }
  23230. break;
  23231. }
  23232. }
  23233. return $datetime ? $datetime->format(DATE_RFC3339) : null;
  23234. }
  23235. }
  23236. <?php declare(strict_types=1);
  23237. namespace Composer\Package;
  23238. use Composer\Package\Version\VersionParser;
  23239. use Composer\Pcre\Preg;
  23240. use Composer\Util\ComposerMirror;
  23241. class Package extends BasePackage
  23242. {
  23243. protected $type;
  23244. protected $targetDir;
  23245. protected $installationSource;
  23246. protected $sourceType;
  23247. protected $sourceUrl;
  23248. protected $sourceReference;
  23249. protected $sourceMirrors;
  23250. protected $distType;
  23251. protected $distUrl;
  23252. protected $distReference;
  23253. protected $distSha1Checksum;
  23254. protected $distMirrors;
  23255. protected $version;
  23256. protected $prettyVersion;
  23257. protected $releaseDate;
  23258. protected $extra = array();
  23259. protected $binaries = array();
  23260. protected $dev;
  23261. protected $stability;
  23262. protected $notificationUrl;
  23263. protected $requires = array();
  23264. protected $conflicts = array();
  23265. protected $provides = array();
  23266. protected $replaces = array();
  23267. protected $devRequires = array();
  23268. protected $suggests = array();
  23269. protected $autoload = array();
  23270. protected $devAutoload = array();
  23271. protected $includePaths = array();
  23272. protected $isDefaultBranch = false;
  23273. protected $transportOptions = array();
  23274. public function __construct(string $name, string $version, string $prettyVersion)
  23275. {
  23276. parent::__construct($name);
  23277. $this->version = $version;
  23278. $this->prettyVersion = $prettyVersion;
  23279. $this->stability = VersionParser::parseStability($version);
  23280. $this->dev = $this->stability === 'dev';
  23281. }
  23282. public function isDev(): bool
  23283. {
  23284. return $this->dev;
  23285. }
  23286. public function setType(string $type): void
  23287. {
  23288. $this->type = $type;
  23289. }
  23290. public function getType(): string
  23291. {
  23292. return $this->type ?: 'library';
  23293. }
  23294. public function getStability(): string
  23295. {
  23296. return $this->stability;
  23297. }
  23298. public function setTargetDir(?string $targetDir): void
  23299. {
  23300. $this->targetDir = $targetDir;
  23301. }
  23302. public function getTargetDir(): ?string
  23303. {
  23304. if (null === $this->targetDir) {
  23305. return null;
  23306. }
  23307. return ltrim(Preg::replace('{ (?:^|[\\\\/]+) \.\.? (?:[\\\\/]+|$) (?:\.\.? (?:[\\\\/]+|$) )*}x', '/', $this->targetDir), '/');
  23308. }
  23309. public function setExtra(array $extra): void
  23310. {
  23311. $this->extra = $extra;
  23312. }
  23313. public function getExtra(): array
  23314. {
  23315. return $this->extra;
  23316. }
  23317. public function setBinaries(array $binaries): void
  23318. {
  23319. $this->binaries = $binaries;
  23320. }
  23321. public function getBinaries(): array
  23322. {
  23323. return $this->binaries;
  23324. }
  23325. public function setInstallationSource(?string $type): void
  23326. {
  23327. $this->installationSource = $type;
  23328. }
  23329. public function getInstallationSource(): ?string
  23330. {
  23331. return $this->installationSource;
  23332. }
  23333. public function setSourceType(?string $type): void
  23334. {
  23335. $this->sourceType = $type;
  23336. }
  23337. public function getSourceType(): ?string
  23338. {
  23339. return $this->sourceType;
  23340. }
  23341. public function setSourceUrl(?string $url): void
  23342. {
  23343. $this->sourceUrl = $url;
  23344. }
  23345. public function getSourceUrl(): ?string
  23346. {
  23347. return $this->sourceUrl;
  23348. }
  23349. public function setSourceReference(?string $reference): void
  23350. {
  23351. $this->sourceReference = $reference;
  23352. }
  23353. public function getSourceReference(): ?string
  23354. {
  23355. return $this->sourceReference;
  23356. }
  23357. public function setSourceMirrors(?array $mirrors): void
  23358. {
  23359. $this->sourceMirrors = $mirrors;
  23360. }
  23361. public function getSourceMirrors(): ?array
  23362. {
  23363. return $this->sourceMirrors;
  23364. }
  23365. public function getSourceUrls(): array
  23366. {
  23367. return $this->getUrls($this->sourceUrl, $this->sourceMirrors, $this->sourceReference, $this->sourceType, 'source');
  23368. }
  23369. public function setDistType(?string $type): void
  23370. {
  23371. $this->distType = $type;
  23372. }
  23373. public function getDistType(): ?string
  23374. {
  23375. return $this->distType;
  23376. }
  23377. public function setDistUrl(?string $url): void
  23378. {
  23379. $this->distUrl = $url;
  23380. }
  23381. public function getDistUrl(): ?string
  23382. {
  23383. return $this->distUrl;
  23384. }
  23385. public function setDistReference(?string $reference): void
  23386. {
  23387. $this->distReference = $reference;
  23388. }
  23389. public function getDistReference(): ?string
  23390. {
  23391. return $this->distReference;
  23392. }
  23393. public function setDistSha1Checksum(?string $sha1checksum): void
  23394. {
  23395. $this->distSha1Checksum = $sha1checksum;
  23396. }
  23397. public function getDistSha1Checksum(): ?string
  23398. {
  23399. return $this->distSha1Checksum;
  23400. }
  23401. public function setDistMirrors(?array $mirrors): void
  23402. {
  23403. $this->distMirrors = $mirrors;
  23404. }
  23405. public function getDistMirrors(): ?array
  23406. {
  23407. return $this->distMirrors;
  23408. }
  23409. public function getDistUrls(): array
  23410. {
  23411. return $this->getUrls($this->distUrl, $this->distMirrors, $this->distReference, $this->distType, 'dist');
  23412. }
  23413. public function getTransportOptions(): array
  23414. {
  23415. return $this->transportOptions;
  23416. }
  23417. public function setTransportOptions(array $options): void
  23418. {
  23419. $this->transportOptions = $options;
  23420. }
  23421. public function getVersion(): string
  23422. {
  23423. return $this->version;
  23424. }
  23425. public function getPrettyVersion(): string
  23426. {
  23427. return $this->prettyVersion;
  23428. }
  23429. public function setReleaseDate(?\DateTimeInterface $releaseDate): void
  23430. {
  23431. $this->releaseDate = $releaseDate;
  23432. }
  23433. public function getReleaseDate(): ?\DateTimeInterface
  23434. {
  23435. return $this->releaseDate;
  23436. }
  23437. public function setRequires(array $requires): void
  23438. {
  23439. if (isset($requires[0])) {
  23440. $requires = $this->convertLinksToMap($requires, 'setRequires');
  23441. }
  23442. $this->requires = $requires;
  23443. }
  23444. public function getRequires(): array
  23445. {
  23446. return $this->requires;
  23447. }
  23448. public function setConflicts(array $conflicts): void
  23449. {
  23450. if (isset($conflicts[0])) {
  23451. $conflicts = $this->convertLinksToMap($conflicts, 'setConflicts');
  23452. }
  23453. $this->conflicts = $conflicts;
  23454. }
  23455. public function getConflicts(): array
  23456. {
  23457. return $this->conflicts;
  23458. }
  23459. public function setProvides(array $provides): void
  23460. {
  23461. if (isset($provides[0])) {
  23462. $provides = $this->convertLinksToMap($provides, 'setProvides');
  23463. }
  23464. $this->provides = $provides;
  23465. }
  23466. public function getProvides(): array
  23467. {
  23468. return $this->provides;
  23469. }
  23470. public function setReplaces(array $replaces): void
  23471. {
  23472. if (isset($replaces[0])) {
  23473. $replaces = $this->convertLinksToMap($replaces, 'setReplaces');
  23474. }
  23475. $this->replaces = $replaces;
  23476. }
  23477. public function getReplaces(): array
  23478. {
  23479. return $this->replaces;
  23480. }
  23481. public function setDevRequires(array $devRequires): void
  23482. {
  23483. if (isset($devRequires[0])) {
  23484. $devRequires = $this->convertLinksToMap($devRequires, 'setDevRequires');
  23485. }
  23486. $this->devRequires = $devRequires;
  23487. }
  23488. public function getDevRequires(): array
  23489. {
  23490. return $this->devRequires;
  23491. }
  23492. public function setSuggests(array $suggests): void
  23493. {
  23494. $this->suggests = $suggests;
  23495. }
  23496. public function getSuggests(): array
  23497. {
  23498. return $this->suggests;
  23499. }
  23500. public function setAutoload(array $autoload): void
  23501. {
  23502. $this->autoload = $autoload;
  23503. }
  23504. public function getAutoload(): array
  23505. {
  23506. return $this->autoload;
  23507. }
  23508. public function setDevAutoload(array $devAutoload): void
  23509. {
  23510. $this->devAutoload = $devAutoload;
  23511. }
  23512. public function getDevAutoload(): array
  23513. {
  23514. return $this->devAutoload;
  23515. }
  23516. public function setIncludePaths(array $includePaths): void
  23517. {
  23518. $this->includePaths = $includePaths;
  23519. }
  23520. public function getIncludePaths(): array
  23521. {
  23522. return $this->includePaths;
  23523. }
  23524. public function setNotificationUrl(string $notificationUrl): void
  23525. {
  23526. $this->notificationUrl = $notificationUrl;
  23527. }
  23528. public function getNotificationUrl(): ?string
  23529. {
  23530. return $this->notificationUrl;
  23531. }
  23532. public function setIsDefaultBranch(bool $defaultBranch): void
  23533. {
  23534. $this->isDefaultBranch = $defaultBranch;
  23535. }
  23536. public function isDefaultBranch(): bool
  23537. {
  23538. return $this->isDefaultBranch;
  23539. }
  23540. public function setSourceDistReferences(string $reference): void
  23541. {
  23542. $this->setSourceReference($reference);
  23543. if (
  23544. $this->getDistUrl() !== null
  23545. && Preg::isMatch('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com|(?:www\.)?gitlab\.com)/}i', $this->getDistUrl())
  23546. ) {
  23547. $this->setDistReference($reference);
  23548. $this->setDistUrl(Preg::replace('{(?<=/|sha=)[a-f0-9]{40}(?=/|$)}i', $reference, $this->getDistUrl()));
  23549. } elseif ($this->getDistReference()) {
  23550. $this->setDistReference($reference);
  23551. }
  23552. }
  23553. public function replaceVersion(string $version, string $prettyVersion): void
  23554. {
  23555. $this->version = $version;
  23556. $this->prettyVersion = $prettyVersion;
  23557. $this->stability = VersionParser::parseStability($version);
  23558. $this->dev = $this->stability === 'dev';
  23559. }
  23560. protected function getUrls(?string $url, ?array $mirrors, ?string $ref, ?string $type, string $urlType): array
  23561. {
  23562. if (!$url) {
  23563. return array();
  23564. }
  23565. if ($urlType === 'dist' && false !== strpos($url, '%')) {
  23566. $url = ComposerMirror::processUrl($url, $this->name, $this->version, $ref, $type, $this->prettyVersion);
  23567. }
  23568. $urls = array($url);
  23569. if ($mirrors) {
  23570. foreach ($mirrors as $mirror) {
  23571. if ($urlType === 'dist') {
  23572. $mirrorUrl = ComposerMirror::processUrl($mirror['url'], $this->name, $this->version, $ref, $type, $this->prettyVersion);
  23573. } elseif ($urlType === 'source' && $type === 'git') {
  23574. $mirrorUrl = ComposerMirror::processGitUrl($mirror['url'], $this->name, $url, $type);
  23575. } elseif ($urlType === 'source' && $type === 'hg') {
  23576. $mirrorUrl = ComposerMirror::processHgUrl($mirror['url'], $this->name, $url, $type);
  23577. } else {
  23578. continue;
  23579. }
  23580. if (!\in_array($mirrorUrl, $urls)) {
  23581. $func = $mirror['preferred'] ? 'array_unshift' : 'array_push';
  23582. $func($urls, $mirrorUrl);
  23583. }
  23584. }
  23585. }
  23586. return $urls;
  23587. }
  23588. private function convertLinksToMap(array $links, string $source): array
  23589. {
  23590. trigger_error('Package::'.$source.' must be called with a map of lowercased package name => Link object, got a indexed array, this is deprecated and you should fix your usage.');
  23591. $newLinks = array();
  23592. foreach ($links as $link) {
  23593. $newLinks[$link->getTarget()] = $link;
  23594. }
  23595. return $newLinks;
  23596. }
  23597. }
  23598. <?php declare(strict_types=1);
  23599. namespace Composer\Package;
  23600. use Composer\Repository\RepositoryInterface;
  23601. interface PackageInterface
  23602. {
  23603. public const DISPLAY_SOURCE_REF_IF_DEV = 0;
  23604. public const DISPLAY_SOURCE_REF = 1;
  23605. public const DISPLAY_DIST_REF = 2;
  23606. public function getName(): string;
  23607. public function getPrettyName(): string;
  23608. public function getNames(bool $provides = true): array;
  23609. public function setId(int $id): void;
  23610. public function getId(): int;
  23611. public function isDev(): bool;
  23612. public function getType(): string;
  23613. public function getTargetDir(): ?string;
  23614. public function getExtra(): array;
  23615. public function setInstallationSource(?string $type): void;
  23616. public function getInstallationSource(): ?string;
  23617. public function getSourceType(): ?string;
  23618. public function getSourceUrl(): ?string;
  23619. public function getSourceUrls(): array;
  23620. public function getSourceReference(): ?string;
  23621. public function getSourceMirrors(): ?array;
  23622. public function setSourceMirrors(?array $mirrors): void;
  23623. public function getDistType(): ?string;
  23624. public function getDistUrl(): ?string;
  23625. public function getDistUrls(): array;
  23626. public function getDistReference(): ?string;
  23627. public function getDistSha1Checksum(): ?string;
  23628. public function getDistMirrors(): ?array;
  23629. public function setDistMirrors(?array $mirrors): void;
  23630. public function getVersion(): string;
  23631. public function getPrettyVersion(): string;
  23632. public function getFullPrettyVersion(bool $truncate = true, int $displayMode = self::DISPLAY_SOURCE_REF_IF_DEV): string;
  23633. public function getReleaseDate(): ?\DateTimeInterface;
  23634. public function getStability(): string;
  23635. public function getRequires(): array;
  23636. public function getConflicts(): array;
  23637. public function getProvides(): array;
  23638. public function getReplaces(): array;
  23639. public function getDevRequires(): array;
  23640. public function getSuggests(): array;
  23641. public function getAutoload(): array;
  23642. public function getDevAutoload(): array;
  23643. public function getIncludePaths(): array;
  23644. public function setRepository(RepositoryInterface $repository): void;
  23645. public function getRepository(): ?RepositoryInterface;
  23646. public function getBinaries(): array;
  23647. public function getUniqueName(): string;
  23648. public function getNotificationUrl(): ?string;
  23649. public function __toString(): string;
  23650. public function getPrettyString(): string;
  23651. public function isDefaultBranch(): bool;
  23652. public function getTransportOptions(): array;
  23653. public function setTransportOptions(array $options): void;
  23654. public function setSourceReference(?string $reference): void;
  23655. public function setDistUrl(?string $url): void;
  23656. public function setDistType(?string $type): void;
  23657. public function setDistReference(?string $reference): void;
  23658. public function setSourceDistReferences(string $reference): void;
  23659. }
  23660. <?php declare(strict_types=1);
  23661. namespace Composer\Package;
  23662. class RootAliasPackage extends CompleteAliasPackage implements RootPackageInterface
  23663. {
  23664. protected $aliasOf;
  23665. public function __construct(RootPackage $aliasOf, string $version, string $prettyVersion)
  23666. {
  23667. parent::__construct($aliasOf, $version, $prettyVersion);
  23668. }
  23669. public function getAliasOf()
  23670. {
  23671. return $this->aliasOf;
  23672. }
  23673. public function getAliases(): array
  23674. {
  23675. return $this->aliasOf->getAliases();
  23676. }
  23677. public function getMinimumStability(): string
  23678. {
  23679. return $this->aliasOf->getMinimumStability();
  23680. }
  23681. public function getStabilityFlags(): array
  23682. {
  23683. return $this->aliasOf->getStabilityFlags();
  23684. }
  23685. public function getReferences(): array
  23686. {
  23687. return $this->aliasOf->getReferences();
  23688. }
  23689. public function getPreferStable(): bool
  23690. {
  23691. return $this->aliasOf->getPreferStable();
  23692. }
  23693. public function getConfig(): array
  23694. {
  23695. return $this->aliasOf->getConfig();
  23696. }
  23697. public function setRequires(array $requires): void
  23698. {
  23699. $this->requires = $this->replaceSelfVersionDependencies($requires, Link::TYPE_REQUIRE);
  23700. $this->aliasOf->setRequires($requires);
  23701. }
  23702. public function setDevRequires(array $devRequires): void
  23703. {
  23704. $this->devRequires = $this->replaceSelfVersionDependencies($devRequires, Link::TYPE_DEV_REQUIRE);
  23705. $this->aliasOf->setDevRequires($devRequires);
  23706. }
  23707. public function setConflicts(array $conflicts): void
  23708. {
  23709. $this->conflicts = $this->replaceSelfVersionDependencies($conflicts, Link::TYPE_CONFLICT);
  23710. $this->aliasOf->setConflicts($conflicts);
  23711. }
  23712. public function setProvides(array $provides): void
  23713. {
  23714. $this->provides = $this->replaceSelfVersionDependencies($provides, Link::TYPE_PROVIDE);
  23715. $this->aliasOf->setProvides($provides);
  23716. }
  23717. public function setReplaces(array $replaces): void
  23718. {
  23719. $this->replaces = $this->replaceSelfVersionDependencies($replaces, Link::TYPE_REPLACE);
  23720. $this->aliasOf->setReplaces($replaces);
  23721. }
  23722. public function setAutoload(array $autoload): void
  23723. {
  23724. $this->aliasOf->setAutoload($autoload);
  23725. }
  23726. public function setDevAutoload(array $devAutoload): void
  23727. {
  23728. $this->aliasOf->setDevAutoload($devAutoload);
  23729. }
  23730. public function setStabilityFlags(array $stabilityFlags): void
  23731. {
  23732. $this->aliasOf->setStabilityFlags($stabilityFlags);
  23733. }
  23734. public function setMinimumStability($minimumStability): void
  23735. {
  23736. $this->aliasOf->setMinimumStability($minimumStability);
  23737. }
  23738. public function setPreferStable($preferStable): void
  23739. {
  23740. $this->aliasOf->setPreferStable($preferStable);
  23741. }
  23742. public function setConfig(array $config): void
  23743. {
  23744. $this->aliasOf->setConfig($config);
  23745. }
  23746. public function setReferences(array $references): void
  23747. {
  23748. $this->aliasOf->setReferences($references);
  23749. }
  23750. public function setAliases(array $aliases): void
  23751. {
  23752. $this->aliasOf->setAliases($aliases);
  23753. }
  23754. public function setSuggests(array $suggests): void
  23755. {
  23756. $this->aliasOf->setSuggests($suggests);
  23757. }
  23758. public function setExtra(array $extra): void
  23759. {
  23760. $this->aliasOf->setExtra($extra);
  23761. }
  23762. public function __clone()
  23763. {
  23764. parent::__clone();
  23765. $this->aliasOf = clone $this->aliasOf;
  23766. }
  23767. }
  23768. <?php declare(strict_types=1);
  23769. namespace Composer\Package;
  23770. class RootPackage extends CompletePackage implements RootPackageInterface
  23771. {
  23772. public const DEFAULT_PRETTY_VERSION = '1.0.0+no-version-set';
  23773. protected $minimumStability = 'stable';
  23774. protected $preferStable = false;
  23775. protected $stabilityFlags = array();
  23776. protected $config = array();
  23777. protected $references = array();
  23778. protected $aliases = array();
  23779. public function setMinimumStability(string $minimumStability): void
  23780. {
  23781. $this->minimumStability = $minimumStability;
  23782. }
  23783. public function getMinimumStability(): string
  23784. {
  23785. return $this->minimumStability;
  23786. }
  23787. public function setStabilityFlags(array $stabilityFlags): void
  23788. {
  23789. $this->stabilityFlags = $stabilityFlags;
  23790. }
  23791. public function getStabilityFlags(): array
  23792. {
  23793. return $this->stabilityFlags;
  23794. }
  23795. public function setPreferStable(bool $preferStable): void
  23796. {
  23797. $this->preferStable = $preferStable;
  23798. }
  23799. public function getPreferStable(): bool
  23800. {
  23801. return $this->preferStable;
  23802. }
  23803. public function setConfig(array $config): void
  23804. {
  23805. $this->config = $config;
  23806. }
  23807. public function getConfig(): array
  23808. {
  23809. return $this->config;
  23810. }
  23811. public function setReferences(array $references): void
  23812. {
  23813. $this->references = $references;
  23814. }
  23815. public function getReferences(): array
  23816. {
  23817. return $this->references;
  23818. }
  23819. public function setAliases(array $aliases): void
  23820. {
  23821. $this->aliases = $aliases;
  23822. }
  23823. public function getAliases(): array
  23824. {
  23825. return $this->aliases;
  23826. }
  23827. }
  23828. <?php declare(strict_types=1);
  23829. namespace Composer\Package;
  23830. interface RootPackageInterface extends CompletePackageInterface
  23831. {
  23832. public function getAliases(): array;
  23833. public function getMinimumStability(): string;
  23834. public function getStabilityFlags(): array;
  23835. public function getReferences(): array;
  23836. public function getPreferStable(): bool;
  23837. public function getConfig(): array;
  23838. public function setRequires(array $requires): void;
  23839. public function setDevRequires(array $devRequires): void;
  23840. public function setConflicts(array $conflicts): void;
  23841. public function setProvides(array $provides): void;
  23842. public function setReplaces(array $replaces): void;
  23843. public function setRepositories(array $repositories): void;
  23844. public function setAutoload(array $autoload): void;
  23845. public function setDevAutoload(array $devAutoload): void;
  23846. public function setStabilityFlags(array $stabilityFlags): void;
  23847. public function setMinimumStability(string $minimumStability): void;
  23848. public function setPreferStable(bool $preferStable): void;
  23849. public function setConfig(array $config): void;
  23850. public function setReferences(array $references): void;
  23851. public function setAliases(array $aliases): void;
  23852. public function setSuggests(array $suggests): void;
  23853. public function setExtra(array $extra): void;
  23854. }
  23855. <?php declare(strict_types=1);
  23856. namespace Composer\Package\Version;
  23857. use Composer\Package\BasePackage;
  23858. class StabilityFilter
  23859. {
  23860. public static function isPackageAcceptable(array $acceptableStabilities, array $stabilityFlags, array $names, string $stability): bool
  23861. {
  23862. foreach ($names as $name) {
  23863. if (isset($stabilityFlags[$name])) {
  23864. if (BasePackage::$stabilities[$stability] <= $stabilityFlags[$name]) {
  23865. return true;
  23866. }
  23867. } elseif (isset($acceptableStabilities[$stability])) {
  23868. return true;
  23869. }
  23870. }
  23871. return false;
  23872. }
  23873. }
  23874. <?php declare(strict_types=1);
  23875. namespace Composer\Package\Version;
  23876. use Composer\Config;
  23877. use Composer\Pcre\Preg;
  23878. use Composer\Repository\Vcs\HgDriver;
  23879. use Composer\IO\NullIO;
  23880. use Composer\Semver\VersionParser as SemverVersionParser;
  23881. use Composer\Util\Git as GitUtil;
  23882. use Composer\Util\HttpDownloader;
  23883. use Composer\Util\ProcessExecutor;
  23884. use Composer\Util\Svn as SvnUtil;
  23885. use React\Promise\CancellablePromiseInterface;
  23886. use Symfony\Component\Process\Process;
  23887. class VersionGuesser
  23888. {
  23889. private $config;
  23890. private $process;
  23891. private $versionParser;
  23892. public function __construct(Config $config, ProcessExecutor $process, SemverVersionParser $versionParser)
  23893. {
  23894. $this->config = $config;
  23895. $this->process = $process;
  23896. $this->versionParser = $versionParser;
  23897. }
  23898. public function guessVersion(array $packageConfig, string $path): ?array
  23899. {
  23900. if (!function_exists('proc_open')) {
  23901. return null;
  23902. }
  23903. $versionData = $this->guessGitVersion($packageConfig, $path);
  23904. if (null !== $versionData && null !== $versionData['version']) {
  23905. return $this->postprocess($versionData);
  23906. }
  23907. $versionData = $this->guessHgVersion($packageConfig, $path);
  23908. if (null !== $versionData && null !== $versionData['version']) {
  23909. return $this->postprocess($versionData);
  23910. }
  23911. $versionData = $this->guessFossilVersion($path);
  23912. if (null !== $versionData && null !== $versionData['version']) {
  23913. return $this->postprocess($versionData);
  23914. }
  23915. $versionData = $this->guessSvnVersion($packageConfig, $path);
  23916. if (null !== $versionData && null !== $versionData['version']) {
  23917. return $this->postprocess($versionData);
  23918. }
  23919. return null;
  23920. }
  23921. private function postprocess(array $versionData): array
  23922. {
  23923. if (!empty($versionData['feature_version']) && $versionData['feature_version'] === $versionData['version'] && $versionData['feature_pretty_version'] === $versionData['pretty_version']) {
  23924. unset($versionData['feature_version'], $versionData['feature_pretty_version']);
  23925. }
  23926. if ('-dev' === substr($versionData['version'], -4) && Preg::isMatch('{\.9{7}}', $versionData['version'])) {
  23927. $versionData['pretty_version'] = Preg::replace('{(\.9{7})+}', '.x', $versionData['version']);
  23928. }
  23929. if (!empty($versionData['feature_version']) && '-dev' === substr($versionData['feature_version'], -4) && Preg::isMatch('{\.9{7}}', $versionData['feature_version'])) {
  23930. $versionData['feature_pretty_version'] = Preg::replace('{(\.9{7})+}', '.x', $versionData['feature_version']);
  23931. }
  23932. return $versionData;
  23933. }
  23934. private function guessGitVersion(array $packageConfig, string $path): array
  23935. {
  23936. GitUtil::cleanEnv();
  23937. $commit = null;
  23938. $version = null;
  23939. $prettyVersion = null;
  23940. $featureVersion = null;
  23941. $featurePrettyVersion = null;
  23942. $isDetached = false;
  23943. if (0 === $this->process->execute(['git', 'branch', '-a', '--no-color', '--no-abbrev', '-v'], $output, $path)) {
  23944. $branches = array();
  23945. $isFeatureBranch = false;
  23946. foreach ($this->process->splitLines($output) as $branch) {
  23947. if ($branch && Preg::isMatch('{^(?:\* ) *(\(no branch\)|\(detached from \S+\)|\(HEAD detached at \S+\)|\S+) *([a-f0-9]+) .*$}', $branch, $match)) {
  23948. if (
  23949. $match[1] === '(no branch)'
  23950. || strpos($match[1], '(detached ') === 0
  23951. || strpos($match[1], '(HEAD detached at') === 0
  23952. ) {
  23953. $version = 'dev-' . $match[2];
  23954. $prettyVersion = $version;
  23955. $isFeatureBranch = true;
  23956. $isDetached = true;
  23957. } else {
  23958. $version = $this->versionParser->normalizeBranch($match[1]);
  23959. $prettyVersion = 'dev-' . $match[1];
  23960. $isFeatureBranch = $this->isFeatureBranch($packageConfig, $match[1]);
  23961. }
  23962. if ($match[2]) {
  23963. $commit = $match[2];
  23964. }
  23965. }
  23966. if ($branch && !Preg::isMatch('{^ *.+/HEAD }', $branch)) {
  23967. if (Preg::isMatch('{^(?:\* )? *((?:remotes/(?:origin|upstream)/)?[^\s/]+) *([a-f0-9]+) .*$}', $branch, $match)) {
  23968. $branches[] = $match[1];
  23969. }
  23970. }
  23971. }
  23972. if ($isFeatureBranch) {
  23973. $featureVersion = $version;
  23974. $featurePrettyVersion = $prettyVersion;
  23975. $result = $this->guessFeatureVersion($packageConfig, $version, $branches, 'git rev-list %candidate%..%branch%', $path);
  23976. $version = $result['version'];
  23977. $prettyVersion = $result['pretty_version'];
  23978. }
  23979. }
  23980. if (!$version || $isDetached) {
  23981. $result = $this->versionFromGitTags($path);
  23982. if ($result) {
  23983. $version = $result['version'];
  23984. $prettyVersion = $result['pretty_version'];
  23985. $featureVersion = null;
  23986. $featurePrettyVersion = null;
  23987. }
  23988. }
  23989. if (!$commit) {
  23990. $command = 'git log --pretty="%H" -n1 HEAD'.GitUtil::getNoShowSignatureFlag($this->process);
  23991. if (0 === $this->process->execute($command, $output, $path)) {
  23992. $commit = trim($output) ?: null;
  23993. }
  23994. }
  23995. if ($featureVersion) {
  23996. return array('version' => $version, 'commit' => $commit, 'pretty_version' => $prettyVersion, 'feature_version' => $featureVersion, 'feature_pretty_version' => $featurePrettyVersion);
  23997. }
  23998. return array('version' => $version, 'commit' => $commit, 'pretty_version' => $prettyVersion);
  23999. }
  24000. private function versionFromGitTags(string $path): ?array
  24001. {
  24002. if (0 === $this->process->execute('git describe --exact-match --tags', $output, $path)) {
  24003. try {
  24004. $version = $this->versionParser->normalize(trim($output));
  24005. return array('version' => $version, 'pretty_version' => trim($output));
  24006. } catch (\Exception $e) {
  24007. }
  24008. }
  24009. return null;
  24010. }
  24011. private function guessHgVersion(array $packageConfig, string $path): ?array
  24012. {
  24013. if (0 === $this->process->execute('hg branch', $output, $path)) {
  24014. $branch = trim($output);
  24015. $version = $this->versionParser->normalizeBranch($branch);
  24016. $isFeatureBranch = 0 === strpos($version, 'dev-');
  24017. if (VersionParser::DEFAULT_BRANCH_ALIAS === $version) {
  24018. return array('version' => $version, 'commit' => null, 'pretty_version' => 'dev-'.$branch);
  24019. }
  24020. if (!$isFeatureBranch) {
  24021. return array('version' => $version, 'commit' => null, 'pretty_version' => $version);
  24022. }
  24023. $io = new NullIO();
  24024. $driver = new HgDriver(array('url' => $path), $io, $this->config, new HttpDownloader($io, $this->config), $this->process);
  24025. $branches = array_map('strval', array_keys($driver->getBranches()));
  24026. $result = $this->guessFeatureVersion($packageConfig, $version, $branches, 'hg log -r "not ancestors(\'%candidate%\') and ancestors(\'%branch%\')" --template "{node}\\n"', $path);
  24027. $result['commit'] = '';
  24028. $result['feature_version'] = $version;
  24029. $result['feature_pretty_version'] = $version;
  24030. return $result;
  24031. }
  24032. return null;
  24033. }
  24034. private function guessFeatureVersion(array $packageConfig, ?string $version, array $branches, string $scmCmdline, string $path): array
  24035. {
  24036. $prettyVersion = $version;
  24037. if (!isset($packageConfig['extra']['branch-alias'][$version])
  24038. || strpos(json_encode($packageConfig), '"self.version"')
  24039. ) {
  24040. $branch = Preg::replace('{^dev-}', '', $version);
  24041. $length = PHP_INT_MAX;
  24042. if (!$this->isFeatureBranch($packageConfig, $branch)) {
  24043. return array('version' => $version, 'pretty_version' => $prettyVersion);
  24044. }
  24045. usort($branches, function ($a, $b): int {
  24046. $aRemote = 0 === strpos($a, 'remotes/');
  24047. $bRemote = 0 === strpos($b, 'remotes/');
  24048. if ($aRemote !== $bRemote) {
  24049. return $aRemote ? 1 : -1;
  24050. }
  24051. return strnatcasecmp($b, $a);
  24052. });
  24053. $promises = [];
  24054. $this->process->setMaxJobs(30);
  24055. try {
  24056. foreach ($branches as $candidate) {
  24057. $candidateVersion = Preg::replace('{^remotes/\S+/}', '', $candidate);
  24058. if ($candidate === $branch || $this->isFeatureBranch($packageConfig, $candidateVersion)) {
  24059. continue;
  24060. }
  24061. $cmdLine = str_replace(array('%candidate%', '%branch%'), array($candidate, $branch), $scmCmdline);
  24062. $promises[] = $this->process->executeAsync($cmdLine, $path)->then(function (Process $process) use (&$length, &$version, &$prettyVersion, $candidateVersion, &$promises): void {
  24063. if (!$process->isSuccessful()) {
  24064. return;
  24065. }
  24066. $output = $process->getOutput();
  24067. if (strlen($output) < $length) {
  24068. $length = strlen($output);
  24069. $version = $this->versionParser->normalizeBranch($candidateVersion);
  24070. $prettyVersion = 'dev-' . $candidateVersion;
  24071. if ($length === 0) {
  24072. foreach ($promises as $promise) {
  24073. if ($promise instanceof CancellablePromiseInterface) {
  24074. $promise->cancel();
  24075. }
  24076. }
  24077. }
  24078. }
  24079. });
  24080. }
  24081. $this->process->wait();
  24082. } finally {
  24083. $this->process->resetMaxJobs();
  24084. }
  24085. }
  24086. return array('version' => $version, 'pretty_version' => $prettyVersion);
  24087. }
  24088. private function isFeatureBranch(array $packageConfig, ?string $branchName): bool
  24089. {
  24090. $nonFeatureBranches = '';
  24091. if (!empty($packageConfig['non-feature-branches'])) {
  24092. $nonFeatureBranches = implode('|', $packageConfig['non-feature-branches']);
  24093. }
  24094. return !Preg::isMatch('{^(' . $nonFeatureBranches . '|master|main|latest|next|current|support|tip|trunk|default|develop|\d+\..+)$}', $branchName, $match);
  24095. }
  24096. private function guessFossilVersion(string $path): array
  24097. {
  24098. $version = null;
  24099. $prettyVersion = null;
  24100. if (0 === $this->process->execute('fossil branch list', $output, $path)) {
  24101. $branch = trim($output);
  24102. $version = $this->versionParser->normalizeBranch($branch);
  24103. $prettyVersion = 'dev-' . $branch;
  24104. }
  24105. if (0 === $this->process->execute('fossil tag list', $output, $path)) {
  24106. try {
  24107. $version = $this->versionParser->normalize(trim($output));
  24108. $prettyVersion = trim($output);
  24109. } catch (\Exception $e) {
  24110. }
  24111. }
  24112. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  24113. }
  24114. private function guessSvnVersion(array $packageConfig, string $path): ?array
  24115. {
  24116. SvnUtil::cleanEnv();
  24117. if (0 === $this->process->execute('svn info --xml', $output, $path)) {
  24118. $trunkPath = isset($packageConfig['trunk-path']) ? preg_quote($packageConfig['trunk-path'], '#') : 'trunk';
  24119. $branchesPath = isset($packageConfig['branches-path']) ? preg_quote($packageConfig['branches-path'], '#') : 'branches';
  24120. $tagsPath = isset($packageConfig['tags-path']) ? preg_quote($packageConfig['tags-path'], '#') : 'tags';
  24121. $urlPattern = '#<url>.*/(' . $trunkPath . '|(' . $branchesPath . '|' . $tagsPath . ')/(.*))</url>#';
  24122. if (Preg::isMatch($urlPattern, $output, $matches)) {
  24123. if (isset($matches[2]) && ($branchesPath === $matches[2] || $tagsPath === $matches[2])) {
  24124. $version = $this->versionParser->normalizeBranch($matches[3]);
  24125. $prettyVersion = 'dev-' . $matches[3];
  24126. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  24127. }
  24128. $prettyVersion = trim($matches[1]);
  24129. if ($prettyVersion === 'trunk') {
  24130. $version = 'dev-trunk';
  24131. } else {
  24132. $version = $this->versionParser->normalize($prettyVersion);
  24133. }
  24134. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  24135. }
  24136. }
  24137. return null;
  24138. }
  24139. }
  24140. <?php declare(strict_types=1);
  24141. namespace Composer\Package\Version;
  24142. use Composer\Pcre\Preg;
  24143. use Composer\Repository\PlatformRepository;
  24144. use Composer\Semver\VersionParser as SemverVersionParser;
  24145. use Composer\Semver\Semver;
  24146. use Composer\Semver\Constraint\ConstraintInterface;
  24147. class VersionParser extends SemverVersionParser
  24148. {
  24149. public const DEFAULT_BRANCH_ALIAS = '9999999-dev';
  24150. private static $constraints = array();
  24151. public function parseConstraints($constraints): ConstraintInterface
  24152. {
  24153. if (!isset(self::$constraints[$constraints])) {
  24154. self::$constraints[$constraints] = parent::parseConstraints($constraints);
  24155. }
  24156. return self::$constraints[$constraints];
  24157. }
  24158. public function parseNameVersionPairs(array $pairs): array
  24159. {
  24160. $pairs = array_values($pairs);
  24161. $result = array();
  24162. for ($i = 0, $count = count($pairs); $i < $count; $i++) {
  24163. $pair = Preg::replace('{^([^=: ]+)[=: ](.*)$}', '$1 $2', trim($pairs[$i]));
  24164. if (false === strpos($pair, ' ') && isset($pairs[$i + 1]) && false === strpos($pairs[$i + 1], '/') && !Preg::isMatch('{(?<=[a-z0-9_/-])\*|\*(?=[a-z0-9_/-])}i', $pairs[$i + 1]) && !PlatformRepository::isPlatformPackage($pairs[$i + 1])) {
  24165. $pair .= ' '.$pairs[$i + 1];
  24166. $i++;
  24167. }
  24168. if (strpos($pair, ' ')) {
  24169. list($name, $version) = explode(' ', $pair, 2);
  24170. $result[] = array('name' => $name, 'version' => $version);
  24171. } else {
  24172. $result[] = array('name' => $pair);
  24173. }
  24174. }
  24175. return $result;
  24176. }
  24177. public static function isUpgrade(string $normalizedFrom, string $normalizedTo): bool
  24178. {
  24179. if ($normalizedFrom === $normalizedTo) {
  24180. return true;
  24181. }
  24182. if (in_array($normalizedFrom, array('dev-master', 'dev-trunk', 'dev-default'), true)) {
  24183. $normalizedFrom = VersionParser::DEFAULT_BRANCH_ALIAS;
  24184. }
  24185. if (in_array($normalizedTo, array('dev-master', 'dev-trunk', 'dev-default'), true)) {
  24186. $normalizedTo = VersionParser::DEFAULT_BRANCH_ALIAS;
  24187. }
  24188. if (strpos($normalizedFrom, 'dev-') === 0 || strpos($normalizedTo, 'dev-') === 0) {
  24189. return true;
  24190. }
  24191. $sorted = Semver::sort(array($normalizedTo, $normalizedFrom));
  24192. return $sorted[0] === $normalizedFrom;
  24193. }
  24194. }
  24195. <?php declare(strict_types=1);
  24196. namespace Composer\Package\Version;
  24197. use Composer\Filter\PlatformRequirementFilter\IgnoreAllPlatformRequirementFilter;
  24198. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  24199. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  24200. use Composer\Package\BasePackage;
  24201. use Composer\Package\AliasPackage;
  24202. use Composer\Package\PackageInterface;
  24203. use Composer\Composer;
  24204. use Composer\Package\Loader\ArrayLoader;
  24205. use Composer\Package\Dumper\ArrayDumper;
  24206. use Composer\Pcre\Preg;
  24207. use Composer\Repository\RepositorySet;
  24208. use Composer\Repository\PlatformRepository;
  24209. use Composer\Semver\Constraint\Constraint;
  24210. use Composer\Semver\Constraint\ConstraintInterface;
  24211. class VersionSelector
  24212. {
  24213. private $repositorySet;
  24214. private $platformConstraints = array();
  24215. private $parser;
  24216. public function __construct(RepositorySet $repositorySet, PlatformRepository $platformRepo = null)
  24217. {
  24218. $this->repositorySet = $repositorySet;
  24219. if ($platformRepo) {
  24220. foreach ($platformRepo->getPackages() as $package) {
  24221. $this->platformConstraints[$package->getName()][] = new Constraint('==', $package->getVersion());
  24222. }
  24223. }
  24224. }
  24225. public function findBestCandidate(string $packageName, string $targetPackageVersion = null, string $preferredStability = 'stable', $platformRequirementFilter = null, int $repoSetFlags = 0)
  24226. {
  24227. if (!isset(BasePackage::$stabilities[$preferredStability])) {
  24228. throw new \UnexpectedValueException('Expected a valid stability name as 3rd argument, got '.$preferredStability);
  24229. }
  24230. if (null === $platformRequirementFilter) {
  24231. $platformRequirementFilter = PlatformRequirementFilterFactory::ignoreNothing();
  24232. } elseif (!($platformRequirementFilter instanceof PlatformRequirementFilterInterface)) {
  24233. trigger_error('VersionSelector::findBestCandidate with ignored platform reqs as bool|array is deprecated since Composer 2.2, use an instance of PlatformRequirementFilterInterface instead.', E_USER_DEPRECATED);
  24234. $platformRequirementFilter = PlatformRequirementFilterFactory::fromBoolOrList($platformRequirementFilter);
  24235. }
  24236. $constraint = $targetPackageVersion ? $this->getParser()->parseConstraints($targetPackageVersion) : null;
  24237. $candidates = $this->repositorySet->findPackages(strtolower($packageName), $constraint, $repoSetFlags);
  24238. if ($this->platformConstraints && !($platformRequirementFilter instanceof IgnoreAllPlatformRequirementFilter)) {
  24239. $platformConstraints = $this->platformConstraints;
  24240. $candidates = array_filter($candidates, function ($pkg) use ($platformConstraints, $platformRequirementFilter): bool {
  24241. $reqs = $pkg->getRequires();
  24242. foreach ($reqs as $name => $link) {
  24243. if (!$platformRequirementFilter->isIgnored($name)) {
  24244. if (isset($platformConstraints[$name])) {
  24245. foreach ($platformConstraints[$name] as $constraint) {
  24246. if ($link->getConstraint()->matches($constraint)) {
  24247. continue 2;
  24248. }
  24249. }
  24250. return false;
  24251. } elseif (PlatformRepository::isPlatformPackage($name)) {
  24252. return false;
  24253. }
  24254. }
  24255. }
  24256. return true;
  24257. });
  24258. }
  24259. if (!$candidates) {
  24260. return false;
  24261. }
  24262. $package = reset($candidates);
  24263. $minPriority = BasePackage::$stabilities[$preferredStability];
  24264. foreach ($candidates as $candidate) {
  24265. $candidatePriority = $candidate->getStabilityPriority();
  24266. $currentPriority = $package->getStabilityPriority();
  24267. if ($minPriority < $candidatePriority && $currentPriority < $candidatePriority) {
  24268. continue;
  24269. }
  24270. if ($minPriority < $candidatePriority && $candidatePriority < $currentPriority) {
  24271. $package = $candidate;
  24272. continue;
  24273. }
  24274. if ($minPriority >= $candidatePriority && $minPriority < $currentPriority) {
  24275. $package = $candidate;
  24276. continue;
  24277. }
  24278. if (version_compare($package->getVersion(), $candidate->getVersion(), '<')) {
  24279. $package = $candidate;
  24280. }
  24281. }
  24282. if ($package instanceof AliasPackage && $package->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  24283. $package = $package->getAliasOf();
  24284. }
  24285. return $package;
  24286. }
  24287. public function findRecommendedRequireVersion(PackageInterface $package): string
  24288. {
  24289. if (0 === strpos($package->getName(), 'ext-')) {
  24290. $phpVersion = PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
  24291. $extVersion = implode('.', array_slice(explode('.', $package->getVersion()), 0, 3));
  24292. if ($phpVersion === $extVersion) {
  24293. return '*';
  24294. }
  24295. }
  24296. $version = $package->getVersion();
  24297. if (!$package->isDev()) {
  24298. return $this->transformVersion($version, $package->getPrettyVersion(), $package->getStability());
  24299. }
  24300. $loader = new ArrayLoader($this->getParser());
  24301. $dumper = new ArrayDumper();
  24302. $extra = $loader->getBranchAlias($dumper->dump($package));
  24303. if ($extra && $extra !== VersionParser::DEFAULT_BRANCH_ALIAS) {
  24304. $extra = Preg::replace('{^(\d+\.\d+\.\d+)(\.9999999)-dev$}', '$1.0', $extra, -1, $count);
  24305. if ($count) {
  24306. $extra = str_replace('.9999999', '.0', $extra);
  24307. return $this->transformVersion($extra, $extra, 'dev');
  24308. }
  24309. }
  24310. return $package->getPrettyVersion();
  24311. }
  24312. private function transformVersion(string $version, string $prettyVersion, string $stability): string
  24313. {
  24314. $semanticVersionParts = explode('.', $version);
  24315. if (count($semanticVersionParts) == 4 && Preg::isMatch('{^0\D?}', $semanticVersionParts[3])) {
  24316. if ($semanticVersionParts[0] === '0') {
  24317. unset($semanticVersionParts[3]);
  24318. } else {
  24319. unset($semanticVersionParts[2], $semanticVersionParts[3]);
  24320. }
  24321. $version = implode('.', $semanticVersionParts);
  24322. } else {
  24323. return $prettyVersion;
  24324. }
  24325. if ($stability != 'stable') {
  24326. $version .= '@'.$stability;
  24327. }
  24328. return '^' . $version;
  24329. }
  24330. private function getParser(): VersionParser
  24331. {
  24332. if ($this->parser === null) {
  24333. $this->parser = new VersionParser();
  24334. }
  24335. return $this->parser;
  24336. }
  24337. }
  24338. <?php declare(strict_types=1);
  24339. namespace Composer;
  24340. use Composer\Package\RootPackageInterface;
  24341. use Composer\Util\Loop;
  24342. use Composer\Repository\RepositoryManager;
  24343. use Composer\Installer\InstallationManager;
  24344. use Composer\EventDispatcher\EventDispatcher;
  24345. class PartialComposer
  24346. {
  24347. private $package;
  24348. private $loop;
  24349. private $repositoryManager;
  24350. private $installationManager;
  24351. private $config;
  24352. private $eventDispatcher;
  24353. public function setPackage(RootPackageInterface $package): void
  24354. {
  24355. $this->package = $package;
  24356. }
  24357. public function getPackage(): RootPackageInterface
  24358. {
  24359. return $this->package;
  24360. }
  24361. public function setConfig(Config $config): void
  24362. {
  24363. $this->config = $config;
  24364. }
  24365. public function getConfig(): Config
  24366. {
  24367. return $this->config;
  24368. }
  24369. public function setLoop(Loop $loop): void
  24370. {
  24371. $this->loop = $loop;
  24372. }
  24373. public function getLoop(): Loop
  24374. {
  24375. return $this->loop;
  24376. }
  24377. public function setRepositoryManager(RepositoryManager $manager): void
  24378. {
  24379. $this->repositoryManager = $manager;
  24380. }
  24381. public function getRepositoryManager(): RepositoryManager
  24382. {
  24383. return $this->repositoryManager;
  24384. }
  24385. public function setInstallationManager(InstallationManager $manager): void
  24386. {
  24387. $this->installationManager = $manager;
  24388. }
  24389. public function getInstallationManager(): InstallationManager
  24390. {
  24391. return $this->installationManager;
  24392. }
  24393. public function setEventDispatcher(EventDispatcher $eventDispatcher): void
  24394. {
  24395. $this->eventDispatcher = $eventDispatcher;
  24396. }
  24397. public function getEventDispatcher(): EventDispatcher
  24398. {
  24399. return $this->eventDispatcher;
  24400. }
  24401. }
  24402. <?php declare(strict_types=1);
  24403. namespace Composer\Platform;
  24404. use Composer\Util\Platform;
  24405. use Composer\Util\ProcessExecutor;
  24406. use Symfony\Component\Process\ExecutableFinder;
  24407. class HhvmDetector
  24408. {
  24409. private static $hhvmVersion = null;
  24410. private $executableFinder;
  24411. private $processExecutor;
  24412. public function __construct(ExecutableFinder $executableFinder = null, ProcessExecutor $processExecutor = null)
  24413. {
  24414. $this->executableFinder = $executableFinder;
  24415. $this->processExecutor = $processExecutor;
  24416. }
  24417. public function reset(): void
  24418. {
  24419. self::$hhvmVersion = null;
  24420. }
  24421. public function getVersion(): ?string
  24422. {
  24423. if (null !== self::$hhvmVersion) {
  24424. return self::$hhvmVersion ?: null;
  24425. }
  24426. self::$hhvmVersion = defined('HHVM_VERSION') ? HHVM_VERSION : null;
  24427. if (self::$hhvmVersion === null && !Platform::isWindows()) {
  24428. self::$hhvmVersion = false;
  24429. $this->executableFinder = $this->executableFinder ?: new ExecutableFinder();
  24430. $hhvmPath = $this->executableFinder->find('hhvm');
  24431. if ($hhvmPath !== null) {
  24432. $this->processExecutor = $this->processExecutor ?? new ProcessExecutor();
  24433. $exitCode = $this->processExecutor->execute(
  24434. ProcessExecutor::escape($hhvmPath).
  24435. ' --php -d hhvm.jit=0 -r "echo HHVM_VERSION;" 2>/dev/null',
  24436. self::$hhvmVersion
  24437. );
  24438. if ($exitCode !== 0) {
  24439. self::$hhvmVersion = false;
  24440. }
  24441. }
  24442. }
  24443. return self::$hhvmVersion ?: null;
  24444. }
  24445. }
  24446. <?php declare(strict_types=1);
  24447. namespace Composer\Platform;
  24448. class Runtime
  24449. {
  24450. public function hasConstant(string $constant, ?string $class = null): bool
  24451. {
  24452. return defined(ltrim($class.'::'.$constant, ':'));
  24453. }
  24454. public function getConstant(string $constant, ?string $class = null)
  24455. {
  24456. return constant(ltrim($class.'::'.$constant, ':'));
  24457. }
  24458. public function hasFunction(string $fn): bool
  24459. {
  24460. return function_exists($fn);
  24461. }
  24462. public function invoke(callable $callable, array $arguments = array())
  24463. {
  24464. return call_user_func_array($callable, $arguments);
  24465. }
  24466. public function hasClass(string $class): bool
  24467. {
  24468. return class_exists($class, false);
  24469. }
  24470. public function construct(string $class, array $arguments = array()): object
  24471. {
  24472. if (empty($arguments)) {
  24473. return new $class;
  24474. }
  24475. $refl = new \ReflectionClass($class);
  24476. return $refl->newInstanceArgs($arguments);
  24477. }
  24478. public function getExtensions(): array
  24479. {
  24480. return get_loaded_extensions();
  24481. }
  24482. public function getExtensionVersion(string $extension): string
  24483. {
  24484. $version = phpversion($extension);
  24485. if ($version === false) {
  24486. $version = '0';
  24487. }
  24488. return $version;
  24489. }
  24490. public function getExtensionInfo(string $extension): string
  24491. {
  24492. $reflector = new \ReflectionExtension($extension);
  24493. ob_start();
  24494. $reflector->info();
  24495. return ob_get_clean();
  24496. }
  24497. }
  24498. <?php declare(strict_types=1);
  24499. namespace Composer\Platform;
  24500. use Composer\Pcre\Preg;
  24501. class Version
  24502. {
  24503. public static function parseOpenssl(string $opensslVersion, ?bool &$isFips): ?string
  24504. {
  24505. $isFips = false;
  24506. if (!Preg::isMatch('/^(?<version>[0-9.]+)(?<patch>[a-z]{0,2})?(?<suffix>(?:-?(?:dev|pre|alpha|beta|rc|fips)[\d]*)*)?(?<garbage>-\w+)?(?<garbage2> \(.+?\))?$/', $opensslVersion, $matches)) {
  24507. return null;
  24508. }
  24509. $isFips = strpos($matches['suffix'], 'fips') !== false;
  24510. $suffix = strtr('-'.ltrim($matches['suffix'], '-'), array('-fips' => '', '-pre' => '-alpha'));
  24511. $patch = self::convertAlphaVersionToIntVersion($matches['patch']);
  24512. return rtrim($matches['version'].'.'.$patch.$suffix, '-');
  24513. }
  24514. public static function parseLibjpeg(string $libjpegVersion): ?string
  24515. {
  24516. if (!Preg::isMatch('/^(?<major>\d+)(?<minor>[a-z]*)$/', $libjpegVersion, $matches)) {
  24517. return null;
  24518. }
  24519. return $matches['major'].'.'.self::convertAlphaVersionToIntVersion($matches['minor']);
  24520. }
  24521. public static function parseZoneinfoVersion(string $zoneinfoVersion): ?string
  24522. {
  24523. if (!Preg::isMatch('/^(?<year>\d{4})(?<revision>[a-z]*)$/', $zoneinfoVersion, $matches)) {
  24524. return null;
  24525. }
  24526. return $matches['year'].'.'.self::convertAlphaVersionToIntVersion($matches['revision']);
  24527. }
  24528. private static function convertAlphaVersionToIntVersion(string $alpha): int
  24529. {
  24530. return strlen($alpha) * (-ord('a') + 1) + array_sum(array_map('ord', str_split($alpha)));
  24531. }
  24532. public static function convertLibxpmVersionId(int $versionId): string
  24533. {
  24534. return self::convertVersionId($versionId, 100);
  24535. }
  24536. public static function convertOpenldapVersionId(int $versionId): string
  24537. {
  24538. return self::convertVersionId($versionId, 100);
  24539. }
  24540. private static function convertVersionId(int $versionId, int $base): string
  24541. {
  24542. return sprintf(
  24543. '%d.%d.%d',
  24544. $versionId / ($base * $base),
  24545. (int) ($versionId / $base) % $base,
  24546. $versionId % $base
  24547. );
  24548. }
  24549. }
  24550. <?php declare(strict_types=1);
  24551. namespace Composer\Plugin\Capability;
  24552. interface Capability
  24553. {
  24554. }
  24555. <?php declare(strict_types=1);
  24556. namespace Composer\Plugin\Capability;
  24557. interface CommandProvider extends Capability
  24558. {
  24559. public function getCommands();
  24560. }
  24561. <?php declare(strict_types=1);
  24562. namespace Composer\Plugin;
  24563. interface Capable
  24564. {
  24565. public function getCapabilities();
  24566. }
  24567. <?php declare(strict_types=1);
  24568. namespace Composer\Plugin;
  24569. use Composer\EventDispatcher\Event;
  24570. use Symfony\Component\Console\Input\InputInterface;
  24571. use Symfony\Component\Console\Output\OutputInterface;
  24572. class CommandEvent extends Event
  24573. {
  24574. private $commandName;
  24575. private $input;
  24576. private $output;
  24577. public function __construct(string $name, string $commandName, InputInterface $input, OutputInterface $output, array $args = array(), array $flags = array())
  24578. {
  24579. parent::__construct($name, $args, $flags);
  24580. $this->commandName = $commandName;
  24581. $this->input = $input;
  24582. $this->output = $output;
  24583. }
  24584. public function getInput(): InputInterface
  24585. {
  24586. return $this->input;
  24587. }
  24588. public function getOutput(): OutputInterface
  24589. {
  24590. return $this->output;
  24591. }
  24592. public function getCommandName(): string
  24593. {
  24594. return $this->commandName;
  24595. }
  24596. }
  24597. <?php declare(strict_types=1);
  24598. namespace Composer\Plugin;
  24599. class PluginEvents
  24600. {
  24601. public const INIT = 'init';
  24602. public const COMMAND = 'command';
  24603. public const PRE_FILE_DOWNLOAD = 'pre-file-download';
  24604. public const POST_FILE_DOWNLOAD = 'post-file-download';
  24605. public const PRE_COMMAND_RUN = 'pre-command-run';
  24606. public const PRE_POOL_CREATE = 'pre-pool-create';
  24607. }
  24608. <?php declare(strict_types=1);
  24609. namespace Composer\Plugin;
  24610. use Composer\Composer;
  24611. use Composer\IO\IOInterface;
  24612. interface PluginInterface
  24613. {
  24614. public const PLUGIN_API_VERSION = '2.3.0';
  24615. public function activate(Composer $composer, IOInterface $io);
  24616. public function deactivate(Composer $composer, IOInterface $io);
  24617. public function uninstall(Composer $composer, IOInterface $io);
  24618. }
  24619. <?php declare(strict_types=1);
  24620. namespace Composer\Plugin;
  24621. use Composer\Composer;
  24622. use Composer\EventDispatcher\EventSubscriberInterface;
  24623. use Composer\Installer\InstallerInterface;
  24624. use Composer\IO\IOInterface;
  24625. use Composer\Package\BasePackage;
  24626. use Composer\Package\CompletePackage;
  24627. use Composer\Package\Package;
  24628. use Composer\Package\Version\VersionParser;
  24629. use Composer\PartialComposer;
  24630. use Composer\Pcre\Preg;
  24631. use Composer\Repository\RepositoryInterface;
  24632. use Composer\Repository\InstalledRepository;
  24633. use Composer\Repository\RootPackageRepository;
  24634. use Composer\Package\PackageInterface;
  24635. use Composer\Package\Link;
  24636. use Composer\Semver\Constraint\Constraint;
  24637. use Composer\Plugin\Capability\Capability;
  24638. use Composer\Util\PackageSorter;
  24639. class PluginManager
  24640. {
  24641. protected $composer;
  24642. protected $io;
  24643. protected $globalComposer;
  24644. protected $versionParser;
  24645. protected $disablePlugins = false;
  24646. protected $plugins = array();
  24647. protected $registeredPlugins = array();
  24648. private $allowPluginRules;
  24649. private $allowGlobalPluginRules;
  24650. private static $classCounter = 0;
  24651. public function __construct(IOInterface $io, Composer $composer, PartialComposer $globalComposer = null, bool $disablePlugins = false)
  24652. {
  24653. $this->io = $io;
  24654. $this->composer = $composer;
  24655. $this->globalComposer = $globalComposer;
  24656. $this->versionParser = new VersionParser();
  24657. $this->disablePlugins = $disablePlugins;
  24658. $this->allowPluginRules = $this->parseAllowedPlugins($composer->getConfig()->get('allow-plugins'));
  24659. $this->allowGlobalPluginRules = $this->parseAllowedPlugins($globalComposer !== null ? $globalComposer->getConfig()->get('allow-plugins') : false);
  24660. }
  24661. public function loadInstalledPlugins(): void
  24662. {
  24663. if ($this->disablePlugins) {
  24664. return;
  24665. }
  24666. $repo = $this->composer->getRepositoryManager()->getLocalRepository();
  24667. $globalRepo = $this->globalComposer !== null ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null;
  24668. $this->loadRepository($repo, false);
  24669. if ($globalRepo) {
  24670. $this->loadRepository($globalRepo, true);
  24671. }
  24672. }
  24673. public function deactivateInstalledPlugins(): void
  24674. {
  24675. if ($this->disablePlugins) {
  24676. return;
  24677. }
  24678. $repo = $this->composer->getRepositoryManager()->getLocalRepository();
  24679. $this->deactivateRepository($repo, false);
  24680. if ($this->globalComposer !== null) {
  24681. $this->deactivateRepository($this->globalComposer->getRepositoryManager()->getLocalRepository(), true);
  24682. }
  24683. }
  24684. public function getPlugins(): array
  24685. {
  24686. return $this->plugins;
  24687. }
  24688. public function getGlobalComposer(): ?PartialComposer
  24689. {
  24690. return $this->globalComposer;
  24691. }
  24692. public function registerPackage(PackageInterface $package, bool $failOnMissingClasses = false, bool $isGlobalPlugin = false): void
  24693. {
  24694. if ($this->disablePlugins) {
  24695. return;
  24696. }
  24697. if (!$this->isPluginAllowed($package->getName(), $isGlobalPlugin)) {
  24698. $this->io->writeError('Skipped loading "'.$package->getName() . '" '.($isGlobalPlugin ? '(installed globally) ' : '').'as it is not in config.allow-plugins', true, IOInterface::DEBUG);
  24699. return;
  24700. }
  24701. if ($package->getType() === 'composer-plugin') {
  24702. $requiresComposer = null;
  24703. foreach ($package->getRequires() as $link) {
  24704. if ('composer-plugin-api' === $link->getTarget()) {
  24705. $requiresComposer = $link->getConstraint();
  24706. break;
  24707. }
  24708. }
  24709. if (!$requiresComposer) {
  24710. throw new \RuntimeException("Plugin ".$package->getName()." is missing a require statement for a version of the composer-plugin-api package.");
  24711. }
  24712. $currentPluginApiVersion = $this->getPluginApiVersion();
  24713. $currentPluginApiConstraint = new Constraint('==', $this->versionParser->normalize($currentPluginApiVersion));
  24714. if ($requiresComposer->getPrettyString() === $this->getPluginApiVersion()) {
  24715. $this->io->writeError('<warning>The "' . $package->getName() . '" plugin requires composer-plugin-api '.$this->getPluginApiVersion().', this *WILL* break in the future and it should be fixed ASAP (require ^'.$this->getPluginApiVersion().' instead for example).</warning>');
  24716. } elseif (!$requiresComposer->matches($currentPluginApiConstraint)) {
  24717. $this->io->writeError('<warning>The "' . $package->getName() . '" plugin '.($isGlobalPlugin ? '(installed globally) ' : '').'was skipped because it requires a Plugin API version ("' . $requiresComposer->getPrettyString() . '") that does not match your Composer installation ("' . $currentPluginApiVersion . '"). You may need to run composer update with the "--no-plugins" option.</warning>');
  24718. return;
  24719. }
  24720. if ($package->getName() === 'symfony/flex' && Preg::isMatch('{^[0-9.]+$}', $package->getVersion()) && version_compare($package->getVersion(), '1.9.8', '<')) {
  24721. $this->io->writeError('<warning>The "' . $package->getName() . '" plugin '.($isGlobalPlugin ? '(installed globally) ' : '').'was skipped because it is not compatible with Composer 2+. Make sure to update it to version 1.9.8 or greater.</warning>');
  24722. return;
  24723. }
  24724. }
  24725. $oldInstallerPlugin = ($package->getType() === 'composer-installer');
  24726. if (isset($this->registeredPlugins[$package->getName()])) {
  24727. return;
  24728. }
  24729. $extra = $package->getExtra();
  24730. if (empty($extra['class'])) {
  24731. throw new \UnexpectedValueException('Error while installing '.$package->getPrettyName().', composer-plugin packages should have a class defined in their extra key to be usable.');
  24732. }
  24733. $classes = is_array($extra['class']) ? $extra['class'] : array($extra['class']);
  24734. $localRepo = $this->composer->getRepositoryManager()->getLocalRepository();
  24735. $globalRepo = $this->globalComposer !== null ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null;
  24736. $rootPackage = clone $this->composer->getPackage();
  24737. $rootPackageAutoloads = $rootPackage->getAutoload();
  24738. $rootPackageAutoloads['files'] = array();
  24739. $rootPackage->setAutoload($rootPackageAutoloads);
  24740. $rootPackageAutoloads = $rootPackage->getDevAutoload();
  24741. $rootPackageAutoloads['files'] = array();
  24742. $rootPackage->setDevAutoload($rootPackageAutoloads);
  24743. unset($rootPackageAutoloads);
  24744. $rootPackageRepo = new RootPackageRepository($rootPackage);
  24745. $installedRepo = new InstalledRepository(array($localRepo, $rootPackageRepo));
  24746. if ($globalRepo) {
  24747. $installedRepo->addRepository($globalRepo);
  24748. }
  24749. $autoloadPackages = array($package->getName() => $package);
  24750. $autoloadPackages = $this->collectDependencies($installedRepo, $autoloadPackages, $package);
  24751. $generator = $this->composer->getAutoloadGenerator();
  24752. $autoloads = array(array($rootPackage, ''));
  24753. foreach ($autoloadPackages as $autoloadPackage) {
  24754. if ($autoloadPackage === $rootPackage) {
  24755. continue;
  24756. }
  24757. $downloadPath = $this->getInstallPath($autoloadPackage, $globalRepo && $globalRepo->hasPackage($autoloadPackage));
  24758. $autoloads[] = array($autoloadPackage, $downloadPath);
  24759. }
  24760. $map = $generator->parseAutoloads($autoloads, $rootPackage);
  24761. $classLoader = $generator->createLoader($map, $this->composer->getConfig()->get('vendor-dir'));
  24762. $classLoader->register(false);
  24763. foreach ($map['files'] as $fileIdentifier => $file) {
  24764. if ($fileIdentifier === '7e9bd612cc444b3eed788ebbe46263a0') {
  24765. continue;
  24766. }
  24767. \Composer\Autoload\composerRequire($fileIdentifier, $file);
  24768. }
  24769. foreach ($classes as $class) {
  24770. if (class_exists($class, false)) {
  24771. $class = trim($class, '\\');
  24772. $path = $classLoader->findFile($class);
  24773. $code = file_get_contents($path);
  24774. $separatorPos = strrpos($class, '\\');
  24775. $className = $class;
  24776. if ($separatorPos) {
  24777. $className = substr($class, $separatorPos + 1);
  24778. }
  24779. $code = Preg::replace('{^((?:final\s+)?(?:\s*))class\s+('.preg_quote($className).')}mi', '$1class $2_composer_tmp'.self::$classCounter, $code, 1);
  24780. $code = strtr($code, array(
  24781. '__FILE__' => var_export($path, true),
  24782. '__DIR__' => var_export(dirname($path), true),
  24783. '__CLASS__' => var_export($class, true),
  24784. ));
  24785. $code = Preg::replace('/^\s*<\?(php)?/i', '', $code, 1);
  24786. eval($code);
  24787. $class .= '_composer_tmp'.self::$classCounter;
  24788. self::$classCounter++;
  24789. }
  24790. if ($oldInstallerPlugin) {
  24791. if (!is_a($class, 'Composer\Installer\InstallerInterface', true)) {
  24792. throw new \RuntimeException('Could not activate plugin "'.$package->getName().'" as "'.$class.'" does not implement Composer\Installer\InstallerInterface');
  24793. }
  24794. $this->io->writeError('<warning>Loading "'.$package->getName() . '" '.($isGlobalPlugin ? '(installed globally) ' : '').'which is a legacy composer-installer built for Composer 1.x, it is likely to cause issues as you are running Composer 2.x.</warning>');
  24795. $installer = new $class($this->io, $this->composer);
  24796. $this->composer->getInstallationManager()->addInstaller($installer);
  24797. $this->registeredPlugins[$package->getName()] = $installer;
  24798. } elseif (class_exists($class)) {
  24799. if (!is_a($class, 'Composer\Plugin\PluginInterface', true)) {
  24800. throw new \RuntimeException('Could not activate plugin "'.$package->getName().'" as "'.$class.'" does not implement Composer\Plugin\PluginInterface');
  24801. }
  24802. $plugin = new $class();
  24803. $this->addPlugin($plugin, $isGlobalPlugin, $package);
  24804. $this->registeredPlugins[$package->getName()] = $plugin;
  24805. } elseif ($failOnMissingClasses) {
  24806. throw new \UnexpectedValueException('Plugin '.$package->getName().' could not be initialized, class not found: '.$class);
  24807. }
  24808. }
  24809. }
  24810. public function deactivatePackage(PackageInterface $package): void
  24811. {
  24812. if ($this->disablePlugins) {
  24813. return;
  24814. }
  24815. if (!isset($this->registeredPlugins[$package->getName()])) {
  24816. return;
  24817. }
  24818. $plugin = $this->registeredPlugins[$package->getName()];
  24819. unset($this->registeredPlugins[$package->getName()]);
  24820. if ($plugin instanceof InstallerInterface) {
  24821. $this->composer->getInstallationManager()->removeInstaller($plugin);
  24822. } else {
  24823. $this->removePlugin($plugin);
  24824. }
  24825. }
  24826. public function uninstallPackage(PackageInterface $package): void
  24827. {
  24828. if ($this->disablePlugins) {
  24829. return;
  24830. }
  24831. if (!isset($this->registeredPlugins[$package->getName()])) {
  24832. return;
  24833. }
  24834. $plugin = $this->registeredPlugins[$package->getName()];
  24835. if ($plugin instanceof InstallerInterface) {
  24836. $this->deactivatePackage($package);
  24837. } else {
  24838. unset($this->registeredPlugins[$package->getName()]);
  24839. $this->removePlugin($plugin);
  24840. $this->uninstallPlugin($plugin);
  24841. }
  24842. }
  24843. protected function getPluginApiVersion(): string
  24844. {
  24845. return PluginInterface::PLUGIN_API_VERSION;
  24846. }
  24847. public function addPlugin(PluginInterface $plugin, bool $isGlobalPlugin = false, PackageInterface $sourcePackage = null): void
  24848. {
  24849. if ($sourcePackage === null) {
  24850. trigger_error('Calling PluginManager::addPlugin without $sourcePackage is deprecated, if you are using this please get in touch with us to explain the use case', E_USER_DEPRECATED);
  24851. } elseif (!$this->isPluginAllowed($sourcePackage->getName(), $isGlobalPlugin)) {
  24852. $this->io->writeError('Skipped loading "'.get_class($plugin).' from '.$sourcePackage->getName() . '" '.($isGlobalPlugin ? '(installed globally) ' : '').' as it is not in config.allow-plugins', true, IOInterface::DEBUG);
  24853. return;
  24854. }
  24855. $details = array();
  24856. if ($sourcePackage) {
  24857. $details[] = 'from '.$sourcePackage->getName();
  24858. }
  24859. if ($isGlobalPlugin) {
  24860. $details[] = 'installed globally';
  24861. }
  24862. $this->io->writeError('Loading plugin '.get_class($plugin).($details ? ' ('.implode(', ', $details).')' : ''), true, IOInterface::DEBUG);
  24863. $this->plugins[] = $plugin;
  24864. $plugin->activate($this->composer, $this->io);
  24865. if ($plugin instanceof EventSubscriberInterface) {
  24866. $this->composer->getEventDispatcher()->addSubscriber($plugin);
  24867. }
  24868. }
  24869. public function removePlugin(PluginInterface $plugin): void
  24870. {
  24871. $index = array_search($plugin, $this->plugins, true);
  24872. if ($index === false) {
  24873. return;
  24874. }
  24875. $this->io->writeError('Unloading plugin '.get_class($plugin), true, IOInterface::DEBUG);
  24876. unset($this->plugins[$index]);
  24877. $plugin->deactivate($this->composer, $this->io);
  24878. $this->composer->getEventDispatcher()->removeListener($plugin);
  24879. }
  24880. public function uninstallPlugin(PluginInterface $plugin): void
  24881. {
  24882. $this->io->writeError('Uninstalling plugin '.get_class($plugin), true, IOInterface::DEBUG);
  24883. $plugin->uninstall($this->composer, $this->io);
  24884. }
  24885. private function loadRepository(RepositoryInterface $repo, bool $isGlobalRepo): void
  24886. {
  24887. $packages = $repo->getPackages();
  24888. $weights = array();
  24889. foreach ($packages as $package) {
  24890. if ($package->getType() === 'composer-plugin') {
  24891. $extra = $package->getExtra();
  24892. if ($package->getName() === 'composer/installers' || true === ($extra['plugin-modifies-install-path'] ?? false)) {
  24893. $weights[$package->getName()] = -10000;
  24894. }
  24895. }
  24896. }
  24897. $sortedPackages = PackageSorter::sortPackages($packages, $weights);
  24898. foreach ($sortedPackages as $package) {
  24899. if (!($package instanceof CompletePackage)) {
  24900. continue;
  24901. }
  24902. if ('composer-plugin' === $package->getType()) {
  24903. $this->registerPackage($package, false, $isGlobalRepo);
  24904. } elseif ('composer-installer' === $package->getType()) {
  24905. $this->registerPackage($package, false, $isGlobalRepo);
  24906. }
  24907. }
  24908. }
  24909. private function deactivateRepository(RepositoryInterface $repo, bool $isGlobalRepo): void
  24910. {
  24911. $packages = $repo->getPackages();
  24912. $sortedPackages = array_reverse(PackageSorter::sortPackages($packages));
  24913. foreach ($sortedPackages as $package) {
  24914. if (!($package instanceof CompletePackage)) {
  24915. continue;
  24916. }
  24917. if ('composer-plugin' === $package->getType()) {
  24918. $this->deactivatePackage($package);
  24919. } elseif ('composer-installer' === $package->getType()) {
  24920. $this->deactivatePackage($package);
  24921. }
  24922. }
  24923. }
  24924. private function collectDependencies(InstalledRepository $installedRepo, array $collected, PackageInterface $package): array
  24925. {
  24926. foreach ($package->getRequires() as $requireLink) {
  24927. foreach ($installedRepo->findPackagesWithReplacersAndProviders($requireLink->getTarget()) as $requiredPackage) {
  24928. if (!isset($collected[$requiredPackage->getName()])) {
  24929. $collected[$requiredPackage->getName()] = $requiredPackage;
  24930. $collected = $this->collectDependencies($installedRepo, $collected, $requiredPackage);
  24931. }
  24932. }
  24933. }
  24934. return $collected;
  24935. }
  24936. private function getInstallPath(PackageInterface $package, bool $global = false): string
  24937. {
  24938. if (!$global) {
  24939. return $this->composer->getInstallationManager()->getInstallPath($package);
  24940. }
  24941. assert(null !== $this->globalComposer);
  24942. return $this->globalComposer->getInstallationManager()->getInstallPath($package);
  24943. }
  24944. protected function getCapabilityImplementationClassName(PluginInterface $plugin, string $capability): ?string
  24945. {
  24946. if (!($plugin instanceof Capable)) {
  24947. return null;
  24948. }
  24949. $capabilities = (array) $plugin->getCapabilities();
  24950. if (!empty($capabilities[$capability]) && is_string($capabilities[$capability]) && trim($capabilities[$capability])) {
  24951. return trim($capabilities[$capability]);
  24952. }
  24953. if (
  24954. array_key_exists($capability, $capabilities)
  24955. && (empty($capabilities[$capability]) || !is_string($capabilities[$capability]) || !trim($capabilities[$capability]))
  24956. ) {
  24957. throw new \UnexpectedValueException('Plugin '.get_class($plugin).' provided invalid capability class name(s), got '.var_export($capabilities[$capability], true));
  24958. }
  24959. return null;
  24960. }
  24961. public function getPluginCapability(PluginInterface $plugin, $capabilityClassName, array $ctorArgs = array()): ?Capability
  24962. {
  24963. if ($capabilityClass = $this->getCapabilityImplementationClassName($plugin, $capabilityClassName)) {
  24964. if (!class_exists($capabilityClass)) {
  24965. throw new \RuntimeException("Cannot instantiate Capability, as class $capabilityClass from plugin ".get_class($plugin)." does not exist.");
  24966. }
  24967. $ctorArgs['plugin'] = $plugin;
  24968. $capabilityObj = new $capabilityClass($ctorArgs);
  24969. if (!$capabilityObj instanceof Capability || !$capabilityObj instanceof $capabilityClassName) {
  24970. throw new \RuntimeException(
  24971. 'Class ' . $capabilityClass . ' must implement both Composer\Plugin\Capability\Capability and '. $capabilityClassName . '.'
  24972. );
  24973. }
  24974. return $capabilityObj;
  24975. }
  24976. return null;
  24977. }
  24978. public function getPluginCapabilities($capabilityClassName, array $ctorArgs = array()): array
  24979. {
  24980. $capabilities = array();
  24981. foreach ($this->getPlugins() as $plugin) {
  24982. if ($capability = $this->getPluginCapability($plugin, $capabilityClassName, $ctorArgs)) {
  24983. $capabilities[] = $capability;
  24984. }
  24985. }
  24986. return $capabilities;
  24987. }
  24988. private function parseAllowedPlugins($allowPluginsConfig): ?array
  24989. {
  24990. if (null === $allowPluginsConfig) {
  24991. return null;
  24992. }
  24993. if (true === $allowPluginsConfig) {
  24994. return array('{}' => true);
  24995. }
  24996. if (false === $allowPluginsConfig) {
  24997. return array('{}' => false);
  24998. }
  24999. $rules = array();
  25000. foreach ($allowPluginsConfig as $pattern => $allow) {
  25001. $rules[BasePackage::packageNameToRegexp($pattern)] = $allow;
  25002. }
  25003. return $rules;
  25004. }
  25005. private function isPluginAllowed(string $package, bool $isGlobalPlugin): bool
  25006. {
  25007. static $warned = array();
  25008. $rules = $isGlobalPlugin ? $this->allowGlobalPluginRules : $this->allowPluginRules;
  25009. if ($rules === null) {
  25010. if (!$this->io->isInteractive()) {
  25011. if (!isset($warned['all'])) {
  25012. $this->io->writeError('<warning>For additional security you should declare the allow-plugins config with a list of packages names that are allowed to run code. See https://getcomposer.org/allow-plugins</warning>');
  25013. $this->io->writeError('<warning>You have until July 2022 to add the setting. Composer will then switch the default behavior to disallow all plugins.</warning>');
  25014. $warned['all'] = true;
  25015. }
  25016. return true;
  25017. }
  25018. $rules = array();
  25019. }
  25020. foreach ($rules as $pattern => $allow) {
  25021. if (Preg::isMatch($pattern, $package)) {
  25022. return $allow === true;
  25023. }
  25024. }
  25025. if ($package === 'composer/package-versions-deprecated') {
  25026. return false;
  25027. }
  25028. if (!isset($warned[$package])) {
  25029. if ($this->io->isInteractive()) {
  25030. $composer = $isGlobalPlugin && $this->globalComposer !== null ? $this->globalComposer : $this->composer;
  25031. $this->io->writeError('<warning>'.$package.($isGlobalPlugin ? ' (installed globally)' : '').' contains a Composer plugin which is currently not in your allow-plugins config. See https://getcomposer.org/allow-plugins</warning>');
  25032. $attempts = 0;
  25033. while (true) {
  25034. $default = '?';
  25035. if ($attempts > 5) {
  25036. $default = 'd';
  25037. }
  25038. switch ($answer = $this->io->ask('Do you trust "<fg=green;options=bold>'.$package.'</>" to execute code and wish to enable it now? (writes "allow-plugins" to composer.json) [<comment>y,n,d,?</comment>] ', $default)) {
  25039. case 'y':
  25040. case 'n':
  25041. case 'd':
  25042. $allow = $answer === 'y';
  25043. if ($isGlobalPlugin) {
  25044. $this->allowGlobalPluginRules[BasePackage::packageNameToRegexp($package)] = $allow;
  25045. } else {
  25046. $this->allowPluginRules[BasePackage::packageNameToRegexp($package)] = $allow;
  25047. }
  25048. if ($answer === 'y' || $answer === 'n') {
  25049. $composer->getConfig()->getConfigSource()->addConfigSetting('allow-plugins.'.$package, $allow);
  25050. }
  25051. return $allow;
  25052. case '?':
  25053. default:
  25054. $attempts++;
  25055. $this->io->writeError(array(
  25056. 'y - add package to allow-plugins in composer.json and let it run immediately',
  25057. 'n - add package (as disallowed) to allow-plugins in composer.json to suppress further prompts',
  25058. 'd - discard this, do not change composer.json and do not allow the plugin to run',
  25059. '? - print help',
  25060. ));
  25061. break;
  25062. }
  25063. }
  25064. } else {
  25065. $this->io->writeError('<warning>'.$package.($isGlobalPlugin ? ' (installed globally)' : '').' contains a Composer plugin which is blocked by your allow-plugins config. You may add it to the list if you consider it safe. See https://getcomposer.org/allow-plugins</warning>');
  25066. $this->io->writeError('<warning>You can run "composer '.($isGlobalPlugin ? 'global ' : '').'config --no-plugins allow-plugins.'.$package.' [true|false]" to enable it (true) or keep it disabled and suppress this warning (false)</warning>');
  25067. }
  25068. $warned[$package] = true;
  25069. }
  25070. return false;
  25071. }
  25072. }
  25073. <?php declare(strict_types=1);
  25074. namespace Composer\Plugin;
  25075. use Composer\EventDispatcher\Event;
  25076. use Composer\Package\PackageInterface;
  25077. class PostFileDownloadEvent extends Event
  25078. {
  25079. private $fileName;
  25080. private $checksum;
  25081. private $url;
  25082. private $context;
  25083. private $type;
  25084. public function __construct(string $name, ?string $fileName, ?string $checksum, string $url, string $type, $context = null)
  25085. {
  25086. if ($context === null && $type instanceof PackageInterface) {
  25087. $context = $type;
  25088. $type = 'package';
  25089. trigger_error('PostFileDownloadEvent::__construct should receive a $type=package and the package object in $context since Composer 2.1.', E_USER_DEPRECATED);
  25090. }
  25091. parent::__construct($name);
  25092. $this->fileName = $fileName;
  25093. $this->checksum = $checksum;
  25094. $this->url = $url;
  25095. $this->context = $context;
  25096. $this->type = $type;
  25097. }
  25098. public function getFileName(): ?string
  25099. {
  25100. return $this->fileName;
  25101. }
  25102. public function getChecksum(): ?string
  25103. {
  25104. return $this->checksum;
  25105. }
  25106. public function getUrl(): string
  25107. {
  25108. return $this->url;
  25109. }
  25110. public function getContext()
  25111. {
  25112. return $this->context;
  25113. }
  25114. public function getPackage(): ?PackageInterface
  25115. {
  25116. trigger_error('PostFileDownloadEvent::getPackage is deprecated since Composer 2.1, use getContext instead.', E_USER_DEPRECATED);
  25117. $context = $this->getContext();
  25118. return $context instanceof PackageInterface ? $context : null;
  25119. }
  25120. public function getType(): string
  25121. {
  25122. return $this->type;
  25123. }
  25124. }
  25125. <?php declare(strict_types=1);
  25126. namespace Composer\Plugin;
  25127. use Composer\EventDispatcher\Event;
  25128. use Symfony\Component\Console\Input\InputInterface;
  25129. class PreCommandRunEvent extends Event
  25130. {
  25131. private $input;
  25132. private $command;
  25133. public function __construct(string $name, InputInterface $input, string $command)
  25134. {
  25135. parent::__construct($name);
  25136. $this->input = $input;
  25137. $this->command = $command;
  25138. }
  25139. public function getInput(): InputInterface
  25140. {
  25141. return $this->input;
  25142. }
  25143. public function getCommand(): string
  25144. {
  25145. return $this->command;
  25146. }
  25147. }
  25148. <?php declare(strict_types=1);
  25149. namespace Composer\Plugin;
  25150. use Composer\EventDispatcher\Event;
  25151. use Composer\Util\HttpDownloader;
  25152. class PreFileDownloadEvent extends Event
  25153. {
  25154. private $httpDownloader;
  25155. private $processedUrl;
  25156. private $customCacheKey;
  25157. private $type;
  25158. private $context;
  25159. private $transportOptions = array();
  25160. public function __construct(string $name, HttpDownloader $httpDownloader, string $processedUrl, string $type, $context = null)
  25161. {
  25162. parent::__construct($name);
  25163. $this->httpDownloader = $httpDownloader;
  25164. $this->processedUrl = $processedUrl;
  25165. $this->type = $type;
  25166. $this->context = $context;
  25167. }
  25168. public function getHttpDownloader(): HttpDownloader
  25169. {
  25170. return $this->httpDownloader;
  25171. }
  25172. public function getProcessedUrl(): string
  25173. {
  25174. return $this->processedUrl;
  25175. }
  25176. public function setProcessedUrl(string $processedUrl): void
  25177. {
  25178. $this->processedUrl = $processedUrl;
  25179. }
  25180. public function getCustomCacheKey(): ?string
  25181. {
  25182. return $this->customCacheKey;
  25183. }
  25184. public function setCustomCacheKey(?string $customCacheKey): void
  25185. {
  25186. $this->customCacheKey = $customCacheKey;
  25187. }
  25188. public function getType(): string
  25189. {
  25190. return $this->type;
  25191. }
  25192. public function getContext()
  25193. {
  25194. return $this->context;
  25195. }
  25196. public function getTransportOptions(): array
  25197. {
  25198. return $this->transportOptions;
  25199. }
  25200. public function setTransportOptions(array $options): void
  25201. {
  25202. $this->transportOptions = $options;
  25203. }
  25204. }
  25205. <?php declare(strict_types=1);
  25206. namespace Composer\Plugin;
  25207. use Composer\EventDispatcher\Event;
  25208. use Composer\Repository\RepositoryInterface;
  25209. use Composer\DependencyResolver\Request;
  25210. use Composer\Package\BasePackage;
  25211. class PrePoolCreateEvent extends Event
  25212. {
  25213. private $repositories;
  25214. private $request;
  25215. private $acceptableStabilities;
  25216. private $stabilityFlags;
  25217. private $rootAliases;
  25218. private $rootReferences;
  25219. private $packages;
  25220. private $unacceptableFixedPackages;
  25221. public function __construct(string $name, array $repositories, Request $request, array $acceptableStabilities, array $stabilityFlags, array $rootAliases, array $rootReferences, array $packages, array $unacceptableFixedPackages)
  25222. {
  25223. parent::__construct($name);
  25224. $this->repositories = $repositories;
  25225. $this->request = $request;
  25226. $this->acceptableStabilities = $acceptableStabilities;
  25227. $this->stabilityFlags = $stabilityFlags;
  25228. $this->rootAliases = $rootAliases;
  25229. $this->rootReferences = $rootReferences;
  25230. $this->packages = $packages;
  25231. $this->unacceptableFixedPackages = $unacceptableFixedPackages;
  25232. }
  25233. public function getRepositories(): array
  25234. {
  25235. return $this->repositories;
  25236. }
  25237. public function getRequest(): Request
  25238. {
  25239. return $this->request;
  25240. }
  25241. public function getAcceptableStabilities(): array
  25242. {
  25243. return $this->acceptableStabilities;
  25244. }
  25245. public function getStabilityFlags(): array
  25246. {
  25247. return $this->stabilityFlags;
  25248. }
  25249. public function getRootAliases(): array
  25250. {
  25251. return $this->rootAliases;
  25252. }
  25253. public function getRootReferences(): array
  25254. {
  25255. return $this->rootReferences;
  25256. }
  25257. public function getPackages(): array
  25258. {
  25259. return $this->packages;
  25260. }
  25261. public function getUnacceptableFixedPackages(): array
  25262. {
  25263. return $this->unacceptableFixedPackages;
  25264. }
  25265. public function setPackages(array $packages): void
  25266. {
  25267. $this->packages = $packages;
  25268. }
  25269. public function setUnacceptableFixedPackages(array $packages): void
  25270. {
  25271. $this->unacceptableFixedPackages = $packages;
  25272. }
  25273. }
  25274. <?php declare(strict_types=1);
  25275. namespace Composer\Question;
  25276. use Composer\Pcre\Preg;
  25277. use Symfony\Component\Console\Exception\InvalidArgumentException;
  25278. use Symfony\Component\Console\Question\Question;
  25279. class StrictConfirmationQuestion extends Question
  25280. {
  25281. private $trueAnswerRegex;
  25282. private $falseAnswerRegex;
  25283. public function __construct(string $question, bool $default = true, string $trueAnswerRegex = '/^y(?:es)?$/i', string $falseAnswerRegex = '/^no?$/i')
  25284. {
  25285. parent::__construct($question, (bool) $default);
  25286. $this->trueAnswerRegex = $trueAnswerRegex;
  25287. $this->falseAnswerRegex = $falseAnswerRegex;
  25288. $this->setNormalizer($this->getDefaultNormalizer());
  25289. $this->setValidator($this->getDefaultValidator());
  25290. }
  25291. private function getDefaultNormalizer(): callable
  25292. {
  25293. $default = $this->getDefault();
  25294. $trueRegex = $this->trueAnswerRegex;
  25295. $falseRegex = $this->falseAnswerRegex;
  25296. return function ($answer) use ($default, $trueRegex, $falseRegex) {
  25297. if (is_bool($answer)) {
  25298. return $answer;
  25299. }
  25300. if (empty($answer) && !empty($default)) {
  25301. return $default;
  25302. }
  25303. if (Preg::isMatch($trueRegex, $answer)) {
  25304. return true;
  25305. }
  25306. if (Preg::isMatch($falseRegex, $answer)) {
  25307. return false;
  25308. }
  25309. return null;
  25310. };
  25311. }
  25312. private function getDefaultValidator(): callable
  25313. {
  25314. return function ($answer): bool {
  25315. if (!is_bool($answer)) {
  25316. throw new InvalidArgumentException('Please answer yes, y, no, or n.');
  25317. }
  25318. return $answer;
  25319. };
  25320. }
  25321. }
  25322. <?php declare(strict_types=1);
  25323. namespace Composer\Repository;
  25324. use Composer\Package\AliasPackage;
  25325. use Composer\Package\BasePackage;
  25326. use Composer\Package\CompleteAliasPackage;
  25327. use Composer\Package\CompletePackage;
  25328. use Composer\Package\PackageInterface;
  25329. use Composer\Package\CompletePackageInterface;
  25330. use Composer\Package\Version\VersionParser;
  25331. use Composer\Package\Version\StabilityFilter;
  25332. use Composer\Pcre\Preg;
  25333. use Composer\Semver\Constraint\ConstraintInterface;
  25334. use Composer\Semver\Constraint\Constraint;
  25335. class ArrayRepository implements RepositoryInterface
  25336. {
  25337. protected $packages = null;
  25338. protected $packageMap = null;
  25339. public function __construct(array $packages = array())
  25340. {
  25341. foreach ($packages as $package) {
  25342. $this->addPackage($package);
  25343. }
  25344. }
  25345. public function getRepoName()
  25346. {
  25347. return 'array repo (defining '.$this->count().' package'.($this->count() > 1 ? 's' : '').')';
  25348. }
  25349. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  25350. {
  25351. $packages = $this->getPackages();
  25352. $result = array();
  25353. $namesFound = array();
  25354. foreach ($packages as $package) {
  25355. if (array_key_exists($package->getName(), $packageNameMap)) {
  25356. if (
  25357. (!$packageNameMap[$package->getName()] || $packageNameMap[$package->getName()]->matches(new Constraint('==', $package->getVersion())))
  25358. && StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, $package->getNames(), $package->getStability())
  25359. && !isset($alreadyLoaded[$package->getName()][$package->getVersion()])
  25360. ) {
  25361. $result[spl_object_hash($package)] = $package;
  25362. if ($package instanceof AliasPackage && !isset($result[spl_object_hash($package->getAliasOf())])) {
  25363. $result[spl_object_hash($package->getAliasOf())] = $package->getAliasOf();
  25364. }
  25365. }
  25366. $namesFound[$package->getName()] = true;
  25367. }
  25368. }
  25369. foreach ($packages as $package) {
  25370. if ($package instanceof AliasPackage) {
  25371. if (isset($result[spl_object_hash($package->getAliasOf())])) {
  25372. $result[spl_object_hash($package)] = $package;
  25373. }
  25374. }
  25375. }
  25376. return array('namesFound' => array_keys($namesFound), 'packages' => $result);
  25377. }
  25378. public function findPackage(string $name, $constraint)
  25379. {
  25380. $name = strtolower($name);
  25381. if (!$constraint instanceof ConstraintInterface) {
  25382. $versionParser = new VersionParser();
  25383. $constraint = $versionParser->parseConstraints($constraint);
  25384. }
  25385. foreach ($this->getPackages() as $package) {
  25386. if ($name === $package->getName()) {
  25387. $pkgConstraint = new Constraint('==', $package->getVersion());
  25388. if ($constraint->matches($pkgConstraint)) {
  25389. return $package;
  25390. }
  25391. }
  25392. }
  25393. return null;
  25394. }
  25395. public function findPackages(string $name, $constraint = null)
  25396. {
  25397. $name = strtolower($name);
  25398. $packages = array();
  25399. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  25400. $versionParser = new VersionParser();
  25401. $constraint = $versionParser->parseConstraints($constraint);
  25402. }
  25403. foreach ($this->getPackages() as $package) {
  25404. if ($name === $package->getName()) {
  25405. if (null === $constraint || $constraint->matches(new Constraint('==', $package->getVersion()))) {
  25406. $packages[] = $package;
  25407. }
  25408. }
  25409. }
  25410. return $packages;
  25411. }
  25412. public function search(string $query, int $mode = 0, ?string $type = null)
  25413. {
  25414. if ($mode === self::SEARCH_FULLTEXT) {
  25415. $regex = '{(?:'.implode('|', Preg::split('{\s+}', preg_quote($query))).')}i';
  25416. } else {
  25417. $regex = '{(?:'.implode('|', Preg::split('{\s+}', $query)).')}i';
  25418. }
  25419. $matches = array();
  25420. foreach ($this->getPackages() as $package) {
  25421. $name = $package->getName();
  25422. if ($mode === self::SEARCH_VENDOR) {
  25423. list($name) = explode('/', $name);
  25424. }
  25425. if (isset($matches[$name])) {
  25426. continue;
  25427. }
  25428. if (null !== $type && $package->getType() !== $type) {
  25429. continue;
  25430. }
  25431. if (Preg::isMatch($regex, $name)
  25432. || ($mode === self::SEARCH_FULLTEXT && $package instanceof CompletePackageInterface && Preg::isMatch($regex, implode(' ', (array) $package->getKeywords()) . ' ' . $package->getDescription()))
  25433. ) {
  25434. if ($mode === self::SEARCH_VENDOR) {
  25435. $matches[$name] = array(
  25436. 'name' => $name,
  25437. 'description' => null,
  25438. );
  25439. } else {
  25440. $matches[$name] = array(
  25441. 'name' => $package->getPrettyName(),
  25442. 'description' => $package instanceof CompletePackageInterface ? $package->getDescription() : null,
  25443. );
  25444. if ($package instanceof CompletePackageInterface && $package->isAbandoned()) {
  25445. $matches[$name]['abandoned'] = $package->getReplacementPackage() ?: true;
  25446. }
  25447. }
  25448. }
  25449. }
  25450. return array_values($matches);
  25451. }
  25452. public function hasPackage(PackageInterface $package)
  25453. {
  25454. if ($this->packageMap === null) {
  25455. $this->packageMap = array();
  25456. foreach ($this->getPackages() as $repoPackage) {
  25457. $this->packageMap[$repoPackage->getUniqueName()] = $repoPackage;
  25458. }
  25459. }
  25460. return isset($this->packageMap[$package->getUniqueName()]);
  25461. }
  25462. public function addPackage(PackageInterface $package)
  25463. {
  25464. if (!$package instanceof BasePackage) {
  25465. throw new \InvalidArgumentException('Only subclasses of BasePackage are supported');
  25466. }
  25467. if (null === $this->packages) {
  25468. $this->initialize();
  25469. }
  25470. $package->setRepository($this);
  25471. $this->packages[] = $package;
  25472. if ($package instanceof AliasPackage) {
  25473. $aliasedPackage = $package->getAliasOf();
  25474. if (null === $aliasedPackage->getRepository()) {
  25475. $this->addPackage($aliasedPackage);
  25476. }
  25477. }
  25478. $this->packageMap = null;
  25479. }
  25480. public function getProviders(string $packageName)
  25481. {
  25482. $result = array();
  25483. foreach ($this->getPackages() as $candidate) {
  25484. if (isset($result[$candidate->getName()])) {
  25485. continue;
  25486. }
  25487. foreach ($candidate->getProvides() as $link) {
  25488. if ($packageName === $link->getTarget()) {
  25489. $result[$candidate->getName()] = array(
  25490. 'name' => $candidate->getName(),
  25491. 'description' => $candidate instanceof CompletePackageInterface ? $candidate->getDescription() : null,
  25492. 'type' => $candidate->getType(),
  25493. );
  25494. continue 2;
  25495. }
  25496. }
  25497. }
  25498. return $result;
  25499. }
  25500. protected function createAliasPackage(BasePackage $package, string $alias, string $prettyAlias)
  25501. {
  25502. while ($package instanceof AliasPackage) {
  25503. $package = $package->getAliasOf();
  25504. }
  25505. if ($package instanceof CompletePackage) {
  25506. return new CompleteAliasPackage($package, $alias, $prettyAlias);
  25507. }
  25508. return new AliasPackage($package, $alias, $prettyAlias);
  25509. }
  25510. public function removePackage(PackageInterface $package)
  25511. {
  25512. $packageId = $package->getUniqueName();
  25513. foreach ($this->getPackages() as $key => $repoPackage) {
  25514. if ($packageId === $repoPackage->getUniqueName()) {
  25515. array_splice($this->packages, $key, 1);
  25516. $this->packageMap = null;
  25517. return;
  25518. }
  25519. }
  25520. }
  25521. public function getPackages()
  25522. {
  25523. if (null === $this->packages) {
  25524. $this->initialize();
  25525. }
  25526. if (null === $this->packages) {
  25527. throw new \LogicException('initialize failed to initialize the packages array');
  25528. }
  25529. return $this->packages;
  25530. }
  25531. public function count(): int
  25532. {
  25533. if (null === $this->packages) {
  25534. $this->initialize();
  25535. }
  25536. return count($this->packages);
  25537. }
  25538. protected function initialize()
  25539. {
  25540. $this->packages = array();
  25541. }
  25542. }
  25543. <?php declare(strict_types=1);
  25544. namespace Composer\Repository;
  25545. use Composer\IO\IOInterface;
  25546. use Composer\Json\JsonFile;
  25547. use Composer\Package\BasePackage;
  25548. use Composer\Package\Loader\ArrayLoader;
  25549. use Composer\Package\Loader\LoaderInterface;
  25550. use Composer\Util\Tar;
  25551. use Composer\Util\Zip;
  25552. class ArtifactRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  25553. {
  25554. protected $loader;
  25555. protected $lookup;
  25556. protected $repoConfig;
  25557. private $io;
  25558. public function __construct(array $repoConfig, IOInterface $io)
  25559. {
  25560. parent::__construct();
  25561. if (!extension_loaded('zip')) {
  25562. throw new \RuntimeException('The artifact repository requires PHP\'s zip extension');
  25563. }
  25564. $this->loader = new ArrayLoader();
  25565. $this->lookup = $repoConfig['url'];
  25566. $this->io = $io;
  25567. $this->repoConfig = $repoConfig;
  25568. }
  25569. public function getRepoName()
  25570. {
  25571. return 'artifact repo ('.$this->lookup.')';
  25572. }
  25573. public function getRepoConfig()
  25574. {
  25575. return $this->repoConfig;
  25576. }
  25577. protected function initialize()
  25578. {
  25579. parent::initialize();
  25580. $this->scanDirectory($this->lookup);
  25581. }
  25582. private function scanDirectory(string $path): void
  25583. {
  25584. $io = $this->io;
  25585. $directory = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS);
  25586. $iterator = new \RecursiveIteratorIterator($directory);
  25587. $regex = new \RegexIterator($iterator, '/^.+\.(zip|tar|gz|tgz)$/i');
  25588. foreach ($regex as $file) {
  25589. if (!$file->isFile()) {
  25590. continue;
  25591. }
  25592. $package = $this->getComposerInformation($file);
  25593. if (!$package) {
  25594. $io->writeError("File <comment>{$file->getBasename()}</comment> doesn't seem to hold a package", true, IOInterface::VERBOSE);
  25595. continue;
  25596. }
  25597. $template = 'Found package <info>%s</info> (<comment>%s</comment>) in file <info>%s</info>';
  25598. $io->writeError(sprintf($template, $package->getName(), $package->getPrettyVersion(), $file->getBasename()), true, IOInterface::VERBOSE);
  25599. $this->addPackage($package);
  25600. }
  25601. }
  25602. private function getComposerInformation(\SplFileInfo $file): ?BasePackage
  25603. {
  25604. $json = null;
  25605. $fileType = null;
  25606. $fileExtension = pathinfo($file->getPathname(), PATHINFO_EXTENSION);
  25607. if (in_array($fileExtension, array('gz', 'tar', 'tgz'), true)) {
  25608. $fileType = 'tar';
  25609. } elseif ($fileExtension === 'zip') {
  25610. $fileType = 'zip';
  25611. } else {
  25612. throw new \RuntimeException('Files with "'.$fileExtension.'" extensions aren\'t supported. Only ZIP and TAR/TAR.GZ/TGZ archives are supported.');
  25613. }
  25614. try {
  25615. if ($fileType === 'tar') {
  25616. $json = Tar::getComposerJson($file->getPathname());
  25617. } else {
  25618. $json = Zip::getComposerJson($file->getPathname());
  25619. }
  25620. } catch (\Exception $exception) {
  25621. $this->io->write('Failed loading package '.$file->getPathname().': '.$exception->getMessage(), false, IOInterface::VERBOSE);
  25622. }
  25623. if (null === $json) {
  25624. return null;
  25625. }
  25626. $package = JsonFile::parseJson($json, $file->getPathname().'#composer.json');
  25627. $package['dist'] = array(
  25628. 'type' => $fileType,
  25629. 'url' => strtr($file->getPathname(), '\\', '/'),
  25630. 'shasum' => sha1_file($file->getRealPath()),
  25631. );
  25632. try {
  25633. $package = $this->loader->load($package);
  25634. } catch (\UnexpectedValueException $e) {
  25635. throw new \UnexpectedValueException('Failed loading package in '.$file.': '.$e->getMessage(), 0, $e);
  25636. }
  25637. return $package;
  25638. }
  25639. }
  25640. <?php declare(strict_types=1);
  25641. namespace Composer\Repository;
  25642. use Composer\Package\BasePackage;
  25643. use Composer\Package\Loader\ArrayLoader;
  25644. use Composer\Package\PackageInterface;
  25645. use Composer\Package\AliasPackage;
  25646. use Composer\Package\CompletePackage;
  25647. use Composer\Package\CompleteAliasPackage;
  25648. use Composer\Package\Version\VersionParser;
  25649. use Composer\Package\Version\StabilityFilter;
  25650. use Composer\Json\JsonFile;
  25651. use Composer\Cache;
  25652. use Composer\Config;
  25653. use Composer\IO\IOInterface;
  25654. use Composer\Pcre\Preg;
  25655. use Composer\Plugin\PostFileDownloadEvent;
  25656. use Composer\Semver\CompilingMatcher;
  25657. use Composer\Util\HttpDownloader;
  25658. use Composer\Util\Loop;
  25659. use Composer\Plugin\PluginEvents;
  25660. use Composer\Plugin\PreFileDownloadEvent;
  25661. use Composer\EventDispatcher\EventDispatcher;
  25662. use Composer\Downloader\TransportException;
  25663. use Composer\Semver\Constraint\ConstraintInterface;
  25664. use Composer\Semver\Constraint\Constraint;
  25665. use Composer\Semver\Constraint\MatchAllConstraint;
  25666. use Composer\Util\Http\Response;
  25667. use Composer\MetadataMinifier\MetadataMinifier;
  25668. use Composer\Util\Url;
  25669. use React\Promise\PromiseInterface;
  25670. class ComposerRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  25671. {
  25672. private $repoConfig;
  25673. private $options;
  25674. private $url;
  25675. private $baseUrl;
  25676. private $io;
  25677. private $httpDownloader;
  25678. private $loop;
  25679. protected $cache;
  25680. protected $notifyUrl = null;
  25681. protected $searchUrl = null;
  25682. protected $providersApiUrl = null;
  25683. protected $hasProviders = false;
  25684. protected $providersUrl = null;
  25685. protected $listUrl = null;
  25686. protected $hasAvailablePackageList = false;
  25687. protected $availablePackages = null;
  25688. protected $availablePackagePatterns = null;
  25689. protected $lazyProvidersUrl = null;
  25690. protected $providerListing;
  25691. protected $loader;
  25692. private $allowSslDowngrade = false;
  25693. private $eventDispatcher;
  25694. private $sourceMirrors;
  25695. private $distMirrors;
  25696. private $degradedMode = false;
  25697. private $rootData;
  25698. private $hasPartialPackages = false;
  25699. private $partialPackagesByName = null;
  25700. private $freshMetadataUrls = array();
  25701. private $packagesNotFoundCache = array();
  25702. private $versionParser;
  25703. public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null)
  25704. {
  25705. parent::__construct();
  25706. if (!Preg::isMatch('{^[\w.]+\??://}', $repoConfig['url'])) {
  25707. $repoConfig['url'] = 'http://'.$repoConfig['url'];
  25708. }
  25709. $repoConfig['url'] = rtrim($repoConfig['url'], '/');
  25710. if (strpos($repoConfig['url'], 'https?') === 0) {
  25711. $repoConfig['url'] = (extension_loaded('openssl') ? 'https' : 'http') . substr($repoConfig['url'], 6);
  25712. }
  25713. $urlBits = parse_url(strtr($repoConfig['url'], '\\', '/'));
  25714. if ($urlBits === false || empty($urlBits['scheme'])) {
  25715. throw new \UnexpectedValueException('Invalid url given for Composer repository: '.$repoConfig['url']);
  25716. }
  25717. if (!isset($repoConfig['options'])) {
  25718. $repoConfig['options'] = array();
  25719. }
  25720. if (isset($repoConfig['allow_ssl_downgrade']) && true === $repoConfig['allow_ssl_downgrade']) {
  25721. $this->allowSslDowngrade = true;
  25722. }
  25723. $this->options = $repoConfig['options'];
  25724. $this->url = $repoConfig['url'];
  25725. if (Preg::isMatch('{^(?P<proto>https?)://packagist\.org/?$}i', $this->url, $match)) {
  25726. $this->url = $match['proto'].'://repo.packagist.org';
  25727. }
  25728. $this->baseUrl = rtrim(Preg::replace('{(?:/[^/\\\\]+\.json)?(?:[?#].*)?$}', '', $this->url), '/');
  25729. $this->io = $io;
  25730. $this->cache = new Cache($io, $config->get('cache-repo-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', Url::sanitize($this->url)), 'a-z0-9.$~');
  25731. $this->cache->setReadOnly($config->get('cache-read-only'));
  25732. $this->versionParser = new VersionParser();
  25733. $this->loader = new ArrayLoader($this->versionParser);
  25734. $this->httpDownloader = $httpDownloader;
  25735. $this->eventDispatcher = $eventDispatcher;
  25736. $this->repoConfig = $repoConfig;
  25737. $this->loop = new Loop($this->httpDownloader);
  25738. }
  25739. public function getRepoName()
  25740. {
  25741. return 'composer repo ('.Url::sanitize($this->url).')';
  25742. }
  25743. public function getRepoConfig()
  25744. {
  25745. return $this->repoConfig;
  25746. }
  25747. public function findPackage(string $name, $constraint)
  25748. {
  25749. $hasProviders = $this->hasProviders();
  25750. $name = strtolower($name);
  25751. if (!$constraint instanceof ConstraintInterface) {
  25752. $constraint = $this->versionParser->parseConstraints($constraint);
  25753. }
  25754. if ($this->lazyProvidersUrl) {
  25755. if ($this->hasPartialPackages() && isset($this->partialPackagesByName[$name])) {
  25756. return $this->filterPackages($this->whatProvides($name), $constraint, true);
  25757. }
  25758. if ($this->hasAvailablePackageList && !$this->lazyProvidersRepoContains($name)) {
  25759. return null;
  25760. }
  25761. $packages = $this->loadAsyncPackages(array($name => $constraint));
  25762. if (count($packages['packages']) > 0) {
  25763. return reset($packages['packages']);
  25764. }
  25765. return null;
  25766. }
  25767. if ($hasProviders) {
  25768. foreach ($this->getProviderNames() as $providerName) {
  25769. if ($name === $providerName) {
  25770. return $this->filterPackages($this->whatProvides($providerName), $constraint, true);
  25771. }
  25772. }
  25773. return null;
  25774. }
  25775. return parent::findPackage($name, $constraint);
  25776. }
  25777. public function findPackages(string $name, $constraint = null)
  25778. {
  25779. $hasProviders = $this->hasProviders();
  25780. $name = strtolower($name);
  25781. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  25782. $constraint = $this->versionParser->parseConstraints($constraint);
  25783. }
  25784. if ($this->lazyProvidersUrl) {
  25785. if ($this->hasPartialPackages() && isset($this->partialPackagesByName[$name])) {
  25786. return $this->filterPackages($this->whatProvides($name), $constraint);
  25787. }
  25788. if ($this->hasAvailablePackageList && !$this->lazyProvidersRepoContains($name)) {
  25789. return array();
  25790. }
  25791. $result = $this->loadAsyncPackages(array($name => $constraint));
  25792. return $result['packages'];
  25793. }
  25794. if ($hasProviders) {
  25795. foreach ($this->getProviderNames() as $providerName) {
  25796. if ($name === $providerName) {
  25797. return $this->filterPackages($this->whatProvides($providerName), $constraint);
  25798. }
  25799. }
  25800. return array();
  25801. }
  25802. return parent::findPackages($name, $constraint);
  25803. }
  25804. private function filterPackages(array $packages, ?ConstraintInterface $constraint = null, bool $returnFirstMatch = false)
  25805. {
  25806. if (null === $constraint) {
  25807. if ($returnFirstMatch) {
  25808. return reset($packages);
  25809. }
  25810. return $packages;
  25811. }
  25812. $filteredPackages = array();
  25813. foreach ($packages as $package) {
  25814. $pkgConstraint = new Constraint('==', $package->getVersion());
  25815. if ($constraint->matches($pkgConstraint)) {
  25816. if ($returnFirstMatch) {
  25817. return $package;
  25818. }
  25819. $filteredPackages[] = $package;
  25820. }
  25821. }
  25822. if ($returnFirstMatch) {
  25823. return null;
  25824. }
  25825. return $filteredPackages;
  25826. }
  25827. public function getPackages()
  25828. {
  25829. $hasProviders = $this->hasProviders();
  25830. if ($this->lazyProvidersUrl) {
  25831. if (is_array($this->availablePackages) && !$this->availablePackagePatterns) {
  25832. $packageMap = array();
  25833. foreach ($this->availablePackages as $name) {
  25834. $packageMap[$name] = new MatchAllConstraint();
  25835. }
  25836. $result = $this->loadAsyncPackages($packageMap);
  25837. return array_values($result['packages']);
  25838. }
  25839. if ($this->hasPartialPackages()) {
  25840. if (!is_array($this->partialPackagesByName)) {
  25841. throw new \LogicException('hasPartialPackages failed to initialize $this->partialPackagesByName');
  25842. }
  25843. return $this->createPackages($this->partialPackagesByName, 'packages.json inline packages');
  25844. }
  25845. throw new \LogicException('Composer repositories that have lazy providers and no available-packages list can not load the complete list of packages, use getPackageNames instead.');
  25846. }
  25847. if ($hasProviders) {
  25848. throw new \LogicException('Composer repositories that have providers can not load the complete list of packages, use getPackageNames instead.');
  25849. }
  25850. return parent::getPackages();
  25851. }
  25852. public function getPackageNames(?string $packageFilter = null)
  25853. {
  25854. $hasProviders = $this->hasProviders();
  25855. $filterResults =
  25856. function (array $results): array {
  25857. return $results;
  25858. }
  25859. ;
  25860. if (null !== $packageFilter && '' !== $packageFilter) {
  25861. $packageFilterRegex = BasePackage::packageNameToRegexp($packageFilter);
  25862. $filterResults =
  25863. function (array $results) use ($packageFilterRegex): array {
  25864. return Preg::grep($packageFilterRegex, $results);
  25865. }
  25866. ;
  25867. }
  25868. if ($this->lazyProvidersUrl) {
  25869. if (is_array($this->availablePackages)) {
  25870. return $filterResults(array_keys($this->availablePackages));
  25871. }
  25872. if ($this->listUrl) {
  25873. return $this->loadPackageList($packageFilter);
  25874. }
  25875. if ($this->hasPartialPackages() && $this->partialPackagesByName !== null) {
  25876. return $filterResults(array_keys($this->partialPackagesByName));
  25877. }
  25878. return array();
  25879. }
  25880. if ($hasProviders) {
  25881. return $filterResults($this->getProviderNames());
  25882. }
  25883. $names = array();
  25884. foreach ($this->getPackages() as $package) {
  25885. $names[] = $package->getPrettyName();
  25886. }
  25887. return $filterResults($names);
  25888. }
  25889. private function getVendorNames(): array
  25890. {
  25891. $cacheKey = 'vendor-list.txt';
  25892. $cacheAge = $this->cache->getAge($cacheKey);
  25893. if (false !== $cacheAge && $cacheAge < 600 && ($cachedData = $this->cache->read($cacheKey)) !== false) {
  25894. $cachedData = explode("\n", $cachedData);
  25895. return $cachedData;
  25896. }
  25897. $names = $this->getPackageNames();
  25898. $uniques = array();
  25899. foreach ($names as $name) {
  25900. $uniques[substr($name, 0, strpos($name, '/'))] = true;
  25901. }
  25902. $vendors = array_keys($uniques);
  25903. if (!$this->cache->isReadOnly()) {
  25904. $this->cache->write($cacheKey, implode("\n", $vendors));
  25905. }
  25906. return $vendors;
  25907. }
  25908. private function loadPackageList(?string $packageFilter = null): array
  25909. {
  25910. if (null === $this->listUrl) {
  25911. throw new \LogicException('Make sure to call loadRootServerFile before loadPackageList');
  25912. }
  25913. $url = $this->listUrl;
  25914. if (is_string($packageFilter) && $packageFilter !== '') {
  25915. $url .= '?filter='.urlencode($packageFilter);
  25916. $result = $this->httpDownloader->get($url, $this->options)->decodeJson();
  25917. return $result['packageNames'];
  25918. }
  25919. $cacheKey = 'package-list.txt';
  25920. $cacheAge = $this->cache->getAge($cacheKey);
  25921. if (false !== $cacheAge && $cacheAge < 600 && ($cachedData = $this->cache->read($cacheKey)) !== false) {
  25922. $cachedData = explode("\n", $cachedData);
  25923. return $cachedData;
  25924. }
  25925. $result = $this->httpDownloader->get($url, $this->options)->decodeJson();
  25926. if (!$this->cache->isReadOnly()) {
  25927. $this->cache->write($cacheKey, implode("\n", $result['packageNames']));
  25928. }
  25929. return $result['packageNames'];
  25930. }
  25931. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  25932. {
  25933. $hasProviders = $this->hasProviders();
  25934. if (!$hasProviders && !$this->hasPartialPackages() && !$this->lazyProvidersUrl) {
  25935. return parent::loadPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  25936. }
  25937. $packages = array();
  25938. $namesFound = array();
  25939. if ($hasProviders || $this->hasPartialPackages()) {
  25940. foreach ($packageNameMap as $name => $constraint) {
  25941. $matches = array();
  25942. if (!$hasProviders && !isset($this->partialPackagesByName[$name])) {
  25943. continue;
  25944. }
  25945. $candidates = $this->whatProvides($name, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  25946. foreach ($candidates as $candidate) {
  25947. if ($candidate->getName() !== $name) {
  25948. throw new \LogicException('whatProvides should never return a package with a different name than the requested one');
  25949. }
  25950. $namesFound[$name] = true;
  25951. if (!$constraint || $constraint->matches(new Constraint('==', $candidate->getVersion()))) {
  25952. $matches[spl_object_hash($candidate)] = $candidate;
  25953. if ($candidate instanceof AliasPackage && !isset($matches[spl_object_hash($candidate->getAliasOf())])) {
  25954. $matches[spl_object_hash($candidate->getAliasOf())] = $candidate->getAliasOf();
  25955. }
  25956. }
  25957. }
  25958. foreach ($candidates as $candidate) {
  25959. if ($candidate instanceof AliasPackage) {
  25960. if (isset($matches[spl_object_hash($candidate->getAliasOf())])) {
  25961. $matches[spl_object_hash($candidate)] = $candidate;
  25962. }
  25963. }
  25964. }
  25965. $packages = array_merge($packages, $matches);
  25966. unset($packageNameMap[$name]);
  25967. }
  25968. }
  25969. if ($this->lazyProvidersUrl && count($packageNameMap)) {
  25970. if ($this->hasAvailablePackageList) {
  25971. foreach ($packageNameMap as $name => $constraint) {
  25972. if (!$this->lazyProvidersRepoContains(strtolower($name))) {
  25973. unset($packageNameMap[$name]);
  25974. }
  25975. }
  25976. }
  25977. $result = $this->loadAsyncPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  25978. $packages = array_merge($packages, $result['packages']);
  25979. $namesFound = array_merge($namesFound, $result['namesFound']);
  25980. }
  25981. return array('namesFound' => array_keys($namesFound), 'packages' => $packages);
  25982. }
  25983. public function search(string $query, int $mode = 0, ?string $type = null)
  25984. {
  25985. $this->loadRootServerFile(600);
  25986. if ($this->searchUrl && $mode === self::SEARCH_FULLTEXT) {
  25987. $url = str_replace(array('%query%', '%type%'), array(urlencode($query), $type), $this->searchUrl);
  25988. $search = $this->httpDownloader->get($url, $this->options)->decodeJson();
  25989. if (empty($search['results'])) {
  25990. return array();
  25991. }
  25992. $results = array();
  25993. foreach ($search['results'] as $result) {
  25994. if (!empty($result['virtual'])) {
  25995. continue;
  25996. }
  25997. $results[] = $result;
  25998. }
  25999. return $results;
  26000. }
  26001. if ($mode === self::SEARCH_VENDOR) {
  26002. $results = array();
  26003. $regex = '{(?:'.implode('|', Preg::split('{\s+}', $query)).')}i';
  26004. $vendorNames = $this->getVendorNames();
  26005. foreach (Preg::grep($regex, $vendorNames) as $name) {
  26006. $results[] = array('name' => $name, 'description' => '');
  26007. }
  26008. return $results;
  26009. }
  26010. if ($this->hasProviders() || $this->lazyProvidersUrl) {
  26011. if (Preg::isMatch('{^\^(?P<query>(?P<vendor>[a-z0-9_.-]+)/[a-z0-9_.-]*)\*?$}i', $query, $match) && $this->listUrl !== null) {
  26012. $url = $this->listUrl . '?vendor='.urlencode($match['vendor']).'&filter='.urlencode($match['query'].'*');
  26013. $result = $this->httpDownloader->get($url, $this->options)->decodeJson();
  26014. $results = array();
  26015. foreach ($result['packageNames'] as $name) {
  26016. $results[] = array('name' => $name, 'description' => '');
  26017. }
  26018. return $results;
  26019. }
  26020. $results = array();
  26021. $regex = '{(?:'.implode('|', Preg::split('{\s+}', $query)).')}i';
  26022. $packageNames = $this->getPackageNames();
  26023. foreach (Preg::grep($regex, $packageNames) as $name) {
  26024. $results[] = array('name' => $name, 'description' => '');
  26025. }
  26026. return $results;
  26027. }
  26028. return parent::search($query, $mode);
  26029. }
  26030. public function getProviders(string $packageName)
  26031. {
  26032. $this->loadRootServerFile();
  26033. $result = array();
  26034. if ($this->providersApiUrl) {
  26035. $apiResult = $this->httpDownloader->get(str_replace('%package%', $packageName, $this->providersApiUrl), $this->options)->decodeJson();
  26036. foreach ($apiResult['providers'] as $provider) {
  26037. $result[$provider['name']] = $provider;
  26038. }
  26039. return $result;
  26040. }
  26041. if ($this->hasPartialPackages()) {
  26042. if (!is_array($this->partialPackagesByName)) {
  26043. throw new \LogicException('hasPartialPackages failed to initialize $this->partialPackagesByName');
  26044. }
  26045. foreach ($this->partialPackagesByName as $versions) {
  26046. foreach ($versions as $candidate) {
  26047. if (isset($result[$candidate['name']]) || !isset($candidate['provide'][$packageName])) {
  26048. continue;
  26049. }
  26050. $result[$candidate['name']] = array(
  26051. 'name' => $candidate['name'],
  26052. 'description' => $candidate['description'] ?? '',
  26053. 'type' => $candidate['type'] ?? '',
  26054. );
  26055. }
  26056. }
  26057. }
  26058. if ($this->packages) {
  26059. $result = array_merge($result, parent::getProviders($packageName));
  26060. }
  26061. return $result;
  26062. }
  26063. private function getProviderNames(): array
  26064. {
  26065. $this->loadRootServerFile();
  26066. if (null === $this->providerListing) {
  26067. $data = $this->loadRootServerFile();
  26068. if (is_array($data)) {
  26069. $this->loadProviderListings($data);
  26070. }
  26071. }
  26072. if ($this->lazyProvidersUrl) {
  26073. return array();
  26074. }
  26075. if (null !== $this->providersUrl && null !== $this->providerListing) {
  26076. return array_keys($this->providerListing);
  26077. }
  26078. return array();
  26079. }
  26080. protected function configurePackageTransportOptions(PackageInterface $package): void
  26081. {
  26082. foreach ($package->getDistUrls() as $url) {
  26083. if (strpos($url, $this->baseUrl) === 0) {
  26084. $package->setTransportOptions($this->options);
  26085. return;
  26086. }
  26087. }
  26088. }
  26089. private function hasProviders(): bool
  26090. {
  26091. $this->loadRootServerFile();
  26092. return $this->hasProviders;
  26093. }
  26094. private function whatProvides(string $name, array $acceptableStabilities = null, array $stabilityFlags = null, array $alreadyLoaded = array()): array
  26095. {
  26096. $packagesSource = null;
  26097. if (!$this->hasPartialPackages() || !isset($this->partialPackagesByName[$name])) {
  26098. if (PlatformRepository::isPlatformPackage($name) || '__root__' === $name) {
  26099. return array();
  26100. }
  26101. if (null === $this->providerListing) {
  26102. $data = $this->loadRootServerFile();
  26103. if (is_array($data)) {
  26104. $this->loadProviderListings($data);
  26105. }
  26106. }
  26107. $useLastModifiedCheck = false;
  26108. if ($this->lazyProvidersUrl && !isset($this->providerListing[$name])) {
  26109. $hash = null;
  26110. $url = str_replace('%package%', $name, $this->lazyProvidersUrl);
  26111. $cacheKey = 'provider-'.strtr($name, '/', '$').'.json';
  26112. $useLastModifiedCheck = true;
  26113. } elseif ($this->providersUrl) {
  26114. if (!isset($this->providerListing[$name])) {
  26115. return array();
  26116. }
  26117. $hash = $this->providerListing[$name]['sha256'];
  26118. $url = str_replace(array('%package%', '%hash%'), array($name, $hash), $this->providersUrl);
  26119. $cacheKey = 'provider-'.strtr($name, '/', '$').'.json';
  26120. } else {
  26121. return array();
  26122. }
  26123. $packages = null;
  26124. if (!$useLastModifiedCheck && $hash && $this->cache->sha256($cacheKey) === $hash) {
  26125. $packages = json_decode($this->cache->read($cacheKey), true);
  26126. $packagesSource = 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')';
  26127. } elseif ($useLastModifiedCheck) {
  26128. if ($contents = $this->cache->read($cacheKey)) {
  26129. $contents = json_decode($contents, true);
  26130. if (isset($alreadyLoaded[$name])) {
  26131. $packages = $contents;
  26132. $packagesSource = 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')';
  26133. } elseif (isset($contents['last-modified'])) {
  26134. $response = $this->fetchFileIfLastModified($url, $cacheKey, $contents['last-modified']);
  26135. $packages = true === $response ? $contents : $response;
  26136. $packagesSource = true === $response ? 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')' : 'downloaded file ('.Url::sanitize($url).')';
  26137. }
  26138. }
  26139. }
  26140. if (!$packages) {
  26141. try {
  26142. $packages = $this->fetchFile($url, $cacheKey, $hash, $useLastModifiedCheck);
  26143. $packagesSource = 'downloaded file ('.Url::sanitize($url).')';
  26144. } catch (TransportException $e) {
  26145. if ($this->lazyProvidersUrl && in_array($e->getStatusCode(), array(404, 499), true)) {
  26146. $packages = array('packages' => array());
  26147. $packagesSource = 'not-found file ('.Url::sanitize($url).')';
  26148. if ($e->getStatusCode() === 499) {
  26149. $this->io->error('<warning>' . $e->getMessage() . '</warning>');
  26150. }
  26151. } else {
  26152. throw $e;
  26153. }
  26154. }
  26155. }
  26156. $loadingPartialPackage = false;
  26157. } else {
  26158. $packages = array('packages' => array('versions' => $this->partialPackagesByName[$name]));
  26159. $packagesSource = 'root file ('.Url::sanitize($this->getPackagesJsonUrl()).')';
  26160. $loadingPartialPackage = true;
  26161. }
  26162. $result = array();
  26163. $versionsToLoad = array();
  26164. foreach ($packages['packages'] as $versions) {
  26165. foreach ($versions as $version) {
  26166. $normalizedName = strtolower($version['name']);
  26167. if ($normalizedName !== $name) {
  26168. continue;
  26169. }
  26170. if (!$loadingPartialPackage && $this->hasPartialPackages() && isset($this->partialPackagesByName[$normalizedName])) {
  26171. continue;
  26172. }
  26173. if (!isset($versionsToLoad[$version['uid']])) {
  26174. if (!isset($version['version_normalized'])) {
  26175. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  26176. } elseif ($version['version_normalized'] === VersionParser::DEFAULT_BRANCH_ALIAS) {
  26177. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  26178. }
  26179. if (isset($alreadyLoaded[$name][$version['version_normalized']])) {
  26180. continue;
  26181. }
  26182. if ($this->isVersionAcceptable(null, $normalizedName, $version, $acceptableStabilities, $stabilityFlags)) {
  26183. $versionsToLoad[$version['uid']] = $version;
  26184. }
  26185. }
  26186. }
  26187. }
  26188. $loadedPackages = $this->createPackages($versionsToLoad, $packagesSource);
  26189. $uids = array_keys($versionsToLoad);
  26190. foreach ($loadedPackages as $index => $package) {
  26191. $package->setRepository($this);
  26192. $uid = $uids[$index];
  26193. if ($package instanceof AliasPackage) {
  26194. $aliased = $package->getAliasOf();
  26195. $aliased->setRepository($this);
  26196. $result[$uid] = $aliased;
  26197. $result[$uid.'-alias'] = $package;
  26198. } else {
  26199. $result[$uid] = $package;
  26200. }
  26201. }
  26202. return $result;
  26203. }
  26204. protected function initialize()
  26205. {
  26206. parent::initialize();
  26207. $repoData = $this->loadDataFromServer();
  26208. foreach ($this->createPackages($repoData, 'root file ('.Url::sanitize($this->getPackagesJsonUrl()).')') as $package) {
  26209. $this->addPackage($package);
  26210. }
  26211. }
  26212. public function addPackage(PackageInterface $package)
  26213. {
  26214. parent::addPackage($package);
  26215. $this->configurePackageTransportOptions($package);
  26216. }
  26217. private function loadAsyncPackages(array $packageNames, array $acceptableStabilities = null, array $stabilityFlags = null, array $alreadyLoaded = array()): array
  26218. {
  26219. $this->loadRootServerFile();
  26220. $packages = array();
  26221. $namesFound = array();
  26222. $promises = array();
  26223. if (!$this->lazyProvidersUrl) {
  26224. throw new \LogicException('loadAsyncPackages only supports v2 protocol composer repos with a metadata-url');
  26225. }
  26226. foreach ($packageNames as $name => $constraint) {
  26227. if ($acceptableStabilities === null || $stabilityFlags === null || StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, array($name), 'dev')) {
  26228. $packageNames[$name.'~dev'] = $constraint;
  26229. }
  26230. if (isset($acceptableStabilities['dev']) && count($acceptableStabilities) === 1 && count($stabilityFlags) === 0) {
  26231. unset($packageNames[$name]);
  26232. }
  26233. }
  26234. foreach ($packageNames as $name => $constraint) {
  26235. $name = strtolower($name);
  26236. $realName = Preg::replace('{~dev$}', '', $name);
  26237. if (PlatformRepository::isPlatformPackage($realName) || '__root__' === $realName) {
  26238. continue;
  26239. }
  26240. $url = str_replace('%package%', $name, $this->lazyProvidersUrl);
  26241. $cacheKey = 'provider-'.strtr($name, '/', '~').'.json';
  26242. $lastModified = null;
  26243. if ($contents = $this->cache->read($cacheKey)) {
  26244. $contents = json_decode($contents, true);
  26245. $lastModified = $contents['last-modified'] ?? null;
  26246. }
  26247. $promises[] = $this->asyncFetchFile($url, $cacheKey, $lastModified)
  26248. ->then(function ($response) use (&$packages, &$namesFound, $url, $cacheKey, $contents, $realName, $constraint, $acceptableStabilities, $stabilityFlags, $alreadyLoaded): void {
  26249. $packagesSource = 'downloaded file ('.Url::sanitize($url).')';
  26250. if (true === $response) {
  26251. $packagesSource = 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')';
  26252. $response = $contents;
  26253. }
  26254. if (!isset($response['packages'][$realName])) {
  26255. return;
  26256. }
  26257. $versions = $response['packages'][$realName];
  26258. if (isset($response['minified']) && $response['minified'] === 'composer/2.0') {
  26259. $versions = MetadataMinifier::expand($versions);
  26260. }
  26261. $namesFound[$realName] = true;
  26262. $versionsToLoad = array();
  26263. foreach ($versions as $version) {
  26264. if (!isset($version['version_normalized'])) {
  26265. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  26266. } elseif ($version['version_normalized'] === VersionParser::DEFAULT_BRANCH_ALIAS) {
  26267. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  26268. }
  26269. if (isset($alreadyLoaded[$realName][$version['version_normalized']])) {
  26270. continue;
  26271. }
  26272. if ($this->isVersionAcceptable($constraint, $realName, $version, $acceptableStabilities, $stabilityFlags)) {
  26273. $versionsToLoad[] = $version;
  26274. }
  26275. }
  26276. $loadedPackages = $this->createPackages($versionsToLoad, $packagesSource);
  26277. foreach ($loadedPackages as $package) {
  26278. $package->setRepository($this);
  26279. $packages[spl_object_hash($package)] = $package;
  26280. if ($package instanceof AliasPackage && !isset($packages[spl_object_hash($package->getAliasOf())])) {
  26281. $package->getAliasOf()->setRepository($this);
  26282. $packages[spl_object_hash($package->getAliasOf())] = $package->getAliasOf();
  26283. }
  26284. }
  26285. });
  26286. }
  26287. $this->loop->wait($promises);
  26288. return array('namesFound' => $namesFound, 'packages' => $packages);
  26289. }
  26290. private function isVersionAcceptable(?ConstraintInterface $constraint, string $name, array $versionData, array $acceptableStabilities = null, array $stabilityFlags = null): bool
  26291. {
  26292. $versions = array($versionData['version_normalized']);
  26293. if ($alias = $this->loader->getBranchAlias($versionData)) {
  26294. $versions[] = $alias;
  26295. }
  26296. foreach ($versions as $version) {
  26297. if (null !== $acceptableStabilities && null !== $stabilityFlags && !StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, array($name), VersionParser::parseStability($version))) {
  26298. continue;
  26299. }
  26300. if ($constraint && !CompilingMatcher::match($constraint, Constraint::OP_EQ, $version)) {
  26301. continue;
  26302. }
  26303. return true;
  26304. }
  26305. return false;
  26306. }
  26307. private function getPackagesJsonUrl(): string
  26308. {
  26309. $jsonUrlParts = parse_url(strtr($this->url, '\\', '/'));
  26310. if (isset($jsonUrlParts['path']) && false !== strpos($jsonUrlParts['path'], '.json')) {
  26311. return $this->url;
  26312. }
  26313. return $this->url . '/packages.json';
  26314. }
  26315. protected function loadRootServerFile(?int $rootMaxAge = null)
  26316. {
  26317. if (null !== $this->rootData) {
  26318. return $this->rootData;
  26319. }
  26320. if (!extension_loaded('openssl') && strpos($this->url, 'https') === 0) {
  26321. throw new \RuntimeException('You must enable the openssl extension in your php.ini to load information from '.$this->url);
  26322. }
  26323. if ($cachedData = $this->cache->read('packages.json')) {
  26324. $cachedData = json_decode($cachedData, true);
  26325. if ($rootMaxAge !== null && ($age = $this->cache->getAge('packages.json')) !== false && $age <= $rootMaxAge) {
  26326. $data = $cachedData;
  26327. } elseif (isset($cachedData['last-modified'])) {
  26328. $response = $this->fetchFileIfLastModified($this->getPackagesJsonUrl(), 'packages.json', $cachedData['last-modified']);
  26329. $data = true === $response ? $cachedData : $response;
  26330. }
  26331. }
  26332. if (!isset($data)) {
  26333. $data = $this->fetchFile($this->getPackagesJsonUrl(), 'packages.json', null, true);
  26334. }
  26335. if (!empty($data['notify-batch'])) {
  26336. $this->notifyUrl = $this->canonicalizeUrl($data['notify-batch']);
  26337. } elseif (!empty($data['notify'])) {
  26338. $this->notifyUrl = $this->canonicalizeUrl($data['notify']);
  26339. }
  26340. if (!empty($data['search'])) {
  26341. $this->searchUrl = $this->canonicalizeUrl($data['search']);
  26342. }
  26343. if (!empty($data['mirrors'])) {
  26344. foreach ($data['mirrors'] as $mirror) {
  26345. if (!empty($mirror['git-url'])) {
  26346. $this->sourceMirrors['git'][] = array('url' => $mirror['git-url'], 'preferred' => !empty($mirror['preferred']));
  26347. }
  26348. if (!empty($mirror['hg-url'])) {
  26349. $this->sourceMirrors['hg'][] = array('url' => $mirror['hg-url'], 'preferred' => !empty($mirror['preferred']));
  26350. }
  26351. if (!empty($mirror['dist-url'])) {
  26352. $this->distMirrors[] = array(
  26353. 'url' => $this->canonicalizeUrl($mirror['dist-url']),
  26354. 'preferred' => !empty($mirror['preferred']),
  26355. );
  26356. }
  26357. }
  26358. }
  26359. if (!empty($data['providers-lazy-url'])) {
  26360. $this->lazyProvidersUrl = $this->canonicalizeUrl($data['providers-lazy-url']);
  26361. $this->hasProviders = true;
  26362. $this->hasPartialPackages = !empty($data['packages']) && is_array($data['packages']);
  26363. }
  26364. if (!empty($data['metadata-url'])) {
  26365. $this->lazyProvidersUrl = $this->canonicalizeUrl($data['metadata-url']);
  26366. $this->providersUrl = null;
  26367. $this->hasProviders = false;
  26368. $this->hasPartialPackages = !empty($data['packages']) && is_array($data['packages']);
  26369. $this->allowSslDowngrade = false;
  26370. if (!empty($data['available-packages'])) {
  26371. $availPackages = array_map('strtolower', $data['available-packages']);
  26372. $this->availablePackages = array_combine($availPackages, $availPackages);
  26373. $this->hasAvailablePackageList = true;
  26374. }
  26375. if (!empty($data['available-package-patterns'])) {
  26376. $this->availablePackagePatterns = array_map(function ($pattern): string {
  26377. return BasePackage::packageNameToRegexp($pattern);
  26378. }, $data['available-package-patterns']);
  26379. $this->hasAvailablePackageList = true;
  26380. }
  26381. unset($data['providers-url'], $data['providers'], $data['providers-includes']);
  26382. }
  26383. if ($this->allowSslDowngrade) {
  26384. $this->url = str_replace('https://', 'http://', $this->url);
  26385. $this->baseUrl = str_replace('https://', 'http://', $this->baseUrl);
  26386. }
  26387. if (!empty($data['providers-url'])) {
  26388. $this->providersUrl = $this->canonicalizeUrl($data['providers-url']);
  26389. $this->hasProviders = true;
  26390. }
  26391. if (!empty($data['list'])) {
  26392. $this->listUrl = $this->canonicalizeUrl($data['list']);
  26393. }
  26394. if (!empty($data['providers']) || !empty($data['providers-includes'])) {
  26395. $this->hasProviders = true;
  26396. }
  26397. if (!empty($data['providers-api'])) {
  26398. $this->providersApiUrl = $this->canonicalizeUrl($data['providers-api']);
  26399. }
  26400. return $this->rootData = $data;
  26401. }
  26402. private function canonicalizeUrl(string $url): string
  26403. {
  26404. if ('/' === $url[0]) {
  26405. if (Preg::isMatch('{^[^:]++://[^/]*+}', $this->url, $matches)) {
  26406. return $matches[0] . $url;
  26407. }
  26408. return $this->url;
  26409. }
  26410. return $url;
  26411. }
  26412. private function loadDataFromServer(): array
  26413. {
  26414. $data = $this->loadRootServerFile();
  26415. if (true === $data) {
  26416. throw new \LogicException('loadRootServerFile should not return true during initialization');
  26417. }
  26418. return $this->loadIncludes($data);
  26419. }
  26420. private function hasPartialPackages(): bool
  26421. {
  26422. if ($this->hasPartialPackages && null === $this->partialPackagesByName) {
  26423. $this->initializePartialPackages();
  26424. }
  26425. return $this->hasPartialPackages;
  26426. }
  26427. private function loadProviderListings($data): void
  26428. {
  26429. if (isset($data['providers'])) {
  26430. if (!is_array($this->providerListing)) {
  26431. $this->providerListing = array();
  26432. }
  26433. $this->providerListing = array_merge($this->providerListing, $data['providers']);
  26434. }
  26435. if ($this->providersUrl && isset($data['provider-includes'])) {
  26436. $includes = $data['provider-includes'];
  26437. foreach ($includes as $include => $metadata) {
  26438. $url = $this->baseUrl . '/' . str_replace('%hash%', $metadata['sha256'], $include);
  26439. $cacheKey = str_replace(array('%hash%','$'), '', $include);
  26440. if ($this->cache->sha256($cacheKey) === $metadata['sha256']) {
  26441. $includedData = json_decode($this->cache->read($cacheKey), true);
  26442. } else {
  26443. $includedData = $this->fetchFile($url, $cacheKey, $metadata['sha256']);
  26444. }
  26445. $this->loadProviderListings($includedData);
  26446. }
  26447. }
  26448. }
  26449. private function loadIncludes(array $data): array
  26450. {
  26451. $packages = array();
  26452. if (!isset($data['packages']) && !isset($data['includes'])) {
  26453. foreach ($data as $pkg) {
  26454. if (isset($pkg['versions']) && is_array($pkg['versions'])) {
  26455. foreach ($pkg['versions'] as $metadata) {
  26456. $packages[] = $metadata;
  26457. }
  26458. }
  26459. }
  26460. return $packages;
  26461. }
  26462. if (isset($data['packages'])) {
  26463. foreach ($data['packages'] as $package => $versions) {
  26464. foreach ($versions as $version => $metadata) {
  26465. $packages[] = $metadata;
  26466. }
  26467. }
  26468. }
  26469. if (isset($data['includes'])) {
  26470. foreach ($data['includes'] as $include => $metadata) {
  26471. if (isset($metadata['sha1']) && $this->cache->sha1((string) $include) === $metadata['sha1']) {
  26472. $includedData = json_decode($this->cache->read((string) $include), true);
  26473. } else {
  26474. $includedData = $this->fetchFile($include);
  26475. }
  26476. $packages = array_merge($packages, $this->loadIncludes($includedData));
  26477. }
  26478. }
  26479. return $packages;
  26480. }
  26481. private function createPackages(array $packages, ?string $source = null): array
  26482. {
  26483. if (!$packages) {
  26484. return array();
  26485. }
  26486. try {
  26487. foreach ($packages as &$data) {
  26488. if (!isset($data['notification-url'])) {
  26489. $data['notification-url'] = $this->notifyUrl;
  26490. }
  26491. }
  26492. $packageInstances = $this->loader->loadPackages($packages);
  26493. foreach ($packageInstances as $package) {
  26494. if (isset($this->sourceMirrors[$package->getSourceType()])) {
  26495. $package->setSourceMirrors($this->sourceMirrors[$package->getSourceType()]);
  26496. }
  26497. $package->setDistMirrors($this->distMirrors);
  26498. $this->configurePackageTransportOptions($package);
  26499. }
  26500. return $packageInstances;
  26501. } catch (\Exception $e) {
  26502. throw new \RuntimeException('Could not load packages '.($packages[0]['name'] ?? json_encode($packages)).' in '.$this->getRepoName().($source ? ' from '.$source : '').': ['.get_class($e).'] '.$e->getMessage(), 0, $e);
  26503. }
  26504. }
  26505. protected function fetchFile(string $filename, ?string $cacheKey = null, ?string $sha256 = null, bool $storeLastModifiedTime = false)
  26506. {
  26507. if (null === $cacheKey) {
  26508. $cacheKey = $filename;
  26509. $filename = $this->baseUrl.'/'.$filename;
  26510. }
  26511. if (($pos = strpos($filename, '$')) && Preg::isMatch('{^https?://}i', $filename)) {
  26512. $filename = substr($filename, 0, $pos) . '%24' . substr($filename, $pos + 1);
  26513. }
  26514. $retries = 3;
  26515. while ($retries--) {
  26516. try {
  26517. $options = $this->options;
  26518. if ($this->eventDispatcher) {
  26519. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata', array('repository' => $this));
  26520. $preFileDownloadEvent->setTransportOptions($this->options);
  26521. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  26522. $filename = $preFileDownloadEvent->getProcessedUrl();
  26523. $options = $preFileDownloadEvent->getTransportOptions();
  26524. }
  26525. $response = $this->httpDownloader->get($filename, $options);
  26526. $json = (string) $response->getBody();
  26527. if ($sha256 && $sha256 !== hash('sha256', $json)) {
  26528. if ($this->allowSslDowngrade) {
  26529. $this->url = str_replace('http://', 'https://', $this->url);
  26530. $this->baseUrl = str_replace('http://', 'https://', $this->baseUrl);
  26531. $filename = str_replace('http://', 'https://', $filename);
  26532. }
  26533. if ($retries > 0) {
  26534. usleep(100000);
  26535. continue;
  26536. }
  26537. 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.');
  26538. }
  26539. if ($this->eventDispatcher) {
  26540. $postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, null, $sha256, $filename, 'metadata', array('response' => $response, 'repository' => $this));
  26541. $this->eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
  26542. }
  26543. $data = $response->decodeJson();
  26544. HttpDownloader::outputWarnings($this->io, $this->url, $data);
  26545. if ($cacheKey && !$this->cache->isReadOnly()) {
  26546. if ($storeLastModifiedTime) {
  26547. $lastModifiedDate = $response->getHeader('last-modified');
  26548. if ($lastModifiedDate) {
  26549. $data['last-modified'] = $lastModifiedDate;
  26550. $json = JsonFile::encode($data, 0);
  26551. }
  26552. }
  26553. $this->cache->write($cacheKey, $json);
  26554. }
  26555. $response->collect();
  26556. break;
  26557. } catch (\Exception $e) {
  26558. if ($e instanceof \LogicException) {
  26559. throw $e;
  26560. }
  26561. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  26562. throw $e;
  26563. }
  26564. if ($e instanceof RepositorySecurityException) {
  26565. throw $e;
  26566. }
  26567. if ($cacheKey && ($contents = $this->cache->read($cacheKey))) {
  26568. if (!$this->degradedMode) {
  26569. $this->io->writeError('<warning>'.$this->url.' could not be fully loaded ('.$e->getMessage().'), package information was loaded from the local cache and may be out of date</warning>');
  26570. }
  26571. $this->degradedMode = true;
  26572. $data = JsonFile::parseJson($contents, $this->cache->getRoot().$cacheKey);
  26573. break;
  26574. }
  26575. throw $e;
  26576. }
  26577. }
  26578. if (!isset($data)) {
  26579. throw new \LogicException("ComposerRepository: Undefined \$data. Please report at https://github.com/composer/composer/issues/new.");
  26580. }
  26581. return $data;
  26582. }
  26583. private function fetchFileIfLastModified(string $filename, string $cacheKey, string $lastModifiedTime)
  26584. {
  26585. try {
  26586. $options = $this->options;
  26587. if ($this->eventDispatcher) {
  26588. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata', array('repository' => $this));
  26589. $preFileDownloadEvent->setTransportOptions($this->options);
  26590. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  26591. $filename = $preFileDownloadEvent->getProcessedUrl();
  26592. $options = $preFileDownloadEvent->getTransportOptions();
  26593. }
  26594. if (isset($options['http']['header'])) {
  26595. $options['http']['header'] = (array) $options['http']['header'];
  26596. }
  26597. $options['http']['header'][] = 'If-Modified-Since: '.$lastModifiedTime;
  26598. $response = $this->httpDownloader->get($filename, $options);
  26599. $json = (string) $response->getBody();
  26600. if ($json === '' && $response->getStatusCode() === 304) {
  26601. return true;
  26602. }
  26603. if ($this->eventDispatcher) {
  26604. $postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, null, null, $filename, 'metadata', array('response' => $response, 'repository' => $this));
  26605. $this->eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
  26606. }
  26607. $data = $response->decodeJson();
  26608. HttpDownloader::outputWarnings($this->io, $this->url, $data);
  26609. $lastModifiedDate = $response->getHeader('last-modified');
  26610. $response->collect();
  26611. if ($lastModifiedDate) {
  26612. $data['last-modified'] = $lastModifiedDate;
  26613. $json = JsonFile::encode($data, 0);
  26614. }
  26615. if (!$this->cache->isReadOnly()) {
  26616. $this->cache->write($cacheKey, $json);
  26617. }
  26618. return $data;
  26619. } catch (\Exception $e) {
  26620. if ($e instanceof \LogicException) {
  26621. throw $e;
  26622. }
  26623. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  26624. throw $e;
  26625. }
  26626. if (!$this->degradedMode) {
  26627. $this->io->writeError('<warning>'.$this->url.' could not be fully loaded ('.$e->getMessage().'), package information was loaded from the local cache and may be out of date</warning>');
  26628. }
  26629. $this->degradedMode = true;
  26630. return true;
  26631. }
  26632. }
  26633. private function asyncFetchFile(string $filename, string $cacheKey, ?string $lastModifiedTime = null): PromiseInterface
  26634. {
  26635. if (isset($this->packagesNotFoundCache[$filename])) {
  26636. return \React\Promise\resolve(array('packages' => array()));
  26637. }
  26638. if (isset($this->freshMetadataUrls[$filename]) && $lastModifiedTime) {
  26639. return \React\Promise\resolve(true);
  26640. }
  26641. $httpDownloader = $this->httpDownloader;
  26642. $options = $this->options;
  26643. if ($this->eventDispatcher) {
  26644. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata', array('repository' => $this));
  26645. $preFileDownloadEvent->setTransportOptions($this->options);
  26646. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  26647. $filename = $preFileDownloadEvent->getProcessedUrl();
  26648. $options = $preFileDownloadEvent->getTransportOptions();
  26649. }
  26650. if ($lastModifiedTime) {
  26651. if (isset($options['http']['header'])) {
  26652. $options['http']['header'] = (array) $options['http']['header'];
  26653. }
  26654. $options['http']['header'][] = 'If-Modified-Since: '.$lastModifiedTime;
  26655. }
  26656. $io = $this->io;
  26657. $url = $this->url;
  26658. $cache = $this->cache;
  26659. $degradedMode = &$this->degradedMode;
  26660. $eventDispatcher = $this->eventDispatcher;
  26661. $accept = function ($response) use ($io, $url, $filename, $cache, $cacheKey, $eventDispatcher) {
  26662. if ($response->getStatusCode() === 404) {
  26663. $this->packagesNotFoundCache[$filename] = true;
  26664. return array('packages' => array());
  26665. }
  26666. $json = (string) $response->getBody();
  26667. if ($json === '' && $response->getStatusCode() === 304) {
  26668. $this->freshMetadataUrls[$filename] = true;
  26669. return true;
  26670. }
  26671. if ($eventDispatcher) {
  26672. $postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, null, null, $filename, 'metadata', array('response' => $response, 'repository' => $this));
  26673. $eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
  26674. }
  26675. $data = $response->decodeJson();
  26676. HttpDownloader::outputWarnings($io, $url, $data);
  26677. $lastModifiedDate = $response->getHeader('last-modified');
  26678. $response->collect();
  26679. if ($lastModifiedDate) {
  26680. $data['last-modified'] = $lastModifiedDate;
  26681. $json = JsonFile::encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
  26682. }
  26683. if (!$cache->isReadOnly()) {
  26684. $cache->write($cacheKey, $json);
  26685. }
  26686. $this->freshMetadataUrls[$filename] = true;
  26687. return $data;
  26688. };
  26689. $reject = function ($e) use ($filename, $accept, $io, $url, &$degradedMode, $lastModifiedTime) {
  26690. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  26691. $this->packagesNotFoundCache[$filename] = true;
  26692. return false;
  26693. }
  26694. if (!$degradedMode) {
  26695. $io->writeError('<warning>'.$url.' could not be fully loaded ('.$e->getMessage().'), package information was loaded from the local cache and may be out of date</warning>');
  26696. }
  26697. $degradedMode = true;
  26698. if ($lastModifiedTime) {
  26699. return $accept(new Response(array('url' => $url), 304, array(), ''));
  26700. }
  26701. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  26702. return $accept(new Response(array('url' => $url), 404, array(), ''));
  26703. }
  26704. throw $e;
  26705. };
  26706. return $httpDownloader->add($filename, $options)->then($accept, $reject);
  26707. }
  26708. private function initializePartialPackages(): void
  26709. {
  26710. $rootData = $this->loadRootServerFile();
  26711. if ($rootData === true) {
  26712. return;
  26713. }
  26714. $this->partialPackagesByName = array();
  26715. foreach ($rootData['packages'] as $package => $versions) {
  26716. foreach ($versions as $version) {
  26717. $this->partialPackagesByName[strtolower($version['name'])][] = $version;
  26718. }
  26719. }
  26720. $this->rootData = true;
  26721. }
  26722. protected function lazyProvidersRepoContains(string $name)
  26723. {
  26724. if (!$this->hasAvailablePackageList) {
  26725. throw new \LogicException('lazyProvidersRepoContains should not be called unless hasAvailablePackageList is true');
  26726. }
  26727. if (is_array($this->availablePackages) && isset($this->availablePackages[$name])) {
  26728. return true;
  26729. }
  26730. if (is_array($this->availablePackagePatterns)) {
  26731. foreach ($this->availablePackagePatterns as $providerRegex) {
  26732. if (Preg::isMatch($providerRegex, $name)) {
  26733. return true;
  26734. }
  26735. }
  26736. }
  26737. return false;
  26738. }
  26739. }
  26740. <?php declare(strict_types=1);
  26741. namespace Composer\Repository;
  26742. use Composer\Package\BasePackage;
  26743. use Composer\Package\PackageInterface;
  26744. class CompositeRepository implements RepositoryInterface
  26745. {
  26746. private $repositories;
  26747. public function __construct(array $repositories)
  26748. {
  26749. $this->repositories = array();
  26750. foreach ($repositories as $repo) {
  26751. $this->addRepository($repo);
  26752. }
  26753. }
  26754. public function getRepoName(): string
  26755. {
  26756. return 'composite repo ('.implode(', ', array_map(function ($repo): string {
  26757. return $repo->getRepoName();
  26758. }, $this->repositories)).')';
  26759. }
  26760. public function getRepositories(): array
  26761. {
  26762. return $this->repositories;
  26763. }
  26764. public function hasPackage(PackageInterface $package): bool
  26765. {
  26766. foreach ($this->repositories as $repository) {
  26767. if ($repository->hasPackage($package)) {
  26768. return true;
  26769. }
  26770. }
  26771. return false;
  26772. }
  26773. public function findPackage($name, $constraint): ?BasePackage
  26774. {
  26775. foreach ($this->repositories as $repository) {
  26776. $package = $repository->findPackage($name, $constraint);
  26777. if (null !== $package) {
  26778. return $package;
  26779. }
  26780. }
  26781. return null;
  26782. }
  26783. public function findPackages($name, $constraint = null): array
  26784. {
  26785. $packages = array();
  26786. foreach ($this->repositories as $repository) {
  26787. $packages[] = $repository->findPackages($name, $constraint);
  26788. }
  26789. return $packages ? call_user_func_array('array_merge', $packages) : array();
  26790. }
  26791. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array()): array
  26792. {
  26793. $packages = array();
  26794. $namesFound = array();
  26795. foreach ($this->repositories as $repository) {
  26796. $result = $repository->loadPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  26797. $packages[] = $result['packages'];
  26798. $namesFound[] = $result['namesFound'];
  26799. }
  26800. return array(
  26801. 'packages' => $packages ? call_user_func_array('array_merge', $packages) : array(),
  26802. 'namesFound' => $namesFound ? array_unique(call_user_func_array('array_merge', $namesFound)) : array(),
  26803. );
  26804. }
  26805. public function search(string $query, int $mode = 0, ?string $type = null): array
  26806. {
  26807. $matches = array();
  26808. foreach ($this->repositories as $repository) {
  26809. $matches[] = $repository->search($query, $mode, $type);
  26810. }
  26811. return $matches ? call_user_func_array('array_merge', $matches) : array();
  26812. }
  26813. public function getPackages(): array
  26814. {
  26815. $packages = array();
  26816. foreach ($this->repositories as $repository) {
  26817. $packages[] = $repository->getPackages();
  26818. }
  26819. return $packages ? call_user_func_array('array_merge', $packages) : array();
  26820. }
  26821. public function getProviders($packageName): array
  26822. {
  26823. $results = array();
  26824. foreach ($this->repositories as $repository) {
  26825. $results[] = $repository->getProviders($packageName);
  26826. }
  26827. return $results ? call_user_func_array('array_merge', $results) : array();
  26828. }
  26829. public function removePackage(PackageInterface $package): void
  26830. {
  26831. foreach ($this->repositories as $repository) {
  26832. if ($repository instanceof WritableRepositoryInterface) {
  26833. $repository->removePackage($package);
  26834. }
  26835. }
  26836. }
  26837. public function count(): int
  26838. {
  26839. $total = 0;
  26840. foreach ($this->repositories as $repository) {
  26841. $total += $repository->count();
  26842. }
  26843. return $total;
  26844. }
  26845. public function addRepository(RepositoryInterface $repository): void
  26846. {
  26847. if ($repository instanceof self) {
  26848. foreach ($repository->getRepositories() as $repo) {
  26849. $this->addRepository($repo);
  26850. }
  26851. } else {
  26852. $this->repositories[] = $repository;
  26853. }
  26854. }
  26855. }
  26856. <?php declare(strict_types=1);
  26857. namespace Composer\Repository;
  26858. interface ConfigurableRepositoryInterface
  26859. {
  26860. public function getRepoConfig();
  26861. }
  26862. <?php declare(strict_types=1);
  26863. namespace Composer\Repository;
  26864. use Composer\Json\JsonFile;
  26865. use Composer\Package\Loader\ArrayLoader;
  26866. use Composer\Package\RootPackageInterface;
  26867. use Composer\Package\AliasPackage;
  26868. use Composer\Package\Dumper\ArrayDumper;
  26869. use Composer\Installer\InstallationManager;
  26870. use Composer\Util\Filesystem;
  26871. use Composer\Util\Platform;
  26872. class FilesystemRepository extends WritableArrayRepository
  26873. {
  26874. protected $file;
  26875. private $dumpVersions;
  26876. private $rootPackage;
  26877. private $filesystem;
  26878. private $devMode = null;
  26879. public function __construct(JsonFile $repositoryFile, bool $dumpVersions = false, RootPackageInterface $rootPackage = null, Filesystem $filesystem = null)
  26880. {
  26881. parent::__construct();
  26882. $this->file = $repositoryFile;
  26883. $this->dumpVersions = $dumpVersions;
  26884. $this->rootPackage = $rootPackage;
  26885. $this->filesystem = $filesystem ?: new Filesystem;
  26886. if ($dumpVersions && !$rootPackage) {
  26887. throw new \InvalidArgumentException('Expected a root package instance if $dumpVersions is true');
  26888. }
  26889. }
  26890. public function getDevMode()
  26891. {
  26892. return $this->devMode;
  26893. }
  26894. protected function initialize()
  26895. {
  26896. parent::initialize();
  26897. if (!$this->file->exists()) {
  26898. return;
  26899. }
  26900. try {
  26901. $data = $this->file->read();
  26902. if (isset($data['packages'])) {
  26903. $packages = $data['packages'];
  26904. } else {
  26905. $packages = $data;
  26906. }
  26907. if (isset($data['dev-package-names'])) {
  26908. $this->setDevPackageNames($data['dev-package-names']);
  26909. }
  26910. if (isset($data['dev'])) {
  26911. $this->devMode = $data['dev'];
  26912. }
  26913. if (!is_array($packages)) {
  26914. throw new \UnexpectedValueException('Could not parse package list from the repository');
  26915. }
  26916. } catch (\Exception $e) {
  26917. throw new InvalidRepositoryException('Invalid repository data in '.$this->file->getPath().', packages could not be loaded: ['.get_class($e).'] '.$e->getMessage());
  26918. }
  26919. $loader = new ArrayLoader(null, true);
  26920. foreach ($packages as $packageData) {
  26921. $package = $loader->load($packageData);
  26922. $this->addPackage($package);
  26923. }
  26924. }
  26925. public function reload()
  26926. {
  26927. $this->packages = null;
  26928. $this->initialize();
  26929. }
  26930. public function write(bool $devMode, InstallationManager $installationManager)
  26931. {
  26932. $data = array('packages' => array(), 'dev' => $devMode, 'dev-package-names' => array());
  26933. $dumper = new ArrayDumper();
  26934. $repoDir = dirname($this->file->getPath());
  26935. $this->filesystem->ensureDirectoryExists($repoDir);
  26936. $repoDir = $this->filesystem->normalizePath(realpath($repoDir));
  26937. $installPaths = array();
  26938. foreach ($this->getCanonicalPackages() as $package) {
  26939. $pkgArray = $dumper->dump($package);
  26940. $path = $installationManager->getInstallPath($package);
  26941. $installPath = null;
  26942. if ('' !== $path && null !== $path) {
  26943. $normalizedPath = $this->filesystem->normalizePath($this->filesystem->isAbsolutePath($path) ? $path : Platform::getCwd() . '/' . $path);
  26944. $installPath = $this->filesystem->findShortestPath($repoDir, $normalizedPath, true);
  26945. }
  26946. $installPaths[$package->getName()] = $installPath;
  26947. $pkgArray['install-path'] = $installPath;
  26948. $data['packages'][] = $pkgArray;
  26949. if (in_array($package->getName(), $this->devPackageNames, true)) {
  26950. $data['dev-package-names'][] = $package->getName();
  26951. }
  26952. }
  26953. sort($data['dev-package-names']);
  26954. usort($data['packages'], function ($a, $b): int {
  26955. return strcmp($a['name'], $b['name']);
  26956. });
  26957. $this->file->write($data);
  26958. if ($this->dumpVersions) {
  26959. $versions = $this->generateInstalledVersions($installationManager, $installPaths, $devMode, $repoDir);
  26960. $this->filesystem->filePutContentsIfModified($repoDir.'/installed.php', '<?php return ' . $this->dumpToPhpCode($versions) . ';'."\n");
  26961. $installedVersionsClass = file_get_contents(__DIR__.'/../InstalledVersions.php');
  26962. $this->filesystem->filePutContentsIfModified($repoDir.'/InstalledVersions.php', $installedVersionsClass);
  26963. \Composer\InstalledVersions::reload($versions);
  26964. }
  26965. }
  26966. private function dumpToPhpCode(array $array = array(), int $level = 0): string
  26967. {
  26968. $lines = "array(\n";
  26969. $level++;
  26970. foreach ($array as $key => $value) {
  26971. $lines .= str_repeat(' ', $level);
  26972. $lines .= is_int($key) ? $key . ' => ' : '\'' . $key . '\' => ';
  26973. if (is_array($value)) {
  26974. if (!empty($value)) {
  26975. $lines .= $this->dumpToPhpCode($value, $level);
  26976. } else {
  26977. $lines .= "array(),\n";
  26978. }
  26979. } elseif ($key === 'install_path' && is_string($value)) {
  26980. if ($this->filesystem->isAbsolutePath($value)) {
  26981. $lines .= var_export($value, true) . ",\n";
  26982. } else {
  26983. $lines .= "__DIR__ . " . var_export('/' . $value, true) . ",\n";
  26984. }
  26985. } else {
  26986. $lines .= var_export($value, true) . ",\n";
  26987. }
  26988. }
  26989. $lines .= str_repeat(' ', $level - 1) . ')' . ($level - 1 == 0 ? '' : ",\n");
  26990. return $lines;
  26991. }
  26992. private function generateInstalledVersions(InstallationManager $installationManager, array $installPaths, bool $devMode, string $repoDir): ?array
  26993. {
  26994. if (!$this->dumpVersions) {
  26995. return null;
  26996. }
  26997. $devPackages = array_flip($this->devPackageNames);
  26998. $versions = array('versions' => array());
  26999. $packages = $this->getPackages();
  27000. $packages[] = $rootPackage = $this->rootPackage;
  27001. while ($rootPackage instanceof AliasPackage) {
  27002. $rootPackage = $rootPackage->getAliasOf();
  27003. $packages[] = $rootPackage;
  27004. }
  27005. foreach ($packages as $package) {
  27006. if ($package instanceof AliasPackage) {
  27007. continue;
  27008. }
  27009. $reference = null;
  27010. if ($package->getInstallationSource()) {
  27011. $reference = $package->getInstallationSource() === 'source' ? $package->getSourceReference() : $package->getDistReference();
  27012. }
  27013. if (null === $reference) {
  27014. $reference = ($package->getSourceReference() ?: $package->getDistReference()) ?: null;
  27015. }
  27016. if ($package instanceof RootPackageInterface) {
  27017. $to = $this->filesystem->normalizePath(realpath(Platform::getCwd()));
  27018. $installPath = $this->filesystem->findShortestPath($repoDir, $to, true);
  27019. } else {
  27020. $installPath = $installPaths[$package->getName()];
  27021. }
  27022. $versions['versions'][$package->getName()] = array(
  27023. 'pretty_version' => $package->getPrettyVersion(),
  27024. 'version' => $package->getVersion(),
  27025. 'type' => $package->getType(),
  27026. 'install_path' => $installPath,
  27027. 'aliases' => array(),
  27028. 'reference' => $reference,
  27029. 'dev_requirement' => isset($devPackages[$package->getName()]),
  27030. );
  27031. if ($package instanceof RootPackageInterface) {
  27032. $versions['root'] = $versions['versions'][$package->getName()];
  27033. unset($versions['root']['dev_requirement']);
  27034. $versions['root']['name'] = $package->getName();
  27035. $versions['root']['dev'] = $devMode;
  27036. }
  27037. }
  27038. foreach ($packages as $package) {
  27039. $isDevPackage = isset($devPackages[$package->getName()]);
  27040. foreach ($package->getReplaces() as $replace) {
  27041. if (PlatformRepository::isPlatformPackage($replace->getTarget())) {
  27042. continue;
  27043. }
  27044. if (!isset($versions['versions'][$replace->getTarget()]['dev_requirement'])) {
  27045. $versions['versions'][$replace->getTarget()]['dev_requirement'] = $isDevPackage;
  27046. } elseif (!$isDevPackage) {
  27047. $versions['versions'][$replace->getTarget()]['dev_requirement'] = false;
  27048. }
  27049. $replaced = $replace->getPrettyConstraint();
  27050. if ($replaced === 'self.version') {
  27051. $replaced = $package->getPrettyVersion();
  27052. }
  27053. if (!isset($versions['versions'][$replace->getTarget()]['replaced']) || !in_array($replaced, $versions['versions'][$replace->getTarget()]['replaced'], true)) {
  27054. $versions['versions'][$replace->getTarget()]['replaced'][] = $replaced;
  27055. }
  27056. }
  27057. foreach ($package->getProvides() as $provide) {
  27058. if (PlatformRepository::isPlatformPackage($provide->getTarget())) {
  27059. continue;
  27060. }
  27061. if (!isset($versions['versions'][$provide->getTarget()]['dev_requirement'])) {
  27062. $versions['versions'][$provide->getTarget()]['dev_requirement'] = $isDevPackage;
  27063. } elseif (!$isDevPackage) {
  27064. $versions['versions'][$provide->getTarget()]['dev_requirement'] = false;
  27065. }
  27066. $provided = $provide->getPrettyConstraint();
  27067. if ($provided === 'self.version') {
  27068. $provided = $package->getPrettyVersion();
  27069. }
  27070. if (!isset($versions['versions'][$provide->getTarget()]['provided']) || !in_array($provided, $versions['versions'][$provide->getTarget()]['provided'], true)) {
  27071. $versions['versions'][$provide->getTarget()]['provided'][] = $provided;
  27072. }
  27073. }
  27074. }
  27075. foreach ($packages as $package) {
  27076. if (!$package instanceof AliasPackage) {
  27077. continue;
  27078. }
  27079. $versions['versions'][$package->getName()]['aliases'][] = $package->getPrettyVersion();
  27080. if ($package instanceof RootPackageInterface) {
  27081. $versions['root']['aliases'][] = $package->getPrettyVersion();
  27082. }
  27083. }
  27084. ksort($versions['versions']);
  27085. ksort($versions);
  27086. return $versions;
  27087. }
  27088. }
  27089. <?php declare(strict_types=1);
  27090. namespace Composer\Repository;
  27091. use Composer\Package\PackageInterface;
  27092. use Composer\Package\BasePackage;
  27093. use Composer\Pcre\Preg;
  27094. class FilterRepository implements RepositoryInterface
  27095. {
  27096. private $only = null;
  27097. private $exclude = null;
  27098. private $canonical = true;
  27099. private $repo;
  27100. public function __construct(RepositoryInterface $repo, array $options)
  27101. {
  27102. if (isset($options['only'])) {
  27103. if (!is_array($options['only'])) {
  27104. throw new \InvalidArgumentException('"only" key for repository '.$repo->getRepoName().' should be an array');
  27105. }
  27106. $this->only = BasePackage::packageNamesToRegexp($options['only']);
  27107. }
  27108. if (isset($options['exclude'])) {
  27109. if (!is_array($options['exclude'])) {
  27110. throw new \InvalidArgumentException('"exclude" key for repository '.$repo->getRepoName().' should be an array');
  27111. }
  27112. $this->exclude = BasePackage::packageNamesToRegexp($options['exclude']);
  27113. }
  27114. if ($this->exclude && $this->only) {
  27115. throw new \InvalidArgumentException('Only one of "only" and "exclude" can be specified for repository '.$repo->getRepoName());
  27116. }
  27117. if (isset($options['canonical'])) {
  27118. if (!is_bool($options['canonical'])) {
  27119. throw new \InvalidArgumentException('"canonical" key for repository '.$repo->getRepoName().' should be a boolean');
  27120. }
  27121. $this->canonical = $options['canonical'];
  27122. }
  27123. $this->repo = $repo;
  27124. }
  27125. public function getRepoName(): string
  27126. {
  27127. return $this->repo->getRepoName();
  27128. }
  27129. public function getRepository(): RepositoryInterface
  27130. {
  27131. return $this->repo;
  27132. }
  27133. public function hasPackage(PackageInterface $package): bool
  27134. {
  27135. return $this->repo->hasPackage($package);
  27136. }
  27137. public function findPackage($name, $constraint): ?BasePackage
  27138. {
  27139. if (!$this->isAllowed($name)) {
  27140. return null;
  27141. }
  27142. return $this->repo->findPackage($name, $constraint);
  27143. }
  27144. public function findPackages($name, $constraint = null): array
  27145. {
  27146. if (!$this->isAllowed($name)) {
  27147. return array();
  27148. }
  27149. return $this->repo->findPackages($name, $constraint);
  27150. }
  27151. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array()): array
  27152. {
  27153. foreach ($packageNameMap as $name => $constraint) {
  27154. if (!$this->isAllowed($name)) {
  27155. unset($packageNameMap[$name]);
  27156. }
  27157. }
  27158. if (!$packageNameMap) {
  27159. return array('namesFound' => array(), 'packages' => array());
  27160. }
  27161. $result = $this->repo->loadPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  27162. if (!$this->canonical) {
  27163. $result['namesFound'] = array();
  27164. }
  27165. return $result;
  27166. }
  27167. public function search(string $query, int $mode = 0, ?string $type = null): array
  27168. {
  27169. $result = array();
  27170. foreach ($this->repo->search($query, $mode, $type) as $package) {
  27171. if ($this->isAllowed($package['name'])) {
  27172. $result[] = $package;
  27173. }
  27174. }
  27175. return $result;
  27176. }
  27177. public function getPackages(): array
  27178. {
  27179. $result = array();
  27180. foreach ($this->repo->getPackages() as $package) {
  27181. if ($this->isAllowed($package->getName())) {
  27182. $result[] = $package;
  27183. }
  27184. }
  27185. return $result;
  27186. }
  27187. public function getProviders($packageName): array
  27188. {
  27189. $result = array();
  27190. foreach ($this->repo->getProviders($packageName) as $name => $provider) {
  27191. if ($this->isAllowed($provider['name'])) {
  27192. $result[$name] = $provider;
  27193. }
  27194. }
  27195. return $result;
  27196. }
  27197. public function count(): int
  27198. {
  27199. if ($this->repo->count() > 0) {
  27200. return count($this->getPackages());
  27201. }
  27202. return 0;
  27203. }
  27204. private function isAllowed(string $name): bool
  27205. {
  27206. if (!$this->only && !$this->exclude) {
  27207. return true;
  27208. }
  27209. if ($this->only) {
  27210. return Preg::isMatch($this->only, $name);
  27211. }
  27212. if ($this->exclude === null) {
  27213. return true;
  27214. }
  27215. return !Preg::isMatch($this->exclude, $name);
  27216. }
  27217. }
  27218. <?php declare(strict_types=1);
  27219. namespace Composer\Repository;
  27220. class InstalledArrayRepository extends WritableArrayRepository implements InstalledRepositoryInterface
  27221. {
  27222. public function getRepoName(): string
  27223. {
  27224. return 'installed '.parent::getRepoName();
  27225. }
  27226. public function isFresh(): bool
  27227. {
  27228. return $this->count() === 0;
  27229. }
  27230. }
  27231. <?php declare(strict_types=1);
  27232. namespace Composer\Repository;
  27233. class InstalledFilesystemRepository extends FilesystemRepository implements InstalledRepositoryInterface
  27234. {
  27235. public function getRepoName()
  27236. {
  27237. return 'installed '.parent::getRepoName();
  27238. }
  27239. public function isFresh()
  27240. {
  27241. return !$this->file->exists();
  27242. }
  27243. }
  27244. <?php declare(strict_types=1);
  27245. namespace Composer\Repository;
  27246. use Composer\Package\BasePackage;
  27247. use Composer\Package\PackageInterface;
  27248. use Composer\Package\Version\VersionParser;
  27249. use Composer\Semver\Constraint\ConstraintInterface;
  27250. use Composer\Semver\Constraint\Constraint;
  27251. use Composer\Semver\Constraint\MatchAllConstraint;
  27252. use Composer\Package\RootPackageInterface;
  27253. use Composer\Package\Link;
  27254. class InstalledRepository extends CompositeRepository
  27255. {
  27256. public function findPackagesWithReplacersAndProviders(string $name, $constraint = null): array
  27257. {
  27258. $name = strtolower($name);
  27259. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  27260. $versionParser = new VersionParser();
  27261. $constraint = $versionParser->parseConstraints($constraint);
  27262. }
  27263. $matches = array();
  27264. foreach ($this->getRepositories() as $repo) {
  27265. foreach ($repo->getPackages() as $candidate) {
  27266. if ($name === $candidate->getName()) {
  27267. if (null === $constraint || $constraint->matches(new Constraint('==', $candidate->getVersion()))) {
  27268. $matches[] = $candidate;
  27269. }
  27270. continue;
  27271. }
  27272. foreach (array_merge($candidate->getProvides(), $candidate->getReplaces()) as $link) {
  27273. if (
  27274. $name === $link->getTarget()
  27275. && ($constraint === null || $constraint->matches($link->getConstraint()))
  27276. ) {
  27277. $matches[] = $candidate;
  27278. continue 2;
  27279. }
  27280. }
  27281. }
  27282. }
  27283. return $matches;
  27284. }
  27285. public function getDependents($needle, ?ConstraintInterface $constraint = null, bool $invert = false, bool $recurse = true, array $packagesFound = null): array
  27286. {
  27287. $needles = array_map('strtolower', (array) $needle);
  27288. $results = array();
  27289. if (null === $packagesFound) {
  27290. $packagesFound = $needles;
  27291. }
  27292. $rootPackage = null;
  27293. foreach ($this->getPackages() as $package) {
  27294. if ($package instanceof RootPackageInterface) {
  27295. $rootPackage = $package;
  27296. break;
  27297. }
  27298. }
  27299. foreach ($this->getPackages() as $package) {
  27300. $links = $package->getRequires();
  27301. $packagesInTree = $packagesFound;
  27302. if (!$invert) {
  27303. $links += $package->getReplaces();
  27304. foreach ($package->getReplaces() as $link) {
  27305. foreach ($needles as $needle) {
  27306. if ($link->getSource() === $needle) {
  27307. if ($constraint === null || ($link->getConstraint()->matches($constraint) === true)) {
  27308. if (in_array($link->getTarget(), $packagesInTree)) {
  27309. $results[] = array($package, $link, false);
  27310. continue;
  27311. }
  27312. $packagesInTree[] = $link->getTarget();
  27313. $dependents = $recurse ? $this->getDependents($link->getTarget(), null, false, true, $packagesInTree) : array();
  27314. $results[] = array($package, $link, $dependents);
  27315. $needles[] = $link->getTarget();
  27316. }
  27317. }
  27318. }
  27319. }
  27320. }
  27321. if ($package instanceof RootPackageInterface) {
  27322. $links += $package->getDevRequires();
  27323. }
  27324. foreach ($links as $link) {
  27325. foreach ($needles as $needle) {
  27326. if ($link->getTarget() === $needle) {
  27327. if ($constraint === null || ($link->getConstraint()->matches($constraint) === !$invert)) {
  27328. if (in_array($link->getSource(), $packagesInTree)) {
  27329. $results[] = array($package, $link, false);
  27330. continue;
  27331. }
  27332. $packagesInTree[] = $link->getSource();
  27333. $dependents = $recurse ? $this->getDependents($link->getSource(), null, false, true, $packagesInTree) : array();
  27334. $results[] = array($package, $link, $dependents);
  27335. }
  27336. }
  27337. }
  27338. }
  27339. if ($invert && in_array($package->getName(), $needles)) {
  27340. foreach ($package->getConflicts() as $link) {
  27341. foreach ($this->findPackages($link->getTarget()) as $pkg) {
  27342. $version = new Constraint('=', $pkg->getVersion());
  27343. if ($link->getConstraint()->matches($version) === $invert) {
  27344. $results[] = array($package, $link, false);
  27345. }
  27346. }
  27347. }
  27348. }
  27349. foreach ($package->getConflicts() as $link) {
  27350. if (in_array($link->getTarget(), $needles)) {
  27351. foreach ($this->findPackages($link->getTarget()) as $pkg) {
  27352. $version = new Constraint('=', $pkg->getVersion());
  27353. if ($link->getConstraint()->matches($version) === $invert) {
  27354. $results[] = array($package, $link, false);
  27355. }
  27356. }
  27357. }
  27358. }
  27359. if ($invert && $constraint && in_array($package->getName(), $needles) && $constraint->matches(new Constraint('=', $package->getVersion()))) {
  27360. foreach ($package->getRequires() as $link) {
  27361. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  27362. if ($this->findPackage($link->getTarget(), $link->getConstraint())) {
  27363. continue;
  27364. }
  27365. $platformPkg = $this->findPackage($link->getTarget(), '*');
  27366. $description = $platformPkg ? 'but '.$platformPkg->getPrettyVersion().' is installed' : 'but it is missing';
  27367. $results[] = array($package, new Link($package->getName(), $link->getTarget(), new MatchAllConstraint, Link::TYPE_REQUIRE, $link->getPrettyConstraint().' '.$description), false);
  27368. continue;
  27369. }
  27370. foreach ($this->getPackages() as $pkg) {
  27371. if (!in_array($link->getTarget(), $pkg->getNames())) {
  27372. continue;
  27373. }
  27374. $version = new Constraint('=', $pkg->getVersion());
  27375. if ($link->getTarget() !== $pkg->getName()) {
  27376. foreach (array_merge($pkg->getReplaces(), $pkg->getProvides()) as $prov) {
  27377. if ($link->getTarget() === $prov->getTarget()) {
  27378. $version = $prov->getConstraint();
  27379. break;
  27380. }
  27381. }
  27382. }
  27383. if (!$link->getConstraint()->matches($version)) {
  27384. if ($rootPackage) {
  27385. foreach (array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires()) as $rootReq) {
  27386. if (in_array($rootReq->getTarget(), $pkg->getNames()) && !$rootReq->getConstraint()->matches($link->getConstraint())) {
  27387. $results[] = array($package, $link, false);
  27388. $results[] = array($rootPackage, $rootReq, false);
  27389. continue 3;
  27390. }
  27391. }
  27392. $results[] = array($package, $link, false);
  27393. $results[] = array($rootPackage, new Link($rootPackage->getName(), $link->getTarget(), new MatchAllConstraint, Link::TYPE_DOES_NOT_REQUIRE, 'but ' . $pkg->getPrettyVersion() . ' is installed'), false);
  27394. } else {
  27395. $results[] = array($package, $link, false);
  27396. }
  27397. }
  27398. continue 2;
  27399. }
  27400. }
  27401. }
  27402. }
  27403. ksort($results);
  27404. return $results;
  27405. }
  27406. public function getRepoName(): string
  27407. {
  27408. return 'installed repo ('.implode(', ', array_map(function ($repo): string {
  27409. return $repo->getRepoName();
  27410. }, $this->getRepositories())).')';
  27411. }
  27412. public function addRepository(RepositoryInterface $repository): void
  27413. {
  27414. if (
  27415. $repository instanceof LockArrayRepository
  27416. || $repository instanceof InstalledRepositoryInterface
  27417. || $repository instanceof RootPackageRepository
  27418. || $repository instanceof PlatformRepository
  27419. ) {
  27420. parent::addRepository($repository);
  27421. return;
  27422. }
  27423. throw new \LogicException('An InstalledRepository can not contain a repository of type '.get_class($repository).' ('.$repository->getRepoName().')');
  27424. }
  27425. }
  27426. <?php declare(strict_types=1);
  27427. namespace Composer\Repository;
  27428. interface InstalledRepositoryInterface extends WritableRepositoryInterface
  27429. {
  27430. public function getDevMode();
  27431. public function isFresh();
  27432. }
  27433. <?php declare(strict_types=1);
  27434. namespace Composer\Repository;
  27435. class InvalidRepositoryException extends \Exception
  27436. {
  27437. }
  27438. <?php declare(strict_types=1);
  27439. namespace Composer\Repository;
  27440. class LockArrayRepository extends ArrayRepository
  27441. {
  27442. public function getRepoName(): string
  27443. {
  27444. return 'lock repo';
  27445. }
  27446. }
  27447. <?php declare(strict_types=1);
  27448. namespace Composer\Repository;
  27449. use Composer\Package\Loader\ArrayLoader;
  27450. use Composer\Package\Loader\ValidatingArrayLoader;
  27451. use Composer\Pcre\Preg;
  27452. class PackageRepository extends ArrayRepository
  27453. {
  27454. private $config;
  27455. public function __construct(array $config)
  27456. {
  27457. parent::__construct();
  27458. $this->config = $config['package'];
  27459. if (!is_numeric(key($this->config))) {
  27460. $this->config = array($this->config);
  27461. }
  27462. }
  27463. protected function initialize(): void
  27464. {
  27465. parent::initialize();
  27466. $loader = new ValidatingArrayLoader(new ArrayLoader(null, true), true);
  27467. foreach ($this->config as $package) {
  27468. try {
  27469. $package = $loader->load($package);
  27470. } catch (\Exception $e) {
  27471. throw new InvalidRepositoryException('A repository of type "package" contains an invalid package definition: '.$e->getMessage()."\n\nInvalid package definition:\n".json_encode($package));
  27472. }
  27473. $this->addPackage($package);
  27474. }
  27475. }
  27476. public function getRepoName(): string
  27477. {
  27478. return Preg::replace('{^array }', 'package ', parent::getRepoName());
  27479. }
  27480. }
  27481. <?php declare(strict_types=1);
  27482. namespace Composer\Repository;
  27483. use Composer\Config;
  27484. use Composer\EventDispatcher\EventDispatcher;
  27485. use Composer\IO\IOInterface;
  27486. use Composer\Json\JsonFile;
  27487. use Composer\Package\CompleteAliasPackage;
  27488. use Composer\Package\CompletePackage;
  27489. use Composer\Package\Loader\ArrayLoader;
  27490. use Composer\Package\Version\VersionGuesser;
  27491. use Composer\Package\Version\VersionParser;
  27492. use Composer\Pcre\Preg;
  27493. use Composer\Util\HttpDownloader;
  27494. use Composer\Util\Platform;
  27495. use Composer\Util\ProcessExecutor;
  27496. use Composer\Util\Filesystem;
  27497. use Composer\Util\Url;
  27498. use Composer\Util\Git as GitUtil;
  27499. class PathRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  27500. {
  27501. private $loader;
  27502. private $versionGuesser;
  27503. private $url;
  27504. private $repoConfig;
  27505. private $process;
  27506. private $options;
  27507. public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader = null, EventDispatcher $dispatcher = null, ProcessExecutor $process = null)
  27508. {
  27509. if (!isset($repoConfig['url'])) {
  27510. throw new \RuntimeException('You must specify the `url` configuration for the path repository');
  27511. }
  27512. $this->loader = new ArrayLoader(null, true);
  27513. $this->url = Platform::expandPath($repoConfig['url']);
  27514. $this->process = $process ?? new ProcessExecutor($io);
  27515. $this->versionGuesser = new VersionGuesser($config, $this->process, new VersionParser());
  27516. $this->repoConfig = $repoConfig;
  27517. $this->options = $repoConfig['options'] ?? array();
  27518. if (!isset($this->options['relative'])) {
  27519. $filesystem = new Filesystem();
  27520. $this->options['relative'] = !$filesystem->isAbsolutePath($this->url);
  27521. }
  27522. parent::__construct();
  27523. }
  27524. public function getRepoName(): string
  27525. {
  27526. return 'path repo ('.Url::sanitize($this->repoConfig['url']).')';
  27527. }
  27528. public function getRepoConfig(): array
  27529. {
  27530. return $this->repoConfig;
  27531. }
  27532. protected function initialize(): void
  27533. {
  27534. parent::initialize();
  27535. $urlMatches = $this->getUrlMatches();
  27536. if (empty($urlMatches)) {
  27537. if (Preg::isMatch('{[*{}]}', $this->url)) {
  27538. $url = $this->url;
  27539. while (Preg::isMatch('{[*{}]}', $url)) {
  27540. $url = dirname($url);
  27541. }
  27542. if (is_dir($url)) {
  27543. return;
  27544. }
  27545. }
  27546. throw new \RuntimeException('The `url` supplied for the path (' . $this->url . ') repository does not exist');
  27547. }
  27548. foreach ($urlMatches as $url) {
  27549. $path = realpath($url) . DIRECTORY_SEPARATOR;
  27550. $composerFilePath = $path.'composer.json';
  27551. if (!file_exists($composerFilePath)) {
  27552. continue;
  27553. }
  27554. $json = file_get_contents($composerFilePath);
  27555. $package = JsonFile::parseJson($json, $composerFilePath);
  27556. $package['dist'] = array(
  27557. 'type' => 'path',
  27558. 'url' => $url,
  27559. );
  27560. $reference = $this->options['reference'] ?? 'auto';
  27561. if ('none' === $reference) {
  27562. $package['dist']['reference'] = null;
  27563. } elseif ('config' === $reference || 'auto' === $reference) {
  27564. $package['dist']['reference'] = sha1($json . serialize($this->options));
  27565. }
  27566. $package['transport-options'] = array_intersect_key($this->options, array('symlink' => true, 'relative' => true));
  27567. if (isset($package['name'], $this->options['versions'][$package['name']])) {
  27568. $package['version'] = $this->options['versions'][$package['name']];
  27569. }
  27570. if (!isset($package['version']) && ($rootVersion = Platform::getEnv('COMPOSER_ROOT_VERSION'))) {
  27571. if (
  27572. 0 === $this->process->execute('git rev-parse HEAD', $ref1, $path)
  27573. && 0 === $this->process->execute('git rev-parse HEAD', $ref2)
  27574. && $ref1 === $ref2
  27575. ) {
  27576. $package['version'] = $rootVersion;
  27577. }
  27578. }
  27579. $output = '';
  27580. if ('auto' === $reference && is_dir($path . DIRECTORY_SEPARATOR . '.git') && 0 === $this->process->execute('git log -n1 --pretty=%H'.GitUtil::getNoShowSignatureFlag($this->process), $output, $path)) {
  27581. $package['dist']['reference'] = trim($output);
  27582. }
  27583. if (!isset($package['version'])) {
  27584. $versionData = $this->versionGuesser->guessVersion($package, $path);
  27585. if (is_array($versionData) && $versionData['pretty_version']) {
  27586. if (!empty($versionData['feature_pretty_version'])) {
  27587. $package['version'] = $versionData['feature_pretty_version'];
  27588. $this->addPackage($this->loader->load($package));
  27589. }
  27590. $package['version'] = $versionData['pretty_version'];
  27591. } else {
  27592. $package['version'] = 'dev-main';
  27593. }
  27594. }
  27595. $this->addPackage($this->loader->load($package));
  27596. }
  27597. }
  27598. private function getUrlMatches(): array
  27599. {
  27600. $flags = GLOB_MARK | GLOB_ONLYDIR;
  27601. if (defined('GLOB_BRACE')) {
  27602. $flags |= GLOB_BRACE;
  27603. } elseif (strpos($this->url, '{') !== false || strpos($this->url, '}') !== false) {
  27604. throw new \RuntimeException('The operating system does not support GLOB_BRACE which is required for the url '. $this->url);
  27605. }
  27606. return array_map(function ($val): string {
  27607. return rtrim(str_replace(DIRECTORY_SEPARATOR, '/', $val), '/');
  27608. }, glob($this->url, $flags));
  27609. }
  27610. }
  27611. <?php declare(strict_types=1);
  27612. namespace Composer\Repository;
  27613. class PearRepository extends ArrayRepository
  27614. {
  27615. public function __construct()
  27616. {
  27617. throw new \InvalidArgumentException('The PEAR repository has been removed from Composer 2.x');
  27618. }
  27619. }
  27620. <?php declare(strict_types=1);
  27621. namespace Composer\Repository;
  27622. use Composer\Composer;
  27623. use Composer\Package\CompletePackage;
  27624. use Composer\Package\CompletePackageInterface;
  27625. use Composer\Package\Link;
  27626. use Composer\Package\PackageInterface;
  27627. use Composer\Package\Version\VersionParser;
  27628. use Composer\Pcre\Preg;
  27629. use Composer\Platform\HhvmDetector;
  27630. use Composer\Platform\Runtime;
  27631. use Composer\Platform\Version;
  27632. use Composer\Plugin\PluginInterface;
  27633. use Composer\Semver\Constraint\Constraint;
  27634. use Composer\Util\Silencer;
  27635. use Composer\XdebugHandler\XdebugHandler;
  27636. class PlatformRepository extends ArrayRepository
  27637. {
  27638. public const PLATFORM_PACKAGE_REGEX = '{^(?:php(?:-64bit|-ipv6|-zts|-debug)?|hhvm|(?:ext|lib)-[a-z0-9](?:[_.-]?[a-z0-9]+)*|composer(?:-(?:plugin|runtime)-api)?)$}iD';
  27639. private static $lastSeenPlatformPhp = null;
  27640. private $versionParser;
  27641. private $overrides = array();
  27642. private $disabledPackages = array();
  27643. private $runtime;
  27644. private $hhvmDetector;
  27645. public function __construct(array $packages = array(), array $overrides = array(), Runtime $runtime = null, HhvmDetector $hhvmDetector = null)
  27646. {
  27647. $this->runtime = $runtime ?: new Runtime();
  27648. $this->hhvmDetector = $hhvmDetector ?: new HhvmDetector();
  27649. foreach ($overrides as $name => $version) {
  27650. if (!is_string($version) && false !== $version) {
  27651. throw new \UnexpectedValueException('config.platform.'.$name.' should be a string or false, but got '.gettype($version).' '.var_export($version, true));
  27652. }
  27653. if ($name === 'php' && $version === false) {
  27654. throw new \UnexpectedValueException('config.platform.'.$name.' cannot be set to false as you cannot disable php entirely.');
  27655. }
  27656. $this->overrides[strtolower($name)] = array('name' => $name, 'version' => $version);
  27657. }
  27658. parent::__construct($packages);
  27659. }
  27660. public function getRepoName(): string
  27661. {
  27662. return 'platform repo';
  27663. }
  27664. public function isPlatformPackageDisabled(string $name): bool
  27665. {
  27666. return isset($this->disabledPackages[$name]);
  27667. }
  27668. public function getDisabledPackages(): array
  27669. {
  27670. return $this->disabledPackages;
  27671. }
  27672. protected function initialize(): void
  27673. {
  27674. parent::initialize();
  27675. $this->versionParser = new VersionParser();
  27676. foreach ($this->overrides as $override) {
  27677. if (!self::isPlatformPackage($override['name'])) {
  27678. throw new \InvalidArgumentException('Invalid platform package name in config.platform: '.$override['name']);
  27679. }
  27680. if ($override['version'] !== false) {
  27681. $this->addOverriddenPackage($override);
  27682. }
  27683. }
  27684. $prettyVersion = Composer::getVersion();
  27685. $version = $this->versionParser->normalize($prettyVersion);
  27686. $composer = new CompletePackage('composer', $version, $prettyVersion);
  27687. $composer->setDescription('Composer package');
  27688. $this->addPackage($composer);
  27689. $prettyVersion = PluginInterface::PLUGIN_API_VERSION;
  27690. $version = $this->versionParser->normalize($prettyVersion);
  27691. $composerPluginApi = new CompletePackage('composer-plugin-api', $version, $prettyVersion);
  27692. $composerPluginApi->setDescription('The Composer Plugin API');
  27693. $this->addPackage($composerPluginApi);
  27694. $prettyVersion = Composer::RUNTIME_API_VERSION;
  27695. $version = $this->versionParser->normalize($prettyVersion);
  27696. $composerRuntimeApi = new CompletePackage('composer-runtime-api', $version, $prettyVersion);
  27697. $composerRuntimeApi->setDescription('The Composer Runtime API');
  27698. $this->addPackage($composerRuntimeApi);
  27699. try {
  27700. $prettyVersion = $this->runtime->getConstant('PHP_VERSION');
  27701. $version = $this->versionParser->normalize($prettyVersion);
  27702. } catch (\UnexpectedValueException $e) {
  27703. $prettyVersion = Preg::replace('#^([^~+-]+).*$#', '$1', $this->runtime->getConstant('PHP_VERSION'));
  27704. $version = $this->versionParser->normalize($prettyVersion);
  27705. }
  27706. $php = new CompletePackage('php', $version, $prettyVersion);
  27707. $php->setDescription('The PHP interpreter');
  27708. $this->addPackage($php);
  27709. if ($this->runtime->getConstant('PHP_DEBUG')) {
  27710. $phpdebug = new CompletePackage('php-debug', $version, $prettyVersion);
  27711. $phpdebug->setDescription('The PHP interpreter, with debugging symbols');
  27712. $this->addPackage($phpdebug);
  27713. }
  27714. if ($this->runtime->hasConstant('PHP_ZTS') && $this->runtime->getConstant('PHP_ZTS')) {
  27715. $phpzts = new CompletePackage('php-zts', $version, $prettyVersion);
  27716. $phpzts->setDescription('The PHP interpreter, with Zend Thread Safety');
  27717. $this->addPackage($phpzts);
  27718. }
  27719. if ($this->runtime->getConstant('PHP_INT_SIZE') === 8) {
  27720. $php64 = new CompletePackage('php-64bit', $version, $prettyVersion);
  27721. $php64->setDescription('The PHP interpreter, 64bit');
  27722. $this->addPackage($php64);
  27723. }
  27724. if ($this->runtime->hasConstant('AF_INET6') || Silencer::call(array($this->runtime, 'invoke'), 'inet_pton', array('::')) !== false) {
  27725. $phpIpv6 = new CompletePackage('php-ipv6', $version, $prettyVersion);
  27726. $phpIpv6->setDescription('The PHP interpreter, with IPv6 support');
  27727. $this->addPackage($phpIpv6);
  27728. }
  27729. $loadedExtensions = $this->runtime->getExtensions();
  27730. foreach ($loadedExtensions as $name) {
  27731. if (in_array($name, array('standard', 'Core'))) {
  27732. continue;
  27733. }
  27734. $this->addExtension($name, $this->runtime->getExtensionVersion($name));
  27735. }
  27736. if (!in_array('xdebug', $loadedExtensions, true) && ($prettyVersion = XdebugHandler::getSkippedVersion())) {
  27737. $this->addExtension('xdebug', $prettyVersion);
  27738. }
  27739. foreach ($loadedExtensions as $name) {
  27740. switch ($name) {
  27741. case 'amqp':
  27742. $info = $this->runtime->getExtensionInfo($name);
  27743. if (Preg::isMatch('/^librabbitmq version => (?<version>.+)$/im', $info, $librabbitmqMatches)) {
  27744. $this->addLibrary($name.'-librabbitmq', $librabbitmqMatches['version'], 'AMQP librabbitmq version');
  27745. }
  27746. if (Preg::isMatch('/^AMQP protocol version => (?<version>.+)$/im', $info, $protocolMatches)) {
  27747. $this->addLibrary($name.'-protocol', str_replace('-', '.', $protocolMatches['version']), 'AMQP protocol version');
  27748. }
  27749. break;
  27750. case 'bz2':
  27751. $info = $this->runtime->getExtensionInfo($name);
  27752. if (Preg::isMatch('/^BZip2 Version => (?<version>.*),/im', $info, $matches)) {
  27753. $this->addLibrary($name, $matches['version']);
  27754. }
  27755. break;
  27756. case 'curl':
  27757. $curlVersion = $this->runtime->invoke('curl_version');
  27758. $this->addLibrary($name, $curlVersion['version']);
  27759. $info = $this->runtime->getExtensionInfo($name);
  27760. if (Preg::isMatch('{^SSL Version => (?<library>[^/]+)/(?<version>.+)$}im', $info, $sslMatches)) {
  27761. $library = strtolower($sslMatches['library']);
  27762. if ($library === 'openssl') {
  27763. $parsedVersion = Version::parseOpenssl($sslMatches['version'], $isFips);
  27764. $this->addLibrary($name.'-openssl'.($isFips ? '-fips' : ''), $parsedVersion, 'curl OpenSSL version ('.$parsedVersion.')', array(), $isFips ? array('curl-openssl') : array());
  27765. } else {
  27766. $this->addLibrary($name.'-'.$library, $sslMatches['version'], 'curl '.$library.' version ('.$sslMatches['version'].')', array('curl-openssl'));
  27767. }
  27768. }
  27769. if (Preg::isMatch('{^libSSH Version => (?<library>[^/]+)/(?<version>.+?)(?:/.*)?$}im', $info, $sshMatches)) {
  27770. $this->addLibrary($name.'-'.strtolower($sshMatches['library']), $sshMatches['version'], 'curl '.$sshMatches['library'].' version');
  27771. }
  27772. if (Preg::isMatch('{^ZLib Version => (?<version>.+)$}im', $info, $zlibMatches)) {
  27773. $this->addLibrary($name.'-zlib', $zlibMatches['version'], 'curl zlib version');
  27774. }
  27775. break;
  27776. case 'date':
  27777. $info = $this->runtime->getExtensionInfo($name);
  27778. if (Preg::isMatch('/^timelib version => (?<version>.+)$/im', $info, $timelibMatches)) {
  27779. $this->addLibrary($name.'-timelib', $timelibMatches['version'], 'date timelib version');
  27780. }
  27781. if (Preg::isMatch('/^Timezone Database => (?<source>internal|external)$/im', $info, $zoneinfoSourceMatches)) {
  27782. $external = $zoneinfoSourceMatches['source'] === 'external';
  27783. if (Preg::isMatch('/^"Olson" Timezone Database Version => (?<version>.+?)(\.system)?$/im', $info, $zoneinfoMatches)) {
  27784. if ($external && in_array('timezonedb', $loadedExtensions, true)) {
  27785. $this->addLibrary('timezonedb-zoneinfo', $zoneinfoMatches['version'], 'zoneinfo ("Olson") database for date (replaced by timezonedb)', array($name.'-zoneinfo'));
  27786. } else {
  27787. $this->addLibrary($name.'-zoneinfo', $zoneinfoMatches['version'], 'zoneinfo ("Olson") database for date');
  27788. }
  27789. }
  27790. }
  27791. break;
  27792. case 'fileinfo':
  27793. $info = $this->runtime->getExtensionInfo($name);
  27794. if (Preg::isMatch('/^libmagic => (?<version>.+)$/im', $info, $magicMatches)) {
  27795. $this->addLibrary($name.'-libmagic', $magicMatches['version'], 'fileinfo libmagic version');
  27796. }
  27797. break;
  27798. case 'gd':
  27799. $this->addLibrary($name, $this->runtime->getConstant('GD_VERSION'));
  27800. $info = $this->runtime->getExtensionInfo($name);
  27801. if (Preg::isMatch('/^libJPEG Version => (?<version>.+?)(?: compatible)?$/im', $info, $libjpegMatches)) {
  27802. $this->addLibrary($name.'-libjpeg', Version::parseLibjpeg($libjpegMatches['version']), 'libjpeg version for gd');
  27803. }
  27804. if (Preg::isMatch('/^libPNG Version => (?<version>.+)$/im', $info, $libpngMatches)) {
  27805. $this->addLibrary($name.'-libpng', $libpngMatches['version'], 'libpng version for gd');
  27806. }
  27807. if (Preg::isMatch('/^FreeType Version => (?<version>.+)$/im', $info, $freetypeMatches)) {
  27808. $this->addLibrary($name.'-freetype', $freetypeMatches['version'], 'freetype version for gd');
  27809. }
  27810. if (Preg::isMatch('/^libXpm Version => (?<versionId>\d+)$/im', $info, $libxpmMatches)) {
  27811. $this->addLibrary($name.'-libxpm', Version::convertLibxpmVersionId((int) $libxpmMatches['versionId']), 'libxpm version for gd');
  27812. }
  27813. break;
  27814. case 'gmp':
  27815. $this->addLibrary($name, $this->runtime->getConstant('GMP_VERSION'));
  27816. break;
  27817. case 'iconv':
  27818. $this->addLibrary($name, $this->runtime->getConstant('ICONV_VERSION'));
  27819. break;
  27820. case 'intl':
  27821. $info = $this->runtime->getExtensionInfo($name);
  27822. $description = 'The ICU unicode and globalization support library';
  27823. if ($this->runtime->hasConstant('INTL_ICU_VERSION')) {
  27824. $this->addLibrary('icu', $this->runtime->getConstant('INTL_ICU_VERSION'), $description);
  27825. } elseif (Preg::isMatch('/^ICU version => (?<version>.+)$/im', $info, $matches)) {
  27826. $this->addLibrary('icu', $matches['version'], $description);
  27827. }
  27828. if (Preg::isMatch('/^ICU TZData version => (?<version>.*)$/im', $info, $zoneinfoMatches) && null !== ($version = Version::parseZoneinfoVersion($zoneinfoMatches['version']))) {
  27829. $this->addLibrary('icu-zoneinfo', $version, 'zoneinfo ("Olson") database for icu');
  27830. }
  27831. if ($this->runtime->hasClass('ResourceBundle')) {
  27832. $cldrVersion = $this->runtime->invoke(array('ResourceBundle', 'create'), array('root', 'ICUDATA', false))->get('Version');
  27833. $this->addLibrary('icu-cldr', $cldrVersion, 'ICU CLDR project version');
  27834. }
  27835. if ($this->runtime->hasClass('IntlChar')) {
  27836. $this->addLibrary('icu-unicode', implode('.', array_slice($this->runtime->invoke(array('IntlChar', 'getUnicodeVersion')), 0, 3)), 'ICU unicode version');
  27837. }
  27838. break;
  27839. case 'imagick':
  27840. $imageMagickVersion = $this->runtime->construct('Imagick')->getVersion();
  27841. Preg::match('/^ImageMagick (?<version>[\d.]+)(?:-(?<patch>\d+))?/', $imageMagickVersion['versionString'], $matches);
  27842. $version = $matches['version'];
  27843. if (isset($matches['patch'])) {
  27844. $version .= '.'.$matches['patch'];
  27845. }
  27846. $this->addLibrary($name.'-imagemagick', $version, null, array('imagick'));
  27847. break;
  27848. case 'ldap':
  27849. $info = $this->runtime->getExtensionInfo($name);
  27850. if (Preg::isMatch('/^Vendor Version => (?<versionId>\d+)$/im', $info, $matches) && Preg::isMatch('/^Vendor Name => (?<vendor>.+)$/im', $info, $vendorMatches)) {
  27851. $this->addLibrary($name.'-'.strtolower($vendorMatches['vendor']), Version::convertOpenldapVersionId((int) $matches['versionId']), $vendorMatches['vendor'].' version of ldap');
  27852. }
  27853. break;
  27854. case 'libxml':
  27855. $libxmlProvides = array_map(function ($extension): string {
  27856. return $extension . '-libxml';
  27857. }, array_intersect($loadedExtensions, array('dom', 'simplexml', 'xml', 'xmlreader', 'xmlwriter')));
  27858. $this->addLibrary($name, $this->runtime->getConstant('LIBXML_DOTTED_VERSION'), 'libxml library version', array(), $libxmlProvides);
  27859. break;
  27860. case 'mbstring':
  27861. $info = $this->runtime->getExtensionInfo($name);
  27862. if (Preg::isMatch('/^libmbfl version => (?<version>.+)$/im', $info, $libmbflMatches)) {
  27863. $this->addLibrary($name.'-libmbfl', $libmbflMatches['version'], 'mbstring libmbfl version');
  27864. }
  27865. if ($this->runtime->hasConstant('MB_ONIGURUMA_VERSION')) {
  27866. $this->addLibrary($name.'-oniguruma', $this->runtime->getConstant('MB_ONIGURUMA_VERSION'), 'mbstring oniguruma version');
  27867. } elseif (Preg::isMatch('/^(?:oniguruma|Multibyte regex \(oniguruma\)) version => (?<version>.+)$/im', $info, $onigurumaMatches)) {
  27868. $this->addLibrary($name.'-oniguruma', $onigurumaMatches['version'], 'mbstring oniguruma version');
  27869. }
  27870. break;
  27871. case 'memcached':
  27872. $info = $this->runtime->getExtensionInfo($name);
  27873. if (Preg::isMatch('/^libmemcached version => (?<version>.+)$/im', $info, $matches)) {
  27874. $this->addLibrary($name.'-libmemcached', $matches['version'], 'libmemcached version');
  27875. }
  27876. break;
  27877. case 'openssl':
  27878. if (Preg::isMatch('{^(?:OpenSSL|LibreSSL)?\s*(?<version>\S+)}i', $this->runtime->getConstant('OPENSSL_VERSION_TEXT'), $matches)) {
  27879. $parsedVersion = Version::parseOpenssl($matches['version'], $isFips);
  27880. $this->addLibrary($name.($isFips ? '-fips' : ''), $parsedVersion, $this->runtime->getConstant('OPENSSL_VERSION_TEXT'), array(), $isFips ? array($name) : array());
  27881. }
  27882. break;
  27883. case 'pcre':
  27884. $this->addLibrary($name, Preg::replace('{^(\S+).*}', '$1', $this->runtime->getConstant('PCRE_VERSION')));
  27885. $info = $this->runtime->getExtensionInfo($name);
  27886. if (Preg::isMatch('/^PCRE Unicode Version => (?<version>.+)$/im', $info, $pcreUnicodeMatches)) {
  27887. $this->addLibrary($name.'-unicode', $pcreUnicodeMatches['version'], 'PCRE Unicode version support');
  27888. }
  27889. break;
  27890. case 'mysqlnd':
  27891. case 'pdo_mysql':
  27892. $info = $this->runtime->getExtensionInfo($name);
  27893. if (Preg::isMatch('/^(?:Client API version|Version) => mysqlnd (?<version>.+?) /mi', $info, $matches)) {
  27894. $this->addLibrary($name.'-mysqlnd', $matches['version'], 'mysqlnd library version for '.$name);
  27895. }
  27896. break;
  27897. case 'mongodb':
  27898. $info = $this->runtime->getExtensionInfo($name);
  27899. if (Preg::isMatch('/^libmongoc bundled version => (?<version>.+)$/im', $info, $libmongocMatches)) {
  27900. $this->addLibrary($name.'-libmongoc', $libmongocMatches['version'], 'libmongoc version of mongodb');
  27901. }
  27902. if (Preg::isMatch('/^libbson bundled version => (?<version>.+)$/im', $info, $libbsonMatches)) {
  27903. $this->addLibrary($name.'-libbson', $libbsonMatches['version'], 'libbson version of mongodb');
  27904. }
  27905. break;
  27906. case 'pgsql':
  27907. case 'pdo_pgsql':
  27908. $info = $this->runtime->getExtensionInfo($name);
  27909. if (Preg::isMatch('/^PostgreSQL\(libpq\) Version => (?<version>.*)$/im', $info, $matches)) {
  27910. $this->addLibrary($name.'-libpq', $matches['version'], 'libpq for '.$name);
  27911. }
  27912. break;
  27913. case 'libsodium':
  27914. case 'sodium':
  27915. if ($this->runtime->hasConstant('SODIUM_LIBRARY_VERSION')) {
  27916. $this->addLibrary('libsodium', $this->runtime->getConstant('SODIUM_LIBRARY_VERSION'));
  27917. }
  27918. break;
  27919. case 'sqlite3':
  27920. case 'pdo_sqlite':
  27921. $info = $this->runtime->getExtensionInfo($name);
  27922. if (Preg::isMatch('/^SQLite Library => (?<version>.+)$/im', $info, $matches)) {
  27923. $this->addLibrary($name.'-sqlite', $matches['version']);
  27924. }
  27925. break;
  27926. case 'ssh2':
  27927. $info = $this->runtime->getExtensionInfo($name);
  27928. if (Preg::isMatch('/^libssh2 version => (?<version>.+)$/im', $info, $matches)) {
  27929. $this->addLibrary($name.'-libssh2', $matches['version']);
  27930. }
  27931. break;
  27932. case 'xsl':
  27933. $this->addLibrary('libxslt', $this->runtime->getConstant('LIBXSLT_DOTTED_VERSION'), null, array('xsl'));
  27934. $info = $this->runtime->getExtensionInfo('xsl');
  27935. if (Preg::isMatch('/^libxslt compiled against libxml Version => (?<version>.+)$/im', $info, $matches)) {
  27936. $this->addLibrary('libxslt-libxml', $matches['version'], 'libxml version libxslt is compiled against');
  27937. }
  27938. break;
  27939. case 'yaml':
  27940. $info = $this->runtime->getExtensionInfo('yaml');
  27941. if (Preg::isMatch('/^LibYAML Version => (?<version>.+)$/im', $info, $matches)) {
  27942. $this->addLibrary($name.'-libyaml', $matches['version'], 'libyaml version of yaml');
  27943. }
  27944. break;
  27945. case 'zip':
  27946. if ($this->runtime->hasConstant('LIBZIP_VERSION', 'ZipArchive')) {
  27947. $this->addLibrary($name.'-libzip', $this->runtime->getConstant('LIBZIP_VERSION', 'ZipArchive'), null, array('zip'));
  27948. }
  27949. break;
  27950. case 'zlib':
  27951. if ($this->runtime->hasConstant('ZLIB_VERSION')) {
  27952. $this->addLibrary($name, $this->runtime->getConstant('ZLIB_VERSION'));
  27953. } elseif (Preg::isMatch('/^Linked Version => (?<version>.+)$/im', $this->runtime->getExtensionInfo($name), $matches)) {
  27954. $this->addLibrary($name, $matches['version']);
  27955. }
  27956. break;
  27957. default:
  27958. break;
  27959. }
  27960. }
  27961. $hhvmVersion = $this->hhvmDetector->getVersion();
  27962. if ($hhvmVersion) {
  27963. try {
  27964. $prettyVersion = $hhvmVersion;
  27965. $version = $this->versionParser->normalize($prettyVersion);
  27966. } catch (\UnexpectedValueException $e) {
  27967. $prettyVersion = Preg::replace('#^([^~+-]+).*$#', '$1', $hhvmVersion);
  27968. $version = $this->versionParser->normalize($prettyVersion);
  27969. }
  27970. $hhvm = new CompletePackage('hhvm', $version, $prettyVersion);
  27971. $hhvm->setDescription('The HHVM Runtime (64bit)');
  27972. $this->addPackage($hhvm);
  27973. }
  27974. }
  27975. public function addPackage(PackageInterface $package): void
  27976. {
  27977. if (!$package instanceof CompletePackage) {
  27978. throw new \UnexpectedValueException('Expected CompletePackage but got '.get_class($package));
  27979. }
  27980. if (isset($this->overrides[$package->getName()])) {
  27981. if ($this->overrides[$package->getName()]['version'] === false) {
  27982. $this->addDisabledPackage($package);
  27983. return;
  27984. }
  27985. $overrider = $this->findPackage($package->getName(), '*');
  27986. if ($package->getVersion() === $overrider->getVersion()) {
  27987. $actualText = 'same as actual';
  27988. } else {
  27989. $actualText = 'actual: '.$package->getPrettyVersion();
  27990. }
  27991. if ($overrider instanceof CompletePackageInterface) {
  27992. $overrider->setDescription($overrider->getDescription().', '.$actualText);
  27993. }
  27994. return;
  27995. }
  27996. if (isset($this->overrides['php']) && 0 === strpos($package->getName(), 'php-')) {
  27997. if (isset($this->overrides[$package->getName()]) && $this->overrides[$package->getName()]['version'] === false) {
  27998. $this->addDisabledPackage($package);
  27999. return;
  28000. }
  28001. $overrider = $this->addOverriddenPackage($this->overrides['php'], $package->getPrettyName());
  28002. if ($package->getVersion() === $overrider->getVersion()) {
  28003. $actualText = 'same as actual';
  28004. } else {
  28005. $actualText = 'actual: '.$package->getPrettyVersion();
  28006. }
  28007. $overrider->setDescription($overrider->getDescription().', '.$actualText);
  28008. return;
  28009. }
  28010. parent::addPackage($package);
  28011. }
  28012. private function addOverriddenPackage(array $override, ?string $name = null): CompletePackage
  28013. {
  28014. $version = $this->versionParser->normalize($override['version']);
  28015. $package = new CompletePackage($name ?: $override['name'], $version, $override['version']);
  28016. $package->setDescription('Package overridden via config.platform');
  28017. $package->setExtra(array('config.platform' => true));
  28018. parent::addPackage($package);
  28019. if ($package->getName() === 'php') {
  28020. self::$lastSeenPlatformPhp = implode('.', array_slice(explode('.', $package->getVersion()), 0, 3));
  28021. }
  28022. return $package;
  28023. }
  28024. private function addDisabledPackage(CompletePackage $package): void
  28025. {
  28026. $package->setDescription($package->getDescription().'. <warning>Package disabled via config.platform</warning>');
  28027. $package->setExtra(array('config.platform' => true));
  28028. $this->disabledPackages[$package->getName()] = $package;
  28029. }
  28030. private function addExtension(string $name, string $prettyVersion): void
  28031. {
  28032. $extraDescription = null;
  28033. try {
  28034. $version = $this->versionParser->normalize($prettyVersion);
  28035. } catch (\UnexpectedValueException $e) {
  28036. $extraDescription = ' (actual version: '.$prettyVersion.')';
  28037. if (Preg::isMatch('{^(\d+\.\d+\.\d+(?:\.\d+)?)}', $prettyVersion, $match)) {
  28038. $prettyVersion = $match[1];
  28039. } else {
  28040. $prettyVersion = '0';
  28041. }
  28042. $version = $this->versionParser->normalize($prettyVersion);
  28043. }
  28044. $packageName = $this->buildPackageName($name);
  28045. $ext = new CompletePackage($packageName, $version, $prettyVersion);
  28046. $ext->setDescription('The '.$name.' PHP extension'.$extraDescription);
  28047. if ($name === 'uuid') {
  28048. $ext->setReplaces(array(
  28049. 'lib-uuid' => new Link('ext-uuid', 'lib-uuid', new Constraint('=', $version), Link::TYPE_REPLACE, $ext->getPrettyVersion()),
  28050. ));
  28051. }
  28052. $this->addPackage($ext);
  28053. }
  28054. private function buildPackageName(string $name): string
  28055. {
  28056. return 'ext-' . str_replace(' ', '-', strtolower($name));
  28057. }
  28058. private function addLibrary(string $name, ?string $prettyVersion, ?string $description = null, array $replaces = array(), array $provides = array()): void
  28059. {
  28060. if (null === $prettyVersion) {
  28061. return;
  28062. }
  28063. try {
  28064. $version = $this->versionParser->normalize($prettyVersion);
  28065. } catch (\UnexpectedValueException $e) {
  28066. return;
  28067. }
  28068. if ($description === null) {
  28069. $description = 'The '.$name.' library';
  28070. }
  28071. $lib = new CompletePackage('lib-'.$name, $version, $prettyVersion);
  28072. $lib->setDescription($description);
  28073. $replaceLinks = array();
  28074. foreach ($replaces as $replace) {
  28075. $replace = strtolower($replace);
  28076. $replaceLinks[$replace] = new Link('lib-'.$name, 'lib-'.$replace, new Constraint('=', $version), Link::TYPE_REPLACE, $lib->getPrettyVersion());
  28077. }
  28078. $provideLinks = array();
  28079. foreach ($provides as $provide) {
  28080. $provide = strtolower($provide);
  28081. $provideLinks[$provide] = new Link('lib-'.$name, 'lib-'.$provide, new Constraint('=', $version), Link::TYPE_PROVIDE, $lib->getPrettyVersion());
  28082. }
  28083. $lib->setReplaces($replaceLinks);
  28084. $lib->setProvides($provideLinks);
  28085. $this->addPackage($lib);
  28086. }
  28087. public static function isPlatformPackage(string $name): bool
  28088. {
  28089. static $cache = array();
  28090. if (isset($cache[$name])) {
  28091. return $cache[$name];
  28092. }
  28093. return $cache[$name] = Preg::isMatch(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name);
  28094. }
  28095. public static function getPlatformPhpVersion(): ?string
  28096. {
  28097. return self::$lastSeenPlatformPhp;
  28098. }
  28099. public function search(string $query, int $mode = 0, ?string $type = null): array
  28100. {
  28101. if ($mode === self::SEARCH_VENDOR) {
  28102. return array();
  28103. }
  28104. return parent::search($query, $mode, $type);
  28105. }
  28106. }
  28107. <?php declare(strict_types=1);
  28108. namespace Composer\Repository;
  28109. use Composer\Factory;
  28110. use Composer\IO\IOInterface;
  28111. use Composer\Config;
  28112. use Composer\EventDispatcher\EventDispatcher;
  28113. use Composer\Pcre\Preg;
  28114. use Composer\Util\HttpDownloader;
  28115. use Composer\Util\ProcessExecutor;
  28116. use Composer\Json\JsonFile;
  28117. class RepositoryFactory
  28118. {
  28119. public static function configFromString(IOInterface $io, Config $config, string $repository, bool $allowFilesystem = false)
  28120. {
  28121. if (0 === strpos($repository, 'http')) {
  28122. $repoConfig = array('type' => 'composer', 'url' => $repository);
  28123. } elseif ("json" === pathinfo($repository, PATHINFO_EXTENSION)) {
  28124. $json = new JsonFile($repository, Factory::createHttpDownloader($io, $config));
  28125. $data = $json->read();
  28126. if (!empty($data['packages']) || !empty($data['includes']) || !empty($data['provider-includes'])) {
  28127. $repoConfig = array('type' => 'composer', 'url' => 'file://' . strtr(realpath($repository), '\\', '/'));
  28128. } elseif ($allowFilesystem) {
  28129. $repoConfig = array('type' => 'filesystem', 'json' => $json);
  28130. } else {
  28131. throw new \InvalidArgumentException("Invalid repository URL ($repository) given. This file does not contain a valid composer repository.");
  28132. }
  28133. } elseif (strpos($repository, '{') === 0) {
  28134. $repoConfig = JsonFile::parseJson($repository);
  28135. } else {
  28136. throw new \InvalidArgumentException("Invalid repository url ($repository) given. Has to be a .json file, an http url or a JSON object.");
  28137. }
  28138. return $repoConfig;
  28139. }
  28140. public static function fromString(IOInterface $io, Config $config, string $repository, bool $allowFilesystem = false, RepositoryManager $rm = null): RepositoryInterface
  28141. {
  28142. $repoConfig = static::configFromString($io, $config, $repository, $allowFilesystem);
  28143. return static::createRepo($io, $config, $repoConfig, $rm);
  28144. }
  28145. public static function createRepo(IOInterface $io, Config $config, array $repoConfig, RepositoryManager $rm = null): RepositoryInterface
  28146. {
  28147. if (!$rm) {
  28148. $rm = static::manager($io, $config, Factory::createHttpDownloader($io, $config));
  28149. }
  28150. $repos = self::createRepos($rm, array($repoConfig));
  28151. return reset($repos);
  28152. }
  28153. public static function defaultRepos(IOInterface $io = null, Config $config = null, RepositoryManager $rm = null): array
  28154. {
  28155. if (!$config) {
  28156. $config = Factory::createConfig($io);
  28157. }
  28158. if ($io) {
  28159. $io->loadConfiguration($config);
  28160. }
  28161. if (!$rm) {
  28162. if (!$io) {
  28163. throw new \InvalidArgumentException('This function requires either an IOInterface or a RepositoryManager');
  28164. }
  28165. $rm = static::manager($io, $config, Factory::createHttpDownloader($io, $config));
  28166. }
  28167. return self::createRepos($rm, $config->getRepositories());
  28168. }
  28169. public static function manager(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, ProcessExecutor $process = null): RepositoryManager
  28170. {
  28171. $rm = new RepositoryManager($io, $config, $httpDownloader, $eventDispatcher, $process);
  28172. $rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
  28173. $rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository');
  28174. $rm->setRepositoryClass('package', 'Composer\Repository\PackageRepository');
  28175. $rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
  28176. $rm->setRepositoryClass('git', 'Composer\Repository\VcsRepository');
  28177. $rm->setRepositoryClass('bitbucket', 'Composer\Repository\VcsRepository');
  28178. $rm->setRepositoryClass('git-bitbucket', 'Composer\Repository\VcsRepository');
  28179. $rm->setRepositoryClass('github', 'Composer\Repository\VcsRepository');
  28180. $rm->setRepositoryClass('gitlab', 'Composer\Repository\VcsRepository');
  28181. $rm->setRepositoryClass('svn', 'Composer\Repository\VcsRepository');
  28182. $rm->setRepositoryClass('fossil', 'Composer\Repository\VcsRepository');
  28183. $rm->setRepositoryClass('perforce', 'Composer\Repository\VcsRepository');
  28184. $rm->setRepositoryClass('hg', 'Composer\Repository\VcsRepository');
  28185. $rm->setRepositoryClass('artifact', 'Composer\Repository\ArtifactRepository');
  28186. $rm->setRepositoryClass('path', 'Composer\Repository\PathRepository');
  28187. return $rm;
  28188. }
  28189. private static function createRepos(RepositoryManager $rm, array $repoConfigs): array
  28190. {
  28191. $repos = array();
  28192. foreach ($repoConfigs as $index => $repo) {
  28193. if (is_string($repo)) {
  28194. throw new \UnexpectedValueException('"repositories" should be an array of repository definitions, only a single repository was given');
  28195. }
  28196. if (!is_array($repo)) {
  28197. throw new \UnexpectedValueException('Repository "'.$index.'" ('.json_encode($repo).') should be an array, '.gettype($repo).' given');
  28198. }
  28199. if (!isset($repo['type'])) {
  28200. throw new \UnexpectedValueException('Repository "'.$index.'" ('.json_encode($repo).') must have a type defined');
  28201. }
  28202. $name = self::generateRepositoryName($index, $repo, $repos);
  28203. if ($repo['type'] === 'filesystem') {
  28204. $repos[$name] = new FilesystemRepository($repo['json']);
  28205. } else {
  28206. $repos[$name] = $rm->createRepository($repo['type'], $repo, (string) $index);
  28207. }
  28208. }
  28209. return $repos;
  28210. }
  28211. public static function generateRepositoryName($index, array $repo, array $existingRepos): string
  28212. {
  28213. $name = is_int($index) && isset($repo['url']) ? Preg::replace('{^https?://}i', '', $repo['url']) : (string) $index;
  28214. while (isset($existingRepos[$name])) {
  28215. $name .= '2';
  28216. }
  28217. return $name;
  28218. }
  28219. }
  28220. <?php declare(strict_types=1);
  28221. namespace Composer\Repository;
  28222. use Composer\Package\PackageInterface;
  28223. use Composer\Package\BasePackage;
  28224. use Composer\Semver\Constraint\ConstraintInterface;
  28225. interface RepositoryInterface extends \Countable
  28226. {
  28227. public const SEARCH_FULLTEXT = 0;
  28228. public const SEARCH_NAME = 1;
  28229. public const SEARCH_VENDOR = 2;
  28230. public function hasPackage(PackageInterface $package);
  28231. public function findPackage(string $name, $constraint);
  28232. public function findPackages(string $name, $constraint = null);
  28233. public function getPackages();
  28234. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array());
  28235. public function search(string $query, int $mode = 0, ?string $type = null);
  28236. public function getProviders(string $packageName);
  28237. public function getRepoName();
  28238. }
  28239. <?php declare(strict_types=1);
  28240. namespace Composer\Repository;
  28241. use Composer\IO\IOInterface;
  28242. use Composer\Config;
  28243. use Composer\EventDispatcher\EventDispatcher;
  28244. use Composer\Package\PackageInterface;
  28245. use Composer\Util\HttpDownloader;
  28246. use Composer\Util\ProcessExecutor;
  28247. class RepositoryManager
  28248. {
  28249. private $localRepository;
  28250. private $repositories = array();
  28251. private $repositoryClasses = array();
  28252. private $io;
  28253. private $config;
  28254. private $httpDownloader;
  28255. private $eventDispatcher;
  28256. private $process;
  28257. public function __construct(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, ProcessExecutor $process = null)
  28258. {
  28259. $this->io = $io;
  28260. $this->config = $config;
  28261. $this->httpDownloader = $httpDownloader;
  28262. $this->eventDispatcher = $eventDispatcher;
  28263. $this->process = $process ?? new ProcessExecutor($io);
  28264. }
  28265. public function findPackage(string $name, $constraint): ?PackageInterface
  28266. {
  28267. foreach ($this->repositories as $repository) {
  28268. if ($package = $repository->findPackage($name, $constraint)) {
  28269. return $package;
  28270. }
  28271. }
  28272. return null;
  28273. }
  28274. public function findPackages(string $name, $constraint): array
  28275. {
  28276. $packages = array();
  28277. foreach ($this->getRepositories() as $repository) {
  28278. $packages = array_merge($packages, $repository->findPackages($name, $constraint));
  28279. }
  28280. return $packages;
  28281. }
  28282. public function addRepository(RepositoryInterface $repository): void
  28283. {
  28284. $this->repositories[] = $repository;
  28285. }
  28286. public function prependRepository(RepositoryInterface $repository): void
  28287. {
  28288. array_unshift($this->repositories, $repository);
  28289. }
  28290. public function createRepository(string $type, array $config, string $name = null): RepositoryInterface
  28291. {
  28292. if (!isset($this->repositoryClasses[$type])) {
  28293. throw new \InvalidArgumentException('Repository type is not registered: '.$type);
  28294. }
  28295. if (isset($config['packagist']) && false === $config['packagist']) {
  28296. $this->io->writeError('<warning>Repository "'.$name.'" ('.json_encode($config).') has a packagist key which should be in its own repository definition</warning>');
  28297. }
  28298. $class = $this->repositoryClasses[$type];
  28299. if (isset($config['only']) || isset($config['exclude']) || isset($config['canonical'])) {
  28300. $filterConfig = $config;
  28301. unset($config['only'], $config['exclude'], $config['canonical']);
  28302. }
  28303. $repository = new $class($config, $this->io, $this->config, $this->httpDownloader, $this->eventDispatcher, $this->process);
  28304. if (isset($filterConfig)) {
  28305. $repository = new FilterRepository($repository, $filterConfig);
  28306. }
  28307. return $repository;
  28308. }
  28309. public function setRepositoryClass(string $type, $class): void
  28310. {
  28311. $this->repositoryClasses[$type] = $class;
  28312. }
  28313. public function getRepositories(): array
  28314. {
  28315. return $this->repositories;
  28316. }
  28317. public function setLocalRepository(InstalledRepositoryInterface $repository): void
  28318. {
  28319. $this->localRepository = $repository;
  28320. }
  28321. public function getLocalRepository(): InstalledRepositoryInterface
  28322. {
  28323. return $this->localRepository;
  28324. }
  28325. }
  28326. <?php declare(strict_types=1);
  28327. namespace Composer\Repository;
  28328. class RepositorySecurityException extends \Exception
  28329. {
  28330. }
  28331. <?php declare(strict_types=1);
  28332. namespace Composer\Repository;
  28333. use Composer\DependencyResolver\PoolOptimizer;
  28334. use Composer\DependencyResolver\Pool;
  28335. use Composer\DependencyResolver\PoolBuilder;
  28336. use Composer\DependencyResolver\Request;
  28337. use Composer\EventDispatcher\EventDispatcher;
  28338. use Composer\IO\IOInterface;
  28339. use Composer\IO\NullIO;
  28340. use Composer\Package\BasePackage;
  28341. use Composer\Package\AliasPackage;
  28342. use Composer\Package\CompleteAliasPackage;
  28343. use Composer\Package\CompletePackage;
  28344. use Composer\Semver\Constraint\ConstraintInterface;
  28345. use Composer\Package\Version\StabilityFilter;
  28346. class RepositorySet
  28347. {
  28348. public const ALLOW_UNACCEPTABLE_STABILITIES = 1;
  28349. public const ALLOW_SHADOWED_REPOSITORIES = 2;
  28350. private $rootAliases;
  28351. private $rootReferences;
  28352. private $repositories = array();
  28353. private $acceptableStabilities;
  28354. private $stabilityFlags;
  28355. private $rootRequires;
  28356. private $locked = false;
  28357. private $allowInstalledRepositories = false;
  28358. public function __construct(string $minimumStability = 'stable', array $stabilityFlags = array(), array $rootAliases = array(), array $rootReferences = array(), array $rootRequires = array())
  28359. {
  28360. $this->rootAliases = self::getRootAliasesPerPackage($rootAliases);
  28361. $this->rootReferences = $rootReferences;
  28362. $this->acceptableStabilities = array();
  28363. foreach (BasePackage::$stabilities as $stability => $value) {
  28364. if ($value <= BasePackage::$stabilities[$minimumStability]) {
  28365. $this->acceptableStabilities[$stability] = $value;
  28366. }
  28367. }
  28368. $this->stabilityFlags = $stabilityFlags;
  28369. $this->rootRequires = $rootRequires;
  28370. foreach ($rootRequires as $name => $constraint) {
  28371. if (PlatformRepository::isPlatformPackage($name)) {
  28372. unset($this->rootRequires[$name]);
  28373. }
  28374. }
  28375. }
  28376. public function allowInstalledRepositories(bool $allow = true): void
  28377. {
  28378. $this->allowInstalledRepositories = $allow;
  28379. }
  28380. public function getRootRequires(): array
  28381. {
  28382. return $this->rootRequires;
  28383. }
  28384. public function addRepository(RepositoryInterface $repo): void
  28385. {
  28386. if ($this->locked) {
  28387. throw new \RuntimeException("Pool has already been created from this repository set, it cannot be modified anymore.");
  28388. }
  28389. if ($repo instanceof CompositeRepository) {
  28390. $repos = $repo->getRepositories();
  28391. } else {
  28392. $repos = array($repo);
  28393. }
  28394. foreach ($repos as $repo) {
  28395. $this->repositories[] = $repo;
  28396. }
  28397. }
  28398. public function findPackages(string $name, ConstraintInterface $constraint = null, int $flags = 0): array
  28399. {
  28400. $ignoreStability = ($flags & self::ALLOW_UNACCEPTABLE_STABILITIES) !== 0;
  28401. $loadFromAllRepos = ($flags & self::ALLOW_SHADOWED_REPOSITORIES) !== 0;
  28402. $packages = array();
  28403. if ($loadFromAllRepos) {
  28404. foreach ($this->repositories as $repository) {
  28405. $packages[] = $repository->findPackages($name, $constraint) ?: array();
  28406. }
  28407. } else {
  28408. foreach ($this->repositories as $repository) {
  28409. $result = $repository->loadPackages(array($name => $constraint), $ignoreStability ? BasePackage::$stabilities : $this->acceptableStabilities, $ignoreStability ? array() : $this->stabilityFlags);
  28410. $packages[] = $result['packages'];
  28411. foreach ($result['namesFound'] as $nameFound) {
  28412. if ($name === $nameFound) {
  28413. break 2;
  28414. }
  28415. }
  28416. }
  28417. }
  28418. $candidates = $packages ? call_user_func_array('array_merge', $packages) : array();
  28419. if ($ignoreStability || !$loadFromAllRepos) {
  28420. return $candidates;
  28421. }
  28422. $result = array();
  28423. foreach ($candidates as $candidate) {
  28424. if ($this->isPackageAcceptable($candidate->getNames(), $candidate->getStability())) {
  28425. $result[] = $candidate;
  28426. }
  28427. }
  28428. return $result;
  28429. }
  28430. public function getProviders(string $packageName): array
  28431. {
  28432. $providers = array();
  28433. foreach ($this->repositories as $repository) {
  28434. if ($repoProviders = $repository->getProviders($packageName)) {
  28435. $providers = array_merge($providers, $repoProviders);
  28436. }
  28437. }
  28438. return $providers;
  28439. }
  28440. public function isPackageAcceptable(array $names, string $stability): bool
  28441. {
  28442. return StabilityFilter::isPackageAcceptable($this->acceptableStabilities, $this->stabilityFlags, $names, $stability);
  28443. }
  28444. public function createPool(Request $request, IOInterface $io, EventDispatcher $eventDispatcher = null, PoolOptimizer $poolOptimizer = null): Pool
  28445. {
  28446. $poolBuilder = new PoolBuilder($this->acceptableStabilities, $this->stabilityFlags, $this->rootAliases, $this->rootReferences, $io, $eventDispatcher, $poolOptimizer);
  28447. foreach ($this->repositories as $repo) {
  28448. if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) {
  28449. throw new \LogicException('The pool can not accept packages from an installed repository');
  28450. }
  28451. }
  28452. $this->locked = true;
  28453. return $poolBuilder->buildPool($this->repositories, $request);
  28454. }
  28455. public function createPoolWithAllPackages(): Pool
  28456. {
  28457. foreach ($this->repositories as $repo) {
  28458. if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) {
  28459. throw new \LogicException('The pool can not accept packages from an installed repository');
  28460. }
  28461. }
  28462. $this->locked = true;
  28463. $packages = array();
  28464. foreach ($this->repositories as $repository) {
  28465. foreach ($repository->getPackages() as $package) {
  28466. $packages[] = $package;
  28467. if (isset($this->rootAliases[$package->getName()][$package->getVersion()])) {
  28468. $alias = $this->rootAliases[$package->getName()][$package->getVersion()];
  28469. while ($package instanceof AliasPackage) {
  28470. $package = $package->getAliasOf();
  28471. }
  28472. if ($package instanceof CompletePackage) {
  28473. $aliasPackage = new CompleteAliasPackage($package, $alias['alias_normalized'], $alias['alias']);
  28474. } else {
  28475. $aliasPackage = new AliasPackage($package, $alias['alias_normalized'], $alias['alias']);
  28476. }
  28477. $aliasPackage->setRootPackageAlias(true);
  28478. $packages[] = $aliasPackage;
  28479. }
  28480. }
  28481. }
  28482. return new Pool($packages);
  28483. }
  28484. public function createPoolForPackage(string $packageName, LockArrayRepository $lockedRepo = null): Pool
  28485. {
  28486. return $this->createPoolForPackages(array($packageName), $lockedRepo);
  28487. }
  28488. public function createPoolForPackages(array $packageNames, LockArrayRepository $lockedRepo = null): Pool
  28489. {
  28490. $request = new Request($lockedRepo);
  28491. foreach ($packageNames as $packageName) {
  28492. if (PlatformRepository::isPlatformPackage($packageName)) {
  28493. throw new \LogicException('createPoolForPackage(s) can not be used for platform packages, as they are never loaded by the PoolBuilder which expects them to be fixed. Use createPoolWithAllPackages or pass in a proper request with the platform packages you need fixed in it.');
  28494. }
  28495. $request->requireName($packageName);
  28496. }
  28497. return $this->createPool($request, new NullIO());
  28498. }
  28499. private static function getRootAliasesPerPackage(array $aliases): array
  28500. {
  28501. $normalizedAliases = array();
  28502. foreach ($aliases as $alias) {
  28503. $normalizedAliases[$alias['package']][$alias['version']] = array(
  28504. 'alias' => $alias['alias'],
  28505. 'alias_normalized' => $alias['alias_normalized'],
  28506. );
  28507. }
  28508. return $normalizedAliases;
  28509. }
  28510. }
  28511. <?php declare(strict_types=1);
  28512. namespace Composer\Repository;
  28513. use Composer\Package\RootPackageInterface;
  28514. class RootPackageRepository extends ArrayRepository
  28515. {
  28516. public function __construct(RootPackageInterface $package)
  28517. {
  28518. parent::__construct(array($package));
  28519. }
  28520. public function getRepoName(): string
  28521. {
  28522. return 'root package repo';
  28523. }
  28524. }
  28525. <?php declare(strict_types=1);
  28526. namespace Composer\Repository\Vcs;
  28527. use Composer\Cache;
  28528. use Composer\Config;
  28529. use Composer\Pcre\Preg;
  28530. use Composer\Util\ProcessExecutor;
  28531. use Composer\Util\Filesystem;
  28532. use Composer\IO\IOInterface;
  28533. class FossilDriver extends VcsDriver
  28534. {
  28535. protected $tags;
  28536. protected $branches;
  28537. protected $rootIdentifier = null;
  28538. protected $repoFile = null;
  28539. protected $checkoutDir;
  28540. public function initialize(): void
  28541. {
  28542. $this->checkFossil();
  28543. $this->config->prohibitUrlByConfig($this->url, $this->io);
  28544. if (Filesystem::isLocalPath($this->url) && is_dir($this->url)) {
  28545. $this->checkoutDir = $this->url;
  28546. } else {
  28547. if (!Cache::isUsable((string) $this->config->get('cache-repo-dir')) || !Cache::isUsable((string) $this->config->get('cache-vcs-dir'))) {
  28548. throw new \RuntimeException('FossilDriver requires a usable cache directory, and it looks like you set it to be disabled');
  28549. }
  28550. $localName = Preg::replace('{[^a-z0-9]}i', '-', $this->url);
  28551. $this->repoFile = $this->config->get('cache-repo-dir') . '/' . $localName . '.fossil';
  28552. $this->checkoutDir = $this->config->get('cache-vcs-dir') . '/' . $localName . '/';
  28553. $this->updateLocalRepo();
  28554. }
  28555. $this->getTags();
  28556. $this->getBranches();
  28557. }
  28558. protected function checkFossil(): void
  28559. {
  28560. if (0 !== $this->process->execute('fossil version', $ignoredOutput)) {
  28561. throw new \RuntimeException("fossil was not found, check that it is installed and in your PATH env.\n\n" . $this->process->getErrorOutput());
  28562. }
  28563. }
  28564. protected function updateLocalRepo(): void
  28565. {
  28566. $fs = new Filesystem();
  28567. $fs->ensureDirectoryExists($this->checkoutDir);
  28568. if (!is_writable(dirname($this->checkoutDir))) {
  28569. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.$this->checkoutDir.'" directory is not writable by the current user.');
  28570. }
  28571. if (is_file($this->repoFile) && is_dir($this->checkoutDir) && 0 === $this->process->execute('fossil info', $output, $this->checkoutDir)) {
  28572. if (0 !== $this->process->execute('fossil pull', $output, $this->checkoutDir)) {
  28573. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')</error>');
  28574. }
  28575. } else {
  28576. $fs->removeDirectory($this->checkoutDir);
  28577. $fs->remove($this->repoFile);
  28578. $fs->ensureDirectoryExists($this->checkoutDir);
  28579. if (0 !== $this->process->execute(sprintf('fossil clone -- %s %s', ProcessExecutor::escape($this->url), ProcessExecutor::escape($this->repoFile)), $output)) {
  28580. $output = $this->process->getErrorOutput();
  28581. throw new \RuntimeException('Failed to clone '.$this->url.' to repository ' . $this->repoFile . "\n\n" .$output);
  28582. }
  28583. if (0 !== $this->process->execute(sprintf('fossil open --nested -- %s', ProcessExecutor::escape($this->repoFile)), $output, $this->checkoutDir)) {
  28584. $output = $this->process->getErrorOutput();
  28585. throw new \RuntimeException('Failed to open repository '.$this->repoFile.' in ' . $this->checkoutDir . "\n\n" .$output);
  28586. }
  28587. }
  28588. }
  28589. public function getRootIdentifier(): string
  28590. {
  28591. if (null === $this->rootIdentifier) {
  28592. $this->rootIdentifier = 'trunk';
  28593. }
  28594. return $this->rootIdentifier;
  28595. }
  28596. public function getUrl(): string
  28597. {
  28598. return $this->url;
  28599. }
  28600. public function getSource(string $identifier): array
  28601. {
  28602. return array('type' => 'fossil', 'url' => $this->getUrl(), 'reference' => $identifier);
  28603. }
  28604. public function getDist(string $identifier): ?array
  28605. {
  28606. return null;
  28607. }
  28608. public function getFileContent(string $file, string $identifier): ?string
  28609. {
  28610. $command = sprintf('fossil cat -r %s -- %s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  28611. $this->process->execute($command, $content, $this->checkoutDir);
  28612. if (!trim($content)) {
  28613. return null;
  28614. }
  28615. return $content;
  28616. }
  28617. public function getChangeDate(string $identifier): ?\DateTimeImmutable
  28618. {
  28619. $this->process->execute('fossil finfo -b -n 1 composer.json', $output, $this->checkoutDir);
  28620. list(, $date) = explode(' ', trim($output), 3);
  28621. return new \DateTimeImmutable($date, new \DateTimeZone('UTC'));
  28622. }
  28623. public function getTags(): array
  28624. {
  28625. if (null === $this->tags) {
  28626. $tags = array();
  28627. $this->process->execute('fossil tag list', $output, $this->checkoutDir);
  28628. foreach ($this->process->splitLines($output) as $tag) {
  28629. $tags[$tag] = $tag;
  28630. }
  28631. $this->tags = $tags;
  28632. }
  28633. return $this->tags;
  28634. }
  28635. public function getBranches(): array
  28636. {
  28637. if (null === $this->branches) {
  28638. $branches = array();
  28639. $this->process->execute('fossil branch list', $output, $this->checkoutDir);
  28640. foreach ($this->process->splitLines($output) as $branch) {
  28641. $branch = trim(Preg::replace('/^\*/', '', trim($branch)));
  28642. $branches[$branch] = $branch;
  28643. }
  28644. $this->branches = $branches;
  28645. }
  28646. return $this->branches;
  28647. }
  28648. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
  28649. {
  28650. if (Preg::isMatch('#(^(?:https?|ssh)://(?:[^@]@)?(?:chiselapp\.com|fossil\.))#i', $url)) {
  28651. return true;
  28652. }
  28653. if (Preg::isMatch('!/fossil/|\.fossil!', $url)) {
  28654. return true;
  28655. }
  28656. if (Filesystem::isLocalPath($url)) {
  28657. $url = Filesystem::getPlatformPath($url);
  28658. if (!is_dir($url)) {
  28659. return false;
  28660. }
  28661. $process = new ProcessExecutor($io);
  28662. if ($process->execute('fossil info', $output, $url) === 0) {
  28663. return true;
  28664. }
  28665. }
  28666. return false;
  28667. }
  28668. }
  28669. <?php declare(strict_types=1);
  28670. namespace Composer\Repository\Vcs;
  28671. use Composer\Config;
  28672. use Composer\IO\IOInterface;
  28673. use Composer\Cache;
  28674. use Composer\Downloader\TransportException;
  28675. use Composer\Json\JsonFile;
  28676. use Composer\Pcre\Preg;
  28677. use Composer\Util\Bitbucket;
  28678. use Composer\Util\Http\Response;
  28679. class GitBitbucketDriver extends VcsDriver
  28680. {
  28681. protected $owner;
  28682. protected $repository;
  28683. private $hasIssues = false;
  28684. private $rootIdentifier;
  28685. private $tags;
  28686. private $branches;
  28687. private $branchesUrl = '';
  28688. private $tagsUrl = '';
  28689. private $homeUrl = '';
  28690. private $website = '';
  28691. private $cloneHttpsUrl = '';
  28692. protected $fallbackDriver = null;
  28693. private $vcsType;
  28694. public function initialize(): void
  28695. {
  28696. if (!Preg::isMatch('#^https?://bitbucket\.org/([^/]+)/([^/]+?)(\.git|/?)?$#i', $this->url, $match)) {
  28697. throw new \InvalidArgumentException(sprintf('The Bitbucket repository URL %s is invalid. It must be the HTTPS URL of a Bitbucket repository.', $this->url));
  28698. }
  28699. $this->owner = $match[1];
  28700. $this->repository = $match[2];
  28701. $this->originUrl = 'bitbucket.org';
  28702. $this->cache = new Cache(
  28703. $this->io,
  28704. implode('/', array(
  28705. $this->config->get('cache-repo-dir'),
  28706. $this->originUrl,
  28707. $this->owner,
  28708. $this->repository,
  28709. ))
  28710. );
  28711. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  28712. }
  28713. public function getUrl(): string
  28714. {
  28715. if ($this->fallbackDriver) {
  28716. return $this->fallbackDriver->getUrl();
  28717. }
  28718. return $this->cloneHttpsUrl;
  28719. }
  28720. protected function getRepoData(): bool
  28721. {
  28722. $resource = sprintf(
  28723. 'https://api.bitbucket.org/2.0/repositories/%s/%s?%s',
  28724. $this->owner,
  28725. $this->repository,
  28726. http_build_query(
  28727. array('fields' => '-project,-owner'),
  28728. '',
  28729. '&'
  28730. )
  28731. );
  28732. $repoData = $this->fetchWithOAuthCredentials($resource, true)->decodeJson();
  28733. if ($this->fallbackDriver) {
  28734. return false;
  28735. }
  28736. $this->parseCloneUrls($repoData['links']['clone']);
  28737. $this->hasIssues = !empty($repoData['has_issues']);
  28738. $this->branchesUrl = $repoData['links']['branches']['href'];
  28739. $this->tagsUrl = $repoData['links']['tags']['href'];
  28740. $this->homeUrl = $repoData['links']['html']['href'];
  28741. $this->website = $repoData['website'];
  28742. $this->vcsType = $repoData['scm'];
  28743. return true;
  28744. }
  28745. public function getComposerInformation(string $identifier): ?array
  28746. {
  28747. if ($this->fallbackDriver) {
  28748. return $this->fallbackDriver->getComposerInformation($identifier);
  28749. }
  28750. if (!isset($this->infoCache[$identifier])) {
  28751. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  28752. $composer = JsonFile::parseJson($res);
  28753. } else {
  28754. $composer = $this->getBaseComposerInformation($identifier);
  28755. if ($this->shouldCache($identifier)) {
  28756. $this->cache->write($identifier, json_encode($composer));
  28757. }
  28758. }
  28759. if ($composer !== null) {
  28760. if (!isset($composer['support']['source'])) {
  28761. $label = array_search(
  28762. $identifier,
  28763. $this->getTags()
  28764. ) ?: array_search(
  28765. $identifier,
  28766. $this->getBranches()
  28767. ) ?: $identifier;
  28768. if (array_key_exists($label, $tags = $this->getTags())) {
  28769. $hash = $tags[$label];
  28770. } elseif (array_key_exists($label, $branches = $this->getBranches())) {
  28771. $hash = $branches[$label];
  28772. }
  28773. if (!isset($hash)) {
  28774. $composer['support']['source'] = sprintf(
  28775. 'https://%s/%s/%s/src',
  28776. $this->originUrl,
  28777. $this->owner,
  28778. $this->repository
  28779. );
  28780. } else {
  28781. $composer['support']['source'] = sprintf(
  28782. 'https://%s/%s/%s/src/%s/?at=%s',
  28783. $this->originUrl,
  28784. $this->owner,
  28785. $this->repository,
  28786. $hash,
  28787. $label
  28788. );
  28789. }
  28790. }
  28791. if (!isset($composer['support']['issues']) && $this->hasIssues) {
  28792. $composer['support']['issues'] = sprintf(
  28793. 'https://%s/%s/%s/issues',
  28794. $this->originUrl,
  28795. $this->owner,
  28796. $this->repository
  28797. );
  28798. }
  28799. if (!isset($composer['homepage'])) {
  28800. $composer['homepage'] = empty($this->website) ? $this->homeUrl : $this->website;
  28801. }
  28802. }
  28803. $this->infoCache[$identifier] = $composer;
  28804. }
  28805. return $this->infoCache[$identifier];
  28806. }
  28807. public function getFileContent(string $file, string $identifier): ?string
  28808. {
  28809. if ($this->fallbackDriver) {
  28810. return $this->fallbackDriver->getFileContent($file, $identifier);
  28811. }
  28812. if (strpos($identifier, '/') !== false) {
  28813. $branches = $this->getBranches();
  28814. if (isset($branches[$identifier])) {
  28815. $identifier = $branches[$identifier];
  28816. }
  28817. }
  28818. $resource = sprintf(
  28819. 'https://api.bitbucket.org/2.0/repositories/%s/%s/src/%s/%s',
  28820. $this->owner,
  28821. $this->repository,
  28822. $identifier,
  28823. $file
  28824. );
  28825. return $this->fetchWithOAuthCredentials($resource)->getBody();
  28826. }
  28827. public function getChangeDate(string $identifier): ?\DateTimeImmutable
  28828. {
  28829. if ($this->fallbackDriver) {
  28830. return $this->fallbackDriver->getChangeDate($identifier);
  28831. }
  28832. if (strpos($identifier, '/') !== false) {
  28833. $branches = $this->getBranches();
  28834. if (isset($branches[$identifier])) {
  28835. $identifier = $branches[$identifier];
  28836. }
  28837. }
  28838. $resource = sprintf(
  28839. 'https://api.bitbucket.org/2.0/repositories/%s/%s/commit/%s?fields=date',
  28840. $this->owner,
  28841. $this->repository,
  28842. $identifier
  28843. );
  28844. $commit = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  28845. return new \DateTimeImmutable($commit['date']);
  28846. }
  28847. public function getSource(string $identifier): array
  28848. {
  28849. if ($this->fallbackDriver) {
  28850. return $this->fallbackDriver->getSource($identifier);
  28851. }
  28852. return array('type' => $this->vcsType, 'url' => $this->getUrl(), 'reference' => $identifier);
  28853. }
  28854. public function getDist(string $identifier): ?array
  28855. {
  28856. if ($this->fallbackDriver) {
  28857. return $this->fallbackDriver->getDist($identifier);
  28858. }
  28859. $url = sprintf(
  28860. 'https://bitbucket.org/%s/%s/get/%s.zip',
  28861. $this->owner,
  28862. $this->repository,
  28863. $identifier
  28864. );
  28865. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  28866. }
  28867. public function getTags(): array
  28868. {
  28869. if ($this->fallbackDriver) {
  28870. return $this->fallbackDriver->getTags();
  28871. }
  28872. if (null === $this->tags) {
  28873. $tags = array();
  28874. $resource = sprintf(
  28875. '%s?%s',
  28876. $this->tagsUrl,
  28877. http_build_query(
  28878. array(
  28879. 'pagelen' => 100,
  28880. 'fields' => 'values.name,values.target.hash,next',
  28881. 'sort' => '-target.date',
  28882. ),
  28883. '',
  28884. '&'
  28885. )
  28886. );
  28887. $hasNext = true;
  28888. while ($hasNext) {
  28889. $tagsData = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  28890. foreach ($tagsData['values'] as $data) {
  28891. $tags[$data['name']] = $data['target']['hash'];
  28892. }
  28893. if (empty($tagsData['next'])) {
  28894. $hasNext = false;
  28895. } else {
  28896. $resource = $tagsData['next'];
  28897. }
  28898. }
  28899. $this->tags = $tags;
  28900. }
  28901. return $this->tags;
  28902. }
  28903. public function getBranches(): array
  28904. {
  28905. if ($this->fallbackDriver) {
  28906. return $this->fallbackDriver->getBranches();
  28907. }
  28908. if (null === $this->branches) {
  28909. $branches = array();
  28910. $resource = sprintf(
  28911. '%s?%s',
  28912. $this->branchesUrl,
  28913. http_build_query(
  28914. array(
  28915. 'pagelen' => 100,
  28916. 'fields' => 'values.name,values.target.hash,values.heads,next',
  28917. 'sort' => '-target.date',
  28918. ),
  28919. '',
  28920. '&'
  28921. )
  28922. );
  28923. $hasNext = true;
  28924. while ($hasNext) {
  28925. $branchData = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  28926. foreach ($branchData['values'] as $data) {
  28927. $branches[$data['name']] = $data['target']['hash'];
  28928. }
  28929. if (empty($branchData['next'])) {
  28930. $hasNext = false;
  28931. } else {
  28932. $resource = $branchData['next'];
  28933. }
  28934. }
  28935. $this->branches = $branches;
  28936. }
  28937. return $this->branches;
  28938. }
  28939. protected function fetchWithOAuthCredentials(string $url, bool $fetchingRepoData = false): Response
  28940. {
  28941. try {
  28942. return parent::getContents($url);
  28943. } catch (TransportException $e) {
  28944. $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process, $this->httpDownloader);
  28945. if (in_array($e->getCode(), array(403, 404), true) || (401 === $e->getCode() && strpos($e->getMessage(), 'Could not authenticate against') === 0)) {
  28946. if (!$this->io->hasAuthentication($this->originUrl)
  28947. && $bitbucketUtil->authorizeOAuth($this->originUrl)
  28948. ) {
  28949. return parent::getContents($url);
  28950. }
  28951. if (!$this->io->isInteractive() && $fetchingRepoData) {
  28952. $this->attemptCloneFallback();
  28953. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  28954. }
  28955. }
  28956. throw $e;
  28957. }
  28958. }
  28959. protected function generateSshUrl(): string
  28960. {
  28961. return 'git@' . $this->originUrl . ':' . $this->owner.'/'.$this->repository.'.git';
  28962. }
  28963. protected function attemptCloneFallback(): bool
  28964. {
  28965. try {
  28966. $this->setupFallbackDriver($this->generateSshUrl());
  28967. return true;
  28968. } catch (\RuntimeException $e) {
  28969. $this->fallbackDriver = null;
  28970. $this->io->writeError(
  28971. '<error>Failed to clone the ' . $this->generateSshUrl() . ' repository, try running in interactive mode'
  28972. . ' so that you can enter your Bitbucket OAuth consumer credentials</error>'
  28973. );
  28974. throw $e;
  28975. }
  28976. }
  28977. protected function setupFallbackDriver(string $url): void
  28978. {
  28979. $this->fallbackDriver = new GitDriver(
  28980. array('url' => $url),
  28981. $this->io,
  28982. $this->config,
  28983. $this->httpDownloader,
  28984. $this->process
  28985. );
  28986. $this->fallbackDriver->initialize();
  28987. }
  28988. protected function parseCloneUrls(array $cloneLinks): void
  28989. {
  28990. foreach ($cloneLinks as $cloneLink) {
  28991. if ($cloneLink['name'] === 'https') {
  28992. $this->cloneHttpsUrl = Preg::replace('/https:\/\/([^@]+@)?/', 'https://', $cloneLink['href']);
  28993. }
  28994. }
  28995. }
  28996. protected function getMainBranchData(): ?array
  28997. {
  28998. $resource = sprintf(
  28999. 'https://api.bitbucket.org/2.0/repositories/%s/%s?fields=mainbranch',
  29000. $this->owner,
  29001. $this->repository
  29002. );
  29003. $data = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  29004. if (isset($data['mainbranch'])) {
  29005. return $data['mainbranch'];
  29006. }
  29007. return null;
  29008. }
  29009. public function getRootIdentifier(): string
  29010. {
  29011. if ($this->fallbackDriver) {
  29012. return $this->fallbackDriver->getRootIdentifier();
  29013. }
  29014. if (null === $this->rootIdentifier) {
  29015. if (!$this->getRepoData()) {
  29016. if (!$this->fallbackDriver) {
  29017. throw new \LogicException('A fallback driver should be setup if getRepoData returns false');
  29018. }
  29019. return $this->fallbackDriver->getRootIdentifier();
  29020. }
  29021. if ($this->vcsType !== 'git') {
  29022. throw new \RuntimeException(
  29023. $this->url.' does not appear to be a git repository, use '.
  29024. $this->cloneHttpsUrl.' but remember that Bitbucket no longer supports the mercurial repositories. '.
  29025. 'https://bitbucket.org/blog/sunsetting-mercurial-support-in-bitbucket'
  29026. );
  29027. }
  29028. $mainBranchData = $this->getMainBranchData();
  29029. $this->rootIdentifier = !empty($mainBranchData['name']) ? $mainBranchData['name'] : 'master';
  29030. }
  29031. return $this->rootIdentifier;
  29032. }
  29033. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
  29034. {
  29035. if (!Preg::isMatch('#^https?://bitbucket\.org/([^/]+)/([^/]+?)(\.git|/?)?$#i', $url)) {
  29036. return false;
  29037. }
  29038. if (!extension_loaded('openssl')) {
  29039. $io->writeError('Skipping Bitbucket git driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  29040. return false;
  29041. }
  29042. return true;
  29043. }
  29044. }
  29045. <?php declare(strict_types=1);
  29046. namespace Composer\Repository\Vcs;
  29047. use Composer\Pcre\Preg;
  29048. use Composer\Util\Platform;
  29049. use Composer\Util\ProcessExecutor;
  29050. use Composer\Util\Filesystem;
  29051. use Composer\Util\Url;
  29052. use Composer\Util\Git as GitUtil;
  29053. use Composer\IO\IOInterface;
  29054. use Composer\Cache;
  29055. use Composer\Config;
  29056. class GitDriver extends VcsDriver
  29057. {
  29058. protected $tags;
  29059. protected $branches;
  29060. protected $rootIdentifier;
  29061. protected $repoDir;
  29062. public function initialize(): void
  29063. {
  29064. if (Filesystem::isLocalPath($this->url)) {
  29065. $this->url = Preg::replace('{[\\/]\.git/?$}', '', $this->url);
  29066. if (!is_dir($this->url)) {
  29067. throw new \RuntimeException('Failed to read package information from '.$this->url.' as the path does not exist');
  29068. }
  29069. $this->repoDir = $this->url;
  29070. $cacheUrl = realpath($this->url);
  29071. } else {
  29072. if (!Cache::isUsable((string) $this->config->get('cache-vcs-dir'))) {
  29073. throw new \RuntimeException('GitDriver requires a usable cache directory, and it looks like you set it to be disabled');
  29074. }
  29075. $this->repoDir = $this->config->get('cache-vcs-dir') . '/' . Preg::replace('{[^a-z0-9.]}i', '-', $this->url) . '/';
  29076. GitUtil::cleanEnv();
  29077. $fs = new Filesystem();
  29078. $fs->ensureDirectoryExists(dirname($this->repoDir));
  29079. if (!is_writable(dirname($this->repoDir))) {
  29080. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.dirname($this->repoDir).'" directory is not writable by the current user.');
  29081. }
  29082. if (Preg::isMatch('{^ssh://[^@]+@[^:]+:[^0-9]+}', $this->url)) {
  29083. throw new \InvalidArgumentException('The source URL '.$this->url.' is invalid, ssh URLs should have a port number after ":".'."\n".'Use ssh://git@example.com:22/path or just git@example.com:path if you do not want to provide a password or custom port.');
  29084. }
  29085. $gitUtil = new GitUtil($this->io, $this->config, $this->process, $fs);
  29086. if (!$gitUtil->syncMirror($this->url, $this->repoDir)) {
  29087. if (!is_dir($this->repoDir)) {
  29088. throw new \RuntimeException('Failed to clone '.$this->url.' to read package information from it');
  29089. }
  29090. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated</error>');
  29091. }
  29092. $cacheUrl = $this->url;
  29093. }
  29094. $this->getTags();
  29095. $this->getBranches();
  29096. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', Url::sanitize($cacheUrl)));
  29097. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  29098. }
  29099. public function getRootIdentifier(): string
  29100. {
  29101. if (null === $this->rootIdentifier) {
  29102. $this->rootIdentifier = 'master';
  29103. $gitUtil = new GitUtil($this->io, $this->config, $this->process, new Filesystem());
  29104. $defaultBranch = $gitUtil->getMirrorDefaultBranch($this->url, $this->repoDir, Filesystem::isLocalPath($this->url));
  29105. if ($defaultBranch !== null) {
  29106. return $this->rootIdentifier = $defaultBranch;
  29107. }
  29108. $this->process->execute('git branch --no-color', $output, $this->repoDir);
  29109. $branches = $this->process->splitLines($output);
  29110. if (!in_array('* master', $branches)) {
  29111. foreach ($branches as $branch) {
  29112. if ($branch && Preg::isMatch('{^\* +(\S+)}', $branch, $match)) {
  29113. $this->rootIdentifier = $match[1];
  29114. break;
  29115. }
  29116. }
  29117. }
  29118. }
  29119. return $this->rootIdentifier;
  29120. }
  29121. public function getUrl(): string
  29122. {
  29123. return $this->url;
  29124. }
  29125. public function getSource(string $identifier): array
  29126. {
  29127. return array('type' => 'git', 'url' => $this->getUrl(), 'reference' => $identifier);
  29128. }
  29129. public function getDist(string $identifier): ?array
  29130. {
  29131. return null;
  29132. }
  29133. public function getFileContent(string $file, string $identifier): ?string
  29134. {
  29135. if (isset($identifier[0]) && $identifier[0] === '-') {
  29136. throw new \RuntimeException('Invalid git identifier detected. Identifier must not start with a -, given: ' . $identifier);
  29137. }
  29138. $resource = sprintf('%s:%s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  29139. $this->process->execute(sprintf('git show %s', $resource), $content, $this->repoDir);
  29140. if (!trim($content)) {
  29141. return null;
  29142. }
  29143. return $content;
  29144. }
  29145. public function getChangeDate(string $identifier): ?\DateTimeImmutable
  29146. {
  29147. $this->process->execute(sprintf(
  29148. 'git -c log.showSignature=false log -1 --format=%%at %s',
  29149. ProcessExecutor::escape($identifier)
  29150. ), $output, $this->repoDir);
  29151. return new \DateTimeImmutable('@'.trim($output), new \DateTimeZone('UTC'));
  29152. }
  29153. public function getTags(): array
  29154. {
  29155. if (null === $this->tags) {
  29156. $this->tags = array();
  29157. $this->process->execute('git show-ref --tags --dereference', $output, $this->repoDir);
  29158. foreach ($output = $this->process->splitLines($output) as $tag) {
  29159. if ($tag && Preg::isMatch('{^([a-f0-9]{40}) refs/tags/(\S+?)(\^\{\})?$}', $tag, $match)) {
  29160. $this->tags[$match[2]] = (string) $match[1];
  29161. }
  29162. }
  29163. }
  29164. return $this->tags;
  29165. }
  29166. public function getBranches(): array
  29167. {
  29168. if (null === $this->branches) {
  29169. $branches = array();
  29170. $this->process->execute('git branch --no-color --no-abbrev -v', $output, $this->repoDir);
  29171. foreach ($this->process->splitLines($output) as $branch) {
  29172. if ($branch && !Preg::isMatch('{^ *[^/]+/HEAD }', $branch)) {
  29173. if (Preg::isMatch('{^(?:\* )? *(\S+) *([a-f0-9]+)(?: .*)?$}', $branch, $match) && $match[1][0] !== '-') {
  29174. $branches[$match[1]] = $match[2];
  29175. }
  29176. }
  29177. }
  29178. $this->branches = $branches;
  29179. }
  29180. return $this->branches;
  29181. }
  29182. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
  29183. {
  29184. if (Preg::isMatch('#(^git://|\.git/?$|git(?:olite)?@|//git\.|//github.com/)#i', $url)) {
  29185. return true;
  29186. }
  29187. if (Filesystem::isLocalPath($url)) {
  29188. $url = Filesystem::getPlatformPath($url);
  29189. if (!is_dir($url)) {
  29190. return false;
  29191. }
  29192. $process = new ProcessExecutor($io);
  29193. if ($process->execute('git tag', $output, $url) === 0) {
  29194. return true;
  29195. }
  29196. }
  29197. if (!$deep) {
  29198. return false;
  29199. }
  29200. $gitUtil = new GitUtil($io, $config, new ProcessExecutor($io), new Filesystem());
  29201. GitUtil::cleanEnv();
  29202. try {
  29203. $gitUtil->runCommand(function ($url): string {
  29204. return 'git ls-remote --heads -- ' . ProcessExecutor::escape($url);
  29205. }, $url, sys_get_temp_dir());
  29206. } catch (\RuntimeException $e) {
  29207. return false;
  29208. }
  29209. return true;
  29210. }
  29211. }
  29212. <?php declare(strict_types=1);
  29213. namespace Composer\Repository\Vcs;
  29214. use Composer\Config;
  29215. use Composer\Downloader\TransportException;
  29216. use Composer\Json\JsonFile;
  29217. use Composer\Cache;
  29218. use Composer\IO\IOInterface;
  29219. use Composer\Pcre\Preg;
  29220. use Composer\Util\GitHub;
  29221. use Composer\Util\Http\Response;
  29222. class GitHubDriver extends VcsDriver
  29223. {
  29224. protected $owner;
  29225. protected $repository;
  29226. protected $tags;
  29227. protected $branches;
  29228. protected $rootIdentifier;
  29229. protected $repoData;
  29230. protected $hasIssues = false;
  29231. protected $isPrivate = false;
  29232. private $isArchived = false;
  29233. private $fundingInfo;
  29234. protected $gitDriver = null;
  29235. public function initialize(): void
  29236. {
  29237. if (!Preg::isMatch('#^(?:(?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/(.+?)(?:\.git|/)?$#', $this->url, $match)) {
  29238. throw new \InvalidArgumentException(sprintf('The GitHub repository URL %s is invalid.', $this->url));
  29239. }
  29240. $this->owner = $match[3];
  29241. $this->repository = $match[4];
  29242. $this->originUrl = strtolower(!empty($match[1]) ? $match[1] : $match[2]);
  29243. if ($this->originUrl === 'www.github.com') {
  29244. $this->originUrl = 'github.com';
  29245. }
  29246. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->owner.'/'.$this->repository);
  29247. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  29248. if ($this->config->get('use-github-api') === false || (isset($this->repoConfig['no-api']) && $this->repoConfig['no-api'])) {
  29249. $this->setupGitDriver($this->url);
  29250. return;
  29251. }
  29252. $this->fetchRootIdentifier();
  29253. }
  29254. public function getRepositoryUrl(): string
  29255. {
  29256. return 'https://'.$this->originUrl.'/'.$this->owner.'/'.$this->repository;
  29257. }
  29258. public function getRootIdentifier(): string
  29259. {
  29260. if ($this->gitDriver) {
  29261. return $this->gitDriver->getRootIdentifier();
  29262. }
  29263. return $this->rootIdentifier;
  29264. }
  29265. public function getUrl(): string
  29266. {
  29267. if ($this->gitDriver) {
  29268. return $this->gitDriver->getUrl();
  29269. }
  29270. return 'https://' . $this->originUrl . '/'.$this->owner.'/'.$this->repository.'.git';
  29271. }
  29272. protected function getApiUrl(): string
  29273. {
  29274. if ('github.com' === $this->originUrl) {
  29275. $apiUrl = 'api.github.com';
  29276. } else {
  29277. $apiUrl = $this->originUrl . '/api/v3';
  29278. }
  29279. return 'https://' . $apiUrl;
  29280. }
  29281. public function getSource(string $identifier): array
  29282. {
  29283. if ($this->gitDriver) {
  29284. return $this->gitDriver->getSource($identifier);
  29285. }
  29286. if ($this->isPrivate) {
  29287. $url = $this->generateSshUrl();
  29288. } else {
  29289. $url = $this->getUrl();
  29290. }
  29291. return array('type' => 'git', 'url' => $url, 'reference' => $identifier);
  29292. }
  29293. public function getDist(string $identifier): ?array
  29294. {
  29295. $url = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/zipball/'.$identifier;
  29296. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  29297. }
  29298. public function getComposerInformation(string $identifier): ?array
  29299. {
  29300. if ($this->gitDriver) {
  29301. return $this->gitDriver->getComposerInformation($identifier);
  29302. }
  29303. if (!isset($this->infoCache[$identifier])) {
  29304. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  29305. $composer = JsonFile::parseJson($res);
  29306. } else {
  29307. $composer = $this->getBaseComposerInformation($identifier);
  29308. if ($this->shouldCache($identifier)) {
  29309. $this->cache->write($identifier, json_encode($composer));
  29310. }
  29311. }
  29312. if ($composer !== null) {
  29313. if (!isset($composer['support']['source'])) {
  29314. $label = array_search($identifier, $this->getTags()) ?: array_search($identifier, $this->getBranches()) ?: $identifier;
  29315. $composer['support']['source'] = sprintf('https://%s/%s/%s/tree/%s', $this->originUrl, $this->owner, $this->repository, $label);
  29316. }
  29317. if (!isset($composer['support']['issues']) && $this->hasIssues) {
  29318. $composer['support']['issues'] = sprintf('https://%s/%s/%s/issues', $this->originUrl, $this->owner, $this->repository);
  29319. }
  29320. if (!isset($composer['abandoned']) && $this->isArchived) {
  29321. $composer['abandoned'] = true;
  29322. }
  29323. if (!isset($composer['funding']) && $funding = $this->getFundingInfo()) {
  29324. $composer['funding'] = $funding;
  29325. }
  29326. }
  29327. $this->infoCache[$identifier] = $composer;
  29328. }
  29329. return $this->infoCache[$identifier];
  29330. }
  29331. private function getFundingInfo()
  29332. {
  29333. if (null !== $this->fundingInfo) {
  29334. return $this->fundingInfo;
  29335. }
  29336. if ($this->originUrl !== 'github.com') {
  29337. return $this->fundingInfo = false;
  29338. }
  29339. foreach (array($this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/.github/FUNDING.yml', $this->getApiUrl() . '/repos/'.$this->owner.'/.github/contents/FUNDING.yml') as $file) {
  29340. try {
  29341. $response = $this->httpDownloader->get($file, array(
  29342. 'retry-auth-failure' => false,
  29343. ))->decodeJson();
  29344. } catch (TransportException $e) {
  29345. continue;
  29346. }
  29347. if (empty($response['content']) || $response['encoding'] !== 'base64' || !($funding = base64_decode($response['content']))) {
  29348. continue;
  29349. }
  29350. break;
  29351. }
  29352. if (empty($funding)) {
  29353. return $this->fundingInfo = false;
  29354. }
  29355. $result = array();
  29356. $key = null;
  29357. foreach (Preg::split('{\r?\n}', $funding) as $line) {
  29358. $line = trim($line);
  29359. if (Preg::isMatch('{^(\w+)\s*:\s*(.+)$}', $line, $match)) {
  29360. if (Preg::isMatch('{^\[(.*)\](?:\s*#.*)?$}', $match[2], $match2)) {
  29361. foreach (array_map('trim', Preg::split('{[\'"]?\s*,\s*[\'"]?}', $match2[1])) as $item) {
  29362. $result[] = array('type' => $match[1], 'url' => trim($item, '"\' '));
  29363. }
  29364. } elseif (Preg::isMatch('{^([^#].*?)(\s+#.*)?$}', $match[2], $match2)) {
  29365. $result[] = array('type' => $match[1], 'url' => trim($match2[1], '"\' '));
  29366. }
  29367. $key = null;
  29368. } elseif (Preg::isMatch('{^(\w+)\s*:\s*#\s*$}', $line, $match)) {
  29369. $key = $match[1];
  29370. } elseif ($key && Preg::isMatch('{^-\s*(.+)(\s+#.*)?$}', $line, $match)) {
  29371. $result[] = array('type' => $key, 'url' => trim($match[1], '"\' '));
  29372. }
  29373. }
  29374. foreach ($result as $key => $item) {
  29375. switch ($item['type']) {
  29376. case 'tidelift':
  29377. $result[$key]['url'] = 'https://tidelift.com/funding/github/' . $item['url'];
  29378. break;
  29379. case 'github':
  29380. $result[$key]['url'] = 'https://github.com/' . basename($item['url']);
  29381. break;
  29382. case 'patreon':
  29383. $result[$key]['url'] = 'https://www.patreon.com/' . basename($item['url']);
  29384. break;
  29385. case 'otechie':
  29386. $result[$key]['url'] = 'https://otechie.com/' . basename($item['url']);
  29387. break;
  29388. case 'open_collective':
  29389. $result[$key]['url'] = 'https://opencollective.com/' . basename($item['url']);
  29390. break;
  29391. case 'liberapay':
  29392. $result[$key]['url'] = 'https://liberapay.com/' . basename($item['url']);
  29393. break;
  29394. case 'ko_fi':
  29395. $result[$key]['url'] = 'https://ko-fi.com/' . basename($item['url']);
  29396. break;
  29397. case 'issuehunt':
  29398. $result[$key]['url'] = 'https://issuehunt.io/r/' . $item['url'];
  29399. break;
  29400. case 'community_bridge':
  29401. $result[$key]['url'] = 'https://funding.communitybridge.org/projects/' . basename($item['url']);
  29402. break;
  29403. }
  29404. }
  29405. return $this->fundingInfo = $result;
  29406. }
  29407. public function getFileContent(string $file, string $identifier): ?string
  29408. {
  29409. if ($this->gitDriver) {
  29410. return $this->gitDriver->getFileContent($file, $identifier);
  29411. }
  29412. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/' . $file . '?ref='.urlencode($identifier);
  29413. $resource = $this->getContents($resource)->decodeJson();
  29414. if (empty($resource['content']) || $resource['encoding'] !== 'base64' || !($content = base64_decode($resource['content']))) {
  29415. throw new \RuntimeException('Could not retrieve ' . $file . ' for '.$identifier);
  29416. }
  29417. return $content;
  29418. }
  29419. public function getChangeDate(string $identifier): ?\DateTimeImmutable
  29420. {
  29421. if ($this->gitDriver) {
  29422. return $this->gitDriver->getChangeDate($identifier);
  29423. }
  29424. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/commits/'.urlencode($identifier);
  29425. $commit = $this->getContents($resource)->decodeJson();
  29426. return new \DateTimeImmutable($commit['commit']['committer']['date']);
  29427. }
  29428. public function getTags(): array
  29429. {
  29430. if ($this->gitDriver) {
  29431. return $this->gitDriver->getTags();
  29432. }
  29433. if (null === $this->tags) {
  29434. $tags = array();
  29435. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/tags?per_page=100';
  29436. do {
  29437. $response = $this->getContents($resource);
  29438. $tagsData = $response->decodeJson();
  29439. foreach ($tagsData as $tag) {
  29440. $tags[$tag['name']] = $tag['commit']['sha'];
  29441. }
  29442. $resource = $this->getNextPage($response);
  29443. } while ($resource);
  29444. $this->tags = $tags;
  29445. }
  29446. return $this->tags;
  29447. }
  29448. public function getBranches(): array
  29449. {
  29450. if ($this->gitDriver) {
  29451. return $this->gitDriver->getBranches();
  29452. }
  29453. if (null === $this->branches) {
  29454. $branches = array();
  29455. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/git/refs/heads?per_page=100';
  29456. do {
  29457. $response = $this->getContents($resource);
  29458. $branchData = $response->decodeJson();
  29459. foreach ($branchData as $branch) {
  29460. $name = substr($branch['ref'], 11);
  29461. if ($name !== 'gh-pages') {
  29462. $branches[$name] = $branch['object']['sha'];
  29463. }
  29464. }
  29465. $resource = $this->getNextPage($response);
  29466. } while ($resource);
  29467. $this->branches = $branches;
  29468. }
  29469. return $this->branches;
  29470. }
  29471. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
  29472. {
  29473. if (!Preg::isMatch('#^((?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/(.+?)(?:\.git|/)?$#', $url, $matches)) {
  29474. return false;
  29475. }
  29476. $originUrl = !empty($matches[2]) ? $matches[2] : $matches[3];
  29477. if (!in_array(strtolower(Preg::replace('{^www\.}i', '', $originUrl)), $config->get('github-domains'))) {
  29478. return false;
  29479. }
  29480. if (!extension_loaded('openssl')) {
  29481. $io->writeError('Skipping GitHub driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  29482. return false;
  29483. }
  29484. return true;
  29485. }
  29486. public function getRepoData(): ?array
  29487. {
  29488. $this->fetchRootIdentifier();
  29489. return $this->repoData;
  29490. }
  29491. protected function generateSshUrl(): string
  29492. {
  29493. if (false !== strpos($this->originUrl, ':')) {
  29494. return 'ssh://git@' . $this->originUrl . '/'.$this->owner.'/'.$this->repository.'.git';
  29495. }
  29496. return 'git@' . $this->originUrl . ':'.$this->owner.'/'.$this->repository.'.git';
  29497. }
  29498. protected function getContents(string $url, bool $fetchingRepoData = false): Response
  29499. {
  29500. try {
  29501. return parent::getContents($url);
  29502. } catch (TransportException $e) {
  29503. $gitHubUtil = new GitHub($this->io, $this->config, $this->process, $this->httpDownloader);
  29504. switch ($e->getCode()) {
  29505. case 401:
  29506. case 404:
  29507. if (!$fetchingRepoData) {
  29508. throw $e;
  29509. }
  29510. if ($gitHubUtil->authorizeOAuth($this->originUrl)) {
  29511. return parent::getContents($url);
  29512. }
  29513. if (!$this->io->isInteractive()) {
  29514. $this->attemptCloneFallback();
  29515. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  29516. }
  29517. $scopesIssued = array();
  29518. $scopesNeeded = array();
  29519. if ($headers = $e->getHeaders()) {
  29520. if ($scopes = Response::findHeaderValue($headers, 'X-OAuth-Scopes')) {
  29521. $scopesIssued = explode(' ', $scopes);
  29522. }
  29523. if ($scopes = Response::findHeaderValue($headers, 'X-Accepted-OAuth-Scopes')) {
  29524. $scopesNeeded = explode(' ', $scopes);
  29525. }
  29526. }
  29527. $scopesFailed = array_diff($scopesNeeded, $scopesIssued);
  29528. if (!$headers || !count($scopesNeeded) || count($scopesFailed)) {
  29529. $gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'Your GitHub credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
  29530. }
  29531. return parent::getContents($url);
  29532. case 403:
  29533. if (!$this->io->hasAuthentication($this->originUrl) && $gitHubUtil->authorizeOAuth($this->originUrl)) {
  29534. return parent::getContents($url);
  29535. }
  29536. if (!$this->io->isInteractive() && $fetchingRepoData) {
  29537. $this->attemptCloneFallback();
  29538. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  29539. }
  29540. $rateLimited = $gitHubUtil->isRateLimited((array) $e->getHeaders());
  29541. if (!$this->io->hasAuthentication($this->originUrl)) {
  29542. if (!$this->io->isInteractive()) {
  29543. $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>');
  29544. throw $e;
  29545. }
  29546. $gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'API limit exhausted. Enter your GitHub credentials to get a larger API limit (<info>'.$this->url.'</info>)');
  29547. return parent::getContents($url);
  29548. }
  29549. if ($rateLimited) {
  29550. $rateLimit = $gitHubUtil->getRateLimit($e->getHeaders());
  29551. $this->io->writeError(sprintf(
  29552. '<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>',
  29553. $rateLimit['limit'],
  29554. $rateLimit['reset']
  29555. ));
  29556. }
  29557. throw $e;
  29558. default:
  29559. throw $e;
  29560. }
  29561. }
  29562. }
  29563. protected function fetchRootIdentifier(): void
  29564. {
  29565. if ($this->repoData) {
  29566. return;
  29567. }
  29568. $repoDataUrl = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository;
  29569. try {
  29570. $this->repoData = $this->getContents($repoDataUrl, true)->decodeJson();
  29571. } catch (TransportException $e) {
  29572. if ($e->getCode() === 499) {
  29573. $this->attemptCloneFallback();
  29574. } else {
  29575. throw $e;
  29576. }
  29577. }
  29578. if (null === $this->repoData && null !== $this->gitDriver) {
  29579. return;
  29580. }
  29581. $this->owner = $this->repoData['owner']['login'];
  29582. $this->repository = $this->repoData['name'];
  29583. $this->isPrivate = !empty($this->repoData['private']);
  29584. if (isset($this->repoData['default_branch'])) {
  29585. $this->rootIdentifier = $this->repoData['default_branch'];
  29586. } elseif (isset($this->repoData['master_branch'])) {
  29587. $this->rootIdentifier = $this->repoData['master_branch'];
  29588. } else {
  29589. $this->rootIdentifier = 'master';
  29590. }
  29591. $this->hasIssues = !empty($this->repoData['has_issues']);
  29592. $this->isArchived = !empty($this->repoData['archived']);
  29593. }
  29594. protected function attemptCloneFallback(): bool
  29595. {
  29596. $this->isPrivate = true;
  29597. try {
  29598. $this->setupGitDriver($this->generateSshUrl());
  29599. return true;
  29600. } catch (\RuntimeException $e) {
  29601. $this->gitDriver = null;
  29602. $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>');
  29603. throw $e;
  29604. }
  29605. }
  29606. protected function setupGitDriver(string $url): void
  29607. {
  29608. $this->gitDriver = new GitDriver(
  29609. array('url' => $url),
  29610. $this->io,
  29611. $this->config,
  29612. $this->httpDownloader,
  29613. $this->process
  29614. );
  29615. $this->gitDriver->initialize();
  29616. }
  29617. protected function getNextPage(Response $response): ?string
  29618. {
  29619. $header = $response->getHeader('link');
  29620. if (!$header) {
  29621. return null;
  29622. }
  29623. $links = explode(',', $header);
  29624. foreach ($links as $link) {
  29625. if (Preg::isMatch('{<(.+?)>; *rel="next"}', $link, $match)) {
  29626. return $match[1];
  29627. }
  29628. }
  29629. return null;
  29630. }
  29631. }
  29632. <?php declare(strict_types=1);
  29633. namespace Composer\Repository\Vcs;
  29634. use Composer\Config;
  29635. use Composer\Cache;
  29636. use Composer\IO\IOInterface;
  29637. use Composer\Json\JsonFile;
  29638. use Composer\Downloader\TransportException;
  29639. use Composer\Pcre\Preg;
  29640. use Composer\Util\HttpDownloader;
  29641. use Composer\Util\GitLab;
  29642. use Composer\Util\Http\Response;
  29643. class GitLabDriver extends VcsDriver
  29644. {
  29645. private $scheme;
  29646. private $namespace;
  29647. private $repository;
  29648. private $project;
  29649. private $commits = array();
  29650. private $tags;
  29651. private $branches;
  29652. protected $gitDriver = null;
  29653. protected $protocol;
  29654. private $isPrivate = true;
  29655. private $hasNonstandardOrigin = false;
  29656. public const URL_REGEX = '#^(?:(?P<scheme>https?)://(?P<domain>.+?)(?::(?P<port>[0-9]+))?/|git@(?P<domain2>[^:]+):)(?P<parts>.+)/(?P<repo>[^/]+?)(?:\.git|/)?$#';
  29657. public function initialize(): void
  29658. {
  29659. if (!Preg::isMatch(self::URL_REGEX, $this->url, $match)) {
  29660. throw new \InvalidArgumentException(sprintf('The GitLab repository URL %s is invalid. It must be the HTTP URL of a GitLab project.', $this->url));
  29661. }
  29662. $guessedDomain = !empty($match['domain']) ? $match['domain'] : $match['domain2'];
  29663. $configuredDomains = $this->config->get('gitlab-domains');
  29664. $urlParts = explode('/', $match['parts']);
  29665. $this->scheme = !empty($match['scheme'])
  29666. ? $match['scheme']
  29667. : (isset($this->repoConfig['secure-http']) && $this->repoConfig['secure-http'] === false ? 'http' : 'https')
  29668. ;
  29669. $origin = self::determineOrigin($configuredDomains, $guessedDomain, $urlParts, $match['port']);
  29670. if (false === $origin) {
  29671. throw new \LogicException('It should not be possible to create a gitlab driver with an unparseable origin URL ('.$this->url.')');
  29672. }
  29673. $this->originUrl = $origin;
  29674. if ($protocol = $this->config->get('gitlab-protocol')) {
  29675. if (!in_array($protocol, array('git', 'http', 'https'))) {
  29676. throw new \RuntimeException('gitlab-protocol must be one of git, http.');
  29677. }
  29678. $this->protocol = $protocol === 'git' ? 'ssh' : 'http';
  29679. }
  29680. if (false !== strpos($this->originUrl, ':') || false !== strpos($this->originUrl, '/')) {
  29681. $this->hasNonstandardOrigin = true;
  29682. }
  29683. $this->namespace = implode('/', $urlParts);
  29684. $this->repository = Preg::replace('#(\.git)$#', '', $match['repo']);
  29685. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->namespace.'/'.$this->repository);
  29686. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  29687. $this->fetchProject();
  29688. }
  29689. public function setHttpDownloader(HttpDownloader $httpDownloader): void
  29690. {
  29691. $this->httpDownloader = $httpDownloader;
  29692. }
  29693. public function getComposerInformation(string $identifier): ?array
  29694. {
  29695. if ($this->gitDriver) {
  29696. return $this->gitDriver->getComposerInformation($identifier);
  29697. }
  29698. if (!isset($this->infoCache[$identifier])) {
  29699. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  29700. $composer = JsonFile::parseJson($res);
  29701. } else {
  29702. $composer = $this->getBaseComposerInformation($identifier);
  29703. if ($this->shouldCache($identifier)) {
  29704. $this->cache->write($identifier, json_encode($composer));
  29705. }
  29706. }
  29707. if (null !== $composer) {
  29708. if (!isset($composer['support']['source']) && isset($this->project['web_url'])) {
  29709. $label = array_search($identifier, $this->getTags(), true) ?: array_search($identifier, $this->getBranches(), true) ?: $identifier;
  29710. $composer['support']['source'] = sprintf('%s/-/tree/%s', $this->project['web_url'], $label);
  29711. }
  29712. if (!isset($composer['support']['issues']) && !empty($this->project['issues_enabled']) && isset($this->project['web_url'])) {
  29713. $composer['support']['issues'] = sprintf('%s/-/issues', $this->project['web_url']);
  29714. }
  29715. if (!isset($composer['abandoned']) && !empty($this->project['archived'])) {
  29716. $composer['abandoned'] = true;
  29717. }
  29718. }
  29719. $this->infoCache[$identifier] = $composer;
  29720. }
  29721. return $this->infoCache[$identifier];
  29722. }
  29723. public function getFileContent(string $file, string $identifier): ?string
  29724. {
  29725. if ($this->gitDriver) {
  29726. return $this->gitDriver->getFileContent($file, $identifier);
  29727. }
  29728. if (!Preg::isMatch('{[a-f0-9]{40}}i', $identifier)) {
  29729. $branches = $this->getBranches();
  29730. if (isset($branches[$identifier])) {
  29731. $identifier = $branches[$identifier];
  29732. }
  29733. }
  29734. $resource = $this->getApiUrl().'/repository/files/'.$this->urlEncodeAll($file).'/raw?ref='.$identifier;
  29735. try {
  29736. $content = $this->getContents($resource)->getBody();
  29737. } catch (TransportException $e) {
  29738. if ($e->getCode() !== 404) {
  29739. throw $e;
  29740. }
  29741. return null;
  29742. }
  29743. return $content;
  29744. }
  29745. public function getChangeDate(string $identifier): ?\DateTimeImmutable
  29746. {
  29747. if ($this->gitDriver) {
  29748. return $this->gitDriver->getChangeDate($identifier);
  29749. }
  29750. if (isset($this->commits[$identifier])) {
  29751. return new \DateTimeImmutable($this->commits[$identifier]['committed_date']);
  29752. }
  29753. return null;
  29754. }
  29755. public function getRepositoryUrl(): string
  29756. {
  29757. if ($this->protocol) {
  29758. return $this->project["{$this->protocol}_url_to_repo"];
  29759. }
  29760. return $this->isPrivate ? $this->project['ssh_url_to_repo'] : $this->project['http_url_to_repo'];
  29761. }
  29762. public function getUrl(): string
  29763. {
  29764. if ($this->gitDriver) {
  29765. return $this->gitDriver->getUrl();
  29766. }
  29767. return $this->project['web_url'];
  29768. }
  29769. public function getDist(string $identifier): ?array
  29770. {
  29771. $url = $this->getApiUrl().'/repository/archive.zip?sha='.$identifier;
  29772. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  29773. }
  29774. public function getSource(string $identifier): array
  29775. {
  29776. if ($this->gitDriver) {
  29777. return $this->gitDriver->getSource($identifier);
  29778. }
  29779. return array('type' => 'git', 'url' => $this->getRepositoryUrl(), 'reference' => $identifier);
  29780. }
  29781. public function getRootIdentifier(): string
  29782. {
  29783. if ($this->gitDriver) {
  29784. return $this->gitDriver->getRootIdentifier();
  29785. }
  29786. return $this->project['default_branch'];
  29787. }
  29788. public function getBranches(): array
  29789. {
  29790. if ($this->gitDriver) {
  29791. return $this->gitDriver->getBranches();
  29792. }
  29793. if (null === $this->branches) {
  29794. $this->branches = $this->getReferences('branches');
  29795. }
  29796. return $this->branches;
  29797. }
  29798. public function getTags(): array
  29799. {
  29800. if ($this->gitDriver) {
  29801. return $this->gitDriver->getTags();
  29802. }
  29803. if (null === $this->tags) {
  29804. $this->tags = $this->getReferences('tags');
  29805. }
  29806. return $this->tags;
  29807. }
  29808. public function getApiUrl(): string
  29809. {
  29810. return $this->scheme.'://'.$this->originUrl.'/api/v4/projects/'.$this->urlEncodeAll($this->namespace).'%2F'.$this->urlEncodeAll($this->repository);
  29811. }
  29812. private function urlEncodeAll(string $string): string
  29813. {
  29814. $encoded = '';
  29815. for ($i = 0; isset($string[$i]); $i++) {
  29816. $character = $string[$i];
  29817. if (!ctype_alnum($character) && !in_array($character, array('-', '_'), true)) {
  29818. $character = '%' . sprintf('%02X', ord($character));
  29819. }
  29820. $encoded .= $character;
  29821. }
  29822. return $encoded;
  29823. }
  29824. protected function getReferences(string $type): array
  29825. {
  29826. $perPage = 100;
  29827. $resource = $this->getApiUrl().'/repository/'.$type.'?per_page='.$perPage;
  29828. $references = array();
  29829. do {
  29830. $response = $this->getContents($resource);
  29831. $data = $response->decodeJson();
  29832. foreach ($data as $datum) {
  29833. $references[$datum['name']] = $datum['commit']['id'];
  29834. $this->commits[$datum['commit']['id']] = $datum['commit'];
  29835. }
  29836. if (count($data) >= $perPage) {
  29837. $resource = $this->getNextPage($response);
  29838. } else {
  29839. $resource = false;
  29840. }
  29841. } while ($resource);
  29842. return $references;
  29843. }
  29844. protected function fetchProject(): void
  29845. {
  29846. $resource = $this->getApiUrl();
  29847. $this->project = $this->getContents($resource, true)->decodeJson();
  29848. if (isset($this->project['visibility'])) {
  29849. $this->isPrivate = $this->project['visibility'] !== 'public';
  29850. } else {
  29851. $this->isPrivate = false;
  29852. }
  29853. }
  29854. protected function attemptCloneFallback(): bool
  29855. {
  29856. if ($this->isPrivate === false) {
  29857. $url = $this->generatePublicUrl();
  29858. } else {
  29859. $url = $this->generateSshUrl();
  29860. }
  29861. try {
  29862. $this->setupGitDriver($url);
  29863. return true;
  29864. } catch (\RuntimeException $e) {
  29865. $this->gitDriver = null;
  29866. $this->io->writeError('<error>Failed to clone the '.$url.' repository, try running in interactive mode so that you can enter your credentials</error>');
  29867. throw $e;
  29868. }
  29869. }
  29870. protected function generateSshUrl(): string
  29871. {
  29872. if ($this->hasNonstandardOrigin) {
  29873. return 'ssh://git@'.$this->originUrl.'/'.$this->namespace.'/'.$this->repository.'.git';
  29874. }
  29875. return 'git@' . $this->originUrl . ':'.$this->namespace.'/'.$this->repository.'.git';
  29876. }
  29877. protected function generatePublicUrl(): string
  29878. {
  29879. return $this->scheme . '://' . $this->originUrl . '/'.$this->namespace.'/'.$this->repository.'.git';
  29880. }
  29881. protected function setupGitDriver(string $url): void
  29882. {
  29883. $this->gitDriver = new GitDriver(
  29884. array('url' => $url),
  29885. $this->io,
  29886. $this->config,
  29887. $this->httpDownloader,
  29888. $this->process
  29889. );
  29890. $this->gitDriver->initialize();
  29891. }
  29892. protected function getContents(string $url, bool $fetchingRepoData = false): Response
  29893. {
  29894. try {
  29895. $response = parent::getContents($url);
  29896. if ($fetchingRepoData) {
  29897. $json = $response->decodeJson();
  29898. if (!isset($json['default_branch']) && isset($json['permissions'])) {
  29899. $this->isPrivate = $json['visibility'] !== 'public';
  29900. $moreThanGuestAccess = false;
  29901. foreach ($json['permissions'] as $permission) {
  29902. if ($permission && $permission['access_level'] > 10) {
  29903. $moreThanGuestAccess = true;
  29904. }
  29905. }
  29906. if (!$moreThanGuestAccess) {
  29907. $this->io->writeError('<warning>GitLab token with Guest only access detected</warning>');
  29908. $this->attemptCloneFallback();
  29909. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  29910. }
  29911. }
  29912. if (!isset($json['default_branch'])) {
  29913. if (isset($json['repository_access_level']) && $json['repository_access_level'] === 'disabled') {
  29914. throw new TransportException('The GitLab repository is disabled in the project', 400);
  29915. }
  29916. if (!empty($json['id'])) {
  29917. $this->isPrivate = false;
  29918. }
  29919. throw new TransportException('GitLab API seems to not be authenticated as it did not return a default_branch', 401);
  29920. }
  29921. }
  29922. return $response;
  29923. } catch (TransportException $e) {
  29924. $gitLabUtil = new GitLab($this->io, $this->config, $this->process, $this->httpDownloader);
  29925. switch ($e->getCode()) {
  29926. case 401:
  29927. case 404:
  29928. if (!$fetchingRepoData) {
  29929. throw $e;
  29930. }
  29931. if ($gitLabUtil->authorizeOAuth($this->originUrl)) {
  29932. return parent::getContents($url);
  29933. }
  29934. if (!$this->io->isInteractive()) {
  29935. $this->attemptCloneFallback();
  29936. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  29937. }
  29938. $this->io->writeError('<warning>Failed to download ' . $this->namespace . '/' . $this->repository . ':' . $e->getMessage() . '</warning>');
  29939. $gitLabUtil->authorizeOAuthInteractively($this->scheme, $this->originUrl, 'Your credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
  29940. return parent::getContents($url);
  29941. case 403:
  29942. if (!$this->io->hasAuthentication($this->originUrl) && $gitLabUtil->authorizeOAuth($this->originUrl)) {
  29943. return parent::getContents($url);
  29944. }
  29945. if (!$this->io->isInteractive() && $fetchingRepoData) {
  29946. $this->attemptCloneFallback();
  29947. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  29948. }
  29949. throw $e;
  29950. default:
  29951. throw $e;
  29952. }
  29953. }
  29954. }
  29955. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
  29956. {
  29957. if (!Preg::isMatch(self::URL_REGEX, $url, $match)) {
  29958. return false;
  29959. }
  29960. $scheme = !empty($match['scheme']) ? $match['scheme'] : null;
  29961. $guessedDomain = !empty($match['domain']) ? $match['domain'] : $match['domain2'];
  29962. $urlParts = explode('/', $match['parts']);
  29963. if (false === self::determineOrigin((array) $config->get('gitlab-domains'), $guessedDomain, $urlParts, $match['port'])) {
  29964. return false;
  29965. }
  29966. if ('https' === $scheme && !extension_loaded('openssl')) {
  29967. $io->writeError('Skipping GitLab driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  29968. return false;
  29969. }
  29970. return true;
  29971. }
  29972. protected function getNextPage(Response $response): ?string
  29973. {
  29974. $header = $response->getHeader('link');
  29975. $links = explode(',', $header);
  29976. foreach ($links as $link) {
  29977. if (Preg::isMatch('{<(.+?)>; *rel="next"}', $link, $match)) {
  29978. return $match[1];
  29979. }
  29980. }
  29981. return null;
  29982. }
  29983. private static function determineOrigin(array $configuredDomains, string $guessedDomain, array &$urlParts, ?string $portNumber)
  29984. {
  29985. $guessedDomain = strtolower($guessedDomain);
  29986. if (in_array($guessedDomain, $configuredDomains) || (null !== $portNumber && in_array($guessedDomain.':'.$portNumber, $configuredDomains))) {
  29987. if (null !== $portNumber) {
  29988. return $guessedDomain.':'.$portNumber;
  29989. }
  29990. return $guessedDomain;
  29991. }
  29992. if (null !== $portNumber) {
  29993. $guessedDomain .= ':'.$portNumber;
  29994. }
  29995. while (null !== ($part = array_shift($urlParts))) {
  29996. $guessedDomain .= '/' . $part;
  29997. if (in_array($guessedDomain, $configuredDomains) || (null !== $portNumber && in_array(Preg::replace('{:\d+}', '', $guessedDomain), $configuredDomains))) {
  29998. return $guessedDomain;
  29999. }
  30000. }
  30001. return false;
  30002. }
  30003. }
  30004. <?php declare(strict_types=1);
  30005. namespace Composer\Repository\Vcs;
  30006. use Composer\Config;
  30007. use Composer\Cache;
  30008. use Composer\Pcre\Preg;
  30009. use Composer\Util\Hg as HgUtils;
  30010. use Composer\Util\ProcessExecutor;
  30011. use Composer\Util\Filesystem;
  30012. use Composer\IO\IOInterface;
  30013. class HgDriver extends VcsDriver
  30014. {
  30015. protected $tags;
  30016. protected $branches;
  30017. protected $rootIdentifier;
  30018. protected $repoDir;
  30019. public function initialize(): void
  30020. {
  30021. if (Filesystem::isLocalPath($this->url)) {
  30022. $this->repoDir = $this->url;
  30023. } else {
  30024. if (!Cache::isUsable((string) $this->config->get('cache-vcs-dir'))) {
  30025. throw new \RuntimeException('HgDriver requires a usable cache directory, and it looks like you set it to be disabled');
  30026. }
  30027. $cacheDir = $this->config->get('cache-vcs-dir');
  30028. $this->repoDir = $cacheDir . '/' . Preg::replace('{[^a-z0-9]}i', '-', $this->url) . '/';
  30029. $fs = new Filesystem();
  30030. $fs->ensureDirectoryExists($cacheDir);
  30031. if (!is_writable(dirname($this->repoDir))) {
  30032. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.$cacheDir.'" directory is not writable by the current user.');
  30033. }
  30034. $this->config->prohibitUrlByConfig($this->url, $this->io);
  30035. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  30036. if (is_dir($this->repoDir) && 0 === $this->process->execute('hg summary', $output, $this->repoDir)) {
  30037. if (0 !== $this->process->execute('hg pull', $output, $this->repoDir)) {
  30038. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')</error>');
  30039. }
  30040. } else {
  30041. $fs->removeDirectory($this->repoDir);
  30042. $repoDir = $this->repoDir;
  30043. $command = function ($url) use ($repoDir): string {
  30044. return sprintf('hg clone --noupdate -- %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($repoDir));
  30045. };
  30046. $hgUtils->runCommand($command, $this->url, null);
  30047. }
  30048. }
  30049. $this->getTags();
  30050. $this->getBranches();
  30051. }
  30052. public function getRootIdentifier(): string
  30053. {
  30054. if (null === $this->rootIdentifier) {
  30055. $this->process->execute(sprintf('hg tip --template "{node}"'), $output, $this->repoDir);
  30056. $output = $this->process->splitLines($output);
  30057. $this->rootIdentifier = $output[0];
  30058. }
  30059. return $this->rootIdentifier;
  30060. }
  30061. public function getUrl(): string
  30062. {
  30063. return $this->url;
  30064. }
  30065. public function getSource(string $identifier): array
  30066. {
  30067. return array('type' => 'hg', 'url' => $this->getUrl(), 'reference' => $identifier);
  30068. }
  30069. public function getDist(string $identifier): ?array
  30070. {
  30071. return null;
  30072. }
  30073. public function getFileContent(string $file, string $identifier): ?string
  30074. {
  30075. if (isset($identifier[0]) && $identifier[0] === '-') {
  30076. throw new \RuntimeException('Invalid hg identifier detected. Identifier must not start with a -, given: ' . $identifier);
  30077. }
  30078. $resource = sprintf('hg cat -r %s -- %s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  30079. $this->process->execute($resource, $content, $this->repoDir);
  30080. if (!trim($content)) {
  30081. return null;
  30082. }
  30083. return $content;
  30084. }
  30085. public function getChangeDate(string $identifier): ?\DateTimeImmutable
  30086. {
  30087. $this->process->execute(
  30088. sprintf(
  30089. 'hg log --template "{date|rfc3339date}" -r %s',
  30090. ProcessExecutor::escape($identifier)
  30091. ),
  30092. $output,
  30093. $this->repoDir
  30094. );
  30095. return new \DateTimeImmutable(trim($output), new \DateTimeZone('UTC'));
  30096. }
  30097. public function getTags(): array
  30098. {
  30099. if (null === $this->tags) {
  30100. $tags = array();
  30101. $this->process->execute('hg tags', $output, $this->repoDir);
  30102. foreach ($this->process->splitLines($output) as $tag) {
  30103. if ($tag && Preg::isMatch('(^([^\s]+)\s+\d+:(.*)$)', $tag, $match)) {
  30104. $tags[$match[1]] = $match[2];
  30105. }
  30106. }
  30107. unset($tags['tip']);
  30108. $this->tags = $tags;
  30109. }
  30110. return $this->tags;
  30111. }
  30112. public function getBranches(): array
  30113. {
  30114. if (null === $this->branches) {
  30115. $branches = array();
  30116. $bookmarks = array();
  30117. $this->process->execute('hg branches', $output, $this->repoDir);
  30118. foreach ($this->process->splitLines($output) as $branch) {
  30119. if ($branch && Preg::isMatch('(^([^\s]+)\s+\d+:([a-f0-9]+))', $branch, $match) && $match[1][0] !== '-') {
  30120. $branches[$match[1]] = $match[2];
  30121. }
  30122. }
  30123. $this->process->execute('hg bookmarks', $output, $this->repoDir);
  30124. foreach ($this->process->splitLines($output) as $branch) {
  30125. if ($branch && Preg::isMatch('(^(?:[\s*]*)([^\s]+)\s+\d+:(.*)$)', $branch, $match) && $match[1][0] !== '-') {
  30126. $bookmarks[$match[1]] = $match[2];
  30127. }
  30128. }
  30129. $this->branches = array_merge($bookmarks, $branches);
  30130. }
  30131. return $this->branches;
  30132. }
  30133. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
  30134. {
  30135. if (Preg::isMatch('#(^(?:https?|ssh)://(?:[^@]+@)?bitbucket.org|https://(?:.*?)\.kilnhg.com)#i', $url)) {
  30136. return true;
  30137. }
  30138. if (Filesystem::isLocalPath($url)) {
  30139. $url = Filesystem::getPlatformPath($url);
  30140. if (!is_dir($url)) {
  30141. return false;
  30142. }
  30143. $process = new ProcessExecutor($io);
  30144. if ($process->execute('hg summary', $output, $url) === 0) {
  30145. return true;
  30146. }
  30147. }
  30148. if (!$deep) {
  30149. return false;
  30150. }
  30151. $process = new ProcessExecutor($io);
  30152. $exit = $process->execute(sprintf('hg identify -- %s', ProcessExecutor::escape($url)), $ignored);
  30153. return $exit === 0;
  30154. }
  30155. }
  30156. <?php declare(strict_types=1);
  30157. namespace Composer\Repository\Vcs;
  30158. use Composer\Config;
  30159. use Composer\Cache;
  30160. use Composer\IO\IOInterface;
  30161. use Composer\Pcre\Preg;
  30162. use Composer\Util\ProcessExecutor;
  30163. use Composer\Util\Perforce;
  30164. use Composer\Util\Http\Response;
  30165. class PerforceDriver extends VcsDriver
  30166. {
  30167. protected $depot;
  30168. protected $branch;
  30169. protected $perforce = null;
  30170. public function initialize(): void
  30171. {
  30172. $this->depot = $this->repoConfig['depot'];
  30173. $this->branch = '';
  30174. if (!empty($this->repoConfig['branch'])) {
  30175. $this->branch = $this->repoConfig['branch'];
  30176. }
  30177. $this->initPerforce($this->repoConfig);
  30178. $this->perforce->p4Login();
  30179. $this->perforce->checkStream();
  30180. $this->perforce->writeP4ClientSpec();
  30181. $this->perforce->connectClient();
  30182. }
  30183. private function initPerforce(array $repoConfig): void
  30184. {
  30185. if (!empty($this->perforce)) {
  30186. return;
  30187. }
  30188. if (!Cache::isUsable((string) $this->config->get('cache-vcs-dir'))) {
  30189. throw new \RuntimeException('PerforceDriver requires a usable cache directory, and it looks like you set it to be disabled');
  30190. }
  30191. $repoDir = $this->config->get('cache-vcs-dir') . '/' . $this->depot;
  30192. $this->perforce = Perforce::create($repoConfig, $this->getUrl(), $repoDir, $this->process, $this->io);
  30193. }
  30194. public function getFileContent(string $file, string $identifier): ?string
  30195. {
  30196. return $this->perforce->getFileContent($file, $identifier);
  30197. }
  30198. public function getChangeDate(string $identifier): ?\DateTimeImmutable
  30199. {
  30200. return null;
  30201. }
  30202. public function getRootIdentifier(): string
  30203. {
  30204. return $this->branch;
  30205. }
  30206. public function getBranches(): array
  30207. {
  30208. return $this->perforce->getBranches();
  30209. }
  30210. public function getTags(): array
  30211. {
  30212. return $this->perforce->getTags();
  30213. }
  30214. public function getDist(string $identifier): ?array
  30215. {
  30216. return null;
  30217. }
  30218. public function getSource(string $identifier): array
  30219. {
  30220. return array(
  30221. 'type' => 'perforce',
  30222. 'url' => $this->repoConfig['url'],
  30223. 'reference' => $identifier,
  30224. 'p4user' => $this->perforce->getUser(),
  30225. );
  30226. }
  30227. public function getUrl(): string
  30228. {
  30229. return $this->url;
  30230. }
  30231. public function hasComposerFile(string $identifier): bool
  30232. {
  30233. $composerInfo = $this->perforce->getComposerInformation('//' . $this->depot . '/' . $identifier);
  30234. return !empty($composerInfo);
  30235. }
  30236. public function getContents(string $url): Response
  30237. {
  30238. throw new \BadMethodCallException('Not implemented/used in PerforceDriver');
  30239. }
  30240. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
  30241. {
  30242. if ($deep || Preg::isMatch('#\b(perforce|p4)\b#i', $url)) {
  30243. return Perforce::checkServerExists($url, new ProcessExecutor($io));
  30244. }
  30245. return false;
  30246. }
  30247. public function cleanup(): void
  30248. {
  30249. $this->perforce->cleanupClientSpec();
  30250. $this->perforce = null;
  30251. }
  30252. public function getDepot(): string
  30253. {
  30254. return $this->depot;
  30255. }
  30256. public function getBranch(): string
  30257. {
  30258. return $this->branch;
  30259. }
  30260. }
  30261. <?php declare(strict_types=1);
  30262. namespace Composer\Repository\Vcs;
  30263. use Composer\Cache;
  30264. use Composer\Config;
  30265. use Composer\Json\JsonFile;
  30266. use Composer\Pcre\Preg;
  30267. use Composer\Util\ProcessExecutor;
  30268. use Composer\Util\Filesystem;
  30269. use Composer\Util\Url;
  30270. use Composer\Util\Svn as SvnUtil;
  30271. use Composer\IO\IOInterface;
  30272. use Composer\Downloader\TransportException;
  30273. class SvnDriver extends VcsDriver
  30274. {
  30275. protected $baseUrl;
  30276. protected $tags;
  30277. protected $branches;
  30278. protected $rootIdentifier;
  30279. protected $trunkPath = 'trunk';
  30280. protected $branchesPath = 'branches';
  30281. protected $tagsPath = 'tags';
  30282. protected $packagePath = '';
  30283. protected $cacheCredentials = true;
  30284. private $util;
  30285. public function initialize(): void
  30286. {
  30287. $this->url = $this->baseUrl = rtrim(self::normalizeUrl($this->url), '/');
  30288. SvnUtil::cleanEnv();
  30289. if (isset($this->repoConfig['trunk-path'])) {
  30290. $this->trunkPath = $this->repoConfig['trunk-path'];
  30291. }
  30292. if (isset($this->repoConfig['branches-path'])) {
  30293. $this->branchesPath = $this->repoConfig['branches-path'];
  30294. }
  30295. if (isset($this->repoConfig['tags-path'])) {
  30296. $this->tagsPath = $this->repoConfig['tags-path'];
  30297. }
  30298. if (array_key_exists('svn-cache-credentials', $this->repoConfig)) {
  30299. $this->cacheCredentials = (bool) $this->repoConfig['svn-cache-credentials'];
  30300. }
  30301. if (isset($this->repoConfig['package-path'])) {
  30302. $this->packagePath = '/' . trim($this->repoConfig['package-path'], '/');
  30303. }
  30304. if (false !== ($pos = strrpos($this->url, '/' . $this->trunkPath))) {
  30305. $this->baseUrl = substr($this->url, 0, $pos);
  30306. }
  30307. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', Url::sanitize($this->baseUrl)));
  30308. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  30309. $this->getBranches();
  30310. $this->getTags();
  30311. }
  30312. public function getRootIdentifier(): string
  30313. {
  30314. return $this->rootIdentifier ?: $this->trunkPath;
  30315. }
  30316. public function getUrl(): string
  30317. {
  30318. return $this->url;
  30319. }
  30320. public function getSource(string $identifier): array
  30321. {
  30322. return array('type' => 'svn', 'url' => $this->baseUrl, 'reference' => $identifier);
  30323. }
  30324. public function getDist(string $identifier): ?array
  30325. {
  30326. return null;
  30327. }
  30328. protected function shouldCache(string $identifier): bool
  30329. {
  30330. return $this->cache && Preg::isMatch('{@\d+$}', $identifier);
  30331. }
  30332. public function getComposerInformation(string $identifier): ?array
  30333. {
  30334. if (!isset($this->infoCache[$identifier])) {
  30335. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier.'.json')) {
  30336. return $this->infoCache[$identifier] = JsonFile::parseJson($res);
  30337. }
  30338. try {
  30339. $composer = $this->getBaseComposerInformation($identifier);
  30340. } catch (TransportException $e) {
  30341. $message = $e->getMessage();
  30342. if (stripos($message, 'path not found') === false && stripos($message, 'svn: warning: W160013') === false) {
  30343. throw $e;
  30344. }
  30345. $composer = null;
  30346. }
  30347. if ($this->shouldCache($identifier)) {
  30348. $this->cache->write($identifier.'.json', json_encode($composer));
  30349. }
  30350. $this->infoCache[$identifier] = $composer;
  30351. }
  30352. if (!is_array($this->infoCache[$identifier])) {
  30353. return null;
  30354. }
  30355. return $this->infoCache[$identifier];
  30356. }
  30357. public function getFileContent(string $file, string $identifier): ?string
  30358. {
  30359. $identifier = '/' . trim($identifier, '/') . '/';
  30360. Preg::match('{^(.+?)(@\d+)?/$}', $identifier, $match);
  30361. if (!empty($match[2])) {
  30362. $path = $match[1];
  30363. $rev = $match[2];
  30364. } else {
  30365. $path = $identifier;
  30366. $rev = '';
  30367. }
  30368. try {
  30369. $resource = $path.$file;
  30370. $output = $this->execute('svn cat', $this->baseUrl . $resource . $rev);
  30371. if (!trim($output)) {
  30372. return null;
  30373. }
  30374. } catch (\RuntimeException $e) {
  30375. throw new TransportException($e->getMessage());
  30376. }
  30377. return $output;
  30378. }
  30379. public function getChangeDate(string $identifier): ?\DateTimeImmutable
  30380. {
  30381. $identifier = '/' . trim($identifier, '/') . '/';
  30382. Preg::match('{^(.+?)(@\d+)?/$}', $identifier, $match);
  30383. if (!empty($match[2])) {
  30384. $path = $match[1];
  30385. $rev = $match[2];
  30386. } else {
  30387. $path = $identifier;
  30388. $rev = '';
  30389. }
  30390. $output = $this->execute('svn info', $this->baseUrl . $path . $rev);
  30391. foreach ($this->process->splitLines($output) as $line) {
  30392. if ($line && Preg::isMatch('{^Last Changed Date: ([^(]+)}', $line, $match)) {
  30393. return new \DateTimeImmutable($match[1], new \DateTimeZone('UTC'));
  30394. }
  30395. }
  30396. return null;
  30397. }
  30398. public function getTags(): array
  30399. {
  30400. if (null === $this->tags) {
  30401. $tags = array();
  30402. if ($this->tagsPath !== false) {
  30403. $output = $this->execute('svn ls --verbose', $this->baseUrl . '/' . $this->tagsPath);
  30404. if ($output) {
  30405. foreach ($this->process->splitLines($output) as $line) {
  30406. $line = trim($line);
  30407. if ($line && Preg::isMatch('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  30408. if (isset($match[1], $match[2]) && $match[2] !== './') {
  30409. $tags[rtrim($match[2], '/')] = $this->buildIdentifier(
  30410. '/' . $this->tagsPath . '/' . $match[2],
  30411. $match[1]
  30412. );
  30413. }
  30414. }
  30415. }
  30416. }
  30417. }
  30418. $this->tags = $tags;
  30419. }
  30420. return $this->tags;
  30421. }
  30422. public function getBranches(): array
  30423. {
  30424. if (null === $this->branches) {
  30425. $branches = array();
  30426. if (false === $this->trunkPath) {
  30427. $trunkParent = $this->baseUrl . '/';
  30428. } else {
  30429. $trunkParent = $this->baseUrl . '/' . $this->trunkPath;
  30430. }
  30431. $output = $this->execute('svn ls --verbose', $trunkParent);
  30432. if ($output) {
  30433. foreach ($this->process->splitLines($output) as $line) {
  30434. $line = trim($line);
  30435. if ($line && Preg::isMatch('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  30436. if (isset($match[1], $match[2]) && $match[2] === './') {
  30437. $branches['trunk'] = $this->buildIdentifier(
  30438. '/' . $this->trunkPath,
  30439. $match[1]
  30440. );
  30441. $this->rootIdentifier = $branches['trunk'];
  30442. break;
  30443. }
  30444. }
  30445. }
  30446. }
  30447. unset($output);
  30448. if ($this->branchesPath !== false) {
  30449. $output = $this->execute('svn ls --verbose', $this->baseUrl . '/' . $this->branchesPath);
  30450. if ($output) {
  30451. foreach ($this->process->splitLines(trim($output)) as $line) {
  30452. $line = trim($line);
  30453. if ($line && Preg::isMatch('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  30454. if (isset($match[1], $match[2]) && $match[2] !== './') {
  30455. $branches[rtrim($match[2], '/')] = $this->buildIdentifier(
  30456. '/' . $this->branchesPath . '/' . $match[2],
  30457. $match[1]
  30458. );
  30459. }
  30460. }
  30461. }
  30462. }
  30463. }
  30464. $this->branches = $branches;
  30465. }
  30466. return $this->branches;
  30467. }
  30468. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
  30469. {
  30470. $url = self::normalizeUrl($url);
  30471. if (Preg::isMatch('#(^svn://|^svn\+ssh://|svn\.)#i', $url)) {
  30472. return true;
  30473. }
  30474. if (!$deep && !Filesystem::isLocalPath($url)) {
  30475. return false;
  30476. }
  30477. $process = new ProcessExecutor($io);
  30478. $exit = $process->execute(
  30479. "svn info --non-interactive -- ".ProcessExecutor::escape($url),
  30480. $ignoredOutput
  30481. );
  30482. if ($exit === 0) {
  30483. return true;
  30484. }
  30485. if (false !== stripos($process->getErrorOutput(), 'authorization failed:')) {
  30486. return true;
  30487. }
  30488. if (false !== stripos($process->getErrorOutput(), 'Authentication failed')) {
  30489. return true;
  30490. }
  30491. return false;
  30492. }
  30493. protected static function normalizeUrl(string $url): string
  30494. {
  30495. $fs = new Filesystem();
  30496. if ($fs->isAbsolutePath($url)) {
  30497. return 'file://' . strtr($url, '\\', '/');
  30498. }
  30499. return $url;
  30500. }
  30501. protected function execute(string $command, string $url): string
  30502. {
  30503. if (null === $this->util) {
  30504. $this->util = new SvnUtil($this->baseUrl, $this->io, $this->config, $this->process);
  30505. $this->util->setCacheCredentials($this->cacheCredentials);
  30506. }
  30507. try {
  30508. return $this->util->execute($command, $url);
  30509. } catch (\RuntimeException $e) {
  30510. if (null === $this->util->binaryVersion()) {
  30511. 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());
  30512. }
  30513. throw new \RuntimeException(
  30514. 'Repository '.$this->url.' could not be processed, '.$e->getMessage()
  30515. );
  30516. }
  30517. }
  30518. protected function buildIdentifier(string $baseDir, string $revision): string
  30519. {
  30520. return rtrim($baseDir, '/') . $this->packagePath . '/@' . $revision;
  30521. }
  30522. }
  30523. <?php declare(strict_types=1);
  30524. namespace Composer\Repository\Vcs;
  30525. use Composer\Cache;
  30526. use Composer\Downloader\TransportException;
  30527. use Composer\Config;
  30528. use Composer\IO\IOInterface;
  30529. use Composer\Json\JsonFile;
  30530. use Composer\Pcre\Preg;
  30531. use Composer\Util\ProcessExecutor;
  30532. use Composer\Util\HttpDownloader;
  30533. use Composer\Util\Filesystem;
  30534. use Composer\Util\Http\Response;
  30535. abstract class VcsDriver implements VcsDriverInterface
  30536. {
  30537. protected $url;
  30538. protected $originUrl;
  30539. protected $repoConfig;
  30540. protected $io;
  30541. protected $config;
  30542. protected $process;
  30543. protected $httpDownloader;
  30544. protected $infoCache = array();
  30545. protected $cache;
  30546. final public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, ProcessExecutor $process)
  30547. {
  30548. if (Filesystem::isLocalPath($repoConfig['url'])) {
  30549. $repoConfig['url'] = Filesystem::getPlatformPath($repoConfig['url']);
  30550. }
  30551. $this->url = $repoConfig['url'];
  30552. $this->originUrl = $repoConfig['url'];
  30553. $this->repoConfig = $repoConfig;
  30554. $this->io = $io;
  30555. $this->config = $config;
  30556. $this->httpDownloader = $httpDownloader;
  30557. $this->process = $process;
  30558. }
  30559. protected function shouldCache(string $identifier): bool
  30560. {
  30561. return $this->cache && Preg::isMatch('{^[a-f0-9]{40}$}iD', $identifier);
  30562. }
  30563. public function getComposerInformation(string $identifier): ?array
  30564. {
  30565. if (!isset($this->infoCache[$identifier])) {
  30566. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  30567. return $this->infoCache[$identifier] = JsonFile::parseJson($res);
  30568. }
  30569. $composer = $this->getBaseComposerInformation($identifier);
  30570. if ($this->shouldCache($identifier)) {
  30571. $this->cache->write($identifier, JsonFile::encode($composer, 0));
  30572. }
  30573. $this->infoCache[$identifier] = $composer;
  30574. }
  30575. return $this->infoCache[$identifier];
  30576. }
  30577. protected function getBaseComposerInformation(string $identifier): ?array
  30578. {
  30579. $composerFileContent = $this->getFileContent('composer.json', $identifier);
  30580. if (!$composerFileContent) {
  30581. return null;
  30582. }
  30583. $composer = JsonFile::parseJson($composerFileContent, $identifier . ':composer.json');
  30584. if ([] === $composer || !is_array($composer)) {
  30585. return null;
  30586. }
  30587. if (empty($composer['time']) && null !== ($changeDate = $this->getChangeDate($identifier))) {
  30588. $composer['time'] = $changeDate->format(DATE_RFC3339);
  30589. }
  30590. return $composer;
  30591. }
  30592. public function hasComposerFile(string $identifier): bool
  30593. {
  30594. try {
  30595. return null !== $this->getComposerInformation($identifier);
  30596. } catch (TransportException $e) {
  30597. }
  30598. return false;
  30599. }
  30600. protected function getScheme(): string
  30601. {
  30602. if (extension_loaded('openssl')) {
  30603. return 'https';
  30604. }
  30605. return 'http';
  30606. }
  30607. protected function getContents(string $url): Response
  30608. {
  30609. $options = $this->repoConfig['options'] ?? array();
  30610. return $this->httpDownloader->get($url, $options);
  30611. }
  30612. public function cleanup(): void
  30613. {
  30614. return;
  30615. }
  30616. }
  30617. <?php declare(strict_types=1);
  30618. namespace Composer\Repository\Vcs;
  30619. use Composer\Config;
  30620. use Composer\IO\IOInterface;
  30621. interface VcsDriverInterface
  30622. {
  30623. public function initialize(): void;
  30624. public function getComposerInformation(string $identifier): ?array;
  30625. public function getFileContent(string $file, string $identifier): ?string;
  30626. public function getChangeDate(string $identifier): ?\DateTimeImmutable;
  30627. public function getRootIdentifier(): string;
  30628. public function getBranches(): array;
  30629. public function getTags(): array;
  30630. public function getDist(string $identifier): ?array;
  30631. public function getSource(string $identifier): array;
  30632. public function getUrl(): string;
  30633. public function hasComposerFile(string $identifier): bool;
  30634. public function cleanup(): void;
  30635. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool;
  30636. }
  30637. <?php declare(strict_types=1);
  30638. namespace Composer\Repository;
  30639. use Composer\Downloader\TransportException;
  30640. use Composer\Pcre\Preg;
  30641. use Composer\Repository\Vcs\VcsDriverInterface;
  30642. use Composer\Package\Version\VersionParser;
  30643. use Composer\Package\Loader\ArrayLoader;
  30644. use Composer\Package\Loader\ValidatingArrayLoader;
  30645. use Composer\Package\Loader\InvalidPackageException;
  30646. use Composer\Package\Loader\LoaderInterface;
  30647. use Composer\EventDispatcher\EventDispatcher;
  30648. use Composer\Util\ProcessExecutor;
  30649. use Composer\Util\HttpDownloader;
  30650. use Composer\Util\Url;
  30651. use Composer\Semver\Constraint\Constraint;
  30652. use Composer\IO\IOInterface;
  30653. use Composer\Config;
  30654. class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  30655. {
  30656. protected $url;
  30657. protected $packageName;
  30658. protected $isVerbose;
  30659. protected $isVeryVerbose;
  30660. protected $io;
  30661. protected $config;
  30662. protected $versionParser;
  30663. protected $type;
  30664. protected $loader;
  30665. protected $repoConfig;
  30666. protected $httpDownloader;
  30667. protected $processExecutor;
  30668. protected $branchErrorOccurred = false;
  30669. private $drivers;
  30670. private $driver;
  30671. private $versionCache;
  30672. private $emptyReferences = array();
  30673. private $versionTransportExceptions = array();
  30674. public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $dispatcher = null, ProcessExecutor $process = null, array $drivers = null, VersionCacheInterface $versionCache = null)
  30675. {
  30676. parent::__construct();
  30677. $this->drivers = $drivers ?: array(
  30678. 'github' => 'Composer\Repository\Vcs\GitHubDriver',
  30679. 'gitlab' => 'Composer\Repository\Vcs\GitLabDriver',
  30680. 'bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver',
  30681. 'git-bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver',
  30682. 'git' => 'Composer\Repository\Vcs\GitDriver',
  30683. 'hg' => 'Composer\Repository\Vcs\HgDriver',
  30684. 'perforce' => 'Composer\Repository\Vcs\PerforceDriver',
  30685. 'fossil' => 'Composer\Repository\Vcs\FossilDriver',
  30686. 'svn' => 'Composer\Repository\Vcs\SvnDriver',
  30687. );
  30688. $this->url = $repoConfig['url'];
  30689. $this->io = $io;
  30690. $this->type = $repoConfig['type'] ?? 'vcs';
  30691. $this->isVerbose = $io->isVerbose();
  30692. $this->isVeryVerbose = $io->isVeryVerbose();
  30693. $this->config = $config;
  30694. $this->repoConfig = $repoConfig;
  30695. $this->versionCache = $versionCache;
  30696. $this->httpDownloader = $httpDownloader;
  30697. $this->processExecutor = $process ?? new ProcessExecutor($io);
  30698. }
  30699. public function getRepoName()
  30700. {
  30701. $driverClass = get_class($this->getDriver());
  30702. $driverType = array_search($driverClass, $this->drivers);
  30703. if (!$driverType) {
  30704. $driverType = $driverClass;
  30705. }
  30706. return 'vcs repo ('.$driverType.' '.Url::sanitize($this->url).')';
  30707. }
  30708. public function getRepoConfig()
  30709. {
  30710. return $this->repoConfig;
  30711. }
  30712. public function setLoader(LoaderInterface $loader): void
  30713. {
  30714. $this->loader = $loader;
  30715. }
  30716. public function getDriver(): ?VcsDriverInterface
  30717. {
  30718. if ($this->driver) {
  30719. return $this->driver;
  30720. }
  30721. if (isset($this->drivers[$this->type])) {
  30722. $class = $this->drivers[$this->type];
  30723. $this->driver = new $class($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  30724. $this->driver->initialize();
  30725. return $this->driver;
  30726. }
  30727. foreach ($this->drivers as $driver) {
  30728. if ($driver::supports($this->io, $this->config, $this->url)) {
  30729. $this->driver = new $driver($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  30730. $this->driver->initialize();
  30731. return $this->driver;
  30732. }
  30733. }
  30734. foreach ($this->drivers as $driver) {
  30735. if ($driver::supports($this->io, $this->config, $this->url, true)) {
  30736. $this->driver = new $driver($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  30737. $this->driver->initialize();
  30738. return $this->driver;
  30739. }
  30740. }
  30741. return null;
  30742. }
  30743. public function hadInvalidBranches(): bool
  30744. {
  30745. return $this->branchErrorOccurred;
  30746. }
  30747. public function getEmptyReferences(): array
  30748. {
  30749. return $this->emptyReferences;
  30750. }
  30751. public function getVersionTransportExceptions(): array
  30752. {
  30753. return $this->versionTransportExceptions;
  30754. }
  30755. protected function initialize()
  30756. {
  30757. parent::initialize();
  30758. $isVerbose = $this->isVerbose;
  30759. $isVeryVerbose = $this->isVeryVerbose;
  30760. $driver = $this->getDriver();
  30761. if (!$driver) {
  30762. throw new \InvalidArgumentException('No driver found to handle VCS repository '.$this->url);
  30763. }
  30764. $this->versionParser = new VersionParser;
  30765. if (!$this->loader) {
  30766. $this->loader = new ArrayLoader($this->versionParser);
  30767. }
  30768. $hasRootIdentifierComposerJson = false;
  30769. try {
  30770. $hasRootIdentifierComposerJson = $driver->hasComposerFile($driver->getRootIdentifier());
  30771. if ($hasRootIdentifierComposerJson) {
  30772. $data = $driver->getComposerInformation($driver->getRootIdentifier());
  30773. $this->packageName = !empty($data['name']) ? $data['name'] : null;
  30774. }
  30775. } catch (\Exception $e) {
  30776. if ($e instanceof TransportException && $this->shouldRethrowTransportException($e)) {
  30777. throw $e;
  30778. }
  30779. if ($isVeryVerbose) {
  30780. $this->io->writeError('<error>Skipped parsing '.$driver->getRootIdentifier().', '.$e->getMessage().'</error>');
  30781. }
  30782. }
  30783. foreach ($driver->getTags() as $tag => $identifier) {
  30784. $tag = (string) $tag;
  30785. $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $tag . '</comment>)';
  30786. if ($isVeryVerbose) {
  30787. $this->io->writeError($msg);
  30788. } elseif ($isVerbose) {
  30789. $this->io->overwriteError($msg, false);
  30790. }
  30791. $tag = str_replace('release-', '', $tag);
  30792. $cachedPackage = $this->getCachedPackageVersion($tag, $identifier, $isVerbose, $isVeryVerbose);
  30793. if ($cachedPackage) {
  30794. $this->addPackage($cachedPackage);
  30795. continue;
  30796. }
  30797. if ($cachedPackage === false) {
  30798. $this->emptyReferences[] = $identifier;
  30799. continue;
  30800. }
  30801. if (!$parsedTag = $this->validateTag($tag)) {
  30802. if ($isVeryVerbose) {
  30803. $this->io->writeError('<warning>Skipped tag '.$tag.', invalid tag name</warning>');
  30804. }
  30805. continue;
  30806. }
  30807. try {
  30808. $data = $driver->getComposerInformation($identifier);
  30809. if (null === $data) {
  30810. if ($isVeryVerbose) {
  30811. $this->io->writeError('<warning>Skipped tag '.$tag.', no composer file</warning>');
  30812. }
  30813. $this->emptyReferences[] = $identifier;
  30814. continue;
  30815. }
  30816. if (isset($data['version'])) {
  30817. $data['version_normalized'] = $this->versionParser->normalize($data['version']);
  30818. } else {
  30819. $data['version'] = $tag;
  30820. $data['version_normalized'] = $parsedTag;
  30821. }
  30822. $data['version'] = Preg::replace('{[.-]?dev$}i', '', $data['version']);
  30823. $data['version_normalized'] = Preg::replace('{(^dev-|[.-]?dev$)}i', '', $data['version_normalized']);
  30824. unset($data['default-branch']);
  30825. if ($data['version_normalized'] !== $parsedTag) {
  30826. if ($isVeryVerbose) {
  30827. if (Preg::isMatch('{(^dev-|[.-]?dev$)}i', $parsedTag)) {
  30828. $this->io->writeError('<warning>Skipped tag '.$tag.', invalid tag name, tags can not use dev prefixes or suffixes</warning>');
  30829. } else {
  30830. $this->io->writeError('<warning>Skipped tag '.$tag.', tag ('.$parsedTag.') does not match version ('.$data['version_normalized'].') in composer.json</warning>');
  30831. }
  30832. }
  30833. continue;
  30834. }
  30835. $tagPackageName = $this->packageName ?: ($data['name'] ?? '');
  30836. if ($existingPackage = $this->findPackage($tagPackageName, $data['version_normalized'])) {
  30837. if ($isVeryVerbose) {
  30838. $this->io->writeError('<warning>Skipped tag '.$tag.', it conflicts with an another tag ('.$existingPackage->getPrettyVersion().') as both resolve to '.$data['version_normalized'].' internally</warning>');
  30839. }
  30840. continue;
  30841. }
  30842. if ($isVeryVerbose) {
  30843. $this->io->writeError('Importing tag '.$tag.' ('.$data['version_normalized'].')');
  30844. }
  30845. $this->addPackage($this->loader->load($this->preProcess($driver, $data, $identifier)));
  30846. } catch (\Exception $e) {
  30847. if ($e instanceof TransportException) {
  30848. $this->versionTransportExceptions['tags'][$tag] = $e;
  30849. if ($e->getCode() === 404) {
  30850. $this->emptyReferences[] = $identifier;
  30851. }
  30852. if ($this->shouldRethrowTransportException($e)) {
  30853. throw $e;
  30854. }
  30855. }
  30856. if ($isVeryVerbose) {
  30857. $this->io->writeError('<warning>Skipped tag '.$tag.', '.($e instanceof TransportException ? 'no composer file was found (' . $e->getCode() . ' HTTP status code)' : $e->getMessage()).'</warning>');
  30858. }
  30859. continue;
  30860. }
  30861. }
  30862. if (!$isVeryVerbose) {
  30863. $this->io->overwriteError('', false);
  30864. }
  30865. $branches = $driver->getBranches();
  30866. if ($hasRootIdentifierComposerJson && isset($branches[$driver->getRootIdentifier()])) {
  30867. $branches = array($driver->getRootIdentifier() => $branches[$driver->getRootIdentifier()]) + $branches;
  30868. }
  30869. foreach ($branches as $branch => $identifier) {
  30870. $branch = (string) $branch;
  30871. $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $branch . '</comment>)';
  30872. if ($isVeryVerbose) {
  30873. $this->io->writeError($msg);
  30874. } elseif ($isVerbose) {
  30875. $this->io->overwriteError($msg, false);
  30876. }
  30877. if (!$parsedBranch = $this->validateBranch($branch)) {
  30878. if ($isVeryVerbose) {
  30879. $this->io->writeError('<warning>Skipped branch '.$branch.', invalid name</warning>');
  30880. }
  30881. continue;
  30882. }
  30883. if (strpos($parsedBranch, 'dev-') === 0 || VersionParser::DEFAULT_BRANCH_ALIAS === $parsedBranch) {
  30884. $version = 'dev-' . $branch;
  30885. } else {
  30886. $prefix = strpos($branch, 'v') === 0 ? 'v' : '';
  30887. $version = $prefix . Preg::replace('{(\.9{7})+}', '.x', $parsedBranch);
  30888. }
  30889. $cachedPackage = $this->getCachedPackageVersion($version, $identifier, $isVerbose, $isVeryVerbose, $driver->getRootIdentifier() === $branch);
  30890. if ($cachedPackage) {
  30891. $this->addPackage($cachedPackage);
  30892. continue;
  30893. }
  30894. if ($cachedPackage === false) {
  30895. $this->emptyReferences[] = $identifier;
  30896. continue;
  30897. }
  30898. try {
  30899. $data = $driver->getComposerInformation($identifier);
  30900. if (null === $data) {
  30901. if ($isVeryVerbose) {
  30902. $this->io->writeError('<warning>Skipped branch '.$branch.', no composer file</warning>');
  30903. }
  30904. $this->emptyReferences[] = $identifier;
  30905. continue;
  30906. }
  30907. $data['version'] = $version;
  30908. $data['version_normalized'] = $parsedBranch;
  30909. unset($data['default-branch']);
  30910. if ($driver->getRootIdentifier() === $branch) {
  30911. $data['default-branch'] = true;
  30912. }
  30913. if ($isVeryVerbose) {
  30914. $this->io->writeError('Importing branch '.$branch.' ('.$data['version'].')');
  30915. }
  30916. $packageData = $this->preProcess($driver, $data, $identifier);
  30917. $package = $this->loader->load($packageData);
  30918. if ($this->loader instanceof ValidatingArrayLoader && $this->loader->getWarnings()) {
  30919. throw new InvalidPackageException($this->loader->getErrors(), $this->loader->getWarnings(), $packageData);
  30920. }
  30921. $this->addPackage($package);
  30922. } catch (TransportException $e) {
  30923. $this->versionTransportExceptions['branches'][$branch] = $e;
  30924. if ($e->getCode() === 404) {
  30925. $this->emptyReferences[] = $identifier;
  30926. }
  30927. if ($this->shouldRethrowTransportException($e)) {
  30928. throw $e;
  30929. }
  30930. if ($isVeryVerbose) {
  30931. $this->io->writeError('<warning>Skipped branch '.$branch.', no composer file was found (' . $e->getCode() . ' HTTP status code)</warning>');
  30932. }
  30933. continue;
  30934. } catch (\Exception $e) {
  30935. if (!$isVeryVerbose) {
  30936. $this->io->writeError('');
  30937. }
  30938. $this->branchErrorOccurred = true;
  30939. $this->io->writeError('<error>Skipped branch '.$branch.', '.$e->getMessage().'</error>');
  30940. $this->io->writeError('');
  30941. continue;
  30942. }
  30943. }
  30944. $driver->cleanup();
  30945. if (!$isVeryVerbose) {
  30946. $this->io->overwriteError('', false);
  30947. }
  30948. if (!$this->getPackages()) {
  30949. throw new InvalidRepositoryException('No valid composer.json was found in any branch or tag of '.$this->url.', could not load a package from it.');
  30950. }
  30951. }
  30952. protected function preProcess(VcsDriverInterface $driver, array $data, string $identifier): array
  30953. {
  30954. $dataPackageName = $data['name'] ?? null;
  30955. $data['name'] = $this->packageName ?: $dataPackageName;
  30956. if (!isset($data['dist'])) {
  30957. $data['dist'] = $driver->getDist($identifier);
  30958. }
  30959. if (!isset($data['source'])) {
  30960. $data['source'] = $driver->getSource($identifier);
  30961. }
  30962. return $data;
  30963. }
  30964. private function validateBranch(string $branch)
  30965. {
  30966. try {
  30967. $normalizedBranch = $this->versionParser->normalizeBranch($branch);
  30968. $this->versionParser->parseConstraints($normalizedBranch);
  30969. return $normalizedBranch;
  30970. } catch (\Exception $e) {
  30971. }
  30972. return false;
  30973. }
  30974. private function validateTag(string $version)
  30975. {
  30976. try {
  30977. return $this->versionParser->normalize($version);
  30978. } catch (\Exception $e) {
  30979. }
  30980. return false;
  30981. }
  30982. private function getCachedPackageVersion(string $version, string $identifier, bool $isVerbose, bool $isVeryVerbose, bool $isDefaultBranch = false)
  30983. {
  30984. if (!$this->versionCache) {
  30985. return null;
  30986. }
  30987. $cachedPackage = $this->versionCache->getVersionPackage($version, $identifier);
  30988. if ($cachedPackage === false) {
  30989. if ($isVeryVerbose) {
  30990. $this->io->writeError('<warning>Skipped '.$version.', no composer file (cached from ref '.$identifier.')</warning>');
  30991. }
  30992. return false;
  30993. }
  30994. if ($cachedPackage) {
  30995. $msg = 'Found cached composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $version . '</comment>)';
  30996. if ($isVeryVerbose) {
  30997. $this->io->writeError($msg);
  30998. } elseif ($isVerbose) {
  30999. $this->io->overwriteError($msg, false);
  31000. }
  31001. unset($cachedPackage['default-branch']);
  31002. if ($isDefaultBranch) {
  31003. $cachedPackage['default-branch'] = true;
  31004. }
  31005. if ($existingPackage = $this->findPackage($cachedPackage['name'], new Constraint('=', $cachedPackage['version_normalized']))) {
  31006. if ($isVeryVerbose) {
  31007. $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>');
  31008. }
  31009. $cachedPackage = null;
  31010. }
  31011. }
  31012. if ($cachedPackage) {
  31013. return $this->loader->load($cachedPackage);
  31014. }
  31015. return null;
  31016. }
  31017. private function shouldRethrowTransportException(TransportException $e): bool
  31018. {
  31019. return in_array($e->getCode(), array(401, 403, 429), true) || $e->getCode() >= 500;
  31020. }
  31021. }
  31022. <?php declare(strict_types=1);
  31023. namespace Composer\Repository;
  31024. interface VersionCacheInterface
  31025. {
  31026. public function getVersionPackage(string $version, string $identifier);
  31027. }
  31028. <?php declare(strict_types=1);
  31029. namespace Composer\Repository;
  31030. use Composer\Package\AliasPackage;
  31031. use Composer\Installer\InstallationManager;
  31032. class WritableArrayRepository extends ArrayRepository implements WritableRepositoryInterface
  31033. {
  31034. protected $devPackageNames = array();
  31035. private $devMode = null;
  31036. public function getDevMode()
  31037. {
  31038. return $this->devMode;
  31039. }
  31040. public function setDevPackageNames(array $devPackageNames)
  31041. {
  31042. $this->devPackageNames = $devPackageNames;
  31043. }
  31044. public function getDevPackageNames()
  31045. {
  31046. return $this->devPackageNames;
  31047. }
  31048. public function write(bool $devMode, InstallationManager $installationManager)
  31049. {
  31050. $this->devMode = $devMode;
  31051. }
  31052. public function reload()
  31053. {
  31054. $this->devMode = null;
  31055. }
  31056. public function getCanonicalPackages()
  31057. {
  31058. $packages = $this->getPackages();
  31059. $packagesByName = array();
  31060. foreach ($packages as $package) {
  31061. if (!isset($packagesByName[$package->getName()]) || $packagesByName[$package->getName()] instanceof AliasPackage) {
  31062. $packagesByName[$package->getName()] = $package;
  31063. }
  31064. }
  31065. $canonicalPackages = array();
  31066. foreach ($packagesByName as $package) {
  31067. while ($package instanceof AliasPackage) {
  31068. $package = $package->getAliasOf();
  31069. }
  31070. $canonicalPackages[] = $package;
  31071. }
  31072. return $canonicalPackages;
  31073. }
  31074. }
  31075. <?php declare(strict_types=1);
  31076. namespace Composer\Repository;
  31077. use Composer\Package\PackageInterface;
  31078. use Composer\Installer\InstallationManager;
  31079. interface WritableRepositoryInterface extends RepositoryInterface
  31080. {
  31081. public function write(bool $devMode, InstallationManager $installationManager);
  31082. public function addPackage(PackageInterface $package);
  31083. public function removePackage(PackageInterface $package);
  31084. public function getCanonicalPackages();
  31085. public function reload();
  31086. public function setDevPackageNames(array $devPackageNames);
  31087. public function getDevPackageNames();
  31088. }
  31089. <?php declare(strict_types=1);
  31090. namespace Composer\Script;
  31091. use Composer\Composer;
  31092. use Composer\IO\IOInterface;
  31093. use Composer\EventDispatcher\Event as BaseEvent;
  31094. class Event extends BaseEvent
  31095. {
  31096. private $composer;
  31097. private $io;
  31098. private $devMode;
  31099. private $originatingEvent;
  31100. public function __construct(string $name, Composer $composer, IOInterface $io, bool $devMode = false, array $args = array(), array $flags = array())
  31101. {
  31102. parent::__construct($name, $args, $flags);
  31103. $this->composer = $composer;
  31104. $this->io = $io;
  31105. $this->devMode = $devMode;
  31106. }
  31107. public function getComposer(): Composer
  31108. {
  31109. return $this->composer;
  31110. }
  31111. public function getIO(): IOInterface
  31112. {
  31113. return $this->io;
  31114. }
  31115. public function isDevMode(): bool
  31116. {
  31117. return $this->devMode;
  31118. }
  31119. public function getOriginatingEvent(): ?BaseEvent
  31120. {
  31121. return $this->originatingEvent;
  31122. }
  31123. public function setOriginatingEvent(BaseEvent $event): self
  31124. {
  31125. $this->originatingEvent = $this->calculateOriginatingEvent($event);
  31126. return $this;
  31127. }
  31128. private function calculateOriginatingEvent(BaseEvent $event): BaseEvent
  31129. {
  31130. if ($event instanceof Event && $event->getOriginatingEvent()) {
  31131. return $this->calculateOriginatingEvent($event->getOriginatingEvent());
  31132. }
  31133. return $event;
  31134. }
  31135. }
  31136. <?php declare(strict_types=1);
  31137. namespace Composer\Script;
  31138. class ScriptEvents
  31139. {
  31140. public const PRE_INSTALL_CMD = 'pre-install-cmd';
  31141. public const POST_INSTALL_CMD = 'post-install-cmd';
  31142. public const PRE_UPDATE_CMD = 'pre-update-cmd';
  31143. public const POST_UPDATE_CMD = 'post-update-cmd';
  31144. public const PRE_STATUS_CMD = 'pre-status-cmd';
  31145. public const POST_STATUS_CMD = 'post-status-cmd';
  31146. public const PRE_AUTOLOAD_DUMP = 'pre-autoload-dump';
  31147. public const POST_AUTOLOAD_DUMP = 'post-autoload-dump';
  31148. public const POST_ROOT_PACKAGE_INSTALL = 'post-root-package-install';
  31149. public const POST_CREATE_PROJECT_CMD = 'post-create-project-cmd';
  31150. public const PRE_ARCHIVE_CMD = 'pre-archive-cmd';
  31151. public const POST_ARCHIVE_CMD = 'post-archive-cmd';
  31152. }
  31153. <?php declare(strict_types=1);
  31154. namespace Composer\SelfUpdate;
  31155. use Composer\Pcre\Preg;
  31156. class Keys
  31157. {
  31158. public static function fingerprint(string $path): string
  31159. {
  31160. $hash = strtoupper(hash('sha256', Preg::replace('{\s}', '', file_get_contents($path))));
  31161. return implode(' ', array(
  31162. substr($hash, 0, 8),
  31163. substr($hash, 8, 8),
  31164. substr($hash, 16, 8),
  31165. substr($hash, 24, 8),
  31166. '',
  31167. substr($hash, 32, 8),
  31168. substr($hash, 40, 8),
  31169. substr($hash, 48, 8),
  31170. substr($hash, 56, 8),
  31171. ));
  31172. }
  31173. }
  31174. <?php declare(strict_types=1);
  31175. namespace Composer\SelfUpdate;
  31176. use Composer\Pcre\Preg;
  31177. use Composer\Util\HttpDownloader;
  31178. use Composer\Config;
  31179. class Versions
  31180. {
  31181. public static $channels = self::CHANNELS;
  31182. public const CHANNELS = ['stable', 'preview', 'snapshot', '1', '2', '2.2'];
  31183. private $httpDownloader;
  31184. private $config;
  31185. private $channel;
  31186. private $versionsData = null;
  31187. public function __construct(Config $config, HttpDownloader $httpDownloader)
  31188. {
  31189. $this->httpDownloader = $httpDownloader;
  31190. $this->config = $config;
  31191. }
  31192. public function getChannel(): string
  31193. {
  31194. if ($this->channel) {
  31195. return $this->channel;
  31196. }
  31197. $channelFile = $this->config->get('home').'/update-channel';
  31198. if (file_exists($channelFile)) {
  31199. $channel = trim(file_get_contents($channelFile));
  31200. if (in_array($channel, array('stable', 'preview', 'snapshot', '2.2'), true)) {
  31201. return $this->channel = $channel;
  31202. }
  31203. }
  31204. return $this->channel = 'stable';
  31205. }
  31206. public function setChannel(string $channel): void
  31207. {
  31208. if (!in_array($channel, self::$channels, true)) {
  31209. throw new \InvalidArgumentException('Invalid channel '.$channel.', must be one of: ' . implode(', ', self::$channels));
  31210. }
  31211. $channelFile = $this->config->get('home').'/update-channel';
  31212. $this->channel = $channel;
  31213. file_put_contents($channelFile, (Preg::isMatch('{^\d+$}D', $channel) ? 'stable' : $channel).PHP_EOL);
  31214. }
  31215. public function getLatest(?string $channel = null): array
  31216. {
  31217. $versions = $this->getVersionsData();
  31218. foreach ($versions[$channel ?: $this->getChannel()] as $version) {
  31219. if ($version['min-php'] <= PHP_VERSION_ID) {
  31220. return $version;
  31221. }
  31222. }
  31223. throw new \UnexpectedValueException('There is no version of Composer available for your PHP version ('.PHP_VERSION.')');
  31224. }
  31225. private function getVersionsData(): array
  31226. {
  31227. if (null === $this->versionsData) {
  31228. if ($this->config->get('disable-tls') === true) {
  31229. $protocol = 'http';
  31230. } else {
  31231. $protocol = 'https';
  31232. }
  31233. $this->versionsData = $this->httpDownloader->get($protocol . '://getcomposer.org/versions')->decodeJson();
  31234. }
  31235. return $this->versionsData;
  31236. }
  31237. }
  31238. <?php declare(strict_types=1);
  31239. namespace Composer\Util;
  31240. use Composer\Config;
  31241. use Composer\IO\IOInterface;
  31242. use Composer\Downloader\TransportException;
  31243. use Composer\Pcre\Preg;
  31244. class AuthHelper
  31245. {
  31246. protected $io;
  31247. protected $config;
  31248. private $displayedOriginAuthentications = array();
  31249. public function __construct(IOInterface $io, Config $config)
  31250. {
  31251. $this->io = $io;
  31252. $this->config = $config;
  31253. }
  31254. public function storeAuth(string $origin, $storeAuth): void
  31255. {
  31256. $store = false;
  31257. $configSource = $this->config->getAuthConfigSource();
  31258. if ($storeAuth === true) {
  31259. $store = $configSource;
  31260. } elseif ($storeAuth === 'prompt') {
  31261. $answer = $this->io->askAndValidate(
  31262. 'Do you want to store credentials for '.$origin.' in '.$configSource->getName().' ? [Yn] ',
  31263. function ($value): string {
  31264. $input = strtolower(substr(trim($value), 0, 1));
  31265. if (in_array($input, array('y','n'))) {
  31266. return $input;
  31267. }
  31268. throw new \RuntimeException('Please answer (y)es or (n)o');
  31269. },
  31270. null,
  31271. 'y'
  31272. );
  31273. if ($answer === 'y') {
  31274. $store = $configSource;
  31275. }
  31276. }
  31277. if ($store) {
  31278. $store->addConfigSetting(
  31279. 'http-basic.'.$origin,
  31280. $this->io->getAuthentication($origin)
  31281. );
  31282. }
  31283. }
  31284. public function promptAuthIfNeeded(string $url, string $origin, int $statusCode, ?string $reason = null, array $headers = array()): ?array
  31285. {
  31286. $storeAuth = false;
  31287. if (in_array($origin, $this->config->get('github-domains'), true)) {
  31288. $gitHubUtil = new GitHub($this->io, $this->config, null);
  31289. $message = "\n";
  31290. $rateLimited = $gitHubUtil->isRateLimited($headers);
  31291. $requiresSso = $gitHubUtil->requiresSso($headers);
  31292. if ($requiresSso) {
  31293. $ssoUrl = $gitHubUtil->getSsoUrl($headers);
  31294. $message = 'GitHub API token requires SSO authorization. Authorize this token at ' . $ssoUrl . "\n";
  31295. $this->io->writeError($message);
  31296. if (!$this->io->isInteractive()) {
  31297. throw new TransportException('Could not authenticate against ' . $origin, 403);
  31298. }
  31299. $this->io->ask('After authorizing your token, confirm that you would like to retry the request');
  31300. return array('retry' => true, 'storeAuth' => $storeAuth);
  31301. }
  31302. if ($rateLimited) {
  31303. $rateLimit = $gitHubUtil->getRateLimit($headers);
  31304. if ($this->io->hasAuthentication($origin)) {
  31305. $message = 'Review your configured GitHub OAuth token or enter a new one to go over the API rate limit.';
  31306. } else {
  31307. $message = 'Create a GitHub OAuth token to go over the API rate limit.';
  31308. }
  31309. $message = sprintf(
  31310. 'GitHub API limit (%d calls/hr) is exhausted, could not fetch '.$url.'. '.$message.' You can also wait until %s for the rate limit to reset.',
  31311. $rateLimit['limit'],
  31312. $rateLimit['reset']
  31313. )."\n";
  31314. } else {
  31315. $message .= 'Could not fetch '.$url.', please ';
  31316. if ($this->io->hasAuthentication($origin)) {
  31317. $message .= 'review your configured GitHub OAuth token or enter a new one to access private repos';
  31318. } else {
  31319. $message .= 'create a GitHub OAuth token to access private repos';
  31320. }
  31321. }
  31322. if (!$gitHubUtil->authorizeOAuth($origin)
  31323. && (!$this->io->isInteractive() || !$gitHubUtil->authorizeOAuthInteractively($origin, $message))
  31324. ) {
  31325. throw new TransportException('Could not authenticate against '.$origin, 401);
  31326. }
  31327. } elseif (in_array($origin, $this->config->get('gitlab-domains'), true)) {
  31328. $message = "\n".'Could not fetch '.$url.', enter your ' . $origin . ' credentials ' .($statusCode === 401 ? 'to access private repos' : 'to go over the API rate limit');
  31329. $gitLabUtil = new GitLab($this->io, $this->config, null);
  31330. if ($this->io->hasAuthentication($origin)) {
  31331. $auth = $this->io->getAuthentication($origin);
  31332. if (in_array($auth['password'], array('gitlab-ci-token', 'private-token', 'oauth2'), true)) {
  31333. throw new TransportException("Invalid credentials for '" . $url . "', aborting.", $statusCode);
  31334. }
  31335. }
  31336. if (!$gitLabUtil->authorizeOAuth($origin)
  31337. && (!$this->io->isInteractive() || !$gitLabUtil->authorizeOAuthInteractively(parse_url($url, PHP_URL_SCHEME), $origin, $message))
  31338. ) {
  31339. throw new TransportException('Could not authenticate against '.$origin, 401);
  31340. }
  31341. } elseif ($origin === 'bitbucket.org' || $origin === 'api.bitbucket.org') {
  31342. $askForOAuthToken = true;
  31343. $origin = 'bitbucket.org';
  31344. if ($this->io->hasAuthentication($origin)) {
  31345. $auth = $this->io->getAuthentication($origin);
  31346. if ($auth['username'] !== 'x-token-auth') {
  31347. $bitbucketUtil = new Bitbucket($this->io, $this->config);
  31348. $accessToken = $bitbucketUtil->requestToken($origin, $auth['username'], $auth['password']);
  31349. if (!empty($accessToken)) {
  31350. $this->io->setAuthentication($origin, 'x-token-auth', $accessToken);
  31351. $askForOAuthToken = false;
  31352. }
  31353. } else {
  31354. throw new TransportException('Could not authenticate against ' . $origin, 401);
  31355. }
  31356. }
  31357. if ($askForOAuthToken) {
  31358. $message = "\n".'Could not fetch ' . $url . ', please create a bitbucket OAuth token to ' . (($statusCode === 401 || $statusCode === 403) ? 'access private repos' : 'go over the API rate limit');
  31359. $bitBucketUtil = new Bitbucket($this->io, $this->config);
  31360. if (!$bitBucketUtil->authorizeOAuth($origin)
  31361. && (!$this->io->isInteractive() || !$bitBucketUtil->authorizeOAuthInteractively($origin, $message))
  31362. ) {
  31363. throw new TransportException('Could not authenticate against ' . $origin, 401);
  31364. }
  31365. }
  31366. } else {
  31367. if ($statusCode === 404) {
  31368. return null;
  31369. }
  31370. if (!$this->io->isInteractive()) {
  31371. if ($statusCode === 401) {
  31372. $message = "The '" . $url . "' URL required authentication.\nYou must be using the interactive console to authenticate";
  31373. } elseif ($statusCode === 403) {
  31374. $message = "The '" . $url . "' URL could not be accessed: " . $reason;
  31375. } else {
  31376. $message = "Unknown error code '" . $statusCode . "', reason: " . $reason;
  31377. }
  31378. throw new TransportException($message, $statusCode);
  31379. }
  31380. if ($this->io->hasAuthentication($origin)) {
  31381. throw new TransportException("Invalid credentials for '" . $url . "', aborting.", $statusCode);
  31382. }
  31383. $this->io->writeError(' Authentication required (<info>'.$origin.'</info>):');
  31384. $username = $this->io->ask(' Username: ');
  31385. $password = $this->io->askAndHideAnswer(' Password: ');
  31386. $this->io->setAuthentication($origin, $username, $password);
  31387. $storeAuth = $this->config->get('store-auths');
  31388. }
  31389. return array('retry' => true, 'storeAuth' => $storeAuth);
  31390. }
  31391. public function addAuthenticationHeader(array $headers, string $origin, string $url): array
  31392. {
  31393. if ($this->io->hasAuthentication($origin)) {
  31394. $authenticationDisplayMessage = null;
  31395. $auth = $this->io->getAuthentication($origin);
  31396. if ($auth['password'] === 'bearer') {
  31397. $headers[] = 'Authorization: Bearer '.$auth['username'];
  31398. } elseif ('github.com' === $origin && 'x-oauth-basic' === $auth['password']) {
  31399. if (Preg::isMatch('{^https?://api\.github\.com/}', $url)) {
  31400. $headers[] = 'Authorization: token '.$auth['username'];
  31401. $authenticationDisplayMessage = 'Using GitHub token authentication';
  31402. }
  31403. } elseif (
  31404. in_array($origin, $this->config->get('gitlab-domains'), true)
  31405. && in_array($auth['password'], array('oauth2', 'private-token', 'gitlab-ci-token'), true)
  31406. ) {
  31407. if ($auth['password'] === 'oauth2') {
  31408. $headers[] = 'Authorization: Bearer '.$auth['username'];
  31409. $authenticationDisplayMessage = 'Using GitLab OAuth token authentication';
  31410. } else {
  31411. $headers[] = 'PRIVATE-TOKEN: '.$auth['username'];
  31412. $authenticationDisplayMessage = 'Using GitLab private token authentication';
  31413. }
  31414. } elseif (
  31415. 'bitbucket.org' === $origin
  31416. && $url !== Bitbucket::OAUTH2_ACCESS_TOKEN_URL
  31417. && 'x-token-auth' === $auth['username']
  31418. ) {
  31419. if (!$this->isPublicBitBucketDownload($url)) {
  31420. $headers[] = 'Authorization: Bearer ' . $auth['password'];
  31421. $authenticationDisplayMessage = 'Using Bitbucket OAuth token authentication';
  31422. }
  31423. } else {
  31424. $authStr = base64_encode($auth['username'] . ':' . $auth['password']);
  31425. $headers[] = 'Authorization: Basic '.$authStr;
  31426. $authenticationDisplayMessage = 'Using HTTP basic authentication with username "' . $auth['username'] . '"';
  31427. }
  31428. if ($authenticationDisplayMessage && (!isset($this->displayedOriginAuthentications[$origin]) || $this->displayedOriginAuthentications[$origin] !== $authenticationDisplayMessage)) {
  31429. $this->io->writeError($authenticationDisplayMessage, true, IOInterface::DEBUG);
  31430. $this->displayedOriginAuthentications[$origin] = $authenticationDisplayMessage;
  31431. }
  31432. } elseif (in_array($origin, array('api.bitbucket.org', 'api.github.com'), true)) {
  31433. return $this->addAuthenticationHeader($headers, str_replace('api.', '', $origin), $url);
  31434. }
  31435. return $headers;
  31436. }
  31437. public function isPublicBitBucketDownload(string $urlToBitBucketFile): bool
  31438. {
  31439. $domain = parse_url($urlToBitBucketFile, PHP_URL_HOST);
  31440. if (strpos($domain, 'bitbucket.org') === false) {
  31441. return true;
  31442. }
  31443. $path = parse_url($urlToBitBucketFile, PHP_URL_PATH);
  31444. $pathParts = explode('/', $path);
  31445. return count($pathParts) >= 4 && $pathParts[3] == 'downloads';
  31446. }
  31447. }
  31448. <?php declare(strict_types=1);
  31449. namespace Composer\Util;
  31450. use Composer\Factory;
  31451. use Composer\IO\IOInterface;
  31452. use Composer\Config;
  31453. use Composer\Downloader\TransportException;
  31454. class Bitbucket
  31455. {
  31456. private $io;
  31457. private $config;
  31458. private $process;
  31459. private $httpDownloader;
  31460. private $token = null;
  31461. private $time;
  31462. public const OAUTH2_ACCESS_TOKEN_URL = 'https://bitbucket.org/site/oauth2/access_token';
  31463. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null, int $time = null)
  31464. {
  31465. $this->io = $io;
  31466. $this->config = $config;
  31467. $this->process = $process ?: new ProcessExecutor($io);
  31468. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  31469. $this->time = $time;
  31470. }
  31471. public function getToken(): string
  31472. {
  31473. if (!isset($this->token['access_token'])) {
  31474. return '';
  31475. }
  31476. return $this->token['access_token'];
  31477. }
  31478. public function authorizeOAuth(string $originUrl): bool
  31479. {
  31480. if ($originUrl !== 'bitbucket.org') {
  31481. return false;
  31482. }
  31483. if (0 === $this->process->execute('git config bitbucket.accesstoken', $output)) {
  31484. $this->io->setAuthentication($originUrl, 'x-token-auth', trim($output));
  31485. return true;
  31486. }
  31487. return false;
  31488. }
  31489. private function requestAccessToken(): bool
  31490. {
  31491. try {
  31492. $response = $this->httpDownloader->get(self::OAUTH2_ACCESS_TOKEN_URL, array(
  31493. 'retry-auth-failure' => false,
  31494. 'http' => array(
  31495. 'method' => 'POST',
  31496. 'content' => 'grant_type=client_credentials',
  31497. ),
  31498. ));
  31499. $token = $response->decodeJson();
  31500. if (!isset($token['expires_in']) || !isset($token['access_token'])) {
  31501. throw new \LogicException('Expected a token configured with expires_in and access_token present, got '.json_encode($token));
  31502. }
  31503. $this->token = $token;
  31504. } catch (TransportException $e) {
  31505. if ($e->getCode() === 400) {
  31506. $this->io->writeError('<error>Invalid OAuth consumer provided.</error>');
  31507. $this->io->writeError('This can have three reasons:');
  31508. $this->io->writeError('1. You are authenticating with a bitbucket username/password combination');
  31509. $this->io->writeError('2. You are using an OAuth consumer, but didn\'t configure a (dummy) callback url');
  31510. $this->io->writeError('3. You are using an OAuth consumer, but didn\'t configure it as private consumer');
  31511. return false;
  31512. }
  31513. if (in_array($e->getCode(), array(403, 401))) {
  31514. $this->io->writeError('<error>Invalid OAuth consumer provided.</error>');
  31515. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  31516. return false;
  31517. }
  31518. throw $e;
  31519. }
  31520. return true;
  31521. }
  31522. public function authorizeOAuthInteractively(string $originUrl, string $message = null): bool
  31523. {
  31524. if ($message) {
  31525. $this->io->writeError($message);
  31526. }
  31527. $url = 'https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/';
  31528. $this->io->writeError(sprintf('Follow the instructions on %s', $url));
  31529. $this->io->writeError(sprintf('to create a consumer. It will be stored in "%s" for future use by Composer.', $this->config->getAuthConfigSource()->getName()));
  31530. $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)');
  31531. $consumerKey = trim((string) $this->io->askAndHideAnswer('Consumer Key (hidden): '));
  31532. if (!$consumerKey) {
  31533. $this->io->writeError('<warning>No consumer key given, aborting.</warning>');
  31534. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  31535. return false;
  31536. }
  31537. $consumerSecret = trim((string) $this->io->askAndHideAnswer('Consumer Secret (hidden): '));
  31538. if (!$consumerSecret) {
  31539. $this->io->writeError('<warning>No consumer secret given, aborting.</warning>');
  31540. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  31541. return false;
  31542. }
  31543. $this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret);
  31544. if (!$this->requestAccessToken()) {
  31545. return false;
  31546. }
  31547. $this->storeInAuthConfig($originUrl, $consumerKey, $consumerSecret);
  31548. $this->config->getAuthConfigSource()->removeConfigSetting('http-basic.' . $originUrl);
  31549. $this->io->writeError('<info>Consumer stored successfully.</info>');
  31550. return true;
  31551. }
  31552. public function requestToken(string $originUrl, string $consumerKey, string $consumerSecret): string
  31553. {
  31554. if ($this->token !== null || $this->getTokenFromConfig($originUrl)) {
  31555. return $this->token['access_token'];
  31556. }
  31557. $this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret);
  31558. if (!$this->requestAccessToken()) {
  31559. return '';
  31560. }
  31561. $this->storeInAuthConfig($originUrl, $consumerKey, $consumerSecret);
  31562. if (!isset($this->token['access_token'])) {
  31563. throw new \LogicException('Failed to initialize token above');
  31564. }
  31565. return $this->token['access_token'];
  31566. }
  31567. private function storeInAuthConfig(string $originUrl, string $consumerKey, string $consumerSecret): void
  31568. {
  31569. $this->config->getConfigSource()->removeConfigSetting('bitbucket-oauth.'.$originUrl);
  31570. if (null === $this->token || !isset($this->token['expires_in'])) {
  31571. throw new \LogicException('Expected a token configured with expires_in present, got '.json_encode($this->token));
  31572. }
  31573. $time = null === $this->time ? time() : $this->time;
  31574. $consumer = array(
  31575. "consumer-key" => $consumerKey,
  31576. "consumer-secret" => $consumerSecret,
  31577. "access-token" => $this->token['access_token'],
  31578. "access-token-expiration" => $time + $this->token['expires_in'],
  31579. );
  31580. $this->config->getAuthConfigSource()->addConfigSetting('bitbucket-oauth.'.$originUrl, $consumer);
  31581. }
  31582. private function getTokenFromConfig(string $originUrl): bool
  31583. {
  31584. $authConfig = $this->config->get('bitbucket-oauth');
  31585. if (
  31586. !isset($authConfig[$originUrl]['access-token'], $authConfig[$originUrl]['access-token-expiration'])
  31587. || time() > $authConfig[$originUrl]['access-token-expiration']
  31588. ) {
  31589. return false;
  31590. }
  31591. $this->token = array(
  31592. 'access_token' => $authConfig[$originUrl]['access-token'],
  31593. );
  31594. return true;
  31595. }
  31596. }
  31597. <?php declare(strict_types=1);
  31598. namespace Composer\Util;
  31599. use Composer\Pcre\Preg;
  31600. class ComposerMirror
  31601. {
  31602. public static function processUrl(string $mirrorUrl, string $packageName, string $version, ?string $reference, ?string $type, ?string $prettyVersion = null): string
  31603. {
  31604. if ($reference) {
  31605. $reference = Preg::isMatch('{^([a-f0-9]*|%reference%)$}', $reference) ? $reference : md5($reference);
  31606. }
  31607. $version = strpos($version, '/') === false ? $version : md5($version);
  31608. $from = array('%package%', '%version%', '%reference%', '%type%');
  31609. $to = array($packageName, $version, $reference, $type);
  31610. if (null !== $prettyVersion) {
  31611. $from[] = '%prettyVersion%';
  31612. $to[] = $prettyVersion;
  31613. }
  31614. return str_replace($from, $to, $mirrorUrl);
  31615. }
  31616. public static function processGitUrl(string $mirrorUrl, string $packageName, string $url, ?string $type): string
  31617. {
  31618. if (Preg::isMatch('#^(?:(?:https?|git)://github\.com/|git@github\.com:)([^/]+)/(.+?)(?:\.git)?$#', $url, $match)) {
  31619. $url = 'gh-'.$match[1].'/'.$match[2];
  31620. } elseif (Preg::isMatch('#^https://bitbucket\.org/([^/]+)/(.+?)(?:\.git)?/?$#', $url, $match)) {
  31621. $url = 'bb-'.$match[1].'/'.$match[2];
  31622. } else {
  31623. $url = Preg::replace('{[^a-z0-9_.-]}i', '-', trim($url, '/'));
  31624. }
  31625. return str_replace(
  31626. array('%package%', '%normalizedUrl%', '%type%'),
  31627. array($packageName, $url, $type),
  31628. $mirrorUrl
  31629. );
  31630. }
  31631. public static function processHgUrl(string $mirrorUrl, string $packageName, string $url, string $type): string
  31632. {
  31633. return self::processGitUrl($mirrorUrl, $packageName, $url, $type);
  31634. }
  31635. }
  31636. <?php declare(strict_types=1);
  31637. namespace Composer\Util;
  31638. use Composer\Package\Loader\ArrayLoader;
  31639. use Composer\Package\Loader\ValidatingArrayLoader;
  31640. use Composer\Package\Loader\InvalidPackageException;
  31641. use Composer\Json\JsonValidationException;
  31642. use Composer\IO\IOInterface;
  31643. use Composer\Json\JsonFile;
  31644. use Composer\Pcre\Preg;
  31645. use Composer\Spdx\SpdxLicenses;
  31646. use Seld\JsonLint\DuplicateKeyException;
  31647. use Seld\JsonLint\JsonParser;
  31648. class ConfigValidator
  31649. {
  31650. public const CHECK_VERSION = 1;
  31651. private $io;
  31652. public function __construct(IOInterface $io)
  31653. {
  31654. $this->io = $io;
  31655. }
  31656. public function validate(string $file, int $arrayLoaderValidationFlags = ValidatingArrayLoader::CHECK_ALL, int $flags = self::CHECK_VERSION): array
  31657. {
  31658. $errors = array();
  31659. $publishErrors = array();
  31660. $warnings = array();
  31661. $laxValid = false;
  31662. $manifest = null;
  31663. try {
  31664. $json = new JsonFile($file, null, $this->io);
  31665. $manifest = $json->read();
  31666. $json->validateSchema(JsonFile::LAX_SCHEMA);
  31667. $laxValid = true;
  31668. $json->validateSchema();
  31669. } catch (JsonValidationException $e) {
  31670. foreach ($e->getErrors() as $message) {
  31671. if ($laxValid) {
  31672. $publishErrors[] = $message;
  31673. } else {
  31674. $errors[] = $message;
  31675. }
  31676. }
  31677. } catch (\Exception $e) {
  31678. $errors[] = $e->getMessage();
  31679. return array($errors, $publishErrors, $warnings);
  31680. }
  31681. if (is_array($manifest)) {
  31682. $jsonParser = new JsonParser();
  31683. try {
  31684. $jsonParser->parse((string) file_get_contents($file), JsonParser::DETECT_KEY_CONFLICTS);
  31685. } catch (DuplicateKeyException $e) {
  31686. $details = $e->getDetails();
  31687. $warnings[] = 'Key '.$details['key'].' is a duplicate in '.$file.' at line '.$details['line'];
  31688. }
  31689. }
  31690. if (empty($manifest['license'])) {
  31691. $warnings[] = 'No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.';
  31692. } else {
  31693. $licenses = (array) $manifest['license'];
  31694. foreach ($licenses as $key => $license) {
  31695. if ('proprietary' === $license) {
  31696. unset($licenses[$key]);
  31697. }
  31698. }
  31699. $licenseValidator = new SpdxLicenses();
  31700. foreach ($licenses as $license) {
  31701. $spdxLicense = $licenseValidator->getLicenseByIdentifier($license);
  31702. if ($spdxLicense && $spdxLicense[3]) {
  31703. if (Preg::isMatch('{^[AL]?GPL-[123](\.[01])?\+$}i', $license)) {
  31704. $warnings[] = sprintf(
  31705. 'License "%s" is a deprecated SPDX license identifier, use "'.str_replace('+', '', $license).'-or-later" instead',
  31706. $license
  31707. );
  31708. } elseif (Preg::isMatch('{^[AL]?GPL-[123](\.[01])?$}i', $license)) {
  31709. $warnings[] = sprintf(
  31710. 'License "%s" is a deprecated SPDX license identifier, use "'.$license.'-only" or "'.$license.'-or-later" instead',
  31711. $license
  31712. );
  31713. } else {
  31714. $warnings[] = sprintf(
  31715. 'License "%s" is a deprecated SPDX license identifier, see https://spdx.org/licenses/',
  31716. $license
  31717. );
  31718. }
  31719. }
  31720. }
  31721. }
  31722. if (($flags & self::CHECK_VERSION) && isset($manifest['version'])) {
  31723. $warnings[] = 'The version field is present, it is recommended to leave it out if the package is published on Packagist.';
  31724. }
  31725. if (!empty($manifest['name']) && Preg::isMatch('{[A-Z]}', $manifest['name'])) {
  31726. $suggestName = Preg::replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $manifest['name']);
  31727. $suggestName = strtolower($suggestName);
  31728. $publishErrors[] = sprintf(
  31729. '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.',
  31730. $manifest['name'],
  31731. $suggestName
  31732. );
  31733. }
  31734. if (!empty($manifest['type']) && $manifest['type'] == 'composer-installer') {
  31735. $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.";
  31736. }
  31737. if (isset($manifest['require'], $manifest['require-dev'])) {
  31738. $requireOverrides = array_intersect_key($manifest['require'], $manifest['require-dev']);
  31739. if (!empty($requireOverrides)) {
  31740. $plural = (count($requireOverrides) > 1) ? 'are' : 'is';
  31741. $warnings[] = implode(', ', array_keys($requireOverrides)). " {$plural} required both in require and require-dev, this can lead to unexpected behavior";
  31742. }
  31743. }
  31744. foreach (array('provide', 'replace') as $linkType) {
  31745. if (isset($manifest[$linkType])) {
  31746. foreach (array('require', 'require-dev') as $requireType) {
  31747. if (isset($manifest[$requireType])) {
  31748. foreach ($manifest[$linkType] as $provide => $constraint) {
  31749. if (isset($manifest[$requireType][$provide])) {
  31750. $warnings[] = 'The package ' . $provide . ' in '.$requireType.' is also listed in '.$linkType.' which satisfies the requirement. Remove it from '.$linkType.' if you wish to install it.';
  31751. }
  31752. }
  31753. }
  31754. }
  31755. }
  31756. }
  31757. $require = $manifest['require'] ?? array();
  31758. $requireDev = $manifest['require-dev'] ?? array();
  31759. $packages = array_merge($require, $requireDev);
  31760. foreach ($packages as $package => $version) {
  31761. if (Preg::isMatch('/#/', $version)) {
  31762. $warnings[] = sprintf(
  31763. 'The package "%s" is pointing to a commit-ref, this is bad practice and can cause unforeseen issues.',
  31764. $package
  31765. );
  31766. }
  31767. }
  31768. $scriptsDescriptions = $manifest['scripts-descriptions'] ?? array();
  31769. $scripts = $manifest['scripts'] ?? array();
  31770. foreach ($scriptsDescriptions as $scriptName => $scriptDescription) {
  31771. if (!array_key_exists($scriptName, $scripts)) {
  31772. $warnings[] = sprintf(
  31773. 'Description for non-existent script "%s" found in "scripts-descriptions"',
  31774. $scriptName
  31775. );
  31776. }
  31777. }
  31778. if (isset($manifest['autoload']['psr-0'][''])) {
  31779. $warnings[] = "Defining autoload.psr-0 with an empty namespace prefix is a bad idea for performance";
  31780. }
  31781. if (isset($manifest['autoload']['psr-4'][''])) {
  31782. $warnings[] = "Defining autoload.psr-4 with an empty namespace prefix is a bad idea for performance";
  31783. }
  31784. $loader = new ValidatingArrayLoader(new ArrayLoader(), true, null, $arrayLoaderValidationFlags);
  31785. try {
  31786. if (!isset($manifest['version'])) {
  31787. $manifest['version'] = '1.0.0';
  31788. }
  31789. if (!isset($manifest['name'])) {
  31790. $manifest['name'] = 'dummy/dummy';
  31791. }
  31792. $loader->load($manifest);
  31793. } catch (InvalidPackageException $e) {
  31794. $errors = array_merge($errors, $e->getErrors());
  31795. }
  31796. $warnings = array_merge($warnings, $loader->getWarnings());
  31797. return array($errors, $publishErrors, $warnings);
  31798. }
  31799. }
  31800. <?php declare(strict_types=1);
  31801. namespace Composer\Util;
  31802. use Composer\IO\IOInterface;
  31803. class ErrorHandler
  31804. {
  31805. private static $io;
  31806. public static function handle(int $level, string $message, string $file, int $line): bool
  31807. {
  31808. if (!(error_reporting() & $level)) {
  31809. return true;
  31810. }
  31811. if (filter_var(ini_get('xdebug.scream'), FILTER_VALIDATE_BOOLEAN)) {
  31812. $message .= "\n\nWarning: You have xdebug.scream enabled, the warning above may be".
  31813. "\na legitimately suppressed error that you were not supposed to see.";
  31814. }
  31815. if ($level !== E_DEPRECATED && $level !== E_USER_DEPRECATED) {
  31816. throw new \ErrorException($message, 0, $level, $file, $line);
  31817. }
  31818. if (self::$io) {
  31819. self::$io->writeError('<warning>Deprecation Notice: '.$message.' in '.$file.':'.$line.'</warning>');
  31820. if (self::$io->isVerbose()) {
  31821. self::$io->writeError('<warning>Stack trace:</warning>');
  31822. self::$io->writeError(array_filter(array_map(function ($a): ?string {
  31823. if (isset($a['line'], $a['file'])) {
  31824. return '<warning> '.$a['file'].':'.$a['line'].'</warning>';
  31825. }
  31826. return null;
  31827. }, array_slice(debug_backtrace(), 2))));
  31828. }
  31829. }
  31830. return true;
  31831. }
  31832. public static function register(IOInterface $io = null): void
  31833. {
  31834. set_error_handler(array(__CLASS__, 'handle'));
  31835. error_reporting(E_ALL | E_STRICT);
  31836. self::$io = $io;
  31837. }
  31838. }
  31839. <?php declare(strict_types=1);
  31840. namespace Composer\Util;
  31841. use Composer\Pcre\Preg;
  31842. use React\Promise\PromiseInterface;
  31843. use RecursiveDirectoryIterator;
  31844. use RecursiveIteratorIterator;
  31845. use Symfony\Component\Filesystem\Exception\IOException;
  31846. use Symfony\Component\Finder\Finder;
  31847. class Filesystem
  31848. {
  31849. private $processExecutor;
  31850. public function __construct(ProcessExecutor $executor = null)
  31851. {
  31852. $this->processExecutor = $executor;
  31853. }
  31854. public function remove(string $file)
  31855. {
  31856. if (is_dir($file)) {
  31857. return $this->removeDirectory($file);
  31858. }
  31859. if (file_exists($file)) {
  31860. return $this->unlink($file);
  31861. }
  31862. return false;
  31863. }
  31864. public function isDirEmpty(string $dir)
  31865. {
  31866. $finder = Finder::create()
  31867. ->ignoreVCS(false)
  31868. ->ignoreDotFiles(false)
  31869. ->depth(0)
  31870. ->in($dir);
  31871. return \count($finder) === 0;
  31872. }
  31873. public function emptyDirectory(string $dir, bool $ensureDirectoryExists = true)
  31874. {
  31875. if (is_link($dir) && file_exists($dir)) {
  31876. $this->unlink($dir);
  31877. }
  31878. if ($ensureDirectoryExists) {
  31879. $this->ensureDirectoryExists($dir);
  31880. }
  31881. if (is_dir($dir)) {
  31882. $finder = Finder::create()
  31883. ->ignoreVCS(false)
  31884. ->ignoreDotFiles(false)
  31885. ->depth(0)
  31886. ->in($dir);
  31887. foreach ($finder as $path) {
  31888. $this->remove((string) $path);
  31889. }
  31890. }
  31891. }
  31892. public function removeDirectory(string $directory)
  31893. {
  31894. $edgeCaseResult = $this->removeEdgeCases($directory);
  31895. if ($edgeCaseResult !== null) {
  31896. return $edgeCaseResult;
  31897. }
  31898. if (Platform::isWindows()) {
  31899. $cmd = sprintf('rmdir /S /Q %s', ProcessExecutor::escape(realpath($directory)));
  31900. } else {
  31901. $cmd = sprintf('rm -rf %s', ProcessExecutor::escape($directory));
  31902. }
  31903. $result = $this->getProcess()->execute($cmd, $output) === 0;
  31904. clearstatcache();
  31905. if ($result && !is_dir($directory)) {
  31906. return true;
  31907. }
  31908. return $this->removeDirectoryPhp($directory);
  31909. }
  31910. public function removeDirectoryAsync(string $directory)
  31911. {
  31912. $edgeCaseResult = $this->removeEdgeCases($directory);
  31913. if ($edgeCaseResult !== null) {
  31914. return \React\Promise\resolve($edgeCaseResult);
  31915. }
  31916. if (Platform::isWindows()) {
  31917. $cmd = sprintf('rmdir /S /Q %s', ProcessExecutor::escape(realpath($directory)));
  31918. } else {
  31919. $cmd = sprintf('rm -rf %s', ProcessExecutor::escape($directory));
  31920. }
  31921. $promise = $this->getProcess()->executeAsync($cmd);
  31922. return $promise->then(function ($process) use ($directory) {
  31923. clearstatcache();
  31924. if ($process->isSuccessful()) {
  31925. if (!is_dir($directory)) {
  31926. return \React\Promise\resolve(true);
  31927. }
  31928. }
  31929. return \React\Promise\resolve($this->removeDirectoryPhp($directory));
  31930. });
  31931. }
  31932. private function removeEdgeCases(string $directory, bool $fallbackToPhp = true): ?bool
  31933. {
  31934. if ($this->isSymlinkedDirectory($directory)) {
  31935. return $this->unlinkSymlinkedDirectory($directory);
  31936. }
  31937. if ($this->isJunction($directory)) {
  31938. return $this->removeJunction($directory);
  31939. }
  31940. if (is_link($directory)) {
  31941. return unlink($directory);
  31942. }
  31943. if (!is_dir($directory) || !file_exists($directory)) {
  31944. return true;
  31945. }
  31946. if (Preg::isMatch('{^(?:[a-z]:)?[/\\\\]+$}i', $directory)) {
  31947. throw new \RuntimeException('Aborting an attempted deletion of '.$directory.', this was probably not intended, if it is a real use case please report it.');
  31948. }
  31949. if (!\function_exists('proc_open') && $fallbackToPhp) {
  31950. return $this->removeDirectoryPhp($directory);
  31951. }
  31952. return null;
  31953. }
  31954. public function removeDirectoryPhp(string $directory)
  31955. {
  31956. $edgeCaseResult = $this->removeEdgeCases($directory, false);
  31957. if ($edgeCaseResult !== null) {
  31958. return $edgeCaseResult;
  31959. }
  31960. try {
  31961. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  31962. } catch (\UnexpectedValueException $e) {
  31963. clearstatcache();
  31964. usleep(100000);
  31965. if (!is_dir($directory)) {
  31966. return true;
  31967. }
  31968. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  31969. }
  31970. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
  31971. foreach ($ri as $file) {
  31972. if ($file->isDir()) {
  31973. $this->rmdir($file->getPathname());
  31974. } else {
  31975. $this->unlink($file->getPathname());
  31976. }
  31977. }
  31978. unset($ri, $it, $file);
  31979. return $this->rmdir($directory);
  31980. }
  31981. public function ensureDirectoryExists(string $directory)
  31982. {
  31983. if (!is_dir($directory)) {
  31984. if (file_exists($directory)) {
  31985. throw new \RuntimeException(
  31986. $directory.' exists and is not a directory.'
  31987. );
  31988. }
  31989. if (!@mkdir($directory, 0777, true)) {
  31990. throw new \RuntimeException(
  31991. $directory.' does not exist and could not be created.'
  31992. );
  31993. }
  31994. }
  31995. }
  31996. public function unlink(string $path)
  31997. {
  31998. $unlinked = @$this->unlinkImplementation($path);
  31999. if (!$unlinked) {
  32000. if (Platform::isWindows()) {
  32001. usleep(350000);
  32002. $unlinked = @$this->unlinkImplementation($path);
  32003. }
  32004. if (!$unlinked) {
  32005. $error = error_get_last();
  32006. $message = 'Could not delete '.$path.': ' . ($error['message'] ?? '');
  32007. if (Platform::isWindows()) {
  32008. $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed";
  32009. }
  32010. throw new \RuntimeException($message);
  32011. }
  32012. }
  32013. return true;
  32014. }
  32015. public function rmdir(string $path)
  32016. {
  32017. $deleted = @rmdir($path);
  32018. if (!$deleted) {
  32019. if (Platform::isWindows()) {
  32020. usleep(350000);
  32021. $deleted = @rmdir($path);
  32022. }
  32023. if (!$deleted) {
  32024. $error = error_get_last();
  32025. $message = 'Could not delete '.$path.': ' . ($error['message'] ?? '');
  32026. if (Platform::isWindows()) {
  32027. $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed";
  32028. }
  32029. throw new \RuntimeException($message);
  32030. }
  32031. }
  32032. return true;
  32033. }
  32034. public function copyThenRemove(string $source, string $target)
  32035. {
  32036. $this->copy($source, $target);
  32037. if (!is_dir($source)) {
  32038. $this->unlink($source);
  32039. return;
  32040. }
  32041. $this->removeDirectoryPhp($source);
  32042. }
  32043. public function copy(string $source, string $target)
  32044. {
  32045. if (!is_dir($source)) {
  32046. return copy($source, $target);
  32047. }
  32048. $it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
  32049. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);
  32050. $this->ensureDirectoryExists($target);
  32051. $result = true;
  32052. foreach ($ri as $file) {
  32053. $targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathname();
  32054. if ($file->isDir()) {
  32055. $this->ensureDirectoryExists($targetPath);
  32056. } else {
  32057. $result = $result && copy($file->getPathname(), $targetPath);
  32058. }
  32059. }
  32060. return $result;
  32061. }
  32062. public function rename(string $source, string $target)
  32063. {
  32064. if (true === @rename($source, $target)) {
  32065. return;
  32066. }
  32067. if (!\function_exists('proc_open')) {
  32068. $this->copyThenRemove($source, $target);
  32069. return;
  32070. }
  32071. if (Platform::isWindows()) {
  32072. $command = sprintf('xcopy %s %s /E /I /Q /Y', ProcessExecutor::escape($source), ProcessExecutor::escape($target));
  32073. $result = $this->getProcess()->execute($command, $output);
  32074. clearstatcache();
  32075. if (0 === $result) {
  32076. $this->remove($source);
  32077. return;
  32078. }
  32079. } else {
  32080. $command = sprintf('mv %s %s', ProcessExecutor::escape($source), ProcessExecutor::escape($target));
  32081. $result = $this->getProcess()->execute($command, $output);
  32082. clearstatcache();
  32083. if (0 === $result) {
  32084. return;
  32085. }
  32086. }
  32087. $this->copyThenRemove($source, $target);
  32088. }
  32089. public function findShortestPath(string $from, string $to, bool $directories = false)
  32090. {
  32091. if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
  32092. throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
  32093. }
  32094. $from = $this->normalizePath($from);
  32095. $to = $this->normalizePath($to);
  32096. if ($directories) {
  32097. $from = rtrim($from, '/') . '/dummy_file';
  32098. }
  32099. if (\dirname($from) === \dirname($to)) {
  32100. return './'.basename($to);
  32101. }
  32102. $commonPath = $to;
  32103. while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !Preg::isMatch('{^[A-Z]:/?$}i', $commonPath)) {
  32104. $commonPath = strtr(\dirname($commonPath), '\\', '/');
  32105. }
  32106. if (0 !== strpos($from, $commonPath) || '/' === $commonPath) {
  32107. return $to;
  32108. }
  32109. $commonPath = rtrim($commonPath, '/') . '/';
  32110. $sourcePathDepth = substr_count((string) substr($from, \strlen($commonPath)), '/');
  32111. $commonPathCode = str_repeat('../', $sourcePathDepth);
  32112. $result = $commonPathCode . substr($to, \strlen($commonPath));
  32113. if (\strlen($result) === 0) {
  32114. return './';
  32115. }
  32116. return $result;
  32117. }
  32118. public function findShortestPathCode(string $from, string $to, bool $directories = false, bool $staticCode = false)
  32119. {
  32120. if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
  32121. throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
  32122. }
  32123. $from = $this->normalizePath($from);
  32124. $to = $this->normalizePath($to);
  32125. if ($from === $to) {
  32126. return $directories ? '__DIR__' : '__FILE__';
  32127. }
  32128. $commonPath = $to;
  32129. while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !Preg::isMatch('{^[A-Z]:/?$}i', $commonPath) && '.' !== $commonPath) {
  32130. $commonPath = strtr(\dirname($commonPath), '\\', '/');
  32131. }
  32132. if (0 !== strpos($from, $commonPath) || '/' === $commonPath || '.' === $commonPath) {
  32133. return var_export($to, true);
  32134. }
  32135. $commonPath = rtrim($commonPath, '/') . '/';
  32136. if (strpos($to, $from.'/') === 0) {
  32137. return '__DIR__ . '.var_export((string) substr($to, \strlen($from)), true);
  32138. }
  32139. $sourcePathDepth = substr_count((string) substr($from, \strlen($commonPath)), '/') + (int) $directories;
  32140. if ($staticCode) {
  32141. $commonPathCode = "__DIR__ . '".str_repeat('/..', $sourcePathDepth)."'";
  32142. } else {
  32143. $commonPathCode = str_repeat('dirname(', $sourcePathDepth).'__DIR__'.str_repeat(')', $sourcePathDepth);
  32144. }
  32145. $relTarget = (string) substr($to, \strlen($commonPath));
  32146. return $commonPathCode . (\strlen($relTarget) > 0 ? '.' . var_export('/' . $relTarget, true) : '');
  32147. }
  32148. public function isAbsolutePath(string $path)
  32149. {
  32150. return strpos($path, '/') === 0 || substr($path, 1, 1) === ':' || strpos($path, '\\\\') === 0;
  32151. }
  32152. public function size(string $path)
  32153. {
  32154. if (!file_exists($path)) {
  32155. throw new \RuntimeException("$path does not exist.");
  32156. }
  32157. if (is_dir($path)) {
  32158. return $this->directorySize($path);
  32159. }
  32160. return (int) filesize($path);
  32161. }
  32162. public function normalizePath(string $path)
  32163. {
  32164. $parts = array();
  32165. $path = strtr($path, '\\', '/');
  32166. $prefix = '';
  32167. $absolute = '';
  32168. if (strpos($path, '//') === 0 && \strlen($path) > 2) {
  32169. $absolute = '//';
  32170. $path = substr($path, 2);
  32171. }
  32172. if (Preg::isMatch('{^( [0-9a-z]{2,}+: (?: // (?: [a-z]: )? )? | [a-z]: )}ix', $path, $match)) {
  32173. $prefix = $match[1];
  32174. $path = substr($path, \strlen($prefix));
  32175. }
  32176. if (strpos($path, '/') === 0) {
  32177. $absolute = '/';
  32178. $path = substr($path, 1);
  32179. }
  32180. $up = false;
  32181. foreach (explode('/', $path) as $chunk) {
  32182. if ('..' === $chunk && (\strlen($absolute) > 0 || $up)) {
  32183. array_pop($parts);
  32184. $up = !(\count($parts) === 0 || '..' === end($parts));
  32185. } elseif ('.' !== $chunk && '' !== $chunk) {
  32186. $parts[] = $chunk;
  32187. $up = '..' !== $chunk;
  32188. }
  32189. }
  32190. $prefix = Preg::replaceCallback('{(^|://)[a-z]:$}i', function (array $m) { return strtoupper($m[0]); }, $prefix);
  32191. return $prefix.$absolute.implode('/', $parts);
  32192. }
  32193. public static function trimTrailingSlash(string $path)
  32194. {
  32195. if (!Preg::isMatch('{^[/\\\\]+$}', $path)) {
  32196. $path = rtrim($path, '/\\');
  32197. }
  32198. return $path;
  32199. }
  32200. public static function isLocalPath(string $path)
  32201. {
  32202. return Preg::isMatch('{^(file://(?!//)|/(?!/)|/?[a-z]:[\\\\/]|\.\.[\\\\/]|[a-z0-9_.-]+[\\\\/])}i', $path);
  32203. }
  32204. public static function getPlatformPath(string $path)
  32205. {
  32206. if (Platform::isWindows()) {
  32207. $path = Preg::replace('{^(?:file:///([a-z]):?/)}i', 'file://$1:/', $path);
  32208. }
  32209. return Preg::replace('{^file://}i', '', $path);
  32210. }
  32211. public static function isReadable(string $path)
  32212. {
  32213. if (is_readable($path)) {
  32214. return true;
  32215. }
  32216. if (is_file($path)) {
  32217. return false !== Silencer::call('file_get_contents', $path, false, null, 0, 1);
  32218. }
  32219. if (is_dir($path)) {
  32220. return false !== Silencer::call('opendir', $path);
  32221. }
  32222. return false;
  32223. }
  32224. protected function directorySize(string $directory)
  32225. {
  32226. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  32227. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
  32228. $size = 0;
  32229. foreach ($ri as $file) {
  32230. if ($file->isFile()) {
  32231. $size += $file->getSize();
  32232. }
  32233. }
  32234. return $size;
  32235. }
  32236. protected function getProcess()
  32237. {
  32238. if (null === $this->processExecutor) {
  32239. $this->processExecutor = new ProcessExecutor();
  32240. }
  32241. return $this->processExecutor;
  32242. }
  32243. private function unlinkImplementation(string $path): bool
  32244. {
  32245. if (Platform::isWindows() && is_dir($path) && is_link($path)) {
  32246. return rmdir($path);
  32247. }
  32248. return unlink($path);
  32249. }
  32250. public function relativeSymlink(string $target, string $link)
  32251. {
  32252. if (!function_exists('symlink')) {
  32253. return false;
  32254. }
  32255. $cwd = Platform::getCwd();
  32256. $relativePath = $this->findShortestPath($link, $target);
  32257. chdir(\dirname($link));
  32258. $result = @symlink($relativePath, $link);
  32259. chdir($cwd);
  32260. return $result;
  32261. }
  32262. public function isSymlinkedDirectory(string $directory)
  32263. {
  32264. if (!is_dir($directory)) {
  32265. return false;
  32266. }
  32267. $resolved = $this->resolveSymlinkedDirectorySymlink($directory);
  32268. return is_link($resolved);
  32269. }
  32270. private function unlinkSymlinkedDirectory(string $directory): bool
  32271. {
  32272. $resolved = $this->resolveSymlinkedDirectorySymlink($directory);
  32273. return $this->unlink($resolved);
  32274. }
  32275. private function resolveSymlinkedDirectorySymlink(string $pathname): string
  32276. {
  32277. if (!is_dir($pathname)) {
  32278. return $pathname;
  32279. }
  32280. $resolved = rtrim($pathname, '/');
  32281. if (0 === \strlen($resolved)) {
  32282. return $pathname;
  32283. }
  32284. return $resolved;
  32285. }
  32286. public function junction(string $target, string $junction)
  32287. {
  32288. if (!Platform::isWindows()) {
  32289. throw new \LogicException(sprintf('Function %s is not available on non-Windows platform', __CLASS__));
  32290. }
  32291. if (!is_dir($target)) {
  32292. throw new IOException(sprintf('Cannot junction to "%s" as it is not a directory.', $target), 0, null, $target);
  32293. }
  32294. $cmd = sprintf(
  32295. 'mklink /J %s %s',
  32296. ProcessExecutor::escape(str_replace('/', DIRECTORY_SEPARATOR, $junction)),
  32297. ProcessExecutor::escape(realpath($target))
  32298. );
  32299. if ($this->getProcess()->execute($cmd, $output) !== 0) {
  32300. throw new IOException(sprintf('Failed to create junction to "%s" at "%s".', $target, $junction), 0, null, $target);
  32301. }
  32302. clearstatcache(true, $junction);
  32303. }
  32304. public function isJunction(string $junction)
  32305. {
  32306. if (!Platform::isWindows()) {
  32307. return false;
  32308. }
  32309. clearstatcache(true, $junction);
  32310. if (!is_dir($junction) || is_link($junction)) {
  32311. return false;
  32312. }
  32313. $stat = lstat($junction);
  32314. return is_array($stat) ? 0x4000 !== ($stat['mode'] & 0xF000) : false;
  32315. }
  32316. public function removeJunction(string $junction)
  32317. {
  32318. if (!Platform::isWindows()) {
  32319. return false;
  32320. }
  32321. $junction = rtrim(str_replace('/', DIRECTORY_SEPARATOR, $junction), DIRECTORY_SEPARATOR);
  32322. if (!$this->isJunction($junction)) {
  32323. throw new IOException(sprintf('%s is not a junction and thus cannot be removed as one', $junction));
  32324. }
  32325. return $this->rmdir($junction);
  32326. }
  32327. public function filePutContentsIfModified(string $path, string $content)
  32328. {
  32329. $currentContent = Silencer::call('file_get_contents', $path);
  32330. if (false === $currentContent || $currentContent !== $content) {
  32331. return file_put_contents($path, $content);
  32332. }
  32333. return 0;
  32334. }
  32335. public function safeCopy(string $source, string $target)
  32336. {
  32337. if (!file_exists($target) || !file_exists($source) || !$this->filesAreEqual($source, $target)) {
  32338. $sourceHandle = fopen($source, 'r');
  32339. assert($sourceHandle !== false, 'Could not open "'.$source.'" for reading.');
  32340. $targetHandle = fopen($target, 'w+');
  32341. assert($targetHandle !== false, 'Could not open "'.$target.'" for writing.');
  32342. stream_copy_to_stream($sourceHandle, $targetHandle);
  32343. fclose($sourceHandle);
  32344. fclose($targetHandle);
  32345. }
  32346. }
  32347. private function filesAreEqual(string $a, string $b): bool
  32348. {
  32349. if (filesize($a) !== filesize($b)) {
  32350. return false;
  32351. }
  32352. $aHandle = fopen($a, 'rb');
  32353. assert($aHandle !== false, 'Could not open "'.$a.'" for reading.');
  32354. $bHandle = fopen($b, 'rb');
  32355. assert($bHandle !== false, 'Could not open "'.$b.'" for reading.');
  32356. $result = true;
  32357. while (!feof($aHandle)) {
  32358. if (fread($aHandle, 8192) !== fread($bHandle, 8192)) {
  32359. $result = false;
  32360. break;
  32361. }
  32362. }
  32363. fclose($aHandle);
  32364. fclose($bHandle);
  32365. return $result;
  32366. }
  32367. }
  32368. <?php declare(strict_types=1);
  32369. namespace Composer\Util;
  32370. use Composer\Config;
  32371. use Composer\IO\IOInterface;
  32372. use Composer\Pcre\Preg;
  32373. class Git
  32374. {
  32375. private static $version = false;
  32376. protected $io;
  32377. protected $config;
  32378. protected $process;
  32379. protected $filesystem;
  32380. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process, Filesystem $fs)
  32381. {
  32382. $this->io = $io;
  32383. $this->config = $config;
  32384. $this->process = $process;
  32385. $this->filesystem = $fs;
  32386. }
  32387. public function runCommand(callable $commandCallable, string $url, ?string $cwd, bool $initialClone = false, &$commandOutput = null): void
  32388. {
  32389. $this->config->prohibitUrlByConfig($url, $this->io);
  32390. if ($initialClone) {
  32391. $origCwd = $cwd;
  32392. $cwd = null;
  32393. }
  32394. if (Preg::isMatch('{^ssh://[^@]+@[^:]+:[^0-9]+}', $url)) {
  32395. throw new \InvalidArgumentException('The source URL ' . $url . ' is invalid, ssh URLs should have a port number after ":".' . "\n" . 'Use ssh://git@example.com:22/path or just git@example.com:path if you do not want to provide a password or custom port.');
  32396. }
  32397. if (!$initialClone) {
  32398. $this->process->execute('git remote -v', $output, $cwd);
  32399. if (Preg::isMatch('{^(?:composer|origin)\s+https?://(.+):(.+)@([^/]+)}im', $output, $match) && !$this->io->hasAuthentication($match[3])) {
  32400. $this->io->setAuthentication($match[3], rawurldecode($match[1]), rawurldecode($match[2]));
  32401. }
  32402. }
  32403. $protocols = $this->config->get('github-protocols');
  32404. if (!is_array($protocols)) {
  32405. throw new \RuntimeException('Config value "github-protocols" must be an array, got ' . gettype($protocols));
  32406. }
  32407. if (Preg::isMatch('{^(?:https?|git)://' . self::getGitHubDomainsRegex($this->config) . '/(.*)}', $url, $match)) {
  32408. $messages = array();
  32409. foreach ($protocols as $protocol) {
  32410. if ('ssh' === $protocol) {
  32411. $protoUrl = "git@" . $match[1] . ":" . $match[2];
  32412. } else {
  32413. $protoUrl = $protocol . "://" . $match[1] . "/" . $match[2];
  32414. }
  32415. if (0 === $this->process->execute(call_user_func($commandCallable, $protoUrl), $commandOutput, $cwd)) {
  32416. return;
  32417. }
  32418. $messages[] = '- ' . $protoUrl . "\n" . Preg::replace('#^#m', ' ', $this->process->getErrorOutput());
  32419. if ($initialClone && isset($origCwd)) {
  32420. $this->filesystem->removeDirectory($origCwd);
  32421. }
  32422. }
  32423. if (!$this->io->hasAuthentication($match[1]) && !$this->io->isInteractive()) {
  32424. $this->throwException('Failed to clone ' . $url . ' via ' . implode(', ', $protocols) . ' protocols, aborting.' . "\n\n" . implode("\n", $messages), $url);
  32425. }
  32426. }
  32427. $bypassSshForGitHub = Preg::isMatch('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\.git$}i', $url) && !in_array('ssh', $protocols, true);
  32428. $command = call_user_func($commandCallable, $url);
  32429. $auth = null;
  32430. $credentials = array();
  32431. if ($bypassSshForGitHub || 0 !== $this->process->execute($command, $commandOutput, $cwd)) {
  32432. $errorMsg = $this->process->getErrorOutput();
  32433. if (Preg::isMatch('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\.git$}i', $url, $match)
  32434. || Preg::isMatch('{^https?://' . self::getGitHubDomainsRegex($this->config) . '/(.*?)(?:\.git)?$}i', $url, $match)
  32435. ) {
  32436. if (!$this->io->hasAuthentication($match[1])) {
  32437. $gitHubUtil = new GitHub($this->io, $this->config, $this->process);
  32438. $message = 'Cloning failed using an ssh key for authentication, enter your GitHub credentials to access private repos';
  32439. if (!$gitHubUtil->authorizeOAuth($match[1]) && $this->io->isInteractive()) {
  32440. $gitHubUtil->authorizeOAuthInteractively($match[1], $message);
  32441. }
  32442. }
  32443. if ($this->io->hasAuthentication($match[1])) {
  32444. $auth = $this->io->getAuthentication($match[1]);
  32445. $authUrl = 'https://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[1] . '/' . $match[2] . '.git';
  32446. $command = call_user_func($commandCallable, $authUrl);
  32447. if (0 === $this->process->execute($command, $commandOutput, $cwd)) {
  32448. return;
  32449. }
  32450. $credentials = array(rawurlencode($auth['username']), rawurlencode($auth['password']));
  32451. $errorMsg = $this->process->getErrorOutput();
  32452. }
  32453. } elseif (Preg::isMatch('{^https://(bitbucket\.org)/(.*?)(?:\.git)?$}i', $url, $match)) {
  32454. $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process);
  32455. if (!$this->io->hasAuthentication($match[1])) {
  32456. $message = 'Enter your Bitbucket credentials to access private repos';
  32457. if (!$bitbucketUtil->authorizeOAuth($match[1]) && $this->io->isInteractive()) {
  32458. $bitbucketUtil->authorizeOAuthInteractively($match[1], $message);
  32459. $accessToken = $bitbucketUtil->getToken();
  32460. $this->io->setAuthentication($match[1], 'x-token-auth', $accessToken);
  32461. }
  32462. } else {
  32463. $auth = $this->io->getAuthentication($match[1]);
  32464. if ($auth['username'] !== 'x-token-auth') {
  32465. $accessToken = $bitbucketUtil->requestToken($match[1], $auth['username'], $auth['password']);
  32466. if (!empty($accessToken)) {
  32467. $this->io->setAuthentication($match[1], 'x-token-auth', $accessToken);
  32468. }
  32469. }
  32470. }
  32471. if ($this->io->hasAuthentication($match[1])) {
  32472. $auth = $this->io->getAuthentication($match[1]);
  32473. $authUrl = 'https://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[1] . '/' . $match[2] . '.git';
  32474. $command = call_user_func($commandCallable, $authUrl);
  32475. if (0 === $this->process->execute($command, $commandOutput, $cwd)) {
  32476. return;
  32477. }
  32478. $credentials = array(rawurlencode($auth['username']), rawurlencode($auth['password']));
  32479. $errorMsg = $this->process->getErrorOutput();
  32480. } else {
  32481. $sshUrl = 'git@bitbucket.org:' . $match[2] . '.git';
  32482. $this->io->writeError(' No bitbucket authentication configured. Falling back to ssh.');
  32483. $command = call_user_func($commandCallable, $sshUrl);
  32484. if (0 === $this->process->execute($command, $commandOutput, $cwd)) {
  32485. return;
  32486. }
  32487. $errorMsg = $this->process->getErrorOutput();
  32488. }
  32489. } elseif (
  32490. Preg::isMatch('{^(git)@' . self::getGitLabDomainsRegex($this->config) . ':(.+?\.git)$}i', $url, $match)
  32491. || Preg::isMatch('{^(https?)://' . self::getGitLabDomainsRegex($this->config) . '/(.*)}i', $url, $match)
  32492. ) {
  32493. if ($match[1] === 'git') {
  32494. $match[1] = 'https';
  32495. }
  32496. if (!$this->io->hasAuthentication($match[2])) {
  32497. $gitLabUtil = new GitLab($this->io, $this->config, $this->process);
  32498. $message = 'Cloning failed, enter your GitLab credentials to access private repos';
  32499. if (!$gitLabUtil->authorizeOAuth($match[2]) && $this->io->isInteractive()) {
  32500. $gitLabUtil->authorizeOAuthInteractively($match[1], $match[2], $message);
  32501. }
  32502. }
  32503. if ($this->io->hasAuthentication($match[2])) {
  32504. $auth = $this->io->getAuthentication($match[2]);
  32505. if ($auth['password'] === 'private-token' || $auth['password'] === 'oauth2' || $auth['password'] === 'gitlab-ci-token') {
  32506. $authUrl = $match[1] . '://' . rawurlencode($auth['password']) . ':' . rawurlencode($auth['username']) . '@' . $match[2] . '/' . $match[3];
  32507. } else {
  32508. $authUrl = $match[1] . '://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[2] . '/' . $match[3];
  32509. }
  32510. $command = call_user_func($commandCallable, $authUrl);
  32511. if (0 === $this->process->execute($command, $commandOutput, $cwd)) {
  32512. return;
  32513. }
  32514. $credentials = array(rawurlencode($auth['username']), rawurlencode($auth['password']));
  32515. $errorMsg = $this->process->getErrorOutput();
  32516. }
  32517. } elseif ($this->isAuthenticationFailure($url, $match)) {
  32518. if (strpos($match[2], '@')) {
  32519. list($authParts, $match[2]) = explode('@', $match[2], 2);
  32520. }
  32521. $storeAuth = false;
  32522. if ($this->io->hasAuthentication($match[2])) {
  32523. $auth = $this->io->getAuthentication($match[2]);
  32524. } elseif ($this->io->isInteractive()) {
  32525. $defaultUsername = null;
  32526. if (isset($authParts) && $authParts) {
  32527. if (false !== strpos($authParts, ':')) {
  32528. list($defaultUsername, ) = explode(':', $authParts, 2);
  32529. } else {
  32530. $defaultUsername = $authParts;
  32531. }
  32532. }
  32533. $this->io->writeError(' Authentication required (<info>' . $match[2] . '</info>):');
  32534. $auth = array(
  32535. 'username' => $this->io->ask(' Username: ', $defaultUsername),
  32536. 'password' => $this->io->askAndHideAnswer(' Password: '),
  32537. );
  32538. $storeAuth = $this->config->get('store-auths');
  32539. }
  32540. if (null !== $auth) {
  32541. $authUrl = $match[1] . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[2] . $match[3];
  32542. $command = call_user_func($commandCallable, $authUrl);
  32543. if (0 === $this->process->execute($command, $commandOutput, $cwd)) {
  32544. $this->io->setAuthentication($match[2], $auth['username'], $auth['password']);
  32545. $authHelper = new AuthHelper($this->io, $this->config);
  32546. $authHelper->storeAuth($match[2], $storeAuth);
  32547. return;
  32548. }
  32549. $credentials = array(rawurlencode($auth['username']), rawurlencode($auth['password']));
  32550. $errorMsg = $this->process->getErrorOutput();
  32551. }
  32552. }
  32553. if ($initialClone && isset($origCwd)) {
  32554. $this->filesystem->removeDirectory($origCwd);
  32555. }
  32556. if (count($credentials) > 0) {
  32557. $command = $this->maskCredentials($command, $credentials);
  32558. $errorMsg = $this->maskCredentials($errorMsg, $credentials);
  32559. }
  32560. $this->throwException('Failed to execute ' . $command . "\n\n" . $errorMsg, $url);
  32561. }
  32562. }
  32563. public function syncMirror(string $url, string $dir): bool
  32564. {
  32565. if (Platform::getEnv('COMPOSER_DISABLE_NETWORK') && Platform::getEnv('COMPOSER_DISABLE_NETWORK') !== 'prime') {
  32566. $this->io->writeError('<warning>Aborting git mirror sync of '.$url.' as network is disabled</warning>');
  32567. return false;
  32568. }
  32569. if (is_dir($dir) && 0 === $this->process->execute('git rev-parse --git-dir', $output, $dir) && trim($output) === '.') {
  32570. try {
  32571. $commandCallable = function ($url): string {
  32572. $sanitizedUrl = Preg::replace('{://([^@]+?):(.+?)@}', '://', $url);
  32573. return sprintf('git remote set-url origin -- %s && git remote update --prune origin && git remote set-url origin -- %s && git gc --auto', ProcessExecutor::escape($url), ProcessExecutor::escape($sanitizedUrl));
  32574. };
  32575. $this->runCommand($commandCallable, $url, $dir);
  32576. } catch (\Exception $e) {
  32577. $this->io->writeError('<error>Sync mirror failed: ' . $e->getMessage() . '</error>', true, IOInterface::DEBUG);
  32578. return false;
  32579. }
  32580. return true;
  32581. }
  32582. $this->filesystem->removeDirectory($dir);
  32583. $commandCallable = function ($url) use ($dir): string {
  32584. return sprintf('git clone --mirror -- %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($dir));
  32585. };
  32586. $this->runCommand($commandCallable, $url, $dir, true);
  32587. return true;
  32588. }
  32589. public function fetchRefOrSyncMirror(string $url, string $dir, string $ref): bool
  32590. {
  32591. if ($this->checkRefIsInMirror($dir, $ref)) {
  32592. return true;
  32593. }
  32594. if ($this->syncMirror($url, $dir)) {
  32595. return $this->checkRefIsInMirror($dir, $ref);
  32596. }
  32597. return false;
  32598. }
  32599. public static function getNoShowSignatureFlag(ProcessExecutor $process): string
  32600. {
  32601. $gitVersion = self::getVersion($process);
  32602. if ($gitVersion && version_compare($gitVersion, '2.10.0-rc0', '>=')) {
  32603. return ' --no-show-signature';
  32604. }
  32605. return '';
  32606. }
  32607. private function checkRefIsInMirror(string $dir, string $ref): bool
  32608. {
  32609. if (is_dir($dir) && 0 === $this->process->execute('git rev-parse --git-dir', $output, $dir) && trim($output) === '.') {
  32610. $escapedRef = ProcessExecutor::escape($ref.'^{commit}');
  32611. $exitCode = $this->process->execute(sprintf('git rev-parse --quiet --verify %s', $escapedRef), $ignoredOutput, $dir);
  32612. if ($exitCode === 0) {
  32613. return true;
  32614. }
  32615. }
  32616. return false;
  32617. }
  32618. private function isAuthenticationFailure(string $url, array &$match): bool
  32619. {
  32620. if (!Preg::isMatch('{^(https?://)([^/]+)(.*)$}i', $url, $match)) {
  32621. return false;
  32622. }
  32623. $authFailures = array(
  32624. 'fatal: Authentication failed',
  32625. 'remote error: Invalid username or password.',
  32626. 'error: 401 Unauthorized',
  32627. 'fatal: unable to access',
  32628. 'fatal: could not read Username',
  32629. );
  32630. $errorOutput = $this->process->getErrorOutput();
  32631. foreach ($authFailures as $authFailure) {
  32632. if (strpos($errorOutput, $authFailure) !== false) {
  32633. return true;
  32634. }
  32635. }
  32636. return false;
  32637. }
  32638. public function getMirrorDefaultBranch(string $url, string $dir, bool $isLocalPathRepository): ?string
  32639. {
  32640. if ((bool) Platform::getEnv('COMPOSER_DISABLE_NETWORK')) {
  32641. return null;
  32642. }
  32643. try {
  32644. if ($isLocalPathRepository) {
  32645. $this->process->execute('git remote show origin', $output, $dir);
  32646. } else {
  32647. $commandCallable = function ($url): string {
  32648. $sanitizedUrl = Preg::replace('{://([^@]+?):(.+?)@}', '://', $url);
  32649. return sprintf('git remote set-url origin -- %s && git remote show origin && git remote set-url origin -- %s', ProcessExecutor::escape($url), ProcessExecutor::escape($sanitizedUrl));
  32650. };
  32651. $this->runCommand($commandCallable, $url, $dir, false, $output);
  32652. }
  32653. $lines = $this->process->splitLines($output);
  32654. foreach ($lines as $line) {
  32655. if (Preg::match('{^\s*HEAD branch:\s(.+)\s*$}m', $line, $matches) > 0) {
  32656. return $matches[1];
  32657. }
  32658. }
  32659. } catch (\Exception $e) {
  32660. $this->io->writeError('<error>Failed to fetch root identifier from remote: ' . $e->getMessage() . '</error>', true, IOInterface::DEBUG);
  32661. }
  32662. return null;
  32663. }
  32664. public static function cleanEnv(): void
  32665. {
  32666. if (Platform::getEnv('GIT_ASKPASS') !== 'echo') {
  32667. Platform::putEnv('GIT_ASKPASS', 'echo');
  32668. }
  32669. if (Platform::getEnv('GIT_DIR')) {
  32670. Platform::clearEnv('GIT_DIR');
  32671. }
  32672. if (Platform::getEnv('GIT_WORK_TREE')) {
  32673. Platform::clearEnv('GIT_WORK_TREE');
  32674. }
  32675. if (Platform::getEnv('LANGUAGE') !== 'C') {
  32676. Platform::putEnv('LANGUAGE', 'C');
  32677. }
  32678. Platform::clearEnv('DYLD_LIBRARY_PATH');
  32679. }
  32680. public static function getGitHubDomainsRegex(Config $config): string
  32681. {
  32682. return '(' . implode('|', array_map('preg_quote', $config->get('github-domains'))) . ')';
  32683. }
  32684. public static function getGitLabDomainsRegex(Config $config): string
  32685. {
  32686. return '(' . implode('|', array_map('preg_quote', $config->get('gitlab-domains'))) . ')';
  32687. }
  32688. private function throwException($message, string $url): void
  32689. {
  32690. clearstatcache();
  32691. if (0 !== $this->process->execute('git --version', $ignoredOutput)) {
  32692. throw new \RuntimeException(Url::sanitize('Failed to clone ' . $url . ', git was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput()));
  32693. }
  32694. throw new \RuntimeException(Url::sanitize($message));
  32695. }
  32696. public static function getVersion(ProcessExecutor $process): ?string
  32697. {
  32698. if (false === self::$version) {
  32699. self::$version = null;
  32700. if (0 === $process->execute('git --version', $output) && Preg::isMatch('/^git version (\d+(?:\.\d+)+)/m', $output, $matches)) {
  32701. self::$version = $matches[1];
  32702. }
  32703. }
  32704. return self::$version;
  32705. }
  32706. private function maskCredentials(string $error, array $credentials): string
  32707. {
  32708. $maskedCredentials = array();
  32709. foreach ($credentials as $credential) {
  32710. if (in_array($credential, array('private-token', 'x-token-auth', 'oauth2', 'gitlab-ci-token', 'x-oauth-basic'))) {
  32711. $maskedCredentials[] = $credential;
  32712. } elseif (strlen($credential) > 6) {
  32713. $maskedCredentials[] = substr($credential, 0, 3) . '...' . substr($credential, -3);
  32714. } elseif (strlen($credential) > 3) {
  32715. $maskedCredentials[] = substr($credential, 0, 3) . '...';
  32716. } else {
  32717. $maskedCredentials[] = 'XXX';
  32718. }
  32719. }
  32720. return str_replace($credentials, $maskedCredentials, $error);
  32721. }
  32722. }
  32723. <?php declare(strict_types=1);
  32724. namespace Composer\Util;
  32725. use Composer\Factory;
  32726. use Composer\IO\IOInterface;
  32727. use Composer\Config;
  32728. use Composer\Downloader\TransportException;
  32729. use Composer\Pcre\Preg;
  32730. class GitHub
  32731. {
  32732. protected $io;
  32733. protected $config;
  32734. protected $process;
  32735. protected $httpDownloader;
  32736. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null)
  32737. {
  32738. $this->io = $io;
  32739. $this->config = $config;
  32740. $this->process = $process ?: new ProcessExecutor($io);
  32741. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  32742. }
  32743. public function authorizeOAuth(string $originUrl): bool
  32744. {
  32745. if (!in_array($originUrl, $this->config->get('github-domains'))) {
  32746. return false;
  32747. }
  32748. if (0 === $this->process->execute('git config github.accesstoken', $output)) {
  32749. $this->io->setAuthentication($originUrl, trim($output), 'x-oauth-basic');
  32750. return true;
  32751. }
  32752. return false;
  32753. }
  32754. public function authorizeOAuthInteractively(string $originUrl, string $message = null): bool
  32755. {
  32756. if ($message) {
  32757. $this->io->writeError($message);
  32758. }
  32759. $note = 'Composer';
  32760. if ($this->config->get('github-expose-hostname') === true && 0 === $this->process->execute('hostname', $output)) {
  32761. $note .= ' on ' . trim($output);
  32762. }
  32763. $note .= ' ' . date('Y-m-d Hi');
  32764. $url = 'https://'.$originUrl.'/settings/tokens/new?scopes=&description=' . str_replace('%20', '+', rawurlencode($note));
  32765. $this->io->writeError(sprintf('When working with _public_ GitHub repositories only, head to %s to retrieve a token.', $url));
  32766. $this->io->writeError('This token will have read-only permission for public information only.');
  32767. $url = 'https://'.$originUrl.'/settings/tokens/new?scopes=repo&description=' . str_replace('%20', '+', rawurlencode($note));
  32768. $this->io->writeError(sprintf('When you need to access _private_ GitHub repositories as well, go to %s', $url));
  32769. $this->io->writeError('Note that such tokens have broad read/write permissions on your behalf, even if not needed by Composer.');
  32770. $this->io->writeError(sprintf('Tokens will be stored in plain text in "%s" for future use by Composer.', $this->config->getAuthConfigSource()->getName()));
  32771. $this->io->writeError('For additional information, check https://getcomposer.org/doc/articles/authentication-for-private-packages.md#github-oauth');
  32772. $token = trim($this->io->askAndHideAnswer('Token (hidden): '));
  32773. if (!$token) {
  32774. $this->io->writeError('<warning>No token given, aborting.</warning>');
  32775. $this->io->writeError('You can also add it manually later by using "composer config --global --auth github-oauth.github.com <token>"');
  32776. return false;
  32777. }
  32778. $this->io->setAuthentication($originUrl, $token, 'x-oauth-basic');
  32779. try {
  32780. $apiUrl = ('github.com' === $originUrl) ? 'api.github.com/' : $originUrl . '/api/v3/';
  32781. $this->httpDownloader->get('https://'. $apiUrl, array(
  32782. 'retry-auth-failure' => false,
  32783. ));
  32784. } catch (TransportException $e) {
  32785. if (in_array($e->getCode(), array(403, 401))) {
  32786. $this->io->writeError('<error>Invalid token provided.</error>');
  32787. $this->io->writeError('You can also add it manually later by using "composer config --global --auth github-oauth.github.com <token>"');
  32788. return false;
  32789. }
  32790. throw $e;
  32791. }
  32792. $this->config->getConfigSource()->removeConfigSetting('github-oauth.'.$originUrl);
  32793. $this->config->getAuthConfigSource()->addConfigSetting('github-oauth.'.$originUrl, $token);
  32794. $this->io->writeError('<info>Token stored successfully.</info>');
  32795. return true;
  32796. }
  32797. public function getRateLimit(array $headers): array
  32798. {
  32799. $rateLimit = array(
  32800. 'limit' => '?',
  32801. 'reset' => '?',
  32802. );
  32803. foreach ($headers as $header) {
  32804. $header = trim($header);
  32805. if (false === strpos($header, 'X-RateLimit-')) {
  32806. continue;
  32807. }
  32808. list($type, $value) = explode(':', $header, 2);
  32809. switch ($type) {
  32810. case 'X-RateLimit-Limit':
  32811. $rateLimit['limit'] = (int) trim($value);
  32812. break;
  32813. case 'X-RateLimit-Reset':
  32814. $rateLimit['reset'] = date('Y-m-d H:i:s', (int) trim($value));
  32815. break;
  32816. }
  32817. }
  32818. return $rateLimit;
  32819. }
  32820. public function getSsoUrl(array $headers): ?string
  32821. {
  32822. foreach ($headers as $header) {
  32823. $header = trim($header);
  32824. if (false === stripos($header, 'x-github-sso: required')) {
  32825. continue;
  32826. }
  32827. if (Preg::isMatch('{\burl=(?P<url>[^\s;]+)}', $header, $match)) {
  32828. return $match['url'];
  32829. }
  32830. }
  32831. return null;
  32832. }
  32833. public function isRateLimited(array $headers): bool
  32834. {
  32835. foreach ($headers as $header) {
  32836. if (Preg::isMatch('{^X-RateLimit-Remaining: *0$}i', trim($header))) {
  32837. return true;
  32838. }
  32839. }
  32840. return false;
  32841. }
  32842. public function requiresSso(array $headers): bool
  32843. {
  32844. foreach ($headers as $header) {
  32845. if (Preg::isMatch('{^X-GitHub-SSO: required}i', trim($header))) {
  32846. return true;
  32847. }
  32848. }
  32849. return false;
  32850. }
  32851. }
  32852. <?php declare(strict_types=1);
  32853. namespace Composer\Util;
  32854. use Composer\IO\IOInterface;
  32855. use Composer\Config;
  32856. use Composer\Factory;
  32857. use Composer\Downloader\TransportException;
  32858. use Composer\Pcre\Preg;
  32859. class GitLab
  32860. {
  32861. protected $io;
  32862. protected $config;
  32863. protected $process;
  32864. protected $httpDownloader;
  32865. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null)
  32866. {
  32867. $this->io = $io;
  32868. $this->config = $config;
  32869. $this->process = $process ?: new ProcessExecutor($io);
  32870. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  32871. }
  32872. public function authorizeOAuth(string $originUrl): bool
  32873. {
  32874. $bcOriginUrl = Preg::replace('{:\d+}', '', $originUrl);
  32875. if (!in_array($originUrl, $this->config->get('gitlab-domains'), true) && !in_array($bcOriginUrl, $this->config->get('gitlab-domains'), true)) {
  32876. return false;
  32877. }
  32878. if (0 === $this->process->execute('git config gitlab.accesstoken', $output)) {
  32879. $this->io->setAuthentication($originUrl, trim($output), 'oauth2');
  32880. return true;
  32881. }
  32882. if (0 === $this->process->execute('git config gitlab.deploytoken.user', $tokenUser) && 0 === $this->process->execute('git config gitlab.deploytoken.token', $tokenPassword)) {
  32883. $this->io->setAuthentication($originUrl, trim($tokenUser), trim($tokenPassword));
  32884. return true;
  32885. }
  32886. $authTokens = $this->config->get('gitlab-token');
  32887. if (isset($authTokens[$originUrl])) {
  32888. $token = $authTokens[$originUrl];
  32889. }
  32890. if (isset($authTokens[$bcOriginUrl])) {
  32891. $token = $authTokens[$bcOriginUrl];
  32892. }
  32893. if (isset($token)) {
  32894. $username = is_array($token) && array_key_exists("username", $token) ? $token["username"] : $token;
  32895. $password = is_array($token) && array_key_exists("token", $token) ? $token["token"] : 'private-token';
  32896. $this->io->setAuthentication($originUrl, $username, $password);
  32897. return true;
  32898. }
  32899. return false;
  32900. }
  32901. public function authorizeOAuthInteractively(string $scheme, string $originUrl, string $message = null): bool
  32902. {
  32903. if ($message) {
  32904. $this->io->writeError($message);
  32905. }
  32906. $this->io->writeError(sprintf('A token will be created and stored in "%s", your password will never be stored', $this->config->getAuthConfigSource()->getName()));
  32907. $this->io->writeError('To revoke access to this token you can visit '.$scheme.'://'.$originUrl.'/-/profile/personal_access_tokens');
  32908. $attemptCounter = 0;
  32909. while ($attemptCounter++ < 5) {
  32910. try {
  32911. $response = $this->createToken($scheme, $originUrl);
  32912. } catch (TransportException $e) {
  32913. if (in_array($e->getCode(), array(403, 401))) {
  32914. if (401 === $e->getCode()) {
  32915. $response = json_decode($e->getResponse(), true);
  32916. if (isset($response['error']) && $response['error'] === 'invalid_grant') {
  32917. $this->io->writeError('Bad credentials. If you have two factor authentication enabled you will have to manually create a personal access token');
  32918. } else {
  32919. $this->io->writeError('Bad credentials.');
  32920. }
  32921. } else {
  32922. $this->io->writeError('Maximum number of login attempts exceeded. Please try again later.');
  32923. }
  32924. $this->io->writeError('You can also manually create a personal access token enabling the "read_api" scope at '.$scheme.'://'.$originUrl.'/profile/personal_access_tokens');
  32925. $this->io->writeError('Add it using "composer config --global --auth gitlab-token.'.$originUrl.' <token>"');
  32926. continue;
  32927. }
  32928. throw $e;
  32929. }
  32930. $this->io->setAuthentication($originUrl, $response['access_token'], 'oauth2');
  32931. $this->config->getAuthConfigSource()->addConfigSetting('gitlab-oauth.'.$originUrl, $response['access_token']);
  32932. return true;
  32933. }
  32934. throw new \RuntimeException('Invalid GitLab credentials 5 times in a row, aborting.');
  32935. }
  32936. private function createToken(string $scheme, string $originUrl): array
  32937. {
  32938. $username = $this->io->ask('Username: ');
  32939. $password = $this->io->askAndHideAnswer('Password: ');
  32940. $headers = array('Content-Type: application/x-www-form-urlencoded');
  32941. $apiUrl = $originUrl;
  32942. $data = http_build_query(array(
  32943. 'username' => $username,
  32944. 'password' => $password,
  32945. 'grant_type' => 'password',
  32946. ), '', '&');
  32947. $options = array(
  32948. 'retry-auth-failure' => false,
  32949. 'http' => array(
  32950. 'method' => 'POST',
  32951. 'header' => $headers,
  32952. 'content' => $data,
  32953. ),
  32954. );
  32955. $token = $this->httpDownloader->get($scheme.'://'.$apiUrl.'/oauth/token', $options)->decodeJson();
  32956. $this->io->writeError('Token successfully created');
  32957. return $token;
  32958. }
  32959. }
  32960. <?php declare(strict_types=1);
  32961. namespace Composer\Util;
  32962. use Composer\Config;
  32963. use Composer\IO\IOInterface;
  32964. use Composer\Pcre\Preg;
  32965. class Hg
  32966. {
  32967. private static $version = false;
  32968. private $io;
  32969. private $config;
  32970. private $process;
  32971. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process)
  32972. {
  32973. $this->io = $io;
  32974. $this->config = $config;
  32975. $this->process = $process;
  32976. }
  32977. public function runCommand(callable $commandCallable, string $url, ?string $cwd): void
  32978. {
  32979. $this->config->prohibitUrlByConfig($url, $this->io);
  32980. $command = call_user_func($commandCallable, $url);
  32981. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  32982. return;
  32983. }
  32984. if (Preg::isMatch('{^(https?)://((.+)(?:\:(.+))?@)?([^/]+)(/.*)?}mi', $url, $match) && $this->io->hasAuthentication($match[5])) {
  32985. $auth = $this->io->getAuthentication($match[5]);
  32986. $authenticatedUrl = $match[1] . '://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[5] . (!empty($match[6]) ? $match[6] : null);
  32987. $command = call_user_func($commandCallable, $authenticatedUrl);
  32988. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  32989. return;
  32990. }
  32991. $error = $this->process->getErrorOutput();
  32992. } else {
  32993. $error = 'The given URL (' . $url . ') does not match the required format (http(s)://(username:password@)example.com/path-to-repository)';
  32994. }
  32995. $this->throwException('Failed to clone ' . $url . ', ' . "\n\n" . $error, $url);
  32996. }
  32997. private function throwException($message, string $url): void
  32998. {
  32999. if (null === self::getVersion($this->process)) {
  33000. throw new \RuntimeException(Url::sanitize('Failed to clone ' . $url . ', hg was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput()));
  33001. }
  33002. throw new \RuntimeException(Url::sanitize($message));
  33003. }
  33004. public static function getVersion(ProcessExecutor $process): ?string
  33005. {
  33006. if (false === self::$version) {
  33007. self::$version = null;
  33008. if (0 === $process->execute('hg --version', $output) && Preg::isMatch('/^.+? (\d+(?:\.\d+)+)\)?\r?\n/', $output, $matches)) {
  33009. self::$version = $matches[1];
  33010. }
  33011. }
  33012. return self::$version;
  33013. }
  33014. }
  33015. <?php declare(strict_types=1);
  33016. namespace Composer\Util\Http;
  33017. use Composer\Config;
  33018. use Composer\Downloader\MaxFileSizeExceededException;
  33019. use Composer\IO\IOInterface;
  33020. use Composer\Downloader\TransportException;
  33021. use Composer\Pcre\Preg;
  33022. use Composer\Util\StreamContextFactory;
  33023. use Composer\Util\AuthHelper;
  33024. use Composer\Util\Url;
  33025. use Composer\Util\HttpDownloader;
  33026. use React\Promise\Promise;
  33027. class CurlDownloader
  33028. {
  33029. private $multiHandle;
  33030. private $shareHandle;
  33031. private $jobs = array();
  33032. private $io;
  33033. private $config;
  33034. private $authHelper;
  33035. private $selectTimeout = 5.0;
  33036. private $maxRedirects = 20;
  33037. private $maxRetries = 3;
  33038. private $proxyManager;
  33039. private $supportsSecureProxy;
  33040. protected $multiErrors = array(
  33041. CURLM_BAD_HANDLE => array('CURLM_BAD_HANDLE', 'The passed-in handle is not a valid CURLM handle.'),
  33042. CURLM_BAD_EASY_HANDLE => array('CURLM_BAD_EASY_HANDLE', "An easy handle was not good/valid. It could mean that it isn't an easy handle at all, or possibly that the handle already is in used by this or another multi handle."),
  33043. CURLM_OUT_OF_MEMORY => array('CURLM_OUT_OF_MEMORY', 'You are doomed.'),
  33044. CURLM_INTERNAL_ERROR => array('CURLM_INTERNAL_ERROR', 'This can only be returned if libcurl bugs. Please report it to us!'),
  33045. );
  33046. private static $options = array(
  33047. 'http' => array(
  33048. 'method' => CURLOPT_CUSTOMREQUEST,
  33049. 'content' => CURLOPT_POSTFIELDS,
  33050. 'header' => CURLOPT_HTTPHEADER,
  33051. 'timeout' => CURLOPT_TIMEOUT,
  33052. ),
  33053. 'ssl' => array(
  33054. 'cafile' => CURLOPT_CAINFO,
  33055. 'capath' => CURLOPT_CAPATH,
  33056. 'verify_peer' => CURLOPT_SSL_VERIFYPEER,
  33057. 'verify_peer_name' => CURLOPT_SSL_VERIFYHOST,
  33058. 'local_cert' => CURLOPT_SSLCERT,
  33059. 'local_pk' => CURLOPT_SSLKEY,
  33060. 'passphrase' => CURLOPT_SSLKEYPASSWD,
  33061. ),
  33062. );
  33063. private static $timeInfo = array(
  33064. 'total_time' => true,
  33065. 'namelookup_time' => true,
  33066. 'connect_time' => true,
  33067. 'pretransfer_time' => true,
  33068. 'starttransfer_time' => true,
  33069. 'redirect_time' => true,
  33070. );
  33071. public function __construct(IOInterface $io, Config $config, array $options = array(), bool $disableTls = false)
  33072. {
  33073. $this->io = $io;
  33074. $this->config = $config;
  33075. $this->multiHandle = $mh = curl_multi_init();
  33076. if (function_exists('curl_multi_setopt')) {
  33077. curl_multi_setopt($mh, CURLMOPT_PIPELINING, PHP_VERSION_ID >= 70400 ? 2 : 3);
  33078. if (defined('CURLMOPT_MAX_HOST_CONNECTIONS') && !defined('HHVM_VERSION')) {
  33079. curl_multi_setopt($mh, CURLMOPT_MAX_HOST_CONNECTIONS, 8);
  33080. }
  33081. }
  33082. if (function_exists('curl_share_init')) {
  33083. $this->shareHandle = $sh = curl_share_init();
  33084. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
  33085. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
  33086. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
  33087. }
  33088. $this->authHelper = new AuthHelper($io, $config);
  33089. $this->proxyManager = ProxyManager::getInstance();
  33090. $version = curl_version();
  33091. $features = $version['features'];
  33092. $this->supportsSecureProxy = defined('CURL_VERSION_HTTPS_PROXY') && ($features & CURL_VERSION_HTTPS_PROXY);
  33093. }
  33094. public function download(callable $resolve, callable $reject, string $origin, string $url, array $options, ?string $copyTo = null): int
  33095. {
  33096. $attributes = array();
  33097. if (isset($options['retry-auth-failure'])) {
  33098. $attributes['retryAuthFailure'] = $options['retry-auth-failure'];
  33099. unset($options['retry-auth-failure']);
  33100. }
  33101. return $this->initDownload($resolve, $reject, $origin, $url, $options, $copyTo, $attributes);
  33102. }
  33103. private function initDownload(callable $resolve, callable $reject, string $origin, string $url, array $options, ?string $copyTo = null, array $attributes = array()): int
  33104. {
  33105. $attributes['retryAuthFailure'] = $attributes['retryAuthFailure'] ?? true;
  33106. $attributes['redirects'] = $attributes['redirects'] ?? 0;
  33107. $attributes['retries'] = $attributes['retries'] ?? 0;
  33108. $attributes['storeAuth'] = $attributes['storeAuth'] ?? false;
  33109. $originalOptions = $options;
  33110. if (!Preg::isMatch('{^http://(repo\.)?packagist\.org/p/}', $url) || (false === strpos($url, '$') && false === strpos($url, '%24'))) {
  33111. $this->config->prohibitUrlByConfig($url, $this->io, $options);
  33112. }
  33113. $curlHandle = curl_init();
  33114. $headerHandle = fopen('php://temp/maxmemory:32768', 'w+b');
  33115. if (false === $headerHandle) {
  33116. throw new \RuntimeException('Failed to open a temp stream to store curl headers');
  33117. }
  33118. if ($copyTo) {
  33119. $errorMessage = '';
  33120. set_error_handler(function ($code, $msg) use (&$errorMessage): void {
  33121. if ($errorMessage) {
  33122. $errorMessage .= "\n";
  33123. }
  33124. $errorMessage .= Preg::replace('{^fopen\(.*?\): }', '', $msg);
  33125. });
  33126. $bodyHandle = fopen($copyTo.'~', 'w+b');
  33127. restore_error_handler();
  33128. if (!$bodyHandle) {
  33129. throw new TransportException('The "'.$url.'" file could not be written to '.$copyTo.': '.$errorMessage);
  33130. }
  33131. } else {
  33132. $bodyHandle = @fopen('php://temp/maxmemory:524288', 'w+b');
  33133. }
  33134. curl_setopt($curlHandle, CURLOPT_URL, $url);
  33135. curl_setopt($curlHandle, CURLOPT_FOLLOWLOCATION, false);
  33136. curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 10);
  33137. curl_setopt($curlHandle, CURLOPT_TIMEOUT, max((int) ini_get("default_socket_timeout"), 300));
  33138. curl_setopt($curlHandle, CURLOPT_WRITEHEADER, $headerHandle);
  33139. curl_setopt($curlHandle, CURLOPT_FILE, $bodyHandle);
  33140. curl_setopt($curlHandle, CURLOPT_ENCODING, "");
  33141. curl_setopt($curlHandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
  33142. if (function_exists('curl_share_init')) {
  33143. curl_setopt($curlHandle, CURLOPT_SHARE, $this->shareHandle);
  33144. }
  33145. if (!isset($options['http']['header'])) {
  33146. $options['http']['header'] = array();
  33147. }
  33148. $options['http']['header'] = array_diff($options['http']['header'], array('Connection: close'));
  33149. $options['http']['header'][] = 'Connection: keep-alive';
  33150. $version = curl_version();
  33151. $features = $version['features'];
  33152. if (0 === strpos($url, 'https://') && \defined('CURL_VERSION_HTTP2') && \defined('CURL_HTTP_VERSION_2_0') && (CURL_VERSION_HTTP2 & $features)) {
  33153. curl_setopt($curlHandle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
  33154. }
  33155. $options['http']['header'] = $this->authHelper->addAuthenticationHeader($options['http']['header'], $origin, $url);
  33156. $options = StreamContextFactory::initOptions($url, $options, true);
  33157. foreach (self::$options as $type => $curlOptions) {
  33158. foreach ($curlOptions as $name => $curlOption) {
  33159. if (isset($options[$type][$name])) {
  33160. if ($type === 'ssl' && $name === 'verify_peer_name') {
  33161. curl_setopt($curlHandle, $curlOption, $options[$type][$name] === true ? 2 : $options[$type][$name]);
  33162. } else {
  33163. curl_setopt($curlHandle, $curlOption, $options[$type][$name]);
  33164. }
  33165. }
  33166. }
  33167. }
  33168. $proxy = $this->proxyManager->getProxyForRequest($url);
  33169. curl_setopt($curlHandle, CURLOPT_PROXY, $proxy->getUrl());
  33170. if ($proxy->isSecure()) {
  33171. if (!$this->supportsSecureProxy) {
  33172. throw new TransportException('Connecting to a secure proxy using curl is not supported on PHP versions below 7.3.0.');
  33173. }
  33174. if (!empty($options['ssl']['cafile'])) {
  33175. curl_setopt($curlHandle, CURLOPT_PROXY_CAINFO, $options['ssl']['cafile']);
  33176. }
  33177. if (!empty($options['ssl']['capath'])) {
  33178. curl_setopt($curlHandle, CURLOPT_PROXY_CAPATH, $options['ssl']['capath']);
  33179. }
  33180. }
  33181. $progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo);
  33182. $this->jobs[(int) $curlHandle] = array(
  33183. 'url' => $url,
  33184. 'origin' => $origin,
  33185. 'attributes' => $attributes,
  33186. 'options' => $originalOptions,
  33187. 'progress' => $progress,
  33188. 'curlHandle' => $curlHandle,
  33189. 'filename' => $copyTo,
  33190. 'headerHandle' => $headerHandle,
  33191. 'bodyHandle' => $bodyHandle,
  33192. 'resolve' => $resolve,
  33193. 'reject' => $reject,
  33194. );
  33195. $usingProxy = $proxy->getFormattedUrl(' using proxy (%s)');
  33196. $ifModified = false !== stripos(implode(',', $options['http']['header']), 'if-modified-since:') ? ' if modified' : '';
  33197. if ($attributes['redirects'] === 0 && $attributes['retries'] === 0) {
  33198. $this->io->writeError('Downloading ' . Url::sanitize($url) . $usingProxy . $ifModified, true, IOInterface::DEBUG);
  33199. }
  33200. $this->checkCurlResult(curl_multi_add_handle($this->multiHandle, $curlHandle));
  33201. return (int) $curlHandle;
  33202. }
  33203. public function abortRequest(int $id): void
  33204. {
  33205. if (isset($this->jobs[$id], $this->jobs[$id]['curlHandle'])) {
  33206. $job = $this->jobs[$id];
  33207. curl_multi_remove_handle($this->multiHandle, $job['curlHandle']);
  33208. curl_close($job['curlHandle']);
  33209. if (is_resource($job['headerHandle'])) {
  33210. fclose($job['headerHandle']);
  33211. }
  33212. if (is_resource($job['bodyHandle'])) {
  33213. fclose($job['bodyHandle']);
  33214. }
  33215. if (null !== $job['filename']) {
  33216. @unlink($job['filename'].'~');
  33217. }
  33218. unset($this->jobs[$id]);
  33219. }
  33220. }
  33221. public function tick(): void
  33222. {
  33223. static $timeoutWarning = false;
  33224. if (count($this->jobs) === 0) {
  33225. return;
  33226. }
  33227. $active = true;
  33228. $this->checkCurlResult(curl_multi_exec($this->multiHandle, $active));
  33229. if (-1 === curl_multi_select($this->multiHandle, $this->selectTimeout)) {
  33230. usleep(150);
  33231. }
  33232. while ($progress = curl_multi_info_read($this->multiHandle)) {
  33233. $curlHandle = $progress['handle'];
  33234. $result = $progress['result'];
  33235. $i = (int) $curlHandle;
  33236. if (!isset($this->jobs[$i])) {
  33237. continue;
  33238. }
  33239. $progress = curl_getinfo($curlHandle);
  33240. if (false === $progress) {
  33241. throw new \RuntimeException('Failed getting info from curl handle '.$i.' ('.$this->jobs[$i]['url'].')');
  33242. }
  33243. $job = $this->jobs[$i];
  33244. unset($this->jobs[$i]);
  33245. $error = curl_error($curlHandle);
  33246. $errno = curl_errno($curlHandle);
  33247. curl_multi_remove_handle($this->multiHandle, $curlHandle);
  33248. curl_close($curlHandle);
  33249. $headers = null;
  33250. $statusCode = null;
  33251. $response = null;
  33252. try {
  33253. if (CURLE_OK !== $errno || $error || $result !== CURLE_OK) {
  33254. $errno = $errno ?: $result;
  33255. if (!$error && function_exists('curl_strerror')) {
  33256. $error = curl_strerror($errno);
  33257. }
  33258. $progress['error_code'] = $errno;
  33259. if (
  33260. (!isset($job['options']['http']['method']) || $job['options']['http']['method'] === 'GET')
  33261. && (
  33262. in_array($errno, array(7 , 16 , 92 , 6 ), true)
  33263. || ($errno === 35 && false !== strpos($error, 'Connection reset by peer'))
  33264. ) && $job['attributes']['retries'] < $this->maxRetries
  33265. ) {
  33266. $this->io->writeError('Retrying ('.($job['attributes']['retries'] + 1).') ' . Url::sanitize($job['url']) . ' due to curl error '. $errno, true, IOInterface::DEBUG);
  33267. $this->restartJob($job, $job['url'], array('retries' => $job['attributes']['retries'] + 1));
  33268. continue;
  33269. }
  33270. if ($errno === 28 && PHP_VERSION_ID >= 70300 && $progress['namelookup_time'] == 0 && !$timeoutWarning) {
  33271. $timeoutWarning = true;
  33272. $this->io->writeError('<warning>A connection timeout was encountered. If you intend to run Composer without connecting to the internet, run the command again prefixed with COMPOSER_DISABLE_NETWORK=1 to make Composer run in offline mode.</warning>');
  33273. }
  33274. throw new TransportException('curl error '.$errno.' while downloading '.Url::sanitize($progress['url']).': '.$error);
  33275. }
  33276. $statusCode = $progress['http_code'];
  33277. rewind($job['headerHandle']);
  33278. $headers = explode("\r\n", rtrim(stream_get_contents($job['headerHandle'])));
  33279. fclose($job['headerHandle']);
  33280. if ($statusCode === 0) {
  33281. throw new \LogicException('Received unexpected http status code 0 without error for '.Url::sanitize($progress['url']).': headers '.var_export($headers, true).' curl info '.var_export($progress, true));
  33282. }
  33283. if (null !== $job['filename']) {
  33284. $contents = $job['filename'].'~';
  33285. if ($statusCode >= 300) {
  33286. rewind($job['bodyHandle']);
  33287. $contents = stream_get_contents($job['bodyHandle']);
  33288. }
  33289. $response = new CurlResponse(array('url' => $progress['url']), $statusCode, $headers, $contents, $progress);
  33290. $this->io->writeError('['.$statusCode.'] '.Url::sanitize($progress['url']), true, IOInterface::DEBUG);
  33291. } else {
  33292. rewind($job['bodyHandle']);
  33293. $contents = stream_get_contents($job['bodyHandle']);
  33294. $response = new CurlResponse(array('url' => $progress['url']), $statusCode, $headers, $contents, $progress);
  33295. $this->io->writeError('['.$statusCode.'] '.Url::sanitize($progress['url']), true, IOInterface::DEBUG);
  33296. }
  33297. fclose($job['bodyHandle']);
  33298. if ($response->getStatusCode() >= 400 && $response->getHeader('content-type') === 'application/json') {
  33299. HttpDownloader::outputWarnings($this->io, $job['origin'], json_decode($response->getBody(), true));
  33300. }
  33301. $result = $this->isAuthenticatedRetryNeeded($job, $response);
  33302. if ($result['retry']) {
  33303. $this->restartJob($job, $job['url'], array('storeAuth' => $result['storeAuth']));
  33304. continue;
  33305. }
  33306. if ($statusCode >= 300 && $statusCode <= 399 && $statusCode !== 304 && $job['attributes']['redirects'] < $this->maxRedirects) {
  33307. $location = $this->handleRedirect($job, $response);
  33308. if ($location) {
  33309. $this->restartJob($job, $location, array('redirects' => $job['attributes']['redirects'] + 1));
  33310. continue;
  33311. }
  33312. }
  33313. if ($statusCode >= 400 && $statusCode <= 599) {
  33314. if (
  33315. (!isset($job['options']['http']['method']) || $job['options']['http']['method'] === 'GET')
  33316. && in_array($statusCode, array(423, 425, 500, 502, 503, 504, 507, 510), true)
  33317. && $job['attributes']['retries'] < $this->maxRetries
  33318. ) {
  33319. $this->io->writeError('Retrying ('.($job['attributes']['retries'] + 1).') ' . Url::sanitize($job['url']) . ' due to status code '. $statusCode, true, IOInterface::DEBUG);
  33320. $this->restartJob($job, $job['url'], array('retries' => $job['attributes']['retries'] + 1));
  33321. continue;
  33322. }
  33323. throw $this->failResponse($job, $response, $response->getStatusMessage());
  33324. }
  33325. if ($job['attributes']['storeAuth']) {
  33326. $this->authHelper->storeAuth($job['origin'], $job['attributes']['storeAuth']);
  33327. }
  33328. if (null !== $job['filename']) {
  33329. rename($job['filename'].'~', $job['filename']);
  33330. call_user_func($job['resolve'], $response);
  33331. } else {
  33332. call_user_func($job['resolve'], $response);
  33333. }
  33334. } catch (\Exception $e) {
  33335. if ($e instanceof TransportException) {
  33336. if (null !== $headers) {
  33337. $e->setHeaders($headers);
  33338. $e->setStatusCode($statusCode);
  33339. }
  33340. if (null !== $response) {
  33341. $e->setResponse($response->getBody());
  33342. }
  33343. $e->setResponseInfo($progress);
  33344. }
  33345. $this->rejectJob($job, $e);
  33346. }
  33347. }
  33348. foreach ($this->jobs as $i => $curlHandle) {
  33349. if (!isset($this->jobs[$i])) {
  33350. continue;
  33351. }
  33352. $curlHandle = $this->jobs[$i]['curlHandle'];
  33353. $progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo);
  33354. if ($this->jobs[$i]['progress'] !== $progress) {
  33355. $this->jobs[$i]['progress'] = $progress;
  33356. if (isset($this->jobs[$i]['options']['max_file_size'])) {
  33357. if ($this->jobs[$i]['options']['max_file_size'] < $progress['download_content_length']) {
  33358. $this->rejectJob($this->jobs[$i], new MaxFileSizeExceededException('Maximum allowed download size reached. Content-length header indicates ' . $progress['download_content_length'] . ' bytes. Allowed ' . $this->jobs[$i]['options']['max_file_size'] . ' bytes'));
  33359. }
  33360. if ($this->jobs[$i]['options']['max_file_size'] < $progress['size_download']) {
  33361. $this->rejectJob($this->jobs[$i], new MaxFileSizeExceededException('Maximum allowed download size reached. Downloaded ' . $progress['size_download'] . ' of allowed ' . $this->jobs[$i]['options']['max_file_size'] . ' bytes'));
  33362. }
  33363. }
  33364. }
  33365. }
  33366. }
  33367. private function handleRedirect(array $job, Response $response): string
  33368. {
  33369. if ($locationHeader = $response->getHeader('location')) {
  33370. if (parse_url($locationHeader, PHP_URL_SCHEME)) {
  33371. $targetUrl = $locationHeader;
  33372. } elseif (parse_url($locationHeader, PHP_URL_HOST)) {
  33373. $targetUrl = parse_url($job['url'], PHP_URL_SCHEME).':'.$locationHeader;
  33374. } elseif ('/' === $locationHeader[0]) {
  33375. $urlHost = parse_url($job['url'], PHP_URL_HOST);
  33376. $targetUrl = Preg::replace('{^(.+(?://|@)'.preg_quote($urlHost).'(?::\d+)?)(?:[/\?].*)?$}', '\1'.$locationHeader, $job['url']);
  33377. } else {
  33378. $targetUrl = Preg::replace('{^(.+/)[^/?]*(?:\?.*)?$}', '\1'.$locationHeader, $job['url']);
  33379. }
  33380. }
  33381. if (!empty($targetUrl)) {
  33382. $this->io->writeError(sprintf('Following redirect (%u) %s', $job['attributes']['redirects'] + 1, Url::sanitize($targetUrl)), true, IOInterface::DEBUG);
  33383. return $targetUrl;
  33384. }
  33385. throw new TransportException('The "'.$job['url'].'" file could not be downloaded, got redirect without Location ('.$response->getStatusMessage().')');
  33386. }
  33387. private function isAuthenticatedRetryNeeded(array $job, Response $response): array
  33388. {
  33389. if (in_array($response->getStatusCode(), array(401, 403)) && $job['attributes']['retryAuthFailure']) {
  33390. $result = $this->authHelper->promptAuthIfNeeded($job['url'], $job['origin'], $response->getStatusCode(), $response->getStatusMessage(), $response->getHeaders());
  33391. if ($result['retry']) {
  33392. return $result;
  33393. }
  33394. }
  33395. $locationHeader = $response->getHeader('location');
  33396. $needsAuthRetry = false;
  33397. if (
  33398. $job['origin'] === 'bitbucket.org'
  33399. && !$this->authHelper->isPublicBitBucketDownload($job['url'])
  33400. && substr($job['url'], -4) === '.zip'
  33401. && (!$locationHeader || substr($locationHeader, -4) !== '.zip')
  33402. && Preg::isMatch('{^text/html\b}i', $response->getHeader('content-type'))
  33403. ) {
  33404. $needsAuthRetry = 'Bitbucket requires authentication and it was not provided';
  33405. }
  33406. if (
  33407. $response->getStatusCode() === 404
  33408. && in_array($job['origin'], $this->config->get('gitlab-domains'), true)
  33409. && false !== strpos($job['url'], 'archive.zip')
  33410. ) {
  33411. $needsAuthRetry = 'GitLab requires authentication and it was not provided';
  33412. }
  33413. if ($needsAuthRetry) {
  33414. if ($job['attributes']['retryAuthFailure']) {
  33415. $result = $this->authHelper->promptAuthIfNeeded($job['url'], $job['origin'], 401);
  33416. if ($result['retry']) {
  33417. return $result;
  33418. }
  33419. }
  33420. throw $this->failResponse($job, $response, $needsAuthRetry);
  33421. }
  33422. return array('retry' => false, 'storeAuth' => false);
  33423. }
  33424. private function restartJob(array $job, string $url, array $attributes = array()): void
  33425. {
  33426. if (null !== $job['filename']) {
  33427. @unlink($job['filename'].'~');
  33428. }
  33429. $attributes = array_merge($job['attributes'], $attributes);
  33430. $origin = Url::getOrigin($this->config, $url);
  33431. $this->initDownload($job['resolve'], $job['reject'], $origin, $url, $job['options'], $job['filename'], $attributes);
  33432. }
  33433. private function failResponse(array $job, Response $response, string $errorMessage): TransportException
  33434. {
  33435. if (null !== $job['filename']) {
  33436. @unlink($job['filename'].'~');
  33437. }
  33438. $details = '';
  33439. if (in_array(strtolower($response->getHeader('content-type')), array('application/json', 'application/json; charset=utf-8'), true)) {
  33440. $details = ':'.PHP_EOL.substr($response->getBody(), 0, 200).(strlen($response->getBody()) > 200 ? '...' : '');
  33441. }
  33442. return new TransportException('The "'.$job['url'].'" file could not be downloaded ('.$errorMessage.')' . $details, $response->getStatusCode());
  33443. }
  33444. private function rejectJob(array $job, \Exception $e): void
  33445. {
  33446. if (is_resource($job['headerHandle'])) {
  33447. fclose($job['headerHandle']);
  33448. }
  33449. if (is_resource($job['bodyHandle'])) {
  33450. fclose($job['bodyHandle']);
  33451. }
  33452. if (null !== $job['filename']) {
  33453. @unlink($job['filename'].'~');
  33454. }
  33455. call_user_func($job['reject'], $e);
  33456. }
  33457. private function checkCurlResult(int $code): void
  33458. {
  33459. if ($code != CURLM_OK && $code != CURLM_CALL_MULTI_PERFORM) {
  33460. throw new \RuntimeException(
  33461. isset($this->multiErrors[$code])
  33462. ? "cURL error: {$code} ({$this->multiErrors[$code][0]}): cURL message: {$this->multiErrors[$code][1]}"
  33463. : 'Unexpected cURL error: ' . $code
  33464. );
  33465. }
  33466. }
  33467. }
  33468. <?php declare(strict_types=1);
  33469. namespace Composer\Util\Http;
  33470. class CurlResponse extends Response
  33471. {
  33472. private $curlInfo;
  33473. public function __construct(array $request, $code, array $headers, $body, array $curlInfo)
  33474. {
  33475. parent::__construct($request, $code, $headers, $body);
  33476. $this->curlInfo = $curlInfo;
  33477. }
  33478. public function getCurlInfo(): array
  33479. {
  33480. return $this->curlInfo;
  33481. }
  33482. }
  33483. <?php declare(strict_types=1);
  33484. namespace Composer\Util\Http;
  33485. class ProxyHelper
  33486. {
  33487. public static function getProxyData(): array
  33488. {
  33489. $httpProxy = null;
  33490. $httpsProxy = null;
  33491. if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
  33492. if ($env = self::getProxyEnv(array('http_proxy', 'HTTP_PROXY'), $name)) {
  33493. $httpProxy = self::checkProxy($env, $name);
  33494. }
  33495. }
  33496. if ($env = self::getProxyEnv(array('CGI_HTTP_PROXY'), $name)) {
  33497. $httpProxy = self::checkProxy($env, $name);
  33498. }
  33499. if ($env = self::getProxyEnv(array('https_proxy', 'HTTPS_PROXY'), $name)) {
  33500. $httpsProxy = self::checkProxy($env, $name);
  33501. } else {
  33502. $httpsProxy = $httpProxy;
  33503. }
  33504. $noProxy = self::getProxyEnv(array('no_proxy', 'NO_PROXY'), $name);
  33505. return array($httpProxy, $httpsProxy, $noProxy);
  33506. }
  33507. public static function getContextOptions(string $proxyUrl): array
  33508. {
  33509. $proxy = parse_url($proxyUrl);
  33510. $proxyUrl = self::formatParsedUrl($proxy, false);
  33511. $proxyUrl = str_replace(array('http://', 'https://'), array('tcp://', 'ssl://'), $proxyUrl);
  33512. $options['http']['proxy'] = $proxyUrl;
  33513. if (isset($proxy['user'])) {
  33514. $auth = rawurldecode($proxy['user']);
  33515. if (isset($proxy['pass'])) {
  33516. $auth .= ':' . rawurldecode($proxy['pass']);
  33517. }
  33518. $auth = base64_encode($auth);
  33519. $options['http']['header'] = "Proxy-Authorization: Basic {$auth}";
  33520. }
  33521. return $options;
  33522. }
  33523. public static function setRequestFullUri(string $requestUrl, array &$options): void
  33524. {
  33525. if ('http' === parse_url($requestUrl, PHP_URL_SCHEME)) {
  33526. $options['http']['request_fulluri'] = true;
  33527. } else {
  33528. unset($options['http']['request_fulluri']);
  33529. }
  33530. }
  33531. private static function getProxyEnv(array $names, ?string &$name): ?string
  33532. {
  33533. foreach ($names as $name) {
  33534. if (!empty($_SERVER[$name])) {
  33535. return $_SERVER[$name];
  33536. }
  33537. }
  33538. return null;
  33539. }
  33540. private static function checkProxy(string $proxyUrl, string $envName): string
  33541. {
  33542. $error = sprintf('malformed %s url', $envName);
  33543. $proxy = parse_url($proxyUrl);
  33544. if (!isset($proxy['host'])) {
  33545. throw new \RuntimeException($error);
  33546. }
  33547. $proxyUrl = self::formatParsedUrl($proxy, true);
  33548. if (!parse_url($proxyUrl, PHP_URL_PORT)) {
  33549. throw new \RuntimeException($error);
  33550. }
  33551. return $proxyUrl;
  33552. }
  33553. private static function formatParsedUrl(array $proxy, bool $includeAuth): string
  33554. {
  33555. $proxyUrl = isset($proxy['scheme']) ? strtolower($proxy['scheme']) . '://' : '';
  33556. if ($includeAuth && isset($proxy['user'])) {
  33557. $proxyUrl .= $proxy['user'];
  33558. if (isset($proxy['pass'])) {
  33559. $proxyUrl .= ':' . $proxy['pass'];
  33560. }
  33561. $proxyUrl .= '@';
  33562. }
  33563. $proxyUrl .= $proxy['host'];
  33564. if (isset($proxy['port'])) {
  33565. $proxyUrl .= ':' . $proxy['port'];
  33566. } elseif (strpos($proxyUrl, 'http://') === 0) {
  33567. $proxyUrl .= ':80';
  33568. } elseif (strpos($proxyUrl, 'https://') === 0) {
  33569. $proxyUrl .= ':443';
  33570. }
  33571. return $proxyUrl;
  33572. }
  33573. }
  33574. <?php declare(strict_types=1);
  33575. namespace Composer\Util\Http;
  33576. use Composer\Downloader\TransportException;
  33577. use Composer\Util\NoProxyPattern;
  33578. use Composer\Util\Url;
  33579. class ProxyManager
  33580. {
  33581. private $error = null;
  33582. private $fullProxy;
  33583. private $safeProxy;
  33584. private $streams;
  33585. private $hasProxy;
  33586. private $info = null;
  33587. private $noProxyHandler = null;
  33588. private static $instance = null;
  33589. private function __construct()
  33590. {
  33591. $this->fullProxy = $this->safeProxy = array(
  33592. 'http' => null,
  33593. 'https' => null,
  33594. );
  33595. $this->streams['http'] = $this->streams['https'] = array(
  33596. 'options' => null,
  33597. );
  33598. $this->hasProxy = false;
  33599. $this->initProxyData();
  33600. }
  33601. public static function getInstance(): ProxyManager
  33602. {
  33603. if (!self::$instance) {
  33604. self::$instance = new self();
  33605. }
  33606. return self::$instance;
  33607. }
  33608. public static function reset(): void
  33609. {
  33610. self::$instance = null;
  33611. }
  33612. public function getProxyForRequest(string $requestUrl): RequestProxy
  33613. {
  33614. if ($this->error) {
  33615. throw new TransportException('Unable to use a proxy: '.$this->error);
  33616. }
  33617. $scheme = parse_url($requestUrl, PHP_URL_SCHEME) ?: 'http';
  33618. $proxyUrl = '';
  33619. $options = array();
  33620. $formattedProxyUrl = '';
  33621. if ($this->hasProxy && in_array($scheme, array('http', 'https'), true) && $this->fullProxy[$scheme]) {
  33622. if ($this->noProxy($requestUrl)) {
  33623. $formattedProxyUrl = 'excluded by no_proxy';
  33624. } else {
  33625. $proxyUrl = $this->fullProxy[$scheme];
  33626. $options = $this->streams[$scheme]['options'];
  33627. ProxyHelper::setRequestFullUri($requestUrl, $options);
  33628. $formattedProxyUrl = $this->safeProxy[$scheme];
  33629. }
  33630. }
  33631. return new RequestProxy($proxyUrl, $options, $formattedProxyUrl);
  33632. }
  33633. public function isProxying(): bool
  33634. {
  33635. return $this->hasProxy;
  33636. }
  33637. public function getFormattedProxy(): ?string
  33638. {
  33639. return $this->hasProxy ? $this->info : $this->error;
  33640. }
  33641. private function initProxyData(): void
  33642. {
  33643. try {
  33644. list($httpProxy, $httpsProxy, $noProxy) = ProxyHelper::getProxyData();
  33645. } catch (\RuntimeException $e) {
  33646. $this->error = $e->getMessage();
  33647. return;
  33648. }
  33649. $info = array();
  33650. if ($httpProxy) {
  33651. $info[] = $this->setData($httpProxy, 'http');
  33652. }
  33653. if ($httpsProxy) {
  33654. $info[] = $this->setData($httpsProxy, 'https');
  33655. }
  33656. if ($this->hasProxy) {
  33657. $this->info = implode(', ', $info);
  33658. if ($noProxy) {
  33659. $this->noProxyHandler = new NoProxyPattern($noProxy);
  33660. }
  33661. }
  33662. }
  33663. private function setData($url, $scheme): string
  33664. {
  33665. $safeProxy = Url::sanitize($url);
  33666. $this->fullProxy[$scheme] = $url;
  33667. $this->safeProxy[$scheme] = $safeProxy;
  33668. $this->streams[$scheme]['options'] = ProxyHelper::getContextOptions($url);
  33669. $this->hasProxy = true;
  33670. return sprintf('%s=%s', $scheme, $safeProxy);
  33671. }
  33672. private function noProxy(string $requestUrl): bool
  33673. {
  33674. return $this->noProxyHandler && $this->noProxyHandler->test($requestUrl);
  33675. }
  33676. }
  33677. <?php declare(strict_types=1);
  33678. namespace Composer\Util\Http;
  33679. use Composer\Util\Url;
  33680. class RequestProxy
  33681. {
  33682. private $contextOptions;
  33683. private $isSecure;
  33684. private $formattedUrl;
  33685. private $url;
  33686. public function __construct(string $url, array $contextOptions, string $formattedUrl)
  33687. {
  33688. $this->url = $url;
  33689. $this->contextOptions = $contextOptions;
  33690. $this->formattedUrl = $formattedUrl;
  33691. $this->isSecure = 0 === strpos($url, 'https://');
  33692. }
  33693. public function getContextOptions(): array
  33694. {
  33695. return $this->contextOptions;
  33696. }
  33697. public function getFormattedUrl(?string $format = ''): string
  33698. {
  33699. $result = '';
  33700. if ($this->formattedUrl) {
  33701. $format = $format ?: '%s';
  33702. $result = sprintf($format, $this->formattedUrl);
  33703. }
  33704. return $result;
  33705. }
  33706. public function getUrl(): string
  33707. {
  33708. return $this->url;
  33709. }
  33710. public function isSecure(): bool
  33711. {
  33712. return $this->isSecure;
  33713. }
  33714. }
  33715. <?php declare(strict_types=1);
  33716. namespace Composer\Util\Http;
  33717. use Composer\Json\JsonFile;
  33718. use Composer\Pcre\Preg;
  33719. use Composer\Util\HttpDownloader;
  33720. class Response
  33721. {
  33722. private $request;
  33723. private $code;
  33724. private $headers;
  33725. private $body;
  33726. public function __construct(array $request, ?int $code, array $headers, ?string $body)
  33727. {
  33728. if (!isset($request['url'])) {
  33729. throw new \LogicException('url key missing from request array');
  33730. }
  33731. $this->request = $request;
  33732. $this->code = (int) $code;
  33733. $this->headers = $headers;
  33734. $this->body = $body;
  33735. }
  33736. public function getStatusCode(): int
  33737. {
  33738. return $this->code;
  33739. }
  33740. public function getStatusMessage(): ?string
  33741. {
  33742. $value = null;
  33743. foreach ($this->headers as $header) {
  33744. if (Preg::isMatch('{^HTTP/\S+ \d+}i', $header)) {
  33745. $value = $header;
  33746. }
  33747. }
  33748. return $value;
  33749. }
  33750. public function getHeaders(): array
  33751. {
  33752. return $this->headers;
  33753. }
  33754. public function getHeader(string $name): ?string
  33755. {
  33756. return self::findHeaderValue($this->headers, $name);
  33757. }
  33758. public function getBody(): ?string
  33759. {
  33760. return $this->body;
  33761. }
  33762. public function decodeJson()
  33763. {
  33764. return JsonFile::parseJson($this->body, $this->request['url']);
  33765. }
  33766. public function collect(): void
  33767. {
  33768. $this->request = $this->code = $this->headers = $this->body = null;
  33769. }
  33770. public static function findHeaderValue(array $headers, string $name): ?string
  33771. {
  33772. $value = null;
  33773. foreach ($headers as $header) {
  33774. if (Preg::isMatch('{^'.preg_quote($name).':\s*(.+?)\s*$}i', $header, $match)) {
  33775. $value = $match[1];
  33776. }
  33777. }
  33778. return $value;
  33779. }
  33780. }
  33781. <?php declare(strict_types=1);
  33782. namespace Composer\Util;
  33783. use Composer\Config;
  33784. use Composer\IO\IOInterface;
  33785. use Composer\Downloader\TransportException;
  33786. use Composer\Pcre\Preg;
  33787. use Composer\Util\Http\Response;
  33788. use Composer\Util\Http\CurlDownloader;
  33789. use Composer\Composer;
  33790. use Composer\Package\Version\VersionParser;
  33791. use Composer\Semver\Constraint\Constraint;
  33792. use Composer\Exception\IrrecoverableDownloadException;
  33793. use React\Promise\Promise;
  33794. use React\Promise\PromiseInterface;
  33795. class HttpDownloader
  33796. {
  33797. private const STATUS_QUEUED = 1;
  33798. private const STATUS_STARTED = 2;
  33799. private const STATUS_COMPLETED = 3;
  33800. private const STATUS_FAILED = 4;
  33801. private const STATUS_ABORTED = 5;
  33802. private $io;
  33803. private $config;
  33804. private $jobs = array();
  33805. private $options = array();
  33806. private $runningJobs = 0;
  33807. private $maxJobs = 12;
  33808. private $curl;
  33809. private $rfs;
  33810. private $idGen = 0;
  33811. private $disabled;
  33812. private $allowAsync = false;
  33813. public function __construct(IOInterface $io, Config $config, array $options = array(), bool $disableTls = false)
  33814. {
  33815. $this->io = $io;
  33816. $this->disabled = (bool) Platform::getEnv('COMPOSER_DISABLE_NETWORK');
  33817. if ($disableTls === false) {
  33818. $this->options = StreamContextFactory::getTlsDefaults($options, $io);
  33819. }
  33820. $this->options = array_replace_recursive($this->options, $options);
  33821. $this->config = $config;
  33822. if (self::isCurlEnabled()) {
  33823. $this->curl = new CurlDownloader($io, $config, $options, $disableTls);
  33824. }
  33825. $this->rfs = new RemoteFilesystem($io, $config, $options, $disableTls);
  33826. if (is_numeric($maxJobs = Platform::getEnv('COMPOSER_MAX_PARALLEL_HTTP'))) {
  33827. $this->maxJobs = max(1, min(50, (int) $maxJobs));
  33828. }
  33829. }
  33830. public function get(string $url, array $options = array())
  33831. {
  33832. list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => null), true);
  33833. $this->wait($job['id']);
  33834. $response = $this->getResponse($job['id']);
  33835. return $response;
  33836. }
  33837. public function add(string $url, array $options = array())
  33838. {
  33839. list(, $promise) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => null));
  33840. return $promise;
  33841. }
  33842. public function copy(string $url, string $to, array $options = array())
  33843. {
  33844. list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => $to), true);
  33845. $this->wait($job['id']);
  33846. return $this->getResponse($job['id']);
  33847. }
  33848. public function addCopy(string $url, string $to, array $options = array())
  33849. {
  33850. list(, $promise) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => $to));
  33851. return $promise;
  33852. }
  33853. public function getOptions()
  33854. {
  33855. return $this->options;
  33856. }
  33857. public function setOptions(array $options)
  33858. {
  33859. $this->options = array_replace_recursive($this->options, $options);
  33860. }
  33861. private function addJob(array $request, bool $sync = false): array
  33862. {
  33863. $request['options'] = array_replace_recursive($this->options, $request['options']);
  33864. $job = array(
  33865. 'id' => $this->idGen++,
  33866. 'status' => self::STATUS_QUEUED,
  33867. 'request' => $request,
  33868. 'sync' => $sync,
  33869. 'origin' => Url::getOrigin($this->config, $request['url']),
  33870. );
  33871. if (!$sync && !$this->allowAsync) {
  33872. throw new \LogicException('You must use the HttpDownloader instance which is part of a Composer\Loop instance to be able to run async http requests');
  33873. }
  33874. if (Preg::isMatch('{^https?://([^:/]+):([^@/]+)@([^/]+)}i', $request['url'], $match)) {
  33875. $this->io->setAuthentication($job['origin'], rawurldecode($match[1]), rawurldecode($match[2]));
  33876. }
  33877. $rfs = $this->rfs;
  33878. if ($this->canUseCurl($job)) {
  33879. $resolver = function ($resolve, $reject) use (&$job): void {
  33880. $job['status'] = HttpDownloader::STATUS_QUEUED;
  33881. $job['resolve'] = $resolve;
  33882. $job['reject'] = $reject;
  33883. };
  33884. } else {
  33885. $resolver = function ($resolve, $reject) use (&$job, $rfs): void {
  33886. $url = $job['request']['url'];
  33887. $options = $job['request']['options'];
  33888. $job['status'] = HttpDownloader::STATUS_STARTED;
  33889. if ($job['request']['copyTo']) {
  33890. $rfs->copy($job['origin'], $url, $job['request']['copyTo'], false , $options);
  33891. $headers = $rfs->getLastHeaders();
  33892. $response = new Http\Response($job['request'], $rfs->findStatusCode($headers), $headers, $job['request']['copyTo'].'~');
  33893. $resolve($response);
  33894. } else {
  33895. $body = $rfs->getContents($job['origin'], $url, false , $options);
  33896. $headers = $rfs->getLastHeaders();
  33897. $response = new Http\Response($job['request'], $rfs->findStatusCode($headers), $headers, $body);
  33898. $resolve($response);
  33899. }
  33900. };
  33901. }
  33902. $curl = $this->curl;
  33903. $canceler = function () use (&$job, $curl): void {
  33904. if ($job['status'] === HttpDownloader::STATUS_QUEUED) {
  33905. $job['status'] = HttpDownloader::STATUS_ABORTED;
  33906. }
  33907. if ($job['status'] !== HttpDownloader::STATUS_STARTED) {
  33908. return;
  33909. }
  33910. $job['status'] = HttpDownloader::STATUS_ABORTED;
  33911. if (isset($job['curl_id'])) {
  33912. $curl->abortRequest($job['curl_id']);
  33913. }
  33914. throw new IrrecoverableDownloadException('Download of ' . Url::sanitize($job['request']['url']) . ' canceled');
  33915. };
  33916. $promise = new Promise($resolver, $canceler);
  33917. $promise = $promise->then(function ($response) use (&$job) {
  33918. $job['status'] = HttpDownloader::STATUS_COMPLETED;
  33919. $job['response'] = $response;
  33920. $this->markJobDone();
  33921. return $response;
  33922. }, function ($e) use (&$job): void {
  33923. $job['status'] = HttpDownloader::STATUS_FAILED;
  33924. $job['exception'] = $e;
  33925. $this->markJobDone();
  33926. throw $e;
  33927. });
  33928. $this->jobs[$job['id']] = &$job;
  33929. if ($this->runningJobs < $this->maxJobs) {
  33930. $this->startJob($job['id']);
  33931. }
  33932. return array($job, $promise);
  33933. }
  33934. private function startJob(int $id): void
  33935. {
  33936. $job = &$this->jobs[$id];
  33937. if ($job['status'] !== self::STATUS_QUEUED) {
  33938. return;
  33939. }
  33940. $job['status'] = self::STATUS_STARTED;
  33941. $this->runningJobs++;
  33942. $resolve = $job['resolve'];
  33943. $reject = $job['reject'];
  33944. $url = $job['request']['url'];
  33945. $options = $job['request']['options'];
  33946. $origin = $job['origin'];
  33947. if ($this->disabled) {
  33948. if (isset($job['request']['options']['http']['header']) && false !== stripos(implode('', $job['request']['options']['http']['header']), 'if-modified-since')) {
  33949. $resolve(new Response(array('url' => $url), 304, array(), ''));
  33950. } else {
  33951. $e = new TransportException('Network disabled, request canceled: '.Url::sanitize($url), 499);
  33952. $e->setStatusCode(499);
  33953. $reject($e);
  33954. }
  33955. return;
  33956. }
  33957. try {
  33958. if ($job['request']['copyTo']) {
  33959. $job['curl_id'] = $this->curl->download($resolve, $reject, $origin, $url, $options, $job['request']['copyTo']);
  33960. } else {
  33961. $job['curl_id'] = $this->curl->download($resolve, $reject, $origin, $url, $options);
  33962. }
  33963. } catch (\Exception $exception) {
  33964. $reject($exception);
  33965. }
  33966. }
  33967. private function markJobDone(): void
  33968. {
  33969. $this->runningJobs--;
  33970. }
  33971. public function wait(?int $index = null)
  33972. {
  33973. do {
  33974. $jobCount = $this->countActiveJobs($index);
  33975. } while ($jobCount);
  33976. }
  33977. public function enableAsync(): void
  33978. {
  33979. $this->allowAsync = true;
  33980. }
  33981. public function countActiveJobs(?int $index = null): int
  33982. {
  33983. if ($this->runningJobs < $this->maxJobs) {
  33984. foreach ($this->jobs as $job) {
  33985. if ($job['status'] === self::STATUS_QUEUED && $this->runningJobs < $this->maxJobs) {
  33986. $this->startJob($job['id']);
  33987. }
  33988. }
  33989. }
  33990. if ($this->curl) {
  33991. $this->curl->tick();
  33992. }
  33993. if (null !== $index) {
  33994. return $this->jobs[$index]['status'] < self::STATUS_COMPLETED ? 1 : 0;
  33995. }
  33996. $active = 0;
  33997. foreach ($this->jobs as $job) {
  33998. if ($job['status'] < self::STATUS_COMPLETED) {
  33999. $active++;
  34000. } elseif (!$job['sync']) {
  34001. unset($this->jobs[$job['id']]);
  34002. }
  34003. }
  34004. return $active;
  34005. }
  34006. private function getResponse(int $index): Response
  34007. {
  34008. if (!isset($this->jobs[$index])) {
  34009. throw new \LogicException('Invalid request id');
  34010. }
  34011. if ($this->jobs[$index]['status'] === self::STATUS_FAILED) {
  34012. throw $this->jobs[$index]['exception'];
  34013. }
  34014. if (!isset($this->jobs[$index]['response'])) {
  34015. throw new \LogicException('Response not available yet, call wait() first');
  34016. }
  34017. $resp = $this->jobs[$index]['response'];
  34018. unset($this->jobs[$index]);
  34019. return $resp;
  34020. }
  34021. public static function outputWarnings(IOInterface $io, string $url, $data): void
  34022. {
  34023. $cleanMessage = function ($msg) use ($io) {
  34024. if (!$io->isDecorated()) {
  34025. $msg = Preg::replace('{'.chr(27).'\\[[;\d]*m}u', '', $msg);
  34026. }
  34027. return $msg;
  34028. };
  34029. foreach (array('warning', 'info') as $type) {
  34030. if (empty($data[$type])) {
  34031. continue;
  34032. }
  34033. if (!empty($data[$type . '-versions'])) {
  34034. $versionParser = new VersionParser();
  34035. $constraint = $versionParser->parseConstraints($data[$type . '-versions']);
  34036. $composer = new Constraint('==', $versionParser->normalize(Composer::getVersion()));
  34037. if (!$constraint->matches($composer)) {
  34038. continue;
  34039. }
  34040. }
  34041. $io->writeError('<'.$type.'>'.ucfirst($type).' from '.Url::sanitize($url).': '.$cleanMessage($data[$type]).'</'.$type.'>');
  34042. }
  34043. foreach (array('warnings', 'infos') as $key) {
  34044. if (empty($data[$key])) {
  34045. continue;
  34046. }
  34047. $versionParser = new VersionParser();
  34048. foreach ($data[$key] as $spec) {
  34049. $type = substr($key, 0, -1);
  34050. $constraint = $versionParser->parseConstraints($spec['versions']);
  34051. $composer = new Constraint('==', $versionParser->normalize(Composer::getVersion()));
  34052. if (!$constraint->matches($composer)) {
  34053. continue;
  34054. }
  34055. $io->writeError('<'.$type.'>'.ucfirst($type).' from '.Url::sanitize($url).': '.$cleanMessage($spec['message']).'</'.$type.'>');
  34056. }
  34057. }
  34058. }
  34059. public static function getExceptionHints(\Throwable $e): ?array
  34060. {
  34061. if (!$e instanceof TransportException) {
  34062. return null;
  34063. }
  34064. if (
  34065. false !== strpos($e->getMessage(), 'Resolving timed out')
  34066. || false !== strpos($e->getMessage(), 'Could not resolve host')
  34067. ) {
  34068. Silencer::suppress();
  34069. $testConnectivity = file_get_contents('https://8.8.8.8', false, stream_context_create(array(
  34070. 'ssl' => array('verify_peer' => false),
  34071. 'http' => array('follow_location' => false, 'ignore_errors' => true),
  34072. )));
  34073. Silencer::restore();
  34074. if (false !== $testConnectivity) {
  34075. return array(
  34076. '<error>The following exception probably indicates you have misconfigured DNS resolver(s)</error>',
  34077. );
  34078. }
  34079. return array(
  34080. '<error>The following exception probably indicates you are offline or have misconfigured DNS resolver(s)</error>',
  34081. );
  34082. }
  34083. return null;
  34084. }
  34085. private function canUseCurl(array $job): bool
  34086. {
  34087. if (!$this->curl) {
  34088. return false;
  34089. }
  34090. if (!Preg::isMatch('{^https?://}i', $job['request']['url'])) {
  34091. return false;
  34092. }
  34093. if (!empty($job['request']['options']['ssl']['allow_self_signed'])) {
  34094. return false;
  34095. }
  34096. return true;
  34097. }
  34098. public static function isCurlEnabled(): bool
  34099. {
  34100. return \extension_loaded('curl') && \function_exists('curl_multi_exec') && \function_exists('curl_multi_init');
  34101. }
  34102. }
  34103. <?php declare(strict_types=1);
  34104. namespace Composer\Util;
  34105. use Composer\XdebugHandler\XdebugHandler;
  34106. class IniHelper
  34107. {
  34108. public static function getAll(): array
  34109. {
  34110. return XdebugHandler::getAllIniFiles();
  34111. }
  34112. public static function getMessage(): string
  34113. {
  34114. $paths = self::getAll();
  34115. if (empty($paths[0])) {
  34116. array_shift($paths);
  34117. }
  34118. $ini = array_shift($paths);
  34119. if (empty($ini)) {
  34120. return 'A php.ini file does not exist. You will have to create one.';
  34121. }
  34122. if (!empty($paths)) {
  34123. return 'Your command-line PHP is using multiple ini files. Run `php --ini` to show them.';
  34124. }
  34125. return 'The php.ini used by your command-line PHP is: '.$ini;
  34126. }
  34127. }
  34128. <?php declare(strict_types=1);
  34129. namespace Composer\Util;
  34130. use React\Promise\CancellablePromiseInterface;
  34131. use Symfony\Component\Console\Helper\ProgressBar;
  34132. use React\Promise\PromiseInterface;
  34133. class Loop
  34134. {
  34135. private $httpDownloader;
  34136. private $processExecutor;
  34137. private $currentPromises = array();
  34138. private $waitIndex = 0;
  34139. public function __construct(HttpDownloader $httpDownloader, ProcessExecutor $processExecutor = null)
  34140. {
  34141. $this->httpDownloader = $httpDownloader;
  34142. $this->httpDownloader->enableAsync();
  34143. $this->processExecutor = $processExecutor;
  34144. if ($this->processExecutor) {
  34145. $this->processExecutor->enableAsync();
  34146. }
  34147. }
  34148. public function getHttpDownloader(): HttpDownloader
  34149. {
  34150. return $this->httpDownloader;
  34151. }
  34152. public function getProcessExecutor(): ?ProcessExecutor
  34153. {
  34154. return $this->processExecutor;
  34155. }
  34156. public function wait(array $promises, ProgressBar $progress = null): void
  34157. {
  34158. $uncaught = null;
  34159. \React\Promise\all($promises)->then(
  34160. function (): void {
  34161. },
  34162. function ($e) use (&$uncaught): void {
  34163. $uncaught = $e;
  34164. }
  34165. );
  34166. $waitIndex = $this->waitIndex++;
  34167. $this->currentPromises[$waitIndex] = $promises;
  34168. if ($progress) {
  34169. $totalJobs = 0;
  34170. $totalJobs += $this->httpDownloader->countActiveJobs();
  34171. if ($this->processExecutor) {
  34172. $totalJobs += $this->processExecutor->countActiveJobs();
  34173. }
  34174. $progress->start($totalJobs);
  34175. }
  34176. $lastUpdate = 0;
  34177. while (true) {
  34178. $activeJobs = 0;
  34179. $activeJobs += $this->httpDownloader->countActiveJobs();
  34180. if ($this->processExecutor) {
  34181. $activeJobs += $this->processExecutor->countActiveJobs();
  34182. }
  34183. if ($progress && microtime(true) - $lastUpdate > 0.1) {
  34184. $lastUpdate = microtime(true);
  34185. $progress->setProgress($progress->getMaxSteps() - $activeJobs);
  34186. }
  34187. if (!$activeJobs) {
  34188. break;
  34189. }
  34190. }
  34191. if ($progress) {
  34192. $progress->finish();
  34193. }
  34194. unset($this->currentPromises[$waitIndex]);
  34195. if ($uncaught) {
  34196. throw $uncaught;
  34197. }
  34198. }
  34199. public function abortJobs(): void
  34200. {
  34201. foreach ($this->currentPromises as $promiseGroup) {
  34202. foreach ($promiseGroup as $promise) {
  34203. if ($promise instanceof CancellablePromiseInterface) {
  34204. $promise->cancel();
  34205. }
  34206. }
  34207. }
  34208. }
  34209. }
  34210. <?php declare(strict_types=1);
  34211. namespace Composer\Util;
  34212. @trigger_error('Composer\Util\MetadataMinifier is deprecated, use Composer\MetadataMinifier\MetadataMinifier from composer/metadata-minifier instead.', E_USER_DEPRECATED);
  34213. class MetadataMinifier extends \Composer\MetadataMinifier\MetadataMinifier
  34214. {
  34215. }
  34216. <?php declare(strict_types=1);
  34217. namespace Composer\Util;
  34218. use Composer\Pcre\Preg;
  34219. use stdClass;
  34220. class NoProxyPattern
  34221. {
  34222. protected $hostNames = array();
  34223. protected $rules = array();
  34224. protected $noproxy;
  34225. public function __construct(string $pattern)
  34226. {
  34227. $this->hostNames = Preg::split('{[\s,]+}', $pattern, -1, PREG_SPLIT_NO_EMPTY);
  34228. $this->noproxy = empty($this->hostNames) || '*' === $this->hostNames[0];
  34229. }
  34230. public function test(string $url): bool
  34231. {
  34232. if ($this->noproxy) {
  34233. return true;
  34234. }
  34235. if (!$urlData = $this->getUrlData($url)) {
  34236. return false;
  34237. }
  34238. foreach ($this->hostNames as $index => $hostName) {
  34239. if ($this->match($index, $hostName, $urlData)) {
  34240. return true;
  34241. }
  34242. }
  34243. return false;
  34244. }
  34245. protected function getUrlData(string $url)
  34246. {
  34247. if (!$host = parse_url($url, PHP_URL_HOST)) {
  34248. return false;
  34249. }
  34250. $port = parse_url($url, PHP_URL_PORT);
  34251. if (empty($port)) {
  34252. switch (parse_url($url, PHP_URL_SCHEME)) {
  34253. case 'http':
  34254. $port = 80;
  34255. break;
  34256. case 'https':
  34257. $port = 443;
  34258. break;
  34259. }
  34260. }
  34261. $hostName = $host . ($port ? ':' . $port : '');
  34262. list($host, $port, $err) = $this->splitHostPort($hostName);
  34263. if ($err || !$this->ipCheckData($host, $ipdata)) {
  34264. return false;
  34265. }
  34266. return $this->makeData($host, $port, $ipdata);
  34267. }
  34268. protected function match(int $index, string $hostName, stdClass $url): bool
  34269. {
  34270. if (!$rule = $this->getRule($index, $hostName)) {
  34271. return false;
  34272. }
  34273. if ($rule->ipdata) {
  34274. if (!$url->ipdata) {
  34275. return false;
  34276. }
  34277. if ($rule->ipdata->netmask) {
  34278. return $this->matchRange($rule->ipdata, $url->ipdata);
  34279. }
  34280. $match = $rule->ipdata->ip === $url->ipdata->ip;
  34281. } else {
  34282. $haystack = substr($url->name, -strlen($rule->name));
  34283. $match = stripos($haystack, $rule->name) === 0;
  34284. }
  34285. if ($match && $rule->port) {
  34286. $match = $rule->port === $url->port;
  34287. }
  34288. return $match;
  34289. }
  34290. protected function matchRange(stdClass $network, stdClass $target): bool
  34291. {
  34292. $net = unpack('C*', $network->ip);
  34293. $mask = unpack('C*', $network->netmask);
  34294. $ip = unpack('C*', $target->ip);
  34295. if (false === $net) {
  34296. throw new \RuntimeException('Could not parse network IP '.$network->ip);
  34297. }
  34298. if (false === $mask) {
  34299. throw new \RuntimeException('Could not parse netmask '.$network->netmask);
  34300. }
  34301. if (false === $ip) {
  34302. throw new \RuntimeException('Could not parse target IP '.$target->ip);
  34303. }
  34304. for ($i = 1; $i < 17; ++$i) {
  34305. if (($net[$i] & $mask[$i]) !== ($ip[$i] & $mask[$i])) {
  34306. return false;
  34307. }
  34308. }
  34309. return true;
  34310. }
  34311. private function getRule(int $index, string $hostName): ?stdClass
  34312. {
  34313. if (array_key_exists($index, $this->rules)) {
  34314. return $this->rules[$index];
  34315. }
  34316. $this->rules[$index] = null;
  34317. list($host, $port, $err) = $this->splitHostPort($hostName);
  34318. if ($err || !$this->ipCheckData($host, $ipdata, true)) {
  34319. return null;
  34320. }
  34321. $this->rules[$index] = $this->makeData($host, $port, $ipdata);
  34322. return $this->rules[$index];
  34323. }
  34324. private function ipCheckData(string $host, ?stdClass &$ipdata, bool $allowPrefix = false): bool
  34325. {
  34326. $ipdata = null;
  34327. $netmask = null;
  34328. $prefix = null;
  34329. $modified = false;
  34330. if (strpos($host, '/') !== false) {
  34331. list($host, $prefix) = explode('/', $host);
  34332. if (!$allowPrefix || !$this->validateInt($prefix, 0, 128)) {
  34333. return false;
  34334. }
  34335. $prefix = (int) $prefix;
  34336. $modified = true;
  34337. }
  34338. if (!filter_var($host, FILTER_VALIDATE_IP)) {
  34339. return !$modified;
  34340. }
  34341. list($ip, $size) = $this->ipGetAddr($host);
  34342. if ($prefix !== null) {
  34343. if ($prefix > $size * 8) {
  34344. return false;
  34345. }
  34346. list($ip, $netmask) = $this->ipGetNetwork($ip, $size, $prefix);
  34347. }
  34348. $ipdata = $this->makeIpData($ip, $size, $netmask);
  34349. return true;
  34350. }
  34351. private function ipGetAddr(string $host): array
  34352. {
  34353. $ip = inet_pton($host);
  34354. $size = strlen($ip);
  34355. $mapped = $this->ipMapTo6($ip, $size);
  34356. return array($mapped, $size);
  34357. }
  34358. private function ipGetMask(int $prefix, int $size): string
  34359. {
  34360. $mask = '';
  34361. if ($ones = floor($prefix / 8)) {
  34362. $mask = str_repeat(chr(255), (int) $ones);
  34363. }
  34364. if ($remainder = $prefix % 8) {
  34365. $mask .= chr(0xff ^ (0xff >> $remainder));
  34366. }
  34367. $mask = str_pad($mask, $size, chr(0));
  34368. return $this->ipMapTo6($mask, $size);
  34369. }
  34370. private function ipGetNetwork(string $rangeIp, int $size, int $prefix): array
  34371. {
  34372. $netmask = $this->ipGetMask($prefix, $size);
  34373. $mask = unpack('C*', $netmask);
  34374. $ip = unpack('C*', $rangeIp);
  34375. $net = '';
  34376. if (false === $mask) {
  34377. throw new \RuntimeException('Could not parse netmask '.$netmask);
  34378. }
  34379. if (false === $ip) {
  34380. throw new \RuntimeException('Could not parse range IP '.$rangeIp);
  34381. }
  34382. for ($i = 1; $i < 17; ++$i) {
  34383. $net .= chr($ip[$i] & $mask[$i]);
  34384. }
  34385. return array($net, $netmask);
  34386. }
  34387. private function ipMapTo6(string $binary, int $size): string
  34388. {
  34389. if ($size === 4) {
  34390. $prefix = str_repeat(chr(0), 10) . str_repeat(chr(255), 2);
  34391. $binary = $prefix . $binary;
  34392. }
  34393. return $binary;
  34394. }
  34395. private function makeData(string $host, int $port, ?stdClass $ipdata): stdClass
  34396. {
  34397. return (object) array(
  34398. 'host' => $host,
  34399. 'name' => '.' . ltrim($host, '.'),
  34400. 'port' => $port,
  34401. 'ipdata' => $ipdata,
  34402. );
  34403. }
  34404. private function makeIpData(string $ip, int $size, ?string $netmask): stdClass
  34405. {
  34406. return (object) array(
  34407. 'ip' => $ip,
  34408. 'size' => $size,
  34409. 'netmask' => $netmask,
  34410. );
  34411. }
  34412. private function splitHostPort(string $hostName): array
  34413. {
  34414. $error = array('', '', true);
  34415. $port = 0;
  34416. $ip6 = '';
  34417. if ($hostName[0] === '[') {
  34418. $index = strpos($hostName, ']');
  34419. if (false === $index || $index < 3) {
  34420. return $error;
  34421. }
  34422. $ip6 = substr($hostName, 1, $index - 1);
  34423. $hostName = substr($hostName, $index + 1);
  34424. if (strpbrk($hostName, '[]') !== false || substr_count($hostName, ':') > 1) {
  34425. return $error;
  34426. }
  34427. }
  34428. if (substr_count($hostName, ':') === 1) {
  34429. $index = strpos($hostName, ':');
  34430. $port = substr($hostName, $index + 1);
  34431. $hostName = substr($hostName, 0, $index);
  34432. if (!$this->validateInt($port, 1, 65535)) {
  34433. return $error;
  34434. }
  34435. $port = (int) $port;
  34436. }
  34437. $host = $ip6 . $hostName;
  34438. return array($host, $port, false);
  34439. }
  34440. private function validateInt(string $int, int $min, int $max): bool
  34441. {
  34442. $options = array(
  34443. 'options' => array(
  34444. 'min_range' => $min,
  34445. 'max_range' => $max,
  34446. ),
  34447. );
  34448. return false !== filter_var($int, FILTER_VALIDATE_INT, $options);
  34449. }
  34450. }
  34451. <?php declare(strict_types=1);
  34452. namespace Composer\Util;
  34453. use Composer\Package\CompletePackageInterface;
  34454. use Composer\Package\PackageInterface;
  34455. class PackageInfo
  34456. {
  34457. public static function getViewSourceUrl(PackageInterface $package): ?string
  34458. {
  34459. if ($package instanceof CompletePackageInterface && isset($package->getSupport()['source'])) {
  34460. return $package->getSupport()['source'];
  34461. }
  34462. return $package->getSourceUrl();
  34463. }
  34464. public static function getViewSourceOrHomepageUrl(PackageInterface $package): ?string
  34465. {
  34466. return self::getViewSourceUrl($package) ?? ($package instanceof CompletePackageInterface ? $package->getHomepage() : null);
  34467. }
  34468. }
  34469. <?php declare(strict_types=1);
  34470. namespace Composer\Util;
  34471. use Composer\Package\PackageInterface;
  34472. use Composer\Package\RootPackageInterface;
  34473. class PackageSorter
  34474. {
  34475. public static function sortPackages(array $packages, array $weights = array()): array
  34476. {
  34477. $usageList = array();
  34478. foreach ($packages as $package) {
  34479. $links = $package->getRequires();
  34480. if ($package instanceof RootPackageInterface) {
  34481. $links = array_merge($links, $package->getDevRequires());
  34482. }
  34483. foreach ($links as $link) {
  34484. $target = $link->getTarget();
  34485. $usageList[$target][] = $package->getName();
  34486. }
  34487. }
  34488. $computing = array();
  34489. $computed = array();
  34490. $computeImportance = function ($name) use (&$computeImportance, &$computing, &$computed, $usageList, $weights) {
  34491. if (isset($computed[$name])) {
  34492. return $computed[$name];
  34493. }
  34494. if (isset($computing[$name])) {
  34495. return 0;
  34496. }
  34497. $computing[$name] = true;
  34498. $weight = $weights[$name] ?? 0;
  34499. if (isset($usageList[$name])) {
  34500. foreach ($usageList[$name] as $user) {
  34501. $weight -= 1 - $computeImportance($user);
  34502. }
  34503. }
  34504. unset($computing[$name]);
  34505. $computed[$name] = $weight;
  34506. return $weight;
  34507. };
  34508. $weightedPackages = array();
  34509. foreach ($packages as $index => $package) {
  34510. $name = $package->getName();
  34511. $weight = $computeImportance($name);
  34512. $weightedPackages[] = array('name' => $name, 'weight' => $weight, 'index' => $index);
  34513. }
  34514. usort($weightedPackages, function (array $a, array $b): int {
  34515. if ($a['weight'] !== $b['weight']) {
  34516. return $a['weight'] - $b['weight'];
  34517. }
  34518. return strnatcasecmp($a['name'], $b['name']);
  34519. });
  34520. $sortedPackages = array();
  34521. foreach ($weightedPackages as $pkg) {
  34522. $sortedPackages[] = $packages[$pkg['index']];
  34523. }
  34524. return $sortedPackages;
  34525. }
  34526. }
  34527. <?php declare(strict_types=1);
  34528. namespace Composer\Util;
  34529. use Composer\IO\IOInterface;
  34530. use Composer\Pcre\Preg;
  34531. use Symfony\Component\Process\Process;
  34532. class Perforce
  34533. {
  34534. protected $path;
  34535. protected $p4Depot;
  34536. protected $p4Client;
  34537. protected $p4User;
  34538. protected $p4Password;
  34539. protected $p4Port;
  34540. protected $p4Stream;
  34541. protected $p4ClientSpec;
  34542. protected $p4DepotType;
  34543. protected $p4Branch;
  34544. protected $process;
  34545. protected $uniquePerforceClientName;
  34546. protected $windowsFlag;
  34547. protected $commandResult;
  34548. protected $io;
  34549. protected $filesystem;
  34550. public function __construct($repoConfig, string $port, string $path, ProcessExecutor $process, bool $isWindows, IOInterface $io)
  34551. {
  34552. $this->windowsFlag = $isWindows;
  34553. $this->p4Port = $port;
  34554. $this->initializePath($path);
  34555. $this->process = $process;
  34556. $this->initialize($repoConfig);
  34557. $this->io = $io;
  34558. }
  34559. public static function create($repoConfig, string $port, string $path, ProcessExecutor $process, IOInterface $io): self
  34560. {
  34561. return new Perforce($repoConfig, $port, $path, $process, Platform::isWindows(), $io);
  34562. }
  34563. public static function checkServerExists(string $url, ProcessExecutor $processExecutor): bool
  34564. {
  34565. return 0 === $processExecutor->execute('p4 -p ' . ProcessExecutor::escape($url) . ' info -s', $ignoredOutput);
  34566. }
  34567. public function initialize($repoConfig): void
  34568. {
  34569. $this->uniquePerforceClientName = $this->generateUniquePerforceClientName();
  34570. if (!$repoConfig) {
  34571. return;
  34572. }
  34573. if (isset($repoConfig['unique_perforce_client_name'])) {
  34574. $this->uniquePerforceClientName = $repoConfig['unique_perforce_client_name'];
  34575. }
  34576. if (isset($repoConfig['depot'])) {
  34577. $this->p4Depot = $repoConfig['depot'];
  34578. }
  34579. if (isset($repoConfig['branch'])) {
  34580. $this->p4Branch = $repoConfig['branch'];
  34581. }
  34582. if (isset($repoConfig['p4user'])) {
  34583. $this->p4User = $repoConfig['p4user'];
  34584. } else {
  34585. $this->p4User = $this->getP4variable('P4USER');
  34586. }
  34587. if (isset($repoConfig['p4password'])) {
  34588. $this->p4Password = $repoConfig['p4password'];
  34589. }
  34590. }
  34591. public function initializeDepotAndBranch(?string $depot, ?string $branch): void
  34592. {
  34593. if (isset($depot)) {
  34594. $this->p4Depot = $depot;
  34595. }
  34596. if (isset($branch)) {
  34597. $this->p4Branch = $branch;
  34598. }
  34599. }
  34600. public function generateUniquePerforceClientName(): string
  34601. {
  34602. return gethostname() . "_" . time();
  34603. }
  34604. public function cleanupClientSpec(): void
  34605. {
  34606. $client = $this->getClient();
  34607. $task = 'client -d ' . ProcessExecutor::escape($client);
  34608. $useP4Client = false;
  34609. $command = $this->generateP4Command($task, $useP4Client);
  34610. $this->executeCommand($command);
  34611. $clientSpec = $this->getP4ClientSpec();
  34612. $fileSystem = $this->getFilesystem();
  34613. $fileSystem->remove($clientSpec);
  34614. }
  34615. protected function executeCommand($command): int
  34616. {
  34617. $this->commandResult = '';
  34618. return $this->process->execute($command, $this->commandResult);
  34619. }
  34620. public function getClient(): string
  34621. {
  34622. if (!isset($this->p4Client)) {
  34623. $cleanStreamName = str_replace(array('//', '/', '@'), array('', '_', ''), $this->getStream());
  34624. $this->p4Client = 'composer_perforce_' . $this->uniquePerforceClientName . '_' . $cleanStreamName;
  34625. }
  34626. return $this->p4Client;
  34627. }
  34628. protected function getPath(): string
  34629. {
  34630. return $this->path;
  34631. }
  34632. public function initializePath(string $path): void
  34633. {
  34634. $this->path = $path;
  34635. $fs = $this->getFilesystem();
  34636. $fs->ensureDirectoryExists($path);
  34637. }
  34638. protected function getPort(): string
  34639. {
  34640. return $this->p4Port;
  34641. }
  34642. public function setStream(string $stream): void
  34643. {
  34644. $this->p4Stream = $stream;
  34645. $index = strrpos($stream, '/');
  34646. if ($index > 2) {
  34647. $this->p4DepotType = 'stream';
  34648. }
  34649. }
  34650. public function isStream(): bool
  34651. {
  34652. return is_string($this->p4DepotType) && (strcmp($this->p4DepotType, 'stream') === 0);
  34653. }
  34654. public function getStream(): string
  34655. {
  34656. if (!isset($this->p4Stream)) {
  34657. if ($this->isStream()) {
  34658. $this->p4Stream = '//' . $this->p4Depot . '/' . $this->p4Branch;
  34659. } else {
  34660. $this->p4Stream = '//' . $this->p4Depot;
  34661. }
  34662. }
  34663. return $this->p4Stream;
  34664. }
  34665. public function getStreamWithoutLabel(string $stream): string
  34666. {
  34667. $index = strpos($stream, '@');
  34668. if ($index === false) {
  34669. return $stream;
  34670. }
  34671. return substr($stream, 0, $index);
  34672. }
  34673. public function getP4ClientSpec(): string
  34674. {
  34675. return $this->path . '/' . $this->getClient() . '.p4.spec';
  34676. }
  34677. public function getUser(): ?string
  34678. {
  34679. return $this->p4User;
  34680. }
  34681. public function setUser(?string $user): void
  34682. {
  34683. $this->p4User = $user;
  34684. }
  34685. public function queryP4User(): void
  34686. {
  34687. $this->getUser();
  34688. if (strlen((string) $this->p4User) > 0) {
  34689. return;
  34690. }
  34691. $this->p4User = $this->getP4variable('P4USER');
  34692. if (strlen((string) $this->p4User) > 0) {
  34693. return;
  34694. }
  34695. $this->p4User = $this->io->ask('Enter P4 User:');
  34696. if ($this->windowsFlag) {
  34697. $command = 'p4 set P4USER=' . $this->p4User;
  34698. } else {
  34699. $command = 'export P4USER=' . $this->p4User;
  34700. }
  34701. $this->executeCommand($command);
  34702. }
  34703. protected function getP4variable(string $name): ?string
  34704. {
  34705. if ($this->windowsFlag) {
  34706. $command = 'p4 set';
  34707. $this->executeCommand($command);
  34708. $result = trim($this->commandResult);
  34709. $resArray = explode(PHP_EOL, $result);
  34710. foreach ($resArray as $line) {
  34711. $fields = explode('=', $line);
  34712. if (strcmp($name, $fields[0]) == 0) {
  34713. $index = strpos($fields[1], ' ');
  34714. if ($index === false) {
  34715. $value = $fields[1];
  34716. } else {
  34717. $value = substr($fields[1], 0, $index);
  34718. }
  34719. $value = trim($value);
  34720. return $value;
  34721. }
  34722. }
  34723. return null;
  34724. }
  34725. $command = 'echo $' . $name;
  34726. $this->executeCommand($command);
  34727. $result = trim($this->commandResult);
  34728. return $result;
  34729. }
  34730. public function queryP4Password(): ?string
  34731. {
  34732. if (isset($this->p4Password)) {
  34733. return $this->p4Password;
  34734. }
  34735. $password = $this->getP4variable('P4PASSWD');
  34736. if (strlen((string) $password) <= 0) {
  34737. $password = $this->io->askAndHideAnswer('Enter password for Perforce user ' . $this->getUser() . ': ');
  34738. }
  34739. $this->p4Password = $password;
  34740. return $password;
  34741. }
  34742. public function generateP4Command(string $command, bool $useClient = true): string
  34743. {
  34744. $p4Command = 'p4 ';
  34745. $p4Command .= '-u ' . $this->getUser() . ' ';
  34746. if ($useClient) {
  34747. $p4Command .= '-c ' . $this->getClient() . ' ';
  34748. }
  34749. $p4Command .= '-p ' . $this->getPort() . ' ' . $command;
  34750. return $p4Command;
  34751. }
  34752. public function isLoggedIn(): bool
  34753. {
  34754. $command = $this->generateP4Command('login -s', false);
  34755. $exitCode = $this->executeCommand($command);
  34756. if ($exitCode) {
  34757. $errorOutput = $this->process->getErrorOutput();
  34758. $index = strpos($errorOutput, $this->getUser());
  34759. if ($index === false) {
  34760. $index = strpos($errorOutput, 'p4');
  34761. if ($index === false) {
  34762. return false;
  34763. }
  34764. throw new \Exception('p4 command not found in path: ' . $errorOutput);
  34765. }
  34766. throw new \Exception('Invalid user name: ' . $this->getUser());
  34767. }
  34768. return true;
  34769. }
  34770. public function connectClient(): void
  34771. {
  34772. $p4CreateClientCommand = $this->generateP4Command(
  34773. 'client -i < ' . str_replace(" ", "\\ ", $this->getP4ClientSpec())
  34774. );
  34775. $this->executeCommand($p4CreateClientCommand);
  34776. }
  34777. public function syncCodeBase(?string $sourceReference): void
  34778. {
  34779. $prevDir = Platform::getCwd();
  34780. chdir($this->path);
  34781. $p4SyncCommand = $this->generateP4Command('sync -f ');
  34782. if (null !== $sourceReference) {
  34783. $p4SyncCommand .= '@' . $sourceReference;
  34784. }
  34785. $this->executeCommand($p4SyncCommand);
  34786. chdir($prevDir);
  34787. }
  34788. public function writeClientSpecToFile($spec): void
  34789. {
  34790. fwrite($spec, 'Client: ' . $this->getClient() . PHP_EOL . PHP_EOL);
  34791. fwrite($spec, 'Update: ' . date('Y/m/d H:i:s') . PHP_EOL . PHP_EOL);
  34792. fwrite($spec, 'Access: ' . date('Y/m/d H:i:s') . PHP_EOL);
  34793. fwrite($spec, 'Owner: ' . $this->getUser() . PHP_EOL . PHP_EOL);
  34794. fwrite($spec, 'Description:' . PHP_EOL);
  34795. fwrite($spec, ' Created by ' . $this->getUser() . ' from composer.' . PHP_EOL . PHP_EOL);
  34796. fwrite($spec, 'Root: ' . $this->getPath() . PHP_EOL . PHP_EOL);
  34797. fwrite($spec, 'Options: noallwrite noclobber nocompress unlocked modtime rmdir' . PHP_EOL . PHP_EOL);
  34798. fwrite($spec, 'SubmitOptions: revertunchanged' . PHP_EOL . PHP_EOL);
  34799. fwrite($spec, 'LineEnd: local' . PHP_EOL . PHP_EOL);
  34800. if ($this->isStream()) {
  34801. fwrite($spec, 'Stream:' . PHP_EOL);
  34802. fwrite($spec, ' ' . $this->getStreamWithoutLabel($this->p4Stream) . PHP_EOL);
  34803. } else {
  34804. fwrite(
  34805. $spec,
  34806. 'View: ' . $this->getStream() . '/... //' . $this->getClient() . '/... ' . PHP_EOL
  34807. );
  34808. }
  34809. }
  34810. public function writeP4ClientSpec(): void
  34811. {
  34812. $clientSpec = $this->getP4ClientSpec();
  34813. $spec = fopen($clientSpec, 'w');
  34814. try {
  34815. $this->writeClientSpecToFile($spec);
  34816. } catch (\Exception $e) {
  34817. fclose($spec);
  34818. throw $e;
  34819. }
  34820. fclose($spec);
  34821. }
  34822. protected function read($pipe, $name): void
  34823. {
  34824. if (feof($pipe)) {
  34825. return;
  34826. }
  34827. $line = fgets($pipe);
  34828. while ($line !== false) {
  34829. $line = fgets($pipe);
  34830. }
  34831. }
  34832. public function windowsLogin(?string $password): int
  34833. {
  34834. $command = $this->generateP4Command(' login -a');
  34835. $process = Process::fromShellCommandline($command, null, null, $password);
  34836. return $process->run();
  34837. }
  34838. public function p4Login(): void
  34839. {
  34840. $this->queryP4User();
  34841. if (!$this->isLoggedIn()) {
  34842. $password = $this->queryP4Password();
  34843. if ($this->windowsFlag) {
  34844. $this->windowsLogin($password);
  34845. } else {
  34846. $command = 'echo ' . ProcessExecutor::escape($password) . ' | ' . $this->generateP4Command(' login -a', false);
  34847. $exitCode = $this->executeCommand($command);
  34848. if ($exitCode) {
  34849. throw new \Exception("Error logging in:" . $this->process->getErrorOutput());
  34850. }
  34851. }
  34852. }
  34853. }
  34854. public function getComposerInformation(string $identifier): ?array
  34855. {
  34856. $composerFileContent = $this->getFileContent('composer.json', $identifier);
  34857. if (!$composerFileContent) {
  34858. return null;
  34859. }
  34860. return json_decode($composerFileContent, true);
  34861. }
  34862. public function getFileContent(string $file, string $identifier): ?string
  34863. {
  34864. $path = $this->getFilePath($file, $identifier);
  34865. $command = $this->generateP4Command(' print ' . ProcessExecutor::escape($path));
  34866. $this->executeCommand($command);
  34867. $result = $this->commandResult;
  34868. if (!trim($result)) {
  34869. return null;
  34870. }
  34871. return $result;
  34872. }
  34873. public function getFilePath(string $file, string $identifier): ?string
  34874. {
  34875. $index = strpos($identifier, '@');
  34876. if ($index === false) {
  34877. return $identifier. '/' . $file;
  34878. }
  34879. $path = substr($identifier, 0, $index) . '/' . $file . substr($identifier, $index);
  34880. $command = $this->generateP4Command(' files ' . ProcessExecutor::escape($path), false);
  34881. $this->executeCommand($command);
  34882. $result = $this->commandResult;
  34883. $index2 = strpos($result, 'no such file(s).');
  34884. if ($index2 === false) {
  34885. $index3 = strpos($result, 'change');
  34886. if ($index3 !== false) {
  34887. $phrase = trim(substr($result, $index3));
  34888. $fields = explode(' ', $phrase);
  34889. return substr($identifier, 0, $index) . '/' . $file . '@' . $fields[1];
  34890. }
  34891. }
  34892. return null;
  34893. }
  34894. public function getBranches(): array
  34895. {
  34896. $possibleBranches = array();
  34897. if (!$this->isStream()) {
  34898. $possibleBranches[$this->p4Branch] = $this->getStream();
  34899. } else {
  34900. $command = $this->generateP4Command('streams '.ProcessExecutor::escape('//' . $this->p4Depot . '/...'));
  34901. $this->executeCommand($command);
  34902. $result = $this->commandResult;
  34903. $resArray = explode(PHP_EOL, $result);
  34904. foreach ($resArray as $line) {
  34905. $resBits = explode(' ', $line);
  34906. if (count($resBits) > 4) {
  34907. $branch = Preg::replace('/[^A-Za-z0-9 ]/', '', $resBits[4]);
  34908. $possibleBranches[$branch] = $resBits[1];
  34909. }
  34910. }
  34911. }
  34912. $command = $this->generateP4Command('changes '. ProcessExecutor::escape($this->getStream() . '/...'), false);
  34913. $this->executeCommand($command);
  34914. $result = $this->commandResult;
  34915. $resArray = explode(PHP_EOL, $result);
  34916. $lastCommit = $resArray[0];
  34917. $lastCommitArr = explode(' ', $lastCommit);
  34918. $lastCommitNum = $lastCommitArr[1];
  34919. return array('master' => $possibleBranches[$this->p4Branch] . '@'. $lastCommitNum);
  34920. }
  34921. public function getTags(): array
  34922. {
  34923. $command = $this->generateP4Command('labels');
  34924. $this->executeCommand($command);
  34925. $result = $this->commandResult;
  34926. $resArray = explode(PHP_EOL, $result);
  34927. $tags = array();
  34928. foreach ($resArray as $line) {
  34929. if (strpos($line, 'Label') !== false) {
  34930. $fields = explode(' ', $line);
  34931. $tags[$fields[1]] = $this->getStream() . '@' . $fields[1];
  34932. }
  34933. }
  34934. return $tags;
  34935. }
  34936. public function checkStream(): bool
  34937. {
  34938. $command = $this->generateP4Command('depots', false);
  34939. $this->executeCommand($command);
  34940. $result = $this->commandResult;
  34941. $resArray = explode(PHP_EOL, $result);
  34942. foreach ($resArray as $line) {
  34943. if (strpos($line, 'Depot') !== false) {
  34944. $fields = explode(' ', $line);
  34945. if (strcmp($this->p4Depot, $fields[1]) === 0) {
  34946. $this->p4DepotType = $fields[3];
  34947. return $this->isStream();
  34948. }
  34949. }
  34950. }
  34951. return false;
  34952. }
  34953. protected function getChangeList(string $reference): mixed
  34954. {
  34955. $index = strpos($reference, '@');
  34956. if ($index === false) {
  34957. return null;
  34958. }
  34959. $label = substr($reference, $index);
  34960. $command = $this->generateP4Command(' changes -m1 ' . ProcessExecutor::escape($label));
  34961. $this->executeCommand($command);
  34962. $changes = $this->commandResult;
  34963. if (strpos($changes, 'Change') !== 0) {
  34964. return null;
  34965. }
  34966. $fields = explode(' ', $changes);
  34967. return $fields[1];
  34968. }
  34969. public function getCommitLogs(string $fromReference, string $toReference): mixed
  34970. {
  34971. $fromChangeList = $this->getChangeList($fromReference);
  34972. if ($fromChangeList === null) {
  34973. return null;
  34974. }
  34975. $toChangeList = $this->getChangeList($toReference);
  34976. if ($toChangeList === null) {
  34977. return null;
  34978. }
  34979. $index = strpos($fromReference, '@');
  34980. $main = substr($fromReference, 0, $index) . '/...';
  34981. $command = $this->generateP4Command('filelog ' . ProcessExecutor::escape($main . '@' . $fromChangeList. ',' . $toChangeList));
  34982. $this->executeCommand($command);
  34983. return $this->commandResult;
  34984. }
  34985. public function getFilesystem(): Filesystem
  34986. {
  34987. if (null === $this->filesystem) {
  34988. $this->filesystem = new Filesystem($this->process);
  34989. }
  34990. return $this->filesystem;
  34991. }
  34992. public function setFilesystem(Filesystem $fs): void
  34993. {
  34994. $this->filesystem = $fs;
  34995. }
  34996. }
  34997. <?php declare(strict_types=1);
  34998. namespace Composer\Util;
  34999. use Composer\Pcre\Preg;
  35000. class Platform
  35001. {
  35002. private static $isVirtualBoxGuest = null;
  35003. private static $isWindowsSubsystemForLinux = null;
  35004. public static function getCwd(bool $allowEmpty = false): string
  35005. {
  35006. $cwd = getcwd();
  35007. if (false === $cwd) {
  35008. $cwd = realpath('');
  35009. }
  35010. if (false === $cwd) {
  35011. if ($allowEmpty) {
  35012. return '';
  35013. }
  35014. throw new \RuntimeException('Could not determine the current working directory');
  35015. }
  35016. return $cwd;
  35017. }
  35018. public static function getEnv(string $name)
  35019. {
  35020. if (array_key_exists($name, $_SERVER)) {
  35021. return (string) $_SERVER[$name];
  35022. }
  35023. if (array_key_exists($name, $_ENV)) {
  35024. return (string) $_ENV[$name];
  35025. }
  35026. return getenv($name);
  35027. }
  35028. public static function putEnv(string $name, string $value): void
  35029. {
  35030. $value = (string) $value;
  35031. putenv($name . '=' . $value);
  35032. $_SERVER[$name] = $_ENV[$name] = $value;
  35033. }
  35034. public static function clearEnv(string $name): void
  35035. {
  35036. putenv($name);
  35037. unset($_SERVER[$name], $_ENV[$name]);
  35038. }
  35039. public static function expandPath(string $path): string
  35040. {
  35041. if (Preg::isMatch('#^~[\\/]#', $path)) {
  35042. return self::getUserDirectory() . substr($path, 1);
  35043. }
  35044. return Preg::replaceCallback('#^(\$|(?P<percent>%))(?P<var>\w++)(?(percent)%)(?P<path>.*)#', function ($matches): string {
  35045. if (Platform::isWindows() && $matches['var'] == 'HOME') {
  35046. return (Platform::getEnv('HOME') ?: Platform::getEnv('USERPROFILE')) . $matches['path'];
  35047. }
  35048. return Platform::getEnv($matches['var']) . $matches['path'];
  35049. }, $path);
  35050. }
  35051. public static function getUserDirectory(): string
  35052. {
  35053. if (false !== ($home = self::getEnv('HOME'))) {
  35054. return $home;
  35055. }
  35056. if (self::isWindows() && false !== ($home = self::getEnv('USERPROFILE'))) {
  35057. return $home;
  35058. }
  35059. if (\function_exists('posix_getuid') && \function_exists('posix_getpwuid')) {
  35060. $info = posix_getpwuid(posix_getuid());
  35061. return $info['dir'];
  35062. }
  35063. throw new \RuntimeException('Could not determine user directory');
  35064. }
  35065. public static function isWindowsSubsystemForLinux(): bool
  35066. {
  35067. if (null === self::$isWindowsSubsystemForLinux) {
  35068. self::$isWindowsSubsystemForLinux = false;
  35069. if (self::isWindows()) {
  35070. return self::$isWindowsSubsystemForLinux = false;
  35071. }
  35072. if (
  35073. !ini_get('open_basedir')
  35074. && is_readable('/proc/version')
  35075. && false !== stripos(Silencer::call('file_get_contents', '/proc/version'), 'microsoft')
  35076. && !file_exists('/.dockerenv')
  35077. ) {
  35078. return self::$isWindowsSubsystemForLinux = true;
  35079. }
  35080. }
  35081. return self::$isWindowsSubsystemForLinux;
  35082. }
  35083. public static function isWindows(): bool
  35084. {
  35085. return \defined('PHP_WINDOWS_VERSION_BUILD');
  35086. }
  35087. public static function strlen(string $str): int
  35088. {
  35089. static $useMbString = null;
  35090. if (null === $useMbString) {
  35091. $useMbString = \function_exists('mb_strlen') && ini_get('mbstring.func_overload');
  35092. }
  35093. if ($useMbString) {
  35094. return mb_strlen($str, '8bit');
  35095. }
  35096. return \strlen($str);
  35097. }
  35098. public static function isTty($fd = null): bool
  35099. {
  35100. if ($fd === null) {
  35101. $fd = defined('STDOUT') ? STDOUT : fopen('php://stdout', 'w');
  35102. }
  35103. if (in_array(strtoupper(self::getEnv('MSYSTEM') ?: ''), array('MINGW32', 'MINGW64'), true)) {
  35104. return true;
  35105. }
  35106. if (function_exists('stream_isatty')) {
  35107. return stream_isatty($fd);
  35108. }
  35109. if (function_exists('posix_isatty') && posix_isatty($fd)) {
  35110. return true;
  35111. }
  35112. $stat = @fstat($fd);
  35113. return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
  35114. }
  35115. public static function workaroundFilesystemIssues(): void
  35116. {
  35117. if (self::isVirtualBoxGuest()) {
  35118. usleep(200000);
  35119. }
  35120. }
  35121. private static function isVirtualBoxGuest(): bool
  35122. {
  35123. if (null === self::$isVirtualBoxGuest) {
  35124. self::$isVirtualBoxGuest = false;
  35125. if (self::isWindows()) {
  35126. return self::$isVirtualBoxGuest;
  35127. }
  35128. if (function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
  35129. $processUser = posix_getpwuid(posix_geteuid());
  35130. if ($processUser && $processUser['name'] === 'vagrant') {
  35131. return self::$isVirtualBoxGuest = true;
  35132. }
  35133. }
  35134. if (self::getEnv('COMPOSER_RUNTIME_ENV') === 'virtualbox') {
  35135. return self::$isVirtualBoxGuest = true;
  35136. }
  35137. if (defined('PHP_OS_FAMILY') && PHP_OS_FAMILY === 'Linux') {
  35138. $process = new ProcessExecutor();
  35139. try {
  35140. if (0 === $process->execute('lsmod | grep vboxguest', $ignoredOutput)) {
  35141. return self::$isVirtualBoxGuest = true;
  35142. }
  35143. } catch (\Exception $e) {
  35144. }
  35145. }
  35146. }
  35147. return self::$isVirtualBoxGuest;
  35148. }
  35149. public static function getDevNull(): string
  35150. {
  35151. if (self::isWindows()) {
  35152. return 'NUL';
  35153. }
  35154. return '/dev/null';
  35155. }
  35156. }
  35157. <?php declare(strict_types=1);
  35158. namespace Composer\Util;
  35159. use Composer\IO\IOInterface;
  35160. use Composer\Pcre\Preg;
  35161. use Symfony\Component\Process\Process;
  35162. use Symfony\Component\Process\Exception\RuntimeException;
  35163. use React\Promise\Promise;
  35164. use React\Promise\PromiseInterface;
  35165. class ProcessExecutor
  35166. {
  35167. private const STATUS_QUEUED = 1;
  35168. private const STATUS_STARTED = 2;
  35169. private const STATUS_COMPLETED = 3;
  35170. private const STATUS_FAILED = 4;
  35171. private const STATUS_ABORTED = 5;
  35172. protected static $timeout = 300;
  35173. protected $captureOutput = false;
  35174. protected $errorOutput = '';
  35175. protected $io;
  35176. private $jobs = array();
  35177. private $runningJobs = 0;
  35178. private $maxJobs = 10;
  35179. private $idGen = 0;
  35180. private $allowAsync = false;
  35181. public function __construct(IOInterface $io = null)
  35182. {
  35183. $this->io = $io;
  35184. }
  35185. public function execute($command, &$output = null, ?string $cwd = null): int
  35186. {
  35187. if (func_num_args() > 1) {
  35188. return $this->doExecute($command, $cwd, false, $output);
  35189. }
  35190. return $this->doExecute($command, $cwd, false);
  35191. }
  35192. public function executeTty($command, ?string $cwd = null): int
  35193. {
  35194. if (Platform::isTty()) {
  35195. return $this->doExecute($command, $cwd, true);
  35196. }
  35197. return $this->doExecute($command, $cwd, false);
  35198. }
  35199. private function doExecute($command, ?string $cwd, bool $tty, &$output = null): int
  35200. {
  35201. $this->outputCommandRun($command, $cwd, false);
  35202. $this->captureOutput = func_num_args() > 3;
  35203. $this->errorOutput = '';
  35204. if (is_string($command)) {
  35205. $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout());
  35206. } else {
  35207. $process = new Process($command, $cwd, null, null, static::getTimeout());
  35208. }
  35209. if (!Platform::isWindows() && $tty) {
  35210. try {
  35211. $process->setTty(true);
  35212. } catch (RuntimeException $e) {
  35213. }
  35214. }
  35215. $callback = is_callable($output) ? $output : function (string $type, string $buffer): void {
  35216. $this->outputHandler($type, $buffer);
  35217. };
  35218. $process->run($callback);
  35219. if ($this->captureOutput && !is_callable($output)) {
  35220. $output = $process->getOutput();
  35221. }
  35222. $this->errorOutput = $process->getErrorOutput();
  35223. return $process->getExitCode();
  35224. }
  35225. public function executeAsync($command, ?string $cwd = null): PromiseInterface
  35226. {
  35227. if (!$this->allowAsync) {
  35228. throw new \LogicException('You must use the ProcessExecutor instance which is part of a Composer\Loop instance to be able to run async processes');
  35229. }
  35230. $job = array(
  35231. 'id' => $this->idGen++,
  35232. 'status' => self::STATUS_QUEUED,
  35233. 'command' => $command,
  35234. 'cwd' => $cwd,
  35235. );
  35236. $resolver = function ($resolve, $reject) use (&$job): void {
  35237. $job['status'] = ProcessExecutor::STATUS_QUEUED;
  35238. $job['resolve'] = $resolve;
  35239. $job['reject'] = $reject;
  35240. };
  35241. $canceler = function () use (&$job): void {
  35242. if ($job['status'] === ProcessExecutor::STATUS_QUEUED) {
  35243. $job['status'] = ProcessExecutor::STATUS_ABORTED;
  35244. }
  35245. if ($job['status'] !== ProcessExecutor::STATUS_STARTED) {
  35246. return;
  35247. }
  35248. $job['status'] = ProcessExecutor::STATUS_ABORTED;
  35249. try {
  35250. if (defined('SIGINT')) {
  35251. $job['process']->signal(SIGINT);
  35252. }
  35253. } catch (\Exception $e) {
  35254. }
  35255. $job['process']->stop(1);
  35256. throw new \RuntimeException('Aborted process');
  35257. };
  35258. $promise = new Promise($resolver, $canceler);
  35259. $promise = $promise->then(function () use (&$job) {
  35260. if ($job['process']->isSuccessful()) {
  35261. $job['status'] = ProcessExecutor::STATUS_COMPLETED;
  35262. } else {
  35263. $job['status'] = ProcessExecutor::STATUS_FAILED;
  35264. }
  35265. $this->markJobDone();
  35266. return $job['process'];
  35267. }, function ($e) use (&$job): void {
  35268. $job['status'] = ProcessExecutor::STATUS_FAILED;
  35269. $this->markJobDone();
  35270. throw $e;
  35271. });
  35272. $this->jobs[$job['id']] = &$job;
  35273. if ($this->runningJobs < $this->maxJobs) {
  35274. $this->startJob($job['id']);
  35275. }
  35276. return $promise;
  35277. }
  35278. protected function outputHandler(string $type, string $buffer): void
  35279. {
  35280. if ($this->captureOutput) {
  35281. return;
  35282. }
  35283. if (null === $this->io) {
  35284. echo $buffer;
  35285. return;
  35286. }
  35287. if (Process::ERR === $type) {
  35288. $this->io->writeErrorRaw($buffer, false);
  35289. } else {
  35290. $this->io->writeRaw($buffer, false);
  35291. }
  35292. }
  35293. private function startJob(int $id): void
  35294. {
  35295. $job = &$this->jobs[$id];
  35296. if ($job['status'] !== self::STATUS_QUEUED) {
  35297. return;
  35298. }
  35299. $job['status'] = self::STATUS_STARTED;
  35300. $this->runningJobs++;
  35301. $command = $job['command'];
  35302. $cwd = $job['cwd'];
  35303. $this->outputCommandRun($command, $cwd, true);
  35304. try {
  35305. if (is_string($command)) {
  35306. $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout());
  35307. } else {
  35308. $process = new Process($command, $cwd, null, null, static::getTimeout());
  35309. }
  35310. } catch (\Throwable $e) {
  35311. call_user_func($job['reject'], $e);
  35312. return;
  35313. }
  35314. $job['process'] = $process;
  35315. try {
  35316. $process->start();
  35317. } catch (\Throwable $e) {
  35318. call_user_func($job['reject'], $e);
  35319. return;
  35320. }
  35321. }
  35322. public function setMaxJobs(int $maxJobs): void
  35323. {
  35324. $this->maxJobs = $maxJobs;
  35325. }
  35326. public function resetMaxJobs(): void
  35327. {
  35328. $this->maxJobs = 10;
  35329. }
  35330. public function wait($index = null): void
  35331. {
  35332. while (true) {
  35333. if (0 === $this->countActiveJobs($index)) {
  35334. return;
  35335. }
  35336. usleep(1000);
  35337. }
  35338. }
  35339. public function enableAsync(): void
  35340. {
  35341. $this->allowAsync = true;
  35342. }
  35343. public function countActiveJobs($index = null): int
  35344. {
  35345. foreach ($this->jobs as $job) {
  35346. if ($job['status'] === self::STATUS_STARTED) {
  35347. if (!$job['process']->isRunning()) {
  35348. call_user_func($job['resolve'], $job['process']);
  35349. }
  35350. $job['process']->checkTimeout();
  35351. }
  35352. if ($this->runningJobs < $this->maxJobs) {
  35353. if ($job['status'] === self::STATUS_QUEUED) {
  35354. $this->startJob($job['id']);
  35355. }
  35356. }
  35357. }
  35358. if (null !== $index) {
  35359. return $this->jobs[$index]['status'] < self::STATUS_COMPLETED ? 1 : 0;
  35360. }
  35361. $active = 0;
  35362. foreach ($this->jobs as $job) {
  35363. if ($job['status'] < self::STATUS_COMPLETED) {
  35364. $active++;
  35365. } else {
  35366. unset($this->jobs[$job['id']]);
  35367. }
  35368. }
  35369. return $active;
  35370. }
  35371. private function markJobDone(): void
  35372. {
  35373. $this->runningJobs--;
  35374. }
  35375. public function splitLines(?string $output): array
  35376. {
  35377. $output = trim((string) $output);
  35378. return $output === '' ? array() : Preg::split('{\r?\n}', $output);
  35379. }
  35380. public function getErrorOutput(): string
  35381. {
  35382. return $this->errorOutput;
  35383. }
  35384. public static function getTimeout(): int
  35385. {
  35386. return static::$timeout;
  35387. }
  35388. public static function setTimeout(int $timeout): void
  35389. {
  35390. static::$timeout = $timeout;
  35391. }
  35392. public static function escape($argument): string
  35393. {
  35394. return self::escapeArgument($argument);
  35395. }
  35396. private function outputCommandRun($command, ?string $cwd, bool $async): void
  35397. {
  35398. if (null === $this->io || !$this->io->isDebug()) {
  35399. return;
  35400. }
  35401. $commandString = is_string($command) ? $command : implode(' ', array_map(self::class.'::escape', $command));
  35402. $safeCommand = Preg::replaceCallback('{://(?P<user>[^:/\s]+):(?P<password>[^@\s/]+)@}i', function ($m): string {
  35403. if (Preg::isMatch('{^([a-f0-9]{12,}|gh[a-z]_[a-zA-Z0-9_]+)$}', $m['user'])) {
  35404. return '://***:***@';
  35405. }
  35406. if (Preg::isMatch('{^[a-f0-9]{12,}$}', $m['user'])) {
  35407. return '://***:***@';
  35408. }
  35409. return '://'.$m['user'].':***@';
  35410. }, $commandString);
  35411. $safeCommand = Preg::replace("{--password (.*[^\\\\]\') }", '--password \'***\' ', $safeCommand);
  35412. $this->io->writeError('Executing'.($async ? ' async' : '').' command ('.($cwd ?: 'CWD').'): '.$safeCommand);
  35413. }
  35414. private static function escapeArgument($argument): string
  35415. {
  35416. if ('' === ($argument = (string) $argument)) {
  35417. return escapeshellarg($argument);
  35418. }
  35419. if (!Platform::isWindows()) {
  35420. return "'".str_replace("'", "'\\''", $argument)."'";
  35421. }
  35422. $argument = strtr($argument, "\n", ' ');
  35423. $quote = strpbrk($argument, " \t") !== false;
  35424. $argument = Preg::replace('/(\\\\*)"/', '$1$1\\"', $argument, -1, $dquotes);
  35425. $meta = $dquotes || Preg::isMatch('/%[^%]+%|![^!]+!/', $argument);
  35426. if (!$meta && !$quote) {
  35427. $quote = strpbrk($argument, '^&|<>()') !== false;
  35428. }
  35429. if ($quote) {
  35430. $argument = '"'.Preg::replace('/(\\\\*)$/', '$1$1', $argument).'"';
  35431. }
  35432. if ($meta) {
  35433. $argument = Preg::replace('/(["^&|<>()%])/', '^$1', $argument);
  35434. $argument = Preg::replace('/(!)/', '^^$1', $argument);
  35435. }
  35436. return $argument;
  35437. }
  35438. }
  35439. <?php declare(strict_types=1);
  35440. namespace Composer\Util;
  35441. use Composer\Config;
  35442. use Composer\Downloader\MaxFileSizeExceededException;
  35443. use Composer\IO\IOInterface;
  35444. use Composer\Downloader\TransportException;
  35445. use Composer\Pcre\Preg;
  35446. use Composer\Util\Http\Response;
  35447. use Composer\Util\Http\ProxyManager;
  35448. class RemoteFilesystem
  35449. {
  35450. private $io;
  35451. private $config;
  35452. private $scheme;
  35453. private $bytesMax;
  35454. private $originUrl;
  35455. private $fileUrl;
  35456. private $fileName;
  35457. private $retry = false;
  35458. private $progress;
  35459. private $lastProgress;
  35460. private $options = array();
  35461. private $disableTls = false;
  35462. private $lastHeaders;
  35463. private $storeAuth = false;
  35464. private $authHelper;
  35465. private $degradedMode = false;
  35466. private $redirects;
  35467. private $maxRedirects = 20;
  35468. private $proxyManager;
  35469. public function __construct(IOInterface $io, Config $config, array $options = array(), bool $disableTls = false, AuthHelper $authHelper = null)
  35470. {
  35471. $this->io = $io;
  35472. if ($disableTls === false) {
  35473. $this->options = StreamContextFactory::getTlsDefaults($options, $io);
  35474. } else {
  35475. $this->disableTls = true;
  35476. }
  35477. $this->options = array_replace_recursive($this->options, $options);
  35478. $this->config = $config;
  35479. $this->authHelper = $authHelper ?? new AuthHelper($io, $config);
  35480. $this->proxyManager = ProxyManager::getInstance();
  35481. }
  35482. public function copy(string $originUrl, string $fileUrl, string $fileName, bool $progress = true, array $options = array())
  35483. {
  35484. return $this->get($originUrl, $fileUrl, $options, $fileName, $progress);
  35485. }
  35486. public function getContents(string $originUrl, string $fileUrl, bool $progress = true, array $options = array())
  35487. {
  35488. return $this->get($originUrl, $fileUrl, $options, null, $progress);
  35489. }
  35490. public function getOptions()
  35491. {
  35492. return $this->options;
  35493. }
  35494. public function setOptions(array $options)
  35495. {
  35496. $this->options = array_replace_recursive($this->options, $options);
  35497. }
  35498. public function isTlsDisabled()
  35499. {
  35500. return $this->disableTls === true;
  35501. }
  35502. public function getLastHeaders()
  35503. {
  35504. return $this->lastHeaders;
  35505. }
  35506. public static function findStatusCode(array $headers)
  35507. {
  35508. $value = null;
  35509. foreach ($headers as $header) {
  35510. if (Preg::isMatch('{^HTTP/\S+ (\d+)}i', $header, $match)) {
  35511. $value = (int) $match[1];
  35512. }
  35513. }
  35514. return $value;
  35515. }
  35516. public function findStatusMessage(array $headers)
  35517. {
  35518. $value = null;
  35519. foreach ($headers as $header) {
  35520. if (Preg::isMatch('{^HTTP/\S+ \d+}i', $header)) {
  35521. $value = $header;
  35522. }
  35523. }
  35524. return $value;
  35525. }
  35526. protected function get(string $originUrl, string $fileUrl, array $additionalOptions = array(), string $fileName = null, bool $progress = true)
  35527. {
  35528. $this->scheme = parse_url(strtr($fileUrl, '\\', '/'), PHP_URL_SCHEME);
  35529. $this->bytesMax = 0;
  35530. $this->originUrl = $originUrl;
  35531. $this->fileUrl = $fileUrl;
  35532. $this->fileName = $fileName;
  35533. $this->progress = $progress;
  35534. $this->lastProgress = null;
  35535. $retryAuthFailure = true;
  35536. $this->lastHeaders = array();
  35537. $this->redirects = 1;
  35538. $tempAdditionalOptions = $additionalOptions;
  35539. if (isset($tempAdditionalOptions['retry-auth-failure'])) {
  35540. $retryAuthFailure = (bool) $tempAdditionalOptions['retry-auth-failure'];
  35541. unset($tempAdditionalOptions['retry-auth-failure']);
  35542. }
  35543. $isRedirect = false;
  35544. if (isset($tempAdditionalOptions['redirects'])) {
  35545. $this->redirects = $tempAdditionalOptions['redirects'];
  35546. $isRedirect = true;
  35547. unset($tempAdditionalOptions['redirects']);
  35548. }
  35549. $options = $this->getOptionsForUrl($originUrl, $tempAdditionalOptions);
  35550. unset($tempAdditionalOptions);
  35551. $origFileUrl = $fileUrl;
  35552. if (isset($options['gitlab-token'])) {
  35553. $fileUrl .= (false === strpos($fileUrl, '?') ? '?' : '&') . 'access_token='.$options['gitlab-token'];
  35554. unset($options['gitlab-token']);
  35555. }
  35556. if (isset($options['http'])) {
  35557. $options['http']['ignore_errors'] = true;
  35558. }
  35559. if ($this->degradedMode && strpos($fileUrl, 'http://repo.packagist.org/') === 0) {
  35560. $fileUrl = 'http://' . gethostbyname('repo.packagist.org') . substr($fileUrl, 20);
  35561. $degradedPackagist = true;
  35562. }
  35563. $maxFileSize = null;
  35564. if (isset($options['max_file_size'])) {
  35565. $maxFileSize = $options['max_file_size'];
  35566. unset($options['max_file_size']);
  35567. }
  35568. $ctx = StreamContextFactory::getContext($fileUrl, $options, array('notification' => array($this, 'callbackGet')));
  35569. $proxy = $this->proxyManager->getProxyForRequest($fileUrl);
  35570. $usingProxy = $proxy->getFormattedUrl(' using proxy (%s)');
  35571. $this->io->writeError((strpos($origFileUrl, 'http') === 0 ? 'Downloading ' : 'Reading ') . Url::sanitize($origFileUrl) . $usingProxy, true, IOInterface::DEBUG);
  35572. unset($origFileUrl, $proxy, $usingProxy);
  35573. if ((!Preg::isMatch('{^http://(repo\.)?packagist\.org/p/}', $fileUrl) || (false === strpos($fileUrl, '$') && false === strpos($fileUrl, '%24'))) && empty($degradedPackagist)) {
  35574. $this->config->prohibitUrlByConfig($fileUrl, $this->io);
  35575. }
  35576. if ($this->progress && !$isRedirect) {
  35577. $this->io->writeError("Downloading (<comment>connecting...</comment>)", false);
  35578. }
  35579. $errorMessage = '';
  35580. $errorCode = 0;
  35581. $result = false;
  35582. set_error_handler(function ($code, $msg) use (&$errorMessage): bool {
  35583. if ($errorMessage) {
  35584. $errorMessage .= "\n";
  35585. }
  35586. $errorMessage .= Preg::replace('{^file_get_contents\(.*?\): }', '', $msg);
  35587. return true;
  35588. });
  35589. $http_response_header = array();
  35590. try {
  35591. $result = $this->getRemoteContents($originUrl, $fileUrl, $ctx, $http_response_header, $maxFileSize);
  35592. if (!empty($http_response_header[0])) {
  35593. $statusCode = self::findStatusCode($http_response_header);
  35594. if ($statusCode >= 400 && Response::findHeaderValue($http_response_header, 'content-type') === 'application/json') {
  35595. HttpDownloader::outputWarnings($this->io, $originUrl, json_decode($result, true));
  35596. }
  35597. if (in_array($statusCode, array(401, 403)) && $retryAuthFailure) {
  35598. $this->promptAuthAndRetry($statusCode, $this->findStatusMessage($http_response_header), $http_response_header);
  35599. }
  35600. }
  35601. $contentLength = !empty($http_response_header[0]) ? Response::findHeaderValue($http_response_header, 'content-length') : null;
  35602. if ($contentLength && Platform::strlen($result) < $contentLength) {
  35603. $e = new TransportException('Content-Length mismatch, received '.Platform::strlen($result).' bytes out of the expected '.$contentLength);
  35604. $e->setHeaders($http_response_header);
  35605. $e->setStatusCode(self::findStatusCode($http_response_header));
  35606. try {
  35607. $e->setResponse($this->decodeResult($result, $http_response_header));
  35608. } catch (\Exception $discarded) {
  35609. $e->setResponse($this->normalizeResult($result));
  35610. }
  35611. $this->io->writeError('Content-Length mismatch, received '.Platform::strlen($result).' out of '.$contentLength.' bytes: (' . base64_encode($result).')', true, IOInterface::DEBUG);
  35612. throw $e;
  35613. }
  35614. } catch (\Exception $e) {
  35615. if ($e instanceof TransportException && !empty($http_response_header[0])) {
  35616. $e->setHeaders($http_response_header);
  35617. $e->setStatusCode(self::findStatusCode($http_response_header));
  35618. }
  35619. if ($e instanceof TransportException && $result !== false) {
  35620. $e->setResponse($this->decodeResult($result, $http_response_header));
  35621. }
  35622. $result = false;
  35623. }
  35624. if ($errorMessage && !filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN)) {
  35625. $errorMessage = 'allow_url_fopen must be enabled in php.ini ('.$errorMessage.')';
  35626. }
  35627. restore_error_handler();
  35628. if (isset($e) && !$this->retry) {
  35629. if (!$this->degradedMode && false !== strpos($e->getMessage(), 'Operation timed out')) {
  35630. $this->degradedMode = true;
  35631. $this->io->writeError('');
  35632. $this->io->writeError(array(
  35633. '<error>'.$e->getMessage().'</error>',
  35634. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  35635. ));
  35636. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  35637. }
  35638. throw $e;
  35639. }
  35640. $statusCode = null;
  35641. $contentType = null;
  35642. $locationHeader = null;
  35643. if (!empty($http_response_header[0])) {
  35644. $statusCode = self::findStatusCode($http_response_header);
  35645. $contentType = Response::findHeaderValue($http_response_header, 'content-type');
  35646. $locationHeader = Response::findHeaderValue($http_response_header, 'location');
  35647. }
  35648. if ($originUrl === 'bitbucket.org'
  35649. && !$this->authHelper->isPublicBitBucketDownload($fileUrl)
  35650. && substr($fileUrl, -4) === '.zip'
  35651. && (!$locationHeader || substr(parse_url($locationHeader, PHP_URL_PATH), -4) !== '.zip')
  35652. && $contentType && Preg::isMatch('{^text/html\b}i', $contentType)
  35653. ) {
  35654. $result = false;
  35655. if ($retryAuthFailure) {
  35656. $this->promptAuthAndRetry(401);
  35657. }
  35658. }
  35659. if ($statusCode === 404
  35660. && in_array($originUrl, $this->config->get('gitlab-domains'), true)
  35661. && false !== strpos($fileUrl, 'archive.zip')
  35662. ) {
  35663. $result = false;
  35664. if ($retryAuthFailure) {
  35665. $this->promptAuthAndRetry(401);
  35666. }
  35667. }
  35668. $hasFollowedRedirect = false;
  35669. if ($statusCode >= 300 && $statusCode <= 399 && $statusCode !== 304 && $this->redirects < $this->maxRedirects) {
  35670. $hasFollowedRedirect = true;
  35671. $result = $this->handleRedirect($http_response_header, $additionalOptions, $result);
  35672. }
  35673. if ($statusCode && $statusCode >= 400 && $statusCode <= 599) {
  35674. if (!$this->retry) {
  35675. if ($this->progress && !$isRedirect) {
  35676. $this->io->overwriteError("Downloading (<error>failed</error>)", false);
  35677. }
  35678. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded ('.$http_response_header[0].')', $statusCode);
  35679. $e->setHeaders($http_response_header);
  35680. $e->setResponse($this->decodeResult($result, $http_response_header));
  35681. $e->setStatusCode($statusCode);
  35682. throw $e;
  35683. }
  35684. $result = false;
  35685. }
  35686. if ($this->progress && !$this->retry && !$isRedirect) {
  35687. $this->io->overwriteError("Downloading (".($result === false ? '<error>failed</error>' : '<comment>100%</comment>').")", false);
  35688. }
  35689. if ($result && extension_loaded('zlib') && strpos($fileUrl, 'http') === 0 && !$hasFollowedRedirect) {
  35690. try {
  35691. $result = $this->decodeResult($result, $http_response_header);
  35692. } catch (\Exception $e) {
  35693. if ($this->degradedMode) {
  35694. throw $e;
  35695. }
  35696. $this->degradedMode = true;
  35697. $this->io->writeError(array(
  35698. '',
  35699. '<error>Failed to decode response: '.$e->getMessage().'</error>',
  35700. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  35701. ));
  35702. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  35703. }
  35704. }
  35705. if (false !== $result && null !== $fileName && !$isRedirect) {
  35706. if ('' === $result) {
  35707. throw new TransportException('"'.$this->fileUrl.'" appears broken, and returned an empty 200 response');
  35708. }
  35709. $errorMessage = '';
  35710. set_error_handler(function ($code, $msg) use (&$errorMessage): bool {
  35711. if ($errorMessage) {
  35712. $errorMessage .= "\n";
  35713. }
  35714. $errorMessage .= Preg::replace('{^file_put_contents\(.*?\): }', '', $msg);
  35715. return true;
  35716. });
  35717. $result = (bool) file_put_contents($fileName, $result);
  35718. restore_error_handler();
  35719. if (false === $result) {
  35720. throw new TransportException('The "'.$this->fileUrl.'" file could not be written to '.$fileName.': '.$errorMessage);
  35721. }
  35722. }
  35723. if ($this->retry) {
  35724. $this->retry = false;
  35725. $result = $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  35726. if ($this->storeAuth) {
  35727. $this->authHelper->storeAuth($this->originUrl, $this->storeAuth);
  35728. $this->storeAuth = false;
  35729. }
  35730. return $result;
  35731. }
  35732. if (false === $result) {
  35733. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded: '.$errorMessage, $errorCode);
  35734. if (!empty($http_response_header[0])) {
  35735. $e->setHeaders($http_response_header);
  35736. }
  35737. if (!$this->degradedMode && false !== strpos($e->getMessage(), 'Operation timed out')) {
  35738. $this->degradedMode = true;
  35739. $this->io->writeError('');
  35740. $this->io->writeError(array(
  35741. '<error>'.$e->getMessage().'</error>',
  35742. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  35743. ));
  35744. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  35745. }
  35746. throw $e;
  35747. }
  35748. if (!empty($http_response_header[0])) {
  35749. $this->lastHeaders = $http_response_header;
  35750. }
  35751. return $result;
  35752. }
  35753. protected function getRemoteContents(string $originUrl, string $fileUrl, $context, array &$responseHeaders = null, int $maxFileSize = null)
  35754. {
  35755. $result = false;
  35756. try {
  35757. $e = null;
  35758. if ($maxFileSize !== null) {
  35759. $result = file_get_contents($fileUrl, false, $context, 0, $maxFileSize);
  35760. } else {
  35761. $result = file_get_contents($fileUrl, false, $context);
  35762. }
  35763. } catch (\Throwable $e) {
  35764. }
  35765. if ($result !== false && $maxFileSize !== null && Platform::strlen($result) >= $maxFileSize) {
  35766. throw new MaxFileSizeExceededException('Maximum allowed download size reached. Downloaded ' . Platform::strlen($result) . ' of allowed ' . $maxFileSize . ' bytes');
  35767. }
  35768. $responseHeaders = $http_response_header ?? array();
  35769. if (null !== $e) {
  35770. throw $e;
  35771. }
  35772. return $result;
  35773. }
  35774. protected function callbackGet(int $notificationCode, int $severity, ?string $message, int $messageCode, int $bytesTransferred, int $bytesMax)
  35775. {
  35776. switch ($notificationCode) {
  35777. case STREAM_NOTIFY_FAILURE:
  35778. if (400 === $messageCode) {
  35779. throw new TransportException("The '" . $this->fileUrl . "' URL could not be accessed: " . $message, $messageCode);
  35780. }
  35781. break;
  35782. case STREAM_NOTIFY_FILE_SIZE_IS:
  35783. $this->bytesMax = $bytesMax;
  35784. break;
  35785. case STREAM_NOTIFY_PROGRESS:
  35786. if ($this->bytesMax > 0 && $this->progress) {
  35787. $progression = min(100, (int) round($bytesTransferred / $this->bytesMax * 100));
  35788. if ((0 === $progression % 5) && 100 !== $progression && $progression !== $this->lastProgress) {
  35789. $this->lastProgress = $progression;
  35790. $this->io->overwriteError("Downloading (<comment>$progression%</comment>)", false);
  35791. }
  35792. }
  35793. break;
  35794. default:
  35795. break;
  35796. }
  35797. }
  35798. protected function promptAuthAndRetry($httpStatus, ?string $reason = null, array $headers = array())
  35799. {
  35800. $result = $this->authHelper->promptAuthIfNeeded($this->fileUrl, $this->originUrl, $httpStatus, $reason, $headers);
  35801. $this->storeAuth = $result['storeAuth'];
  35802. $this->retry = $result['retry'];
  35803. if ($this->retry) {
  35804. throw new TransportException('RETRY');
  35805. }
  35806. }
  35807. protected function getOptionsForUrl(string $originUrl, array $additionalOptions)
  35808. {
  35809. $tlsOptions = array();
  35810. $headers = array();
  35811. if (extension_loaded('zlib')) {
  35812. $headers[] = 'Accept-Encoding: gzip';
  35813. }
  35814. $options = array_replace_recursive($this->options, $tlsOptions, $additionalOptions);
  35815. if (!$this->degradedMode) {
  35816. $options['http']['protocol_version'] = 1.1;
  35817. $headers[] = 'Connection: close';
  35818. }
  35819. $headers = $this->authHelper->addAuthenticationHeader($headers, $originUrl, $this->fileUrl);
  35820. $options['http']['follow_location'] = 0;
  35821. if (isset($options['http']['header']) && !is_array($options['http']['header'])) {
  35822. $options['http']['header'] = explode("\r\n", trim($options['http']['header'], "\r\n"));
  35823. }
  35824. foreach ($headers as $header) {
  35825. $options['http']['header'][] = $header;
  35826. }
  35827. return $options;
  35828. }
  35829. private function handleRedirect(array $http_response_header, array $additionalOptions, $result)
  35830. {
  35831. if ($locationHeader = Response::findHeaderValue($http_response_header, 'location')) {
  35832. if (parse_url($locationHeader, PHP_URL_SCHEME)) {
  35833. $targetUrl = $locationHeader;
  35834. } elseif (parse_url($locationHeader, PHP_URL_HOST)) {
  35835. $targetUrl = $this->scheme.':'.$locationHeader;
  35836. } elseif ('/' === $locationHeader[0]) {
  35837. $urlHost = parse_url($this->fileUrl, PHP_URL_HOST);
  35838. $targetUrl = Preg::replace('{^(.+(?://|@)'.preg_quote($urlHost).'(?::\d+)?)(?:[/\?].*)?$}', '\1'.$locationHeader, $this->fileUrl);
  35839. } else {
  35840. $targetUrl = Preg::replace('{^(.+/)[^/?]*(?:\?.*)?$}', '\1'.$locationHeader, $this->fileUrl);
  35841. }
  35842. }
  35843. if (!empty($targetUrl)) {
  35844. $this->redirects++;
  35845. $this->io->writeError('', true, IOInterface::DEBUG);
  35846. $this->io->writeError(sprintf('Following redirect (%u) %s', $this->redirects, Url::sanitize($targetUrl)), true, IOInterface::DEBUG);
  35847. $additionalOptions['redirects'] = $this->redirects;
  35848. return $this->get(parse_url($targetUrl, PHP_URL_HOST), $targetUrl, $additionalOptions, $this->fileName, $this->progress);
  35849. }
  35850. if (!$this->retry) {
  35851. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded, got redirect without Location ('.$http_response_header[0].')');
  35852. $e->setHeaders($http_response_header);
  35853. $e->setResponse($this->decodeResult($result, $http_response_header));
  35854. throw $e;
  35855. }
  35856. return false;
  35857. }
  35858. private function decodeResult($result, array $http_response_header): ?string
  35859. {
  35860. if ($result && extension_loaded('zlib')) {
  35861. $contentEncoding = Response::findHeaderValue($http_response_header, 'content-encoding');
  35862. $decode = $contentEncoding && 'gzip' === strtolower($contentEncoding);
  35863. if ($decode) {
  35864. $result = zlib_decode($result);
  35865. if ($result === false) {
  35866. throw new TransportException('Failed to decode zlib stream');
  35867. }
  35868. }
  35869. }
  35870. return $this->normalizeResult($result);
  35871. }
  35872. private function normalizeResult($result): ?string
  35873. {
  35874. if ($result === false) {
  35875. return null;
  35876. }
  35877. return $result;
  35878. }
  35879. }
  35880. <?php declare(strict_types=1);
  35881. namespace Composer\Util;
  35882. class Silencer
  35883. {
  35884. private static $stack = array();
  35885. public static function suppress(?int $mask = null): int
  35886. {
  35887. if (!isset($mask)) {
  35888. $mask = E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_DEPRECATED | E_USER_DEPRECATED | E_STRICT;
  35889. }
  35890. $old = error_reporting();
  35891. self::$stack[] = $old;
  35892. error_reporting($old & ~$mask);
  35893. return $old;
  35894. }
  35895. public static function restore(): void
  35896. {
  35897. if (!empty(self::$stack)) {
  35898. error_reporting(array_pop(self::$stack));
  35899. }
  35900. }
  35901. public static function call(callable $callable, ...$parameters)
  35902. {
  35903. try {
  35904. self::suppress();
  35905. $result = $callable(...$parameters);
  35906. self::restore();
  35907. return $result;
  35908. } catch (\Exception $e) {
  35909. self::restore();
  35910. throw $e;
  35911. }
  35912. }
  35913. }
  35914. <?php declare(strict_types=1);
  35915. namespace Composer\Util;
  35916. use Composer\Composer;
  35917. use Composer\CaBundle\CaBundle;
  35918. use Composer\Downloader\TransportException;
  35919. use Composer\Repository\PlatformRepository;
  35920. use Composer\Util\Http\ProxyManager;
  35921. use Psr\Log\LoggerInterface;
  35922. final class StreamContextFactory
  35923. {
  35924. public static function getContext(string $url, array $defaultOptions = array(), array $defaultParams = array())
  35925. {
  35926. $options = array('http' => array(
  35927. 'follow_location' => 1,
  35928. 'max_redirects' => 20,
  35929. ));
  35930. $options = array_replace_recursive($options, self::initOptions($url, $defaultOptions));
  35931. unset($defaultOptions['http']['header']);
  35932. $options = array_replace_recursive($options, $defaultOptions);
  35933. if (isset($options['http']['header'])) {
  35934. $options['http']['header'] = self::fixHttpHeaderField($options['http']['header']);
  35935. }
  35936. return stream_context_create($options, $defaultParams);
  35937. }
  35938. public static function initOptions(string $url, array $options, bool $forCurl = false): array
  35939. {
  35940. if (!isset($options['http']['header'])) {
  35941. $options['http']['header'] = array();
  35942. }
  35943. if (is_string($options['http']['header'])) {
  35944. $options['http']['header'] = explode("\r\n", $options['http']['header']);
  35945. }
  35946. if (!$forCurl) {
  35947. $proxy = ProxyManager::getInstance()->getProxyForRequest($url);
  35948. if ($proxyOptions = $proxy->getContextOptions()) {
  35949. $isHttpsRequest = 0 === strpos($url, 'https://');
  35950. if ($proxy->isSecure()) {
  35951. if (!extension_loaded('openssl')) {
  35952. throw new TransportException('You must enable the openssl extension to use a secure proxy.');
  35953. }
  35954. if ($isHttpsRequest) {
  35955. throw new TransportException('You must enable the curl extension to make https requests through a secure proxy.');
  35956. }
  35957. } elseif ($isHttpsRequest && !extension_loaded('openssl')) {
  35958. throw new TransportException('You must enable the openssl extension to make https requests through a proxy.');
  35959. }
  35960. if (isset($proxyOptions['http']['header'])) {
  35961. $options['http']['header'][] = $proxyOptions['http']['header'];
  35962. unset($proxyOptions['http']['header']);
  35963. }
  35964. $options = array_replace_recursive($options, $proxyOptions);
  35965. }
  35966. }
  35967. if (defined('HHVM_VERSION')) {
  35968. $phpVersion = 'HHVM ' . HHVM_VERSION;
  35969. } else {
  35970. $phpVersion = 'PHP ' . PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
  35971. }
  35972. if ($forCurl) {
  35973. $curl = curl_version();
  35974. $httpVersion = 'cURL '.$curl['version'];
  35975. } else {
  35976. $httpVersion = 'streams';
  35977. }
  35978. if (!isset($options['http']['header']) || false === stripos(implode('', $options['http']['header']), 'user-agent')) {
  35979. $platformPhpVersion = PlatformRepository::getPlatformPhpVersion();
  35980. $options['http']['header'][] = sprintf(
  35981. 'User-Agent: Composer/%s (%s; %s; %s; %s%s%s)',
  35982. Composer::getVersion(),
  35983. function_exists('php_uname') ? php_uname('s') : 'Unknown',
  35984. function_exists('php_uname') ? php_uname('r') : 'Unknown',
  35985. $phpVersion,
  35986. $httpVersion,
  35987. $platformPhpVersion ? '; Platform-PHP '.$platformPhpVersion : '',
  35988. Platform::getEnv('CI') ? '; CI' : ''
  35989. );
  35990. }
  35991. return $options;
  35992. }
  35993. public static function getTlsDefaults(array $options, LoggerInterface $logger = null): array
  35994. {
  35995. $ciphers = implode(':', array(
  35996. 'ECDHE-RSA-AES128-GCM-SHA256',
  35997. 'ECDHE-ECDSA-AES128-GCM-SHA256',
  35998. 'ECDHE-RSA-AES256-GCM-SHA384',
  35999. 'ECDHE-ECDSA-AES256-GCM-SHA384',
  36000. 'DHE-RSA-AES128-GCM-SHA256',
  36001. 'DHE-DSS-AES128-GCM-SHA256',
  36002. 'kEDH+AESGCM',
  36003. 'ECDHE-RSA-AES128-SHA256',
  36004. 'ECDHE-ECDSA-AES128-SHA256',
  36005. 'ECDHE-RSA-AES128-SHA',
  36006. 'ECDHE-ECDSA-AES128-SHA',
  36007. 'ECDHE-RSA-AES256-SHA384',
  36008. 'ECDHE-ECDSA-AES256-SHA384',
  36009. 'ECDHE-RSA-AES256-SHA',
  36010. 'ECDHE-ECDSA-AES256-SHA',
  36011. 'DHE-RSA-AES128-SHA256',
  36012. 'DHE-RSA-AES128-SHA',
  36013. 'DHE-DSS-AES128-SHA256',
  36014. 'DHE-RSA-AES256-SHA256',
  36015. 'DHE-DSS-AES256-SHA',
  36016. 'DHE-RSA-AES256-SHA',
  36017. 'AES128-GCM-SHA256',
  36018. 'AES256-GCM-SHA384',
  36019. 'AES128-SHA256',
  36020. 'AES256-SHA256',
  36021. 'AES128-SHA',
  36022. 'AES256-SHA',
  36023. 'AES',
  36024. 'CAMELLIA',
  36025. 'DES-CBC3-SHA',
  36026. '!aNULL',
  36027. '!eNULL',
  36028. '!EXPORT',
  36029. '!DES',
  36030. '!RC4',
  36031. '!MD5',
  36032. '!PSK',
  36033. '!aECDH',
  36034. '!EDH-DSS-DES-CBC3-SHA',
  36035. '!EDH-RSA-DES-CBC3-SHA',
  36036. '!KRB5-DES-CBC3-SHA',
  36037. ));
  36038. $defaults = array(
  36039. 'ssl' => array(
  36040. 'ciphers' => $ciphers,
  36041. 'verify_peer' => true,
  36042. 'verify_depth' => 7,
  36043. 'SNI_enabled' => true,
  36044. 'capture_peer_cert' => true,
  36045. ),
  36046. );
  36047. if (isset($options['ssl'])) {
  36048. $defaults['ssl'] = array_replace_recursive($defaults['ssl'], $options['ssl']);
  36049. }
  36050. if (!isset($defaults['ssl']['cafile']) && !isset($defaults['ssl']['capath'])) {
  36051. $result = CaBundle::getSystemCaRootBundlePath($logger);
  36052. if (is_dir($result)) {
  36053. $defaults['ssl']['capath'] = $result;
  36054. } else {
  36055. $defaults['ssl']['cafile'] = $result;
  36056. }
  36057. }
  36058. if (isset($defaults['ssl']['cafile']) && (!Filesystem::isReadable($defaults['ssl']['cafile']) || !CaBundle::validateCaFile($defaults['ssl']['cafile'], $logger))) {
  36059. throw new TransportException('The configured cafile was not valid or could not be read.');
  36060. }
  36061. if (isset($defaults['ssl']['capath']) && (!is_dir($defaults['ssl']['capath']) || !Filesystem::isReadable($defaults['ssl']['capath']))) {
  36062. throw new TransportException('The configured capath was not valid or could not be read.');
  36063. }
  36064. $defaults['ssl']['disable_compression'] = true;
  36065. return $defaults;
  36066. }
  36067. private static function fixHttpHeaderField($header): array
  36068. {
  36069. if (!is_array($header)) {
  36070. $header = explode("\r\n", $header);
  36071. }
  36072. uasort($header, function ($el): int {
  36073. return stripos($el, 'content-type') === 0 ? 1 : -1;
  36074. });
  36075. return $header;
  36076. }
  36077. }
  36078. <?php declare(strict_types=1);
  36079. namespace Composer\Util;
  36080. use Composer\Config;
  36081. use Composer\IO\IOInterface;
  36082. use Composer\Pcre\Preg;
  36083. class Svn
  36084. {
  36085. private const MAX_QTY_AUTH_TRIES = 5;
  36086. protected $credentials;
  36087. protected $hasAuth;
  36088. protected $io;
  36089. protected $url;
  36090. protected $cacheCredentials = true;
  36091. protected $process;
  36092. protected $qtyAuthTries = 0;
  36093. protected $config;
  36094. private static $version;
  36095. public function __construct(string $url, IOInterface $io, Config $config, ProcessExecutor $process = null)
  36096. {
  36097. $this->url = $url;
  36098. $this->io = $io;
  36099. $this->config = $config;
  36100. $this->process = $process ?: new ProcessExecutor($io);
  36101. }
  36102. public static function cleanEnv(): void
  36103. {
  36104. Platform::clearEnv('DYLD_LIBRARY_PATH');
  36105. }
  36106. public function execute(string $command, string $url, ?string $cwd = null, ?string $path = null, bool $verbose = false): string
  36107. {
  36108. $this->config->prohibitUrlByConfig($url, $this->io);
  36109. return $this->executeWithAuthRetry($command, $cwd, $url, $path, $verbose);
  36110. }
  36111. public function executeLocal(string $command, string $path, string $cwd = null, bool $verbose = false): string
  36112. {
  36113. return $this->executeWithAuthRetry($command, $cwd, '', $path, $verbose);
  36114. }
  36115. private function executeWithAuthRetry(string $svnCommand, ?string $cwd, string $url, ?string $path, bool $verbose): ?string
  36116. {
  36117. $command = $this->getCommand($svnCommand, $url, $path);
  36118. $output = null;
  36119. $io = $this->io;
  36120. $handler = function ($type, $buffer) use (&$output, $io, $verbose) {
  36121. if ($type !== 'out') {
  36122. return null;
  36123. }
  36124. if (strpos($buffer, 'Redirecting to URL ') === 0) {
  36125. return null;
  36126. }
  36127. $output .= $buffer;
  36128. if ($verbose) {
  36129. $io->writeError($buffer, false);
  36130. }
  36131. };
  36132. $status = $this->process->execute($command, $handler, $cwd);
  36133. if (0 === $status) {
  36134. return $output;
  36135. }
  36136. $errorOutput = $this->process->getErrorOutput();
  36137. $fullOutput = trim(implode("\n", array($output, $errorOutput)));
  36138. if (false === stripos($fullOutput, 'Could not authenticate to server:')
  36139. && false === stripos($fullOutput, 'authorization failed')
  36140. && false === stripos($fullOutput, 'svn: E170001:')
  36141. && false === stripos($fullOutput, 'svn: E215004:')) {
  36142. throw new \RuntimeException($fullOutput);
  36143. }
  36144. if (!$this->hasAuth()) {
  36145. $this->doAuthDance();
  36146. }
  36147. if ($this->qtyAuthTries++ < self::MAX_QTY_AUTH_TRIES) {
  36148. return $this->executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose);
  36149. }
  36150. throw new \RuntimeException(
  36151. 'wrong credentials provided ('.$fullOutput.')'
  36152. );
  36153. }
  36154. public function setCacheCredentials(bool $cacheCredentials): void
  36155. {
  36156. $this->cacheCredentials = $cacheCredentials;
  36157. }
  36158. protected function doAuthDance(): Svn
  36159. {
  36160. if (!$this->io->isInteractive()) {
  36161. throw new \RuntimeException(
  36162. 'can not ask for authentication in non interactive mode'
  36163. );
  36164. }
  36165. $this->io->writeError("The Subversion server ({$this->url}) requested credentials:");
  36166. $this->hasAuth = true;
  36167. $this->credentials = array(
  36168. 'username' => (string) $this->io->ask("Username: ", ''),
  36169. 'password' => (string) $this->io->askAndHideAnswer("Password: "),
  36170. );
  36171. $this->cacheCredentials = $this->io->askConfirmation("Should Subversion cache these credentials? (yes/no) ");
  36172. return $this;
  36173. }
  36174. protected function getCommand(string $cmd, string $url, ?string $path = null): string
  36175. {
  36176. $cmd = sprintf(
  36177. '%s %s%s -- %s',
  36178. $cmd,
  36179. '--non-interactive ',
  36180. $this->getCredentialString(),
  36181. ProcessExecutor::escape($url)
  36182. );
  36183. if ($path) {
  36184. $cmd .= ' ' . ProcessExecutor::escape($path);
  36185. }
  36186. return $cmd;
  36187. }
  36188. protected function getCredentialString(): string
  36189. {
  36190. if (!$this->hasAuth()) {
  36191. return '';
  36192. }
  36193. return sprintf(
  36194. ' %s--username %s --password %s ',
  36195. $this->getAuthCache(),
  36196. ProcessExecutor::escape($this->getUsername()),
  36197. ProcessExecutor::escape($this->getPassword())
  36198. );
  36199. }
  36200. protected function getPassword(): string
  36201. {
  36202. if ($this->credentials === null) {
  36203. throw new \LogicException("No svn auth detected.");
  36204. }
  36205. return $this->credentials['password'];
  36206. }
  36207. protected function getUsername(): string
  36208. {
  36209. if ($this->credentials === null) {
  36210. throw new \LogicException("No svn auth detected.");
  36211. }
  36212. return $this->credentials['username'];
  36213. }
  36214. protected function hasAuth(): bool
  36215. {
  36216. if (null !== $this->hasAuth) {
  36217. return $this->hasAuth;
  36218. }
  36219. if (false === $this->createAuthFromConfig()) {
  36220. $this->createAuthFromUrl();
  36221. }
  36222. return (bool) $this->hasAuth;
  36223. }
  36224. protected function getAuthCache(): string
  36225. {
  36226. return $this->cacheCredentials ? '' : '--no-auth-cache ';
  36227. }
  36228. private function createAuthFromConfig(): bool
  36229. {
  36230. if (!$this->config->has('http-basic')) {
  36231. return $this->hasAuth = false;
  36232. }
  36233. $authConfig = $this->config->get('http-basic');
  36234. $host = parse_url($this->url, PHP_URL_HOST);
  36235. if (isset($authConfig[$host])) {
  36236. $this->credentials = array(
  36237. 'username' => $authConfig[$host]['username'],
  36238. 'password' => $authConfig[$host]['password'],
  36239. );
  36240. return $this->hasAuth = true;
  36241. }
  36242. return $this->hasAuth = false;
  36243. }
  36244. private function createAuthFromUrl(): bool
  36245. {
  36246. $uri = parse_url($this->url);
  36247. if (empty($uri['user'])) {
  36248. return $this->hasAuth = false;
  36249. }
  36250. $this->credentials = array(
  36251. 'username' => $uri['user'],
  36252. 'password' => !empty($uri['pass']) ? $uri['pass'] : '',
  36253. );
  36254. return $this->hasAuth = true;
  36255. }
  36256. public function binaryVersion(): ?string
  36257. {
  36258. if (!self::$version) {
  36259. if (0 === $this->process->execute('svn --version', $output)) {
  36260. if (Preg::isMatch('{(\d+(?:\.\d+)+)}', $output, $match)) {
  36261. self::$version = $match[1];
  36262. }
  36263. }
  36264. }
  36265. return self::$version;
  36266. }
  36267. }
  36268. <?php declare(strict_types=1);
  36269. namespace Composer\Util;
  36270. use Composer\Downloader\DownloaderInterface;
  36271. use Composer\Package\PackageInterface;
  36272. use React\Promise\PromiseInterface;
  36273. class SyncHelper
  36274. {
  36275. public static function downloadAndInstallPackageSync(Loop $loop, DownloaderInterface $downloader, string $path, PackageInterface $package, PackageInterface $prevPackage = null): void
  36276. {
  36277. $type = $prevPackage ? 'update' : 'install';
  36278. try {
  36279. self::await($loop, $downloader->download($package, $path, $prevPackage));
  36280. self::await($loop, $downloader->prepare($type, $package, $path, $prevPackage));
  36281. if ($type === 'update') {
  36282. self::await($loop, $downloader->update($package, $prevPackage, $path));
  36283. } else {
  36284. self::await($loop, $downloader->install($package, $path));
  36285. }
  36286. } catch (\Exception $e) {
  36287. self::await($loop, $downloader->cleanup($type, $package, $path, $prevPackage));
  36288. throw $e;
  36289. }
  36290. self::await($loop, $downloader->cleanup($type, $package, $path, $prevPackage));
  36291. }
  36292. public static function await(Loop $loop, PromiseInterface $promise = null): void
  36293. {
  36294. if ($promise) {
  36295. $loop->wait(array($promise));
  36296. }
  36297. }
  36298. }
  36299. <?php declare(strict_types=1);
  36300. namespace Composer\Util;
  36301. class Tar
  36302. {
  36303. public static function getComposerJson(string $pathToArchive): ?string
  36304. {
  36305. $phar = new \PharData($pathToArchive);
  36306. if (!$phar->valid()) {
  36307. return null;
  36308. }
  36309. return self::extractComposerJsonFromFolder($phar);
  36310. }
  36311. private static function extractComposerJsonFromFolder(\PharData $phar): string
  36312. {
  36313. if (isset($phar['composer.json'])) {
  36314. return $phar['composer.json']->getContent();
  36315. }
  36316. $topLevelPaths = array();
  36317. foreach ($phar as $folderFile) {
  36318. $name = $folderFile->getBasename();
  36319. if ($folderFile->isDir()) {
  36320. $topLevelPaths[$name] = true;
  36321. if (\count($topLevelPaths) > 1) {
  36322. throw new \RuntimeException('Archive has more than one top level directories, and no composer.json was found on the top level, so it\'s an invalid archive. Top level paths found were: '.implode(',', array_keys($topLevelPaths)));
  36323. }
  36324. }
  36325. }
  36326. $composerJsonPath = key($topLevelPaths).'/composer.json';
  36327. if ($topLevelPaths && isset($phar[$composerJsonPath])) {
  36328. return $phar[$composerJsonPath]->getContent();
  36329. }
  36330. throw new \RuntimeException('No composer.json found either at the top level or within the topmost directory');
  36331. }
  36332. }
  36333. <?php declare(strict_types=1);
  36334. namespace Composer\Util;
  36335. use Composer\CaBundle\CaBundle;
  36336. use Composer\Pcre\Preg;
  36337. final class TlsHelper
  36338. {
  36339. public static function checkCertificateHost($certificate, string $hostname, string &$cn = null): bool
  36340. {
  36341. $names = self::getCertificateNames($certificate);
  36342. if (empty($names)) {
  36343. return false;
  36344. }
  36345. $combinedNames = array_merge($names['san'], array($names['cn']));
  36346. $hostname = strtolower($hostname);
  36347. foreach ($combinedNames as $certName) {
  36348. $matcher = self::certNameMatcher($certName);
  36349. if ($matcher && $matcher($hostname)) {
  36350. $cn = $names['cn'];
  36351. return true;
  36352. }
  36353. }
  36354. return false;
  36355. }
  36356. public static function getCertificateNames($certificate): ?array
  36357. {
  36358. if (is_array($certificate)) {
  36359. $info = $certificate;
  36360. } elseif (CaBundle::isOpensslParseSafe()) {
  36361. $info = openssl_x509_parse($certificate, false);
  36362. }
  36363. if (!isset($info['subject']['commonName'])) {
  36364. return null;
  36365. }
  36366. $commonName = strtolower($info['subject']['commonName']);
  36367. $subjectAltNames = array();
  36368. if (isset($info['extensions']['subjectAltName'])) {
  36369. $subjectAltNames = Preg::split('{\s*,\s*}', $info['extensions']['subjectAltName']);
  36370. $subjectAltNames = array_filter(array_map(function ($name): ?string {
  36371. if (0 === strpos($name, 'DNS:')) {
  36372. return strtolower(ltrim(substr($name, 4)));
  36373. }
  36374. return null;
  36375. }, $subjectAltNames));
  36376. $subjectAltNames = array_values($subjectAltNames);
  36377. }
  36378. return array(
  36379. 'cn' => $commonName,
  36380. 'san' => $subjectAltNames,
  36381. );
  36382. }
  36383. public static function getCertificateFingerprint(string $certificate): string
  36384. {
  36385. $pubkey = openssl_get_publickey($certificate);
  36386. if ($pubkey === false) {
  36387. throw new \RuntimeException('Failed to retrieve the public key from certificate');
  36388. }
  36389. $pubkeydetails = openssl_pkey_get_details($pubkey);
  36390. $pubkeypem = $pubkeydetails['key'];
  36391. $start = '-----BEGIN PUBLIC KEY-----';
  36392. $end = '-----END PUBLIC KEY-----';
  36393. $pemtrim = substr($pubkeypem, strpos($pubkeypem, $start) + strlen($start), (strlen($pubkeypem) - strpos($pubkeypem, $end)) * (-1));
  36394. $der = base64_decode($pemtrim);
  36395. return sha1($der);
  36396. }
  36397. public static function isOpensslParseSafe(): bool
  36398. {
  36399. return CaBundle::isOpensslParseSafe();
  36400. }
  36401. private static function certNameMatcher(string $certName): ?callable
  36402. {
  36403. $wildcards = substr_count($certName, '*');
  36404. if (0 === $wildcards) {
  36405. return function ($hostname) use ($certName): bool {
  36406. return $hostname === $certName;
  36407. };
  36408. }
  36409. if (1 === $wildcards) {
  36410. $components = explode('.', $certName);
  36411. if (3 > count($components)) {
  36412. return null;
  36413. }
  36414. $firstComponent = $components[0];
  36415. if ('*' !== $firstComponent[strlen($firstComponent) - 1]) {
  36416. return null;
  36417. }
  36418. $wildcardRegex = preg_quote($certName);
  36419. $wildcardRegex = str_replace('\\*', '[a-z0-9-]+', $wildcardRegex);
  36420. $wildcardRegex = "{^{$wildcardRegex}$}";
  36421. return function ($hostname) use ($wildcardRegex): bool {
  36422. return Preg::isMatch($wildcardRegex, $hostname);
  36423. };
  36424. }
  36425. return null;
  36426. }
  36427. }
  36428. <?php declare(strict_types=1);
  36429. namespace Composer\Util;
  36430. use Composer\Config;
  36431. use Composer\Pcre\Preg;
  36432. class Url
  36433. {
  36434. public static function updateDistReference(Config $config, string $url, string $ref): string
  36435. {
  36436. $host = parse_url($url, PHP_URL_HOST);
  36437. if ($host === 'api.github.com' || $host === 'github.com' || $host === 'www.github.com') {
  36438. if (Preg::isMatch('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/(zip|tar)ball/(.+)$}i', $url, $match)) {
  36439. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  36440. } elseif (Preg::isMatch('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/archive/.+\.(zip|tar)(?:\.gz)?$}i', $url, $match)) {
  36441. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  36442. } elseif (Preg::isMatch('{^https?://api\.github\.com/repos/([^/]+)/([^/]+)/(zip|tar)ball(?:/.+)?$}i', $url, $match)) {
  36443. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  36444. }
  36445. } elseif ($host === 'bitbucket.org' || $host === 'www.bitbucket.org') {
  36446. if (Preg::isMatch('{^https?://(?:www\.)?bitbucket\.org/([^/]+)/([^/]+)/get/(.+)\.(zip|tar\.gz|tar\.bz2)$}i', $url, $match)) {
  36447. $url = 'https://bitbucket.org/' . $match[1] . '/'. $match[2] . '/get/' . $ref . '.' . $match[4];
  36448. }
  36449. } elseif ($host === 'gitlab.com' || $host === 'www.gitlab.com') {
  36450. if (Preg::isMatch('{^https?://(?:www\.)?gitlab\.com/api/v[34]/projects/([^/]+)/repository/archive\.(zip|tar\.gz|tar\.bz2|tar)\?sha=.+$}i', $url, $match)) {
  36451. $url = 'https://gitlab.com/api/v4/projects/' . $match[1] . '/repository/archive.' . $match[2] . '?sha=' . $ref;
  36452. }
  36453. } elseif (in_array($host, $config->get('github-domains'), true)) {
  36454. $url = Preg::replace('{(/repos/[^/]+/[^/]+/(zip|tar)ball)(?:/.+)?$}i', '$1/'.$ref, $url);
  36455. } elseif (in_array($host, $config->get('gitlab-domains'), true)) {
  36456. $url = Preg::replace('{(/api/v[34]/projects/[^/]+/repository/archive\.(?:zip|tar\.gz|tar\.bz2|tar)\?sha=).+$}i', '${1}'.$ref, $url);
  36457. }
  36458. return $url;
  36459. }
  36460. public static function getOrigin(Config $config, string $url): string
  36461. {
  36462. if (0 === strpos($url, 'file://')) {
  36463. return $url;
  36464. }
  36465. $origin = (string) parse_url($url, PHP_URL_HOST);
  36466. if ($port = parse_url($url, PHP_URL_PORT)) {
  36467. $origin .= ':'.$port;
  36468. }
  36469. if (strpos($origin, '.github.com') === (strlen($origin) - 11)) {
  36470. return 'github.com';
  36471. }
  36472. if ($origin === 'repo.packagist.org') {
  36473. return 'packagist.org';
  36474. }
  36475. if ($origin === '') {
  36476. $origin = $url;
  36477. }
  36478. if (
  36479. is_array($config->get('gitlab-domains'))
  36480. && false === strpos($origin, '/')
  36481. && !in_array($origin, $config->get('gitlab-domains'))
  36482. ) {
  36483. foreach ($config->get('gitlab-domains') as $gitlabDomain) {
  36484. if (0 === strpos($gitlabDomain, $origin)) {
  36485. return $gitlabDomain;
  36486. }
  36487. }
  36488. }
  36489. return $origin;
  36490. }
  36491. public static function sanitize(string $url): string
  36492. {
  36493. $url = Preg::replace('{([&?]access_token=)[^&]+}', '$1***', $url);
  36494. $url = Preg::replaceCallback('{^(?P<prefix>[a-z0-9]+://)?(?P<user>[^:/\s@]+):(?P<password>[^@\s/]+)@}i', function ($m): string {
  36495. if (Preg::isMatch('{^([a-f0-9]{12,}|gh[a-z]_[a-zA-Z0-9_]+)$}', $m['user'])) {
  36496. return $m['prefix'].'***:***@';
  36497. }
  36498. return $m['prefix'].$m['user'].':***@';
  36499. }, $url);
  36500. return $url;
  36501. }
  36502. }
  36503. <?php declare(strict_types=1);
  36504. namespace Composer\Util;
  36505. class Zip
  36506. {
  36507. public static function getComposerJson(string $pathToZip): ?string
  36508. {
  36509. if (!extension_loaded('zip')) {
  36510. throw new \RuntimeException('The Zip Util requires PHP\'s zip extension');
  36511. }
  36512. $zip = new \ZipArchive();
  36513. if ($zip->open($pathToZip) !== true) {
  36514. return null;
  36515. }
  36516. if (0 == $zip->numFiles) {
  36517. $zip->close();
  36518. return null;
  36519. }
  36520. $foundFileIndex = self::locateFile($zip, 'composer.json');
  36521. $content = null;
  36522. $configurationFileName = $zip->getNameIndex($foundFileIndex);
  36523. $stream = $zip->getStream($configurationFileName);
  36524. if (false !== $stream) {
  36525. $content = stream_get_contents($stream);
  36526. }
  36527. $zip->close();
  36528. return $content;
  36529. }
  36530. private static function locateFile(\ZipArchive $zip, string $filename): int
  36531. {
  36532. if (false !== ($index = $zip->locateName($filename)) && $zip->getFromIndex($index) !== false) {
  36533. return $index;
  36534. }
  36535. $topLevelPaths = array();
  36536. for ($i = 0; $i < $zip->numFiles; $i++) {
  36537. $name = $zip->getNameIndex($i);
  36538. $dirname = dirname($name);
  36539. if (strpos($name, '__MACOSX') !== false) {
  36540. continue;
  36541. }
  36542. if ($dirname === '.') {
  36543. $topLevelPaths[$name] = true;
  36544. if (\count($topLevelPaths) > 1) {
  36545. throw new \RuntimeException('Archive has more than one top level directories, and no composer.json was found on the top level, so it\'s an invalid archive. Top level paths found were: '.implode(',', array_keys($topLevelPaths)));
  36546. }
  36547. continue;
  36548. }
  36549. if (false === strpos($dirname, '\\') && false === strpos($dirname, '/')) {
  36550. $topLevelPaths[$dirname.'/'] = true;
  36551. if (\count($topLevelPaths) > 1) {
  36552. throw new \RuntimeException('Archive has more than one top level directories, and no composer.json was found on the top level, so it\'s an invalid archive. Top level paths found were: '.implode(',', array_keys($topLevelPaths)));
  36553. }
  36554. }
  36555. }
  36556. if ($topLevelPaths && false !== ($index = $zip->locateName(key($topLevelPaths).$filename)) && $zip->getFromIndex($index) !== false) {
  36557. return $index;
  36558. }
  36559. throw new \RuntimeException('No composer.json found either at the top level or within the topmost directory');
  36560. }
  36561. }
  36562. <?php declare(strict_types=1);
  36563. use Composer\Autoload\ClassLoader;
  36564. function includeIfExists(string $file): ?ClassLoader
  36565. {
  36566. return file_exists($file) ? include $file : null;
  36567. }
  36568. if ((!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../../../autoload.php'))) {
  36569. echo 'You must set up the project dependencies using `composer install`'.PHP_EOL.
  36570. 'See https://getcomposer.org/download/ for instructions on installing Composer'.PHP_EOL;
  36571. exit(1);
  36572. }
  36573. return $loader;
  36574. <?php
  36575. /*
  36576. * This file is part of Composer.
  36577. *
  36578. * (c) Nils Adermann <naderman@naderman.de>
  36579. * Jordi Boggiano <j.boggiano@seld.be>
  36580. *
  36581. * For the full copyright and license information, please view the LICENSE
  36582. * file that was distributed with this source code.
  36583. */
  36584. namespace Composer\Autoload;
  36585. /**
  36586. * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
  36587. *
  36588. * $loader = new \Composer\Autoload\ClassLoader();
  36589. *
  36590. * // register classes with namespaces
  36591. * $loader->add('Symfony\Component', __DIR__.'/component');
  36592. * $loader->add('Symfony', __DIR__.'/framework');
  36593. *
  36594. * // activate the autoloader
  36595. * $loader->register();
  36596. *
  36597. * // to enable searching the include path (eg. for PEAR packages)
  36598. * $loader->setUseIncludePath(true);
  36599. *
  36600. * In this example, if you try to use a class in the Symfony\Component
  36601. * namespace or one of its children (Symfony\Component\Console for instance),
  36602. * the autoloader will first look for the class under the component/
  36603. * directory, and it will then fallback to the framework/ directory if not
  36604. * found before giving up.
  36605. *
  36606. * This class is loosely based on the Symfony UniversalClassLoader.
  36607. *
  36608. * @author Fabien Potencier <fabien@symfony.com>
  36609. * @author Jordi Boggiano <j.boggiano@seld.be>
  36610. * @see https://www.php-fig.org/psr/psr-0/
  36611. * @see https://www.php-fig.org/psr/psr-4/
  36612. */
  36613. class ClassLoader
  36614. {
  36615. /** @var ?string */
  36616. private $vendorDir;
  36617. // PSR-4
  36618. /**
  36619. * @var array[]
  36620. * @psalm-var array<string, array<string, int>>
  36621. */
  36622. private $prefixLengthsPsr4 = array();
  36623. /**
  36624. * @var array[]
  36625. * @psalm-var array<string, array<int, string>>
  36626. */
  36627. private $prefixDirsPsr4 = array();
  36628. /**
  36629. * @var array[]
  36630. * @psalm-var array<string, string>
  36631. */
  36632. private $fallbackDirsPsr4 = array();
  36633. // PSR-0
  36634. /**
  36635. * @var array[]
  36636. * @psalm-var array<string, array<string, string[]>>
  36637. */
  36638. private $prefixesPsr0 = array();
  36639. /**
  36640. * @var array[]
  36641. * @psalm-var array<string, string>
  36642. */
  36643. private $fallbackDirsPsr0 = array();
  36644. /** @var bool */
  36645. private $useIncludePath = false;
  36646. /**
  36647. * @var string[]
  36648. * @psalm-var array<string, string>
  36649. */
  36650. private $classMap = array();
  36651. /** @var bool */
  36652. private $classMapAuthoritative = false;
  36653. /**
  36654. * @var bool[]
  36655. * @psalm-var array<string, bool>
  36656. */
  36657. private $missingClasses = array();
  36658. /** @var ?string */
  36659. private $apcuPrefix;
  36660. /**
  36661. * @var self[]
  36662. */
  36663. private static $registeredLoaders = array();
  36664. /**
  36665. * @param ?string $vendorDir
  36666. */
  36667. public function __construct($vendorDir = null)
  36668. {
  36669. $this->vendorDir = $vendorDir;
  36670. }
  36671. /**
  36672. * @return string[]
  36673. */
  36674. public function getPrefixes()
  36675. {
  36676. if (!empty($this->prefixesPsr0)) {
  36677. return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
  36678. }
  36679. return array();
  36680. }
  36681. /**
  36682. * @return array[]
  36683. * @psalm-return array<string, array<int, string>>
  36684. */
  36685. public function getPrefixesPsr4()
  36686. {
  36687. return $this->prefixDirsPsr4;
  36688. }
  36689. /**
  36690. * @return array[]
  36691. * @psalm-return array<string, string>
  36692. */
  36693. public function getFallbackDirs()
  36694. {
  36695. return $this->fallbackDirsPsr0;
  36696. }
  36697. /**
  36698. * @return array[]
  36699. * @psalm-return array<string, string>
  36700. */
  36701. public function getFallbackDirsPsr4()
  36702. {
  36703. return $this->fallbackDirsPsr4;
  36704. }
  36705. /**
  36706. * @return string[] Array of classname => path
  36707. * @psalm-return array<string, string>
  36708. */
  36709. public function getClassMap()
  36710. {
  36711. return $this->classMap;
  36712. }
  36713. /**
  36714. * @param string[] $classMap Class to filename map
  36715. * @psalm-param array<string, string> $classMap
  36716. *
  36717. * @return void
  36718. */
  36719. public function addClassMap(array $classMap)
  36720. {
  36721. if ($this->classMap) {
  36722. $this->classMap = array_merge($this->classMap, $classMap);
  36723. } else {
  36724. $this->classMap = $classMap;
  36725. }
  36726. }
  36727. /**
  36728. * Registers a set of PSR-0 directories for a given prefix, either
  36729. * appending or prepending to the ones previously set for this prefix.
  36730. *
  36731. * @param string $prefix The prefix
  36732. * @param string[]|string $paths The PSR-0 root directories
  36733. * @param bool $prepend Whether to prepend the directories
  36734. *
  36735. * @return void
  36736. */
  36737. public function add($prefix, $paths, $prepend = false)
  36738. {
  36739. if (!$prefix) {
  36740. if ($prepend) {
  36741. $this->fallbackDirsPsr0 = array_merge(
  36742. (array) $paths,
  36743. $this->fallbackDirsPsr0
  36744. );
  36745. } else {
  36746. $this->fallbackDirsPsr0 = array_merge(
  36747. $this->fallbackDirsPsr0,
  36748. (array) $paths
  36749. );
  36750. }
  36751. return;
  36752. }
  36753. $first = $prefix[0];
  36754. if (!isset($this->prefixesPsr0[$first][$prefix])) {
  36755. $this->prefixesPsr0[$first][$prefix] = (array) $paths;
  36756. return;
  36757. }
  36758. if ($prepend) {
  36759. $this->prefixesPsr0[$first][$prefix] = array_merge(
  36760. (array) $paths,
  36761. $this->prefixesPsr0[$first][$prefix]
  36762. );
  36763. } else {
  36764. $this->prefixesPsr0[$first][$prefix] = array_merge(
  36765. $this->prefixesPsr0[$first][$prefix],
  36766. (array) $paths
  36767. );
  36768. }
  36769. }
  36770. /**
  36771. * Registers a set of PSR-4 directories for a given namespace, either
  36772. * appending or prepending to the ones previously set for this namespace.
  36773. *
  36774. * @param string $prefix The prefix/namespace, with trailing '\\'
  36775. * @param string[]|string $paths The PSR-4 base directories
  36776. * @param bool $prepend Whether to prepend the directories
  36777. *
  36778. * @throws \InvalidArgumentException
  36779. *
  36780. * @return void
  36781. */
  36782. public function addPsr4($prefix, $paths, $prepend = false)
  36783. {
  36784. if (!$prefix) {
  36785. // Register directories for the root namespace.
  36786. if ($prepend) {
  36787. $this->fallbackDirsPsr4 = array_merge(
  36788. (array) $paths,
  36789. $this->fallbackDirsPsr4
  36790. );
  36791. } else {
  36792. $this->fallbackDirsPsr4 = array_merge(
  36793. $this->fallbackDirsPsr4,
  36794. (array) $paths
  36795. );
  36796. }
  36797. } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
  36798. // Register directories for a new namespace.
  36799. $length = strlen($prefix);
  36800. if ('\\' !== $prefix[$length - 1]) {
  36801. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  36802. }
  36803. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  36804. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  36805. } elseif ($prepend) {
  36806. // Prepend directories for an already registered namespace.
  36807. $this->prefixDirsPsr4[$prefix] = array_merge(
  36808. (array) $paths,
  36809. $this->prefixDirsPsr4[$prefix]
  36810. );
  36811. } else {
  36812. // Append directories for an already registered namespace.
  36813. $this->prefixDirsPsr4[$prefix] = array_merge(
  36814. $this->prefixDirsPsr4[$prefix],
  36815. (array) $paths
  36816. );
  36817. }
  36818. }
  36819. /**
  36820. * Registers a set of PSR-0 directories for a given prefix,
  36821. * replacing any others previously set for this prefix.
  36822. *
  36823. * @param string $prefix The prefix
  36824. * @param string[]|string $paths The PSR-0 base directories
  36825. *
  36826. * @return void
  36827. */
  36828. public function set($prefix, $paths)
  36829. {
  36830. if (!$prefix) {
  36831. $this->fallbackDirsPsr0 = (array) $paths;
  36832. } else {
  36833. $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
  36834. }
  36835. }
  36836. /**
  36837. * Registers a set of PSR-4 directories for a given namespace,
  36838. * replacing any others previously set for this namespace.
  36839. *
  36840. * @param string $prefix The prefix/namespace, with trailing '\\'
  36841. * @param string[]|string $paths The PSR-4 base directories
  36842. *
  36843. * @throws \InvalidArgumentException
  36844. *
  36845. * @return void
  36846. */
  36847. public function setPsr4($prefix, $paths)
  36848. {
  36849. if (!$prefix) {
  36850. $this->fallbackDirsPsr4 = (array) $paths;
  36851. } else {
  36852. $length = strlen($prefix);
  36853. if ('\\' !== $prefix[$length - 1]) {
  36854. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  36855. }
  36856. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  36857. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  36858. }
  36859. }
  36860. /**
  36861. * Turns on searching the include path for class files.
  36862. *
  36863. * @param bool $useIncludePath
  36864. *
  36865. * @return void
  36866. */
  36867. public function setUseIncludePath($useIncludePath)
  36868. {
  36869. $this->useIncludePath = $useIncludePath;
  36870. }
  36871. /**
  36872. * Can be used to check if the autoloader uses the include path to check
  36873. * for classes.
  36874. *
  36875. * @return bool
  36876. */
  36877. public function getUseIncludePath()
  36878. {
  36879. return $this->useIncludePath;
  36880. }
  36881. /**
  36882. * Turns off searching the prefix and fallback directories for classes
  36883. * that have not been registered with the class map.
  36884. *
  36885. * @param bool $classMapAuthoritative
  36886. *
  36887. * @return void
  36888. */
  36889. public function setClassMapAuthoritative($classMapAuthoritative)
  36890. {
  36891. $this->classMapAuthoritative = $classMapAuthoritative;
  36892. }
  36893. /**
  36894. * Should class lookup fail if not found in the current class map?
  36895. *
  36896. * @return bool
  36897. */
  36898. public function isClassMapAuthoritative()
  36899. {
  36900. return $this->classMapAuthoritative;
  36901. }
  36902. /**
  36903. * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
  36904. *
  36905. * @param string|null $apcuPrefix
  36906. *
  36907. * @return void
  36908. */
  36909. public function setApcuPrefix($apcuPrefix)
  36910. {
  36911. $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
  36912. }
  36913. /**
  36914. * The APCu prefix in use, or null if APCu caching is not enabled.
  36915. *
  36916. * @return string|null
  36917. */
  36918. public function getApcuPrefix()
  36919. {
  36920. return $this->apcuPrefix;
  36921. }
  36922. /**
  36923. * Registers this instance as an autoloader.
  36924. *
  36925. * @param bool $prepend Whether to prepend the autoloader or not
  36926. *
  36927. * @return void
  36928. */
  36929. public function register($prepend = false)
  36930. {
  36931. spl_autoload_register(array($this, 'loadClass'), true, $prepend);
  36932. if (null === $this->vendorDir) {
  36933. return;
  36934. }
  36935. if ($prepend) {
  36936. self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
  36937. } else {
  36938. unset(self::$registeredLoaders[$this->vendorDir]);
  36939. self::$registeredLoaders[$this->vendorDir] = $this;
  36940. }
  36941. }
  36942. /**
  36943. * Unregisters this instance as an autoloader.
  36944. *
  36945. * @return void
  36946. */
  36947. public function unregister()
  36948. {
  36949. spl_autoload_unregister(array($this, 'loadClass'));
  36950. if (null !== $this->vendorDir) {
  36951. unset(self::$registeredLoaders[$this->vendorDir]);
  36952. }
  36953. }
  36954. /**
  36955. * Loads the given class or interface.
  36956. *
  36957. * @param string $class The name of the class
  36958. * @return true|null True if loaded, null otherwise
  36959. */
  36960. public function loadClass($class)
  36961. {
  36962. if ($file = $this->findFile($class)) {
  36963. includeFile($file);
  36964. return true;
  36965. }
  36966. return null;
  36967. }
  36968. /**
  36969. * Finds the path to the file where the class is defined.
  36970. *
  36971. * @param string $class The name of the class
  36972. *
  36973. * @return string|false The path if found, false otherwise
  36974. */
  36975. public function findFile($class)
  36976. {
  36977. // class map lookup
  36978. if (isset($this->classMap[$class])) {
  36979. return $this->classMap[$class];
  36980. }
  36981. if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
  36982. return false;
  36983. }
  36984. if (null !== $this->apcuPrefix) {
  36985. $file = apcu_fetch($this->apcuPrefix.$class, $hit);
  36986. if ($hit) {
  36987. return $file;
  36988. }
  36989. }
  36990. $file = $this->findFileWithExtension($class, '.php');
  36991. // Search for Hack files if we are running on HHVM
  36992. if (false === $file && defined('HHVM_VERSION')) {
  36993. $file = $this->findFileWithExtension($class, '.hh');
  36994. }
  36995. if (null !== $this->apcuPrefix) {
  36996. apcu_add($this->apcuPrefix.$class, $file);
  36997. }
  36998. if (false === $file) {
  36999. // Remember that this class does not exist.
  37000. $this->missingClasses[$class] = true;
  37001. }
  37002. return $file;
  37003. }
  37004. /**
  37005. * Returns the currently registered loaders indexed by their corresponding vendor directories.
  37006. *
  37007. * @return self[]
  37008. */
  37009. public static function getRegisteredLoaders()
  37010. {
  37011. return self::$registeredLoaders;
  37012. }
  37013. /**
  37014. * @param string $class
  37015. * @param string $ext
  37016. * @return string|false
  37017. */
  37018. private function findFileWithExtension($class, $ext)
  37019. {
  37020. // PSR-4 lookup
  37021. $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
  37022. $first = $class[0];
  37023. if (isset($this->prefixLengthsPsr4[$first])) {
  37024. $subPath = $class;
  37025. while (false !== $lastPos = strrpos($subPath, '\\')) {
  37026. $subPath = substr($subPath, 0, $lastPos);
  37027. $search = $subPath . '\\';
  37028. if (isset($this->prefixDirsPsr4[$search])) {
  37029. $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
  37030. foreach ($this->prefixDirsPsr4[$search] as $dir) {
  37031. if (file_exists($file = $dir . $pathEnd)) {
  37032. return $file;
  37033. }
  37034. }
  37035. }
  37036. }
  37037. }
  37038. // PSR-4 fallback dirs
  37039. foreach ($this->fallbackDirsPsr4 as $dir) {
  37040. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
  37041. return $file;
  37042. }
  37043. }
  37044. // PSR-0 lookup
  37045. if (false !== $pos = strrpos($class, '\\')) {
  37046. // namespaced class name
  37047. $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
  37048. . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
  37049. } else {
  37050. // PEAR-like class name
  37051. $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
  37052. }
  37053. if (isset($this->prefixesPsr0[$first])) {
  37054. foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
  37055. if (0 === strpos($class, $prefix)) {
  37056. foreach ($dirs as $dir) {
  37057. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  37058. return $file;
  37059. }
  37060. }
  37061. }
  37062. }
  37063. }
  37064. // PSR-0 fallback dirs
  37065. foreach ($this->fallbackDirsPsr0 as $dir) {
  37066. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  37067. return $file;
  37068. }
  37069. }
  37070. // PSR-0 include paths.
  37071. if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
  37072. return $file;
  37073. }
  37074. return false;
  37075. }
  37076. }
  37077. /**
  37078. * Scope isolated include.
  37079. *
  37080. * Prevents access to $this/self from included files.
  37081. *
  37082. * @param string $file
  37083. * @return void
  37084. * @private
  37085. */
  37086. function includeFile($file)
  37087. {
  37088. include $file;
  37089. }
  37090. <?php
  37091. /*
  37092. * This file is part of Composer.
  37093. *
  37094. * (c) Nils Adermann <naderman@naderman.de>
  37095. * Jordi Boggiano <j.boggiano@seld.be>
  37096. *
  37097. * For the full copyright and license information, please view the LICENSE
  37098. * file that was distributed with this source code.
  37099. */
  37100. namespace Composer;
  37101. use Composer\Autoload\ClassLoader;
  37102. use Composer\Semver\VersionParser;
  37103. /**
  37104. * This class is copied in every Composer installed project and available to all
  37105. *
  37106. * See also https://getcomposer.org/doc/07-runtime.md#installed-versions
  37107. *
  37108. * To require its presence, you can require `composer-runtime-api ^2.0`
  37109. *
  37110. * @final
  37111. */
  37112. class InstalledVersions
  37113. {
  37114. /**
  37115. * @var mixed[]|null
  37116. * @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}|array{}|null
  37117. */
  37118. private static $installed;
  37119. /**
  37120. * @var bool|null
  37121. */
  37122. private static $canGetVendors;
  37123. /**
  37124. * @var array[]
  37125. * @psalm-var array<string, array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
  37126. */
  37127. private static $installedByVendor = array();
  37128. /**
  37129. * Returns a list of all package names which are present, either by being installed, replaced or provided
  37130. *
  37131. * @return string[]
  37132. * @psalm-return list<string>
  37133. */
  37134. public static function getInstalledPackages()
  37135. {
  37136. $packages = array();
  37137. foreach (self::getInstalled() as $installed) {
  37138. $packages[] = array_keys($installed['versions']);
  37139. }
  37140. if (1 === \count($packages)) {
  37141. return $packages[0];
  37142. }
  37143. return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
  37144. }
  37145. /**
  37146. * Returns a list of all package names with a specific type e.g. 'library'
  37147. *
  37148. * @param string $type
  37149. * @return string[]
  37150. * @psalm-return list<string>
  37151. */
  37152. public static function getInstalledPackagesByType($type)
  37153. {
  37154. $packagesByType = array();
  37155. foreach (self::getInstalled() as $installed) {
  37156. foreach ($installed['versions'] as $name => $package) {
  37157. if (isset($package['type']) && $package['type'] === $type) {
  37158. $packagesByType[] = $name;
  37159. }
  37160. }
  37161. }
  37162. return $packagesByType;
  37163. }
  37164. /**
  37165. * Checks whether the given package is installed
  37166. *
  37167. * This also returns true if the package name is provided or replaced by another package
  37168. *
  37169. * @param string $packageName
  37170. * @param bool $includeDevRequirements
  37171. * @return bool
  37172. */
  37173. public static function isInstalled($packageName, $includeDevRequirements = true)
  37174. {
  37175. foreach (self::getInstalled() as $installed) {
  37176. if (isset($installed['versions'][$packageName])) {
  37177. return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
  37178. }
  37179. }
  37180. return false;
  37181. }
  37182. /**
  37183. * Checks whether the given package satisfies a version constraint
  37184. *
  37185. * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
  37186. *
  37187. * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
  37188. *
  37189. * @param VersionParser $parser Install composer/semver to have access to this class and functionality
  37190. * @param string $packageName
  37191. * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
  37192. * @return bool
  37193. */
  37194. public static function satisfies(VersionParser $parser, $packageName, $constraint)
  37195. {
  37196. $constraint = $parser->parseConstraints($constraint);
  37197. $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
  37198. return $provided->matches($constraint);
  37199. }
  37200. /**
  37201. * Returns a version constraint representing all the range(s) which are installed for a given package
  37202. *
  37203. * It is easier to use this via isInstalled() with the $constraint argument if you need to check
  37204. * whether a given version of a package is installed, and not just whether it exists
  37205. *
  37206. * @param string $packageName
  37207. * @return string Version constraint usable with composer/semver
  37208. */
  37209. public static function getVersionRanges($packageName)
  37210. {
  37211. foreach (self::getInstalled() as $installed) {
  37212. if (!isset($installed['versions'][$packageName])) {
  37213. continue;
  37214. }
  37215. $ranges = array();
  37216. if (isset($installed['versions'][$packageName]['pretty_version'])) {
  37217. $ranges[] = $installed['versions'][$packageName]['pretty_version'];
  37218. }
  37219. if (array_key_exists('aliases', $installed['versions'][$packageName])) {
  37220. $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
  37221. }
  37222. if (array_key_exists('replaced', $installed['versions'][$packageName])) {
  37223. $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
  37224. }
  37225. if (array_key_exists('provided', $installed['versions'][$packageName])) {
  37226. $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
  37227. }
  37228. return implode(' || ', $ranges);
  37229. }
  37230. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  37231. }
  37232. /**
  37233. * @param string $packageName
  37234. * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
  37235. */
  37236. public static function getVersion($packageName)
  37237. {
  37238. foreach (self::getInstalled() as $installed) {
  37239. if (!isset($installed['versions'][$packageName])) {
  37240. continue;
  37241. }
  37242. if (!isset($installed['versions'][$packageName]['version'])) {
  37243. return null;
  37244. }
  37245. return $installed['versions'][$packageName]['version'];
  37246. }
  37247. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  37248. }
  37249. /**
  37250. * @param string $packageName
  37251. * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
  37252. */
  37253. public static function getPrettyVersion($packageName)
  37254. {
  37255. foreach (self::getInstalled() as $installed) {
  37256. if (!isset($installed['versions'][$packageName])) {
  37257. continue;
  37258. }
  37259. if (!isset($installed['versions'][$packageName]['pretty_version'])) {
  37260. return null;
  37261. }
  37262. return $installed['versions'][$packageName]['pretty_version'];
  37263. }
  37264. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  37265. }
  37266. /**
  37267. * @param string $packageName
  37268. * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
  37269. */
  37270. public static function getReference($packageName)
  37271. {
  37272. foreach (self::getInstalled() as $installed) {
  37273. if (!isset($installed['versions'][$packageName])) {
  37274. continue;
  37275. }
  37276. if (!isset($installed['versions'][$packageName]['reference'])) {
  37277. return null;
  37278. }
  37279. return $installed['versions'][$packageName]['reference'];
  37280. }
  37281. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  37282. }
  37283. /**
  37284. * @param string $packageName
  37285. * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
  37286. */
  37287. public static function getInstallPath($packageName)
  37288. {
  37289. foreach (self::getInstalled() as $installed) {
  37290. if (!isset($installed['versions'][$packageName])) {
  37291. continue;
  37292. }
  37293. return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
  37294. }
  37295. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  37296. }
  37297. /**
  37298. * @return array
  37299. * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}
  37300. */
  37301. public static function getRootPackage()
  37302. {
  37303. $installed = self::getInstalled();
  37304. return $installed[0]['root'];
  37305. }
  37306. /**
  37307. * Returns the raw installed.php data for custom implementations
  37308. *
  37309. * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
  37310. * @return array[]
  37311. * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}
  37312. */
  37313. public static function getRawData()
  37314. {
  37315. @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
  37316. if (null === self::$installed) {
  37317. // only require the installed.php file if this file is loaded from its dumped location,
  37318. // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
  37319. if (substr(__DIR__, -8, 1) !== 'C') {
  37320. self::$installed = include __DIR__ . '/installed.php';
  37321. } else {
  37322. self::$installed = array();
  37323. }
  37324. }
  37325. return self::$installed;
  37326. }
  37327. /**
  37328. * Returns the raw data of all installed.php which are currently loaded for custom implementations
  37329. *
  37330. * @return array[]
  37331. * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
  37332. */
  37333. public static function getAllRawData()
  37334. {
  37335. return self::getInstalled();
  37336. }
  37337. /**
  37338. * Lets you reload the static array from another file
  37339. *
  37340. * This is only useful for complex integrations in which a project needs to use
  37341. * this class but then also needs to execute another project's autoloader in process,
  37342. * and wants to ensure both projects have access to their version of installed.php.
  37343. *
  37344. * A typical case would be PHPUnit, where it would need to make sure it reads all
  37345. * the data it needs from this class, then call reload() with
  37346. * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
  37347. * the project in which it runs can then also use this class safely, without
  37348. * interference between PHPUnit's dependencies and the project's dependencies.
  37349. *
  37350. * @param array[] $data A vendor/composer/installed.php data set
  37351. * @return void
  37352. *
  37353. * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data
  37354. */
  37355. public static function reload($data)
  37356. {
  37357. self::$installed = $data;
  37358. self::$installedByVendor = array();
  37359. }
  37360. /**
  37361. * @return array[]
  37362. * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
  37363. */
  37364. private static function getInstalled()
  37365. {
  37366. if (null === self::$canGetVendors) {
  37367. self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
  37368. }
  37369. $installed = array();
  37370. if (self::$canGetVendors) {
  37371. foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
  37372. if (isset(self::$installedByVendor[$vendorDir])) {
  37373. $installed[] = self::$installedByVendor[$vendorDir];
  37374. } elseif (is_file($vendorDir.'/composer/installed.php')) {
  37375. $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
  37376. if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
  37377. self::$installed = $installed[count($installed) - 1];
  37378. }
  37379. }
  37380. }
  37381. }
  37382. if (null === self::$installed) {
  37383. // only require the installed.php file if this file is loaded from its dumped location,
  37384. // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
  37385. if (substr(__DIR__, -8, 1) !== 'C') {
  37386. self::$installed = require __DIR__ . '/installed.php';
  37387. } else {
  37388. self::$installed = array();
  37389. }
  37390. }
  37391. $installed[] = self::$installed;
  37392. return $installed;
  37393. }
  37394. }
  37395. {
  37396. "$schema": "https://json-schema.org/draft-04/schema#",
  37397. "description": "A representation of packages metadata.",
  37398. "type": "object",
  37399. "oneOf": [
  37400. { "required": [ "packages" ] },
  37401. { "required": [ "providers" ] },
  37402. { "required": [ "provider-includes", "providers-url" ] }
  37403. ],
  37404. "properties": {
  37405. "packages": {
  37406. "type": ["object", "array"],
  37407. "description": "A hashmap of package names in the form of <vendor>/<name>.",
  37408. "additionalProperties": { "$ref": "#/definitions/versions" }
  37409. },
  37410. "providers-url": {
  37411. "type": "string",
  37412. "description": "Endpoint to retrieve provider data from, e.g. '/p/%package%$%hash%.json'."
  37413. },
  37414. "provider-includes": {
  37415. "type": "object",
  37416. "description": "A hashmap of provider listings.",
  37417. "additionalProperties": { "$ref": "#/definitions/provider" }
  37418. },
  37419. "providers": {
  37420. "type": "object",
  37421. "description": "A hashmap of package names in the form of <vendor>/<name>.",
  37422. "additionalProperties": { "$ref": "#/definitions/provider" }
  37423. },
  37424. "notify-batch": {
  37425. "type": "string",
  37426. "description": "Endpoint to call after multiple packages have been installed, e.g. '/downloads/'."
  37427. },
  37428. "search": {
  37429. "type": "string",
  37430. "description": "Endpoint that provides search capabilities, e.g. '/search.json?q=%query%&type=%type%'."
  37431. },
  37432. "warning": {
  37433. "type": "string",
  37434. "description": "A message that will be output by Composer as a warning when this source is consulted."
  37435. }
  37436. },
  37437. "definitions": {
  37438. "versions": {
  37439. "type": "object",
  37440. "description": "A hashmap of versions and their metadata.",
  37441. "additionalProperties": { "$ref": "#/definitions/version" }
  37442. },
  37443. "version": {
  37444. "type": "object",
  37445. "oneOf": [
  37446. { "$ref": "#/definitions/package" },
  37447. { "$ref": "#/definitions/metapackage" }
  37448. ]
  37449. },
  37450. "package-base": {
  37451. "properties": {
  37452. "name": { "type": "string" },
  37453. "type": { "type": "string" },
  37454. "version": { "type": "string" },
  37455. "version_normalized": {
  37456. "type": "string",
  37457. "description": "Normalized version, optional but can save computational time on client side."
  37458. },
  37459. "autoload": { "type": "object" },
  37460. "require": { "type": "object" },
  37461. "replace": { "type": "object" },
  37462. "conflict": { "type": "object" },
  37463. "provide": { "type": "object" },
  37464. "time": { "type": "string" }
  37465. },
  37466. "additionalProperties": true
  37467. },
  37468. "package": {
  37469. "allOf": [
  37470. { "$ref": "#/definitions/package-base" },
  37471. {
  37472. "properties": {
  37473. "dist": { "type": "object" },
  37474. "source": { "type": "object" }
  37475. }
  37476. },
  37477. { "oneOf": [
  37478. { "required": [ "name", "version", "source" ] },
  37479. { "required": [ "name", "version", "dist" ] }
  37480. ] }
  37481. ]
  37482. },
  37483. "metapackage": {
  37484. "allOf": [
  37485. { "$ref": "#/definitions/package-base" },
  37486. {
  37487. "properties": {
  37488. "type": { "type": "string", "enum": [ "metapackage" ] }
  37489. },
  37490. "required": [ "name", "version", "type" ]
  37491. }
  37492. ]
  37493. },
  37494. "provider": {
  37495. "type": "object",
  37496. "properties": {
  37497. "sha256": {
  37498. "type": "string",
  37499. "description": "Hash value that can be used to validate the resource."
  37500. }
  37501. }
  37502. }
  37503. }
  37504. }
  37505. {
  37506. "$schema": "https://json-schema.org/draft-04/schema#",
  37507. "title": "Package",
  37508. "type": "object",
  37509. "properties": {
  37510. "name": {
  37511. "type": "string",
  37512. "description": "Package name, including 'vendor-name/' prefix.",
  37513. "pattern": "^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$"
  37514. },
  37515. "description": {
  37516. "type": "string",
  37517. "description": "Short package description."
  37518. },
  37519. "license": {
  37520. "type": ["string", "array"],
  37521. "description": "License name. Or an array of license names."
  37522. },
  37523. "type": {
  37524. "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.",
  37525. "type": "string",
  37526. "pattern": "^[a-z0-9-]+$"
  37527. },
  37528. "abandoned": {
  37529. "type": ["boolean", "string"],
  37530. "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."
  37531. },
  37532. "version": {
  37533. "type": "string",
  37534. "description": "Package version, see https://getcomposer.org/doc/04-schema.md#version for more info on valid schemes.",
  37535. "pattern": "^v?\\d+(\\.\\d+){0,3}|^dev-"
  37536. },
  37537. "default-branch": {
  37538. "type": ["boolean"],
  37539. "description": "Internal use only, do not specify this in composer.json. Indicates whether this version is the default branch of the linked VCS repository. Defaults to false."
  37540. },
  37541. "non-feature-branches": {
  37542. "type": ["array"],
  37543. "description": "A set of string or regex patterns for non-numeric branch names that will not be handled as feature branches.",
  37544. "items": {
  37545. "type": "string"
  37546. }
  37547. },
  37548. "keywords": {
  37549. "type": "array",
  37550. "items": {
  37551. "type": "string",
  37552. "description": "A tag/keyword that this package relates to."
  37553. }
  37554. },
  37555. "readme": {
  37556. "type": "string",
  37557. "description": "Relative path to the readme document."
  37558. },
  37559. "time": {
  37560. "type": "string",
  37561. "description": "Package release date, in 'YYYY-MM-DD', 'YYYY-MM-DD HH:MM:SS' or 'YYYY-MM-DDTHH:MM:SSZ' format."
  37562. },
  37563. "authors": {
  37564. "$ref": "#/definitions/authors"
  37565. },
  37566. "homepage": {
  37567. "type": "string",
  37568. "description": "Homepage URL for the project.",
  37569. "format": "uri"
  37570. },
  37571. "support": {
  37572. "type": "object",
  37573. "properties": {
  37574. "email": {
  37575. "type": "string",
  37576. "description": "Email address for support.",
  37577. "format": "email"
  37578. },
  37579. "issues": {
  37580. "type": "string",
  37581. "description": "URL to the issue tracker.",
  37582. "format": "uri"
  37583. },
  37584. "forum": {
  37585. "type": "string",
  37586. "description": "URL to the forum.",
  37587. "format": "uri"
  37588. },
  37589. "wiki": {
  37590. "type": "string",
  37591. "description": "URL to the wiki.",
  37592. "format": "uri"
  37593. },
  37594. "irc": {
  37595. "type": "string",
  37596. "description": "IRC channel for support, as irc://server/channel.",
  37597. "format": "uri"
  37598. },
  37599. "chat": {
  37600. "type": "string",
  37601. "description": "URL to the support chat.",
  37602. "format": "uri"
  37603. },
  37604. "source": {
  37605. "type": "string",
  37606. "description": "URL to browse or download the sources.",
  37607. "format": "uri"
  37608. },
  37609. "docs": {
  37610. "type": "string",
  37611. "description": "URL to the documentation.",
  37612. "format": "uri"
  37613. },
  37614. "rss": {
  37615. "type": "string",
  37616. "description": "URL to the RSS feed.",
  37617. "format": "uri"
  37618. }
  37619. }
  37620. },
  37621. "funding": {
  37622. "type": "array",
  37623. "description": "A list of options to fund the development and maintenance of the package.",
  37624. "items": {
  37625. "type": "object",
  37626. "properties": {
  37627. "type": {
  37628. "type": "string",
  37629. "description": "Type of funding or platform through which funding is possible."
  37630. },
  37631. "url": {
  37632. "type": "string",
  37633. "description": "URL to a website with details on funding and a way to fund the package.",
  37634. "format": "uri"
  37635. }
  37636. }
  37637. }
  37638. },
  37639. "source": {
  37640. "$ref": "#/definitions/source"
  37641. },
  37642. "dist": {
  37643. "$ref": "#/definitions/dist"
  37644. },
  37645. "_comment": {
  37646. "type": ["array", "string"],
  37647. "description": "A key to store comments in"
  37648. },
  37649. "require": {
  37650. "type": "object",
  37651. "description": "This is an object of package name (keys) and version constraints (values) that are required to run this package.",
  37652. "additionalProperties": {
  37653. "type": "string"
  37654. }
  37655. },
  37656. "require-dev": {
  37657. "type": "object",
  37658. "description": "This is an object of package name (keys) and version constraints (values) that this package requires for developing it (testing tools and such).",
  37659. "additionalProperties": {
  37660. "type": "string"
  37661. }
  37662. },
  37663. "replace": {
  37664. "type": "object",
  37665. "description": "This is an object of package name (keys) and version constraints (values) that can be replaced by this package.",
  37666. "additionalProperties": {
  37667. "type": "string"
  37668. }
  37669. },
  37670. "conflict": {
  37671. "type": "object",
  37672. "description": "This is an object of package name (keys) and version constraints (values) that conflict with this package.",
  37673. "additionalProperties": {
  37674. "type": "string"
  37675. }
  37676. },
  37677. "provide": {
  37678. "type": "object",
  37679. "description": "This is an object of package name (keys) and version constraints (values) that this package provides in addition to this package's name.",
  37680. "additionalProperties": {
  37681. "type": "string"
  37682. }
  37683. },
  37684. "suggest": {
  37685. "type": "object",
  37686. "description": "This is an object of package name (keys) and descriptions (values) that this package suggests work well with it (this will be suggested to the user during installation).",
  37687. "additionalProperties": {
  37688. "type": "string"
  37689. }
  37690. },
  37691. "repositories": {
  37692. "type": ["object", "array"],
  37693. "description": "A set of additional repositories where packages can be found.",
  37694. "additionalProperties": {
  37695. "anyOf": [
  37696. { "$ref": "#/definitions/repository" },
  37697. { "type": "boolean", "enum": [false] }
  37698. ]
  37699. },
  37700. "items": {
  37701. "anyOf": [
  37702. { "$ref": "#/definitions/repository" },
  37703. {
  37704. "type": "object",
  37705. "additionalProperties": { "type": "boolean", "enum": [false] },
  37706. "minProperties": 1,
  37707. "maxProperties": 1
  37708. }
  37709. ]
  37710. }
  37711. },
  37712. "minimum-stability": {
  37713. "type": ["string"],
  37714. "description": "The minimum stability the packages must have to be install-able. Possible values are: dev, alpha, beta, RC, stable.",
  37715. "enum": ["dev", "alpha", "beta", "rc", "RC", "stable"]
  37716. },
  37717. "prefer-stable": {
  37718. "type": ["boolean"],
  37719. "description": "If set to true, stable packages will be preferred to dev packages when possible, even if the minimum-stability allows unstable packages."
  37720. },
  37721. "autoload": {
  37722. "$ref": "#/definitions/autoload"
  37723. },
  37724. "autoload-dev": {
  37725. "type": "object",
  37726. "description": "Description of additional autoload rules for development purpose (eg. a test suite).",
  37727. "properties": {
  37728. "psr-0": {
  37729. "type": "object",
  37730. "description": "This is an object of namespaces (keys) and the directories they can be found into (values, can be arrays of paths) by the autoloader.",
  37731. "additionalProperties": {
  37732. "type": ["string", "array"],
  37733. "items": {
  37734. "type": "string"
  37735. }
  37736. }
  37737. },
  37738. "psr-4": {
  37739. "type": "object",
  37740. "description": "This is an object of namespaces (keys) and the PSR-4 directories they can map to (values, can be arrays of paths) by the autoloader.",
  37741. "additionalProperties": {
  37742. "type": ["string", "array"],
  37743. "items": {
  37744. "type": "string"
  37745. }
  37746. }
  37747. },
  37748. "classmap": {
  37749. "type": "array",
  37750. "description": "This is an array of paths that contain classes to be included in the class-map generation process."
  37751. },
  37752. "files": {
  37753. "type": "array",
  37754. "description": "This is an array of files that are always required on every request."
  37755. }
  37756. }
  37757. },
  37758. "target-dir": {
  37759. "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.",
  37760. "type": "string"
  37761. },
  37762. "include-path": {
  37763. "type": ["array"],
  37764. "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.",
  37765. "items": {
  37766. "type": "string"
  37767. }
  37768. },
  37769. "bin": {
  37770. "type": ["string", "array"],
  37771. "description": "A set of files, or a single file, that should be treated as binaries and symlinked into bin-dir (from config).",
  37772. "items": {
  37773. "type": "string"
  37774. }
  37775. },
  37776. "archive": {
  37777. "type": ["object"],
  37778. "description": "Options for creating package archives for distribution.",
  37779. "properties": {
  37780. "name": {
  37781. "type": "string",
  37782. "description": "A base name for archive."
  37783. },
  37784. "exclude": {
  37785. "type": "array",
  37786. "description": "A list of patterns for paths to exclude or include if prefixed with an exclamation mark."
  37787. }
  37788. }
  37789. },
  37790. "config": {
  37791. "type": "object",
  37792. "description": "Composer options.",
  37793. "properties": {
  37794. "platform": {
  37795. "type": "object",
  37796. "description": "This is an object of package name (keys) and version (values) that will be used to mock the platform packages on this machine.",
  37797. "additionalProperties": {
  37798. "type": ["string", "boolean"]
  37799. }
  37800. },
  37801. "allow-plugins": {
  37802. "type": ["object", "boolean"],
  37803. "description": "This is an object of {\"pattern\": true|false} with packages which are allowed to be loaded as plugins, or true to allow all, false to allow none. Defaults to {} which prompts when an unknown plugin is added.",
  37804. "additionalProperties": {
  37805. "type": ["boolean"]
  37806. }
  37807. },
  37808. "process-timeout": {
  37809. "type": "integer",
  37810. "description": "The timeout in seconds for process executions, defaults to 300 (5mins)."
  37811. },
  37812. "use-include-path": {
  37813. "type": "boolean",
  37814. "description": "If true, the Composer autoloader will also look for classes in the PHP include path."
  37815. },
  37816. "use-parent-dir": {
  37817. "type": ["string", "boolean"],
  37818. "description": "When running Composer in a directory where there is no composer.json, if there is one present in a directory above Composer will by default ask you whether you want to use that directory's composer.json instead. One of: true (always use parent if needed), false (never ask or use it) or \"prompt\" (ask every time), defaults to prompt."
  37819. },
  37820. "preferred-install": {
  37821. "type": ["string", "object"],
  37822. "description": "The install method Composer will prefer to use, defaults to auto and can be any of source, dist, auto, or an object of {\"pattern\": \"preference\"}.",
  37823. "additionalProperties": {
  37824. "type": ["string"]
  37825. }
  37826. },
  37827. "notify-on-install": {
  37828. "type": "boolean",
  37829. "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."
  37830. },
  37831. "github-protocols": {
  37832. "type": "array",
  37833. "description": "A list of protocols to use for github.com clones, in priority order, defaults to [\"git\", \"https\", \"http\"].",
  37834. "items": {
  37835. "type": "string"
  37836. }
  37837. },
  37838. "github-oauth": {
  37839. "type": "object",
  37840. "description": "An object of domain name => github API oauth tokens, typically {\"github.com\":\"<token>\"}.",
  37841. "additionalProperties": {
  37842. "type": "string"
  37843. }
  37844. },
  37845. "gitlab-oauth": {
  37846. "type": "object",
  37847. "description": "An object of domain name => gitlab API oauth tokens, typically {\"gitlab.com\":\"<token>\"}.",
  37848. "additionalProperties": {
  37849. "type": "string"
  37850. }
  37851. },
  37852. "gitlab-token": {
  37853. "type": "object",
  37854. "description": "An object of domain name => gitlab private tokens, typically {\"gitlab.com\":\"<token>\"}.",
  37855. "additionalProperties": {
  37856. "type": "string"
  37857. }
  37858. },
  37859. "gitlab-protocol": {
  37860. "enum": ["git", "http", "https"],
  37861. "description": "A protocol to force use of when creating a repository URL for the `source` value of the package metadata. One of `git` or `http`. By default, Composer will generate a git URL for private repositories and http one for public repos."
  37862. },
  37863. "bearer": {
  37864. "type": "object",
  37865. "description": "An object of domain name => bearer authentication token, for example {\"example.com\":\"<token>\"}.",
  37866. "additionalProperties": {
  37867. "type": "string"
  37868. }
  37869. },
  37870. "disable-tls": {
  37871. "type": "boolean",
  37872. "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."
  37873. },
  37874. "secure-http": {
  37875. "type": "boolean",
  37876. "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."
  37877. },
  37878. "secure-svn-domains": {
  37879. "type": "array",
  37880. "description": "A list of domains which should be trusted/marked as using a secure Subversion/SVN transport. By default svn:// protocol is seen as insecure and will throw. This is a better/safer alternative to disabling `secure-http` altogether.",
  37881. "items": {
  37882. "type": "string"
  37883. }
  37884. },
  37885. "cafile": {
  37886. "type": "string",
  37887. "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."
  37888. },
  37889. "capath": {
  37890. "type": "string",
  37891. "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."
  37892. },
  37893. "http-basic": {
  37894. "type": "object",
  37895. "description": "An object of domain name => {\"username\": \"...\", \"password\": \"...\"}.",
  37896. "additionalProperties": {
  37897. "type": "object",
  37898. "required": ["username", "password"],
  37899. "properties": {
  37900. "username": {
  37901. "type": "string",
  37902. "description": "The username used for HTTP Basic authentication"
  37903. },
  37904. "password": {
  37905. "type": "string",
  37906. "description": "The password used for HTTP Basic authentication"
  37907. }
  37908. }
  37909. }
  37910. },
  37911. "store-auths": {
  37912. "type": ["string", "boolean"],
  37913. "description": "What to do after prompting for authentication, one of: true (store), false (do not store) or \"prompt\" (ask every time), defaults to prompt."
  37914. },
  37915. "vendor-dir": {
  37916. "type": "string",
  37917. "description": "The location where all packages are installed, defaults to \"vendor\"."
  37918. },
  37919. "bin-dir": {
  37920. "type": "string",
  37921. "description": "The location where all binaries are linked, defaults to \"vendor/bin\"."
  37922. },
  37923. "data-dir": {
  37924. "type": "string",
  37925. "description": "The location where old phar files are stored, defaults to \"$home\" except on XDG Base Directory compliant unixes."
  37926. },
  37927. "cache-dir": {
  37928. "type": "string",
  37929. "description": "The location where all caches are located, defaults to \"~/.composer/cache\" on *nix and \"%LOCALAPPDATA%\\Composer\" on windows."
  37930. },
  37931. "cache-files-dir": {
  37932. "type": "string",
  37933. "description": "The location where files (zip downloads) are cached, defaults to \"{$cache-dir}/files\"."
  37934. },
  37935. "cache-repo-dir": {
  37936. "type": "string",
  37937. "description": "The location where repo (git/hg repo clones) are cached, defaults to \"{$cache-dir}/repo\"."
  37938. },
  37939. "cache-vcs-dir": {
  37940. "type": "string",
  37941. "description": "The location where vcs infos (git clones, github api calls, etc. when reading vcs repos) are cached, defaults to \"{$cache-dir}/vcs\"."
  37942. },
  37943. "cache-ttl": {
  37944. "type": "integer",
  37945. "description": "The default cache time-to-live, defaults to 15552000 (6 months)."
  37946. },
  37947. "cache-files-ttl": {
  37948. "type": "integer",
  37949. "description": "The cache time-to-live for files, defaults to the value of cache-ttl."
  37950. },
  37951. "cache-files-maxsize": {
  37952. "type": ["string", "integer"],
  37953. "description": "The cache max size for the files cache, defaults to \"300MiB\"."
  37954. },
  37955. "cache-read-only": {
  37956. "type": ["boolean"],
  37957. "description": "Whether to use the Composer cache in read-only mode."
  37958. },
  37959. "bin-compat": {
  37960. "enum": ["auto", "full", "proxy", "symlink"],
  37961. "description": "The compatibility of the binaries, defaults to \"auto\" (automatically guessed), can be \"full\" (compatible with both Windows and Unix-based systems) and \"proxy\" (only bash-style proxy)."
  37962. },
  37963. "discard-changes": {
  37964. "type": ["string", "boolean"],
  37965. "description": "The default style of handling dirty updates, defaults to false and can be any of true, false or \"stash\"."
  37966. },
  37967. "autoloader-suffix": {
  37968. "type": "string",
  37969. "description": "Optional string to be used as a suffix for the generated Composer autoloader. When null a random one will be generated."
  37970. },
  37971. "optimize-autoloader": {
  37972. "type": "boolean",
  37973. "description": "Always optimize when dumping the autoloader."
  37974. },
  37975. "prepend-autoloader": {
  37976. "type": "boolean",
  37977. "description": "If false, the composer autoloader will not be prepended to existing autoloaders, defaults to true."
  37978. },
  37979. "classmap-authoritative": {
  37980. "type": "boolean",
  37981. "description": "If true, the composer autoloader will not scan the filesystem for classes that are not found in the class map, defaults to false."
  37982. },
  37983. "apcu-autoloader": {
  37984. "type": "boolean",
  37985. "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."
  37986. },
  37987. "github-domains": {
  37988. "type": "array",
  37989. "description": "A list of domains to use in github mode. This is used for GitHub Enterprise setups, defaults to [\"github.com\"].",
  37990. "items": {
  37991. "type": "string"
  37992. }
  37993. },
  37994. "github-expose-hostname": {
  37995. "type": "boolean",
  37996. "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."
  37997. },
  37998. "gitlab-domains": {
  37999. "type": "array",
  38000. "description": "A list of domains to use in gitlab mode. This is used for custom GitLab setups, defaults to [\"gitlab.com\"].",
  38001. "items": {
  38002. "type": "string"
  38003. }
  38004. },
  38005. "bitbucket-oauth": {
  38006. "type": "object",
  38007. "description": "An object of domain name => {\"consumer-key\": \"...\", \"consumer-secret\": \"...\"}.",
  38008. "additionalProperties": {
  38009. "type": "object",
  38010. "required": ["consumer-key", "consumer-secret"],
  38011. "properties": {
  38012. "consumer-key": {
  38013. "type": "string",
  38014. "description": "The consumer-key used for OAuth authentication"
  38015. },
  38016. "consumer-secret": {
  38017. "type": "string",
  38018. "description": "The consumer-secret used for OAuth authentication"
  38019. }
  38020. }
  38021. }
  38022. },
  38023. "use-github-api": {
  38024. "type": "boolean",
  38025. "description": "Defaults to true. If set to false, globally disables the use of the GitHub API for all GitHub repositories and clones the repository as it would for any other repository."
  38026. },
  38027. "archive-format": {
  38028. "type": "string",
  38029. "description": "The default archiving format when not provided on cli, defaults to \"tar\"."
  38030. },
  38031. "archive-dir": {
  38032. "type": "string",
  38033. "description": "The default archive path when not provided on cli, defaults to \".\"."
  38034. },
  38035. "htaccess-protect": {
  38036. "type": "boolean",
  38037. "description": "Defaults to true. If set to false, Composer will not create .htaccess files in the composer home, cache, and data directories."
  38038. },
  38039. "sort-packages": {
  38040. "type": "boolean",
  38041. "description": "Defaults to false. If set to true, Composer will sort packages when adding/updating a new dependency."
  38042. },
  38043. "lock": {
  38044. "type": "boolean",
  38045. "description": "Defaults to true. If set to false, Composer will not create a composer.lock file."
  38046. },
  38047. "platform-check": {
  38048. "type": ["boolean", "string"],
  38049. "description": "Defaults to \"php-only\" which checks only the PHP version. Setting to true will also check the presence of required PHP extensions. If set to false, Composer will not create and require a platform_check.php file as part of the autoloader bootstrap."
  38050. }
  38051. }
  38052. },
  38053. "extra": {
  38054. "type": ["object", "array"],
  38055. "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.",
  38056. "additionalProperties": true
  38057. },
  38058. "scripts": {
  38059. "type": ["object"],
  38060. "description": "Script listeners that will be executed before/after some events.",
  38061. "properties": {
  38062. "pre-install-cmd": {
  38063. "type": ["array", "string"],
  38064. "description": "Occurs before the install command is executed, contains one or more Class::method callables or shell commands."
  38065. },
  38066. "post-install-cmd": {
  38067. "type": ["array", "string"],
  38068. "description": "Occurs after the install command is executed, contains one or more Class::method callables or shell commands."
  38069. },
  38070. "pre-update-cmd": {
  38071. "type": ["array", "string"],
  38072. "description": "Occurs before the update command is executed, contains one or more Class::method callables or shell commands."
  38073. },
  38074. "post-update-cmd": {
  38075. "type": ["array", "string"],
  38076. "description": "Occurs after the update command is executed, contains one or more Class::method callables or shell commands."
  38077. },
  38078. "pre-status-cmd": {
  38079. "type": ["array", "string"],
  38080. "description": "Occurs before the status command is executed, contains one or more Class::method callables or shell commands."
  38081. },
  38082. "post-status-cmd": {
  38083. "type": ["array", "string"],
  38084. "description": "Occurs after the status command is executed, contains one or more Class::method callables or shell commands."
  38085. },
  38086. "pre-package-install": {
  38087. "type": ["array", "string"],
  38088. "description": "Occurs before a package is installed, contains one or more Class::method callables or shell commands."
  38089. },
  38090. "post-package-install": {
  38091. "type": ["array", "string"],
  38092. "description": "Occurs after a package is installed, contains one or more Class::method callables or shell commands."
  38093. },
  38094. "pre-package-update": {
  38095. "type": ["array", "string"],
  38096. "description": "Occurs before a package is updated, contains one or more Class::method callables or shell commands."
  38097. },
  38098. "post-package-update": {
  38099. "type": ["array", "string"],
  38100. "description": "Occurs after a package is updated, contains one or more Class::method callables or shell commands."
  38101. },
  38102. "pre-package-uninstall": {
  38103. "type": ["array", "string"],
  38104. "description": "Occurs before a package has been uninstalled, contains one or more Class::method callables or shell commands."
  38105. },
  38106. "post-package-uninstall": {
  38107. "type": ["array", "string"],
  38108. "description": "Occurs after a package has been uninstalled, contains one or more Class::method callables or shell commands."
  38109. },
  38110. "pre-autoload-dump": {
  38111. "type": ["array", "string"],
  38112. "description": "Occurs before the autoloader is dumped, contains one or more Class::method callables or shell commands."
  38113. },
  38114. "post-autoload-dump": {
  38115. "type": ["array", "string"],
  38116. "description": "Occurs after the autoloader is dumped, contains one or more Class::method callables or shell commands."
  38117. },
  38118. "post-root-package-install": {
  38119. "type": ["array", "string"],
  38120. "description": "Occurs after the root-package is installed, contains one or more Class::method callables or shell commands."
  38121. },
  38122. "post-create-project-cmd": {
  38123. "type": ["array", "string"],
  38124. "description": "Occurs after the create-project command is executed, contains one or more Class::method callables or shell commands."
  38125. }
  38126. }
  38127. },
  38128. "scripts-descriptions": {
  38129. "type": ["object"],
  38130. "description": "Descriptions for custom commands, shown in console help.",
  38131. "additionalProperties": {
  38132. "type": "string"
  38133. }
  38134. }
  38135. },
  38136. "definitions": {
  38137. "authors": {
  38138. "type": "array",
  38139. "description": "List of authors that contributed to the package. This is typically the main maintainers, not the full list.",
  38140. "items": {
  38141. "type": "object",
  38142. "additionalProperties": false,
  38143. "required": [ "name"],
  38144. "properties": {
  38145. "name": {
  38146. "type": "string",
  38147. "description": "Full name of the author."
  38148. },
  38149. "email": {
  38150. "type": "string",
  38151. "description": "Email address of the author.",
  38152. "format": "email"
  38153. },
  38154. "homepage": {
  38155. "type": "string",
  38156. "description": "Homepage URL for the author.",
  38157. "format": "uri"
  38158. },
  38159. "role": {
  38160. "type": "string",
  38161. "description": "Author's role in the project."
  38162. }
  38163. }
  38164. }
  38165. },
  38166. "autoload": {
  38167. "type": "object",
  38168. "description": "Description of how the package can be autoloaded.",
  38169. "properties": {
  38170. "psr-0": {
  38171. "type": "object",
  38172. "description": "This is an object of namespaces (keys) and the directories they can be found in (values, can be arrays of paths) by the autoloader.",
  38173. "additionalProperties": {
  38174. "type": ["string", "array"],
  38175. "items": {
  38176. "type": "string"
  38177. }
  38178. }
  38179. },
  38180. "psr-4": {
  38181. "type": "object",
  38182. "description": "This is an object of namespaces (keys) and the PSR-4 directories they can map to (values, can be arrays of paths) by the autoloader.",
  38183. "additionalProperties": {
  38184. "type": ["string", "array"],
  38185. "items": {
  38186. "type": "string"
  38187. }
  38188. }
  38189. },
  38190. "classmap": {
  38191. "type": "array",
  38192. "description": "This is an array of paths that contain classes to be included in the class-map generation process."
  38193. },
  38194. "files": {
  38195. "type": "array",
  38196. "description": "This is an array of files that are always required on every request."
  38197. },
  38198. "exclude-from-classmap": {
  38199. "type": "array",
  38200. "description": "This is an array of patterns to exclude from autoload classmap generation. (e.g. \"exclude-from-classmap\": [\"/test/\", \"/tests/\", \"/Tests/\"]"
  38201. }
  38202. }
  38203. },
  38204. "repository": {
  38205. "type": "object",
  38206. "anyOf": [
  38207. { "$ref": "#/definitions/composer-repository" },
  38208. { "$ref": "#/definitions/vcs-repository" },
  38209. { "$ref": "#/definitions/path-repository" },
  38210. { "$ref": "#/definitions/artifact-repository" },
  38211. { "$ref": "#/definitions/pear-repository" },
  38212. { "$ref": "#/definitions/package-repository" }
  38213. ]
  38214. },
  38215. "composer-repository": {
  38216. "type": "object",
  38217. "required": ["type", "url"],
  38218. "properties": {
  38219. "type": { "type": "string", "enum": ["composer"] },
  38220. "url": { "type": "string" },
  38221. "canonical": { "type": "boolean" },
  38222. "only": {
  38223. "type": "array",
  38224. "items": {
  38225. "type": "string"
  38226. }
  38227. },
  38228. "exclude": {
  38229. "type": "array",
  38230. "items": {
  38231. "type": "string"
  38232. }
  38233. },
  38234. "options": {
  38235. "type": "object",
  38236. "additionalProperties": true
  38237. },
  38238. "allow_ssl_downgrade": { "type": "boolean" },
  38239. "force-lazy-providers": { "type": "boolean" }
  38240. }
  38241. },
  38242. "vcs-repository": {
  38243. "type": "object",
  38244. "required": ["type", "url"],
  38245. "properties": {
  38246. "type": { "type": "string", "enum": ["vcs", "github", "git", "gitlab", "bitbucket", "git-bitbucket", "hg", "fossil", "perforce", "svn"] },
  38247. "url": { "type": "string" },
  38248. "canonical": { "type": "boolean" },
  38249. "only": {
  38250. "type": "array",
  38251. "items": {
  38252. "type": "string"
  38253. }
  38254. },
  38255. "exclude": {
  38256. "type": "array",
  38257. "items": {
  38258. "type": "string"
  38259. }
  38260. },
  38261. "no-api": { "type": "boolean" },
  38262. "secure-http": { "type": "boolean" },
  38263. "svn-cache-credentials": { "type": "boolean" },
  38264. "trunk-path": { "type": ["string", "boolean"] },
  38265. "branches-path": { "type": ["string", "boolean"] },
  38266. "tags-path": { "type": ["string", "boolean"] },
  38267. "package-path": { "type": "string" },
  38268. "depot": { "type": "string" },
  38269. "branch": { "type": "string" },
  38270. "unique_perforce_client_name": { "type": "string" },
  38271. "p4user": { "type": "string" },
  38272. "p4password": { "type": "string" }
  38273. }
  38274. },
  38275. "path-repository": {
  38276. "type": "object",
  38277. "required": ["type", "url"],
  38278. "properties": {
  38279. "type": { "type": "string", "enum": ["path"] },
  38280. "url": { "type": "string" },
  38281. "canonical": { "type": "boolean" },
  38282. "only": {
  38283. "type": "array",
  38284. "items": {
  38285. "type": "string"
  38286. }
  38287. },
  38288. "exclude": {
  38289. "type": "array",
  38290. "items": {
  38291. "type": "string"
  38292. }
  38293. },
  38294. "options": {
  38295. "type": "object",
  38296. "properties": {
  38297. "symlink": { "type": ["boolean", "null"] }
  38298. },
  38299. "additionalProperties": true
  38300. }
  38301. }
  38302. },
  38303. "artifact-repository": {
  38304. "type": "object",
  38305. "required": ["type", "url"],
  38306. "properties": {
  38307. "type": { "type": "string", "enum": ["artifact"] },
  38308. "url": { "type": "string" },
  38309. "canonical": { "type": "boolean" },
  38310. "only": {
  38311. "type": "array",
  38312. "items": {
  38313. "type": "string"
  38314. }
  38315. },
  38316. "exclude": {
  38317. "type": "array",
  38318. "items": {
  38319. "type": "string"
  38320. }
  38321. }
  38322. }
  38323. },
  38324. "pear-repository": {
  38325. "type": "object",
  38326. "required": ["type", "url"],
  38327. "properties": {
  38328. "type": { "type": "string", "enum": ["pear"] },
  38329. "url": { "type": "string" },
  38330. "canonical": { "type": "boolean" },
  38331. "only": {
  38332. "type": "array",
  38333. "items": {
  38334. "type": "string"
  38335. }
  38336. },
  38337. "exclude": {
  38338. "type": "array",
  38339. "items": {
  38340. "type": "string"
  38341. }
  38342. },
  38343. "vendor-alias": { "type": "string" }
  38344. }
  38345. },
  38346. "package-repository": {
  38347. "type": "object",
  38348. "required": ["type", "package"],
  38349. "properties": {
  38350. "type": { "type": "string", "enum": ["package"] },
  38351. "canonical": { "type": "boolean" },
  38352. "only": {
  38353. "type": "array",
  38354. "items": {
  38355. "type": "string"
  38356. }
  38357. },
  38358. "exclude": {
  38359. "type": "array",
  38360. "items": {
  38361. "type": "string"
  38362. }
  38363. },
  38364. "package": {
  38365. "oneOf": [
  38366. { "$ref": "#/definitions/inline-package" },
  38367. {
  38368. "type": "array",
  38369. "items": { "$ref": "#/definitions/inline-package" }
  38370. }
  38371. ]
  38372. }
  38373. }
  38374. },
  38375. "inline-package": {
  38376. "type": "object",
  38377. "required": ["name", "version"],
  38378. "properties": {
  38379. "name": {
  38380. "type": "string",
  38381. "description": "Package name, including 'vendor-name/' prefix."
  38382. },
  38383. "type": {
  38384. "type": "string"
  38385. },
  38386. "target-dir": {
  38387. "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.",
  38388. "type": "string"
  38389. },
  38390. "description": {
  38391. "type": "string"
  38392. },
  38393. "keywords": {
  38394. "type": "array",
  38395. "items": {
  38396. "type": "string"
  38397. }
  38398. },
  38399. "homepage": {
  38400. "type": "string",
  38401. "format": "uri"
  38402. },
  38403. "version": {
  38404. "type": "string"
  38405. },
  38406. "time": {
  38407. "type": "string"
  38408. },
  38409. "license": {
  38410. "type": [
  38411. "string",
  38412. "array"
  38413. ]
  38414. },
  38415. "authors": {
  38416. "$ref": "#/definitions/authors"
  38417. },
  38418. "require": {
  38419. "type": "object",
  38420. "additionalProperties": {
  38421. "type": "string"
  38422. }
  38423. },
  38424. "replace": {
  38425. "type": "object",
  38426. "additionalProperties": {
  38427. "type": "string"
  38428. }
  38429. },
  38430. "conflict": {
  38431. "type": "object",
  38432. "additionalProperties": {
  38433. "type": "string"
  38434. }
  38435. },
  38436. "provide": {
  38437. "type": "object",
  38438. "additionalProperties": {
  38439. "type": "string"
  38440. }
  38441. },
  38442. "require-dev": {
  38443. "type": "object",
  38444. "additionalProperties": {
  38445. "type": "string"
  38446. }
  38447. },
  38448. "suggest": {
  38449. "type": "object",
  38450. "additionalProperties": {
  38451. "type": "string"
  38452. }
  38453. },
  38454. "extra": {
  38455. "type": ["object", "array"],
  38456. "additionalProperties": true
  38457. },
  38458. "autoload": {
  38459. "$ref": "#/definitions/autoload"
  38460. },
  38461. "archive": {
  38462. "type": ["object"],
  38463. "properties": {
  38464. "exclude": {
  38465. "type": "array"
  38466. }
  38467. }
  38468. },
  38469. "bin": {
  38470. "type": ["string", "array"],
  38471. "description": "A set of files, or a single file, that should be treated as binaries and symlinked into bin-dir (from config).",
  38472. "items": {
  38473. "type": "string"
  38474. }
  38475. },
  38476. "include-path": {
  38477. "type": ["array"],
  38478. "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.",
  38479. "items": {
  38480. "type": "string"
  38481. }
  38482. },
  38483. "source": {
  38484. "$ref": "#/definitions/source"
  38485. },
  38486. "dist": {
  38487. "$ref": "#/definitions/dist"
  38488. }
  38489. },
  38490. "additionalProperties": true
  38491. },
  38492. "source": {
  38493. "type": "object",
  38494. "required": ["type", "url", "reference"],
  38495. "properties": {
  38496. "type": {
  38497. "type": "string"
  38498. },
  38499. "url": {
  38500. "type": "string"
  38501. },
  38502. "reference": {
  38503. "type": "string"
  38504. },
  38505. "mirrors": {
  38506. "type": "array"
  38507. }
  38508. }
  38509. },
  38510. "dist": {
  38511. "type": "object",
  38512. "required": ["type", "url"],
  38513. "properties": {
  38514. "type": {
  38515. "type": "string"
  38516. },
  38517. "url": {
  38518. "type": "string"
  38519. },
  38520. "reference": {
  38521. "type": "string"
  38522. },
  38523. "shasum": {
  38524. "type": "string"
  38525. },
  38526. "mirrors": {
  38527. "type": "array"
  38528. }
  38529. }
  38530. }
  38531. }
  38532. }
  38533. <?php
  38534. if (PHP_VERSION_ID < 50600) {
  38535. echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
  38536. exit(1);
  38537. }
  38538. require_once __DIR__ . '/composer/autoload_real.php';
  38539. return ComposerAutoloaderInitComposerPhar1649860980::getLoader();
  38540. <?php
  38541. namespace Composer\Autoload;
  38542. class ClassLoader
  38543. {
  38544. private $vendorDir;
  38545. private $prefixLengthsPsr4 = array();
  38546. private $prefixDirsPsr4 = array();
  38547. private $fallbackDirsPsr4 = array();
  38548. private $prefixesPsr0 = array();
  38549. private $fallbackDirsPsr0 = array();
  38550. private $useIncludePath = false;
  38551. private $classMap = array();
  38552. private $classMapAuthoritative = false;
  38553. private $missingClasses = array();
  38554. private $apcuPrefix;
  38555. private static $registeredLoaders = array();
  38556. public function __construct($vendorDir = null)
  38557. {
  38558. $this->vendorDir = $vendorDir;
  38559. }
  38560. public function getPrefixes()
  38561. {
  38562. if (!empty($this->prefixesPsr0)) {
  38563. return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
  38564. }
  38565. return array();
  38566. }
  38567. public function getPrefixesPsr4()
  38568. {
  38569. return $this->prefixDirsPsr4;
  38570. }
  38571. public function getFallbackDirs()
  38572. {
  38573. return $this->fallbackDirsPsr0;
  38574. }
  38575. public function getFallbackDirsPsr4()
  38576. {
  38577. return $this->fallbackDirsPsr4;
  38578. }
  38579. public function getClassMap()
  38580. {
  38581. return $this->classMap;
  38582. }
  38583. public function addClassMap(array $classMap)
  38584. {
  38585. if ($this->classMap) {
  38586. $this->classMap = array_merge($this->classMap, $classMap);
  38587. } else {
  38588. $this->classMap = $classMap;
  38589. }
  38590. }
  38591. public function add($prefix, $paths, $prepend = false)
  38592. {
  38593. if (!$prefix) {
  38594. if ($prepend) {
  38595. $this->fallbackDirsPsr0 = array_merge(
  38596. (array) $paths,
  38597. $this->fallbackDirsPsr0
  38598. );
  38599. } else {
  38600. $this->fallbackDirsPsr0 = array_merge(
  38601. $this->fallbackDirsPsr0,
  38602. (array) $paths
  38603. );
  38604. }
  38605. return;
  38606. }
  38607. $first = $prefix[0];
  38608. if (!isset($this->prefixesPsr0[$first][$prefix])) {
  38609. $this->prefixesPsr0[$first][$prefix] = (array) $paths;
  38610. return;
  38611. }
  38612. if ($prepend) {
  38613. $this->prefixesPsr0[$first][$prefix] = array_merge(
  38614. (array) $paths,
  38615. $this->prefixesPsr0[$first][$prefix]
  38616. );
  38617. } else {
  38618. $this->prefixesPsr0[$first][$prefix] = array_merge(
  38619. $this->prefixesPsr0[$first][$prefix],
  38620. (array) $paths
  38621. );
  38622. }
  38623. }
  38624. public function addPsr4($prefix, $paths, $prepend = false)
  38625. {
  38626. if (!$prefix) {
  38627. if ($prepend) {
  38628. $this->fallbackDirsPsr4 = array_merge(
  38629. (array) $paths,
  38630. $this->fallbackDirsPsr4
  38631. );
  38632. } else {
  38633. $this->fallbackDirsPsr4 = array_merge(
  38634. $this->fallbackDirsPsr4,
  38635. (array) $paths
  38636. );
  38637. }
  38638. } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
  38639. $length = strlen($prefix);
  38640. if ('\\' !== $prefix[$length - 1]) {
  38641. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  38642. }
  38643. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  38644. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  38645. } elseif ($prepend) {
  38646. $this->prefixDirsPsr4[$prefix] = array_merge(
  38647. (array) $paths,
  38648. $this->prefixDirsPsr4[$prefix]
  38649. );
  38650. } else {
  38651. $this->prefixDirsPsr4[$prefix] = array_merge(
  38652. $this->prefixDirsPsr4[$prefix],
  38653. (array) $paths
  38654. );
  38655. }
  38656. }
  38657. public function set($prefix, $paths)
  38658. {
  38659. if (!$prefix) {
  38660. $this->fallbackDirsPsr0 = (array) $paths;
  38661. } else {
  38662. $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
  38663. }
  38664. }
  38665. public function setPsr4($prefix, $paths)
  38666. {
  38667. if (!$prefix) {
  38668. $this->fallbackDirsPsr4 = (array) $paths;
  38669. } else {
  38670. $length = strlen($prefix);
  38671. if ('\\' !== $prefix[$length - 1]) {
  38672. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  38673. }
  38674. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  38675. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  38676. }
  38677. }
  38678. public function setUseIncludePath($useIncludePath)
  38679. {
  38680. $this->useIncludePath = $useIncludePath;
  38681. }
  38682. public function getUseIncludePath()
  38683. {
  38684. return $this->useIncludePath;
  38685. }
  38686. public function setClassMapAuthoritative($classMapAuthoritative)
  38687. {
  38688. $this->classMapAuthoritative = $classMapAuthoritative;
  38689. }
  38690. public function isClassMapAuthoritative()
  38691. {
  38692. return $this->classMapAuthoritative;
  38693. }
  38694. public function setApcuPrefix($apcuPrefix)
  38695. {
  38696. $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
  38697. }
  38698. public function getApcuPrefix()
  38699. {
  38700. return $this->apcuPrefix;
  38701. }
  38702. public function register($prepend = false)
  38703. {
  38704. spl_autoload_register(array($this, 'loadClass'), true, $prepend);
  38705. if (null === $this->vendorDir) {
  38706. return;
  38707. }
  38708. if ($prepend) {
  38709. self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
  38710. } else {
  38711. unset(self::$registeredLoaders[$this->vendorDir]);
  38712. self::$registeredLoaders[$this->vendorDir] = $this;
  38713. }
  38714. }
  38715. public function unregister()
  38716. {
  38717. spl_autoload_unregister(array($this, 'loadClass'));
  38718. if (null !== $this->vendorDir) {
  38719. unset(self::$registeredLoaders[$this->vendorDir]);
  38720. }
  38721. }
  38722. public function loadClass($class)
  38723. {
  38724. if ($file = $this->findFile($class)) {
  38725. includeFile($file);
  38726. return true;
  38727. }
  38728. return null;
  38729. }
  38730. public function findFile($class)
  38731. {
  38732. if (isset($this->classMap[$class])) {
  38733. return $this->classMap[$class];
  38734. }
  38735. if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
  38736. return false;
  38737. }
  38738. if (null !== $this->apcuPrefix) {
  38739. $file = apcu_fetch($this->apcuPrefix.$class, $hit);
  38740. if ($hit) {
  38741. return $file;
  38742. }
  38743. }
  38744. $file = $this->findFileWithExtension($class, '.php');
  38745. if (false === $file && defined('HHVM_VERSION')) {
  38746. $file = $this->findFileWithExtension($class, '.hh');
  38747. }
  38748. if (null !== $this->apcuPrefix) {
  38749. apcu_add($this->apcuPrefix.$class, $file);
  38750. }
  38751. if (false === $file) {
  38752. $this->missingClasses[$class] = true;
  38753. }
  38754. return $file;
  38755. }
  38756. public static function getRegisteredLoaders()
  38757. {
  38758. return self::$registeredLoaders;
  38759. }
  38760. private function findFileWithExtension($class, $ext)
  38761. {
  38762. $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
  38763. $first = $class[0];
  38764. if (isset($this->prefixLengthsPsr4[$first])) {
  38765. $subPath = $class;
  38766. while (false !== $lastPos = strrpos($subPath, '\\')) {
  38767. $subPath = substr($subPath, 0, $lastPos);
  38768. $search = $subPath . '\\';
  38769. if (isset($this->prefixDirsPsr4[$search])) {
  38770. $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
  38771. foreach ($this->prefixDirsPsr4[$search] as $dir) {
  38772. if (file_exists($file = $dir . $pathEnd)) {
  38773. return $file;
  38774. }
  38775. }
  38776. }
  38777. }
  38778. }
  38779. foreach ($this->fallbackDirsPsr4 as $dir) {
  38780. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
  38781. return $file;
  38782. }
  38783. }
  38784. if (false !== $pos = strrpos($class, '\\')) {
  38785. $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
  38786. . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
  38787. } else {
  38788. $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
  38789. }
  38790. if (isset($this->prefixesPsr0[$first])) {
  38791. foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
  38792. if (0 === strpos($class, $prefix)) {
  38793. foreach ($dirs as $dir) {
  38794. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  38795. return $file;
  38796. }
  38797. }
  38798. }
  38799. }
  38800. }
  38801. foreach ($this->fallbackDirsPsr0 as $dir) {
  38802. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  38803. return $file;
  38804. }
  38805. }
  38806. if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
  38807. return $file;
  38808. }
  38809. return false;
  38810. }
  38811. }
  38812. function includeFile($file)
  38813. {
  38814. include $file;
  38815. }
  38816. <?php
  38817. namespace Composer;
  38818. use Composer\Autoload\ClassLoader;
  38819. use Composer\Semver\VersionParser;
  38820. class InstalledVersions
  38821. {
  38822. private static $installed;
  38823. private static $canGetVendors;
  38824. private static $installedByVendor = array();
  38825. public static function getInstalledPackages()
  38826. {
  38827. $packages = array();
  38828. foreach (self::getInstalled() as $installed) {
  38829. $packages[] = array_keys($installed['versions']);
  38830. }
  38831. if (1 === \count($packages)) {
  38832. return $packages[0];
  38833. }
  38834. return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
  38835. }
  38836. public static function getInstalledPackagesByType($type)
  38837. {
  38838. $packagesByType = array();
  38839. foreach (self::getInstalled() as $installed) {
  38840. foreach ($installed['versions'] as $name => $package) {
  38841. if (isset($package['type']) && $package['type'] === $type) {
  38842. $packagesByType[] = $name;
  38843. }
  38844. }
  38845. }
  38846. return $packagesByType;
  38847. }
  38848. public static function isInstalled($packageName, $includeDevRequirements = true)
  38849. {
  38850. foreach (self::getInstalled() as $installed) {
  38851. if (isset($installed['versions'][$packageName])) {
  38852. return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
  38853. }
  38854. }
  38855. return false;
  38856. }
  38857. public static function satisfies(VersionParser $parser, $packageName, $constraint)
  38858. {
  38859. $constraint = $parser->parseConstraints($constraint);
  38860. $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
  38861. return $provided->matches($constraint);
  38862. }
  38863. public static function getVersionRanges($packageName)
  38864. {
  38865. foreach (self::getInstalled() as $installed) {
  38866. if (!isset($installed['versions'][$packageName])) {
  38867. continue;
  38868. }
  38869. $ranges = array();
  38870. if (isset($installed['versions'][$packageName]['pretty_version'])) {
  38871. $ranges[] = $installed['versions'][$packageName]['pretty_version'];
  38872. }
  38873. if (array_key_exists('aliases', $installed['versions'][$packageName])) {
  38874. $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
  38875. }
  38876. if (array_key_exists('replaced', $installed['versions'][$packageName])) {
  38877. $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
  38878. }
  38879. if (array_key_exists('provided', $installed['versions'][$packageName])) {
  38880. $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
  38881. }
  38882. return implode(' || ', $ranges);
  38883. }
  38884. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  38885. }
  38886. public static function getVersion($packageName)
  38887. {
  38888. foreach (self::getInstalled() as $installed) {
  38889. if (!isset($installed['versions'][$packageName])) {
  38890. continue;
  38891. }
  38892. if (!isset($installed['versions'][$packageName]['version'])) {
  38893. return null;
  38894. }
  38895. return $installed['versions'][$packageName]['version'];
  38896. }
  38897. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  38898. }
  38899. public static function getPrettyVersion($packageName)
  38900. {
  38901. foreach (self::getInstalled() as $installed) {
  38902. if (!isset($installed['versions'][$packageName])) {
  38903. continue;
  38904. }
  38905. if (!isset($installed['versions'][$packageName]['pretty_version'])) {
  38906. return null;
  38907. }
  38908. return $installed['versions'][$packageName]['pretty_version'];
  38909. }
  38910. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  38911. }
  38912. public static function getReference($packageName)
  38913. {
  38914. foreach (self::getInstalled() as $installed) {
  38915. if (!isset($installed['versions'][$packageName])) {
  38916. continue;
  38917. }
  38918. if (!isset($installed['versions'][$packageName]['reference'])) {
  38919. return null;
  38920. }
  38921. return $installed['versions'][$packageName]['reference'];
  38922. }
  38923. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  38924. }
  38925. public static function getInstallPath($packageName)
  38926. {
  38927. foreach (self::getInstalled() as $installed) {
  38928. if (!isset($installed['versions'][$packageName])) {
  38929. continue;
  38930. }
  38931. return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
  38932. }
  38933. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  38934. }
  38935. public static function getRootPackage()
  38936. {
  38937. $installed = self::getInstalled();
  38938. return $installed[0]['root'];
  38939. }
  38940. public static function getRawData()
  38941. {
  38942. @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
  38943. if (null === self::$installed) {
  38944. if (substr(__DIR__, -8, 1) !== 'C') {
  38945. self::$installed = include __DIR__ . '/installed.php';
  38946. } else {
  38947. self::$installed = array();
  38948. }
  38949. }
  38950. return self::$installed;
  38951. }
  38952. public static function getAllRawData()
  38953. {
  38954. return self::getInstalled();
  38955. }
  38956. public static function reload($data)
  38957. {
  38958. self::$installed = $data;
  38959. self::$installedByVendor = array();
  38960. }
  38961. private static function getInstalled()
  38962. {
  38963. if (null === self::$canGetVendors) {
  38964. self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
  38965. }
  38966. $installed = array();
  38967. if (self::$canGetVendors) {
  38968. foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
  38969. if (isset(self::$installedByVendor[$vendorDir])) {
  38970. $installed[] = self::$installedByVendor[$vendorDir];
  38971. } elseif (is_file($vendorDir.'/composer/installed.php')) {
  38972. $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
  38973. if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
  38974. self::$installed = $installed[count($installed) - 1];
  38975. }
  38976. }
  38977. }
  38978. }
  38979. if (null === self::$installed) {
  38980. if (substr(__DIR__, -8, 1) !== 'C') {
  38981. self::$installed = require __DIR__ . '/installed.php';
  38982. } else {
  38983. self::$installed = array();
  38984. }
  38985. }
  38986. $installed[] = self::$installed;
  38987. return $installed;
  38988. }
  38989. }
  38990. <?php
  38991. $vendorDir = dirname(__DIR__);
  38992. $baseDir = dirname($vendorDir);
  38993. return array(
  38994. 'Attribute' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
  38995. 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
  38996. 'JsonException' => $vendorDir . '/symfony/polyfill-php73/Resources/stubs/JsonException.php',
  38997. 'Normalizer' => $vendorDir . '/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php',
  38998. 'PhpToken' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php',
  38999. 'Stringable' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Stringable.php',
  39000. 'UnhandledMatchError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php',
  39001. 'ValueError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/ValueError.php',
  39002. );
  39003. <?php
  39004. $vendorDir = dirname(__DIR__);
  39005. $baseDir = dirname($vendorDir);
  39006. return array(
  39007. 'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php',
  39008. '6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php',
  39009. '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
  39010. '320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
  39011. '8825ede83f2f289127722d4e842cf7e8' => $vendorDir . '/symfony/polyfill-intl-grapheme/bootstrap.php',
  39012. 'e69f7f6ee287b969198c3c9d6777bd38' => $vendorDir . '/symfony/polyfill-intl-normalizer/bootstrap.php',
  39013. '0d59ee240a4cd96ddbb4ff164fccea4d' => $vendorDir . '/symfony/polyfill-php73/bootstrap.php',
  39014. 'b6b991a57620e2fb6b2f66f03fe9ddc2' => $vendorDir . '/symfony/string/Resources/functions.php',
  39015. 'ad155f8f1cf0d418fe49e248db8c661b' => $vendorDir . '/react/promise/src/functions_include.php',
  39016. );
  39017. <?php
  39018. $vendorDir = dirname(__DIR__);
  39019. $baseDir = dirname($vendorDir);
  39020. return array(
  39021. );
  39022. <?php
  39023. $vendorDir = dirname(__DIR__);
  39024. $baseDir = dirname($vendorDir);
  39025. return array(
  39026. 'Symfony\\Polyfill\\Php80\\' => array($vendorDir . '/symfony/polyfill-php80'),
  39027. 'Symfony\\Polyfill\\Php73\\' => array($vendorDir . '/symfony/polyfill-php73'),
  39028. 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
  39029. 'Symfony\\Polyfill\\Intl\\Normalizer\\' => array($vendorDir . '/symfony/polyfill-intl-normalizer'),
  39030. 'Symfony\\Polyfill\\Intl\\Grapheme\\' => array($vendorDir . '/symfony/polyfill-intl-grapheme'),
  39031. 'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
  39032. 'Symfony\\Contracts\\Service\\' => array($vendorDir . '/symfony/service-contracts'),
  39033. 'Symfony\\Component\\String\\' => array($vendorDir . '/symfony/string'),
  39034. 'Symfony\\Component\\Process\\' => array($vendorDir . '/symfony/process'),
  39035. 'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'),
  39036. 'Symfony\\Component\\Filesystem\\' => array($vendorDir . '/symfony/filesystem'),
  39037. 'Symfony\\Component\\Console\\' => array($vendorDir . '/symfony/console'),
  39038. 'Seld\\PharUtils\\' => array($vendorDir . '/seld/phar-utils/src'),
  39039. 'Seld\\JsonLint\\' => array($vendorDir . '/seld/jsonlint/src/Seld/JsonLint'),
  39040. 'React\\Promise\\' => array($vendorDir . '/react/promise/src'),
  39041. 'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
  39042. 'Psr\\Container\\' => array($vendorDir . '/psr/container/src'),
  39043. 'JsonSchema\\' => array($vendorDir . '/justinrainbow/json-schema/src/JsonSchema'),
  39044. 'Composer\\XdebugHandler\\' => array($vendorDir . '/composer/xdebug-handler/src'),
  39045. 'Composer\\Spdx\\' => array($vendorDir . '/composer/spdx-licenses/src'),
  39046. 'Composer\\Semver\\' => array($vendorDir . '/composer/semver/src'),
  39047. 'Composer\\Pcre\\' => array($vendorDir . '/composer/pcre/src'),
  39048. 'Composer\\MetadataMinifier\\' => array($vendorDir . '/composer/metadata-minifier/src'),
  39049. 'Composer\\CaBundle\\' => array($vendorDir . '/composer/ca-bundle/src'),
  39050. 'Composer\\' => array($baseDir . '/src/Composer'),
  39051. );
  39052. <?php
  39053. class ComposerAutoloaderInitComposerPhar1649860980
  39054. {
  39055. private static $loader;
  39056. public static function loadClassLoader($class)
  39057. {
  39058. if ('Composer\Autoload\ClassLoader' === $class) {
  39059. require __DIR__ . '/ClassLoader.php';
  39060. }
  39061. }
  39062. public static function getLoader()
  39063. {
  39064. if (null !== self::$loader) {
  39065. return self::$loader;
  39066. }
  39067. spl_autoload_register(array('ComposerAutoloaderInitComposerPhar1649860980', 'loadClassLoader'), true, true);
  39068. self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
  39069. spl_autoload_unregister(array('ComposerAutoloaderInitComposerPhar1649860980', 'loadClassLoader'));
  39070. require __DIR__ . '/autoload_static.php';
  39071. call_user_func(\Composer\Autoload\ComposerStaticInitComposerPhar1649860980::getInitializer($loader));
  39072. $loader->register(true);
  39073. $includeFiles = \Composer\Autoload\ComposerStaticInitComposerPhar1649860980::$files;
  39074. foreach ($includeFiles as $fileIdentifier => $file) {
  39075. composerRequireComposerPhar1649860980($fileIdentifier, $file);
  39076. }
  39077. return $loader;
  39078. }
  39079. }
  39080. function composerRequireComposerPhar1649860980($fileIdentifier, $file)
  39081. {
  39082. if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  39083. $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
  39084. require $file;
  39085. }
  39086. }
  39087. <?php
  39088. namespace Composer\Autoload;
  39089. class ComposerStaticInitComposerPhar1649860980
  39090. {
  39091. public static $files = array (
  39092. 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
  39093. '6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php',
  39094. '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
  39095. '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
  39096. '8825ede83f2f289127722d4e842cf7e8' => __DIR__ . '/..' . '/symfony/polyfill-intl-grapheme/bootstrap.php',
  39097. 'e69f7f6ee287b969198c3c9d6777bd38' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/bootstrap.php',
  39098. '0d59ee240a4cd96ddbb4ff164fccea4d' => __DIR__ . '/..' . '/symfony/polyfill-php73/bootstrap.php',
  39099. 'b6b991a57620e2fb6b2f66f03fe9ddc2' => __DIR__ . '/..' . '/symfony/string/Resources/functions.php',
  39100. 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
  39101. );
  39102. public static $prefixLengthsPsr4 = array (
  39103. 'S' =>
  39104. array (
  39105. 'Symfony\\Polyfill\\Php80\\' => 23,
  39106. 'Symfony\\Polyfill\\Php73\\' => 23,
  39107. 'Symfony\\Polyfill\\Mbstring\\' => 26,
  39108. 'Symfony\\Polyfill\\Intl\\Normalizer\\' => 33,
  39109. 'Symfony\\Polyfill\\Intl\\Grapheme\\' => 31,
  39110. 'Symfony\\Polyfill\\Ctype\\' => 23,
  39111. 'Symfony\\Contracts\\Service\\' => 26,
  39112. 'Symfony\\Component\\String\\' => 25,
  39113. 'Symfony\\Component\\Process\\' => 26,
  39114. 'Symfony\\Component\\Finder\\' => 25,
  39115. 'Symfony\\Component\\Filesystem\\' => 29,
  39116. 'Symfony\\Component\\Console\\' => 26,
  39117. 'Seld\\PharUtils\\' => 15,
  39118. 'Seld\\JsonLint\\' => 14,
  39119. ),
  39120. 'R' =>
  39121. array (
  39122. 'React\\Promise\\' => 14,
  39123. ),
  39124. 'P' =>
  39125. array (
  39126. 'Psr\\Log\\' => 8,
  39127. 'Psr\\Container\\' => 14,
  39128. ),
  39129. 'J' =>
  39130. array (
  39131. 'JsonSchema\\' => 11,
  39132. ),
  39133. 'C' =>
  39134. array (
  39135. 'Composer\\XdebugHandler\\' => 23,
  39136. 'Composer\\Spdx\\' => 14,
  39137. 'Composer\\Semver\\' => 16,
  39138. 'Composer\\Pcre\\' => 14,
  39139. 'Composer\\MetadataMinifier\\' => 26,
  39140. 'Composer\\CaBundle\\' => 18,
  39141. 'Composer\\' => 9,
  39142. ),
  39143. );
  39144. public static $prefixDirsPsr4 = array (
  39145. 'Symfony\\Polyfill\\Php80\\' =>
  39146. array (
  39147. 0 => __DIR__ . '/..' . '/symfony/polyfill-php80',
  39148. ),
  39149. 'Symfony\\Polyfill\\Php73\\' =>
  39150. array (
  39151. 0 => __DIR__ . '/..' . '/symfony/polyfill-php73',
  39152. ),
  39153. 'Symfony\\Polyfill\\Mbstring\\' =>
  39154. array (
  39155. 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
  39156. ),
  39157. 'Symfony\\Polyfill\\Intl\\Normalizer\\' =>
  39158. array (
  39159. 0 => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer',
  39160. ),
  39161. 'Symfony\\Polyfill\\Intl\\Grapheme\\' =>
  39162. array (
  39163. 0 => __DIR__ . '/..' . '/symfony/polyfill-intl-grapheme',
  39164. ),
  39165. 'Symfony\\Polyfill\\Ctype\\' =>
  39166. array (
  39167. 0 => __DIR__ . '/..' . '/symfony/polyfill-ctype',
  39168. ),
  39169. 'Symfony\\Contracts\\Service\\' =>
  39170. array (
  39171. 0 => __DIR__ . '/..' . '/symfony/service-contracts',
  39172. ),
  39173. 'Symfony\\Component\\String\\' =>
  39174. array (
  39175. 0 => __DIR__ . '/..' . '/symfony/string',
  39176. ),
  39177. 'Symfony\\Component\\Process\\' =>
  39178. array (
  39179. 0 => __DIR__ . '/..' . '/symfony/process',
  39180. ),
  39181. 'Symfony\\Component\\Finder\\' =>
  39182. array (
  39183. 0 => __DIR__ . '/..' . '/symfony/finder',
  39184. ),
  39185. 'Symfony\\Component\\Filesystem\\' =>
  39186. array (
  39187. 0 => __DIR__ . '/..' . '/symfony/filesystem',
  39188. ),
  39189. 'Symfony\\Component\\Console\\' =>
  39190. array (
  39191. 0 => __DIR__ . '/..' . '/symfony/console',
  39192. ),
  39193. 'Seld\\PharUtils\\' =>
  39194. array (
  39195. 0 => __DIR__ . '/..' . '/seld/phar-utils/src',
  39196. ),
  39197. 'Seld\\JsonLint\\' =>
  39198. array (
  39199. 0 => __DIR__ . '/..' . '/seld/jsonlint/src/Seld/JsonLint',
  39200. ),
  39201. 'React\\Promise\\' =>
  39202. array (
  39203. 0 => __DIR__ . '/..' . '/react/promise/src',
  39204. ),
  39205. 'Psr\\Log\\' =>
  39206. array (
  39207. 0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
  39208. ),
  39209. 'Psr\\Container\\' =>
  39210. array (
  39211. 0 => __DIR__ . '/..' . '/psr/container/src',
  39212. ),
  39213. 'JsonSchema\\' =>
  39214. array (
  39215. 0 => __DIR__ . '/..' . '/justinrainbow/json-schema/src/JsonSchema',
  39216. ),
  39217. 'Composer\\XdebugHandler\\' =>
  39218. array (
  39219. 0 => __DIR__ . '/..' . '/composer/xdebug-handler/src',
  39220. ),
  39221. 'Composer\\Spdx\\' =>
  39222. array (
  39223. 0 => __DIR__ . '/..' . '/composer/spdx-licenses/src',
  39224. ),
  39225. 'Composer\\Semver\\' =>
  39226. array (
  39227. 0 => __DIR__ . '/..' . '/composer/semver/src',
  39228. ),
  39229. 'Composer\\Pcre\\' =>
  39230. array (
  39231. 0 => __DIR__ . '/..' . '/composer/pcre/src',
  39232. ),
  39233. 'Composer\\MetadataMinifier\\' =>
  39234. array (
  39235. 0 => __DIR__ . '/..' . '/composer/metadata-minifier/src',
  39236. ),
  39237. 'Composer\\CaBundle\\' =>
  39238. array (
  39239. 0 => __DIR__ . '/..' . '/composer/ca-bundle/src',
  39240. ),
  39241. 'Composer\\' =>
  39242. array (
  39243. 0 => __DIR__ . '/../..' . '/src/Composer',
  39244. ),
  39245. );
  39246. public static $classMap = array (
  39247. 'Attribute' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
  39248. 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
  39249. 'JsonException' => __DIR__ . '/..' . '/symfony/polyfill-php73/Resources/stubs/JsonException.php',
  39250. 'Normalizer' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php',
  39251. 'PhpToken' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php',
  39252. 'Stringable' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Stringable.php',
  39253. 'UnhandledMatchError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php',
  39254. 'ValueError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/ValueError.php',
  39255. );
  39256. public static function getInitializer(ClassLoader $loader)
  39257. {
  39258. return \Closure::bind(function () use ($loader) {
  39259. $loader->prefixLengthsPsr4 = ComposerStaticInitComposerPhar1649860980::$prefixLengthsPsr4;
  39260. $loader->prefixDirsPsr4 = ComposerStaticInitComposerPhar1649860980::$prefixDirsPsr4;
  39261. $loader->classMap = ComposerStaticInitComposerPhar1649860980::$classMap;
  39262. }, null, ClassLoader::class);
  39263. }
  39264. }
  39265. Copyright (C) 2016 Composer
  39266. Permission is hereby granted, free of charge, to any person obtaining a copy of
  39267. this software and associated documentation files (the "Software"), to deal in
  39268. the Software without restriction, including without limitation the rights to
  39269. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  39270. of the Software, and to permit persons to whom the Software is furnished to do
  39271. so, subject to the following conditions:
  39272. The above copyright notice and this permission notice shall be included in all
  39273. copies or substantial portions of the Software.
  39274. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  39275. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  39276. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  39277. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  39278. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  39279. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  39280. SOFTWARE.
  39281. ##
  39282. ## Bundle of CA Root Certificates
  39283. ##
  39284. ## Certificate data from Mozilla as of: Tue Oct 26 03:12:05 2021 GMT
  39285. ##
  39286. ## This is a bundle of X.509 certificates of public Certificate Authorities
  39287. ## (CA). These were automatically extracted from Mozilla's root certificates
  39288. ## file (certdata.txt). This file can be found in the mozilla source tree:
  39289. ## https://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt
  39290. ##
  39291. ## It contains the certificates in PEM format and therefore
  39292. ## can be directly used with curl / libcurl / php_curl, or with
  39293. ## an Apache+mod_ssl webserver for SSL client authentication.
  39294. ## Just configure this file as the SSLCACertificateFile.
  39295. ##
  39296. ## Conversion done with mk-ca-bundle.pl version 1.28.
  39297. ## SHA256: bb36818a81feaa4cca61101e6d6276cd09e972efcb08112dfed846918ca41d7f
  39298. ##
  39299. GlobalSign Root CA
  39300. ==================
  39301. -----BEGIN CERTIFICATE-----
  39302. MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkGA1UEBhMCQkUx
  39303. GTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jvb3QgQ0ExGzAZBgNVBAMTEkds
  39304. b2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAwMDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNV
  39305. BAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYD
  39306. VQQDExJHbG9iYWxTaWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDa
  39307. DuaZjc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavpxy0Sy6sc
  39308. THAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp1Wrjsok6Vjk4bwY8iGlb
  39309. Kk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdGsnUOhugZitVtbNV4FpWi6cgKOOvyJBNP
  39310. c1STE4U6G7weNLWLBYy5d4ux2x8gkasJU26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrX
  39311. gzT/LCrBbBlDSgeF59N89iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV
  39312. HRMBAf8EBTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0BAQUF
  39313. AAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOzyj1hTdNGCbM+w6Dj
  39314. Y1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE38NflNUVyRRBnMRddWQVDf9VMOyG
  39315. j/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymPAbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhH
  39316. hm4qxFYxldBniYUr+WymXUadDKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveC
  39317. X4XSQRjbgbMEHMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==
  39318. -----END CERTIFICATE-----
  39319. GlobalSign Root CA - R2
  39320. =======================
  39321. -----BEGIN CERTIFICATE-----
  39322. MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4GA1UECxMXR2xv
  39323. YmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh
  39324. bFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1MDgwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT
  39325. aWduIFJvb3QgQ0EgLSBSMjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln
  39326. bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKbPJA6+Lm8omUVCxKs+IVSbC9N/hHD6
  39327. ErPLv4dfxn+G07IwXNb9rfF73OX4YJYJkhD10FPe+3t+c4isUoh7SqbKSaZeqKeMWhG8eoLrvozp
  39328. s6yWJQeXSpkqBy+0Hne/ig+1AnwblrjFuTosvNYSuetZfeLQBoZfXklqtTleiDTsvHgMCJiEbKjN
  39329. S7SgfQx5TfC4LcshytVsW33hoCmEofnTlEnLJGKRILzdC9XZzPnqJworc5HGnRusyMvo4KD0L5CL
  39330. TfuwNhv2GXqF4G3yYROIXJ/gkwpRl4pazq+r1feqCapgvdzZX99yqWATXgAByUr6P6TqBwMhAo6C
  39331. ygPCm48CAwEAAaOBnDCBmTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4E
  39332. FgQUm+IHV2ccHsBqBt5ZtJot39wZhi4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL2NybC5nbG9i
  39333. YWxzaWduLm5ldC9yb290LXIyLmNybDAfBgNVHSMEGDAWgBSb4gdXZxwewGoG3lm0mi3f3BmGLjAN
  39334. BgkqhkiG9w0BAQUFAAOCAQEAmYFThxxol4aR7OBKuEQLq4GsJ0/WwbgcQ3izDJr86iw8bmEbTUsp
  39335. 9Z8FHSbBuOmDAGJFtqkIk7mpM0sYmsL4h4hO291xNBrBVNpGP+DTKqttVCL1OmLNIG+6KYnX3ZHu
  39336. 01yiPqFbQfXf5WRDLenVOavSot+3i9DAgBkcRcAtjOj4LaR0VknFBbVPFd5uRHg5h6h+u/N5GJG7
  39337. 9G+dwfCMNYxdAfvDbbnvRG15RjF+Cv6pgsH/76tuIMRQyV+dTZsXjAzlAcmgQWpzU/qlULRuJQ/7
  39338. TBj0/VLZjmmx6BEP3ojY+x1J96relc8geMJgEtslQIxq/H5COEBkEveegeGTLg==
  39339. -----END CERTIFICATE-----
  39340. Entrust.net Premium 2048 Secure Server CA
  39341. =========================================
  39342. -----BEGIN CERTIFICATE-----
  39343. MIIEKjCCAxKgAwIBAgIEOGPe+DANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChMLRW50cnVzdC5u
  39344. ZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9DUFNfMjA0OCBpbmNvcnAuIGJ5IHJlZi4gKGxp
  39345. bWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAxOTk5IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNV
  39346. BAMTKkVudHJ1c3QubmV0IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ICgyMDQ4KTAeFw05OTEyMjQx
  39347. NzUwNTFaFw0yOTA3MjQxNDE1MTJaMIG0MRQwEgYDVQQKEwtFbnRydXN0Lm5ldDFAMD4GA1UECxQ3
  39348. d3d3LmVudHJ1c3QubmV0L0NQU18yMDQ4IGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTEl
  39349. MCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEGA1UEAxMqRW50cnVzdC5u
  39350. ZXQgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgKDIwNDgpMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  39351. MIIBCgKCAQEArU1LqRKGsuqjIAcVFmQqK0vRvwtKTY7tgHalZ7d4QMBzQshowNtTK91euHaYNZOL
  39352. Gp18EzoOH1u3Hs/lJBQesYGpjX24zGtLA/ECDNyrpUAkAH90lKGdCCmziAv1h3edVc3kw37XamSr
  39353. hRSGlVuXMlBvPci6Zgzj/L24ScF2iUkZ/cCovYmjZy/Gn7xxGWC4LeksyZB2ZnuU4q941mVTXTzW
  39354. nLLPKQP5L6RQstRIzgUyVYr9smRMDuSYB3Xbf9+5CFVghTAp+XtIpGmG4zU/HoZdenoVve8AjhUi
  39355. VBcAkCaTvA5JaJG/+EfTnZVCwQ5N328mz8MYIWJmQ3DW1cAH4QIDAQABo0IwQDAOBgNVHQ8BAf8E
  39356. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUVeSB0RGAvtiJuQijMfmhJAkWuXAwDQYJ
  39357. KoZIhvcNAQEFBQADggEBADubj1abMOdTmXx6eadNl9cZlZD7Bh/KM3xGY4+WZiT6QBshJ8rmcnPy
  39358. T/4xmf3IDExoU8aAghOY+rat2l098c5u9hURlIIM7j+VrxGrD9cv3h8Dj1csHsm7mhpElesYT6Yf
  39359. zX1XEC+bBAlahLVu2B064dae0Wx5XnkcFMXj0EyTO2U87d89vqbllRrDtRnDvV5bu/8j72gZyxKT
  39360. J1wDLW8w0B62GqzeWvfRqqgnpv55gcR5mTNXuhKwqeBCbJPKVt7+bYQLCIt+jerXmCHG8+c8eS9e
  39361. nNFMFY3h7CI3zJpDC5fcgJCNs2ebb0gIFVbPv/ErfF6adulZkMV8gzURZVE=
  39362. -----END CERTIFICATE-----
  39363. Baltimore CyberTrust Root
  39364. =========================
  39365. -----BEGIN CERTIFICATE-----
  39366. MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJRTESMBAGA1UE
  39367. ChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYDVQQDExlCYWx0aW1vcmUgQ3li
  39368. ZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoXDTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMC
  39369. SUUxEjAQBgNVBAoTCUJhbHRpbW9yZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFs
  39370. dGltb3JlIEN5YmVyVHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKME
  39371. uyKrmD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjrIZ3AQSsB
  39372. UnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeKmpYcqWe4PwzV9/lSEy/C
  39373. G9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSuXmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9
  39374. XbIGevOF6uvUA65ehD5f/xXtabz5OTZydc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjpr
  39375. l3RjM71oGDHweI12v/yejl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoI
  39376. VDaGezq1BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEB
  39377. BQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT929hkTI7gQCvlYpNRh
  39378. cL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3WgxjkzSswF07r51XgdIGn9w/xZchMB5
  39379. hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsa
  39380. Y71k5h+3zvDyny67G7fyUIhzksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9H
  39381. RCwBXbsdtTLSR9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp
  39382. -----END CERTIFICATE-----
  39383. Entrust Root Certification Authority
  39384. ====================================
  39385. -----BEGIN CERTIFICATE-----
  39386. MIIEkTCCA3mgAwIBAgIERWtQVDANBgkqhkiG9w0BAQUFADCBsDELMAkGA1UEBhMCVVMxFjAUBgNV
  39387. BAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0Lm5ldC9DUFMgaXMgaW5jb3Jw
  39388. b3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMWKGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsG
  39389. A1UEAxMkRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2MTEyNzIwMjM0
  39390. MloXDTI2MTEyNzIwNTM0MlowgbAxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMu
  39391. MTkwNwYDVQQLEzB3d3cuZW50cnVzdC5uZXQvQ1BTIGlzIGluY29ycG9yYXRlZCBieSByZWZlcmVu
  39392. Y2UxHzAdBgNVBAsTFihjKSAyMDA2IEVudHJ1c3QsIEluYy4xLTArBgNVBAMTJEVudHJ1c3QgUm9v
  39393. dCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  39394. ALaVtkNC+sZtKm9I35RMOVcF7sN5EUFoNu3s/poBj6E4KPz3EEZmLk0eGrEaTsbRwJWIsMn/MYsz
  39395. A9u3g3s+IIRe7bJWKKf44LlAcTfFy0cOlypowCKVYhXbR9n10Cv/gkvJrT7eTNuQgFA/CYqEAOww
  39396. Cj0Yzfv9KlmaI5UXLEWeH25DeW0MXJj+SKfFI0dcXv1u5x609mhF0YaDW6KKjbHjKYD+JXGIrb68
  39397. j6xSlkuqUY3kEzEZ6E5Nn9uss2rVvDlUccp6en+Q3X0dgNmBu1kmwhH+5pPi94DkZfs0Nw4pgHBN
  39398. rziGLp5/V6+eF67rHMsoIV+2HNjnogQi+dPa2MsCAwEAAaOBsDCBrTAOBgNVHQ8BAf8EBAMCAQYw
  39399. DwYDVR0TAQH/BAUwAwEB/zArBgNVHRAEJDAigA8yMDA2MTEyNzIwMjM0MlqBDzIwMjYxMTI3MjA1
  39400. MzQyWjAfBgNVHSMEGDAWgBRokORnpKZTgMeGZqTx90tD+4S9bTAdBgNVHQ4EFgQUaJDkZ6SmU4DH
  39401. hmak8fdLQ/uEvW0wHQYJKoZIhvZ9B0EABBAwDhsIVjcuMTo0LjADAgSQMA0GCSqGSIb3DQEBBQUA
  39402. A4IBAQCT1DCw1wMgKtD5Y+iRDAUgqV8ZyntyTtSx29CW+1RaGSwMCPeyvIWonX9tO1KzKtvn1ISM
  39403. Y/YPyyYBkVBs9F8U4pN0wBOeMDpQ47RgxRzwIkSNcUesyBrJ6ZuaAGAT/3B+XxFNSRuzFVJ7yVTa
  39404. v52Vr2ua2J7p8eRDjeIRRDq/r72DQnNSi6q7pynP9WQcCk3RvKqsnyrQ/39/2n3qse0wJcGE2jTS
  39405. W3iDVuycNsMm4hH2Z0kdkquM++v/eu6FSqdQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0
  39406. tHuu2guQOHXvgR1m0vdXcDazv/wor3ElhVsT/h5/WrQ8
  39407. -----END CERTIFICATE-----
  39408. Comodo AAA Services root
  39409. ========================
  39410. -----BEGIN CERTIFICATE-----
  39411. MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJHQjEbMBkGA1UECAwS
  39412. R3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRowGAYDVQQKDBFDb21vZG8gQ0Eg
  39413. TGltaXRlZDEhMB8GA1UEAwwYQUFBIENlcnRpZmljYXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAwMDAw
  39414. MFoXDTI4MTIzMTIzNTk1OVowezELMAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFuY2hl
  39415. c3RlcjEQMA4GA1UEBwwHU2FsZm9yZDEaMBgGA1UECgwRQ29tb2RvIENBIExpbWl0ZWQxITAfBgNV
  39416. BAMMGEFBQSBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
  39417. ggEBAL5AnfRu4ep2hxxNRUSOvkbIgwadwSr+GB+O5AL686tdUIoWMQuaBtDFcCLNSS1UY8y2bmhG
  39418. C1Pqy0wkwLxyTurxFa70VJoSCsN6sjNg4tqJVfMiWPPe3M/vg4aijJRPn2jymJBGhCfHdr/jzDUs
  39419. i14HZGWCwEiwqJH5YZ92IFCokcdmtet4YgNW8IoaE+oxox6gmf049vYnMlhvB/VruPsUK6+3qszW
  39420. Y19zjNoFmag4qMsXeDZRrOme9Hg6jc8P2ULimAyrL58OAd7vn5lJ8S3frHRNG5i1R8XlKdH5kBjH
  39421. Ypy+g8cmez6KJcfA3Z3mNWgQIJ2P2N7Sw4ScDV7oL8kCAwEAAaOBwDCBvTAdBgNVHQ4EFgQUoBEK
  39422. Iz6W8Qfs4q8p74Klf9AwpLQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wewYDVR0f
  39423. BHQwcjA4oDagNIYyaHR0cDovL2NybC5jb21vZG9jYS5jb20vQUFBQ2VydGlmaWNhdGVTZXJ2aWNl
  39424. cy5jcmwwNqA0oDKGMGh0dHA6Ly9jcmwuY29tb2RvLm5ldC9BQUFDZXJ0aWZpY2F0ZVNlcnZpY2Vz
  39425. LmNybDANBgkqhkiG9w0BAQUFAAOCAQEACFb8AvCb6P+k+tZ7xkSAzk/ExfYAWMymtrwUSWgEdujm
  39426. 7l3sAg9g1o1QGE8mTgHj5rCl7r+8dFRBv/38ErjHT1r0iWAFf2C3BUrz9vHCv8S5dIa2LX1rzNLz
  39427. Rt0vxuBqw8M0Ayx9lt1awg6nCpnBBYurDC/zXDrPbDdVCYfeU0BsWO/8tqtlbgT2G9w84FoVxp7Z
  39428. 8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsil2D4kF501KKaU73yqWjgom7C
  39429. 12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg==
  39430. -----END CERTIFICATE-----
  39431. QuoVadis Root CA 2
  39432. ==================
  39433. -----BEGIN CERTIFICATE-----
  39434. MIIFtzCCA5+gAwIBAgICBQkwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT
  39435. EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMjAeFw0wNjExMjQx
  39436. ODI3MDBaFw0zMTExMjQxODIzMzNaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM
  39437. aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  39438. DwAwggIKAoICAQCaGMpLlA0ALa8DKYrwD4HIrkwZhR0In6spRIXzL4GtMh6QRr+jhiYaHv5+HBg6
  39439. XJxgFyo6dIMzMH1hVBHL7avg5tKifvVrbxi3Cgst/ek+7wrGsxDp3MJGF/hd/aTa/55JWpzmM+Yk
  39440. lvc/ulsrHHo1wtZn/qtmUIttKGAr79dgw8eTvI02kfN/+NsRE8Scd3bBrrcCaoF6qUWD4gXmuVbB
  39441. lDePSHFjIuwXZQeVikvfj8ZaCuWw419eaxGrDPmF60Tp+ARz8un+XJiM9XOva7R+zdRcAitMOeGy
  39442. lZUtQofX1bOQQ7dsE/He3fbE+Ik/0XX1ksOR1YqI0JDs3G3eicJlcZaLDQP9nL9bFqyS2+r+eXyt
  39443. 66/3FsvbzSUr5R/7mp/iUcw6UwxI5g69ybR2BlLmEROFcmMDBOAENisgGQLodKcftslWZvB1Jdxn
  39444. wQ5hYIizPtGo/KPaHbDRsSNU30R2be1B2MGyIrZTHN81Hdyhdyox5C315eXbyOD/5YDXC2Og/zOh
  39445. D7osFRXql7PSorW+8oyWHhqPHWykYTe5hnMz15eWniN9gqRMgeKh0bpnX5UHoycR7hYQe7xFSkyy
  39446. BNKr79X9DFHOUGoIMfmR2gyPZFwDwzqLID9ujWc9Otb+fVuIyV77zGHcizN300QyNQliBJIWENie
  39447. J0f7OyHj+OsdWwIDAQABo4GwMIGtMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1Ud
  39448. DgQWBBQahGK8SEwzJQTU7tD2A8QZRtGUazBuBgNVHSMEZzBlgBQahGK8SEwzJQTU7tD2A8QZRtGU
  39449. a6FJpEcwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMT
  39450. ElF1b1ZhZGlzIFJvb3QgQ0EgMoICBQkwDQYJKoZIhvcNAQEFBQADggIBAD4KFk2fBluornFdLwUv
  39451. Z+YTRYPENvbzwCYMDbVHZF34tHLJRqUDGCdViXh9duqWNIAXINzng/iN/Ae42l9NLmeyhP3ZRPx3
  39452. UIHmfLTJDQtyU/h2BwdBR5YM++CCJpNVjP4iH2BlfF/nJrP3MpCYUNQ3cVX2kiF495V5+vgtJodm
  39453. VjB3pjd4M1IQWK4/YY7yarHvGH5KWWPKjaJW1acvvFYfzznB4vsKqBUsfU16Y8Zsl0Q80m/DShcK
  39454. +JDSV6IZUaUtl0HaB0+pUNqQjZRG4T7wlP0QADj1O+hA4bRuVhogzG9Yje0uRY/W6ZM/57Es3zrW
  39455. IozchLsib9D45MY56QSIPMO661V6bYCZJPVsAfv4l7CUW+v90m/xd2gNNWQjrLhVoQPRTUIZ3Ph1
  39456. WVaj+ahJefivDrkRoHy3au000LYmYjgahwz46P0u05B/B5EqHdZ+XIWDmbA4CD/pXvk1B+TJYm5X
  39457. f6dQlfe6yJvmjqIBxdZmv3lh8zwc4bmCXF2gw+nYSL0ZohEUGW6yhhtoPkg3Goi3XZZenMfvJ2II
  39458. 4pEZXNLxId26F0KCl3GBUzGpn/Z9Yr9y4aOTHcyKJloJONDO1w2AFrR4pTqHTI2KpdVGl/IsELm8
  39459. VCLAAVBpQ570su9t+Oza8eOx79+Rj1QqCyXBJhnEUhAFZdWCEOrCMc0u
  39460. -----END CERTIFICATE-----
  39461. QuoVadis Root CA 3
  39462. ==================
  39463. -----BEGIN CERTIFICATE-----
  39464. MIIGnTCCBIWgAwIBAgICBcYwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT
  39465. EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMzAeFw0wNjExMjQx
  39466. OTExMjNaFw0zMTExMjQxOTA2NDRaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM
  39467. aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  39468. DwAwggIKAoICAQDMV0IWVJzmmNPTTe7+7cefQzlKZbPoFog02w1ZkXTPkrgEQK0CSzGrvI2RaNgg
  39469. DhoB4hp7Thdd4oq3P5kazethq8Jlph+3t723j/z9cI8LoGe+AaJZz3HmDyl2/7FWeUUrH556VOij
  39470. KTVopAFPD6QuN+8bv+OPEKhyq1hX51SGyMnzW9os2l2ObjyjPtr7guXd8lyyBTNvijbO0BNO/79K
  39471. DDRMpsMhvVAEVeuxu537RR5kFd5VAYwCdrXLoT9CabwvvWhDFlaJKjdhkf2mrk7AyxRllDdLkgbv
  39472. BNDInIjbC3uBr7E9KsRlOni27tyAsdLTmZw67mtaa7ONt9XOnMK+pUsvFrGeaDsGb659n/je7Mwp
  39473. p5ijJUMv7/FfJuGITfhebtfZFG4ZM2mnO4SJk8RTVROhUXhA+LjJou57ulJCg54U7QVSWllWp5f8
  39474. nT8KKdjcT5EOE7zelaTfi5m+rJsziO+1ga8bxiJTyPbH7pcUsMV8eFLI8M5ud2CEpukqdiDtWAEX
  39475. MJPpGovgc2PZapKUSU60rUqFxKMiMPwJ7Wgic6aIDFUhWMXhOp8q3crhkODZc6tsgLjoC2SToJyM
  39476. Gf+z0gzskSaHirOi4XCPLArlzW1oUevaPwV/izLmE1xr/l9A4iLItLRkT9a6fUg+qGkM17uGcclz
  39477. uD87nSVL2v9A6wIDAQABo4IBlTCCAZEwDwYDVR0TAQH/BAUwAwEB/zCB4QYDVR0gBIHZMIHWMIHT
  39478. BgkrBgEEAb5YAAMwgcUwgZMGCCsGAQUFBwICMIGGGoGDQW55IHVzZSBvZiB0aGlzIENlcnRpZmlj
  39479. YXRlIGNvbnN0aXR1dGVzIGFjY2VwdGFuY2Ugb2YgdGhlIFF1b1ZhZGlzIFJvb3QgQ0EgMyBDZXJ0
  39480. aWZpY2F0ZSBQb2xpY3kgLyBDZXJ0aWZpY2F0aW9uIFByYWN0aWNlIFN0YXRlbWVudC4wLQYIKwYB
  39481. BQUHAgEWIWh0dHA6Ly93d3cucXVvdmFkaXNnbG9iYWwuY29tL2NwczALBgNVHQ8EBAMCAQYwHQYD
  39482. VR0OBBYEFPLAE+CCQz777i9nMpY1XNu4ywLQMG4GA1UdIwRnMGWAFPLAE+CCQz777i9nMpY1XNu4
  39483. ywLQoUmkRzBFMQswCQYDVQQGEwJCTTEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRlZDEbMBkGA1UE
  39484. AxMSUXVvVmFkaXMgUm9vdCBDQSAzggIFxjANBgkqhkiG9w0BAQUFAAOCAgEAT62gLEz6wPJv92ZV
  39485. qyM07ucp2sNbtrCD2dDQ4iH782CnO11gUyeim/YIIirnv6By5ZwkajGxkHon24QRiSemd1o417+s
  39486. hvzuXYO8BsbRd2sPbSQvS3pspweWyuOEn62Iix2rFo1bZhfZFvSLgNLd+LJ2w/w4E6oM3kJpK27z
  39487. POuAJ9v1pkQNn1pVWQvVDVJIxa6f8i+AxeoyUDUSly7B4f/xI4hROJ/yZlZ25w9Rl6VSDE1JUZU2
  39488. Pb+iSwwQHYaZTKrzchGT5Or2m9qoXadNt54CrnMAyNojA+j56hl0YgCUyyIgvpSnWbWCar6ZeXqp
  39489. 8kokUvd0/bpO5qgdAm6xDYBEwa7TIzdfu4V8K5Iu6H6li92Z4b8nby1dqnuH/grdS/yO9SbkbnBC
  39490. bjPsMZ57k8HkyWkaPcBrTiJt7qtYTcbQQcEr6k8Sh17rRdhs9ZgC06DYVYoGmRmioHfRMJ6szHXu
  39491. g/WwYjnPbFfiTNKRCw51KBuav/0aQ/HKd/s7j2G4aSgWQgRecCocIdiP4b0jWy10QJLZYxkNc91p
  39492. vGJHvOB0K7Lrfb5BG7XARsWhIstfTsEokt4YutUqKLsRixeTmJlglFwjz1onl14LBQaTNx47aTbr
  39493. qZ5hHY8y2o4M1nQ+ewkk2gF3R8Q7zTSMmfXK4SVhM7JZG+Ju1zdXtg2pEto=
  39494. -----END CERTIFICATE-----
  39495. Security Communication Root CA
  39496. ==============================
  39497. -----BEGIN CERTIFICATE-----
  39498. MIIDWjCCAkKgAwIBAgIBADANBgkqhkiG9w0BAQUFADBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMP
  39499. U0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEw
  39500. HhcNMDMwOTMwMDQyMDQ5WhcNMjMwOTMwMDQyMDQ5WjBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMP
  39501. U0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEw
  39502. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCzs/5/022x7xZ8V6UMbXaKL0u/ZPtM7orw
  39503. 8yl89f/uKuDp6bpbZCKamm8sOiZpUQWZJtzVHGpxxpp9Hp3dfGzGjGdnSj74cbAZJ6kJDKaVv0uM
  39504. DPpVmDvY6CKhS3E4eayXkmmziX7qIWgGmBSWh9JhNrxtJ1aeV+7AwFb9Ms+k2Y7CI9eNqPPYJayX
  39505. 5HA49LY6tJ07lyZDo6G8SVlyTCMwhwFY9k6+HGhWZq/NQV3Is00qVUarH9oe4kA92819uZKAnDfd
  39506. DJZkndwi92SL32HeFZRSFaB9UslLqCHJxrHty8OVYNEP8Ktw+N/LTX7s1vqr2b1/VPKl6Xn62dZ2
  39507. JChzAgMBAAGjPzA9MB0GA1UdDgQWBBSgc0mZaNyFW2XjmygvV5+9M7wHSDALBgNVHQ8EBAMCAQYw
  39508. DwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAaECpqLvkT115swW1F7NgE+vGkl3g
  39509. 0dNq/vu+m22/xwVtWSDEHPC32oRYAmP6SBbvT6UL90qY8j+eG61Ha2POCEfrUj94nK9NrvjVT8+a
  39510. mCoQQTlSxN3Zmw7vkwGusi7KaEIkQmywszo+zenaSMQVy+n5Bw+SUEmK3TGXX8npN6o7WWWXlDLJ
  39511. s58+OmJYxUmtYg5xpTKqL8aJdkNAExNnPaJUJRDL8Try2frbSVa7pv6nQTXD4IhhyYjH3zYQIphZ
  39512. 6rBK+1YWc26sTfcioU+tHXotRSflMMFe8toTyyVCUZVHA4xsIcx0Qu1T/zOLjw9XARYvz6buyXAi
  39513. FL39vmwLAw==
  39514. -----END CERTIFICATE-----
  39515. XRamp Global CA Root
  39516. ====================
  39517. -----BEGIN CERTIFICATE-----
  39518. MIIEMDCCAxigAwIBAgIQUJRs7Bjq1ZxN1ZfvdY+grTANBgkqhkiG9w0BAQUFADCBgjELMAkGA1UE
  39519. BhMCVVMxHjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2Vj
  39520. dXJpdHkgU2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBB
  39521. dXRob3JpdHkwHhcNMDQxMTAxMTcxNDA0WhcNMzUwMTAxMDUzNzE5WjCBgjELMAkGA1UEBhMCVVMx
  39522. HjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2VjdXJpdHkg
  39523. U2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBBdXRob3Jp
  39524. dHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCYJB69FbS638eMpSe2OAtp87ZOqCwu
  39525. IR1cRN8hXX4jdP5efrRKt6atH67gBhbim1vZZ3RrXYCPKZ2GG9mcDZhtdhAoWORlsH9KmHmf4MMx
  39526. foArtYzAQDsRhtDLooY2YKTVMIJt2W7QDxIEM5dfT2Fa8OT5kavnHTu86M/0ay00fOJIYRyO82FE
  39527. zG+gSqmUsE3a56k0enI4qEHMPJQRfevIpoy3hsvKMzvZPTeL+3o+hiznc9cKV6xkmxnr9A8ECIqs
  39528. AxcZZPRaJSKNNCyy9mgdEm3Tih4U2sSPpuIjhdV6Db1q4Ons7Be7QhtnqiXtRYMh/MHJfNViPvry
  39529. xS3T/dRlAgMBAAGjgZ8wgZwwEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud
  39530. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFMZPoj0GY4QJnM5i5ASsjVy16bYbMDYGA1UdHwQvMC0wK6Ap
  39531. oCeGJWh0dHA6Ly9jcmwueHJhbXBzZWN1cml0eS5jb20vWEdDQS5jcmwwEAYJKwYBBAGCNxUBBAMC
  39532. AQEwDQYJKoZIhvcNAQEFBQADggEBAJEVOQMBG2f7Shz5CmBbodpNl2L5JFMn14JkTpAuw0kbK5rc
  39533. /Kh4ZzXxHfARvbdI4xD2Dd8/0sm2qlWkSLoC295ZLhVbO50WfUfXN+pfTXYSNrsf16GBBEYgoyxt
  39534. qZ4Bfj8pzgCT3/3JknOJiWSe5yvkHJEs0rnOfc5vMZnT5r7SHpDwCRR5XCOrTdLaIR9NmXmd4c8n
  39535. nxCbHIgNsIpkQTG4DmyQJKSbXHGPurt+HBvbaoAPIbzp26a3QPSyi6mx5O+aGtA9aZnuqCij4Tyz
  39536. 8LIRnM98QObd50N9otg6tamN8jSZxNQQ4Qb9CYQQO+7ETPTsJ3xCwnR8gooJybQDJbw=
  39537. -----END CERTIFICATE-----
  39538. Go Daddy Class 2 CA
  39539. ===================
  39540. -----BEGIN CERTIFICATE-----
  39541. MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMY
  39542. VGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRp
  39543. ZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkG
  39544. A1UEBhMCVVMxITAfBgNVBAoTGFRoZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28g
  39545. RGFkZHkgQ2xhc3MgMiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQAD
  39546. ggENADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCAPVYYYwhv
  39547. 2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6wwdhFJ2+qN1j3hybX2C32
  39548. qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXiEqITLdiOr18SPaAIBQi2XKVlOARFmR6j
  39549. YGB0xUGlcmIbYsUfb18aQr4CUWWoriMYavx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmY
  39550. vLEHZ6IVDd2gWMZEewo+YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjgcAwgb0wHQYDVR0O
  39551. BBYEFNLEsNKR1EwRcbNhyz2h/t2oatTjMIGNBgNVHSMEgYUwgYKAFNLEsNKR1EwRcbNhyz2h/t2o
  39552. atTjoWekZTBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMu
  39553. MTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwG
  39554. A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wim
  39555. PQoZ+YeAEW5p5JYXMP80kWNyOO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKt
  39556. I3lpjbi2Tc7PTMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ
  39557. HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mERdEr/VxqHD3VI
  39558. Ls9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5CufReYNnyicsbkqWletNw+vHX/b
  39559. vZ8=
  39560. -----END CERTIFICATE-----
  39561. Starfield Class 2 CA
  39562. ====================
  39563. -----BEGIN CERTIFICATE-----
  39564. MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzElMCMGA1UEChMc
  39565. U3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZpZWxkIENsYXNzIDIg
  39566. Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQwNjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBo
  39567. MQswCQYDVQQGEwJVUzElMCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAG
  39568. A1UECxMpU3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqG
  39569. SIb3DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf8MOh2tTY
  39570. bitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN+lq2cwQlZut3f+dZxkqZ
  39571. JRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVm
  39572. epsZGD3/cVE8MC5fvj13c7JdBmzDI1aaK4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSN
  39573. F4Azbl5KXZnJHoe0nRrA1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HF
  39574. MIHCMB0GA1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fRzt0f
  39575. hvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNo
  39576. bm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBDbGFzcyAyIENlcnRpZmljYXRpb24g
  39577. QXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGs
  39578. afPzWdqbAYcaT1epoXkJKtv3L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLM
  39579. PUxA2IGvd56Deruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl
  39580. xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynpVSJYACPq4xJD
  39581. KVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEYWQPJIrSPnNVeKtelttQKbfi3
  39582. QBFGmh95DmK/D5fs4C8fF5Q=
  39583. -----END CERTIFICATE-----
  39584. DigiCert Assured ID Root CA
  39585. ===========================
  39586. -----BEGIN CERTIFICATE-----
  39587. MIIDtzCCAp+gAwIBAgIQDOfg5RfYRv6P5WD8G/AwOTANBgkqhkiG9w0BAQUFADBlMQswCQYDVQQG
  39588. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw
  39589. IgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0EwHhcNMDYxMTEwMDAwMDAwWhcNMzEx
  39590. MTEwMDAwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL
  39591. ExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0Ew
  39592. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtDhXO5EOAXLGH87dg+XESpa7cJpSIqvTO
  39593. 9SA5KFhgDPiA2qkVlTJhPLWxKISKityfCgyDF3qPkKyK53lTXDGEKvYPmDI2dsze3Tyoou9q+yHy
  39594. UmHfnyDXH+Kx2f4YZNISW1/5WBg1vEfNoTb5a3/UsDg+wRvDjDPZ2C8Y/igPs6eD1sNuRMBhNZYW
  39595. /lmci3Zt1/GiSw0r/wty2p5g0I6QNcZ4VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpy
  39596. oeb6pNnVFzF1roV9Iq4/AUaG9ih5yLHa5FcXxH4cDrC0kqZWs72yl+2qp/C3xag/lRbQ/6GW6whf
  39597. GHdPAgMBAAGjYzBhMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRF
  39598. 66Kv9JLLgjEtUYunpyGd823IDzAfBgNVHSMEGDAWgBRF66Kv9JLLgjEtUYunpyGd823IDzANBgkq
  39599. hkiG9w0BAQUFAAOCAQEAog683+Lt8ONyc3pklL/3cmbYMuRCdWKuh+vy1dneVrOfzM4UKLkNl2Bc
  39600. EkxY5NM9g0lFWJc1aRqoR+pWxnmrEthngYTffwk8lOa4JiwgvT2zKIn3X/8i4peEH+ll74fg38Fn
  39601. SbNd67IJKusm7Xi+fT8r87cmNW1fiQG2SVufAQWbqz0lwcy2f8Lxb4bG+mRo64EtlOtCt/qMHt1i
  39602. 8b5QZ7dsvfPxH2sMNgcWfzd8qVttevESRmCD1ycEvkvOl77DZypoEd+A5wwzZr8TDRRu838fYxAe
  39603. +o0bJW1sj6W3YQGx0qMmoRBxna3iw/nDmVG3KwcIzi7mULKn+gpFL6Lw8g==
  39604. -----END CERTIFICATE-----
  39605. DigiCert Global Root CA
  39606. =======================
  39607. -----BEGIN CERTIFICATE-----
  39608. MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQG
  39609. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw
  39610. HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBDQTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAw
  39611. MDAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3
  39612. dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkq
  39613. hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsBCSDMAZOn
  39614. TjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97nh6Vfe63SKMI2tavegw5
  39615. BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt43C/dxC//AH2hdmoRBBYMql1GNXRor5H
  39616. 4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7PT19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y
  39617. 7vrTC0LUq7dBMtoM1O/4gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQAB
  39618. o2MwYTAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbRTLtm
  39619. 8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUwDQYJKoZIhvcNAQEF
  39620. BQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/EsrhMAtudXH/vTBH1jLuG2cenTnmCmr
  39621. EbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIt
  39622. tep3Sp+dWOIrWcBAI+0tKIJFPnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886
  39623. UAb3LujEV0lsYSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk
  39624. CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=
  39625. -----END CERTIFICATE-----
  39626. DigiCert High Assurance EV Root CA
  39627. ==================================
  39628. -----BEGIN CERTIFICATE-----
  39629. MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBsMQswCQYDVQQG
  39630. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSsw
  39631. KQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5jZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAw
  39632. MFoXDTMxMTExMDAwMDAwMFowbDELMAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZ
  39633. MBcGA1UECxMQd3d3LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFu
  39634. Y2UgRVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm+9S75S0t
  39635. Mqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTWPNt0OKRKzE0lgvdKpVMS
  39636. OO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEMxChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3
  39637. MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFBIk5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQ
  39638. NAQTXKFx01p8VdteZOE3hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUe
  39639. h10aUAsgEsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMB
  39640. Af8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaAFLE+w2kD+L9HAdSY
  39641. JhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3NecnzyIZgYIVyHbIUf4KmeqvxgydkAQ
  39642. V8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6zeM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFp
  39643. myPInngiK3BD41VHMWEZ71jFhS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkK
  39644. mNEVX58Svnw2Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe
  39645. vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep+OkuE6N36B9K
  39646. -----END CERTIFICATE-----
  39647. SwissSign Gold CA - G2
  39648. ======================
  39649. -----BEGIN CERTIFICATE-----
  39650. MIIFujCCA6KgAwIBAgIJALtAHEP1Xk+wMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNVBAYTAkNIMRUw
  39651. EwYDVQQKEwxTd2lzc1NpZ24gQUcxHzAdBgNVBAMTFlN3aXNzU2lnbiBHb2xkIENBIC0gRzIwHhcN
  39652. MDYxMDI1MDgzMDM1WhcNMzYxMDI1MDgzMDM1WjBFMQswCQYDVQQGEwJDSDEVMBMGA1UEChMMU3dp
  39653. c3NTaWduIEFHMR8wHQYDVQQDExZTd2lzc1NpZ24gR29sZCBDQSAtIEcyMIICIjANBgkqhkiG9w0B
  39654. AQEFAAOCAg8AMIICCgKCAgEAr+TufoskDhJuqVAtFkQ7kpJcyrhdhJJCEyq8ZVeCQD5XJM1QiyUq
  39655. t2/876LQwB8CJEoTlo8jE+YoWACjR8cGp4QjK7u9lit/VcyLwVcfDmJlD909Vopz2q5+bbqBHH5C
  39656. jCA12UNNhPqE21Is8w4ndwtrvxEvcnifLtg+5hg3Wipy+dpikJKVyh+c6bM8K8vzARO/Ws/BtQpg
  39657. vd21mWRTuKCWs2/iJneRjOBiEAKfNA+k1ZIzUd6+jbqEemA8atufK+ze3gE/bk3lUIbLtK/tREDF
  39658. ylqM2tIrfKjuvqblCqoOpd8FUrdVxyJdMmqXl2MT28nbeTZ7hTpKxVKJ+STnnXepgv9VHKVxaSvR
  39659. AiTysybUa9oEVeXBCsdtMDeQKuSeFDNeFhdVxVu1yzSJkvGdJo+hB9TGsnhQ2wwMC3wLjEHXuend
  39660. jIj3o02yMszYF9rNt85mndT9Xv+9lz4pded+p2JYryU0pUHHPbwNUMoDAw8IWh+Vc3hiv69yFGkO
  39661. peUDDniOJihC8AcLYiAQZzlG+qkDzAQ4embvIIO1jEpWjpEA/I5cgt6IoMPiaG59je883WX0XaxR
  39662. 7ySArqpWl2/5rX3aYT+YdzylkbYcjCbaZaIJbcHiVOO5ykxMgI93e2CaHt+28kgeDrpOVG2Y4OGi
  39663. GqJ3UM/EY5LsRxmd6+ZrzsECAwEAAaOBrDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUw
  39664. AwEB/zAdBgNVHQ4EFgQUWyV7lqRlUX64OfPAeGZe6Drn8O4wHwYDVR0jBBgwFoAUWyV7lqRlUX64
  39665. OfPAeGZe6Drn8O4wRgYDVR0gBD8wPTA7BglghXQBWQECAQEwLjAsBggrBgEFBQcCARYgaHR0cDov
  39666. L3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBACe645R88a7A3hfm
  39667. 5djV9VSwg/S7zV4Fe0+fdWavPOhWfvxyeDgD2StiGwC5+OlgzczOUYrHUDFu4Up+GC9pWbY9ZIEr
  39668. 44OE5iKHjn3g7gKZYbge9LgriBIWhMIxkziWMaa5O1M/wySTVltpkuzFwbs4AOPsF6m43Md8AYOf
  39669. Mke6UiI0HTJ6CVanfCU2qT1L2sCCbwq7EsiHSycR+R4tx5M/nttfJmtS2S6K8RTGRI0Vqbe/vd6m
  39670. Gu6uLftIdxf+u+yvGPUqUfA5hJeVbG4bwyvEdGB5JbAKJ9/fXtI5z0V9QkvfsywexcZdylU6oJxp
  39671. mo/a77KwPJ+HbBIrZXAVUjEaJM9vMSNQH4xPjyPDdEFjHFWoFN0+4FFQz/EbMFYOkrCChdiDyyJk
  39672. vC24JdVUorgG6q2SpCSgwYa1ShNqR88uC1aVVMvOmttqtKay20EIhid392qgQmwLOM7XdVAyksLf
  39673. KzAiSNDVQTglXaTpXZ/GlHXQRf0wl0OPkKsKx4ZzYEppLd6leNcG2mqeSz53OiATIgHQv2ieY2Br
  39674. NU0LbbqhPcCT4H8js1WtciVORvnSFu+wZMEBnunKoGqYDs/YYPIvSbjkQuE4NRb0yG5P94FW6Lqj
  39675. viOvrv1vA+ACOzB2+httQc8Bsem4yWb02ybzOqR08kkkW8mw0FfB+j564ZfJ
  39676. -----END CERTIFICATE-----
  39677. SwissSign Silver CA - G2
  39678. ========================
  39679. -----BEGIN CERTIFICATE-----
  39680. MIIFvTCCA6WgAwIBAgIITxvUL1S7L0swDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCQ0gxFTAT
  39681. BgNVBAoTDFN3aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMB4X
  39682. DTA2MTAyNTA4MzI0NloXDTM2MTAyNTA4MzI0NlowRzELMAkGA1UEBhMCQ0gxFTATBgNVBAoTDFN3
  39683. aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMIICIjANBgkqhkiG
  39684. 9w0BAQEFAAOCAg8AMIICCgKCAgEAxPGHf9N4Mfc4yfjDmUO8x/e8N+dOcbpLj6VzHVxumK4DV644
  39685. N0MvFz0fyM5oEMF4rhkDKxD6LHmD9ui5aLlV8gREpzn5/ASLHvGiTSf5YXu6t+WiE7brYT7QbNHm
  39686. +/pe7R20nqA1W6GSy/BJkv6FCgU+5tkL4k+73JU3/JHpMjUi0R86TieFnbAVlDLaYQ1HTWBCrpJH
  39687. 6INaUFjpiou5XaHc3ZlKHzZnu0jkg7Y360g6rw9njxcH6ATK72oxh9TAtvmUcXtnZLi2kUpCe2Uu
  39688. MGoM9ZDulebyzYLs2aFK7PayS+VFheZteJMELpyCbTapxDFkH4aDCyr0NQp4yVXPQbBH6TCfmb5h
  39689. qAaEuSh6XzjZG6k4sIN/c8HDO0gqgg8hm7jMqDXDhBuDsz6+pJVpATqJAHgE2cn0mRmrVn5bi4Y5
  39690. FZGkECwJMoBgs5PAKrYYC51+jUnyEEp/+dVGLxmSo5mnJqy7jDzmDrxHB9xzUfFwZC8I+bRHHTBs
  39691. ROopN4WSaGa8gzj+ezku01DwH/teYLappvonQfGbGHLy9YR0SslnxFSuSGTfjNFusB3hB48IHpmc
  39692. celM2KX3RxIfdNFRnobzwqIjQAtz20um53MGjMGg6cFZrEb65i/4z3GcRm25xBWNOHkDRUjvxF3X
  39693. CO6HOSKGsg0PWEP3calILv3q1h8CAwEAAaOBrDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/
  39694. BAUwAwEB/zAdBgNVHQ4EFgQUF6DNweRBtjpbO8tFnb0cwpj6hlgwHwYDVR0jBBgwFoAUF6DNweRB
  39695. tjpbO8tFnb0cwpj6hlgwRgYDVR0gBD8wPTA7BglghXQBWQEDAQEwLjAsBggrBgEFBQcCARYgaHR0
  39696. cDovL3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBAHPGgeAn0i0P
  39697. 4JUw4ppBf1AsX19iYamGamkYDHRJ1l2E6kFSGG9YrVBWIGrGvShpWJHckRE1qTodvBqlYJ7YH39F
  39698. kWnZfrt4csEGDyrOj4VwYaygzQu4OSlWhDJOhrs9xCrZ1x9y7v5RoSJBsXECYxqCsGKrXlcSH9/L
  39699. 3XWgwF15kIwb4FDm3jH+mHtwX6WQ2K34ArZv02DdQEsixT2tOnqfGhpHkXkzuoLcMmkDlm4fS/Bx
  39700. /uNncqCxv1yL5PqZIseEuRuNI5c/7SXgz2W79WEE790eslpBIlqhn10s6FvJbakMDHiqYMZWjwFa
  39701. DGi8aRl5xB9+lwW/xekkUV7U1UtT7dkjWjYDZaPBA61BMPNGG4WQr2W11bHkFlt4dR2Xem1ZqSqP
  39702. e97Dh4kQmUlzeMg9vVE1dCrV8X5pGyq7O70luJpaPXJhkGaH7gzWTdQRdAtq/gsD/KNVV4n+Ssuu
  39703. WxcFyPKNIzFTONItaj+CuY0IavdeQXRuwxF+B6wpYJE/OMpXEA29MC/HpeZBoNquBYeaoKRlbEwJ
  39704. DIm6uNO5wJOKMPqN5ZprFQFOZ6raYlY+hAhm0sQ2fac+EPyI4NSA5QC9qvNOBqN6avlicuMJT+ub
  39705. DgEj8Z+7fNzcbBGXJbLytGMU0gYqZ4yD9c7qB9iaah7s5Aq7KkzrCWA5zspi2C5u
  39706. -----END CERTIFICATE-----
  39707. SecureTrust CA
  39708. ==============
  39709. -----BEGIN CERTIFICATE-----
  39710. MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBIMQswCQYDVQQG
  39711. EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xFzAVBgNVBAMTDlNlY3VyZVRy
  39712. dXN0IENBMB4XDTA2MTEwNzE5MzExOFoXDTI5MTIzMTE5NDA1NVowSDELMAkGA1UEBhMCVVMxIDAe
  39713. BgNVBAoTF1NlY3VyZVRydXN0IENvcnBvcmF0aW9uMRcwFQYDVQQDEw5TZWN1cmVUcnVzdCBDQTCC
  39714. ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKukgeWVzfX2FI7CT8rU4niVWJxB4Q2ZQCQX
  39715. OZEzZum+4YOvYlyJ0fwkW2Gz4BERQRwdbvC4u/jep4G6pkjGnx29vo6pQT64lO0pGtSO0gMdA+9t
  39716. DWccV9cGrcrI9f4Or2YlSASWC12juhbDCE/RRvgUXPLIXgGZbf2IzIaowW8xQmxSPmjL8xk037uH
  39717. GFaAJsTQ3MBv396gwpEWoGQRS0S8Hvbn+mPeZqx2pHGj7DaUaHp3pLHnDi+BeuK1cobvomuL8A/b
  39718. 01k/unK8RCSc43Oz969XL0Imnal0ugBS8kvNU3xHCzaFDmapCJcWNFfBZveA4+1wVMeT4C4oFVmH
  39719. ursCAwEAAaOBnTCBmjATBgkrBgEEAYI3FAIEBh4EAEMAQTALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/
  39720. BAUwAwEB/zAdBgNVHQ4EFgQUQjK2FvoE/f5dS3rD/fdMQB1aQ68wNAYDVR0fBC0wKzApoCegJYYj
  39721. aHR0cDovL2NybC5zZWN1cmV0cnVzdC5jb20vU1RDQS5jcmwwEAYJKwYBBAGCNxUBBAMCAQAwDQYJ
  39722. KoZIhvcNAQEFBQADggEBADDtT0rhWDpSclu1pqNlGKa7UTt36Z3q059c4EVlew3KW+JwULKUBRSu
  39723. SceNQQcSc5R+DCMh/bwQf2AQWnL1mA6s7Ll/3XpvXdMc9P+IBWlCqQVxyLesJugutIxq/3HcuLHf
  39724. mbx8IVQr5Fiiu1cprp6poxkmD5kuCLDv/WnPmRoJjeOnnyvJNjR7JLN4TJUXpAYmHrZkUjZfYGfZ
  39725. nMUFdAvnZyPSCPyI6a6Lf+Ew9Dd+/cYy2i2eRDAwbO4H3tI0/NL/QPZL9GZGBlSm8jIKYyYwa5vR
  39726. 3ItHuuG51WLQoqD0ZwV4KWMabwTW+MZMo5qxN7SN5ShLHZ4swrhovO0C7jE=
  39727. -----END CERTIFICATE-----
  39728. Secure Global CA
  39729. ================
  39730. -----BEGIN CERTIFICATE-----
  39731. MIIDvDCCAqSgAwIBAgIQB1YipOjUiolN9BPI8PjqpTANBgkqhkiG9w0BAQUFADBKMQswCQYDVQQG
  39732. EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBH
  39733. bG9iYWwgQ0EwHhcNMDYxMTA3MTk0MjI4WhcNMjkxMjMxMTk1MjA2WjBKMQswCQYDVQQGEwJVUzEg
  39734. MB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBHbG9iYWwg
  39735. Q0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvNS7YrGxVaQZx5RNoJLNP2MwhR/jx
  39736. YDiJiQPpvepeRlMJ3Fz1Wuj3RSoC6zFh1ykzTM7HfAo3fg+6MpjhHZevj8fcyTiW89sa/FHtaMbQ
  39737. bqR8JNGuQsiWUGMu4P51/pinX0kuleM5M2SOHqRfkNJnPLLZ/kG5VacJjnIFHovdRIWCQtBJwB1g
  39738. 8NEXLJXr9qXBkqPFwqcIYA1gBBCWeZ4WNOaptvolRTnIHmX5k/Wq8VLcmZg9pYYaDDUz+kulBAYV
  39739. HDGA76oYa8J719rO+TMg1fW9ajMtgQT7sFzUnKPiXB3jqUJ1XnvUd+85VLrJChgbEplJL4hL/VBi
  39740. 0XPnj3pDAgMBAAGjgZ0wgZowEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud
  39741. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFK9EBMJBfkiD2045AuzshHrmzsmkMDQGA1UdHwQtMCswKaAn
  39742. oCWGI2h0dHA6Ly9jcmwuc2VjdXJldHJ1c3QuY29tL1NHQ0EuY3JsMBAGCSsGAQQBgjcVAQQDAgEA
  39743. MA0GCSqGSIb3DQEBBQUAA4IBAQBjGghAfaReUw132HquHw0LURYD7xh8yOOvaliTFGCRsoTciE6+
  39744. OYo68+aCiV0BN7OrJKQVDpI1WkpEXk5X+nXOH0jOZvQ8QCaSmGwb7iRGDBezUqXbpZGRzzfTb+cn
  39745. CDpOGR86p1hcF895P4vkp9MmI50mD1hp/Ed+stCNi5O/KU9DaXR2Z0vPB4zmAve14bRDtUstFJ/5
  39746. 3CYNv6ZHdAbYiNE6KTCEztI5gGIbqMdXSbxqVVFnFUq+NQfk1XWYN3kwFNspnWzFacxHVaIw98xc
  39747. f8LDmBxrThaA63p4ZUWiABqvDA1VZDRIuJK58bRQKfJPIx/abKwfROHdI3hRW8cW
  39748. -----END CERTIFICATE-----
  39749. COMODO Certification Authority
  39750. ==============================
  39751. -----BEGIN CERTIFICATE-----
  39752. MIIEHTCCAwWgAwIBAgIQToEtioJl4AsC7j41AkblPTANBgkqhkiG9w0BAQUFADCBgTELMAkGA1UE
  39753. BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG
  39754. A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxJzAlBgNVBAMTHkNPTU9ETyBDZXJ0aWZpY2F0aW9uIEF1
  39755. dGhvcml0eTAeFw0wNjEyMDEwMDAwMDBaFw0yOTEyMzEyMzU5NTlaMIGBMQswCQYDVQQGEwJHQjEb
  39756. MBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQKExFD
  39757. T01PRE8gQ0EgTGltaXRlZDEnMCUGA1UEAxMeQ09NT0RPIENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  39758. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0ECLi3LjkRv3UcEbVASY06m/weaKXTuH
  39759. +7uIzg3jLz8GlvCiKVCZrts7oVewdFFxze1CkU1B/qnI2GqGd0S7WWaXUF601CxwRM/aN5VCaTww
  39760. xHGzUvAhTaHYujl8HJ6jJJ3ygxaYqhZ8Q5sVW7euNJH+1GImGEaaP+vB+fGQV+useg2L23IwambV
  39761. 4EajcNxo2f8ESIl33rXp+2dtQem8Ob0y2WIC8bGoPW43nOIv4tOiJovGuFVDiOEjPqXSJDlqR6sA
  39762. 1KGzqSX+DT+nHbrTUcELpNqsOO9VUCQFZUaTNE8tja3G1CEZ0o7KBWFxB3NH5YoZEr0ETc5OnKVI
  39763. rLsm9wIDAQABo4GOMIGLMB0GA1UdDgQWBBQLWOWLxkwVN6RAqTCpIb5HNlpW/zAOBgNVHQ8BAf8E
  39764. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zBJBgNVHR8EQjBAMD6gPKA6hjhodHRwOi8vY3JsLmNvbW9k
  39765. b2NhLmNvbS9DT01PRE9DZXJ0aWZpY2F0aW9uQXV0aG9yaXR5LmNybDANBgkqhkiG9w0BAQUFAAOC
  39766. AQEAPpiem/Yb6dc5t3iuHXIYSdOH5EOC6z/JqvWote9VfCFSZfnVDeFs9D6Mk3ORLgLETgdxb8CP
  39767. OGEIqB6BCsAvIC9Bi5HcSEW88cbeunZrM8gALTFGTO3nnc+IlP8zwFboJIYmuNg4ON8qa90SzMc/
  39768. RxdMosIGlgnW2/4/PEZB31jiVg88O8EckzXZOFKs7sjsLjBOlDW0JB9LeGna8gI4zJVSk/BwJVmc
  39769. IGfE7vmLV2H0knZ9P4SNVbfo5azV8fUZVqZa+5Acr5Pr5RzUZ5ddBA6+C4OmF4O5MBKgxTMVBbkN
  39770. +8cFduPYSo38NBejxiEovjBFMR7HeL5YYTisO+IBZQ==
  39771. -----END CERTIFICATE-----
  39772. Network Solutions Certificate Authority
  39773. =======================================
  39774. -----BEGIN CERTIFICATE-----
  39775. MIID5jCCAs6gAwIBAgIQV8szb8JcFuZHFhfjkDFo4DANBgkqhkiG9w0BAQUFADBiMQswCQYDVQQG
  39776. EwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMuMTAwLgYDVQQDEydOZXR3b3Jr
  39777. IFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMDYxMjAxMDAwMDAwWhcNMjkxMjMx
  39778. MjM1OTU5WjBiMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMu
  39779. MTAwLgYDVQQDEydOZXR3b3JrIFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggEiMA0G
  39780. CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDkvH6SMG3G2I4rC7xGzuAnlt7e+foS0zwzc7MEL7xx
  39781. jOWftiJgPl9dzgn/ggwbmlFQGiaJ3dVhXRncEg8tCqJDXRfQNJIg6nPPOCwGJgl6cvf6UDL4wpPT
  39782. aaIjzkGxzOTVHzbRijr4jGPiFFlp7Q3Tf2vouAPlT2rlmGNpSAW+Lv8ztumXWWn4Zxmuk2GWRBXT
  39783. crA/vGp97Eh/jcOrqnErU2lBUzS1sLnFBgrEsEX1QV1uiUV7PTsmjHTC5dLRfbIR1PtYMiKagMnc
  39784. /Qzpf14Dl847ABSHJ3A4qY5usyd2mFHgBeMhqxrVhSI8KbWaFsWAqPS7azCPL0YCorEMIuDTAgMB
  39785. AAGjgZcwgZQwHQYDVR0OBBYEFCEwyfsA106Y2oeqKtCnLrFAMadMMA4GA1UdDwEB/wQEAwIBBjAP
  39786. BgNVHRMBAf8EBTADAQH/MFIGA1UdHwRLMEkwR6BFoEOGQWh0dHA6Ly9jcmwubmV0c29sc3NsLmNv
  39787. bS9OZXR3b3JrU29sdXRpb25zQ2VydGlmaWNhdGVBdXRob3JpdHkuY3JsMA0GCSqGSIb3DQEBBQUA
  39788. A4IBAQC7rkvnt1frf6ott3NHhWrB5KUd5Oc86fRZZXe1eltajSU24HqXLjjAV2CDmAaDn7l2em5Q
  39789. 4LqILPxFzBiwmZVRDuwduIj/h1AcgsLj4DKAv6ALR8jDMe+ZZzKATxcheQxpXN5eNK4CtSbqUN9/
  39790. GGUsyfJj4akH/nxxH2szJGoeBfcFaMBqEssuXmHLrijTfsK0ZpEmXzwuJF/LWA/rKOyvEZbz3Htv
  39791. wKeI8lN3s2Berq4o2jUsbzRF0ybh3uxbTydrFny9RAQYgrOJeRcQcT16ohZO9QHNpGxlaKFJdlxD
  39792. ydi8NmdspZS11My5vWo1ViHe2MPr+8ukYEywVaCge1ey
  39793. -----END CERTIFICATE-----
  39794. COMODO ECC Certification Authority
  39795. ==================================
  39796. -----BEGIN CERTIFICATE-----
  39797. MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTELMAkGA1UEBhMC
  39798. R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE
  39799. ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBB
  39800. dXRob3JpdHkwHhcNMDgwMzA2MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0Ix
  39801. GzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR
  39802. Q09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRo
  39803. b3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSRFtSrYpn1PlILBs5BAH+X
  39804. 4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0JcfRK9ChQtP6IHG4/bC8vCVlbpVsLM5ni
  39805. wz2J+Wos77LTBumjQjBAMB0GA1UdDgQWBBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8E
  39806. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VG
  39807. FAkK+qDmfQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdvGDeA
  39808. U/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY=
  39809. -----END CERTIFICATE-----
  39810. Certigna
  39811. ========
  39812. -----BEGIN CERTIFICATE-----
  39813. MIIDqDCCApCgAwIBAgIJAP7c4wEPyUj/MA0GCSqGSIb3DQEBBQUAMDQxCzAJBgNVBAYTAkZSMRIw
  39814. EAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hMB4XDTA3MDYyOTE1MTMwNVoXDTI3
  39815. MDYyOTE1MTMwNVowNDELMAkGA1UEBhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczERMA8GA1UEAwwI
  39816. Q2VydGlnbmEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDIaPHJ1tazNHUmgh7stL7q
  39817. XOEm7RFHYeGifBZ4QCHkYJ5ayGPhxLGWkv8YbWkj4Sti993iNi+RB7lIzw7sebYs5zRLcAglozyH
  39818. GxnygQcPOJAZ0xH+hrTy0V4eHpbNgGzOOzGTtvKg0KmVEn2lmsxryIRWijOp5yIVUxbwzBfsV1/p
  39819. ogqYCd7jX5xv3EjjhQsVWqa6n6xI4wmy9/Qy3l40vhx4XUJbzg4ij02Q130yGLMLLGq/jj8UEYkg
  39820. DncUtT2UCIf3JR7VsmAA7G8qKCVuKj4YYxclPz5EIBb2JsglrgVKtOdjLPOMFlN+XPsRGgjBRmKf
  39821. Irjxwo1p3Po6WAbfAgMBAAGjgbwwgbkwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUGu3+QTmQ
  39822. tCRZvgHyUtVF9lo53BEwZAYDVR0jBF0wW4AUGu3+QTmQtCRZvgHyUtVF9lo53BGhOKQ2MDQxCzAJ
  39823. BgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hggkA/tzjAQ/J
  39824. SP8wDgYDVR0PAQH/BAQDAgEGMBEGCWCGSAGG+EIBAQQEAwIABzANBgkqhkiG9w0BAQUFAAOCAQEA
  39825. hQMeknH2Qq/ho2Ge6/PAD/Kl1NqV5ta+aDY9fm4fTIrv0Q8hbV6lUmPOEvjvKtpv6zf+EwLHyzs+
  39826. ImvaYS5/1HI93TDhHkxAGYwP15zRgzB7mFncfca5DClMoTOi62c6ZYTTluLtdkVwj7Ur3vkj1klu
  39827. PBS1xp81HlDQwY9qcEQCYsuuHWhBp6pX6FOqB9IG9tUUBguRA3UsbHK1YZWaDYu5Def131TN3ubY
  39828. 1gkIl2PlwS6wt0QmwCbAr1UwnjvVNioZBPRcHv/PLLf/0P2HQBHVESO7SMAhqaQoLf0V+LBOK/Qw
  39829. WyH8EZE0vkHve52Xdf+XlcCWWC/qu0bXu+TZLg==
  39830. -----END CERTIFICATE-----
  39831. Cybertrust Global Root
  39832. ======================
  39833. -----BEGIN CERTIFICATE-----
  39834. MIIDoTCCAomgAwIBAgILBAAAAAABD4WqLUgwDQYJKoZIhvcNAQEFBQAwOzEYMBYGA1UEChMPQ3li
  39835. ZXJ0cnVzdCwgSW5jMR8wHQYDVQQDExZDeWJlcnRydXN0IEdsb2JhbCBSb290MB4XDTA2MTIxNTA4
  39836. MDAwMFoXDTIxMTIxNTA4MDAwMFowOzEYMBYGA1UEChMPQ3liZXJ0cnVzdCwgSW5jMR8wHQYDVQQD
  39837. ExZDeWJlcnRydXN0IEdsb2JhbCBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
  39838. +Mi8vRRQZhP/8NN57CPytxrHjoXxEnOmGaoQ25yiZXRadz5RfVb23CO21O1fWLE3TdVJDm71aofW
  39839. 0ozSJ8bi/zafmGWgE07GKmSb1ZASzxQG9Dvj1Ci+6A74q05IlG2OlTEQXO2iLb3VOm2yHLtgwEZL
  39840. AfVJrn5GitB0jaEMAs7u/OePuGtm839EAL9mJRQr3RAwHQeWP032a7iPt3sMpTjr3kfb1V05/Iin
  39841. 89cqdPHoWqI7n1C6poxFNcJQZZXcY4Lv3b93TZxiyWNzFtApD0mpSPCzqrdsxacwOUBdrsTiXSZT
  39842. 8M4cIwhhqJQZugRiQOwfOHB3EgZxpzAYXSUnpQIDAQABo4GlMIGiMA4GA1UdDwEB/wQEAwIBBjAP
  39843. BgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBS2CHsNesysIEyGVjJez6tuhS1wVzA/BgNVHR8EODA2
  39844. MDSgMqAwhi5odHRwOi8vd3d3Mi5wdWJsaWMtdHJ1c3QuY29tL2NybC9jdC9jdHJvb3QuY3JsMB8G
  39845. A1UdIwQYMBaAFLYIew16zKwgTIZWMl7Pq26FLXBXMA0GCSqGSIb3DQEBBQUAA4IBAQBW7wojoFRO
  39846. lZfJ+InaRcHUowAl9B8Tq7ejhVhpwjCt2BWKLePJzYFa+HMjWqd8BfP9IjsO0QbE2zZMcwSO5bAi
  39847. 5MXzLqXZI+O4Tkogp24CJJ8iYGd7ix1yCcUxXOl5n4BHPa2hCwcUPUf/A2kaDAtE52Mlp3+yybh2
  39848. hO0j9n0Hq0V+09+zv+mKts2oomcrUtW3ZfA5TGOgkXmTUg9U3YO7n9GPp1Nzw8v/MOx8BLjYRB+T
  39849. X3EJIrduPuocA06dGiBh+4E37F78CkWr1+cXVdCg6mCbpvbjjFspwgZgFJ0tl0ypkxWdYcQBX0jW
  39850. WL1WMRJOEcgh4LMRkWXbtKaIOM5V
  39851. -----END CERTIFICATE-----
  39852. ePKI Root Certification Authority
  39853. =================================
  39854. -----BEGIN CERTIFICATE-----
  39855. MIIFsDCCA5igAwIBAgIQFci9ZUdcr7iXAF7kBtK8nTANBgkqhkiG9w0BAQUFADBeMQswCQYDVQQG
  39856. EwJUVzEjMCEGA1UECgwaQ2h1bmdod2EgVGVsZWNvbSBDby4sIEx0ZC4xKjAoBgNVBAsMIWVQS0kg
  39857. Um9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNDEyMjAwMjMxMjdaFw0zNDEyMjAwMjMx
  39858. MjdaMF4xCzAJBgNVBAYTAlRXMSMwIQYDVQQKDBpDaHVuZ2h3YSBUZWxlY29tIENvLiwgTHRkLjEq
  39859. MCgGA1UECwwhZVBLSSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0B
  39860. AQEFAAOCAg8AMIICCgKCAgEA4SUP7o3biDN1Z82tH306Tm2d0y8U82N0ywEhajfqhFAHSyZbCUNs
  39861. IZ5qyNUD9WBpj8zwIuQf5/dqIjG3LBXy4P4AakP/h2XGtRrBp0xtInAhijHyl3SJCRImHJ7K2RKi
  39862. lTza6We/CKBk49ZCt0Xvl/T29de1ShUCWH2YWEtgvM3XDZoTM1PRYfl61dd4s5oz9wCGzh1NlDiv
  39863. qOx4UXCKXBCDUSH3ET00hl7lSM2XgYI1TBnsZfZrxQWh7kcT1rMhJ5QQCtkkO7q+RBNGMD+XPNjX
  39864. 12ruOzjjK9SXDrkb5wdJfzcq+Xd4z1TtW0ado4AOkUPB1ltfFLqfpo0kR0BZv3I4sjZsN/+Z0V0O
  39865. WQqraffAsgRFelQArr5T9rXn4fg8ozHSqf4hUmTFpmfwdQcGlBSBVcYn5AGPF8Fqcde+S/uUWH1+
  39866. ETOxQvdibBjWzwloPn9s9h6PYq2lY9sJpx8iQkEeb5mKPtf5P0B6ebClAZLSnT0IFaUQAS2zMnao
  39867. lQ2zepr7BxB4EW/hj8e6DyUadCrlHJhBmd8hh+iVBmoKs2pHdmX2Os+PYhcZewoozRrSgx4hxyy/
  39868. vv9haLdnG7t4TY3OZ+XkwY63I2binZB1NJipNiuKmpS5nezMirH4JYlcWrYvjB9teSSnUmjDhDXi
  39869. Zo1jDiVN1Rmy5nk3pyKdVDECAwEAAaNqMGgwHQYDVR0OBBYEFB4M97Zn8uGSJglFwFU5Lnc/Qkqi
  39870. MAwGA1UdEwQFMAMBAf8wOQYEZyoHAAQxMC8wLQIBADAJBgUrDgMCGgUAMAcGBWcqAwAABBRFsMLH
  39871. ClZ87lt4DJX5GFPBphzYEDANBgkqhkiG9w0BAQUFAAOCAgEACbODU1kBPpVJufGBuvl2ICO1J2B0
  39872. 1GqZNF5sAFPZn/KmsSQHRGoqxqWOeBLoR9lYGxMqXnmbnwoqZ6YlPwZpVnPDimZI+ymBV3QGypzq
  39873. KOg4ZyYr8dW1P2WT+DZdjo2NQCCHGervJ8A9tDkPJXtoUHRVnAxZfVo9QZQlUgjgRywVMRnVvwdV
  39874. xrsStZf0X4OFunHB2WyBEXYKCrC/gpf36j36+uwtqSiUO1bd0lEursC9CBWMd1I0ltabrNMdjmEP
  39875. NXubrjlpC2JgQCA2j6/7Nu4tCEoduL+bXPjqpRugc6bY+G7gMwRfaKonh+3ZwZCc7b3jajWvY9+r
  39876. GNm65ulK6lCKD2GTHuItGeIwlDWSXQ62B68ZgI9HkFFLLk3dheLSClIKF5r8GrBQAuUBo2M3IUxE
  39877. xJtRmREOc5wGj1QupyheRDmHVi03vYVElOEMSyycw5KFNGHLD7ibSkNS/jQ6fbjpKdx2qcgw+BRx
  39878. gMYeNkh0IkFch4LoGHGLQYlE535YW6i4jRPpp2zDR+2zGp1iro2C6pSe3VkQw63d4k3jMdXH7Ojy
  39879. sP6SHhYKGvzZ8/gntsm+HbRsZJB/9OTEW9c3rkIO3aQab3yIVMUWbuF6aC74Or8NpDyJO3inTmOD
  39880. BCEIZ43ygknQW/2xzQ+DhNQ+IIX3Sj0rnP0qCglN6oH4EZw=
  39881. -----END CERTIFICATE-----
  39882. certSIGN ROOT CA
  39883. ================
  39884. -----BEGIN CERTIFICATE-----
  39885. MIIDODCCAiCgAwIBAgIGIAYFFnACMA0GCSqGSIb3DQEBBQUAMDsxCzAJBgNVBAYTAlJPMREwDwYD
  39886. VQQKEwhjZXJ0U0lHTjEZMBcGA1UECxMQY2VydFNJR04gUk9PVCBDQTAeFw0wNjA3MDQxNzIwMDRa
  39887. Fw0zMTA3MDQxNzIwMDRaMDsxCzAJBgNVBAYTAlJPMREwDwYDVQQKEwhjZXJ0U0lHTjEZMBcGA1UE
  39888. CxMQY2VydFNJR04gUk9PVCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALczuX7I
  39889. JUqOtdu0KBuqV5Do0SLTZLrTk+jUrIZhQGpgV2hUhE28alQCBf/fm5oqrl0Hj0rDKH/v+yv6efHH
  39890. rfAQUySQi2bJqIirr1qjAOm+ukbuW3N7LBeCgV5iLKECZbO9xSsAfsT8AzNXDe3i+s5dRdY4zTW2
  39891. ssHQnIFKquSyAVwdj1+ZxLGt24gh65AIgoDzMKND5pCCrlUoSe1b16kQOA7+j0xbm0bqQfWwCHTD
  39892. 0IgztnzXdN/chNFDDnU5oSVAKOp4yw4sLjmdjItuFhwvJoIQ4uNllAoEwF73XVv4EOLQunpL+943
  39893. AAAaWyjj0pxzPjKHmKHJUS/X3qwzs08CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8B
  39894. Af8EBAMCAcYwHQYDVR0OBBYEFOCMm9slSbPxfIbWskKHC9BroNnkMA0GCSqGSIb3DQEBBQUAA4IB
  39895. AQA+0hyJLjX8+HXd5n9liPRyTMks1zJO890ZeUe9jjtbkw9QSSQTaxQGcu8J06Gh40CEyecYMnQ8
  39896. SG4Pn0vU9x7Tk4ZkVJdjclDVVc/6IJMCopvDI5NOFlV2oHB5bc0hH88vLbwZ44gx+FkagQnIl6Z0
  39897. x2DEW8xXjrJ1/RsCCdtZb3KTafcxQdaIOL+Hsr0Wefmq5L6IJd1hJyMctTEHBDa0GpC9oHRxUIlt
  39898. vBTjD4au8as+x6AJzKNI0eDbZOeStc+vckNwi/nDhDwTqn6Sm1dTk/pwwpEOMfmbZ13pljheX7Nz
  39899. TogVZ96edhBiIL5VaZVDADlN9u6wWk5JRFRYX0KD
  39900. -----END CERTIFICATE-----
  39901. NetLock Arany (Class Gold) Főtanúsítvány
  39902. ========================================
  39903. -----BEGIN CERTIFICATE-----
  39904. MIIEFTCCAv2gAwIBAgIGSUEs5AAQMA0GCSqGSIb3DQEBCwUAMIGnMQswCQYDVQQGEwJIVTERMA8G
  39905. A1UEBwwIQnVkYXBlc3QxFTATBgNVBAoMDE5ldExvY2sgS2Z0LjE3MDUGA1UECwwuVGFuw7pzw610
  39906. dsOhbnlraWFkw7NrIChDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzKTE1MDMGA1UEAwwsTmV0TG9jayBB
  39907. cmFueSAoQ2xhc3MgR29sZCkgRsWRdGFuw7pzw610dsOhbnkwHhcNMDgxMjExMTUwODIxWhcNMjgx
  39908. MjA2MTUwODIxWjCBpzELMAkGA1UEBhMCSFUxETAPBgNVBAcMCEJ1ZGFwZXN0MRUwEwYDVQQKDAxO
  39909. ZXRMb2NrIEtmdC4xNzA1BgNVBAsMLlRhbsO6c8OtdHbDoW55a2lhZMOzayAoQ2VydGlmaWNhdGlv
  39910. biBTZXJ2aWNlcykxNTAzBgNVBAMMLE5ldExvY2sgQXJhbnkgKENsYXNzIEdvbGQpIEbFkXRhbsO6
  39911. c8OtdHbDoW55MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxCRec75LbRTDofTjl5Bu
  39912. 0jBFHjzuZ9lk4BqKf8owyoPjIMHj9DrTlF8afFttvzBPhCf2nx9JvMaZCpDyD/V/Q4Q3Y1GLeqVw
  39913. /HpYzY6b7cNGbIRwXdrzAZAj/E4wqX7hJ2Pn7WQ8oLjJM2P+FpD/sLj916jAwJRDC7bVWaaeVtAk
  39914. H3B5r9s5VA1lddkVQZQBr17s9o3x/61k/iCa11zr/qYfCGSji3ZVrR47KGAuhyXoqq8fxmRGILdw
  39915. fzzeSNuWU7c5d+Qa4scWhHaXWy+7GRWF+GmF9ZmnqfI0p6m2pgP8b4Y9VHx2BJtr+UBdADTHLpl1
  39916. neWIA6pN+APSQnbAGwIDAKiLo0UwQzASBgNVHRMBAf8ECDAGAQH/AgEEMA4GA1UdDwEB/wQEAwIB
  39917. BjAdBgNVHQ4EFgQUzPpnk/C2uNClwB7zU/2MU9+D15YwDQYJKoZIhvcNAQELBQADggEBAKt/7hwW
  39918. qZw8UQCgwBEIBaeZ5m8BiFRhbvG5GK1Krf6BQCOUL/t1fC8oS2IkgYIL9WHxHG64YTjrgfpioTta
  39919. YtOUZcTh5m2C+C8lcLIhJsFyUR+MLMOEkMNaj7rP9KdlpeuY0fsFskZ1FSNqb4VjMIDw1Z4fKRzC
  39920. bLBQWV2QWzuoDTDPv31/zvGdg73JRm4gpvlhUbohL3u+pRVjodSVh/GeufOJ8z2FuLjbvrW5Kfna
  39921. NwUASZQDhETnv0Mxz3WLJdH0pmT1kvarBes96aULNmLazAZfNou2XjG4Kvte9nHfRCaexOYNkbQu
  39922. dZWAUWpLMKawYqGT8ZvYzsRjdT9ZR7E=
  39923. -----END CERTIFICATE-----
  39924. Hongkong Post Root CA 1
  39925. =======================
  39926. -----BEGIN CERTIFICATE-----
  39927. MIIDMDCCAhigAwIBAgICA+gwDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCSEsxFjAUBgNVBAoT
  39928. DUhvbmdrb25nIFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3QgUm9vdCBDQSAxMB4XDTAzMDUx
  39929. NTA1MTMxNFoXDTIzMDUxNTA0NTIyOVowRzELMAkGA1UEBhMCSEsxFjAUBgNVBAoTDUhvbmdrb25n
  39930. IFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3QgUm9vdCBDQSAxMIIBIjANBgkqhkiG9w0BAQEF
  39931. AAOCAQ8AMIIBCgKCAQEArP84tulmAknjorThkPlAj3n54r15/gK97iSSHSL22oVyaf7XPwnU3ZG1
  39932. ApzQjVrhVcNQhrkpJsLj2aDxaQMoIIBFIi1WpztUlVYiWR8o3x8gPW2iNr4joLFutbEnPzlTCeqr
  39933. auh0ssJlXI6/fMN4hM2eFvz1Lk8gKgifd/PFHsSaUmYeSF7jEAaPIpjhZY4bXSNmO7ilMlHIhqqh
  39934. qZ5/dpTCpmy3QfDVyAY45tQM4vM7TG1QjMSDJ8EThFk9nnV0ttgCXjqQesBCNnLsak3c78QA3xMY
  39935. V18meMjWCnl3v/evt3a5pQuEF10Q6m/hq5URX208o1xNg1vysxmKgIsLhwIDAQABoyYwJDASBgNV
  39936. HRMBAf8ECDAGAQH/AgEDMA4GA1UdDwEB/wQEAwIBxjANBgkqhkiG9w0BAQUFAAOCAQEADkbVPK7i
  39937. h9legYsCmEEIjEy82tvuJxuC52pF7BaLT4Wg87JwvVqWuspube5Gi27nKi6Wsxkz67SfqLI37pio
  39938. l7Yutmcn1KZJ/RyTZXaeQi/cImyaT/JaFTmxcdcrUehtHJjA2Sr0oYJ71clBoiMBdDhViw+5Lmei
  39939. IAQ32pwL0xch4I+XeTRvhEgCIDMb5jREn5Fw9IBehEPCKdJsEhTkYY2sEJCehFC78JZvRZ+K88ps
  39940. T/oROhUVRsPNH4NbLUES7VBnQRM9IauUiqpOfMGx+6fWtScvl6tu4B3i0RwsH0Ti/L6RoZz71ilT
  39941. c4afU9hDDl3WY4JxHYB0yvbiAmvZWg==
  39942. -----END CERTIFICATE-----
  39943. SecureSign RootCA11
  39944. ===================
  39945. -----BEGIN CERTIFICATE-----
  39946. MIIDbTCCAlWgAwIBAgIBATANBgkqhkiG9w0BAQUFADBYMQswCQYDVQQGEwJKUDErMCkGA1UEChMi
  39947. SmFwYW4gQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcywgSW5jLjEcMBoGA1UEAxMTU2VjdXJlU2lnbiBS
  39948. b290Q0ExMTAeFw0wOTA0MDgwNDU2NDdaFw0yOTA0MDgwNDU2NDdaMFgxCzAJBgNVBAYTAkpQMSsw
  39949. KQYDVQQKEyJKYXBhbiBDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzLCBJbmMuMRwwGgYDVQQDExNTZWN1
  39950. cmVTaWduIFJvb3RDQTExMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA/XeqpRyQBTvL
  39951. TJszi1oURaTnkBbR31fSIRCkF/3frNYfp+TbfPfs37gD2pRY/V1yfIw/XwFndBWW4wI8h9uuywGO
  39952. wvNmxoVF9ALGOrVisq/6nL+k5tSAMJjzDbaTj6nU2DbysPyKyiyhFTOVMdrAG/LuYpmGYz+/3ZMq
  39953. g6h2uRMft85OQoWPIucuGvKVCbIFtUROd6EgvanyTgp9UK31BQ1FT0Zx/Sg+U/sE2C3XZR1KG/rP
  39954. O7AxmjVuyIsG0wCR8pQIZUyxNAYAeoni8McDWc/V1uinMrPmmECGxc0nEovMe863ETxiYAcjPitA
  39955. bpSACW22s293bzUIUPsCh8U+iQIDAQABo0IwQDAdBgNVHQ4EFgQUW/hNT7KlhtQ60vFjmqC+CfZX
  39956. t94wDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAKCh
  39957. OBZmLqdWHyGcBvod7bkixTgm2E5P7KN/ed5GIaGHd48HCJqypMWvDzKYC3xmKbabfSVSSUOrTC4r
  39958. bnpwrxYO4wJs+0LmGJ1F2FXI6Dvd5+H0LgscNFxsWEr7jIhQX5Ucv+2rIrVls4W6ng+4reV6G4pQ
  39959. Oh29Dbx7VFALuUKvVaAYga1lme++5Jy/xIWrQbJUb9wlze144o4MjQlJ3WN7WmmWAiGovVJZ6X01
  39960. y8hSyn+B/tlr0/cR7SXf+Of5pPpyl4RTDaXQMhhRdlkUbA/r7F+AjHVDg8OFmP9Mni0N5HeDk061
  39961. lgeLKBObjBmNQSdJQO7e5iNEOdyhIta6A/I=
  39962. -----END CERTIFICATE-----
  39963. Microsec e-Szigno Root CA 2009
  39964. ==============================
  39965. -----BEGIN CERTIFICATE-----
  39966. MIIECjCCAvKgAwIBAgIJAMJ+QwRORz8ZMA0GCSqGSIb3DQEBCwUAMIGCMQswCQYDVQQGEwJIVTER
  39967. MA8GA1UEBwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jv
  39968. c2VjIGUtU3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5o
  39969. dTAeFw0wOTA2MTYxMTMwMThaFw0yOTEyMzAxMTMwMThaMIGCMQswCQYDVQQGEwJIVTERMA8GA1UE
  39970. BwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jvc2VjIGUt
  39971. U3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5odTCCASIw
  39972. DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOn4j/NjrdqG2KfgQvvPkd6mJviZpWNwrZuuyjNA
  39973. fW2WbqEORO7hE52UQlKavXWFdCyoDh2Tthi3jCyoz/tccbna7P7ofo/kLx2yqHWH2Leh5TvPmUpG
  39974. 0IMZfcChEhyVbUr02MelTTMuhTlAdX4UfIASmFDHQWe4oIBhVKZsTh/gnQ4H6cm6M+f+wFUoLAKA
  39975. pxn1ntxVUwOXewdI/5n7N4okxFnMUBBjjqqpGrCEGob5X7uxUG6k0QrM1XF+H6cbfPVTbiJfyyvm
  39976. 1HxdrtbCxkzlBQHZ7Vf8wSN5/PrIJIOV87VqUQHQd9bpEqH5GoP7ghu5sJf0dgYzQ0mg/wu1+rUC
  39977. AwEAAaOBgDB+MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTLD8bf
  39978. QkPMPcu1SCOhGnqmKrs0aDAfBgNVHSMEGDAWgBTLD8bfQkPMPcu1SCOhGnqmKrs0aDAbBgNVHREE
  39979. FDASgRBpbmZvQGUtc3ppZ25vLmh1MA0GCSqGSIb3DQEBCwUAA4IBAQDJ0Q5eLtXMs3w+y/w9/w0o
  39980. lZMEyL/azXm4Q5DwpL7v8u8hmLzU1F0G9u5C7DBsoKqpyvGvivo/C3NqPuouQH4frlRheesuCDfX
  39981. I/OMn74dseGkddug4lQUsbocKaQY9hK6ohQU4zE1yED/t+AFdlfBHFny+L/k7SViXITwfn4fs775
  39982. tyERzAMBVnCnEJIeGzSBHq2cGsMEPO0CYdYeBvNfOofyK/FFh+U9rNHHV4S9a67c2Pm2G2JwCz02
  39983. yULyMtd6YebS2z3PyKnJm9zbWETXbzivf3jTo60adbocwTZ8jx5tHMN1Rq41Bab2XD0h7lbwyYIi
  39984. LXpUq3DDfSJlgnCW
  39985. -----END CERTIFICATE-----
  39986. GlobalSign Root CA - R3
  39987. =======================
  39988. -----BEGIN CERTIFICATE-----
  39989. MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4GA1UECxMXR2xv
  39990. YmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh
  39991. bFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT
  39992. aWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln
  39993. bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWt
  39994. iHL8RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsTgHeMCOFJ
  39995. 0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmmKPZpO/bLyCiR5Z2KYVc3
  39996. rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zdQQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjl
  39997. OCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZXriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2
  39998. xmmFghcCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE
  39999. FI/wS3+oLkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZURUm7
  40000. lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMpjjM5RcOO5LlXbKr8
  40001. EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK6fBdRoyV3XpYKBovHd7NADdBj+1E
  40002. bddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQXmcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18
  40003. YIvDQVETI53O9zJrlAGomecsMx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7r
  40004. kpeDMdmztcpHWD9f
  40005. -----END CERTIFICATE-----
  40006. Autoridad de Certificacion Firmaprofesional CIF A62634068
  40007. =========================================================
  40008. -----BEGIN CERTIFICATE-----
  40009. MIIGFDCCA/ygAwIBAgIIU+w77vuySF8wDQYJKoZIhvcNAQEFBQAwUTELMAkGA1UEBhMCRVMxQjBA
  40010. BgNVBAMMOUF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1hcHJvZmVzaW9uYWwgQ0lGIEE2
  40011. MjYzNDA2ODAeFw0wOTA1MjAwODM4MTVaFw0zMDEyMzEwODM4MTVaMFExCzAJBgNVBAYTAkVTMUIw
  40012. QAYDVQQDDDlBdXRvcmlkYWQgZGUgQ2VydGlmaWNhY2lvbiBGaXJtYXByb2Zlc2lvbmFsIENJRiBB
  40013. NjI2MzQwNjgwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKlmuO6vj78aI14H9M2uDD
  40014. Utd9thDIAl6zQyrET2qyyhxdKJp4ERppWVevtSBC5IsP5t9bpgOSL/UR5GLXMnE42QQMcas9UX4P
  40015. B99jBVzpv5RvwSmCwLTaUbDBPLutN0pcyvFLNg4kq7/DhHf9qFD0sefGL9ItWY16Ck6WaVICqjaY
  40016. 7Pz6FIMMNx/Jkjd/14Et5cS54D40/mf0PmbR0/RAz15iNA9wBj4gGFrO93IbJWyTdBSTo3OxDqqH
  40017. ECNZXyAFGUftaI6SEspd/NYrspI8IM/hX68gvqB2f3bl7BqGYTM+53u0P6APjqK5am+5hyZvQWyI
  40018. plD9amML9ZMWGxmPsu2bm8mQ9QEM3xk9Dz44I8kvjwzRAv4bVdZO0I08r0+k8/6vKtMFnXkIoctX
  40019. MbScyJCyZ/QYFpM6/EfY0XiWMR+6KwxfXZmtY4laJCB22N/9q06mIqqdXuYnin1oKaPnirjaEbsX
  40020. LZmdEyRG98Xi2J+Of8ePdG1asuhy9azuJBCtLxTa/y2aRnFHvkLfuwHb9H/TKI8xWVvTyQKmtFLK
  40021. bpf7Q8UIJm+K9Lv9nyiqDdVF8xM6HdjAeI9BZzwelGSuewvF6NkBiDkal4ZkQdU7hwxu+g/GvUgU
  40022. vzlN1J5Bto+WHWOWk9mVBngxaJ43BjuAiUVhOSPHG0SjFeUc+JIwuwIDAQABo4HvMIHsMBIGA1Ud
  40023. EwEB/wQIMAYBAf8CAQEwDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBRlzeurNR4APn7VdMActHNH
  40024. DhpkLzCBpgYDVR0gBIGeMIGbMIGYBgRVHSAAMIGPMC8GCCsGAQUFBwIBFiNodHRwOi8vd3d3LmZp
  40025. cm1hcHJvZmVzaW9uYWwuY29tL2NwczBcBggrBgEFBQcCAjBQHk4AUABhAHMAZQBvACAAZABlACAA
  40026. bABhACAAQgBvAG4AYQBuAG8AdgBhACAANAA3ACAAQgBhAHIAYwBlAGwAbwBuAGEAIAAwADgAMAAx
  40027. ADcwDQYJKoZIhvcNAQEFBQADggIBABd9oPm03cXF661LJLWhAqvdpYhKsg9VSytXjDvlMd3+xDLx
  40028. 51tkljYyGOylMnfX40S2wBEqgLk9am58m9Ot/MPWo+ZkKXzR4Tgegiv/J2Wv+xYVxC5xhOW1//qk
  40029. R71kMrv2JYSiJ0L1ILDCExARzRAVukKQKtJE4ZYm6zFIEv0q2skGz3QeqUvVhyj5eTSSPi5E6PaP
  40030. T481PyWzOdxjKpBrIF/EUhJOlywqrJ2X3kjyo2bbwtKDlaZmp54lD+kLM5FlClrD2VQS3a/DTg4f
  40031. Jl4N3LON7NWBcN7STyQF82xO9UxJZo3R/9ILJUFI/lGExkKvgATP0H5kSeTy36LssUzAKh3ntLFl
  40032. osS88Zj0qnAHY7S42jtM+kAiMFsRpvAFDsYCA0irhpuF3dvd6qJ2gHN99ZwExEWN57kci57q13XR
  40033. crHedUTnQn3iV2t93Jm8PYMo6oCTjcVMZcFwgbg4/EMxsvYDNEeyrPsiBsse3RdHHF9mudMaotoR
  40034. saS8I8nkvof/uZS2+F0gStRf571oe2XyFR7SOqkt6dhrJKyXWERHrVkY8SFlcN7ONGCoQPHzPKTD
  40035. KCOM/iczQ0CgFzzr6juwcqajuUpLXhZI9LK8yIySxZ2frHI2vDSANGupi5LAuBft7HZT9SQBjLMi
  40036. 6Et8Vcad+qMUu2WFbm5PEn4KPJ2V
  40037. -----END CERTIFICATE-----
  40038. Izenpe.com
  40039. ==========
  40040. -----BEGIN CERTIFICATE-----
  40041. MIIF8TCCA9mgAwIBAgIQALC3WhZIX7/hy/WL1xnmfTANBgkqhkiG9w0BAQsFADA4MQswCQYDVQQG
  40042. EwJFUzEUMBIGA1UECgwLSVpFTlBFIFMuQS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wHhcNMDcxMjEz
  40043. MTMwODI4WhcNMzcxMjEzMDgyNzI1WjA4MQswCQYDVQQGEwJFUzEUMBIGA1UECgwLSVpFTlBFIFMu
  40044. QS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDJ
  40045. 03rKDx6sp4boFmVqscIbRTJxldn+EFvMr+eleQGPicPK8lVx93e+d5TzcqQsRNiekpsUOqHnJJAK
  40046. ClaOxdgmlOHZSOEtPtoKct2jmRXagaKH9HtuJneJWK3W6wyyQXpzbm3benhB6QiIEn6HLmYRY2xU
  40047. +zydcsC8Lv/Ct90NduM61/e0aL6i9eOBbsFGb12N4E3GVFWJGjMxCrFXuaOKmMPsOzTFlUFpfnXC
  40048. PCDFYbpRR6AgkJOhkEvzTnyFRVSa0QUmQbC1TR0zvsQDyCV8wXDbO/QJLVQnSKwv4cSsPsjLkkxT
  40049. OTcj7NMB+eAJRE1NZMDhDVqHIrytG6P+JrUV86f8hBnp7KGItERphIPzidF0BqnMC9bC3ieFUCbK
  40050. F7jJeodWLBoBHmy+E60QrLUk9TiRodZL2vG70t5HtfG8gfZZa88ZU+mNFctKy6lvROUbQc/hhqfK
  40051. 0GqfvEyNBjNaooXlkDWgYlwWTvDjovoDGrQscbNYLN57C9saD+veIR8GdwYDsMnvmfzAuU8Lhij+
  40052. 0rnq49qlw0dpEuDb8PYZi+17cNcC1u2HGCgsBCRMd+RIihrGO5rUD8r6ddIBQFqNeb+Lz0vPqhbB
  40053. leStTIo+F5HUsWLlguWABKQDfo2/2n+iD5dPDNMN+9fR5XJ+HMh3/1uaD7euBUbl8agW7EekFwID
  40054. AQABo4H2MIHzMIGwBgNVHREEgagwgaWBD2luZm9AaXplbnBlLmNvbaSBkTCBjjFHMEUGA1UECgw+
  40055. SVpFTlBFIFMuQS4gLSBDSUYgQTAxMzM3MjYwLVJNZXJjLlZpdG9yaWEtR2FzdGVpeiBUMTA1NSBG
  40056. NjIgUzgxQzBBBgNVBAkMOkF2ZGEgZGVsIE1lZGl0ZXJyYW5lbyBFdG9yYmlkZWEgMTQgLSAwMTAx
  40057. MCBWaXRvcmlhLUdhc3RlaXowDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O
  40058. BBYEFB0cZQ6o8iV7tJHP5LGx5r1VdGwFMA0GCSqGSIb3DQEBCwUAA4ICAQB4pgwWSp9MiDrAyw6l
  40059. Fn2fuUhfGI8NYjb2zRlrrKvV9pF9rnHzP7MOeIWblaQnIUdCSnxIOvVFfLMMjlF4rJUT3sb9fbga
  40060. kEyrkgPH7UIBzg/YsfqikuFgba56awmqxinuaElnMIAkejEWOVt+8Rwu3WwJrfIxwYJOubv5vr8q
  40061. hT/AQKM6WfxZSzwoJNu0FXWuDYi6LnPAvViH5ULy617uHjAimcs30cQhbIHsvm0m5hzkQiCeR7Cs
  40062. g1lwLDXWrzY0tM07+DKo7+N4ifuNRSzanLh+QBxh5z6ikixL8s36mLYp//Pye6kfLqCTVyvehQP5
  40063. aTfLnnhqBbTFMXiJ7HqnheG5ezzevh55hM6fcA5ZwjUukCox2eRFekGkLhObNA5me0mrZJfQRsN5
  40064. nXJQY6aYWwa9SG3YOYNw6DXwBdGqvOPbyALqfP2C2sJbUjWumDqtujWTI6cfSN01RpiyEGjkpTHC
  40065. ClguGYEQyVB1/OpaFs4R1+7vUIgtYf8/QnMFlEPVjjxOAToZpR9GTnfQXeWBIiGH/pR9hNiTrdZo
  40066. Q0iy2+tzJOeRf1SktoA+naM8THLCV8Sg1Mw4J87VBp6iSNnpn86CcDaTmjvfliHjWbcM2pE38P1Z
  40067. WrOZyGlsQyYBNWNgVYkDOnXYukrZVP/u3oDYLdE41V4tC5h9Pmzb/CaIxw==
  40068. -----END CERTIFICATE-----
  40069. Go Daddy Root Certificate Authority - G2
  40070. ========================================
  40071. -----BEGIN CERTIFICATE-----
  40072. MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  40073. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoTEUdvRGFkZHkuY29tLCBJbmMu
  40074. MTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5
  40075. MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgYMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6
  40076. b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjExMC8G
  40077. A1UEAxMoR28gRGFkZHkgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZI
  40078. hvcNAQEBBQADggEPADCCAQoCggEBAL9xYgjx+lk09xvJGKP3gElY6SKDE6bFIEMBO4Tx5oVJnyfq
  40079. 9oQbTqC023CYxzIBsQU+B07u9PpPL1kwIuerGVZr4oAH/PMWdYA5UXvl+TW2dE6pjYIT5LY/qQOD
  40080. +qK+ihVqf94Lw7YZFAXK6sOoBJQ7RnwyDfMAZiLIjWltNowRGLfTshxgtDj6AozO091GB94KPutd
  40081. fMh8+7ArU6SSYmlRJQVhGkSBjCypQ5Yj36w6gZoOKcUcqeldHraenjAKOc7xiID7S13MMuyFYkMl
  40082. NAJWJwGRtDtwKj9useiciAF9n9T521NtYJ2/LOdYq7hfRvzOxBsDPAnrSTFcaUaz4EcCAwEAAaNC
  40083. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFDqahQcQZyi27/a9
  40084. BUFuIMGU2g/eMA0GCSqGSIb3DQEBCwUAA4IBAQCZ21151fmXWWcDYfF+OwYxdS2hII5PZYe096ac
  40085. vNjpL9DbWu7PdIxztDhC2gV7+AJ1uP2lsdeu9tfeE8tTEH6KRtGX+rcuKxGrkLAngPnon1rpN5+r
  40086. 5N9ss4UXnT3ZJE95kTXWXwTrgIOrmgIttRD02JDHBHNA7XIloKmf7J6raBKZV8aPEjoJpL1E/QYV
  40087. N8Gb5DKj7Tjo2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO
  40088. LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI4uJEvlz36hz1
  40089. -----END CERTIFICATE-----
  40090. Starfield Root Certificate Authority - G2
  40091. =========================================
  40092. -----BEGIN CERTIFICATE-----
  40093. MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  40094. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s
  40095. b2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVsZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0
  40096. eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAw
  40097. DgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQg
  40098. VGVjaG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZpY2F0ZSBB
  40099. dXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL3twQP89o/8ArFv
  40100. W59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMgnLRJdzIpVv257IzdIvpy3Cdhl+72WoTs
  40101. bhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNk
  40102. N3mSwOxGXn/hbVNMYq/NHwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7Nf
  40103. ZTD4p7dNdloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0HZbU
  40104. JtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  40105. AQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0GCSqGSIb3DQEBCwUAA4IBAQARWfol
  40106. TwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjUsHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx
  40107. 4mcujJUDJi5DnUox9g61DLu34jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUw
  40108. F5okxBDgBPfg8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K
  40109. pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1mMpYjn0q7pBZ
  40110. c2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0
  40111. -----END CERTIFICATE-----
  40112. Starfield Services Root Certificate Authority - G2
  40113. ==================================================
  40114. -----BEGIN CERTIFICATE-----
  40115. MIID7zCCAtegAwIBAgIBADANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  40116. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s
  40117. b2dpZXMsIEluYy4xOzA5BgNVBAMTMlN0YXJmaWVsZCBTZXJ2aWNlcyBSb290IENlcnRpZmljYXRl
  40118. IEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgZgxCzAJBgNV
  40119. BAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxT
  40120. dGFyZmllbGQgVGVjaG5vbG9naWVzLCBJbmMuMTswOQYDVQQDEzJTdGFyZmllbGQgU2VydmljZXMg
  40121. Um9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
  40122. AQoCggEBANUMOsQq+U7i9b4Zl1+OiFOxHz/Lz58gE20pOsgPfTz3a3Y4Y9k2YKibXlwAgLIvWX/2
  40123. h/klQ4bnaRtSmpDhcePYLQ1Ob/bISdm28xpWriu2dBTrz/sm4xq6HZYuajtYlIlHVv8loJNwU4Pa
  40124. hHQUw2eeBGg6345AWh1KTs9DkTvnVtYAcMtS7nt9rjrnvDH5RfbCYM8TWQIrgMw0R9+53pBlbQLP
  40125. LJGmpufehRhJfGZOozptqbXuNC66DQO4M99H67FrjSXZm86B0UVGMpZwh94CDklDhbZsc7tk6mFB
  40126. rMnUVN+HL8cisibMn1lUaJ/8viovxFUcdUBgF4UCVTmLfwUCAwEAAaNCMEAwDwYDVR0TAQH/BAUw
  40127. AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJxfAN+qAdcwKziIorhtSpzyEZGDMA0GCSqG
  40128. SIb3DQEBCwUAA4IBAQBLNqaEd2ndOxmfZyMIbw5hyf2E3F/YNoHN2BtBLZ9g3ccaaNnRbobhiCPP
  40129. E95Dz+I0swSdHynVv/heyNXBve6SbzJ08pGCL72CQnqtKrcgfU28elUSwhXqvfdqlS5sdJ/PHLTy
  40130. xQGjhdByPq1zqwubdQxtRbeOlKyWN7Wg0I8VRw7j6IPdj/3vQQF3zCepYoUz8jcI73HPdwbeyBkd
  40131. iEDPfUYd/x7H4c7/I9vG+o1VTqkC50cRRj70/b17KSa7qWFiNyi2LSr2EIZkyXCn0q23KXB56jza
  40132. YyWf/Wi3MOxw+3WKt21gZ7IeyLnp2KhvAotnDU0mV3HaIPzBSlCNsSi6
  40133. -----END CERTIFICATE-----
  40134. AffirmTrust Commercial
  40135. ======================
  40136. -----BEGIN CERTIFICATE-----
  40137. MIIDTDCCAjSgAwIBAgIId3cGJyapsXwwDQYJKoZIhvcNAQELBQAwRDELMAkGA1UEBhMCVVMxFDAS
  40138. BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMB4XDTEw
  40139. MDEyOTE0MDYwNloXDTMwMTIzMTE0MDYwNlowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly
  40140. bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMIIBIjANBgkqhkiG9w0BAQEF
  40141. AAOCAQ8AMIIBCgKCAQEA9htPZwcroRX1BiLLHwGy43NFBkRJLLtJJRTWzsO3qyxPxkEylFf6Eqdb
  40142. DuKPHx6GGaeqtS25Xw2Kwq+FNXkyLbscYjfysVtKPcrNcV/pQr6U6Mje+SJIZMblq8Yrba0F8PrV
  40143. C8+a5fBQpIs7R6UjW3p6+DM/uO+Zl+MgwdYoic+U+7lF7eNAFxHUdPALMeIrJmqbTFeurCA+ukV6
  40144. BfO9m2kVrn1OIGPENXY6BwLJN/3HR+7o8XYdcxXyl6S1yHp52UKqK39c/s4mT6NmgTWvRLpUHhww
  40145. MmWd5jyTXlBOeuM61G7MGvv50jeuJCqrVwMiKA1JdX+3KNp1v47j3A55MQIDAQABo0IwQDAdBgNV
  40146. HQ4EFgQUnZPGU4teyq8/nx4P5ZmVvCT2lI8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  40147. AQYwDQYJKoZIhvcNAQELBQADggEBAFis9AQOzcAN/wr91LoWXym9e2iZWEnStB03TX8nfUYGXUPG
  40148. hi4+c7ImfU+TqbbEKpqrIZcUsd6M06uJFdhrJNTxFq7YpFzUf1GO7RgBsZNjvbz4YYCanrHOQnDi
  40149. qX0GJX0nof5v7LMeJNrjS1UaADs1tDvZ110w/YETifLCBivtZ8SOyUOyXGsViQK8YvxO8rUzqrJv
  40150. 0wqiUOP2O+guRMLbZjipM1ZI8W0bM40NjD9gN53Tym1+NH4Nn3J2ixufcv1SNUFFApYvHLKac0kh
  40151. sUlHRUe072o0EclNmsxZt9YCnlpOZbWUrhvfKbAW8b8Angc6F2S1BLUjIZkKlTuXfO8=
  40152. -----END CERTIFICATE-----
  40153. AffirmTrust Networking
  40154. ======================
  40155. -----BEGIN CERTIFICATE-----
  40156. MIIDTDCCAjSgAwIBAgIIfE8EORzUmS0wDQYJKoZIhvcNAQEFBQAwRDELMAkGA1UEBhMCVVMxFDAS
  40157. BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMB4XDTEw
  40158. MDEyOTE0MDgyNFoXDTMwMTIzMTE0MDgyNFowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly
  40159. bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMIIBIjANBgkqhkiG9w0BAQEF
  40160. AAOCAQ8AMIIBCgKCAQEAtITMMxcua5Rsa2FSoOujz3mUTOWUgJnLVWREZY9nZOIG41w3SfYvm4SE
  40161. Hi3yYJ0wTsyEheIszx6e/jarM3c1RNg1lho9Nuh6DtjVR6FqaYvZ/Ls6rnla1fTWcbuakCNrmreI
  40162. dIcMHl+5ni36q1Mr3Lt2PpNMCAiMHqIjHNRqrSK6mQEubWXLviRmVSRLQESxG9fhwoXA3hA/Pe24
  40163. /PHxI1Pcv2WXb9n5QHGNfb2V1M6+oF4nI979ptAmDgAp6zxG8D1gvz9Q0twmQVGeFDdCBKNwV6gb
  40164. h+0t+nvujArjqWaJGctB+d1ENmHP4ndGyH329JKBNv3bNPFyfvMMFr20FQIDAQABo0IwQDAdBgNV
  40165. HQ4EFgQUBx/S55zawm6iQLSwelAQUHTEyL0wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  40166. AQYwDQYJKoZIhvcNAQEFBQADggEBAIlXshZ6qML91tmbmzTCnLQyFE2npN/svqe++EPbkTfOtDIu
  40167. UFUaNU52Q3Eg75N3ThVwLofDwR1t3Mu1J9QsVtFSUzpE0nPIxBsFZVpikpzuQY0x2+c06lkh1QF6
  40168. 12S4ZDnNye2v7UsDSKegmQGA3GWjNq5lWUhPgkvIZfFXHeVZLgo/bNjR9eUJtGxUAArgFU2HdW23
  40169. WJZa3W3SAKD0m0i+wzekujbgfIeFlxoVot4uolu9rxj5kFDNcFn4J2dHy8egBzp90SxdbBk6ZrV9
  40170. /ZFvgrG+CJPbFEfxojfHRZ48x3evZKiT3/Zpg4Jg8klCNO1aAFSFHBY2kgxc+qatv9s=
  40171. -----END CERTIFICATE-----
  40172. AffirmTrust Premium
  40173. ===================
  40174. -----BEGIN CERTIFICATE-----
  40175. MIIFRjCCAy6gAwIBAgIIbYwURrGmCu4wDQYJKoZIhvcNAQEMBQAwQTELMAkGA1UEBhMCVVMxFDAS
  40176. BgNVBAoMC0FmZmlybVRydXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMB4XDTEwMDEy
  40177. OTE0MTAzNloXDTQwMTIzMTE0MTAzNlowQTELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRy
  40178. dXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  40179. MIICCgKCAgEAxBLfqV/+Qd3d9Z+K4/as4Tx4mrzY8H96oDMq3I0gW64tb+eT2TZwamjPjlGjhVtn
  40180. BKAQJG9dKILBl1fYSCkTtuG+kU3fhQxTGJoeJKJPj/CihQvL9Cl/0qRY7iZNyaqoe5rZ+jjeRFcV
  40181. 5fiMyNlI4g0WJx0eyIOFJbe6qlVBzAMiSy2RjYvmia9mx+n/K+k8rNrSs8PhaJyJ+HoAVt70VZVs
  40182. +7pk3WKL3wt3MutizCaam7uqYoNMtAZ6MMgpv+0GTZe5HMQxK9VfvFMSF5yZVylmd2EhMQcuJUmd
  40183. GPLu8ytxjLW6OQdJd/zvLpKQBY0tL3d770O/Nbua2Plzpyzy0FfuKE4mX4+QaAkvuPjcBukumj5R
  40184. p9EixAqnOEhss/n/fauGV+O61oV4d7pD6kh/9ti+I20ev9E2bFhc8e6kGVQa9QPSdubhjL08s9NI
  40185. S+LI+H+SqHZGnEJlPqQewQcDWkYtuJfzt9WyVSHvutxMAJf7FJUnM7/oQ0dG0giZFmA7mn7S5u04
  40186. 6uwBHjxIVkkJx0w3AJ6IDsBz4W9m6XJHMD4Q5QsDyZpCAGzFlH5hxIrff4IaC1nEWTJ3s7xgaVY5
  40187. /bQGeyzWZDbZvUjthB9+pSKPKrhC9IK31FOQeE4tGv2Bb0TXOwF0lkLgAOIua+rF7nKsu7/+6qqo
  40188. +Nz2snmKtmcCAwEAAaNCMEAwHQYDVR0OBBYEFJ3AZ6YMItkm9UWrpmVSESfYRaxjMA8GA1UdEwEB
  40189. /wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBDAUAA4ICAQCzV00QYk465KzquByv
  40190. MiPIs0laUZx2KI15qldGF9X1Uva3ROgIRL8YhNILgM3FEv0AVQVhh0HctSSePMTYyPtwni94loMg
  40191. Nt58D2kTiKV1NpgIpsbfrM7jWNa3Pt668+s0QNiigfV4Py/VpfzZotReBA4Xrf5B8OWycvpEgjNC
  40192. 6C1Y91aMYj+6QrCcDFx+LmUmXFNPALJ4fqENmS2NuB2OosSw/WDQMKSOyARiqcTtNd56l+0OOF6S
  40193. L5Nwpamcb6d9Ex1+xghIsV5n61EIJenmJWtSKZGc0jlzCFfemQa0W50QBuHCAKi4HEoCChTQwUHK
  40194. +4w1IX2COPKpVJEZNZOUbWo6xbLQu4mGk+ibyQ86p3q4ofB4Rvr8Ny/lioTz3/4E2aFooC8k4gmV
  40195. BtWVyuEklut89pMFu+1z6S3RdTnX5yTb2E5fQ4+e0BQ5v1VwSJlXMbSc7kqYA5YwH2AG7hsj/oFg
  40196. IxpHYoWlzBk0gG+zrBrjn/B7SK3VAdlntqlyk+otZrWyuOQ9PLLvTIzq6we/qzWaVYa8GKa1qF60
  40197. g2xraUDTn9zxw2lrueFtCfTxqlB2Cnp9ehehVZZCmTEJ3WARjQUwfuaORtGdFNrHF+QFlozEJLUb
  40198. zxQHskD4o55BhrwE0GuWyCqANP2/7waj3VjFhT0+j/6eKeC2uAloGRwYQw==
  40199. -----END CERTIFICATE-----
  40200. AffirmTrust Premium ECC
  40201. =======================
  40202. -----BEGIN CERTIFICATE-----
  40203. MIIB/jCCAYWgAwIBAgIIdJclisc/elQwCgYIKoZIzj0EAwMwRTELMAkGA1UEBhMCVVMxFDASBgNV
  40204. BAoMC0FmZmlybVRydXN0MSAwHgYDVQQDDBdBZmZpcm1UcnVzdCBQcmVtaXVtIEVDQzAeFw0xMDAx
  40205. MjkxNDIwMjRaFw00MDEyMzExNDIwMjRaMEUxCzAJBgNVBAYTAlVTMRQwEgYDVQQKDAtBZmZpcm1U
  40206. cnVzdDEgMB4GA1UEAwwXQWZmaXJtVHJ1c3QgUHJlbWl1bSBFQ0MwdjAQBgcqhkjOPQIBBgUrgQQA
  40207. IgNiAAQNMF4bFZ0D0KF5Nbc6PJJ6yhUczWLznCZcBz3lVPqj1swS6vQUX+iOGasvLkjmrBhDeKzQ
  40208. N8O9ss0s5kfiGuZjuD0uL3jET9v0D6RoTFVya5UdThhClXjMNzyR4ptlKymjQjBAMB0GA1UdDgQW
  40209. BBSaryl6wBE1NSZRMADDav5A1a7WPDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAK
  40210. BggqhkjOPQQDAwNnADBkAjAXCfOHiFBar8jAQr9HX/VsaobgxCd05DhT1wV/GzTjxi+zygk8N53X
  40211. 57hG8f2h4nECMEJZh0PUUd+60wkyWs6Iflc9nF9Ca/UHLbXwgpP5WW+uZPpY5Yse42O+tYHNbwKM
  40212. eQ==
  40213. -----END CERTIFICATE-----
  40214. Certum Trusted Network CA
  40215. =========================
  40216. -----BEGIN CERTIFICATE-----
  40217. MIIDuzCCAqOgAwIBAgIDBETAMA0GCSqGSIb3DQEBBQUAMH4xCzAJBgNVBAYTAlBMMSIwIAYDVQQK
  40218. ExlVbml6ZXRvIFRlY2hub2xvZ2llcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlv
  40219. biBBdXRob3JpdHkxIjAgBgNVBAMTGUNlcnR1bSBUcnVzdGVkIE5ldHdvcmsgQ0EwHhcNMDgxMDIy
  40220. MTIwNzM3WhcNMjkxMjMxMTIwNzM3WjB+MQswCQYDVQQGEwJQTDEiMCAGA1UEChMZVW5pemV0byBU
  40221. ZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  40222. MSIwIAYDVQQDExlDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENBMIIBIjANBgkqhkiG9w0BAQEFAAOC
  40223. AQ8AMIIBCgKCAQEA4/t9o3K6wvDJFIf1awFO4W5AB7ptJ11/91sts1rHUV+rpDKmYYe2bg+G0jAC
  40224. l/jXaVehGDldamR5xgFZrDwxSjh80gTSSyjoIF87B6LMTXPb865Px1bVWqeWifrzq2jUI4ZZJ88J
  40225. J7ysbnKDHDBy3+Ci6dLhdHUZvSqeexVUBBvXQzmtVSjF4hq79MDkrjhJM8x2hZ85RdKknvISjFH4
  40226. fOQtf/WsX+sWn7Et0brMkUJ3TCXJkDhv2/DM+44el1k+1WBO5gUo7Ul5E0u6SNsv+XLTOcr+H9g0
  40227. cvW0QM8xAcPs3hEtF10fuFDRXhmnad4HMyjKUJX5p1TLVIZQRan5SQIDAQABo0IwQDAPBgNVHRMB
  40228. Af8EBTADAQH/MB0GA1UdDgQWBBQIds3LB/8k9sXN7buQvOKEN0Z19zAOBgNVHQ8BAf8EBAMCAQYw
  40229. DQYJKoZIhvcNAQEFBQADggEBAKaorSLOAT2mo/9i0Eidi15ysHhE49wcrwn9I0j6vSrEuVUEtRCj
  40230. jSfeC4Jj0O7eDDd5QVsisrCaQVymcODU0HfLI9MA4GxWL+FpDQ3Zqr8hgVDZBqWo/5U30Kr+4rP1
  40231. mS1FhIrlQgnXdAIv94nYmem8J9RHjboNRhx3zxSkHLmkMcScKHQDNP8zGSal6Q10tz6XxnboJ5aj
  40232. Zt3hrvJBW8qYVoNzcOSGGtIxQbovvi0TWnZvTuhOgQ4/WwMioBK+ZlgRSssDxLQqKi2WF+A5VLxI
  40233. 03YnnZotBqbJ7DnSq9ufmgsnAjUpsUCV5/nonFWIGUbWtzT1fs45mtk48VH3Tyw=
  40234. -----END CERTIFICATE-----
  40235. TWCA Root Certification Authority
  40236. =================================
  40237. -----BEGIN CERTIFICATE-----
  40238. MIIDezCCAmOgAwIBAgIBATANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJUVzESMBAGA1UECgwJ
  40239. VEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NBIFJvb3QgQ2VydGlmaWNh
  40240. dGlvbiBBdXRob3JpdHkwHhcNMDgwODI4MDcyNDMzWhcNMzAxMjMxMTU1OTU5WjBfMQswCQYDVQQG
  40241. EwJUVzESMBAGA1UECgwJVEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NB
  40242. IFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
  40243. AoIBAQCwfnK4pAOU5qfeCTiRShFAh6d8WWQUe7UREN3+v9XAu1bihSX0NXIP+FPQQeFEAcK0HMMx
  40244. QhZHhTMidrIKbw/lJVBPhYa+v5guEGcevhEFhgWQxFnQfHgQsIBct+HHK3XLfJ+utdGdIzdjp9xC
  40245. oi2SBBtQwXu4PhvJVgSLL1KbralW6cH/ralYhzC2gfeXRfwZVzsrb+RH9JlF/h3x+JejiB03HFyP
  40246. 4HYlmlD4oFT/RJB2I9IyxsOrBr/8+7/zrX2SYgJbKdM1o5OaQ2RgXbL6Mv87BK9NQGr5x+PvI/1r
  40247. y+UPizgN7gr8/g+YnzAx3WxSZfmLgb4i4RxYA7qRG4kHAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIB
  40248. BjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqOFsmjd6LWvJPelSDGRjjCDWmujANBgkqhkiG
  40249. 9w0BAQUFAAOCAQEAPNV3PdrfibqHDAhUaiBQkr6wQT25JmSDCi/oQMCXKCeCMErJk/9q56YAf4lC
  40250. mtYR5VPOL8zy2gXE/uJQxDqGfczafhAJO5I1KlOy/usrBdlsXebQ79NqZp4VKIV66IIArB6nCWlW
  40251. QtNoURi+VJq/REG6Sb4gumlc7rh3zc5sH62Dlhh9DrUUOYTxKOkto557HnpyWoOzeW/vtPzQCqVY
  40252. T0bf+215WfKEIlKuD8z7fDvnaspHYcN6+NOSBB+4IIThNlQWx0DeO4pz3N/GCUzf7Nr/1FNCocny
  40253. Yh0igzyXxfkZYiesZSLX0zzG5Y6yU8xJzrww/nsOM5D77dIUkR8Hrw==
  40254. -----END CERTIFICATE-----
  40255. Security Communication RootCA2
  40256. ==============================
  40257. -----BEGIN CERTIFICATE-----
  40258. MIIDdzCCAl+gAwIBAgIBADANBgkqhkiG9w0BAQsFADBdMQswCQYDVQQGEwJKUDElMCMGA1UEChMc
  40259. U0VDT00gVHJ1c3QgU3lzdGVtcyBDTy4sTFRELjEnMCUGA1UECxMeU2VjdXJpdHkgQ29tbXVuaWNh
  40260. dGlvbiBSb290Q0EyMB4XDTA5MDUyOTA1MDAzOVoXDTI5MDUyOTA1MDAzOVowXTELMAkGA1UEBhMC
  40261. SlAxJTAjBgNVBAoTHFNFQ09NIFRydXN0IFN5c3RlbXMgQ08uLExURC4xJzAlBgNVBAsTHlNlY3Vy
  40262. aXR5IENvbW11bmljYXRpb24gUm9vdENBMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  40263. ANAVOVKxUrO6xVmCxF1SrjpDZYBLx/KWvNs2l9amZIyoXvDjChz335c9S672XewhtUGrzbl+dp++
  40264. +T42NKA7wfYxEUV0kz1XgMX5iZnK5atq1LXaQZAQwdbWQonCv/Q4EpVMVAX3NuRFg3sUZdbcDE3R
  40265. 3n4MqzvEFb46VqZab3ZpUql6ucjrappdUtAtCms1FgkQhNBqyjoGADdH5H5XTz+L62e4iKrFvlNV
  40266. spHEfbmwhRkGeC7bYRr6hfVKkaHnFtWOojnflLhwHyg/i/xAXmODPIMqGplrz95Zajv8bxbXH/1K
  40267. EOtOghY6rCcMU/Gt1SSwawNQwS08Ft1ENCcadfsCAwEAAaNCMEAwHQYDVR0OBBYEFAqFqXdlBZh8
  40268. QIH4D5csOPEK7DzPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEB
  40269. CwUAA4IBAQBMOqNErLlFsceTfsgLCkLfZOoc7llsCLqJX2rKSpWeeo8HxdpFcoJxDjrSzG+ntKEj
  40270. u/Ykn8sX/oymzsLS28yN/HH8AynBbF0zX2S2ZTuJbxh2ePXcokgfGT+Ok+vx+hfuzU7jBBJV1uXk
  40271. 3fs+BXziHV7Gp7yXT2g69ekuCkO2r1dcYmh8t/2jioSgrGK+KwmHNPBqAbubKVY8/gA3zyNs8U6q
  40272. tnRGEmyR7jTV7JqR50S+kDFy1UkC9gLl9B/rfNmWVan/7Ir5mUf/NVoCqgTLiluHcSmRvaS0eg29
  40273. mvVXIwAHIRc/SjnRBUkLp7Y3gaVdjKozXoEofKd9J+sAro03
  40274. -----END CERTIFICATE-----
  40275. EC-ACC
  40276. ======
  40277. -----BEGIN CERTIFICATE-----
  40278. MIIFVjCCBD6gAwIBAgIQ7is969Qh3hSoYqwE893EATANBgkqhkiG9w0BAQUFADCB8zELMAkGA1UE
  40279. BhMCRVMxOzA5BgNVBAoTMkFnZW5jaWEgQ2F0YWxhbmEgZGUgQ2VydGlmaWNhY2lvIChOSUYgUS0w
  40280. ODAxMTc2LUkpMSgwJgYDVQQLEx9TZXJ2ZWlzIFB1YmxpY3MgZGUgQ2VydGlmaWNhY2lvMTUwMwYD
  40281. VQQLEyxWZWdldSBodHRwczovL3d3dy5jYXRjZXJ0Lm5ldC92ZXJhcnJlbCAoYykwMzE1MDMGA1UE
  40282. CxMsSmVyYXJxdWlhIEVudGl0YXRzIGRlIENlcnRpZmljYWNpbyBDYXRhbGFuZXMxDzANBgNVBAMT
  40283. BkVDLUFDQzAeFw0wMzAxMDcyMzAwMDBaFw0zMTAxMDcyMjU5NTlaMIHzMQswCQYDVQQGEwJFUzE7
  40284. MDkGA1UEChMyQWdlbmNpYSBDYXRhbGFuYSBkZSBDZXJ0aWZpY2FjaW8gKE5JRiBRLTA4MDExNzYt
  40285. SSkxKDAmBgNVBAsTH1NlcnZlaXMgUHVibGljcyBkZSBDZXJ0aWZpY2FjaW8xNTAzBgNVBAsTLFZl
  40286. Z2V1IGh0dHBzOi8vd3d3LmNhdGNlcnQubmV0L3ZlcmFycmVsIChjKTAzMTUwMwYDVQQLEyxKZXJh
  40287. cnF1aWEgRW50aXRhdHMgZGUgQ2VydGlmaWNhY2lvIENhdGFsYW5lczEPMA0GA1UEAxMGRUMtQUND
  40288. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsyLHT+KXQpWIR4NA9h0X84NzJB5R85iK
  40289. w5K4/0CQBXCHYMkAqbWUZRkiFRfCQ2xmRJoNBD45b6VLeqpjt4pEndljkYRm4CgPukLjbo73FCeT
  40290. ae6RDqNfDrHrZqJyTxIThmV6PttPB/SnCWDaOkKZx7J/sxaVHMf5NLWUhdWZXqBIoH7nF2W4onW4
  40291. HvPlQn2v7fOKSGRdghST2MDk/7NQcvJ29rNdQlB50JQ+awwAvthrDk4q7D7SzIKiGGUzE3eeml0a
  40292. E9jD2z3Il3rucO2n5nzbcc8tlGLfbdb1OL4/pYUKGbio2Al1QnDE6u/LDsg0qBIimAy4E5S2S+zw
  40293. 0JDnJwIDAQABo4HjMIHgMB0GA1UdEQQWMBSBEmVjX2FjY0BjYXRjZXJ0Lm5ldDAPBgNVHRMBAf8E
  40294. BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUoMOLRKo3pUW/l4Ba0fF4opvpXY0wfwYD
  40295. VR0gBHgwdjB0BgsrBgEEAfV4AQMBCjBlMCwGCCsGAQUFBwIBFiBodHRwczovL3d3dy5jYXRjZXJ0
  40296. Lm5ldC92ZXJhcnJlbDA1BggrBgEFBQcCAjApGidWZWdldSBodHRwczovL3d3dy5jYXRjZXJ0Lm5l
  40297. dC92ZXJhcnJlbCAwDQYJKoZIhvcNAQEFBQADggEBAKBIW4IB9k1IuDlVNZyAelOZ1Vr/sXE7zDkJ
  40298. lF7W2u++AVtd0x7Y/X1PzaBB4DSTv8vihpw3kpBWHNzrKQXlxJ7HNd+KDM3FIUPpqojlNcAZQmNa
  40299. Al6kSBg6hW/cnbw/nZzBh7h6YQjpdwt/cKt63dmXLGQehb+8dJahw3oS7AwaboMMPOhyRp/7SNVe
  40300. l+axofjk70YllJyJ22k4vuxcDlbHZVHlUIiIv0LVKz3l+bqeLrPK9HOSAgu+TGbrIP65y7WZf+a2
  40301. E/rKS03Z7lNGBjvGTq2TWoF+bCpLagVFjPIhpDGQh2xlnJ2lYJU6Un/10asIbvPuW/mIPX64b24D
  40302. 5EI=
  40303. -----END CERTIFICATE-----
  40304. Hellenic Academic and Research Institutions RootCA 2011
  40305. =======================================================
  40306. -----BEGIN CERTIFICATE-----
  40307. MIIEMTCCAxmgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBlTELMAkGA1UEBhMCR1IxRDBCBgNVBAoT
  40308. O0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9y
  40309. aXR5MUAwPgYDVQQDEzdIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25z
  40310. IFJvb3RDQSAyMDExMB4XDTExMTIwNjEzNDk1MloXDTMxMTIwMTEzNDk1MlowgZUxCzAJBgNVBAYT
  40311. AkdSMUQwQgYDVQQKEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25z
  40312. IENlcnQuIEF1dGhvcml0eTFAMD4GA1UEAxM3SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNo
  40313. IEluc3RpdHV0aW9ucyBSb290Q0EgMjAxMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  40314. AKlTAOMupvaO+mDYLZU++CwqVE7NuYRhlFhPjz2L5EPzdYmNUeTDN9KKiE15HrcS3UN4SoqS5tdI
  40315. 1Q+kOilENbgH9mgdVc04UfCMJDGFr4PJfel3r+0ae50X+bOdOFAPplp5kYCvN66m0zH7tSYJnTxa
  40316. 71HFK9+WXesyHgLacEnsbgzImjeN9/E2YEsmLIKe0HjzDQ9jpFEw4fkrJxIH2Oq9GGKYsFk3fb7u
  40317. 8yBRQlqD75O6aRXxYp2fmTmCobd0LovUxQt7L/DICto9eQqakxylKHJzkUOap9FNhYS5qXSPFEDH
  40318. 3N6sQWRstBmbAmNtJGSPRLIl6s5ddAxjMlyNh+UCAwEAAaOBiTCBhjAPBgNVHRMBAf8EBTADAQH/
  40319. MAsGA1UdDwQEAwIBBjAdBgNVHQ4EFgQUppFC/RNhSiOeCKQp5dgTBCPuQSUwRwYDVR0eBEAwPqA8
  40320. MAWCAy5ncjAFggMuZXUwBoIELmVkdTAGggQub3JnMAWBAy5ncjAFgQMuZXUwBoEELmVkdTAGgQQu
  40321. b3JnMA0GCSqGSIb3DQEBBQUAA4IBAQAf73lB4XtuP7KMhjdCSk4cNx6NZrokgclPEg8hwAOXhiVt
  40322. XdMiKahsog2p6z0GW5k6x8zDmjR/qw7IThzh+uTczQ2+vyT+bOdrwg3IBp5OjWEopmr95fZi6hg8
  40323. TqBTnbI6nOulnJEWtk2C4AwFSKls9cz4y51JtPACpf1wA+2KIaWuE4ZJwzNzvoc7dIsXRSZMFpGD
  40324. /md9zU1jZ/rzAxKWeAaNsWftjj++n08C9bMJL/NMh98qy5V8AcysNnq/onN694/BtZqhFLKPM58N
  40325. 7yLcZnuEvUUXBj08yrl3NI/K6s8/MT7jiOOASSXIl7WdmplNsDz4SgCbZN2fOUvRJ9e4
  40326. -----END CERTIFICATE-----
  40327. Actalis Authentication Root CA
  40328. ==============================
  40329. -----BEGIN CERTIFICATE-----
  40330. MIIFuzCCA6OgAwIBAgIIVwoRl0LE48wwDQYJKoZIhvcNAQELBQAwazELMAkGA1UEBhMCSVQxDjAM
  40331. BgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UE
  40332. AwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290IENBMB4XDTExMDkyMjExMjIwMloXDTMwMDky
  40333. MjExMjIwMlowazELMAkGA1UEBhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlz
  40334. IFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290
  40335. IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAp8bEpSmkLO/lGMWwUKNvUTufClrJ
  40336. wkg4CsIcoBh/kbWHuUA/3R1oHwiD1S0eiKD4j1aPbZkCkpAW1V8IbInX4ay8IMKx4INRimlNAJZa
  40337. by/ARH6jDuSRzVju3PvHHkVH3Se5CAGfpiEd9UEtL0z9KK3giq0itFZljoZUj5NDKd45RnijMCO6
  40338. zfB9E1fAXdKDa0hMxKufgFpbOr3JpyI/gCczWw63igxdBzcIy2zSekciRDXFzMwujt0q7bd9Zg1f
  40339. YVEiVRvjRuPjPdA1YprbrxTIW6HMiRvhMCb8oJsfgadHHwTrozmSBp+Z07/T6k9QnBn+locePGX2
  40340. oxgkg4YQ51Q+qDp2JE+BIcXjDwL4k5RHILv+1A7TaLndxHqEguNTVHnd25zS8gebLra8Pu2Fbe8l
  40341. EfKXGkJh90qX6IuxEAf6ZYGyojnP9zz/GPvG8VqLWeICrHuS0E4UT1lF9gxeKF+w6D9Fz8+vm2/7
  40342. hNN3WpVvrJSEnu68wEqPSpP4RCHiMUVhUE4Q2OM1fEwZtN4Fv6MGn8i1zeQf1xcGDXqVdFUNaBr8
  40343. EBtiZJ1t4JWgw5QHVw0U5r0F+7if5t+L4sbnfpb2U8WANFAoWPASUHEXMLrmeGO89LKtmyuy/uE5
  40344. jF66CyCU3nuDuP/jVo23Eek7jPKxwV2dpAtMK9myGPW1n0sCAwEAAaNjMGEwHQYDVR0OBBYEFFLY
  40345. iDrIn3hm7YnzezhwlMkCAjbQMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUUtiIOsifeGbt
  40346. ifN7OHCUyQICNtAwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBCwUAA4ICAQALe3KHwGCmSUyI
  40347. WOYdiPcUZEim2FgKDk8TNd81HdTtBjHIgT5q1d07GjLukD0R0i70jsNjLiNmsGe+b7bAEzlgqqI0
  40348. JZN1Ut6nna0Oh4lScWoWPBkdg/iaKWW+9D+a2fDzWochcYBNy+A4mz+7+uAwTc+G02UQGRjRlwKx
  40349. K3JCaKygvU5a2hi/a5iB0P2avl4VSM0RFbnAKVy06Ij3Pjaut2L9HmLecHgQHEhb2rykOLpn7VU+
  40350. Xlff1ANATIGk0k9jpwlCCRT8AKnCgHNPLsBA2RF7SOp6AsDT6ygBJlh0wcBzIm2Tlf05fbsq4/aC
  40351. 4yyXX04fkZT6/iyj2HYauE2yOE+b+h1IYHkm4vP9qdCa6HCPSXrW5b0KDtst842/6+OkfcvHlXHo
  40352. 2qN8xcL4dJIEG4aspCJTQLas/kx2z/uUMsA1n3Y/buWQbqCmJqK4LL7RK4X9p2jIugErsWx0Hbhz
  40353. lefut8cl8ABMALJ+tguLHPPAUJ4lueAI3jZm/zel0btUZCzJJ7VLkn5l/9Mt4blOvH+kQSGQQXem
  40354. OR/qnuOf0GZvBeyqdn6/axag67XH/JJULysRJyU3eExRarDzzFhdFPFqSBX/wge2sY0PjlxQRrM9
  40355. vwGYT7JZVEc+NHt4bVaTLnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg==
  40356. -----END CERTIFICATE-----
  40357. Buypass Class 2 Root CA
  40358. =======================
  40359. -----BEGIN CERTIFICATE-----
  40360. MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU
  40361. QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMiBSb290IENBMB4X
  40362. DTEwMTAyNjA4MzgwM1oXDTQwMTAyNjA4MzgwM1owTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1
  40363. eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDIgUm9vdCBDQTCCAiIw
  40364. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANfHXvfBB9R3+0Mh9PT1aeTuMgHbo4Yf5FkNuud1
  40365. g1Lr6hxhFUi7HQfKjK6w3Jad6sNgkoaCKHOcVgb/S2TwDCo3SbXlzwx87vFKu3MwZfPVL4O2fuPn
  40366. 9Z6rYPnT8Z2SdIrkHJasW4DptfQxh6NR/Md+oW+OU3fUl8FVM5I+GC911K2GScuVr1QGbNgGE41b
  40367. /+EmGVnAJLqBcXmQRFBoJJRfuLMR8SlBYaNByyM21cHxMlAQTn/0hpPshNOOvEu/XAFOBz3cFIqU
  40368. CqTqc/sLUegTBxj6DvEr0VQVfTzh97QZQmdiXnfgolXsttlpF9U6r0TtSsWe5HonfOV116rLJeff
  40369. awrbD02TTqigzXsu8lkBarcNuAeBfos4GzjmCleZPe4h6KP1DBbdi+w0jpwqHAAVF41og9JwnxgI
  40370. zRFo1clrUs3ERo/ctfPYV3Me6ZQ5BL/T3jjetFPsaRyifsSP5BtwrfKi+fv3FmRmaZ9JUaLiFRhn
  40371. Bkp/1Wy1TbMz4GHrXb7pmA8y1x1LPC5aAVKRCfLf6o3YBkBjqhHk/sM3nhRSP/TizPJhk9H9Z2vX
  40372. Uq6/aKtAQ6BXNVN48FP4YUIHZMbXb5tMOA1jrGKvNouicwoN9SG9dKpN6nIDSdvHXx1iY8f93ZHs
  40373. M+71bbRuMGjeyNYmsHVee7QHIJihdjK4TWxPAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  40374. VR0OBBYEFMmAd+BikoL1RpzzuvdMw964o605MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF
  40375. AAOCAgEAU18h9bqwOlI5LJKwbADJ784g7wbylp7ppHR/ehb8t/W2+xUbP6umwHJdELFx7rxP462s
  40376. A20ucS6vxOOto70MEae0/0qyexAQH6dXQbLArvQsWdZHEIjzIVEpMMpghq9Gqx3tOluwlN5E40EI
  40377. osHsHdb9T7bWR9AUC8rmyrV7d35BH16Dx7aMOZawP5aBQW9gkOLo+fsicdl9sz1Gv7SEr5AcD48S
  40378. aq/v7h56rgJKihcrdv6sVIkkLE8/trKnToyokZf7KcZ7XC25y2a2t6hbElGFtQl+Ynhw/qlqYLYd
  40379. DnkM/crqJIByw5c/8nerQyIKx+u2DISCLIBrQYoIwOula9+ZEsuK1V6ADJHgJgg2SMX6OBE1/yWD
  40380. LfJ6v9r9jv6ly0UsH8SIU653DtmadsWOLB2jutXsMq7Aqqz30XpN69QH4kj3Io6wpJ9qzo6ysmD0
  40381. oyLQI+uUWnpp3Q+/QFesa1lQ2aOZ4W7+jQF5JyMV3pKdewlNWudLSDBaGOYKbeaP4NK75t98biGC
  40382. wWg5TbSYWGZizEqQXsP6JwSxeRV0mcy+rSDeJmAc61ZRpqPq5KM/p/9h3PFaTWwyI0PurKju7koS
  40383. CTxdccK+efrCh2gdC/1cacwG0Jp9VJkqyTkaGa9LKkPzY11aWOIv4x3kqdbQCtCev9eBCfHJxyYN
  40384. rJgWVqA=
  40385. -----END CERTIFICATE-----
  40386. Buypass Class 3 Root CA
  40387. =======================
  40388. -----BEGIN CERTIFICATE-----
  40389. MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU
  40390. QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMyBSb290IENBMB4X
  40391. DTEwMTAyNjA4Mjg1OFoXDTQwMTAyNjA4Mjg1OFowTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1
  40392. eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDMgUm9vdCBDQTCCAiIw
  40393. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKXaCpUWUOOV8l6ddjEGMnqb8RB2uACatVI2zSRH
  40394. sJ8YZLya9vrVediQYkwiL944PdbgqOkcLNt4EemOaFEVcsfzM4fkoF0LXOBXByow9c3EN3coTRiR
  40395. 5r/VUv1xLXA+58bEiuPwKAv0dpihi4dVsjoT/Lc+JzeOIuOoTyrvYLs9tznDDgFHmV0ST9tD+leh
  40396. 7fmdvhFHJlsTmKtdFoqwNxxXnUX/iJY2v7vKB3tvh2PX0DJq1l1sDPGzbjniazEuOQAnFN44wOwZ
  40397. ZoYS6J1yFhNkUsepNxz9gjDthBgd9K5c/3ATAOux9TN6S9ZV+AWNS2mw9bMoNlwUxFFzTWsL8TQH
  40398. 2xc519woe2v1n/MuwU8XKhDzzMro6/1rqy6any2CbgTUUgGTLT2G/H783+9CHaZr77kgxve9oKeV
  40399. /afmiSTYzIw0bOIjL9kSGiG5VZFvC5F5GQytQIgLcOJ60g7YaEi7ghM5EFjp2CoHxhLbWNvSO1UQ
  40400. RwUVZ2J+GGOmRj8JDlQyXr8NYnon74Do29lLBlo3WiXQCBJ31G8JUJc9yB3D34xFMFbG02SrZvPA
  40401. Xpacw8Tvw3xrizp5f7NJzz3iiZ+gMEuFuZyUJHmPfWupRWgPK9Dx2hzLabjKSWJtyNBjYt1gD1iq
  40402. j6G8BaVmos8bdrKEZLFMOVLAMLrwjEsCsLa3AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  40403. VR0OBBYEFEe4zf/lb+74suwvTg75JbCOPGvDMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF
  40404. AAOCAgEAACAjQTUEkMJAYmDv4jVM1z+s4jSQuKFvdvoWFqRINyzpkMLyPPgKn9iB5btb2iUspKdV
  40405. cSQy9sgL8rxq+JOssgfCX5/bzMiKqr5qb+FJEMwx14C7u8jYog5kV+qi9cKpMRXSIGrs/CIBKM+G
  40406. uIAeqcwRpTzyFrNHnfzSgCHEy9BHcEGhyoMZCCxt8l13nIoUE9Q2HJLw5QY33KbmkJs4j1xrG0aG
  40407. Q0JfPgEHU1RdZX33inOhmlRaHylDFCfChQ+1iHsaO5S3HWCntZznKWlXWpuTekMwGwPXYshApqr8
  40408. ZORK15FTAaggiG6cX0S5y2CBNOxv033aSF/rtJC8LakcC6wc1aJoIIAE1vyxjy+7SjENSoYc6+I2
  40409. KSb12tjE8nVhz36udmNKekBlk4f4HoCMhuWG1o8O/FMsYOgWYRqiPkN7zTlgVGr18okmAWiDSKIz
  40410. 6MkEkbIRNBE+6tBDGR8Dk5AM/1E9V/RBbuHLoL7ryWPNbczk+DaqaJ3tvV2XcEQNtg413OEMXbug
  40411. UZTLfhbrES+jkkXITHHZvMmZUldGL1DPvTVp9D0VzgalLA8+9oG6lLvDu79leNKGef9JOxqDDPDe
  40412. eOzI8k1MGt6CKfjBWtrt7uYnXuhF0J0cUahoq0Tj0Itq4/g7u9xN12TyUb7mqqta6THuBrxzvxNi
  40413. Cp/HuZc=
  40414. -----END CERTIFICATE-----
  40415. T-TeleSec GlobalRoot Class 3
  40416. ============================
  40417. -----BEGIN CERTIFICATE-----
  40418. MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM
  40419. IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU
  40420. cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwHhcNMDgx
  40421. MDAxMTAyOTU2WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz
  40422. dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD
  40423. ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwggEiMA0GCSqGSIb3
  40424. DQEBAQUAA4IBDwAwggEKAoIBAQC9dZPwYiJvJK7genasfb3ZJNW4t/zN8ELg63iIVl6bmlQdTQyK
  40425. 9tPPcPRStdiTBONGhnFBSivwKixVA9ZIw+A5OO3yXDw/RLyTPWGrTs0NvvAgJ1gORH8EGoel15YU
  40426. NpDQSXuhdfsaa3Ox+M6pCSzyU9XDFES4hqX2iys52qMzVNn6chr3IhUciJFrf2blw2qAsCTz34ZF
  40427. iP0Zf3WHHx+xGwpzJFu5ZeAsVMhg02YXP+HMVDNzkQI6pn97djmiH5a2OK61yJN0HZ65tOVgnS9W
  40428. 0eDrXltMEnAMbEQgqxHY9Bn20pxSN+f6tsIxO0rUFJmtxxr1XV/6B7h8DR/Wgx6zAgMBAAGjQjBA
  40429. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS1A/d2O2GCahKqGFPr
  40430. AyGUv/7OyjANBgkqhkiG9w0BAQsFAAOCAQEAVj3vlNW92nOyWL6ukK2YJ5f+AbGwUgC4TeQbIXQb
  40431. fsDuXmkqJa9c1h3a0nnJ85cp4IaH3gRZD/FZ1GSFS5mvJQQeyUapl96Cshtwn5z2r3Ex3XsFpSzT
  40432. ucpH9sry9uetuUg/vBa3wW306gmv7PO15wWeph6KU1HWk4HMdJP2udqmJQV0eVp+QD6CSyYRMG7h
  40433. P0HHRwA11fXT91Q+gT3aSWqas+8QPebrb9HIIkfLzM8BMZLZGOMivgkeGj5asuRrDFR6fUNOuIml
  40434. e9eiPZaGzPImNC1qkp2aGtAw4l1OBLBfiyB+d8E9lYLRRpo7PHi4b6HQDWSieB4pTpPDpFQUWw==
  40435. -----END CERTIFICATE-----
  40436. D-TRUST Root Class 3 CA 2 2009
  40437. ==============================
  40438. -----BEGIN CERTIFICATE-----
  40439. MIIEMzCCAxugAwIBAgIDCYPzMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  40440. DAxELVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTAe
  40441. Fw0wOTExMDUwODM1NThaFw0yOTExMDUwODM1NThaME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxE
  40442. LVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTCCASIw
  40443. DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANOySs96R+91myP6Oi/WUEWJNTrGa9v+2wBoqOAD
  40444. ER03UAifTUpolDWzU9GUY6cgVq/eUXjsKj3zSEhQPgrfRlWLJ23DEE0NkVJD2IfgXU42tSHKXzlA
  40445. BF9bfsyjxiupQB7ZNoTWSPOSHjRGICTBpFGOShrvUD9pXRl/RcPHAY9RySPocq60vFYJfxLLHLGv
  40446. KZAKyVXMD9O0Gu1HNVpK7ZxzBCHQqr0ME7UAyiZsxGsMlFqVlNpQmvH/pStmMaTJOKDfHR+4CS7z
  40447. p+hnUquVH+BGPtikw8paxTGA6Eian5Rp/hnd2HN8gcqW3o7tszIFZYQ05ub9VxC1X3a/L7AQDcUC
  40448. AwEAAaOCARowggEWMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFP3aFMSfMN4hvR5COfyrYyNJ
  40449. 4PGEMA4GA1UdDwEB/wQEAwIBBjCB0wYDVR0fBIHLMIHIMIGAoH6gfIZ6bGRhcDovL2RpcmVjdG9y
  40450. eS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwUm9vdCUyMENsYXNzJTIwMyUyMENBJTIwMiUyMDIw
  40451. MDksTz1ELVRydXN0JTIwR21iSCxDPURFP2NlcnRpZmljYXRlcmV2b2NhdGlvbmxpc3QwQ6BBoD+G
  40452. PWh0dHA6Ly93d3cuZC10cnVzdC5uZXQvY3JsL2QtdHJ1c3Rfcm9vdF9jbGFzc18zX2NhXzJfMjAw
  40453. OS5jcmwwDQYJKoZIhvcNAQELBQADggEBAH+X2zDI36ScfSF6gHDOFBJpiBSVYEQBrLLpME+bUMJm
  40454. 2H6NMLVwMeniacfzcNsgFYbQDfC+rAF1hM5+n02/t2A7nPPKHeJeaNijnZflQGDSNiH+0LS4F9p0
  40455. o3/U37CYAqxva2ssJSRyoWXuJVrl5jLn8t+rSfrzkGkj2wTZ51xY/GXUl77M/C4KzCUqNQT4YJEV
  40456. dT1B/yMfGchs64JTBKbkTCJNjYy6zltz7GRUUG3RnFX7acM2w4y8PIWmawomDeCTmGCufsYkl4ph
  40457. X5GOZpIJhzbNi5stPvZR1FDUWSi9g/LMKHtThm3YJohw1+qRzT65ysCQblrGXnRl11z+o+I=
  40458. -----END CERTIFICATE-----
  40459. D-TRUST Root Class 3 CA 2 EV 2009
  40460. =================================
  40461. -----BEGIN CERTIFICATE-----
  40462. MIIEQzCCAyugAwIBAgIDCYP0MA0GCSqGSIb3DQEBCwUAMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  40463. DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw
  40464. OTAeFw0wOTExMDUwODUwNDZaFw0yOTExMDUwODUwNDZaMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  40465. DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw
  40466. OTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJnxhDRwui+3MKCOvXwEz75ivJn9gpfS
  40467. egpnljgJ9hBOlSJzmY3aFS3nBfwZcyK3jpgAvDw9rKFs+9Z5JUut8Mxk2og+KbgPCdM03TP1YtHh
  40468. zRnp7hhPTFiu4h7WDFsVWtg6uMQYZB7jM7K1iXdODL/ZlGsTl28So/6ZqQTMFexgaDbtCHu39b+T
  40469. 7WYxg4zGcTSHThfqr4uRjRxWQa4iN1438h3Z0S0NL2lRp75mpoo6Kr3HGrHhFPC+Oh25z1uxav60
  40470. sUYgovseO3Dvk5h9jHOW8sXvhXCtKSb8HgQ+HKDYD8tSg2J87otTlZCpV6LqYQXY+U3EJ/pure35
  40471. 11H3a6UCAwEAAaOCASQwggEgMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFNOUikxiEyoZLsyv
  40472. cop9NteaHNxnMA4GA1UdDwEB/wQEAwIBBjCB3QYDVR0fBIHVMIHSMIGHoIGEoIGBhn9sZGFwOi8v
  40473. ZGlyZWN0b3J5LmQtdHJ1c3QubmV0L0NOPUQtVFJVU1QlMjBSb290JTIwQ2xhc3MlMjAzJTIwQ0El
  40474. MjAyJTIwRVYlMjAyMDA5LE89RC1UcnVzdCUyMEdtYkgsQz1ERT9jZXJ0aWZpY2F0ZXJldm9jYXRp
  40475. b25saXN0MEagRKBChkBodHRwOi8vd3d3LmQtdHJ1c3QubmV0L2NybC9kLXRydXN0X3Jvb3RfY2xh
  40476. c3NfM19jYV8yX2V2XzIwMDkuY3JsMA0GCSqGSIb3DQEBCwUAA4IBAQA07XtaPKSUiO8aEXUHL7P+
  40477. PPoeUSbrh/Yp3uDx1MYkCenBz1UbtDDZzhr+BlGmFaQt77JLvyAoJUnRpjZ3NOhk31KxEcdzes05
  40478. nsKtjHEh8lprr988TlWvsoRlFIm5d8sqMb7Po23Pb0iUMkZv53GMoKaEGTcH8gNFCSuGdXzfX2lX
  40479. ANtu2KZyIktQ1HWYVt+3GP9DQ1CuekR78HlR10M9p9OB0/DJT7naxpeG0ILD5EJt/rDiZE4OJudA
  40480. NCa1CInXCGNjOCd1HjPqbqjdn5lPdE2BiYBL3ZqXKVwvvoFBuYz/6n1gBp7N1z3TLqMVvKjmJuVv
  40481. w9y4AyHqnxbxLFS1
  40482. -----END CERTIFICATE-----
  40483. CA Disig Root R2
  40484. ================
  40485. -----BEGIN CERTIFICATE-----
  40486. MIIFaTCCA1GgAwIBAgIJAJK4iNuwisFjMA0GCSqGSIb3DQEBCwUAMFIxCzAJBgNVBAYTAlNLMRMw
  40487. EQYDVQQHEwpCcmF0aXNsYXZhMRMwEQYDVQQKEwpEaXNpZyBhLnMuMRkwFwYDVQQDExBDQSBEaXNp
  40488. ZyBSb290IFIyMB4XDTEyMDcxOTA5MTUzMFoXDTQyMDcxOTA5MTUzMFowUjELMAkGA1UEBhMCU0sx
  40489. EzARBgNVBAcTCkJyYXRpc2xhdmExEzARBgNVBAoTCkRpc2lnIGEucy4xGTAXBgNVBAMTEENBIERp
  40490. c2lnIFJvb3QgUjIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCio8QACdaFXS1tFPbC
  40491. w3OeNcJxVX6B+6tGUODBfEl45qt5WDza/3wcn9iXAng+a0EE6UG9vgMsRfYvZNSrXaNHPWSb6Wia
  40492. xswbP7q+sos0Ai6YVRn8jG+qX9pMzk0DIaPY0jSTVpbLTAwAFjxfGs3Ix2ymrdMxp7zo5eFm1tL7
  40493. A7RBZckQrg4FY8aAamkw/dLukO8NJ9+flXP04SXabBbeQTg06ov80egEFGEtQX6sx3dOy1FU+16S
  40494. GBsEWmjGycT6txOgmLcRK7fWV8x8nhfRyyX+hk4kLlYMeE2eARKmK6cBZW58Yh2EhN/qwGu1pSqV
  40495. g8NTEQxzHQuyRpDRQjrOQG6Vrf/GlK1ul4SOfW+eioANSW1z4nuSHsPzwfPrLgVv2RvPN3YEyLRa
  40496. 5Beny912H9AZdugsBbPWnDTYltxhh5EF5EQIM8HauQhl1K6yNg3ruji6DOWbnuuNZt2Zz9aJQfYE
  40497. koopKW1rOhzndX0CcQ7zwOe9yxndnWCywmZgtrEE7snmhrmaZkCo5xHtgUUDi/ZnWejBBhG93c+A
  40498. Ak9lQHhcR1DIm+YfgXvkRKhbhZri3lrVx/k6RGZL5DJUfORsnLMOPReisjQS1n6yqEm70XooQL6i
  40499. Fh/f5DcfEXP7kAplQ6INfPgGAVUzfbANuPT1rqVCV3w2EYx7XsQDnYx5nQIDAQABo0IwQDAPBgNV
  40500. HRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUtZn4r7CU9eMg1gqtzk5WpC5u
  40501. Qu0wDQYJKoZIhvcNAQELBQADggIBACYGXnDnZTPIgm7ZnBc6G3pmsgH2eDtpXi/q/075KMOYKmFM
  40502. tCQSin1tERT3nLXK5ryeJ45MGcipvXrA1zYObYVybqjGom32+nNjf7xueQgcnYqfGopTpti72TVV
  40503. sRHFqQOzVju5hJMiXn7B9hJSi+osZ7z+Nkz1uM/Rs0mSO9MpDpkblvdhuDvEK7Z4bLQjb/D907Je
  40504. dR+Zlais9trhxTF7+9FGs9K8Z7RiVLoJ92Owk6Ka+elSLotgEqv89WBW7xBci8QaQtyDW2QOy7W8
  40505. 1k/BfDxujRNt+3vrMNDcTa/F1balTFtxyegxvug4BkihGuLq0t4SOVga/4AOgnXmt8kHbA7v/zjx
  40506. mHHEt38OFdAlab0inSvtBfZGR6ztwPDUO+Ls7pZbkBNOHlY667DvlruWIxG68kOGdGSVyCh13x01
  40507. utI3gzhTODY7z2zp+WsO0PsE6E9312UBeIYMej4hYvF/Y3EMyZ9E26gnonW+boE+18DrG5gPcFw0
  40508. sorMwIUY6256s/daoQe/qUKS82Ail+QUoQebTnbAjn39pCXHR+3/H3OszMOl6W8KjptlwlCFtaOg
  40509. UxLMVYdh84GuEEZhvUQhuMI9dM9+JDX6HAcOmz0iyu8xL4ysEr3vQCj8KWefshNPZiTEUxnpHikV
  40510. 7+ZtsH8tZ/3zbBt1RqPlShfppNcL
  40511. -----END CERTIFICATE-----
  40512. ACCVRAIZ1
  40513. =========
  40514. -----BEGIN CERTIFICATE-----
  40515. MIIH0zCCBbugAwIBAgIIXsO3pkN/pOAwDQYJKoZIhvcNAQEFBQAwQjESMBAGA1UEAwwJQUNDVlJB
  40516. SVoxMRAwDgYDVQQLDAdQS0lBQ0NWMQ0wCwYDVQQKDARBQ0NWMQswCQYDVQQGEwJFUzAeFw0xMTA1
  40517. MDUwOTM3MzdaFw0zMDEyMzEwOTM3MzdaMEIxEjAQBgNVBAMMCUFDQ1ZSQUlaMTEQMA4GA1UECwwH
  40518. UEtJQUNDVjENMAsGA1UECgwEQUNDVjELMAkGA1UEBhMCRVMwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  40519. DwAwggIKAoICAQCbqau/YUqXry+XZpp0X9DZlv3P4uRm7x8fRzPCRKPfmt4ftVTdFXxpNRFvu8gM
  40520. jmoYHtiP2Ra8EEg2XPBjs5BaXCQ316PWywlxufEBcoSwfdtNgM3802/J+Nq2DoLSRYWoG2ioPej0
  40521. RGy9ocLLA76MPhMAhN9KSMDjIgro6TenGEyxCQ0jVn8ETdkXhBilyNpAlHPrzg5XPAOBOp0KoVdD
  40522. aaxXbXmQeOW1tDvYvEyNKKGno6e6Ak4l0Squ7a4DIrhrIA8wKFSVf+DuzgpmndFALW4ir50awQUZ
  40523. 0m/A8p/4e7MCQvtQqR0tkw8jq8bBD5L/0KIV9VMJcRz/RROE5iZe+OCIHAr8Fraocwa48GOEAqDG
  40524. WuzndN9wrqODJerWx5eHk6fGioozl2A3ED6XPm4pFdahD9GILBKfb6qkxkLrQaLjlUPTAYVtjrs7
  40525. 8yM2x/474KElB0iryYl0/wiPgL/AlmXz7uxLaL2diMMxs0Dx6M/2OLuc5NF/1OVYm3z61PMOm3WR
  40526. 5LpSLhl+0fXNWhn8ugb2+1KoS5kE3fj5tItQo05iifCHJPqDQsGH+tUtKSpacXpkatcnYGMN285J
  40527. 9Y0fkIkyF/hzQ7jSWpOGYdbhdQrqeWZ2iE9x6wQl1gpaepPluUsXQA+xtrn13k/c4LOsOxFwYIRK
  40528. Q26ZIMApcQrAZQIDAQABo4ICyzCCAscwfQYIKwYBBQUHAQEEcTBvMEwGCCsGAQUFBzAChkBodHRw
  40529. Oi8vd3d3LmFjY3YuZXMvZmlsZWFkbWluL0FyY2hpdm9zL2NlcnRpZmljYWRvcy9yYWl6YWNjdjEu
  40530. Y3J0MB8GCCsGAQUFBzABhhNodHRwOi8vb2NzcC5hY2N2LmVzMB0GA1UdDgQWBBTSh7Tj3zcnk1X2
  40531. VuqB5TbMjB4/vTAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFNKHtOPfNyeTVfZW6oHlNsyM
  40532. Hj+9MIIBcwYDVR0gBIIBajCCAWYwggFiBgRVHSAAMIIBWDCCASIGCCsGAQUFBwICMIIBFB6CARAA
  40533. QQB1AHQAbwByAGkAZABhAGQAIABkAGUAIABDAGUAcgB0AGkAZgBpAGMAYQBjAGkA8wBuACAAUgBh
  40534. AO0AegAgAGQAZQAgAGwAYQAgAEEAQwBDAFYAIAAoAEEAZwBlAG4AYwBpAGEAIABkAGUAIABUAGUA
  40535. YwBuAG8AbABvAGcA7QBhACAAeQAgAEMAZQByAHQAaQBmAGkAYwBhAGMAaQDzAG4AIABFAGwAZQBj
  40536. AHQAcgDzAG4AaQBjAGEALAAgAEMASQBGACAAUQA0ADYAMAAxADEANQA2AEUAKQAuACAAQwBQAFMA
  40537. IABlAG4AIABoAHQAdABwADoALwAvAHcAdwB3AC4AYQBjAGMAdgAuAGUAczAwBggrBgEFBQcCARYk
  40538. aHR0cDovL3d3dy5hY2N2LmVzL2xlZ2lzbGFjaW9uX2MuaHRtMFUGA1UdHwROMEwwSqBIoEaGRGh0
  40539. dHA6Ly93d3cuYWNjdi5lcy9maWxlYWRtaW4vQXJjaGl2b3MvY2VydGlmaWNhZG9zL3JhaXphY2N2
  40540. MV9kZXIuY3JsMA4GA1UdDwEB/wQEAwIBBjAXBgNVHREEEDAOgQxhY2N2QGFjY3YuZXMwDQYJKoZI
  40541. hvcNAQEFBQADggIBAJcxAp/n/UNnSEQU5CmH7UwoZtCPNdpNYbdKl02125DgBS4OxnnQ8pdpD70E
  40542. R9m+27Up2pvZrqmZ1dM8MJP1jaGo/AaNRPTKFpV8M9xii6g3+CfYCS0b78gUJyCpZET/LtZ1qmxN
  40543. YEAZSUNUY9rizLpm5U9EelvZaoErQNV/+QEnWCzI7UiRfD+mAM/EKXMRNt6GGT6d7hmKG9Ww7Y49
  40544. nCrADdg9ZuM8Db3VlFzi4qc1GwQA9j9ajepDvV+JHanBsMyZ4k0ACtrJJ1vnE5Bc5PUzolVt3OAJ
  40545. TS+xJlsndQAJxGJ3KQhfnlmstn6tn1QwIgPBHnFk/vk4CpYY3QIUrCPLBhwepH2NDd4nQeit2hW3
  40546. sCPdK6jT2iWH7ehVRE2I9DZ+hJp4rPcOVkkO1jMl1oRQQmwgEh0q1b688nCBpHBgvgW1m54ERL5h
  40547. I6zppSSMEYCUWqKiuUnSwdzRp+0xESyeGabu4VXhwOrPDYTkF7eifKXeVSUG7szAh1xA2syVP1Xg
  40548. Nce4hL60Xc16gwFy7ofmXx2utYXGJt/mwZrpHgJHnyqobalbz+xFd3+YJ5oyXSrjhO7FmGYvliAd
  40549. 3djDJ9ew+f7Zfc3Qn48LFFhRny+Lwzgt3uiP1o2HpPVWQxaZLPSkVrQ0uGE3ycJYgBugl6H8WY3p
  40550. EfbRD0tVNEYqi4Y7
  40551. -----END CERTIFICATE-----
  40552. TWCA Global Root CA
  40553. ===================
  40554. -----BEGIN CERTIFICATE-----
  40555. MIIFQTCCAymgAwIBAgICDL4wDQYJKoZIhvcNAQELBQAwUTELMAkGA1UEBhMCVFcxEjAQBgNVBAoT
  40556. CVRBSVdBTi1DQTEQMA4GA1UECxMHUm9vdCBDQTEcMBoGA1UEAxMTVFdDQSBHbG9iYWwgUm9vdCBD
  40557. QTAeFw0xMjA2MjcwNjI4MzNaFw0zMDEyMzExNTU5NTlaMFExCzAJBgNVBAYTAlRXMRIwEAYDVQQK
  40558. EwlUQUlXQU4tQ0ExEDAOBgNVBAsTB1Jvb3QgQ0ExHDAaBgNVBAMTE1RXQ0EgR2xvYmFsIFJvb3Qg
  40559. Q0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCwBdvI64zEbooh745NnHEKH1Jw7W2C
  40560. nJfF10xORUnLQEK1EjRsGcJ0pDFfhQKX7EMzClPSnIyOt7h52yvVavKOZsTuKwEHktSz0ALfUPZV
  40561. r2YOy+BHYC8rMjk1Ujoog/h7FsYYuGLWRyWRzvAZEk2tY/XTP3VfKfChMBwqoJimFb3u/Rk28OKR
  40562. Q4/6ytYQJ0lM793B8YVwm8rqqFpD/G2Gb3PpN0Wp8DbHzIh1HrtsBv+baz4X7GGqcXzGHaL3SekV
  40563. tTzWoWH1EfcFbx39Eb7QMAfCKbAJTibc46KokWofwpFFiFzlmLhxpRUZyXx1EcxwdE8tmx2RRP1W
  40564. KKD+u4ZqyPpcC1jcxkt2yKsi2XMPpfRaAok/T54igu6idFMqPVMnaR1sjjIsZAAmY2E2TqNGtz99
  40565. sy2sbZCilaLOz9qC5wc0GZbpuCGqKX6mOL6OKUohZnkfs8O1CWfe1tQHRvMq2uYiN2DLgbYPoA/p
  40566. yJV/v1WRBXrPPRXAb94JlAGD1zQbzECl8LibZ9WYkTunhHiVJqRaCPgrdLQABDzfuBSO6N+pjWxn
  40567. kjMdwLfS7JLIvgm/LCkFbwJrnu+8vyq8W8BQj0FwcYeyTbcEqYSjMq+u7msXi7Kx/mzhkIyIqJdI
  40568. zshNy/MGz19qCkKxHh53L46g5pIOBvwFItIm4TFRfTLcDwIDAQABoyMwITAOBgNVHQ8BAf8EBAMC
  40569. AQYwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEAXzSBdu+WHdXltdkCY4QWwa6g
  40570. cFGn90xHNcgL1yg9iXHZqjNB6hQbbCEAwGxCGX6faVsgQt+i0trEfJdLjbDorMjupWkEmQqSpqsn
  40571. LhpNgb+E1HAerUf+/UqdM+DyucRFCCEK2mlpc3INvjT+lIutwx4116KD7+U4x6WFH6vPNOw/KP4M
  40572. 8VeGTslV9xzU2KV9Bnpv1d8Q34FOIWWxtuEXeZVFBs5fzNxGiWNoRI2T9GRwoD2dKAXDOXC4Ynsg
  40573. /eTb6QihuJ49CcdP+yz4k3ZB3lLg4VfSnQO8d57+nile98FRYB/e2guyLXW3Q0iT5/Z5xoRdgFlg
  40574. lPx4mI88k1HtQJAH32RjJMtOcQWh15QaiDLxInQirqWm2BJpTGCjAu4r7NRjkgtevi92a6O2JryP
  40575. A9gK8kxkRr05YuWW6zRjESjMlfGt7+/cgFhI6Uu46mWs6fyAtbXIRfmswZ/ZuepiiI7E8UuDEq3m
  40576. i4TWnsLrgxifarsbJGAzcMzs9zLzXNl5fe+epP7JI8Mk7hWSsT2RTyaGvWZzJBPqpK5jwa19hAM8
  40577. EHiGG3njxPPyBJUgriOCxLM6AGK/5jYk4Ve6xx6QddVfP5VhK8E7zeWzaGHQRiapIVJpLesux+t3
  40578. zqY6tQMzT3bR51xUAV3LePTJDL/PEo4XLSNolOer/qmyKwbQBM0=
  40579. -----END CERTIFICATE-----
  40580. TeliaSonera Root CA v1
  40581. ======================
  40582. -----BEGIN CERTIFICATE-----
  40583. MIIFODCCAyCgAwIBAgIRAJW+FqD3LkbxezmCcvqLzZYwDQYJKoZIhvcNAQEFBQAwNzEUMBIGA1UE
  40584. CgwLVGVsaWFTb25lcmExHzAdBgNVBAMMFlRlbGlhU29uZXJhIFJvb3QgQ0EgdjEwHhcNMDcxMDE4
  40585. MTIwMDUwWhcNMzIxMDE4MTIwMDUwWjA3MRQwEgYDVQQKDAtUZWxpYVNvbmVyYTEfMB0GA1UEAwwW
  40586. VGVsaWFTb25lcmEgUm9vdCBDQSB2MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMK+
  40587. 6yfwIaPzaSZVfp3FVRaRXP3vIb9TgHot0pGMYzHw7CTww6XScnwQbfQ3t+XmfHnqjLWCi65ItqwA
  40588. 3GV17CpNX8GH9SBlK4GoRz6JI5UwFpB/6FcHSOcZrr9FZ7E3GwYq/t75rH2D+1665I+XZ75Ljo1k
  40589. B1c4VWk0Nj0TSO9P4tNmHqTPGrdeNjPUtAa9GAH9d4RQAEX1jF3oI7x+/jXh7VB7qTCNGdMJjmhn
  40590. Xb88lxhTuylixcpecsHHltTbLaC0H2kD7OriUPEMPPCs81Mt8Bz17Ww5OXOAFshSsCPN4D7c3TxH
  40591. oLs1iuKYaIu+5b9y7tL6pe0S7fyYGKkmdtwoSxAgHNN/Fnct7W+A90m7UwW7XWjH1Mh1Fj+JWov3
  40592. F0fUTPHSiXk+TT2YqGHeOh7S+F4D4MHJHIzTjU3TlTazN19jY5szFPAtJmtTfImMMsJu7D0hADnJ
  40593. oWjiUIMusDor8zagrC/kb2HCUQk5PotTubtn2txTuXZZNp1D5SDgPTJghSJRt8czu90VL6R4pgd7
  40594. gUY2BIbdeTXHlSw7sKMXNeVzH7RcWe/a6hBle3rQf5+ztCo3O3CLm1u5K7fsslESl1MpWtTwEhDc
  40595. TwK7EpIvYtQ/aUN8Ddb8WHUBiJ1YFkveupD/RwGJBmr2X7KQarMCpgKIv7NHfirZ1fpoeDVNAgMB
  40596. AAGjPzA9MA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1UdDgQWBBTwj1k4ALP1j5qW
  40597. DNXr+nuqF+gTEjANBgkqhkiG9w0BAQUFAAOCAgEAvuRcYk4k9AwI//DTDGjkk0kiP0Qnb7tt3oNm
  40598. zqjMDfz1mgbldxSR651Be5kqhOX//CHBXfDkH1e3damhXwIm/9fH907eT/j3HEbAek9ALCI18Bmx
  40599. 0GtnLLCo4MBANzX2hFxc469CeP6nyQ1Q6g2EdvZR74NTxnr/DlZJLo961gzmJ1TjTQpgcmLNkQfW
  40600. pb/ImWvtxBnmq0wROMVvMeJuScg/doAmAyYp4Db29iBT4xdwNBedY2gea+zDTYa4EzAvXUYNR0PV
  40601. G6pZDrlcjQZIrXSHX8f8MVRBE+LHIQ6e4B4N4cB7Q4WQxYpYxmUKeFfyxiMPAdkgS94P+5KFdSpc
  40602. c41teyWRyu5FrgZLAMzTsVlQ2jqIOylDRl6XK1TOU2+NSueW+r9xDkKLfP0ooNBIytrEgUy7onOT
  40603. JsjrDNYmiLbAJM+7vVvrdX3pCI6GMyx5dwlppYn8s3CQh3aP0yK7Qs69cwsgJirQmz1wHiRszYd2
  40604. qReWt88NkvuOGKmYSdGe/mBEciG5Ge3C9THxOUiIkCR1VBatzvT4aRRkOfujuLpwQMcnHL/EVlP6
  40605. Y2XQ8xwOFvVrhlhNGNTkDY6lnVuR3HYkUD/GKvvZt5y11ubQ2egZixVxSK236thZiNSQvxaz2ems
  40606. WWFUyBy6ysHK4bkgTI86k4mloMy/0/Z1pHWWbVY=
  40607. -----END CERTIFICATE-----
  40608. E-Tugra Certification Authority
  40609. ===============================
  40610. -----BEGIN CERTIFICATE-----
  40611. MIIGSzCCBDOgAwIBAgIIamg+nFGby1MwDQYJKoZIhvcNAQELBQAwgbIxCzAJBgNVBAYTAlRSMQ8w
  40612. DQYDVQQHDAZBbmthcmExQDA+BgNVBAoMN0UtVHXEn3JhIEVCRyBCaWxpxZ9pbSBUZWtub2xvamls
  40613. ZXJpIHZlIEhpem1ldGxlcmkgQS7Fni4xJjAkBgNVBAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBN
  40614. ZXJrZXppMSgwJgYDVQQDDB9FLVR1Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTEzMDMw
  40615. NTEyMDk0OFoXDTIzMDMwMzEyMDk0OFowgbIxCzAJBgNVBAYTAlRSMQ8wDQYDVQQHDAZBbmthcmEx
  40616. QDA+BgNVBAoMN0UtVHXEn3JhIEVCRyBCaWxpxZ9pbSBUZWtub2xvamlsZXJpIHZlIEhpem1ldGxl
  40617. cmkgQS7Fni4xJjAkBgNVBAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBNZXJrZXppMSgwJgYDVQQD
  40618. DB9FLVR1Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  40619. MIICCgKCAgEA4vU/kwVRHoViVF56C/UYB4Oufq9899SKa6VjQzm5S/fDxmSJPZQuVIBSOTkHS0vd
  40620. hQd2h8y/L5VMzH2nPbxHD5hw+IyFHnSOkm0bQNGZDbt1bsipa5rAhDGvykPL6ys06I+XawGb1Q5K
  40621. CKpbknSFQ9OArqGIW66z6l7LFpp3RMih9lRozt6Plyu6W0ACDGQXwLWTzeHxE2bODHnv0ZEoq1+g
  40622. ElIwcxmOj+GMB6LDu0rw6h8VqO4lzKRG+Bsi77MOQ7osJLjFLFzUHPhdZL3Dk14opz8n8Y4e0ypQ
  40623. BaNV2cvnOVPAmJ6MVGKLJrD3fY185MaeZkJVgkfnsliNZvcHfC425lAcP9tDJMW/hkd5s3kc91r0
  40624. E+xs+D/iWR+V7kI+ua2oMoVJl0b+SzGPWsutdEcf6ZG33ygEIqDUD13ieU/qbIWGvaimzuT6w+Gz
  40625. rt48Ue7LE3wBf4QOXVGUnhMMti6lTPk5cDZvlsouDERVxcr6XQKj39ZkjFqzAQqptQpHF//vkUAq
  40626. jqFGOjGY5RH8zLtJVor8udBhmm9lbObDyz51Sf6Pp+KJxWfXnUYTTjF2OySznhFlhqt/7x3U+Lzn
  40627. rFpct1pHXFXOVbQicVtbC/DP3KBhZOqp12gKY6fgDT+gr9Oq0n7vUaDmUStVkhUXU8u3Zg5mTPj5
  40628. dUyQ5xJwx0UCAwEAAaNjMGEwHQYDVR0OBBYEFC7j27JJ0JxUeVz6Jyr+zE7S6E5UMA8GA1UdEwEB
  40629. /wQFMAMBAf8wHwYDVR0jBBgwFoAULuPbsknQnFR5XPonKv7MTtLoTlQwDgYDVR0PAQH/BAQDAgEG
  40630. MA0GCSqGSIb3DQEBCwUAA4ICAQAFNzr0TbdF4kV1JI+2d1LoHNgQk2Xz8lkGpD4eKexd0dCrfOAK
  40631. kEh47U6YA5n+KGCRHTAduGN8qOY1tfrTYXbm1gdLymmasoR6d5NFFxWfJNCYExL/u6Au/U5Mh/jO
  40632. XKqYGwXgAEZKgoClM4so3O0409/lPun++1ndYYRP0lSWE2ETPo+Aab6TR7U1Q9Jauz1c77NCR807
  40633. VRMGsAnb/WP2OogKmW9+4c4bU2pEZiNRCHu8W1Ki/QY3OEBhj0qWuJA3+GbHeJAAFS6LrVE1Uweo
  40634. a2iu+U48BybNCAVwzDk/dr2l02cmAYamU9JgO3xDf1WKvJUawSg5TB9D0pH0clmKuVb8P7Sd2nCc
  40635. dlqMQ1DujjByTd//SffGqWfZbawCEeI6FiWnWAjLb1NBnEg4R2gz0dfHj9R0IdTDBZB6/86WiLEV
  40636. KV0jq9BgoRJP3vQXzTLlyb/IQ639Lo7xr+L0mPoSHyDYwKcMhcWQ9DstliaxLL5Mq+ux0orJ23gT
  40637. Dx4JnW2PAJ8C2sH6H3p6CcRK5ogql5+Ji/03X186zjhZhkuvcQu02PJwT58yE+Owp1fl2tpDy4Q0
  40638. 8ijE6m30Ku/Ba3ba+367hTzSU8JNvnHhRdH9I2cNE3X7z2VnIp2usAnRCf8dNL/+I5c30jn6PQ0G
  40639. C7TbO6Orb1wdtn7os4I07QZcJA==
  40640. -----END CERTIFICATE-----
  40641. T-TeleSec GlobalRoot Class 2
  40642. ============================
  40643. -----BEGIN CERTIFICATE-----
  40644. MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM
  40645. IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU
  40646. cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwHhcNMDgx
  40647. MDAxMTA0MDE0WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz
  40648. dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD
  40649. ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwggEiMA0GCSqGSIb3
  40650. DQEBAQUAA4IBDwAwggEKAoIBAQCqX9obX+hzkeXaXPSi5kfl82hVYAUdAqSzm1nzHoqvNK38DcLZ
  40651. SBnuaY/JIPwhqgcZ7bBcrGXHX+0CfHt8LRvWurmAwhiCFoT6ZrAIxlQjgeTNuUk/9k9uN0goOA/F
  40652. vudocP05l03Sx5iRUKrERLMjfTlH6VJi1hKTXrcxlkIF+3anHqP1wvzpesVsqXFP6st4vGCvx970
  40653. 2cu+fjOlbpSD8DT6IavqjnKgP6TeMFvvhk1qlVtDRKgQFRzlAVfFmPHmBiiRqiDFt1MmUUOyCxGV
  40654. WOHAD3bZwI18gfNycJ5v/hqO2V81xrJvNHy+SE/iWjnX2J14np+GPgNeGYtEotXHAgMBAAGjQjBA
  40655. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS/WSA2AHmgoCJrjNXy
  40656. YdK4LMuCSjANBgkqhkiG9w0BAQsFAAOCAQEAMQOiYQsfdOhyNsZt+U2e+iKo4YFWz827n+qrkRk4
  40657. r6p8FU3ztqONpfSO9kSpp+ghla0+AGIWiPACuvxhI+YzmzB6azZie60EI4RYZeLbK4rnJVM3YlNf
  40658. vNoBYimipidx5joifsFvHZVwIEoHNN/q/xWA5brXethbdXwFeilHfkCoMRN3zUA7tFFHei4R40cR
  40659. 3p1m0IvVVGb6g1XqfMIpiRvpb7PO4gWEyS8+eIVibslfwXhjdFjASBgMmTnrpMwatXlajRWc2BQN
  40660. 9noHV8cigwUtPJslJj0Ys6lDfMjIq2SPDqO/nBudMNva0Bkuqjzx+zOAduTNrRlPBSeOE6Fuwg==
  40661. -----END CERTIFICATE-----
  40662. Atos TrustedRoot 2011
  40663. =====================
  40664. -----BEGIN CERTIFICATE-----
  40665. MIIDdzCCAl+gAwIBAgIIXDPLYixfszIwDQYJKoZIhvcNAQELBQAwPDEeMBwGA1UEAwwVQXRvcyBU
  40666. cnVzdGVkUm9vdCAyMDExMQ0wCwYDVQQKDARBdG9zMQswCQYDVQQGEwJERTAeFw0xMTA3MDcxNDU4
  40667. MzBaFw0zMDEyMzEyMzU5NTlaMDwxHjAcBgNVBAMMFUF0b3MgVHJ1c3RlZFJvb3QgMjAxMTENMAsG
  40668. A1UECgwEQXRvczELMAkGA1UEBhMCREUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCV
  40669. hTuXbyo7LjvPpvMpNb7PGKw+qtn4TaA+Gke5vJrf8v7MPkfoepbCJI419KkM/IL9bcFyYie96mvr
  40670. 54rMVD6QUM+A1JX76LWC1BTFtqlVJVfbsVD2sGBkWXppzwO3bw2+yj5vdHLqqjAqc2K+SZFhyBH+
  40671. DgMq92og3AIVDV4VavzjgsG1xZ1kCWyjWZgHJ8cblithdHFsQ/H3NYkQ4J7sVaE3IqKHBAUsR320
  40672. HLliKWYoyrfhk/WklAOZuXCFteZI6o1Q/NnezG8HDt0Lcp2AMBYHlT8oDv3FdU9T1nSatCQujgKR
  40673. z3bFmx5VdJx4IbHwLfELn8LVlhgf8FQieowHAgMBAAGjfTB7MB0GA1UdDgQWBBSnpQaxLKYJYO7R
  40674. l+lwrrw7GWzbITAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFKelBrEspglg7tGX6XCuvDsZ
  40675. bNshMBgGA1UdIAQRMA8wDQYLKwYBBAGwLQMEAQEwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEB
  40676. CwUAA4IBAQAmdzTblEiGKkGdLD4GkGDEjKwLVLgfuXvTBznk+j57sj1O7Z8jvZfza1zv7v1Apt+h
  40677. k6EKhqzvINB5Ab149xnYJDE0BAGmuhWawyfc2E8PzBhj/5kPDpFrdRbhIfzYJsdHt6bPWHJxfrrh
  40678. TZVHO8mvbaG0weyJ9rQPOLXiZNwlz6bb65pcmaHFCN795trV1lpFDMS3wrUU77QR/w4VtfX128a9
  40679. 61qn8FYiqTxlVMYVqL2Gns2Dlmh6cYGJ4Qvh6hEbaAjMaZ7snkGeRDImeuKHCnE96+RapNLbxc3G
  40680. 3mB/ufNPRJLvKrcYPqcZ2Qt9sTdBQrC6YB3y/gkRsPCHe6ed
  40681. -----END CERTIFICATE-----
  40682. QuoVadis Root CA 1 G3
  40683. =====================
  40684. -----BEGIN CERTIFICATE-----
  40685. MIIFYDCCA0igAwIBAgIUeFhfLq0sGUvjNwc1NBMotZbUZZMwDQYJKoZIhvcNAQELBQAwSDELMAkG
  40686. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  40687. b3QgQ0EgMSBHMzAeFw0xMjAxMTIxNzI3NDRaFw00MjAxMTIxNzI3NDRaMEgxCzAJBgNVBAYTAkJN
  40688. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDEg
  40689. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCgvlAQjunybEC0BJyFuTHK3C3kEakE
  40690. PBtVwedYMB0ktMPvhd6MLOHBPd+C5k+tR4ds7FtJwUrVu4/sh6x/gpqG7D0DmVIB0jWerNrwU8lm
  40691. PNSsAgHaJNM7qAJGr6Qc4/hzWHa39g6QDbXwz8z6+cZM5cOGMAqNF34168Xfuw6cwI2H44g4hWf6
  40692. Pser4BOcBRiYz5P1sZK0/CPTz9XEJ0ngnjybCKOLXSoh4Pw5qlPafX7PGglTvF0FBM+hSo+LdoIN
  40693. ofjSxxR3W5A2B4GbPgb6Ul5jxaYA/qXpUhtStZI5cgMJYr2wYBZupt0lwgNm3fME0UDiTouG9G/l
  40694. g6AnhF4EwfWQvTA9xO+oabw4m6SkltFi2mnAAZauy8RRNOoMqv8hjlmPSlzkYZqn0ukqeI1RPToV
  40695. 7qJZjqlc3sX5kCLliEVx3ZGZbHqfPT2YfF72vhZooF6uCyP8Wg+qInYtyaEQHeTTRCOQiJ/GKubX
  40696. 9ZqzWB4vMIkIG1SitZgj7Ah3HJVdYdHLiZxfokqRmu8hqkkWCKi9YSgxyXSthfbZxbGL0eUQMk1f
  40697. iyA6PEkfM4VZDdvLCXVDaXP7a3F98N/ETH3Goy7IlXnLc6KOTk0k+17kBL5yG6YnLUlamXrXXAkg
  40698. t3+UuU/xDRxeiEIbEbfnkduebPRq34wGmAOtzCjvpUfzUwIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  40699. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUo5fW816iEOGrRZ88F2Q87gFwnMwwDQYJKoZI
  40700. hvcNAQELBQADggIBABj6W3X8PnrHX3fHyt/PX8MSxEBd1DKquGrX1RUVRpgjpeaQWxiZTOOtQqOC
  40701. MTaIzen7xASWSIsBx40Bz1szBpZGZnQdT+3Btrm0DWHMY37XLneMlhwqI2hrhVd2cDMT/uFPpiN3
  40702. GPoajOi9ZcnPP/TJF9zrx7zABC4tRi9pZsMbj/7sPtPKlL92CiUNqXsCHKnQO18LwIE6PWThv6ct
  40703. Tr1NxNgpxiIY0MWscgKCP6o6ojoilzHdCGPDdRS5YCgtW2jgFqlmgiNR9etT2DGbe+m3nUvriBbP
  40704. +V04ikkwj+3x6xn0dxoxGE1nVGwvb2X52z3sIexe9PSLymBlVNFxZPT5pqOBMzYzcfCkeF9OrYMh
  40705. 3jRJjehZrJ3ydlo28hP0r+AJx2EqbPfgna67hkooby7utHnNkDPDs3b69fBsnQGQ+p6Q9pxyz0fa
  40706. wx/kNSBT8lTR32GDpgLiJTjehTItXnOQUl1CxM49S+H5GYQd1aJQzEH7QRTDvdbJWqNjZgKAvQU6
  40707. O0ec7AAmTPWIUb+oI38YB7AL7YsmoWTTYUrrXJ/es69nA7Mf3W1daWhpq1467HxpvMc7hU6eFbm0
  40708. FU/DlXpY18ls6Wy58yljXrQs8C097Vpl4KlbQMJImYFtnh8GKjwStIsPm6Ik8KaN1nrgS7ZklmOV
  40709. hMJKzRwuJIczYOXD
  40710. -----END CERTIFICATE-----
  40711. QuoVadis Root CA 2 G3
  40712. =====================
  40713. -----BEGIN CERTIFICATE-----
  40714. MIIFYDCCA0igAwIBAgIURFc0JFuBiZs18s64KztbpybwdSgwDQYJKoZIhvcNAQELBQAwSDELMAkG
  40715. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  40716. b3QgQ0EgMiBHMzAeFw0xMjAxMTIxODU5MzJaFw00MjAxMTIxODU5MzJaMEgxCzAJBgNVBAYTAkJN
  40717. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDIg
  40718. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQChriWyARjcV4g/Ruv5r+LrI3HimtFh
  40719. ZiFfqq8nUeVuGxbULX1QsFN3vXg6YOJkApt8hpvWGo6t/x8Vf9WVHhLL5hSEBMHfNrMWn4rjyduY
  40720. NM7YMxcoRvynyfDStNVNCXJJ+fKH46nafaF9a7I6JaltUkSs+L5u+9ymc5GQYaYDFCDy54ejiK2t
  40721. oIz/pgslUiXnFgHVy7g1gQyjO/Dh4fxaXc6AcW34Sas+O7q414AB+6XrW7PFXmAqMaCvN+ggOp+o
  40722. MiwMzAkd056OXbxMmO7FGmh77FOm6RQ1o9/NgJ8MSPsc9PG/Srj61YxxSscfrf5BmrODXfKEVu+l
  40723. V0POKa2Mq1W/xPtbAd0jIaFYAI7D0GoT7RPjEiuA3GfmlbLNHiJuKvhB1PLKFAeNilUSxmn1uIZo
  40724. L1NesNKqIcGY5jDjZ1XHm26sGahVpkUG0CM62+tlXSoREfA7T8pt9DTEceT/AFr2XK4jYIVz8eQQ
  40725. sSWu1ZK7E8EM4DnatDlXtas1qnIhO4M15zHfeiFuuDIIfR0ykRVKYnLP43ehvNURG3YBZwjgQQvD
  40726. 6xVu+KQZ2aKrr+InUlYrAoosFCT5v0ICvybIxo/gbjh9Uy3l7ZizlWNof/k19N+IxWA1ksB8aRxh
  40727. lRbQ694Lrz4EEEVlWFA4r0jyWbYW8jwNkALGcC4BrTwV1wIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  40728. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQU7edvdlq/YOxJW8ald7tyFnGbxD0wDQYJKoZI
  40729. hvcNAQELBQADggIBAJHfgD9DCX5xwvfrs4iP4VGyvD11+ShdyLyZm3tdquXK4Qr36LLTn91nMX66
  40730. AarHakE7kNQIXLJgapDwyM4DYvmL7ftuKtwGTTwpD4kWilhMSA/ohGHqPHKmd+RCroijQ1h5fq7K
  40731. pVMNqT1wvSAZYaRsOPxDMuHBR//47PERIjKWnML2W2mWeyAMQ0GaW/ZZGYjeVYg3UQt4XAoeo0L9
  40732. x52ID8DyeAIkVJOviYeIyUqAHerQbj5hLja7NQ4nlv1mNDthcnPxFlxHBlRJAHpYErAK74X9sbgz
  40733. dWqTHBLmYF5vHX/JHyPLhGGfHoJE+V+tYlUkmlKY7VHnoX6XOuYvHxHaU4AshZ6rNRDbIl9qxV6X
  40734. U/IyAgkwo1jwDQHVcsaxfGl7w/U2Rcxhbl5MlMVerugOXou/983g7aEOGzPuVBj+D77vfoRrQ+Nw
  40735. mNtddbINWQeFFSM51vHfqSYP1kjHs6Yi9TM3WpVHn3u6GBVv/9YUZINJ0gpnIdsPNWNgKCLjsZWD
  40736. zYWm3S8P52dSbrsvhXz1SnPnxT7AvSESBT/8twNJAlvIJebiVDj1eYeMHVOyToV7BjjHLPj4sHKN
  40737. JeV3UvQDHEimUF+IIDBu8oJDqz2XhOdT+yHBTw8imoa4WSr2Rz0ZiC3oheGe7IUIarFsNMkd7Egr
  40738. O3jtZsSOeWmD3n+M
  40739. -----END CERTIFICATE-----
  40740. QuoVadis Root CA 3 G3
  40741. =====================
  40742. -----BEGIN CERTIFICATE-----
  40743. MIIFYDCCA0igAwIBAgIULvWbAiin23r/1aOp7r0DoM8Sah0wDQYJKoZIhvcNAQELBQAwSDELMAkG
  40744. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  40745. b3QgQ0EgMyBHMzAeFw0xMjAxMTIyMDI2MzJaFw00MjAxMTIyMDI2MzJaMEgxCzAJBgNVBAYTAkJN
  40746. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDMg
  40747. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCzyw4QZ47qFJenMioKVjZ/aEzHs286
  40748. IxSR/xl/pcqs7rN2nXrpixurazHb+gtTTK/FpRp5PIpM/6zfJd5O2YIyC0TeytuMrKNuFoM7pmRL
  40749. Mon7FhY4futD4tN0SsJiCnMK3UmzV9KwCoWdcTzeo8vAMvMBOSBDGzXRU7Ox7sWTaYI+FrUoRqHe
  40750. 6okJ7UO4BUaKhvVZR74bbwEhELn9qdIoyhA5CcoTNs+cra1AdHkrAj80//ogaX3T7mH1urPnMNA3
  40751. I4ZyYUUpSFlob3emLoG+B01vr87ERRORFHAGjx+f+IdpsQ7vw4kZ6+ocYfx6bIrc1gMLnia6Et3U
  40752. VDmrJqMz6nWB2i3ND0/kA9HvFZcba5DFApCTZgIhsUfei5pKgLlVj7WiL8DWM2fafsSntARE60f7
  40753. 5li59wzweyuxwHApw0BiLTtIadwjPEjrewl5qW3aqDCYz4ByA4imW0aucnl8CAMhZa634RylsSqi
  40754. Md5mBPfAdOhx3v89WcyWJhKLhZVXGqtrdQtEPREoPHtht+KPZ0/l7DxMYIBpVzgeAVuNVejH38DM
  40755. dyM0SXV89pgR6y3e7UEuFAUCf+D+IOs15xGsIs5XPd7JMG0QA4XN8f+MFrXBsj6IbGB/kE+V9/Yt
  40756. rQE5BwT6dYB9v0lQ7e/JxHwc64B+27bQ3RP+ydOc17KXqQIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  40757. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUxhfQvKjqAkPyGwaZXSuQILnXnOQwDQYJKoZI
  40758. hvcNAQELBQADggIBADRh2Va1EodVTd2jNTFGu6QHcrxfYWLopfsLN7E8trP6KZ1/AvWkyaiTt3px
  40759. KGmPc+FSkNrVvjrlt3ZqVoAh313m6Tqe5T72omnHKgqwGEfcIHB9UqM+WXzBusnIFUBhynLWcKzS
  40760. t/Ac5IYp8M7vaGPQtSCKFWGafoaYtMnCdvvMujAWzKNhxnQT5WvvoxXqA/4Ti2Tk08HS6IT7SdEQ
  40761. TXlm66r99I0xHnAUrdzeZxNMgRVhvLfZkXdxGYFgu/BYpbWcC/ePIlUnwEsBbTuZDdQdm2NnL9Du
  40762. DcpmvJRPpq3t/O5jrFc/ZSXPsoaP0Aj/uHYUbt7lJ+yreLVTubY/6CD50qi+YUbKh4yE8/nxoGib
  40763. Ih6BJpsQBJFxwAYf3KDTuVan45gtf4Od34wrnDKOMpTwATwiKp9Dwi7DmDkHOHv8XgBCH/MyJnmD
  40764. hPbl8MFREsALHgQjDFSlTC9JxUrRtm5gDWv8a4uFJGS3iQ6rJUdbPM9+Sb3H6QrG2vd+DhcI00iX
  40765. 0HGS8A85PjRqHH3Y8iKuu2n0M7SmSFXRDw4m6Oy2Cy2nhTXN/VnIn9HNPlopNLk9hM6xZdRZkZFW
  40766. dSHBd575euFgndOtBBj0fOtek49TSiIp+EgrPk2GrFt/ywaZWWDYWGWVjUTR939+J399roD1B0y2
  40767. PpxxVJkES/1Y+Zj0
  40768. -----END CERTIFICATE-----
  40769. DigiCert Assured ID Root G2
  40770. ===========================
  40771. -----BEGIN CERTIFICATE-----
  40772. MIIDljCCAn6gAwIBAgIQC5McOtY5Z+pnI7/Dr5r0SzANBgkqhkiG9w0BAQsFADBlMQswCQYDVQQG
  40773. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw
  40774. IgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIwHhcNMTMwODAxMTIwMDAwWhcNMzgw
  40775. MTE1MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL
  40776. ExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIw
  40777. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDZ5ygvUj82ckmIkzTz+GoeMVSAn61UQbVH
  40778. 35ao1K+ALbkKz3X9iaV9JPrjIgwrvJUXCzO/GU1BBpAAvQxNEP4HteccbiJVMWWXvdMX0h5i89vq
  40779. bFCMP4QMls+3ywPgym2hFEwbid3tALBSfK+RbLE4E9HpEgjAALAcKxHad3A2m67OeYfcgnDmCXRw
  40780. VWmvo2ifv922ebPynXApVfSr/5Vh88lAbx3RvpO704gqu52/clpWcTs/1PPRCv4o76Pu2ZmvA9OP
  40781. YLfykqGxvYmJHzDNw6YuYjOuFgJ3RFrngQo8p0Quebg/BLxcoIfhG69Rjs3sLPr4/m3wOnyqi+Rn
  40782. lTGNAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTO
  40783. w0q5mVXyuNtgv6l+vVa1lzan1jANBgkqhkiG9w0BAQsFAAOCAQEAyqVVjOPIQW5pJ6d1Ee88hjZv
  40784. 0p3GeDgdaZaikmkuOGybfQTUiaWxMTeKySHMq2zNixya1r9I0jJmwYrA8y8678Dj1JGG0VDjA9tz
  40785. d29KOVPt3ibHtX2vK0LRdWLjSisCx1BL4GnilmwORGYQRI+tBev4eaymG+g3NJ1TyWGqolKvSnAW
  40786. hsI6yLETcDbYz+70CjTVW0z9B5yiutkBclzzTcHdDrEcDcRjvq30FPuJ7KJBDkzMyFdA0G4Dqs0M
  40787. jomZmWzwPDCvON9vvKO+KSAnq3T/EyJ43pdSVR6DtVQgA+6uwE9W3jfMw3+qBCe703e4YtsXfJwo
  40788. IhNzbM8m9Yop5w==
  40789. -----END CERTIFICATE-----
  40790. DigiCert Assured ID Root G3
  40791. ===========================
  40792. -----BEGIN CERTIFICATE-----
  40793. MIICRjCCAc2gAwIBAgIQC6Fa+h3foLVJRK/NJKBs7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV
  40794. UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQwIgYD
  40795. VQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1
  40796. MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
  40797. d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwdjAQ
  40798. BgcqhkjOPQIBBgUrgQQAIgNiAAQZ57ysRGXtzbg/WPuNsVepRC0FFfLvC/8QdJ+1YlJfZn4f5dwb
  40799. RXkLzMZTCp2NXQLZqVneAlr2lSoOjThKiknGvMYDOAdfVdp+CW7if17QRSAPWXYQ1qAk8C3eNvJs
  40800. KTmjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTL0L2p4ZgF
  40801. UaFNN6KDec6NHSrkhDAKBggqhkjOPQQDAwNnADBkAjAlpIFFAmsSS3V0T8gj43DydXLefInwz5Fy
  40802. YZ5eEJJZVrmDxxDnOOlYJjZ91eQ0hjkCMHw2U/Aw5WJjOpnitqM7mzT6HtoQknFekROn3aRukswy
  40803. 1vUhZscv6pZjamVFkpUBtA==
  40804. -----END CERTIFICATE-----
  40805. DigiCert Global Root G2
  40806. =======================
  40807. -----BEGIN CERTIFICATE-----
  40808. MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBhMQswCQYDVQQG
  40809. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw
  40810. HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMjAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUx
  40811. MjAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3
  40812. dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEcyMIIBIjANBgkq
  40813. hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuzfNNNx7a8myaJCtSnX/RrohCgiN9RlUyfuI2/Ou8jqJ
  40814. kTx65qsGGmvPrC3oXgkkRLpimn7Wo6h+4FR1IAWsULecYxpsMNzaHxmx1x7e/dfgy5SDN67sH0NO
  40815. 3Xss0r0upS/kqbitOtSZpLYl6ZtrAGCSYP9PIUkY92eQq2EGnI/yuum06ZIya7XzV+hdG82MHauV
  40816. BJVJ8zUtluNJbd134/tJS7SsVQepj5WztCO7TG1F8PapspUwtP1MVYwnSlcUfIKdzXOS0xZKBgyM
  40817. UNGPHgm+F6HmIcr9g+UQvIOlCsRnKPZzFBQ9RnbDhxSJITRNrw9FDKZJobq7nMWxM4MphQIDAQAB
  40818. o0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUTiJUIBiV5uNu
  40819. 5g/6+rkS7QYXjzkwDQYJKoZIhvcNAQELBQADggEBAGBnKJRvDkhj6zHd6mcY1Yl9PMWLSn/pvtsr
  40820. F9+wX3N3KjITOYFnQoQj8kVnNeyIv/iPsGEMNKSuIEyExtv4NeF22d+mQrvHRAiGfzZ0JFrabA0U
  40821. WTW98kndth/Jsw1HKj2ZL7tcu7XUIOGZX1NGFdtom/DzMNU+MeKNhJ7jitralj41E6Vf8PlwUHBH
  40822. QRFXGU7Aj64GxJUTFy8bJZ918rGOmaFvE7FBcf6IKshPECBV1/MUReXgRPTqh5Uykw7+U0b6LJ3/
  40823. iyK5S9kJRaTepLiaWN0bfVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTfl
  40824. MrY=
  40825. -----END CERTIFICATE-----
  40826. DigiCert Global Root G3
  40827. =======================
  40828. -----BEGIN CERTIFICATE-----
  40829. MIICPzCCAcWgAwIBAgIQBVVWvPJepDU1w6QP1atFcjAKBggqhkjOPQQDAzBhMQswCQYDVQQGEwJV
  40830. UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAwHgYD
  40831. VQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMzAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAw
  40832. MDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5k
  40833. aWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEczMHYwEAYHKoZIzj0C
  40834. AQYFK4EEACIDYgAE3afZu4q4C/sLfyHS8L6+c/MzXRq8NOrexpu80JX28MzQC7phW1FGfp4tn+6O
  40835. YwwX7Adw9c+ELkCDnOg/QW07rdOkFFk2eJ0DQ+4QE2xy3q6Ip6FrtUPOZ9wj/wMco+I+o0IwQDAP
  40836. BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUs9tIpPmhxdiuNkHMEWNp
  40837. Yim8S8YwCgYIKoZIzj0EAwMDaAAwZQIxAK288mw/EkrRLTnDCgmXc/SINoyIJ7vmiI1Qhadj+Z4y
  40838. 3maTD/HMsQmP3Wyr+mt/oAIwOWZbwmSNuJ5Q3KjVSaLtx9zRSX8XAbjIho9OjIgrqJqpisXRAL34
  40839. VOKa5Vt8sycX
  40840. -----END CERTIFICATE-----
  40841. DigiCert Trusted Root G4
  40842. ========================
  40843. -----BEGIN CERTIFICATE-----
  40844. MIIFkDCCA3igAwIBAgIQBZsbV56OITLiOQe9p3d1XDANBgkqhkiG9w0BAQwFADBiMQswCQYDVQQG
  40845. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSEw
  40846. HwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1
  40847. MTIwMDAwWjBiMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
  40848. d3cuZGlnaWNlcnQuY29tMSEwHwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwggIiMA0G
  40849. CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC/5pBzaN675F1KPDAiMGkz7MKnJS7JIT3yithZwuEp
  40850. pz1Yq3aaza57G4QNxDAf8xukOBbrVsaXbR2rsnnyyhHS5F/WBTxSD1Ifxp4VpX6+n6lXFllVcq9o
  40851. k3DCsrp1mWpzMpTREEQQLt+C8weE5nQ7bXHiLQwb7iDVySAdYyktzuxeTsiT+CFhmzTrBcZe7Fsa
  40852. vOvJz82sNEBfsXpm7nfISKhmV1efVFiODCu3T6cw2Vbuyntd463JT17lNecxy9qTXtyOj4DatpGY
  40853. QJB5w3jHtrHEtWoYOAMQjdjUN6QuBX2I9YI+EJFwq1WCQTLX2wRzKm6RAXwhTNS8rhsDdV14Ztk6
  40854. MUSaM0C/CNdaSaTC5qmgZ92kJ7yhTzm1EVgX9yRcRo9k98FpiHaYdj1ZXUJ2h4mXaXpI8OCiEhtm
  40855. mnTK3kse5w5jrubU75KSOp493ADkRSWJtppEGSt+wJS00mFt6zPZxd9LBADMfRyVw4/3IbKyEbe7
  40856. f/LVjHAsQWCqsWMYRJUadmJ+9oCw++hkpjPRiQfhvbfmQ6QYuKZ3AeEPlAwhHbJUKSWJbOUOUlFH
  40857. dL4mrLZBdd56rF+NP8m800ERElvlEFDrMcXKchYiCd98THU/Y+whX8QgUWtvsauGi0/C1kVfnSD8
  40858. oR7FwI+isX4KJpn15GkvmB0t9dmpsh3lGwIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1Ud
  40859. DwEB/wQEAwIBhjAdBgNVHQ4EFgQU7NfjgtJxXWRM3y5nP+e6mK4cD08wDQYJKoZIhvcNAQEMBQAD
  40860. ggIBALth2X2pbL4XxJEbw6GiAI3jZGgPVs93rnD5/ZpKmbnJeFwMDF/k5hQpVgs2SV1EY+CtnJYY
  40861. ZhsjDT156W1r1lT40jzBQ0CuHVD1UvyQO7uYmWlrx8GnqGikJ9yd+SeuMIW59mdNOj6PWTkiU0Tr
  40862. yF0Dyu1Qen1iIQqAyHNm0aAFYF/opbSnr6j3bTWcfFqK1qI4mfN4i/RN0iAL3gTujJtHgXINwBQy
  40863. 7zBZLq7gcfJW5GqXb5JQbZaNaHqasjYUegbyJLkJEVDXCLG4iXqEI2FCKeWjzaIgQdfRnGTZ6iah
  40864. ixTXTBmyUEFxPT9NcCOGDErcgdLMMpSEDQgJlxxPwO5rIHQw0uA5NBCFIRUBCOhVMt5xSdkoF1BN
  40865. 5r5N0XWs0Mr7QbhDparTwwVETyw2m+L64kW4I1NsBm9nVX9GtUw/bihaeSbSpKhil9Ie4u1Ki7wb
  40866. /UdKDd9nZn6yW0HQO+T0O/QEY+nvwlQAUaCKKsnOeMzV6ocEGLPOr0mIr/OSmbaz5mEP0oUA51Aa
  40867. 5BuVnRmhuZyxm7EAHu/QD09CbMkKvO5D+jpxpchNJqU1/YldvIViHTLSoCtU7ZpXwdv6EM8Zt4tK
  40868. G48BtieVU+i2iW1bvGjUI+iLUaJW+fCmgKDWHrO8Dw9TdSmq6hN35N6MgSGtBxBHEa2HPQfRdbzP
  40869. 82Z+
  40870. -----END CERTIFICATE-----
  40871. COMODO RSA Certification Authority
  40872. ==================================
  40873. -----BEGIN CERTIFICATE-----
  40874. MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCBhTELMAkGA1UE
  40875. BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG
  40876. A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlv
  40877. biBBdXRob3JpdHkwHhcNMTAwMTE5MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMC
  40878. R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE
  40879. ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBB
  40880. dXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCR6FSS0gpWsawNJN3Fz0Rn
  40881. dJkrN6N9I3AAcbxT38T6KhKPS38QVr2fcHK3YX/JSw8Xpz3jsARh7v8Rl8f0hj4K+j5c+ZPmNHrZ
  40882. FGvnnLOFoIJ6dq9xkNfs/Q36nGz637CC9BR++b7Epi9Pf5l/tfxnQ3K9DADWietrLNPtj5gcFKt+
  40883. 5eNu/Nio5JIk2kNrYrhV/erBvGy2i/MOjZrkm2xpmfh4SDBF1a3hDTxFYPwyllEnvGfDyi62a+pG
  40884. x8cgoLEfZd5ICLqkTqnyg0Y3hOvozIFIQ2dOciqbXL1MGyiKXCJ7tKuY2e7gUYPDCUZObT6Z+pUX
  40885. 2nwzV0E8jVHtC7ZcryxjGt9XyD+86V3Em69FmeKjWiS0uqlWPc9vqv9JWL7wqP/0uK3pN/u6uPQL
  40886. OvnoQ0IeidiEyxPx2bvhiWC4jChWrBQdnArncevPDt09qZahSL0896+1DSJMwBGB7FY79tOi4lu3
  40887. sgQiUpWAk2nojkxl8ZEDLXB0AuqLZxUpaVICu9ffUGpVRr+goyhhf3DQw6KqLCGqR84onAZFdr+C
  40888. GCe01a60y1Dma/RMhnEw6abfFobg2P9A3fvQQoh/ozM6LlweQRGBY84YcWsr7KaKtzFcOmpH4MN5
  40889. WdYgGq/yapiqcrxXStJLnbsQ/LBMQeXtHT1eKJ2czL+zUdqnR+WEUwIDAQABo0IwQDAdBgNVHQ4E
  40890. FgQUu69+Aj36pvE8hI6t7jiY7NkyMtQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8w
  40891. DQYJKoZIhvcNAQEMBQADggIBAArx1UaEt65Ru2yyTUEUAJNMnMvlwFTPoCWOAvn9sKIN9SCYPBMt
  40892. rFaisNZ+EZLpLrqeLppysb0ZRGxhNaKatBYSaVqM4dc+pBroLwP0rmEdEBsqpIt6xf4FpuHA1sj+
  40893. nq6PK7o9mfjYcwlYRm6mnPTXJ9OV2jeDchzTc+CiR5kDOF3VSXkAKRzH7JsgHAckaVd4sjn8OoSg
  40894. tZx8jb8uk2IntznaFxiuvTwJaP+EmzzV1gsD41eeFPfR60/IvYcjt7ZJQ3mFXLrrkguhxuhoqEwW
  40895. sRqZCuhTLJK7oQkYdQxlqHvLI7cawiiFwxv/0Cti76R7CZGYZ4wUAc1oBmpjIXUDgIiKboHGhfKp
  40896. pC3n9KUkEEeDys30jXlYsQab5xoq2Z0B15R97QNKyvDb6KkBPvVWmckejkk9u+UJueBPSZI9FoJA
  40897. zMxZxuY67RIuaTxslbH9qh17f4a+Hg4yRvv7E491f0yLS0Zj/gA0QHDBw7mh3aZw4gSzQbzpgJHq
  40898. ZJx64SIDqZxubw5lT2yHh17zbqD5daWbQOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk52
  40899. 7RH89elWsn2/x20Kk4yl0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7I
  40900. LaZRfyHBNVOFBkpdn627G190
  40901. -----END CERTIFICATE-----
  40902. USERTrust RSA Certification Authority
  40903. =====================================
  40904. -----BEGIN CERTIFICATE-----
  40905. MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCBiDELMAkGA1UE
  40906. BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK
  40907. ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh
  40908. dGlvbiBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UE
  40909. BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK
  40910. ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh
  40911. dGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCAEmUXNg7D2wiz
  40912. 0KxXDXbtzSfTTK1Qg2HiqiBNCS1kCdzOiZ/MPans9s/B3PHTsdZ7NygRK0faOca8Ohm0X6a9fZ2j
  40913. Y0K2dvKpOyuR+OJv0OwWIJAJPuLodMkYtJHUYmTbf6MG8YgYapAiPLz+E/CHFHv25B+O1ORRxhFn
  40914. RghRy4YUVD+8M/5+bJz/Fp0YvVGONaanZshyZ9shZrHUm3gDwFA66Mzw3LyeTP6vBZY1H1dat//O
  40915. +T23LLb2VN3I5xI6Ta5MirdcmrS3ID3KfyI0rn47aGYBROcBTkZTmzNg95S+UzeQc0PzMsNT79uq
  40916. /nROacdrjGCT3sTHDN/hMq7MkztReJVni+49Vv4M0GkPGw/zJSZrM233bkf6c0Plfg6lZrEpfDKE
  40917. Y1WJxA3Bk1QwGROs0303p+tdOmw1XNtB1xLaqUkL39iAigmTYo61Zs8liM2EuLE/pDkP2QKe6xJM
  40918. lXzzawWpXhaDzLhn4ugTncxbgtNMs+1b/97lc6wjOy0AvzVVdAlJ2ElYGn+SNuZRkg7zJn0cTRe8
  40919. yexDJtC/QV9AqURE9JnnV4eeUB9XVKg+/XRjL7FQZQnmWEIuQxpMtPAlR1n6BB6T1CZGSlCBst6+
  40920. eLf8ZxXhyVeEHg9j1uliutZfVS7qXMYoCAQlObgOK6nyTJccBz8NUvXt7y+CDwIDAQABo0IwQDAd
  40921. BgNVHQ4EFgQUU3m/WqorSs9UgOHYm8Cd8rIDZsswDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQF
  40922. MAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAFzUfA3P9wF9QZllDHPFUp/L+M+ZBn8b2kMVn54CVVeW
  40923. FPFSPCeHlCjtHzoBN6J2/FNQwISbxmtOuowhT6KOVWKR82kV2LyI48SqC/3vqOlLVSoGIG1VeCkZ
  40924. 7l8wXEskEVX/JJpuXior7gtNn3/3ATiUFJVDBwn7YKnuHKsSjKCaXqeYalltiz8I+8jRRa8YFWSQ
  40925. Eg9zKC7F4iRO/Fjs8PRF/iKz6y+O0tlFYQXBl2+odnKPi4w2r78NBc5xjeambx9spnFixdjQg3IM
  40926. 8WcRiQycE0xyNN+81XHfqnHd4blsjDwSXWXavVcStkNr/+XeTWYRUc+ZruwXtuhxkYzeSf7dNXGi
  40927. FSeUHM9h4ya7b6NnJSFd5t0dCy5oGzuCr+yDZ4XUmFF0sbmZgIn/f3gZXHlKYC6SQK5MNyosycdi
  40928. yA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9c
  40929. J2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRBVXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGw
  40930. sAvgnEzDHNb842m1R0aBL6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gx
  40931. Q+6IHdfGjjxDah2nGN59PRbxYvnKkKj9
  40932. -----END CERTIFICATE-----
  40933. USERTrust ECC Certification Authority
  40934. =====================================
  40935. -----BEGIN CERTIFICATE-----
  40936. MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDELMAkGA1UEBhMC
  40937. VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU
  40938. aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv
  40939. biBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMC
  40940. VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU
  40941. aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv
  40942. biBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQarFRaqfloI+d61SRvU8Za2EurxtW2
  40943. 0eZzca7dnNYMYf3boIkDuAUU7FfO7l0/4iGzzvfUinngo4N+LZfQYcTxmdwlkWOrfzCjtHDix6Ez
  40944. nPO/LlxTsV+zfTJ/ijTjeXmjQjBAMB0GA1UdDgQWBBQ64QmG1M8ZwpZ2dEl23OA1xmNjmjAOBgNV
  40945. HQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjA2Z6EWCNzklwBB
  40946. HU6+4WMBzzuqQhFkoJ2UOQIReVx7Hfpkue4WQrO/isIJxOzksU0CMQDpKmFHjFJKS04YcPbWRNZu
  40947. 9YO6bVi9JNlWSOrvxKJGgYhqOkbRqZtNyWHa0V1Xahg=
  40948. -----END CERTIFICATE-----
  40949. GlobalSign ECC Root CA - R4
  40950. ===========================
  40951. -----BEGIN CERTIFICATE-----
  40952. MIIB4TCCAYegAwIBAgIRKjikHJYKBN5CsiilC+g0mAIwCgYIKoZIzj0EAwIwUDEkMCIGA1UECxMb
  40953. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  40954. EwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoXDTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMb
  40955. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  40956. EwpHbG9iYWxTaWduMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEuMZ5049sJQ6fLjkZHAOkrprl
  40957. OQcJFspjsbmG+IpXwVfOQvpzofdlQv8ewQCybnMO/8ch5RikqtlxP6jUuc6MHaNCMEAwDgYDVR0P
  40958. AQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFFSwe61FuOJAf/sKbvu+M8k8o4TV
  40959. MAoGCCqGSM49BAMCA0gAMEUCIQDckqGgE6bPA7DmxCGXkPoUVy0D7O48027KqGx2vKLeuwIgJ6iF
  40960. JzWbVsaj8kfSt24bAgAXqmemFZHe+pTsewv4n4Q=
  40961. -----END CERTIFICATE-----
  40962. GlobalSign ECC Root CA - R5
  40963. ===========================
  40964. -----BEGIN CERTIFICATE-----
  40965. MIICHjCCAaSgAwIBAgIRYFlJ4CYuu1X5CneKcflK2GwwCgYIKoZIzj0EAwMwUDEkMCIGA1UECxMb
  40966. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  40967. EwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoXDTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMb
  40968. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  40969. EwpHbG9iYWxTaWduMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAER0UOlvt9Xb/pOdEh+J8LttV7HpI6
  40970. SFkc8GIxLcB6KP4ap1yztsyX50XUWPrRd21DosCHZTQKH3rd6zwzocWdTaRvQZU4f8kehOvRnkmS
  40971. h5SHDDqFSmafnVmTTZdhBoZKo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd
  40972. BgNVHQ4EFgQUPeYpSJvqB8ohREom3m7e0oPQn1kwCgYIKoZIzj0EAwMDaAAwZQIxAOVpEslu28Yx
  40973. uglB4Zf4+/2a4n0Sye18ZNPLBSWLVtmg515dTguDnFt2KaAJJiFqYgIwcdK1j1zqO+F4CYWodZI7
  40974. yFz9SO8NdCKoCOJuxUnOxwy8p2Fp8fc74SrL+SvzZpA3
  40975. -----END CERTIFICATE-----
  40976. Staat der Nederlanden EV Root CA
  40977. ================================
  40978. -----BEGIN CERTIFICATE-----
  40979. MIIFcDCCA1igAwIBAgIEAJiWjTANBgkqhkiG9w0BAQsFADBYMQswCQYDVQQGEwJOTDEeMBwGA1UE
  40980. CgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSkwJwYDVQQDDCBTdGFhdCBkZXIgTmVkZXJsYW5kZW4g
  40981. RVYgUm9vdCBDQTAeFw0xMDEyMDgxMTE5MjlaFw0yMjEyMDgxMTEwMjhaMFgxCzAJBgNVBAYTAk5M
  40982. MR4wHAYDVQQKDBVTdGFhdCBkZXIgTmVkZXJsYW5kZW4xKTAnBgNVBAMMIFN0YWF0IGRlciBOZWRl
  40983. cmxhbmRlbiBFViBSb290IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA48d+ifkk
  40984. SzrSM4M1LGns3Amk41GoJSt5uAg94JG6hIXGhaTK5skuU6TJJB79VWZxXSzFYGgEt9nCUiY4iKTW
  40985. O0Cmws0/zZiTs1QUWJZV1VD+hq2kY39ch/aO5ieSZxeSAgMs3NZmdO3dZ//BYY1jTw+bbRcwJu+r
  40986. 0h8QoPnFfxZpgQNH7R5ojXKhTbImxrpsX23Wr9GxE46prfNeaXUmGD5BKyF/7otdBwadQ8QpCiv8
  40987. Kj6GyzyDOvnJDdrFmeK8eEEzduG/L13lpJhQDBXd4Pqcfzho0LKmeqfRMb1+ilgnQ7O6M5HTp5gV
  40988. XJrm0w912fxBmJc+qiXbj5IusHsMX/FjqTf5m3VpTCgmJdrV8hJwRVXj33NeN/UhbJCONVrJ0yPr
  40989. 08C+eKxCKFhmpUZtcALXEPlLVPxdhkqHz3/KRawRWrUgUY0viEeXOcDPusBCAUCZSCELa6fS/ZbV
  40990. 0b5GnUngC6agIk440ME8MLxwjyx1zNDFjFE7PZQIZCZhfbnDZY8UnCHQqv0XcgOPvZuM5l5Tnrmd
  40991. 74K74bzickFbIZTTRTeU0d8JOV3nI6qaHcptqAqGhYqCvkIH1vI4gnPah1vlPNOePqc7nvQDs/nx
  40992. fRN0Av+7oeX6AHkcpmZBiFxgV6YuCcS6/ZrPpx9Aw7vMWgpVSzs4dlG4Y4uElBbmVvMCAwEAAaNC
  40993. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFP6rAJCYniT8qcwa
  40994. ivsnuL8wbqg7MA0GCSqGSIb3DQEBCwUAA4ICAQDPdyxuVr5Os7aEAJSrR8kN0nbHhp8dB9O2tLsI
  40995. eK9p0gtJ3jPFrK3CiAJ9Brc1AsFgyb/E6JTe1NOpEyVa/m6irn0F3H3zbPB+po3u2dfOWBfoqSmu
  40996. c0iH55vKbimhZF8ZE/euBhD/UcabTVUlT5OZEAFTdfETzsemQUHSv4ilf0X8rLiltTMMgsT7B/Zq
  40997. 5SWEXwbKwYY5EdtYzXc7LMJMD16a4/CrPmEbUCTCwPTxGfARKbalGAKb12NMcIxHowNDXLldRqAN
  40998. b/9Zjr7dn3LDWyvfjFvO5QxGbJKyCqNMVEIYFRIYvdr8unRu/8G2oGTYqV9Vrp9canaW2HNnh/tN
  40999. f1zuacpzEPuKqf2evTY4SUmH9A4U8OmHuD+nT3pajnnUk+S7aFKErGzp85hwVXIy+TSrK0m1zSBi
  41000. 5Dp6Z2Orltxtrpfs/J92VoguZs9btsmksNcFuuEnL5O7Jiqik7Ab846+HUCjuTaPPoIaGl6I6lD4
  41001. WeKDRikL40Rc4ZW2aZCaFG+XroHPaO+Zmr615+F/+PoTRxZMzG0IQOeLeG9QgkRQP2YGiqtDhFZK
  41002. DyAthg710tvSeopLzaXoTvFeJiUBWSOgftL2fiFX1ye8FVdMpEbB4IMeDExNH08GGeL5qPQ6gqGy
  41003. eUN51q1veieQA6TqJIc/2b3Z6fJfUEkc7uzXLg==
  41004. -----END CERTIFICATE-----
  41005. IdenTrust Commercial Root CA 1
  41006. ==============================
  41007. -----BEGIN CERTIFICATE-----
  41008. MIIFYDCCA0igAwIBAgIQCgFCgAAAAUUjyES1AAAAAjANBgkqhkiG9w0BAQsFADBKMQswCQYDVQQG
  41009. EwJVUzESMBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBS
  41010. b290IENBIDEwHhcNMTQwMTE2MTgxMjIzWhcNMzQwMTE2MTgxMjIzWjBKMQswCQYDVQQGEwJVUzES
  41011. MBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBSb290IENB
  41012. IDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCnUBneP5k91DNG8W9RYYKyqU+PZ4ld
  41013. hNlT3Qwo2dfw/66VQ3KZ+bVdfIrBQuExUHTRgQ18zZshq0PirK1ehm7zCYofWjK9ouuU+ehcCuz/
  41014. mNKvcbO0U59Oh++SvL3sTzIwiEsXXlfEU8L2ApeN2WIrvyQfYo3fw7gpS0l4PJNgiCL8mdo2yMKi
  41015. 1CxUAGc1bnO/AljwpN3lsKImesrgNqUZFvX9t++uP0D1bVoE/c40yiTcdCMbXTMTEl3EASX2MN0C
  41016. XZ/g1Ue9tOsbobtJSdifWwLziuQkkORiT0/Br4sOdBeo0XKIanoBScy0RnnGF7HamB4HWfp1IYVl
  41017. 3ZBWzvurpWCdxJ35UrCLvYf5jysjCiN2O/cz4ckA82n5S6LgTrx+kzmEB/dEcH7+B1rlsazRGMzy
  41018. NeVJSQjKVsk9+w8YfYs7wRPCTY/JTw436R+hDmrfYi7LNQZReSzIJTj0+kuniVyc0uMNOYZKdHzV
  41019. WYfCP04MXFL0PfdSgvHqo6z9STQaKPNBiDoT7uje/5kdX7rL6B7yuVBgwDHTc+XvvqDtMwt0viAg
  41020. xGds8AgDelWAf0ZOlqf0Hj7h9tgJ4TNkK2PXMl6f+cB7D3hvl7yTmvmcEpB4eoCHFddydJxVdHix
  41021. uuFucAS6T6C6aMN7/zHwcz09lCqxC0EOoP5NiGVreTO01wIDAQABo0IwQDAOBgNVHQ8BAf8EBAMC
  41022. AQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU7UQZwNPwBovupHu+QucmVMiONnYwDQYJKoZI
  41023. hvcNAQELBQADggIBAA2ukDL2pkt8RHYZYR4nKM1eVO8lvOMIkPkp165oCOGUAFjvLi5+U1KMtlwH
  41024. 6oi6mYtQlNeCgN9hCQCTrQ0U5s7B8jeUeLBfnLOic7iPBZM4zY0+sLj7wM+x8uwtLRvM7Kqas6pg
  41025. ghstO8OEPVeKlh6cdbjTMM1gCIOQ045U8U1mwF10A0Cj7oV+wh93nAbowacYXVKV7cndJZ5t+qnt
  41026. ozo00Fl72u1Q8zW/7esUTTHHYPTa8Yec4kjixsU3+wYQ+nVZZjFHKdp2mhzpgq7vmrlR94gjmmmV
  41027. YjzlVYA211QC//G5Xc7UI2/YRYRKW2XviQzdFKcgyxilJbQN+QHwotL0AMh0jqEqSI5l2xPE4iUX
  41028. feu+h1sXIFRRk0pTAwvsXcoz7WL9RccvW9xYoIA55vrX/hMUpu09lEpCdNTDd1lzzY9GvlU47/ro
  41029. kTLql1gEIt44w8y8bckzOmoKaT+gyOpyj4xjhiO9bTyWnpXgSUyqorkqG5w2gXjtw+hG4iZZRHUe
  41030. 2XWJUc0QhJ1hYMtd+ZciTY6Y5uN/9lu7rs3KSoFrXgvzUeF0K+l+J6fZmUlO+KWA2yUPHGNiiskz
  41031. Z2s8EIPGrd6ozRaOjfAHN3Gf8qv8QfXBi+wAN10J5U6A7/qxXDgGpRtK4dw4LTzcqx+QGtVKnO7R
  41032. cGzM7vRX+Bi6hG6H
  41033. -----END CERTIFICATE-----
  41034. IdenTrust Public Sector Root CA 1
  41035. =================================
  41036. -----BEGIN CERTIFICATE-----
  41037. MIIFZjCCA06gAwIBAgIQCgFCgAAAAUUjz0Z8AAAAAjANBgkqhkiG9w0BAQsFADBNMQswCQYDVQQG
  41038. EwJVUzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3Rv
  41039. ciBSb290IENBIDEwHhcNMTQwMTE2MTc1MzMyWhcNMzQwMTE2MTc1MzMyWjBNMQswCQYDVQQGEwJV
  41040. UzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3RvciBS
  41041. b290IENBIDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2IpT8pEiv6EdrCvsnduTy
  41042. P4o7ekosMSqMjbCpwzFrqHd2hCa2rIFCDQjrVVi7evi8ZX3yoG2LqEfpYnYeEe4IFNGyRBb06tD6
  41043. Hi9e28tzQa68ALBKK0CyrOE7S8ItneShm+waOh7wCLPQ5CQ1B5+ctMlSbdsHyo+1W/CD80/HLaXI
  41044. rcuVIKQxKFdYWuSNG5qrng0M8gozOSI5Cpcu81N3uURF/YTLNiCBWS2ab21ISGHKTN9T0a9SvESf
  41045. qy9rg3LvdYDaBjMbXcjaY8ZNzaxmMc3R3j6HEDbhuaR672BQssvKplbgN6+rNBM5Jeg5ZuSYeqoS
  41046. mJxZZoY+rfGwyj4GD3vwEUs3oERte8uojHH01bWRNszwFcYr3lEXsZdMUD2xlVl8BX0tIdUAvwFn
  41047. ol57plzy9yLxkA2T26pEUWbMfXYD62qoKjgZl3YNa4ph+bz27nb9cCvdKTz4Ch5bQhyLVi9VGxyh
  41048. LrXHFub4qjySjmm2AcG1hp2JDws4lFTo6tyePSW8Uybt1as5qsVATFSrsrTZ2fjXctscvG29ZV/v
  41049. iDUqZi/u9rNl8DONfJhBaUYPQxxp+pu10GFqzcpL2UyQRqsVWaFHVCkugyhfHMKiq3IXAAaOReyL
  41050. 4jM9f9oZRORicsPfIsbyVtTdX5Vy7W1f90gDW/3FKqD2cyOEEBsB5wIDAQABo0IwQDAOBgNVHQ8B
  41051. Af8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU43HgntinQtnbcZFrlJPrw6PRFKMw
  41052. DQYJKoZIhvcNAQELBQADggIBAEf63QqwEZE4rU1d9+UOl1QZgkiHVIyqZJnYWv6IAcVYpZmxI1Qj
  41053. t2odIFflAWJBF9MJ23XLblSQdf4an4EKwt3X9wnQW3IV5B4Jaj0z8yGa5hV+rVHVDRDtfULAj+7A
  41054. mgjVQdZcDiFpboBhDhXAuM/FSRJSzL46zNQuOAXeNf0fb7iAaJg9TaDKQGXSc3z1i9kKlT/YPyNt
  41055. GtEqJBnZhbMX73huqVjRI9PHE+1yJX9dsXNw0H8GlwmEKYBhHfpe/3OsoOOJuBxxFcbeMX8S3OFt
  41056. m6/n6J91eEyrRjuazr8FGF1NFTwWmhlQBJqymm9li1JfPFgEKCXAZmExfrngdbkaqIHWchezxQMx
  41057. NRF4eKLg6TCMf4DfWN88uieW4oA0beOY02QnrEh+KHdcxiVhJfiFDGX6xDIvpZgF5PgLZxYWxoK4
  41058. Mhn5+bl53B/N66+rDt0b20XkeucC4pVd/GnwU2lhlXV5C15V5jgclKlZM57IcXR5f1GJtshquDDI
  41059. ajjDbp7hNxbqBWJMWxJH7ae0s1hWx0nzfxJoCTFx8G34Tkf71oXuxVhAGaQdp/lLQzfcaFpPz+vC
  41060. ZHTetBXZ9FRUGi8c15dxVJCO2SCdUyt/q4/i6jC8UDfv8Ue1fXwsBOxonbRJRBD0ckscZOf85muQ
  41061. 3Wl9af0AVqW3rLatt8o+Ae+c
  41062. -----END CERTIFICATE-----
  41063. Entrust Root Certification Authority - G2
  41064. =========================================
  41065. -----BEGIN CERTIFICATE-----
  41066. MIIEPjCCAyagAwIBAgIESlOMKDANBgkqhkiG9w0BAQsFADCBvjELMAkGA1UEBhMCVVMxFjAUBgNV
  41067. BAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVy
  41068. bXMxOTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ug
  41069. b25seTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIw
  41070. HhcNMDkwNzA3MTcyNTU0WhcNMzAxMjA3MTc1NTU0WjCBvjELMAkGA1UEBhMCVVMxFjAUBgNVBAoT
  41071. DUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVybXMx
  41072. OTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25s
  41073. eTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIwggEi
  41074. MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC6hLZy254Ma+KZ6TABp3bqMriVQRrJ2mFOWHLP
  41075. /vaCeb9zYQYKpSfYs1/TRU4cctZOMvJyig/3gxnQaoCAAEUesMfnmr8SVycco2gvCoe9amsOXmXz
  41076. HHfV1IWNcCG0szLni6LVhjkCsbjSR87kyUnEO6fe+1R9V77w6G7CebI6C1XiUJgWMhNcL3hWwcKU
  41077. s/Ja5CeanyTXxuzQmyWC48zCxEXFjJd6BmsqEZ+pCm5IO2/b1BEZQvePB7/1U1+cPvQXLOZprE4y
  41078. TGJ36rfo5bs0vBmLrpxR57d+tVOxMyLlbc9wPBr64ptntoP0jaWvYkxN4FisZDQSA/i2jZRjJKRx
  41079. AgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqciZ6
  41080. 0B7vfec7aVHUbI2fkBJmqzANBgkqhkiG9w0BAQsFAAOCAQEAeZ8dlsa2eT8ijYfThwMEYGprmi5Z
  41081. iXMRrEPR9RP/jTkrwPK9T3CMqS/qF8QLVJ7UG5aYMzyorWKiAHarWWluBh1+xLlEjZivEtRh2woZ
  41082. Rkfz6/djwUAFQKXSt/S1mja/qYh2iARVBCuch38aNzx+LaUa2NSJXsq9rD1s2G2v1fN2D807iDgi
  41083. nWyTmsQ9v4IbZT+mD12q/OWyFcq1rca8PdCE6OoGcrBNOTJ4vz4RnAuknZoh8/CbCzB428Hch0P+
  41084. vGOaysXCHMnHjf87ElgI5rY97HosTvuDls4MPGmHVHOkc8KT/1EQrBVUAdj8BbGJoX90g5pJ19xO
  41085. e4pIb4tF9g==
  41086. -----END CERTIFICATE-----
  41087. Entrust Root Certification Authority - EC1
  41088. ==========================================
  41089. -----BEGIN CERTIFICATE-----
  41090. MIIC+TCCAoCgAwIBAgINAKaLeSkAAAAAUNCR+TAKBggqhkjOPQQDAzCBvzELMAkGA1UEBhMCVVMx
  41091. FjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVn
  41092. YWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDEyIEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXpl
  41093. ZCB1c2Ugb25seTEzMDEGA1UEAxMqRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  41094. IC0gRUMxMB4XDTEyMTIxODE1MjUzNloXDTM3MTIxODE1NTUzNlowgb8xCzAJBgNVBAYTAlVTMRYw
  41095. FAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0L2xlZ2Fs
  41096. LXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxMiBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhvcml6ZWQg
  41097. dXNlIG9ubHkxMzAxBgNVBAMTKkVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAt
  41098. IEVDMTB2MBAGByqGSM49AgEGBSuBBAAiA2IABIQTydC6bUF74mzQ61VfZgIaJPRbiWlH47jCffHy
  41099. AsWfoPZb1YsGGYZPUxBtByQnoaD41UcZYUx9ypMn6nQM72+WCf5j7HBdNq1nd67JnXxVRDqiY1Ef
  41100. 9eNi1KlHBz7MIKNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE
  41101. FLdj5xrdjekIplWDpOBqUEFlEUJJMAoGCCqGSM49BAMDA2cAMGQCMGF52OVCR98crlOZF7ZvHH3h
  41102. vxGU0QOIdeSNiaSKd0bebWHvAvX7td/M/k7//qnmpwIwW5nXhTcGtXsI/esni0qU+eH6p44mCOh8
  41103. kmhtc9hvJqwhAriZtyZBWyVgrtBIGu4G
  41104. -----END CERTIFICATE-----
  41105. CFCA EV ROOT
  41106. ============
  41107. -----BEGIN CERTIFICATE-----
  41108. MIIFjTCCA3WgAwIBAgIEGErM1jANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJDTjEwMC4GA1UE
  41109. CgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQDDAxDRkNB
  41110. IEVWIFJPT1QwHhcNMTIwODA4MDMwNzAxWhcNMjkxMjMxMDMwNzAxWjBWMQswCQYDVQQGEwJDTjEw
  41111. MC4GA1UECgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQD
  41112. DAxDRkNBIEVWIFJPT1QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDXXWvNED8fBVnV
  41113. BU03sQ7smCuOFR36k0sXgiFxEFLXUWRwFsJVaU2OFW2fvwwbwuCjZ9YMrM8irq93VCpLTIpTUnrD
  41114. 7i7es3ElweldPe6hL6P3KjzJIx1qqx2hp/Hz7KDVRM8Vz3IvHWOX6Jn5/ZOkVIBMUtRSqy5J35DN
  41115. uF++P96hyk0g1CXohClTt7GIH//62pCfCqktQT+x8Rgp7hZZLDRJGqgG16iI0gNyejLi6mhNbiyW
  41116. ZXvKWfry4t3uMCz7zEasxGPrb382KzRzEpR/38wmnvFyXVBlWY9ps4deMm/DGIq1lY+wejfeWkU7
  41117. xzbh72fROdOXW3NiGUgthxwG+3SYIElz8AXSG7Ggo7cbcNOIabla1jj0Ytwli3i/+Oh+uFzJlU9f
  41118. py25IGvPa931DfSCt/SyZi4QKPaXWnuWFo8BGS1sbn85WAZkgwGDg8NNkt0yxoekN+kWzqotaK8K
  41119. gWU6cMGbrU1tVMoqLUuFG7OA5nBFDWteNfB/O7ic5ARwiRIlk9oKmSJgamNgTnYGmE69g60dWIol
  41120. hdLHZR4tjsbftsbhf4oEIRUpdPA+nJCdDC7xij5aqgwJHsfVPKPtl8MeNPo4+QgO48BdK4PRVmrJ
  41121. tqhUUy54Mmc9gn900PvhtgVguXDbjgv5E1hvcWAQUhC5wUEJ73IfZzF4/5YFjQIDAQABo2MwYTAf
  41122. BgNVHSMEGDAWgBTj/i39KNALtbq2osS/BqoFjJP7LzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB
  41123. /wQEAwIBBjAdBgNVHQ4EFgQU4/4t/SjQC7W6tqLEvwaqBYyT+y8wDQYJKoZIhvcNAQELBQADggIB
  41124. ACXGumvrh8vegjmWPfBEp2uEcwPenStPuiB/vHiyz5ewG5zz13ku9Ui20vsXiObTej/tUxPQ4i9q
  41125. ecsAIyjmHjdXNYmEwnZPNDatZ8POQQaIxffu2Bq41gt/UP+TqhdLjOztUmCypAbqTuv0axn96/Ua
  41126. 4CUqmtzHQTb3yHQFhDmVOdYLO6Qn+gjYXB74BGBSESgoA//vU2YApUo0FmZ8/Qmkrp5nGm9BC2sG
  41127. E5uPhnEFtC+NiWYzKXZUmhH4J/qyP5Hgzg0b8zAarb8iXRvTvyUFTeGSGn+ZnzxEk8rUQElsgIfX
  41128. BDrDMlI1Dlb4pd19xIsNER9Tyx6yF7Zod1rg1MvIB671Oi6ON7fQAUtDKXeMOZePglr4UeWJoBjn
  41129. aH9dCi77o0cOPaYjesYBx4/IXr9tgFa+iiS6M+qf4TIRnvHST4D2G0CvOJ4RUHlzEhLN5mydLIhy
  41130. PDCBBpEi6lmt2hkuIsKNuYyH4Ga8cyNfIWRjgEj1oDwYPZTISEEdQLpe/v5WOaHIz16eGWRGENoX
  41131. kbcFgKyLmZJ956LYBws2J+dIeWCKw9cTXPhyQN9Ky8+ZAAoACxGV2lZFA4gKn2fQ1XmxqI1AbQ3C
  41132. ekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su
  41133. -----END CERTIFICATE-----
  41134. OISTE WISeKey Global Root GB CA
  41135. ===============================
  41136. -----BEGIN CERTIFICATE-----
  41137. MIIDtTCCAp2gAwIBAgIQdrEgUnTwhYdGs/gjGvbCwDANBgkqhkiG9w0BAQsFADBtMQswCQYDVQQG
  41138. EwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNl
  41139. ZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQiBDQTAeFw0xNDEyMDExNTAw
  41140. MzJaFw0zOTEyMDExNTEwMzFaMG0xCzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYD
  41141. VQQLExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEds
  41142. b2JhbCBSb290IEdCIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2Be3HEokKtaX
  41143. scriHvt9OO+Y9bI5mE4nuBFde9IllIiCFSZqGzG7qFshISvYD06fWvGxWuR51jIjK+FTzJlFXHtP
  41144. rby/h0oLS5daqPZI7H17Dc0hBt+eFf1Biki3IPShehtX1F1Q/7pn2COZH8g/497/b1t3sWtuuMlk
  41145. 9+HKQUYOKXHQuSP8yYFfTvdv37+ErXNku7dCjmn21HYdfp2nuFeKUWdy19SouJVUQHMD9ur06/4o
  41146. Qnc/nSMbsrY9gBQHTC5P99UKFg29ZkM3fiNDecNAhvVMKdqOmq0NpQSHiB6F4+lT1ZvIiwNjeOvg
  41147. GUpuuy9rM2RYk61pv48b74JIxwIDAQABo1EwTzALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB
  41148. /zAdBgNVHQ4EFgQUNQ/INmNe4qPs+TtmFc5RUuORmj0wEAYJKwYBBAGCNxUBBAMCAQAwDQYJKoZI
  41149. hvcNAQELBQADggEBAEBM+4eymYGQfp3FsLAmzYh7KzKNbrghcViXfa43FK8+5/ea4n32cZiZBKpD
  41150. dHij40lhPnOMTZTg+XHEthYOU3gf1qKHLwI5gSk8rxWYITD+KJAAjNHhy/peyP34EEY7onhCkRd0
  41151. VQreUGdNZtGn//3ZwLWoo4rOZvUPQ82nK1d7Y0Zqqi5S2PTt4W2tKZB4SLrhI6qjiey1q5bAtEui
  41152. HZeeevJuQHHfaPFlTc58Bd9TZaml8LGXBHAVRgOY1NK/VLSgWH1Sb9pWJmLU2NuJMW8c8CLC02Ic
  41153. Nc1MaRVUGpCY3useX8p3x8uOPUNpnJpY0CQ73xtAln41rYHHTnG6iBM=
  41154. -----END CERTIFICATE-----
  41155. SZAFIR ROOT CA2
  41156. ===============
  41157. -----BEGIN CERTIFICATE-----
  41158. MIIDcjCCAlqgAwIBAgIUPopdB+xV0jLVt+O2XwHrLdzk1uQwDQYJKoZIhvcNAQELBQAwUTELMAkG
  41159. A1UEBhMCUEwxKDAmBgNVBAoMH0tyYWpvd2EgSXpiYSBSb3psaWN6ZW5pb3dhIFMuQS4xGDAWBgNV
  41160. BAMMD1NaQUZJUiBST09UIENBMjAeFw0xNTEwMTkwNzQzMzBaFw0zNTEwMTkwNzQzMzBaMFExCzAJ
  41161. BgNVBAYTAlBMMSgwJgYDVQQKDB9LcmFqb3dhIEl6YmEgUm96bGljemVuaW93YSBTLkEuMRgwFgYD
  41162. VQQDDA9TWkFGSVIgUk9PVCBDQTIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC3vD5Q
  41163. qEvNQLXOYeeWyrSh2gwisPq1e3YAd4wLz32ohswmUeQgPYUM1ljj5/QqGJ3a0a4m7utT3PSQ1hNK
  41164. DJA8w/Ta0o4NkjrcsbH/ON7Dui1fgLkCvUqdGw+0w8LBZwPd3BucPbOw3gAeqDRHu5rr/gsUvTaE
  41165. 2g0gv/pby6kWIK05YO4vdbbnl5z5Pv1+TW9NL++IDWr63fE9biCloBK0TXC5ztdyO4mTp4CEHCdJ
  41166. ckm1/zuVnsHMyAHs6A6KCpbns6aH5db5BSsNl0BwPLqsdVqc1U2dAgrSS5tmS0YHF2Wtn2yIANwi
  41167. ieDhZNRnvDF5YTy7ykHNXGoAyDw4jlivAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0P
  41168. AQH/BAQDAgEGMB0GA1UdDgQWBBQuFqlKGLXLzPVvUPMjX/hd56zwyDANBgkqhkiG9w0BAQsFAAOC
  41169. AQEAtXP4A9xZWx126aMqe5Aosk3AM0+qmrHUuOQn/6mWmc5G4G18TKI4pAZw8PRBEew/R40/cof5
  41170. O/2kbytTAOD/OblqBw7rHRz2onKQy4I9EYKL0rufKq8h5mOGnXkZ7/e7DDWQw4rtTw/1zBLZpD67
  41171. oPwglV9PJi8RI4NOdQcPv5vRtB3pEAT+ymCPoky4rc/hkA/NrgrHXXu3UNLUYfrVFdvXn4dRVOul
  41172. 4+vJhaAlIDf7js4MNIThPIGyd05DpYhfhmehPea0XGG2Ptv+tyjFogeutcrKjSoS75ftwjCkySp6
  41173. +/NNIxuZMzSgLvWpCz/UXeHPhJ/iGcJfitYgHuNztw==
  41174. -----END CERTIFICATE-----
  41175. Certum Trusted Network CA 2
  41176. ===========================
  41177. -----BEGIN CERTIFICATE-----
  41178. MIIF0jCCA7qgAwIBAgIQIdbQSk8lD8kyN/yqXhKN6TANBgkqhkiG9w0BAQ0FADCBgDELMAkGA1UE
  41179. BhMCUEwxIjAgBgNVBAoTGVVuaXpldG8gVGVjaG5vbG9naWVzIFMuQS4xJzAlBgNVBAsTHkNlcnR1
  41180. bSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEkMCIGA1UEAxMbQ2VydHVtIFRydXN0ZWQgTmV0d29y
  41181. ayBDQSAyMCIYDzIwMTExMDA2MDgzOTU2WhgPMjA0NjEwMDYwODM5NTZaMIGAMQswCQYDVQQGEwJQ
  41182. TDEiMCAGA1UEChMZVW5pemV0byBUZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENl
  41183. cnRpZmljYXRpb24gQXV0aG9yaXR5MSQwIgYDVQQDExtDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENB
  41184. IDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC9+Xj45tWADGSdhhuWZGc/IjoedQF9
  41185. 7/tcZ4zJzFxrqZHmuULlIEub2pt7uZld2ZuAS9eEQCsn0+i6MLs+CRqnSZXvK0AkwpfHp+6bJe+o
  41186. CgCXhVqqndwpyeI1B+twTUrWwbNWuKFBOJvR+zF/j+Bf4bE/D44WSWDXBo0Y+aomEKsq09DRZ40b
  41187. Rr5HMNUuctHFY9rnY3lEfktjJImGLjQ/KUxSiyqnwOKRKIm5wFv5HdnnJ63/mgKXwcZQkpsCLL2p
  41188. uTRZCr+ESv/f/rOf69me4Jgj7KZrdxYq28ytOxykh9xGc14ZYmhFV+SQgkK7QtbwYeDBoz1mo130
  41189. GO6IyY0XRSmZMnUCMe4pJshrAua1YkV/NxVaI2iJ1D7eTiew8EAMvE0Xy02isx7QBlrd9pPPV3WZ
  41190. 9fqGGmd4s7+W/jTcvedSVuWz5XV710GRBdxdaeOVDUO5/IOWOZV7bIBaTxNyxtd9KXpEulKkKtVB
  41191. Rgkg/iKgtlswjbyJDNXXcPiHUv3a76xRLgezTv7QCdpw75j6VuZt27VXS9zlLCUVyJ4ueE742pye
  41192. hizKV/Ma5ciSixqClnrDvFASadgOWkaLOusm+iPJtrCBvkIApPjW/jAux9JG9uWOdf3yzLnQh1vM
  41193. BhBgu4M1t15n3kfsmUjxpKEV/q2MYo45VU85FrmxY53/twIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  41194. AQH/MB0GA1UdDgQWBBS2oVQ5AsOgP46KvPrU+Bym0ToO/TAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZI
  41195. hvcNAQENBQADggIBAHGlDs7k6b8/ONWJWsQCYftMxRQXLYtPU2sQF/xlhMcQSZDe28cmk4gmb3DW
  41196. Al45oPePq5a1pRNcgRRtDoGCERuKTsZPpd1iHkTfCVn0W3cLN+mLIMb4Ck4uWBzrM9DPhmDJ2vuA
  41197. L55MYIR4PSFk1vtBHxgP58l1cb29XN40hz5BsA72udY/CROWFC/emh1auVbONTqwX3BNXuMp8SMo
  41198. clm2q8KMZiYcdywmdjWLKKdpoPk79SPdhRB0yZADVpHnr7pH1BKXESLjokmUbOe3lEu6LaTaM4tM
  41199. pkT/WjzGHWTYtTHkpjx6qFcL2+1hGsvxznN3Y6SHb0xRONbkX8eftoEq5IVIeVheO/jbAoJnwTnb
  41200. w3RLPTYe+SmTiGhbqEQZIfCn6IENLOiTNrQ3ssqwGyZ6miUfmpqAnksqP/ujmv5zMnHCnsZy4Ypo
  41201. J/HkD7TETKVhk/iXEAcqMCWpuchxuO9ozC1+9eB+D4Kob7a6bINDd82Kkhehnlt4Fj1F4jNy3eFm
  41202. ypnTycUm/Q1oBEauttmbjL4ZvrHG8hnjXALKLNhvSgfZyTXaQHXyxKcZb55CEJh15pWLYLztxRLX
  41203. is7VmFxWlgPF7ncGNf/P5O4/E2Hu29othfDNrp2yGAlFw5Khchf8R7agCyzxxN5DaAhqXzvwdmP7
  41204. zAYspsbiDrW5viSP
  41205. -----END CERTIFICATE-----
  41206. Hellenic Academic and Research Institutions RootCA 2015
  41207. =======================================================
  41208. -----BEGIN CERTIFICATE-----
  41209. MIIGCzCCA/OgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcT
  41210. BkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0
  41211. aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNVBAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNl
  41212. YXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIwMTUwHhcNMTUwNzA3MTAxMTIxWhcNNDAwNjMwMTAx
  41213. MTIxWjCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMg
  41214. QWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNV
  41215. BAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIw
  41216. MTUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDC+Kk/G4n8PDwEXT2QNrCROnk8Zlrv
  41217. bTkBSRq0t89/TSNTt5AA4xMqKKYx8ZEA4yjsriFBzh/a/X0SWwGDD7mwX5nh8hKDgE0GPt+sr+eh
  41218. iGsxr/CL0BgzuNtFajT0AoAkKAoCFZVedioNmToUW/bLy1O8E00BiDeUJRtCvCLYjqOWXjrZMts+
  41219. 6PAQZe104S+nfK8nNLspfZu2zwnI5dMK/IhlZXQK3HMcXM1AsRzUtoSMTFDPaI6oWa7CJ06CojXd
  41220. FPQf/7J31Ycvqm59JCfnxssm5uX+Zwdj2EUN3TpZZTlYepKZcj2chF6IIbjV9Cz82XBST3i4vTwr
  41221. i5WY9bPRaM8gFH5MXF/ni+X1NYEZN9cRCLdmvtNKzoNXADrDgfgXy5I2XdGj2HUb4Ysn6npIQf1F
  41222. GQatJ5lOwXBH3bWfgVMS5bGMSF0xQxfjjMZ6Y5ZLKTBOhE5iGV48zpeQpX8B653g+IuJ3SWYPZK2
  41223. fu/Z8VFRfS0myGlZYeCsargqNhEEelC9MoS+L9xy1dcdFkfkR2YgP/SWxa+OAXqlD3pk9Q0Yh9mu
  41224. iNX6hME6wGkoLfINaFGq46V3xqSQDqE3izEjR8EJCOtu93ib14L8hCCZSRm2Ekax+0VVFqmjZayc
  41225. Bw/qa9wfLgZy7IaIEuQt218FL+TwA9MmM+eAws1CoRc0CwIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  41226. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUcRVnyMjJvXVdctA4GGqd83EkVAswDQYJKoZI
  41227. hvcNAQELBQADggIBAHW7bVRLqhBYRjTyYtcWNl0IXtVsyIe9tC5G8jH4fOpCtZMWVdyhDBKg2mF+
  41228. D1hYc2Ryx+hFjtyp8iY/xnmMsVMIM4GwVhO+5lFc2JsKT0ucVlMC6U/2DWDqTUJV6HwbISHTGzrM
  41229. d/K4kPFox/la/vot9L/J9UUbzjgQKjeKeaO04wlshYaT/4mWJ3iBj2fjRnRUjtkNaeJK9E10A/+y
  41230. d+2VZ5fkscWrv2oj6NSU4kQoYsRL4vDY4ilrGnB+JGGTe08DMiUNRSQrlrRGar9KC/eaj8GsGsVn
  41231. 82800vpzY4zvFrCopEYq+OsS7HK07/grfoxSwIuEVPkvPuNVqNxmsdnhX9izjFk0WaSrT2y7Hxjb
  41232. davYy5LNlDhhDgcGH0tGEPEVvo2FXDtKK4F5D7Rpn0lQl033DlZdwJVqwjbDG2jJ9SrcR5q+ss7F
  41233. Jej6A7na+RZukYT1HCjI/CbM1xyQVqdfbzoEvM14iQuODy+jqk+iGxI9FghAD/FGTNeqewjBCvVt
  41234. J94Cj8rDtSvK6evIIVM4pcw72Hc3MKJP2W/R8kCtQXoXxdZKNYm3QdV8hn9VTYNKpXMgwDqvkPGa
  41235. JI7ZjnHKe7iG2rKPmT4dEw0SEe7Uq/DpFXYC5ODfqiAeW2GFZECpkJcNrVPSWh2HagCXZWK0vm9q
  41236. p/UsQu0yrbYhnr68
  41237. -----END CERTIFICATE-----
  41238. Hellenic Academic and Research Institutions ECC RootCA 2015
  41239. ===========================================================
  41240. -----BEGIN CERTIFICATE-----
  41241. MIICwzCCAkqgAwIBAgIBADAKBggqhkjOPQQDAjCBqjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0
  41242. aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9u
  41243. cyBDZXJ0LiBBdXRob3JpdHkxRDBCBgNVBAMTO0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJj
  41244. aCBJbnN0aXR1dGlvbnMgRUNDIFJvb3RDQSAyMDE1MB4XDTE1MDcwNzEwMzcxMloXDTQwMDYzMDEw
  41245. MzcxMlowgaoxCzAJBgNVBAYTAkdSMQ8wDQYDVQQHEwZBdGhlbnMxRDBCBgNVBAoTO0hlbGxlbmlj
  41246. IEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9yaXR5MUQwQgYD
  41247. VQQDEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25zIEVDQyBSb290
  41248. Q0EgMjAxNTB2MBAGByqGSM49AgEGBSuBBAAiA2IABJKgQehLgoRc4vgxEZmGZE4JJS+dQS8KrjVP
  41249. dJWyUWRrjWvmP3CV8AVER6ZyOFB2lQJajq4onvktTpnvLEhvTCUp6NFxW98dwXU3tNf6e3pCnGoK
  41250. Vlp8aQuqgAkkbH7BRqNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O
  41251. BBYEFLQiC4KZJAEOnLvkDv2/+5cgk5kqMAoGCCqGSM49BAMCA2cAMGQCMGfOFmI4oqxiRaeplSTA
  41252. GiecMjvAwNW6qef4BENThe5SId6d9SWDPp5YSy/XZxMOIQIwBeF1Ad5o7SofTUwJCA3sS61kFyjn
  41253. dc5FZXIhF8siQQ6ME5g4mlRtm8rifOoCWCKR
  41254. -----END CERTIFICATE-----
  41255. ISRG Root X1
  41256. ============
  41257. -----BEGIN CERTIFICATE-----
  41258. MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAwTzELMAkGA1UE
  41259. BhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2VhcmNoIEdyb3VwMRUwEwYDVQQD
  41260. EwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQG
  41261. EwJVUzEpMCcGA1UEChMgSW50ZXJuZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMT
  41262. DElTUkcgUm9vdCBYMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54r
  41263. Vygch77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+0TM8ukj1
  41264. 3Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6UA5/TR5d8mUgjU+g4rk8K
  41265. b4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sWT8KOEUt+zwvo/7V3LvSye0rgTBIlDHCN
  41266. Aymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyHB5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ
  41267. 4Q7e2RCOFvu396j3x+UCB5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf
  41268. 1b0SHzUvKBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWnOlFu
  41269. hjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTnjh8BCNAw1FtxNrQH
  41270. usEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbwqHyGO0aoSCqI3Haadr8faqU9GY/r
  41271. OPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CIrU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4G
  41272. A1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY
  41273. 9umbbjANBgkqhkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL
  41274. ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ3BebYhtF8GaV
  41275. 0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KKNFtY2PwByVS5uCbMiogziUwt
  41276. hDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJw
  41277. TdwJx4nLCgdNbOhdjsnvzqvHu7UrTkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nx
  41278. e5AW0wdeRlN8NwdCjNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZA
  41279. JzVcoyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq4RgqsahD
  41280. YVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPAmRGunUHBcnWEvgJBQl9n
  41281. JEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57demyPxgcYxn/eR44/KJ4EBs+lVDR3veyJ
  41282. m+kXQ99b21/+jh5Xos1AnX5iItreGCc=
  41283. -----END CERTIFICATE-----
  41284. AC RAIZ FNMT-RCM
  41285. ================
  41286. -----BEGIN CERTIFICATE-----
  41287. MIIFgzCCA2ugAwIBAgIPXZONMGc2yAYdGsdUhGkHMA0GCSqGSIb3DQEBCwUAMDsxCzAJBgNVBAYT
  41288. AkVTMREwDwYDVQQKDAhGTk1ULVJDTTEZMBcGA1UECwwQQUMgUkFJWiBGTk1ULVJDTTAeFw0wODEw
  41289. MjkxNTU5NTZaFw0zMDAxMDEwMDAwMDBaMDsxCzAJBgNVBAYTAkVTMREwDwYDVQQKDAhGTk1ULVJD
  41290. TTEZMBcGA1UECwwQQUMgUkFJWiBGTk1ULVJDTTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
  41291. ggIBALpxgHpMhm5/yBNtwMZ9HACXjywMI7sQmkCpGreHiPibVmr75nuOi5KOpyVdWRHbNi63URcf
  41292. qQgfBBckWKo3Shjf5TnUV/3XwSyRAZHiItQDwFj8d0fsjz50Q7qsNI1NOHZnjrDIbzAzWHFctPVr
  41293. btQBULgTfmxKo0nRIBnuvMApGGWn3v7v3QqQIecaZ5JCEJhfTzC8PhxFtBDXaEAUwED653cXeuYL
  41294. j2VbPNmaUtu1vZ5Gzz3rkQUCwJaydkxNEJY7kvqcfw+Z374jNUUeAlz+taibmSXaXvMiwzn15Cou
  41295. 08YfxGyqxRxqAQVKL9LFwag0Jl1mpdICIfkYtwb1TplvqKtMUejPUBjFd8g5CSxJkjKZqLsXF3mw
  41296. WsXmo8RZZUc1g16p6DULmbvkzSDGm0oGObVo/CK67lWMK07q87Hj/LaZmtVC+nFNCM+HHmpxffnT
  41297. tOmlcYF7wk5HlqX2doWjKI/pgG6BU6VtX7hI+cL5NqYuSf+4lsKMB7ObiFj86xsc3i1w4peSMKGJ
  41298. 47xVqCfWS+2QrYv6YyVZLag13cqXM7zlzced0ezvXg5KkAYmY6252TUtB7p2ZSysV4999AeU14EC
  41299. ll2jB0nVetBX+RvnU0Z1qrB5QstocQjpYL05ac70r8NWQMetUqIJ5G+GR4of6ygnXYMgrwTJbFaa
  41300. i0b1AgMBAAGjgYMwgYAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE
  41301. FPd9xf3E6Jobd2Sn9R2gzL+HYJptMD4GA1UdIAQ3MDUwMwYEVR0gADArMCkGCCsGAQUFBwIBFh1o
  41302. dHRwOi8vd3d3LmNlcnQuZm5tdC5lcy9kcGNzLzANBgkqhkiG9w0BAQsFAAOCAgEAB5BK3/MjTvDD
  41303. nFFlm5wioooMhfNzKWtN/gHiqQxjAb8EZ6WdmF/9ARP67Jpi6Yb+tmLSbkyU+8B1RXxlDPiyN8+s
  41304. D8+Nb/kZ94/sHvJwnvDKuO+3/3Y3dlv2bojzr2IyIpMNOmqOFGYMLVN0V2Ue1bLdI4E7pWYjJ2cJ
  41305. j+F3qkPNZVEI7VFY/uY5+ctHhKQV8Xa7pO6kO8Rf77IzlhEYt8llvhjho6Tc+hj507wTmzl6NLrT
  41306. Qfv6MooqtyuGC2mDOL7Nii4LcK2NJpLuHvUBKwrZ1pebbuCoGRw6IYsMHkCtA+fdZn71uSANA+iW
  41307. +YJF1DngoABd15jmfZ5nc8OaKveri6E6FO80vFIOiZiaBECEHX5FaZNXzuvO+FB8TxxuBEOb+dY7
  41308. Ixjp6o7RTUaN8Tvkasq6+yO3m/qZASlaWFot4/nUbQ4mrcFuNLwy+AwF+mWj2zs3gyLp1txyM/1d
  41309. 8iC9djwj2ij3+RvrWWTV3F9yfiD8zYm1kGdNYno/Tq0dwzn+evQoFt9B9kiABdcPUXmsEKvU7ANm
  41310. 5mqwujGSQkBqvjrTcuFqN1W8rB2Vt2lh8kORdOag0wokRqEIr9baRRmW1FMdW4R58MD3R++Lj8UG
  41311. rp1MYp3/RgT408m2ECVAdf4WqslKYIYvuu8wd+RU4riEmViAqhOLUTpPSPaLtrM=
  41312. -----END CERTIFICATE-----
  41313. Amazon Root CA 1
  41314. ================
  41315. -----BEGIN CERTIFICATE-----
  41316. MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsFADA5MQswCQYD
  41317. VQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAxMB4XDTE1
  41318. MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpv
  41319. bjEZMBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
  41320. ggEBALJ4gHHKeNXjca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgH
  41321. FzZM9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qwIFAGbHrQ
  41322. gLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6VOujw5H5SNz/0egwLX0t
  41323. dHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L93FcXmn/6pUCyziKrlA4b9v7LWIbxcce
  41324. VOF34GfID5yHI9Y/QCB/IIDEgEw+OyQmjgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB
  41325. /zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3
  41326. DQEBCwUAA4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDIU5PM
  41327. CCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUsN+gDS63pYaACbvXy
  41328. 8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vvo/ufQJVtMVT8QtPHRh8jrdkPSHCa
  41329. 2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2
  41330. xJNDd2ZhwLnoQdeXeGADbkpyrqXRfboQnoZsG4q5WTP468SQvvG5
  41331. -----END CERTIFICATE-----
  41332. Amazon Root CA 2
  41333. ================
  41334. -----BEGIN CERTIFICATE-----
  41335. MIIFQTCCAymgAwIBAgITBmyf0pY1hp8KD+WGePhbJruKNzANBgkqhkiG9w0BAQwFADA5MQswCQYD
  41336. VQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAyMB4XDTE1
  41337. MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpv
  41338. bjEZMBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
  41339. ggIBAK2Wny2cSkxKgXlRmeyKy2tgURO8TW0G/LAIjd0ZEGrHJgw12MBvIITplLGbhQPDW9tK6Mj4
  41340. kHbZW0/jTOgGNk3Mmqw9DJArktQGGWCsN0R5hYGCrVo34A3MnaZMUnbqQ523BNFQ9lXg1dKmSYXp
  41341. N+nKfq5clU1Imj+uIFptiJXZNLhSGkOQsL9sBbm2eLfq0OQ6PBJTYv9K8nu+NQWpEjTj82R0Yiw9
  41342. AElaKP4yRLuH3WUnAnE72kr3H9rN9yFVkE8P7K6C4Z9r2UXTu/Bfh+08LDmG2j/e7HJV63mjrdvd
  41343. fLC6HM783k81ds8P+HgfajZRRidhW+mez/CiVX18JYpvL7TFz4QuK/0NURBs+18bvBt+xa47mAEx
  41344. kv8LV/SasrlX6avvDXbR8O70zoan4G7ptGmh32n2M8ZpLpcTnqWHsFcQgTfJU7O7f/aS0ZzQGPSS
  41345. btqDT6ZjmUyl+17vIWR6IF9sZIUVyzfpYgwLKhbcAS4y2j5L9Z469hdAlO+ekQiG+r5jqFoz7Mt0
  41346. Q5X5bGlSNscpb/xVA1wf+5+9R+vnSUeVC06JIglJ4PVhHvG/LopyboBZ/1c6+XUyo05f7O0oYtlN
  41347. c/LMgRdg7c3r3NunysV+Ar3yVAhU/bQtCSwXVEqY0VThUWcI0u1ufm8/0i2BWSlmy5A5lREedCf+
  41348. 3euvAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSw
  41349. DPBMMPQFWAJI/TPlUq9LhONmUjANBgkqhkiG9w0BAQwFAAOCAgEAqqiAjw54o+Ci1M3m9Zh6O+oA
  41350. A7CXDpO8Wqj2LIxyh6mx/H9z/WNxeKWHWc8w4Q0QshNabYL1auaAn6AFC2jkR2vHat+2/XcycuUY
  41351. +gn0oJMsXdKMdYV2ZZAMA3m3MSNjrXiDCYZohMr/+c8mmpJ5581LxedhpxfL86kSk5Nrp+gvU5LE
  41352. YFiwzAJRGFuFjWJZY7attN6a+yb3ACfAXVU3dJnJUH/jWS5E4ywl7uxMMne0nxrpS10gxdr9HIcW
  41353. xkPo1LsmmkVwXqkLN1PiRnsn/eBG8om3zEK2yygmbtmlyTrIQRNg91CMFa6ybRoVGld45pIq2WWQ
  41354. gj9sAq+uEjonljYE1x2igGOpm/HlurR8FLBOybEfdF849lHqm/osohHUqS0nGkWxr7JOcQ3AWEbW
  41355. aQbLU8uz/mtBzUF+fUwPfHJ5elnNXkoOrJupmHN5fLT0zLm4BwyydFy4x2+IoZCn9Kr5v2c69BoV
  41356. Yh63n749sSmvZ6ES8lgQGVMDMBu4Gon2nL2XA46jCfMdiyHxtN/kHNGfZQIG6lzWE7OE76KlXIx3
  41357. KadowGuuQNKotOrN8I1LOJwZmhsoVLiJkO/KdYE+HvJkJMcYr07/R54H9jVlpNMKVv/1F2Rs76gi
  41358. JUmTtt8AF9pYfl3uxRuw0dFfIRDH+fO6AgonB8Xx1sfT4PsJYGw=
  41359. -----END CERTIFICATE-----
  41360. Amazon Root CA 3
  41361. ================
  41362. -----BEGIN CERTIFICATE-----
  41363. MIIBtjCCAVugAwIBAgITBmyf1XSXNmY/Owua2eiedgPySjAKBggqhkjOPQQDAjA5MQswCQYDVQQG
  41364. EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAzMB4XDTE1MDUy
  41365. NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ
  41366. MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCmXp8ZB
  41367. f8ANm+gBG1bG8lKlui2yEujSLtf6ycXYqm0fc4E7O5hrOXwzpcVOho6AF2hiRVd9RFgdszflZwjr
  41368. Zt6jQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSrttvXBp43
  41369. rDCGB5Fwx5zEGbF4wDAKBggqhkjOPQQDAgNJADBGAiEA4IWSoxe3jfkrBqWTrBqYaGFy+uGh0Psc
  41370. eGCmQ5nFuMQCIQCcAu/xlJyzlvnrxir4tiz+OpAUFteMYyRIHN8wfdVoOw==
  41371. -----END CERTIFICATE-----
  41372. Amazon Root CA 4
  41373. ================
  41374. -----BEGIN CERTIFICATE-----
  41375. MIIB8jCCAXigAwIBAgITBmyf18G7EEwpQ+Vxe3ssyBrBDjAKBggqhkjOPQQDAzA5MQswCQYDVQQG
  41376. EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSA0MB4XDTE1MDUy
  41377. NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ
  41378. MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgNDB2MBAGByqGSM49AgEGBSuBBAAiA2IABNKrijdPo1MN
  41379. /sGKe0uoe0ZLY7Bi9i0b2whxIdIA6GO9mif78DluXeo9pcmBqqNbIJhFXRbb/egQbeOc4OO9X4Ri
  41380. 83BkM6DLJC9wuoihKqB1+IGuYgbEgds5bimwHvouXKNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV
  41381. HQ8BAf8EBAMCAYYwHQYDVR0OBBYEFNPsxzplbszh2naaVvuc84ZtV+WBMAoGCCqGSM49BAMDA2gA
  41382. MGUCMDqLIfG9fhGt0O9Yli/W651+kI0rz2ZVwyzjKKlwCkcO8DdZEv8tmZQoTipPNU0zWgIxAOp1
  41383. AE47xDqUEpHJWEadIRNyp4iciuRMStuW1KyLa2tJElMzrdfkviT8tQp21KW8EA==
  41384. -----END CERTIFICATE-----
  41385. TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1
  41386. =============================================
  41387. -----BEGIN CERTIFICATE-----
  41388. MIIEYzCCA0ugAwIBAgIBATANBgkqhkiG9w0BAQsFADCB0jELMAkGA1UEBhMCVFIxGDAWBgNVBAcT
  41389. D0dlYnplIC0gS29jYWVsaTFCMEAGA1UEChM5VHVya2l5ZSBCaWxpbXNlbCB2ZSBUZWtub2xvamlr
  41390. IEFyYXN0aXJtYSBLdXJ1bXUgLSBUVUJJVEFLMS0wKwYDVQQLEyRLYW11IFNlcnRpZmlrYXN5b24g
  41391. TWVya2V6aSAtIEthbXUgU00xNjA0BgNVBAMTLVRVQklUQUsgS2FtdSBTTSBTU0wgS29rIFNlcnRp
  41392. ZmlrYXNpIC0gU3VydW0gMTAeFw0xMzExMjUwODI1NTVaFw00MzEwMjUwODI1NTVaMIHSMQswCQYD
  41393. VQQGEwJUUjEYMBYGA1UEBxMPR2ViemUgLSBLb2NhZWxpMUIwQAYDVQQKEzlUdXJraXllIEJpbGlt
  41394. c2VsIHZlIFRla25vbG9qaWsgQXJhc3Rpcm1hIEt1cnVtdSAtIFRVQklUQUsxLTArBgNVBAsTJEth
  41395. bXUgU2VydGlmaWthc3lvbiBNZXJrZXppIC0gS2FtdSBTTTE2MDQGA1UEAxMtVFVCSVRBSyBLYW11
  41396. IFNNIFNTTCBLb2sgU2VydGlmaWthc2kgLSBTdXJ1bSAxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  41397. MIIBCgKCAQEAr3UwM6q7a9OZLBI3hNmNe5eA027n/5tQlT6QlVZC1xl8JoSNkvoBHToP4mQ4t4y8
  41398. 6Ij5iySrLqP1N+RAjhgleYN1Hzv/bKjFxlb4tO2KRKOrbEz8HdDc72i9z+SqzvBV96I01INrN3wc
  41399. wv61A+xXzry0tcXtAA9TNypN9E8Mg/uGz8v+jE69h/mniyFXnHrfA2eJLJ2XYacQuFWQfw4tJzh0
  41400. 3+f92k4S400VIgLI4OD8D62K18lUUMw7D8oWgITQUVbDjlZ/iSIzL+aFCr2lqBs23tPcLG07xxO9
  41401. WSMs5uWk99gL7eqQQESolbuT1dCANLZGeA4fAJNG4e7p+exPFwIDAQABo0IwQDAdBgNVHQ4EFgQU
  41402. ZT/HiobGPN08VFw1+DrtUgxHV8gwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJ
  41403. KoZIhvcNAQELBQADggEBACo/4fEyjq7hmFxLXs9rHmoJ0iKpEsdeV31zVmSAhHqT5Am5EM2fKifh
  41404. AHe+SMg1qIGf5LgsyX8OsNJLN13qudULXjS99HMpw+0mFZx+CFOKWI3QSyjfwbPfIPP54+M638yc
  41405. lNhOT8NrF7f3cuitZjO1JVOr4PhMqZ398g26rrnZqsZr+ZO7rqu4lzwDGrpDxpa5RXI4s6ehlj2R
  41406. e37AIVNMh+3yC1SVUZPVIqUNivGTDj5UDrDYyU7c8jEyVupk+eq1nRZmQnLzf9OxMUP8pI4X8W0j
  41407. q5Rm+K37DwhuJi1/FwcJsoz7UMCflo3Ptv0AnVoUmr8CRPXBwp8iXqIPoeM=
  41408. -----END CERTIFICATE-----
  41409. GDCA TrustAUTH R5 ROOT
  41410. ======================
  41411. -----BEGIN CERTIFICATE-----
  41412. MIIFiDCCA3CgAwIBAgIIfQmX/vBH6nowDQYJKoZIhvcNAQELBQAwYjELMAkGA1UEBhMCQ04xMjAw
  41413. BgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZIENPLixMVEQuMR8wHQYDVQQD
  41414. DBZHRENBIFRydXN0QVVUSCBSNSBST09UMB4XDTE0MTEyNjA1MTMxNVoXDTQwMTIzMTE1NTk1OVow
  41415. YjELMAkGA1UEBhMCQ04xMjAwBgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZ
  41416. IENPLixMVEQuMR8wHQYDVQQDDBZHRENBIFRydXN0QVVUSCBSNSBST09UMIICIjANBgkqhkiG9w0B
  41417. AQEFAAOCAg8AMIICCgKCAgEA2aMW8Mh0dHeb7zMNOwZ+Vfy1YI92hhJCfVZmPoiC7XJjDp6L3TQs
  41418. AlFRwxn9WVSEyfFrs0yw6ehGXTjGoqcuEVe6ghWinI9tsJlKCvLriXBjTnnEt1u9ol2x8kECK62p
  41419. OqPseQrsXzrj/e+APK00mxqriCZ7VqKChh/rNYmDf1+uKU49tm7srsHwJ5uu4/Ts765/94Y9cnrr
  41420. pftZTqfrlYwiOXnhLQiPzLyRuEH3FMEjqcOtmkVEs7LXLM3GKeJQEK5cy4KOFxg2fZfmiJqwTTQJ
  41421. 9Cy5WmYqsBebnh52nUpmMUHfP/vFBu8btn4aRjb3ZGM74zkYI+dndRTVdVeSN72+ahsmUPI2JgaQ
  41422. xXABZG12ZuGR224HwGGALrIuL4xwp9E7PLOR5G62xDtw8mySlwnNR30YwPO7ng/Wi64HtloPzgsM
  41423. R6flPri9fcebNaBhlzpBdRfMK5Z3KpIhHtmVdiBnaM8Nvd/WHwlqmuLMc3GkL30SgLdTMEZeS1SZ
  41424. D2fJpcjyIMGC7J0R38IC+xo70e0gmu9lZJIQDSri3nDxGGeCjGHeuLzRL5z7D9Ar7Rt2ueQ5Vfj4
  41425. oR24qoAATILnsn8JuLwwoC8N9VKejveSswoAHQBUlwbgsQfZxw9cZX08bVlX5O2ljelAU58VS6Bx
  41426. 9hoh49pwBiFYFIeFd3mqgnkCAwEAAaNCMEAwHQYDVR0OBBYEFOLJQJ9NzuiaoXzPDj9lxSmIahlR
  41427. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQDRSVfg
  41428. p8xoWLoBDysZzY2wYUWsEe1jUGn4H3++Fo/9nesLqjJHdtJnJO29fDMylyrHBYZmDRd9FBUb1Ov9
  41429. H5r2XpdptxolpAqzkT9fNqyL7FeoPueBihhXOYV0GkLH6VsTX4/5COmSdI31R9KrO9b7eGZONn35
  41430. 6ZLpBN79SWP8bfsUcZNnL0dKt7n/HipzcEYwv1ryL3ml4Y0M2fmyYzeMN2WFcGpcWwlyua1jPLHd
  41431. +PwyvzeG5LuOmCd+uh8W4XAR8gPfJWIyJyYYMoSf/wA6E7qaTfRPuBRwIrHKK5DOKcFw9C+df/KQ
  41432. HtZa37dG/OaG+svgIHZ6uqbL9XzeYqWxi+7egmaKTjowHz+Ay60nugxe19CxVsp3cbK1daFQqUBD
  41433. F8Io2c9Si1vIY9RCPqAzekYu9wogRlR+ak8x8YF+QnQ4ZXMn7sZ8uI7XpTrXmKGcjBBV09tL7ECQ
  41434. 8s1uV9JiDnxXk7Gnbc2dg7sq5+W2O3FYrf3RRbxake5TFW/TRQl1brqQXR4EzzffHqhmsYzmIGrv
  41435. /EhOdJhCrylvLmrH+33RZjEizIYAfmaDDEL0vTSSwxrqT8p+ck0LcIymSLumoRT2+1hEmRSuqguT
  41436. aaApJUqlyyvdimYHFngVV3Eb7PVHhPOeMTd61X8kreS8/f3MboPoDKi3QWwH3b08hpcv0g==
  41437. -----END CERTIFICATE-----
  41438. TrustCor RootCert CA-1
  41439. ======================
  41440. -----BEGIN CERTIFICATE-----
  41441. MIIEMDCCAxigAwIBAgIJANqb7HHzA7AZMA0GCSqGSIb3DQEBCwUAMIGkMQswCQYDVQQGEwJQQTEP
  41442. MA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3Ig
  41443. U3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5UcnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3Jp
  41444. dHkxHzAdBgNVBAMMFlRydXN0Q29yIFJvb3RDZXJ0IENBLTEwHhcNMTYwMjA0MTIzMjE2WhcNMjkx
  41445. MjMxMTcyMzE2WjCBpDELMAkGA1UEBhMCUEExDzANBgNVBAgMBlBhbmFtYTEUMBIGA1UEBwwLUGFu
  41446. YW1hIENpdHkxJDAiBgNVBAoMG1RydXN0Q29yIFN5c3RlbXMgUy4gZGUgUi5MLjEnMCUGA1UECwwe
  41447. VHJ1c3RDb3IgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR8wHQYDVQQDDBZUcnVzdENvciBSb290Q2Vy
  41448. dCBDQS0xMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv463leLCJhJrMxnHQFgKq1mq
  41449. jQCj/IDHUHuO1CAmujIS2CNUSSUQIpidRtLByZ5OGy4sDjjzGiVoHKZaBeYei0i/mJZ0PmnK6bV4
  41450. pQa81QBeCQryJ3pS/C3Vseq0iWEk8xoT26nPUu0MJLq5nux+AHT6k61sKZKuUbS701e/s/OojZz0
  41451. JEsq1pme9J7+wH5COucLlVPat2gOkEz7cD+PSiyU8ybdY2mplNgQTsVHCJCZGxdNuWxu72CVEY4h
  41452. gLW9oHPY0LJ3xEXqWib7ZnZ2+AYfYW0PVcWDtxBWcgYHpfOxGgMFZA6dWorWhnAbJN7+KIor0Gqw
  41453. /Hqi3LJ5DotlDwIDAQABo2MwYTAdBgNVHQ4EFgQU7mtJPHo/DeOxCbeKyKsZn3MzUOcwHwYDVR0j
  41454. BBgwFoAU7mtJPHo/DeOxCbeKyKsZn3MzUOcwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  41455. AYYwDQYJKoZIhvcNAQELBQADggEBACUY1JGPE+6PHh0RU9otRCkZoB5rMZ5NDp6tPVxBb5UrJKF5
  41456. mDo4Nvu7Zp5I/5CQ7z3UuJu0h3U/IJvOcs+hVcFNZKIZBqEHMwwLKeXx6quj7LUKdJDHfXLy11yf
  41457. ke+Ri7fc7Waiz45mO7yfOgLgJ90WmMCV1Aqk5IGadZQ1nJBfiDcGrVmVCrDRZ9MZyonnMlo2HD6C
  41458. qFqTvsbQZJG2z9m2GM/bftJlo6bEjhcxwft+dtvTheNYsnd6djtsL1Ac59v2Z3kf9YKVmgenFK+P
  41459. 3CghZwnS1k1aHBkcjndcw5QkPTJrS37UeJSDvjdNzl/HHk484IkzlQsPpTLWPFp5LBk=
  41460. -----END CERTIFICATE-----
  41461. TrustCor RootCert CA-2
  41462. ======================
  41463. -----BEGIN CERTIFICATE-----
  41464. MIIGLzCCBBegAwIBAgIIJaHfyjPLWQIwDQYJKoZIhvcNAQELBQAwgaQxCzAJBgNVBAYTAlBBMQ8w
  41465. DQYDVQQIDAZQYW5hbWExFDASBgNVBAcMC1BhbmFtYSBDaXR5MSQwIgYDVQQKDBtUcnVzdENvciBT
  41466. eXN0ZW1zIFMuIGRlIFIuTC4xJzAlBgNVBAsMHlRydXN0Q29yIENlcnRpZmljYXRlIEF1dGhvcml0
  41467. eTEfMB0GA1UEAwwWVHJ1c3RDb3IgUm9vdENlcnQgQ0EtMjAeFw0xNjAyMDQxMjMyMjNaFw0zNDEy
  41468. MzExNzI2MzlaMIGkMQswCQYDVQQGEwJQQTEPMA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5h
  41469. bWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3IgU3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5U
  41470. cnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHzAdBgNVBAMMFlRydXN0Q29yIFJvb3RDZXJ0
  41471. IENBLTIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCnIG7CKqJiJJWQdsg4foDSq8Gb
  41472. ZQWU9MEKENUCrO2fk8eHyLAnK0IMPQo+QVqedd2NyuCb7GgypGmSaIwLgQ5WoD4a3SwlFIIvl9Nk
  41473. RvRUqdw6VC0xK5mC8tkq1+9xALgxpL56JAfDQiDyitSSBBtlVkxs1Pu2YVpHI7TYabS3OtB0PAx1
  41474. oYxOdqHp2yqlO/rOsP9+aij9JxzIsekp8VduZLTQwRVtDr4uDkbIXvRR/u8OYzo7cbrPb1nKDOOb
  41475. XUm4TOJXsZiKQlecdu/vvdFoqNL0Cbt3Nb4lggjEFixEIFapRBF37120Hapeaz6LMvYHL1cEksr1
  41476. /p3C6eizjkxLAjHZ5DxIgif3GIJ2SDpxsROhOdUuxTTCHWKF3wP+TfSvPd9cW436cOGlfifHhi5q
  41477. jxLGhF5DUVCcGZt45vz27Ud+ez1m7xMTiF88oWP7+ayHNZ/zgp6kPwqcMWmLmaSISo5uZk3vFsQP
  41478. eSghYA2FFn3XVDjxklb9tTNMg9zXEJ9L/cb4Qr26fHMC4P99zVvh1Kxhe1fVSntb1IVYJ12/+Ctg
  41479. rKAmrhQhJ8Z3mjOAPF5GP/fDsaOGM8boXg25NSyqRsGFAnWAoOsk+xWq5Gd/bnc/9ASKL3x74xdh
  41480. 8N0JqSDIvgmk0H5Ew7IwSjiqqewYmgeCK9u4nBit2uBGF6zPXQIDAQABo2MwYTAdBgNVHQ4EFgQU
  41481. 2f4hQG6UnrybPZx9mCAZ5YwwYrIwHwYDVR0jBBgwFoAU2f4hQG6UnrybPZx9mCAZ5YwwYrIwDwYD
  41482. VR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQELBQADggIBAJ5Fngw7tu/h
  41483. Osh80QA9z+LqBrWyOrsGS2h60COXdKcs8AjYeVrXWoSK2BKaG9l9XE1wxaX5q+WjiYndAfrs3fnp
  41484. kpfbsEZC89NiqpX+MWcUaViQCqoL7jcjx1BRtPV+nuN79+TMQjItSQzL/0kMmx40/W5ulop5A7Zv
  41485. 2wnL/V9lFDfhOPXzYRZY5LVtDQsEGz9QLX+zx3oaFoBg+Iof6Rsqxvm6ARppv9JYx1RXCI/hOWB3
  41486. S6xZhBqI8d3LT3jX5+EzLfzuQfogsL7L9ziUwOHQhQ+77Sxzq+3+knYaZH9bDTMJBzN7Bj8RpFxw
  41487. PIXAz+OQqIN3+tvmxYxoZxBnpVIt8MSZj3+/0WvitUfW2dCFmU2Umw9Lje4AWkcdEQOsQRivh7dv
  41488. DDqPys/cA8GiCcjl/YBeyGBCARsaU1q7N6a3vLqE6R5sGtRk2tRD/pOLS/IseRYQ1JMLiI+h2IYU
  41489. RpFHmygk71dSTlxCnKr3Sewn6EAes6aJInKc9Q0ztFijMDvd1GpUk74aTfOTlPf8hAs/hCBcNANE
  41490. xdqtvArBAs8e5ZTZ845b2EzwnexhF7sUMlQMAimTHpKG9n/v55IFDlndmQguLvqcAFLTxWYp5KeX
  41491. RKQOKIETNcX2b2TmQcTVL8w0RSXPQQCWPUouwpaYT05KnJe32x+SMsj/D1Fu1uwJ
  41492. -----END CERTIFICATE-----
  41493. TrustCor ECA-1
  41494. ==============
  41495. -----BEGIN CERTIFICATE-----
  41496. MIIEIDCCAwigAwIBAgIJAISCLF8cYtBAMA0GCSqGSIb3DQEBCwUAMIGcMQswCQYDVQQGEwJQQTEP
  41497. MA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3Ig
  41498. U3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5UcnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3Jp
  41499. dHkxFzAVBgNVBAMMDlRydXN0Q29yIEVDQS0xMB4XDTE2MDIwNDEyMzIzM1oXDTI5MTIzMTE3Mjgw
  41500. N1owgZwxCzAJBgNVBAYTAlBBMQ8wDQYDVQQIDAZQYW5hbWExFDASBgNVBAcMC1BhbmFtYSBDaXR5
  41501. MSQwIgYDVQQKDBtUcnVzdENvciBTeXN0ZW1zIFMuIGRlIFIuTC4xJzAlBgNVBAsMHlRydXN0Q29y
  41502. IENlcnRpZmljYXRlIEF1dGhvcml0eTEXMBUGA1UEAwwOVHJ1c3RDb3IgRUNBLTEwggEiMA0GCSqG
  41503. SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDPj+ARtZ+odnbb3w9U73NjKYKtR8aja+3+XzP4Q1HpGjOR
  41504. MRegdMTUpwHmspI+ap3tDvl0mEDTPwOABoJA6LHip1GnHYMma6ve+heRK9jGrB6xnhkB1Zem6g23
  41505. xFUfJ3zSCNV2HykVh0A53ThFEXXQmqc04L/NyFIduUd+Dbi7xgz2c1cWWn5DkR9VOsZtRASqnKmc
  41506. p0yJF4OuowReUoCLHhIlERnXDH19MURB6tuvsBzvgdAsxZohmz3tQjtQJvLsznFhBmIhVE5/wZ0+
  41507. fyCMgMsq2JdiyIMzkX2woloPV+g7zPIlstR8L+xNxqE6FXrntl019fZISjZFZtS6mFjBAgMBAAGj
  41508. YzBhMB0GA1UdDgQWBBREnkj1zG1I1KBLf/5ZJC+Dl5mahjAfBgNVHSMEGDAWgBREnkj1zG1I1KBL
  41509. f/5ZJC+Dl5mahjAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQsF
  41510. AAOCAQEABT41XBVwm8nHc2FvcivUwo/yQ10CzsSUuZQRg2dd4mdsdXa/uwyqNsatR5Nj3B5+1t4u
  41511. /ukZMjgDfxT2AHMsWbEhBuH7rBiVDKP/mZb3Kyeb1STMHd3BOuCYRLDE5D53sXOpZCz2HAF8P11F
  41512. hcCF5yWPldwX8zyfGm6wyuMdKulMY/okYWLW2n62HGz1Ah3UKt1VkOsqEUc8Ll50soIipX1TH0Xs
  41513. J5F95yIW6MBoNtjG8U+ARDL54dHRHareqKucBK+tIA5kmE2la8BIWJZpTdwHjFGTot+fDz2LYLSC
  41514. jaoITmJF4PkL0uDgPFveXHEnJcLmA4GLEFPjx1WitJ/X5g==
  41515. -----END CERTIFICATE-----
  41516. SSL.com Root Certification Authority RSA
  41517. ========================================
  41518. -----BEGIN CERTIFICATE-----
  41519. MIIF3TCCA8WgAwIBAgIIeyyb0xaAMpkwDQYJKoZIhvcNAQELBQAwfDELMAkGA1UEBhMCVVMxDjAM
  41520. BgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24x
  41521. MTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBSU0EwHhcNMTYw
  41522. MjEyMTczOTM5WhcNNDEwMjEyMTczOTM5WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx
  41523. EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NM
  41524. LmNvbSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFJTQTCCAiIwDQYJKoZIhvcNAQEBBQAD
  41525. ggIPADCCAgoCggIBAPkP3aMrfcvQKv7sZ4Wm5y4bunfh4/WvpOz6Sl2RxFdHaxh3a3by/ZPkPQ/C
  41526. Fp4LZsNWlJ4Xg4XOVu/yFv0AYvUiCVToZRdOQbngT0aXqhvIuG5iXmmxX9sqAn78bMrzQdjt0Oj8
  41527. P2FI7bADFB0QDksZ4LtO7IZl/zbzXmcCC52GVWH9ejjt/uIZALdvoVBidXQ8oPrIJZK0bnoix/ge
  41528. oeOy3ZExqysdBP+lSgQ36YWkMyv94tZVNHwZpEpox7Ko07fKoZOI68GXvIz5HdkihCR0xwQ9aqkp
  41529. k8zruFvh/l8lqjRYyMEjVJ0bmBHDOJx+PYZspQ9AhnwC9FwCTyjLrnGfDzrIM/4RJTXq/LrFYD3Z
  41530. fBjVsqnTdXgDciLKOsMf7yzlLqn6niy2UUb9rwPW6mBo6oUWNmuF6R7As93EJNyAKoFBbZQ+yODJ
  41531. gUEAnl6/f8UImKIYLEJAs/lvOCdLToD0PYFH4Ih86hzOtXVcUS4cK38acijnALXRdMbX5J+tB5O2
  41532. UzU1/Dfkw/ZdFr4hc96SCvigY2q8lpJqPvi8ZVWb3vUNiSYE/CUapiVpy8JtynziWV+XrOvvLsi8
  41533. 1xtZPCvM8hnIk2snYxnP/Okm+Mpxm3+T/jRnhE6Z6/yzeAkzcLpmpnbtG3PrGqUNxCITIJRWCk4s
  41534. bE6x/c+cCbqiM+2HAgMBAAGjYzBhMB0GA1UdDgQWBBTdBAkHovV6fVJTEpKV7jiAJQ2mWTAPBgNV
  41535. HRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFN0ECQei9Xp9UlMSkpXuOIAlDaZZMA4GA1UdDwEB/wQE
  41536. AwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAIBgRlCn7Jp0cHh5wYfGVcpNxJK1ok1iOMq8bs3AD/CUr
  41537. dIWQPXhq9LmLpZc7tRiRux6n+UBbkflVma8eEdBcHadm47GUBwwyOabqG7B52B2ccETjit3E+ZUf
  41538. ijhDPwGFpUenPUayvOUiaPd7nNgsPgohyC0zrL/FgZkxdMF1ccW+sfAjRfSda/wZY52jvATGGAsl
  41539. u1OJD7OAUN5F7kR/q5R4ZJjT9ijdh9hwZXT7DrkT66cPYakylszeu+1jTBi7qUD3oFRuIIhxdRjq
  41540. erQ0cuAjJ3dctpDqhiVAq+8zD8ufgr6iIPv2tS0a5sKFsXQP+8hlAqRSAUfdSSLBv9jra6x+3uxj
  41541. MxW3IwiPxg+NQVrdjsW5j+VFP3jbutIbQLH+cU0/4IGiul607BXgk90IH37hVZkLId6Tngr75qNJ
  41542. vTYw/ud3sqB1l7UtgYgXZSD32pAAn8lSzDLKNXz1PQ/YK9f1JmzJBjSWFupwWRoyeXkLtoh/D1JI
  41543. Pb9s2KJELtFOt3JY04kTlf5Eq/jXixtunLwsoFvVagCvXzfh1foQC5ichucmj87w7G6KVwuA406y
  41544. wKBjYZC6VWg3dGq2ktufoYYitmUnDuy2n0Jg5GfCtdpBC8TTi2EbvPofkSvXRAdeuims2cXp71NI
  41545. WuuA8ShYIc2wBlX7Jz9TkHCpBB5XJ7k=
  41546. -----END CERTIFICATE-----
  41547. SSL.com Root Certification Authority ECC
  41548. ========================================
  41549. -----BEGIN CERTIFICATE-----
  41550. MIICjTCCAhSgAwIBAgIIdebfy8FoW6gwCgYIKoZIzj0EAwIwfDELMAkGA1UEBhMCVVMxDjAMBgNV
  41551. BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xMTAv
  41552. BgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEy
  41553. MTgxNDAzWhcNNDEwMjEyMTgxNDAzWjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAO
  41554. BgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNv
  41555. bSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuBBAAiA2IA
  41556. BEVuqVDEpiM2nl8ojRfLliJkP9x6jh3MCLOicSS6jkm5BBtHllirLZXI7Z4INcgn64mMU1jrYor+
  41557. 8FsPazFSY0E7ic3s7LaNGdM0B9y7xgZ/wkWV7Mt/qCPgCemB+vNH06NjMGEwHQYDVR0OBBYEFILR
  41558. hXMw5zUE044CkvvlpNHEIejNMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUgtGFczDnNQTT
  41559. jgKS++Wk0cQh6M0wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2cAMGQCMG/n61kRpGDPYbCW
  41560. e+0F+S8Tkdzt5fxQaxFGRrMcIQBiu77D5+jNB5n5DQtdcj7EqgIwH7y6C+IwJPt8bYBVCpk+gA0z
  41561. 5Wajs6O7pdWLjwkspl1+4vAHCGht0nxpbl/f5Wpl
  41562. -----END CERTIFICATE-----
  41563. SSL.com EV Root Certification Authority RSA R2
  41564. ==============================================
  41565. -----BEGIN CERTIFICATE-----
  41566. MIIF6zCCA9OgAwIBAgIIVrYpzTS8ePYwDQYJKoZIhvcNAQELBQAwgYIxCzAJBgNVBAYTAlVTMQ4w
  41567. DAYDVQQIDAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9u
  41568. MTcwNQYDVQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIy
  41569. MB4XDTE3MDUzMTE4MTQzN1oXDTQyMDUzMDE4MTQzN1owgYIxCzAJBgNVBAYTAlVTMQ4wDAYDVQQI
  41570. DAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMTcwNQYD
  41571. VQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIyMIICIjAN
  41572. BgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAjzZlQOHWTcDXtOlG2mvqM0fNTPl9fb69LT3w23jh
  41573. hqXZuglXaO1XPqDQCEGD5yhBJB/jchXQARr7XnAjssufOePPxU7Gkm0mxnu7s9onnQqG6YE3Bf7w
  41574. cXHswxzpY6IXFJ3vG2fThVUCAtZJycxa4bH3bzKfydQ7iEGonL3Lq9ttewkfokxykNorCPzPPFTO
  41575. Zw+oz12WGQvE43LrrdF9HSfvkusQv1vrO6/PgN3B0pYEW3p+pKk8OHakYo6gOV7qd89dAFmPZiw+
  41576. B6KjBSYRaZfqhbcPlgtLyEDhULouisv3D5oi53+aNxPN8k0TayHRwMwi8qFG9kRpnMphNQcAb9Zh
  41577. CBHqurj26bNg5U257J8UZslXWNvNh2n4ioYSA0e/ZhN2rHd9NCSFg83XqpyQGp8hLH94t2S42Oim
  41578. 9HizVcuE0jLEeK6jj2HdzghTreyI/BXkmg3mnxp3zkyPuBQVPWKchjgGAGYS5Fl2WlPAApiiECto
  41579. RHuOec4zSnaqW4EWG7WK2NAAe15itAnWhmMOpgWVSbooi4iTsjQc2KRVbrcc0N6ZVTsj9CLg+Slm
  41580. JuwgUHfbSguPvuUCYHBBXtSuUDkiFCbLsjtzdFVHB3mBOagwE0TlBIqulhMlQg+5U8Sb/M3kHN48
  41581. +qvWBkofZ6aYMBzdLNvcGJVXZsb/XItW9XcCAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNV
  41582. HSMEGDAWgBT5YLvU49U09rj1BoAlp3PbRmmonjAdBgNVHQ4EFgQU+WC71OPVNPa49QaAJadz20Zp
  41583. qJ4wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQBWs47LCp1Jjr+kxJG7ZhcFUZh1
  41584. ++VQLHqe8RT6q9OKPv+RKY9ji9i0qVQBDb6Thi/5Sm3HXvVX+cpVHBK+Rw82xd9qt9t1wkclf7nx
  41585. Y/hoLVUE0fKNsKTPvDxeH3jnpaAgcLAExbf3cqfeIg29MyVGjGSSJuM+LmOW2puMPfgYCdcDzH2G
  41586. guDKBAdRUNf/ktUM79qGn5nX67evaOI5JpS6aLe/g9Pqemc9YmeuJeVy6OLk7K4S9ksrPJ/psEDz
  41587. OFSz/bdoyNrGj1E8svuR3Bznm53htw1yj+KkxKl4+esUrMZDBcJlOSgYAsOCsp0FvmXtll9ldDz7
  41588. CTUue5wT/RsPXcdtgTpWD8w74a8CLyKsRspGPKAcTNZEtF4uXBVmCeEmKf7GUmG6sXP/wwyc5Wxq
  41589. lD8UykAWlYTzWamsX0xhk23RO8yilQwipmdnRC652dKKQbNmC1r7fSOl8hqw/96bg5Qu0T/fkreR
  41590. rwU7ZcegbLHNYhLDkBvjJc40vG93drEQw/cFGsDWr3RiSBd3kmmQYRzelYB0VI8YHMPzA9C/pEN1
  41591. hlMYegouCRw2n5H9gooiS9EOUCXdywMMF8mDAAhONU2Ki+3wApRmLER/y5UnlhetCTCstnEXbosX
  41592. 9hwJ1C07mKVx01QT2WDz9UtmT/rx7iASjbSsV7FFY6GsdqnC+w==
  41593. -----END CERTIFICATE-----
  41594. SSL.com EV Root Certification Authority ECC
  41595. ===========================================
  41596. -----BEGIN CERTIFICATE-----
  41597. MIIClDCCAhqgAwIBAgIILCmcWxbtBZUwCgYIKoZIzj0EAwIwfzELMAkGA1UEBhMCVVMxDjAMBgNV
  41598. BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xNDAy
  41599. BgNVBAMMK1NTTC5jb20gRVYgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYw
  41600. MjEyMTgxNTIzWhcNNDEwMjEyMTgxNTIzWjB/MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx
  41601. EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjE0MDIGA1UEAwwrU1NM
  41602. LmNvbSBFViBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuB
  41603. BAAiA2IABKoSR5CYG/vvw0AHgyBO8TCCogbR8pKGYfL2IWjKAMTH6kMAVIbc/R/fALhBYlzccBYy
  41604. 3h+Z1MzFB8gIH2EWB1E9fVwHU+M1OIzfzZ/ZLg1KthkuWnBaBu2+8KGwytAJKaNjMGEwHQYDVR0O
  41605. BBYEFFvKXuXe0oGqzagtZFG22XKbl+ZPMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUW8pe
  41606. 5d7SgarNqC1kUbbZcpuX5k8wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2gAMGUCMQCK5kCJ
  41607. N+vp1RPZytRrJPOwPYdGWBrssd9v+1a6cGvHOMzosYxPD/fxZ3YOg9AeUY8CMD32IygmTMZgh5Mm
  41608. m7I1HrrW9zzRHM76JTymGoEVW/MSD2zuZYrJh6j5B+BimoxcSg==
  41609. -----END CERTIFICATE-----
  41610. GlobalSign Root CA - R6
  41611. =======================
  41612. -----BEGIN CERTIFICATE-----
  41613. MIIFgzCCA2ugAwIBAgIORea7A4Mzw4VlSOb/RVEwDQYJKoZIhvcNAQEMBQAwTDEgMB4GA1UECxMX
  41614. R2xvYmFsU2lnbiBSb290IENBIC0gUjYxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkds
  41615. b2JhbFNpZ24wHhcNMTQxMjEwMDAwMDAwWhcNMzQxMjEwMDAwMDAwWjBMMSAwHgYDVQQLExdHbG9i
  41616. YWxTaWduIFJvb3QgQ0EgLSBSNjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFs
  41617. U2lnbjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAJUH6HPKZvnsFMp7PPcNCPG0RQss
  41618. grRIxutbPK6DuEGSMxSkb3/pKszGsIhrxbaJ0cay/xTOURQh7ErdG1rG1ofuTToVBu1kZguSgMpE
  41619. 3nOUTvOniX9PeGMIyBJQbUJmL025eShNUhqKGoC3GYEOfsSKvGRMIRxDaNc9PIrFsmbVkJq3MQbF
  41620. vuJtMgamHvm566qjuL++gmNQ0PAYid/kD3n16qIfKtJwLnvnvJO7bVPiSHyMEAc4/2ayd2F+4OqM
  41621. PKq0pPbzlUoSB239jLKJz9CgYXfIWHSw1CM69106yqLbnQneXUQtkPGBzVeS+n68UARjNN9rkxi+
  41622. azayOeSsJDa38O+2HBNXk7besvjihbdzorg1qkXy4J02oW9UivFyVm4uiMVRQkQVlO6jxTiWm05O
  41623. WgtH8wY2SXcwvHE35absIQh1/OZhFj931dmRl4QKbNQCTXTAFO39OfuD8l4UoQSwC+n+7o/hbguy
  41624. CLNhZglqsQY6ZZZZwPA1/cnaKI0aEYdwgQqomnUdnjqGBQCe24DWJfncBZ4nWUx2OVvq+aWh2IMP
  41625. 0f/fMBH5hc8zSPXKbWQULHpYT9NLCEnFlWQaYw55PfWzjMpYrZxCRXluDocZXFSxZba/jJvcE+kN
  41626. b7gu3GduyYsRtYQUigAZcIN5kZeR1BonvzceMgfYFGM8KEyvAgMBAAGjYzBhMA4GA1UdDwEB/wQE
  41627. AwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSubAWjkxPioufi1xzWx/B/yGdToDAfBgNV
  41628. HSMEGDAWgBSubAWjkxPioufi1xzWx/B/yGdToDANBgkqhkiG9w0BAQwFAAOCAgEAgyXt6NH9lVLN
  41629. nsAEoJFp5lzQhN7craJP6Ed41mWYqVuoPId8AorRbrcWc+ZfwFSY1XS+wc3iEZGtIxg93eFyRJa0
  41630. lV7Ae46ZeBZDE1ZXs6KzO7V33EByrKPrmzU+sQghoefEQzd5Mr6155wsTLxDKZmOMNOsIeDjHfrY
  41631. BzN2VAAiKrlNIC5waNrlU/yDXNOd8v9EDERm8tLjvUYAGm0CuiVdjaExUd1URhxN25mW7xocBFym
  41632. Fe944Hn+Xds+qkxV/ZoVqW/hpvvfcDDpw+5CRu3CkwWJ+n1jez/QcYF8AOiYrg54NMMl+68KnyBr
  41633. 3TsTjxKM4kEaSHpzoHdpx7Zcf4LIHv5YGygrqGytXm3ABdJ7t+uA/iU3/gKbaKxCXcPu9czc8FB1
  41634. 0jZpnOZ7BN9uBmm23goJSFmH63sUYHpkqmlD75HHTOwY3WzvUy2MmeFe8nI+z1TIvWfspA9MRf/T
  41635. uTAjB0yPEL+GltmZWrSZVxykzLsViVO6LAUP5MSeGbEYNNVMnbrt9x+vJJUEeKgDu+6B5dpffItK
  41636. oZB0JaezPkvILFa9x8jvOOJckvB595yEunQtYQEgfn7R8k8HWV+LLUNS60YMlOH1Zkd5d9VUWx+t
  41637. JDfLRVpOoERIyNiwmcUVhAn21klJwGW45hpxbqCo8YLoRT5s1gLXCmeDBVrJpBA=
  41638. -----END CERTIFICATE-----
  41639. OISTE WISeKey Global Root GC CA
  41640. ===============================
  41641. -----BEGIN CERTIFICATE-----
  41642. MIICaTCCAe+gAwIBAgIQISpWDK7aDKtARb8roi066jAKBggqhkjOPQQDAzBtMQswCQYDVQQGEwJD
  41643. SDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNlZDEo
  41644. MCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQyBDQTAeFw0xNzA1MDkwOTQ4MzRa
  41645. Fw00MjA1MDkwOTU4MzNaMG0xCzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYDVQQL
  41646. ExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEdsb2Jh
  41647. bCBSb290IEdDIENBMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAETOlQwMYPchi82PG6s4nieUqjFqdr
  41648. VCTbUf/q9Akkwwsin8tqJ4KBDdLArzHkdIJuyiXZjHWd8dvQmqJLIX4Wp2OQ0jnUsYd4XxiWD1Ab
  41649. NTcPasbc2RNNpI6QN+a9WzGRo1QwUjAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd
  41650. BgNVHQ4EFgQUSIcUrOPDnpBgOtfKie7TrYy0UGYwEAYJKwYBBAGCNxUBBAMCAQAwCgYIKoZIzj0E
  41651. AwMDaAAwZQIwJsdpW9zV57LnyAyMjMPdeYwbY9XJUpROTYJKcx6ygISpJcBMWm1JKWB4E+J+SOtk
  41652. AjEA2zQgMgj/mkkCtojeFK9dbJlxjRo/i9fgojaGHAeCOnZT/cKi7e97sIBPWA9LUzm9
  41653. -----END CERTIFICATE-----
  41654. GTS Root R1
  41655. ===========
  41656. -----BEGIN CERTIFICATE-----
  41657. MIIFWjCCA0KgAwIBAgIQbkepxUtHDA3sM9CJuRz04TANBgkqhkiG9w0BAQwFADBHMQswCQYDVQQG
  41658. EwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJv
  41659. b3QgUjEwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAG
  41660. A1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjEwggIi
  41661. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2EQKLHuOhd5s73L+UPreVp0A8of2C+X0yBoJx
  41662. 9vaMf/vo27xqLpeXo4xL+Sv2sfnOhB2x+cWX3u+58qPpvBKJXqeqUqv4IyfLpLGcY9vXmX7wCl7r
  41663. aKb0xlpHDU0QM+NOsROjyBhsS+z8CZDfnWQpJSMHobTSPS5g4M/SCYe7zUjwTcLCeoiKu7rPWRnW
  41664. r4+wB7CeMfGCwcDfLqZtbBkOtdh+JhpFAz2weaSUKK0PfyblqAj+lug8aJRT7oM6iCsVlgmy4HqM
  41665. LnXWnOunVmSPlk9orj2XwoSPwLxAwAtcvfaHszVsrBhQf4TgTM2S0yDpM7xSma8ytSmzJSq0SPly
  41666. 4cpk9+aCEI3oncKKiPo4Zor8Y/kB+Xj9e1x3+naH+uzfsQ55lVe0vSbv1gHR6xYKu44LtcXFilWr
  41667. 06zqkUspzBmkMiVOKvFlRNACzqrOSbTqn3yDsEB750Orp2yjj32JgfpMpf/VjsPOS+C12LOORc92
  41668. wO1AK/1TD7Cn1TsNsYqiA94xrcx36m97PtbfkSIS5r762DL8EGMUUXLeXdYWk70paDPvOmbsB4om
  41669. 3xPXV2V4J95eSRQAogB/mqghtqmxlbCluQ0WEdrHbEg8QOB+DVrNVjzRlwW5y0vtOUucxD/SVRNu
  41670. JLDWcfr0wbrM7Rv1/oFB2ACYPTrIrnqYNxgFlQIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD
  41671. VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU5K8rJnEaK0gnhS9SZizv8IkTcT4wDQYJKoZIhvcNAQEM
  41672. BQADggIBADiWCu49tJYeX++dnAsznyvgyv3SjgofQXSlfKqE1OXyHuY3UjKcC9FhHb8owbZEKTV1
  41673. d5iyfNm9dKyKaOOpMQkpAWBz40d8U6iQSifvS9efk+eCNs6aaAyC58/UEBZvXw6ZXPYfcX3v73sv
  41674. fuo21pdwCxXu11xWajOl40k4DLh9+42FpLFZXvRq4d2h9mREruZRgyFmxhE+885H7pwoHyXa/6xm
  41675. ld01D1zvICxi/ZG6qcz8WpyTgYMpl0p8WnK0OdC3d8t5/Wk6kjftbjhlRn7pYL15iJdfOBL07q9b
  41676. gsiG1eGZbYwE8na6SfZu6W0eX6DvJ4J2QPim01hcDyxC2kLGe4g0x8HYRZvBPsVhHdljUEn2NIVq
  41677. 4BjFbkerQUIpm/ZgDdIx02OYI5NaAIFItO/Nis3Jz5nu2Z6qNuFoS3FJFDYoOj0dzpqPJeaAcWEr
  41678. tXvM+SUWgeExX6GjfhaknBZqlxi9dnKlC54dNuYvoS++cJEPqOba+MSSQGwlfnuzCdyyF62ARPBo
  41679. pY+Udf90WuioAnwMCeKpSwughQtiue+hMZL77/ZRBIls6Kl0obsXs7X9SQ98POyDGCBDTtWTurQ0
  41680. sR8WNh8M5mQ5Fkzc4P4dyKliPUDqysU0ArSuiYgzNdwsE3PYJ/HQcu51OyLemGhmW/HGY0dVHLql
  41681. CFF1pkgl
  41682. -----END CERTIFICATE-----
  41683. GTS Root R2
  41684. ===========
  41685. -----BEGIN CERTIFICATE-----
  41686. MIIFWjCCA0KgAwIBAgIQbkepxlqz5yDFMJo/aFLybzANBgkqhkiG9w0BAQwFADBHMQswCQYDVQQG
  41687. EwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJv
  41688. b3QgUjIwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAG
  41689. A1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjIwggIi
  41690. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDO3v2m++zsFDQ8BwZabFn3GTXd98GdVarTzTuk
  41691. k3LvCvptnfbwhYBboUhSnznFt+4orO/LdmgUud+tAWyZH8QiHZ/+cnfgLFuv5AS/T3KgGjSY6Dlo
  41692. 7JUle3ah5mm5hRm9iYz+re026nO8/4Piy33B0s5Ks40FnotJk9/BW9BuXvAuMC6C/Pq8tBcKSOWI
  41693. m8Wba96wyrQD8Nr0kLhlZPdcTK3ofmZemde4wj7I0BOdre7kRXuJVfeKH2JShBKzwkCX44ofR5Gm
  41694. dFrS+LFjKBC4swm4VndAoiaYecb+3yXuPuWgf9RhD1FLPD+M2uFwdNjCaKH5wQzpoeJ/u1U8dgbu
  41695. ak7MkogwTZq9TwtImoS1mKPV+3PBV2HdKFZ1E66HjucMUQkQdYhMvI35ezzUIkgfKtzra7tEscsz
  41696. cTJGr61K8YzodDqs5xoic4DSMPclQsciOzsSrZYuxsN2B6ogtzVJV+mSSeh2FnIxZyuWfoqjx5RW
  41697. Ir9qS34BIbIjMt/kmkRtWVtd9QCgHJvGeJeNkP+byKq0rxFROV7Z+2et1VsRnTKaG73Vululycsl
  41698. aVNVJ1zgyjbLiGH7HrfQy+4W+9OmTN6SpdTi3/UGVN4unUu0kzCqgc7dGtxRcw1PcOnlthYhGXmy
  41699. 5okLdWTK1au8CcEYof/UVKGFPP0UJAOyh9OktwIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD
  41700. VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUu//KjiOfT5nK2+JopqUVJxce2Q4wDQYJKoZIhvcNAQEM
  41701. BQADggIBALZp8KZ3/p7uC4Gt4cCpx/k1HUCCq+YEtN/L9x0Pg/B+E02NjO7jMyLDOfxA325BS0JT
  41702. vhaI8dI4XsRomRyYUpOM52jtG2pzegVATX9lO9ZY8c6DR2Dj/5epnGB3GFW1fgiTz9D2PGcDFWEJ
  41703. +YF59exTpJ/JjwGLc8R3dtyDovUMSRqodt6Sm2T4syzFJ9MHwAiApJiS4wGWAqoC7o87xdFtCjMw
  41704. c3i5T1QWvwsHoaRc5svJXISPD+AVdyx+Jn7axEvbpxZ3B7DNdehyQtaVhJ2Gg/LkkM0JR9SLA3Da
  41705. WsYDQvTtN6LwG1BUSw7YhN4ZKJmBR64JGz9I0cNv4rBgF/XuIwKl2gBbbZCr7qLpGzvpx0QnRY5r
  41706. n/WkhLx3+WuXrD5RRaIRpsyF7gpo8j5QOHokYh4XIDdtak23CZvJ/KRY9bb7nE4Yu5UC56Gtmwfu
  41707. Nmsk0jmGwZODUNKBRqhfYlcsu2xkiAhu7xNUX90txGdj08+JN7+dIPT7eoOboB6BAFDC5AwiWVIQ
  41708. 7UNWhwD4FFKnHYuTjKJNRn8nxnGbJN7k2oaLDX5rIMHAnuFl2GqjpuiFizoHCBy69Y9Vmhh1fuXs
  41709. gWbRIXOhNUQLgD1bnF5vKheW0YMjiGZt5obicDIvUiLnyOd/xCxgXS/Dr55FBcOEArf9LAhST4Ld
  41710. o/DUhgkC
  41711. -----END CERTIFICATE-----
  41712. GTS Root R3
  41713. ===========
  41714. -----BEGIN CERTIFICATE-----
  41715. MIICDDCCAZGgAwIBAgIQbkepx2ypcyRAiQ8DVd2NHTAKBggqhkjOPQQDAzBHMQswCQYDVQQGEwJV
  41716. UzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3Qg
  41717. UjMwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UE
  41718. ChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjMwdjAQBgcq
  41719. hkjOPQIBBgUrgQQAIgNiAAQfTzOHMymKoYTey8chWEGJ6ladK0uFxh1MJ7x/JlFyb+Kf1qPKzEUU
  41720. Rout736GjOyxfi//qXGdGIRFBEFVbivqJn+7kAHjSxm65FSWRQmx1WyRRK2EE46ajA2ADDL24Cej
  41721. QjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTB8Sa6oC2uhYHP
  41722. 0/EqEr24Cmf9vDAKBggqhkjOPQQDAwNpADBmAjEAgFukfCPAlaUs3L6JbyO5o91lAFJekazInXJ0
  41723. glMLfalAvWhgxeG4VDvBNhcl2MG9AjEAnjWSdIUlUfUk7GRSJFClH9voy8l27OyCbvWFGFPouOOa
  41724. KaqW04MjyaR7YbPMAuhd
  41725. -----END CERTIFICATE-----
  41726. GTS Root R4
  41727. ===========
  41728. -----BEGIN CERTIFICATE-----
  41729. MIICCjCCAZGgAwIBAgIQbkepyIuUtui7OyrYorLBmTAKBggqhkjOPQQDAzBHMQswCQYDVQQGEwJV
  41730. UzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3Qg
  41731. UjQwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UE
  41732. ChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjQwdjAQBgcq
  41733. hkjOPQIBBgUrgQQAIgNiAATzdHOnaItgrkO4NcWBMHtLSZ37wWHO5t5GvWvVYRg1rkDdc/eJkTBa
  41734. 6zzuhXyiQHY7qca4R9gq55KRanPpsXI5nymfopjTX15YhmUPoYRlBtHci8nHc8iMai/lxKvRHYqj
  41735. QjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSATNbrdP9JNqPV
  41736. 2Py1PsVq8JQdjDAKBggqhkjOPQQDAwNnADBkAjBqUFJ0CMRw3J5QdCHojXohw0+WbhXRIjVhLfoI
  41737. N+4Zba3bssx9BzT1YBkstTTZbyACMANxsbqjYAuG7ZoIapVon+Kz4ZNkfF6Tpt95LY2F45TPI11x
  41738. zPKwTdb+mciUqXWi4w==
  41739. -----END CERTIFICATE-----
  41740. UCA Global G2 Root
  41741. ==================
  41742. -----BEGIN CERTIFICATE-----
  41743. MIIFRjCCAy6gAwIBAgIQXd+x2lqj7V2+WmUgZQOQ7zANBgkqhkiG9w0BAQsFADA9MQswCQYDVQQG
  41744. EwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxGzAZBgNVBAMMElVDQSBHbG9iYWwgRzIgUm9vdDAeFw0x
  41745. NjAzMTEwMDAwMDBaFw00MDEyMzEwMDAwMDBaMD0xCzAJBgNVBAYTAkNOMREwDwYDVQQKDAhVbmlU
  41746. cnVzdDEbMBkGA1UEAwwSVUNBIEdsb2JhbCBHMiBSb290MIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  41747. MIICCgKCAgEAxeYrb3zvJgUno4Ek2m/LAfmZmqkywiKHYUGRO8vDaBsGxUypK8FnFyIdK+35KYmT
  41748. oni9kmugow2ifsqTs6bRjDXVdfkX9s9FxeV67HeToI8jrg4aA3++1NDtLnurRiNb/yzmVHqUwCoV
  41749. 8MmNsHo7JOHXaOIxPAYzRrZUEaalLyJUKlgNAQLx+hVRZ2zA+te2G3/RVogvGjqNO7uCEeBHANBS
  41750. h6v7hn4PJGtAnTRnvI3HLYZveT6OqTwXS3+wmeOwcWDcC/Vkw85DvG1xudLeJ1uK6NjGruFZfc8o
  41751. LTW4lVYa8bJYS7cSN8h8s+1LgOGN+jIjtm+3SJUIsUROhYw6AlQgL9+/V087OpAh18EmNVQg7Mc/
  41752. R+zvWr9LesGtOxdQXGLYD0tK3Cv6brxzks3sx1DoQZbXqX5t2Okdj4q1uViSukqSKwxW/YDrCPBe
  41753. KW4bHAyvj5OJrdu9o54hyokZ7N+1wxrrFv54NkzWbtA+FxyQF2smuvt6L78RHBgOLXMDj6DlNaBa
  41754. 4kx1HXHhOThTeEDMg5PXCp6dW4+K5OXgSORIskfNTip1KnvyIvbJvgmRlld6iIis7nCs+dwp4wwc
  41755. OxJORNanTrAmyPPZGpeRaOrvjUYG0lZFWJo8DA+DuAUlwznPO6Q0ibd5Ei9Hxeepl2n8pndntd97
  41756. 8XplFeRhVmUCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O
  41757. BBYEFIHEjMz15DD/pQwIX4wVZyF0Ad/fMA0GCSqGSIb3DQEBCwUAA4ICAQATZSL1jiutROTL/7lo
  41758. 5sOASD0Ee/ojL3rtNtqyzm325p7lX1iPyzcyochltq44PTUbPrw7tgTQvPlJ9Zv3hcU2tsu8+Mg5
  41759. 1eRfB70VVJd0ysrtT7q6ZHafgbiERUlMjW+i67HM0cOU2kTC5uLqGOiiHycFutfl1qnN3e92mI0A
  41760. Ds0b+gO3joBYDic/UvuUospeZcnWhNq5NXHzJsBPd+aBJ9J3O5oUb3n09tDh05S60FdRvScFDcH9
  41761. yBIw7m+NESsIndTUv4BFFJqIRNow6rSn4+7vW4LVPtateJLbXDzz2K36uGt/xDYotgIVilQsnLAX
  41762. c47QN6MUPJiVAAwpBVueSUmxX8fjy88nZY41F7dXyDDZQVu5FLbowg+UMaeUmMxq67XhJ/UQqAHo
  41763. jhJi6IjMtX9Gl8CbEGY4GjZGXyJoPd/JxhMnq1MGrKI8hgZlb7F+sSlEmqO6SWkoaY/X5V+tBIZk
  41764. bxqgDMUIYs6Ao9Dz7GjevjPHF1t/gMRMTLGmhIrDO7gJzRSBuhjjVFc2/tsvfEehOjPI+Vg7RE+x
  41765. ygKJBJYoaMVLuCaJu9YzL1DV/pqJuhgyklTGW+Cd+V7lDSKb9triyCGyYiGqhkCyLmTTX8jjfhFn
  41766. RR8F/uOi77Oos/N9j/gMHyIfLXC0uAE0djAA5SN4p1bXUB+K+wb1whnw0A==
  41767. -----END CERTIFICATE-----
  41768. UCA Extended Validation Root
  41769. ============================
  41770. -----BEGIN CERTIFICATE-----
  41771. MIIFWjCCA0KgAwIBAgIQT9Irj/VkyDOeTzRYZiNwYDANBgkqhkiG9w0BAQsFADBHMQswCQYDVQQG
  41772. EwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9u
  41773. IFJvb3QwHhcNMTUwMzEzMDAwMDAwWhcNMzgxMjMxMDAwMDAwWjBHMQswCQYDVQQGEwJDTjERMA8G
  41774. A1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9uIFJvb3QwggIi
  41775. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCpCQcoEwKwmeBkqh5DFnpzsZGgdT6o+uM4AHrs
  41776. iWogD4vFsJszA1qGxliG1cGFu0/GnEBNyr7uaZa4rYEwmnySBesFK5pI0Lh2PpbIILvSsPGP2KxF
  41777. Rv+qZ2C0d35qHzwaUnoEPQc8hQ2E0B92CvdqFN9y4zR8V05WAT558aopO2z6+I9tTcg1367r3CTu
  41778. eUWnhbYFiN6IXSV8l2RnCdm/WhUFhvMJHuxYMjMR83dksHYf5BA1FxvyDrFspCqjc/wJHx4yGVMR
  41779. 59mzLC52LqGj3n5qiAno8geK+LLNEOfic0CTuwjRP+H8C5SzJe98ptfRr5//lpr1kXuYC3fUfugH
  41780. 0mK1lTnj8/FtDw5lhIpjVMWAtuCeS31HJqcBCF3RiJ7XwzJE+oJKCmhUfzhTA8ykADNkUVkLo4KR
  41781. el7sFsLzKuZi2irbWWIQJUoqgQtHB0MGcIfS+pMRKXpITeuUx3BNr2fVUbGAIAEBtHoIppB/TuDv
  41782. B0GHr2qlXov7z1CymlSvw4m6WC31MJixNnI5fkkE/SmnTHnkBVfblLkWU41Gsx2VYVdWf6/wFlth
  41783. WG82UBEL2KwrlRYaDh8IzTY0ZRBiZtWAXxQgXy0MoHgKaNYs1+lvK9JKBZP8nm9rZ/+I8U6laUpS
  41784. NwXqxhaN0sSZ0YIrO7o1dfdRUVjzyAfd5LQDfwIDAQABo0IwQDAdBgNVHQ4EFgQU2XQ65DA9DfcS
  41785. 3H5aBZ8eNJr34RQwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQEL
  41786. BQADggIBADaNl8xCFWQpN5smLNb7rhVpLGsaGvdftvkHTFnq88nIua7Mui563MD1sC3AO6+fcAUR
  41787. ap8lTwEpcOPlDOHqWnzcSbvBHiqB9RZLcpHIojG5qtr8nR/zXUACE/xOHAbKsxSQVBcZEhrxH9cM
  41788. aVr2cXj0lH2RC47skFSOvG+hTKv8dGT9cZr4QQehzZHkPJrgmzI5c6sq1WnIeJEmMX3ixzDx/BR4
  41789. dxIOE/TdFpS/S2d7cFOFyrC78zhNLJA5wA3CXWvp4uXViI3WLL+rG761KIcSF3Ru/H38j9CHJrAb
  41790. +7lsq+KePRXBOy5nAliRn+/4Qh8st2j1da3Ptfb/EX3C8CSlrdP6oDyp+l3cpaDvRKS+1ujl5BOW
  41791. F3sGPjLtx7dCvHaj2GU4Kzg1USEODm8uNBNA4StnDG1KQTAYI1oyVZnJF+A83vbsea0rWBmirSwi
  41792. GpWOvpaQXUJXxPkUAzUrHC1RVwinOt4/5Mi0A3PCwSaAuwtCH60NryZy2sy+s6ODWA2CxR9GUeOc
  41793. GMyNm43sSet1UNWMKFnKdDTajAshqx7qG+XH/RU+wBeq+yNuJkbL+vmxcmtpzyKEC2IPrNkZAJSi
  41794. djzULZrtBJ4tBmIQN1IchXIbJ+XMxjHsN+xjWZsLHXbMfjKaiJUINlK73nZfdklJrX+9ZSCyycEr
  41795. dhh2n1ax
  41796. -----END CERTIFICATE-----
  41797. Certigna Root CA
  41798. ================
  41799. -----BEGIN CERTIFICATE-----
  41800. MIIGWzCCBEOgAwIBAgIRAMrpG4nxVQMNo+ZBbcTjpuEwDQYJKoZIhvcNAQELBQAwWjELMAkGA1UE
  41801. BhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczEcMBoGA1UECwwTMDAwMiA0ODE0NjMwODEwMDAzNjEZ
  41802. MBcGA1UEAwwQQ2VydGlnbmEgUm9vdCBDQTAeFw0xMzEwMDEwODMyMjdaFw0zMzEwMDEwODMyMjda
  41803. MFoxCzAJBgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxHDAaBgNVBAsMEzAwMDIgNDgxNDYz
  41804. MDgxMDAwMzYxGTAXBgNVBAMMEENlcnRpZ25hIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  41805. DwAwggIKAoICAQDNGDllGlmx6mQWDoyUJJV8g9PFOSbcDO8WV43X2KyjQn+Cyu3NW9sOty3tRQgX
  41806. stmzy9YXUnIo245Onoq2C/mehJpNdt4iKVzSs9IGPjA5qXSjklYcoW9MCiBtnyN6tMbaLOQdLNyz
  41807. KNAT8kxOAkmhVECe5uUFoC2EyP+YbNDrihqECB63aCPuI9Vwzm1RaRDuoXrC0SIxwoKF0vJVdlB8
  41808. JXrJhFwLrN1CTivngqIkicuQstDuI7pmTLtipPlTWmR7fJj6o0ieD5Wupxj0auwuA0Wv8HT4Ks16
  41809. XdG+RCYyKfHx9WzMfgIhC59vpD++nVPiz32pLHxYGpfhPTc3GGYo0kDFUYqMwy3OU4gkWGQwFsWq
  41810. 4NYKpkDfePb1BHxpE4S80dGnBs8B92jAqFe7OmGtBIyT46388NtEbVncSVmurJqZNjBBe3YzIoej
  41811. wpKGbvlw7q6Hh5UbxHq9MfPU0uWZ/75I7HX1eBYdpnDBfzwboZL7z8g81sWTCo/1VTp2lc5ZmIoJ
  41812. lXcymoO6LAQ6l73UL77XbJuiyn1tJslV1c/DeVIICZkHJC1kJWumIWmbat10TWuXekG9qxf5kBdI
  41813. jzb5LdXF2+6qhUVB+s06RbFo5jZMm5BX7CO5hwjCxAnxl4YqKE3idMDaxIzb3+KhF1nOJFl0Mdp/
  41814. /TBt2dzhauH8XwIDAQABo4IBGjCCARYwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYw
  41815. HQYDVR0OBBYEFBiHVuBud+4kNTxOc5of1uHieX4rMB8GA1UdIwQYMBaAFBiHVuBud+4kNTxOc5of
  41816. 1uHieX4rMEQGA1UdIAQ9MDswOQYEVR0gADAxMC8GCCsGAQUFBwIBFiNodHRwczovL3d3d3cuY2Vy
  41817. dGlnbmEuZnIvYXV0b3JpdGVzLzBtBgNVHR8EZjBkMC+gLaArhilodHRwOi8vY3JsLmNlcnRpZ25h
  41818. LmZyL2NlcnRpZ25hcm9vdGNhLmNybDAxoC+gLYYraHR0cDovL2NybC5kaGlteW90aXMuY29tL2Nl
  41819. cnRpZ25hcm9vdGNhLmNybDANBgkqhkiG9w0BAQsFAAOCAgEAlLieT/DjlQgi581oQfccVdV8AOIt
  41820. OoldaDgvUSILSo3L6btdPrtcPbEo/uRTVRPPoZAbAh1fZkYJMyjhDSSXcNMQH+pkV5a7XdrnxIxP
  41821. TGRGHVyH41neQtGbqH6mid2PHMkwgu07nM3A6RngatgCdTer9zQoKJHyBApPNeNgJgH60BGM+RFq
  41822. 7q89w1DTj18zeTyGqHNFkIwgtnJzFyO+B2XleJINugHA64wcZr+shncBlA2c5uk5jR+mUYyZDDl3
  41823. 4bSb+hxnV29qao6pK0xXeXpXIs/NX2NGjVxZOob4Mkdio2cNGJHc+6Zr9UhhcyNZjgKnvETq9Emd
  41824. 8VRY+WCv2hikLyhF3HqgiIZd8zvn/yk1gPxkQ5Tm4xxvvq0OKmOZK8l+hfZx6AYDlf7ej0gcWtSS
  41825. 6Cvu5zHbugRqh5jnxV/vfaci9wHYTfmJ0A6aBVmknpjZbyvKcL5kwlWj9Omvw5Ip3IgWJJk8jSaY
  41826. tlu3zM63Nwf9JtmYhST/WSMDmu2dnajkXjjO11INb9I/bbEFa0nOipFGc/T2L/Coc3cOZayhjWZS
  41827. aX5LaAzHHjcng6WMxwLkFM1JAbBzs/3GkDpv0mztO+7skb6iQ12LAEpmJURw3kAP+HwV96LOPNde
  41828. E4yBFxgX0b3xdxA61GU5wSesVywlVP+i2k+KYTlerj1KjL0=
  41829. -----END CERTIFICATE-----
  41830. emSign Root CA - G1
  41831. ===================
  41832. -----BEGIN CERTIFICATE-----
  41833. MIIDlDCCAnygAwIBAgIKMfXkYgxsWO3W2DANBgkqhkiG9w0BAQsFADBnMQswCQYDVQQGEwJJTjET
  41834. MBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRl
  41835. ZDEcMBoGA1UEAxMTZW1TaWduIFJvb3QgQ0EgLSBHMTAeFw0xODAyMTgxODMwMDBaFw00MzAyMTgx
  41836. ODMwMDBaMGcxCzAJBgNVBAYTAklOMRMwEQYDVQQLEwplbVNpZ24gUEtJMSUwIwYDVQQKExxlTXVk
  41837. aHJhIFRlY2hub2xvZ2llcyBMaW1pdGVkMRwwGgYDVQQDExNlbVNpZ24gUm9vdCBDQSAtIEcxMIIB
  41838. IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk0u76WaK7p1b1TST0Bsew+eeuGQzf2N4aLTN
  41839. LnF115sgxk0pvLZoYIr3IZpWNVrzdr3YzZr/k1ZLpVkGoZM0Kd0WNHVO8oG0x5ZOrRkVUkr+PHB1
  41840. cM2vK6sVmjM8qrOLqs1D/fXqcP/tzxE7lM5OMhbTI0Aqd7OvPAEsbO2ZLIvZTmmYsvePQbAyeGHW
  41841. DV/D+qJAkh1cF+ZwPjXnorfCYuKrpDhMtTk1b+oDafo6VGiFbdbyL0NVHpENDtjVaqSW0RM8LHhQ
  41842. 6DqS0hdW5TUaQBw+jSztOd9C4INBdN+jzcKGYEho42kLVACL5HZpIQ15TjQIXhTCzLG3rdd8cIrH
  41843. hQIDAQABo0IwQDAdBgNVHQ4EFgQU++8Nhp6w492pufEhF38+/PB3KxowDgYDVR0PAQH/BAQDAgEG
  41844. MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAFn/8oz1h31xPaOfG1vR2vjTnGs2
  41845. vZupYeveFix0PZ7mddrXuqe8QhfnPZHr5X3dPpzxz5KsbEjMwiI/aTvFthUvozXGaCocV685743Q
  41846. NcMYDHsAVhzNixl03r4PEuDQqqE/AjSxcM6dGNYIAwlG7mDgfrbESQRRfXBgvKqy/3lyeqYdPV8q
  41847. +Mri/Tm3R7nrft8EI6/6nAYH6ftjk4BAtcZsCjEozgyfz7MjNYBBjWzEN3uBL4ChQEKF6dk4jeih
  41848. U80Bv2noWgbyRQuQ+q7hv53yrlc8pa6yVvSLZUDp/TGBLPQ5Cdjua6e0ph0VpZj3AYHYhX3zUVxx
  41849. iN66zB+Afko=
  41850. -----END CERTIFICATE-----
  41851. emSign ECC Root CA - G3
  41852. =======================
  41853. -----BEGIN CERTIFICATE-----
  41854. MIICTjCCAdOgAwIBAgIKPPYHqWhwDtqLhDAKBggqhkjOPQQDAzBrMQswCQYDVQQGEwJJTjETMBEG
  41855. A1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRlZDEg
  41856. MB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0gRzMwHhcNMTgwMjE4MTgzMDAwWhcNNDMwMjE4
  41857. MTgzMDAwWjBrMQswCQYDVQQGEwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11
  41858. ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0g
  41859. RzMwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQjpQy4LRL1KPOxst3iAhKAnjlfSU2fySU0WXTsuwYc
  41860. 58Byr+iuL+FBVIcUqEqy6HyC5ltqtdyzdc6LBtCGI79G1Y4PPwT01xySfvalY8L1X44uT6EYGQIr
  41861. MgqCZH0Wk9GjQjBAMB0GA1UdDgQWBBR8XQKEE9TMipuBzhccLikenEhjQjAOBgNVHQ8BAf8EBAMC
  41862. AQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNpADBmAjEAvvNhzwIQHWSVB7gYboiFBS+D
  41863. CBeQyh+KTOgNG3qxrdWBCUfvO6wIBHxcmbHtRwfSAjEAnbpV/KlK6O3t5nYBQnvI+GDZjVGLVTv7
  41864. jHvrZQnD+JbNR6iC8hZVdyR+EhCVBCyj
  41865. -----END CERTIFICATE-----
  41866. emSign Root CA - C1
  41867. ===================
  41868. -----BEGIN CERTIFICATE-----
  41869. MIIDczCCAlugAwIBAgILAK7PALrEzzL4Q7IwDQYJKoZIhvcNAQELBQAwVjELMAkGA1UEBhMCVVMx
  41870. EzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQDExNlbVNp
  41871. Z24gUm9vdCBDQSAtIEMxMB4XDTE4MDIxODE4MzAwMFoXDTQzMDIxODE4MzAwMFowVjELMAkGA1UE
  41872. BhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQD
  41873. ExNlbVNpZ24gUm9vdCBDQSAtIEMxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz+up
  41874. ufGZBczYKCFK83M0UYRWEPWgTywS4/oTmifQz/l5GnRfHXk5/Fv4cI7gklL35CX5VIPZHdPIWoU/
  41875. Xse2B+4+wM6ar6xWQio5JXDWv7V7Nq2s9nPczdcdioOl+yuQFTdrHCZH3DspVpNqs8FqOp099cGX
  41876. OFgFixwR4+S0uF2FHYP+eF8LRWgYSKVGczQ7/g/IdrvHGPMF0Ybzhe3nudkyrVWIzqa2kbBPrH4V
  41877. I5b2P/AgNBbeCsbEBEV5f6f9vtKppa+cxSMq9zwhbL2vj07FOrLzNBL834AaSaTUqZX3noleooms
  41878. lMuoaJuvimUnzYnu3Yy1aylwQ6BpC+S5DwIDAQABo0IwQDAdBgNVHQ4EFgQU/qHgcB4qAzlSWkK+
  41879. XJGFehiqTbUwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQAD
  41880. ggEBAMJKVvoVIXsoounlHfv4LcQ5lkFMOycsxGwYFYDGrK9HWS8mC+M2sO87/kOXSTKZEhVb3xEp
  41881. /6tT+LvBeA+snFOvV71ojD1pM/CjoCNjO2RnIkSt1XHLVip4kqNPEjE2NuLe/gDEo2APJ62gsIq1
  41882. NnpSob0n9CAnYuhNlCQT5AoE6TyrLshDCUrGYQTlSTR+08TI9Q/Aqum6VF7zYytPT1DU/rl7mYw9
  41883. wC68AivTxEDkigcxHpvOJpkT+xHqmiIMERnHXhuBUDDIlhJu58tBf5E7oke3VIAb3ADMmpDqw8NQ
  41884. BmIMMMAVSKeoWXzhriKi4gp6D/piq1JM4fHfyr6DDUI=
  41885. -----END CERTIFICATE-----
  41886. emSign ECC Root CA - C3
  41887. =======================
  41888. -----BEGIN CERTIFICATE-----
  41889. MIICKzCCAbGgAwIBAgIKe3G2gla4EnycqDAKBggqhkjOPQQDAzBaMQswCQYDVQQGEwJVUzETMBEG
  41890. A1UECxMKZW1TaWduIFBLSTEUMBIGA1UEChMLZU11ZGhyYSBJbmMxIDAeBgNVBAMTF2VtU2lnbiBF
  41891. Q0MgUm9vdCBDQSAtIEMzMB4XDTE4MDIxODE4MzAwMFoXDTQzMDIxODE4MzAwMFowWjELMAkGA1UE
  41892. BhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMSAwHgYDVQQD
  41893. ExdlbVNpZ24gRUNDIFJvb3QgQ0EgLSBDMzB2MBAGByqGSM49AgEGBSuBBAAiA2IABP2lYa57JhAd
  41894. 6bciMK4G9IGzsUJxlTm801Ljr6/58pc1kjZGDoeVjbk5Wum739D+yAdBPLtVb4OjavtisIGJAnB9
  41895. SMVK4+kiVCJNk7tCDK93nCOmfddhEc5lx/h//vXyqaNCMEAwHQYDVR0OBBYEFPtaSNCAIEDyqOkA
  41896. B2kZd6fmw/TPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MAoGCCqGSM49BAMDA2gA
  41897. MGUCMQC02C8Cif22TGK6Q04ThHK1rt0c3ta13FaPWEBaLd4gTCKDypOofu4SQMfWh0/434UCMBwU
  41898. ZOR8loMRnLDRWmFLpg9J0wD8ofzkpf9/rdcw0Md3f76BB1UwUCAU9Vc4CqgxUQ==
  41899. -----END CERTIFICATE-----
  41900. Hongkong Post Root CA 3
  41901. =======================
  41902. -----BEGIN CERTIFICATE-----
  41903. MIIFzzCCA7egAwIBAgIUCBZfikyl7ADJk0DfxMauI7gcWqQwDQYJKoZIhvcNAQELBQAwbzELMAkG
  41904. A1UEBhMCSEsxEjAQBgNVBAgTCUhvbmcgS29uZzESMBAGA1UEBxMJSG9uZyBLb25nMRYwFAYDVQQK
  41905. Ew1Ib25na29uZyBQb3N0MSAwHgYDVQQDExdIb25na29uZyBQb3N0IFJvb3QgQ0EgMzAeFw0xNzA2
  41906. MDMwMjI5NDZaFw00MjA2MDMwMjI5NDZaMG8xCzAJBgNVBAYTAkhLMRIwEAYDVQQIEwlIb25nIEtv
  41907. bmcxEjAQBgNVBAcTCUhvbmcgS29uZzEWMBQGA1UEChMNSG9uZ2tvbmcgUG9zdDEgMB4GA1UEAxMX
  41908. SG9uZ2tvbmcgUG9zdCBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCz
  41909. iNfqzg8gTr7m1gNt7ln8wlffKWihgw4+aMdoWJwcYEuJQwy51BWy7sFOdem1p+/l6TWZ5Mwc50tf
  41910. jTMwIDNT2aa71T4Tjukfh0mtUC1Qyhi+AViiE3CWu4mIVoBc+L0sPOFMV4i707mV78vH9toxdCim
  41911. 5lSJ9UExyuUmGs2C4HDaOym71QP1mbpV9WTRYA6ziUm4ii8F0oRFKHyPaFASePwLtVPLwpgchKOe
  41912. sL4jpNrcyCse2m5FHomY2vkALgbpDDtw1VAliJnLzXNg99X/NWfFobxeq81KuEXryGgeDQ0URhLj
  41913. 0mRiikKYvLTGCAj4/ahMZJx2Ab0vqWwzD9g/KLg8aQFChn5pwckGyuV6RmXpwtZQQS4/t+TtbNe/
  41914. JgERohYpSms0BpDsE9K2+2p20jzt8NYt3eEV7KObLyzJPivkaTv/ciWxNoZbx39ri1UbSsUgYT2u
  41915. y1DhCDq+sI9jQVMwCFk8mB13umOResoQUGC/8Ne8lYePl8X+l2oBlKN8W4UdKjk60FSh0Tlxnf0h
  41916. +bV78OLgAo9uliQlLKAeLKjEiafv7ZkGL7YKTE/bosw3Gq9HhS2KX8Q0NEwA/RiTZxPRN+ZItIsG
  41917. xVd7GYYKecsAyVKvQv83j+GjHno9UKtjBucVtT+2RTeUN7F+8kjDf8V1/peNRY8apxpyKBpADwID
  41918. AQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAfBgNVHSMEGDAWgBQXnc0e
  41919. i9Y5K3DTXNSguB+wAPzFYTAdBgNVHQ4EFgQUF53NHovWOStw01zUoLgfsAD8xWEwDQYJKoZIhvcN
  41920. AQELBQADggIBAFbVe27mIgHSQpsY1Q7XZiNc4/6gx5LS6ZStS6LG7BJ8dNVI0lkUmcDrudHr9Egw
  41921. W62nV3OZqdPlt9EuWSRY3GguLmLYauRwCy0gUCCkMpXRAJi70/33MvJJrsZ64Ee+bs7Lo3I6LWld
  41922. y8joRTnU+kLBEUx3XZL7av9YROXrgZ6voJmtvqkBZss4HTzfQx/0TW60uhdG/H39h4F5ag0zD/ov
  41923. +BS5gLNdTaqX4fnkGMX41TiMJjz98iji7lpJiCzfeT2OnpA8vUFKOt1b9pq0zj8lMH8yfaIDlNDc
  41924. eqFS3m6TjRgm/VWsvY+b0s+v54Ysyx8Jb6NvqYTUc79NoXQbTiNg8swOqn+knEwlqLJmOzj/2ZQw
  41925. 9nKEvmhVEA/GcywWaZMH/rFF7buiVWqw2rVKAiUnhde3t4ZEFolsgCs+l6mc1X5VTMbeRRAc6uk7
  41926. nwNT7u56AQIWeNTowr5GdogTPyK7SBIdUgC0An4hGh6cJfTzPV4e0hz5sy229zdcxsshTrD3mUcY
  41927. hcErulWuBurQB7Lcq9CClnXO0lD+mefPL5/ndtFhKvshuzHQqp9HpLIiyhY6UFfEW0NnxWViA0kB
  41928. 60PZ2Pierc+xYw5F9KBaLJstxabArahH9CdMOA0uG0k7UvToiIMrVCjU8jVStDKDYmlkDJGcn5fq
  41929. dBb9HxEGmpv0
  41930. -----END CERTIFICATE-----
  41931. Entrust Root Certification Authority - G4
  41932. =========================================
  41933. -----BEGIN CERTIFICATE-----
  41934. MIIGSzCCBDOgAwIBAgIRANm1Q3+vqTkPAAAAAFVlrVgwDQYJKoZIhvcNAQELBQAwgb4xCzAJBgNV
  41935. BAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3Qu
  41936. bmV0L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxNSBFbnRydXN0LCBJbmMuIC0gZm9yIGF1
  41937. dGhvcml6ZWQgdXNlIG9ubHkxMjAwBgNVBAMTKUVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1
  41938. dGhvcml0eSAtIEc0MB4XDTE1MDUyNzExMTExNloXDTM3MTIyNzExNDExNlowgb4xCzAJBgNVBAYT
  41939. AlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0
  41940. L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxNSBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhv
  41941. cml6ZWQgdXNlIG9ubHkxMjAwBgNVBAMTKUVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhv
  41942. cml0eSAtIEc0MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAsewsQu7i0TD/pZJH4i3D
  41943. umSXbcr3DbVZwbPLqGgZ2K+EbTBwXX7zLtJTmeH+H17ZSK9dE43b/2MzTdMAArzE+NEGCJR5WIoV
  41944. 3imz/f3ET+iq4qA7ec2/a0My3dl0ELn39GjUu9CH1apLiipvKgS1sqbHoHrmSKvS0VnM1n4j5pds
  41945. 8ELl3FFLFUHtSUrJ3hCX1nbB76W1NhSXNdh4IjVS70O92yfbYVaCNNzLiGAMC1rlLAHGVK/XqsEQ
  41946. e9IFWrhAnoanw5CGAlZSCXqc0ieCU0plUmr1POeo8pyvi73TDtTUXm6Hnmo9RR3RXRv06QqsYJn7
  41947. ibT/mCzPfB3pAqoEmh643IhuJbNsZvc8kPNXwbMv9W3y+8qh+CmdRouzavbmZwe+LGcKKh9asj5X
  41948. xNMhIWNlUpEbsZmOeX7m640A2Vqq6nPopIICR5b+W45UYaPrL0swsIsjdXJ8ITzI9vF01Bx7owVV
  41949. 7rtNOzK+mndmnqxpkCIHH2E6lr7lmk/MBTwoWdPBDFSoWWG9yHJM6Nyfh3+9nEg2XpWjDrk4JFX8
  41950. dWbrAuMINClKxuMrLzOg2qOGpRKX/YAr2hRC45K9PvJdXmd0LhyIRyk0X+IyqJwlN4y6mACXi0mW
  41951. Hv0liqzc2thddG5msP9E36EYxr5ILzeUePiVSj9/E15dWf10hkNjc0kCAwEAAaNCMEAwDwYDVR0T
  41952. AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJ84xFYjwznooHFs6FRM5Og6sb9n
  41953. MA0GCSqGSIb3DQEBCwUAA4ICAQAS5UKme4sPDORGpbZgQIeMJX6tuGguW8ZAdjwD+MlZ9POrYs4Q
  41954. jbRaZIxowLByQzTSGwv2LFPSypBLhmb8qoMi9IsabyZIrHZ3CL/FmFz0Jomee8O5ZDIBf9PD3Vht
  41955. 7LGrhFV0d4QEJ1JrhkzO3bll/9bGXp+aEJlLdWr+aumXIOTkdnrG0CSqkM0gkLpHZPt/B7NTeLUK
  41956. YvJzQ85BK4FqLoUWlFPUa19yIqtRLULVAJyZv967lDtX/Zr1hstWO1uIAeV8KEsD+UmDfLJ/fOPt
  41957. jqF/YFOOVZ1QNBIPt5d7bIdKROf1beyAN/BYGW5KaHbwH5Lk6rWS02FREAutp9lfx1/cH6NcjKF+
  41958. m7ee01ZvZl4HliDtC3T7Zk6LERXpgUl+b7DUUH8i119lAg2m9IUe2K4GS0qn0jFmwvjO5QimpAKW
  41959. RGhXxNUzzxkvFMSUHHuk2fCfDrGA4tGeEWSpiBE6doLlYsKA2KSD7ZPvfC+QsDJMlhVoSFLUmQjA
  41960. JOgc47OlIQ6SwJAfzyBfyjs4x7dtOvPmRLgOMWuIjnDrnBdSqEGULoe256YSxXXfW8AKbnuk5F6G
  41961. +TaU33fD6Q3AOfF5u0aOq0NZJ7cguyPpVkAh7DE9ZapD8j3fcEThuk0mEDuYn/PIjhs4ViFqUZPT
  41962. kcpG2om3PVODLAgfi49T3f+sHw==
  41963. -----END CERTIFICATE-----
  41964. Microsoft ECC Root Certificate Authority 2017
  41965. =============================================
  41966. -----BEGIN CERTIFICATE-----
  41967. MIICWTCCAd+gAwIBAgIQZvI9r4fei7FK6gxXMQHC7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV
  41968. UzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNyb3NvZnQgRUND
  41969. IFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwHhcNMTkxMjE4MjMwNjQ1WhcNNDIwNzE4
  41970. MjMxNjA0WjBlMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYw
  41971. NAYDVQQDEy1NaWNyb3NvZnQgRUNDIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwdjAQ
  41972. BgcqhkjOPQIBBgUrgQQAIgNiAATUvD0CQnVBEyPNgASGAlEvaqiBYgtlzPbKnR5vSmZRogPZnZH6
  41973. thaxjG7efM3beaYvzrvOcS/lpaso7GMEZpn4+vKTEAXhgShC48Zo9OYbhGBKia/teQ87zvH2RPUB
  41974. eMCjVDBSMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTIy5lycFIM
  41975. +Oa+sgRXKSrPQhDtNTAQBgkrBgEEAYI3FQEEAwIBADAKBggqhkjOPQQDAwNoADBlAjBY8k3qDPlf
  41976. Xu5gKcs68tvWMoQZP3zVL8KxzJOuULsJMsbG7X7JNpQS5GiFBqIb0C8CMQCZ6Ra0DvpWSNSkMBaR
  41977. eNtUjGUBiudQZsIxtzm6uBoiB078a1QWIP8rtedMDE2mT3M=
  41978. -----END CERTIFICATE-----
  41979. Microsoft RSA Root Certificate Authority 2017
  41980. =============================================
  41981. -----BEGIN CERTIFICATE-----
  41982. MIIFqDCCA5CgAwIBAgIQHtOXCV/YtLNHcB6qvn9FszANBgkqhkiG9w0BAQwFADBlMQswCQYDVQQG
  41983. EwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNyb3NvZnQg
  41984. UlNBIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwHhcNMTkxMjE4MjI1MTIyWhcNNDIw
  41985. NzE4MjMwMDIzWjBlMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9u
  41986. MTYwNAYDVQQDEy1NaWNyb3NvZnQgUlNBIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcw
  41987. ggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKW76UM4wplZEWCpW9R2LBifOZNt9GkMml
  41988. 7Xhqb0eRaPgnZ1AzHaGm++DlQ6OEAlcBXZxIQIJTELy/xztokLaCLeX0ZdDMbRnMlfl7rEqUrQ7e
  41989. S0MdhweSE5CAg2Q1OQT85elss7YfUJQ4ZVBcF0a5toW1HLUX6NZFndiyJrDKxHBKrmCk3bPZ7Pw7
  41990. 1VdyvD/IybLeS2v4I2wDwAW9lcfNcztmgGTjGqwu+UcF8ga2m3P1eDNbx6H7JyqhtJqRjJHTOoI+
  41991. dkC0zVJhUXAoP8XFWvLJjEm7FFtNyP9nTUwSlq31/niol4fX/V4ggNyhSyL71Imtus5Hl0dVe49F
  41992. yGcohJUcaDDv70ngNXtk55iwlNpNhTs+VcQor1fznhPbRiefHqJeRIOkpcrVE7NLP8TjwuaGYaRS
  41993. MLl6IE9vDzhTyzMMEyuP1pq9KsgtsRx9S1HKR9FIJ3Jdh+vVReZIZZ2vUpC6W6IYZVcSn2i51BVr
  41994. lMRpIpj0M+Dt+VGOQVDJNE92kKz8OMHY4Xu54+OU4UZpyw4KUGsTuqwPN1q3ErWQgR5WrlcihtnJ
  41995. 0tHXUeOrO8ZV/R4O03QK0dqq6mm4lyiPSMQH+FJDOvTKVTUssKZqwJz58oHhEmrARdlns87/I6KJ
  41996. ClTUFLkqqNfs+avNJVgyeY+QW5g5xAgGwax/Dj0ApQIDAQABo1QwUjAOBgNVHQ8BAf8EBAMCAYYw
  41997. DwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUCctZf4aycI8awznjwNnpv7tNsiMwEAYJKwYBBAGC
  41998. NxUBBAMCAQAwDQYJKoZIhvcNAQEMBQADggIBAKyvPl3CEZaJjqPnktaXFbgToqZCLgLNFgVZJ8og
  41999. 6Lq46BrsTaiXVq5lQ7GPAJtSzVXNUzltYkyLDVt8LkS/gxCP81OCgMNPOsduET/m4xaRhPtthH80
  42000. dK2Jp86519efhGSSvpWhrQlTM93uCupKUY5vVau6tZRGrox/2KJQJWVggEbbMwSubLWYdFQl3JPk
  42001. +ONVFT24bcMKpBLBaYVu32TxU5nhSnUgnZUP5NbcA/FZGOhHibJXWpS2qdgXKxdJ5XbLwVaZOjex
  42002. /2kskZGT4d9Mozd2TaGf+G0eHdP67Pv0RR0Tbc/3WeUiJ3IrhvNXuzDtJE3cfVa7o7P4NHmJweDy
  42003. AmH3pvwPuxwXC65B2Xy9J6P9LjrRk5Sxcx0ki69bIImtt2dmefU6xqaWM/5TkshGsRGRxpl/j8nW
  42004. ZjEgQRCHLQzWwa80mMpkg/sTV9HB8Dx6jKXB/ZUhoHHBk2dxEuqPiAppGWSZI1b7rCoucL5mxAyE
  42005. 7+WL85MB+GqQk2dLsmijtWKP6T+MejteD+eMuMZ87zf9dOLITzNy4ZQ5bb0Sr74MTnB8G2+NszKT
  42006. c0QWbej09+CVgI+WXTik9KveCjCHk9hNAHFiRSdLOkKEW39lt2c0Ui2cFmuqqNh7o0JMcccMyj6D
  42007. 5KbvtwEwXlGjefVwaaZBRA+GsCyRxj3qrg+E
  42008. -----END CERTIFICATE-----
  42009. e-Szigno Root CA 2017
  42010. =====================
  42011. -----BEGIN CERTIFICATE-----
  42012. MIICQDCCAeWgAwIBAgIMAVRI7yH9l1kN9QQKMAoGCCqGSM49BAMCMHExCzAJBgNVBAYTAkhVMREw
  42013. DwYDVQQHDAhCdWRhcGVzdDEWMBQGA1UECgwNTWljcm9zZWMgTHRkLjEXMBUGA1UEYQwOVkFUSFUt
  42014. MjM1ODQ0OTcxHjAcBgNVBAMMFWUtU3ppZ25vIFJvb3QgQ0EgMjAxNzAeFw0xNzA4MjIxMjA3MDZa
  42015. Fw00MjA4MjIxMjA3MDZaMHExCzAJBgNVBAYTAkhVMREwDwYDVQQHDAhCdWRhcGVzdDEWMBQGA1UE
  42016. CgwNTWljcm9zZWMgTHRkLjEXMBUGA1UEYQwOVkFUSFUtMjM1ODQ0OTcxHjAcBgNVBAMMFWUtU3pp
  42017. Z25vIFJvb3QgQ0EgMjAxNzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABJbcPYrYsHtvxie+RJCx
  42018. s1YVe45DJH0ahFnuY2iyxl6H0BVIHqiQrb1TotreOpCmYF9oMrWGQd+HWyx7xf58etqjYzBhMA8G
  42019. A1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBSHERUI0arBeAyxr87GyZDv
  42020. vzAEwDAfBgNVHSMEGDAWgBSHERUI0arBeAyxr87GyZDvvzAEwDAKBggqhkjOPQQDAgNJADBGAiEA
  42021. tVfd14pVCzbhhkT61NlojbjcI4qKDdQvfepz7L9NbKgCIQDLpbQS+ue16M9+k/zzNY9vTlp8tLxO
  42022. svxyqltZ+efcMQ==
  42023. -----END CERTIFICATE-----
  42024. certSIGN Root CA G2
  42025. ===================
  42026. -----BEGIN CERTIFICATE-----
  42027. MIIFRzCCAy+gAwIBAgIJEQA0tk7GNi02MA0GCSqGSIb3DQEBCwUAMEExCzAJBgNVBAYTAlJPMRQw
  42028. EgYDVQQKEwtDRVJUU0lHTiBTQTEcMBoGA1UECxMTY2VydFNJR04gUk9PVCBDQSBHMjAeFw0xNzAy
  42029. MDYwOTI3MzVaFw00MjAyMDYwOTI3MzVaMEExCzAJBgNVBAYTAlJPMRQwEgYDVQQKEwtDRVJUU0lH
  42030. TiBTQTEcMBoGA1UECxMTY2VydFNJR04gUk9PVCBDQSBHMjCCAiIwDQYJKoZIhvcNAQEBBQADggIP
  42031. ADCCAgoCggIBAMDFdRmRfUR0dIf+DjuW3NgBFszuY5HnC2/OOwppGnzC46+CjobXXo9X69MhWf05
  42032. N0IwvlDqtg+piNguLWkh59E3GE59kdUWX2tbAMI5Qw02hVK5U2UPHULlj88F0+7cDBrZuIt4Imfk
  42033. abBoxTzkbFpG583H+u/E7Eu9aqSs/cwoUe+StCmrqzWaTOTECMYmzPhpn+Sc8CnTXPnGFiWeI8Mg
  42034. wT0PPzhAsP6CRDiqWhqKa2NYOLQV07YRaXseVO6MGiKscpc/I1mbySKEwQdPzH/iV8oScLumZfNp
  42035. dWO9lfsbl83kqK/20U6o2YpxJM02PbyWxPFsqa7lzw1uKA2wDrXKUXt4FMMgL3/7FFXhEZn91Qqh
  42036. ngLjYl/rNUssuHLoPj1PrCy7Lobio3aP5ZMqz6WryFyNSwb/EkaseMsUBzXgqd+L6a8VTxaJW732
  42037. jcZZroiFDsGJ6x9nxUWO/203Nit4ZoORUSs9/1F3dmKh7Gc+PoGD4FapUB8fepmrY7+EF3fxDTvf
  42038. 95xhszWYijqy7DwaNz9+j5LP2RIUZNoQAhVB/0/E6xyjyfqZ90bp4RjZsbgyLcsUDFDYg2WD7rlc
  42039. z8sFWkz6GZdr1l0T08JcVLwyc6B49fFtHsufpaafItzRUZ6CeWRgKRM+o/1Pcmqr4tTluCRVLERL
  42040. iohEnMqE0yo7AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1Ud
  42041. DgQWBBSCIS1mxteg4BXrzkwJd8RgnlRuAzANBgkqhkiG9w0BAQsFAAOCAgEAYN4auOfyYILVAzOB
  42042. ywaK8SJJ6ejqkX/GM15oGQOGO0MBzwdw5AgeZYWR5hEit/UCI46uuR59H35s5r0l1ZUa8gWmr4UC
  42043. b6741jH/JclKyMeKqdmfS0mbEVeZkkMR3rYzpMzXjWR91M08KCy0mpbqTfXERMQlqiCA2ClV9+BB
  42044. /AYm/7k29UMUA2Z44RGx2iBfRgB4ACGlHgAoYXhvqAEBj500mv/0OJD7uNGzcgbJceaBxXntC6Z5
  42045. 8hMLnPddDnskk7RI24Zf3lCGeOdA5jGokHZwYa+cNywRtYK3qq4kNFtyDGkNzVmf9nGvnAvRCjj5
  42046. BiKDUyUM/FHE5r7iOZULJK2v0ZXkltd0ZGtxTgI8qoXzIKNDOXZbbFD+mpwUHmUUihW9o4JFWklW
  42047. atKcsWMy5WHgUyIOpwpJ6st+H6jiYoD2EEVSmAYY3qXNL3+q1Ok+CHLsIwMCPKaq2LxndD0UF/tU
  42048. Sxfj03k9bWtJySgOLnRQvwzZRjoQhsmnP+mg7H/rpXdYaXHmgwo38oZJar55CJD2AhZkPuXaTH4M
  42049. NMn5X7azKFGnpyuqSfqNZSlO42sTp5SjLVFteAxEy9/eCG/Oo2Sr05WE1LlSVHJ7liXMvGnjSG4N
  42050. 0MedJ5qq+BOS3R7fY581qRY27Iy4g/Q9iY/NtBde17MXQRBdJ3NghVdJIgc=
  42051. -----END CERTIFICATE-----
  42052. Trustwave Global Certification Authority
  42053. ========================================
  42054. -----BEGIN CERTIFICATE-----
  42055. MIIF2jCCA8KgAwIBAgIMBfcOhtpJ80Y1LrqyMA0GCSqGSIb3DQEBCwUAMIGIMQswCQYDVQQGEwJV
  42056. UzERMA8GA1UECAwISWxsaW5vaXMxEDAOBgNVBAcMB0NoaWNhZ28xITAfBgNVBAoMGFRydXN0d2F2
  42057. ZSBIb2xkaW5ncywgSW5jLjExMC8GA1UEAwwoVHJ1c3R3YXZlIEdsb2JhbCBDZXJ0aWZpY2F0aW9u
  42058. IEF1dGhvcml0eTAeFw0xNzA4MjMxOTM0MTJaFw00MjA4MjMxOTM0MTJaMIGIMQswCQYDVQQGEwJV
  42059. UzERMA8GA1UECAwISWxsaW5vaXMxEDAOBgNVBAcMB0NoaWNhZ28xITAfBgNVBAoMGFRydXN0d2F2
  42060. ZSBIb2xkaW5ncywgSW5jLjExMC8GA1UEAwwoVHJ1c3R3YXZlIEdsb2JhbCBDZXJ0aWZpY2F0aW9u
  42061. IEF1dGhvcml0eTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBALldUShLPDeS0YLOvR29
  42062. zd24q88KPuFd5dyqCblXAj7mY2Hf8g+CY66j96xz0XznswuvCAAJWX/NKSqIk4cXGIDtiLK0thAf
  42063. LdZfVaITXdHG6wZWiYj+rDKd/VzDBcdu7oaJuogDnXIhhpCujwOl3J+IKMujkkkP7NAP4m1ET4Bq
  42064. stTnoApTAbqOl5F2brz81Ws25kCI1nsvXwXoLG0R8+eyvpJETNKXpP7ScoFDB5zpET71ixpZfR9o
  42065. WN0EACyW80OzfpgZdNmcc9kYvkHHNHnZ9GLCQ7mzJ7Aiy/k9UscwR7PJPrhq4ufogXBeQotPJqX+
  42066. OsIgbrv4Fo7NDKm0G2x2EOFYeUY+VM6AqFcJNykbmROPDMjWLBz7BegIlT1lRtzuzWniTY+HKE40
  42067. Cz7PFNm73bZQmq131BnW2hqIyE4bJ3XYsgjxroMwuREOzYfwhI0Vcnyh78zyiGG69Gm7DIwLdVcE
  42068. uE4qFC49DxweMqZiNu5m4iK4BUBjECLzMx10coos9TkpoNPnG4CELcU9402x/RpvumUHO1jsQkUm
  42069. +9jaJXLE9gCxInm943xZYkqcBW89zubWR2OZxiRvchLIrH+QtAuRcOi35hYQcRfO3gZPSEF9NUqj
  42070. ifLJS3tBEW1ntwiYTOURGa5CgNz7kAXU+FDKvuStx8KU1xad5hePrzb7AgMBAAGjQjBAMA8GA1Ud
  42071. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFJngGWcNYtt2s9o9uFvo/ULSMQ6HMA4GA1UdDwEB/wQEAwIB
  42072. BjANBgkqhkiG9w0BAQsFAAOCAgEAmHNw4rDT7TnsTGDZqRKGFx6W0OhUKDtkLSGm+J1WE2pIPU/H
  42073. PinbbViDVD2HfSMF1OQc3Og4ZYbFdada2zUFvXfeuyk3QAUHw5RSn8pk3fEbK9xGChACMf1KaA0H
  42074. ZJDmHvUqoai7PF35owgLEQzxPy0QlG/+4jSHg9bP5Rs1bdID4bANqKCqRieCNqcVtgimQlRXtpla
  42075. 4gt5kNdXElE1GYhBaCXUNxeEFfsBctyV3lImIJgm4nb1J2/6ADtKYdkNy1GTKv0WBpanI5ojSP5R
  42076. vbbEsLFUzt5sQa0WZ37b/TjNuThOssFgy50X31ieemKyJo90lZvkWx3SD92YHJtZuSPTMaCm/zjd
  42077. zyBP6VhWOmfD0faZmZ26NraAL4hHT4a/RDqA5Dccprrql5gR0IRiR2Qequ5AvzSxnI9O4fKSTx+O
  42078. 856X3vOmeWqJcU9LJxdI/uz0UA9PSX3MReO9ekDFQdxhVicGaeVyQYHTtgGJoC86cnn+OjC/QezH
  42079. Yj6RS8fZMXZC+fc8Y+wmjHMMfRod6qh8h6jCJ3zhM0EPz8/8AKAigJ5Kp28AsEFFtyLKaEjFQqKu
  42080. 3R3y4G5OBVixwJAWKqQ9EEC+j2Jjg6mcgn0tAumDMHzLJ8n9HmYAsC7TIS+OMxZsmO0QqAfWzJPP
  42081. 29FpHOTKyeC2nOnOcXHebD8WpHk=
  42082. -----END CERTIFICATE-----
  42083. Trustwave Global ECC P256 Certification Authority
  42084. =================================================
  42085. -----BEGIN CERTIFICATE-----
  42086. MIICYDCCAgegAwIBAgIMDWpfCD8oXD5Rld9dMAoGCCqGSM49BAMCMIGRMQswCQYDVQQGEwJVUzER
  42087. MA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRydXN0d2F2ZSBI
  42088. b2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDI1NiBDZXJ0aWZp
  42089. Y2F0aW9uIEF1dGhvcml0eTAeFw0xNzA4MjMxOTM1MTBaFw00MjA4MjMxOTM1MTBaMIGRMQswCQYD
  42090. VQQGEwJVUzERMA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRy
  42091. dXN0d2F2ZSBIb2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDI1
  42092. NiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABH77bOYj
  42093. 43MyCMpg5lOcunSNGLB4kFKA3TjASh3RqMyTpJcGOMoNFWLGjgEqZZ2q3zSRLoHB5DOSMcT9CTqm
  42094. P62jQzBBMA8GA1UdEwEB/wQFMAMBAf8wDwYDVR0PAQH/BAUDAwcGADAdBgNVHQ4EFgQUo0EGrJBt
  42095. 0UrrdaVKEJmzsaGLSvcwCgYIKoZIzj0EAwIDRwAwRAIgB+ZU2g6gWrKuEZ+Hxbb/ad4lvvigtwjz
  42096. RM4q3wghDDcCIC0mA6AFvWvR9lz4ZcyGbbOcNEhjhAnFjXca4syc4XR7
  42097. -----END CERTIFICATE-----
  42098. Trustwave Global ECC P384 Certification Authority
  42099. =================================================
  42100. -----BEGIN CERTIFICATE-----
  42101. MIICnTCCAiSgAwIBAgIMCL2Fl2yZJ6SAaEc7MAoGCCqGSM49BAMDMIGRMQswCQYDVQQGEwJVUzER
  42102. MA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRydXN0d2F2ZSBI
  42103. b2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDM4NCBDZXJ0aWZp
  42104. Y2F0aW9uIEF1dGhvcml0eTAeFw0xNzA4MjMxOTM2NDNaFw00MjA4MjMxOTM2NDNaMIGRMQswCQYD
  42105. VQQGEwJVUzERMA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRy
  42106. dXN0d2F2ZSBIb2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDM4
  42107. NCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTB2MBAGByqGSM49AgEGBSuBBAAiA2IABGvaDXU1CDFH
  42108. Ba5FmVXxERMuSvgQMSOjfoPTfygIOiYaOs+Xgh+AtycJj9GOMMQKmw6sWASr9zZ9lCOkmwqKi6vr
  42109. /TklZvFe/oyujUF5nQlgziip04pt89ZF1PKYhDhloKNDMEEwDwYDVR0TAQH/BAUwAwEB/zAPBgNV
  42110. HQ8BAf8EBQMDBwYAMB0GA1UdDgQWBBRVqYSJ0sEyvRjLbKYHTsjnnb6CkDAKBggqhkjOPQQDAwNn
  42111. ADBkAjA3AZKXRRJ+oPM+rRk6ct30UJMDEr5E0k9BpIycnR+j9sKS50gU/k6bpZFXrsY3crsCMGcl
  42112. CrEMXu6pY5Jv5ZAL/mYiykf9ijH3g/56vxC+GCsej/YpHpRZ744hN8tRmKVuSw==
  42113. -----END CERTIFICATE-----
  42114. NAVER Global Root Certification Authority
  42115. =========================================
  42116. -----BEGIN CERTIFICATE-----
  42117. MIIFojCCA4qgAwIBAgIUAZQwHqIL3fXFMyqxQ0Rx+NZQTQ0wDQYJKoZIhvcNAQEMBQAwaTELMAkG
  42118. A1UEBhMCS1IxJjAkBgNVBAoMHU5BVkVSIEJVU0lORVNTIFBMQVRGT1JNIENvcnAuMTIwMAYDVQQD
  42119. DClOQVZFUiBHbG9iYWwgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0xNzA4MTgwODU4
  42120. NDJaFw0zNzA4MTgyMzU5NTlaMGkxCzAJBgNVBAYTAktSMSYwJAYDVQQKDB1OQVZFUiBCVVNJTkVT
  42121. UyBQTEFURk9STSBDb3JwLjEyMDAGA1UEAwwpTkFWRVIgR2xvYmFsIFJvb3QgQ2VydGlmaWNhdGlv
  42122. biBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC21PGTXLVAiQqrDZBb
  42123. UGOukJR0F0Vy1ntlWilLp1agS7gvQnXp2XskWjFlqxcX0TM62RHcQDaH38dq6SZeWYp34+hInDEW
  42124. +j6RscrJo+KfziFTowI2MMtSAuXaMl3Dxeb57hHHi8lEHoSTGEq0n+USZGnQJoViAbbJAh2+g1G7
  42125. XNr4rRVqmfeSVPc0W+m/6imBEtRTkZazkVrd/pBzKPswRrXKCAfHcXLJZtM0l/aM9BhK4dA9WkW2
  42126. aacp+yPOiNgSnABIqKYPszuSjXEOdMWLyEz59JuOuDxp7W87UC9Y7cSw0BwbagzivESq2M0UXZR4
  42127. Yb8ObtoqvC8MC3GmsxY/nOb5zJ9TNeIDoKAYv7vxvvTWjIcNQvcGufFt7QSUqP620wbGQGHfnZ3z
  42128. VHbOUzoBppJB7ASjjw2i1QnK1sua8e9DXcCrpUHPXFNwcMmIpi3Ua2FzUCaGYQ5fG8Ir4ozVu53B
  42129. A0K6lNpfqbDKzE0K70dpAy8i+/Eozr9dUGWokG2zdLAIx6yo0es+nPxdGoMuK8u180SdOqcXYZai
  42130. cdNwlhVNt0xz7hlcxVs+Qf6sdWA7G2POAN3aCJBitOUt7kinaxeZVL6HSuOpXgRM6xBtVNbv8ejy
  42131. YhbLgGvtPe31HzClrkvJE+2KAQHJuFFYwGY6sWZLxNUxAmLpdIQM201GLQIDAQABo0IwQDAdBgNV
  42132. HQ4EFgQU0p+I36HNLL3s9TsBAZMzJ7LrYEswDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMB
  42133. Af8wDQYJKoZIhvcNAQEMBQADggIBADLKgLOdPVQG3dLSLvCkASELZ0jKbY7gyKoNqo0hV4/GPnrK
  42134. 21HUUrPUloSlWGB/5QuOH/XcChWB5Tu2tyIvCZwTFrFsDDUIbatjcu3cvuzHV+YwIHHW1xDBE1UB
  42135. jCpD5EHxzzp6U5LOogMFDTjfArsQLtk70pt6wKGm+LUx5vR1yblTmXVHIloUFcd4G7ad6Qz4G3bx
  42136. hYTeodoS76TiEJd6eN4MUZeoIUCLhr0N8F5OSza7OyAfikJW4Qsav3vQIkMsRIz75Sq0bBwcupTg
  42137. E34h5prCy8VCZLQelHsIJchxzIdFV4XTnyliIoNRlwAYl3dqmJLJfGBs32x9SuRwTMKeuB330DTH
  42138. D8z7p/8Dvq1wkNoL3chtl1+afwkyQf3NosxabUzyqkn+Zvjp2DXrDige7kgvOtB5CTh8piKCk5XQ
  42139. A76+AqAF3SAi428diDRgxuYKuQl1C/AH6GmWNcf7I4GOODm4RStDeKLRLBT/DShycpWbXgnbiUSY
  42140. qqFJu3FS8r/2/yehNq+4tneI3TqkbZs0kNwUXTC/t+sX5Ie3cdCh13cV1ELX8vMxmV2b3RZtP+oG
  42141. I/hGoiLtk/bdmuYqh7GYVPEi92tF4+KOdh2ajcQGjTa3FPOdVGm3jjzVpG2Tgbet9r1ke8LJaDmg
  42142. kpzNNIaRkPpkUZ3+/uul9XXeifdy
  42143. -----END CERTIFICATE-----
  42144. AC RAIZ FNMT-RCM SERVIDORES SEGUROS
  42145. ===================================
  42146. -----BEGIN CERTIFICATE-----
  42147. MIICbjCCAfOgAwIBAgIQYvYybOXE42hcG2LdnC6dlTAKBggqhkjOPQQDAzB4MQswCQYDVQQGEwJF
  42148. UzERMA8GA1UECgwIRk5NVC1SQ00xDjAMBgNVBAsMBUNlcmVzMRgwFgYDVQRhDA9WQVRFUy1RMjgy
  42149. NjAwNEoxLDAqBgNVBAMMI0FDIFJBSVogRk5NVC1SQ00gU0VSVklET1JFUyBTRUdVUk9TMB4XDTE4
  42150. MTIyMDA5MzczM1oXDTQzMTIyMDA5MzczM1oweDELMAkGA1UEBhMCRVMxETAPBgNVBAoMCEZOTVQt
  42151. UkNNMQ4wDAYDVQQLDAVDZXJlczEYMBYGA1UEYQwPVkFURVMtUTI4MjYwMDRKMSwwKgYDVQQDDCNB
  42152. QyBSQUlaIEZOTVQtUkNNIFNFUlZJRE9SRVMgU0VHVVJPUzB2MBAGByqGSM49AgEGBSuBBAAiA2IA
  42153. BPa6V1PIyqvfNkpSIeSX0oNnnvBlUdBeh8dHsVnyV0ebAAKTRBdp20LHsbI6GA60XYyzZl2hNPk2
  42154. LEnb80b8s0RpRBNm/dfF/a82Tc4DTQdxz69qBdKiQ1oKUm8BA06Oi6NCMEAwDwYDVR0TAQH/BAUw
  42155. AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFAG5L++/EYZg8k/QQW6rcx/n0m5JMAoGCCqG
  42156. SM49BAMDA2kAMGYCMQCuSuMrQMN0EfKVrRYj3k4MGuZdpSRea0R7/DjiT8ucRRcRTBQnJlU5dUoD
  42157. zBOQn5ICMQD6SmxgiHPz7riYYqnOK8LZiqZwMR2vsJRM60/G49HzYqc8/5MuB1xJAWdpEgJyv+c=
  42158. -----END CERTIFICATE-----
  42159. GlobalSign Root R46
  42160. ===================
  42161. -----BEGIN CERTIFICATE-----
  42162. MIIFWjCCA0KgAwIBAgISEdK7udcjGJ5AXwqdLdDfJWfRMA0GCSqGSIb3DQEBDAUAMEYxCzAJBgNV
  42163. BAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRwwGgYDVQQDExNHbG9iYWxTaWduIFJv
  42164. b3QgUjQ2MB4XDTE5MDMyMDAwMDAwMFoXDTQ2MDMyMDAwMDAwMFowRjELMAkGA1UEBhMCQkUxGTAX
  42165. BgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExHDAaBgNVBAMTE0dsb2JhbFNpZ24gUm9vdCBSNDYwggIi
  42166. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCsrHQy6LNl5brtQyYdpokNRbopiLKkHWPd08Es
  42167. CVeJOaFV6Wc0dwxu5FUdUiXSE2te4R2pt32JMl8Nnp8semNgQB+msLZ4j5lUlghYruQGvGIFAha/
  42168. r6gjA7aUD7xubMLL1aa7DOn2wQL7Id5m3RerdELv8HQvJfTqa1VbkNud316HCkD7rRlr+/fKYIje
  42169. 2sGP1q7Vf9Q8g+7XFkyDRTNrJ9CG0Bwta/OrffGFqfUo0q3v84RLHIf8E6M6cqJaESvWJ3En7YEt
  42170. bWaBkoe0G1h6zD8K+kZPTXhc+CtI4wSEy132tGqzZfxCnlEmIyDLPRT5ge1lFgBPGmSXZgjPjHvj
  42171. K8Cd+RTyG/FWaha/LIWFzXg4mutCagI0GIMXTpRW+LaCtfOW3T3zvn8gdz57GSNrLNRyc0NXfeD4
  42172. 12lPFzYE+cCQYDdF3uYM2HSNrpyibXRdQr4G9dlkbgIQrImwTDsHTUB+JMWKmIJ5jqSngiCNI/on
  42173. ccnfxkF0oE32kRbcRoxfKWMxWXEM2G/CtjJ9++ZdU6Z+Ffy7dXxd7Pj2Fxzsx2sZy/N78CsHpdls
  42174. eVR2bJ0cpm4O6XkMqCNqo98bMDGfsVR7/mrLZqrcZdCinkqaByFrgY/bxFn63iLABJzjqls2k+g9
  42175. vXqhnQt2sQvHnf3PmKgGwvgqo6GDoLclcqUC4wIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAYYwDwYD
  42176. VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA1yrc4GHqMywptWU4jaWSf8FmSwwDQYJKoZIhvcNAQEM
  42177. BQADggIBAHx47PYCLLtbfpIrXTncvtgdokIzTfnvpCo7RGkerNlFo048p9gkUbJUHJNOxO97k4Vg
  42178. JuoJSOD1u8fpaNK7ajFxzHmuEajwmf3lH7wvqMxX63bEIaZHU1VNaL8FpO7XJqti2kM3S+LGteWy
  42179. gxk6x9PbTZ4IevPuzz5i+6zoYMzRx6Fcg0XERczzF2sUyQQCPtIkpnnpHs6i58FZFZ8d4kuaPp92
  42180. CC1r2LpXFNqD6v6MVenQTqnMdzGxRBF6XLE+0xRFFRhiJBPSy03OXIPBNvIQtQ6IbbjhVp+J3pZm
  42181. OUdkLG5NrmJ7v2B0GbhWrJKsFjLtrWhV/pi60zTe9Mlhww6G9kuEYO4Ne7UyWHmRVSyBQ7N0H3qq
  42182. JZ4d16GLuc1CLgSkZoNNiTW2bKg2SnkheCLQQrzRQDGQob4Ez8pn7fXwgNNgyYMqIgXQBztSvwye
  42183. qiv5u+YfjyW6hY0XHgL+XVAEV8/+LbzvXMAaq7afJMbfc2hIkCwU9D9SGuTSyxTDYWnP4vkYxboz
  42184. nxSjBF25cfe1lNj2M8FawTSLfJvdkzrnE6JwYZ+vj+vYxXX4M2bUdGc6N3ec592kD3ZDZopD8p/7
  42185. DEJ4Y9HiD2971KE9dJeFt0g5QdYg/NA6s/rob8SKunE3vouXsXgxT7PntgMTzlSdriVZzH81Xwj3
  42186. QEUxeCp6
  42187. -----END CERTIFICATE-----
  42188. GlobalSign Root E46
  42189. ===================
  42190. -----BEGIN CERTIFICATE-----
  42191. MIICCzCCAZGgAwIBAgISEdK7ujNu1LzmJGjFDYQdmOhDMAoGCCqGSM49BAMDMEYxCzAJBgNVBAYT
  42192. AkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRwwGgYDVQQDExNHbG9iYWxTaWduIFJvb3Qg
  42193. RTQ2MB4XDTE5MDMyMDAwMDAwMFoXDTQ2MDMyMDAwMDAwMFowRjELMAkGA1UEBhMCQkUxGTAXBgNV
  42194. BAoTEEdsb2JhbFNpZ24gbnYtc2ExHDAaBgNVBAMTE0dsb2JhbFNpZ24gUm9vdCBFNDYwdjAQBgcq
  42195. hkjOPQIBBgUrgQQAIgNiAAScDrHPt+ieUnd1NPqlRqetMhkytAepJ8qUuwzSChDH2omwlwxwEwkB
  42196. jtjqR+q+soArzfwoDdusvKSGN+1wCAB16pMLey5SnCNoIwZD7JIvU4Tb+0cUB+hflGddyXqBPCCj
  42197. QjBAMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBQxCpCPtsad0kRL
  42198. gLWi5h+xEk8blTAKBggqhkjOPQQDAwNoADBlAjEA31SQ7Zvvi5QCkxeCmb6zniz2C5GMn0oUsfZk
  42199. vLtoURMMA/cVi4RguYv/Uo7njLwcAjA8+RHUjE7AwWHCFUyqqx0LMV87HOIAl0Qx5v5zli/altP+
  42200. CAezNIm8BZ/3Hobui3A=
  42201. -----END CERTIFICATE-----
  42202. GLOBALTRUST 2020
  42203. ================
  42204. -----BEGIN CERTIFICATE-----
  42205. MIIFgjCCA2qgAwIBAgILWku9WvtPilv6ZeUwDQYJKoZIhvcNAQELBQAwTTELMAkGA1UEBhMCQVQx
  42206. IzAhBgNVBAoTGmUtY29tbWVyY2UgbW9uaXRvcmluZyBHbWJIMRkwFwYDVQQDExBHTE9CQUxUUlVT
  42207. VCAyMDIwMB4XDTIwMDIxMDAwMDAwMFoXDTQwMDYxMDAwMDAwMFowTTELMAkGA1UEBhMCQVQxIzAh
  42208. BgNVBAoTGmUtY29tbWVyY2UgbW9uaXRvcmluZyBHbWJIMRkwFwYDVQQDExBHTE9CQUxUUlVTVCAy
  42209. MDIwMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAri5WrRsc7/aVj6B3GyvTY4+ETUWi
  42210. D59bRatZe1E0+eyLinjF3WuvvcTfk0Uev5E4C64OFudBc/jbu9G4UeDLgztzOG53ig9ZYybNpyrO
  42211. VPu44sB8R85gfD+yc/LAGbaKkoc1DZAoouQVBGM+uq/ufF7MpotQsjj3QWPKzv9pj2gOlTblzLmM
  42212. CcpL3TGQlsjMH/1WljTbjhzqLL6FLmPdqqmV0/0plRPwyJiT2S0WR5ARg6I6IqIoV6Lr/sCMKKCm
  42213. fecqQjuCgGOlYx8ZzHyyZqjC0203b+J+BlHZRYQfEs4kUmSFC0iAToexIiIwquuuvuAC4EDosEKA
  42214. A1GqtH6qRNdDYfOiaxaJSaSjpCuKAsR49GiKweR6NrFvG5Ybd0mN1MkGco/PU+PcF4UgStyYJ9OR
  42215. JitHHmkHr96i5OTUawuzXnzUJIBHKWk7buis/UDr2O1xcSvy6Fgd60GXIsUf1DnQJ4+H4xj04KlG
  42216. DfV0OoIu0G4skaMxXDtG6nsEEFZegB31pWXogvziB4xiRfUg3kZwhqG8k9MedKZssCz3AwyIDMvU
  42217. clOGvGBG85hqwvG/Q/lwIHfKN0F5VVJjjVsSn8VoxIidrPIwq7ejMZdnrY8XD2zHc+0klGvIg5rQ
  42218. mjdJBKuxFshsSUktq6HQjJLyQUp5ISXbY9e2nKd+Qmn7OmMCAwEAAaNjMGEwDwYDVR0TAQH/BAUw
  42219. AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFNwuH9FhN3nkq9XVsxJxaD1qaJwiMB8GA1Ud
  42220. IwQYMBaAFNwuH9FhN3nkq9XVsxJxaD1qaJwiMA0GCSqGSIb3DQEBCwUAA4ICAQCR8EICaEDuw2jA
  42221. VC/f7GLDw56KoDEoqoOOpFaWEhCGVrqXctJUMHytGdUdaG/7FELYjQ7ztdGl4wJCXtzoRlgHNQIw
  42222. 4Lx0SsFDKv/bGtCwr2zD/cuz9X9tAy5ZVp0tLTWMstZDFyySCstd6IwPS3BD0IL/qMy/pJTAvoe9
  42223. iuOTe8aPmxadJ2W8esVCgmxcB9CpwYhgROmYhRZf+I/KARDOJcP5YBugxZfD0yyIMaK9MOzQ0MAS
  42224. 8cE54+X1+NZK3TTN+2/BT+MAi1bikvcoskJ3ciNnxz8RFbLEAwW+uxF7Cr+obuf/WEPPm2eggAe2
  42225. HcqtbepBEX4tdJP7wry+UUTF72glJ4DjyKDUEuzZpTcdN3y0kcra1LGWge9oXHYQSa9+pTeAsRxS
  42226. vTOBTI/53WXZFM2KJVj04sWDpQmQ1GwUY7VA3+vA/MRYfg0UFodUJ25W5HCEuGwyEn6CMUO+1918
  42227. oa2u1qsgEu8KwxCMSZY13At1XrFP1U80DhEgB3VDRemjEdqso5nCtnkn4rnvyOL2NSl6dPrFf4IF
  42228. YqYK6miyeUcGbvJXqBUzxvd4Sj1Ce2t+/vdG6tHrju+IaFvowdlxfv1k7/9nR4hYJS8+hge9+6jl
  42229. gqispdNpQ80xiEmEU5LAsTkbOYMBMMTyqfrQA71yN2BWHzZ8vTmR9W0Nv3vXkg==
  42230. -----END CERTIFICATE-----
  42231. ANF Secure Server Root CA
  42232. =========================
  42233. -----BEGIN CERTIFICATE-----
  42234. MIIF7zCCA9egAwIBAgIIDdPjvGz5a7EwDQYJKoZIhvcNAQELBQAwgYQxEjAQBgNVBAUTCUc2MzI4
  42235. NzUxMDELMAkGA1UEBhMCRVMxJzAlBgNVBAoTHkFORiBBdXRvcmlkYWQgZGUgQ2VydGlmaWNhY2lv
  42236. bjEUMBIGA1UECxMLQU5GIENBIFJhaXoxIjAgBgNVBAMTGUFORiBTZWN1cmUgU2VydmVyIFJvb3Qg
  42237. Q0EwHhcNMTkwOTA0MTAwMDM4WhcNMzkwODMwMTAwMDM4WjCBhDESMBAGA1UEBRMJRzYzMjg3NTEw
  42238. MQswCQYDVQQGEwJFUzEnMCUGA1UEChMeQU5GIEF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uMRQw
  42239. EgYDVQQLEwtBTkYgQ0EgUmFpejEiMCAGA1UEAxMZQU5GIFNlY3VyZSBTZXJ2ZXIgUm9vdCBDQTCC
  42240. AiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANvrayvmZFSVgpCjcqQZAZ2cC4Ffc0m6p6zz
  42241. BE57lgvsEeBbphzOG9INgxwruJ4dfkUyYA8H6XdYfp9qyGFOtibBTI3/TO80sh9l2Ll49a2pcbnv
  42242. T1gdpd50IJeh7WhM3pIXS7yr/2WanvtH2Vdy8wmhrnZEE26cLUQ5vPnHO6RYPUG9tMJJo8gN0pcv
  42243. B2VSAKduyK9o7PQUlrZXH1bDOZ8rbeTzPvY1ZNoMHKGESy9LS+IsJJ1tk0DrtSOOMspvRdOoiXse
  42244. zx76W0OLzc2oD2rKDF65nkeP8Nm2CgtYZRczuSPkdxl9y0oukntPLxB3sY0vaJxizOBQ+OyRp1RM
  42245. VwnVdmPF6GUe7m1qzwmd+nxPrWAI/VaZDxUse6mAq4xhj0oHdkLePfTdsiQzW7i1o0TJrH93PB0j
  42246. 7IKppuLIBkwC/qxcmZkLLxCKpvR/1Yd0DVlJRfbwcVw5Kda/SiOL9V8BY9KHcyi1Swr1+KuCLH5z
  42247. JTIdC2MKF4EA/7Z2Xue0sUDKIbvVgFHlSFJnLNJhiQcND85Cd8BEc5xEUKDbEAotlRyBr+Qc5RQe
  42248. 8TZBAQIvfXOn3kLMTOmJDVb3n5HUA8ZsyY/b2BzgQJhdZpmYgG4t/wHFzstGH6wCxkPmrqKEPMVO
  42249. Hj1tyRRM4y5Bu8o5vzY8KhmqQYdOpc5LMnndkEl/AgMBAAGjYzBhMB8GA1UdIwQYMBaAFJxf0Gxj
  42250. o1+TypOYCK2Mh6UsXME3MB0GA1UdDgQWBBScX9BsY6Nfk8qTmAitjIelLFzBNzAOBgNVHQ8BAf8E
  42251. BAMCAYYwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEATh65isagmD9uw2nAalxJ
  42252. UqzLK114OMHVVISfk/CHGT0sZonrDUL8zPB1hT+L9IBdeeUXZ701guLyPI59WzbLWoAAKfLOKyzx
  42253. j6ptBZNscsdW699QIyjlRRA96Gejrw5VD5AJYu9LWaL2U/HANeQvwSS9eS9OICI7/RogsKQOLHDt
  42254. dD+4E5UGUcjohybKpFtqFiGS3XNgnhAY3jyB6ugYw3yJ8otQPr0R4hUDqDZ9MwFsSBXXiJCZBMXM
  42255. 5gf0vPSQ7RPi6ovDj6MzD8EpTBNO2hVWcXNyglD2mjN8orGoGjR0ZVzO0eurU+AagNjqOknkJjCb
  42256. 5RyKqKkVMoaZkgoQI1YS4PbOTOK7vtuNknMBZi9iPrJyJ0U27U1W45eZ/zo1PqVUSlJZS2Db7v54
  42257. EX9K3BR5YLZrZAPbFYPhor72I5dQ8AkzNqdxliXzuUJ92zg/LFis6ELhDtjTO0wugumDLmsx2d1H
  42258. hk9tl5EuT+IocTUW0fJz/iUrB0ckYyfI+PbZa/wSMVYIwFNCr5zQM378BvAxRAMU8Vjq8moNqRGy
  42259. g77FGr8H6lnco4g175x2MjxNBiLOFeXdntiP2t7SxDnlF4HPOEfrf4htWRvfn0IUrn7PqLBmZdo3
  42260. r5+qPeoott7VMVgWglvquxl1AnMaykgaIZOQCo6ThKd9OyMYkomgjaw=
  42261. -----END CERTIFICATE-----
  42262. Certum EC-384 CA
  42263. ================
  42264. -----BEGIN CERTIFICATE-----
  42265. MIICZTCCAeugAwIBAgIQeI8nXIESUiClBNAt3bpz9DAKBggqhkjOPQQDAzB0MQswCQYDVQQGEwJQ
  42266. TDEhMB8GA1UEChMYQXNzZWNvIERhdGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2Vy
  42267. dGlmaWNhdGlvbiBBdXRob3JpdHkxGTAXBgNVBAMTEENlcnR1bSBFQy0zODQgQ0EwHhcNMTgwMzI2
  42268. MDcyNDU0WhcNNDMwMzI2MDcyNDU0WjB0MQswCQYDVQQGEwJQTDEhMB8GA1UEChMYQXNzZWNvIERh
  42269. dGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkx
  42270. GTAXBgNVBAMTEENlcnR1bSBFQy0zODQgQ0EwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAATEKI6rGFtq
  42271. vm5kN2PkzeyrOvfMobgOgknXhimfoZTy42B4mIF4Bk3y7JoOV2CDn7TmFy8as10CW4kjPMIRBSqn
  42272. iBMY81CE1700LCeJVf/OTOffph8oxPBUw7l8t1Ot68KjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  42273. VR0OBBYEFI0GZnQkdjrzife81r1HfS+8EF9LMA4GA1UdDwEB/wQEAwIBBjAKBggqhkjOPQQDAwNo
  42274. ADBlAjADVS2m5hjEfO/JUG7BJw+ch69u1RsIGL2SKcHvlJF40jocVYli5RsJHrpka/F2tNQCMQC0
  42275. QoSZ/6vnnvuRlydd3LBbMHHOXjgaatkl5+r3YZJW+OraNsKHZZYuciUvf9/DE8k=
  42276. -----END CERTIFICATE-----
  42277. Certum Trusted Root CA
  42278. ======================
  42279. -----BEGIN CERTIFICATE-----
  42280. MIIFwDCCA6igAwIBAgIQHr9ZULjJgDdMBvfrVU+17TANBgkqhkiG9w0BAQ0FADB6MQswCQYDVQQG
  42281. EwJQTDEhMB8GA1UEChMYQXNzZWNvIERhdGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0g
  42282. Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkxHzAdBgNVBAMTFkNlcnR1bSBUcnVzdGVkIFJvb3QgQ0Ew
  42283. HhcNMTgwMzE2MTIxMDEzWhcNNDMwMzE2MTIxMDEzWjB6MQswCQYDVQQGEwJQTDEhMB8GA1UEChMY
  42284. QXNzZWNvIERhdGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlvbiBB
  42285. dXRob3JpdHkxHzAdBgNVBAMTFkNlcnR1bSBUcnVzdGVkIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEB
  42286. AQUAA4ICDwAwggIKAoICAQDRLY67tzbqbTeRn06TpwXkKQMlzhyC93yZn0EGze2jusDbCSzBfN8p
  42287. fktlL5On1AFrAygYo9idBcEq2EXxkd7fO9CAAozPOA/qp1x4EaTByIVcJdPTsuclzxFUl6s1wB52
  42288. HO8AU5853BSlLCIls3Jy/I2z5T4IHhQqNwuIPMqw9MjCoa68wb4pZ1Xi/K1ZXP69VyywkI3C7Te2
  42289. fJmItdUDmj0VDT06qKhF8JVOJVkdzZhpu9PMMsmN74H+rX2Ju7pgE8pllWeg8xn2A1bUatMn4qGt
  42290. g/BKEiJ3HAVz4hlxQsDsdUaakFjgao4rpUYwBI4Zshfjvqm6f1bxJAPXsiEodg42MEx51UGamqi4
  42291. NboMOvJEGyCI98Ul1z3G4z5D3Yf+xOr1Uz5MZf87Sst4WmsXXw3Hw09Omiqi7VdNIuJGmj8PkTQk
  42292. fVXjjJU30xrwCSss0smNtA0Aq2cpKNgB9RkEth2+dv5yXMSFytKAQd8FqKPVhJBPC/PgP5sZ0jeJ
  42293. P/J7UhyM9uH3PAeXjA6iWYEMspA90+NZRu0PqafegGtaqge2Gcu8V/OXIXoMsSt0Puvap2ctTMSY
  42294. njYJdmZm/Bo/6khUHL4wvYBQv3y1zgD2DGHZ5yQD4OMBgQ692IU0iL2yNqh7XAjlRICMb/gv1SHK
  42295. HRzQ+8S1h9E6Tsd2tTVItQIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSM+xx1
  42296. vALTn04uSNn5YFSqxLNP+jAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQENBQADggIBAEii1QAL
  42297. LtA/vBzVtVRJHlpr9OTy4EA34MwUe7nJ+jW1dReTagVphZzNTxl4WxmB82M+w85bj/UvXgF2Ez8s
  42298. ALnNllI5SW0ETsXpD4YN4fqzX4IS8TrOZgYkNCvozMrnadyHncI013nR03e4qllY/p0m+jiGPp2K
  42299. h2RX5Rc64vmNueMzeMGQ2Ljdt4NR5MTMI9UGfOZR0800McD2RrsLrfw9EAUqO0qRJe6M1ISHgCq8
  42300. CYyqOhNf6DR5UMEQGfnTKB7U0VEwKbOukGfWHwpjscWpxkIxYxeU72nLL/qMFH3EQxiJ2fAyQOaA
  42301. 4kZf5ePBAFmo+eggvIksDkc0C+pXwlM2/KfUrzHN/gLldfq5Jwn58/U7yn2fqSLLiMmq0Uc9Nneo
  42302. WWRrJ8/vJ8HjJLWG965+Mk2weWjROeiQWMODvA8s1pfrzgzhIMfatz7DP78v3DSk+yshzWePS/Tj
  42303. 6tQ/50+6uaWTRRxmHyH6ZF5v4HaUMst19W7l9o/HuKTMqJZ9ZPskWkoDbGs4xugDQ5r3V7mzKWmT
  42304. OPQD8rv7gmsHINFSH5pkAnuYZttcTVoP0ISVoDwUQwbKytu4QTbaakRnh6+v40URFWkIsr4WOZck
  42305. bxJF0WddCajJFdr60qZfE2Efv4WstK2tBZQIgx51F9NxO5NQI1mg7TyRVJ12AMXDuDjb
  42306. -----END CERTIFICATE-----
  42307. TunTrust Root CA
  42308. ================
  42309. -----BEGIN CERTIFICATE-----
  42310. MIIFszCCA5ugAwIBAgIUEwLV4kBMkkaGFmddtLu7sms+/BMwDQYJKoZIhvcNAQELBQAwYTELMAkG
  42311. A1UEBhMCVE4xNzA1BgNVBAoMLkFnZW5jZSBOYXRpb25hbGUgZGUgQ2VydGlmaWNhdGlvbiBFbGVj
  42312. dHJvbmlxdWUxGTAXBgNVBAMMEFR1blRydXN0IFJvb3QgQ0EwHhcNMTkwNDI2MDg1NzU2WhcNNDQw
  42313. NDI2MDg1NzU2WjBhMQswCQYDVQQGEwJUTjE3MDUGA1UECgwuQWdlbmNlIE5hdGlvbmFsZSBkZSBD
  42314. ZXJ0aWZpY2F0aW9uIEVsZWN0cm9uaXF1ZTEZMBcGA1UEAwwQVHVuVHJ1c3QgUm9vdCBDQTCCAiIw
  42315. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMPN0/y9BFPdDCA61YguBUtB9YOCfvdZn56eY+hz
  42316. 2vYGqU8ftPkLHzmMmiDQfgbU7DTZhrx1W4eI8NLZ1KMKsmwb60ksPqxd2JQDoOw05TDENX37Jk0b
  42317. bjBU2PWARZw5rZzJJQRNmpA+TkBuimvNKWfGzC3gdOgFVwpIUPp6Q9p+7FuaDmJ2/uqdHYVy7BG7
  42318. NegfJ7/Boce7SBbdVtfMTqDhuazb1YMZGoXRlJfXyqNlC/M4+QKu3fZnz8k/9YosRxqZbwUN/dAd
  42319. gjH8KcwAWJeRTIAAHDOFli/LQcKLEITDCSSJH7UP2dl3RxiSlGBcx5kDPP73lad9UKGAwqmDrViW
  42320. VSHbhlnUr8a83YFuB9tgYv7sEG7aaAH0gxupPqJbI9dkxt/con3YS7qC0lH4Zr8GRuR5KiY2eY8f
  42321. Tpkdso8MDhz/yV3A/ZAQprE38806JG60hZC/gLkMjNWb1sjxVj8agIl6qeIbMlEsPvLfe/ZdeikZ
  42322. juXIvTZxi11Mwh0/rViizz1wTaZQmCXcI/m4WEEIcb9PuISgjwBUFfyRbVinljvrS5YnzWuioYas
  42323. DXxU5mZMZl+QviGaAkYt5IPCgLnPSz7ofzwB7I9ezX/SKEIBlYrilz0QIX32nRzFNKHsLA4KUiwS
  42324. VXAkPcvCFDVDXSdOvsC9qnyW5/yeYa1E0wCXAgMBAAGjYzBhMB0GA1UdDgQWBBQGmpsfU33x9aTI
  42325. 04Y+oXNZtPdEITAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFAaamx9TffH1pMjThj6hc1m0
  42326. 90QhMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAgEAqgVutt0Vyb+zxiD2BkewhpMl
  42327. 0425yAA/l/VSJ4hxyXT968pk21vvHl26v9Hr7lxpuhbI87mP0zYuQEkHDVneixCwSQXi/5E/S7fd
  42328. Ao74gShczNxtr18UnH1YeA32gAm56Q6XKRm4t+v4FstVEuTGfbvE7Pi1HE4+Z7/FXxttbUcoqgRY
  42329. YdZ2vyJ/0Adqp2RT8JeNnYA/u8EH22Wv5psymsNUk8QcCMNE+3tjEUPRahphanltkE8pjkcFwRJp
  42330. adbGNjHh/PqAulxPxOu3Mqz4dWEX1xAZufHSCe96Qp1bWgvUxpVOKs7/B9dPfhgGiPEZtdmYu65x
  42331. xBzndFlY7wyJz4sfdZMaBBSSSFCp61cpABbjNhzI+L/wM9VBD8TMPN3pM0MBkRArHtG5Xc0yGYuP
  42332. jCB31yLEQtyEFpslbei0VXF/sHyz03FJuc9SpAQ/3D2gu68zngowYI7bnV2UqL1g52KAdoGDDIzM
  42333. MEZJ4gzSqK/rYXHv5yJiqfdcZGyfFoxnNidF9Ql7v/YQCvGwjVRDjAS6oz/v4jXH+XTgbzRB0L9z
  42334. ZVcg+ZtnemZoJE6AZb0QmQZZ8mWvuMZHu/2QeItBcy6vVR/cO5JyboTT0GFMDcx2V+IthSIVNg3r
  42335. AZ3r2OvEhJn7wAzMMujjd9qDRIueVSjAi1jTkD5OGwDxFa2DK5o=
  42336. -----END CERTIFICATE-----
  42337. HARICA TLS RSA Root CA 2021
  42338. ===========================
  42339. -----BEGIN CERTIFICATE-----
  42340. MIIFpDCCA4ygAwIBAgIQOcqTHO9D88aOk8f0ZIk4fjANBgkqhkiG9w0BAQsFADBsMQswCQYDVQQG
  42341. EwJHUjE3MDUGA1UECgwuSGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9u
  42342. cyBDQTEkMCIGA1UEAwwbSEFSSUNBIFRMUyBSU0EgUm9vdCBDQSAyMDIxMB4XDTIxMDIxOTEwNTUz
  42343. OFoXDTQ1MDIxMzEwNTUzN1owbDELMAkGA1UEBhMCR1IxNzA1BgNVBAoMLkhlbGxlbmljIEFjYWRl
  42344. bWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ0ExJDAiBgNVBAMMG0hBUklDQSBUTFMgUlNB
  42345. IFJvb3QgQ0EgMjAyMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAIvC569lmwVnlskN
  42346. JLnQDmT8zuIkGCyEf3dRywQRNrhe7Wlxp57kJQmXZ8FHws+RFjZiPTgE4VGC/6zStGndLuwRo0Xu
  42347. a2s7TL+MjaQenRG56Tj5eg4MmOIjHdFOY9TnuEFE+2uva9of08WRiFukiZLRgeaMOVig1mlDqa2Y
  42348. Ulhu2wr7a89o+uOkXjpFc5gH6l8Cct4MpbOfrqkdtx2z/IpZ525yZa31MJQjB/OCFks1mJxTuy/K
  42349. 5FrZx40d/JiZ+yykgmvwKh+OC19xXFyuQnspiYHLA6OZyoieC0AJQTPb5lh6/a6ZcMBaD9YThnEv
  42350. dmn8kN3bLW7R8pv1GmuebxWMevBLKKAiOIAkbDakO/IwkfN4E8/BPzWr8R0RI7VDIp4BkrcYAuUR
  42351. 0YLbFQDMYTfBKnya4dC6s1BG7oKsnTH4+yPiAwBIcKMJJnkVU2DzOFytOOqBAGMUuTNe3QvboEUH
  42352. GjMJ+E20pwKmafTCWQWIZYVWrkvL4N48fS0ayOn7H6NhStYqE613TBoYm5EPWNgGVMWX+Ko/IIqm
  42353. haZ39qb8HOLubpQzKoNQhArlT4b4UEV4AIHrW2jjJo3Me1xR9BQsQL4aYB16cmEdH2MtiKrOokWQ
  42354. CPxrvrNQKlr9qEgYRtaQQJKQCoReaDH46+0N0x3GfZkYVVYnZS6NRcUk7M7jAgMBAAGjQjBAMA8G
  42355. A1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFApII6ZgpJIKM+qTW8VX6iVNvRLuMA4GA1UdDwEB/wQE
  42356. AwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAPpBIqm5iFSVmewzVjIuJndftTgfvnNAUX15QvWiWkKQU
  42357. EapobQk1OUAJ2vQJLDSle1mESSmXdMgHHkdt8s4cUCbjnj1AUz/3f5Z2EMVGpdAgS1D0NTsY9FVq
  42358. QRtHBmg8uwkIYtlfVUKqrFOFrJVWNlar5AWMxajaH6NpvVMPxP/cyuN+8kyIhkdGGvMA9YCRotxD
  42359. QpSbIPDRzbLrLFPCU3hKTwSUQZqPJzLB5UkZv/HywouoCjkxKLR9YjYsTewfM7Z+d21+UPCfDtcR
  42360. j88YxeMn/ibvBZ3PzzfF0HvaO7AWhAw6k9a+F9sPPg4ZeAnHqQJyIkv3N3a6dcSFA1pj1bF1BcK5
  42361. vZStjBWZp5N99sXzqnTPBIWUmAD04vnKJGW/4GKvyMX6ssmeVkjaef2WdhW+o45WxLM0/L5H9MG0
  42362. qPzVMIho7suuyWPEdr6sOBjhXlzPrjoiUevRi7PzKzMHVIf6tLITe7pTBGIBnfHAT+7hOtSLIBD6
  42363. Alfm78ELt5BGnBkpjNxvoEppaZS3JGWg/6w/zgH7IS79aPib8qXPMThcFarmlwDB31qlpzmq6YR/
  42364. PFGoOtmUW4y/Twhx5duoXNTSpv4Ao8YWxw/ogM4cKGR0GQjTQuPOAF1/sdwTsOEFy9EgqoZ0njnn
  42365. kf3/W9b3raYvAwtt41dU63ZTGI0RmLo=
  42366. -----END CERTIFICATE-----
  42367. HARICA TLS ECC Root CA 2021
  42368. ===========================
  42369. -----BEGIN CERTIFICATE-----
  42370. MIICVDCCAdugAwIBAgIQZ3SdjXfYO2rbIvT/WeK/zjAKBggqhkjOPQQDAzBsMQswCQYDVQQGEwJH
  42371. UjE3MDUGA1UECgwuSGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBD
  42372. QTEkMCIGA1UEAwwbSEFSSUNBIFRMUyBFQ0MgUm9vdCBDQSAyMDIxMB4XDTIxMDIxOTExMDExMFoX
  42373. DTQ1MDIxMzExMDEwOVowbDELMAkGA1UEBhMCR1IxNzA1BgNVBAoMLkhlbGxlbmljIEFjYWRlbWlj
  42374. IGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ0ExJDAiBgNVBAMMG0hBUklDQSBUTFMgRUNDIFJv
  42375. b3QgQ0EgMjAyMTB2MBAGByqGSM49AgEGBSuBBAAiA2IABDgI/rGgltJ6rK9JOtDA4MM7KKrxcm1l
  42376. AEeIhPyaJmuqS7psBAqIXhfyVYf8MLA04jRYVxqEU+kw2anylnTDUR9YSTHMmE5gEYd103KUkE+b
  42377. ECUqqHgtvpBBWJAVcqeht6NCMEAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUyRtTgRL+BNUW
  42378. 0aq8mm+3oJUZbsowDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMDA2cAMGQCMBHervjcToiwqfAi
  42379. rcJRQO9gcS3ujwLEXQNwSaSS6sUUiHCm0w2wqsosQJz76YJumgIwK0eaB8bRwoF8yguWGEEbo/Qw
  42380. CZ61IygNnxS2PFOiTAZpffpskcYqSUXm7LcT4Tps
  42381. -----END CERTIFICATE-----
  42382. <?php
  42383. namespace Composer\CaBundle;
  42384. use Psr\Log\LoggerInterface;
  42385. use Symfony\Component\Process\PhpProcess;
  42386. class CaBundle
  42387. {
  42388. private static $caPath;
  42389. private static $caFileValidity = array();
  42390. private static $useOpensslParse;
  42391. public static function getSystemCaRootBundlePath(LoggerInterface $logger = null)
  42392. {
  42393. if (self::$caPath !== null) {
  42394. return self::$caPath;
  42395. }
  42396. $caBundlePaths = array();
  42397. $caBundlePaths[] = self::getEnvVariable('SSL_CERT_FILE');
  42398. $caBundlePaths[] = self::getEnvVariable('SSL_CERT_DIR');
  42399. $caBundlePaths[] = ini_get('openssl.cafile');
  42400. $caBundlePaths[] = ini_get('openssl.capath');
  42401. $otherLocations = array(
  42402. '/etc/pki/tls/certs/ca-bundle.crt',
  42403. '/etc/ssl/certs/ca-certificates.crt',
  42404. '/etc/ssl/ca-bundle.pem',
  42405. '/usr/local/share/certs/ca-root-nss.crt',
  42406. '/usr/ssl/certs/ca-bundle.crt',
  42407. '/opt/local/share/curl/curl-ca-bundle.crt',
  42408. '/usr/local/share/curl/curl-ca-bundle.crt',
  42409. '/usr/share/ssl/certs/ca-bundle.crt',
  42410. '/etc/ssl/cert.pem',
  42411. '/usr/local/etc/ssl/cert.pem',
  42412. '/usr/local/etc/openssl/cert.pem',
  42413. '/usr/local/etc/openssl@1.1/cert.pem',
  42414. );
  42415. foreach($otherLocations as $location) {
  42416. $otherLocations[] = dirname($location);
  42417. }
  42418. $caBundlePaths = array_merge($caBundlePaths, $otherLocations);
  42419. foreach ($caBundlePaths as $caBundle) {
  42420. if ($caBundle && self::caFileUsable($caBundle, $logger)) {
  42421. return self::$caPath = $caBundle;
  42422. }
  42423. if ($caBundle && self::caDirUsable($caBundle, $logger)) {
  42424. return self::$caPath = $caBundle;
  42425. }
  42426. }
  42427. return self::$caPath = static::getBundledCaBundlePath();
  42428. }
  42429. public static function getBundledCaBundlePath()
  42430. {
  42431. $caBundleFile = __DIR__.'/../res/cacert.pem';
  42432. if (0 === strpos($caBundleFile, 'phar://')) {
  42433. $tempCaBundleFile = tempnam(sys_get_temp_dir(), 'openssl-ca-bundle-');
  42434. if (false === $tempCaBundleFile) {
  42435. throw new \RuntimeException('Could not create a temporary file to store the bundled CA file');
  42436. }
  42437. file_put_contents(
  42438. $tempCaBundleFile,
  42439. file_get_contents($caBundleFile)
  42440. );
  42441. register_shutdown_function(function() use ($tempCaBundleFile) {
  42442. @unlink($tempCaBundleFile);
  42443. });
  42444. $caBundleFile = $tempCaBundleFile;
  42445. }
  42446. return $caBundleFile;
  42447. }
  42448. public static function validateCaFile($filename, LoggerInterface $logger = null)
  42449. {
  42450. static $warned = false;
  42451. if (isset(self::$caFileValidity[$filename])) {
  42452. return self::$caFileValidity[$filename];
  42453. }
  42454. $contents = file_get_contents($filename);
  42455. if (!static::isOpensslParseSafe()) {
  42456. if (!$warned && $logger) {
  42457. $logger->warning(sprintf(
  42458. 'Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.',
  42459. PHP_VERSION
  42460. ));
  42461. $warned = true;
  42462. }
  42463. $isValid = !empty($contents);
  42464. } elseif (is_string($contents) && strlen($contents) > 0) {
  42465. $contents = preg_replace("/^(\\-+(?:BEGIN|END))\\s+TRUSTED\\s+(CERTIFICATE\\-+)\$/m", '$1 $2', $contents);
  42466. if (null === $contents) {
  42467. $isValid = false;
  42468. } else {
  42469. $isValid = (bool) openssl_x509_parse($contents);
  42470. }
  42471. } else {
  42472. $isValid = false;
  42473. }
  42474. if ($logger) {
  42475. $logger->debug('Checked CA file '.realpath($filename).': '.($isValid ? 'valid' : 'invalid'));
  42476. }
  42477. return self::$caFileValidity[$filename] = $isValid;
  42478. }
  42479. public static function isOpensslParseSafe()
  42480. {
  42481. if (null !== self::$useOpensslParse) {
  42482. return self::$useOpensslParse;
  42483. }
  42484. if (PHP_VERSION_ID >= 50600) {
  42485. return self::$useOpensslParse = true;
  42486. }
  42487. if (
  42488. (PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50328)
  42489. || (PHP_VERSION_ID < 50500 && PHP_VERSION_ID >= 50423)
  42490. || PHP_VERSION_ID >= 50507
  42491. ) {
  42492. return self::$useOpensslParse = true;
  42493. }
  42494. if (defined('PHP_WINDOWS_VERSION_BUILD')) {
  42495. return self::$useOpensslParse = false;
  42496. }
  42497. $compareDistroVersionPrefix = function ($prefix, $fixedVersion) {
  42498. $regex = '{^'.preg_quote($prefix).'([0-9]+)$}';
  42499. if (preg_match($regex, PHP_VERSION, $m)) {
  42500. return ((int) $m[1]) >= $fixedVersion;
  42501. }
  42502. return false;
  42503. };
  42504. if (
  42505. $compareDistroVersionPrefix('5.3.3-7+squeeze', 18)
  42506. || $compareDistroVersionPrefix('5.4.4-14+deb7u', 7)
  42507. || $compareDistroVersionPrefix('5.3.10-1ubuntu3.', 9)
  42508. ) {
  42509. return self::$useOpensslParse = true;
  42510. }
  42511. if (!class_exists('Symfony\Component\Process\PhpProcess')) {
  42512. return self::$useOpensslParse = false;
  42513. }
  42514. $cert = 'LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUVwRENDQTR5Z0F3SUJBZ0lKQUp6dThyNnU2ZUJjTUEwR0NTcUdTSWIzRFFFQkJRVUFNSUhETVFzd0NRWUQKVlFRR0V3SkVSVEVjTUJvR0ExVUVDQXdUVG05eVpISm9aV2x1TFZkbGMzUm1ZV3hsYmpFUU1BNEdBMVVFQnd3SApTOE9Ed3Jac2JqRVVNQklHQTFVRUNnd0xVMlZyZEdsdmJrVnBibk14SHpBZEJnTlZCQXNNRmsxaGJHbGphVzkxCmN5QkRaWEowSUZObFkzUnBiMjR4SVRBZkJnTlZCQU1NR0cxaGJHbGphVzkxY3k1elpXdDBhVzl1WldsdWN5NWsKWlRFcU1DZ0dDU3FHU0liM0RRRUpBUlliYzNSbFptRnVMbVZ6YzJWeVFITmxhM1JwYjI1bGFXNXpMbVJsTUhVWQpaREU1TnpBd01UQXhNREF3TURBd1dnQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBCkFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUEKQUFBQUFBQVhEVEUwTVRFeU9ERXhNemt6TlZvd2djTXhDekFKQmdOVkJBWVRBa1JGTVJ3d0dnWURWUVFJREJOTwpiM0prY21obGFXNHRWMlZ6ZEdaaGJHVnVNUkF3RGdZRFZRUUhEQWRMdzRQQ3RteHVNUlF3RWdZRFZRUUtEQXRUClpXdDBhVzl1UldsdWN6RWZNQjBHQTFVRUN3d1dUV0ZzYVdOcGIzVnpJRU5sY25RZ1UyVmpkR2x2YmpFaE1COEcKQTFVRUF3d1liV0ZzYVdOcGIzVnpMbk5sYTNScGIyNWxhVzV6TG1SbE1Tb3dLQVlKS29aSWh2Y05BUWtCRmh0egpkR1ZtWVc0dVpYTnpaWEpBYzJWcmRHbHZibVZwYm5NdVpHVXdnZ0VpTUEwR0NTcUdTSWIzRFFFQkFRVUFBNElCCkR3QXdnZ0VLQW9JQkFRRERBZjNobDdKWTBYY0ZuaXlFSnBTU0RxbjBPcUJyNlFQNjV1c0pQUnQvOFBhRG9xQnUKd0VZVC9OYSs2ZnNnUGpDMHVLOURaZ1dnMnRIV1dvYW5TYmxBTW96NVBINlorUzRTSFJaN2UyZERJalBqZGhqaAowbUxnMlVNTzV5cDBWNzk3R2dzOWxOdDZKUmZIODFNTjJvYlhXczROdHp0TE11RDZlZ3FwcjhkRGJyMzRhT3M4CnBrZHVpNVVhd1Raa3N5NXBMUEhxNWNNaEZHbTA2djY1Q0xvMFYyUGQ5K0tBb2tQclBjTjVLTEtlYno3bUxwazYKU01lRVhPS1A0aWRFcXh5UTdPN2ZCdUhNZWRzUWh1K3ByWTNzaTNCVXlLZlF0UDVDWm5YMmJwMHdLSHhYMTJEWAoxbmZGSXQ5RGJHdkhUY3lPdU4rblpMUEJtM3ZXeG50eUlJdlZBZ01CQUFHalFqQkFNQWtHQTFVZEV3UUNNQUF3CkVRWUpZSVpJQVliNFFnRUJCQVFEQWdlQU1Bc0dBMVVkRHdRRUF3SUZvREFUQmdOVkhTVUVEREFLQmdnckJnRUYKQlFjREFqQU5CZ2txaGtpRzl3MEJBUVVGQUFPQ0FRRUFHMGZaWVlDVGJkajFYWWMrMVNub2FQUit2SThDOENhRAo4KzBVWWhkbnlVNGdnYTBCQWNEclk5ZTk0ZUVBdTZacXljRjZGakxxWFhkQWJvcHBXb2NyNlQ2R0QxeDMzQ2tsClZBcnpHL0t4UW9oR0QySmVxa2hJTWxEb214SE83a2EzOStPYThpMnZXTFZ5alU4QVp2V01BcnVIYTRFRU55RzcKbFcyQWFnYUZLRkNyOVRuWFRmcmR4R1ZFYnY3S1ZRNmJkaGc1cDVTanBXSDErTXEwM3VSM1pYUEJZZHlWODMxOQpvMGxWajFLRkkyRENML2xpV2lzSlJvb2YrMWNSMzVDdGQwd1lCY3BCNlRac2xNY09QbDc2ZHdLd0pnZUpvMlFnClpzZm1jMnZDMS9xT2xOdU5xLzBUenprVkd2OEVUVDNDZ2FVK1VYZTRYT1Z2a2NjZWJKbjJkZz09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K';
  42515. $script = <<<'EOT'
  42516. error_reporting(-1);
  42517. $info = openssl_x509_parse(base64_decode('%s'));
  42518. var_dump(PHP_VERSION, $info['issuer']['emailAddress'], $info['validFrom_time_t']);
  42519. EOT;
  42520. $script = '<'."?php\n".sprintf($script, $cert);
  42521. try {
  42522. $process = new PhpProcess($script);
  42523. $process->mustRun();
  42524. } catch (\Exception $e) {
  42525. return self::$useOpensslParse = false;
  42526. }
  42527. $output = preg_split('{\r?\n}', trim($process->getOutput()));
  42528. $errorOutput = trim($process->getErrorOutput());
  42529. if (
  42530. is_array($output)
  42531. && count($output) === 3
  42532. && $output[0] === sprintf('string(%d) "%s"', strlen(PHP_VERSION), PHP_VERSION)
  42533. && $output[1] === 'string(27) "stefan.esser@sektioneins.de"'
  42534. && $output[2] === 'int(-1)'
  42535. && preg_match('{openssl_x509_parse\(\): illegal (?:ASN1 data type for|length in) timestamp in - on line \d+}', $errorOutput)
  42536. ) {
  42537. return self::$useOpensslParse = true;
  42538. }
  42539. return self::$useOpensslParse = false;
  42540. }
  42541. public static function reset()
  42542. {
  42543. self::$caFileValidity = array();
  42544. self::$caPath = null;
  42545. self::$useOpensslParse = null;
  42546. }
  42547. private static function getEnvVariable($name)
  42548. {
  42549. if (isset($_SERVER[$name])) {
  42550. return (string) $_SERVER[$name];
  42551. }
  42552. if (PHP_SAPI === 'cli' && ($value = getenv($name)) !== false && $value !== null) {
  42553. return (string) $value;
  42554. }
  42555. return false;
  42556. }
  42557. private static function caFileUsable($certFile, LoggerInterface $logger = null)
  42558. {
  42559. return $certFile
  42560. && static::isFile($certFile, $logger)
  42561. && static::isReadable($certFile, $logger)
  42562. && static::validateCaFile($certFile, $logger);
  42563. }
  42564. private static function caDirUsable($certDir, LoggerInterface $logger = null)
  42565. {
  42566. return $certDir
  42567. && static::isDir($certDir, $logger)
  42568. && static::isReadable($certDir, $logger)
  42569. && static::glob($certDir . '/*', $logger);
  42570. }
  42571. private static function isFile($certFile, LoggerInterface $logger = null)
  42572. {
  42573. $isFile = @is_file($certFile);
  42574. if (!$isFile && $logger) {
  42575. $logger->debug(sprintf('Checked CA file %s does not exist or it is not a file.', $certFile));
  42576. }
  42577. return $isFile;
  42578. }
  42579. private static function isDir($certDir, LoggerInterface $logger = null)
  42580. {
  42581. $isDir = @is_dir($certDir);
  42582. if (!$isDir && $logger) {
  42583. $logger->debug(sprintf('Checked directory %s does not exist or it is not a directory.', $certDir));
  42584. }
  42585. return $isDir;
  42586. }
  42587. private static function isReadable($certFileOrDir, LoggerInterface $logger = null)
  42588. {
  42589. $isReadable = @is_readable($certFileOrDir);
  42590. if (!$isReadable && $logger) {
  42591. $logger->debug(sprintf('Checked file or directory %s is not readable.', $certFileOrDir));
  42592. }
  42593. return $isReadable;
  42594. }
  42595. private static function glob($pattern, LoggerInterface $logger = null)
  42596. {
  42597. $certs = glob($pattern);
  42598. if ($certs === false) {
  42599. if ($logger) {
  42600. $logger->debug(sprintf("An error occurred while trying to find certificates for pattern: %s", $pattern));
  42601. }
  42602. return false;
  42603. }
  42604. if (count($certs) === 0) {
  42605. if ($logger) {
  42606. $logger->debug(sprintf("No CA files found for pattern: %s", $pattern));
  42607. }
  42608. return false;
  42609. }
  42610. return true;
  42611. }
  42612. }
  42613. <?php return array(
  42614. 'root' => array(
  42615. 'pretty_version' => '2.3.5',
  42616. 'version' => '2.3.5.0',
  42617. 'type' => 'library',
  42618. 'install_path' => __DIR__ . '/../../',
  42619. 'aliases' => array(),
  42620. 'reference' => '50c47b1f907cfcdb8f072b88164d22b527557ae1',
  42621. 'name' => 'composer/composer',
  42622. 'dev' => false,
  42623. ),
  42624. 'versions' => array(
  42625. 'composer/ca-bundle' => array(
  42626. 'pretty_version' => '1.3.1',
  42627. 'version' => '1.3.1.0',
  42628. 'type' => 'library',
  42629. 'install_path' => __DIR__ . '/./ca-bundle',
  42630. 'aliases' => array(),
  42631. 'reference' => '4c679186f2aca4ab6a0f1b0b9cf9252decb44d0b',
  42632. 'dev_requirement' => false,
  42633. ),
  42634. 'composer/composer' => array(
  42635. 'pretty_version' => '2.3.5',
  42636. 'version' => '2.3.5.0',
  42637. 'type' => 'library',
  42638. 'install_path' => __DIR__ . '/../../',
  42639. 'aliases' => array(),
  42640. 'reference' => '50c47b1f907cfcdb8f072b88164d22b527557ae1',
  42641. 'dev_requirement' => false,
  42642. ),
  42643. 'composer/metadata-minifier' => array(
  42644. 'pretty_version' => '1.0.0',
  42645. 'version' => '1.0.0.0',
  42646. 'type' => 'library',
  42647. 'install_path' => __DIR__ . '/./metadata-minifier',
  42648. 'aliases' => array(),
  42649. 'reference' => 'c549d23829536f0d0e984aaabbf02af91f443207',
  42650. 'dev_requirement' => false,
  42651. ),
  42652. 'composer/pcre' => array(
  42653. 'pretty_version' => '2.0.0',
  42654. 'version' => '2.0.0.0',
  42655. 'type' => 'library',
  42656. 'install_path' => __DIR__ . '/./pcre',
  42657. 'aliases' => array(),
  42658. 'reference' => 'c8e9d27cfc5ed22643c19c160455b473ffd8aabe',
  42659. 'dev_requirement' => false,
  42660. ),
  42661. 'composer/semver' => array(
  42662. 'pretty_version' => '3.3.2',
  42663. 'version' => '3.3.2.0',
  42664. 'type' => 'library',
  42665. 'install_path' => __DIR__ . '/./semver',
  42666. 'aliases' => array(),
  42667. 'reference' => '3953f23262f2bff1919fc82183ad9acb13ff62c9',
  42668. 'dev_requirement' => false,
  42669. ),
  42670. 'composer/spdx-licenses' => array(
  42671. 'pretty_version' => '1.5.6',
  42672. 'version' => '1.5.6.0',
  42673. 'type' => 'library',
  42674. 'install_path' => __DIR__ . '/./spdx-licenses',
  42675. 'aliases' => array(),
  42676. 'reference' => 'a30d487169d799745ca7280bc90fdfa693536901',
  42677. 'dev_requirement' => false,
  42678. ),
  42679. 'composer/xdebug-handler' => array(
  42680. 'pretty_version' => '3.0.3',
  42681. 'version' => '3.0.3.0',
  42682. 'type' => 'library',
  42683. 'install_path' => __DIR__ . '/./xdebug-handler',
  42684. 'aliases' => array(),
  42685. 'reference' => 'ced299686f41dce890debac69273b47ffe98a40c',
  42686. 'dev_requirement' => false,
  42687. ),
  42688. 'justinrainbow/json-schema' => array(
  42689. 'pretty_version' => '5.2.11',
  42690. 'version' => '5.2.11.0',
  42691. 'type' => 'library',
  42692. 'install_path' => __DIR__ . '/../justinrainbow/json-schema',
  42693. 'aliases' => array(),
  42694. 'reference' => '2ab6744b7296ded80f8cc4f9509abbff393399aa',
  42695. 'dev_requirement' => false,
  42696. ),
  42697. 'psr/container' => array(
  42698. 'pretty_version' => '1.1.1',
  42699. 'version' => '1.1.1.0',
  42700. 'type' => 'library',
  42701. 'install_path' => __DIR__ . '/../psr/container',
  42702. 'aliases' => array(),
  42703. 'reference' => '8622567409010282b7aeebe4bb841fe98b58dcaf',
  42704. 'dev_requirement' => false,
  42705. ),
  42706. 'psr/log' => array(
  42707. 'pretty_version' => '1.1.4',
  42708. 'version' => '1.1.4.0',
  42709. 'type' => 'library',
  42710. 'install_path' => __DIR__ . '/../psr/log',
  42711. 'aliases' => array(),
  42712. 'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11',
  42713. 'dev_requirement' => false,
  42714. ),
  42715. 'psr/log-implementation' => array(
  42716. 'dev_requirement' => false,
  42717. 'provided' => array(
  42718. 0 => '1.0|2.0',
  42719. ),
  42720. ),
  42721. 'react/promise' => array(
  42722. 'pretty_version' => 'v2.9.0',
  42723. 'version' => '2.9.0.0',
  42724. 'type' => 'library',
  42725. 'install_path' => __DIR__ . '/../react/promise',
  42726. 'aliases' => array(),
  42727. 'reference' => '234f8fd1023c9158e2314fa9d7d0e6a83db42910',
  42728. 'dev_requirement' => false,
  42729. ),
  42730. 'seld/jsonlint' => array(
  42731. 'pretty_version' => '1.9.0',
  42732. 'version' => '1.9.0.0',
  42733. 'type' => 'library',
  42734. 'install_path' => __DIR__ . '/../seld/jsonlint',
  42735. 'aliases' => array(),
  42736. 'reference' => '4211420d25eba80712bff236a98960ef68b866b7',
  42737. 'dev_requirement' => false,
  42738. ),
  42739. 'seld/phar-utils' => array(
  42740. 'pretty_version' => '1.2.0',
  42741. 'version' => '1.2.0.0',
  42742. 'type' => 'library',
  42743. 'install_path' => __DIR__ . '/../seld/phar-utils',
  42744. 'aliases' => array(),
  42745. 'reference' => '9f3452c93ff423469c0d56450431562ca423dcee',
  42746. 'dev_requirement' => false,
  42747. ),
  42748. 'symfony/console' => array(
  42749. 'pretty_version' => 'v5.4.5',
  42750. 'version' => '5.4.5.0',
  42751. 'type' => 'library',
  42752. 'install_path' => __DIR__ . '/../symfony/console',
  42753. 'aliases' => array(),
  42754. 'reference' => 'd8111acc99876953f52fe16d4c50eb60940d49ad',
  42755. 'dev_requirement' => false,
  42756. ),
  42757. 'symfony/deprecation-contracts' => array(
  42758. 'pretty_version' => 'v2.5.0',
  42759. 'version' => '2.5.0.0',
  42760. 'type' => 'library',
  42761. 'install_path' => __DIR__ . '/../symfony/deprecation-contracts',
  42762. 'aliases' => array(),
  42763. 'reference' => '6f981ee24cf69ee7ce9736146d1c57c2780598a8',
  42764. 'dev_requirement' => false,
  42765. ),
  42766. 'symfony/filesystem' => array(
  42767. 'pretty_version' => 'v5.4.6',
  42768. 'version' => '5.4.6.0',
  42769. 'type' => 'library',
  42770. 'install_path' => __DIR__ . '/../symfony/filesystem',
  42771. 'aliases' => array(),
  42772. 'reference' => 'd53a45039974952af7f7ebc461ccdd4295e29440',
  42773. 'dev_requirement' => false,
  42774. ),
  42775. 'symfony/finder' => array(
  42776. 'pretty_version' => 'v5.4.3',
  42777. 'version' => '5.4.3.0',
  42778. 'type' => 'library',
  42779. 'install_path' => __DIR__ . '/../symfony/finder',
  42780. 'aliases' => array(),
  42781. 'reference' => '231313534dded84c7ecaa79d14bc5da4ccb69b7d',
  42782. 'dev_requirement' => false,
  42783. ),
  42784. 'symfony/polyfill-ctype' => array(
  42785. 'pretty_version' => 'v1.25.0',
  42786. 'version' => '1.25.0.0',
  42787. 'type' => 'library',
  42788. 'install_path' => __DIR__ . '/../symfony/polyfill-ctype',
  42789. 'aliases' => array(),
  42790. 'reference' => '30885182c981ab175d4d034db0f6f469898070ab',
  42791. 'dev_requirement' => false,
  42792. ),
  42793. 'symfony/polyfill-intl-grapheme' => array(
  42794. 'pretty_version' => 'v1.25.0',
  42795. 'version' => '1.25.0.0',
  42796. 'type' => 'library',
  42797. 'install_path' => __DIR__ . '/../symfony/polyfill-intl-grapheme',
  42798. 'aliases' => array(),
  42799. 'reference' => '81b86b50cf841a64252b439e738e97f4a34e2783',
  42800. 'dev_requirement' => false,
  42801. ),
  42802. 'symfony/polyfill-intl-normalizer' => array(
  42803. 'pretty_version' => 'v1.25.0',
  42804. 'version' => '1.25.0.0',
  42805. 'type' => 'library',
  42806. 'install_path' => __DIR__ . '/../symfony/polyfill-intl-normalizer',
  42807. 'aliases' => array(),
  42808. 'reference' => '8590a5f561694770bdcd3f9b5c69dde6945028e8',
  42809. 'dev_requirement' => false,
  42810. ),
  42811. 'symfony/polyfill-mbstring' => array(
  42812. 'pretty_version' => 'v1.25.0',
  42813. 'version' => '1.25.0.0',
  42814. 'type' => 'library',
  42815. 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring',
  42816. 'aliases' => array(),
  42817. 'reference' => '0abb51d2f102e00a4eefcf46ba7fec406d245825',
  42818. 'dev_requirement' => false,
  42819. ),
  42820. 'symfony/polyfill-php73' => array(
  42821. 'pretty_version' => 'v1.25.0',
  42822. 'version' => '1.25.0.0',
  42823. 'type' => 'library',
  42824. 'install_path' => __DIR__ . '/../symfony/polyfill-php73',
  42825. 'aliases' => array(),
  42826. 'reference' => 'cc5db0e22b3cb4111010e48785a97f670b350ca5',
  42827. 'dev_requirement' => false,
  42828. ),
  42829. 'symfony/polyfill-php80' => array(
  42830. 'pretty_version' => 'v1.25.0',
  42831. 'version' => '1.25.0.0',
  42832. 'type' => 'library',
  42833. 'install_path' => __DIR__ . '/../symfony/polyfill-php80',
  42834. 'aliases' => array(),
  42835. 'reference' => '4407588e0d3f1f52efb65fbe92babe41f37fe50c',
  42836. 'dev_requirement' => false,
  42837. ),
  42838. 'symfony/process' => array(
  42839. 'pretty_version' => 'v5.4.5',
  42840. 'version' => '5.4.5.0',
  42841. 'type' => 'library',
  42842. 'install_path' => __DIR__ . '/../symfony/process',
  42843. 'aliases' => array(),
  42844. 'reference' => '95440409896f90a5f85db07a32b517ecec17fa4c',
  42845. 'dev_requirement' => false,
  42846. ),
  42847. 'symfony/service-contracts' => array(
  42848. 'pretty_version' => 'v2.5.0',
  42849. 'version' => '2.5.0.0',
  42850. 'type' => 'library',
  42851. 'install_path' => __DIR__ . '/../symfony/service-contracts',
  42852. 'aliases' => array(),
  42853. 'reference' => '1ab11b933cd6bc5464b08e81e2c5b07dec58b0fc',
  42854. 'dev_requirement' => false,
  42855. ),
  42856. 'symfony/string' => array(
  42857. 'pretty_version' => 'v5.4.3',
  42858. 'version' => '5.4.3.0',
  42859. 'type' => 'library',
  42860. 'install_path' => __DIR__ . '/../symfony/string',
  42861. 'aliases' => array(),
  42862. 'reference' => '92043b7d8383e48104e411bc9434b260dbeb5a10',
  42863. 'dev_requirement' => false,
  42864. ),
  42865. ),
  42866. );
  42867. Copyright (C) 2021 Composer
  42868. Permission is hereby granted, free of charge, to any person obtaining a copy of
  42869. this software and associated documentation files (the "Software"), to deal in
  42870. the Software without restriction, including without limitation the rights to
  42871. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  42872. of the Software, and to permit persons to whom the Software is furnished to do
  42873. so, subject to the following conditions:
  42874. The above copyright notice and this permission notice shall be included in all
  42875. copies or substantial portions of the Software.
  42876. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  42877. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  42878. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  42879. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  42880. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  42881. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  42882. SOFTWARE.
  42883. <?php
  42884. namespace Composer\MetadataMinifier;
  42885. class MetadataMinifier
  42886. {
  42887. public static function expand(array $versions)
  42888. {
  42889. $expanded = array();
  42890. $expandedVersion = null;
  42891. foreach ($versions as $versionData) {
  42892. if (!$expandedVersion) {
  42893. $expandedVersion = $versionData;
  42894. $expanded[] = $expandedVersion;
  42895. continue;
  42896. }
  42897. foreach ($versionData as $key => $val) {
  42898. if ($val === '__unset') {
  42899. unset($expandedVersion[$key]);
  42900. } else {
  42901. $expandedVersion[$key] = $val;
  42902. }
  42903. }
  42904. $expanded[] = $expandedVersion;
  42905. }
  42906. return $expanded;
  42907. }
  42908. public static function minify(array $versions)
  42909. {
  42910. $minifiedVersions = array();
  42911. $lastKnownVersionData = null;
  42912. foreach ($versions as $version) {
  42913. if (!$lastKnownVersionData) {
  42914. $lastKnownVersionData = $version;
  42915. $minifiedVersions[] = $version;
  42916. continue;
  42917. }
  42918. $minifiedVersion = array();
  42919. foreach ($version as $key => $val) {
  42920. if (!isset($lastKnownVersionData[$key]) || $lastKnownVersionData[$key] !== $val) {
  42921. $minifiedVersion[$key] = $val;
  42922. $lastKnownVersionData[$key] = $val;
  42923. }
  42924. }
  42925. foreach ($lastKnownVersionData as $key => $val) {
  42926. if (!isset($version[$key])) {
  42927. $minifiedVersion[$key] = "__unset";
  42928. unset($lastKnownVersionData[$key]);
  42929. }
  42930. }
  42931. $minifiedVersions[] = $minifiedVersion;
  42932. }
  42933. return $minifiedVersions;
  42934. }
  42935. }
  42936. Copyright (C) 2021 Composer
  42937. Permission is hereby granted, free of charge, to any person obtaining a copy of
  42938. this software and associated documentation files (the "Software"), to deal in
  42939. the Software without restriction, including without limitation the rights to
  42940. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  42941. of the Software, and to permit persons to whom the Software is furnished to do
  42942. so, subject to the following conditions:
  42943. The above copyright notice and this permission notice shall be included in all
  42944. copies or substantial portions of the Software.
  42945. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  42946. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  42947. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  42948. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  42949. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  42950. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  42951. SOFTWARE.
  42952. <?php
  42953. namespace Composer\Pcre;
  42954. final class MatchAllResult
  42955. {
  42956. public $matches;
  42957. public $count;
  42958. public $matched;
  42959. public function __construct($count, array $matches)
  42960. {
  42961. $this->matches = $matches;
  42962. $this->matched = (bool) $count;
  42963. $this->count = $count;
  42964. }
  42965. }
  42966. <?php
  42967. namespace Composer\Pcre;
  42968. final class MatchAllWithOffsetsResult
  42969. {
  42970. public $matches;
  42971. public $count;
  42972. public $matched;
  42973. public function __construct($count, array $matches)
  42974. {
  42975. $this->matches = $matches;
  42976. $this->matched = (bool) $count;
  42977. $this->count = $count;
  42978. }
  42979. }
  42980. <?php
  42981. namespace Composer\Pcre;
  42982. final class MatchResult
  42983. {
  42984. public $matches;
  42985. public $matched;
  42986. public function __construct($count, array $matches)
  42987. {
  42988. $this->matches = $matches;
  42989. $this->matched = (bool) $count;
  42990. }
  42991. }
  42992. <?php
  42993. namespace Composer\Pcre;
  42994. final class MatchWithOffsetsResult
  42995. {
  42996. public $matches;
  42997. public $matched;
  42998. public function __construct($count, array $matches)
  42999. {
  43000. $this->matches = $matches;
  43001. $this->matched = (bool) $count;
  43002. }
  43003. }
  43004. <?php
  43005. namespace Composer\Pcre;
  43006. class PcreException extends \RuntimeException
  43007. {
  43008. public static function fromFunction($function, $pattern)
  43009. {
  43010. $code = preg_last_error();
  43011. if (is_array($pattern)) {
  43012. $pattern = implode(', ', $pattern);
  43013. }
  43014. return new PcreException($function.'(): failed executing "'.$pattern.'": '.self::pcreLastErrorMessage($code), $code);
  43015. }
  43016. private static function pcreLastErrorMessage($code)
  43017. {
  43018. if (function_exists('preg_last_error_msg')) {
  43019. return preg_last_error_msg();
  43020. }
  43021. if (PHP_VERSION_ID < 70201 && $code === 0) {
  43022. return 'UNDEFINED_ERROR';
  43023. }
  43024. $constants = get_defined_constants(true);
  43025. if (!isset($constants['pcre'])) {
  43026. return 'UNDEFINED_ERROR';
  43027. }
  43028. foreach ($constants['pcre'] as $const => $val) {
  43029. if ($val === $code && substr($const, -6) === '_ERROR') {
  43030. return $const;
  43031. }
  43032. }
  43033. return 'UNDEFINED_ERROR';
  43034. }
  43035. }
  43036. <?php
  43037. namespace Composer\Pcre;
  43038. class Preg
  43039. {
  43040. public const ARRAY_MSG = '$subject as an array is not supported. You can use \'foreach\' instead.';
  43041. public const INVALID_TYPE_MSG = '$subject must be a string, %s given.';
  43042. public static function match(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int
  43043. {
  43044. if (($flags & PREG_OFFSET_CAPTURE) !== 0) {
  43045. throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the type of $matches, use matchWithOffsets() instead');
  43046. }
  43047. $result = preg_match($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL, $offset);
  43048. if ($result === false) {
  43049. throw PcreException::fromFunction('preg_match', $pattern);
  43050. }
  43051. return $result;
  43052. }
  43053. public static function matchWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): int
  43054. {
  43055. $result = preg_match($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL | PREG_OFFSET_CAPTURE, $offset);
  43056. if ($result === false) {
  43057. throw PcreException::fromFunction('preg_match', $pattern);
  43058. }
  43059. return $result;
  43060. }
  43061. public static function matchAll(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int
  43062. {
  43063. if (($flags & PREG_OFFSET_CAPTURE) !== 0) {
  43064. throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the type of $matches, use matchAllWithOffsets() instead');
  43065. }
  43066. if (($flags & PREG_SET_ORDER) !== 0) {
  43067. throw new \InvalidArgumentException('PREG_SET_ORDER is not supported as it changes the type of $matches');
  43068. }
  43069. $result = preg_match_all($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL, $offset);
  43070. if ($result === false || $result === null) {
  43071. throw PcreException::fromFunction('preg_match_all', $pattern);
  43072. }
  43073. return $result;
  43074. }
  43075. public static function matchAllWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): int
  43076. {
  43077. $result = preg_match_all($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL | PREG_OFFSET_CAPTURE, $offset);
  43078. if ($result === false || $result === null) {
  43079. throw PcreException::fromFunction('preg_match_all', $pattern);
  43080. }
  43081. return $result;
  43082. }
  43083. public static function replace($pattern, $replacement, $subject, int $limit = -1, int &$count = null): string
  43084. {
  43085. if (!is_scalar($subject)) {
  43086. if (is_array($subject)) {
  43087. throw new \InvalidArgumentException(static::ARRAY_MSG);
  43088. }
  43089. throw new \TypeError(sprintf(static::INVALID_TYPE_MSG, gettype($subject)));
  43090. }
  43091. $result = preg_replace($pattern, $replacement, $subject, $limit, $count);
  43092. if ($result === null) {
  43093. throw PcreException::fromFunction('preg_replace', $pattern);
  43094. }
  43095. return $result;
  43096. }
  43097. public static function replaceCallback($pattern, callable $replacement, $subject, int $limit = -1, int &$count = null, int $flags = 0): string
  43098. {
  43099. if (!is_scalar($subject)) {
  43100. if (is_array($subject)) {
  43101. throw new \InvalidArgumentException(static::ARRAY_MSG);
  43102. }
  43103. throw new \TypeError(sprintf(static::INVALID_TYPE_MSG, gettype($subject)));
  43104. }
  43105. if (PHP_VERSION_ID >= 70400) {
  43106. $result = preg_replace_callback($pattern, $replacement, $subject, $limit, $count, $flags);
  43107. } else {
  43108. $result = preg_replace_callback($pattern, $replacement, $subject, $limit, $count);
  43109. }
  43110. if ($result === null) {
  43111. throw PcreException::fromFunction('preg_replace_callback', $pattern);
  43112. }
  43113. return $result;
  43114. }
  43115. public static function replaceCallbackArray(array $pattern, $subject, int $limit = -1, int &$count = null, int $flags = 0): string
  43116. {
  43117. if (!is_scalar($subject)) {
  43118. if (is_array($subject)) {
  43119. throw new \InvalidArgumentException(static::ARRAY_MSG);
  43120. }
  43121. throw new \TypeError(sprintf(static::INVALID_TYPE_MSG, gettype($subject)));
  43122. }
  43123. if (PHP_VERSION_ID >= 70400) {
  43124. $result = preg_replace_callback_array($pattern, $subject, $limit, $count, $flags);
  43125. } else {
  43126. $result = preg_replace_callback_array($pattern, $subject, $limit, $count);
  43127. }
  43128. if ($result === null) {
  43129. $pattern = array_keys($pattern);
  43130. throw PcreException::fromFunction('preg_replace_callback_array', $pattern);
  43131. }
  43132. return $result;
  43133. }
  43134. public static function split(string $pattern, string $subject, int $limit = -1, int $flags = 0): array
  43135. {
  43136. if (($flags & PREG_SPLIT_OFFSET_CAPTURE) !== 0) {
  43137. throw new \InvalidArgumentException('PREG_SPLIT_OFFSET_CAPTURE is not supported as it changes the type of $matches, use splitWithOffsets() instead');
  43138. }
  43139. $result = preg_split($pattern, $subject, $limit, $flags);
  43140. if ($result === false) {
  43141. throw PcreException::fromFunction('preg_split', $pattern);
  43142. }
  43143. return $result;
  43144. }
  43145. public static function splitWithOffsets(string $pattern, string $subject, int $limit = -1, int $flags = 0): array
  43146. {
  43147. $result = preg_split($pattern, $subject, $limit, $flags | PREG_SPLIT_OFFSET_CAPTURE);
  43148. if ($result === false) {
  43149. throw PcreException::fromFunction('preg_split', $pattern);
  43150. }
  43151. return $result;
  43152. }
  43153. public static function grep(string $pattern, array $array, int $flags = 0): array
  43154. {
  43155. $result = preg_grep($pattern, $array, $flags);
  43156. if ($result === false) {
  43157. throw PcreException::fromFunction('preg_grep', $pattern);
  43158. }
  43159. return $result;
  43160. }
  43161. public static function isMatch(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool
  43162. {
  43163. return (bool) static::match($pattern, $subject, $matches, $flags, $offset);
  43164. }
  43165. public static function isMatchAll(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool
  43166. {
  43167. return (bool) static::matchAll($pattern, $subject, $matches, $flags, $offset);
  43168. }
  43169. public static function isMatchWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): bool
  43170. {
  43171. return (bool) static::matchWithOffsets($pattern, $subject, $matches, $flags, $offset);
  43172. }
  43173. public static function isMatchAllWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): bool
  43174. {
  43175. return (bool) static::matchAllWithOffsets($pattern, $subject, $matches, $flags, $offset);
  43176. }
  43177. }
  43178. <?php
  43179. namespace Composer\Pcre;
  43180. class Regex
  43181. {
  43182. public static function isMatch(string $pattern, string $subject, int $offset = 0): bool
  43183. {
  43184. return (bool) Preg::match($pattern, $subject, $matches, 0, $offset);
  43185. }
  43186. public static function match(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchResult
  43187. {
  43188. if (($flags & PREG_OFFSET_CAPTURE) !== 0) {
  43189. throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the return type, use matchWithOffsets() instead');
  43190. }
  43191. $count = Preg::match($pattern, $subject, $matches, $flags, $offset);
  43192. return new MatchResult($count, $matches);
  43193. }
  43194. public static function matchWithOffsets(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchWithOffsetsResult
  43195. {
  43196. $count = Preg::matchWithOffsets($pattern, $subject, $matches, $flags, $offset);
  43197. return new MatchWithOffsetsResult($count, $matches);
  43198. }
  43199. public static function matchAll(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchAllResult
  43200. {
  43201. if (($flags & PREG_OFFSET_CAPTURE) !== 0) {
  43202. throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the return type, use matchAllWithOffsets() instead');
  43203. }
  43204. if (($flags & PREG_SET_ORDER) !== 0) {
  43205. throw new \InvalidArgumentException('PREG_SET_ORDER is not supported as it changes the return type');
  43206. }
  43207. $count = Preg::matchAll($pattern, $subject, $matches, $flags, $offset);
  43208. return new MatchAllResult($count, $matches);
  43209. }
  43210. public static function matchAllWithOffsets(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchAllWithOffsetsResult
  43211. {
  43212. $count = Preg::matchAllWithOffsets($pattern, $subject, $matches, $flags, $offset);
  43213. return new MatchAllWithOffsetsResult($count, $matches);
  43214. }
  43215. public static function replace($pattern, $replacement, $subject, int $limit = -1): ReplaceResult
  43216. {
  43217. $result = Preg::replace($pattern, $replacement, $subject, $limit, $count);
  43218. return new ReplaceResult($count, $result);
  43219. }
  43220. public static function replaceCallback($pattern, callable $replacement, $subject, int $limit = -1, int $flags = 0): ReplaceResult
  43221. {
  43222. $result = Preg::replaceCallback($pattern, $replacement, $subject, $limit, $count, $flags);
  43223. return new ReplaceResult($count, $result);
  43224. }
  43225. public static function replaceCallbackArray(array $pattern, $subject, int $limit = -1, int $flags = 0): ReplaceResult
  43226. {
  43227. $result = Preg::replaceCallbackArray($pattern, $subject, $limit, $count, $flags);
  43228. return new ReplaceResult($count, $result);
  43229. }
  43230. }
  43231. <?php
  43232. namespace Composer\Pcre;
  43233. final class ReplaceResult
  43234. {
  43235. public $result;
  43236. public $count;
  43237. public $matched;
  43238. public function __construct($count, $result)
  43239. {
  43240. $this->count = $count;
  43241. $this->matched = (bool) $count;
  43242. $this->result = $result;
  43243. }
  43244. }
  43245. Copyright (C) 2015 Composer
  43246. Permission is hereby granted, free of charge, to any person obtaining a copy of
  43247. this software and associated documentation files (the "Software"), to deal in
  43248. the Software without restriction, including without limitation the rights to
  43249. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  43250. of the Software, and to permit persons to whom the Software is furnished to do
  43251. so, subject to the following conditions:
  43252. The above copyright notice and this permission notice shall be included in all
  43253. copies or substantial portions of the Software.
  43254. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  43255. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  43256. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  43257. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  43258. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  43259. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  43260. SOFTWARE.
  43261. <?php
  43262. namespace Composer\Semver;
  43263. use Composer\Semver\Constraint\Constraint;
  43264. class Comparator
  43265. {
  43266. public static function greaterThan($version1, $version2)
  43267. {
  43268. return self::compare($version1, '>', $version2);
  43269. }
  43270. public static function greaterThanOrEqualTo($version1, $version2)
  43271. {
  43272. return self::compare($version1, '>=', $version2);
  43273. }
  43274. public static function lessThan($version1, $version2)
  43275. {
  43276. return self::compare($version1, '<', $version2);
  43277. }
  43278. public static function lessThanOrEqualTo($version1, $version2)
  43279. {
  43280. return self::compare($version1, '<=', $version2);
  43281. }
  43282. public static function equalTo($version1, $version2)
  43283. {
  43284. return self::compare($version1, '==', $version2);
  43285. }
  43286. public static function notEqualTo($version1, $version2)
  43287. {
  43288. return self::compare($version1, '!=', $version2);
  43289. }
  43290. public static function compare($version1, $operator, $version2)
  43291. {
  43292. $constraint = new Constraint($operator, $version2);
  43293. return $constraint->matchSpecific(new Constraint('==', $version1), true);
  43294. }
  43295. }
  43296. <?php
  43297. namespace Composer\Semver;
  43298. use Composer\Semver\Constraint\Constraint;
  43299. use Composer\Semver\Constraint\ConstraintInterface;
  43300. class CompilingMatcher
  43301. {
  43302. private static $compiledCheckerCache = array();
  43303. private static $resultCache = array();
  43304. private static $enabled;
  43305. private static $transOpInt = array(
  43306. Constraint::OP_EQ => Constraint::STR_OP_EQ,
  43307. Constraint::OP_LT => Constraint::STR_OP_LT,
  43308. Constraint::OP_LE => Constraint::STR_OP_LE,
  43309. Constraint::OP_GT => Constraint::STR_OP_GT,
  43310. Constraint::OP_GE => Constraint::STR_OP_GE,
  43311. Constraint::OP_NE => Constraint::STR_OP_NE,
  43312. );
  43313. public static function clear()
  43314. {
  43315. self::$resultCache = array();
  43316. self::$compiledCheckerCache = array();
  43317. }
  43318. public static function match(ConstraintInterface $constraint, $operator, $version)
  43319. {
  43320. $resultCacheKey = $operator.$constraint.';'.$version;
  43321. if (isset(self::$resultCache[$resultCacheKey])) {
  43322. return self::$resultCache[$resultCacheKey];
  43323. }
  43324. if (self::$enabled === null) {
  43325. self::$enabled = !\in_array('eval', explode(',', (string) ini_get('disable_functions')), true);
  43326. }
  43327. if (!self::$enabled) {
  43328. return self::$resultCache[$resultCacheKey] = $constraint->matches(new Constraint(self::$transOpInt[$operator], $version));
  43329. }
  43330. $cacheKey = $operator.$constraint;
  43331. if (!isset(self::$compiledCheckerCache[$cacheKey])) {
  43332. $code = $constraint->compile($operator);
  43333. self::$compiledCheckerCache[$cacheKey] = $function = eval('return function($v, $b){return '.$code.';};');
  43334. } else {
  43335. $function = self::$compiledCheckerCache[$cacheKey];
  43336. }
  43337. return self::$resultCache[$resultCacheKey] = $function($version, strpos($version, 'dev-') === 0);
  43338. }
  43339. }
  43340. <?php
  43341. namespace Composer\Semver\Constraint;
  43342. class Bound
  43343. {
  43344. private $version;
  43345. private $isInclusive;
  43346. public function __construct($version, $isInclusive)
  43347. {
  43348. $this->version = $version;
  43349. $this->isInclusive = $isInclusive;
  43350. }
  43351. public function getVersion()
  43352. {
  43353. return $this->version;
  43354. }
  43355. public function isInclusive()
  43356. {
  43357. return $this->isInclusive;
  43358. }
  43359. public function isZero()
  43360. {
  43361. return $this->getVersion() === '0.0.0.0-dev' && $this->isInclusive();
  43362. }
  43363. public function isPositiveInfinity()
  43364. {
  43365. return $this->getVersion() === PHP_INT_MAX.'.0.0.0' && !$this->isInclusive();
  43366. }
  43367. public function compareTo(Bound $other, $operator)
  43368. {
  43369. if (!\in_array($operator, array('<', '>'), true)) {
  43370. throw new \InvalidArgumentException('Does not support any other operator other than > or <.');
  43371. }
  43372. if ($this == $other) {
  43373. return false;
  43374. }
  43375. $compareResult = version_compare($this->getVersion(), $other->getVersion());
  43376. if (0 !== $compareResult) {
  43377. return (('>' === $operator) ? 1 : -1) === $compareResult;
  43378. }
  43379. return '>' === $operator ? $other->isInclusive() : !$other->isInclusive();
  43380. }
  43381. public function __toString()
  43382. {
  43383. return sprintf(
  43384. '%s [%s]',
  43385. $this->getVersion(),
  43386. $this->isInclusive() ? 'inclusive' : 'exclusive'
  43387. );
  43388. }
  43389. public static function zero()
  43390. {
  43391. return new Bound('0.0.0.0-dev', true);
  43392. }
  43393. public static function positiveInfinity()
  43394. {
  43395. return new Bound(PHP_INT_MAX.'.0.0.0', false);
  43396. }
  43397. }
  43398. <?php
  43399. namespace Composer\Semver\Constraint;
  43400. class Constraint implements ConstraintInterface
  43401. {
  43402. const OP_EQ = 0;
  43403. const OP_LT = 1;
  43404. const OP_LE = 2;
  43405. const OP_GT = 3;
  43406. const OP_GE = 4;
  43407. const OP_NE = 5;
  43408. const STR_OP_EQ = '==';
  43409. const STR_OP_EQ_ALT = '=';
  43410. const STR_OP_LT = '<';
  43411. const STR_OP_LE = '<=';
  43412. const STR_OP_GT = '>';
  43413. const STR_OP_GE = '>=';
  43414. const STR_OP_NE = '!=';
  43415. const STR_OP_NE_ALT = '<>';
  43416. private static $transOpStr = array(
  43417. '=' => self::OP_EQ,
  43418. '==' => self::OP_EQ,
  43419. '<' => self::OP_LT,
  43420. '<=' => self::OP_LE,
  43421. '>' => self::OP_GT,
  43422. '>=' => self::OP_GE,
  43423. '<>' => self::OP_NE,
  43424. '!=' => self::OP_NE,
  43425. );
  43426. private static $transOpInt = array(
  43427. self::OP_EQ => '==',
  43428. self::OP_LT => '<',
  43429. self::OP_LE => '<=',
  43430. self::OP_GT => '>',
  43431. self::OP_GE => '>=',
  43432. self::OP_NE => '!=',
  43433. );
  43434. protected $operator;
  43435. protected $version;
  43436. protected $prettyString;
  43437. protected $lowerBound;
  43438. protected $upperBound;
  43439. public function __construct($operator, $version)
  43440. {
  43441. if (!isset(self::$transOpStr[$operator])) {
  43442. throw new \InvalidArgumentException(sprintf(
  43443. 'Invalid operator "%s" given, expected one of: %s',
  43444. $operator,
  43445. implode(', ', self::getSupportedOperators())
  43446. ));
  43447. }
  43448. $this->operator = self::$transOpStr[$operator];
  43449. $this->version = $version;
  43450. }
  43451. public function getVersion()
  43452. {
  43453. return $this->version;
  43454. }
  43455. public function getOperator()
  43456. {
  43457. return self::$transOpInt[$this->operator];
  43458. }
  43459. public function matches(ConstraintInterface $provider)
  43460. {
  43461. if ($provider instanceof self) {
  43462. return $this->matchSpecific($provider);
  43463. }
  43464. return $provider->matches($this);
  43465. }
  43466. public function setPrettyString($prettyString)
  43467. {
  43468. $this->prettyString = $prettyString;
  43469. }
  43470. public function getPrettyString()
  43471. {
  43472. if ($this->prettyString) {
  43473. return $this->prettyString;
  43474. }
  43475. return $this->__toString();
  43476. }
  43477. public static function getSupportedOperators()
  43478. {
  43479. return array_keys(self::$transOpStr);
  43480. }
  43481. public static function getOperatorConstant($operator)
  43482. {
  43483. return self::$transOpStr[$operator];
  43484. }
  43485. public function versionCompare($a, $b, $operator, $compareBranches = false)
  43486. {
  43487. if (!isset(self::$transOpStr[$operator])) {
  43488. throw new \InvalidArgumentException(sprintf(
  43489. 'Invalid operator "%s" given, expected one of: %s',
  43490. $operator,
  43491. implode(', ', self::getSupportedOperators())
  43492. ));
  43493. }
  43494. $aIsBranch = strpos($a, 'dev-') === 0;
  43495. $bIsBranch = strpos($b, 'dev-') === 0;
  43496. if ($operator === '!=' && ($aIsBranch || $bIsBranch)) {
  43497. return $a !== $b;
  43498. }
  43499. if ($aIsBranch && $bIsBranch) {
  43500. return $operator === '==' && $a === $b;
  43501. }
  43502. if (!$compareBranches && ($aIsBranch || $bIsBranch)) {
  43503. return false;
  43504. }
  43505. return \version_compare($a, $b, $operator);
  43506. }
  43507. public function compile($otherOperator)
  43508. {
  43509. if (strpos($this->version, 'dev-') === 0) {
  43510. if (self::OP_EQ === $this->operator) {
  43511. if (self::OP_EQ === $otherOperator) {
  43512. return sprintf('$b && $v === %s', \var_export($this->version, true));
  43513. }
  43514. if (self::OP_NE === $otherOperator) {
  43515. return sprintf('!$b || $v !== %s', \var_export($this->version, true));
  43516. }
  43517. return 'false';
  43518. }
  43519. if (self::OP_NE === $this->operator) {
  43520. if (self::OP_EQ === $otherOperator) {
  43521. return sprintf('!$b || $v !== %s', \var_export($this->version, true));
  43522. }
  43523. if (self::OP_NE === $otherOperator) {
  43524. return 'true';
  43525. }
  43526. return '!$b';
  43527. }
  43528. return 'false';
  43529. }
  43530. if (self::OP_EQ === $this->operator) {
  43531. if (self::OP_EQ === $otherOperator) {
  43532. return sprintf('\version_compare($v, %s, \'==\')', \var_export($this->version, true));
  43533. }
  43534. if (self::OP_NE === $otherOperator) {
  43535. return sprintf('$b || \version_compare($v, %s, \'!=\')', \var_export($this->version, true));
  43536. }
  43537. return sprintf('!$b && \version_compare(%s, $v, \'%s\')', \var_export($this->version, true), self::$transOpInt[$otherOperator]);
  43538. }
  43539. if (self::OP_NE === $this->operator) {
  43540. if (self::OP_EQ === $otherOperator) {
  43541. return sprintf('$b || (!$b && \version_compare($v, %s, \'!=\'))', \var_export($this->version, true));
  43542. }
  43543. if (self::OP_NE === $otherOperator) {
  43544. return 'true';
  43545. }
  43546. return '!$b';
  43547. }
  43548. if (self::OP_LT === $this->operator || self::OP_LE === $this->operator) {
  43549. if (self::OP_LT === $otherOperator || self::OP_LE === $otherOperator) {
  43550. return '!$b';
  43551. }
  43552. } else {
  43553. if (self::OP_GT === $otherOperator || self::OP_GE === $otherOperator) {
  43554. return '!$b';
  43555. }
  43556. }
  43557. if (self::OP_NE === $otherOperator) {
  43558. return 'true';
  43559. }
  43560. $codeComparison = sprintf('\version_compare($v, %s, \'%s\')', \var_export($this->version, true), self::$transOpInt[$this->operator]);
  43561. if ($this->operator === self::OP_LE) {
  43562. if ($otherOperator === self::OP_GT) {
  43563. return sprintf('!$b && \version_compare($v, %s, \'!=\') && ', \var_export($this->version, true)) . $codeComparison;
  43564. }
  43565. } elseif ($this->operator === self::OP_GE) {
  43566. if ($otherOperator === self::OP_LT) {
  43567. return sprintf('!$b && \version_compare($v, %s, \'!=\') && ', \var_export($this->version, true)) . $codeComparison;
  43568. }
  43569. }
  43570. return sprintf('!$b && %s', $codeComparison);
  43571. }
  43572. public function matchSpecific(Constraint $provider, $compareBranches = false)
  43573. {
  43574. $noEqualOp = str_replace('=', '', self::$transOpInt[$this->operator]);
  43575. $providerNoEqualOp = str_replace('=', '', self::$transOpInt[$provider->operator]);
  43576. $isEqualOp = self::OP_EQ === $this->operator;
  43577. $isNonEqualOp = self::OP_NE === $this->operator;
  43578. $isProviderEqualOp = self::OP_EQ === $provider->operator;
  43579. $isProviderNonEqualOp = self::OP_NE === $provider->operator;
  43580. if ($isNonEqualOp || $isProviderNonEqualOp) {
  43581. if ($isNonEqualOp && !$isProviderNonEqualOp && !$isProviderEqualOp && strpos($provider->version, 'dev-') === 0) {
  43582. return false;
  43583. }
  43584. if ($isProviderNonEqualOp && !$isNonEqualOp && !$isEqualOp && strpos($this->version, 'dev-') === 0) {
  43585. return false;
  43586. }
  43587. if (!$isEqualOp && !$isProviderEqualOp) {
  43588. return true;
  43589. }
  43590. return $this->versionCompare($provider->version, $this->version, '!=', $compareBranches);
  43591. }
  43592. if ($this->operator !== self::OP_EQ && $noEqualOp === $providerNoEqualOp) {
  43593. return !(strpos($this->version, 'dev-') === 0 || strpos($provider->version, 'dev-') === 0);
  43594. }
  43595. $version1 = $isEqualOp ? $this->version : $provider->version;
  43596. $version2 = $isEqualOp ? $provider->version : $this->version;
  43597. $operator = $isEqualOp ? $provider->operator : $this->operator;
  43598. if ($this->versionCompare($version1, $version2, self::$transOpInt[$operator], $compareBranches)) {
  43599. return !(self::$transOpInt[$provider->operator] === $providerNoEqualOp
  43600. && self::$transOpInt[$this->operator] !== $noEqualOp
  43601. && \version_compare($provider->version, $this->version, '=='));
  43602. }
  43603. return false;
  43604. }
  43605. public function __toString()
  43606. {
  43607. return self::$transOpInt[$this->operator] . ' ' . $this->version;
  43608. }
  43609. public function getLowerBound()
  43610. {
  43611. $this->extractBounds();
  43612. return $this->lowerBound;
  43613. }
  43614. public function getUpperBound()
  43615. {
  43616. $this->extractBounds();
  43617. return $this->upperBound;
  43618. }
  43619. private function extractBounds()
  43620. {
  43621. if (null !== $this->lowerBound) {
  43622. return;
  43623. }
  43624. if (strpos($this->version, 'dev-') === 0) {
  43625. $this->lowerBound = Bound::zero();
  43626. $this->upperBound = Bound::positiveInfinity();
  43627. return;
  43628. }
  43629. switch ($this->operator) {
  43630. case self::OP_EQ:
  43631. $this->lowerBound = new Bound($this->version, true);
  43632. $this->upperBound = new Bound($this->version, true);
  43633. break;
  43634. case self::OP_LT:
  43635. $this->lowerBound = Bound::zero();
  43636. $this->upperBound = new Bound($this->version, false);
  43637. break;
  43638. case self::OP_LE:
  43639. $this->lowerBound = Bound::zero();
  43640. $this->upperBound = new Bound($this->version, true);
  43641. break;
  43642. case self::OP_GT:
  43643. $this->lowerBound = new Bound($this->version, false);
  43644. $this->upperBound = Bound::positiveInfinity();
  43645. break;
  43646. case self::OP_GE:
  43647. $this->lowerBound = new Bound($this->version, true);
  43648. $this->upperBound = Bound::positiveInfinity();
  43649. break;
  43650. case self::OP_NE:
  43651. $this->lowerBound = Bound::zero();
  43652. $this->upperBound = Bound::positiveInfinity();
  43653. break;
  43654. }
  43655. }
  43656. }
  43657. <?php
  43658. namespace Composer\Semver\Constraint;
  43659. interface ConstraintInterface
  43660. {
  43661. public function matches(ConstraintInterface $provider);
  43662. public function compile($otherOperator);
  43663. public function getUpperBound();
  43664. public function getLowerBound();
  43665. public function getPrettyString();
  43666. public function setPrettyString($prettyString);
  43667. public function __toString();
  43668. }
  43669. <?php
  43670. namespace Composer\Semver\Constraint;
  43671. class MatchAllConstraint implements ConstraintInterface
  43672. {
  43673. protected $prettyString;
  43674. public function matches(ConstraintInterface $provider)
  43675. {
  43676. return true;
  43677. }
  43678. public function compile($otherOperator)
  43679. {
  43680. return 'true';
  43681. }
  43682. public function setPrettyString($prettyString)
  43683. {
  43684. $this->prettyString = $prettyString;
  43685. }
  43686. public function getPrettyString()
  43687. {
  43688. if ($this->prettyString) {
  43689. return $this->prettyString;
  43690. }
  43691. return (string) $this;
  43692. }
  43693. public function __toString()
  43694. {
  43695. return '*';
  43696. }
  43697. public function getUpperBound()
  43698. {
  43699. return Bound::positiveInfinity();
  43700. }
  43701. public function getLowerBound()
  43702. {
  43703. return Bound::zero();
  43704. }
  43705. }
  43706. <?php
  43707. namespace Composer\Semver\Constraint;
  43708. class MatchNoneConstraint implements ConstraintInterface
  43709. {
  43710. protected $prettyString;
  43711. public function matches(ConstraintInterface $provider)
  43712. {
  43713. return false;
  43714. }
  43715. public function compile($otherOperator)
  43716. {
  43717. return 'false';
  43718. }
  43719. public function setPrettyString($prettyString)
  43720. {
  43721. $this->prettyString = $prettyString;
  43722. }
  43723. public function getPrettyString()
  43724. {
  43725. if ($this->prettyString) {
  43726. return $this->prettyString;
  43727. }
  43728. return (string) $this;
  43729. }
  43730. public function __toString()
  43731. {
  43732. return '[]';
  43733. }
  43734. public function getUpperBound()
  43735. {
  43736. return new Bound('0.0.0.0-dev', false);
  43737. }
  43738. public function getLowerBound()
  43739. {
  43740. return new Bound('0.0.0.0-dev', false);
  43741. }
  43742. }
  43743. <?php
  43744. namespace Composer\Semver\Constraint;
  43745. class MultiConstraint implements ConstraintInterface
  43746. {
  43747. protected $constraints;
  43748. protected $prettyString;
  43749. protected $string;
  43750. protected $conjunctive;
  43751. protected $lowerBound;
  43752. protected $upperBound;
  43753. public function __construct(array $constraints, $conjunctive = true)
  43754. {
  43755. if (\count($constraints) < 2) {
  43756. throw new \InvalidArgumentException(
  43757. 'Must provide at least two constraints for a MultiConstraint. Use '.
  43758. 'the regular Constraint class for one constraint only or MatchAllConstraint for none. You may use '.
  43759. 'MultiConstraint::create() which optimizes and handles those cases automatically.'
  43760. );
  43761. }
  43762. $this->constraints = $constraints;
  43763. $this->conjunctive = $conjunctive;
  43764. }
  43765. public function getConstraints()
  43766. {
  43767. return $this->constraints;
  43768. }
  43769. public function isConjunctive()
  43770. {
  43771. return $this->conjunctive;
  43772. }
  43773. public function isDisjunctive()
  43774. {
  43775. return !$this->conjunctive;
  43776. }
  43777. public function compile($otherOperator)
  43778. {
  43779. $parts = array();
  43780. foreach ($this->constraints as $constraint) {
  43781. $code = $constraint->compile($otherOperator);
  43782. if ($code === 'true') {
  43783. if (!$this->conjunctive) {
  43784. return 'true';
  43785. }
  43786. } elseif ($code === 'false') {
  43787. if ($this->conjunctive) {
  43788. return 'false';
  43789. }
  43790. } else {
  43791. $parts[] = '('.$code.')';
  43792. }
  43793. }
  43794. if (!$parts) {
  43795. return $this->conjunctive ? 'true' : 'false';
  43796. }
  43797. return $this->conjunctive ? implode('&&', $parts) : implode('||', $parts);
  43798. }
  43799. public function matches(ConstraintInterface $provider)
  43800. {
  43801. if (false === $this->conjunctive) {
  43802. foreach ($this->constraints as $constraint) {
  43803. if ($provider->matches($constraint)) {
  43804. return true;
  43805. }
  43806. }
  43807. return false;
  43808. }
  43809. if ($provider instanceof MultiConstraint && $provider->isDisjunctive()) {
  43810. return $provider->matches($this);
  43811. }
  43812. foreach ($this->constraints as $constraint) {
  43813. if (!$provider->matches($constraint)) {
  43814. return false;
  43815. }
  43816. }
  43817. return true;
  43818. }
  43819. public function setPrettyString($prettyString)
  43820. {
  43821. $this->prettyString = $prettyString;
  43822. }
  43823. public function getPrettyString()
  43824. {
  43825. if ($this->prettyString) {
  43826. return $this->prettyString;
  43827. }
  43828. return (string) $this;
  43829. }
  43830. public function __toString()
  43831. {
  43832. if ($this->string !== null) {
  43833. return $this->string;
  43834. }
  43835. $constraints = array();
  43836. foreach ($this->constraints as $constraint) {
  43837. $constraints[] = (string) $constraint;
  43838. }
  43839. return $this->string = '[' . implode($this->conjunctive ? ' ' : ' || ', $constraints) . ']';
  43840. }
  43841. public function getLowerBound()
  43842. {
  43843. $this->extractBounds();
  43844. if (null === $this->lowerBound) {
  43845. throw new \LogicException('extractBounds should have populated the lowerBound property');
  43846. }
  43847. return $this->lowerBound;
  43848. }
  43849. public function getUpperBound()
  43850. {
  43851. $this->extractBounds();
  43852. if (null === $this->upperBound) {
  43853. throw new \LogicException('extractBounds should have populated the upperBound property');
  43854. }
  43855. return $this->upperBound;
  43856. }
  43857. public static function create(array $constraints, $conjunctive = true)
  43858. {
  43859. if (0 === \count($constraints)) {
  43860. return new MatchAllConstraint();
  43861. }
  43862. if (1 === \count($constraints)) {
  43863. return $constraints[0];
  43864. }
  43865. $optimized = self::optimizeConstraints($constraints, $conjunctive);
  43866. if ($optimized !== null) {
  43867. list($constraints, $conjunctive) = $optimized;
  43868. if (\count($constraints) === 1) {
  43869. return $constraints[0];
  43870. }
  43871. }
  43872. return new self($constraints, $conjunctive);
  43873. }
  43874. private static function optimizeConstraints(array $constraints, $conjunctive)
  43875. {
  43876. if (!$conjunctive) {
  43877. $left = $constraints[0];
  43878. $mergedConstraints = array();
  43879. $optimized = false;
  43880. for ($i = 1, $l = \count($constraints); $i < $l; $i++) {
  43881. $right = $constraints[$i];
  43882. if (
  43883. $left instanceof self
  43884. && $left->conjunctive
  43885. && $right instanceof self
  43886. && $right->conjunctive
  43887. && \count($left->constraints) === 2
  43888. && \count($right->constraints) === 2
  43889. && ($left0 = (string) $left->constraints[0])
  43890. && $left0[0] === '>' && $left0[1] === '='
  43891. && ($left1 = (string) $left->constraints[1])
  43892. && $left1[0] === '<'
  43893. && ($right0 = (string) $right->constraints[0])
  43894. && $right0[0] === '>' && $right0[1] === '='
  43895. && ($right1 = (string) $right->constraints[1])
  43896. && $right1[0] === '<'
  43897. && substr($left1, 2) === substr($right0, 3)
  43898. ) {
  43899. $optimized = true;
  43900. $left = new MultiConstraint(
  43901. array(
  43902. $left->constraints[0],
  43903. $right->constraints[1],
  43904. ),
  43905. true);
  43906. } else {
  43907. $mergedConstraints[] = $left;
  43908. $left = $right;
  43909. }
  43910. }
  43911. if ($optimized) {
  43912. $mergedConstraints[] = $left;
  43913. return array($mergedConstraints, false);
  43914. }
  43915. }
  43916. return null;
  43917. }
  43918. private function extractBounds()
  43919. {
  43920. if (null !== $this->lowerBound) {
  43921. return;
  43922. }
  43923. foreach ($this->constraints as $constraint) {
  43924. if (null === $this->lowerBound || null === $this->upperBound) {
  43925. $this->lowerBound = $constraint->getLowerBound();
  43926. $this->upperBound = $constraint->getUpperBound();
  43927. continue;
  43928. }
  43929. if ($constraint->getLowerBound()->compareTo($this->lowerBound, $this->isConjunctive() ? '>' : '<')) {
  43930. $this->lowerBound = $constraint->getLowerBound();
  43931. }
  43932. if ($constraint->getUpperBound()->compareTo($this->upperBound, $this->isConjunctive() ? '<' : '>')) {
  43933. $this->upperBound = $constraint->getUpperBound();
  43934. }
  43935. }
  43936. }
  43937. }
  43938. <?php
  43939. namespace Composer\Semver;
  43940. use Composer\Semver\Constraint\Constraint;
  43941. class Interval
  43942. {
  43943. private $start;
  43944. private $end;
  43945. public function __construct(Constraint $start, Constraint $end)
  43946. {
  43947. $this->start = $start;
  43948. $this->end = $end;
  43949. }
  43950. public function getStart()
  43951. {
  43952. return $this->start;
  43953. }
  43954. public function getEnd()
  43955. {
  43956. return $this->end;
  43957. }
  43958. public static function fromZero()
  43959. {
  43960. static $zero;
  43961. if (null === $zero) {
  43962. $zero = new Constraint('>=', '0.0.0.0-dev');
  43963. }
  43964. return $zero;
  43965. }
  43966. public static function untilPositiveInfinity()
  43967. {
  43968. static $positiveInfinity;
  43969. if (null === $positiveInfinity) {
  43970. $positiveInfinity = new Constraint('<', PHP_INT_MAX.'.0.0.0');
  43971. }
  43972. return $positiveInfinity;
  43973. }
  43974. public static function any()
  43975. {
  43976. return new self(self::fromZero(), self::untilPositiveInfinity());
  43977. }
  43978. public static function anyDev()
  43979. {
  43980. return array('names' => array(), 'exclude' => true);
  43981. }
  43982. public static function noDev()
  43983. {
  43984. return array('names' => array(), 'exclude' => false);
  43985. }
  43986. }
  43987. <?php
  43988. namespace Composer\Semver;
  43989. use Composer\Semver\Constraint\Constraint;
  43990. use Composer\Semver\Constraint\ConstraintInterface;
  43991. use Composer\Semver\Constraint\MatchAllConstraint;
  43992. use Composer\Semver\Constraint\MatchNoneConstraint;
  43993. use Composer\Semver\Constraint\MultiConstraint;
  43994. class Intervals
  43995. {
  43996. private static $intervalsCache = array();
  43997. private static $opSortOrder = array(
  43998. '>=' => -3,
  43999. '<' => -2,
  44000. '>' => 2,
  44001. '<=' => 3,
  44002. );
  44003. public static function clear()
  44004. {
  44005. self::$intervalsCache = array();
  44006. }
  44007. public static function isSubsetOf(ConstraintInterface $candidate, ConstraintInterface $constraint)
  44008. {
  44009. if ($constraint instanceof MatchAllConstraint) {
  44010. return true;
  44011. }
  44012. if ($candidate instanceof MatchNoneConstraint || $constraint instanceof MatchNoneConstraint) {
  44013. return false;
  44014. }
  44015. $intersectionIntervals = self::get(new MultiConstraint(array($candidate, $constraint), true));
  44016. $candidateIntervals = self::get($candidate);
  44017. if (\count($intersectionIntervals['numeric']) !== \count($candidateIntervals['numeric'])) {
  44018. return false;
  44019. }
  44020. foreach ($intersectionIntervals['numeric'] as $index => $interval) {
  44021. if (!isset($candidateIntervals['numeric'][$index])) {
  44022. return false;
  44023. }
  44024. if ((string) $candidateIntervals['numeric'][$index]->getStart() !== (string) $interval->getStart()) {
  44025. return false;
  44026. }
  44027. if ((string) $candidateIntervals['numeric'][$index]->getEnd() !== (string) $interval->getEnd()) {
  44028. return false;
  44029. }
  44030. }
  44031. if ($intersectionIntervals['branches']['exclude'] !== $candidateIntervals['branches']['exclude']) {
  44032. return false;
  44033. }
  44034. if (\count($intersectionIntervals['branches']['names']) !== \count($candidateIntervals['branches']['names'])) {
  44035. return false;
  44036. }
  44037. foreach ($intersectionIntervals['branches']['names'] as $index => $name) {
  44038. if ($name !== $candidateIntervals['branches']['names'][$index]) {
  44039. return false;
  44040. }
  44041. }
  44042. return true;
  44043. }
  44044. public static function haveIntersections(ConstraintInterface $a, ConstraintInterface $b)
  44045. {
  44046. if ($a instanceof MatchAllConstraint || $b instanceof MatchAllConstraint) {
  44047. return true;
  44048. }
  44049. if ($a instanceof MatchNoneConstraint || $b instanceof MatchNoneConstraint) {
  44050. return false;
  44051. }
  44052. $intersectionIntervals = self::generateIntervals(new MultiConstraint(array($a, $b), true), true);
  44053. return \count($intersectionIntervals['numeric']) > 0 || $intersectionIntervals['branches']['exclude'] || \count($intersectionIntervals['branches']['names']) > 0;
  44054. }
  44055. public static function compactConstraint(ConstraintInterface $constraint)
  44056. {
  44057. if (!$constraint instanceof MultiConstraint) {
  44058. return $constraint;
  44059. }
  44060. $intervals = self::generateIntervals($constraint);
  44061. $constraints = array();
  44062. $hasNumericMatchAll = false;
  44063. if (\count($intervals['numeric']) === 1 && (string) $intervals['numeric'][0]->getStart() === (string) Interval::fromZero() && (string) $intervals['numeric'][0]->getEnd() === (string) Interval::untilPositiveInfinity()) {
  44064. $constraints[] = $intervals['numeric'][0]->getStart();
  44065. $hasNumericMatchAll = true;
  44066. } else {
  44067. $unEqualConstraints = array();
  44068. for ($i = 0, $count = \count($intervals['numeric']); $i < $count; $i++) {
  44069. $interval = $intervals['numeric'][$i];
  44070. if ($interval->getEnd()->getOperator() === '<' && $i+1 < $count) {
  44071. $nextInterval = $intervals['numeric'][$i+1];
  44072. if ($interval->getEnd()->getVersion() === $nextInterval->getStart()->getVersion() && $nextInterval->getStart()->getOperator() === '>') {
  44073. if (\count($unEqualConstraints) === 0 && (string) $interval->getStart() !== (string) Interval::fromZero()) {
  44074. $unEqualConstraints[] = $interval->getStart();
  44075. }
  44076. $unEqualConstraints[] = new Constraint('!=', $interval->getEnd()->getVersion());
  44077. continue;
  44078. }
  44079. }
  44080. if (\count($unEqualConstraints) > 0) {
  44081. if ((string) $interval->getEnd() !== (string) Interval::untilPositiveInfinity()) {
  44082. $unEqualConstraints[] = $interval->getEnd();
  44083. }
  44084. if (\count($unEqualConstraints) > 1) {
  44085. $constraints[] = new MultiConstraint($unEqualConstraints, true);
  44086. } else {
  44087. $constraints[] = $unEqualConstraints[0];
  44088. }
  44089. $unEqualConstraints = array();
  44090. continue;
  44091. }
  44092. if ($interval->getStart()->getVersion() === $interval->getEnd()->getVersion() && $interval->getStart()->getOperator() === '>=' && $interval->getEnd()->getOperator() === '<=') {
  44093. $constraints[] = new Constraint('==', $interval->getStart()->getVersion());
  44094. continue;
  44095. }
  44096. if ((string) $interval->getStart() === (string) Interval::fromZero()) {
  44097. $constraints[] = $interval->getEnd();
  44098. } elseif ((string) $interval->getEnd() === (string) Interval::untilPositiveInfinity()) {
  44099. $constraints[] = $interval->getStart();
  44100. } else {
  44101. $constraints[] = new MultiConstraint(array($interval->getStart(), $interval->getEnd()), true);
  44102. }
  44103. }
  44104. }
  44105. $devConstraints = array();
  44106. if (0 === \count($intervals['branches']['names'])) {
  44107. if ($intervals['branches']['exclude']) {
  44108. if ($hasNumericMatchAll) {
  44109. return new MatchAllConstraint;
  44110. }
  44111. }
  44112. } else {
  44113. foreach ($intervals['branches']['names'] as $branchName) {
  44114. if ($intervals['branches']['exclude']) {
  44115. $devConstraints[] = new Constraint('!=', $branchName);
  44116. } else {
  44117. $devConstraints[] = new Constraint('==', $branchName);
  44118. }
  44119. }
  44120. if ($intervals['branches']['exclude']) {
  44121. if (\count($constraints) > 1) {
  44122. return new MultiConstraint(array_merge(
  44123. array(new MultiConstraint($constraints, false)),
  44124. $devConstraints
  44125. ), true);
  44126. }
  44127. if (\count($constraints) === 1 && (string)$constraints[0] === (string)Interval::fromZero()) {
  44128. if (\count($devConstraints) > 1) {
  44129. return new MultiConstraint($devConstraints, true);
  44130. }
  44131. return $devConstraints[0];
  44132. }
  44133. return new MultiConstraint(array_merge($constraints, $devConstraints), true);
  44134. }
  44135. $constraints = array_merge($constraints, $devConstraints);
  44136. }
  44137. if (\count($constraints) > 1) {
  44138. return new MultiConstraint($constraints, false);
  44139. }
  44140. if (\count($constraints) === 1) {
  44141. return $constraints[0];
  44142. }
  44143. return new MatchNoneConstraint;
  44144. }
  44145. public static function get(ConstraintInterface $constraint)
  44146. {
  44147. $key = (string) $constraint;
  44148. if (!isset(self::$intervalsCache[$key])) {
  44149. self::$intervalsCache[$key] = self::generateIntervals($constraint);
  44150. }
  44151. return self::$intervalsCache[$key];
  44152. }
  44153. private static function generateIntervals(ConstraintInterface $constraint, $stopOnFirstValidInterval = false)
  44154. {
  44155. if ($constraint instanceof MatchAllConstraint) {
  44156. return array('numeric' => array(new Interval(Interval::fromZero(), Interval::untilPositiveInfinity())), 'branches' => Interval::anyDev());
  44157. }
  44158. if ($constraint instanceof MatchNoneConstraint) {
  44159. return array('numeric' => array(), 'branches' => array('names' => array(), 'exclude' => false));
  44160. }
  44161. if ($constraint instanceof Constraint) {
  44162. return self::generateSingleConstraintIntervals($constraint);
  44163. }
  44164. if (!$constraint instanceof MultiConstraint) {
  44165. throw new \UnexpectedValueException('The constraint passed in should be an MatchAllConstraint, Constraint or MultiConstraint instance, got '.\get_class($constraint).'.');
  44166. }
  44167. $constraints = $constraint->getConstraints();
  44168. $numericGroups = array();
  44169. $constraintBranches = array();
  44170. foreach ($constraints as $c) {
  44171. $res = self::get($c);
  44172. $numericGroups[] = $res['numeric'];
  44173. $constraintBranches[] = $res['branches'];
  44174. }
  44175. if ($constraint->isDisjunctive()) {
  44176. $branches = Interval::noDev();
  44177. foreach ($constraintBranches as $b) {
  44178. if ($b['exclude']) {
  44179. if ($branches['exclude']) {
  44180. $branches['names'] = array_intersect($branches['names'], $b['names']);
  44181. } else {
  44182. $branches['exclude'] = true;
  44183. $branches['names'] = array_diff($b['names'], $branches['names']);
  44184. }
  44185. } else {
  44186. if ($branches['exclude']) {
  44187. $branches['names'] = array_diff($branches['names'], $b['names']);
  44188. } else {
  44189. $branches['names'] = array_merge($branches['names'], $b['names']);
  44190. }
  44191. }
  44192. }
  44193. } else {
  44194. $branches = Interval::anyDev();
  44195. foreach ($constraintBranches as $b) {
  44196. if ($b['exclude']) {
  44197. if ($branches['exclude']) {
  44198. $branches['names'] = array_merge($branches['names'], $b['names']);
  44199. } else {
  44200. $branches['names'] = array_diff($branches['names'], $b['names']);
  44201. }
  44202. } else {
  44203. if ($branches['exclude']) {
  44204. $branches['names'] = array_diff($b['names'], $branches['names']);
  44205. $branches['exclude'] = false;
  44206. } else {
  44207. $branches['names'] = array_intersect($branches['names'], $b['names']);
  44208. }
  44209. }
  44210. }
  44211. }
  44212. $branches['names'] = array_unique($branches['names']);
  44213. if (\count($numericGroups) === 1) {
  44214. return array('numeric' => $numericGroups[0], 'branches' => $branches);
  44215. }
  44216. $borders = array();
  44217. foreach ($numericGroups as $group) {
  44218. foreach ($group as $interval) {
  44219. $borders[] = array('version' => $interval->getStart()->getVersion(), 'operator' => $interval->getStart()->getOperator(), 'side' => 'start');
  44220. $borders[] = array('version' => $interval->getEnd()->getVersion(), 'operator' => $interval->getEnd()->getOperator(), 'side' => 'end');
  44221. }
  44222. }
  44223. $opSortOrder = self::$opSortOrder;
  44224. usort($borders, function ($a, $b) use ($opSortOrder) {
  44225. $order = version_compare($a['version'], $b['version']);
  44226. if ($order === 0) {
  44227. return $opSortOrder[$a['operator']] - $opSortOrder[$b['operator']];
  44228. }
  44229. return $order;
  44230. });
  44231. $activeIntervals = 0;
  44232. $intervals = array();
  44233. $index = 0;
  44234. $activationThreshold = $constraint->isConjunctive() ? \count($numericGroups) : 1;
  44235. $start = null;
  44236. foreach ($borders as $border) {
  44237. if ($border['side'] === 'start') {
  44238. $activeIntervals++;
  44239. } else {
  44240. $activeIntervals--;
  44241. }
  44242. if (!$start && $activeIntervals >= $activationThreshold) {
  44243. $start = new Constraint($border['operator'], $border['version']);
  44244. } elseif ($start && $activeIntervals < $activationThreshold) {
  44245. if (
  44246. version_compare($start->getVersion(), $border['version'], '=')
  44247. && (
  44248. ($start->getOperator() === '>' && $border['operator'] === '<=')
  44249. || ($start->getOperator() === '>=' && $border['operator'] === '<')
  44250. )
  44251. ) {
  44252. unset($intervals[$index]);
  44253. } else {
  44254. $intervals[$index] = new Interval($start, new Constraint($border['operator'], $border['version']));
  44255. $index++;
  44256. if ($stopOnFirstValidInterval) {
  44257. break;
  44258. }
  44259. }
  44260. $start = null;
  44261. }
  44262. }
  44263. return array('numeric' => $intervals, 'branches' => $branches);
  44264. }
  44265. private static function generateSingleConstraintIntervals(Constraint $constraint)
  44266. {
  44267. $op = $constraint->getOperator();
  44268. if (strpos($constraint->getVersion(), 'dev-') === 0) {
  44269. $intervals = array();
  44270. $branches = array('names' => array(), 'exclude' => false);
  44271. if ($op === '!=') {
  44272. $intervals[] = new Interval(Interval::fromZero(), Interval::untilPositiveInfinity());
  44273. $branches = array('names' => array($constraint->getVersion()), 'exclude' => true);
  44274. } elseif ($op === '==') {
  44275. $branches['names'][] = $constraint->getVersion();
  44276. }
  44277. return array(
  44278. 'numeric' => $intervals,
  44279. 'branches' => $branches,
  44280. );
  44281. }
  44282. if ($op[0] === '>') {
  44283. return array('numeric' => array(new Interval($constraint, Interval::untilPositiveInfinity())), 'branches' => Interval::noDev());
  44284. }
  44285. if ($op[0] === '<') {
  44286. return array('numeric' => array(new Interval(Interval::fromZero(), $constraint)), 'branches' => Interval::noDev());
  44287. }
  44288. if ($op === '!=') {
  44289. return array('numeric' => array(
  44290. new Interval(Interval::fromZero(), new Constraint('<', $constraint->getVersion())),
  44291. new Interval(new Constraint('>', $constraint->getVersion()), Interval::untilPositiveInfinity()),
  44292. ), 'branches' => Interval::anyDev());
  44293. }
  44294. return array('numeric' => array(
  44295. new Interval(new Constraint('>=', $constraint->getVersion()), new Constraint('<=', $constraint->getVersion())),
  44296. ), 'branches' => Interval::noDev());
  44297. }
  44298. }
  44299. <?php
  44300. namespace Composer\Semver;
  44301. use Composer\Semver\Constraint\Constraint;
  44302. class Semver
  44303. {
  44304. const SORT_ASC = 1;
  44305. const SORT_DESC = -1;
  44306. private static $versionParser;
  44307. public static function satisfies($version, $constraints)
  44308. {
  44309. if (null === self::$versionParser) {
  44310. self::$versionParser = new VersionParser();
  44311. }
  44312. $versionParser = self::$versionParser;
  44313. $provider = new Constraint('==', $versionParser->normalize($version));
  44314. $parsedConstraints = $versionParser->parseConstraints($constraints);
  44315. return $parsedConstraints->matches($provider);
  44316. }
  44317. public static function satisfiedBy(array $versions, $constraints)
  44318. {
  44319. $versions = array_filter($versions, function ($version) use ($constraints) {
  44320. return Semver::satisfies($version, $constraints);
  44321. });
  44322. return array_values($versions);
  44323. }
  44324. public static function sort(array $versions)
  44325. {
  44326. return self::usort($versions, self::SORT_ASC);
  44327. }
  44328. public static function rsort(array $versions)
  44329. {
  44330. return self::usort($versions, self::SORT_DESC);
  44331. }
  44332. private static function usort(array $versions, $direction)
  44333. {
  44334. if (null === self::$versionParser) {
  44335. self::$versionParser = new VersionParser();
  44336. }
  44337. $versionParser = self::$versionParser;
  44338. $normalized = array();
  44339. foreach ($versions as $key => $version) {
  44340. $normalizedVersion = $versionParser->normalize($version);
  44341. $normalizedVersion = $versionParser->normalizeDefaultBranch($normalizedVersion);
  44342. $normalized[] = array($normalizedVersion, $key);
  44343. }
  44344. usort($normalized, function (array $left, array $right) use ($direction) {
  44345. if ($left[0] === $right[0]) {
  44346. return 0;
  44347. }
  44348. if (Comparator::lessThan($left[0], $right[0])) {
  44349. return -$direction;
  44350. }
  44351. return $direction;
  44352. });
  44353. $sorted = array();
  44354. foreach ($normalized as $item) {
  44355. $sorted[] = $versions[$item[1]];
  44356. }
  44357. return $sorted;
  44358. }
  44359. }
  44360. <?php
  44361. namespace Composer\Semver;
  44362. use Composer\Semver\Constraint\ConstraintInterface;
  44363. use Composer\Semver\Constraint\MatchAllConstraint;
  44364. use Composer\Semver\Constraint\MultiConstraint;
  44365. use Composer\Semver\Constraint\Constraint;
  44366. class VersionParser
  44367. {
  44368. private static $modifierRegex = '[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)((?:[.-]?\d+)*+)?)?([.-]?dev)?';
  44369. private static $stabilitiesRegex = 'stable|RC|beta|alpha|dev';
  44370. public static function parseStability($version)
  44371. {
  44372. $version = (string) preg_replace('{#.+$}', '', (string) $version);
  44373. if (strpos($version, 'dev-') === 0 || '-dev' === substr($version, -4)) {
  44374. return 'dev';
  44375. }
  44376. preg_match('{' . self::$modifierRegex . '(?:\+.*)?$}i', strtolower($version), $match);
  44377. if (!empty($match[3])) {
  44378. return 'dev';
  44379. }
  44380. if (!empty($match[1])) {
  44381. if ('beta' === $match[1] || 'b' === $match[1]) {
  44382. return 'beta';
  44383. }
  44384. if ('alpha' === $match[1] || 'a' === $match[1]) {
  44385. return 'alpha';
  44386. }
  44387. if ('rc' === $match[1]) {
  44388. return 'RC';
  44389. }
  44390. }
  44391. return 'stable';
  44392. }
  44393. public static function normalizeStability($stability)
  44394. {
  44395. $stability = strtolower((string) $stability);
  44396. return $stability === 'rc' ? 'RC' : $stability;
  44397. }
  44398. public function normalize($version, $fullVersion = null)
  44399. {
  44400. $version = trim((string) $version);
  44401. $origVersion = $version;
  44402. if (null === $fullVersion) {
  44403. $fullVersion = $version;
  44404. }
  44405. if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $version, $match)) {
  44406. $version = $match[1];
  44407. }
  44408. if (preg_match('{@(?:' . self::$stabilitiesRegex . ')$}i', $version, $match)) {
  44409. $version = substr($version, 0, strlen($version) - strlen($match[0]));
  44410. }
  44411. if (\in_array($version, array('master', 'trunk', 'default'), true)) {
  44412. $version = 'dev-' . $version;
  44413. }
  44414. if (stripos($version, 'dev-') === 0) {
  44415. return 'dev-' . substr($version, 4);
  44416. }
  44417. if (preg_match('{^([^,\s+]++)\+[^\s]++$}', $version, $match)) {
  44418. $version = $match[1];
  44419. }
  44420. if (preg_match('{^v?(\d{1,5})(\.\d++)?(\.\d++)?(\.\d++)?' . self::$modifierRegex . '$}i', $version, $matches)) {
  44421. $version = $matches[1]
  44422. . (!empty($matches[2]) ? $matches[2] : '.0')
  44423. . (!empty($matches[3]) ? $matches[3] : '.0')
  44424. . (!empty($matches[4]) ? $matches[4] : '.0');
  44425. $index = 5;
  44426. } elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3})?)' . self::$modifierRegex . '$}i', $version, $matches)) {
  44427. $version = preg_replace('{\D}', '.', $matches[1]);
  44428. $index = 2;
  44429. }
  44430. if (isset($index)) {
  44431. if (!empty($matches[$index])) {
  44432. if ('stable' === $matches[$index]) {
  44433. return $version;
  44434. }
  44435. $version .= '-' . $this->expandStability($matches[$index]) . (isset($matches[$index + 1]) && '' !== $matches[$index + 1] ? ltrim($matches[$index + 1], '.-') : '');
  44436. }
  44437. if (!empty($matches[$index + 2])) {
  44438. $version .= '-dev';
  44439. }
  44440. return $version;
  44441. }
  44442. if (preg_match('{(.*?)[.-]?dev$}i', $version, $match)) {
  44443. try {
  44444. $normalized = $this->normalizeBranch($match[1]);
  44445. if (strpos($normalized, 'dev-') === false) {
  44446. return $normalized;
  44447. }
  44448. } catch (\Exception $e) {
  44449. }
  44450. }
  44451. $extraMessage = '';
  44452. if (preg_match('{ +as +' . preg_quote($version) . '(?:@(?:'.self::$stabilitiesRegex.'))?$}', $fullVersion)) {
  44453. $extraMessage = ' in "' . $fullVersion . '", the alias must be an exact version';
  44454. } elseif (preg_match('{^' . preg_quote($version) . '(?:@(?:'.self::$stabilitiesRegex.'))? +as +}', $fullVersion)) {
  44455. $extraMessage = ' in "' . $fullVersion . '", the alias source must be an exact version, if it is a branch name you should prefix it with dev-';
  44456. }
  44457. throw new \UnexpectedValueException('Invalid version string "' . $origVersion . '"' . $extraMessage);
  44458. }
  44459. public function parseNumericAliasPrefix($branch)
  44460. {
  44461. if (preg_match('{^(?P<version>(\d++\\.)*\d++)(?:\.x)?-dev$}i', (string) $branch, $matches)) {
  44462. return $matches['version'] . '.';
  44463. }
  44464. return false;
  44465. }
  44466. public function normalizeBranch($name)
  44467. {
  44468. $name = trim((string) $name);
  44469. if (preg_match('{^v?(\d++)(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?$}i', $name, $matches)) {
  44470. $version = '';
  44471. for ($i = 1; $i < 5; ++$i) {
  44472. $version .= isset($matches[$i]) ? str_replace(array('*', 'X'), 'x', $matches[$i]) : '.x';
  44473. }
  44474. return str_replace('x', '9999999', $version) . '-dev';
  44475. }
  44476. return 'dev-' . $name;
  44477. }
  44478. public function normalizeDefaultBranch($name)
  44479. {
  44480. if ($name === 'dev-master' || $name === 'dev-default' || $name === 'dev-trunk') {
  44481. return '9999999-dev';
  44482. }
  44483. return (string) $name;
  44484. }
  44485. public function parseConstraints($constraints)
  44486. {
  44487. $prettyConstraint = (string) $constraints;
  44488. $orConstraints = preg_split('{\s*\|\|?\s*}', trim((string) $constraints));
  44489. if (false === $orConstraints) {
  44490. throw new \RuntimeException('Failed to preg_split string: '.$constraints);
  44491. }
  44492. $orGroups = array();
  44493. foreach ($orConstraints as $constraints) {
  44494. $andConstraints = preg_split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $constraints);
  44495. if (false === $andConstraints) {
  44496. throw new \RuntimeException('Failed to preg_split string: '.$constraints);
  44497. }
  44498. if (\count($andConstraints) > 1) {
  44499. $constraintObjects = array();
  44500. foreach ($andConstraints as $constraint) {
  44501. foreach ($this->parseConstraint($constraint) as $parsedConstraint) {
  44502. $constraintObjects[] = $parsedConstraint;
  44503. }
  44504. }
  44505. } else {
  44506. $constraintObjects = $this->parseConstraint($andConstraints[0]);
  44507. }
  44508. if (1 === \count($constraintObjects)) {
  44509. $constraint = $constraintObjects[0];
  44510. } else {
  44511. $constraint = new MultiConstraint($constraintObjects);
  44512. }
  44513. $orGroups[] = $constraint;
  44514. }
  44515. $constraint = MultiConstraint::create($orGroups, false);
  44516. $constraint->setPrettyString($prettyConstraint);
  44517. return $constraint;
  44518. }
  44519. private function parseConstraint($constraint)
  44520. {
  44521. if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $constraint, $match)) {
  44522. $constraint = $match[1];
  44523. }
  44524. if (preg_match('{^([^,\s]*?)@(' . self::$stabilitiesRegex . ')$}i', $constraint, $match)) {
  44525. $constraint = '' !== $match[1] ? $match[1] : '*';
  44526. if ($match[2] !== 'stable') {
  44527. $stabilityModifier = $match[2];
  44528. }
  44529. }
  44530. if (preg_match('{^(dev-[^,\s@]+?|[^,\s@]+?\.x-dev)#.+$}i', $constraint, $match)) {
  44531. $constraint = $match[1];
  44532. }
  44533. if (preg_match('{^(v)?[xX*](\.[xX*])*$}i', $constraint, $match)) {
  44534. if (!empty($match[1]) || !empty($match[2])) {
  44535. return array(new Constraint('>=', '0.0.0.0-dev'));
  44536. }
  44537. return array(new MatchAllConstraint());
  44538. }
  44539. $versionRegex = 'v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.(\d++))?(?:' . self::$modifierRegex . '|\.([xX*][.-]?dev))(?:\+[^\s]+)?';
  44540. if (preg_match('{^~>?' . $versionRegex . '$}i', $constraint, $matches)) {
  44541. if (strpos($constraint, '~>') === 0) {
  44542. throw new \UnexpectedValueException(
  44543. 'Could not parse version constraint ' . $constraint . ': ' .
  44544. 'Invalid operator "~>", you probably meant to use the "~" operator'
  44545. );
  44546. }
  44547. if (isset($matches[4]) && '' !== $matches[4] && null !== $matches[4]) {
  44548. $position = 4;
  44549. } elseif (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
  44550. $position = 3;
  44551. } elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
  44552. $position = 2;
  44553. } else {
  44554. $position = 1;
  44555. }
  44556. if (!empty($matches[8])) {
  44557. $position++;
  44558. }
  44559. $stabilitySuffix = '';
  44560. if (empty($matches[5]) && empty($matches[7]) && empty($matches[8])) {
  44561. $stabilitySuffix .= '-dev';
  44562. }
  44563. $lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
  44564. $lowerBound = new Constraint('>=', $lowVersion);
  44565. $highPosition = max(1, $position - 1);
  44566. $highVersion = $this->manipulateVersionString($matches, $highPosition, 1) . '-dev';
  44567. $upperBound = new Constraint('<', $highVersion);
  44568. return array(
  44569. $lowerBound,
  44570. $upperBound,
  44571. );
  44572. }
  44573. if (preg_match('{^\^' . $versionRegex . '($)}i', $constraint, $matches)) {
  44574. if ('0' !== $matches[1] || '' === $matches[2] || null === $matches[2]) {
  44575. $position = 1;
  44576. } elseif ('0' !== $matches[2] || '' === $matches[3] || null === $matches[3]) {
  44577. $position = 2;
  44578. } else {
  44579. $position = 3;
  44580. }
  44581. $stabilitySuffix = '';
  44582. if (empty($matches[5]) && empty($matches[7]) && empty($matches[8])) {
  44583. $stabilitySuffix .= '-dev';
  44584. }
  44585. $lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
  44586. $lowerBound = new Constraint('>=', $lowVersion);
  44587. $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';
  44588. $upperBound = new Constraint('<', $highVersion);
  44589. return array(
  44590. $lowerBound,
  44591. $upperBound,
  44592. );
  44593. }
  44594. if (preg_match('{^v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.[xX*])++$}', $constraint, $matches)) {
  44595. if (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
  44596. $position = 3;
  44597. } elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
  44598. $position = 2;
  44599. } else {
  44600. $position = 1;
  44601. }
  44602. $lowVersion = $this->manipulateVersionString($matches, $position) . '-dev';
  44603. $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';
  44604. if ($lowVersion === '0.0.0.0-dev') {
  44605. return array(new Constraint('<', $highVersion));
  44606. }
  44607. return array(
  44608. new Constraint('>=', $lowVersion),
  44609. new Constraint('<', $highVersion),
  44610. );
  44611. }
  44612. if (preg_match('{^(?P<from>' . $versionRegex . ') +- +(?P<to>' . $versionRegex . ')($)}i', $constraint, $matches)) {
  44613. $lowStabilitySuffix = '';
  44614. if (empty($matches[6]) && empty($matches[8]) && empty($matches[9])) {
  44615. $lowStabilitySuffix = '-dev';
  44616. }
  44617. $lowVersion = $this->normalize($matches['from']);
  44618. $lowerBound = new Constraint('>=', $lowVersion . $lowStabilitySuffix);
  44619. $empty = function ($x) {
  44620. return ($x === 0 || $x === '0') ? false : empty($x);
  44621. };
  44622. if ((!$empty($matches[12]) && !$empty($matches[13])) || !empty($matches[15]) || !empty($matches[17]) || !empty($matches[18])) {
  44623. $highVersion = $this->normalize($matches['to']);
  44624. $upperBound = new Constraint('<=', $highVersion);
  44625. } else {
  44626. $highMatch = array('', $matches[11], $matches[12], $matches[13], $matches[14]);
  44627. $this->normalize($matches['to']);
  44628. $highVersion = $this->manipulateVersionString($highMatch, $empty($matches[12]) ? 1 : 2, 1) . '-dev';
  44629. $upperBound = new Constraint('<', $highVersion);
  44630. }
  44631. return array(
  44632. $lowerBound,
  44633. $upperBound,
  44634. );
  44635. }
  44636. if (preg_match('{^(<>|!=|>=?|<=?|==?)?\s*(.*)}', $constraint, $matches)) {
  44637. try {
  44638. try {
  44639. $version = $this->normalize($matches[2]);
  44640. } catch (\UnexpectedValueException $e) {
  44641. if (substr($matches[2], -4) === '-dev' && preg_match('{^[0-9a-zA-Z-./]+$}', $matches[2])) {
  44642. $version = $this->normalize('dev-'.substr($matches[2], 0, -4));
  44643. } else {
  44644. throw $e;
  44645. }
  44646. }
  44647. $op = $matches[1] ?: '=';
  44648. if ($op !== '==' && $op !== '=' && !empty($stabilityModifier) && self::parseStability($version) === 'stable') {
  44649. $version .= '-' . $stabilityModifier;
  44650. } elseif ('<' === $op || '>=' === $op) {
  44651. if (!preg_match('/-' . self::$modifierRegex . '$/', strtolower($matches[2]))) {
  44652. if (strpos($matches[2], 'dev-') !== 0) {
  44653. $version .= '-dev';
  44654. }
  44655. }
  44656. }
  44657. return array(new Constraint($matches[1] ?: '=', $version));
  44658. } catch (\Exception $e) {
  44659. }
  44660. }
  44661. $message = 'Could not parse version constraint ' . $constraint;
  44662. if (isset($e)) {
  44663. $message .= ': ' . $e->getMessage();
  44664. }
  44665. throw new \UnexpectedValueException($message);
  44666. }
  44667. private function manipulateVersionString(array $matches, $position, $increment = 0, $pad = '0')
  44668. {
  44669. for ($i = 4; $i > 0; --$i) {
  44670. if ($i > $position) {
  44671. $matches[$i] = $pad;
  44672. } elseif ($i === $position && $increment) {
  44673. $matches[$i] += $increment;
  44674. if ($matches[$i] < 0) {
  44675. $matches[$i] = $pad;
  44676. --$position;
  44677. if ($i === 1) {
  44678. return null;
  44679. }
  44680. }
  44681. }
  44682. }
  44683. return $matches[1] . '.' . $matches[2] . '.' . $matches[3] . '.' . $matches[4];
  44684. }
  44685. private function expandStability($stability)
  44686. {
  44687. $stability = strtolower($stability);
  44688. switch ($stability) {
  44689. case 'a':
  44690. return 'alpha';
  44691. case 'b':
  44692. return 'beta';
  44693. case 'p':
  44694. case 'pl':
  44695. return 'patch';
  44696. case 'rc':
  44697. return 'RC';
  44698. default:
  44699. return $stability;
  44700. }
  44701. }
  44702. }
  44703. Copyright (C) 2015 Composer
  44704. Permission is hereby granted, free of charge, to any person obtaining a copy of
  44705. this software and associated documentation files (the "Software"), to deal in
  44706. the Software without restriction, including without limitation the rights to
  44707. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  44708. of the Software, and to permit persons to whom the Software is furnished to do
  44709. so, subject to the following conditions:
  44710. The above copyright notice and this permission notice shall be included in all
  44711. copies or substantial portions of the Software.
  44712. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  44713. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  44714. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  44715. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  44716. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  44717. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  44718. SOFTWARE.
  44719. {
  44720. "389-exception": [
  44721. "389 Directory Server Exception"
  44722. ],
  44723. "Autoconf-exception-2.0": [
  44724. "Autoconf exception 2.0"
  44725. ],
  44726. "Autoconf-exception-3.0": [
  44727. "Autoconf exception 3.0"
  44728. ],
  44729. "Bison-exception-2.2": [
  44730. "Bison exception 2.2"
  44731. ],
  44732. "Bootloader-exception": [
  44733. "Bootloader Distribution Exception"
  44734. ],
  44735. "Classpath-exception-2.0": [
  44736. "Classpath exception 2.0"
  44737. ],
  44738. "CLISP-exception-2.0": [
  44739. "CLISP exception 2.0"
  44740. ],
  44741. "DigiRule-FOSS-exception": [
  44742. "DigiRule FOSS License Exception"
  44743. ],
  44744. "eCos-exception-2.0": [
  44745. "eCos exception 2.0"
  44746. ],
  44747. "Fawkes-Runtime-exception": [
  44748. "Fawkes Runtime Exception"
  44749. ],
  44750. "FLTK-exception": [
  44751. "FLTK exception"
  44752. ],
  44753. "Font-exception-2.0": [
  44754. "Font exception 2.0"
  44755. ],
  44756. "freertos-exception-2.0": [
  44757. "FreeRTOS Exception 2.0"
  44758. ],
  44759. "GCC-exception-2.0": [
  44760. "GCC Runtime Library exception 2.0"
  44761. ],
  44762. "GCC-exception-3.1": [
  44763. "GCC Runtime Library exception 3.1"
  44764. ],
  44765. "gnu-javamail-exception": [
  44766. "GNU JavaMail exception"
  44767. ],
  44768. "GPL-3.0-linking-exception": [
  44769. "GPL-3.0 Linking Exception"
  44770. ],
  44771. "GPL-3.0-linking-source-exception": [
  44772. "GPL-3.0 Linking Exception (with Corresponding Source)"
  44773. ],
  44774. "GPL-CC-1.0": [
  44775. "GPL Cooperation Commitment 1.0"
  44776. ],
  44777. "i2p-gpl-java-exception": [
  44778. "i2p GPL+Java Exception"
  44779. ],
  44780. "LGPL-3.0-linking-exception": [
  44781. "LGPL-3.0 Linking Exception"
  44782. ],
  44783. "Libtool-exception": [
  44784. "Libtool Exception"
  44785. ],
  44786. "Linux-syscall-note": [
  44787. "Linux Syscall Note"
  44788. ],
  44789. "LLVM-exception": [
  44790. "LLVM Exception"
  44791. ],
  44792. "LZMA-exception": [
  44793. "LZMA exception"
  44794. ],
  44795. "mif-exception": [
  44796. "Macros and Inline Functions Exception"
  44797. ],
  44798. "Nokia-Qt-exception-1.1": [
  44799. "Nokia Qt LGPL exception 1.1"
  44800. ],
  44801. "OCaml-LGPL-linking-exception": [
  44802. "OCaml LGPL Linking Exception"
  44803. ],
  44804. "OCCT-exception-1.0": [
  44805. "Open CASCADE Exception 1.0"
  44806. ],
  44807. "OpenJDK-assembly-exception-1.0": [
  44808. "OpenJDK Assembly exception 1.0"
  44809. ],
  44810. "openvpn-openssl-exception": [
  44811. "OpenVPN OpenSSL Exception"
  44812. ],
  44813. "PS-or-PDF-font-exception-20170817": [
  44814. "PS/PDF font exception (2017-08-17)"
  44815. ],
  44816. "Qt-GPL-exception-1.0": [
  44817. "Qt GPL exception 1.0"
  44818. ],
  44819. "Qt-LGPL-exception-1.1": [
  44820. "Qt LGPL exception 1.1"
  44821. ],
  44822. "Qwt-exception-1.0": [
  44823. "Qwt exception 1.0"
  44824. ],
  44825. "SHL-2.0": [
  44826. "Solderpad Hardware License v2.0"
  44827. ],
  44828. "SHL-2.1": [
  44829. "Solderpad Hardware License v2.1"
  44830. ],
  44831. "Swift-exception": [
  44832. "Swift Exception"
  44833. ],
  44834. "u-boot-exception-2.0": [
  44835. "U-Boot exception 2.0"
  44836. ],
  44837. "Universal-FOSS-exception-1.0": [
  44838. "Universal FOSS Exception, Version 1.0"
  44839. ],
  44840. "WxWindows-exception-3.1": [
  44841. "WxWindows Library Exception 3.1"
  44842. ]
  44843. }{
  44844. "0BSD": [
  44845. "BSD Zero Clause License",
  44846. true,
  44847. false
  44848. ],
  44849. "AAL": [
  44850. "Attribution Assurance License",
  44851. true,
  44852. false
  44853. ],
  44854. "Abstyles": [
  44855. "Abstyles License",
  44856. false,
  44857. false
  44858. ],
  44859. "Adobe-2006": [
  44860. "Adobe Systems Incorporated Source Code License Agreement",
  44861. false,
  44862. false
  44863. ],
  44864. "Adobe-Glyph": [
  44865. "Adobe Glyph List License",
  44866. false,
  44867. false
  44868. ],
  44869. "ADSL": [
  44870. "Amazon Digital Services License",
  44871. false,
  44872. false
  44873. ],
  44874. "AFL-1.1": [
  44875. "Academic Free License v1.1",
  44876. true,
  44877. false
  44878. ],
  44879. "AFL-1.2": [
  44880. "Academic Free License v1.2",
  44881. true,
  44882. false
  44883. ],
  44884. "AFL-2.0": [
  44885. "Academic Free License v2.0",
  44886. true,
  44887. false
  44888. ],
  44889. "AFL-2.1": [
  44890. "Academic Free License v2.1",
  44891. true,
  44892. false
  44893. ],
  44894. "AFL-3.0": [
  44895. "Academic Free License v3.0",
  44896. true,
  44897. false
  44898. ],
  44899. "Afmparse": [
  44900. "Afmparse License",
  44901. false,
  44902. false
  44903. ],
  44904. "AGPL-1.0": [
  44905. "Affero General Public License v1.0",
  44906. false,
  44907. true
  44908. ],
  44909. "AGPL-1.0-only": [
  44910. "Affero General Public License v1.0 only",
  44911. false,
  44912. false
  44913. ],
  44914. "AGPL-1.0-or-later": [
  44915. "Affero General Public License v1.0 or later",
  44916. false,
  44917. false
  44918. ],
  44919. "AGPL-3.0": [
  44920. "GNU Affero General Public License v3.0",
  44921. true,
  44922. true
  44923. ],
  44924. "AGPL-3.0-only": [
  44925. "GNU Affero General Public License v3.0 only",
  44926. true,
  44927. false
  44928. ],
  44929. "AGPL-3.0-or-later": [
  44930. "GNU Affero General Public License v3.0 or later",
  44931. true,
  44932. false
  44933. ],
  44934. "Aladdin": [
  44935. "Aladdin Free Public License",
  44936. false,
  44937. false
  44938. ],
  44939. "AMDPLPA": [
  44940. "AMD's plpa_map.c License",
  44941. false,
  44942. false
  44943. ],
  44944. "AML": [
  44945. "Apple MIT License",
  44946. false,
  44947. false
  44948. ],
  44949. "AMPAS": [
  44950. "Academy of Motion Picture Arts and Sciences BSD",
  44951. false,
  44952. false
  44953. ],
  44954. "ANTLR-PD": [
  44955. "ANTLR Software Rights Notice",
  44956. false,
  44957. false
  44958. ],
  44959. "ANTLR-PD-fallback": [
  44960. "ANTLR Software Rights Notice with license fallback",
  44961. false,
  44962. false
  44963. ],
  44964. "Apache-1.0": [
  44965. "Apache License 1.0",
  44966. false,
  44967. false
  44968. ],
  44969. "Apache-1.1": [
  44970. "Apache License 1.1",
  44971. true,
  44972. false
  44973. ],
  44974. "Apache-2.0": [
  44975. "Apache License 2.0",
  44976. true,
  44977. false
  44978. ],
  44979. "APAFML": [
  44980. "Adobe Postscript AFM License",
  44981. false,
  44982. false
  44983. ],
  44984. "APL-1.0": [
  44985. "Adaptive Public License 1.0",
  44986. true,
  44987. false
  44988. ],
  44989. "APSL-1.0": [
  44990. "Apple Public Source License 1.0",
  44991. true,
  44992. false
  44993. ],
  44994. "APSL-1.1": [
  44995. "Apple Public Source License 1.1",
  44996. true,
  44997. false
  44998. ],
  44999. "APSL-1.2": [
  45000. "Apple Public Source License 1.2",
  45001. true,
  45002. false
  45003. ],
  45004. "APSL-2.0": [
  45005. "Apple Public Source License 2.0",
  45006. true,
  45007. false
  45008. ],
  45009. "Artistic-1.0": [
  45010. "Artistic License 1.0",
  45011. true,
  45012. false
  45013. ],
  45014. "Artistic-1.0-cl8": [
  45015. "Artistic License 1.0 w/clause 8",
  45016. true,
  45017. false
  45018. ],
  45019. "Artistic-1.0-Perl": [
  45020. "Artistic License 1.0 (Perl)",
  45021. true,
  45022. false
  45023. ],
  45024. "Artistic-2.0": [
  45025. "Artistic License 2.0",
  45026. true,
  45027. false
  45028. ],
  45029. "Bahyph": [
  45030. "Bahyph License",
  45031. false,
  45032. false
  45033. ],
  45034. "Barr": [
  45035. "Barr License",
  45036. false,
  45037. false
  45038. ],
  45039. "Beerware": [
  45040. "Beerware License",
  45041. false,
  45042. false
  45043. ],
  45044. "BitTorrent-1.0": [
  45045. "BitTorrent Open Source License v1.0",
  45046. false,
  45047. false
  45048. ],
  45049. "BitTorrent-1.1": [
  45050. "BitTorrent Open Source License v1.1",
  45051. false,
  45052. false
  45053. ],
  45054. "blessing": [
  45055. "SQLite Blessing",
  45056. false,
  45057. false
  45058. ],
  45059. "BlueOak-1.0.0": [
  45060. "Blue Oak Model License 1.0.0",
  45061. false,
  45062. false
  45063. ],
  45064. "Borceux": [
  45065. "Borceux license",
  45066. false,
  45067. false
  45068. ],
  45069. "BSD-1-Clause": [
  45070. "BSD 1-Clause License",
  45071. true,
  45072. false
  45073. ],
  45074. "BSD-2-Clause": [
  45075. "BSD 2-Clause \"Simplified\" License",
  45076. true,
  45077. false
  45078. ],
  45079. "BSD-2-Clause-FreeBSD": [
  45080. "BSD 2-Clause FreeBSD License",
  45081. false,
  45082. true
  45083. ],
  45084. "BSD-2-Clause-NetBSD": [
  45085. "BSD 2-Clause NetBSD License",
  45086. false,
  45087. true
  45088. ],
  45089. "BSD-2-Clause-Patent": [
  45090. "BSD-2-Clause Plus Patent License",
  45091. true,
  45092. false
  45093. ],
  45094. "BSD-2-Clause-Views": [
  45095. "BSD 2-Clause with views sentence",
  45096. false,
  45097. false
  45098. ],
  45099. "BSD-3-Clause": [
  45100. "BSD 3-Clause \"New\" or \"Revised\" License",
  45101. true,
  45102. false
  45103. ],
  45104. "BSD-3-Clause-Attribution": [
  45105. "BSD with attribution",
  45106. false,
  45107. false
  45108. ],
  45109. "BSD-3-Clause-Clear": [
  45110. "BSD 3-Clause Clear License",
  45111. false,
  45112. false
  45113. ],
  45114. "BSD-3-Clause-LBNL": [
  45115. "Lawrence Berkeley National Labs BSD variant license",
  45116. true,
  45117. false
  45118. ],
  45119. "BSD-3-Clause-Modification": [
  45120. "BSD 3-Clause Modification",
  45121. false,
  45122. false
  45123. ],
  45124. "BSD-3-Clause-No-Military-License": [
  45125. "BSD 3-Clause No Military License",
  45126. false,
  45127. false
  45128. ],
  45129. "BSD-3-Clause-No-Nuclear-License": [
  45130. "BSD 3-Clause No Nuclear License",
  45131. false,
  45132. false
  45133. ],
  45134. "BSD-3-Clause-No-Nuclear-License-2014": [
  45135. "BSD 3-Clause No Nuclear License 2014",
  45136. false,
  45137. false
  45138. ],
  45139. "BSD-3-Clause-No-Nuclear-Warranty": [
  45140. "BSD 3-Clause No Nuclear Warranty",
  45141. false,
  45142. false
  45143. ],
  45144. "BSD-3-Clause-Open-MPI": [
  45145. "BSD 3-Clause Open MPI variant",
  45146. false,
  45147. false
  45148. ],
  45149. "BSD-4-Clause": [
  45150. "BSD 4-Clause \"Original\" or \"Old\" License",
  45151. false,
  45152. false
  45153. ],
  45154. "BSD-4-Clause-Shortened": [
  45155. "BSD 4 Clause Shortened",
  45156. false,
  45157. false
  45158. ],
  45159. "BSD-4-Clause-UC": [
  45160. "BSD-4-Clause (University of California-Specific)",
  45161. false,
  45162. false
  45163. ],
  45164. "BSD-Protection": [
  45165. "BSD Protection License",
  45166. false,
  45167. false
  45168. ],
  45169. "BSD-Source-Code": [
  45170. "BSD Source Code Attribution",
  45171. false,
  45172. false
  45173. ],
  45174. "BSL-1.0": [
  45175. "Boost Software License 1.0",
  45176. true,
  45177. false
  45178. ],
  45179. "BUSL-1.1": [
  45180. "Business Source License 1.1",
  45181. false,
  45182. false
  45183. ],
  45184. "bzip2-1.0.5": [
  45185. "bzip2 and libbzip2 License v1.0.5",
  45186. false,
  45187. false
  45188. ],
  45189. "bzip2-1.0.6": [
  45190. "bzip2 and libbzip2 License v1.0.6",
  45191. false,
  45192. false
  45193. ],
  45194. "C-UDA-1.0": [
  45195. "Computational Use of Data Agreement v1.0",
  45196. false,
  45197. false
  45198. ],
  45199. "CAL-1.0": [
  45200. "Cryptographic Autonomy License 1.0",
  45201. true,
  45202. false
  45203. ],
  45204. "CAL-1.0-Combined-Work-Exception": [
  45205. "Cryptographic Autonomy License 1.0 (Combined Work Exception)",
  45206. true,
  45207. false
  45208. ],
  45209. "Caldera": [
  45210. "Caldera License",
  45211. false,
  45212. false
  45213. ],
  45214. "CATOSL-1.1": [
  45215. "Computer Associates Trusted Open Source License 1.1",
  45216. true,
  45217. false
  45218. ],
  45219. "CC-BY-1.0": [
  45220. "Creative Commons Attribution 1.0 Generic",
  45221. false,
  45222. false
  45223. ],
  45224. "CC-BY-2.0": [
  45225. "Creative Commons Attribution 2.0 Generic",
  45226. false,
  45227. false
  45228. ],
  45229. "CC-BY-2.5": [
  45230. "Creative Commons Attribution 2.5 Generic",
  45231. false,
  45232. false
  45233. ],
  45234. "CC-BY-2.5-AU": [
  45235. "Creative Commons Attribution 2.5 Australia",
  45236. false,
  45237. false
  45238. ],
  45239. "CC-BY-3.0": [
  45240. "Creative Commons Attribution 3.0 Unported",
  45241. false,
  45242. false
  45243. ],
  45244. "CC-BY-3.0-AT": [
  45245. "Creative Commons Attribution 3.0 Austria",
  45246. false,
  45247. false
  45248. ],
  45249. "CC-BY-3.0-DE": [
  45250. "Creative Commons Attribution 3.0 Germany",
  45251. false,
  45252. false
  45253. ],
  45254. "CC-BY-3.0-NL": [
  45255. "Creative Commons Attribution 3.0 Netherlands",
  45256. false,
  45257. false
  45258. ],
  45259. "CC-BY-3.0-US": [
  45260. "Creative Commons Attribution 3.0 United States",
  45261. false,
  45262. false
  45263. ],
  45264. "CC-BY-4.0": [
  45265. "Creative Commons Attribution 4.0 International",
  45266. false,
  45267. false
  45268. ],
  45269. "CC-BY-NC-1.0": [
  45270. "Creative Commons Attribution Non Commercial 1.0 Generic",
  45271. false,
  45272. false
  45273. ],
  45274. "CC-BY-NC-2.0": [
  45275. "Creative Commons Attribution Non Commercial 2.0 Generic",
  45276. false,
  45277. false
  45278. ],
  45279. "CC-BY-NC-2.5": [
  45280. "Creative Commons Attribution Non Commercial 2.5 Generic",
  45281. false,
  45282. false
  45283. ],
  45284. "CC-BY-NC-3.0": [
  45285. "Creative Commons Attribution Non Commercial 3.0 Unported",
  45286. false,
  45287. false
  45288. ],
  45289. "CC-BY-NC-3.0-DE": [
  45290. "Creative Commons Attribution Non Commercial 3.0 Germany",
  45291. false,
  45292. false
  45293. ],
  45294. "CC-BY-NC-4.0": [
  45295. "Creative Commons Attribution Non Commercial 4.0 International",
  45296. false,
  45297. false
  45298. ],
  45299. "CC-BY-NC-ND-1.0": [
  45300. "Creative Commons Attribution Non Commercial No Derivatives 1.0 Generic",
  45301. false,
  45302. false
  45303. ],
  45304. "CC-BY-NC-ND-2.0": [
  45305. "Creative Commons Attribution Non Commercial No Derivatives 2.0 Generic",
  45306. false,
  45307. false
  45308. ],
  45309. "CC-BY-NC-ND-2.5": [
  45310. "Creative Commons Attribution Non Commercial No Derivatives 2.5 Generic",
  45311. false,
  45312. false
  45313. ],
  45314. "CC-BY-NC-ND-3.0": [
  45315. "Creative Commons Attribution Non Commercial No Derivatives 3.0 Unported",
  45316. false,
  45317. false
  45318. ],
  45319. "CC-BY-NC-ND-3.0-DE": [
  45320. "Creative Commons Attribution Non Commercial No Derivatives 3.0 Germany",
  45321. false,
  45322. false
  45323. ],
  45324. "CC-BY-NC-ND-3.0-IGO": [
  45325. "Creative Commons Attribution Non Commercial No Derivatives 3.0 IGO",
  45326. false,
  45327. false
  45328. ],
  45329. "CC-BY-NC-ND-4.0": [
  45330. "Creative Commons Attribution Non Commercial No Derivatives 4.0 International",
  45331. false,
  45332. false
  45333. ],
  45334. "CC-BY-NC-SA-1.0": [
  45335. "Creative Commons Attribution Non Commercial Share Alike 1.0 Generic",
  45336. false,
  45337. false
  45338. ],
  45339. "CC-BY-NC-SA-2.0": [
  45340. "Creative Commons Attribution Non Commercial Share Alike 2.0 Generic",
  45341. false,
  45342. false
  45343. ],
  45344. "CC-BY-NC-SA-2.0-FR": [
  45345. "Creative Commons Attribution-NonCommercial-ShareAlike 2.0 France",
  45346. false,
  45347. false
  45348. ],
  45349. "CC-BY-NC-SA-2.0-UK": [
  45350. "Creative Commons Attribution Non Commercial Share Alike 2.0 England and Wales",
  45351. false,
  45352. false
  45353. ],
  45354. "CC-BY-NC-SA-2.5": [
  45355. "Creative Commons Attribution Non Commercial Share Alike 2.5 Generic",
  45356. false,
  45357. false
  45358. ],
  45359. "CC-BY-NC-SA-3.0": [
  45360. "Creative Commons Attribution Non Commercial Share Alike 3.0 Unported",
  45361. false,
  45362. false
  45363. ],
  45364. "CC-BY-NC-SA-3.0-DE": [
  45365. "Creative Commons Attribution Non Commercial Share Alike 3.0 Germany",
  45366. false,
  45367. false
  45368. ],
  45369. "CC-BY-NC-SA-3.0-IGO": [
  45370. "Creative Commons Attribution Non Commercial Share Alike 3.0 IGO",
  45371. false,
  45372. false
  45373. ],
  45374. "CC-BY-NC-SA-4.0": [
  45375. "Creative Commons Attribution Non Commercial Share Alike 4.0 International",
  45376. false,
  45377. false
  45378. ],
  45379. "CC-BY-ND-1.0": [
  45380. "Creative Commons Attribution No Derivatives 1.0 Generic",
  45381. false,
  45382. false
  45383. ],
  45384. "CC-BY-ND-2.0": [
  45385. "Creative Commons Attribution No Derivatives 2.0 Generic",
  45386. false,
  45387. false
  45388. ],
  45389. "CC-BY-ND-2.5": [
  45390. "Creative Commons Attribution No Derivatives 2.5 Generic",
  45391. false,
  45392. false
  45393. ],
  45394. "CC-BY-ND-3.0": [
  45395. "Creative Commons Attribution No Derivatives 3.0 Unported",
  45396. false,
  45397. false
  45398. ],
  45399. "CC-BY-ND-3.0-DE": [
  45400. "Creative Commons Attribution No Derivatives 3.0 Germany",
  45401. false,
  45402. false
  45403. ],
  45404. "CC-BY-ND-4.0": [
  45405. "Creative Commons Attribution No Derivatives 4.0 International",
  45406. false,
  45407. false
  45408. ],
  45409. "CC-BY-SA-1.0": [
  45410. "Creative Commons Attribution Share Alike 1.0 Generic",
  45411. false,
  45412. false
  45413. ],
  45414. "CC-BY-SA-2.0": [
  45415. "Creative Commons Attribution Share Alike 2.0 Generic",
  45416. false,
  45417. false
  45418. ],
  45419. "CC-BY-SA-2.0-UK": [
  45420. "Creative Commons Attribution Share Alike 2.0 England and Wales",
  45421. false,
  45422. false
  45423. ],
  45424. "CC-BY-SA-2.1-JP": [
  45425. "Creative Commons Attribution Share Alike 2.1 Japan",
  45426. false,
  45427. false
  45428. ],
  45429. "CC-BY-SA-2.5": [
  45430. "Creative Commons Attribution Share Alike 2.5 Generic",
  45431. false,
  45432. false
  45433. ],
  45434. "CC-BY-SA-3.0": [
  45435. "Creative Commons Attribution Share Alike 3.0 Unported",
  45436. false,
  45437. false
  45438. ],
  45439. "CC-BY-SA-3.0-AT": [
  45440. "Creative Commons Attribution Share Alike 3.0 Austria",
  45441. false,
  45442. false
  45443. ],
  45444. "CC-BY-SA-3.0-DE": [
  45445. "Creative Commons Attribution Share Alike 3.0 Germany",
  45446. false,
  45447. false
  45448. ],
  45449. "CC-BY-SA-4.0": [
  45450. "Creative Commons Attribution Share Alike 4.0 International",
  45451. false,
  45452. false
  45453. ],
  45454. "CC-PDDC": [
  45455. "Creative Commons Public Domain Dedication and Certification",
  45456. false,
  45457. false
  45458. ],
  45459. "CC0-1.0": [
  45460. "Creative Commons Zero v1.0 Universal",
  45461. false,
  45462. false
  45463. ],
  45464. "CDDL-1.0": [
  45465. "Common Development and Distribution License 1.0",
  45466. true,
  45467. false
  45468. ],
  45469. "CDDL-1.1": [
  45470. "Common Development and Distribution License 1.1",
  45471. false,
  45472. false
  45473. ],
  45474. "CDL-1.0": [
  45475. "Common Documentation License 1.0",
  45476. false,
  45477. false
  45478. ],
  45479. "CDLA-Permissive-1.0": [
  45480. "Community Data License Agreement Permissive 1.0",
  45481. false,
  45482. false
  45483. ],
  45484. "CDLA-Permissive-2.0": [
  45485. "Community Data License Agreement Permissive 2.0",
  45486. false,
  45487. false
  45488. ],
  45489. "CDLA-Sharing-1.0": [
  45490. "Community Data License Agreement Sharing 1.0",
  45491. false,
  45492. false
  45493. ],
  45494. "CECILL-1.0": [
  45495. "CeCILL Free Software License Agreement v1.0",
  45496. false,
  45497. false
  45498. ],
  45499. "CECILL-1.1": [
  45500. "CeCILL Free Software License Agreement v1.1",
  45501. false,
  45502. false
  45503. ],
  45504. "CECILL-2.0": [
  45505. "CeCILL Free Software License Agreement v2.0",
  45506. false,
  45507. false
  45508. ],
  45509. "CECILL-2.1": [
  45510. "CeCILL Free Software License Agreement v2.1",
  45511. true,
  45512. false
  45513. ],
  45514. "CECILL-B": [
  45515. "CeCILL-B Free Software License Agreement",
  45516. false,
  45517. false
  45518. ],
  45519. "CECILL-C": [
  45520. "CeCILL-C Free Software License Agreement",
  45521. false,
  45522. false
  45523. ],
  45524. "CERN-OHL-1.1": [
  45525. "CERN Open Hardware Licence v1.1",
  45526. false,
  45527. false
  45528. ],
  45529. "CERN-OHL-1.2": [
  45530. "CERN Open Hardware Licence v1.2",
  45531. false,
  45532. false
  45533. ],
  45534. "CERN-OHL-P-2.0": [
  45535. "CERN Open Hardware Licence Version 2 - Permissive",
  45536. true,
  45537. false
  45538. ],
  45539. "CERN-OHL-S-2.0": [
  45540. "CERN Open Hardware Licence Version 2 - Strongly Reciprocal",
  45541. true,
  45542. false
  45543. ],
  45544. "CERN-OHL-W-2.0": [
  45545. "CERN Open Hardware Licence Version 2 - Weakly Reciprocal",
  45546. true,
  45547. false
  45548. ],
  45549. "ClArtistic": [
  45550. "Clarified Artistic License",
  45551. false,
  45552. false
  45553. ],
  45554. "CNRI-Jython": [
  45555. "CNRI Jython License",
  45556. false,
  45557. false
  45558. ],
  45559. "CNRI-Python": [
  45560. "CNRI Python License",
  45561. true,
  45562. false
  45563. ],
  45564. "CNRI-Python-GPL-Compatible": [
  45565. "CNRI Python Open Source GPL Compatible License Agreement",
  45566. false,
  45567. false
  45568. ],
  45569. "COIL-1.0": [
  45570. "Copyfree Open Innovation License",
  45571. false,
  45572. false
  45573. ],
  45574. "Community-Spec-1.0": [
  45575. "Community Specification License 1.0",
  45576. false,
  45577. false
  45578. ],
  45579. "Condor-1.1": [
  45580. "Condor Public License v1.1",
  45581. false,
  45582. false
  45583. ],
  45584. "copyleft-next-0.3.0": [
  45585. "copyleft-next 0.3.0",
  45586. false,
  45587. false
  45588. ],
  45589. "copyleft-next-0.3.1": [
  45590. "copyleft-next 0.3.1",
  45591. false,
  45592. false
  45593. ],
  45594. "CPAL-1.0": [
  45595. "Common Public Attribution License 1.0",
  45596. true,
  45597. false
  45598. ],
  45599. "CPL-1.0": [
  45600. "Common Public License 1.0",
  45601. true,
  45602. false
  45603. ],
  45604. "CPOL-1.02": [
  45605. "Code Project Open License 1.02",
  45606. false,
  45607. false
  45608. ],
  45609. "Crossword": [
  45610. "Crossword License",
  45611. false,
  45612. false
  45613. ],
  45614. "CrystalStacker": [
  45615. "CrystalStacker License",
  45616. false,
  45617. false
  45618. ],
  45619. "CUA-OPL-1.0": [
  45620. "CUA Office Public License v1.0",
  45621. true,
  45622. false
  45623. ],
  45624. "Cube": [
  45625. "Cube License",
  45626. false,
  45627. false
  45628. ],
  45629. "curl": [
  45630. "curl License",
  45631. false,
  45632. false
  45633. ],
  45634. "D-FSL-1.0": [
  45635. "Deutsche Freie Software Lizenz",
  45636. false,
  45637. false
  45638. ],
  45639. "diffmark": [
  45640. "diffmark license",
  45641. false,
  45642. false
  45643. ],
  45644. "DOC": [
  45645. "DOC License",
  45646. false,
  45647. false
  45648. ],
  45649. "Dotseqn": [
  45650. "Dotseqn License",
  45651. false,
  45652. false
  45653. ],
  45654. "DRL-1.0": [
  45655. "Detection Rule License 1.0",
  45656. false,
  45657. false
  45658. ],
  45659. "DSDP": [
  45660. "DSDP License",
  45661. false,
  45662. false
  45663. ],
  45664. "dvipdfm": [
  45665. "dvipdfm License",
  45666. false,
  45667. false
  45668. ],
  45669. "ECL-1.0": [
  45670. "Educational Community License v1.0",
  45671. true,
  45672. false
  45673. ],
  45674. "ECL-2.0": [
  45675. "Educational Community License v2.0",
  45676. true,
  45677. false
  45678. ],
  45679. "eCos-2.0": [
  45680. "eCos license version 2.0",
  45681. false,
  45682. true
  45683. ],
  45684. "EFL-1.0": [
  45685. "Eiffel Forum License v1.0",
  45686. true,
  45687. false
  45688. ],
  45689. "EFL-2.0": [
  45690. "Eiffel Forum License v2.0",
  45691. true,
  45692. false
  45693. ],
  45694. "eGenix": [
  45695. "eGenix.com Public License 1.1.0",
  45696. false,
  45697. false
  45698. ],
  45699. "Entessa": [
  45700. "Entessa Public License v1.0",
  45701. true,
  45702. false
  45703. ],
  45704. "EPICS": [
  45705. "EPICS Open License",
  45706. false,
  45707. false
  45708. ],
  45709. "EPL-1.0": [
  45710. "Eclipse Public License 1.0",
  45711. true,
  45712. false
  45713. ],
  45714. "EPL-2.0": [
  45715. "Eclipse Public License 2.0",
  45716. true,
  45717. false
  45718. ],
  45719. "ErlPL-1.1": [
  45720. "Erlang Public License v1.1",
  45721. false,
  45722. false
  45723. ],
  45724. "etalab-2.0": [
  45725. "Etalab Open License 2.0",
  45726. false,
  45727. false
  45728. ],
  45729. "EUDatagrid": [
  45730. "EU DataGrid Software License",
  45731. true,
  45732. false
  45733. ],
  45734. "EUPL-1.0": [
  45735. "European Union Public License 1.0",
  45736. false,
  45737. false
  45738. ],
  45739. "EUPL-1.1": [
  45740. "European Union Public License 1.1",
  45741. true,
  45742. false
  45743. ],
  45744. "EUPL-1.2": [
  45745. "European Union Public License 1.2",
  45746. true,
  45747. false
  45748. ],
  45749. "Eurosym": [
  45750. "Eurosym License",
  45751. false,
  45752. false
  45753. ],
  45754. "Fair": [
  45755. "Fair License",
  45756. true,
  45757. false
  45758. ],
  45759. "FDK-AAC": [
  45760. "Fraunhofer FDK AAC Codec Library",
  45761. false,
  45762. false
  45763. ],
  45764. "Frameworx-1.0": [
  45765. "Frameworx Open License 1.0",
  45766. true,
  45767. false
  45768. ],
  45769. "FreeBSD-DOC": [
  45770. "FreeBSD Documentation License",
  45771. false,
  45772. false
  45773. ],
  45774. "FreeImage": [
  45775. "FreeImage Public License v1.0",
  45776. false,
  45777. false
  45778. ],
  45779. "FSFAP": [
  45780. "FSF All Permissive License",
  45781. false,
  45782. false
  45783. ],
  45784. "FSFUL": [
  45785. "FSF Unlimited License",
  45786. false,
  45787. false
  45788. ],
  45789. "FSFULLR": [
  45790. "FSF Unlimited License (with License Retention)",
  45791. false,
  45792. false
  45793. ],
  45794. "FTL": [
  45795. "Freetype Project License",
  45796. false,
  45797. false
  45798. ],
  45799. "GD": [
  45800. "GD License",
  45801. false,
  45802. false
  45803. ],
  45804. "GFDL-1.1": [
  45805. "GNU Free Documentation License v1.1",
  45806. false,
  45807. true
  45808. ],
  45809. "GFDL-1.1-invariants-only": [
  45810. "GNU Free Documentation License v1.1 only - invariants",
  45811. false,
  45812. false
  45813. ],
  45814. "GFDL-1.1-invariants-or-later": [
  45815. "GNU Free Documentation License v1.1 or later - invariants",
  45816. false,
  45817. false
  45818. ],
  45819. "GFDL-1.1-no-invariants-only": [
  45820. "GNU Free Documentation License v1.1 only - no invariants",
  45821. false,
  45822. false
  45823. ],
  45824. "GFDL-1.1-no-invariants-or-later": [
  45825. "GNU Free Documentation License v1.1 or later - no invariants",
  45826. false,
  45827. false
  45828. ],
  45829. "GFDL-1.1-only": [
  45830. "GNU Free Documentation License v1.1 only",
  45831. false,
  45832. false
  45833. ],
  45834. "GFDL-1.1-or-later": [
  45835. "GNU Free Documentation License v1.1 or later",
  45836. false,
  45837. false
  45838. ],
  45839. "GFDL-1.2": [
  45840. "GNU Free Documentation License v1.2",
  45841. false,
  45842. true
  45843. ],
  45844. "GFDL-1.2-invariants-only": [
  45845. "GNU Free Documentation License v1.2 only - invariants",
  45846. false,
  45847. false
  45848. ],
  45849. "GFDL-1.2-invariants-or-later": [
  45850. "GNU Free Documentation License v1.2 or later - invariants",
  45851. false,
  45852. false
  45853. ],
  45854. "GFDL-1.2-no-invariants-only": [
  45855. "GNU Free Documentation License v1.2 only - no invariants",
  45856. false,
  45857. false
  45858. ],
  45859. "GFDL-1.2-no-invariants-or-later": [
  45860. "GNU Free Documentation License v1.2 or later - no invariants",
  45861. false,
  45862. false
  45863. ],
  45864. "GFDL-1.2-only": [
  45865. "GNU Free Documentation License v1.2 only",
  45866. false,
  45867. false
  45868. ],
  45869. "GFDL-1.2-or-later": [
  45870. "GNU Free Documentation License v1.2 or later",
  45871. false,
  45872. false
  45873. ],
  45874. "GFDL-1.3": [
  45875. "GNU Free Documentation License v1.3",
  45876. false,
  45877. true
  45878. ],
  45879. "GFDL-1.3-invariants-only": [
  45880. "GNU Free Documentation License v1.3 only - invariants",
  45881. false,
  45882. false
  45883. ],
  45884. "GFDL-1.3-invariants-or-later": [
  45885. "GNU Free Documentation License v1.3 or later - invariants",
  45886. false,
  45887. false
  45888. ],
  45889. "GFDL-1.3-no-invariants-only": [
  45890. "GNU Free Documentation License v1.3 only - no invariants",
  45891. false,
  45892. false
  45893. ],
  45894. "GFDL-1.3-no-invariants-or-later": [
  45895. "GNU Free Documentation License v1.3 or later - no invariants",
  45896. false,
  45897. false
  45898. ],
  45899. "GFDL-1.3-only": [
  45900. "GNU Free Documentation License v1.3 only",
  45901. false,
  45902. false
  45903. ],
  45904. "GFDL-1.3-or-later": [
  45905. "GNU Free Documentation License v1.3 or later",
  45906. false,
  45907. false
  45908. ],
  45909. "Giftware": [
  45910. "Giftware License",
  45911. false,
  45912. false
  45913. ],
  45914. "GL2PS": [
  45915. "GL2PS License",
  45916. false,
  45917. false
  45918. ],
  45919. "Glide": [
  45920. "3dfx Glide License",
  45921. false,
  45922. false
  45923. ],
  45924. "Glulxe": [
  45925. "Glulxe License",
  45926. false,
  45927. false
  45928. ],
  45929. "GLWTPL": [
  45930. "Good Luck With That Public License",
  45931. false,
  45932. false
  45933. ],
  45934. "gnuplot": [
  45935. "gnuplot License",
  45936. false,
  45937. false
  45938. ],
  45939. "GPL-1.0": [
  45940. "GNU General Public License v1.0 only",
  45941. false,
  45942. true
  45943. ],
  45944. "GPL-1.0+": [
  45945. "GNU General Public License v1.0 or later",
  45946. false,
  45947. true
  45948. ],
  45949. "GPL-1.0-only": [
  45950. "GNU General Public License v1.0 only",
  45951. false,
  45952. false
  45953. ],
  45954. "GPL-1.0-or-later": [
  45955. "GNU General Public License v1.0 or later",
  45956. false,
  45957. false
  45958. ],
  45959. "GPL-2.0": [
  45960. "GNU General Public License v2.0 only",
  45961. true,
  45962. true
  45963. ],
  45964. "GPL-2.0+": [
  45965. "GNU General Public License v2.0 or later",
  45966. true,
  45967. true
  45968. ],
  45969. "GPL-2.0-only": [
  45970. "GNU General Public License v2.0 only",
  45971. true,
  45972. false
  45973. ],
  45974. "GPL-2.0-or-later": [
  45975. "GNU General Public License v2.0 or later",
  45976. true,
  45977. false
  45978. ],
  45979. "GPL-2.0-with-autoconf-exception": [
  45980. "GNU General Public License v2.0 w/Autoconf exception",
  45981. false,
  45982. true
  45983. ],
  45984. "GPL-2.0-with-bison-exception": [
  45985. "GNU General Public License v2.0 w/Bison exception",
  45986. false,
  45987. true
  45988. ],
  45989. "GPL-2.0-with-classpath-exception": [
  45990. "GNU General Public License v2.0 w/Classpath exception",
  45991. false,
  45992. true
  45993. ],
  45994. "GPL-2.0-with-font-exception": [
  45995. "GNU General Public License v2.0 w/Font exception",
  45996. false,
  45997. true
  45998. ],
  45999. "GPL-2.0-with-GCC-exception": [
  46000. "GNU General Public License v2.0 w/GCC Runtime Library exception",
  46001. false,
  46002. true
  46003. ],
  46004. "GPL-3.0": [
  46005. "GNU General Public License v3.0 only",
  46006. true,
  46007. true
  46008. ],
  46009. "GPL-3.0+": [
  46010. "GNU General Public License v3.0 or later",
  46011. true,
  46012. true
  46013. ],
  46014. "GPL-3.0-only": [
  46015. "GNU General Public License v3.0 only",
  46016. true,
  46017. false
  46018. ],
  46019. "GPL-3.0-or-later": [
  46020. "GNU General Public License v3.0 or later",
  46021. true,
  46022. false
  46023. ],
  46024. "GPL-3.0-with-autoconf-exception": [
  46025. "GNU General Public License v3.0 w/Autoconf exception",
  46026. false,
  46027. true
  46028. ],
  46029. "GPL-3.0-with-GCC-exception": [
  46030. "GNU General Public License v3.0 w/GCC Runtime Library exception",
  46031. true,
  46032. true
  46033. ],
  46034. "gSOAP-1.3b": [
  46035. "gSOAP Public License v1.3b",
  46036. false,
  46037. false
  46038. ],
  46039. "HaskellReport": [
  46040. "Haskell Language Report License",
  46041. false,
  46042. false
  46043. ],
  46044. "Hippocratic-2.1": [
  46045. "Hippocratic License 2.1",
  46046. false,
  46047. false
  46048. ],
  46049. "HPND": [
  46050. "Historical Permission Notice and Disclaimer",
  46051. true,
  46052. false
  46053. ],
  46054. "HPND-sell-variant": [
  46055. "Historical Permission Notice and Disclaimer - sell variant",
  46056. false,
  46057. false
  46058. ],
  46059. "HTMLTIDY": [
  46060. "HTML Tidy License",
  46061. false,
  46062. false
  46063. ],
  46064. "IBM-pibs": [
  46065. "IBM PowerPC Initialization and Boot Software",
  46066. false,
  46067. false
  46068. ],
  46069. "ICU": [
  46070. "ICU License",
  46071. false,
  46072. false
  46073. ],
  46074. "IJG": [
  46075. "Independent JPEG Group License",
  46076. false,
  46077. false
  46078. ],
  46079. "ImageMagick": [
  46080. "ImageMagick License",
  46081. false,
  46082. false
  46083. ],
  46084. "iMatix": [
  46085. "iMatix Standard Function Library Agreement",
  46086. false,
  46087. false
  46088. ],
  46089. "Imlib2": [
  46090. "Imlib2 License",
  46091. false,
  46092. false
  46093. ],
  46094. "Info-ZIP": [
  46095. "Info-ZIP License",
  46096. false,
  46097. false
  46098. ],
  46099. "Intel": [
  46100. "Intel Open Source License",
  46101. true,
  46102. false
  46103. ],
  46104. "Intel-ACPI": [
  46105. "Intel ACPI Software License Agreement",
  46106. false,
  46107. false
  46108. ],
  46109. "Interbase-1.0": [
  46110. "Interbase Public License v1.0",
  46111. false,
  46112. false
  46113. ],
  46114. "IPA": [
  46115. "IPA Font License",
  46116. true,
  46117. false
  46118. ],
  46119. "IPL-1.0": [
  46120. "IBM Public License v1.0",
  46121. true,
  46122. false
  46123. ],
  46124. "ISC": [
  46125. "ISC License",
  46126. true,
  46127. false
  46128. ],
  46129. "JasPer-2.0": [
  46130. "JasPer License",
  46131. false,
  46132. false
  46133. ],
  46134. "JPNIC": [
  46135. "Japan Network Information Center License",
  46136. false,
  46137. false
  46138. ],
  46139. "JSON": [
  46140. "JSON License",
  46141. false,
  46142. false
  46143. ],
  46144. "LAL-1.2": [
  46145. "Licence Art Libre 1.2",
  46146. false,
  46147. false
  46148. ],
  46149. "LAL-1.3": [
  46150. "Licence Art Libre 1.3",
  46151. false,
  46152. false
  46153. ],
  46154. "Latex2e": [
  46155. "Latex2e License",
  46156. false,
  46157. false
  46158. ],
  46159. "Leptonica": [
  46160. "Leptonica License",
  46161. false,
  46162. false
  46163. ],
  46164. "LGPL-2.0": [
  46165. "GNU Library General Public License v2 only",
  46166. true,
  46167. true
  46168. ],
  46169. "LGPL-2.0+": [
  46170. "GNU Library General Public License v2 or later",
  46171. true,
  46172. true
  46173. ],
  46174. "LGPL-2.0-only": [
  46175. "GNU Library General Public License v2 only",
  46176. true,
  46177. false
  46178. ],
  46179. "LGPL-2.0-or-later": [
  46180. "GNU Library General Public License v2 or later",
  46181. true,
  46182. false
  46183. ],
  46184. "LGPL-2.1": [
  46185. "GNU Lesser General Public License v2.1 only",
  46186. true,
  46187. true
  46188. ],
  46189. "LGPL-2.1+": [
  46190. "GNU Library General Public License v2.1 or later",
  46191. true,
  46192. true
  46193. ],
  46194. "LGPL-2.1-only": [
  46195. "GNU Lesser General Public License v2.1 only",
  46196. true,
  46197. false
  46198. ],
  46199. "LGPL-2.1-or-later": [
  46200. "GNU Lesser General Public License v2.1 or later",
  46201. true,
  46202. false
  46203. ],
  46204. "LGPL-3.0": [
  46205. "GNU Lesser General Public License v3.0 only",
  46206. true,
  46207. true
  46208. ],
  46209. "LGPL-3.0+": [
  46210. "GNU Lesser General Public License v3.0 or later",
  46211. true,
  46212. true
  46213. ],
  46214. "LGPL-3.0-only": [
  46215. "GNU Lesser General Public License v3.0 only",
  46216. true,
  46217. false
  46218. ],
  46219. "LGPL-3.0-or-later": [
  46220. "GNU Lesser General Public License v3.0 or later",
  46221. true,
  46222. false
  46223. ],
  46224. "LGPLLR": [
  46225. "Lesser General Public License For Linguistic Resources",
  46226. false,
  46227. false
  46228. ],
  46229. "Libpng": [
  46230. "libpng License",
  46231. false,
  46232. false
  46233. ],
  46234. "libpng-2.0": [
  46235. "PNG Reference Library version 2",
  46236. false,
  46237. false
  46238. ],
  46239. "libselinux-1.0": [
  46240. "libselinux public domain notice",
  46241. false,
  46242. false
  46243. ],
  46244. "libtiff": [
  46245. "libtiff License",
  46246. false,
  46247. false
  46248. ],
  46249. "LiLiQ-P-1.1": [
  46250. "Licence Libre du Qu\u00e9bec \u2013 Permissive version 1.1",
  46251. true,
  46252. false
  46253. ],
  46254. "LiLiQ-R-1.1": [
  46255. "Licence Libre du Qu\u00e9bec \u2013 R\u00e9ciprocit\u00e9 version 1.1",
  46256. true,
  46257. false
  46258. ],
  46259. "LiLiQ-Rplus-1.1": [
  46260. "Licence Libre du Qu\u00e9bec \u2013 R\u00e9ciprocit\u00e9 forte version 1.1",
  46261. true,
  46262. false
  46263. ],
  46264. "Linux-man-pages-copyleft": [
  46265. "Linux man-pages Copyleft",
  46266. false,
  46267. false
  46268. ],
  46269. "Linux-OpenIB": [
  46270. "Linux Kernel Variant of OpenIB.org license",
  46271. false,
  46272. false
  46273. ],
  46274. "LPL-1.0": [
  46275. "Lucent Public License Version 1.0",
  46276. true,
  46277. false
  46278. ],
  46279. "LPL-1.02": [
  46280. "Lucent Public License v1.02",
  46281. true,
  46282. false
  46283. ],
  46284. "LPPL-1.0": [
  46285. "LaTeX Project Public License v1.0",
  46286. false,
  46287. false
  46288. ],
  46289. "LPPL-1.1": [
  46290. "LaTeX Project Public License v1.1",
  46291. false,
  46292. false
  46293. ],
  46294. "LPPL-1.2": [
  46295. "LaTeX Project Public License v1.2",
  46296. false,
  46297. false
  46298. ],
  46299. "LPPL-1.3a": [
  46300. "LaTeX Project Public License v1.3a",
  46301. false,
  46302. false
  46303. ],
  46304. "LPPL-1.3c": [
  46305. "LaTeX Project Public License v1.3c",
  46306. true,
  46307. false
  46308. ],
  46309. "MakeIndex": [
  46310. "MakeIndex License",
  46311. false,
  46312. false
  46313. ],
  46314. "MirOS": [
  46315. "The MirOS Licence",
  46316. true,
  46317. false
  46318. ],
  46319. "MIT": [
  46320. "MIT License",
  46321. true,
  46322. false
  46323. ],
  46324. "MIT-0": [
  46325. "MIT No Attribution",
  46326. true,
  46327. false
  46328. ],
  46329. "MIT-advertising": [
  46330. "Enlightenment License (e16)",
  46331. false,
  46332. false
  46333. ],
  46334. "MIT-CMU": [
  46335. "CMU License",
  46336. false,
  46337. false
  46338. ],
  46339. "MIT-enna": [
  46340. "enna License",
  46341. false,
  46342. false
  46343. ],
  46344. "MIT-feh": [
  46345. "feh License",
  46346. false,
  46347. false
  46348. ],
  46349. "MIT-Modern-Variant": [
  46350. "MIT License Modern Variant",
  46351. true,
  46352. false
  46353. ],
  46354. "MIT-open-group": [
  46355. "MIT Open Group variant",
  46356. false,
  46357. false
  46358. ],
  46359. "MITNFA": [
  46360. "MIT +no-false-attribs license",
  46361. false,
  46362. false
  46363. ],
  46364. "Motosoto": [
  46365. "Motosoto License",
  46366. true,
  46367. false
  46368. ],
  46369. "mpich2": [
  46370. "mpich2 License",
  46371. false,
  46372. false
  46373. ],
  46374. "MPL-1.0": [
  46375. "Mozilla Public License 1.0",
  46376. true,
  46377. false
  46378. ],
  46379. "MPL-1.1": [
  46380. "Mozilla Public License 1.1",
  46381. true,
  46382. false
  46383. ],
  46384. "MPL-2.0": [
  46385. "Mozilla Public License 2.0",
  46386. true,
  46387. false
  46388. ],
  46389. "MPL-2.0-no-copyleft-exception": [
  46390. "Mozilla Public License 2.0 (no copyleft exception)",
  46391. true,
  46392. false
  46393. ],
  46394. "MS-PL": [
  46395. "Microsoft Public License",
  46396. true,
  46397. false
  46398. ],
  46399. "MS-RL": [
  46400. "Microsoft Reciprocal License",
  46401. true,
  46402. false
  46403. ],
  46404. "MTLL": [
  46405. "Matrix Template Library License",
  46406. false,
  46407. false
  46408. ],
  46409. "MulanPSL-1.0": [
  46410. "Mulan Permissive Software License, Version 1",
  46411. false,
  46412. false
  46413. ],
  46414. "MulanPSL-2.0": [
  46415. "Mulan Permissive Software License, Version 2",
  46416. true,
  46417. false
  46418. ],
  46419. "Multics": [
  46420. "Multics License",
  46421. true,
  46422. false
  46423. ],
  46424. "Mup": [
  46425. "Mup License",
  46426. false,
  46427. false
  46428. ],
  46429. "NAIST-2003": [
  46430. "Nara Institute of Science and Technology License (2003)",
  46431. false,
  46432. false
  46433. ],
  46434. "NASA-1.3": [
  46435. "NASA Open Source Agreement 1.3",
  46436. true,
  46437. false
  46438. ],
  46439. "Naumen": [
  46440. "Naumen Public License",
  46441. true,
  46442. false
  46443. ],
  46444. "NBPL-1.0": [
  46445. "Net Boolean Public License v1",
  46446. false,
  46447. false
  46448. ],
  46449. "NCGL-UK-2.0": [
  46450. "Non-Commercial Government Licence",
  46451. false,
  46452. false
  46453. ],
  46454. "NCSA": [
  46455. "University of Illinois/NCSA Open Source License",
  46456. true,
  46457. false
  46458. ],
  46459. "Net-SNMP": [
  46460. "Net-SNMP License",
  46461. false,
  46462. false
  46463. ],
  46464. "NetCDF": [
  46465. "NetCDF license",
  46466. false,
  46467. false
  46468. ],
  46469. "Newsletr": [
  46470. "Newsletr License",
  46471. false,
  46472. false
  46473. ],
  46474. "NGPL": [
  46475. "Nethack General Public License",
  46476. true,
  46477. false
  46478. ],
  46479. "NIST-PD": [
  46480. "NIST Public Domain Notice",
  46481. false,
  46482. false
  46483. ],
  46484. "NIST-PD-fallback": [
  46485. "NIST Public Domain Notice with license fallback",
  46486. false,
  46487. false
  46488. ],
  46489. "NLOD-1.0": [
  46490. "Norwegian Licence for Open Government Data (NLOD) 1.0",
  46491. false,
  46492. false
  46493. ],
  46494. "NLOD-2.0": [
  46495. "Norwegian Licence for Open Government Data (NLOD) 2.0",
  46496. false,
  46497. false
  46498. ],
  46499. "NLPL": [
  46500. "No Limit Public License",
  46501. false,
  46502. false
  46503. ],
  46504. "Nokia": [
  46505. "Nokia Open Source License",
  46506. true,
  46507. false
  46508. ],
  46509. "NOSL": [
  46510. "Netizen Open Source License",
  46511. false,
  46512. false
  46513. ],
  46514. "Noweb": [
  46515. "Noweb License",
  46516. false,
  46517. false
  46518. ],
  46519. "NPL-1.0": [
  46520. "Netscape Public License v1.0",
  46521. false,
  46522. false
  46523. ],
  46524. "NPL-1.1": [
  46525. "Netscape Public License v1.1",
  46526. false,
  46527. false
  46528. ],
  46529. "NPOSL-3.0": [
  46530. "Non-Profit Open Software License 3.0",
  46531. true,
  46532. false
  46533. ],
  46534. "NRL": [
  46535. "NRL License",
  46536. false,
  46537. false
  46538. ],
  46539. "NTP": [
  46540. "NTP License",
  46541. true,
  46542. false
  46543. ],
  46544. "NTP-0": [
  46545. "NTP No Attribution",
  46546. false,
  46547. false
  46548. ],
  46549. "Nunit": [
  46550. "Nunit License",
  46551. false,
  46552. true
  46553. ],
  46554. "O-UDA-1.0": [
  46555. "Open Use of Data Agreement v1.0",
  46556. false,
  46557. false
  46558. ],
  46559. "OCCT-PL": [
  46560. "Open CASCADE Technology Public License",
  46561. false,
  46562. false
  46563. ],
  46564. "OCLC-2.0": [
  46565. "OCLC Research Public License 2.0",
  46566. true,
  46567. false
  46568. ],
  46569. "ODbL-1.0": [
  46570. "Open Data Commons Open Database License v1.0",
  46571. false,
  46572. false
  46573. ],
  46574. "ODC-By-1.0": [
  46575. "Open Data Commons Attribution License v1.0",
  46576. false,
  46577. false
  46578. ],
  46579. "OFL-1.0": [
  46580. "SIL Open Font License 1.0",
  46581. false,
  46582. false
  46583. ],
  46584. "OFL-1.0-no-RFN": [
  46585. "SIL Open Font License 1.0 with no Reserved Font Name",
  46586. false,
  46587. false
  46588. ],
  46589. "OFL-1.0-RFN": [
  46590. "SIL Open Font License 1.0 with Reserved Font Name",
  46591. false,
  46592. false
  46593. ],
  46594. "OFL-1.1": [
  46595. "SIL Open Font License 1.1",
  46596. true,
  46597. false
  46598. ],
  46599. "OFL-1.1-no-RFN": [
  46600. "SIL Open Font License 1.1 with no Reserved Font Name",
  46601. true,
  46602. false
  46603. ],
  46604. "OFL-1.1-RFN": [
  46605. "SIL Open Font License 1.1 with Reserved Font Name",
  46606. true,
  46607. false
  46608. ],
  46609. "OGC-1.0": [
  46610. "OGC Software License, Version 1.0",
  46611. false,
  46612. false
  46613. ],
  46614. "OGDL-Taiwan-1.0": [
  46615. "Taiwan Open Government Data License, version 1.0",
  46616. false,
  46617. false
  46618. ],
  46619. "OGL-Canada-2.0": [
  46620. "Open Government Licence - Canada",
  46621. false,
  46622. false
  46623. ],
  46624. "OGL-UK-1.0": [
  46625. "Open Government Licence v1.0",
  46626. false,
  46627. false
  46628. ],
  46629. "OGL-UK-2.0": [
  46630. "Open Government Licence v2.0",
  46631. false,
  46632. false
  46633. ],
  46634. "OGL-UK-3.0": [
  46635. "Open Government Licence v3.0",
  46636. false,
  46637. false
  46638. ],
  46639. "OGTSL": [
  46640. "Open Group Test Suite License",
  46641. true,
  46642. false
  46643. ],
  46644. "OLDAP-1.1": [
  46645. "Open LDAP Public License v1.1",
  46646. false,
  46647. false
  46648. ],
  46649. "OLDAP-1.2": [
  46650. "Open LDAP Public License v1.2",
  46651. false,
  46652. false
  46653. ],
  46654. "OLDAP-1.3": [
  46655. "Open LDAP Public License v1.3",
  46656. false,
  46657. false
  46658. ],
  46659. "OLDAP-1.4": [
  46660. "Open LDAP Public License v1.4",
  46661. false,
  46662. false
  46663. ],
  46664. "OLDAP-2.0": [
  46665. "Open LDAP Public License v2.0 (or possibly 2.0A and 2.0B)",
  46666. false,
  46667. false
  46668. ],
  46669. "OLDAP-2.0.1": [
  46670. "Open LDAP Public License v2.0.1",
  46671. false,
  46672. false
  46673. ],
  46674. "OLDAP-2.1": [
  46675. "Open LDAP Public License v2.1",
  46676. false,
  46677. false
  46678. ],
  46679. "OLDAP-2.2": [
  46680. "Open LDAP Public License v2.2",
  46681. false,
  46682. false
  46683. ],
  46684. "OLDAP-2.2.1": [
  46685. "Open LDAP Public License v2.2.1",
  46686. false,
  46687. false
  46688. ],
  46689. "OLDAP-2.2.2": [
  46690. "Open LDAP Public License 2.2.2",
  46691. false,
  46692. false
  46693. ],
  46694. "OLDAP-2.3": [
  46695. "Open LDAP Public License v2.3",
  46696. false,
  46697. false
  46698. ],
  46699. "OLDAP-2.4": [
  46700. "Open LDAP Public License v2.4",
  46701. false,
  46702. false
  46703. ],
  46704. "OLDAP-2.5": [
  46705. "Open LDAP Public License v2.5",
  46706. false,
  46707. false
  46708. ],
  46709. "OLDAP-2.6": [
  46710. "Open LDAP Public License v2.6",
  46711. false,
  46712. false
  46713. ],
  46714. "OLDAP-2.7": [
  46715. "Open LDAP Public License v2.7",
  46716. false,
  46717. false
  46718. ],
  46719. "OLDAP-2.8": [
  46720. "Open LDAP Public License v2.8",
  46721. true,
  46722. false
  46723. ],
  46724. "OML": [
  46725. "Open Market License",
  46726. false,
  46727. false
  46728. ],
  46729. "OpenSSL": [
  46730. "OpenSSL License",
  46731. false,
  46732. false
  46733. ],
  46734. "OPL-1.0": [
  46735. "Open Public License v1.0",
  46736. false,
  46737. false
  46738. ],
  46739. "OPUBL-1.0": [
  46740. "Open Publication License v1.0",
  46741. false,
  46742. false
  46743. ],
  46744. "OSET-PL-2.1": [
  46745. "OSET Public License version 2.1",
  46746. true,
  46747. false
  46748. ],
  46749. "OSL-1.0": [
  46750. "Open Software License 1.0",
  46751. true,
  46752. false
  46753. ],
  46754. "OSL-1.1": [
  46755. "Open Software License 1.1",
  46756. false,
  46757. false
  46758. ],
  46759. "OSL-2.0": [
  46760. "Open Software License 2.0",
  46761. true,
  46762. false
  46763. ],
  46764. "OSL-2.1": [
  46765. "Open Software License 2.1",
  46766. true,
  46767. false
  46768. ],
  46769. "OSL-3.0": [
  46770. "Open Software License 3.0",
  46771. true,
  46772. false
  46773. ],
  46774. "Parity-6.0.0": [
  46775. "The Parity Public License 6.0.0",
  46776. false,
  46777. false
  46778. ],
  46779. "Parity-7.0.0": [
  46780. "The Parity Public License 7.0.0",
  46781. false,
  46782. false
  46783. ],
  46784. "PDDL-1.0": [
  46785. "Open Data Commons Public Domain Dedication & License 1.0",
  46786. false,
  46787. false
  46788. ],
  46789. "PHP-3.0": [
  46790. "PHP License v3.0",
  46791. true,
  46792. false
  46793. ],
  46794. "PHP-3.01": [
  46795. "PHP License v3.01",
  46796. true,
  46797. false
  46798. ],
  46799. "Plexus": [
  46800. "Plexus Classworlds License",
  46801. false,
  46802. false
  46803. ],
  46804. "PolyForm-Noncommercial-1.0.0": [
  46805. "PolyForm Noncommercial License 1.0.0",
  46806. false,
  46807. false
  46808. ],
  46809. "PolyForm-Small-Business-1.0.0": [
  46810. "PolyForm Small Business License 1.0.0",
  46811. false,
  46812. false
  46813. ],
  46814. "PostgreSQL": [
  46815. "PostgreSQL License",
  46816. true,
  46817. false
  46818. ],
  46819. "PSF-2.0": [
  46820. "Python Software Foundation License 2.0",
  46821. false,
  46822. false
  46823. ],
  46824. "psfrag": [
  46825. "psfrag License",
  46826. false,
  46827. false
  46828. ],
  46829. "psutils": [
  46830. "psutils License",
  46831. false,
  46832. false
  46833. ],
  46834. "Python-2.0": [
  46835. "Python License 2.0",
  46836. true,
  46837. false
  46838. ],
  46839. "Qhull": [
  46840. "Qhull License",
  46841. false,
  46842. false
  46843. ],
  46844. "QPL-1.0": [
  46845. "Q Public License 1.0",
  46846. true,
  46847. false
  46848. ],
  46849. "Rdisc": [
  46850. "Rdisc License",
  46851. false,
  46852. false
  46853. ],
  46854. "RHeCos-1.1": [
  46855. "Red Hat eCos Public License v1.1",
  46856. false,
  46857. false
  46858. ],
  46859. "RPL-1.1": [
  46860. "Reciprocal Public License 1.1",
  46861. true,
  46862. false
  46863. ],
  46864. "RPL-1.5": [
  46865. "Reciprocal Public License 1.5",
  46866. true,
  46867. false
  46868. ],
  46869. "RPSL-1.0": [
  46870. "RealNetworks Public Source License v1.0",
  46871. true,
  46872. false
  46873. ],
  46874. "RSA-MD": [
  46875. "RSA Message-Digest License",
  46876. false,
  46877. false
  46878. ],
  46879. "RSCPL": [
  46880. "Ricoh Source Code Public License",
  46881. true,
  46882. false
  46883. ],
  46884. "Ruby": [
  46885. "Ruby License",
  46886. false,
  46887. false
  46888. ],
  46889. "SAX-PD": [
  46890. "Sax Public Domain Notice",
  46891. false,
  46892. false
  46893. ],
  46894. "Saxpath": [
  46895. "Saxpath License",
  46896. false,
  46897. false
  46898. ],
  46899. "SCEA": [
  46900. "SCEA Shared Source License",
  46901. false,
  46902. false
  46903. ],
  46904. "Sendmail": [
  46905. "Sendmail License",
  46906. false,
  46907. false
  46908. ],
  46909. "Sendmail-8.23": [
  46910. "Sendmail License 8.23",
  46911. false,
  46912. false
  46913. ],
  46914. "SGI-B-1.0": [
  46915. "SGI Free Software License B v1.0",
  46916. false,
  46917. false
  46918. ],
  46919. "SGI-B-1.1": [
  46920. "SGI Free Software License B v1.1",
  46921. false,
  46922. false
  46923. ],
  46924. "SGI-B-2.0": [
  46925. "SGI Free Software License B v2.0",
  46926. false,
  46927. false
  46928. ],
  46929. "SHL-0.5": [
  46930. "Solderpad Hardware License v0.5",
  46931. false,
  46932. false
  46933. ],
  46934. "SHL-0.51": [
  46935. "Solderpad Hardware License, Version 0.51",
  46936. false,
  46937. false
  46938. ],
  46939. "SimPL-2.0": [
  46940. "Simple Public License 2.0",
  46941. true,
  46942. false
  46943. ],
  46944. "SISSL": [
  46945. "Sun Industry Standards Source License v1.1",
  46946. true,
  46947. false
  46948. ],
  46949. "SISSL-1.2": [
  46950. "Sun Industry Standards Source License v1.2",
  46951. false,
  46952. false
  46953. ],
  46954. "Sleepycat": [
  46955. "Sleepycat License",
  46956. true,
  46957. false
  46958. ],
  46959. "SMLNJ": [
  46960. "Standard ML of New Jersey License",
  46961. false,
  46962. false
  46963. ],
  46964. "SMPPL": [
  46965. "Secure Messaging Protocol Public License",
  46966. false,
  46967. false
  46968. ],
  46969. "SNIA": [
  46970. "SNIA Public License 1.1",
  46971. false,
  46972. false
  46973. ],
  46974. "Spencer-86": [
  46975. "Spencer License 86",
  46976. false,
  46977. false
  46978. ],
  46979. "Spencer-94": [
  46980. "Spencer License 94",
  46981. false,
  46982. false
  46983. ],
  46984. "Spencer-99": [
  46985. "Spencer License 99",
  46986. false,
  46987. false
  46988. ],
  46989. "SPL-1.0": [
  46990. "Sun Public License v1.0",
  46991. true,
  46992. false
  46993. ],
  46994. "SSH-OpenSSH": [
  46995. "SSH OpenSSH license",
  46996. false,
  46997. false
  46998. ],
  46999. "SSH-short": [
  47000. "SSH short notice",
  47001. false,
  47002. false
  47003. ],
  47004. "SSPL-1.0": [
  47005. "Server Side Public License, v 1",
  47006. false,
  47007. false
  47008. ],
  47009. "StandardML-NJ": [
  47010. "Standard ML of New Jersey License",
  47011. false,
  47012. true
  47013. ],
  47014. "SugarCRM-1.1.3": [
  47015. "SugarCRM Public License v1.1.3",
  47016. false,
  47017. false
  47018. ],
  47019. "SWL": [
  47020. "Scheme Widget Library (SWL) Software License Agreement",
  47021. false,
  47022. false
  47023. ],
  47024. "TAPR-OHL-1.0": [
  47025. "TAPR Open Hardware License v1.0",
  47026. false,
  47027. false
  47028. ],
  47029. "TCL": [
  47030. "TCL/TK License",
  47031. false,
  47032. false
  47033. ],
  47034. "TCP-wrappers": [
  47035. "TCP Wrappers License",
  47036. false,
  47037. false
  47038. ],
  47039. "TMate": [
  47040. "TMate Open Source License",
  47041. false,
  47042. false
  47043. ],
  47044. "TORQUE-1.1": [
  47045. "TORQUE v2.5+ Software License v1.1",
  47046. false,
  47047. false
  47048. ],
  47049. "TOSL": [
  47050. "Trusster Open Source License",
  47051. false,
  47052. false
  47053. ],
  47054. "TU-Berlin-1.0": [
  47055. "Technische Universitaet Berlin License 1.0",
  47056. false,
  47057. false
  47058. ],
  47059. "TU-Berlin-2.0": [
  47060. "Technische Universitaet Berlin License 2.0",
  47061. false,
  47062. false
  47063. ],
  47064. "UCL-1.0": [
  47065. "Upstream Compatibility License v1.0",
  47066. true,
  47067. false
  47068. ],
  47069. "Unicode-DFS-2015": [
  47070. "Unicode License Agreement - Data Files and Software (2015)",
  47071. false,
  47072. false
  47073. ],
  47074. "Unicode-DFS-2016": [
  47075. "Unicode License Agreement - Data Files and Software (2016)",
  47076. true,
  47077. false
  47078. ],
  47079. "Unicode-TOU": [
  47080. "Unicode Terms of Use",
  47081. false,
  47082. false
  47083. ],
  47084. "Unlicense": [
  47085. "The Unlicense",
  47086. true,
  47087. false
  47088. ],
  47089. "UPL-1.0": [
  47090. "Universal Permissive License v1.0",
  47091. true,
  47092. false
  47093. ],
  47094. "Vim": [
  47095. "Vim License",
  47096. false,
  47097. false
  47098. ],
  47099. "VOSTROM": [
  47100. "VOSTROM Public License for Open Source",
  47101. false,
  47102. false
  47103. ],
  47104. "VSL-1.0": [
  47105. "Vovida Software License v1.0",
  47106. true,
  47107. false
  47108. ],
  47109. "W3C": [
  47110. "W3C Software Notice and License (2002-12-31)",
  47111. true,
  47112. false
  47113. ],
  47114. "W3C-19980720": [
  47115. "W3C Software Notice and License (1998-07-20)",
  47116. false,
  47117. false
  47118. ],
  47119. "W3C-20150513": [
  47120. "W3C Software Notice and Document License (2015-05-13)",
  47121. false,
  47122. false
  47123. ],
  47124. "Watcom-1.0": [
  47125. "Sybase Open Watcom Public License 1.0",
  47126. true,
  47127. false
  47128. ],
  47129. "Wsuipa": [
  47130. "Wsuipa License",
  47131. false,
  47132. false
  47133. ],
  47134. "WTFPL": [
  47135. "Do What The F*ck You Want To Public License",
  47136. false,
  47137. false
  47138. ],
  47139. "wxWindows": [
  47140. "wxWindows Library License",
  47141. true,
  47142. true
  47143. ],
  47144. "X11": [
  47145. "X11 License",
  47146. false,
  47147. false
  47148. ],
  47149. "Xerox": [
  47150. "Xerox License",
  47151. false,
  47152. false
  47153. ],
  47154. "XFree86-1.1": [
  47155. "XFree86 License 1.1",
  47156. false,
  47157. false
  47158. ],
  47159. "xinetd": [
  47160. "xinetd License",
  47161. false,
  47162. false
  47163. ],
  47164. "Xnet": [
  47165. "X.Net License",
  47166. true,
  47167. false
  47168. ],
  47169. "xpp": [
  47170. "XPP License",
  47171. false,
  47172. false
  47173. ],
  47174. "XSkat": [
  47175. "XSkat License",
  47176. false,
  47177. false
  47178. ],
  47179. "YPL-1.0": [
  47180. "Yahoo! Public License v1.0",
  47181. false,
  47182. false
  47183. ],
  47184. "YPL-1.1": [
  47185. "Yahoo! Public License v1.1",
  47186. false,
  47187. false
  47188. ],
  47189. "Zed": [
  47190. "Zed License",
  47191. false,
  47192. false
  47193. ],
  47194. "Zend-2.0": [
  47195. "Zend License v2.0",
  47196. false,
  47197. false
  47198. ],
  47199. "Zimbra-1.3": [
  47200. "Zimbra Public License v1.3",
  47201. false,
  47202. false
  47203. ],
  47204. "Zimbra-1.4": [
  47205. "Zimbra Public License v1.4",
  47206. false,
  47207. false
  47208. ],
  47209. "Zlib": [
  47210. "zlib License",
  47211. true,
  47212. false
  47213. ],
  47214. "zlib-acknowledgement": [
  47215. "zlib/libpng License with Acknowledgement",
  47216. false,
  47217. false
  47218. ],
  47219. "ZPL-1.1": [
  47220. "Zope Public License 1.1",
  47221. false,
  47222. false
  47223. ],
  47224. "ZPL-2.0": [
  47225. "Zope Public License 2.0",
  47226. true,
  47227. false
  47228. ],
  47229. "ZPL-2.1": [
  47230. "Zope Public License 2.1",
  47231. true,
  47232. false
  47233. ]
  47234. }<?php
  47235. namespace Composer\Spdx;
  47236. class SpdxLicenses
  47237. {
  47238. const LICENSES_FILE = 'spdx-licenses.json';
  47239. const EXCEPTIONS_FILE = 'spdx-exceptions.json';
  47240. private $licenses;
  47241. private $licensesExpression;
  47242. private $exceptions;
  47243. private $exceptionsExpression;
  47244. public function __construct()
  47245. {
  47246. $this->loadLicenses();
  47247. $this->loadExceptions();
  47248. }
  47249. public function getLicenseByIdentifier($identifier)
  47250. {
  47251. $key = strtolower($identifier);
  47252. if (!isset($this->licenses[$key])) {
  47253. return null;
  47254. }
  47255. list($identifier, $name, $isOsiApproved, $isDeprecatedLicenseId) = $this->licenses[$key];
  47256. return array(
  47257. $name,
  47258. $isOsiApproved,
  47259. 'https://spdx.org/licenses/' . $identifier . '.html#licenseText',
  47260. $isDeprecatedLicenseId,
  47261. );
  47262. }
  47263. public function getLicenses()
  47264. {
  47265. return $this->licenses;
  47266. }
  47267. public function getExceptionByIdentifier($identifier)
  47268. {
  47269. $key = strtolower($identifier);
  47270. if (!isset($this->exceptions[$key])) {
  47271. return null;
  47272. }
  47273. list($identifier, $name) = $this->exceptions[$key];
  47274. return array(
  47275. $name,
  47276. 'https://spdx.org/licenses/' . $identifier . '.html#licenseExceptionText',
  47277. );
  47278. }
  47279. public function getIdentifierByName($name)
  47280. {
  47281. foreach ($this->licenses as $licenseData) {
  47282. if ($licenseData[1] === $name) {
  47283. return $licenseData[0];
  47284. }
  47285. }
  47286. foreach ($this->exceptions as $licenseData) {
  47287. if ($licenseData[1] === $name) {
  47288. return $licenseData[0];
  47289. }
  47290. }
  47291. return null;
  47292. }
  47293. public function isOsiApprovedByIdentifier($identifier)
  47294. {
  47295. return $this->licenses[strtolower($identifier)][2];
  47296. }
  47297. public function isDeprecatedByIdentifier($identifier)
  47298. {
  47299. return $this->licenses[strtolower($identifier)][3];
  47300. }
  47301. public function validate($license)
  47302. {
  47303. if (is_array($license)) {
  47304. $count = count($license);
  47305. if ($count !== count(array_filter($license, 'is_string'))) {
  47306. throw new \InvalidArgumentException('Array of strings expected.');
  47307. }
  47308. $license = $count > 1 ? '(' . implode(' OR ', $license) . ')' : (string) reset($license);
  47309. }
  47310. if (!is_string($license)) {
  47311. throw new \InvalidArgumentException(sprintf(
  47312. 'Array or String expected, %s given.',
  47313. gettype($license)
  47314. ));
  47315. }
  47316. return $this->isValidLicenseString($license);
  47317. }
  47318. public static function getResourcesDir()
  47319. {
  47320. return dirname(__DIR__) . '/res';
  47321. }
  47322. private function loadLicenses()
  47323. {
  47324. if (null !== $this->licenses) {
  47325. return;
  47326. }
  47327. $json = file_get_contents(self::getResourcesDir() . '/' . self::LICENSES_FILE);
  47328. if (false === $json) {
  47329. throw new \RuntimeException('Missing license file in ' . self::getResourcesDir() . '/' . self::LICENSES_FILE);
  47330. }
  47331. $this->licenses = array();
  47332. foreach (json_decode($json, true) as $identifier => $license) {
  47333. $this->licenses[strtolower($identifier)] = array($identifier, $license[0], $license[1], $license[2]);
  47334. }
  47335. }
  47336. private function loadExceptions()
  47337. {
  47338. if (null !== $this->exceptions) {
  47339. return;
  47340. }
  47341. $json = file_get_contents(self::getResourcesDir() . '/' . self::EXCEPTIONS_FILE);
  47342. if (false === $json) {
  47343. throw new \RuntimeException('Missing exceptions file in ' . self::getResourcesDir() . '/' . self::EXCEPTIONS_FILE);
  47344. }
  47345. $this->exceptions = array();
  47346. foreach (json_decode($json, true) as $identifier => $exception) {
  47347. $this->exceptions[strtolower($identifier)] = array($identifier, $exception[0]);
  47348. }
  47349. }
  47350. private function getLicensesExpression()
  47351. {
  47352. if (null === $this->licensesExpression) {
  47353. $licenses = array_map('preg_quote', array_keys($this->licenses));
  47354. rsort($licenses);
  47355. $licenses = implode('|', $licenses);
  47356. $this->licensesExpression = $licenses;
  47357. }
  47358. return $this->licensesExpression;
  47359. }
  47360. private function getExceptionsExpression()
  47361. {
  47362. if (null === $this->exceptionsExpression) {
  47363. $exceptions = array_map('preg_quote', array_keys($this->exceptions));
  47364. rsort($exceptions);
  47365. $exceptions = implode('|', $exceptions);
  47366. $this->exceptionsExpression = $exceptions;
  47367. }
  47368. return $this->exceptionsExpression;
  47369. }
  47370. private function isValidLicenseString($license)
  47371. {
  47372. if (isset($this->licenses[strtolower($license)])) {
  47373. return true;
  47374. }
  47375. $licenses = $this->getLicensesExpression();
  47376. $exceptions = $this->getExceptionsExpression();
  47377. $regex = <<<REGEX
  47378. {
  47379. (?(DEFINE)
  47380. # idstring: 1*( ALPHA / DIGIT / - / . )
  47381. (?<idstring>[\pL\pN.-]{1,})
  47382. # license-id: taken from list
  47383. (?<licenseid>${licenses})
  47384. # license-exception-id: taken from list
  47385. (?<licenseexceptionid>${exceptions})
  47386. # license-ref: [DocumentRef-1*(idstring):]LicenseRef-1*(idstring)
  47387. (?<licenseref>(?:DocumentRef-(?&idstring):)?LicenseRef-(?&idstring))
  47388. # simple-expresssion: license-id / license-id+ / license-ref
  47389. (?<simple_expression>(?&licenseid)\+? | (?&licenseid) | (?&licenseref))
  47390. # compound-expression: 1*(
  47391. # simple-expression /
  47392. # simple-expression WITH license-exception-id /
  47393. # compound-expression AND compound-expression /
  47394. # compound-expression OR compound-expression
  47395. # ) / ( compound-expression ) )
  47396. (?<compound_head>
  47397. (?&simple_expression) ( \s+ WITH \s+ (?&licenseexceptionid))?
  47398. | \( \s* (?&compound_expression) \s* \)
  47399. )
  47400. (?<compound_expression>
  47401. (?&compound_head) (?: \s+ (?:AND|OR) \s+ (?&compound_expression))?
  47402. )
  47403. # license-expression: 1*1(simple-expression / compound-expression)
  47404. (?<license_expression>(?&compound_expression) | (?&simple_expression))
  47405. ) # end of define
  47406. ^(NONE | NOASSERTION | (?&license_expression))$
  47407. }xi
  47408. REGEX;
  47409. $match = preg_match($regex, $license);
  47410. if (0 === $match) {
  47411. return false;
  47412. }
  47413. if (false === $match) {
  47414. throw new \RuntimeException('Regex failed to compile/run.');
  47415. }
  47416. return true;
  47417. }
  47418. }
  47419. MIT License
  47420. Copyright (c) 2017 Composer
  47421. Permission is hereby granted, free of charge, to any person obtaining a copy
  47422. of this software and associated documentation files (the "Software"), to deal
  47423. in the Software without restriction, including without limitation the rights
  47424. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  47425. copies of the Software, and to permit persons to whom the Software is
  47426. furnished to do so, subject to the following conditions:
  47427. The above copyright notice and this permission notice shall be included in all
  47428. copies or substantial portions of the Software.
  47429. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  47430. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  47431. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  47432. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  47433. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  47434. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  47435. SOFTWARE.
  47436. <?php
  47437. declare(strict_types=1);
  47438. namespace Composer\XdebugHandler;
  47439. class PhpConfig
  47440. {
  47441. public function useOriginal(): array
  47442. {
  47443. $this->getDataAndReset();
  47444. return [];
  47445. }
  47446. public function useStandard(): array
  47447. {
  47448. $data = $this->getDataAndReset();
  47449. if ($data !== null) {
  47450. return ['-n', '-c', $data['tmpIni']];
  47451. }
  47452. return [];
  47453. }
  47454. public function usePersistent(): array
  47455. {
  47456. $data = $this->getDataAndReset();
  47457. if ($data !== null) {
  47458. $this->updateEnv('PHPRC', $data['tmpIni']);
  47459. $this->updateEnv('PHP_INI_SCAN_DIR', '');
  47460. }
  47461. return [];
  47462. }
  47463. private function getDataAndReset(): ?array
  47464. {
  47465. $data = XdebugHandler::getRestartSettings();
  47466. if ($data !== null) {
  47467. $this->updateEnv('PHPRC', $data['phprc']);
  47468. $this->updateEnv('PHP_INI_SCAN_DIR', $data['scanDir']);
  47469. }
  47470. return $data;
  47471. }
  47472. private function updateEnv(string $name, $value): void
  47473. {
  47474. Process::setEnv($name, false !== $value ? $value : null);
  47475. }
  47476. }
  47477. <?php
  47478. declare(strict_types=1);
  47479. namespace Composer\XdebugHandler;
  47480. use Composer\Pcre\Preg;
  47481. class Process
  47482. {
  47483. public static function escape(string $arg, bool $meta = true, bool $module = false): string
  47484. {
  47485. if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
  47486. return "'".str_replace("'", "'\\''", $arg)."'";
  47487. }
  47488. $quote = strpbrk($arg, " \t") !== false || $arg === '';
  47489. $arg = Preg::replace('/(\\\\*)"/', '$1$1\\"', $arg, -1, $dquotes);
  47490. if ($meta) {
  47491. $meta = $dquotes || Preg::isMatch('/%[^%]+%/', $arg);
  47492. if (!$meta) {
  47493. $quote = $quote || strpbrk($arg, '^&|<>()') !== false;
  47494. } elseif ($module && !$dquotes && $quote) {
  47495. $meta = false;
  47496. }
  47497. }
  47498. if ($quote) {
  47499. $arg = '"'.(Preg::replace('/(\\\\*)$/', '$1$1', $arg)).'"';
  47500. }
  47501. if ($meta) {
  47502. $arg = Preg::replace('/(["^&|<>()%])/', '^$1', $arg);
  47503. }
  47504. return $arg;
  47505. }
  47506. public static function escapeShellCommand(array $args): string
  47507. {
  47508. $command = '';
  47509. $module = array_shift($args);
  47510. if ($module !== null) {
  47511. $command = self::escape($module, true, true);
  47512. foreach ($args as $arg) {
  47513. $command .= ' '.self::escape($arg);
  47514. }
  47515. }
  47516. return $command;
  47517. }
  47518. public static function setEnv(string $name, ?string $value = null): bool
  47519. {
  47520. $unset = null === $value;
  47521. if (!putenv($unset ? $name : $name.'='.$value)) {
  47522. return false;
  47523. }
  47524. if ($unset) {
  47525. unset($_SERVER[$name]);
  47526. } else {
  47527. $_SERVER[$name] = $value;
  47528. }
  47529. if (false !== stripos((string) ini_get('variables_order'), 'E')) {
  47530. if ($unset) {
  47531. unset($_ENV[$name]);
  47532. } else {
  47533. $_ENV[$name] = $value;
  47534. }
  47535. }
  47536. return true;
  47537. }
  47538. }
  47539. <?php
  47540. declare(strict_types=1);
  47541. namespace Composer\XdebugHandler;
  47542. use Psr\Log\LoggerInterface;
  47543. use Psr\Log\LogLevel;
  47544. class Status
  47545. {
  47546. const ENV_RESTART = 'XDEBUG_HANDLER_RESTART';
  47547. const CHECK = 'Check';
  47548. const ERROR = 'Error';
  47549. const INFO = 'Info';
  47550. const NORESTART = 'NoRestart';
  47551. const RESTART = 'Restart';
  47552. const RESTARTING = 'Restarting';
  47553. const RESTARTED = 'Restarted';
  47554. private $debug;
  47555. private $envAllowXdebug;
  47556. private $loaded;
  47557. private $logger;
  47558. private $modeOff;
  47559. private $time;
  47560. public function __construct(string $envAllowXdebug, bool $debug)
  47561. {
  47562. $start = getenv(self::ENV_RESTART);
  47563. Process::setEnv(self::ENV_RESTART);
  47564. $this->time = is_numeric($start) ? round((microtime(true) - $start) * 1000) : 0;
  47565. $this->envAllowXdebug = $envAllowXdebug;
  47566. $this->debug = $debug && defined('STDERR');
  47567. $this->modeOff = false;
  47568. }
  47569. public function setLogger(LoggerInterface $logger): void
  47570. {
  47571. $this->logger = $logger;
  47572. }
  47573. public function report(string $op, ?string $data): void
  47574. {
  47575. if ($this->logger !== null || $this->debug) {
  47576. $callable = [$this, 'report'.$op];
  47577. if (!is_callable($callable)) {
  47578. throw new \InvalidArgumentException('Unknown op handler: '.$op);
  47579. }
  47580. $params = $data !== null ? [$data] : [];
  47581. call_user_func_array($callable, $params);
  47582. }
  47583. }
  47584. private function output(string $text, ?string $level = null): void
  47585. {
  47586. if ($this->logger !== null) {
  47587. $this->logger->log($level !== null ? $level: LogLevel::DEBUG, $text);
  47588. }
  47589. if ($this->debug) {
  47590. fwrite(STDERR, sprintf('xdebug-handler[%d] %s', getmypid(), $text.PHP_EOL));
  47591. }
  47592. }
  47593. private function reportCheck(string $loaded): void
  47594. {
  47595. list($version, $mode) = explode('|', $loaded);
  47596. if ($version !== '') {
  47597. $this->loaded = '('.$version.')'.($mode !== '' ? ' xdebug.mode='.$mode : '');
  47598. }
  47599. $this->modeOff = $mode === 'off';
  47600. $this->output('Checking '.$this->envAllowXdebug);
  47601. }
  47602. private function reportError(string $error): void
  47603. {
  47604. $this->output(sprintf('No restart (%s)', $error), LogLevel::WARNING);
  47605. }
  47606. private function reportInfo(string $info): void
  47607. {
  47608. $this->output($info);
  47609. }
  47610. private function reportNoRestart(): void
  47611. {
  47612. $this->output($this->getLoadedMessage());
  47613. if ($this->loaded !== null) {
  47614. $text = sprintf('No restart (%s)', $this->getEnvAllow());
  47615. if (!((bool) getenv($this->envAllowXdebug))) {
  47616. $text .= ' Allowed by '.($this->modeOff ? 'xdebug.mode' : 'application');
  47617. }
  47618. $this->output($text);
  47619. }
  47620. }
  47621. private function reportRestart(): void
  47622. {
  47623. $this->output($this->getLoadedMessage());
  47624. Process::setEnv(self::ENV_RESTART, (string) microtime(true));
  47625. }
  47626. private function reportRestarted(): void
  47627. {
  47628. $loaded = $this->getLoadedMessage();
  47629. $text = sprintf('Restarted (%d ms). %s', $this->time, $loaded);
  47630. $level = $this->loaded !== null ? LogLevel::WARNING : null;
  47631. $this->output($text, $level);
  47632. }
  47633. private function reportRestarting(string $command): void
  47634. {
  47635. $text = sprintf('Process restarting (%s)', $this->getEnvAllow());
  47636. $this->output($text);
  47637. $text = 'Running '.$command;
  47638. $this->output($text);
  47639. }
  47640. private function getEnvAllow(): string
  47641. {
  47642. return $this->envAllowXdebug.'='.getenv($this->envAllowXdebug);
  47643. }
  47644. private function getLoadedMessage(): string
  47645. {
  47646. $loaded = $this->loaded !== null ? sprintf('loaded %s', $this->loaded) : 'not loaded';
  47647. return 'The Xdebug extension is '.$loaded;
  47648. }
  47649. }
  47650. <?php
  47651. declare(strict_types=1);
  47652. namespace Composer\XdebugHandler;
  47653. use Composer\Pcre\Preg;
  47654. use Psr\Log\LoggerInterface;
  47655. class XdebugHandler
  47656. {
  47657. const SUFFIX_ALLOW = '_ALLOW_XDEBUG';
  47658. const SUFFIX_INIS = '_ORIGINAL_INIS';
  47659. const RESTART_ID = 'internal';
  47660. const RESTART_SETTINGS = 'XDEBUG_HANDLER_SETTINGS';
  47661. const DEBUG = 'XDEBUG_HANDLER_DEBUG';
  47662. protected $tmpIni;
  47663. private static $inRestart;
  47664. private static $name;
  47665. private static $skipped;
  47666. private static $xdebugActive;
  47667. private static $xdebugMode;
  47668. private static $xdebugVersion;
  47669. private $cli;
  47670. private $debug;
  47671. private $envAllowXdebug;
  47672. private $envOriginalInis;
  47673. private $persistent;
  47674. private $script;
  47675. private $statusWriter;
  47676. public function __construct(string $envPrefix)
  47677. {
  47678. if ($envPrefix === '') {
  47679. throw new \RuntimeException('Invalid constructor parameter');
  47680. }
  47681. self::$name = strtoupper($envPrefix);
  47682. $this->envAllowXdebug = self::$name.self::SUFFIX_ALLOW;
  47683. $this->envOriginalInis = self::$name.self::SUFFIX_INIS;
  47684. self::setXdebugDetails();
  47685. self::$inRestart = false;
  47686. if ($this->cli = PHP_SAPI === 'cli') {
  47687. $this->debug = (string) getenv(self::DEBUG);
  47688. }
  47689. $this->statusWriter = new Status($this->envAllowXdebug, (bool) $this->debug);
  47690. }
  47691. public function setLogger(LoggerInterface $logger): self
  47692. {
  47693. $this->statusWriter->setLogger($logger);
  47694. return $this;
  47695. }
  47696. public function setMainScript(string $script): self
  47697. {
  47698. $this->script = $script;
  47699. return $this;
  47700. }
  47701. public function setPersistent(): self
  47702. {
  47703. $this->persistent = true;
  47704. return $this;
  47705. }
  47706. public function check(): void
  47707. {
  47708. $this->notify(Status::CHECK, self::$xdebugVersion.'|'.self::$xdebugMode);
  47709. $envArgs = explode('|', (string) getenv($this->envAllowXdebug));
  47710. if (!((bool) $envArgs[0]) && $this->requiresRestart(self::$xdebugActive)) {
  47711. $this->notify(Status::RESTART);
  47712. if ($this->prepareRestart()) {
  47713. $command = $this->getCommand();
  47714. $this->restart($command);
  47715. }
  47716. return;
  47717. }
  47718. if (self::RESTART_ID === $envArgs[0] && count($envArgs) === 5) {
  47719. $this->notify(Status::RESTARTED);
  47720. Process::setEnv($this->envAllowXdebug);
  47721. self::$inRestart = true;
  47722. if (self::$xdebugVersion === null) {
  47723. self::$skipped = $envArgs[1];
  47724. }
  47725. $this->tryEnableSignals();
  47726. $this->setEnvRestartSettings($envArgs);
  47727. return;
  47728. }
  47729. $this->notify(Status::NORESTART);
  47730. $settings = self::getRestartSettings();
  47731. if ($settings !== null) {
  47732. $this->syncSettings($settings);
  47733. }
  47734. }
  47735. public static function getAllIniFiles(): array
  47736. {
  47737. if (self::$name !== null) {
  47738. $env = getenv(self::$name.self::SUFFIX_INIS);
  47739. if (false !== $env) {
  47740. return explode(PATH_SEPARATOR, $env);
  47741. }
  47742. }
  47743. $paths = [(string) php_ini_loaded_file()];
  47744. $scanned = php_ini_scanned_files();
  47745. if ($scanned !== false) {
  47746. $paths = array_merge($paths, array_map('trim', explode(',', $scanned)));
  47747. }
  47748. return $paths;
  47749. }
  47750. public static function getRestartSettings(): ?array
  47751. {
  47752. $envArgs = explode('|', (string) getenv(self::RESTART_SETTINGS));
  47753. if (count($envArgs) !== 6
  47754. || (!self::$inRestart && php_ini_loaded_file() !== $envArgs[0])) {
  47755. return null;
  47756. }
  47757. return [
  47758. 'tmpIni' => $envArgs[0],
  47759. 'scannedInis' => (bool) $envArgs[1],
  47760. 'scanDir' => '*' === $envArgs[2] ? false : $envArgs[2],
  47761. 'phprc' => '*' === $envArgs[3] ? false : $envArgs[3],
  47762. 'inis' => explode(PATH_SEPARATOR, $envArgs[4]),
  47763. 'skipped' => $envArgs[5],
  47764. ];
  47765. }
  47766. public static function getSkippedVersion(): string
  47767. {
  47768. return (string) self::$skipped;
  47769. }
  47770. public static function isXdebugActive(): bool
  47771. {
  47772. self::setXdebugDetails();
  47773. return self::$xdebugActive;
  47774. }
  47775. protected function requiresRestart(bool $default): bool
  47776. {
  47777. return $default;
  47778. }
  47779. protected function restart(array $command): void
  47780. {
  47781. $this->doRestart($command);
  47782. }
  47783. private function doRestart(array $command): void
  47784. {
  47785. $this->tryEnableSignals();
  47786. $this->notify(Status::RESTARTING, implode(' ', $command));
  47787. if (PHP_VERSION_ID >= 70400) {
  47788. $cmd = $command;
  47789. } else {
  47790. $cmd = Process::escapeShellCommand($command);
  47791. if (defined('PHP_WINDOWS_VERSION_BUILD')) {
  47792. $cmd = '"'.$cmd.'"';
  47793. }
  47794. }
  47795. $process = proc_open($cmd, [], $pipes);
  47796. if (is_resource($process)) {
  47797. $exitCode = proc_close($process);
  47798. }
  47799. if (!isset($exitCode)) {
  47800. $this->notify(Status::ERROR, 'Unable to restart process');
  47801. $exitCode = -1;
  47802. } else {
  47803. $this->notify(Status::INFO, 'Restarted process exited '.$exitCode);
  47804. }
  47805. if ($this->debug === '2') {
  47806. $this->notify(Status::INFO, 'Temp ini saved: '.$this->tmpIni);
  47807. } else {
  47808. @unlink((string) $this->tmpIni);
  47809. }
  47810. exit($exitCode);
  47811. }
  47812. private function prepareRestart(): bool
  47813. {
  47814. $error = null;
  47815. $iniFiles = self::getAllIniFiles();
  47816. $scannedInis = count($iniFiles) > 1;
  47817. $tmpDir = sys_get_temp_dir();
  47818. if (!$this->cli) {
  47819. $error = 'Unsupported SAPI: '.PHP_SAPI;
  47820. } elseif (!$this->checkConfiguration($info)) {
  47821. $error = $info;
  47822. } elseif (!$this->checkMainScript()) {
  47823. $error = 'Unable to access main script: '.$this->script;
  47824. } elseif (!$this->writeTmpIni($iniFiles, $tmpDir, $error)) {
  47825. $error = $error !== null ? $error : 'Unable to create temp ini file at: '.$tmpDir;
  47826. } elseif (!$this->setEnvironment($scannedInis, $iniFiles)) {
  47827. $error = 'Unable to set environment variables';
  47828. }
  47829. if ($error !== null) {
  47830. $this->notify(Status::ERROR, $error);
  47831. }
  47832. return $error === null;
  47833. }
  47834. private function writeTmpIni(array $iniFiles, string $tmpDir, ?string &$error): bool
  47835. {
  47836. if (($tmpfile = @tempnam($tmpDir, '')) === false) {
  47837. return false;
  47838. }
  47839. $this->tmpIni = $tmpfile;
  47840. if ($iniFiles[0] === '') {
  47841. array_shift($iniFiles);
  47842. }
  47843. $content = '';
  47844. $sectionRegex = '/^\s*\[(?:PATH|HOST)\s*=/mi';
  47845. $xdebugRegex = '/^\s*(zend_extension\s*=.*xdebug.*)$/mi';
  47846. foreach ($iniFiles as $file) {
  47847. if (($data = @file_get_contents($file)) === false) {
  47848. $error = 'Unable to read ini: '.$file;
  47849. return false;
  47850. }
  47851. if (Preg::isMatchWithOffsets($sectionRegex, $data, $matches, PREG_OFFSET_CAPTURE)) {
  47852. $data = substr($data, 0, $matches[0][1]);
  47853. }
  47854. $content .= Preg::replace($xdebugRegex, ';$1', $data).PHP_EOL;
  47855. }
  47856. $config = parse_ini_string($content);
  47857. $loaded = ini_get_all(null, false);
  47858. if (false === $config || false === $loaded) {
  47859. $error = 'Unable to parse ini data';
  47860. return false;
  47861. }
  47862. $content .= $this->mergeLoadedConfig($loaded, $config);
  47863. $content .= 'opcache.enable_cli=0'.PHP_EOL;
  47864. return (bool) @file_put_contents($this->tmpIni, $content);
  47865. }
  47866. private function getCommand(): array
  47867. {
  47868. $php = [PHP_BINARY];
  47869. $args = array_slice($_SERVER['argv'], 1);
  47870. if (!$this->persistent) {
  47871. array_push($php, '-n', '-c', $this->tmpIni);
  47872. }
  47873. return array_merge($php, [$this->script], $args);
  47874. }
  47875. private function setEnvironment(bool $scannedInis, array $iniFiles): bool
  47876. {
  47877. $scanDir = getenv('PHP_INI_SCAN_DIR');
  47878. $phprc = getenv('PHPRC');
  47879. if (!putenv($this->envOriginalInis.'='.implode(PATH_SEPARATOR, $iniFiles))) {
  47880. return false;
  47881. }
  47882. if ($this->persistent) {
  47883. if (!putenv('PHP_INI_SCAN_DIR=') || !putenv('PHPRC='.$this->tmpIni)) {
  47884. return false;
  47885. }
  47886. }
  47887. $envArgs = [
  47888. self::RESTART_ID,
  47889. self::$xdebugVersion,
  47890. (int) $scannedInis,
  47891. false === $scanDir ? '*' : $scanDir,
  47892. false === $phprc ? '*' : $phprc,
  47893. ];
  47894. return putenv($this->envAllowXdebug.'='.implode('|', $envArgs));
  47895. }
  47896. private function notify(string $op, ?string $data = null): void
  47897. {
  47898. $this->statusWriter->report($op, $data);
  47899. }
  47900. private function mergeLoadedConfig(array $loadedConfig, array $iniConfig): string
  47901. {
  47902. $content = '';
  47903. foreach ($loadedConfig as $name => $value) {
  47904. if (!is_string($value)
  47905. || strpos($name, 'xdebug') === 0
  47906. || $name === 'apc.mmap_file_mask') {
  47907. continue;
  47908. }
  47909. if (!isset($iniConfig[$name]) || $iniConfig[$name] !== $value) {
  47910. $content .= $name.'="'.addcslashes($value, '\\"').'"'.PHP_EOL;
  47911. }
  47912. }
  47913. return $content;
  47914. }
  47915. private function checkMainScript(): bool
  47916. {
  47917. if ($this->script !== null) {
  47918. return file_exists($this->script) || '--' === $this->script;
  47919. }
  47920. if (file_exists($this->script = $_SERVER['argv'][0])) {
  47921. return true;
  47922. }
  47923. $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
  47924. $main = end($trace);
  47925. if ($main !== false && isset($main['file'])) {
  47926. return file_exists($this->script = $main['file']);
  47927. }
  47928. return false;
  47929. }
  47930. private function setEnvRestartSettings(array $envArgs): void
  47931. {
  47932. $settings = [
  47933. php_ini_loaded_file(),
  47934. $envArgs[2],
  47935. $envArgs[3],
  47936. $envArgs[4],
  47937. getenv($this->envOriginalInis),
  47938. self::$skipped,
  47939. ];
  47940. Process::setEnv(self::RESTART_SETTINGS, implode('|', $settings));
  47941. }
  47942. private function syncSettings(array $settings): void
  47943. {
  47944. if (false === getenv($this->envOriginalInis)) {
  47945. Process::setEnv($this->envOriginalInis, implode(PATH_SEPARATOR, $settings['inis']));
  47946. }
  47947. self::$skipped = $settings['skipped'];
  47948. $this->notify(Status::INFO, 'Process called with existing restart settings');
  47949. }
  47950. private function checkConfiguration(?string &$info): bool
  47951. {
  47952. if (!function_exists('proc_open')) {
  47953. $info = 'proc_open function is disabled';
  47954. return false;
  47955. }
  47956. if (extension_loaded('uopz') && !((bool) ini_get('uopz.disable'))) {
  47957. if (function_exists('uopz_allow_exit')) {
  47958. @uopz_allow_exit(true);
  47959. } else {
  47960. $info = 'uopz extension is not compatible';
  47961. return false;
  47962. }
  47963. }
  47964. if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 70400) {
  47965. $workingDir = getcwd();
  47966. if ($workingDir === false) {
  47967. $info = 'unable to determine working directory';
  47968. return false;
  47969. }
  47970. if (0 === strpos($workingDir, '\\\\')) {
  47971. $info = 'cmd.exe does not support UNC paths: '.$workingDir;
  47972. return false;
  47973. }
  47974. }
  47975. return true;
  47976. }
  47977. private function tryEnableSignals(): void
  47978. {
  47979. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  47980. pcntl_async_signals(true);
  47981. $message = 'Async signals enabled';
  47982. if (!self::$inRestart) {
  47983. pcntl_signal(SIGINT, SIG_IGN);
  47984. } elseif (is_int(pcntl_signal_get_handler(SIGINT))) {
  47985. pcntl_signal(SIGINT, SIG_DFL);
  47986. }
  47987. }
  47988. if (!self::$inRestart && function_exists('sapi_windows_set_ctrl_handler')) {
  47989. sapi_windows_set_ctrl_handler(function ($evt) {});
  47990. }
  47991. }
  47992. private static function setXdebugDetails(): void
  47993. {
  47994. if (self::$xdebugActive !== null) {
  47995. return;
  47996. }
  47997. self::$xdebugActive = false;
  47998. if (!extension_loaded('xdebug')) {
  47999. return;
  48000. }
  48001. $version = phpversion('xdebug');
  48002. self::$xdebugVersion = $version !== false ? $version : 'unknown';
  48003. if (version_compare(self::$xdebugVersion, '3.1', '>=')) {
  48004. $modes = xdebug_info('mode');
  48005. self::$xdebugMode = count($modes) === 0 ? 'off' : implode(',', $modes);
  48006. self::$xdebugActive = self::$xdebugMode !== 'off';
  48007. return;
  48008. }
  48009. $iniMode = ini_get('xdebug.mode');
  48010. if ($iniMode === false) {
  48011. self::$xdebugActive = true;
  48012. return;
  48013. }
  48014. $envMode = (string) getenv('XDEBUG_MODE');
  48015. if ($envMode !== '') {
  48016. self::$xdebugMode = $envMode;
  48017. } else {
  48018. self::$xdebugMode = $iniMode !== '' ? $iniMode : 'off';
  48019. }
  48020. if (Preg::isMatch('/^,+$/', str_replace(' ', '', self::$xdebugMode))) {
  48021. self::$xdebugMode = 'off';
  48022. }
  48023. self::$xdebugActive = self::$xdebugMode !== 'off';
  48024. }
  48025. }
  48026. MIT License
  48027. Copyright (c) 2016
  48028. Permission is hereby granted, free of charge, to any person obtaining a copy
  48029. of this software and associated documentation files (the "Software"), to deal
  48030. in the Software without restriction, including without limitation the rights
  48031. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  48032. copies of the Software, and to permit persons to whom the Software is
  48033. furnished to do so, subject to the following conditions:
  48034. The above copyright notice and this permission notice shall be included in all
  48035. copies or substantial portions of the Software.
  48036. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  48037. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  48038. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  48039. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  48040. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  48041. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  48042. SOFTWARE.
  48043. <?php
  48044. namespace JsonSchema\Constraints;
  48045. use JsonSchema\Entity\JsonPointer;
  48046. use JsonSchema\Exception\InvalidArgumentException;
  48047. use JsonSchema\Exception\ValidationException;
  48048. use JsonSchema\Validator;
  48049. class BaseConstraint
  48050. {
  48051. protected $errors = array();
  48052. protected $errorMask = Validator::ERROR_NONE;
  48053. protected $factory;
  48054. public function __construct(Factory $factory = null)
  48055. {
  48056. $this->factory = $factory ?: new Factory();
  48057. }
  48058. public function addError(JsonPointer $path = null, $message, $constraint = '', array $more = null)
  48059. {
  48060. $error = array(
  48061. 'property' => $this->convertJsonPointerIntoPropertyPath($path ?: new JsonPointer('')),
  48062. 'pointer' => ltrim(strval($path ?: new JsonPointer('')), '#'),
  48063. 'message' => $message,
  48064. 'constraint' => $constraint,
  48065. 'context' => $this->factory->getErrorContext(),
  48066. );
  48067. if ($this->factory->getConfig(Constraint::CHECK_MODE_EXCEPTIONS)) {
  48068. throw new ValidationException(sprintf('Error validating %s: %s', $error['pointer'], $error['message']));
  48069. }
  48070. if (is_array($more) && count($more) > 0) {
  48071. $error += $more;
  48072. }
  48073. $this->errors[] = $error;
  48074. $this->errorMask |= $error['context'];
  48075. }
  48076. public function addErrors(array $errors)
  48077. {
  48078. if ($errors) {
  48079. $this->errors = array_merge($this->errors, $errors);
  48080. $errorMask = &$this->errorMask;
  48081. array_walk($errors, function ($error) use (&$errorMask) {
  48082. if (isset($error['context'])) {
  48083. $errorMask |= $error['context'];
  48084. }
  48085. });
  48086. }
  48087. }
  48088. public function getErrors($errorContext = Validator::ERROR_ALL)
  48089. {
  48090. if ($errorContext === Validator::ERROR_ALL) {
  48091. return $this->errors;
  48092. }
  48093. return array_filter($this->errors, function ($error) use ($errorContext) {
  48094. if ($errorContext & $error['context']) {
  48095. return true;
  48096. }
  48097. });
  48098. }
  48099. public function numErrors($errorContext = Validator::ERROR_ALL)
  48100. {
  48101. if ($errorContext === Validator::ERROR_ALL) {
  48102. return count($this->errors);
  48103. }
  48104. return count($this->getErrors($errorContext));
  48105. }
  48106. public function isValid()
  48107. {
  48108. return !$this->getErrors();
  48109. }
  48110. public function reset()
  48111. {
  48112. $this->errors = array();
  48113. $this->errorMask = Validator::ERROR_NONE;
  48114. }
  48115. public function getErrorMask()
  48116. {
  48117. return $this->errorMask;
  48118. }
  48119. public static function arrayToObjectRecursive($array)
  48120. {
  48121. $json = json_encode($array);
  48122. if (json_last_error() !== \JSON_ERROR_NONE) {
  48123. $message = 'Unable to encode schema array as JSON';
  48124. if (function_exists('json_last_error_msg')) {
  48125. $message .= ': ' . json_last_error_msg();
  48126. }
  48127. throw new InvalidArgumentException($message);
  48128. }
  48129. return (object) json_decode($json);
  48130. }
  48131. }
  48132. <?php
  48133. namespace JsonSchema\Constraints;
  48134. use JsonSchema\Entity\JsonPointer;
  48135. class CollectionConstraint extends Constraint
  48136. {
  48137. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null)
  48138. {
  48139. if (isset($schema->minItems) && count($value) < $schema->minItems) {
  48140. $this->addError($path, 'There must be a minimum of ' . $schema->minItems . ' items in the array', 'minItems', array('minItems' => $schema->minItems));
  48141. }
  48142. if (isset($schema->maxItems) && count($value) > $schema->maxItems) {
  48143. $this->addError($path, 'There must be a maximum of ' . $schema->maxItems . ' items in the array', 'maxItems', array('maxItems' => $schema->maxItems));
  48144. }
  48145. if (isset($schema->uniqueItems) && $schema->uniqueItems) {
  48146. $unique = $value;
  48147. if (is_array($value) && count($value)) {
  48148. $unique = array_map(function ($e) {
  48149. return var_export($e, true);
  48150. }, $value);
  48151. }
  48152. if (count(array_unique($unique)) != count($value)) {
  48153. $this->addError($path, 'There are no duplicates allowed in the array', 'uniqueItems');
  48154. }
  48155. }
  48156. if (isset($schema->items)) {
  48157. $this->validateItems($value, $schema, $path, $i);
  48158. }
  48159. }
  48160. protected function validateItems(&$value, $schema = null, JsonPointer $path = null, $i = null)
  48161. {
  48162. if (is_object($schema->items)) {
  48163. foreach ($value as $k => &$v) {
  48164. $initErrors = $this->getErrors();
  48165. $this->checkUndefined($v, $schema->items, $path, $k);
  48166. if (count($initErrors) < count($this->getErrors()) && (isset($schema->additionalItems) && $schema->additionalItems !== false)) {
  48167. $secondErrors = $this->getErrors();
  48168. $this->checkUndefined($v, $schema->additionalItems, $path, $k);
  48169. }
  48170. if (isset($secondErrors) && count($secondErrors) < count($this->getErrors())) {
  48171. $this->errors = $secondErrors;
  48172. } elseif (isset($secondErrors) && count($secondErrors) === count($this->getErrors())) {
  48173. $this->errors = $initErrors;
  48174. }
  48175. }
  48176. unset($v);
  48177. } else {
  48178. foreach ($value as $k => &$v) {
  48179. if (array_key_exists($k, $schema->items)) {
  48180. $this->checkUndefined($v, $schema->items[$k], $path, $k);
  48181. } else {
  48182. if (property_exists($schema, 'additionalItems')) {
  48183. if ($schema->additionalItems !== false) {
  48184. $this->checkUndefined($v, $schema->additionalItems, $path, $k);
  48185. } else {
  48186. $this->addError(
  48187. $path, 'The item ' . $i . '[' . $k . '] is not defined and the definition does not allow additional items', 'additionalItems', array('additionalItems' => $schema->additionalItems));
  48188. }
  48189. } else {
  48190. $this->checkUndefined($v, new \stdClass(), $path, $k);
  48191. }
  48192. }
  48193. }
  48194. unset($v);
  48195. if (count($value) > 0) {
  48196. for ($k = count($value); $k < count($schema->items); $k++) {
  48197. $undefinedInstance = $this->factory->createInstanceFor('undefined');
  48198. $this->checkUndefined($undefinedInstance, $schema->items[$k], $path, $k);
  48199. }
  48200. }
  48201. }
  48202. }
  48203. }
  48204. <?php
  48205. namespace JsonSchema\Constraints;
  48206. use JsonSchema\Entity\JsonPointer;
  48207. abstract class Constraint extends BaseConstraint implements ConstraintInterface
  48208. {
  48209. protected $inlineSchemaProperty = '$schema';
  48210. const CHECK_MODE_NONE = 0x00000000;
  48211. const CHECK_MODE_NORMAL = 0x00000001;
  48212. const CHECK_MODE_TYPE_CAST = 0x00000002;
  48213. const CHECK_MODE_COERCE_TYPES = 0x00000004;
  48214. const CHECK_MODE_APPLY_DEFAULTS = 0x00000008;
  48215. const CHECK_MODE_EXCEPTIONS = 0x00000010;
  48216. const CHECK_MODE_DISABLE_FORMAT = 0x00000020;
  48217. const CHECK_MODE_ONLY_REQUIRED_DEFAULTS = 0x00000080;
  48218. const CHECK_MODE_VALIDATE_SCHEMA = 0x00000100;
  48219. protected function incrementPath(JsonPointer $path = null, $i)
  48220. {
  48221. $path = $path ?: new JsonPointer('');
  48222. if ($i === null || $i === '') {
  48223. return $path;
  48224. }
  48225. $path = $path->withPropertyPaths(
  48226. array_merge(
  48227. $path->getPropertyPaths(),
  48228. array($i)
  48229. )
  48230. );
  48231. return $path;
  48232. }
  48233. protected function checkArray(&$value, $schema = null, JsonPointer $path = null, $i = null)
  48234. {
  48235. $validator = $this->factory->createInstanceFor('collection');
  48236. $validator->check($value, $schema, $path, $i);
  48237. $this->addErrors($validator->getErrors());
  48238. }
  48239. protected function checkObject(&$value, $schema = null, JsonPointer $path = null, $properties = null,
  48240. $additionalProperties = null, $patternProperties = null, $appliedDefaults = array())
  48241. {
  48242. $validator = $this->factory->createInstanceFor('object');
  48243. $validator->check($value, $schema, $path, $properties, $additionalProperties, $patternProperties, $appliedDefaults);
  48244. $this->addErrors($validator->getErrors());
  48245. }
  48246. protected function checkType(&$value, $schema = null, JsonPointer $path = null, $i = null)
  48247. {
  48248. $validator = $this->factory->createInstanceFor('type');
  48249. $validator->check($value, $schema, $path, $i);
  48250. $this->addErrors($validator->getErrors());
  48251. }
  48252. protected function checkUndefined(&$value, $schema = null, JsonPointer $path = null, $i = null, $fromDefault = false)
  48253. {
  48254. $validator = $this->factory->createInstanceFor('undefined');
  48255. $validator->check($value, $this->factory->getSchemaStorage()->resolveRefSchema($schema), $path, $i, $fromDefault);
  48256. $this->addErrors($validator->getErrors());
  48257. }
  48258. protected function checkString($value, $schema = null, JsonPointer $path = null, $i = null)
  48259. {
  48260. $validator = $this->factory->createInstanceFor('string');
  48261. $validator->check($value, $schema, $path, $i);
  48262. $this->addErrors($validator->getErrors());
  48263. }
  48264. protected function checkNumber($value, $schema = null, JsonPointer $path = null, $i = null)
  48265. {
  48266. $validator = $this->factory->createInstanceFor('number');
  48267. $validator->check($value, $schema, $path, $i);
  48268. $this->addErrors($validator->getErrors());
  48269. }
  48270. protected function checkEnum($value, $schema = null, JsonPointer $path = null, $i = null)
  48271. {
  48272. $validator = $this->factory->createInstanceFor('enum');
  48273. $validator->check($value, $schema, $path, $i);
  48274. $this->addErrors($validator->getErrors());
  48275. }
  48276. protected function checkFormat($value, $schema = null, JsonPointer $path = null, $i = null)
  48277. {
  48278. $validator = $this->factory->createInstanceFor('format');
  48279. $validator->check($value, $schema, $path, $i);
  48280. $this->addErrors($validator->getErrors());
  48281. }
  48282. protected function getTypeCheck()
  48283. {
  48284. return $this->factory->getTypeCheck();
  48285. }
  48286. protected function convertJsonPointerIntoPropertyPath(JsonPointer $pointer)
  48287. {
  48288. $result = array_map(
  48289. function ($path) {
  48290. return sprintf(is_numeric($path) ? '[%d]' : '.%s', $path);
  48291. },
  48292. $pointer->getPropertyPaths()
  48293. );
  48294. return trim(implode('', $result), '.');
  48295. }
  48296. }
  48297. <?php
  48298. namespace JsonSchema\Constraints;
  48299. use JsonSchema\Entity\JsonPointer;
  48300. interface ConstraintInterface
  48301. {
  48302. public function getErrors();
  48303. public function addErrors(array $errors);
  48304. public function addError(JsonPointer $path = null, $message, $constraint='', array $more = null);
  48305. public function isValid();
  48306. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null);
  48307. }
  48308. <?php
  48309. namespace JsonSchema\Constraints;
  48310. use JsonSchema\Entity\JsonPointer;
  48311. class EnumConstraint extends Constraint
  48312. {
  48313. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  48314. {
  48315. if ($element instanceof UndefinedConstraint && (!isset($schema->required) || !$schema->required)) {
  48316. return;
  48317. }
  48318. $type = gettype($element);
  48319. foreach ($schema->enum as $enum) {
  48320. $enumType = gettype($enum);
  48321. if ($this->factory->getConfig(self::CHECK_MODE_TYPE_CAST) && $type == 'array' && $enumType == 'object') {
  48322. if ((object) $element == $enum) {
  48323. return;
  48324. }
  48325. }
  48326. if ($type === gettype($enum)) {
  48327. if ($type == 'object') {
  48328. if ($element == $enum) {
  48329. return;
  48330. }
  48331. } elseif ($element === $enum) {
  48332. return;
  48333. }
  48334. }
  48335. }
  48336. $this->addError($path, 'Does not have a value in the enumeration ' . json_encode($schema->enum), 'enum', array('enum' => $schema->enum));
  48337. }
  48338. }
  48339. <?php
  48340. namespace JsonSchema\Constraints;
  48341. use JsonSchema\Exception\InvalidArgumentException;
  48342. use JsonSchema\SchemaStorage;
  48343. use JsonSchema\SchemaStorageInterface;
  48344. use JsonSchema\Uri\UriRetriever;
  48345. use JsonSchema\UriRetrieverInterface;
  48346. use JsonSchema\Validator;
  48347. class Factory
  48348. {
  48349. protected $schemaStorage;
  48350. protected $uriRetriever;
  48351. private $checkMode = Constraint::CHECK_MODE_NORMAL;
  48352. private $typeCheck = array();
  48353. protected $errorContext = Validator::ERROR_DOCUMENT_VALIDATION;
  48354. protected $constraintMap = array(
  48355. 'array' => 'JsonSchema\Constraints\CollectionConstraint',
  48356. 'collection' => 'JsonSchema\Constraints\CollectionConstraint',
  48357. 'object' => 'JsonSchema\Constraints\ObjectConstraint',
  48358. 'type' => 'JsonSchema\Constraints\TypeConstraint',
  48359. 'undefined' => 'JsonSchema\Constraints\UndefinedConstraint',
  48360. 'string' => 'JsonSchema\Constraints\StringConstraint',
  48361. 'number' => 'JsonSchema\Constraints\NumberConstraint',
  48362. 'enum' => 'JsonSchema\Constraints\EnumConstraint',
  48363. 'format' => 'JsonSchema\Constraints\FormatConstraint',
  48364. 'schema' => 'JsonSchema\Constraints\SchemaConstraint',
  48365. 'validator' => 'JsonSchema\Validator'
  48366. );
  48367. private $instanceCache = array();
  48368. public function __construct(
  48369. SchemaStorageInterface $schemaStorage = null,
  48370. UriRetrieverInterface $uriRetriever = null,
  48371. $checkMode = Constraint::CHECK_MODE_NORMAL
  48372. ) {
  48373. $this->setConfig($checkMode);
  48374. $this->uriRetriever = $uriRetriever ?: new UriRetriever();
  48375. $this->schemaStorage = $schemaStorage ?: new SchemaStorage($this->uriRetriever);
  48376. }
  48377. public function setConfig($checkMode = Constraint::CHECK_MODE_NORMAL)
  48378. {
  48379. $this->checkMode = $checkMode;
  48380. }
  48381. public function addConfig($options)
  48382. {
  48383. $this->checkMode |= $options;
  48384. }
  48385. public function removeConfig($options)
  48386. {
  48387. $this->checkMode &= ~$options;
  48388. }
  48389. public function getConfig($options = null)
  48390. {
  48391. if ($options === null) {
  48392. return $this->checkMode;
  48393. }
  48394. return $this->checkMode & $options;
  48395. }
  48396. public function getUriRetriever()
  48397. {
  48398. return $this->uriRetriever;
  48399. }
  48400. public function getSchemaStorage()
  48401. {
  48402. return $this->schemaStorage;
  48403. }
  48404. public function getTypeCheck()
  48405. {
  48406. if (!isset($this->typeCheck[$this->checkMode])) {
  48407. $this->typeCheck[$this->checkMode] = ($this->checkMode & Constraint::CHECK_MODE_TYPE_CAST)
  48408. ? new TypeCheck\LooseTypeCheck()
  48409. : new TypeCheck\StrictTypeCheck();
  48410. }
  48411. return $this->typeCheck[$this->checkMode];
  48412. }
  48413. public function setConstraintClass($name, $class)
  48414. {
  48415. if (!class_exists($class)) {
  48416. throw new InvalidArgumentException('Unknown constraint ' . $name);
  48417. }
  48418. if (!in_array('JsonSchema\Constraints\ConstraintInterface', class_implements($class))) {
  48419. throw new InvalidArgumentException('Invalid class ' . $name);
  48420. }
  48421. $this->constraintMap[$name] = $class;
  48422. return $this;
  48423. }
  48424. public function createInstanceFor($constraintName)
  48425. {
  48426. if (!isset($this->constraintMap[$constraintName])) {
  48427. throw new InvalidArgumentException('Unknown constraint ' . $constraintName);
  48428. }
  48429. if (!isset($this->instanceCache[$constraintName])) {
  48430. $this->instanceCache[$constraintName] = new $this->constraintMap[$constraintName]($this);
  48431. }
  48432. return clone $this->instanceCache[$constraintName];
  48433. }
  48434. public function getErrorContext()
  48435. {
  48436. return $this->errorContext;
  48437. }
  48438. public function setErrorContext($errorContext)
  48439. {
  48440. $this->errorContext = $errorContext;
  48441. }
  48442. }
  48443. <?php
  48444. namespace JsonSchema\Constraints;
  48445. use JsonSchema\Entity\JsonPointer;
  48446. use JsonSchema\Rfc3339;
  48447. class FormatConstraint extends Constraint
  48448. {
  48449. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  48450. {
  48451. if (!isset($schema->format) || $this->factory->getConfig(self::CHECK_MODE_DISABLE_FORMAT)) {
  48452. return;
  48453. }
  48454. switch ($schema->format) {
  48455. case 'date':
  48456. if (!$date = $this->validateDateTime($element, 'Y-m-d')) {
  48457. $this->addError($path, sprintf('Invalid date %s, expected format YYYY-MM-DD', json_encode($element)), 'format', array('format' => $schema->format));
  48458. }
  48459. break;
  48460. case 'time':
  48461. if (!$this->validateDateTime($element, 'H:i:s')) {
  48462. $this->addError($path, sprintf('Invalid time %s, expected format hh:mm:ss', json_encode($element)), 'format', array('format' => $schema->format));
  48463. }
  48464. break;
  48465. case 'date-time':
  48466. if (null === Rfc3339::createFromString($element)) {
  48467. $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));
  48468. }
  48469. break;
  48470. case 'utc-millisec':
  48471. if (!$this->validateDateTime($element, 'U')) {
  48472. $this->addError($path, sprintf('Invalid time %s, expected integer of milliseconds since Epoch', json_encode($element)), 'format', array('format' => $schema->format));
  48473. }
  48474. break;
  48475. case 'regex':
  48476. if (!$this->validateRegex($element)) {
  48477. $this->addError($path, 'Invalid regex format ' . $element, 'format', array('format' => $schema->format));
  48478. }
  48479. break;
  48480. case 'color':
  48481. if (!$this->validateColor($element)) {
  48482. $this->addError($path, 'Invalid color', 'format', array('format' => $schema->format));
  48483. }
  48484. break;
  48485. case 'style':
  48486. if (!$this->validateStyle($element)) {
  48487. $this->addError($path, 'Invalid style', 'format', array('format' => $schema->format));
  48488. }
  48489. break;
  48490. case 'phone':
  48491. if (!$this->validatePhone($element)) {
  48492. $this->addError($path, 'Invalid phone number', 'format', array('format' => $schema->format));
  48493. }
  48494. break;
  48495. case 'uri':
  48496. if (null === filter_var($element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE)) {
  48497. $this->addError($path, 'Invalid URL format', 'format', array('format' => $schema->format));
  48498. }
  48499. break;
  48500. case 'uriref':
  48501. case 'uri-reference':
  48502. if (null === filter_var($element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE)) {
  48503. if (substr($element, 0, 2) === '//') {
  48504. $validURL = filter_var('scheme:' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  48505. } elseif (substr($element, 0, 1) === '/') {
  48506. $validURL = filter_var('scheme://host' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  48507. } elseif (strlen($element)) {
  48508. $pathParts = explode('/', $element, 2);
  48509. if (strpos($pathParts[0], ':') !== false) {
  48510. $validURL = null;
  48511. } else {
  48512. $validURL = filter_var('scheme://host/' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  48513. }
  48514. } else {
  48515. $validURL = null;
  48516. }
  48517. if ($validURL === null) {
  48518. $this->addError($path, 'Invalid URL format', 'format', array('format' => $schema->format));
  48519. }
  48520. }
  48521. break;
  48522. case 'email':
  48523. $filterFlags = FILTER_NULL_ON_FAILURE;
  48524. if (defined('FILTER_FLAG_EMAIL_UNICODE')) {
  48525. $filterFlags |= constant('FILTER_FLAG_EMAIL_UNICODE');
  48526. }
  48527. if (null === filter_var($element, FILTER_VALIDATE_EMAIL, $filterFlags)) {
  48528. $this->addError($path, 'Invalid email', 'format', array('format' => $schema->format));
  48529. }
  48530. break;
  48531. case 'ip-address':
  48532. case 'ipv4':
  48533. if (null === filter_var($element, FILTER_VALIDATE_IP, FILTER_NULL_ON_FAILURE | FILTER_FLAG_IPV4)) {
  48534. $this->addError($path, 'Invalid IP address', 'format', array('format' => $schema->format));
  48535. }
  48536. break;
  48537. case 'ipv6':
  48538. if (null === filter_var($element, FILTER_VALIDATE_IP, FILTER_NULL_ON_FAILURE | FILTER_FLAG_IPV6)) {
  48539. $this->addError($path, 'Invalid IP address', 'format', array('format' => $schema->format));
  48540. }
  48541. break;
  48542. case 'host-name':
  48543. case 'hostname':
  48544. if (!$this->validateHostname($element)) {
  48545. $this->addError($path, 'Invalid hostname', 'format', array('format' => $schema->format));
  48546. }
  48547. break;
  48548. default:
  48549. break;
  48550. }
  48551. }
  48552. protected function validateDateTime($datetime, $format)
  48553. {
  48554. $dt = \DateTime::createFromFormat($format, $datetime);
  48555. if (!$dt) {
  48556. return false;
  48557. }
  48558. if ($datetime === $dt->format($format)) {
  48559. return true;
  48560. }
  48561. if ((strpos('u', $format) !== -1) && (preg_match('/\.\d+Z$/', $datetime))) {
  48562. return true;
  48563. }
  48564. return false;
  48565. }
  48566. protected function validateRegex($regex)
  48567. {
  48568. return false !== @preg_match('/' . $regex . '/u', '');
  48569. }
  48570. protected function validateColor($color)
  48571. {
  48572. if (in_array(strtolower($color), array('aqua', 'black', 'blue', 'fuchsia',
  48573. 'gray', 'green', 'lime', 'maroon', 'navy', 'olive', 'orange', 'purple',
  48574. 'red', 'silver', 'teal', 'white', 'yellow'))) {
  48575. return true;
  48576. }
  48577. return preg_match('/^#([a-f0-9]{3}|[a-f0-9]{6})$/i', $color);
  48578. }
  48579. protected function validateStyle($style)
  48580. {
  48581. $properties = explode(';', rtrim($style, ';'));
  48582. $invalidEntries = preg_grep('/^\s*[-a-z]+\s*:\s*.+$/i', $properties, PREG_GREP_INVERT);
  48583. return empty($invalidEntries);
  48584. }
  48585. protected function validatePhone($phone)
  48586. {
  48587. return preg_match('/^\+?(\(\d{3}\)|\d{3}) \d{3} \d{4}$/', $phone);
  48588. }
  48589. protected function validateHostname($host)
  48590. {
  48591. $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';
  48592. return preg_match($hostnameRegex, $host);
  48593. }
  48594. }
  48595. <?php
  48596. namespace JsonSchema\Constraints;
  48597. use JsonSchema\Entity\JsonPointer;
  48598. class NumberConstraint extends Constraint
  48599. {
  48600. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  48601. {
  48602. if (isset($schema->exclusiveMinimum)) {
  48603. if (isset($schema->minimum)) {
  48604. if ($schema->exclusiveMinimum && $element <= $schema->minimum) {
  48605. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'exclusiveMinimum', array('minimum' => $schema->minimum));
  48606. } elseif ($element < $schema->minimum) {
  48607. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'minimum', array('minimum' => $schema->minimum));
  48608. }
  48609. } else {
  48610. $this->addError($path, 'Use of exclusiveMinimum requires presence of minimum', 'missingMinimum');
  48611. }
  48612. } elseif (isset($schema->minimum) && $element < $schema->minimum) {
  48613. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'minimum', array('minimum' => $schema->minimum));
  48614. }
  48615. if (isset($schema->exclusiveMaximum)) {
  48616. if (isset($schema->maximum)) {
  48617. if ($schema->exclusiveMaximum && $element >= $schema->maximum) {
  48618. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'exclusiveMaximum', array('maximum' => $schema->maximum));
  48619. } elseif ($element > $schema->maximum) {
  48620. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'maximum', array('maximum' => $schema->maximum));
  48621. }
  48622. } else {
  48623. $this->addError($path, 'Use of exclusiveMaximum requires presence of maximum', 'missingMaximum');
  48624. }
  48625. } elseif (isset($schema->maximum) && $element > $schema->maximum) {
  48626. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'maximum', array('maximum' => $schema->maximum));
  48627. }
  48628. if (isset($schema->divisibleBy) && $this->fmod($element, $schema->divisibleBy) != 0) {
  48629. $this->addError($path, 'Is not divisible by ' . $schema->divisibleBy, 'divisibleBy', array('divisibleBy' => $schema->divisibleBy));
  48630. }
  48631. if (isset($schema->multipleOf) && $this->fmod($element, $schema->multipleOf) != 0) {
  48632. $this->addError($path, 'Must be a multiple of ' . $schema->multipleOf, 'multipleOf', array('multipleOf' => $schema->multipleOf));
  48633. }
  48634. $this->checkFormat($element, $schema, $path, $i);
  48635. }
  48636. private function fmod($number1, $number2)
  48637. {
  48638. $modulus = ($number1 - round($number1 / $number2) * $number2);
  48639. $precision = 0.0000000001;
  48640. if (-$precision < $modulus && $modulus < $precision) {
  48641. return 0.0;
  48642. }
  48643. return $modulus;
  48644. }
  48645. }
  48646. <?php
  48647. namespace JsonSchema\Constraints;
  48648. use JsonSchema\Entity\JsonPointer;
  48649. class ObjectConstraint extends Constraint
  48650. {
  48651. protected $appliedDefaults = array();
  48652. public function check(&$element, $schema = null, JsonPointer $path = null, $properties = null,
  48653. $additionalProp = null, $patternProperties = null, $appliedDefaults = array())
  48654. {
  48655. if ($element instanceof UndefinedConstraint) {
  48656. return;
  48657. }
  48658. $this->appliedDefaults = $appliedDefaults;
  48659. $matches = array();
  48660. if ($patternProperties) {
  48661. $matches = $this->validatePatternProperties($element, $path, $patternProperties);
  48662. }
  48663. if ($properties) {
  48664. $this->validateProperties($element, $properties, $path);
  48665. }
  48666. $this->validateElement($element, $matches, $schema, $path, $properties, $additionalProp);
  48667. }
  48668. public function validatePatternProperties($element, JsonPointer $path = null, $patternProperties)
  48669. {
  48670. $try = array('/', '#', '+', '~', '%');
  48671. $matches = array();
  48672. foreach ($patternProperties as $pregex => $schema) {
  48673. $delimiter = '/';
  48674. foreach ($try as $delimiter) {
  48675. if (strpos($pregex, $delimiter) === false) {
  48676. break;
  48677. }
  48678. }
  48679. if (@preg_match($delimiter . $pregex . $delimiter . 'u', '') === false) {
  48680. $this->addError($path, 'The pattern "' . $pregex . '" is invalid', 'pregex', array('pregex' => $pregex));
  48681. continue;
  48682. }
  48683. foreach ($element as $i => $value) {
  48684. if (preg_match($delimiter . $pregex . $delimiter . 'u', $i)) {
  48685. $matches[] = $i;
  48686. $this->checkUndefined($value, $schema ?: new \stdClass(), $path, $i, in_array($i, $this->appliedDefaults));
  48687. }
  48688. }
  48689. }
  48690. return $matches;
  48691. }
  48692. public function validateElement($element, $matches, $schema = null, JsonPointer $path = null,
  48693. $properties = null, $additionalProp = null)
  48694. {
  48695. $this->validateMinMaxConstraint($element, $schema, $path);
  48696. foreach ($element as $i => $value) {
  48697. $definition = $this->getProperty($properties, $i);
  48698. if (!in_array($i, $matches) && $additionalProp === false && $this->inlineSchemaProperty !== $i && !$definition) {
  48699. $this->addError($path, 'The property ' . $i . ' is not defined and the definition does not allow additional properties', 'additionalProp');
  48700. }
  48701. if (!in_array($i, $matches) && $additionalProp && !$definition) {
  48702. if ($additionalProp === true) {
  48703. $this->checkUndefined($value, null, $path, $i, in_array($i, $this->appliedDefaults));
  48704. } else {
  48705. $this->checkUndefined($value, $additionalProp, $path, $i, in_array($i, $this->appliedDefaults));
  48706. }
  48707. }
  48708. $require = $this->getProperty($definition, 'requires');
  48709. if ($require && !$this->getProperty($element, $require)) {
  48710. $this->addError($path, 'The presence of the property ' . $i . ' requires that ' . $require . ' also be present', 'requires');
  48711. }
  48712. $property = $this->getProperty($element, $i, $this->factory->createInstanceFor('undefined'));
  48713. if (is_object($property)) {
  48714. $this->validateMinMaxConstraint(!($property instanceof UndefinedConstraint) ? $property : $element, $definition, $path);
  48715. }
  48716. }
  48717. }
  48718. public function validateProperties(&$element, $properties = null, JsonPointer $path = null)
  48719. {
  48720. $undefinedConstraint = $this->factory->createInstanceFor('undefined');
  48721. foreach ($properties as $i => $value) {
  48722. $property = &$this->getProperty($element, $i, $undefinedConstraint);
  48723. $definition = $this->getProperty($properties, $i);
  48724. if (is_object($definition)) {
  48725. $this->checkUndefined($property, $definition, $path, $i, in_array($i, $this->appliedDefaults));
  48726. }
  48727. }
  48728. }
  48729. protected function &getProperty(&$element, $property, $fallback = null)
  48730. {
  48731. if (is_array($element) && (isset($element[$property]) || array_key_exists($property, $element)) ) {
  48732. return $element[$property];
  48733. } elseif (is_object($element) && property_exists($element, $property)) {
  48734. return $element->$property;
  48735. }
  48736. return $fallback;
  48737. }
  48738. protected function validateMinMaxConstraint($element, $objectDefinition, JsonPointer $path = null)
  48739. {
  48740. if (isset($objectDefinition->minProperties) && !is_object($objectDefinition->minProperties)) {
  48741. if ($this->getTypeCheck()->propertyCount($element) < $objectDefinition->minProperties) {
  48742. $this->addError($path, 'Must contain a minimum of ' . $objectDefinition->minProperties . ' properties', 'minProperties', array('minProperties' => $objectDefinition->minProperties));
  48743. }
  48744. }
  48745. if (isset($objectDefinition->maxProperties) && !is_object($objectDefinition->maxProperties)) {
  48746. if ($this->getTypeCheck()->propertyCount($element) > $objectDefinition->maxProperties) {
  48747. $this->addError($path, 'Must contain no more than ' . $objectDefinition->maxProperties . ' properties', 'maxProperties', array('maxProperties' => $objectDefinition->maxProperties));
  48748. }
  48749. }
  48750. }
  48751. }
  48752. <?php
  48753. namespace JsonSchema\Constraints;
  48754. use JsonSchema\Entity\JsonPointer;
  48755. use JsonSchema\Exception\InvalidArgumentException;
  48756. use JsonSchema\Exception\InvalidSchemaException;
  48757. use JsonSchema\Exception\RuntimeException;
  48758. use JsonSchema\Validator;
  48759. class SchemaConstraint extends Constraint
  48760. {
  48761. const DEFAULT_SCHEMA_SPEC = 'http://json-schema.org/draft-04/schema#';
  48762. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  48763. {
  48764. if ($schema !== null) {
  48765. $validationSchema = $schema;
  48766. } elseif ($this->getTypeCheck()->propertyExists($element, $this->inlineSchemaProperty)) {
  48767. $validationSchema = $this->getTypeCheck()->propertyGet($element, $this->inlineSchemaProperty);
  48768. } else {
  48769. throw new InvalidArgumentException('no schema found to verify against');
  48770. }
  48771. if (is_array($validationSchema)) {
  48772. $validationSchema = BaseConstraint::arrayToObjectRecursive($validationSchema);
  48773. }
  48774. if ($this->factory->getConfig(self::CHECK_MODE_VALIDATE_SCHEMA)) {
  48775. if (!$this->getTypeCheck()->isObject($validationSchema)) {
  48776. throw new RuntimeException('Cannot validate the schema of a non-object');
  48777. }
  48778. if ($this->getTypeCheck()->propertyExists($validationSchema, '$schema')) {
  48779. $schemaSpec = $this->getTypeCheck()->propertyGet($validationSchema, '$schema');
  48780. } else {
  48781. $schemaSpec = self::DEFAULT_SCHEMA_SPEC;
  48782. }
  48783. $schemaStorage = $this->factory->getSchemaStorage();
  48784. if (!$this->getTypeCheck()->isObject($schemaSpec)) {
  48785. $schemaSpec = $schemaStorage->getSchema($schemaSpec);
  48786. }
  48787. $initialErrorCount = $this->numErrors();
  48788. $initialConfig = $this->factory->getConfig();
  48789. $initialContext = $this->factory->getErrorContext();
  48790. $this->factory->removeConfig(self::CHECK_MODE_VALIDATE_SCHEMA | self::CHECK_MODE_APPLY_DEFAULTS);
  48791. $this->factory->addConfig(self::CHECK_MODE_TYPE_CAST);
  48792. $this->factory->setErrorContext(Validator::ERROR_SCHEMA_VALIDATION);
  48793. try {
  48794. $this->check($validationSchema, $schemaSpec);
  48795. } catch (\Exception $e) {
  48796. if ($this->factory->getConfig(self::CHECK_MODE_EXCEPTIONS)) {
  48797. throw new InvalidSchemaException('Schema did not pass validation', 0, $e);
  48798. }
  48799. }
  48800. if ($this->numErrors() > $initialErrorCount) {
  48801. $this->addError($path, 'Schema is not valid', 'schema');
  48802. }
  48803. $this->factory->setConfig($initialConfig);
  48804. $this->factory->setErrorContext($initialContext);
  48805. }
  48806. $this->checkUndefined($element, $validationSchema, $path, $i);
  48807. }
  48808. }
  48809. <?php
  48810. namespace JsonSchema\Constraints;
  48811. use JsonSchema\Entity\JsonPointer;
  48812. class StringConstraint extends Constraint
  48813. {
  48814. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  48815. {
  48816. if (isset($schema->maxLength) && $this->strlen($element) > $schema->maxLength) {
  48817. $this->addError($path, 'Must be at most ' . $schema->maxLength . ' characters long', 'maxLength', array(
  48818. 'maxLength' => $schema->maxLength,
  48819. ));
  48820. }
  48821. if (isset($schema->minLength) && $this->strlen($element) < $schema->minLength) {
  48822. $this->addError($path, 'Must be at least ' . $schema->minLength . ' characters long', 'minLength', array(
  48823. 'minLength' => $schema->minLength,
  48824. ));
  48825. }
  48826. if (isset($schema->pattern) && !preg_match('#' . str_replace('#', '\\#', $schema->pattern) . '#u', $element)) {
  48827. $this->addError($path, 'Does not match the regex pattern ' . $schema->pattern, 'pattern', array(
  48828. 'pattern' => $schema->pattern,
  48829. ));
  48830. }
  48831. $this->checkFormat($element, $schema, $path, $i);
  48832. }
  48833. private function strlen($string)
  48834. {
  48835. if (extension_loaded('mbstring')) {
  48836. return mb_strlen($string, mb_detect_encoding($string));
  48837. }
  48838. return strlen($string);
  48839. }
  48840. }
  48841. <?php
  48842. namespace JsonSchema\Constraints\TypeCheck;
  48843. class LooseTypeCheck implements TypeCheckInterface
  48844. {
  48845. public static function isObject($value)
  48846. {
  48847. return
  48848. is_object($value) ||
  48849. (is_array($value) && (count($value) == 0 || self::isAssociativeArray($value)));
  48850. }
  48851. public static function isArray($value)
  48852. {
  48853. return
  48854. is_array($value) &&
  48855. (count($value) == 0 || !self::isAssociativeArray($value));
  48856. }
  48857. public static function propertyGet($value, $property)
  48858. {
  48859. if (is_object($value)) {
  48860. return $value->{$property};
  48861. }
  48862. return $value[$property];
  48863. }
  48864. public static function propertySet(&$value, $property, $data)
  48865. {
  48866. if (is_object($value)) {
  48867. $value->{$property} = $data;
  48868. } else {
  48869. $value[$property] = $data;
  48870. }
  48871. }
  48872. public static function propertyExists($value, $property)
  48873. {
  48874. if (is_object($value)) {
  48875. return property_exists($value, $property);
  48876. }
  48877. return array_key_exists($property, $value);
  48878. }
  48879. public static function propertyCount($value)
  48880. {
  48881. if (is_object($value)) {
  48882. return count(get_object_vars($value));
  48883. }
  48884. return count($value);
  48885. }
  48886. private static function isAssociativeArray($arr)
  48887. {
  48888. return array_keys($arr) !== range(0, count($arr) - 1);
  48889. }
  48890. }
  48891. <?php
  48892. namespace JsonSchema\Constraints\TypeCheck;
  48893. class StrictTypeCheck implements TypeCheckInterface
  48894. {
  48895. public static function isObject($value)
  48896. {
  48897. return is_object($value);
  48898. }
  48899. public static function isArray($value)
  48900. {
  48901. return is_array($value);
  48902. }
  48903. public static function propertyGet($value, $property)
  48904. {
  48905. return $value->{$property};
  48906. }
  48907. public static function propertySet(&$value, $property, $data)
  48908. {
  48909. $value->{$property} = $data;
  48910. }
  48911. public static function propertyExists($value, $property)
  48912. {
  48913. return property_exists($value, $property);
  48914. }
  48915. public static function propertyCount($value)
  48916. {
  48917. if (!is_object($value)) {
  48918. return 0;
  48919. }
  48920. return count(get_object_vars($value));
  48921. }
  48922. }
  48923. <?php
  48924. namespace JsonSchema\Constraints\TypeCheck;
  48925. interface TypeCheckInterface
  48926. {
  48927. public static function isObject($value);
  48928. public static function isArray($value);
  48929. public static function propertyGet($value, $property);
  48930. public static function propertySet(&$value, $property, $data);
  48931. public static function propertyExists($value, $property);
  48932. public static function propertyCount($value);
  48933. }
  48934. <?php
  48935. namespace JsonSchema\Constraints;
  48936. use JsonSchema\Entity\JsonPointer;
  48937. use JsonSchema\Exception\InvalidArgumentException;
  48938. use UnexpectedValueException as StandardUnexpectedValueException;
  48939. class TypeConstraint extends Constraint
  48940. {
  48941. public static $wording = array(
  48942. 'integer' => 'an integer',
  48943. 'number' => 'a number',
  48944. 'boolean' => 'a boolean',
  48945. 'object' => 'an object',
  48946. 'array' => 'an array',
  48947. 'string' => 'a string',
  48948. 'null' => 'a null',
  48949. 'any' => null,
  48950. 0 => null,
  48951. );
  48952. public function check(&$value = null, $schema = null, JsonPointer $path = null, $i = null)
  48953. {
  48954. $type = isset($schema->type) ? $schema->type : null;
  48955. $isValid = false;
  48956. $wording = array();
  48957. if (is_array($type)) {
  48958. $this->validateTypesArray($value, $type, $wording, $isValid, $path);
  48959. } elseif (is_object($type)) {
  48960. $this->checkUndefined($value, $type, $path);
  48961. return;
  48962. } else {
  48963. $isValid = $this->validateType($value, $type);
  48964. }
  48965. if ($isValid === false) {
  48966. if (!is_array($type)) {
  48967. $this->validateTypeNameWording($type);
  48968. $wording[] = self::$wording[$type];
  48969. }
  48970. $this->addError($path, ucwords(gettype($value)) . ' value found, but ' .
  48971. $this->implodeWith($wording, ', ', 'or') . ' is required', 'type');
  48972. }
  48973. }
  48974. protected function validateTypesArray(&$value, array $type, &$validTypesWording, &$isValid, $path)
  48975. {
  48976. foreach ($type as $tp) {
  48977. if (is_object($tp)) {
  48978. if (!$isValid) {
  48979. $validator = $this->factory->createInstanceFor('type');
  48980. $subSchema = new \stdClass();
  48981. $subSchema->type = $tp;
  48982. $validator->check($value, $subSchema, $path, null);
  48983. $error = $validator->getErrors();
  48984. $isValid = !(bool) $error;
  48985. $validTypesWording[] = self::$wording['object'];
  48986. }
  48987. } else {
  48988. $this->validateTypeNameWording($tp);
  48989. $validTypesWording[] = self::$wording[$tp];
  48990. if (!$isValid) {
  48991. $isValid = $this->validateType($value, $tp);
  48992. }
  48993. }
  48994. }
  48995. }
  48996. protected function implodeWith(array $elements, $delimiter = ', ', $listEnd = false)
  48997. {
  48998. if ($listEnd === false || !isset($elements[1])) {
  48999. return implode($delimiter, $elements);
  49000. }
  49001. $lastElement = array_slice($elements, -1);
  49002. $firsElements = join($delimiter, array_slice($elements, 0, -1));
  49003. $implodedElements = array_merge(array($firsElements), $lastElement);
  49004. return join(" $listEnd ", $implodedElements);
  49005. }
  49006. protected function validateTypeNameWording($type)
  49007. {
  49008. if (!isset(self::$wording[$type])) {
  49009. throw new StandardUnexpectedValueException(
  49010. sprintf(
  49011. 'No wording for %s available, expected wordings are: [%s]',
  49012. var_export($type, true),
  49013. implode(', ', array_filter(self::$wording)))
  49014. );
  49015. }
  49016. }
  49017. protected function validateType(&$value, $type)
  49018. {
  49019. if (!$type) {
  49020. return true;
  49021. }
  49022. if ('any' === $type) {
  49023. return true;
  49024. }
  49025. if ('object' === $type) {
  49026. return $this->getTypeCheck()->isObject($value);
  49027. }
  49028. if ('array' === $type) {
  49029. return $this->getTypeCheck()->isArray($value);
  49030. }
  49031. $coerce = $this->factory->getConfig(Constraint::CHECK_MODE_COERCE_TYPES);
  49032. if ('integer' === $type) {
  49033. if ($coerce) {
  49034. $value = $this->toInteger($value);
  49035. }
  49036. return is_int($value);
  49037. }
  49038. if ('number' === $type) {
  49039. if ($coerce) {
  49040. $value = $this->toNumber($value);
  49041. }
  49042. return is_numeric($value) && !is_string($value);
  49043. }
  49044. if ('boolean' === $type) {
  49045. if ($coerce) {
  49046. $value = $this->toBoolean($value);
  49047. }
  49048. return is_bool($value);
  49049. }
  49050. if ('string' === $type) {
  49051. return is_string($value);
  49052. }
  49053. if ('email' === $type) {
  49054. return is_string($value);
  49055. }
  49056. if ('null' === $type) {
  49057. return is_null($value);
  49058. }
  49059. throw new InvalidArgumentException((is_object($value) ? 'object' : $value) . ' is an invalid type for ' . $type);
  49060. }
  49061. protected function toBoolean($value)
  49062. {
  49063. if ($value === 'true') {
  49064. return true;
  49065. }
  49066. if ($value === 'false') {
  49067. return false;
  49068. }
  49069. return $value;
  49070. }
  49071. protected function toNumber($value)
  49072. {
  49073. if (is_numeric($value)) {
  49074. return $value + 0;
  49075. }
  49076. return $value;
  49077. }
  49078. protected function toInteger($value)
  49079. {
  49080. if (is_numeric($value) && (int) $value == $value) {
  49081. return (int) $value;
  49082. }
  49083. return $value;
  49084. }
  49085. }
  49086. <?php
  49087. namespace JsonSchema\Constraints;
  49088. use JsonSchema\Constraints\TypeCheck\LooseTypeCheck;
  49089. use JsonSchema\Entity\JsonPointer;
  49090. use JsonSchema\Exception\ValidationException;
  49091. use JsonSchema\Uri\UriResolver;
  49092. class UndefinedConstraint extends Constraint
  49093. {
  49094. protected $appliedDefaults = array();
  49095. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null, $fromDefault = false)
  49096. {
  49097. if (is_null($schema) || !is_object($schema)) {
  49098. return;
  49099. }
  49100. $path = $this->incrementPath($path ?: new JsonPointer(''), $i);
  49101. if ($fromDefault) {
  49102. $path->setFromDefault();
  49103. }
  49104. $this->validateCommonProperties($value, $schema, $path, $i);
  49105. $this->validateOfProperties($value, $schema, $path, '');
  49106. $this->validateTypes($value, $schema, $path, $i);
  49107. }
  49108. public function validateTypes(&$value, $schema, JsonPointer $path, $i = null)
  49109. {
  49110. if ($this->getTypeCheck()->isArray($value)) {
  49111. $this->checkArray($value, $schema, $path, $i);
  49112. }
  49113. if (LooseTypeCheck::isObject($value)) {
  49114. $this->checkObject(
  49115. $value,
  49116. $schema,
  49117. $path,
  49118. isset($schema->properties) ? $schema->properties : null,
  49119. isset($schema->additionalProperties) ? $schema->additionalProperties : null,
  49120. isset($schema->patternProperties) ? $schema->patternProperties : null,
  49121. $this->appliedDefaults
  49122. );
  49123. }
  49124. if (is_string($value)) {
  49125. $this->checkString($value, $schema, $path, $i);
  49126. }
  49127. if (is_numeric($value)) {
  49128. $this->checkNumber($value, $schema, $path, $i);
  49129. }
  49130. if (isset($schema->enum)) {
  49131. $this->checkEnum($value, $schema, $path, $i);
  49132. }
  49133. }
  49134. protected function validateCommonProperties(&$value, $schema, JsonPointer $path, $i = '')
  49135. {
  49136. if (isset($schema->extends)) {
  49137. if (is_string($schema->extends)) {
  49138. $schema->extends = $this->validateUri($schema, $schema->extends);
  49139. }
  49140. if (is_array($schema->extends)) {
  49141. foreach ($schema->extends as $extends) {
  49142. $this->checkUndefined($value, $extends, $path, $i);
  49143. }
  49144. } else {
  49145. $this->checkUndefined($value, $schema->extends, $path, $i);
  49146. }
  49147. }
  49148. if (!$path->fromDefault()) {
  49149. $this->applyDefaultValues($value, $schema, $path);
  49150. }
  49151. if ($this->getTypeCheck()->isObject($value)) {
  49152. if (!($value instanceof self) && isset($schema->required) && is_array($schema->required)) {
  49153. foreach ($schema->required as $required) {
  49154. if (!$this->getTypeCheck()->propertyExists($value, $required)) {
  49155. $this->addError(
  49156. $this->incrementPath($path ?: new JsonPointer(''), $required),
  49157. 'The property ' . $required . ' is required',
  49158. 'required'
  49159. );
  49160. }
  49161. }
  49162. } elseif (isset($schema->required) && !is_array($schema->required)) {
  49163. if ($schema->required && $value instanceof self) {
  49164. $propertyPaths = $path->getPropertyPaths();
  49165. $propertyName = end($propertyPaths);
  49166. $this->addError(
  49167. $path,
  49168. 'The property ' . $propertyName . ' is required',
  49169. 'required'
  49170. );
  49171. }
  49172. } else {
  49173. if ($value instanceof self) {
  49174. return;
  49175. }
  49176. }
  49177. }
  49178. if (!($value instanceof self)) {
  49179. $this->checkType($value, $schema, $path, $i);
  49180. }
  49181. if (isset($schema->disallow)) {
  49182. $initErrors = $this->getErrors();
  49183. $typeSchema = new \stdClass();
  49184. $typeSchema->type = $schema->disallow;
  49185. $this->checkType($value, $typeSchema, $path);
  49186. if (count($this->getErrors()) == count($initErrors)) {
  49187. $this->addError($path, 'Disallowed value was matched', 'disallow');
  49188. } else {
  49189. $this->errors = $initErrors;
  49190. }
  49191. }
  49192. if (isset($schema->not)) {
  49193. $initErrors = $this->getErrors();
  49194. $this->checkUndefined($value, $schema->not, $path, $i);
  49195. if (count($this->getErrors()) == count($initErrors)) {
  49196. $this->addError($path, 'Matched a schema which it should not', 'not');
  49197. } else {
  49198. $this->errors = $initErrors;
  49199. }
  49200. }
  49201. if (isset($schema->dependencies) && $this->getTypeCheck()->isObject($value)) {
  49202. $this->validateDependencies($value, $schema->dependencies, $path);
  49203. }
  49204. }
  49205. private function shouldApplyDefaultValue($requiredOnly, $schema, $name = null, $parentSchema = null)
  49206. {
  49207. if (!$requiredOnly) {
  49208. return true;
  49209. }
  49210. if (
  49211. $name !== null
  49212. && isset($parentSchema->required)
  49213. && is_array($parentSchema->required)
  49214. && in_array($name, $parentSchema->required)
  49215. ) {
  49216. return true;
  49217. }
  49218. if (isset($schema->required) && !is_array($schema->required) && $schema->required) {
  49219. return true;
  49220. }
  49221. return false;
  49222. }
  49223. protected function applyDefaultValues(&$value, $schema, $path)
  49224. {
  49225. if (!$this->factory->getConfig(self::CHECK_MODE_APPLY_DEFAULTS)) {
  49226. return;
  49227. }
  49228. $requiredOnly = $this->factory->getConfig(self::CHECK_MODE_ONLY_REQUIRED_DEFAULTS);
  49229. if (isset($schema->properties) && LooseTypeCheck::isObject($value)) {
  49230. foreach ($schema->properties as $currentProperty => $propertyDefinition) {
  49231. $propertyDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($propertyDefinition);
  49232. if (
  49233. !LooseTypeCheck::propertyExists($value, $currentProperty)
  49234. && property_exists($propertyDefinition, 'default')
  49235. && $this->shouldApplyDefaultValue($requiredOnly, $propertyDefinition, $currentProperty, $schema)
  49236. ) {
  49237. if (is_object($propertyDefinition->default)) {
  49238. LooseTypeCheck::propertySet($value, $currentProperty, clone $propertyDefinition->default);
  49239. } else {
  49240. LooseTypeCheck::propertySet($value, $currentProperty, $propertyDefinition->default);
  49241. }
  49242. $this->appliedDefaults[] = $currentProperty;
  49243. }
  49244. }
  49245. } elseif (isset($schema->items) && LooseTypeCheck::isArray($value)) {
  49246. $items = array();
  49247. if (LooseTypeCheck::isArray($schema->items)) {
  49248. $items = $schema->items;
  49249. } elseif (isset($schema->minItems) && count($value) < $schema->minItems) {
  49250. $items = array_fill(count($value), $schema->minItems - count($value), $schema->items);
  49251. }
  49252. foreach ($items as $currentItem => $itemDefinition) {
  49253. $itemDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($itemDefinition);
  49254. if (
  49255. !array_key_exists($currentItem, $value)
  49256. && property_exists($itemDefinition, 'default')
  49257. && $this->shouldApplyDefaultValue($requiredOnly, $itemDefinition)) {
  49258. if (is_object($itemDefinition->default)) {
  49259. $value[$currentItem] = clone $itemDefinition->default;
  49260. } else {
  49261. $value[$currentItem] = $itemDefinition->default;
  49262. }
  49263. }
  49264. $path->setFromDefault();
  49265. }
  49266. } elseif (
  49267. $value instanceof self
  49268. && property_exists($schema, 'default')
  49269. && $this->shouldApplyDefaultValue($requiredOnly, $schema)) {
  49270. $value = is_object($schema->default) ? clone $schema->default : $schema->default;
  49271. $path->setFromDefault();
  49272. }
  49273. }
  49274. protected function validateOfProperties(&$value, $schema, JsonPointer $path, $i = '')
  49275. {
  49276. if ($value instanceof self) {
  49277. return;
  49278. }
  49279. if (isset($schema->allOf)) {
  49280. $isValid = true;
  49281. foreach ($schema->allOf as $allOf) {
  49282. $initErrors = $this->getErrors();
  49283. $this->checkUndefined($value, $allOf, $path, $i);
  49284. $isValid = $isValid && (count($this->getErrors()) == count($initErrors));
  49285. }
  49286. if (!$isValid) {
  49287. $this->addError($path, 'Failed to match all schemas', 'allOf');
  49288. }
  49289. }
  49290. if (isset($schema->anyOf)) {
  49291. $isValid = false;
  49292. $startErrors = $this->getErrors();
  49293. $caughtException = null;
  49294. foreach ($schema->anyOf as $anyOf) {
  49295. $initErrors = $this->getErrors();
  49296. try {
  49297. $this->checkUndefined($value, $anyOf, $path, $i);
  49298. if ($isValid = (count($this->getErrors()) == count($initErrors))) {
  49299. break;
  49300. }
  49301. } catch (ValidationException $e) {
  49302. $isValid = false;
  49303. }
  49304. }
  49305. if (!$isValid) {
  49306. $this->addError($path, 'Failed to match at least one schema', 'anyOf');
  49307. } else {
  49308. $this->errors = $startErrors;
  49309. }
  49310. }
  49311. if (isset($schema->oneOf)) {
  49312. $allErrors = array();
  49313. $matchedSchemas = 0;
  49314. $startErrors = $this->getErrors();
  49315. foreach ($schema->oneOf as $oneOf) {
  49316. try {
  49317. $this->errors = array();
  49318. $this->checkUndefined($value, $oneOf, $path, $i);
  49319. if (count($this->getErrors()) == 0) {
  49320. $matchedSchemas++;
  49321. }
  49322. $allErrors = array_merge($allErrors, array_values($this->getErrors()));
  49323. } catch (ValidationException $e) {
  49324. }
  49325. }
  49326. if ($matchedSchemas !== 1) {
  49327. $this->addErrors(array_merge($allErrors, $startErrors));
  49328. $this->addError($path, 'Failed to match exactly one schema', 'oneOf');
  49329. } else {
  49330. $this->errors = $startErrors;
  49331. }
  49332. }
  49333. }
  49334. protected function validateDependencies($value, $dependencies, JsonPointer $path, $i = '')
  49335. {
  49336. foreach ($dependencies as $key => $dependency) {
  49337. if ($this->getTypeCheck()->propertyExists($value, $key)) {
  49338. if (is_string($dependency)) {
  49339. if (!$this->getTypeCheck()->propertyExists($value, $dependency)) {
  49340. $this->addError($path, "$key depends on $dependency and $dependency is missing", 'dependencies');
  49341. }
  49342. } elseif (is_array($dependency)) {
  49343. foreach ($dependency as $d) {
  49344. if (!$this->getTypeCheck()->propertyExists($value, $d)) {
  49345. $this->addError($path, "$key depends on $d and $d is missing", 'dependencies');
  49346. }
  49347. }
  49348. } elseif (is_object($dependency)) {
  49349. $this->checkUndefined($value, $dependency, $path, $i);
  49350. }
  49351. }
  49352. }
  49353. }
  49354. protected function validateUri($schema, $schemaUri = null)
  49355. {
  49356. $resolver = new UriResolver();
  49357. $retriever = $this->factory->getUriRetriever();
  49358. $jsonSchema = null;
  49359. if ($resolver->isValid($schemaUri)) {
  49360. $schemaId = property_exists($schema, 'id') ? $schema->id : null;
  49361. $jsonSchema = $retriever->retrieve($schemaId, $schemaUri);
  49362. }
  49363. return $jsonSchema;
  49364. }
  49365. }
  49366. <?php
  49367. namespace JsonSchema\Entity;
  49368. use JsonSchema\Exception\InvalidArgumentException;
  49369. class JsonPointer
  49370. {
  49371. private $filename;
  49372. private $propertyPaths = array();
  49373. private $fromDefault = false;
  49374. public function __construct($value)
  49375. {
  49376. if (!is_string($value)) {
  49377. throw new InvalidArgumentException('Ref value must be a string');
  49378. }
  49379. $splitRef = explode('#', $value, 2);
  49380. $this->filename = $splitRef[0];
  49381. if (array_key_exists(1, $splitRef)) {
  49382. $this->propertyPaths = $this->decodePropertyPaths($splitRef[1]);
  49383. }
  49384. }
  49385. private function decodePropertyPaths($propertyPathString)
  49386. {
  49387. $paths = array();
  49388. foreach (explode('/', trim($propertyPathString, '/')) as $path) {
  49389. $path = $this->decodePath($path);
  49390. if (is_string($path) && '' !== $path) {
  49391. $paths[] = $path;
  49392. }
  49393. }
  49394. return $paths;
  49395. }
  49396. private function encodePropertyPaths()
  49397. {
  49398. return array_map(
  49399. array($this, 'encodePath'),
  49400. $this->getPropertyPaths()
  49401. );
  49402. }
  49403. private function decodePath($path)
  49404. {
  49405. return strtr($path, array('~1' => '/', '~0' => '~', '%25' => '%'));
  49406. }
  49407. private function encodePath($path)
  49408. {
  49409. return strtr($path, array('/' => '~1', '~' => '~0', '%' => '%25'));
  49410. }
  49411. public function getFilename()
  49412. {
  49413. return $this->filename;
  49414. }
  49415. public function getPropertyPaths()
  49416. {
  49417. return $this->propertyPaths;
  49418. }
  49419. public function withPropertyPaths(array $propertyPaths)
  49420. {
  49421. $new = clone $this;
  49422. $new->propertyPaths = $propertyPaths;
  49423. return $new;
  49424. }
  49425. public function getPropertyPathAsString()
  49426. {
  49427. return rtrim('#/' . implode('/', $this->encodePropertyPaths()), '/');
  49428. }
  49429. public function __toString()
  49430. {
  49431. return $this->getFilename() . $this->getPropertyPathAsString();
  49432. }
  49433. public function setFromDefault()
  49434. {
  49435. $this->fromDefault = true;
  49436. }
  49437. public function fromDefault()
  49438. {
  49439. return $this->fromDefault;
  49440. }
  49441. }
  49442. <?php
  49443. namespace JsonSchema\Exception;
  49444. interface ExceptionInterface
  49445. {
  49446. }
  49447. <?php
  49448. namespace JsonSchema\Exception;
  49449. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  49450. {
  49451. }
  49452. <?php
  49453. namespace JsonSchema\Exception;
  49454. class InvalidConfigException extends RuntimeException
  49455. {
  49456. }
  49457. <?php
  49458. namespace JsonSchema\Exception;
  49459. class InvalidSchemaException extends RuntimeException
  49460. {
  49461. }
  49462. <?php
  49463. namespace JsonSchema\Exception;
  49464. class InvalidSchemaMediaTypeException extends RuntimeException
  49465. {
  49466. }
  49467. <?php
  49468. namespace JsonSchema\Exception;
  49469. class InvalidSourceUriException extends InvalidArgumentException
  49470. {
  49471. }
  49472. <?php
  49473. namespace JsonSchema\Exception;
  49474. class JsonDecodingException extends RuntimeException
  49475. {
  49476. public function __construct($code = JSON_ERROR_NONE, \Exception $previous = null)
  49477. {
  49478. switch ($code) {
  49479. case JSON_ERROR_DEPTH:
  49480. $message = 'The maximum stack depth has been exceeded';
  49481. break;
  49482. case JSON_ERROR_STATE_MISMATCH:
  49483. $message = 'Invalid or malformed JSON';
  49484. break;
  49485. case JSON_ERROR_CTRL_CHAR:
  49486. $message = 'Control character error, possibly incorrectly encoded';
  49487. break;
  49488. case JSON_ERROR_UTF8:
  49489. $message = 'Malformed UTF-8 characters, possibly incorrectly encoded';
  49490. break;
  49491. case JSON_ERROR_SYNTAX:
  49492. $message = 'JSON syntax is malformed';
  49493. break;
  49494. default:
  49495. $message = 'Syntax error';
  49496. }
  49497. parent::__construct($message, $code, $previous);
  49498. }
  49499. }
  49500. <?php
  49501. namespace JsonSchema\Exception;
  49502. class ResourceNotFoundException extends RuntimeException
  49503. {
  49504. }
  49505. <?php
  49506. namespace JsonSchema\Exception;
  49507. class RuntimeException extends \RuntimeException implements ExceptionInterface
  49508. {
  49509. }
  49510. <?php
  49511. namespace JsonSchema\Exception;
  49512. class UnresolvableJsonPointerException extends InvalidArgumentException
  49513. {
  49514. }
  49515. <?php
  49516. namespace JsonSchema\Exception;
  49517. class UriResolverException extends RuntimeException
  49518. {
  49519. }
  49520. <?php
  49521. namespace JsonSchema\Exception;
  49522. class ValidationException extends RuntimeException
  49523. {
  49524. }
  49525. <?php
  49526. namespace JsonSchema\Iterator;
  49527. class ObjectIterator implements \Iterator, \Countable
  49528. {
  49529. private $object;
  49530. private $position = 0;
  49531. private $data = array();
  49532. private $initialized = false;
  49533. public function __construct($object)
  49534. {
  49535. $this->object = $object;
  49536. }
  49537. public function current()
  49538. {
  49539. $this->initialize();
  49540. return $this->data[$this->position];
  49541. }
  49542. public function next()
  49543. {
  49544. $this->initialize();
  49545. $this->position++;
  49546. }
  49547. public function key()
  49548. {
  49549. $this->initialize();
  49550. return $this->position;
  49551. }
  49552. public function valid()
  49553. {
  49554. $this->initialize();
  49555. return isset($this->data[$this->position]);
  49556. }
  49557. public function rewind()
  49558. {
  49559. $this->initialize();
  49560. $this->position = 0;
  49561. }
  49562. public function count()
  49563. {
  49564. $this->initialize();
  49565. return count($this->data);
  49566. }
  49567. private function initialize()
  49568. {
  49569. if (!$this->initialized) {
  49570. $this->data = $this->buildDataFromObject($this->object);
  49571. $this->initialized = true;
  49572. }
  49573. }
  49574. private function buildDataFromObject($object)
  49575. {
  49576. $result = array();
  49577. $stack = new \SplStack();
  49578. $stack->push($object);
  49579. while (!$stack->isEmpty()) {
  49580. $current = $stack->pop();
  49581. if (is_object($current)) {
  49582. array_push($result, $current);
  49583. }
  49584. foreach ($this->getDataFromItem($current) as $propertyName => $propertyValue) {
  49585. if (is_object($propertyValue) || is_array($propertyValue)) {
  49586. $stack->push($propertyValue);
  49587. }
  49588. }
  49589. }
  49590. return $result;
  49591. }
  49592. private function getDataFromItem($item)
  49593. {
  49594. if (!is_object($item) && !is_array($item)) {
  49595. return array();
  49596. }
  49597. return is_object($item) ? get_object_vars($item) : $item;
  49598. }
  49599. }
  49600. <?php
  49601. namespace JsonSchema;
  49602. class Rfc3339
  49603. {
  49604. const REGEX = '/^(\d{4}-\d{2}-\d{2}[T ]{1}\d{2}:\d{2}:\d{2})(\.\d+)?(Z|([+-]\d{2}):?(\d{2}))$/';
  49605. public static function createFromString($string)
  49606. {
  49607. if (!preg_match(self::REGEX, strtoupper($string), $matches)) {
  49608. return null;
  49609. }
  49610. $dateAndTime = $matches[1];
  49611. $microseconds = $matches[2] ?: '.000000';
  49612. $timeZone = 'Z' !== $matches[3] ? $matches[4] . ':' . $matches[5] : '+00:00';
  49613. $dateFormat = strpos($dateAndTime, 'T') === false ? 'Y-m-d H:i:s.uP' : 'Y-m-d\TH:i:s.uP';
  49614. $dateTime = \DateTime::createFromFormat($dateFormat, $dateAndTime . $microseconds . $timeZone, new \DateTimeZone('UTC'));
  49615. return $dateTime ?: null;
  49616. }
  49617. }
  49618. <?php
  49619. namespace JsonSchema;
  49620. use JsonSchema\Constraints\BaseConstraint;
  49621. use JsonSchema\Entity\JsonPointer;
  49622. use JsonSchema\Exception\UnresolvableJsonPointerException;
  49623. use JsonSchema\Uri\UriResolver;
  49624. use JsonSchema\Uri\UriRetriever;
  49625. class SchemaStorage implements SchemaStorageInterface
  49626. {
  49627. const INTERNAL_PROVIDED_SCHEMA_URI = 'internal://provided-schema/';
  49628. protected $uriRetriever;
  49629. protected $uriResolver;
  49630. protected $schemas = array();
  49631. public function __construct(
  49632. UriRetrieverInterface $uriRetriever = null,
  49633. UriResolverInterface $uriResolver = null
  49634. ) {
  49635. $this->uriRetriever = $uriRetriever ?: new UriRetriever();
  49636. $this->uriResolver = $uriResolver ?: new UriResolver();
  49637. }
  49638. public function getUriRetriever()
  49639. {
  49640. return $this->uriRetriever;
  49641. }
  49642. public function getUriResolver()
  49643. {
  49644. return $this->uriResolver;
  49645. }
  49646. public function addSchema($id, $schema = null)
  49647. {
  49648. if (is_null($schema) && $id !== self::INTERNAL_PROVIDED_SCHEMA_URI) {
  49649. $schema = $this->uriRetriever->retrieve($id);
  49650. }
  49651. if (is_array($schema)) {
  49652. $schema = BaseConstraint::arrayToObjectRecursive($schema);
  49653. }
  49654. if (is_object($schema) && property_exists($schema, 'id')) {
  49655. if ($schema->id == 'http://json-schema.org/draft-04/schema#') {
  49656. $schema->properties->id->format = 'uri-reference';
  49657. } elseif ($schema->id == 'http://json-schema.org/draft-03/schema#') {
  49658. $schema->properties->id->format = 'uri-reference';
  49659. $schema->properties->{'$ref'}->format = 'uri-reference';
  49660. }
  49661. }
  49662. $this->expandRefs($schema, $id);
  49663. $this->schemas[$id] = $schema;
  49664. }
  49665. private function expandRefs(&$schema, $base = null)
  49666. {
  49667. if (!is_object($schema)) {
  49668. if (is_array($schema)) {
  49669. foreach ($schema as &$member) {
  49670. $this->expandRefs($member, $base);
  49671. }
  49672. }
  49673. return;
  49674. }
  49675. if (property_exists($schema, 'id') && is_string($schema->id) && $base != $schema->id) {
  49676. $base = $this->uriResolver->resolve($schema->id, $base);
  49677. }
  49678. if (property_exists($schema, '$ref') && is_string($schema->{'$ref'})) {
  49679. $refPointer = new JsonPointer($this->uriResolver->resolve($schema->{'$ref'}, $base));
  49680. $schema->{'$ref'} = (string) $refPointer;
  49681. }
  49682. foreach ($schema as &$member) {
  49683. $this->expandRefs($member, $base);
  49684. }
  49685. }
  49686. public function getSchema($id)
  49687. {
  49688. if (!array_key_exists($id, $this->schemas)) {
  49689. $this->addSchema($id);
  49690. }
  49691. return $this->schemas[$id];
  49692. }
  49693. public function resolveRef($ref)
  49694. {
  49695. $jsonPointer = new JsonPointer($ref);
  49696. $fileName = $jsonPointer->getFilename();
  49697. if (!strlen($fileName)) {
  49698. throw new UnresolvableJsonPointerException(sprintf(
  49699. "Could not resolve fragment '%s': no file is defined",
  49700. $jsonPointer->getPropertyPathAsString()
  49701. ));
  49702. }
  49703. $refSchema = $this->getSchema($fileName);
  49704. foreach ($jsonPointer->getPropertyPaths() as $path) {
  49705. if (is_object($refSchema) && property_exists($refSchema, $path)) {
  49706. $refSchema = $this->resolveRefSchema($refSchema->{$path});
  49707. } elseif (is_array($refSchema) && array_key_exists($path, $refSchema)) {
  49708. $refSchema = $this->resolveRefSchema($refSchema[$path]);
  49709. } else {
  49710. throw new UnresolvableJsonPointerException(sprintf(
  49711. 'File: %s is found, but could not resolve fragment: %s',
  49712. $jsonPointer->getFilename(),
  49713. $jsonPointer->getPropertyPathAsString()
  49714. ));
  49715. }
  49716. }
  49717. return $refSchema;
  49718. }
  49719. public function resolveRefSchema($refSchema)
  49720. {
  49721. if (is_object($refSchema) && property_exists($refSchema, '$ref') && is_string($refSchema->{'$ref'})) {
  49722. $newSchema = $this->resolveRef($refSchema->{'$ref'});
  49723. $refSchema = (object) (get_object_vars($refSchema) + get_object_vars($newSchema));
  49724. unset($refSchema->{'$ref'});
  49725. }
  49726. return $refSchema;
  49727. }
  49728. }
  49729. <?php
  49730. namespace JsonSchema;
  49731. interface SchemaStorageInterface
  49732. {
  49733. public function addSchema($id, $schema = null);
  49734. public function getSchema($id);
  49735. public function resolveRef($ref);
  49736. public function resolveRefSchema($refSchema);
  49737. }
  49738. <?php
  49739. namespace JsonSchema\Uri\Retrievers;
  49740. abstract class AbstractRetriever implements UriRetrieverInterface
  49741. {
  49742. protected $contentType;
  49743. public function getContentType()
  49744. {
  49745. return $this->contentType;
  49746. }
  49747. }
  49748. <?php
  49749. namespace JsonSchema\Uri\Retrievers;
  49750. use JsonSchema\Exception\RuntimeException;
  49751. use JsonSchema\Validator;
  49752. class Curl extends AbstractRetriever
  49753. {
  49754. protected $messageBody;
  49755. public function __construct()
  49756. {
  49757. if (!function_exists('curl_init')) {
  49758. throw new RuntimeException('cURL not installed');
  49759. }
  49760. }
  49761. public function retrieve($uri)
  49762. {
  49763. $ch = curl_init();
  49764. curl_setopt($ch, CURLOPT_URL, $uri);
  49765. curl_setopt($ch, CURLOPT_HEADER, true);
  49766. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  49767. curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: ' . Validator::SCHEMA_MEDIA_TYPE));
  49768. $response = curl_exec($ch);
  49769. if (false === $response) {
  49770. throw new \JsonSchema\Exception\ResourceNotFoundException('JSON schema not found');
  49771. }
  49772. $this->fetchMessageBody($response);
  49773. $this->fetchContentType($response);
  49774. curl_close($ch);
  49775. return $this->messageBody;
  49776. }
  49777. private function fetchMessageBody($response)
  49778. {
  49779. preg_match("/(?:\r\n){2}(.*)$/ms", $response, $match);
  49780. $this->messageBody = $match[1];
  49781. }
  49782. protected function fetchContentType($response)
  49783. {
  49784. if (0 < preg_match("/Content-Type:(\V*)/ims", $response, $match)) {
  49785. $this->contentType = trim($match[1]);
  49786. return true;
  49787. }
  49788. return false;
  49789. }
  49790. }
  49791. <?php
  49792. namespace JsonSchema\Uri\Retrievers;
  49793. use JsonSchema\Exception\ResourceNotFoundException;
  49794. class FileGetContents extends AbstractRetriever
  49795. {
  49796. protected $messageBody;
  49797. public function retrieve($uri)
  49798. {
  49799. $errorMessage = null;
  49800. set_error_handler(function ($errno, $errstr) use (&$errorMessage) {
  49801. $errorMessage = $errstr;
  49802. });
  49803. $response = file_get_contents($uri);
  49804. restore_error_handler();
  49805. if ($errorMessage) {
  49806. throw new ResourceNotFoundException($errorMessage);
  49807. }
  49808. if (false === $response) {
  49809. throw new ResourceNotFoundException('JSON schema not found at ' . $uri);
  49810. }
  49811. if ($response == ''
  49812. && substr($uri, 0, 7) == 'file://' && substr($uri, -1) == '/'
  49813. ) {
  49814. throw new ResourceNotFoundException('JSON schema not found at ' . $uri);
  49815. }
  49816. $this->messageBody = $response;
  49817. if (!empty($http_response_header)) {
  49818. $this->fetchContentType($http_response_header);
  49819. } else {
  49820. $this->contentType = null;
  49821. }
  49822. return $this->messageBody;
  49823. }
  49824. private function fetchContentType(array $headers)
  49825. {
  49826. foreach ($headers as $header) {
  49827. if ($this->contentType = self::getContentTypeMatchInHeader($header)) {
  49828. return true;
  49829. }
  49830. }
  49831. return false;
  49832. }
  49833. protected static function getContentTypeMatchInHeader($header)
  49834. {
  49835. if (0 < preg_match("/Content-Type:(\V*)/ims", $header, $match)) {
  49836. return trim($match[1]);
  49837. }
  49838. return null;
  49839. }
  49840. }
  49841. <?php
  49842. namespace JsonSchema\Uri\Retrievers;
  49843. use JsonSchema\Validator;
  49844. class PredefinedArray extends AbstractRetriever
  49845. {
  49846. private $schemas;
  49847. public function __construct(array $schemas, $contentType = Validator::SCHEMA_MEDIA_TYPE)
  49848. {
  49849. $this->schemas = $schemas;
  49850. $this->contentType = $contentType;
  49851. }
  49852. public function retrieve($uri)
  49853. {
  49854. if (!array_key_exists($uri, $this->schemas)) {
  49855. throw new \JsonSchema\Exception\ResourceNotFoundException(sprintf(
  49856. 'The JSON schema "%s" was not found.',
  49857. $uri
  49858. ));
  49859. }
  49860. return $this->schemas[$uri];
  49861. }
  49862. }
  49863. <?php
  49864. namespace JsonSchema\Uri\Retrievers;
  49865. interface UriRetrieverInterface
  49866. {
  49867. public function retrieve($uri);
  49868. public function getContentType();
  49869. }
  49870. <?php
  49871. namespace JsonSchema\Uri;
  49872. use JsonSchema\Exception\UriResolverException;
  49873. use JsonSchema\UriResolverInterface;
  49874. class UriResolver implements UriResolverInterface
  49875. {
  49876. public function parse($uri)
  49877. {
  49878. preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
  49879. $components = array();
  49880. if (5 < count($match)) {
  49881. $components = array(
  49882. 'scheme' => $match[2],
  49883. 'authority' => $match[4],
  49884. 'path' => $match[5]
  49885. );
  49886. }
  49887. if (7 < count($match)) {
  49888. $components['query'] = $match[7];
  49889. }
  49890. if (9 < count($match)) {
  49891. $components['fragment'] = $match[9];
  49892. }
  49893. return $components;
  49894. }
  49895. public function generate(array $components)
  49896. {
  49897. $uri = $components['scheme'] . '://'
  49898. . $components['authority']
  49899. . $components['path'];
  49900. if (array_key_exists('query', $components) && strlen($components['query'])) {
  49901. $uri .= '?' . $components['query'];
  49902. }
  49903. if (array_key_exists('fragment', $components)) {
  49904. $uri .= '#' . $components['fragment'];
  49905. }
  49906. return $uri;
  49907. }
  49908. public function resolve($uri, $baseUri = null)
  49909. {
  49910. if (
  49911. !is_null($baseUri) &&
  49912. !filter_var($baseUri, \FILTER_VALIDATE_URL) &&
  49913. !preg_match('|^[^/]+://|u', $baseUri)
  49914. ) {
  49915. if (is_file($baseUri)) {
  49916. $baseUri = 'file://' . realpath($baseUri);
  49917. } elseif (is_dir($baseUri)) {
  49918. $baseUri = 'file://' . realpath($baseUri) . '/';
  49919. } else {
  49920. $baseUri = 'file://' . getcwd() . '/' . $baseUri;
  49921. }
  49922. }
  49923. if ($uri == '') {
  49924. return $baseUri;
  49925. }
  49926. $components = $this->parse($uri);
  49927. $path = $components['path'];
  49928. if (!empty($components['scheme'])) {
  49929. return $uri;
  49930. }
  49931. $baseComponents = $this->parse($baseUri);
  49932. $basePath = $baseComponents['path'];
  49933. $baseComponents['path'] = self::combineRelativePathWithBasePath($path, $basePath);
  49934. if (isset($components['fragment'])) {
  49935. $baseComponents['fragment'] = $components['fragment'];
  49936. }
  49937. return $this->generate($baseComponents);
  49938. }
  49939. public static function combineRelativePathWithBasePath($relativePath, $basePath)
  49940. {
  49941. $relativePath = self::normalizePath($relativePath);
  49942. if ($relativePath == '') {
  49943. return $basePath;
  49944. }
  49945. if ($relativePath[0] == '/') {
  49946. return $relativePath;
  49947. }
  49948. $basePathSegments = explode('/', $basePath);
  49949. preg_match('|^/?(\.\./(?:\./)*)*|', $relativePath, $match);
  49950. $numLevelUp = strlen($match[0]) /3 + 1;
  49951. if ($numLevelUp >= count($basePathSegments)) {
  49952. throw new UriResolverException(sprintf("Unable to resolve URI '%s' from base '%s'", $relativePath, $basePath));
  49953. }
  49954. $basePathSegments = array_slice($basePathSegments, 0, -$numLevelUp);
  49955. $path = preg_replace('|^/?(\.\./(\./)*)*|', '', $relativePath);
  49956. return implode('/', $basePathSegments) . '/' . $path;
  49957. }
  49958. private static function normalizePath($path)
  49959. {
  49960. $path = preg_replace('|((?<!\.)\./)*|', '', $path);
  49961. $path = preg_replace('|//|', '/', $path);
  49962. return $path;
  49963. }
  49964. public function isValid($uri)
  49965. {
  49966. $components = $this->parse($uri);
  49967. return !empty($components);
  49968. }
  49969. }
  49970. <?php
  49971. namespace JsonSchema\Uri;
  49972. use JsonSchema\Exception\InvalidSchemaMediaTypeException;
  49973. use JsonSchema\Exception\JsonDecodingException;
  49974. use JsonSchema\Exception\ResourceNotFoundException;
  49975. use JsonSchema\Uri\Retrievers\FileGetContents;
  49976. use JsonSchema\Uri\Retrievers\UriRetrieverInterface;
  49977. use JsonSchema\UriRetrieverInterface as BaseUriRetrieverInterface;
  49978. use JsonSchema\Validator;
  49979. class UriRetriever implements BaseUriRetrieverInterface
  49980. {
  49981. protected $translationMap = array(
  49982. '|^https?://json-schema.org/draft-(0[34])/schema#?|' => 'package://dist/schema/json-schema-draft-$1.json'
  49983. );
  49984. protected $allowedInvalidContentTypeEndpoints = array(
  49985. 'http://json-schema.org/',
  49986. 'https://json-schema.org/'
  49987. );
  49988. protected $uriRetriever = null;
  49989. private $schemaCache = array();
  49990. public function addInvalidContentTypeEndpoint($endpoint)
  49991. {
  49992. $this->allowedInvalidContentTypeEndpoints[] = $endpoint;
  49993. }
  49994. public function confirmMediaType($uriRetriever, $uri)
  49995. {
  49996. $contentType = $uriRetriever->getContentType();
  49997. if (is_null($contentType)) {
  49998. return;
  49999. }
  50000. if (in_array($contentType, array(Validator::SCHEMA_MEDIA_TYPE, 'application/json'))) {
  50001. return;
  50002. }
  50003. foreach ($this->allowedInvalidContentTypeEndpoints as $endpoint) {
  50004. if (strpos($uri, $endpoint) === 0) {
  50005. return true;
  50006. }
  50007. }
  50008. throw new InvalidSchemaMediaTypeException(sprintf('Media type %s expected', Validator::SCHEMA_MEDIA_TYPE));
  50009. }
  50010. public function getUriRetriever()
  50011. {
  50012. if (is_null($this->uriRetriever)) {
  50013. $this->setUriRetriever(new FileGetContents());
  50014. }
  50015. return $this->uriRetriever;
  50016. }
  50017. public function resolvePointer($jsonSchema, $uri)
  50018. {
  50019. $resolver = new UriResolver();
  50020. $parsed = $resolver->parse($uri);
  50021. if (empty($parsed['fragment'])) {
  50022. return $jsonSchema;
  50023. }
  50024. $path = explode('/', $parsed['fragment']);
  50025. while ($path) {
  50026. $pathElement = array_shift($path);
  50027. if (!empty($pathElement)) {
  50028. $pathElement = str_replace('~1', '/', $pathElement);
  50029. $pathElement = str_replace('~0', '~', $pathElement);
  50030. if (!empty($jsonSchema->$pathElement)) {
  50031. $jsonSchema = $jsonSchema->$pathElement;
  50032. } else {
  50033. throw new ResourceNotFoundException(
  50034. 'Fragment "' . $parsed['fragment'] . '" not found'
  50035. . ' in ' . $uri
  50036. );
  50037. }
  50038. if (!is_object($jsonSchema)) {
  50039. throw new ResourceNotFoundException(
  50040. 'Fragment part "' . $pathElement . '" is no object '
  50041. . ' in ' . $uri
  50042. );
  50043. }
  50044. }
  50045. }
  50046. return $jsonSchema;
  50047. }
  50048. public function retrieve($uri, $baseUri = null, $translate = true)
  50049. {
  50050. $resolver = new UriResolver();
  50051. $resolvedUri = $fetchUri = $resolver->resolve($uri, $baseUri);
  50052. $arParts = $resolver->parse($resolvedUri);
  50053. if (isset($arParts['fragment'])) {
  50054. unset($arParts['fragment']);
  50055. $fetchUri = $resolver->generate($arParts);
  50056. }
  50057. if ($translate) {
  50058. $fetchUri = $this->translate($fetchUri);
  50059. }
  50060. $jsonSchema = $this->loadSchema($fetchUri);
  50061. $jsonSchema = $this->resolvePointer($jsonSchema, $resolvedUri);
  50062. if ($jsonSchema instanceof \stdClass) {
  50063. $jsonSchema->id = $resolvedUri;
  50064. }
  50065. return $jsonSchema;
  50066. }
  50067. protected function loadSchema($fetchUri)
  50068. {
  50069. if (isset($this->schemaCache[$fetchUri])) {
  50070. return $this->schemaCache[$fetchUri];
  50071. }
  50072. $uriRetriever = $this->getUriRetriever();
  50073. $contents = $this->uriRetriever->retrieve($fetchUri);
  50074. $this->confirmMediaType($uriRetriever, $fetchUri);
  50075. $jsonSchema = json_decode($contents);
  50076. if (JSON_ERROR_NONE < $error = json_last_error()) {
  50077. throw new JsonDecodingException($error);
  50078. }
  50079. $this->schemaCache[$fetchUri] = $jsonSchema;
  50080. return $jsonSchema;
  50081. }
  50082. public function setUriRetriever(UriRetrieverInterface $uriRetriever)
  50083. {
  50084. $this->uriRetriever = $uriRetriever;
  50085. return $this;
  50086. }
  50087. public function parse($uri)
  50088. {
  50089. preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
  50090. $components = array();
  50091. if (5 < count($match)) {
  50092. $components = array(
  50093. 'scheme' => $match[2],
  50094. 'authority' => $match[4],
  50095. 'path' => $match[5]
  50096. );
  50097. }
  50098. if (7 < count($match)) {
  50099. $components['query'] = $match[7];
  50100. }
  50101. if (9 < count($match)) {
  50102. $components['fragment'] = $match[9];
  50103. }
  50104. return $components;
  50105. }
  50106. public function generate(array $components)
  50107. {
  50108. $uri = $components['scheme'] . '://'
  50109. . $components['authority']
  50110. . $components['path'];
  50111. if (array_key_exists('query', $components)) {
  50112. $uri .= $components['query'];
  50113. }
  50114. if (array_key_exists('fragment', $components)) {
  50115. $uri .= $components['fragment'];
  50116. }
  50117. return $uri;
  50118. }
  50119. public function resolve($uri, $baseUri = null)
  50120. {
  50121. $components = $this->parse($uri);
  50122. $path = $components['path'];
  50123. if ((array_key_exists('scheme', $components)) && ('http' === $components['scheme'])) {
  50124. return $uri;
  50125. }
  50126. $baseComponents = $this->parse($baseUri);
  50127. $basePath = $baseComponents['path'];
  50128. $baseComponents['path'] = UriResolver::combineRelativePathWithBasePath($path, $basePath);
  50129. return $this->generate($baseComponents);
  50130. }
  50131. public function isValid($uri)
  50132. {
  50133. $components = $this->parse($uri);
  50134. return !empty($components);
  50135. }
  50136. public function setTranslation($from, $to)
  50137. {
  50138. $this->translationMap[$from] = $to;
  50139. }
  50140. public function translate($uri)
  50141. {
  50142. foreach ($this->translationMap as $from => $to) {
  50143. $uri = preg_replace($from, $to, $uri);
  50144. }
  50145. $uri = preg_replace('|^package://|', sprintf('file://%s/', realpath(__DIR__ . '/../../..')), $uri);
  50146. return $uri;
  50147. }
  50148. }
  50149. <?php
  50150. namespace JsonSchema;
  50151. interface UriResolverInterface
  50152. {
  50153. public function resolve($uri, $baseUri = null);
  50154. }
  50155. <?php
  50156. namespace JsonSchema;
  50157. interface UriRetrieverInterface
  50158. {
  50159. public function retrieve($uri, $baseUri = null);
  50160. }
  50161. <?php
  50162. namespace JsonSchema;
  50163. use JsonSchema\Constraints\BaseConstraint;
  50164. use JsonSchema\Constraints\Constraint;
  50165. class Validator extends BaseConstraint
  50166. {
  50167. const SCHEMA_MEDIA_TYPE = 'application/schema+json';
  50168. const ERROR_NONE = 0x00000000;
  50169. const ERROR_ALL = 0xFFFFFFFF;
  50170. const ERROR_DOCUMENT_VALIDATION = 0x00000001;
  50171. const ERROR_SCHEMA_VALIDATION = 0x00000002;
  50172. public function validate(&$value, $schema = null, $checkMode = null)
  50173. {
  50174. if (is_array($schema)) {
  50175. $schema = self::arrayToObjectRecursive($schema);
  50176. }
  50177. $initialCheckMode = $this->factory->getConfig();
  50178. if ($checkMode !== null) {
  50179. $this->factory->setConfig($checkMode);
  50180. }
  50181. if (is_object($schema) && property_exists($schema, 'id')) {
  50182. $schemaURI = $schema->id;
  50183. } else {
  50184. $schemaURI = SchemaStorage::INTERNAL_PROVIDED_SCHEMA_URI;
  50185. }
  50186. $this->factory->getSchemaStorage()->addSchema($schemaURI, $schema);
  50187. $validator = $this->factory->createInstanceFor('schema');
  50188. $validator->check(
  50189. $value,
  50190. $this->factory->getSchemaStorage()->getSchema($schemaURI)
  50191. );
  50192. $this->factory->setConfig($initialCheckMode);
  50193. $this->addErrors(array_unique($validator->getErrors(), SORT_REGULAR));
  50194. return $validator->getErrorMask();
  50195. }
  50196. public function check($value, $schema)
  50197. {
  50198. return $this->validate($value, $schema);
  50199. }
  50200. public function coerce(&$value, $schema)
  50201. {
  50202. return $this->validate($value, $schema, Constraint::CHECK_MODE_COERCE_TYPES);
  50203. }
  50204. }
  50205. The MIT License (MIT)
  50206. Copyright (c) 2013-2016 container-interop
  50207. Copyright (c) 2016 PHP Framework Interoperability Group
  50208. Permission is hereby granted, free of charge, to any person obtaining a copy of
  50209. this software and associated documentation files (the "Software"), to deal in
  50210. the Software without restriction, including without limitation the rights to
  50211. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  50212. the Software, and to permit persons to whom the Software is furnished to do so,
  50213. subject to the following conditions:
  50214. The above copyright notice and this permission notice shall be included in all
  50215. copies or substantial portions of the Software.
  50216. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  50217. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  50218. FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  50219. COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  50220. IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  50221. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  50222. <?php
  50223. namespace Psr\Container;
  50224. interface ContainerExceptionInterface
  50225. {
  50226. }
  50227. <?php
  50228. declare(strict_types=1);
  50229. namespace Psr\Container;
  50230. interface ContainerInterface
  50231. {
  50232. public function get(string $id);
  50233. public function has(string $id);
  50234. }
  50235. <?php
  50236. namespace Psr\Container;
  50237. interface NotFoundExceptionInterface extends ContainerExceptionInterface
  50238. {
  50239. }
  50240. Copyright (c) 2012 PHP Framework Interoperability Group
  50241. Permission is hereby granted, free of charge, to any person obtaining a copy
  50242. of this software and associated documentation files (the "Software"), to deal
  50243. in the Software without restriction, including without limitation the rights
  50244. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  50245. copies of the Software, and to permit persons to whom the Software is
  50246. furnished to do so, subject to the following conditions:
  50247. The above copyright notice and this permission notice shall be included in
  50248. all copies or substantial portions of the Software.
  50249. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  50250. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  50251. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  50252. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  50253. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  50254. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  50255. THE SOFTWARE.
  50256. <?php
  50257. namespace Psr\Log;
  50258. abstract class AbstractLogger implements LoggerInterface
  50259. {
  50260. public function emergency($message, array $context = array())
  50261. {
  50262. $this->log(LogLevel::EMERGENCY, $message, $context);
  50263. }
  50264. public function alert($message, array $context = array())
  50265. {
  50266. $this->log(LogLevel::ALERT, $message, $context);
  50267. }
  50268. public function critical($message, array $context = array())
  50269. {
  50270. $this->log(LogLevel::CRITICAL, $message, $context);
  50271. }
  50272. public function error($message, array $context = array())
  50273. {
  50274. $this->log(LogLevel::ERROR, $message, $context);
  50275. }
  50276. public function warning($message, array $context = array())
  50277. {
  50278. $this->log(LogLevel::WARNING, $message, $context);
  50279. }
  50280. public function notice($message, array $context = array())
  50281. {
  50282. $this->log(LogLevel::NOTICE, $message, $context);
  50283. }
  50284. public function info($message, array $context = array())
  50285. {
  50286. $this->log(LogLevel::INFO, $message, $context);
  50287. }
  50288. public function debug($message, array $context = array())
  50289. {
  50290. $this->log(LogLevel::DEBUG, $message, $context);
  50291. }
  50292. }
  50293. <?php
  50294. namespace Psr\Log;
  50295. class InvalidArgumentException extends \InvalidArgumentException
  50296. {
  50297. }
  50298. <?php
  50299. namespace Psr\Log;
  50300. class LogLevel
  50301. {
  50302. const EMERGENCY = 'emergency';
  50303. const ALERT = 'alert';
  50304. const CRITICAL = 'critical';
  50305. const ERROR = 'error';
  50306. const WARNING = 'warning';
  50307. const NOTICE = 'notice';
  50308. const INFO = 'info';
  50309. const DEBUG = 'debug';
  50310. }
  50311. <?php
  50312. namespace Psr\Log;
  50313. interface LoggerAwareInterface
  50314. {
  50315. public function setLogger(LoggerInterface $logger);
  50316. }
  50317. <?php
  50318. namespace Psr\Log;
  50319. trait LoggerAwareTrait
  50320. {
  50321. protected $logger;
  50322. public function setLogger(LoggerInterface $logger)
  50323. {
  50324. $this->logger = $logger;
  50325. }
  50326. }
  50327. <?php
  50328. namespace Psr\Log;
  50329. interface LoggerInterface
  50330. {
  50331. public function emergency($message, array $context = array());
  50332. public function alert($message, array $context = array());
  50333. public function critical($message, array $context = array());
  50334. public function error($message, array $context = array());
  50335. public function warning($message, array $context = array());
  50336. public function notice($message, array $context = array());
  50337. public function info($message, array $context = array());
  50338. public function debug($message, array $context = array());
  50339. public function log($level, $message, array $context = array());
  50340. }
  50341. <?php
  50342. namespace Psr\Log;
  50343. trait LoggerTrait
  50344. {
  50345. public function emergency($message, array $context = array())
  50346. {
  50347. $this->log(LogLevel::EMERGENCY, $message, $context);
  50348. }
  50349. public function alert($message, array $context = array())
  50350. {
  50351. $this->log(LogLevel::ALERT, $message, $context);
  50352. }
  50353. public function critical($message, array $context = array())
  50354. {
  50355. $this->log(LogLevel::CRITICAL, $message, $context);
  50356. }
  50357. public function error($message, array $context = array())
  50358. {
  50359. $this->log(LogLevel::ERROR, $message, $context);
  50360. }
  50361. public function warning($message, array $context = array())
  50362. {
  50363. $this->log(LogLevel::WARNING, $message, $context);
  50364. }
  50365. public function notice($message, array $context = array())
  50366. {
  50367. $this->log(LogLevel::NOTICE, $message, $context);
  50368. }
  50369. public function info($message, array $context = array())
  50370. {
  50371. $this->log(LogLevel::INFO, $message, $context);
  50372. }
  50373. public function debug($message, array $context = array())
  50374. {
  50375. $this->log(LogLevel::DEBUG, $message, $context);
  50376. }
  50377. abstract public function log($level, $message, array $context = array());
  50378. }
  50379. <?php
  50380. namespace Psr\Log;
  50381. class NullLogger extends AbstractLogger
  50382. {
  50383. public function log($level, $message, array $context = array())
  50384. {
  50385. }
  50386. }
  50387. <?php
  50388. namespace Psr\Log\Test;
  50389. class DummyTest
  50390. {
  50391. public function __toString()
  50392. {
  50393. return 'DummyTest';
  50394. }
  50395. }
  50396. <?php
  50397. namespace Psr\Log\Test;
  50398. use Psr\Log\LoggerInterface;
  50399. use Psr\Log\LogLevel;
  50400. use PHPUnit\Framework\TestCase;
  50401. abstract class LoggerInterfaceTest extends TestCase
  50402. {
  50403. abstract public function getLogger();
  50404. abstract public function getLogs();
  50405. public function testImplements()
  50406. {
  50407. $this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger());
  50408. }
  50409. public function testLogsAtAllLevels($level, $message)
  50410. {
  50411. $logger = $this->getLogger();
  50412. $logger->{$level}($message, array('user' => 'Bob'));
  50413. $logger->log($level, $message, array('user' => 'Bob'));
  50414. $expected = array(
  50415. $level.' message of level '.$level.' with context: Bob',
  50416. $level.' message of level '.$level.' with context: Bob',
  50417. );
  50418. $this->assertEquals($expected, $this->getLogs());
  50419. }
  50420. public function provideLevelsAndMessages()
  50421. {
  50422. return array(
  50423. LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'),
  50424. LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'),
  50425. LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'),
  50426. LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'),
  50427. LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'),
  50428. LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'),
  50429. LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'),
  50430. LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'),
  50431. );
  50432. }
  50433. public function testThrowsOnInvalidLevel()
  50434. {
  50435. $logger = $this->getLogger();
  50436. $logger->log('invalid level', 'Foo');
  50437. }
  50438. public function testContextReplacement()
  50439. {
  50440. $logger = $this->getLogger();
  50441. $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar'));
  50442. $expected = array('info {Message {nothing} Bob Bar a}');
  50443. $this->assertEquals($expected, $this->getLogs());
  50444. }
  50445. public function testObjectCastToString()
  50446. {
  50447. if (method_exists($this, 'createPartialMock')) {
  50448. $dummy = $this->createPartialMock('Psr\Log\Test\DummyTest', array('__toString'));
  50449. } else {
  50450. $dummy = $this->getMock('Psr\Log\Test\DummyTest', array('__toString'));
  50451. }
  50452. $dummy->expects($this->once())
  50453. ->method('__toString')
  50454. ->will($this->returnValue('DUMMY'));
  50455. $this->getLogger()->warning($dummy);
  50456. $expected = array('warning DUMMY');
  50457. $this->assertEquals($expected, $this->getLogs());
  50458. }
  50459. public function testContextCanContainAnything()
  50460. {
  50461. $closed = fopen('php://memory', 'r');
  50462. fclose($closed);
  50463. $context = array(
  50464. 'bool' => true,
  50465. 'null' => null,
  50466. 'string' => 'Foo',
  50467. 'int' => 0,
  50468. 'float' => 0.5,
  50469. 'nested' => array('with object' => new DummyTest),
  50470. 'object' => new \DateTime,
  50471. 'resource' => fopen('php://memory', 'r'),
  50472. 'closed' => $closed,
  50473. );
  50474. $this->getLogger()->warning('Crazy context data', $context);
  50475. $expected = array('warning Crazy context data');
  50476. $this->assertEquals($expected, $this->getLogs());
  50477. }
  50478. public function testContextExceptionKeyCanBeExceptionOrOtherValues()
  50479. {
  50480. $logger = $this->getLogger();
  50481. $logger->warning('Random message', array('exception' => 'oops'));
  50482. $logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail')));
  50483. $expected = array(
  50484. 'warning Random message',
  50485. 'critical Uncaught Exception!'
  50486. );
  50487. $this->assertEquals($expected, $this->getLogs());
  50488. }
  50489. }
  50490. <?php
  50491. namespace Psr\Log\Test;
  50492. use Psr\Log\AbstractLogger;
  50493. class TestLogger extends AbstractLogger
  50494. {
  50495. public $records = [];
  50496. public $recordsByLevel = [];
  50497. public function log($level, $message, array $context = [])
  50498. {
  50499. $record = [
  50500. 'level' => $level,
  50501. 'message' => $message,
  50502. 'context' => $context,
  50503. ];
  50504. $this->recordsByLevel[$record['level']][] = $record;
  50505. $this->records[] = $record;
  50506. }
  50507. public function hasRecords($level)
  50508. {
  50509. return isset($this->recordsByLevel[$level]);
  50510. }
  50511. public function hasRecord($record, $level)
  50512. {
  50513. if (is_string($record)) {
  50514. $record = ['message' => $record];
  50515. }
  50516. return $this->hasRecordThatPasses(function ($rec) use ($record) {
  50517. if ($rec['message'] !== $record['message']) {
  50518. return false;
  50519. }
  50520. if (isset($record['context']) && $rec['context'] !== $record['context']) {
  50521. return false;
  50522. }
  50523. return true;
  50524. }, $level);
  50525. }
  50526. public function hasRecordThatContains($message, $level)
  50527. {
  50528. return $this->hasRecordThatPasses(function ($rec) use ($message) {
  50529. return strpos($rec['message'], $message) !== false;
  50530. }, $level);
  50531. }
  50532. public function hasRecordThatMatches($regex, $level)
  50533. {
  50534. return $this->hasRecordThatPasses(function ($rec) use ($regex) {
  50535. return preg_match($regex, $rec['message']) > 0;
  50536. }, $level);
  50537. }
  50538. public function hasRecordThatPasses(callable $predicate, $level)
  50539. {
  50540. if (!isset($this->recordsByLevel[$level])) {
  50541. return false;
  50542. }
  50543. foreach ($this->recordsByLevel[$level] as $i => $rec) {
  50544. if (call_user_func($predicate, $rec, $i)) {
  50545. return true;
  50546. }
  50547. }
  50548. return false;
  50549. }
  50550. public function __call($method, $args)
  50551. {
  50552. if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) {
  50553. $genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3];
  50554. $level = strtolower($matches[2]);
  50555. if (method_exists($this, $genericMethod)) {
  50556. $args[] = $level;
  50557. return call_user_func_array([$this, $genericMethod], $args);
  50558. }
  50559. }
  50560. throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()');
  50561. }
  50562. public function reset()
  50563. {
  50564. $this->records = [];
  50565. $this->recordsByLevel = [];
  50566. }
  50567. }
  50568. The MIT License (MIT)
  50569. Copyright (c) 2012 Jan Sorgalla, Christian Lück, Cees-Jan Kiewiet, Chris Boden
  50570. Permission is hereby granted, free of charge, to any person
  50571. obtaining a copy of this software and associated documentation
  50572. files (the "Software"), to deal in the Software without
  50573. restriction, including without limitation the rights to use,
  50574. copy, modify, merge, publish, distribute, sublicense, and/or sell
  50575. copies of the Software, and to permit persons to whom the
  50576. Software is furnished to do so, subject to the following
  50577. conditions:
  50578. The above copyright notice and this permission notice shall be
  50579. included in all copies or substantial portions of the Software.
  50580. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  50581. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  50582. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  50583. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  50584. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  50585. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  50586. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  50587. OTHER DEALINGS IN THE SOFTWARE.
  50588. <?php
  50589. namespace React\Promise;
  50590. interface CancellablePromiseInterface extends PromiseInterface
  50591. {
  50592. public function cancel();
  50593. }
  50594. <?php
  50595. namespace React\Promise;
  50596. class CancellationQueue
  50597. {
  50598. private $started = false;
  50599. private $queue = [];
  50600. public function __invoke()
  50601. {
  50602. if ($this->started) {
  50603. return;
  50604. }
  50605. $this->started = true;
  50606. $this->drain();
  50607. }
  50608. public function enqueue($cancellable)
  50609. {
  50610. if (!\is_object($cancellable) || !\method_exists($cancellable, 'then') || !\method_exists($cancellable, 'cancel')) {
  50611. return;
  50612. }
  50613. $length = \array_push($this->queue, $cancellable);
  50614. if ($this->started && 1 === $length) {
  50615. $this->drain();
  50616. }
  50617. }
  50618. private function drain()
  50619. {
  50620. for ($i = key($this->queue); isset($this->queue[$i]); $i++) {
  50621. $cancellable = $this->queue[$i];
  50622. $exception = null;
  50623. try {
  50624. $cancellable->cancel();
  50625. } catch (\Throwable $exception) {
  50626. } catch (\Exception $exception) {
  50627. }
  50628. unset($this->queue[$i]);
  50629. if ($exception) {
  50630. throw $exception;
  50631. }
  50632. }
  50633. $this->queue = [];
  50634. }
  50635. }
  50636. <?php
  50637. namespace React\Promise;
  50638. class Deferred implements PromisorInterface
  50639. {
  50640. private $promise;
  50641. private $resolveCallback;
  50642. private $rejectCallback;
  50643. private $notifyCallback;
  50644. private $canceller;
  50645. public function __construct(callable $canceller = null)
  50646. {
  50647. $this->canceller = $canceller;
  50648. }
  50649. public function promise()
  50650. {
  50651. if (null === $this->promise) {
  50652. $this->promise = new Promise(function ($resolve, $reject, $notify) {
  50653. $this->resolveCallback = $resolve;
  50654. $this->rejectCallback = $reject;
  50655. $this->notifyCallback = $notify;
  50656. }, $this->canceller);
  50657. $this->canceller = null;
  50658. }
  50659. return $this->promise;
  50660. }
  50661. public function resolve($value = null)
  50662. {
  50663. $this->promise();
  50664. \call_user_func($this->resolveCallback, $value);
  50665. }
  50666. public function reject($reason = null)
  50667. {
  50668. $this->promise();
  50669. \call_user_func($this->rejectCallback, $reason);
  50670. }
  50671. public function notify($update = null)
  50672. {
  50673. $this->promise();
  50674. \call_user_func($this->notifyCallback, $update);
  50675. }
  50676. public function progress($update = null)
  50677. {
  50678. $this->notify($update);
  50679. }
  50680. }
  50681. <?php
  50682. namespace React\Promise\Exception;
  50683. class LengthException extends \LengthException
  50684. {
  50685. }
  50686. <?php
  50687. namespace React\Promise;
  50688. interface ExtendedPromiseInterface extends PromiseInterface
  50689. {
  50690. public function done(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null);
  50691. public function otherwise(callable $onRejected);
  50692. public function always(callable $onFulfilledOrRejected);
  50693. public function progress(callable $onProgress);
  50694. }
  50695. <?php
  50696. namespace React\Promise;
  50697. class FulfilledPromise implements ExtendedPromiseInterface, CancellablePromiseInterface
  50698. {
  50699. private $value;
  50700. public function __construct($value = null)
  50701. {
  50702. if ($value instanceof PromiseInterface) {
  50703. throw new \InvalidArgumentException('You cannot create React\Promise\FulfilledPromise with a promise. Use React\Promise\resolve($promiseOrValue) instead.');
  50704. }
  50705. $this->value = $value;
  50706. }
  50707. public function then(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null)
  50708. {
  50709. if (null === $onFulfilled) {
  50710. return $this;
  50711. }
  50712. try {
  50713. return resolve($onFulfilled($this->value));
  50714. } catch (\Throwable $exception) {
  50715. return new RejectedPromise($exception);
  50716. } catch (\Exception $exception) {
  50717. return new RejectedPromise($exception);
  50718. }
  50719. }
  50720. public function done(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null)
  50721. {
  50722. if (null === $onFulfilled) {
  50723. return;
  50724. }
  50725. $result = $onFulfilled($this->value);
  50726. if ($result instanceof ExtendedPromiseInterface) {
  50727. $result->done();
  50728. }
  50729. }
  50730. public function otherwise(callable $onRejected)
  50731. {
  50732. return $this;
  50733. }
  50734. public function always(callable $onFulfilledOrRejected)
  50735. {
  50736. return $this->then(function ($value) use ($onFulfilledOrRejected) {
  50737. return resolve($onFulfilledOrRejected())->then(function () use ($value) {
  50738. return $value;
  50739. });
  50740. });
  50741. }
  50742. public function progress(callable $onProgress)
  50743. {
  50744. return $this;
  50745. }
  50746. public function cancel()
  50747. {
  50748. }
  50749. }
  50750. <?php
  50751. namespace React\Promise;
  50752. class LazyPromise implements ExtendedPromiseInterface, CancellablePromiseInterface
  50753. {
  50754. private $factory;
  50755. private $promise;
  50756. public function __construct(callable $factory)
  50757. {
  50758. $this->factory = $factory;
  50759. }
  50760. public function then(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null)
  50761. {
  50762. return $this->promise()->then($onFulfilled, $onRejected, $onProgress);
  50763. }
  50764. public function done(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null)
  50765. {
  50766. return $this->promise()->done($onFulfilled, $onRejected, $onProgress);
  50767. }
  50768. public function otherwise(callable $onRejected)
  50769. {
  50770. return $this->promise()->otherwise($onRejected);
  50771. }
  50772. public function always(callable $onFulfilledOrRejected)
  50773. {
  50774. return $this->promise()->always($onFulfilledOrRejected);
  50775. }
  50776. public function progress(callable $onProgress)
  50777. {
  50778. return $this->promise()->progress($onProgress);
  50779. }
  50780. public function cancel()
  50781. {
  50782. return $this->promise()->cancel();
  50783. }
  50784. public function promise()
  50785. {
  50786. if (null === $this->promise) {
  50787. try {
  50788. $this->promise = resolve(\call_user_func($this->factory));
  50789. } catch (\Throwable $exception) {
  50790. $this->promise = new RejectedPromise($exception);
  50791. } catch (\Exception $exception) {
  50792. $this->promise = new RejectedPromise($exception);
  50793. }
  50794. }
  50795. return $this->promise;
  50796. }
  50797. }
  50798. <?php
  50799. namespace React\Promise;
  50800. class Promise implements ExtendedPromiseInterface, CancellablePromiseInterface
  50801. {
  50802. private $canceller;
  50803. private $result;
  50804. private $handlers = [];
  50805. private $progressHandlers = [];
  50806. private $requiredCancelRequests = 0;
  50807. private $cancelRequests = 0;
  50808. public function __construct(callable $resolver, callable $canceller = null)
  50809. {
  50810. $this->canceller = $canceller;
  50811. $cb = $resolver;
  50812. $resolver = $canceller = null;
  50813. $this->call($cb);
  50814. }
  50815. public function then(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null)
  50816. {
  50817. if (null !== $this->result) {
  50818. return $this->result->then($onFulfilled, $onRejected, $onProgress);
  50819. }
  50820. if (null === $this->canceller) {
  50821. return new static($this->resolver($onFulfilled, $onRejected, $onProgress));
  50822. }
  50823. $parent = $this;
  50824. ++$parent->requiredCancelRequests;
  50825. return new static(
  50826. $this->resolver($onFulfilled, $onRejected, $onProgress),
  50827. static function () use (&$parent) {
  50828. if (++$parent->cancelRequests >= $parent->requiredCancelRequests) {
  50829. $parent->cancel();
  50830. }
  50831. $parent = null;
  50832. }
  50833. );
  50834. }
  50835. public function done(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null)
  50836. {
  50837. if (null !== $this->result) {
  50838. return $this->result->done($onFulfilled, $onRejected, $onProgress);
  50839. }
  50840. $this->handlers[] = static function (ExtendedPromiseInterface $promise) use ($onFulfilled, $onRejected) {
  50841. $promise
  50842. ->done($onFulfilled, $onRejected);
  50843. };
  50844. if ($onProgress) {
  50845. $this->progressHandlers[] = $onProgress;
  50846. }
  50847. }
  50848. public function otherwise(callable $onRejected)
  50849. {
  50850. return $this->then(null, static function ($reason) use ($onRejected) {
  50851. if (!_checkTypehint($onRejected, $reason)) {
  50852. return new RejectedPromise($reason);
  50853. }
  50854. return $onRejected($reason);
  50855. });
  50856. }
  50857. public function always(callable $onFulfilledOrRejected)
  50858. {
  50859. return $this->then(static function ($value) use ($onFulfilledOrRejected) {
  50860. return resolve($onFulfilledOrRejected())->then(function () use ($value) {
  50861. return $value;
  50862. });
  50863. }, static function ($reason) use ($onFulfilledOrRejected) {
  50864. return resolve($onFulfilledOrRejected())->then(function () use ($reason) {
  50865. return new RejectedPromise($reason);
  50866. });
  50867. });
  50868. }
  50869. public function progress(callable $onProgress)
  50870. {
  50871. return $this->then(null, null, $onProgress);
  50872. }
  50873. public function cancel()
  50874. {
  50875. if (null === $this->canceller || null !== $this->result) {
  50876. return;
  50877. }
  50878. $canceller = $this->canceller;
  50879. $this->canceller = null;
  50880. $this->call($canceller);
  50881. }
  50882. private function resolver(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null)
  50883. {
  50884. return function ($resolve, $reject, $notify) use ($onFulfilled, $onRejected, $onProgress) {
  50885. if ($onProgress) {
  50886. $progressHandler = static function ($update) use ($notify, $onProgress) {
  50887. try {
  50888. $notify($onProgress($update));
  50889. } catch (\Throwable $e) {
  50890. $notify($e);
  50891. } catch (\Exception $e) {
  50892. $notify($e);
  50893. }
  50894. };
  50895. } else {
  50896. $progressHandler = $notify;
  50897. }
  50898. $this->handlers[] = static function (ExtendedPromiseInterface $promise) use ($onFulfilled, $onRejected, $resolve, $reject, $progressHandler) {
  50899. $promise
  50900. ->then($onFulfilled, $onRejected)
  50901. ->done($resolve, $reject, $progressHandler);
  50902. };
  50903. $this->progressHandlers[] = $progressHandler;
  50904. };
  50905. }
  50906. private function reject($reason = null)
  50907. {
  50908. if (null !== $this->result) {
  50909. return;
  50910. }
  50911. $this->settle(reject($reason));
  50912. }
  50913. private function settle(ExtendedPromiseInterface $promise)
  50914. {
  50915. $promise = $this->unwrap($promise);
  50916. if ($promise === $this) {
  50917. $promise = new RejectedPromise(
  50918. new \LogicException('Cannot resolve a promise with itself.')
  50919. );
  50920. }
  50921. $handlers = $this->handlers;
  50922. $this->progressHandlers = $this->handlers = [];
  50923. $this->result = $promise;
  50924. $this->canceller = null;
  50925. foreach ($handlers as $handler) {
  50926. $handler($promise);
  50927. }
  50928. }
  50929. private function unwrap($promise)
  50930. {
  50931. $promise = $this->extract($promise);
  50932. while ($promise instanceof self && null !== $promise->result) {
  50933. $promise = $this->extract($promise->result);
  50934. }
  50935. return $promise;
  50936. }
  50937. private function extract($promise)
  50938. {
  50939. if ($promise instanceof LazyPromise) {
  50940. $promise = $promise->promise();
  50941. }
  50942. return $promise;
  50943. }
  50944. private function call(callable $cb)
  50945. {
  50946. $callback = $cb;
  50947. $cb = null;
  50948. if (\is_array($callback)) {
  50949. $ref = new \ReflectionMethod($callback[0], $callback[1]);
  50950. } elseif (\is_object($callback) && !$callback instanceof \Closure) {
  50951. $ref = new \ReflectionMethod($callback, '__invoke');
  50952. } else {
  50953. $ref = new \ReflectionFunction($callback);
  50954. }
  50955. $args = $ref->getNumberOfParameters();
  50956. try {
  50957. if ($args === 0) {
  50958. $callback();
  50959. } else {
  50960. $target =& $this;
  50961. $progressHandlers =& $this->progressHandlers;
  50962. $callback(
  50963. static function ($value = null) use (&$target) {
  50964. if ($target !== null) {
  50965. $target->settle(resolve($value));
  50966. $target = null;
  50967. }
  50968. },
  50969. static function ($reason = null) use (&$target) {
  50970. if ($target !== null) {
  50971. $target->reject($reason);
  50972. $target = null;
  50973. }
  50974. },
  50975. static function ($update = null) use (&$progressHandlers) {
  50976. foreach ($progressHandlers as $handler) {
  50977. $handler($update);
  50978. }
  50979. }
  50980. );
  50981. }
  50982. } catch (\Throwable $e) {
  50983. $target = null;
  50984. $this->reject($e);
  50985. } catch (\Exception $e) {
  50986. $target = null;
  50987. $this->reject($e);
  50988. }
  50989. }
  50990. }
  50991. <?php
  50992. namespace React\Promise;
  50993. interface PromiseInterface
  50994. {
  50995. public function then(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null);
  50996. }
  50997. <?php
  50998. namespace React\Promise;
  50999. interface PromisorInterface
  51000. {
  51001. public function promise();
  51002. }
  51003. <?php
  51004. namespace React\Promise;
  51005. class RejectedPromise implements ExtendedPromiseInterface, CancellablePromiseInterface
  51006. {
  51007. private $reason;
  51008. public function __construct($reason = null)
  51009. {
  51010. if ($reason instanceof PromiseInterface) {
  51011. throw new \InvalidArgumentException('You cannot create React\Promise\RejectedPromise with a promise. Use React\Promise\reject($promiseOrValue) instead.');
  51012. }
  51013. $this->reason = $reason;
  51014. }
  51015. public function then(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null)
  51016. {
  51017. if (null === $onRejected) {
  51018. return $this;
  51019. }
  51020. try {
  51021. return resolve($onRejected($this->reason));
  51022. } catch (\Throwable $exception) {
  51023. return new RejectedPromise($exception);
  51024. } catch (\Exception $exception) {
  51025. return new RejectedPromise($exception);
  51026. }
  51027. }
  51028. public function done(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null)
  51029. {
  51030. if (null === $onRejected) {
  51031. throw UnhandledRejectionException::resolve($this->reason);
  51032. }
  51033. $result = $onRejected($this->reason);
  51034. if ($result instanceof self) {
  51035. throw UnhandledRejectionException::resolve($result->reason);
  51036. }
  51037. if ($result instanceof ExtendedPromiseInterface) {
  51038. $result->done();
  51039. }
  51040. }
  51041. public function otherwise(callable $onRejected)
  51042. {
  51043. if (!_checkTypehint($onRejected, $this->reason)) {
  51044. return $this;
  51045. }
  51046. return $this->then(null, $onRejected);
  51047. }
  51048. public function always(callable $onFulfilledOrRejected)
  51049. {
  51050. return $this->then(null, function ($reason) use ($onFulfilledOrRejected) {
  51051. return resolve($onFulfilledOrRejected())->then(function () use ($reason) {
  51052. return new RejectedPromise($reason);
  51053. });
  51054. });
  51055. }
  51056. public function progress(callable $onProgress)
  51057. {
  51058. return $this;
  51059. }
  51060. public function cancel()
  51061. {
  51062. }
  51063. }
  51064. <?php
  51065. namespace React\Promise;
  51066. class UnhandledRejectionException extends \RuntimeException
  51067. {
  51068. private $reason;
  51069. public static function resolve($reason)
  51070. {
  51071. if ($reason instanceof \Exception || $reason instanceof \Throwable) {
  51072. return $reason;
  51073. }
  51074. return new static($reason);
  51075. }
  51076. public function __construct($reason)
  51077. {
  51078. $this->reason = $reason;
  51079. $message = \sprintf('Unhandled Rejection: %s', \json_encode($reason));
  51080. parent::__construct($message, 0);
  51081. }
  51082. public function getReason()
  51083. {
  51084. return $this->reason;
  51085. }
  51086. }
  51087. <?php
  51088. namespace React\Promise;
  51089. function resolve($promiseOrValue = null)
  51090. {
  51091. if ($promiseOrValue instanceof ExtendedPromiseInterface) {
  51092. return $promiseOrValue;
  51093. }
  51094. if (\is_object($promiseOrValue) && \method_exists($promiseOrValue, 'then')) {
  51095. $canceller = null;
  51096. if (\method_exists($promiseOrValue, 'cancel')) {
  51097. $canceller = [$promiseOrValue, 'cancel'];
  51098. }
  51099. return new Promise(function ($resolve, $reject, $notify) use ($promiseOrValue) {
  51100. $promiseOrValue->then($resolve, $reject, $notify);
  51101. }, $canceller);
  51102. }
  51103. return new FulfilledPromise($promiseOrValue);
  51104. }
  51105. function reject($promiseOrValue = null)
  51106. {
  51107. if ($promiseOrValue instanceof PromiseInterface) {
  51108. return resolve($promiseOrValue)->then(function ($value) {
  51109. return new RejectedPromise($value);
  51110. });
  51111. }
  51112. return new RejectedPromise($promiseOrValue);
  51113. }
  51114. function all($promisesOrValues)
  51115. {
  51116. return map($promisesOrValues, function ($val) {
  51117. return $val;
  51118. });
  51119. }
  51120. function race($promisesOrValues)
  51121. {
  51122. $cancellationQueue = new CancellationQueue();
  51123. $cancellationQueue->enqueue($promisesOrValues);
  51124. return new Promise(function ($resolve, $reject, $notify) use ($promisesOrValues, $cancellationQueue) {
  51125. resolve($promisesOrValues)
  51126. ->done(function ($array) use ($cancellationQueue, $resolve, $reject, $notify) {
  51127. if (!is_array($array) || !$array) {
  51128. $resolve();
  51129. return;
  51130. }
  51131. foreach ($array as $promiseOrValue) {
  51132. $cancellationQueue->enqueue($promiseOrValue);
  51133. resolve($promiseOrValue)
  51134. ->done($resolve, $reject, $notify);
  51135. }
  51136. }, $reject, $notify);
  51137. }, $cancellationQueue);
  51138. }
  51139. function any($promisesOrValues)
  51140. {
  51141. return some($promisesOrValues, 1)
  51142. ->then(function ($val) {
  51143. return \array_shift($val);
  51144. });
  51145. }
  51146. function some($promisesOrValues, $howMany)
  51147. {
  51148. $cancellationQueue = new CancellationQueue();
  51149. $cancellationQueue->enqueue($promisesOrValues);
  51150. return new Promise(function ($resolve, $reject, $notify) use ($promisesOrValues, $howMany, $cancellationQueue) {
  51151. resolve($promisesOrValues)
  51152. ->done(function ($array) use ($howMany, $cancellationQueue, $resolve, $reject, $notify) {
  51153. if (!\is_array($array) || $howMany < 1) {
  51154. $resolve([]);
  51155. return;
  51156. }
  51157. $len = \count($array);
  51158. if ($len < $howMany) {
  51159. throw new Exception\LengthException(
  51160. \sprintf(
  51161. 'Input array must contain at least %d item%s but contains only %s item%s.',
  51162. $howMany,
  51163. 1 === $howMany ? '' : 's',
  51164. $len,
  51165. 1 === $len ? '' : 's'
  51166. )
  51167. );
  51168. }
  51169. $toResolve = $howMany;
  51170. $toReject = ($len - $toResolve) + 1;
  51171. $values = [];
  51172. $reasons = [];
  51173. foreach ($array as $i => $promiseOrValue) {
  51174. $fulfiller = function ($val) use ($i, &$values, &$toResolve, $toReject, $resolve) {
  51175. if ($toResolve < 1 || $toReject < 1) {
  51176. return;
  51177. }
  51178. $values[$i] = $val;
  51179. if (0 === --$toResolve) {
  51180. $resolve($values);
  51181. }
  51182. };
  51183. $rejecter = function ($reason) use ($i, &$reasons, &$toReject, $toResolve, $reject) {
  51184. if ($toResolve < 1 || $toReject < 1) {
  51185. return;
  51186. }
  51187. $reasons[$i] = $reason;
  51188. if (0 === --$toReject) {
  51189. $reject($reasons);
  51190. }
  51191. };
  51192. $cancellationQueue->enqueue($promiseOrValue);
  51193. resolve($promiseOrValue)
  51194. ->done($fulfiller, $rejecter, $notify);
  51195. }
  51196. }, $reject, $notify);
  51197. }, $cancellationQueue);
  51198. }
  51199. function map($promisesOrValues, callable $mapFunc)
  51200. {
  51201. $cancellationQueue = new CancellationQueue();
  51202. $cancellationQueue->enqueue($promisesOrValues);
  51203. return new Promise(function ($resolve, $reject, $notify) use ($promisesOrValues, $mapFunc, $cancellationQueue) {
  51204. resolve($promisesOrValues)
  51205. ->done(function ($array) use ($mapFunc, $cancellationQueue, $resolve, $reject, $notify) {
  51206. if (!\is_array($array) || !$array) {
  51207. $resolve([]);
  51208. return;
  51209. }
  51210. $toResolve = \count($array);
  51211. $values = [];
  51212. foreach ($array as $i => $promiseOrValue) {
  51213. $cancellationQueue->enqueue($promiseOrValue);
  51214. $values[$i] = null;
  51215. resolve($promiseOrValue)
  51216. ->then($mapFunc)
  51217. ->done(
  51218. function ($mapped) use ($i, &$values, &$toResolve, $resolve) {
  51219. $values[$i] = $mapped;
  51220. if (0 === --$toResolve) {
  51221. $resolve($values);
  51222. }
  51223. },
  51224. $reject,
  51225. $notify
  51226. );
  51227. }
  51228. }, $reject, $notify);
  51229. }, $cancellationQueue);
  51230. }
  51231. function reduce($promisesOrValues, callable $reduceFunc, $initialValue = null)
  51232. {
  51233. $cancellationQueue = new CancellationQueue();
  51234. $cancellationQueue->enqueue($promisesOrValues);
  51235. return new Promise(function ($resolve, $reject, $notify) use ($promisesOrValues, $reduceFunc, $initialValue, $cancellationQueue) {
  51236. resolve($promisesOrValues)
  51237. ->done(function ($array) use ($reduceFunc, $initialValue, $cancellationQueue, $resolve, $reject, $notify) {
  51238. if (!\is_array($array)) {
  51239. $array = [];
  51240. }
  51241. $total = \count($array);
  51242. $i = 0;
  51243. $wrappedReduceFunc = function ($current, $val) use ($reduceFunc, $cancellationQueue, $total, &$i) {
  51244. $cancellationQueue->enqueue($val);
  51245. return $current
  51246. ->then(function ($c) use ($reduceFunc, $total, &$i, $val) {
  51247. return resolve($val)
  51248. ->then(function ($value) use ($reduceFunc, $total, &$i, $c) {
  51249. return $reduceFunc($c, $value, $i++, $total);
  51250. });
  51251. });
  51252. };
  51253. $cancellationQueue->enqueue($initialValue);
  51254. \array_reduce($array, $wrappedReduceFunc, resolve($initialValue))
  51255. ->done($resolve, $reject, $notify);
  51256. }, $reject, $notify);
  51257. }, $cancellationQueue);
  51258. }
  51259. function _checkTypehint(callable $callback, $object)
  51260. {
  51261. if (!\is_object($object)) {
  51262. return true;
  51263. }
  51264. if (\is_array($callback)) {
  51265. $callbackReflection = new \ReflectionMethod($callback[0], $callback[1]);
  51266. } elseif (\is_object($callback) && !$callback instanceof \Closure) {
  51267. $callbackReflection = new \ReflectionMethod($callback, '__invoke');
  51268. } else {
  51269. $callbackReflection = new \ReflectionFunction($callback);
  51270. }
  51271. $parameters = $callbackReflection->getParameters();
  51272. if (!isset($parameters[0])) {
  51273. return true;
  51274. }
  51275. $expectedException = $parameters[0];
  51276. if (\PHP_VERSION_ID < 70100 || \defined('HHVM_VERSION')) {
  51277. if (!$expectedException->getClass()) {
  51278. return true;
  51279. }
  51280. return $expectedException->getClass()->isInstance($object);
  51281. }
  51282. $type = $expectedException->getType();
  51283. $isTypeUnion = true;
  51284. $types = [];
  51285. switch (true) {
  51286. case $type === null:
  51287. break;
  51288. case $type instanceof \ReflectionNamedType:
  51289. $types = [$type];
  51290. break;
  51291. case $type instanceof \ReflectionIntersectionType:
  51292. $isTypeUnion = false;
  51293. case $type instanceof \ReflectionUnionType;
  51294. $types = $type->getTypes();
  51295. break;
  51296. default:
  51297. throw new \LogicException('Unexpected return value of ReflectionParameter::getType');
  51298. }
  51299. if (empty($types)) {
  51300. return true;
  51301. }
  51302. foreach ($types as $type) {
  51303. if (!$type instanceof \ReflectionNamedType) {
  51304. throw new \LogicException('This implementation does not support groups of intersection or union types');
  51305. }
  51306. $matches = ($type->isBuiltin() && \gettype($object) === $type->getName())
  51307. || (new \ReflectionClass($type->getName()))->isInstance($object);
  51308. if ($matches) {
  51309. if ($isTypeUnion) {
  51310. return true;
  51311. }
  51312. } else {
  51313. if (!$isTypeUnion) {
  51314. return false;
  51315. }
  51316. }
  51317. }
  51318. return $isTypeUnion ? false : true;
  51319. }
  51320. <?php
  51321. if (!\function_exists('React\Promise\resolve')) {
  51322. require __DIR__.'/functions.php';
  51323. }
  51324. Copyright (c) 2011 Jordi Boggiano
  51325. Permission is hereby granted, free of charge, to any person obtaining a copy
  51326. of this software and associated documentation files (the "Software"), to deal
  51327. in the Software without restriction, including without limitation the rights
  51328. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  51329. copies of the Software, and to permit persons to whom the Software is furnished
  51330. to do so, subject to the following conditions:
  51331. The above copyright notice and this permission notice shall be included in all
  51332. copies or substantial portions of the Software.
  51333. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  51334. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  51335. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  51336. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  51337. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  51338. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  51339. THE SOFTWARE.
  51340. <?php
  51341. namespace Seld\JsonLint;
  51342. class DuplicateKeyException extends ParsingException
  51343. {
  51344. protected $details;
  51345. public function __construct($message, $key, array $details)
  51346. {
  51347. $details['key'] = $key;
  51348. parent::__construct($message, $details);
  51349. }
  51350. public function getKey()
  51351. {
  51352. return $this->details['key'];
  51353. }
  51354. public function getDetails()
  51355. {
  51356. return $this->details;
  51357. }
  51358. }
  51359. <?php
  51360. namespace Seld\JsonLint;
  51361. use stdClass;
  51362. class JsonParser
  51363. {
  51364. const DETECT_KEY_CONFLICTS = 1;
  51365. const ALLOW_DUPLICATE_KEYS = 2;
  51366. const PARSE_TO_ASSOC = 4;
  51367. private $lexer;
  51368. private $flags;
  51369. private $stack;
  51370. private $vstack;
  51371. private $lstack;
  51372. private $symbols = array(
  51373. 'error' => 2,
  51374. 'JSONString' => 3,
  51375. 'STRING' => 4,
  51376. 'JSONNumber' => 5,
  51377. 'NUMBER' => 6,
  51378. 'JSONNullLiteral' => 7,
  51379. 'NULL' => 8,
  51380. 'JSONBooleanLiteral' => 9,
  51381. 'TRUE' => 10,
  51382. 'FALSE' => 11,
  51383. 'JSONText' => 12,
  51384. 'JSONValue' => 13,
  51385. 'EOF' => 14,
  51386. 'JSONObject' => 15,
  51387. 'JSONArray' => 16,
  51388. '{' => 17,
  51389. '}' => 18,
  51390. 'JSONMemberList' => 19,
  51391. 'JSONMember' => 20,
  51392. ':' => 21,
  51393. ',' => 22,
  51394. '[' => 23,
  51395. ']' => 24,
  51396. 'JSONElementList' => 25,
  51397. '$accept' => 0,
  51398. '$end' => 1,
  51399. );
  51400. private $terminals_ = array(
  51401. 2 => "error",
  51402. 4 => "STRING",
  51403. 6 => "NUMBER",
  51404. 8 => "NULL",
  51405. 10 => "TRUE",
  51406. 11 => "FALSE",
  51407. 14 => "EOF",
  51408. 17 => "{",
  51409. 18 => "}",
  51410. 21 => ":",
  51411. 22 => ",",
  51412. 23 => "[",
  51413. 24 => "]",
  51414. );
  51415. private $productions_ = array(
  51416. 1 => array(3, 1),
  51417. 2 => array(5, 1),
  51418. 3 => array(7, 1),
  51419. 4 => array(9, 1),
  51420. 5 => array(9, 1),
  51421. 6 => array(12, 2),
  51422. 7 => array(13, 1),
  51423. 8 => array(13, 1),
  51424. 9 => array(13, 1),
  51425. 10 => array(13, 1),
  51426. 11 => array(13, 1),
  51427. 12 => array(13, 1),
  51428. 13 => array(15, 2),
  51429. 14 => array(15, 3),
  51430. 15 => array(20, 3),
  51431. 16 => array(19, 1),
  51432. 17 => array(19, 3),
  51433. 18 => array(16, 2),
  51434. 19 => array(16, 3),
  51435. 20 => array(25, 1),
  51436. 21 => array(25, 3)
  51437. );
  51438. private $table = array(
  51439. 0 => 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)),
  51440. 1 => array( 1 => array(3)),
  51441. 2 => array( 14 => array(1,16)),
  51442. 3 => array( 14 => array(2,7), 18 => array(2,7), 22 => array(2,7), 24 => array(2,7)),
  51443. 4 => array( 14 => array(2,8), 18 => array(2,8), 22 => array(2,8), 24 => array(2,8)),
  51444. 5 => array( 14 => array(2,9), 18 => array(2,9), 22 => array(2,9), 24 => array(2,9)),
  51445. 6 => array( 14 => array(2,10), 18 => array(2,10), 22 => array(2,10), 24 => array(2,10)),
  51446. 7 => array( 14 => array(2,11), 18 => array(2,11), 22 => array(2,11), 24 => array(2,11)),
  51447. 8 => array( 14 => array(2,12), 18 => array(2,12), 22 => array(2,12), 24 => array(2,12)),
  51448. 9 => array( 14 => array(2,3), 18 => array(2,3), 22 => array(2,3), 24 => array(2,3)),
  51449. 10 => array( 14 => array(2,4), 18 => array(2,4), 22 => array(2,4), 24 => array(2,4)),
  51450. 11 => array( 14 => array(2,5), 18 => array(2,5), 22 => array(2,5), 24 => array(2,5)),
  51451. 12 => array( 14 => array(2,1), 18 => array(2,1), 21 => array(2,1), 22 => array(2,1), 24 => array(2,1)),
  51452. 13 => array( 14 => array(2,2), 18 => array(2,2), 22 => array(2,2), 24 => array(2,2)),
  51453. 14 => array( 3 => 20, 4 => array(1,12), 18 => array(1,17), 19 => 18, 20 => 19 ),
  51454. 15 => 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 ),
  51455. 16 => array( 1 => array(2,6)),
  51456. 17 => array( 14 => array(2,13), 18 => array(2,13), 22 => array(2,13), 24 => array(2,13)),
  51457. 18 => array( 18 => array(1,24), 22 => array(1,25)),
  51458. 19 => array( 18 => array(2,16), 22 => array(2,16)),
  51459. 20 => array( 21 => array(1,26)),
  51460. 21 => array( 14 => array(2,18), 18 => array(2,18), 22 => array(2,18), 24 => array(2,18)),
  51461. 22 => array( 22 => array(1,28), 24 => array(1,27)),
  51462. 23 => array( 22 => array(2,20), 24 => array(2,20)),
  51463. 24 => array( 14 => array(2,14), 18 => array(2,14), 22 => array(2,14), 24 => array(2,14)),
  51464. 25 => array( 3 => 20, 4 => array(1,12), 20 => 29 ),
  51465. 26 => 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)),
  51466. 27 => array( 14 => array(2,19), 18 => array(2,19), 22 => array(2,19), 24 => array(2,19)),
  51467. 28 => 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)),
  51468. 29 => array( 18 => array(2,17), 22 => array(2,17)),
  51469. 30 => array( 18 => array(2,15), 22 => array(2,15)),
  51470. 31 => array( 22 => array(2,21), 24 => array(2,21)),
  51471. );
  51472. private $defaultActions = array(
  51473. 16 => array(2, 6)
  51474. );
  51475. public function lint($input, $flags = 0)
  51476. {
  51477. try {
  51478. $this->parse($input, $flags);
  51479. } catch (ParsingException $e) {
  51480. return $e;
  51481. }
  51482. return null;
  51483. }
  51484. public function parse($input, $flags = 0)
  51485. {
  51486. $this->failOnBOM($input);
  51487. $this->flags = $flags;
  51488. $this->stack = array(0);
  51489. $this->vstack = array(null);
  51490. $this->lstack = array();
  51491. $yytext = '';
  51492. $yylineno = 0;
  51493. $yyleng = 0;
  51494. $recovering = 0;
  51495. $this->lexer = new Lexer();
  51496. $this->lexer->setInput($input);
  51497. $yyloc = $this->lexer->yylloc;
  51498. $this->lstack[] = $yyloc;
  51499. $symbol = null;
  51500. $preErrorSymbol = null;
  51501. $action = null;
  51502. $a = null;
  51503. $r = null;
  51504. $p = null;
  51505. $len = null;
  51506. $newState = null;
  51507. $expected = null;
  51508. $errStr = null;
  51509. while (true) {
  51510. $state = $this->stack[\count($this->stack)-1];
  51511. if (isset($this->defaultActions[$state])) {
  51512. $action = $this->defaultActions[$state];
  51513. } else {
  51514. if ($symbol === null) {
  51515. $symbol = $this->lexer->lex();
  51516. }
  51517. $action = isset($this->table[$state][$symbol]) ? $this->table[$state][$symbol] : false;
  51518. }
  51519. if (!$action || !$action[0]) {
  51520. assert(isset($symbol));
  51521. if (!$recovering) {
  51522. $expected = array();
  51523. foreach ($this->table[$state] as $p => $ignore) {
  51524. if (isset($this->terminals_[$p]) && $p > 2) {
  51525. $expected[] = "'" . $this->terminals_[$p] . "'";
  51526. }
  51527. }
  51528. $message = null;
  51529. if (\in_array("'STRING'", $expected) && \in_array(substr($this->lexer->match, 0, 1), array('"', "'"))) {
  51530. $message = "Invalid string";
  51531. if ("'" === substr($this->lexer->match, 0, 1)) {
  51532. $message .= ", it appears you used single quotes instead of double quotes";
  51533. } elseif (preg_match('{".+?(\\\\[^"bfnrt/\\\\u](...)?)}', $this->lexer->getFullUpcomingInput(), $match)) {
  51534. $message .= ", it appears you have an unescaped backslash at: ".$match[1];
  51535. } elseif (preg_match('{"(?:[^"]+|\\\\")*$}m', $this->lexer->getFullUpcomingInput())) {
  51536. $message .= ", it appears you forgot to terminate a string, or attempted to write a multiline string which is invalid";
  51537. }
  51538. }
  51539. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  51540. $errStr .= $this->lexer->showPosition() . "\n";
  51541. if ($message) {
  51542. $errStr .= $message;
  51543. } else {
  51544. $errStr .= (\count($expected) > 1) ? "Expected one of: " : "Expected: ";
  51545. $errStr .= implode(', ', $expected);
  51546. }
  51547. if (',' === substr(trim($this->lexer->getPastInput()), -1)) {
  51548. $errStr .= " - It appears you have an extra trailing comma";
  51549. }
  51550. $this->parseError($errStr, array(
  51551. 'text' => $this->lexer->match,
  51552. 'token' => isset($this->terminals_[$symbol]) ? $this->terminals_[$symbol] : $symbol,
  51553. 'line' => $this->lexer->yylineno,
  51554. 'loc' => $yyloc,
  51555. 'expected' => $expected,
  51556. ));
  51557. }
  51558. if ($recovering == 3) {
  51559. if ($symbol === Lexer::EOF) {
  51560. throw new ParsingException($errStr ?: 'Parsing halted.');
  51561. }
  51562. $yyleng = $this->lexer->yyleng;
  51563. $yytext = $this->lexer->yytext;
  51564. $yylineno = $this->lexer->yylineno;
  51565. $yyloc = $this->lexer->yylloc;
  51566. $symbol = $this->lexer->lex();
  51567. }
  51568. while (true) {
  51569. if (\array_key_exists(Lexer::T_ERROR, $this->table[$state])) {
  51570. break;
  51571. }
  51572. if ($state == 0) {
  51573. throw new ParsingException($errStr ?: 'Parsing halted.');
  51574. }
  51575. $this->popStack(1);
  51576. $state = $this->stack[\count($this->stack)-1];
  51577. }
  51578. $preErrorSymbol = $symbol;
  51579. $symbol = Lexer::T_ERROR;
  51580. $state = $this->stack[\count($this->stack)-1];
  51581. $action = isset($this->table[$state][Lexer::T_ERROR]) ? $this->table[$state][Lexer::T_ERROR] : false;
  51582. if ($action === false) {
  51583. throw new \LogicException('No table value found for '.$state.' => '.Lexer::T_ERROR);
  51584. }
  51585. $recovering = 3;
  51586. }
  51587. if (\is_array($action[0]) && \count($action) > 1) {
  51588. throw new ParsingException('Parse Error: multiple actions possible at state: ' . $state . ', token: ' . $symbol);
  51589. }
  51590. switch ($action[0]) {
  51591. case 1:
  51592. assert(isset($symbol));
  51593. $this->stack[] = $symbol;
  51594. $this->vstack[] = $this->lexer->yytext;
  51595. $this->lstack[] = $this->lexer->yylloc;
  51596. $this->stack[] = $action[1];
  51597. $symbol = null;
  51598. if (!$preErrorSymbol) {
  51599. $yyleng = $this->lexer->yyleng;
  51600. $yytext = $this->lexer->yytext;
  51601. $yylineno = $this->lexer->yylineno;
  51602. $yyloc = $this->lexer->yylloc;
  51603. if ($recovering > 0) {
  51604. $recovering--;
  51605. }
  51606. } else {
  51607. $symbol = $preErrorSymbol;
  51608. $preErrorSymbol = null;
  51609. }
  51610. break;
  51611. case 2:
  51612. $len = $this->productions_[$action[1]][1];
  51613. $currentToken = $this->vstack[\count($this->vstack) - $len];
  51614. $position = array(
  51615. 'first_line' => $this->lstack[\count($this->lstack) - ($len ?: 1)]['first_line'],
  51616. 'last_line' => $this->lstack[\count($this->lstack) - 1]['last_line'],
  51617. 'first_column' => $this->lstack[\count($this->lstack) - ($len ?: 1)]['first_column'],
  51618. 'last_column' => $this->lstack[\count($this->lstack) - 1]['last_column'],
  51619. );
  51620. list($newToken, $actionResult) = $this->performAction($currentToken, $yytext, $yyleng, $yylineno, $action[1]);
  51621. if (!$actionResult instanceof Undefined) {
  51622. return $actionResult;
  51623. }
  51624. if ($len) {
  51625. $this->popStack($len);
  51626. }
  51627. $this->stack[] = $this->productions_[$action[1]][0];
  51628. $this->vstack[] = $newToken;
  51629. $this->lstack[] = $position;
  51630. $newState = $this->table[$this->stack[\count($this->stack)-2]][$this->stack[\count($this->stack)-1]];
  51631. $this->stack[] = $newState;
  51632. break;
  51633. case 3:
  51634. return true;
  51635. }
  51636. }
  51637. }
  51638. protected function parseError($str, $hash = null)
  51639. {
  51640. throw new ParsingException($str, $hash ?: array());
  51641. }
  51642. private function performAction($currentToken, $yytext, $yyleng, $yylineno, $yystate)
  51643. {
  51644. $token = $currentToken;
  51645. $len = \count($this->vstack) - 1;
  51646. switch ($yystate) {
  51647. case 1:
  51648. $yytext = preg_replace_callback('{(?:\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4})}', array($this, 'stringInterpolation'), $yytext);
  51649. $token = $yytext;
  51650. break;
  51651. case 2:
  51652. if (strpos($yytext, 'e') !== false || strpos($yytext, 'E') !== false) {
  51653. $token = \floatval($yytext);
  51654. } else {
  51655. $token = strpos($yytext, '.') === false ? \intval($yytext) : \floatval($yytext);
  51656. }
  51657. break;
  51658. case 3:
  51659. $token = null;
  51660. break;
  51661. case 4:
  51662. $token = true;
  51663. break;
  51664. case 5:
  51665. $token = false;
  51666. break;
  51667. case 6:
  51668. $token = $this->vstack[$len-1];
  51669. return array($token, $token);
  51670. case 13:
  51671. if ($this->flags & self::PARSE_TO_ASSOC) {
  51672. $token = array();
  51673. } else {
  51674. $token = new stdClass;
  51675. }
  51676. break;
  51677. case 14:
  51678. $token = $this->vstack[$len-1];
  51679. break;
  51680. case 15:
  51681. $token = array($this->vstack[$len-2], $this->vstack[$len]);
  51682. break;
  51683. case 16:
  51684. assert(\is_array($this->vstack[$len]));
  51685. if (PHP_VERSION_ID < 70100) {
  51686. $property = $this->vstack[$len][0] === '' ? '_empty_' : $this->vstack[$len][0];
  51687. } else {
  51688. $property = $this->vstack[$len][0];
  51689. }
  51690. if ($this->flags & self::PARSE_TO_ASSOC) {
  51691. $token = array();
  51692. $token[$property] = $this->vstack[$len][1];
  51693. } else {
  51694. $token = new stdClass;
  51695. $token->$property = $this->vstack[$len][1];
  51696. }
  51697. break;
  51698. case 17:
  51699. assert(\is_array($this->vstack[$len]));
  51700. if ($this->flags & self::PARSE_TO_ASSOC) {
  51701. assert(\is_array($this->vstack[$len-2]));
  51702. $token =& $this->vstack[$len-2];
  51703. $key = $this->vstack[$len][0];
  51704. if (($this->flags & self::DETECT_KEY_CONFLICTS) && isset($this->vstack[$len-2][$key])) {
  51705. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  51706. $errStr .= $this->lexer->showPosition() . "\n";
  51707. $errStr .= "Duplicate key: ".$this->vstack[$len][0];
  51708. throw new DuplicateKeyException($errStr, $this->vstack[$len][0], array('line' => $yylineno+1));
  51709. } elseif (($this->flags & self::ALLOW_DUPLICATE_KEYS) && isset($this->vstack[$len-2][$key])) {
  51710. $duplicateCount = 1;
  51711. do {
  51712. $duplicateKey = $key . '.' . $duplicateCount++;
  51713. } while (isset($this->vstack[$len-2][$duplicateKey]));
  51714. $key = $duplicateKey;
  51715. }
  51716. $this->vstack[$len-2][$key] = $this->vstack[$len][1];
  51717. } else {
  51718. assert($this->vstack[$len-2] instanceof stdClass);
  51719. $token = $this->vstack[$len-2];
  51720. if (PHP_VERSION_ID < 70100) {
  51721. $key = $this->vstack[$len][0] === '' ? '_empty_' : $this->vstack[$len][0];
  51722. } else {
  51723. $key = $this->vstack[$len][0];
  51724. }
  51725. if (($this->flags & self::DETECT_KEY_CONFLICTS) && isset($this->vstack[$len-2]->{$key})) {
  51726. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  51727. $errStr .= $this->lexer->showPosition() . "\n";
  51728. $errStr .= "Duplicate key: ".$this->vstack[$len][0];
  51729. throw new DuplicateKeyException($errStr, $this->vstack[$len][0], array('line' => $yylineno+1));
  51730. } elseif (($this->flags & self::ALLOW_DUPLICATE_KEYS) && isset($this->vstack[$len-2]->{$key})) {
  51731. $duplicateCount = 1;
  51732. do {
  51733. $duplicateKey = $key . '.' . $duplicateCount++;
  51734. } while (isset($this->vstack[$len-2]->$duplicateKey));
  51735. $key = $duplicateKey;
  51736. }
  51737. $this->vstack[$len-2]->$key = $this->vstack[$len][1];
  51738. }
  51739. break;
  51740. case 18:
  51741. $token = array();
  51742. break;
  51743. case 19:
  51744. $token = $this->vstack[$len-1];
  51745. break;
  51746. case 20:
  51747. $token = array($this->vstack[$len]);
  51748. break;
  51749. case 21:
  51750. assert(\is_array($this->vstack[$len-2]));
  51751. $this->vstack[$len-2][] = $this->vstack[$len];
  51752. $token = $this->vstack[$len-2];
  51753. break;
  51754. }
  51755. return array($token, new Undefined());
  51756. }
  51757. private function stringInterpolation($match)
  51758. {
  51759. switch ($match[0]) {
  51760. case '\\\\':
  51761. return '\\';
  51762. case '\"':
  51763. return '"';
  51764. case '\b':
  51765. return \chr(8);
  51766. case '\f':
  51767. return \chr(12);
  51768. case '\n':
  51769. return "\n";
  51770. case '\r':
  51771. return "\r";
  51772. case '\t':
  51773. return "\t";
  51774. case '\/':
  51775. return "/";
  51776. default:
  51777. return html_entity_decode('&#x'.ltrim(substr($match[0], 2), '0').';', ENT_QUOTES, 'UTF-8');
  51778. }
  51779. }
  51780. private function popStack($n)
  51781. {
  51782. $this->stack = \array_slice($this->stack, 0, - (2 * $n));
  51783. $this->vstack = \array_slice($this->vstack, 0, - $n);
  51784. $this->lstack = \array_slice($this->lstack, 0, - $n);
  51785. }
  51786. private function failOnBOM($input)
  51787. {
  51788. $bom = "\xEF\xBB\xBF";
  51789. if (substr($input, 0, 3) === $bom) {
  51790. $this->parseError("BOM detected, make sure your input does not include a Unicode Byte-Order-Mark");
  51791. }
  51792. }
  51793. }
  51794. <?php
  51795. namespace Seld\JsonLint;
  51796. class Lexer
  51797. {
  51798. const EOF = 1;
  51799. const T_INVALID = -1;
  51800. const T_SKIP_WHITESPACE = 0;
  51801. const T_ERROR = 2;
  51802. private $rules = array(
  51803. 0 => '/\G\s+/',
  51804. 1 => '/\G-?([0-9]|[1-9][0-9]+)(\.[0-9]+)?([eE][+-]?[0-9]+)?\b/',
  51805. 2 => '{\G"(?>\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^\0-\x1f\\\\"]++)*+"}',
  51806. 3 => '/\G\{/',
  51807. 4 => '/\G\}/',
  51808. 5 => '/\G\[/',
  51809. 6 => '/\G\]/',
  51810. 7 => '/\G,/',
  51811. 8 => '/\G:/',
  51812. 9 => '/\Gtrue\b/',
  51813. 10 => '/\Gfalse\b/',
  51814. 11 => '/\Gnull\b/',
  51815. 12 => '/\G$/',
  51816. 13 => '/\G./',
  51817. );
  51818. private $input;
  51819. private $more;
  51820. private $done;
  51821. private $offset;
  51822. public $match;
  51823. public $yylineno;
  51824. public $yyleng;
  51825. public $yytext;
  51826. public $yylloc;
  51827. public function lex()
  51828. {
  51829. do {
  51830. $symbol = $this->next();
  51831. } while ($symbol === self::T_SKIP_WHITESPACE);
  51832. return $symbol;
  51833. }
  51834. public function setInput($input)
  51835. {
  51836. $this->input = $input;
  51837. $this->more = false;
  51838. $this->done = false;
  51839. $this->offset = 0;
  51840. $this->yylineno = $this->yyleng = 0;
  51841. $this->yytext = $this->match = '';
  51842. $this->yylloc = array('first_line' => 1, 'first_column' => 0, 'last_line' => 1, 'last_column' => 0);
  51843. return $this;
  51844. }
  51845. public function showPosition()
  51846. {
  51847. $pre = str_replace("\n", '', $this->getPastInput());
  51848. $c = str_repeat('-', max(0, \strlen($pre) - 1));
  51849. return $pre . str_replace("\n", '', $this->getUpcomingInput()) . "\n" . $c . "^";
  51850. }
  51851. public function getPastInput()
  51852. {
  51853. $pastLength = $this->offset - \strlen($this->match);
  51854. return ($pastLength > 20 ? '...' : '') . substr($this->input, max(0, $pastLength - 20), min(20, $pastLength));
  51855. }
  51856. public function getUpcomingInput()
  51857. {
  51858. $next = $this->match;
  51859. if (\strlen($next) < 20) {
  51860. $next .= substr($this->input, $this->offset, 20 - \strlen($next));
  51861. }
  51862. return substr($next, 0, 20) . (\strlen($next) > 20 ? '...' : '');
  51863. }
  51864. public function getFullUpcomingInput()
  51865. {
  51866. $next = $this->match;
  51867. if (substr($next, 0, 1) === '"' && substr_count($next, '"') === 1) {
  51868. $len = \strlen($this->input);
  51869. if ($len === $this->offset) {
  51870. $strEnd = $len;
  51871. } else {
  51872. $strEnd = min(strpos($this->input, '"', $this->offset + 1) ?: $len, strpos($this->input, "\n", $this->offset + 1) ?: $len);
  51873. }
  51874. $next .= substr($this->input, $this->offset, $strEnd - $this->offset);
  51875. } elseif (\strlen($next) < 20) {
  51876. $next .= substr($this->input, $this->offset, 20 - \strlen($next));
  51877. }
  51878. return $next;
  51879. }
  51880. protected function parseError($str)
  51881. {
  51882. throw new ParsingException($str);
  51883. }
  51884. private function next()
  51885. {
  51886. if ($this->done) {
  51887. return self::EOF;
  51888. }
  51889. if ($this->offset === \strlen($this->input)) {
  51890. $this->done = true;
  51891. }
  51892. $token = null;
  51893. $match = null;
  51894. $col = null;
  51895. $lines = null;
  51896. if (!$this->more) {
  51897. $this->yytext = '';
  51898. $this->match = '';
  51899. }
  51900. $rulesLen = 14;
  51901. for ($i=0; $i < $rulesLen; $i++) {
  51902. if (preg_match($this->rules[$i], $this->input, $match, 0, $this->offset)) {
  51903. $lines = explode("\n", $match[0]);
  51904. array_shift($lines);
  51905. $lineCount = \count($lines);
  51906. $this->yylineno += $lineCount;
  51907. $this->yylloc = array(
  51908. 'first_line' => $this->yylloc['last_line'],
  51909. 'last_line' => $this->yylineno+1,
  51910. 'first_column' => $this->yylloc['last_column'],
  51911. 'last_column' => $lineCount > 0 ? \strlen($lines[$lineCount - 1]) : $this->yylloc['last_column'] + \strlen($match[0]),
  51912. );
  51913. $this->yytext .= $match[0];
  51914. $this->match .= $match[0];
  51915. $this->yyleng = \strlen($this->yytext);
  51916. $this->more = false;
  51917. $this->offset += \strlen($match[0]);
  51918. return $this->performAction($i);
  51919. }
  51920. }
  51921. if ($this->offset === \strlen($this->input)) {
  51922. return self::EOF;
  51923. }
  51924. $this->parseError(
  51925. 'Lexical error on line ' . ($this->yylineno+1) . ". Unrecognized text.\n" . $this->showPosition()
  51926. );
  51927. }
  51928. private function performAction($rule)
  51929. {
  51930. switch ($rule) {
  51931. case 0:
  51932. return self::T_SKIP_WHITESPACE;
  51933. case 1:
  51934. return 6;
  51935. case 2:
  51936. $this->yytext = substr($this->yytext, 1, $this->yyleng-2);
  51937. return 4;
  51938. case 3:
  51939. return 17;
  51940. case 4:
  51941. return 18;
  51942. case 5:
  51943. return 23;
  51944. case 6:
  51945. return 24;
  51946. case 7:
  51947. return 22;
  51948. case 8:
  51949. return 21;
  51950. case 9:
  51951. return 10;
  51952. case 10:
  51953. return 11;
  51954. case 11:
  51955. return 8;
  51956. case 12:
  51957. return 14;
  51958. case 13:
  51959. return self::T_INVALID;
  51960. default:
  51961. throw new \LogicException('Unsupported rule '.$rule);
  51962. }
  51963. }
  51964. }
  51965. <?php
  51966. namespace Seld\JsonLint;
  51967. class ParsingException extends \Exception
  51968. {
  51969. protected $details;
  51970. public function __construct($message, $details = array())
  51971. {
  51972. $this->details = $details;
  51973. parent::__construct($message);
  51974. }
  51975. public function getDetails()
  51976. {
  51977. return $this->details;
  51978. }
  51979. }
  51980. <?php
  51981. namespace Seld\JsonLint;
  51982. class Undefined
  51983. {
  51984. }
  51985. Copyright (c) 2015 Jordi Boggiano
  51986. Permission is hereby granted, free of charge, to any person obtaining a copy
  51987. of this software and associated documentation files (the "Software"), to deal
  51988. in the Software without restriction, including without limitation the rights
  51989. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  51990. copies of the Software, and to permit persons to whom the Software is furnished
  51991. to do so, subject to the following conditions:
  51992. The above copyright notice and this permission notice shall be included in all
  51993. copies or substantial portions of the Software.
  51994. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  51995. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  51996. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  51997. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  51998. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  51999. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  52000. THE SOFTWARE.
  52001. <?php
  52002. namespace Seld\PharUtils;
  52003. class Linter
  52004. {
  52005. public static function lint($path, array $excludedPaths = array())
  52006. {
  52007. $php = defined('PHP_BINARY') ? PHP_BINARY : 'php';
  52008. if ($isWindows = defined('PHP_WINDOWS_VERSION_BUILD')) {
  52009. $tmpFile = @tempnam(sys_get_temp_dir(), '');
  52010. if (!$tmpFile || !is_writable($tmpFile)) {
  52011. throw new \RuntimeException('Unable to create temp file');
  52012. }
  52013. $php = self::escapeWindowsPath($php);
  52014. $tmpFile = self::escapeWindowsPath($tmpFile);
  52015. if (PHP_VERSION_ID >= 80000) {
  52016. $format = '%s -l %s';
  52017. } else {
  52018. $format = '"%s -l %s"';
  52019. }
  52020. $command = sprintf($format, $php, $tmpFile);
  52021. } else {
  52022. $command = "'".$php."' -l";
  52023. }
  52024. $descriptorspec = array(
  52025. 0 => array('pipe', 'r'),
  52026. 1 => array('pipe', 'w'),
  52027. 2 => array('pipe', 'w')
  52028. );
  52029. $baseLen = strlen(realpath($path)) + 7 + 1;
  52030. foreach (new \RecursiveIteratorIterator(new \Phar($path)) as $file) {
  52031. if ($file->isDir()) {
  52032. continue;
  52033. }
  52034. if (substr($file, -4) === '.php') {
  52035. $filename = (string) $file;
  52036. if (in_array(substr($filename, $baseLen), $excludedPaths, true)) {
  52037. continue;
  52038. }
  52039. if ($isWindows) {
  52040. file_put_contents($tmpFile, file_get_contents($filename));
  52041. }
  52042. $process = proc_open($command, $descriptorspec, $pipes);
  52043. if (is_resource($process)) {
  52044. if (!$isWindows) {
  52045. fwrite($pipes[0], file_get_contents($filename));
  52046. }
  52047. fclose($pipes[0]);
  52048. $stdout = stream_get_contents($pipes[1]);
  52049. fclose($pipes[1]);
  52050. $stderr = stream_get_contents($pipes[2]);
  52051. fclose($pipes[2]);
  52052. $exitCode = proc_close($process);
  52053. if ($exitCode !== 0) {
  52054. if ($isWindows) {
  52055. $stderr = str_replace($tmpFile, $filename, $stderr);
  52056. }
  52057. throw new \UnexpectedValueException('Failed linting '.$file.': '.$stderr);
  52058. }
  52059. } else {
  52060. throw new \RuntimeException('Could not start linter process');
  52061. }
  52062. }
  52063. }
  52064. if ($isWindows) {
  52065. @unlink($tmpFile);
  52066. }
  52067. }
  52068. private static function escapeWindowsPath($path)
  52069. {
  52070. if (strpbrk($path, " ()") !== false) {
  52071. $path = '"'.$path.'"';
  52072. }
  52073. return $path;
  52074. }
  52075. }
  52076. <?php
  52077. namespace Seld\PharUtils;
  52078. class Timestamps
  52079. {
  52080. private $contents;
  52081. public function __construct($file)
  52082. {
  52083. $this->contents = file_get_contents($file);
  52084. }
  52085. public function updateTimestamps($timestamp = null)
  52086. {
  52087. if ($timestamp instanceof \DateTime || $timestamp instanceof \DateTimeInterface) {
  52088. $timestamp = $timestamp->getTimestamp();
  52089. } elseif (is_string($timestamp)) {
  52090. $timestamp = strtotime($timestamp);
  52091. } elseif (!is_int($timestamp)) {
  52092. $timestamp = strtotime('1984-12-24T00:00:00Z');
  52093. }
  52094. if (!preg_match('{__HALT_COMPILER\(\);(?: +\?>)?\r?\n}', $this->contents, $match, PREG_OFFSET_CAPTURE)) {
  52095. throw new \RuntimeException('Could not detect the stub\'s end in the phar');
  52096. }
  52097. $pos = $match[0][1] + strlen($match[0][0]);
  52098. $stubEnd = $pos + $this->readUint($pos, 4);
  52099. $pos += 4;
  52100. $numFiles = $this->readUint($pos, 4);
  52101. $pos += 4;
  52102. $pos += 2;
  52103. $pos += 4;
  52104. $aliasLength = $this->readUint($pos, 4);
  52105. $pos += 4 + $aliasLength;
  52106. $metadataLength = $this->readUint($pos, 4);
  52107. $pos += 4 + $metadataLength;
  52108. while ($pos < $stubEnd) {
  52109. $filenameLength = $this->readUint($pos, 4);
  52110. $pos += 4 + $filenameLength;
  52111. $pos += 4;
  52112. $this->contents = substr_replace($this->contents, pack('L', $timestamp), $pos, 4);
  52113. $pos += 4*4;
  52114. $metadataLength = $this->readUint($pos, 4);
  52115. $pos += 4 + $metadataLength;
  52116. $numFiles--;
  52117. }
  52118. if ($numFiles !== 0) {
  52119. throw new \LogicException('All files were not processed, something must have gone wrong');
  52120. }
  52121. }
  52122. public function save($path, $signatureAlgo)
  52123. {
  52124. $pos = $this->determineSignatureBegin();
  52125. $algos = array(
  52126. \Phar::MD5 => 'md5',
  52127. \Phar::SHA1 => 'sha1',
  52128. \Phar::SHA256 => 'sha256',
  52129. \Phar::SHA512 => 'sha512',
  52130. );
  52131. if (!isset($algos[$signatureAlgo])) {
  52132. throw new \UnexpectedValueException('Invalid hash algorithm given: '.$signatureAlgo.' expected one of Phar::MD5, Phar::SHA1, Phar::SHA256 or Phar::SHA512');
  52133. }
  52134. $algo = $algos[$signatureAlgo];
  52135. $signature = hash($algo, substr($this->contents, 0, $pos), true)
  52136. . pack('L', $signatureAlgo)
  52137. . 'GBMB';
  52138. $this->contents = substr($this->contents, 0, $pos) . $signature;
  52139. return file_put_contents($path, $this->contents);
  52140. }
  52141. private function readUint($pos, $bytes)
  52142. {
  52143. $res = unpack('V', substr($this->contents, $pos, $bytes));
  52144. return $res[1];
  52145. }
  52146. private function determineSignatureBegin()
  52147. {
  52148. if (!preg_match('{__HALT_COMPILER\(\);(?: +\?>)?\r?\n}', $this->contents, $match, PREG_OFFSET_CAPTURE)) {
  52149. throw new \RuntimeException('Could not detect the stub\'s end in the phar');
  52150. }
  52151. $pos = $match[0][1] + strlen($match[0][0]);
  52152. $manifestEnd = $pos + 4 + $this->readUint($pos, 4);
  52153. $pos += 4;
  52154. $numFiles = $this->readUint($pos, 4);
  52155. $pos += 4;
  52156. $pos += 2;
  52157. $pos += 4;
  52158. $aliasLength = $this->readUint($pos, 4);
  52159. $pos += 4 + $aliasLength;
  52160. $metadataLength = $this->readUint($pos, 4);
  52161. $pos += 4 + $metadataLength;
  52162. $compressedSizes = 0;
  52163. while (($numFiles > 0) && ($pos < $manifestEnd - 24)) {
  52164. $filenameLength = $this->readUint($pos, 4);
  52165. $pos += 4 + $filenameLength;
  52166. $pos += 2*4;
  52167. $compressedSizes += $this->readUint($pos, 4);
  52168. $pos += 3*4;
  52169. $metadataLength = $this->readUint($pos, 4);
  52170. $pos += 4 + $metadataLength;
  52171. $numFiles--;
  52172. }
  52173. if ($numFiles !== 0) {
  52174. throw new \LogicException('All files were not processed, something must have gone wrong');
  52175. }
  52176. return $manifestEnd + $compressedSizes;
  52177. }
  52178. }
  52179. <?php
  52180. namespace Symfony\Component\Console;
  52181. use Symfony\Component\Console\Command\Command;
  52182. use Symfony\Component\Console\Command\CompleteCommand;
  52183. use Symfony\Component\Console\Command\DumpCompletionCommand;
  52184. use Symfony\Component\Console\Command\HelpCommand;
  52185. use Symfony\Component\Console\Command\LazyCommand;
  52186. use Symfony\Component\Console\Command\ListCommand;
  52187. use Symfony\Component\Console\Command\SignalableCommandInterface;
  52188. use Symfony\Component\Console\CommandLoader\CommandLoaderInterface;
  52189. use Symfony\Component\Console\Completion\CompletionInput;
  52190. use Symfony\Component\Console\Completion\CompletionSuggestions;
  52191. use Symfony\Component\Console\Event\ConsoleCommandEvent;
  52192. use Symfony\Component\Console\Event\ConsoleErrorEvent;
  52193. use Symfony\Component\Console\Event\ConsoleSignalEvent;
  52194. use Symfony\Component\Console\Event\ConsoleTerminateEvent;
  52195. use Symfony\Component\Console\Exception\CommandNotFoundException;
  52196. use Symfony\Component\Console\Exception\ExceptionInterface;
  52197. use Symfony\Component\Console\Exception\LogicException;
  52198. use Symfony\Component\Console\Exception\NamespaceNotFoundException;
  52199. use Symfony\Component\Console\Exception\RuntimeException;
  52200. use Symfony\Component\Console\Formatter\OutputFormatter;
  52201. use Symfony\Component\Console\Helper\DebugFormatterHelper;
  52202. use Symfony\Component\Console\Helper\FormatterHelper;
  52203. use Symfony\Component\Console\Helper\Helper;
  52204. use Symfony\Component\Console\Helper\HelperSet;
  52205. use Symfony\Component\Console\Helper\ProcessHelper;
  52206. use Symfony\Component\Console\Helper\QuestionHelper;
  52207. use Symfony\Component\Console\Input\ArgvInput;
  52208. use Symfony\Component\Console\Input\ArrayInput;
  52209. use Symfony\Component\Console\Input\InputArgument;
  52210. use Symfony\Component\Console\Input\InputAwareInterface;
  52211. use Symfony\Component\Console\Input\InputDefinition;
  52212. use Symfony\Component\Console\Input\InputInterface;
  52213. use Symfony\Component\Console\Input\InputOption;
  52214. use Symfony\Component\Console\Output\ConsoleOutput;
  52215. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  52216. use Symfony\Component\Console\Output\OutputInterface;
  52217. use Symfony\Component\Console\SignalRegistry\SignalRegistry;
  52218. use Symfony\Component\Console\Style\SymfonyStyle;
  52219. use Symfony\Component\ErrorHandler\ErrorHandler;
  52220. use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
  52221. use Symfony\Contracts\Service\ResetInterface;
  52222. class Application implements ResetInterface
  52223. {
  52224. private $commands = [];
  52225. private $wantHelps = false;
  52226. private $runningCommand;
  52227. private $name;
  52228. private $version;
  52229. private $commandLoader;
  52230. private $catchExceptions = true;
  52231. private $autoExit = true;
  52232. private $definition;
  52233. private $helperSet;
  52234. private $dispatcher;
  52235. private $terminal;
  52236. private $defaultCommand;
  52237. private $singleCommand = false;
  52238. private $initialized;
  52239. private $signalRegistry;
  52240. private $signalsToDispatchEvent = [];
  52241. public function __construct(string $name = 'UNKNOWN', string $version = 'UNKNOWN')
  52242. {
  52243. $this->name = $name;
  52244. $this->version = $version;
  52245. $this->terminal = new Terminal();
  52246. $this->defaultCommand = 'list';
  52247. if (\defined('SIGINT') && SignalRegistry::isSupported()) {
  52248. $this->signalRegistry = new SignalRegistry();
  52249. $this->signalsToDispatchEvent = [\SIGINT, \SIGTERM, \SIGUSR1, \SIGUSR2];
  52250. }
  52251. }
  52252. public function setDispatcher(EventDispatcherInterface $dispatcher)
  52253. {
  52254. $this->dispatcher = $dispatcher;
  52255. }
  52256. public function setCommandLoader(CommandLoaderInterface $commandLoader)
  52257. {
  52258. $this->commandLoader = $commandLoader;
  52259. }
  52260. public function getSignalRegistry(): SignalRegistry
  52261. {
  52262. if (!$this->signalRegistry) {
  52263. throw new RuntimeException('Signals are not supported. Make sure that the `pcntl` extension is installed and that "pcntl_*" functions are not disabled by your php.ini\'s "disable_functions" directive.');
  52264. }
  52265. return $this->signalRegistry;
  52266. }
  52267. public function setSignalsToDispatchEvent(int ...$signalsToDispatchEvent)
  52268. {
  52269. $this->signalsToDispatchEvent = $signalsToDispatchEvent;
  52270. }
  52271. public function run(InputInterface $input = null, OutputInterface $output = null)
  52272. {
  52273. if (\function_exists('putenv')) {
  52274. @putenv('LINES='.$this->terminal->getHeight());
  52275. @putenv('COLUMNS='.$this->terminal->getWidth());
  52276. }
  52277. if (null === $input) {
  52278. $input = new ArgvInput();
  52279. }
  52280. if (null === $output) {
  52281. $output = new ConsoleOutput();
  52282. }
  52283. $renderException = function (\Throwable $e) use ($output) {
  52284. if ($output instanceof ConsoleOutputInterface) {
  52285. $this->renderThrowable($e, $output->getErrorOutput());
  52286. } else {
  52287. $this->renderThrowable($e, $output);
  52288. }
  52289. };
  52290. if ($phpHandler = set_exception_handler($renderException)) {
  52291. restore_exception_handler();
  52292. if (!\is_array($phpHandler) || !$phpHandler[0] instanceof ErrorHandler) {
  52293. $errorHandler = true;
  52294. } elseif ($errorHandler = $phpHandler[0]->setExceptionHandler($renderException)) {
  52295. $phpHandler[0]->setExceptionHandler($errorHandler);
  52296. }
  52297. }
  52298. $this->configureIO($input, $output);
  52299. try {
  52300. $exitCode = $this->doRun($input, $output);
  52301. } catch (\Exception $e) {
  52302. if (!$this->catchExceptions) {
  52303. throw $e;
  52304. }
  52305. $renderException($e);
  52306. $exitCode = $e->getCode();
  52307. if (is_numeric($exitCode)) {
  52308. $exitCode = (int) $exitCode;
  52309. if (0 === $exitCode) {
  52310. $exitCode = 1;
  52311. }
  52312. } else {
  52313. $exitCode = 1;
  52314. }
  52315. } finally {
  52316. if (!$phpHandler) {
  52317. if (set_exception_handler($renderException) === $renderException) {
  52318. restore_exception_handler();
  52319. }
  52320. restore_exception_handler();
  52321. } elseif (!$errorHandler) {
  52322. $finalHandler = $phpHandler[0]->setExceptionHandler(null);
  52323. if ($finalHandler !== $renderException) {
  52324. $phpHandler[0]->setExceptionHandler($finalHandler);
  52325. }
  52326. }
  52327. }
  52328. if ($this->autoExit) {
  52329. if ($exitCode > 255) {
  52330. $exitCode = 255;
  52331. }
  52332. exit($exitCode);
  52333. }
  52334. return $exitCode;
  52335. }
  52336. public function doRun(InputInterface $input, OutputInterface $output)
  52337. {
  52338. if (true === $input->hasParameterOption(['--version', '-V'], true)) {
  52339. $output->writeln($this->getLongVersion());
  52340. return 0;
  52341. }
  52342. try {
  52343. $input->bind($this->getDefinition());
  52344. } catch (ExceptionInterface $e) {
  52345. }
  52346. $name = $this->getCommandName($input);
  52347. if (true === $input->hasParameterOption(['--help', '-h'], true)) {
  52348. if (!$name) {
  52349. $name = 'help';
  52350. $input = new ArrayInput(['command_name' => $this->defaultCommand]);
  52351. } else {
  52352. $this->wantHelps = true;
  52353. }
  52354. }
  52355. if (!$name) {
  52356. $name = $this->defaultCommand;
  52357. $definition = $this->getDefinition();
  52358. $definition->setArguments(array_merge(
  52359. $definition->getArguments(),
  52360. [
  52361. 'command' => new InputArgument('command', InputArgument::OPTIONAL, $definition->getArgument('command')->getDescription(), $name),
  52362. ]
  52363. ));
  52364. }
  52365. try {
  52366. $this->runningCommand = null;
  52367. $command = $this->find($name);
  52368. } catch (\Throwable $e) {
  52369. if (!($e instanceof CommandNotFoundException && !$e instanceof NamespaceNotFoundException) || 1 !== \count($alternatives = $e->getAlternatives()) || !$input->isInteractive()) {
  52370. if (null !== $this->dispatcher) {
  52371. $event = new ConsoleErrorEvent($input, $output, $e);
  52372. $this->dispatcher->dispatch($event, ConsoleEvents::ERROR);
  52373. if (0 === $event->getExitCode()) {
  52374. return 0;
  52375. }
  52376. $e = $event->getError();
  52377. }
  52378. throw $e;
  52379. }
  52380. $alternative = $alternatives[0];
  52381. $style = new SymfonyStyle($input, $output);
  52382. $style->block(sprintf("\nCommand \"%s\" is not defined.\n", $name), null, 'error');
  52383. if (!$style->confirm(sprintf('Do you want to run "%s" instead? ', $alternative), false)) {
  52384. if (null !== $this->dispatcher) {
  52385. $event = new ConsoleErrorEvent($input, $output, $e);
  52386. $this->dispatcher->dispatch($event, ConsoleEvents::ERROR);
  52387. return $event->getExitCode();
  52388. }
  52389. return 1;
  52390. }
  52391. $command = $this->find($alternative);
  52392. }
  52393. if ($command instanceof LazyCommand) {
  52394. $command = $command->getCommand();
  52395. }
  52396. $this->runningCommand = $command;
  52397. $exitCode = $this->doRunCommand($command, $input, $output);
  52398. $this->runningCommand = null;
  52399. return $exitCode;
  52400. }
  52401. public function reset()
  52402. {
  52403. }
  52404. public function setHelperSet(HelperSet $helperSet)
  52405. {
  52406. $this->helperSet = $helperSet;
  52407. }
  52408. public function getHelperSet()
  52409. {
  52410. if (!$this->helperSet) {
  52411. $this->helperSet = $this->getDefaultHelperSet();
  52412. }
  52413. return $this->helperSet;
  52414. }
  52415. public function setDefinition(InputDefinition $definition)
  52416. {
  52417. $this->definition = $definition;
  52418. }
  52419. public function getDefinition()
  52420. {
  52421. if (!$this->definition) {
  52422. $this->definition = $this->getDefaultInputDefinition();
  52423. }
  52424. if ($this->singleCommand) {
  52425. $inputDefinition = $this->definition;
  52426. $inputDefinition->setArguments();
  52427. return $inputDefinition;
  52428. }
  52429. return $this->definition;
  52430. }
  52431. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  52432. {
  52433. if (
  52434. CompletionInput::TYPE_ARGUMENT_VALUE === $input->getCompletionType()
  52435. && 'command' === $input->getCompletionName()
  52436. ) {
  52437. $suggestions->suggestValues(array_filter(array_map(function (Command $command) {
  52438. return $command->isHidden() ? null : $command->getName();
  52439. }, $this->all())));
  52440. return;
  52441. }
  52442. if (CompletionInput::TYPE_OPTION_NAME === $input->getCompletionType()) {
  52443. $suggestions->suggestOptions($this->getDefinition()->getOptions());
  52444. return;
  52445. }
  52446. }
  52447. public function getHelp()
  52448. {
  52449. return $this->getLongVersion();
  52450. }
  52451. public function areExceptionsCaught()
  52452. {
  52453. return $this->catchExceptions;
  52454. }
  52455. public function setCatchExceptions(bool $boolean)
  52456. {
  52457. $this->catchExceptions = $boolean;
  52458. }
  52459. public function isAutoExitEnabled()
  52460. {
  52461. return $this->autoExit;
  52462. }
  52463. public function setAutoExit(bool $boolean)
  52464. {
  52465. $this->autoExit = $boolean;
  52466. }
  52467. public function getName()
  52468. {
  52469. return $this->name;
  52470. }
  52471. public function setName(string $name)
  52472. {
  52473. $this->name = $name;
  52474. }
  52475. public function getVersion()
  52476. {
  52477. return $this->version;
  52478. }
  52479. public function setVersion(string $version)
  52480. {
  52481. $this->version = $version;
  52482. }
  52483. public function getLongVersion()
  52484. {
  52485. if ('UNKNOWN' !== $this->getName()) {
  52486. if ('UNKNOWN' !== $this->getVersion()) {
  52487. return sprintf('%s <info>%s</info>', $this->getName(), $this->getVersion());
  52488. }
  52489. return $this->getName();
  52490. }
  52491. return 'Console Tool';
  52492. }
  52493. public function register(string $name)
  52494. {
  52495. return $this->add(new Command($name));
  52496. }
  52497. public function addCommands(array $commands)
  52498. {
  52499. foreach ($commands as $command) {
  52500. $this->add($command);
  52501. }
  52502. }
  52503. public function add(Command $command)
  52504. {
  52505. $this->init();
  52506. $command->setApplication($this);
  52507. if (!$command->isEnabled()) {
  52508. $command->setApplication(null);
  52509. return null;
  52510. }
  52511. if (!$command instanceof LazyCommand) {
  52512. $command->getDefinition();
  52513. }
  52514. if (!$command->getName()) {
  52515. throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', get_debug_type($command)));
  52516. }
  52517. $this->commands[$command->getName()] = $command;
  52518. foreach ($command->getAliases() as $alias) {
  52519. $this->commands[$alias] = $command;
  52520. }
  52521. return $command;
  52522. }
  52523. public function get(string $name)
  52524. {
  52525. $this->init();
  52526. if (!$this->has($name)) {
  52527. throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
  52528. }
  52529. if (!isset($this->commands[$name])) {
  52530. throw new CommandNotFoundException(sprintf('The "%s" command cannot be found because it is registered under multiple names. Make sure you don\'t set a different name via constructor or "setName()".', $name));
  52531. }
  52532. $command = $this->commands[$name];
  52533. if ($this->wantHelps) {
  52534. $this->wantHelps = false;
  52535. $helpCommand = $this->get('help');
  52536. $helpCommand->setCommand($command);
  52537. return $helpCommand;
  52538. }
  52539. return $command;
  52540. }
  52541. public function has(string $name)
  52542. {
  52543. $this->init();
  52544. return isset($this->commands[$name]) || ($this->commandLoader && $this->commandLoader->has($name) && $this->add($this->commandLoader->get($name)));
  52545. }
  52546. public function getNamespaces()
  52547. {
  52548. $namespaces = [];
  52549. foreach ($this->all() as $command) {
  52550. if ($command->isHidden()) {
  52551. continue;
  52552. }
  52553. $namespaces[] = $this->extractAllNamespaces($command->getName());
  52554. foreach ($command->getAliases() as $alias) {
  52555. $namespaces[] = $this->extractAllNamespaces($alias);
  52556. }
  52557. }
  52558. return array_values(array_unique(array_filter(array_merge([], ...$namespaces))));
  52559. }
  52560. public function findNamespace(string $namespace)
  52561. {
  52562. $allNamespaces = $this->getNamespaces();
  52563. $expr = implode('[^:]*:', array_map('preg_quote', explode(':', $namespace))).'[^:]*';
  52564. $namespaces = preg_grep('{^'.$expr.'}', $allNamespaces);
  52565. if (empty($namespaces)) {
  52566. $message = sprintf('There are no commands defined in the "%s" namespace.', $namespace);
  52567. if ($alternatives = $this->findAlternatives($namespace, $allNamespaces)) {
  52568. if (1 == \count($alternatives)) {
  52569. $message .= "\n\nDid you mean this?\n ";
  52570. } else {
  52571. $message .= "\n\nDid you mean one of these?\n ";
  52572. }
  52573. $message .= implode("\n ", $alternatives);
  52574. }
  52575. throw new NamespaceNotFoundException($message, $alternatives);
  52576. }
  52577. $exact = \in_array($namespace, $namespaces, true);
  52578. if (\count($namespaces) > 1 && !$exact) {
  52579. throw new NamespaceNotFoundException(sprintf("The namespace \"%s\" is ambiguous.\nDid you mean one of these?\n%s.", $namespace, $this->getAbbreviationSuggestions(array_values($namespaces))), array_values($namespaces));
  52580. }
  52581. return $exact ? $namespace : reset($namespaces);
  52582. }
  52583. public function find(string $name)
  52584. {
  52585. $this->init();
  52586. $aliases = [];
  52587. foreach ($this->commands as $command) {
  52588. foreach ($command->getAliases() as $alias) {
  52589. if (!$this->has($alias)) {
  52590. $this->commands[$alias] = $command;
  52591. }
  52592. }
  52593. }
  52594. if ($this->has($name)) {
  52595. return $this->get($name);
  52596. }
  52597. $allCommands = $this->commandLoader ? array_merge($this->commandLoader->getNames(), array_keys($this->commands)) : array_keys($this->commands);
  52598. $expr = implode('[^:]*:', array_map('preg_quote', explode(':', $name))).'[^:]*';
  52599. $commands = preg_grep('{^'.$expr.'}', $allCommands);
  52600. if (empty($commands)) {
  52601. $commands = preg_grep('{^'.$expr.'}i', $allCommands);
  52602. }
  52603. if (empty($commands) || \count(preg_grep('{^'.$expr.'$}i', $commands)) < 1) {
  52604. if (false !== $pos = strrpos($name, ':')) {
  52605. $this->findNamespace(substr($name, 0, $pos));
  52606. }
  52607. $message = sprintf('Command "%s" is not defined.', $name);
  52608. if ($alternatives = $this->findAlternatives($name, $allCommands)) {
  52609. $alternatives = array_filter($alternatives, function ($name) {
  52610. return !$this->get($name)->isHidden();
  52611. });
  52612. if (1 == \count($alternatives)) {
  52613. $message .= "\n\nDid you mean this?\n ";
  52614. } else {
  52615. $message .= "\n\nDid you mean one of these?\n ";
  52616. }
  52617. $message .= implode("\n ", $alternatives);
  52618. }
  52619. throw new CommandNotFoundException($message, array_values($alternatives));
  52620. }
  52621. if (\count($commands) > 1) {
  52622. $commandList = $this->commandLoader ? array_merge(array_flip($this->commandLoader->getNames()), $this->commands) : $this->commands;
  52623. $commands = array_unique(array_filter($commands, function ($nameOrAlias) use (&$commandList, $commands, &$aliases) {
  52624. if (!$commandList[$nameOrAlias] instanceof Command) {
  52625. $commandList[$nameOrAlias] = $this->commandLoader->get($nameOrAlias);
  52626. }
  52627. $commandName = $commandList[$nameOrAlias]->getName();
  52628. $aliases[$nameOrAlias] = $commandName;
  52629. return $commandName === $nameOrAlias || !\in_array($commandName, $commands);
  52630. }));
  52631. }
  52632. if (\count($commands) > 1) {
  52633. $usableWidth = $this->terminal->getWidth() - 10;
  52634. $abbrevs = array_values($commands);
  52635. $maxLen = 0;
  52636. foreach ($abbrevs as $abbrev) {
  52637. $maxLen = max(Helper::width($abbrev), $maxLen);
  52638. }
  52639. $abbrevs = array_map(function ($cmd) use ($commandList, $usableWidth, $maxLen, &$commands) {
  52640. if ($commandList[$cmd]->isHidden()) {
  52641. unset($commands[array_search($cmd, $commands)]);
  52642. return false;
  52643. }
  52644. $abbrev = str_pad($cmd, $maxLen, ' ').' '.$commandList[$cmd]->getDescription();
  52645. return Helper::width($abbrev) > $usableWidth ? Helper::substr($abbrev, 0, $usableWidth - 3).'...' : $abbrev;
  52646. }, array_values($commands));
  52647. if (\count($commands) > 1) {
  52648. $suggestions = $this->getAbbreviationSuggestions(array_filter($abbrevs));
  52649. throw new CommandNotFoundException(sprintf("Command \"%s\" is ambiguous.\nDid you mean one of these?\n%s.", $name, $suggestions), array_values($commands));
  52650. }
  52651. }
  52652. $command = $this->get(reset($commands));
  52653. if ($command->isHidden()) {
  52654. throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
  52655. }
  52656. return $command;
  52657. }
  52658. public function all(string $namespace = null)
  52659. {
  52660. $this->init();
  52661. if (null === $namespace) {
  52662. if (!$this->commandLoader) {
  52663. return $this->commands;
  52664. }
  52665. $commands = $this->commands;
  52666. foreach ($this->commandLoader->getNames() as $name) {
  52667. if (!isset($commands[$name]) && $this->has($name)) {
  52668. $commands[$name] = $this->get($name);
  52669. }
  52670. }
  52671. return $commands;
  52672. }
  52673. $commands = [];
  52674. foreach ($this->commands as $name => $command) {
  52675. if ($namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1)) {
  52676. $commands[$name] = $command;
  52677. }
  52678. }
  52679. if ($this->commandLoader) {
  52680. foreach ($this->commandLoader->getNames() as $name) {
  52681. if (!isset($commands[$name]) && $namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1) && $this->has($name)) {
  52682. $commands[$name] = $this->get($name);
  52683. }
  52684. }
  52685. }
  52686. return $commands;
  52687. }
  52688. public static function getAbbreviations(array $names)
  52689. {
  52690. $abbrevs = [];
  52691. foreach ($names as $name) {
  52692. for ($len = \strlen($name); $len > 0; --$len) {
  52693. $abbrev = substr($name, 0, $len);
  52694. $abbrevs[$abbrev][] = $name;
  52695. }
  52696. }
  52697. return $abbrevs;
  52698. }
  52699. public function renderThrowable(\Throwable $e, OutputInterface $output): void
  52700. {
  52701. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  52702. $this->doRenderThrowable($e, $output);
  52703. if (null !== $this->runningCommand) {
  52704. $output->writeln(sprintf('<info>%s</info>', OutputFormatter::escape(sprintf($this->runningCommand->getSynopsis(), $this->getName()))), OutputInterface::VERBOSITY_QUIET);
  52705. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  52706. }
  52707. }
  52708. protected function doRenderThrowable(\Throwable $e, OutputInterface $output): void
  52709. {
  52710. do {
  52711. $message = trim($e->getMessage());
  52712. if ('' === $message || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
  52713. $class = get_debug_type($e);
  52714. $title = sprintf(' [%s%s] ', $class, 0 !== ($code = $e->getCode()) ? ' ('.$code.')' : '');
  52715. $len = Helper::width($title);
  52716. } else {
  52717. $len = 0;
  52718. }
  52719. if (str_contains($message, "@anonymous\0")) {
  52720. $message = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) {
  52721. return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0];
  52722. }, $message);
  52723. }
  52724. $width = $this->terminal->getWidth() ? $this->terminal->getWidth() - 1 : \PHP_INT_MAX;
  52725. $lines = [];
  52726. foreach ('' !== $message ? preg_split('/\r?\n/', $message) : [] as $line) {
  52727. foreach ($this->splitStringByWidth($line, $width - 4) as $line) {
  52728. $lineLength = Helper::width($line) + 4;
  52729. $lines[] = [$line, $lineLength];
  52730. $len = max($lineLength, $len);
  52731. }
  52732. }
  52733. $messages = [];
  52734. if (!$e instanceof ExceptionInterface || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
  52735. $messages[] = sprintf('<comment>%s</comment>', OutputFormatter::escape(sprintf('In %s line %s:', basename($e->getFile()) ?: 'n/a', $e->getLine() ?: 'n/a')));
  52736. }
  52737. $messages[] = $emptyLine = sprintf('<error>%s</error>', str_repeat(' ', $len));
  52738. if ('' === $message || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
  52739. $messages[] = sprintf('<error>%s%s</error>', $title, str_repeat(' ', max(0, $len - Helper::width($title))));
  52740. }
  52741. foreach ($lines as $line) {
  52742. $messages[] = sprintf('<error> %s %s</error>', OutputFormatter::escape($line[0]), str_repeat(' ', $len - $line[1]));
  52743. }
  52744. $messages[] = $emptyLine;
  52745. $messages[] = '';
  52746. $output->writeln($messages, OutputInterface::VERBOSITY_QUIET);
  52747. if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
  52748. $output->writeln('<comment>Exception trace:</comment>', OutputInterface::VERBOSITY_QUIET);
  52749. $trace = $e->getTrace();
  52750. array_unshift($trace, [
  52751. 'function' => '',
  52752. 'file' => $e->getFile() ?: 'n/a',
  52753. 'line' => $e->getLine() ?: 'n/a',
  52754. 'args' => [],
  52755. ]);
  52756. for ($i = 0, $count = \count($trace); $i < $count; ++$i) {
  52757. $class = $trace[$i]['class'] ?? '';
  52758. $type = $trace[$i]['type'] ?? '';
  52759. $function = $trace[$i]['function'] ?? '';
  52760. $file = $trace[$i]['file'] ?? 'n/a';
  52761. $line = $trace[$i]['line'] ?? 'n/a';
  52762. $output->writeln(sprintf(' %s%s at <info>%s:%s</info>', $class, $function ? $type.$function.'()' : '', $file, $line), OutputInterface::VERBOSITY_QUIET);
  52763. }
  52764. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  52765. }
  52766. } while ($e = $e->getPrevious());
  52767. }
  52768. protected function configureIO(InputInterface $input, OutputInterface $output)
  52769. {
  52770. if (true === $input->hasParameterOption(['--ansi'], true)) {
  52771. $output->setDecorated(true);
  52772. } elseif (true === $input->hasParameterOption(['--no-ansi'], true)) {
  52773. $output->setDecorated(false);
  52774. }
  52775. if (true === $input->hasParameterOption(['--no-interaction', '-n'], true)) {
  52776. $input->setInteractive(false);
  52777. }
  52778. switch ($shellVerbosity = (int) getenv('SHELL_VERBOSITY')) {
  52779. case -1: $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); break;
  52780. case 1: $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); break;
  52781. case 2: $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); break;
  52782. case 3: $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); break;
  52783. default: $shellVerbosity = 0; break;
  52784. }
  52785. if (true === $input->hasParameterOption(['--quiet', '-q'], true)) {
  52786. $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
  52787. $shellVerbosity = -1;
  52788. } else {
  52789. if ($input->hasParameterOption('-vvv', true) || $input->hasParameterOption('--verbose=3', true) || 3 === $input->getParameterOption('--verbose', false, true)) {
  52790. $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
  52791. $shellVerbosity = 3;
  52792. } elseif ($input->hasParameterOption('-vv', true) || $input->hasParameterOption('--verbose=2', true) || 2 === $input->getParameterOption('--verbose', false, true)) {
  52793. $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
  52794. $shellVerbosity = 2;
  52795. } elseif ($input->hasParameterOption('-v', true) || $input->hasParameterOption('--verbose=1', true) || $input->hasParameterOption('--verbose', true) || $input->getParameterOption('--verbose', false, true)) {
  52796. $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
  52797. $shellVerbosity = 1;
  52798. }
  52799. }
  52800. if (-1 === $shellVerbosity) {
  52801. $input->setInteractive(false);
  52802. }
  52803. if (\function_exists('putenv')) {
  52804. @putenv('SHELL_VERBOSITY='.$shellVerbosity);
  52805. }
  52806. $_ENV['SHELL_VERBOSITY'] = $shellVerbosity;
  52807. $_SERVER['SHELL_VERBOSITY'] = $shellVerbosity;
  52808. }
  52809. protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
  52810. {
  52811. foreach ($command->getHelperSet() as $helper) {
  52812. if ($helper instanceof InputAwareInterface) {
  52813. $helper->setInput($input);
  52814. }
  52815. }
  52816. if ($command instanceof SignalableCommandInterface && ($this->signalsToDispatchEvent || $command->getSubscribedSignals())) {
  52817. if (!$this->signalRegistry) {
  52818. throw new RuntimeException('Unable to subscribe to signal events. Make sure that the `pcntl` extension is installed and that "pcntl_*" functions are not disabled by your php.ini\'s "disable_functions" directive.');
  52819. }
  52820. if (Terminal::hasSttyAvailable()) {
  52821. $sttyMode = shell_exec('stty -g');
  52822. foreach ([\SIGINT, \SIGTERM] as $signal) {
  52823. $this->signalRegistry->register($signal, static function () use ($sttyMode) {
  52824. shell_exec('stty '.$sttyMode);
  52825. });
  52826. }
  52827. }
  52828. if ($this->dispatcher) {
  52829. foreach ($this->signalsToDispatchEvent as $signal) {
  52830. $event = new ConsoleSignalEvent($command, $input, $output, $signal);
  52831. $this->signalRegistry->register($signal, function ($signal, $hasNext) use ($event) {
  52832. $this->dispatcher->dispatch($event, ConsoleEvents::SIGNAL);
  52833. if (!$hasNext) {
  52834. if (!\in_array($signal, [\SIGUSR1, \SIGUSR2], true)) {
  52835. exit(0);
  52836. }
  52837. }
  52838. });
  52839. }
  52840. }
  52841. foreach ($command->getSubscribedSignals() as $signal) {
  52842. $this->signalRegistry->register($signal, [$command, 'handleSignal']);
  52843. }
  52844. }
  52845. if (null === $this->dispatcher) {
  52846. return $command->run($input, $output);
  52847. }
  52848. try {
  52849. $command->mergeApplicationDefinition();
  52850. $input->bind($command->getDefinition());
  52851. } catch (ExceptionInterface $e) {
  52852. }
  52853. $event = new ConsoleCommandEvent($command, $input, $output);
  52854. $e = null;
  52855. try {
  52856. $this->dispatcher->dispatch($event, ConsoleEvents::COMMAND);
  52857. if ($event->commandShouldRun()) {
  52858. $exitCode = $command->run($input, $output);
  52859. } else {
  52860. $exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
  52861. }
  52862. } catch (\Throwable $e) {
  52863. $event = new ConsoleErrorEvent($input, $output, $e, $command);
  52864. $this->dispatcher->dispatch($event, ConsoleEvents::ERROR);
  52865. $e = $event->getError();
  52866. if (0 === $exitCode = $event->getExitCode()) {
  52867. $e = null;
  52868. }
  52869. }
  52870. $event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
  52871. $this->dispatcher->dispatch($event, ConsoleEvents::TERMINATE);
  52872. if (null !== $e) {
  52873. throw $e;
  52874. }
  52875. return $event->getExitCode();
  52876. }
  52877. protected function getCommandName(InputInterface $input)
  52878. {
  52879. return $this->singleCommand ? $this->defaultCommand : $input->getFirstArgument();
  52880. }
  52881. protected function getDefaultInputDefinition()
  52882. {
  52883. return new InputDefinition([
  52884. new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'),
  52885. new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display help for the given command. When no command is given display help for the <info>'.$this->defaultCommand.'</info> command'),
  52886. new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'),
  52887. 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'),
  52888. new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version'),
  52889. new InputOption('--ansi', '', InputOption::VALUE_NEGATABLE, 'Force (or disable --no-ansi) ANSI output', null),
  52890. new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question'),
  52891. ]);
  52892. }
  52893. protected function getDefaultCommands()
  52894. {
  52895. return [new HelpCommand(), new ListCommand(), new CompleteCommand(), new DumpCompletionCommand()];
  52896. }
  52897. protected function getDefaultHelperSet()
  52898. {
  52899. return new HelperSet([
  52900. new FormatterHelper(),
  52901. new DebugFormatterHelper(),
  52902. new ProcessHelper(),
  52903. new QuestionHelper(),
  52904. ]);
  52905. }
  52906. private function getAbbreviationSuggestions(array $abbrevs): string
  52907. {
  52908. return ' '.implode("\n ", $abbrevs);
  52909. }
  52910. public function extractNamespace(string $name, int $limit = null)
  52911. {
  52912. $parts = explode(':', $name, -1);
  52913. return implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit));
  52914. }
  52915. private function findAlternatives(string $name, iterable $collection): array
  52916. {
  52917. $threshold = 1e3;
  52918. $alternatives = [];
  52919. $collectionParts = [];
  52920. foreach ($collection as $item) {
  52921. $collectionParts[$item] = explode(':', $item);
  52922. }
  52923. foreach (explode(':', $name) as $i => $subname) {
  52924. foreach ($collectionParts as $collectionName => $parts) {
  52925. $exists = isset($alternatives[$collectionName]);
  52926. if (!isset($parts[$i]) && $exists) {
  52927. $alternatives[$collectionName] += $threshold;
  52928. continue;
  52929. } elseif (!isset($parts[$i])) {
  52930. continue;
  52931. }
  52932. $lev = levenshtein($subname, $parts[$i]);
  52933. if ($lev <= \strlen($subname) / 3 || '' !== $subname && str_contains($parts[$i], $subname)) {
  52934. $alternatives[$collectionName] = $exists ? $alternatives[$collectionName] + $lev : $lev;
  52935. } elseif ($exists) {
  52936. $alternatives[$collectionName] += $threshold;
  52937. }
  52938. }
  52939. }
  52940. foreach ($collection as $item) {
  52941. $lev = levenshtein($name, $item);
  52942. if ($lev <= \strlen($name) / 3 || str_contains($item, $name)) {
  52943. $alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev;
  52944. }
  52945. }
  52946. $alternatives = array_filter($alternatives, function ($lev) use ($threshold) { return $lev < 2 * $threshold; });
  52947. ksort($alternatives, \SORT_NATURAL | \SORT_FLAG_CASE);
  52948. return array_keys($alternatives);
  52949. }
  52950. public function setDefaultCommand(string $commandName, bool $isSingleCommand = false)
  52951. {
  52952. $this->defaultCommand = explode('|', ltrim($commandName, '|'))[0];
  52953. if ($isSingleCommand) {
  52954. $this->find($commandName);
  52955. $this->singleCommand = true;
  52956. }
  52957. return $this;
  52958. }
  52959. public function isSingleCommand(): bool
  52960. {
  52961. return $this->singleCommand;
  52962. }
  52963. private function splitStringByWidth(string $string, int $width): array
  52964. {
  52965. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  52966. return str_split($string, $width);
  52967. }
  52968. $utf8String = mb_convert_encoding($string, 'utf8', $encoding);
  52969. $lines = [];
  52970. $line = '';
  52971. $offset = 0;
  52972. while (preg_match('/.{1,10000}/u', $utf8String, $m, 0, $offset)) {
  52973. $offset += \strlen($m[0]);
  52974. foreach (preg_split('//u', $m[0]) as $char) {
  52975. if (mb_strwidth($line.$char, 'utf8') <= $width) {
  52976. $line .= $char;
  52977. continue;
  52978. }
  52979. $lines[] = str_pad($line, $width);
  52980. $line = $char;
  52981. }
  52982. }
  52983. $lines[] = \count($lines) ? str_pad($line, $width) : $line;
  52984. mb_convert_variables($encoding, 'utf8', $lines);
  52985. return $lines;
  52986. }
  52987. private function extractAllNamespaces(string $name): array
  52988. {
  52989. $parts = explode(':', $name, -1);
  52990. $namespaces = [];
  52991. foreach ($parts as $part) {
  52992. if (\count($namespaces)) {
  52993. $namespaces[] = end($namespaces).':'.$part;
  52994. } else {
  52995. $namespaces[] = $part;
  52996. }
  52997. }
  52998. return $namespaces;
  52999. }
  53000. private function init()
  53001. {
  53002. if ($this->initialized) {
  53003. return;
  53004. }
  53005. $this->initialized = true;
  53006. foreach ($this->getDefaultCommands() as $command) {
  53007. $this->add($command);
  53008. }
  53009. }
  53010. }
  53011. <?php
  53012. namespace Symfony\Component\Console\Attribute;
  53013. #[\Attribute(\Attribute::TARGET_CLASS)]
  53014. class AsCommand
  53015. {
  53016. public function __construct(
  53017. public string $name,
  53018. public ?string $description = null,
  53019. array $aliases = [],
  53020. bool $hidden = false,
  53021. ) {
  53022. if (!$hidden && !$aliases) {
  53023. return;
  53024. }
  53025. $name = explode('|', $name);
  53026. $name = array_merge($name, $aliases);
  53027. if ($hidden && '' !== $name[0]) {
  53028. array_unshift($name, '');
  53029. }
  53030. $this->name = implode('|', $name);
  53031. }
  53032. }
  53033. <?php
  53034. namespace Symfony\Component\Console\CI;
  53035. use Symfony\Component\Console\Output\OutputInterface;
  53036. class GithubActionReporter
  53037. {
  53038. private $output;
  53039. private const ESCAPED_DATA = [
  53040. '%' => '%25',
  53041. "\r" => '%0D',
  53042. "\n" => '%0A',
  53043. ];
  53044. private const ESCAPED_PROPERTIES = [
  53045. '%' => '%25',
  53046. "\r" => '%0D',
  53047. "\n" => '%0A',
  53048. ':' => '%3A',
  53049. ',' => '%2C',
  53050. ];
  53051. public function __construct(OutputInterface $output)
  53052. {
  53053. $this->output = $output;
  53054. }
  53055. public static function isGithubActionEnvironment(): bool
  53056. {
  53057. return false !== getenv('GITHUB_ACTIONS');
  53058. }
  53059. public function error(string $message, string $file = null, int $line = null, int $col = null): void
  53060. {
  53061. $this->log('error', $message, $file, $line, $col);
  53062. }
  53063. public function warning(string $message, string $file = null, int $line = null, int $col = null): void
  53064. {
  53065. $this->log('warning', $message, $file, $line, $col);
  53066. }
  53067. public function debug(string $message, string $file = null, int $line = null, int $col = null): void
  53068. {
  53069. $this->log('debug', $message, $file, $line, $col);
  53070. }
  53071. private function log(string $type, string $message, string $file = null, int $line = null, int $col = null): void
  53072. {
  53073. $message = strtr($message, self::ESCAPED_DATA);
  53074. if (!$file) {
  53075. $this->output->writeln(sprintf('::%s::%s', $type, $message));
  53076. return;
  53077. }
  53078. $this->output->writeln(sprintf('::%s file=%s,line=%s,col=%s::%s', $type, strtr($file, self::ESCAPED_PROPERTIES), strtr($line ?? 1, self::ESCAPED_PROPERTIES), strtr($col ?? 0, self::ESCAPED_PROPERTIES), $message));
  53079. }
  53080. }
  53081. <?php
  53082. namespace Symfony\Component\Console;
  53083. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53084. final class Color
  53085. {
  53086. private const COLORS = [
  53087. 'black' => 0,
  53088. 'red' => 1,
  53089. 'green' => 2,
  53090. 'yellow' => 3,
  53091. 'blue' => 4,
  53092. 'magenta' => 5,
  53093. 'cyan' => 6,
  53094. 'white' => 7,
  53095. 'default' => 9,
  53096. ];
  53097. private const BRIGHT_COLORS = [
  53098. 'gray' => 0,
  53099. 'bright-red' => 1,
  53100. 'bright-green' => 2,
  53101. 'bright-yellow' => 3,
  53102. 'bright-blue' => 4,
  53103. 'bright-magenta' => 5,
  53104. 'bright-cyan' => 6,
  53105. 'bright-white' => 7,
  53106. ];
  53107. private const AVAILABLE_OPTIONS = [
  53108. 'bold' => ['set' => 1, 'unset' => 22],
  53109. 'underscore' => ['set' => 4, 'unset' => 24],
  53110. 'blink' => ['set' => 5, 'unset' => 25],
  53111. 'reverse' => ['set' => 7, 'unset' => 27],
  53112. 'conceal' => ['set' => 8, 'unset' => 28],
  53113. ];
  53114. private $foreground;
  53115. private $background;
  53116. private $options = [];
  53117. public function __construct(string $foreground = '', string $background = '', array $options = [])
  53118. {
  53119. $this->foreground = $this->parseColor($foreground);
  53120. $this->background = $this->parseColor($background, true);
  53121. foreach ($options as $option) {
  53122. if (!isset(self::AVAILABLE_OPTIONS[$option])) {
  53123. throw new InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s).', $option, implode(', ', array_keys(self::AVAILABLE_OPTIONS))));
  53124. }
  53125. $this->options[$option] = self::AVAILABLE_OPTIONS[$option];
  53126. }
  53127. }
  53128. public function apply(string $text): string
  53129. {
  53130. return $this->set().$text.$this->unset();
  53131. }
  53132. public function set(): string
  53133. {
  53134. $setCodes = [];
  53135. if ('' !== $this->foreground) {
  53136. $setCodes[] = $this->foreground;
  53137. }
  53138. if ('' !== $this->background) {
  53139. $setCodes[] = $this->background;
  53140. }
  53141. foreach ($this->options as $option) {
  53142. $setCodes[] = $option['set'];
  53143. }
  53144. if (0 === \count($setCodes)) {
  53145. return '';
  53146. }
  53147. return sprintf("\033[%sm", implode(';', $setCodes));
  53148. }
  53149. public function unset(): string
  53150. {
  53151. $unsetCodes = [];
  53152. if ('' !== $this->foreground) {
  53153. $unsetCodes[] = 39;
  53154. }
  53155. if ('' !== $this->background) {
  53156. $unsetCodes[] = 49;
  53157. }
  53158. foreach ($this->options as $option) {
  53159. $unsetCodes[] = $option['unset'];
  53160. }
  53161. if (0 === \count($unsetCodes)) {
  53162. return '';
  53163. }
  53164. return sprintf("\033[%sm", implode(';', $unsetCodes));
  53165. }
  53166. private function parseColor(string $color, bool $background = false): string
  53167. {
  53168. if ('' === $color) {
  53169. return '';
  53170. }
  53171. if ('#' === $color[0]) {
  53172. $color = substr($color, 1);
  53173. if (3 === \strlen($color)) {
  53174. $color = $color[0].$color[0].$color[1].$color[1].$color[2].$color[2];
  53175. }
  53176. if (6 !== \strlen($color)) {
  53177. throw new InvalidArgumentException(sprintf('Invalid "%s" color.', $color));
  53178. }
  53179. return ($background ? '4' : '3').$this->convertHexColorToAnsi(hexdec($color));
  53180. }
  53181. if (isset(self::COLORS[$color])) {
  53182. return ($background ? '4' : '3').self::COLORS[$color];
  53183. }
  53184. if (isset(self::BRIGHT_COLORS[$color])) {
  53185. return ($background ? '10' : '9').self::BRIGHT_COLORS[$color];
  53186. }
  53187. throw new InvalidArgumentException(sprintf('Invalid "%s" color; expected one of (%s).', $color, implode(', ', array_merge(array_keys(self::COLORS), array_keys(self::BRIGHT_COLORS)))));
  53188. }
  53189. private function convertHexColorToAnsi(int $color): string
  53190. {
  53191. $r = ($color >> 16) & 255;
  53192. $g = ($color >> 8) & 255;
  53193. $b = $color & 255;
  53194. if ('truecolor' !== getenv('COLORTERM')) {
  53195. return (string) $this->degradeHexColorToAnsi($r, $g, $b);
  53196. }
  53197. return sprintf('8;2;%d;%d;%d', $r, $g, $b);
  53198. }
  53199. private function degradeHexColorToAnsi(int $r, int $g, int $b): int
  53200. {
  53201. if (0 === round($this->getSaturation($r, $g, $b) / 50)) {
  53202. return 0;
  53203. }
  53204. return (round($b / 255) << 2) | (round($g / 255) << 1) | round($r / 255);
  53205. }
  53206. private function getSaturation(int $r, int $g, int $b): int
  53207. {
  53208. $r = $r / 255;
  53209. $g = $g / 255;
  53210. $b = $b / 255;
  53211. $v = max($r, $g, $b);
  53212. if (0 === $diff = $v - min($r, $g, $b)) {
  53213. return 0;
  53214. }
  53215. return (int) $diff * 100 / $v;
  53216. }
  53217. }
  53218. <?php
  53219. namespace Symfony\Component\Console\Command;
  53220. use Symfony\Component\Console\Application;
  53221. use Symfony\Component\Console\Attribute\AsCommand;
  53222. use Symfony\Component\Console\Completion\CompletionInput;
  53223. use Symfony\Component\Console\Completion\CompletionSuggestions;
  53224. use Symfony\Component\Console\Exception\ExceptionInterface;
  53225. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53226. use Symfony\Component\Console\Exception\LogicException;
  53227. use Symfony\Component\Console\Helper\HelperSet;
  53228. use Symfony\Component\Console\Input\InputArgument;
  53229. use Symfony\Component\Console\Input\InputDefinition;
  53230. use Symfony\Component\Console\Input\InputInterface;
  53231. use Symfony\Component\Console\Input\InputOption;
  53232. use Symfony\Component\Console\Output\OutputInterface;
  53233. class Command
  53234. {
  53235. public const SUCCESS = 0;
  53236. public const FAILURE = 1;
  53237. public const INVALID = 2;
  53238. protected static $defaultName;
  53239. protected static $defaultDescription;
  53240. private $application;
  53241. private $name;
  53242. private $processTitle;
  53243. private $aliases = [];
  53244. private $definition;
  53245. private $hidden = false;
  53246. private $help = '';
  53247. private $description = '';
  53248. private $fullDefinition;
  53249. private $ignoreValidationErrors = false;
  53250. private $code;
  53251. private $synopsis = [];
  53252. private $usages = [];
  53253. private $helperSet;
  53254. public static function getDefaultName()
  53255. {
  53256. $class = static::class;
  53257. if (\PHP_VERSION_ID >= 80000 && $attribute = (new \ReflectionClass($class))->getAttributes(AsCommand::class)) {
  53258. return $attribute[0]->newInstance()->name;
  53259. }
  53260. $r = new \ReflectionProperty($class, 'defaultName');
  53261. return $class === $r->class ? static::$defaultName : null;
  53262. }
  53263. public static function getDefaultDescription(): ?string
  53264. {
  53265. $class = static::class;
  53266. if (\PHP_VERSION_ID >= 80000 && $attribute = (new \ReflectionClass($class))->getAttributes(AsCommand::class)) {
  53267. return $attribute[0]->newInstance()->description;
  53268. }
  53269. $r = new \ReflectionProperty($class, 'defaultDescription');
  53270. return $class === $r->class ? static::$defaultDescription : null;
  53271. }
  53272. public function __construct(string $name = null)
  53273. {
  53274. $this->definition = new InputDefinition();
  53275. if (null === $name && null !== $name = static::getDefaultName()) {
  53276. $aliases = explode('|', $name);
  53277. if ('' === $name = array_shift($aliases)) {
  53278. $this->setHidden(true);
  53279. $name = array_shift($aliases);
  53280. }
  53281. $this->setAliases($aliases);
  53282. }
  53283. if (null !== $name) {
  53284. $this->setName($name);
  53285. }
  53286. if ('' === $this->description) {
  53287. $this->setDescription(static::getDefaultDescription() ?? '');
  53288. }
  53289. $this->configure();
  53290. }
  53291. public function ignoreValidationErrors()
  53292. {
  53293. $this->ignoreValidationErrors = true;
  53294. }
  53295. public function setApplication(Application $application = null)
  53296. {
  53297. $this->application = $application;
  53298. if ($application) {
  53299. $this->setHelperSet($application->getHelperSet());
  53300. } else {
  53301. $this->helperSet = null;
  53302. }
  53303. $this->fullDefinition = null;
  53304. }
  53305. public function setHelperSet(HelperSet $helperSet)
  53306. {
  53307. $this->helperSet = $helperSet;
  53308. }
  53309. public function getHelperSet()
  53310. {
  53311. return $this->helperSet;
  53312. }
  53313. public function getApplication()
  53314. {
  53315. return $this->application;
  53316. }
  53317. public function isEnabled()
  53318. {
  53319. return true;
  53320. }
  53321. protected function configure()
  53322. {
  53323. }
  53324. protected function execute(InputInterface $input, OutputInterface $output)
  53325. {
  53326. throw new LogicException('You must override the execute() method in the concrete command class.');
  53327. }
  53328. protected function interact(InputInterface $input, OutputInterface $output)
  53329. {
  53330. }
  53331. protected function initialize(InputInterface $input, OutputInterface $output)
  53332. {
  53333. }
  53334. public function run(InputInterface $input, OutputInterface $output)
  53335. {
  53336. $this->mergeApplicationDefinition();
  53337. try {
  53338. $input->bind($this->getDefinition());
  53339. } catch (ExceptionInterface $e) {
  53340. if (!$this->ignoreValidationErrors) {
  53341. throw $e;
  53342. }
  53343. }
  53344. $this->initialize($input, $output);
  53345. if (null !== $this->processTitle) {
  53346. if (\function_exists('cli_set_process_title')) {
  53347. if (!@cli_set_process_title($this->processTitle)) {
  53348. if ('Darwin' === \PHP_OS) {
  53349. $output->writeln('<comment>Running "cli_set_process_title" as an unprivileged user is not supported on MacOS.</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE);
  53350. } else {
  53351. cli_set_process_title($this->processTitle);
  53352. }
  53353. }
  53354. } elseif (\function_exists('setproctitle')) {
  53355. setproctitle($this->processTitle);
  53356. } elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) {
  53357. $output->writeln('<comment>Install the proctitle PECL to be able to change the process title.</comment>');
  53358. }
  53359. }
  53360. if ($input->isInteractive()) {
  53361. $this->interact($input, $output);
  53362. }
  53363. if ($input->hasArgument('command') && null === $input->getArgument('command')) {
  53364. $input->setArgument('command', $this->getName());
  53365. }
  53366. $input->validate();
  53367. if ($this->code) {
  53368. $statusCode = ($this->code)($input, $output);
  53369. } else {
  53370. $statusCode = $this->execute($input, $output);
  53371. if (!\is_int($statusCode)) {
  53372. throw new \TypeError(sprintf('Return value of "%s::execute()" must be of the type int, "%s" returned.', static::class, get_debug_type($statusCode)));
  53373. }
  53374. }
  53375. return is_numeric($statusCode) ? (int) $statusCode : 0;
  53376. }
  53377. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  53378. {
  53379. }
  53380. public function setCode(callable $code)
  53381. {
  53382. if ($code instanceof \Closure) {
  53383. $r = new \ReflectionFunction($code);
  53384. if (null === $r->getClosureThis()) {
  53385. set_error_handler(static function () {});
  53386. try {
  53387. if ($c = \Closure::bind($code, $this)) {
  53388. $code = $c;
  53389. }
  53390. } finally {
  53391. restore_error_handler();
  53392. }
  53393. }
  53394. }
  53395. $this->code = $code;
  53396. return $this;
  53397. }
  53398. public function mergeApplicationDefinition(bool $mergeArgs = true)
  53399. {
  53400. if (null === $this->application) {
  53401. return;
  53402. }
  53403. $this->fullDefinition = new InputDefinition();
  53404. $this->fullDefinition->setOptions($this->definition->getOptions());
  53405. $this->fullDefinition->addOptions($this->application->getDefinition()->getOptions());
  53406. if ($mergeArgs) {
  53407. $this->fullDefinition->setArguments($this->application->getDefinition()->getArguments());
  53408. $this->fullDefinition->addArguments($this->definition->getArguments());
  53409. } else {
  53410. $this->fullDefinition->setArguments($this->definition->getArguments());
  53411. }
  53412. }
  53413. public function setDefinition($definition)
  53414. {
  53415. if ($definition instanceof InputDefinition) {
  53416. $this->definition = $definition;
  53417. } else {
  53418. $this->definition->setDefinition($definition);
  53419. }
  53420. $this->fullDefinition = null;
  53421. return $this;
  53422. }
  53423. public function getDefinition()
  53424. {
  53425. return $this->fullDefinition ?? $this->getNativeDefinition();
  53426. }
  53427. public function getNativeDefinition()
  53428. {
  53429. if (null === $this->definition) {
  53430. throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', static::class));
  53431. }
  53432. return $this->definition;
  53433. }
  53434. public function addArgument(string $name, int $mode = null, string $description = '', $default = null)
  53435. {
  53436. $this->definition->addArgument(new InputArgument($name, $mode, $description, $default));
  53437. if (null !== $this->fullDefinition) {
  53438. $this->fullDefinition->addArgument(new InputArgument($name, $mode, $description, $default));
  53439. }
  53440. return $this;
  53441. }
  53442. public function addOption(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null)
  53443. {
  53444. $this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default));
  53445. if (null !== $this->fullDefinition) {
  53446. $this->fullDefinition->addOption(new InputOption($name, $shortcut, $mode, $description, $default));
  53447. }
  53448. return $this;
  53449. }
  53450. public function setName(string $name)
  53451. {
  53452. $this->validateName($name);
  53453. $this->name = $name;
  53454. return $this;
  53455. }
  53456. public function setProcessTitle(string $title)
  53457. {
  53458. $this->processTitle = $title;
  53459. return $this;
  53460. }
  53461. public function getName()
  53462. {
  53463. return $this->name;
  53464. }
  53465. public function setHidden(bool $hidden )
  53466. {
  53467. $this->hidden = $hidden;
  53468. return $this;
  53469. }
  53470. public function isHidden()
  53471. {
  53472. return $this->hidden;
  53473. }
  53474. public function setDescription(string $description)
  53475. {
  53476. $this->description = $description;
  53477. return $this;
  53478. }
  53479. public function getDescription()
  53480. {
  53481. return $this->description;
  53482. }
  53483. public function setHelp(string $help)
  53484. {
  53485. $this->help = $help;
  53486. return $this;
  53487. }
  53488. public function getHelp()
  53489. {
  53490. return $this->help;
  53491. }
  53492. public function getProcessedHelp()
  53493. {
  53494. $name = $this->name;
  53495. $isSingleCommand = $this->application && $this->application->isSingleCommand();
  53496. $placeholders = [
  53497. '%command.name%',
  53498. '%command.full_name%',
  53499. ];
  53500. $replacements = [
  53501. $name,
  53502. $isSingleCommand ? $_SERVER['PHP_SELF'] : $_SERVER['PHP_SELF'].' '.$name,
  53503. ];
  53504. return str_replace($placeholders, $replacements, $this->getHelp() ?: $this->getDescription());
  53505. }
  53506. public function setAliases(iterable $aliases)
  53507. {
  53508. $list = [];
  53509. foreach ($aliases as $alias) {
  53510. $this->validateName($alias);
  53511. $list[] = $alias;
  53512. }
  53513. $this->aliases = \is_array($aliases) ? $aliases : $list;
  53514. return $this;
  53515. }
  53516. public function getAliases()
  53517. {
  53518. return $this->aliases;
  53519. }
  53520. public function getSynopsis(bool $short = false)
  53521. {
  53522. $key = $short ? 'short' : 'long';
  53523. if (!isset($this->synopsis[$key])) {
  53524. $this->synopsis[$key] = trim(sprintf('%s %s', $this->name, $this->definition->getSynopsis($short)));
  53525. }
  53526. return $this->synopsis[$key];
  53527. }
  53528. public function addUsage(string $usage)
  53529. {
  53530. if (!str_starts_with($usage, $this->name)) {
  53531. $usage = sprintf('%s %s', $this->name, $usage);
  53532. }
  53533. $this->usages[] = $usage;
  53534. return $this;
  53535. }
  53536. public function getUsages()
  53537. {
  53538. return $this->usages;
  53539. }
  53540. public function getHelper(string $name)
  53541. {
  53542. if (null === $this->helperSet) {
  53543. 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));
  53544. }
  53545. return $this->helperSet->get($name);
  53546. }
  53547. private function validateName(string $name)
  53548. {
  53549. if (!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) {
  53550. throw new InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name));
  53551. }
  53552. }
  53553. }
  53554. <?php
  53555. namespace Symfony\Component\Console\Command;
  53556. use Symfony\Component\Console\Completion\CompletionInput;
  53557. use Symfony\Component\Console\Completion\CompletionSuggestions;
  53558. use Symfony\Component\Console\Completion\Output\BashCompletionOutput;
  53559. use Symfony\Component\Console\Completion\Output\CompletionOutputInterface;
  53560. use Symfony\Component\Console\Exception\CommandNotFoundException;
  53561. use Symfony\Component\Console\Exception\ExceptionInterface;
  53562. use Symfony\Component\Console\Input\InputInterface;
  53563. use Symfony\Component\Console\Input\InputOption;
  53564. use Symfony\Component\Console\Output\OutputInterface;
  53565. final class CompleteCommand extends Command
  53566. {
  53567. protected static $defaultName = '|_complete';
  53568. protected static $defaultDescription = 'Internal command to provide shell completion suggestions';
  53569. private $completionOutputs;
  53570. private $isDebug = false;
  53571. public function __construct(array $completionOutputs = [])
  53572. {
  53573. $this->completionOutputs = $completionOutputs + ['bash' => BashCompletionOutput::class];
  53574. parent::__construct();
  53575. }
  53576. protected function configure(): void
  53577. {
  53578. $this
  53579. ->addOption('shell', 's', InputOption::VALUE_REQUIRED, 'The shell type ("'.implode('", "', array_keys($this->completionOutputs)).'")')
  53580. ->addOption('input', 'i', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'An array of input tokens (e.g. COMP_WORDS or argv)')
  53581. ->addOption('current', 'c', InputOption::VALUE_REQUIRED, 'The index of the "input" array that the cursor is in (e.g. COMP_CWORD)')
  53582. ->addOption('symfony', 'S', InputOption::VALUE_REQUIRED, 'The version of the completion script')
  53583. ;
  53584. }
  53585. protected function initialize(InputInterface $input, OutputInterface $output)
  53586. {
  53587. $this->isDebug = filter_var(getenv('SYMFONY_COMPLETION_DEBUG'), \FILTER_VALIDATE_BOOLEAN);
  53588. }
  53589. protected function execute(InputInterface $input, OutputInterface $output): int
  53590. {
  53591. try {
  53592. $shell = $input->getOption('shell');
  53593. if (!$shell) {
  53594. throw new \RuntimeException('The "--shell" option must be set.');
  53595. }
  53596. if (!$completionOutput = $this->completionOutputs[$shell] ?? false) {
  53597. throw new \RuntimeException(sprintf('Shell completion is not supported for your shell: "%s" (supported: "%s").', $shell, implode('", "', array_keys($this->completionOutputs))));
  53598. }
  53599. $completionInput = $this->createCompletionInput($input);
  53600. $suggestions = new CompletionSuggestions();
  53601. $this->log([
  53602. '',
  53603. '<comment>'.date('Y-m-d H:i:s').'</>',
  53604. '<info>Input:</> <comment>("|" indicates the cursor position)</>',
  53605. ' '.(string) $completionInput,
  53606. '<info>Command:</>',
  53607. ' '.(string) implode(' ', $_SERVER['argv']),
  53608. '<info>Messages:</>',
  53609. ]);
  53610. $command = $this->findCommand($completionInput, $output);
  53611. if (null === $command) {
  53612. $this->log(' No command found, completing using the Application class.');
  53613. $this->getApplication()->complete($completionInput, $suggestions);
  53614. } elseif (
  53615. $completionInput->mustSuggestArgumentValuesFor('command')
  53616. && $command->getName() !== $completionInput->getCompletionValue()
  53617. ) {
  53618. $this->log(' No command found, completing using the Application class.');
  53619. $suggestions->suggestValue($command->getName());
  53620. } else {
  53621. $command->mergeApplicationDefinition();
  53622. $completionInput->bind($command->getDefinition());
  53623. if (CompletionInput::TYPE_OPTION_NAME === $completionInput->getCompletionType()) {
  53624. $this->log(' Completing option names for the <comment>'.\get_class($command instanceof LazyCommand ? $command->getCommand() : $command).'</> command.');
  53625. $suggestions->suggestOptions($command->getDefinition()->getOptions());
  53626. } else {
  53627. $this->log([
  53628. ' Completing using the <comment>'.\get_class($command instanceof LazyCommand ? $command->getCommand() : $command).'</> class.',
  53629. ' Completing <comment>'.$completionInput->getCompletionType().'</> for <comment>'.$completionInput->getCompletionName().'</>',
  53630. ]);
  53631. if (null !== $compval = $completionInput->getCompletionValue()) {
  53632. $this->log(' Current value: <comment>'.$compval.'</>');
  53633. }
  53634. $command->complete($completionInput, $suggestions);
  53635. }
  53636. }
  53637. $completionOutput = new $completionOutput();
  53638. $this->log('<info>Suggestions:</>');
  53639. if ($options = $suggestions->getOptionSuggestions()) {
  53640. $this->log(' --'.implode(' --', array_map(function ($o) { return $o->getName(); }, $options)));
  53641. } elseif ($values = $suggestions->getValueSuggestions()) {
  53642. $this->log(' '.implode(' ', $values));
  53643. } else {
  53644. $this->log(' <comment>No suggestions were provided</>');
  53645. }
  53646. $completionOutput->write($suggestions, $output);
  53647. } catch (\Throwable $e) {
  53648. $this->log([
  53649. '<error>Error!</error>',
  53650. (string) $e,
  53651. ]);
  53652. if ($output->isDebug()) {
  53653. throw $e;
  53654. }
  53655. return self::FAILURE;
  53656. }
  53657. return self::SUCCESS;
  53658. }
  53659. private function createCompletionInput(InputInterface $input): CompletionInput
  53660. {
  53661. $currentIndex = $input->getOption('current');
  53662. if (!$currentIndex || !ctype_digit($currentIndex)) {
  53663. throw new \RuntimeException('The "--current" option must be set and it must be an integer.');
  53664. }
  53665. $completionInput = CompletionInput::fromTokens($input->getOption('input'), (int) $currentIndex);
  53666. try {
  53667. $completionInput->bind($this->getApplication()->getDefinition());
  53668. } catch (ExceptionInterface $e) {
  53669. }
  53670. return $completionInput;
  53671. }
  53672. private function findCommand(CompletionInput $completionInput, OutputInterface $output): ?Command
  53673. {
  53674. try {
  53675. $inputName = $completionInput->getFirstArgument();
  53676. if (null === $inputName) {
  53677. return null;
  53678. }
  53679. return $this->getApplication()->find($inputName);
  53680. } catch (CommandNotFoundException $e) {
  53681. }
  53682. return null;
  53683. }
  53684. private function log($messages): void
  53685. {
  53686. if (!$this->isDebug) {
  53687. return;
  53688. }
  53689. $commandName = basename($_SERVER['argv'][0]);
  53690. file_put_contents(sys_get_temp_dir().'/sf_'.$commandName.'.log', implode(\PHP_EOL, (array) $messages).\PHP_EOL, \FILE_APPEND);
  53691. }
  53692. }
  53693. <?php
  53694. namespace Symfony\Component\Console\Command;
  53695. use Symfony\Component\Console\Completion\CompletionInput;
  53696. use Symfony\Component\Console\Completion\CompletionSuggestions;
  53697. use Symfony\Component\Console\Input\InputArgument;
  53698. use Symfony\Component\Console\Input\InputInterface;
  53699. use Symfony\Component\Console\Input\InputOption;
  53700. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  53701. use Symfony\Component\Console\Output\OutputInterface;
  53702. use Symfony\Component\Process\Process;
  53703. final class DumpCompletionCommand extends Command
  53704. {
  53705. protected static $defaultName = 'completion';
  53706. protected static $defaultDescription = 'Dump the shell completion script';
  53707. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  53708. {
  53709. if ($input->mustSuggestArgumentValuesFor('shell')) {
  53710. $suggestions->suggestValues($this->getSupportedShells());
  53711. }
  53712. }
  53713. protected function configure()
  53714. {
  53715. $fullCommand = $_SERVER['PHP_SELF'];
  53716. $commandName = basename($fullCommand);
  53717. $fullCommand = realpath($fullCommand) ?: $fullCommand;
  53718. $this
  53719. ->setHelp(<<<EOH
  53720. The <info>%command.name%</> command dumps the shell completion script required
  53721. to use shell autocompletion (currently only bash completion is supported).
  53722. <comment>Static installation
  53723. -------------------</>
  53724. Dump the script to a global completion file and restart your shell:
  53725. <info>%command.full_name% bash | sudo tee /etc/bash_completion.d/${commandName}</>
  53726. Or dump the script to a local file and source it:
  53727. <info>%command.full_name% bash > completion.sh</>
  53728. <comment># source the file whenever you use the project</>
  53729. <info>source completion.sh</>
  53730. <comment># or add this line at the end of your "~/.bashrc" file:</>
  53731. <info>source /path/to/completion.sh</>
  53732. <comment>Dynamic installation
  53733. --------------------</>
  53734. Add this to the end of your shell configuration file (e.g. <info>"~/.bashrc"</>):
  53735. <info>eval "$(${fullCommand} completion bash)"</>
  53736. EOH
  53737. )
  53738. ->addArgument('shell', InputArgument::OPTIONAL, 'The shell type (e.g. "bash"), the value of the "$SHELL" env var will be used if this is not given')
  53739. ->addOption('debug', null, InputOption::VALUE_NONE, 'Tail the completion debug log')
  53740. ;
  53741. }
  53742. protected function execute(InputInterface $input, OutputInterface $output): int
  53743. {
  53744. $commandName = basename($_SERVER['argv'][0]);
  53745. if ($input->getOption('debug')) {
  53746. $this->tailDebugLog($commandName, $output);
  53747. return self::SUCCESS;
  53748. }
  53749. $shell = $input->getArgument('shell') ?? self::guessShell();
  53750. $completionFile = __DIR__.'/../Resources/completion.'.$shell;
  53751. if (!file_exists($completionFile)) {
  53752. $supportedShells = $this->getSupportedShells();
  53753. ($output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output)
  53754. ->writeln(sprintf('<error>Detected shell "%s", which is not supported by Symfony shell completion (supported shells: "%s").</>', $shell, implode('", "', $supportedShells)));
  53755. return self::INVALID;
  53756. }
  53757. $output->write(str_replace(['{{ COMMAND_NAME }}', '{{ VERSION }}'], [$commandName, $this->getApplication()->getVersion()], file_get_contents($completionFile)));
  53758. return self::SUCCESS;
  53759. }
  53760. private static function guessShell(): string
  53761. {
  53762. return basename($_SERVER['SHELL'] ?? '');
  53763. }
  53764. private function tailDebugLog(string $commandName, OutputInterface $output): void
  53765. {
  53766. $debugFile = sys_get_temp_dir().'/sf_'.$commandName.'.log';
  53767. if (!file_exists($debugFile)) {
  53768. touch($debugFile);
  53769. }
  53770. $process = new Process(['tail', '-f', $debugFile], null, null, null, 0);
  53771. $process->run(function (string $type, string $line) use ($output): void {
  53772. $output->write($line);
  53773. });
  53774. }
  53775. private function getSupportedShells(): array
  53776. {
  53777. return array_map(function ($f) {
  53778. return pathinfo($f, \PATHINFO_EXTENSION);
  53779. }, glob(__DIR__.'/../Resources/completion.*'));
  53780. }
  53781. }
  53782. <?php
  53783. namespace Symfony\Component\Console\Command;
  53784. use Symfony\Component\Console\Completion\CompletionInput;
  53785. use Symfony\Component\Console\Completion\CompletionSuggestions;
  53786. use Symfony\Component\Console\Descriptor\ApplicationDescription;
  53787. use Symfony\Component\Console\Helper\DescriptorHelper;
  53788. use Symfony\Component\Console\Input\InputArgument;
  53789. use Symfony\Component\Console\Input\InputInterface;
  53790. use Symfony\Component\Console\Input\InputOption;
  53791. use Symfony\Component\Console\Output\OutputInterface;
  53792. class HelpCommand extends Command
  53793. {
  53794. private $command;
  53795. protected function configure()
  53796. {
  53797. $this->ignoreValidationErrors();
  53798. $this
  53799. ->setName('help')
  53800. ->setDefinition([
  53801. new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'),
  53802. new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
  53803. new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'),
  53804. ])
  53805. ->setDescription('Display help for a command')
  53806. ->setHelp(<<<'EOF'
  53807. The <info>%command.name%</info> command displays help for a given command:
  53808. <info>%command.full_name% list</info>
  53809. You can also output the help in other formats by using the <comment>--format</comment> option:
  53810. <info>%command.full_name% --format=xml list</info>
  53811. To display the list of available commands, please use the <info>list</info> command.
  53812. EOF
  53813. )
  53814. ;
  53815. }
  53816. public function setCommand(Command $command)
  53817. {
  53818. $this->command = $command;
  53819. }
  53820. protected function execute(InputInterface $input, OutputInterface $output)
  53821. {
  53822. if (null === $this->command) {
  53823. $this->command = $this->getApplication()->find($input->getArgument('command_name'));
  53824. }
  53825. $helper = new DescriptorHelper();
  53826. $helper->describe($output, $this->command, [
  53827. 'format' => $input->getOption('format'),
  53828. 'raw_text' => $input->getOption('raw'),
  53829. ]);
  53830. $this->command = null;
  53831. return 0;
  53832. }
  53833. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  53834. {
  53835. if ($input->mustSuggestArgumentValuesFor('command_name')) {
  53836. $descriptor = new ApplicationDescription($this->getApplication());
  53837. $suggestions->suggestValues(array_keys($descriptor->getCommands()));
  53838. return;
  53839. }
  53840. if ($input->mustSuggestOptionValuesFor('format')) {
  53841. $helper = new DescriptorHelper();
  53842. $suggestions->suggestValues($helper->getFormats());
  53843. }
  53844. }
  53845. }
  53846. <?php
  53847. namespace Symfony\Component\Console\Command;
  53848. use Symfony\Component\Console\Application;
  53849. use Symfony\Component\Console\Completion\CompletionInput;
  53850. use Symfony\Component\Console\Completion\CompletionSuggestions;
  53851. use Symfony\Component\Console\Helper\HelperSet;
  53852. use Symfony\Component\Console\Input\InputDefinition;
  53853. use Symfony\Component\Console\Input\InputInterface;
  53854. use Symfony\Component\Console\Output\OutputInterface;
  53855. final class LazyCommand extends Command
  53856. {
  53857. private $command;
  53858. private $isEnabled;
  53859. public function __construct(string $name, array $aliases, string $description, bool $isHidden, \Closure $commandFactory, ?bool $isEnabled = true)
  53860. {
  53861. $this->setName($name)
  53862. ->setAliases($aliases)
  53863. ->setHidden($isHidden)
  53864. ->setDescription($description);
  53865. $this->command = $commandFactory;
  53866. $this->isEnabled = $isEnabled;
  53867. }
  53868. public function ignoreValidationErrors(): void
  53869. {
  53870. $this->getCommand()->ignoreValidationErrors();
  53871. }
  53872. public function setApplication(Application $application = null): void
  53873. {
  53874. if ($this->command instanceof parent) {
  53875. $this->command->setApplication($application);
  53876. }
  53877. parent::setApplication($application);
  53878. }
  53879. public function setHelperSet(HelperSet $helperSet): void
  53880. {
  53881. if ($this->command instanceof parent) {
  53882. $this->command->setHelperSet($helperSet);
  53883. }
  53884. parent::setHelperSet($helperSet);
  53885. }
  53886. public function isEnabled(): bool
  53887. {
  53888. return $this->isEnabled ?? $this->getCommand()->isEnabled();
  53889. }
  53890. public function run(InputInterface $input, OutputInterface $output): int
  53891. {
  53892. return $this->getCommand()->run($input, $output);
  53893. }
  53894. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  53895. {
  53896. $this->getCommand()->complete($input, $suggestions);
  53897. }
  53898. public function setCode(callable $code): self
  53899. {
  53900. $this->getCommand()->setCode($code);
  53901. return $this;
  53902. }
  53903. public function mergeApplicationDefinition(bool $mergeArgs = true): void
  53904. {
  53905. $this->getCommand()->mergeApplicationDefinition($mergeArgs);
  53906. }
  53907. public function setDefinition($definition): self
  53908. {
  53909. $this->getCommand()->setDefinition($definition);
  53910. return $this;
  53911. }
  53912. public function getDefinition(): InputDefinition
  53913. {
  53914. return $this->getCommand()->getDefinition();
  53915. }
  53916. public function getNativeDefinition(): InputDefinition
  53917. {
  53918. return $this->getCommand()->getNativeDefinition();
  53919. }
  53920. public function addArgument(string $name, int $mode = null, string $description = '', $default = null): self
  53921. {
  53922. $this->getCommand()->addArgument($name, $mode, $description, $default);
  53923. return $this;
  53924. }
  53925. public function addOption(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null): self
  53926. {
  53927. $this->getCommand()->addOption($name, $shortcut, $mode, $description, $default);
  53928. return $this;
  53929. }
  53930. public function setProcessTitle(string $title): self
  53931. {
  53932. $this->getCommand()->setProcessTitle($title);
  53933. return $this;
  53934. }
  53935. public function setHelp(string $help): self
  53936. {
  53937. $this->getCommand()->setHelp($help);
  53938. return $this;
  53939. }
  53940. public function getHelp(): string
  53941. {
  53942. return $this->getCommand()->getHelp();
  53943. }
  53944. public function getProcessedHelp(): string
  53945. {
  53946. return $this->getCommand()->getProcessedHelp();
  53947. }
  53948. public function getSynopsis(bool $short = false): string
  53949. {
  53950. return $this->getCommand()->getSynopsis($short);
  53951. }
  53952. public function addUsage(string $usage): self
  53953. {
  53954. $this->getCommand()->addUsage($usage);
  53955. return $this;
  53956. }
  53957. public function getUsages(): array
  53958. {
  53959. return $this->getCommand()->getUsages();
  53960. }
  53961. public function getHelper(string $name)
  53962. {
  53963. return $this->getCommand()->getHelper($name);
  53964. }
  53965. public function getCommand(): parent
  53966. {
  53967. if (!$this->command instanceof \Closure) {
  53968. return $this->command;
  53969. }
  53970. $command = $this->command = ($this->command)();
  53971. $command->setApplication($this->getApplication());
  53972. if (null !== $this->getHelperSet()) {
  53973. $command->setHelperSet($this->getHelperSet());
  53974. }
  53975. $command->setName($this->getName())
  53976. ->setAliases($this->getAliases())
  53977. ->setHidden($this->isHidden())
  53978. ->setDescription($this->getDescription());
  53979. $command->getDefinition();
  53980. return $command;
  53981. }
  53982. }
  53983. <?php
  53984. namespace Symfony\Component\Console\Command;
  53985. use Symfony\Component\Console\Completion\CompletionInput;
  53986. use Symfony\Component\Console\Completion\CompletionSuggestions;
  53987. use Symfony\Component\Console\Descriptor\ApplicationDescription;
  53988. use Symfony\Component\Console\Helper\DescriptorHelper;
  53989. use Symfony\Component\Console\Input\InputArgument;
  53990. use Symfony\Component\Console\Input\InputInterface;
  53991. use Symfony\Component\Console\Input\InputOption;
  53992. use Symfony\Component\Console\Output\OutputInterface;
  53993. class ListCommand extends Command
  53994. {
  53995. protected function configure()
  53996. {
  53997. $this
  53998. ->setName('list')
  53999. ->setDefinition([
  54000. new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
  54001. new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'),
  54002. new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
  54003. new InputOption('short', null, InputOption::VALUE_NONE, 'To skip describing commands\' arguments'),
  54004. ])
  54005. ->setDescription('List commands')
  54006. ->setHelp(<<<'EOF'
  54007. The <info>%command.name%</info> command lists all commands:
  54008. <info>%command.full_name%</info>
  54009. You can also display the commands for a specific namespace:
  54010. <info>%command.full_name% test</info>
  54011. You can also output the information in other formats by using the <comment>--format</comment> option:
  54012. <info>%command.full_name% --format=xml</info>
  54013. It's also possible to get raw list of commands (useful for embedding command runner):
  54014. <info>%command.full_name% --raw</info>
  54015. EOF
  54016. )
  54017. ;
  54018. }
  54019. protected function execute(InputInterface $input, OutputInterface $output)
  54020. {
  54021. $helper = new DescriptorHelper();
  54022. $helper->describe($output, $this->getApplication(), [
  54023. 'format' => $input->getOption('format'),
  54024. 'raw_text' => $input->getOption('raw'),
  54025. 'namespace' => $input->getArgument('namespace'),
  54026. 'short' => $input->getOption('short'),
  54027. ]);
  54028. return 0;
  54029. }
  54030. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  54031. {
  54032. if ($input->mustSuggestArgumentValuesFor('namespace')) {
  54033. $descriptor = new ApplicationDescription($this->getApplication());
  54034. $suggestions->suggestValues(array_keys($descriptor->getNamespaces()));
  54035. return;
  54036. }
  54037. if ($input->mustSuggestOptionValuesFor('format')) {
  54038. $helper = new DescriptorHelper();
  54039. $suggestions->suggestValues($helper->getFormats());
  54040. }
  54041. }
  54042. }
  54043. <?php
  54044. namespace Symfony\Component\Console\Command;
  54045. use Symfony\Component\Console\Exception\LogicException;
  54046. use Symfony\Component\Lock\LockFactory;
  54047. use Symfony\Component\Lock\LockInterface;
  54048. use Symfony\Component\Lock\Store\FlockStore;
  54049. use Symfony\Component\Lock\Store\SemaphoreStore;
  54050. trait LockableTrait
  54051. {
  54052. private $lock;
  54053. private function lock(string $name = null, bool $blocking = false): bool
  54054. {
  54055. if (!class_exists(SemaphoreStore::class)) {
  54056. throw new LogicException('To enable the locking feature you must install the symfony/lock component.');
  54057. }
  54058. if (null !== $this->lock) {
  54059. throw new LogicException('A lock is already in place.');
  54060. }
  54061. if (SemaphoreStore::isSupported()) {
  54062. $store = new SemaphoreStore();
  54063. } else {
  54064. $store = new FlockStore();
  54065. }
  54066. $this->lock = (new LockFactory($store))->createLock($name ?: $this->getName());
  54067. if (!$this->lock->acquire($blocking)) {
  54068. $this->lock = null;
  54069. return false;
  54070. }
  54071. return true;
  54072. }
  54073. private function release()
  54074. {
  54075. if ($this->lock) {
  54076. $this->lock->release();
  54077. $this->lock = null;
  54078. }
  54079. }
  54080. }
  54081. <?php
  54082. namespace Symfony\Component\Console\Command;
  54083. interface SignalableCommandInterface
  54084. {
  54085. public function getSubscribedSignals(): array;
  54086. public function handleSignal(int $signal): void;
  54087. }
  54088. <?php
  54089. namespace Symfony\Component\Console\CommandLoader;
  54090. use Symfony\Component\Console\Command\Command;
  54091. use Symfony\Component\Console\Exception\CommandNotFoundException;
  54092. interface CommandLoaderInterface
  54093. {
  54094. public function get(string $name);
  54095. public function has(string $name);
  54096. public function getNames();
  54097. }
  54098. <?php
  54099. namespace Symfony\Component\Console\CommandLoader;
  54100. use Psr\Container\ContainerInterface;
  54101. use Symfony\Component\Console\Exception\CommandNotFoundException;
  54102. class ContainerCommandLoader implements CommandLoaderInterface
  54103. {
  54104. private $container;
  54105. private $commandMap;
  54106. public function __construct(ContainerInterface $container, array $commandMap)
  54107. {
  54108. $this->container = $container;
  54109. $this->commandMap = $commandMap;
  54110. }
  54111. public function get(string $name)
  54112. {
  54113. if (!$this->has($name)) {
  54114. throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name));
  54115. }
  54116. return $this->container->get($this->commandMap[$name]);
  54117. }
  54118. public function has(string $name)
  54119. {
  54120. return isset($this->commandMap[$name]) && $this->container->has($this->commandMap[$name]);
  54121. }
  54122. public function getNames()
  54123. {
  54124. return array_keys($this->commandMap);
  54125. }
  54126. }
  54127. <?php
  54128. namespace Symfony\Component\Console\CommandLoader;
  54129. use Symfony\Component\Console\Exception\CommandNotFoundException;
  54130. class FactoryCommandLoader implements CommandLoaderInterface
  54131. {
  54132. private $factories;
  54133. public function __construct(array $factories)
  54134. {
  54135. $this->factories = $factories;
  54136. }
  54137. public function has(string $name)
  54138. {
  54139. return isset($this->factories[$name]);
  54140. }
  54141. public function get(string $name)
  54142. {
  54143. if (!isset($this->factories[$name])) {
  54144. throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name));
  54145. }
  54146. $factory = $this->factories[$name];
  54147. return $factory();
  54148. }
  54149. public function getNames()
  54150. {
  54151. return array_keys($this->factories);
  54152. }
  54153. }
  54154. <?php
  54155. namespace Symfony\Component\Console\Completion;
  54156. use Symfony\Component\Console\Exception\RuntimeException;
  54157. use Symfony\Component\Console\Input\ArgvInput;
  54158. use Symfony\Component\Console\Input\InputDefinition;
  54159. use Symfony\Component\Console\Input\InputOption;
  54160. final class CompletionInput extends ArgvInput
  54161. {
  54162. public const TYPE_ARGUMENT_VALUE = 'argument_value';
  54163. public const TYPE_OPTION_VALUE = 'option_value';
  54164. public const TYPE_OPTION_NAME = 'option_name';
  54165. public const TYPE_NONE = 'none';
  54166. private $tokens;
  54167. private $currentIndex;
  54168. private $completionType;
  54169. private $completionName = null;
  54170. private $completionValue = '';
  54171. public static function fromString(string $inputStr, int $currentIndex): self
  54172. {
  54173. preg_match_all('/(?<=^|\s)([\'"]?)(.+?)(?<!\\\\)\1(?=$|\s)/', $inputStr, $tokens);
  54174. return self::fromTokens($tokens[0], $currentIndex);
  54175. }
  54176. public static function fromTokens(array $tokens, int $currentIndex): self
  54177. {
  54178. $input = new self($tokens);
  54179. $input->tokens = $tokens;
  54180. $input->currentIndex = $currentIndex;
  54181. return $input;
  54182. }
  54183. public function bind(InputDefinition $definition): void
  54184. {
  54185. parent::bind($definition);
  54186. $relevantToken = $this->getRelevantToken();
  54187. if ('-' === $relevantToken[0]) {
  54188. [$optionToken, $optionValue] = explode('=', $relevantToken, 2) + ['', ''];
  54189. $option = $this->getOptionFromToken($optionToken);
  54190. if (null === $option && !$this->isCursorFree()) {
  54191. $this->completionType = self::TYPE_OPTION_NAME;
  54192. $this->completionValue = $relevantToken;
  54193. return;
  54194. }
  54195. if (null !== $option && $option->acceptValue()) {
  54196. $this->completionType = self::TYPE_OPTION_VALUE;
  54197. $this->completionName = $option->getName();
  54198. $this->completionValue = $optionValue ?: (!str_starts_with($optionToken, '--') ? substr($optionToken, 2) : '');
  54199. return;
  54200. }
  54201. }
  54202. $previousToken = $this->tokens[$this->currentIndex - 1];
  54203. if ('-' === $previousToken[0] && '' !== trim($previousToken, '-')) {
  54204. $previousOption = $this->getOptionFromToken($previousToken);
  54205. if (null !== $previousOption && $previousOption->acceptValue()) {
  54206. $this->completionType = self::TYPE_OPTION_VALUE;
  54207. $this->completionName = $previousOption->getName();
  54208. $this->completionValue = $relevantToken;
  54209. return;
  54210. }
  54211. }
  54212. $this->completionType = self::TYPE_ARGUMENT_VALUE;
  54213. foreach ($this->definition->getArguments() as $argumentName => $argument) {
  54214. if (!isset($this->arguments[$argumentName])) {
  54215. break;
  54216. }
  54217. $argumentValue = $this->arguments[$argumentName];
  54218. $this->completionName = $argumentName;
  54219. if (\is_array($argumentValue)) {
  54220. $this->completionValue = $argumentValue ? $argumentValue[array_key_last($argumentValue)] : null;
  54221. } else {
  54222. $this->completionValue = $argumentValue;
  54223. }
  54224. }
  54225. if ($this->currentIndex >= \count($this->tokens)) {
  54226. if (!isset($this->arguments[$argumentName]) || $this->definition->getArgument($argumentName)->isArray()) {
  54227. $this->completionName = $argumentName;
  54228. $this->completionValue = '';
  54229. } else {
  54230. $this->completionType = self::TYPE_NONE;
  54231. $this->completionName = null;
  54232. $this->completionValue = '';
  54233. }
  54234. }
  54235. }
  54236. public function getCompletionType(): string
  54237. {
  54238. return $this->completionType;
  54239. }
  54240. public function getCompletionName(): ?string
  54241. {
  54242. return $this->completionName;
  54243. }
  54244. public function getCompletionValue(): string
  54245. {
  54246. return $this->completionValue;
  54247. }
  54248. public function mustSuggestOptionValuesFor(string $optionName): bool
  54249. {
  54250. return self::TYPE_OPTION_VALUE === $this->getCompletionType() && $optionName === $this->getCompletionName();
  54251. }
  54252. public function mustSuggestArgumentValuesFor(string $argumentName): bool
  54253. {
  54254. return self::TYPE_ARGUMENT_VALUE === $this->getCompletionType() && $argumentName === $this->getCompletionName();
  54255. }
  54256. protected function parseToken(string $token, bool $parseOptions): bool
  54257. {
  54258. try {
  54259. return parent::parseToken($token, $parseOptions);
  54260. } catch (RuntimeException $e) {
  54261. }
  54262. return $parseOptions;
  54263. }
  54264. private function getOptionFromToken(string $optionToken): ?InputOption
  54265. {
  54266. $optionName = ltrim($optionToken, '-');
  54267. if (!$optionName) {
  54268. return null;
  54269. }
  54270. if ('-' === ($optionToken[1] ?? ' ')) {
  54271. return $this->definition->hasOption($optionName) ? $this->definition->getOption($optionName) : null;
  54272. }
  54273. return $this->definition->hasShortcut($optionName[0]) ? $this->definition->getOptionForShortcut($optionName[0]) : null;
  54274. }
  54275. private function getRelevantToken(): string
  54276. {
  54277. return $this->tokens[$this->isCursorFree() ? $this->currentIndex - 1 : $this->currentIndex];
  54278. }
  54279. private function isCursorFree(): bool
  54280. {
  54281. $nrOfTokens = \count($this->tokens);
  54282. if ($this->currentIndex > $nrOfTokens) {
  54283. throw new \LogicException('Current index is invalid, it must be the number of input tokens or one more.');
  54284. }
  54285. return $this->currentIndex >= $nrOfTokens;
  54286. }
  54287. public function __toString()
  54288. {
  54289. $str = '';
  54290. foreach ($this->tokens as $i => $token) {
  54291. $str .= $token;
  54292. if ($this->currentIndex === $i) {
  54293. $str .= '|';
  54294. }
  54295. $str .= ' ';
  54296. }
  54297. if ($this->currentIndex > $i) {
  54298. $str .= '|';
  54299. }
  54300. return rtrim($str);
  54301. }
  54302. }
  54303. <?php
  54304. namespace Symfony\Component\Console\Completion;
  54305. use Symfony\Component\Console\Input\InputOption;
  54306. final class CompletionSuggestions
  54307. {
  54308. private $valueSuggestions = [];
  54309. private $optionSuggestions = [];
  54310. public function suggestValue($value): self
  54311. {
  54312. $this->valueSuggestions[] = !$value instanceof Suggestion ? new Suggestion($value) : $value;
  54313. return $this;
  54314. }
  54315. public function suggestValues(array $values): self
  54316. {
  54317. foreach ($values as $value) {
  54318. $this->suggestValue($value);
  54319. }
  54320. return $this;
  54321. }
  54322. public function suggestOption(InputOption $option): self
  54323. {
  54324. $this->optionSuggestions[] = $option;
  54325. return $this;
  54326. }
  54327. public function suggestOptions(array $options): self
  54328. {
  54329. foreach ($options as $option) {
  54330. $this->suggestOption($option);
  54331. }
  54332. return $this;
  54333. }
  54334. public function getOptionSuggestions(): array
  54335. {
  54336. return $this->optionSuggestions;
  54337. }
  54338. public function getValueSuggestions(): array
  54339. {
  54340. return $this->valueSuggestions;
  54341. }
  54342. }
  54343. <?php
  54344. namespace Symfony\Component\Console\Completion\Output;
  54345. use Symfony\Component\Console\Completion\CompletionSuggestions;
  54346. use Symfony\Component\Console\Output\OutputInterface;
  54347. class BashCompletionOutput implements CompletionOutputInterface
  54348. {
  54349. public function write(CompletionSuggestions $suggestions, OutputInterface $output): void
  54350. {
  54351. $values = $suggestions->getValueSuggestions();
  54352. foreach ($suggestions->getOptionSuggestions() as $option) {
  54353. $values[] = '--'.$option->getName();
  54354. }
  54355. $output->writeln(implode("\n", $values));
  54356. }
  54357. }
  54358. <?php
  54359. namespace Symfony\Component\Console\Completion\Output;
  54360. use Symfony\Component\Console\Completion\CompletionSuggestions;
  54361. use Symfony\Component\Console\Output\OutputInterface;
  54362. interface CompletionOutputInterface
  54363. {
  54364. public function write(CompletionSuggestions $suggestions, OutputInterface $output): void;
  54365. }
  54366. <?php
  54367. namespace Symfony\Component\Console\Completion;
  54368. class Suggestion
  54369. {
  54370. private $value;
  54371. public function __construct(string $value)
  54372. {
  54373. $this->value = $value;
  54374. }
  54375. public function getValue(): string
  54376. {
  54377. return $this->value;
  54378. }
  54379. public function __toString(): string
  54380. {
  54381. return $this->getValue();
  54382. }
  54383. }
  54384. <?php
  54385. namespace Symfony\Component\Console;
  54386. use Symfony\Component\Console\Event\ConsoleCommandEvent;
  54387. use Symfony\Component\Console\Event\ConsoleErrorEvent;
  54388. use Symfony\Component\Console\Event\ConsoleSignalEvent;
  54389. use Symfony\Component\Console\Event\ConsoleTerminateEvent;
  54390. final class ConsoleEvents
  54391. {
  54392. public const COMMAND = 'console.command';
  54393. public const SIGNAL = 'console.signal';
  54394. public const TERMINATE = 'console.terminate';
  54395. public const ERROR = 'console.error';
  54396. public const ALIASES = [
  54397. ConsoleCommandEvent::class => self::COMMAND,
  54398. ConsoleErrorEvent::class => self::ERROR,
  54399. ConsoleSignalEvent::class => self::SIGNAL,
  54400. ConsoleTerminateEvent::class => self::TERMINATE,
  54401. ];
  54402. }
  54403. <?php
  54404. namespace Symfony\Component\Console;
  54405. use Symfony\Component\Console\Output\OutputInterface;
  54406. final class Cursor
  54407. {
  54408. private $output;
  54409. private $input;
  54410. public function __construct(OutputInterface $output, $input = null)
  54411. {
  54412. $this->output = $output;
  54413. $this->input = $input ?? (\defined('STDIN') ? \STDIN : fopen('php://input', 'r+'));
  54414. }
  54415. public function moveUp(int $lines = 1): self
  54416. {
  54417. $this->output->write(sprintf("\x1b[%dA", $lines));
  54418. return $this;
  54419. }
  54420. public function moveDown(int $lines = 1): self
  54421. {
  54422. $this->output->write(sprintf("\x1b[%dB", $lines));
  54423. return $this;
  54424. }
  54425. public function moveRight(int $columns = 1): self
  54426. {
  54427. $this->output->write(sprintf("\x1b[%dC", $columns));
  54428. return $this;
  54429. }
  54430. public function moveLeft(int $columns = 1): self
  54431. {
  54432. $this->output->write(sprintf("\x1b[%dD", $columns));
  54433. return $this;
  54434. }
  54435. public function moveToColumn(int $column): self
  54436. {
  54437. $this->output->write(sprintf("\x1b[%dG", $column));
  54438. return $this;
  54439. }
  54440. public function moveToPosition(int $column, int $row): self
  54441. {
  54442. $this->output->write(sprintf("\x1b[%d;%dH", $row + 1, $column));
  54443. return $this;
  54444. }
  54445. public function savePosition(): self
  54446. {
  54447. $this->output->write("\x1b7");
  54448. return $this;
  54449. }
  54450. public function restorePosition(): self
  54451. {
  54452. $this->output->write("\x1b8");
  54453. return $this;
  54454. }
  54455. public function hide(): self
  54456. {
  54457. $this->output->write("\x1b[?25l");
  54458. return $this;
  54459. }
  54460. public function show(): self
  54461. {
  54462. $this->output->write("\x1b[?25h\x1b[?0c");
  54463. return $this;
  54464. }
  54465. public function clearLine(): self
  54466. {
  54467. $this->output->write("\x1b[2K");
  54468. return $this;
  54469. }
  54470. public function clearLineAfter(): self
  54471. {
  54472. $this->output->write("\x1b[K");
  54473. return $this;
  54474. }
  54475. public function clearOutput(): self
  54476. {
  54477. $this->output->write("\x1b[0J");
  54478. return $this;
  54479. }
  54480. public function clearScreen(): self
  54481. {
  54482. $this->output->write("\x1b[2J");
  54483. return $this;
  54484. }
  54485. public function getCurrentPosition(): array
  54486. {
  54487. static $isTtySupported;
  54488. if (null === $isTtySupported && \function_exists('proc_open')) {
  54489. $isTtySupported = (bool) @proc_open('echo 1 >/dev/null', [['file', '/dev/tty', 'r'], ['file', '/dev/tty', 'w'], ['file', '/dev/tty', 'w']], $pipes);
  54490. }
  54491. if (!$isTtySupported) {
  54492. return [1, 1];
  54493. }
  54494. $sttyMode = shell_exec('stty -g');
  54495. shell_exec('stty -icanon -echo');
  54496. @fwrite($this->input, "\033[6n");
  54497. $code = trim(fread($this->input, 1024));
  54498. shell_exec(sprintf('stty %s', $sttyMode));
  54499. sscanf($code, "\033[%d;%dR", $row, $col);
  54500. return [$col, $row];
  54501. }
  54502. }
  54503. <?php
  54504. namespace Symfony\Component\Console\DependencyInjection;
  54505. use Symfony\Component\Console\Command\Command;
  54506. use Symfony\Component\Console\Command\LazyCommand;
  54507. use Symfony\Component\Console\CommandLoader\ContainerCommandLoader;
  54508. use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
  54509. use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
  54510. use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
  54511. use Symfony\Component\DependencyInjection\ContainerBuilder;
  54512. use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
  54513. use Symfony\Component\DependencyInjection\Reference;
  54514. use Symfony\Component\DependencyInjection\TypedReference;
  54515. class AddConsoleCommandPass implements CompilerPassInterface
  54516. {
  54517. private $commandLoaderServiceId;
  54518. private $commandTag;
  54519. private $noPreloadTag;
  54520. private $privateTagName;
  54521. public function __construct(string $commandLoaderServiceId = 'console.command_loader', string $commandTag = 'console.command', string $noPreloadTag = 'container.no_preload', string $privateTagName = 'container.private')
  54522. {
  54523. if (0 < \func_num_args()) {
  54524. trigger_deprecation('symfony/console', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);
  54525. }
  54526. $this->commandLoaderServiceId = $commandLoaderServiceId;
  54527. $this->commandTag = $commandTag;
  54528. $this->noPreloadTag = $noPreloadTag;
  54529. $this->privateTagName = $privateTagName;
  54530. }
  54531. public function process(ContainerBuilder $container)
  54532. {
  54533. $commandServices = $container->findTaggedServiceIds($this->commandTag, true);
  54534. $lazyCommandMap = [];
  54535. $lazyCommandRefs = [];
  54536. $serviceIds = [];
  54537. foreach ($commandServices as $id => $tags) {
  54538. $definition = $container->getDefinition($id);
  54539. $definition->addTag($this->noPreloadTag);
  54540. $class = $container->getParameterBag()->resolveValue($definition->getClass());
  54541. if (isset($tags[0]['command'])) {
  54542. $aliases = $tags[0]['command'];
  54543. } else {
  54544. if (!$r = $container->getReflectionClass($class)) {
  54545. throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id));
  54546. }
  54547. if (!$r->isSubclassOf(Command::class)) {
  54548. throw new InvalidArgumentException(sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, $this->commandTag, Command::class));
  54549. }
  54550. $aliases = $class::getDefaultName();
  54551. }
  54552. $aliases = explode('|', $aliases ?? '');
  54553. $commandName = array_shift($aliases);
  54554. if ($isHidden = '' === $commandName) {
  54555. $commandName = array_shift($aliases);
  54556. }
  54557. if (null === $commandName) {
  54558. if (!$definition->isPublic() || $definition->isPrivate() || $definition->hasTag($this->privateTagName)) {
  54559. $commandId = 'console.command.public_alias.'.$id;
  54560. $container->setAlias($commandId, $id)->setPublic(true);
  54561. $id = $commandId;
  54562. }
  54563. $serviceIds[] = $id;
  54564. continue;
  54565. }
  54566. $description = $tags[0]['description'] ?? null;
  54567. unset($tags[0]);
  54568. $lazyCommandMap[$commandName] = $id;
  54569. $lazyCommandRefs[$id] = new TypedReference($id, $class);
  54570. foreach ($aliases as $alias) {
  54571. $lazyCommandMap[$alias] = $id;
  54572. }
  54573. foreach ($tags as $tag) {
  54574. if (isset($tag['command'])) {
  54575. $aliases[] = $tag['command'];
  54576. $lazyCommandMap[$tag['command']] = $id;
  54577. }
  54578. $description = $description ?? $tag['description'] ?? null;
  54579. }
  54580. $definition->addMethodCall('setName', [$commandName]);
  54581. if ($aliases) {
  54582. $definition->addMethodCall('setAliases', [$aliases]);
  54583. }
  54584. if ($isHidden) {
  54585. $definition->addMethodCall('setHidden', [true]);
  54586. }
  54587. if (!$description) {
  54588. if (!$r = $container->getReflectionClass($class)) {
  54589. throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id));
  54590. }
  54591. if (!$r->isSubclassOf(Command::class)) {
  54592. throw new InvalidArgumentException(sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, $this->commandTag, Command::class));
  54593. }
  54594. $description = $class::getDefaultDescription();
  54595. }
  54596. if ($description) {
  54597. $definition->addMethodCall('setDescription', [$description]);
  54598. $container->register('.'.$id.'.lazy', LazyCommand::class)
  54599. ->setArguments([$commandName, $aliases, $description, $isHidden, new ServiceClosureArgument($lazyCommandRefs[$id])]);
  54600. $lazyCommandRefs[$id] = new Reference('.'.$id.'.lazy');
  54601. }
  54602. }
  54603. $container
  54604. ->register($this->commandLoaderServiceId, ContainerCommandLoader::class)
  54605. ->setPublic(true)
  54606. ->addTag($this->noPreloadTag)
  54607. ->setArguments([ServiceLocatorTagPass::register($container, $lazyCommandRefs), $lazyCommandMap]);
  54608. $container->setParameter('console.command.ids', $serviceIds);
  54609. }
  54610. }
  54611. <?php
  54612. namespace Symfony\Component\Console\Descriptor;
  54613. use Symfony\Component\Console\Application;
  54614. use Symfony\Component\Console\Command\Command;
  54615. use Symfony\Component\Console\Exception\CommandNotFoundException;
  54616. class ApplicationDescription
  54617. {
  54618. public const GLOBAL_NAMESPACE = '_global';
  54619. private $application;
  54620. private $namespace;
  54621. private $showHidden;
  54622. private $namespaces;
  54623. private $commands;
  54624. private $aliases;
  54625. public function __construct(Application $application, string $namespace = null, bool $showHidden = false)
  54626. {
  54627. $this->application = $application;
  54628. $this->namespace = $namespace;
  54629. $this->showHidden = $showHidden;
  54630. }
  54631. public function getNamespaces(): array
  54632. {
  54633. if (null === $this->namespaces) {
  54634. $this->inspectApplication();
  54635. }
  54636. return $this->namespaces;
  54637. }
  54638. public function getCommands(): array
  54639. {
  54640. if (null === $this->commands) {
  54641. $this->inspectApplication();
  54642. }
  54643. return $this->commands;
  54644. }
  54645. public function getCommand(string $name): Command
  54646. {
  54647. if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) {
  54648. throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name));
  54649. }
  54650. return $this->commands[$name] ?? $this->aliases[$name];
  54651. }
  54652. private function inspectApplication()
  54653. {
  54654. $this->commands = [];
  54655. $this->namespaces = [];
  54656. $all = $this->application->all($this->namespace ? $this->application->findNamespace($this->namespace) : null);
  54657. foreach ($this->sortCommands($all) as $namespace => $commands) {
  54658. $names = [];
  54659. foreach ($commands as $name => $command) {
  54660. if (!$command->getName() || (!$this->showHidden && $command->isHidden())) {
  54661. continue;
  54662. }
  54663. if ($command->getName() === $name) {
  54664. $this->commands[$name] = $command;
  54665. } else {
  54666. $this->aliases[$name] = $command;
  54667. }
  54668. $names[] = $name;
  54669. }
  54670. $this->namespaces[$namespace] = ['id' => $namespace, 'commands' => $names];
  54671. }
  54672. }
  54673. private function sortCommands(array $commands): array
  54674. {
  54675. $namespacedCommands = [];
  54676. $globalCommands = [];
  54677. $sortedCommands = [];
  54678. foreach ($commands as $name => $command) {
  54679. $key = $this->application->extractNamespace($name, 1);
  54680. if (\in_array($key, ['', self::GLOBAL_NAMESPACE], true)) {
  54681. $globalCommands[$name] = $command;
  54682. } else {
  54683. $namespacedCommands[$key][$name] = $command;
  54684. }
  54685. }
  54686. if ($globalCommands) {
  54687. ksort($globalCommands);
  54688. $sortedCommands[self::GLOBAL_NAMESPACE] = $globalCommands;
  54689. }
  54690. if ($namespacedCommands) {
  54691. ksort($namespacedCommands);
  54692. foreach ($namespacedCommands as $key => $commandsSet) {
  54693. ksort($commandsSet);
  54694. $sortedCommands[$key] = $commandsSet;
  54695. }
  54696. }
  54697. return $sortedCommands;
  54698. }
  54699. }
  54700. <?php
  54701. namespace Symfony\Component\Console\Descriptor;
  54702. use Symfony\Component\Console\Application;
  54703. use Symfony\Component\Console\Command\Command;
  54704. use Symfony\Component\Console\Exception\InvalidArgumentException;
  54705. use Symfony\Component\Console\Input\InputArgument;
  54706. use Symfony\Component\Console\Input\InputDefinition;
  54707. use Symfony\Component\Console\Input\InputOption;
  54708. use Symfony\Component\Console\Output\OutputInterface;
  54709. abstract class Descriptor implements DescriptorInterface
  54710. {
  54711. protected $output;
  54712. public function describe(OutputInterface $output, object $object, array $options = [])
  54713. {
  54714. $this->output = $output;
  54715. switch (true) {
  54716. case $object instanceof InputArgument:
  54717. $this->describeInputArgument($object, $options);
  54718. break;
  54719. case $object instanceof InputOption:
  54720. $this->describeInputOption($object, $options);
  54721. break;
  54722. case $object instanceof InputDefinition:
  54723. $this->describeInputDefinition($object, $options);
  54724. break;
  54725. case $object instanceof Command:
  54726. $this->describeCommand($object, $options);
  54727. break;
  54728. case $object instanceof Application:
  54729. $this->describeApplication($object, $options);
  54730. break;
  54731. default:
  54732. throw new InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_debug_type($object)));
  54733. }
  54734. }
  54735. protected function write(string $content, bool $decorated = false)
  54736. {
  54737. $this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW);
  54738. }
  54739. abstract protected function describeInputArgument(InputArgument $argument, array $options = []);
  54740. abstract protected function describeInputOption(InputOption $option, array $options = []);
  54741. abstract protected function describeInputDefinition(InputDefinition $definition, array $options = []);
  54742. abstract protected function describeCommand(Command $command, array $options = []);
  54743. abstract protected function describeApplication(Application $application, array $options = []);
  54744. }
  54745. <?php
  54746. namespace Symfony\Component\Console\Descriptor;
  54747. use Symfony\Component\Console\Output\OutputInterface;
  54748. interface DescriptorInterface
  54749. {
  54750. public function describe(OutputInterface $output, object $object, array $options = []);
  54751. }
  54752. <?php
  54753. namespace Symfony\Component\Console\Descriptor;
  54754. use Symfony\Component\Console\Application;
  54755. use Symfony\Component\Console\Command\Command;
  54756. use Symfony\Component\Console\Input\InputArgument;
  54757. use Symfony\Component\Console\Input\InputDefinition;
  54758. use Symfony\Component\Console\Input\InputOption;
  54759. class JsonDescriptor extends Descriptor
  54760. {
  54761. protected function describeInputArgument(InputArgument $argument, array $options = [])
  54762. {
  54763. $this->writeData($this->getInputArgumentData($argument), $options);
  54764. }
  54765. protected function describeInputOption(InputOption $option, array $options = [])
  54766. {
  54767. $this->writeData($this->getInputOptionData($option), $options);
  54768. if ($option->isNegatable()) {
  54769. $this->writeData($this->getInputOptionData($option, true), $options);
  54770. }
  54771. }
  54772. protected function describeInputDefinition(InputDefinition $definition, array $options = [])
  54773. {
  54774. $this->writeData($this->getInputDefinitionData($definition), $options);
  54775. }
  54776. protected function describeCommand(Command $command, array $options = [])
  54777. {
  54778. $this->writeData($this->getCommandData($command, $options['short'] ?? false), $options);
  54779. }
  54780. protected function describeApplication(Application $application, array $options = [])
  54781. {
  54782. $describedNamespace = $options['namespace'] ?? null;
  54783. $description = new ApplicationDescription($application, $describedNamespace, true);
  54784. $commands = [];
  54785. foreach ($description->getCommands() as $command) {
  54786. $commands[] = $this->getCommandData($command, $options['short'] ?? false);
  54787. }
  54788. $data = [];
  54789. if ('UNKNOWN' !== $application->getName()) {
  54790. $data['application']['name'] = $application->getName();
  54791. if ('UNKNOWN' !== $application->getVersion()) {
  54792. $data['application']['version'] = $application->getVersion();
  54793. }
  54794. }
  54795. $data['commands'] = $commands;
  54796. if ($describedNamespace) {
  54797. $data['namespace'] = $describedNamespace;
  54798. } else {
  54799. $data['namespaces'] = array_values($description->getNamespaces());
  54800. }
  54801. $this->writeData($data, $options);
  54802. }
  54803. private function writeData(array $data, array $options)
  54804. {
  54805. $flags = $options['json_encoding'] ?? 0;
  54806. $this->write(json_encode($data, $flags));
  54807. }
  54808. private function getInputArgumentData(InputArgument $argument): array
  54809. {
  54810. return [
  54811. 'name' => $argument->getName(),
  54812. 'is_required' => $argument->isRequired(),
  54813. 'is_array' => $argument->isArray(),
  54814. 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $argument->getDescription()),
  54815. 'default' => \INF === $argument->getDefault() ? 'INF' : $argument->getDefault(),
  54816. ];
  54817. }
  54818. private function getInputOptionData(InputOption $option, bool $negated = false): array
  54819. {
  54820. return $negated ? [
  54821. 'name' => '--no-'.$option->getName(),
  54822. 'shortcut' => '',
  54823. 'accept_value' => false,
  54824. 'is_value_required' => false,
  54825. 'is_multiple' => false,
  54826. 'description' => 'Negate the "--'.$option->getName().'" option',
  54827. 'default' => false,
  54828. ] : [
  54829. 'name' => '--'.$option->getName(),
  54830. 'shortcut' => $option->getShortcut() ? '-'.str_replace('|', '|-', $option->getShortcut()) : '',
  54831. 'accept_value' => $option->acceptValue(),
  54832. 'is_value_required' => $option->isValueRequired(),
  54833. 'is_multiple' => $option->isArray(),
  54834. 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()),
  54835. 'default' => \INF === $option->getDefault() ? 'INF' : $option->getDefault(),
  54836. ];
  54837. }
  54838. private function getInputDefinitionData(InputDefinition $definition): array
  54839. {
  54840. $inputArguments = [];
  54841. foreach ($definition->getArguments() as $name => $argument) {
  54842. $inputArguments[$name] = $this->getInputArgumentData($argument);
  54843. }
  54844. $inputOptions = [];
  54845. foreach ($definition->getOptions() as $name => $option) {
  54846. $inputOptions[$name] = $this->getInputOptionData($option);
  54847. if ($option->isNegatable()) {
  54848. $inputOptions['no-'.$name] = $this->getInputOptionData($option, true);
  54849. }
  54850. }
  54851. return ['arguments' => $inputArguments, 'options' => $inputOptions];
  54852. }
  54853. private function getCommandData(Command $command, bool $short = false): array
  54854. {
  54855. $data = [
  54856. 'name' => $command->getName(),
  54857. 'description' => $command->getDescription(),
  54858. ];
  54859. if ($short) {
  54860. $data += [
  54861. 'usage' => $command->getAliases(),
  54862. ];
  54863. } else {
  54864. $command->mergeApplicationDefinition(false);
  54865. $data += [
  54866. 'usage' => array_merge([$command->getSynopsis()], $command->getUsages(), $command->getAliases()),
  54867. 'help' => $command->getProcessedHelp(),
  54868. 'definition' => $this->getInputDefinitionData($command->getDefinition()),
  54869. ];
  54870. }
  54871. $data['hidden'] = $command->isHidden();
  54872. return $data;
  54873. }
  54874. }
  54875. <?php
  54876. namespace Symfony\Component\Console\Descriptor;
  54877. use Symfony\Component\Console\Application;
  54878. use Symfony\Component\Console\Command\Command;
  54879. use Symfony\Component\Console\Helper\Helper;
  54880. use Symfony\Component\Console\Input\InputArgument;
  54881. use Symfony\Component\Console\Input\InputDefinition;
  54882. use Symfony\Component\Console\Input\InputOption;
  54883. use Symfony\Component\Console\Output\OutputInterface;
  54884. class MarkdownDescriptor extends Descriptor
  54885. {
  54886. public function describe(OutputInterface $output, object $object, array $options = [])
  54887. {
  54888. $decorated = $output->isDecorated();
  54889. $output->setDecorated(false);
  54890. parent::describe($output, $object, $options);
  54891. $output->setDecorated($decorated);
  54892. }
  54893. protected function write(string $content, bool $decorated = true)
  54894. {
  54895. parent::write($content, $decorated);
  54896. }
  54897. protected function describeInputArgument(InputArgument $argument, array $options = [])
  54898. {
  54899. $this->write(
  54900. '#### `'.($argument->getName() ?: '<none>')."`\n\n"
  54901. .($argument->getDescription() ? preg_replace('/\s*[\r\n]\s*/', "\n", $argument->getDescription())."\n\n" : '')
  54902. .'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n"
  54903. .'* Is array: '.($argument->isArray() ? 'yes' : 'no')."\n"
  54904. .'* Default: `'.str_replace("\n", '', var_export($argument->getDefault(), true)).'`'
  54905. );
  54906. }
  54907. protected function describeInputOption(InputOption $option, array $options = [])
  54908. {
  54909. $name = '--'.$option->getName();
  54910. if ($option->isNegatable()) {
  54911. $name .= '|--no-'.$option->getName();
  54912. }
  54913. if ($option->getShortcut()) {
  54914. $name .= '|-'.str_replace('|', '|-', $option->getShortcut()).'';
  54915. }
  54916. $this->write(
  54917. '#### `'.$name.'`'."\n\n"
  54918. .($option->getDescription() ? preg_replace('/\s*[\r\n]\s*/', "\n", $option->getDescription())."\n\n" : '')
  54919. .'* Accept value: '.($option->acceptValue() ? 'yes' : 'no')."\n"
  54920. .'* Is value required: '.($option->isValueRequired() ? 'yes' : 'no')."\n"
  54921. .'* Is multiple: '.($option->isArray() ? 'yes' : 'no')."\n"
  54922. .'* Is negatable: '.($option->isNegatable() ? 'yes' : 'no')."\n"
  54923. .'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`'
  54924. );
  54925. }
  54926. protected function describeInputDefinition(InputDefinition $definition, array $options = [])
  54927. {
  54928. if ($showArguments = \count($definition->getArguments()) > 0) {
  54929. $this->write('### Arguments');
  54930. foreach ($definition->getArguments() as $argument) {
  54931. $this->write("\n\n");
  54932. if (null !== $describeInputArgument = $this->describeInputArgument($argument)) {
  54933. $this->write($describeInputArgument);
  54934. }
  54935. }
  54936. }
  54937. if (\count($definition->getOptions()) > 0) {
  54938. if ($showArguments) {
  54939. $this->write("\n\n");
  54940. }
  54941. $this->write('### Options');
  54942. foreach ($definition->getOptions() as $option) {
  54943. $this->write("\n\n");
  54944. if (null !== $describeInputOption = $this->describeInputOption($option)) {
  54945. $this->write($describeInputOption);
  54946. }
  54947. }
  54948. }
  54949. }
  54950. protected function describeCommand(Command $command, array $options = [])
  54951. {
  54952. if ($options['short'] ?? false) {
  54953. $this->write(
  54954. '`'.$command->getName()."`\n"
  54955. .str_repeat('-', Helper::width($command->getName()) + 2)."\n\n"
  54956. .($command->getDescription() ? $command->getDescription()."\n\n" : '')
  54957. .'### Usage'."\n\n"
  54958. .array_reduce($command->getAliases(), function ($carry, $usage) {
  54959. return $carry.'* `'.$usage.'`'."\n";
  54960. })
  54961. );
  54962. return;
  54963. }
  54964. $command->mergeApplicationDefinition(false);
  54965. $this->write(
  54966. '`'.$command->getName()."`\n"
  54967. .str_repeat('-', Helper::width($command->getName()) + 2)."\n\n"
  54968. .($command->getDescription() ? $command->getDescription()."\n\n" : '')
  54969. .'### Usage'."\n\n"
  54970. .array_reduce(array_merge([$command->getSynopsis()], $command->getAliases(), $command->getUsages()), function ($carry, $usage) {
  54971. return $carry.'* `'.$usage.'`'."\n";
  54972. })
  54973. );
  54974. if ($help = $command->getProcessedHelp()) {
  54975. $this->write("\n");
  54976. $this->write($help);
  54977. }
  54978. $definition = $command->getDefinition();
  54979. if ($definition->getOptions() || $definition->getArguments()) {
  54980. $this->write("\n\n");
  54981. $this->describeInputDefinition($definition);
  54982. }
  54983. }
  54984. protected function describeApplication(Application $application, array $options = [])
  54985. {
  54986. $describedNamespace = $options['namespace'] ?? null;
  54987. $description = new ApplicationDescription($application, $describedNamespace);
  54988. $title = $this->getApplicationTitle($application);
  54989. $this->write($title."\n".str_repeat('=', Helper::width($title)));
  54990. foreach ($description->getNamespaces() as $namespace) {
  54991. if (ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
  54992. $this->write("\n\n");
  54993. $this->write('**'.$namespace['id'].':**');
  54994. }
  54995. $this->write("\n\n");
  54996. $this->write(implode("\n", array_map(function ($commandName) use ($description) {
  54997. return sprintf('* [`%s`](#%s)', $commandName, str_replace(':', '', $description->getCommand($commandName)->getName()));
  54998. }, $namespace['commands'])));
  54999. }
  55000. foreach ($description->getCommands() as $command) {
  55001. $this->write("\n\n");
  55002. if (null !== $describeCommand = $this->describeCommand($command, $options)) {
  55003. $this->write($describeCommand);
  55004. }
  55005. }
  55006. }
  55007. private function getApplicationTitle(Application $application): string
  55008. {
  55009. if ('UNKNOWN' !== $application->getName()) {
  55010. if ('UNKNOWN' !== $application->getVersion()) {
  55011. return sprintf('%s %s', $application->getName(), $application->getVersion());
  55012. }
  55013. return $application->getName();
  55014. }
  55015. return 'Console Tool';
  55016. }
  55017. }
  55018. <?php
  55019. namespace Symfony\Component\Console\Descriptor;
  55020. use Symfony\Component\Console\Application;
  55021. use Symfony\Component\Console\Command\Command;
  55022. use Symfony\Component\Console\Formatter\OutputFormatter;
  55023. use Symfony\Component\Console\Helper\Helper;
  55024. use Symfony\Component\Console\Input\InputArgument;
  55025. use Symfony\Component\Console\Input\InputDefinition;
  55026. use Symfony\Component\Console\Input\InputOption;
  55027. class TextDescriptor extends Descriptor
  55028. {
  55029. protected function describeInputArgument(InputArgument $argument, array $options = [])
  55030. {
  55031. if (null !== $argument->getDefault() && (!\is_array($argument->getDefault()) || \count($argument->getDefault()))) {
  55032. $default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($argument->getDefault()));
  55033. } else {
  55034. $default = '';
  55035. }
  55036. $totalWidth = $options['total_width'] ?? Helper::width($argument->getName());
  55037. $spacingWidth = $totalWidth - \strlen($argument->getName());
  55038. $this->writeText(sprintf(' <info>%s</info> %s%s%s',
  55039. $argument->getName(),
  55040. str_repeat(' ', $spacingWidth),
  55041. preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $argument->getDescription()),
  55042. $default
  55043. ), $options);
  55044. }
  55045. protected function describeInputOption(InputOption $option, array $options = [])
  55046. {
  55047. if ($option->acceptValue() && null !== $option->getDefault() && (!\is_array($option->getDefault()) || \count($option->getDefault()))) {
  55048. $default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($option->getDefault()));
  55049. } else {
  55050. $default = '';
  55051. }
  55052. $value = '';
  55053. if ($option->acceptValue()) {
  55054. $value = '='.strtoupper($option->getName());
  55055. if ($option->isValueOptional()) {
  55056. $value = '['.$value.']';
  55057. }
  55058. }
  55059. $totalWidth = $options['total_width'] ?? $this->calculateTotalWidthForOptions([$option]);
  55060. $synopsis = sprintf('%s%s',
  55061. $option->getShortcut() ? sprintf('-%s, ', $option->getShortcut()) : ' ',
  55062. sprintf($option->isNegatable() ? '--%1$s|--no-%1$s' : '--%1$s%2$s', $option->getName(), $value)
  55063. );
  55064. $spacingWidth = $totalWidth - Helper::width($synopsis);
  55065. $this->writeText(sprintf(' <info>%s</info> %s%s%s%s',
  55066. $synopsis,
  55067. str_repeat(' ', $spacingWidth),
  55068. preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $option->getDescription()),
  55069. $default,
  55070. $option->isArray() ? '<comment> (multiple values allowed)</comment>' : ''
  55071. ), $options);
  55072. }
  55073. protected function describeInputDefinition(InputDefinition $definition, array $options = [])
  55074. {
  55075. $totalWidth = $this->calculateTotalWidthForOptions($definition->getOptions());
  55076. foreach ($definition->getArguments() as $argument) {
  55077. $totalWidth = max($totalWidth, Helper::width($argument->getName()));
  55078. }
  55079. if ($definition->getArguments()) {
  55080. $this->writeText('<comment>Arguments:</comment>', $options);
  55081. $this->writeText("\n");
  55082. foreach ($definition->getArguments() as $argument) {
  55083. $this->describeInputArgument($argument, array_merge($options, ['total_width' => $totalWidth]));
  55084. $this->writeText("\n");
  55085. }
  55086. }
  55087. if ($definition->getArguments() && $definition->getOptions()) {
  55088. $this->writeText("\n");
  55089. }
  55090. if ($definition->getOptions()) {
  55091. $laterOptions = [];
  55092. $this->writeText('<comment>Options:</comment>', $options);
  55093. foreach ($definition->getOptions() as $option) {
  55094. if (\strlen($option->getShortcut() ?? '') > 1) {
  55095. $laterOptions[] = $option;
  55096. continue;
  55097. }
  55098. $this->writeText("\n");
  55099. $this->describeInputOption($option, array_merge($options, ['total_width' => $totalWidth]));
  55100. }
  55101. foreach ($laterOptions as $option) {
  55102. $this->writeText("\n");
  55103. $this->describeInputOption($option, array_merge($options, ['total_width' => $totalWidth]));
  55104. }
  55105. }
  55106. }
  55107. protected function describeCommand(Command $command, array $options = [])
  55108. {
  55109. $command->mergeApplicationDefinition(false);
  55110. if ($description = $command->getDescription()) {
  55111. $this->writeText('<comment>Description:</comment>', $options);
  55112. $this->writeText("\n");
  55113. $this->writeText(' '.$description);
  55114. $this->writeText("\n\n");
  55115. }
  55116. $this->writeText('<comment>Usage:</comment>', $options);
  55117. foreach (array_merge([$command->getSynopsis(true)], $command->getAliases(), $command->getUsages()) as $usage) {
  55118. $this->writeText("\n");
  55119. $this->writeText(' '.OutputFormatter::escape($usage), $options);
  55120. }
  55121. $this->writeText("\n");
  55122. $definition = $command->getDefinition();
  55123. if ($definition->getOptions() || $definition->getArguments()) {
  55124. $this->writeText("\n");
  55125. $this->describeInputDefinition($definition, $options);
  55126. $this->writeText("\n");
  55127. }
  55128. $help = $command->getProcessedHelp();
  55129. if ($help && $help !== $description) {
  55130. $this->writeText("\n");
  55131. $this->writeText('<comment>Help:</comment>', $options);
  55132. $this->writeText("\n");
  55133. $this->writeText(' '.str_replace("\n", "\n ", $help), $options);
  55134. $this->writeText("\n");
  55135. }
  55136. }
  55137. protected function describeApplication(Application $application, array $options = [])
  55138. {
  55139. $describedNamespace = $options['namespace'] ?? null;
  55140. $description = new ApplicationDescription($application, $describedNamespace);
  55141. if (isset($options['raw_text']) && $options['raw_text']) {
  55142. $width = $this->getColumnWidth($description->getCommands());
  55143. foreach ($description->getCommands() as $command) {
  55144. $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
  55145. $this->writeText("\n");
  55146. }
  55147. } else {
  55148. if ('' != $help = $application->getHelp()) {
  55149. $this->writeText("$help\n\n", $options);
  55150. }
  55151. $this->writeText("<comment>Usage:</comment>\n", $options);
  55152. $this->writeText(" command [options] [arguments]\n\n", $options);
  55153. $this->describeInputDefinition(new InputDefinition($application->getDefinition()->getOptions()), $options);
  55154. $this->writeText("\n");
  55155. $this->writeText("\n");
  55156. $commands = $description->getCommands();
  55157. $namespaces = $description->getNamespaces();
  55158. if ($describedNamespace && $namespaces) {
  55159. $describedNamespaceInfo = reset($namespaces);
  55160. foreach ($describedNamespaceInfo['commands'] as $name) {
  55161. $commands[$name] = $description->getCommand($name);
  55162. }
  55163. }
  55164. $width = $this->getColumnWidth(array_merge(...array_values(array_map(function ($namespace) use ($commands) {
  55165. return array_intersect($namespace['commands'], array_keys($commands));
  55166. }, array_values($namespaces)))));
  55167. if ($describedNamespace) {
  55168. $this->writeText(sprintf('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace), $options);
  55169. } else {
  55170. $this->writeText('<comment>Available commands:</comment>', $options);
  55171. }
  55172. foreach ($namespaces as $namespace) {
  55173. $namespace['commands'] = array_filter($namespace['commands'], function ($name) use ($commands) {
  55174. return isset($commands[$name]);
  55175. });
  55176. if (!$namespace['commands']) {
  55177. continue;
  55178. }
  55179. if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
  55180. $this->writeText("\n");
  55181. $this->writeText(' <comment>'.$namespace['id'].'</comment>', $options);
  55182. }
  55183. foreach ($namespace['commands'] as $name) {
  55184. $this->writeText("\n");
  55185. $spacingWidth = $width - Helper::width($name);
  55186. $command = $commands[$name];
  55187. $commandAliases = $name === $command->getName() ? $this->getCommandAliasesText($command) : '';
  55188. $this->writeText(sprintf(' <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $commandAliases.$command->getDescription()), $options);
  55189. }
  55190. }
  55191. $this->writeText("\n");
  55192. }
  55193. }
  55194. private function writeText(string $content, array $options = [])
  55195. {
  55196. $this->write(
  55197. isset($options['raw_text']) && $options['raw_text'] ? strip_tags($content) : $content,
  55198. isset($options['raw_output']) ? !$options['raw_output'] : true
  55199. );
  55200. }
  55201. private function getCommandAliasesText(Command $command): string
  55202. {
  55203. $text = '';
  55204. $aliases = $command->getAliases();
  55205. if ($aliases) {
  55206. $text = '['.implode('|', $aliases).'] ';
  55207. }
  55208. return $text;
  55209. }
  55210. private function formatDefaultValue($default): string
  55211. {
  55212. if (\INF === $default) {
  55213. return 'INF';
  55214. }
  55215. if (\is_string($default)) {
  55216. $default = OutputFormatter::escape($default);
  55217. } elseif (\is_array($default)) {
  55218. foreach ($default as $key => $value) {
  55219. if (\is_string($value)) {
  55220. $default[$key] = OutputFormatter::escape($value);
  55221. }
  55222. }
  55223. }
  55224. return str_replace('\\\\', '\\', json_encode($default, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE));
  55225. }
  55226. private function getColumnWidth(array $commands): int
  55227. {
  55228. $widths = [];
  55229. foreach ($commands as $command) {
  55230. if ($command instanceof Command) {
  55231. $widths[] = Helper::width($command->getName());
  55232. foreach ($command->getAliases() as $alias) {
  55233. $widths[] = Helper::width($alias);
  55234. }
  55235. } else {
  55236. $widths[] = Helper::width($command);
  55237. }
  55238. }
  55239. return $widths ? max($widths) + 2 : 0;
  55240. }
  55241. private function calculateTotalWidthForOptions(array $options): int
  55242. {
  55243. $totalWidth = 0;
  55244. foreach ($options as $option) {
  55245. $nameLength = 1 + max(Helper::width($option->getShortcut()), 1) + 4 + Helper::width($option->getName());
  55246. if ($option->isNegatable()) {
  55247. $nameLength += 6 + Helper::width($option->getName());
  55248. } elseif ($option->acceptValue()) {
  55249. $valueLength = 1 + Helper::width($option->getName());
  55250. $valueLength += $option->isValueOptional() ? 2 : 0;
  55251. $nameLength += $valueLength;
  55252. }
  55253. $totalWidth = max($totalWidth, $nameLength);
  55254. }
  55255. return $totalWidth;
  55256. }
  55257. }
  55258. <?php
  55259. namespace Symfony\Component\Console\Descriptor;
  55260. use Symfony\Component\Console\Application;
  55261. use Symfony\Component\Console\Command\Command;
  55262. use Symfony\Component\Console\Input\InputArgument;
  55263. use Symfony\Component\Console\Input\InputDefinition;
  55264. use Symfony\Component\Console\Input\InputOption;
  55265. class XmlDescriptor extends Descriptor
  55266. {
  55267. public function getInputDefinitionDocument(InputDefinition $definition): \DOMDocument
  55268. {
  55269. $dom = new \DOMDocument('1.0', 'UTF-8');
  55270. $dom->appendChild($definitionXML = $dom->createElement('definition'));
  55271. $definitionXML->appendChild($argumentsXML = $dom->createElement('arguments'));
  55272. foreach ($definition->getArguments() as $argument) {
  55273. $this->appendDocument($argumentsXML, $this->getInputArgumentDocument($argument));
  55274. }
  55275. $definitionXML->appendChild($optionsXML = $dom->createElement('options'));
  55276. foreach ($definition->getOptions() as $option) {
  55277. $this->appendDocument($optionsXML, $this->getInputOptionDocument($option));
  55278. }
  55279. return $dom;
  55280. }
  55281. public function getCommandDocument(Command $command, bool $short = false): \DOMDocument
  55282. {
  55283. $dom = new \DOMDocument('1.0', 'UTF-8');
  55284. $dom->appendChild($commandXML = $dom->createElement('command'));
  55285. $commandXML->setAttribute('id', $command->getName());
  55286. $commandXML->setAttribute('name', $command->getName());
  55287. $commandXML->setAttribute('hidden', $command->isHidden() ? 1 : 0);
  55288. $commandXML->appendChild($usagesXML = $dom->createElement('usages'));
  55289. $commandXML->appendChild($descriptionXML = $dom->createElement('description'));
  55290. $descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getDescription())));
  55291. if ($short) {
  55292. foreach ($command->getAliases() as $usage) {
  55293. $usagesXML->appendChild($dom->createElement('usage', $usage));
  55294. }
  55295. } else {
  55296. $command->mergeApplicationDefinition(false);
  55297. foreach (array_merge([$command->getSynopsis()], $command->getAliases(), $command->getUsages()) as $usage) {
  55298. $usagesXML->appendChild($dom->createElement('usage', $usage));
  55299. }
  55300. $commandXML->appendChild($helpXML = $dom->createElement('help'));
  55301. $helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getProcessedHelp())));
  55302. $definitionXML = $this->getInputDefinitionDocument($command->getDefinition());
  55303. $this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0));
  55304. }
  55305. return $dom;
  55306. }
  55307. public function getApplicationDocument(Application $application, string $namespace = null, bool $short = false): \DOMDocument
  55308. {
  55309. $dom = new \DOMDocument('1.0', 'UTF-8');
  55310. $dom->appendChild($rootXml = $dom->createElement('symfony'));
  55311. if ('UNKNOWN' !== $application->getName()) {
  55312. $rootXml->setAttribute('name', $application->getName());
  55313. if ('UNKNOWN' !== $application->getVersion()) {
  55314. $rootXml->setAttribute('version', $application->getVersion());
  55315. }
  55316. }
  55317. $rootXml->appendChild($commandsXML = $dom->createElement('commands'));
  55318. $description = new ApplicationDescription($application, $namespace, true);
  55319. if ($namespace) {
  55320. $commandsXML->setAttribute('namespace', $namespace);
  55321. }
  55322. foreach ($description->getCommands() as $command) {
  55323. $this->appendDocument($commandsXML, $this->getCommandDocument($command, $short));
  55324. }
  55325. if (!$namespace) {
  55326. $rootXml->appendChild($namespacesXML = $dom->createElement('namespaces'));
  55327. foreach ($description->getNamespaces() as $namespaceDescription) {
  55328. $namespacesXML->appendChild($namespaceArrayXML = $dom->createElement('namespace'));
  55329. $namespaceArrayXML->setAttribute('id', $namespaceDescription['id']);
  55330. foreach ($namespaceDescription['commands'] as $name) {
  55331. $namespaceArrayXML->appendChild($commandXML = $dom->createElement('command'));
  55332. $commandXML->appendChild($dom->createTextNode($name));
  55333. }
  55334. }
  55335. }
  55336. return $dom;
  55337. }
  55338. protected function describeInputArgument(InputArgument $argument, array $options = [])
  55339. {
  55340. $this->writeDocument($this->getInputArgumentDocument($argument));
  55341. }
  55342. protected function describeInputOption(InputOption $option, array $options = [])
  55343. {
  55344. $this->writeDocument($this->getInputOptionDocument($option));
  55345. }
  55346. protected function describeInputDefinition(InputDefinition $definition, array $options = [])
  55347. {
  55348. $this->writeDocument($this->getInputDefinitionDocument($definition));
  55349. }
  55350. protected function describeCommand(Command $command, array $options = [])
  55351. {
  55352. $this->writeDocument($this->getCommandDocument($command, $options['short'] ?? false));
  55353. }
  55354. protected function describeApplication(Application $application, array $options = [])
  55355. {
  55356. $this->writeDocument($this->getApplicationDocument($application, $options['namespace'] ?? null, $options['short'] ?? false));
  55357. }
  55358. private function appendDocument(\DOMNode $parentNode, \DOMNode $importedParent)
  55359. {
  55360. foreach ($importedParent->childNodes as $childNode) {
  55361. $parentNode->appendChild($parentNode->ownerDocument->importNode($childNode, true));
  55362. }
  55363. }
  55364. private function writeDocument(\DOMDocument $dom)
  55365. {
  55366. $dom->formatOutput = true;
  55367. $this->write($dom->saveXML());
  55368. }
  55369. private function getInputArgumentDocument(InputArgument $argument): \DOMDocument
  55370. {
  55371. $dom = new \DOMDocument('1.0', 'UTF-8');
  55372. $dom->appendChild($objectXML = $dom->createElement('argument'));
  55373. $objectXML->setAttribute('name', $argument->getName());
  55374. $objectXML->setAttribute('is_required', $argument->isRequired() ? 1 : 0);
  55375. $objectXML->setAttribute('is_array', $argument->isArray() ? 1 : 0);
  55376. $objectXML->appendChild($descriptionXML = $dom->createElement('description'));
  55377. $descriptionXML->appendChild($dom->createTextNode($argument->getDescription()));
  55378. $objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
  55379. $defaults = \is_array($argument->getDefault()) ? $argument->getDefault() : (\is_bool($argument->getDefault()) ? [var_export($argument->getDefault(), true)] : ($argument->getDefault() ? [$argument->getDefault()] : []));
  55380. foreach ($defaults as $default) {
  55381. $defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
  55382. $defaultXML->appendChild($dom->createTextNode($default));
  55383. }
  55384. return $dom;
  55385. }
  55386. private function getInputOptionDocument(InputOption $option): \DOMDocument
  55387. {
  55388. $dom = new \DOMDocument('1.0', 'UTF-8');
  55389. $dom->appendChild($objectXML = $dom->createElement('option'));
  55390. $objectXML->setAttribute('name', '--'.$option->getName());
  55391. $pos = strpos($option->getShortcut() ?? '', '|');
  55392. if (false !== $pos) {
  55393. $objectXML->setAttribute('shortcut', '-'.substr($option->getShortcut(), 0, $pos));
  55394. $objectXML->setAttribute('shortcuts', '-'.str_replace('|', '|-', $option->getShortcut()));
  55395. } else {
  55396. $objectXML->setAttribute('shortcut', $option->getShortcut() ? '-'.$option->getShortcut() : '');
  55397. }
  55398. $objectXML->setAttribute('accept_value', $option->acceptValue() ? 1 : 0);
  55399. $objectXML->setAttribute('is_value_required', $option->isValueRequired() ? 1 : 0);
  55400. $objectXML->setAttribute('is_multiple', $option->isArray() ? 1 : 0);
  55401. $objectXML->appendChild($descriptionXML = $dom->createElement('description'));
  55402. $descriptionXML->appendChild($dom->createTextNode($option->getDescription()));
  55403. if ($option->acceptValue()) {
  55404. $defaults = \is_array($option->getDefault()) ? $option->getDefault() : (\is_bool($option->getDefault()) ? [var_export($option->getDefault(), true)] : ($option->getDefault() ? [$option->getDefault()] : []));
  55405. $objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
  55406. if (!empty($defaults)) {
  55407. foreach ($defaults as $default) {
  55408. $defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
  55409. $defaultXML->appendChild($dom->createTextNode($default));
  55410. }
  55411. }
  55412. }
  55413. if ($option->isNegatable()) {
  55414. $dom->appendChild($objectXML = $dom->createElement('option'));
  55415. $objectXML->setAttribute('name', '--no-'.$option->getName());
  55416. $objectXML->setAttribute('shortcut', '');
  55417. $objectXML->setAttribute('accept_value', 0);
  55418. $objectXML->setAttribute('is_value_required', 0);
  55419. $objectXML->setAttribute('is_multiple', 0);
  55420. $objectXML->appendChild($descriptionXML = $dom->createElement('description'));
  55421. $descriptionXML->appendChild($dom->createTextNode('Negate the "--'.$option->getName().'" option'));
  55422. }
  55423. return $dom;
  55424. }
  55425. }
  55426. <?php
  55427. namespace Symfony\Component\Console\Event;
  55428. final class ConsoleCommandEvent extends ConsoleEvent
  55429. {
  55430. public const RETURN_CODE_DISABLED = 113;
  55431. private $commandShouldRun = true;
  55432. public function disableCommand(): bool
  55433. {
  55434. return $this->commandShouldRun = false;
  55435. }
  55436. public function enableCommand(): bool
  55437. {
  55438. return $this->commandShouldRun = true;
  55439. }
  55440. public function commandShouldRun(): bool
  55441. {
  55442. return $this->commandShouldRun;
  55443. }
  55444. }
  55445. <?php
  55446. namespace Symfony\Component\Console\Event;
  55447. use Symfony\Component\Console\Command\Command;
  55448. use Symfony\Component\Console\Input\InputInterface;
  55449. use Symfony\Component\Console\Output\OutputInterface;
  55450. final class ConsoleErrorEvent extends ConsoleEvent
  55451. {
  55452. private $error;
  55453. private $exitCode;
  55454. public function __construct(InputInterface $input, OutputInterface $output, \Throwable $error, Command $command = null)
  55455. {
  55456. parent::__construct($command, $input, $output);
  55457. $this->error = $error;
  55458. }
  55459. public function getError(): \Throwable
  55460. {
  55461. return $this->error;
  55462. }
  55463. public function setError(\Throwable $error): void
  55464. {
  55465. $this->error = $error;
  55466. }
  55467. public function setExitCode(int $exitCode): void
  55468. {
  55469. $this->exitCode = $exitCode;
  55470. $r = new \ReflectionProperty($this->error, 'code');
  55471. $r->setAccessible(true);
  55472. $r->setValue($this->error, $this->exitCode);
  55473. }
  55474. public function getExitCode(): int
  55475. {
  55476. return $this->exitCode ?? (\is_int($this->error->getCode()) && 0 !== $this->error->getCode() ? $this->error->getCode() : 1);
  55477. }
  55478. }
  55479. <?php
  55480. namespace Symfony\Component\Console\Event;
  55481. use Symfony\Component\Console\Command\Command;
  55482. use Symfony\Component\Console\Input\InputInterface;
  55483. use Symfony\Component\Console\Output\OutputInterface;
  55484. use Symfony\Contracts\EventDispatcher\Event;
  55485. class ConsoleEvent extends Event
  55486. {
  55487. protected $command;
  55488. private $input;
  55489. private $output;
  55490. public function __construct(?Command $command, InputInterface $input, OutputInterface $output)
  55491. {
  55492. $this->command = $command;
  55493. $this->input = $input;
  55494. $this->output = $output;
  55495. }
  55496. public function getCommand()
  55497. {
  55498. return $this->command;
  55499. }
  55500. public function getInput()
  55501. {
  55502. return $this->input;
  55503. }
  55504. public function getOutput()
  55505. {
  55506. return $this->output;
  55507. }
  55508. }
  55509. <?php
  55510. namespace Symfony\Component\Console\Event;
  55511. use Symfony\Component\Console\Command\Command;
  55512. use Symfony\Component\Console\Input\InputInterface;
  55513. use Symfony\Component\Console\Output\OutputInterface;
  55514. final class ConsoleSignalEvent extends ConsoleEvent
  55515. {
  55516. private $handlingSignal;
  55517. public function __construct(Command $command, InputInterface $input, OutputInterface $output, int $handlingSignal)
  55518. {
  55519. parent::__construct($command, $input, $output);
  55520. $this->handlingSignal = $handlingSignal;
  55521. }
  55522. public function getHandlingSignal(): int
  55523. {
  55524. return $this->handlingSignal;
  55525. }
  55526. }
  55527. <?php
  55528. namespace Symfony\Component\Console\Event;
  55529. use Symfony\Component\Console\Command\Command;
  55530. use Symfony\Component\Console\Input\InputInterface;
  55531. use Symfony\Component\Console\Output\OutputInterface;
  55532. final class ConsoleTerminateEvent extends ConsoleEvent
  55533. {
  55534. private $exitCode;
  55535. public function __construct(Command $command, InputInterface $input, OutputInterface $output, int $exitCode)
  55536. {
  55537. parent::__construct($command, $input, $output);
  55538. $this->setExitCode($exitCode);
  55539. }
  55540. public function setExitCode(int $exitCode): void
  55541. {
  55542. $this->exitCode = $exitCode;
  55543. }
  55544. public function getExitCode(): int
  55545. {
  55546. return $this->exitCode;
  55547. }
  55548. }
  55549. <?php
  55550. namespace Symfony\Component\Console\EventListener;
  55551. use Psr\Log\LoggerInterface;
  55552. use Symfony\Component\Console\ConsoleEvents;
  55553. use Symfony\Component\Console\Event\ConsoleErrorEvent;
  55554. use Symfony\Component\Console\Event\ConsoleEvent;
  55555. use Symfony\Component\Console\Event\ConsoleTerminateEvent;
  55556. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  55557. class ErrorListener implements EventSubscriberInterface
  55558. {
  55559. private $logger;
  55560. public function __construct(LoggerInterface $logger = null)
  55561. {
  55562. $this->logger = $logger;
  55563. }
  55564. public function onConsoleError(ConsoleErrorEvent $event)
  55565. {
  55566. if (null === $this->logger) {
  55567. return;
  55568. }
  55569. $error = $event->getError();
  55570. if (!$inputString = $this->getInputString($event)) {
  55571. $this->logger->critical('An error occurred while using the console. Message: "{message}"', ['exception' => $error, 'message' => $error->getMessage()]);
  55572. return;
  55573. }
  55574. $this->logger->critical('Error thrown while running command "{command}". Message: "{message}"', ['exception' => $error, 'command' => $inputString, 'message' => $error->getMessage()]);
  55575. }
  55576. public function onConsoleTerminate(ConsoleTerminateEvent $event)
  55577. {
  55578. if (null === $this->logger) {
  55579. return;
  55580. }
  55581. $exitCode = $event->getExitCode();
  55582. if (0 === $exitCode) {
  55583. return;
  55584. }
  55585. if (!$inputString = $this->getInputString($event)) {
  55586. $this->logger->debug('The console exited with code "{code}"', ['code' => $exitCode]);
  55587. return;
  55588. }
  55589. $this->logger->debug('Command "{command}" exited with code "{code}"', ['command' => $inputString, 'code' => $exitCode]);
  55590. }
  55591. public static function getSubscribedEvents()
  55592. {
  55593. return [
  55594. ConsoleEvents::ERROR => ['onConsoleError', -128],
  55595. ConsoleEvents::TERMINATE => ['onConsoleTerminate', -128],
  55596. ];
  55597. }
  55598. private static function getInputString(ConsoleEvent $event): ?string
  55599. {
  55600. $commandName = $event->getCommand() ? $event->getCommand()->getName() : null;
  55601. $input = $event->getInput();
  55602. if (method_exists($input, '__toString')) {
  55603. if ($commandName) {
  55604. return str_replace(["'$commandName'", "\"$commandName\""], $commandName, (string) $input);
  55605. }
  55606. return (string) $input;
  55607. }
  55608. return $commandName;
  55609. }
  55610. }
  55611. <?php
  55612. namespace Symfony\Component\Console\Exception;
  55613. class CommandNotFoundException extends \InvalidArgumentException implements ExceptionInterface
  55614. {
  55615. private $alternatives;
  55616. public function __construct(string $message, array $alternatives = [], int $code = 0, \Throwable $previous = null)
  55617. {
  55618. parent::__construct($message, $code, $previous);
  55619. $this->alternatives = $alternatives;
  55620. }
  55621. public function getAlternatives()
  55622. {
  55623. return $this->alternatives;
  55624. }
  55625. }
  55626. <?php
  55627. namespace Symfony\Component\Console\Exception;
  55628. interface ExceptionInterface extends \Throwable
  55629. {
  55630. }
  55631. <?php
  55632. namespace Symfony\Component\Console\Exception;
  55633. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  55634. {
  55635. }
  55636. <?php
  55637. namespace Symfony\Component\Console\Exception;
  55638. class InvalidOptionException extends \InvalidArgumentException implements ExceptionInterface
  55639. {
  55640. }
  55641. <?php
  55642. namespace Symfony\Component\Console\Exception;
  55643. class LogicException extends \LogicException implements ExceptionInterface
  55644. {
  55645. }
  55646. <?php
  55647. namespace Symfony\Component\Console\Exception;
  55648. class MissingInputException extends RuntimeException implements ExceptionInterface
  55649. {
  55650. }
  55651. <?php
  55652. namespace Symfony\Component\Console\Exception;
  55653. class NamespaceNotFoundException extends CommandNotFoundException
  55654. {
  55655. }
  55656. <?php
  55657. namespace Symfony\Component\Console\Exception;
  55658. class RuntimeException extends \RuntimeException implements ExceptionInterface
  55659. {
  55660. }
  55661. <?php
  55662. namespace Symfony\Component\Console\Formatter;
  55663. final class NullOutputFormatter implements OutputFormatterInterface
  55664. {
  55665. private $style;
  55666. public function format(?string $message): ?string
  55667. {
  55668. return null;
  55669. }
  55670. public function getStyle(string $name): OutputFormatterStyleInterface
  55671. {
  55672. return $this->style ?? $this->style = new NullOutputFormatterStyle();
  55673. }
  55674. public function hasStyle(string $name): bool
  55675. {
  55676. return false;
  55677. }
  55678. public function isDecorated(): bool
  55679. {
  55680. return false;
  55681. }
  55682. public function setDecorated(bool $decorated): void
  55683. {
  55684. }
  55685. public function setStyle(string $name, OutputFormatterStyleInterface $style): void
  55686. {
  55687. }
  55688. }
  55689. <?php
  55690. namespace Symfony\Component\Console\Formatter;
  55691. final class NullOutputFormatterStyle implements OutputFormatterStyleInterface
  55692. {
  55693. public function apply(string $text): string
  55694. {
  55695. return $text;
  55696. }
  55697. public function setBackground(string $color = null): void
  55698. {
  55699. }
  55700. public function setForeground(string $color = null): void
  55701. {
  55702. }
  55703. public function setOption(string $option): void
  55704. {
  55705. }
  55706. public function setOptions(array $options): void
  55707. {
  55708. }
  55709. public function unsetOption(string $option): void
  55710. {
  55711. }
  55712. }
  55713. <?php
  55714. namespace Symfony\Component\Console\Formatter;
  55715. use Symfony\Component\Console\Exception\InvalidArgumentException;
  55716. class OutputFormatter implements WrappableOutputFormatterInterface
  55717. {
  55718. private $decorated;
  55719. private $styles = [];
  55720. private $styleStack;
  55721. public function __clone()
  55722. {
  55723. $this->styleStack = clone $this->styleStack;
  55724. foreach ($this->styles as $key => $value) {
  55725. $this->styles[$key] = clone $value;
  55726. }
  55727. }
  55728. public static function escape(string $text)
  55729. {
  55730. $text = preg_replace('/([^\\\\]|^)([<>])/', '$1\\\\$2', $text);
  55731. return self::escapeTrailingBackslash($text);
  55732. }
  55733. public static function escapeTrailingBackslash(string $text): string
  55734. {
  55735. if (str_ends_with($text, '\\')) {
  55736. $len = \strlen($text);
  55737. $text = rtrim($text, '\\');
  55738. $text = str_replace("\0", '', $text);
  55739. $text .= str_repeat("\0", $len - \strlen($text));
  55740. }
  55741. return $text;
  55742. }
  55743. public function __construct(bool $decorated = false, array $styles = [])
  55744. {
  55745. $this->decorated = $decorated;
  55746. $this->setStyle('error', new OutputFormatterStyle('white', 'red'));
  55747. $this->setStyle('info', new OutputFormatterStyle('green'));
  55748. $this->setStyle('comment', new OutputFormatterStyle('yellow'));
  55749. $this->setStyle('question', new OutputFormatterStyle('black', 'cyan'));
  55750. foreach ($styles as $name => $style) {
  55751. $this->setStyle($name, $style);
  55752. }
  55753. $this->styleStack = new OutputFormatterStyleStack();
  55754. }
  55755. public function setDecorated(bool $decorated)
  55756. {
  55757. $this->decorated = $decorated;
  55758. }
  55759. public function isDecorated()
  55760. {
  55761. return $this->decorated;
  55762. }
  55763. public function setStyle(string $name, OutputFormatterStyleInterface $style)
  55764. {
  55765. $this->styles[strtolower($name)] = $style;
  55766. }
  55767. public function hasStyle(string $name)
  55768. {
  55769. return isset($this->styles[strtolower($name)]);
  55770. }
  55771. public function getStyle(string $name)
  55772. {
  55773. if (!$this->hasStyle($name)) {
  55774. throw new InvalidArgumentException(sprintf('Undefined style: "%s".', $name));
  55775. }
  55776. return $this->styles[strtolower($name)];
  55777. }
  55778. public function format(?string $message)
  55779. {
  55780. return $this->formatAndWrap($message, 0);
  55781. }
  55782. public function formatAndWrap(?string $message, int $width)
  55783. {
  55784. if (null === $message) {
  55785. return '';
  55786. }
  55787. $offset = 0;
  55788. $output = '';
  55789. $openTagRegex = '[a-z](?:[^\\\\<>]*+ | \\\\.)*';
  55790. $closeTagRegex = '[a-z][^<>]*+';
  55791. $currentLineLength = 0;
  55792. preg_match_all("#<(($openTagRegex) | /($closeTagRegex)?)>#ix", $message, $matches, \PREG_OFFSET_CAPTURE);
  55793. foreach ($matches[0] as $i => $match) {
  55794. $pos = $match[1];
  55795. $text = $match[0];
  55796. if (0 != $pos && '\\' == $message[$pos - 1]) {
  55797. continue;
  55798. }
  55799. $output .= $this->applyCurrentStyle(substr($message, $offset, $pos - $offset), $output, $width, $currentLineLength);
  55800. $offset = $pos + \strlen($text);
  55801. if ($open = '/' != $text[1]) {
  55802. $tag = $matches[1][$i][0];
  55803. } else {
  55804. $tag = $matches[3][$i][0] ?? '';
  55805. }
  55806. if (!$open && !$tag) {
  55807. $this->styleStack->pop();
  55808. } elseif (null === $style = $this->createStyleFromString($tag)) {
  55809. $output .= $this->applyCurrentStyle($text, $output, $width, $currentLineLength);
  55810. } elseif ($open) {
  55811. $this->styleStack->push($style);
  55812. } else {
  55813. $this->styleStack->pop($style);
  55814. }
  55815. }
  55816. $output .= $this->applyCurrentStyle(substr($message, $offset), $output, $width, $currentLineLength);
  55817. return strtr($output, ["\0" => '\\', '\\<' => '<', '\\>' => '>']);
  55818. }
  55819. public function getStyleStack()
  55820. {
  55821. return $this->styleStack;
  55822. }
  55823. private function createStyleFromString(string $string): ?OutputFormatterStyleInterface
  55824. {
  55825. if (isset($this->styles[$string])) {
  55826. return $this->styles[$string];
  55827. }
  55828. if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', $string, $matches, \PREG_SET_ORDER)) {
  55829. return null;
  55830. }
  55831. $style = new OutputFormatterStyle();
  55832. foreach ($matches as $match) {
  55833. array_shift($match);
  55834. $match[0] = strtolower($match[0]);
  55835. if ('fg' == $match[0]) {
  55836. $style->setForeground(strtolower($match[1]));
  55837. } elseif ('bg' == $match[0]) {
  55838. $style->setBackground(strtolower($match[1]));
  55839. } elseif ('href' === $match[0]) {
  55840. $url = preg_replace('{\\\\([<>])}', '$1', $match[1]);
  55841. $style->setHref($url);
  55842. } elseif ('options' === $match[0]) {
  55843. preg_match_all('([^,;]+)', strtolower($match[1]), $options);
  55844. $options = array_shift($options);
  55845. foreach ($options as $option) {
  55846. $style->setOption($option);
  55847. }
  55848. } else {
  55849. return null;
  55850. }
  55851. }
  55852. return $style;
  55853. }
  55854. private function applyCurrentStyle(string $text, string $current, int $width, int &$currentLineLength): string
  55855. {
  55856. if ('' === $text) {
  55857. return '';
  55858. }
  55859. if (!$width) {
  55860. return $this->isDecorated() ? $this->styleStack->getCurrent()->apply($text) : $text;
  55861. }
  55862. if (!$currentLineLength && '' !== $current) {
  55863. $text = ltrim($text);
  55864. }
  55865. if ($currentLineLength) {
  55866. $prefix = substr($text, 0, $i = $width - $currentLineLength)."\n";
  55867. $text = substr($text, $i);
  55868. } else {
  55869. $prefix = '';
  55870. }
  55871. preg_match('~(\\n)$~', $text, $matches);
  55872. $text = $prefix.preg_replace('~([^\\n]{'.$width.'})\\ *~', "\$1\n", $text);
  55873. $text = rtrim($text, "\n").($matches[1] ?? '');
  55874. if (!$currentLineLength && '' !== $current && "\n" !== substr($current, -1)) {
  55875. $text = "\n".$text;
  55876. }
  55877. $lines = explode("\n", $text);
  55878. foreach ($lines as $line) {
  55879. $currentLineLength += \strlen($line);
  55880. if ($width <= $currentLineLength) {
  55881. $currentLineLength = 0;
  55882. }
  55883. }
  55884. if ($this->isDecorated()) {
  55885. foreach ($lines as $i => $line) {
  55886. $lines[$i] = $this->styleStack->getCurrent()->apply($line);
  55887. }
  55888. }
  55889. return implode("\n", $lines);
  55890. }
  55891. }
  55892. <?php
  55893. namespace Symfony\Component\Console\Formatter;
  55894. interface OutputFormatterInterface
  55895. {
  55896. public function setDecorated(bool $decorated);
  55897. public function isDecorated();
  55898. public function setStyle(string $name, OutputFormatterStyleInterface $style);
  55899. public function hasStyle(string $name);
  55900. public function getStyle(string $name);
  55901. public function format(?string $message);
  55902. }
  55903. <?php
  55904. namespace Symfony\Component\Console\Formatter;
  55905. use Symfony\Component\Console\Color;
  55906. class OutputFormatterStyle implements OutputFormatterStyleInterface
  55907. {
  55908. private $color;
  55909. private $foreground;
  55910. private $background;
  55911. private $options;
  55912. private $href;
  55913. private $handlesHrefGracefully;
  55914. public function __construct(string $foreground = null, string $background = null, array $options = [])
  55915. {
  55916. $this->color = new Color($this->foreground = $foreground ?: '', $this->background = $background ?: '', $this->options = $options);
  55917. }
  55918. public function setForeground(string $color = null)
  55919. {
  55920. $this->color = new Color($this->foreground = $color ?: '', $this->background, $this->options);
  55921. }
  55922. public function setBackground(string $color = null)
  55923. {
  55924. $this->color = new Color($this->foreground, $this->background = $color ?: '', $this->options);
  55925. }
  55926. public function setHref(string $url): void
  55927. {
  55928. $this->href = $url;
  55929. }
  55930. public function setOption(string $option)
  55931. {
  55932. $this->options[] = $option;
  55933. $this->color = new Color($this->foreground, $this->background, $this->options);
  55934. }
  55935. public function unsetOption(string $option)
  55936. {
  55937. $pos = array_search($option, $this->options);
  55938. if (false !== $pos) {
  55939. unset($this->options[$pos]);
  55940. }
  55941. $this->color = new Color($this->foreground, $this->background, $this->options);
  55942. }
  55943. public function setOptions(array $options)
  55944. {
  55945. $this->color = new Color($this->foreground, $this->background, $this->options = $options);
  55946. }
  55947. public function apply(string $text)
  55948. {
  55949. if (null === $this->handlesHrefGracefully) {
  55950. $this->handlesHrefGracefully = 'JetBrains-JediTerm' !== getenv('TERMINAL_EMULATOR')
  55951. && (!getenv('KONSOLE_VERSION') || (int) getenv('KONSOLE_VERSION') > 201100);
  55952. }
  55953. if (null !== $this->href && $this->handlesHrefGracefully) {
  55954. $text = "\033]8;;$this->href\033\\$text\033]8;;\033\\";
  55955. }
  55956. return $this->color->apply($text);
  55957. }
  55958. }
  55959. <?php
  55960. namespace Symfony\Component\Console\Formatter;
  55961. interface OutputFormatterStyleInterface
  55962. {
  55963. public function setForeground(string $color = null);
  55964. public function setBackground(string $color = null);
  55965. public function setOption(string $option);
  55966. public function unsetOption(string $option);
  55967. public function setOptions(array $options);
  55968. public function apply(string $text);
  55969. }
  55970. <?php
  55971. namespace Symfony\Component\Console\Formatter;
  55972. use Symfony\Component\Console\Exception\InvalidArgumentException;
  55973. use Symfony\Contracts\Service\ResetInterface;
  55974. class OutputFormatterStyleStack implements ResetInterface
  55975. {
  55976. private $styles;
  55977. private $emptyStyle;
  55978. public function __construct(OutputFormatterStyleInterface $emptyStyle = null)
  55979. {
  55980. $this->emptyStyle = $emptyStyle ?? new OutputFormatterStyle();
  55981. $this->reset();
  55982. }
  55983. public function reset()
  55984. {
  55985. $this->styles = [];
  55986. }
  55987. public function push(OutputFormatterStyleInterface $style)
  55988. {
  55989. $this->styles[] = $style;
  55990. }
  55991. public function pop(OutputFormatterStyleInterface $style = null)
  55992. {
  55993. if (empty($this->styles)) {
  55994. return $this->emptyStyle;
  55995. }
  55996. if (null === $style) {
  55997. return array_pop($this->styles);
  55998. }
  55999. foreach (array_reverse($this->styles, true) as $index => $stackedStyle) {
  56000. if ($style->apply('') === $stackedStyle->apply('')) {
  56001. $this->styles = \array_slice($this->styles, 0, $index);
  56002. return $stackedStyle;
  56003. }
  56004. }
  56005. throw new InvalidArgumentException('Incorrectly nested style tag found.');
  56006. }
  56007. public function getCurrent()
  56008. {
  56009. if (empty($this->styles)) {
  56010. return $this->emptyStyle;
  56011. }
  56012. return $this->styles[\count($this->styles) - 1];
  56013. }
  56014. public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle)
  56015. {
  56016. $this->emptyStyle = $emptyStyle;
  56017. return $this;
  56018. }
  56019. public function getEmptyStyle()
  56020. {
  56021. return $this->emptyStyle;
  56022. }
  56023. }
  56024. <?php
  56025. namespace Symfony\Component\Console\Formatter;
  56026. interface WrappableOutputFormatterInterface extends OutputFormatterInterface
  56027. {
  56028. public function formatAndWrap(?string $message, int $width);
  56029. }
  56030. <?php
  56031. namespace Symfony\Component\Console\Helper;
  56032. class DebugFormatterHelper extends Helper
  56033. {
  56034. private const COLORS = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default'];
  56035. private $started = [];
  56036. private $count = -1;
  56037. public function start(string $id, string $message, string $prefix = 'RUN')
  56038. {
  56039. $this->started[$id] = ['border' => ++$this->count % \count(self::COLORS)];
  56040. return sprintf("%s<bg=blue;fg=white> %s </> <fg=blue>%s</>\n", $this->getBorder($id), $prefix, $message);
  56041. }
  56042. public function progress(string $id, string $buffer, bool $error = false, string $prefix = 'OUT', string $errorPrefix = 'ERR')
  56043. {
  56044. $message = '';
  56045. if ($error) {
  56046. if (isset($this->started[$id]['out'])) {
  56047. $message .= "\n";
  56048. unset($this->started[$id]['out']);
  56049. }
  56050. if (!isset($this->started[$id]['err'])) {
  56051. $message .= sprintf('%s<bg=red;fg=white> %s </> ', $this->getBorder($id), $errorPrefix);
  56052. $this->started[$id]['err'] = true;
  56053. }
  56054. $message .= str_replace("\n", sprintf("\n%s<bg=red;fg=white> %s </> ", $this->getBorder($id), $errorPrefix), $buffer);
  56055. } else {
  56056. if (isset($this->started[$id]['err'])) {
  56057. $message .= "\n";
  56058. unset($this->started[$id]['err']);
  56059. }
  56060. if (!isset($this->started[$id]['out'])) {
  56061. $message .= sprintf('%s<bg=green;fg=white> %s </> ', $this->getBorder($id), $prefix);
  56062. $this->started[$id]['out'] = true;
  56063. }
  56064. $message .= str_replace("\n", sprintf("\n%s<bg=green;fg=white> %s </> ", $this->getBorder($id), $prefix), $buffer);
  56065. }
  56066. return $message;
  56067. }
  56068. public function stop(string $id, string $message, bool $successful, string $prefix = 'RES')
  56069. {
  56070. $trailingEOL = isset($this->started[$id]['out']) || isset($this->started[$id]['err']) ? "\n" : '';
  56071. if ($successful) {
  56072. return sprintf("%s%s<bg=green;fg=white> %s </> <fg=green>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
  56073. }
  56074. $message = sprintf("%s%s<bg=red;fg=white> %s </> <fg=red>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
  56075. unset($this->started[$id]['out'], $this->started[$id]['err']);
  56076. return $message;
  56077. }
  56078. private function getBorder(string $id): string
  56079. {
  56080. return sprintf('<bg=%s> </>', self::COLORS[$this->started[$id]['border']]);
  56081. }
  56082. public function getName()
  56083. {
  56084. return 'debug_formatter';
  56085. }
  56086. }
  56087. <?php
  56088. namespace Symfony\Component\Console\Helper;
  56089. use Symfony\Component\Console\Descriptor\DescriptorInterface;
  56090. use Symfony\Component\Console\Descriptor\JsonDescriptor;
  56091. use Symfony\Component\Console\Descriptor\MarkdownDescriptor;
  56092. use Symfony\Component\Console\Descriptor\TextDescriptor;
  56093. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  56094. use Symfony\Component\Console\Exception\InvalidArgumentException;
  56095. use Symfony\Component\Console\Output\OutputInterface;
  56096. class DescriptorHelper extends Helper
  56097. {
  56098. private $descriptors = [];
  56099. public function __construct()
  56100. {
  56101. $this
  56102. ->register('txt', new TextDescriptor())
  56103. ->register('xml', new XmlDescriptor())
  56104. ->register('json', new JsonDescriptor())
  56105. ->register('md', new MarkdownDescriptor())
  56106. ;
  56107. }
  56108. public function describe(OutputInterface $output, ?object $object, array $options = [])
  56109. {
  56110. $options = array_merge([
  56111. 'raw_text' => false,
  56112. 'format' => 'txt',
  56113. ], $options);
  56114. if (!isset($this->descriptors[$options['format']])) {
  56115. throw new InvalidArgumentException(sprintf('Unsupported format "%s".', $options['format']));
  56116. }
  56117. $descriptor = $this->descriptors[$options['format']];
  56118. $descriptor->describe($output, $object, $options);
  56119. }
  56120. public function register(string $format, DescriptorInterface $descriptor)
  56121. {
  56122. $this->descriptors[$format] = $descriptor;
  56123. return $this;
  56124. }
  56125. public function getName()
  56126. {
  56127. return 'descriptor';
  56128. }
  56129. public function getFormats(): array
  56130. {
  56131. return array_keys($this->descriptors);
  56132. }
  56133. }
  56134. <?php
  56135. namespace Symfony\Component\Console\Helper;
  56136. use Symfony\Component\Console\Output\OutputInterface;
  56137. use Symfony\Component\VarDumper\Cloner\ClonerInterface;
  56138. use Symfony\Component\VarDumper\Cloner\VarCloner;
  56139. use Symfony\Component\VarDumper\Dumper\CliDumper;
  56140. final class Dumper
  56141. {
  56142. private $output;
  56143. private $dumper;
  56144. private $cloner;
  56145. private $handler;
  56146. public function __construct(OutputInterface $output, CliDumper $dumper = null, ClonerInterface $cloner = null)
  56147. {
  56148. $this->output = $output;
  56149. $this->dumper = $dumper;
  56150. $this->cloner = $cloner;
  56151. if (class_exists(CliDumper::class)) {
  56152. $this->handler = function ($var): string {
  56153. $dumper = $this->dumper ?? $this->dumper = new CliDumper(null, null, CliDumper::DUMP_LIGHT_ARRAY | CliDumper::DUMP_COMMA_SEPARATOR);
  56154. $dumper->setColors($this->output->isDecorated());
  56155. return rtrim($dumper->dump(($this->cloner ?? $this->cloner = new VarCloner())->cloneVar($var)->withRefHandles(false), true));
  56156. };
  56157. } else {
  56158. $this->handler = function ($var): string {
  56159. switch (true) {
  56160. case null === $var:
  56161. return 'null';
  56162. case true === $var:
  56163. return 'true';
  56164. case false === $var:
  56165. return 'false';
  56166. case \is_string($var):
  56167. return '"'.$var.'"';
  56168. default:
  56169. return rtrim(print_r($var, true));
  56170. }
  56171. };
  56172. }
  56173. }
  56174. public function __invoke($var): string
  56175. {
  56176. return ($this->handler)($var);
  56177. }
  56178. }
  56179. <?php
  56180. namespace Symfony\Component\Console\Helper;
  56181. use Symfony\Component\Console\Formatter\OutputFormatter;
  56182. class FormatterHelper extends Helper
  56183. {
  56184. public function formatSection(string $section, string $message, string $style = 'info')
  56185. {
  56186. return sprintf('<%s>[%s]</%s> %s', $style, $section, $style, $message);
  56187. }
  56188. public function formatBlock($messages, string $style, bool $large = false)
  56189. {
  56190. if (!\is_array($messages)) {
  56191. $messages = [$messages];
  56192. }
  56193. $len = 0;
  56194. $lines = [];
  56195. foreach ($messages as $message) {
  56196. $message = OutputFormatter::escape($message);
  56197. $lines[] = sprintf($large ? ' %s ' : ' %s ', $message);
  56198. $len = max(self::width($message) + ($large ? 4 : 2), $len);
  56199. }
  56200. $messages = $large ? [str_repeat(' ', $len)] : [];
  56201. for ($i = 0; isset($lines[$i]); ++$i) {
  56202. $messages[] = $lines[$i].str_repeat(' ', $len - self::width($lines[$i]));
  56203. }
  56204. if ($large) {
  56205. $messages[] = str_repeat(' ', $len);
  56206. }
  56207. for ($i = 0; isset($messages[$i]); ++$i) {
  56208. $messages[$i] = sprintf('<%s>%s</%s>', $style, $messages[$i], $style);
  56209. }
  56210. return implode("\n", $messages);
  56211. }
  56212. public function truncate(string $message, int $length, string $suffix = '...')
  56213. {
  56214. $computedLength = $length - self::width($suffix);
  56215. if ($computedLength > self::width($message)) {
  56216. return $message;
  56217. }
  56218. return self::substr($message, 0, $length).$suffix;
  56219. }
  56220. public function getName()
  56221. {
  56222. return 'formatter';
  56223. }
  56224. }
  56225. <?php
  56226. namespace Symfony\Component\Console\Helper;
  56227. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  56228. use Symfony\Component\String\UnicodeString;
  56229. abstract class Helper implements HelperInterface
  56230. {
  56231. protected $helperSet = null;
  56232. public function setHelperSet(HelperSet $helperSet = null)
  56233. {
  56234. $this->helperSet = $helperSet;
  56235. }
  56236. public function getHelperSet()
  56237. {
  56238. return $this->helperSet;
  56239. }
  56240. public static function strlen(?string $string)
  56241. {
  56242. trigger_deprecation('symfony/console', '5.3', 'Method "%s()" is deprecated and will be removed in Symfony 6.0. Use Helper::width() or Helper::length() instead.', __METHOD__);
  56243. return self::width($string);
  56244. }
  56245. public static function width(?string $string): int
  56246. {
  56247. $string ?? $string = '';
  56248. if (preg_match('//u', $string)) {
  56249. return (new UnicodeString($string))->width(false);
  56250. }
  56251. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  56252. return \strlen($string);
  56253. }
  56254. return mb_strwidth($string, $encoding);
  56255. }
  56256. public static function length(?string $string): int
  56257. {
  56258. $string ?? $string = '';
  56259. if (preg_match('//u', $string)) {
  56260. return (new UnicodeString($string))->length();
  56261. }
  56262. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  56263. return \strlen($string);
  56264. }
  56265. return mb_strlen($string, $encoding);
  56266. }
  56267. public static function substr(?string $string, int $from, int $length = null)
  56268. {
  56269. $string ?? $string = '';
  56270. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  56271. return substr($string, $from, $length);
  56272. }
  56273. return mb_substr($string, $from, $length, $encoding);
  56274. }
  56275. public static function formatTime($secs)
  56276. {
  56277. static $timeFormats = [
  56278. [0, '< 1 sec'],
  56279. [1, '1 sec'],
  56280. [2, 'secs', 1],
  56281. [60, '1 min'],
  56282. [120, 'mins', 60],
  56283. [3600, '1 hr'],
  56284. [7200, 'hrs', 3600],
  56285. [86400, '1 day'],
  56286. [172800, 'days', 86400],
  56287. ];
  56288. foreach ($timeFormats as $index => $format) {
  56289. if ($secs >= $format[0]) {
  56290. if ((isset($timeFormats[$index + 1]) && $secs < $timeFormats[$index + 1][0])
  56291. || $index == \count($timeFormats) - 1
  56292. ) {
  56293. if (2 == \count($format)) {
  56294. return $format[1];
  56295. }
  56296. return floor($secs / $format[2]).' '.$format[1];
  56297. }
  56298. }
  56299. }
  56300. }
  56301. public static function formatMemory(int $memory)
  56302. {
  56303. if ($memory >= 1024 * 1024 * 1024) {
  56304. return sprintf('%.1f GiB', $memory / 1024 / 1024 / 1024);
  56305. }
  56306. if ($memory >= 1024 * 1024) {
  56307. return sprintf('%.1f MiB', $memory / 1024 / 1024);
  56308. }
  56309. if ($memory >= 1024) {
  56310. return sprintf('%d KiB', $memory / 1024);
  56311. }
  56312. return sprintf('%d B', $memory);
  56313. }
  56314. public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, ?string $string)
  56315. {
  56316. trigger_deprecation('symfony/console', '5.3', 'Method "%s()" is deprecated and will be removed in Symfony 6.0. Use Helper::removeDecoration() instead.', __METHOD__);
  56317. return self::width(self::removeDecoration($formatter, $string));
  56318. }
  56319. public static function removeDecoration(OutputFormatterInterface $formatter, ?string $string)
  56320. {
  56321. $isDecorated = $formatter->isDecorated();
  56322. $formatter->setDecorated(false);
  56323. $string = $formatter->format($string ?? '');
  56324. $string = preg_replace("/\033\[[^m]*m/", '', $string ?? '');
  56325. $formatter->setDecorated($isDecorated);
  56326. return $string;
  56327. }
  56328. }
  56329. <?php
  56330. namespace Symfony\Component\Console\Helper;
  56331. interface HelperInterface
  56332. {
  56333. public function setHelperSet(HelperSet $helperSet = null);
  56334. public function getHelperSet();
  56335. public function getName();
  56336. }
  56337. <?php
  56338. namespace Symfony\Component\Console\Helper;
  56339. use Symfony\Component\Console\Command\Command;
  56340. use Symfony\Component\Console\Exception\InvalidArgumentException;
  56341. class HelperSet implements \IteratorAggregate
  56342. {
  56343. private $helpers = [];
  56344. private $command;
  56345. public function __construct(array $helpers = [])
  56346. {
  56347. foreach ($helpers as $alias => $helper) {
  56348. $this->set($helper, \is_int($alias) ? null : $alias);
  56349. }
  56350. }
  56351. public function set(HelperInterface $helper, string $alias = null)
  56352. {
  56353. $this->helpers[$helper->getName()] = $helper;
  56354. if (null !== $alias) {
  56355. $this->helpers[$alias] = $helper;
  56356. }
  56357. $helper->setHelperSet($this);
  56358. }
  56359. public function has(string $name)
  56360. {
  56361. return isset($this->helpers[$name]);
  56362. }
  56363. public function get(string $name)
  56364. {
  56365. if (!$this->has($name)) {
  56366. throw new InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
  56367. }
  56368. return $this->helpers[$name];
  56369. }
  56370. public function setCommand(Command $command = null)
  56371. {
  56372. trigger_deprecation('symfony/console', '5.4', 'Method "%s()" is deprecated.', __METHOD__);
  56373. $this->command = $command;
  56374. }
  56375. public function getCommand()
  56376. {
  56377. trigger_deprecation('symfony/console', '5.4', 'Method "%s()" is deprecated.', __METHOD__);
  56378. return $this->command;
  56379. }
  56380. #[\ReturnTypeWillChange]
  56381. public function getIterator()
  56382. {
  56383. return new \ArrayIterator($this->helpers);
  56384. }
  56385. }
  56386. <?php
  56387. namespace Symfony\Component\Console\Helper;
  56388. use Symfony\Component\Console\Input\InputAwareInterface;
  56389. use Symfony\Component\Console\Input\InputInterface;
  56390. abstract class InputAwareHelper extends Helper implements InputAwareInterface
  56391. {
  56392. protected $input;
  56393. public function setInput(InputInterface $input)
  56394. {
  56395. $this->input = $input;
  56396. }
  56397. }
  56398. <?php
  56399. namespace Symfony\Component\Console\Helper;
  56400. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  56401. use Symfony\Component\Console\Output\OutputInterface;
  56402. use Symfony\Component\Process\Exception\ProcessFailedException;
  56403. use Symfony\Component\Process\Process;
  56404. class ProcessHelper extends Helper
  56405. {
  56406. public function run(OutputInterface $output, $cmd, string $error = null, callable $callback = null, int $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE): Process
  56407. {
  56408. if (!class_exists(Process::class)) {
  56409. throw new \LogicException('The ProcessHelper cannot be run as the Process component is not installed. Try running "compose require symfony/process".');
  56410. }
  56411. if ($output instanceof ConsoleOutputInterface) {
  56412. $output = $output->getErrorOutput();
  56413. }
  56414. $formatter = $this->getHelperSet()->get('debug_formatter');
  56415. if ($cmd instanceof Process) {
  56416. $cmd = [$cmd];
  56417. }
  56418. if (!\is_array($cmd)) {
  56419. throw new \TypeError(sprintf('The "command" argument of "%s()" must be an array or a "%s" instance, "%s" given.', __METHOD__, Process::class, get_debug_type($cmd)));
  56420. }
  56421. if (\is_string($cmd[0] ?? null)) {
  56422. $process = new Process($cmd);
  56423. $cmd = [];
  56424. } elseif (($cmd[0] ?? null) instanceof Process) {
  56425. $process = $cmd[0];
  56426. unset($cmd[0]);
  56427. } else {
  56428. throw new \InvalidArgumentException(sprintf('Invalid command provided to "%s()": the command should be an array whose first element is either the path to the binary to run or a "Process" object.', __METHOD__));
  56429. }
  56430. if ($verbosity <= $output->getVerbosity()) {
  56431. $output->write($formatter->start(spl_object_hash($process), $this->escapeString($process->getCommandLine())));
  56432. }
  56433. if ($output->isDebug()) {
  56434. $callback = $this->wrapCallback($output, $process, $callback);
  56435. }
  56436. $process->run($callback, $cmd);
  56437. if ($verbosity <= $output->getVerbosity()) {
  56438. $message = $process->isSuccessful() ? 'Command ran successfully' : sprintf('%s Command did not run successfully', $process->getExitCode());
  56439. $output->write($formatter->stop(spl_object_hash($process), $message, $process->isSuccessful()));
  56440. }
  56441. if (!$process->isSuccessful() && null !== $error) {
  56442. $output->writeln(sprintf('<error>%s</error>', $this->escapeString($error)));
  56443. }
  56444. return $process;
  56445. }
  56446. public function mustRun(OutputInterface $output, $cmd, string $error = null, callable $callback = null): Process
  56447. {
  56448. $process = $this->run($output, $cmd, $error, $callback);
  56449. if (!$process->isSuccessful()) {
  56450. throw new ProcessFailedException($process);
  56451. }
  56452. return $process;
  56453. }
  56454. public function wrapCallback(OutputInterface $output, Process $process, callable $callback = null): callable
  56455. {
  56456. if ($output instanceof ConsoleOutputInterface) {
  56457. $output = $output->getErrorOutput();
  56458. }
  56459. $formatter = $this->getHelperSet()->get('debug_formatter');
  56460. return function ($type, $buffer) use ($output, $process, $callback, $formatter) {
  56461. $output->write($formatter->progress(spl_object_hash($process), $this->escapeString($buffer), Process::ERR === $type));
  56462. if (null !== $callback) {
  56463. $callback($type, $buffer);
  56464. }
  56465. };
  56466. }
  56467. private function escapeString(string $str): string
  56468. {
  56469. return str_replace('<', '\\<', $str);
  56470. }
  56471. public function getName(): string
  56472. {
  56473. return 'process';
  56474. }
  56475. }
  56476. <?php
  56477. namespace Symfony\Component\Console\Helper;
  56478. use Symfony\Component\Console\Cursor;
  56479. use Symfony\Component\Console\Exception\LogicException;
  56480. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  56481. use Symfony\Component\Console\Output\ConsoleSectionOutput;
  56482. use Symfony\Component\Console\Output\OutputInterface;
  56483. use Symfony\Component\Console\Terminal;
  56484. final class ProgressBar
  56485. {
  56486. public const FORMAT_VERBOSE = 'verbose';
  56487. public const FORMAT_VERY_VERBOSE = 'very_verbose';
  56488. public const FORMAT_DEBUG = 'debug';
  56489. public const FORMAT_NORMAL = 'normal';
  56490. private const FORMAT_VERBOSE_NOMAX = 'verbose_nomax';
  56491. private const FORMAT_VERY_VERBOSE_NOMAX = 'very_verbose_nomax';
  56492. private const FORMAT_DEBUG_NOMAX = 'debug_nomax';
  56493. private const FORMAT_NORMAL_NOMAX = 'normal_nomax';
  56494. private $barWidth = 28;
  56495. private $barChar;
  56496. private $emptyBarChar = '-';
  56497. private $progressChar = '>';
  56498. private $format;
  56499. private $internalFormat;
  56500. private $redrawFreq = 1;
  56501. private $writeCount;
  56502. private $lastWriteTime;
  56503. private $minSecondsBetweenRedraws = 0;
  56504. private $maxSecondsBetweenRedraws = 1;
  56505. private $output;
  56506. private $step = 0;
  56507. private $max;
  56508. private $startTime;
  56509. private $stepWidth;
  56510. private $percent = 0.0;
  56511. private $formatLineCount;
  56512. private $messages = [];
  56513. private $overwrite = true;
  56514. private $terminal;
  56515. private $previousMessage;
  56516. private $cursor;
  56517. private static $formatters;
  56518. private static $formats;
  56519. public function __construct(OutputInterface $output, int $max = 0, float $minSecondsBetweenRedraws = 1 / 25)
  56520. {
  56521. if ($output instanceof ConsoleOutputInterface) {
  56522. $output = $output->getErrorOutput();
  56523. }
  56524. $this->output = $output;
  56525. $this->setMaxSteps($max);
  56526. $this->terminal = new Terminal();
  56527. if (0 < $minSecondsBetweenRedraws) {
  56528. $this->redrawFreq = null;
  56529. $this->minSecondsBetweenRedraws = $minSecondsBetweenRedraws;
  56530. }
  56531. if (!$this->output->isDecorated()) {
  56532. $this->overwrite = false;
  56533. $this->redrawFreq = null;
  56534. }
  56535. $this->startTime = time();
  56536. $this->cursor = new Cursor($output);
  56537. }
  56538. public static function setPlaceholderFormatterDefinition(string $name, callable $callable): void
  56539. {
  56540. if (!self::$formatters) {
  56541. self::$formatters = self::initPlaceholderFormatters();
  56542. }
  56543. self::$formatters[$name] = $callable;
  56544. }
  56545. public static function getPlaceholderFormatterDefinition(string $name): ?callable
  56546. {
  56547. if (!self::$formatters) {
  56548. self::$formatters = self::initPlaceholderFormatters();
  56549. }
  56550. return self::$formatters[$name] ?? null;
  56551. }
  56552. public static function setFormatDefinition(string $name, string $format): void
  56553. {
  56554. if (!self::$formats) {
  56555. self::$formats = self::initFormats();
  56556. }
  56557. self::$formats[$name] = $format;
  56558. }
  56559. public static function getFormatDefinition(string $name): ?string
  56560. {
  56561. if (!self::$formats) {
  56562. self::$formats = self::initFormats();
  56563. }
  56564. return self::$formats[$name] ?? null;
  56565. }
  56566. public function setMessage(string $message, string $name = 'message')
  56567. {
  56568. $this->messages[$name] = $message;
  56569. }
  56570. public function getMessage(string $name = 'message')
  56571. {
  56572. return $this->messages[$name];
  56573. }
  56574. public function getStartTime(): int
  56575. {
  56576. return $this->startTime;
  56577. }
  56578. public function getMaxSteps(): int
  56579. {
  56580. return $this->max;
  56581. }
  56582. public function getProgress(): int
  56583. {
  56584. return $this->step;
  56585. }
  56586. private function getStepWidth(): int
  56587. {
  56588. return $this->stepWidth;
  56589. }
  56590. public function getProgressPercent(): float
  56591. {
  56592. return $this->percent;
  56593. }
  56594. public function getBarOffset(): float
  56595. {
  56596. return floor($this->max ? $this->percent * $this->barWidth : (null === $this->redrawFreq ? (int) (min(5, $this->barWidth / 15) * $this->writeCount) : $this->step) % $this->barWidth);
  56597. }
  56598. public function getEstimated(): float
  56599. {
  56600. if (!$this->step) {
  56601. return 0;
  56602. }
  56603. return round((time() - $this->startTime) / $this->step * $this->max);
  56604. }
  56605. public function getRemaining(): float
  56606. {
  56607. if (!$this->step) {
  56608. return 0;
  56609. }
  56610. return round((time() - $this->startTime) / $this->step * ($this->max - $this->step));
  56611. }
  56612. public function setBarWidth(int $size)
  56613. {
  56614. $this->barWidth = max(1, $size);
  56615. }
  56616. public function getBarWidth(): int
  56617. {
  56618. return $this->barWidth;
  56619. }
  56620. public function setBarCharacter(string $char)
  56621. {
  56622. $this->barChar = $char;
  56623. }
  56624. public function getBarCharacter(): string
  56625. {
  56626. return $this->barChar ?? ($this->max ? '=' : $this->emptyBarChar);
  56627. }
  56628. public function setEmptyBarCharacter(string $char)
  56629. {
  56630. $this->emptyBarChar = $char;
  56631. }
  56632. public function getEmptyBarCharacter(): string
  56633. {
  56634. return $this->emptyBarChar;
  56635. }
  56636. public function setProgressCharacter(string $char)
  56637. {
  56638. $this->progressChar = $char;
  56639. }
  56640. public function getProgressCharacter(): string
  56641. {
  56642. return $this->progressChar;
  56643. }
  56644. public function setFormat(string $format)
  56645. {
  56646. $this->format = null;
  56647. $this->internalFormat = $format;
  56648. }
  56649. public function setRedrawFrequency(?int $freq)
  56650. {
  56651. $this->redrawFreq = null !== $freq ? max(1, $freq) : null;
  56652. }
  56653. public function minSecondsBetweenRedraws(float $seconds): void
  56654. {
  56655. $this->minSecondsBetweenRedraws = $seconds;
  56656. }
  56657. public function maxSecondsBetweenRedraws(float $seconds): void
  56658. {
  56659. $this->maxSecondsBetweenRedraws = $seconds;
  56660. }
  56661. public function iterate(iterable $iterable, int $max = null): iterable
  56662. {
  56663. $this->start($max ?? (is_countable($iterable) ? \count($iterable) : 0));
  56664. foreach ($iterable as $key => $value) {
  56665. yield $key => $value;
  56666. $this->advance();
  56667. }
  56668. $this->finish();
  56669. }
  56670. public function start(int $max = null)
  56671. {
  56672. $this->startTime = time();
  56673. $this->step = 0;
  56674. $this->percent = 0.0;
  56675. if (null !== $max) {
  56676. $this->setMaxSteps($max);
  56677. }
  56678. $this->display();
  56679. }
  56680. public function advance(int $step = 1)
  56681. {
  56682. $this->setProgress($this->step + $step);
  56683. }
  56684. public function setOverwrite(bool $overwrite)
  56685. {
  56686. $this->overwrite = $overwrite;
  56687. }
  56688. public function setProgress(int $step)
  56689. {
  56690. if ($this->max && $step > $this->max) {
  56691. $this->max = $step;
  56692. } elseif ($step < 0) {
  56693. $step = 0;
  56694. }
  56695. $redrawFreq = $this->redrawFreq ?? (($this->max ?: 10) / 10);
  56696. $prevPeriod = (int) ($this->step / $redrawFreq);
  56697. $currPeriod = (int) ($step / $redrawFreq);
  56698. $this->step = $step;
  56699. $this->percent = $this->max ? (float) $this->step / $this->max : 0;
  56700. $timeInterval = microtime(true) - $this->lastWriteTime;
  56701. if ($this->max === $step) {
  56702. $this->display();
  56703. return;
  56704. }
  56705. if ($timeInterval < $this->minSecondsBetweenRedraws) {
  56706. return;
  56707. }
  56708. if ($prevPeriod !== $currPeriod || $timeInterval >= $this->maxSecondsBetweenRedraws) {
  56709. $this->display();
  56710. }
  56711. }
  56712. public function setMaxSteps(int $max)
  56713. {
  56714. $this->format = null;
  56715. $this->max = max(0, $max);
  56716. $this->stepWidth = $this->max ? Helper::width((string) $this->max) : 4;
  56717. }
  56718. public function finish(): void
  56719. {
  56720. if (!$this->max) {
  56721. $this->max = $this->step;
  56722. }
  56723. if ($this->step === $this->max && !$this->overwrite) {
  56724. return;
  56725. }
  56726. $this->setProgress($this->max);
  56727. }
  56728. public function display(): void
  56729. {
  56730. if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) {
  56731. return;
  56732. }
  56733. if (null === $this->format) {
  56734. $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
  56735. }
  56736. $this->overwrite($this->buildLine());
  56737. }
  56738. public function clear(): void
  56739. {
  56740. if (!$this->overwrite) {
  56741. return;
  56742. }
  56743. if (null === $this->format) {
  56744. $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
  56745. }
  56746. $this->overwrite('');
  56747. }
  56748. private function setRealFormat(string $format)
  56749. {
  56750. if (!$this->max && null !== self::getFormatDefinition($format.'_nomax')) {
  56751. $this->format = self::getFormatDefinition($format.'_nomax');
  56752. } elseif (null !== self::getFormatDefinition($format)) {
  56753. $this->format = self::getFormatDefinition($format);
  56754. } else {
  56755. $this->format = $format;
  56756. }
  56757. $this->formatLineCount = substr_count($this->format, "\n");
  56758. }
  56759. private function overwrite(string $message): void
  56760. {
  56761. if ($this->previousMessage === $message) {
  56762. return;
  56763. }
  56764. $originalMessage = $message;
  56765. if ($this->overwrite) {
  56766. if (null !== $this->previousMessage) {
  56767. if ($this->output instanceof ConsoleSectionOutput) {
  56768. $messageLines = explode("\n", $message);
  56769. $lineCount = \count($messageLines);
  56770. foreach ($messageLines as $messageLine) {
  56771. $messageLineLength = Helper::width(Helper::removeDecoration($this->output->getFormatter(), $messageLine));
  56772. if ($messageLineLength > $this->terminal->getWidth()) {
  56773. $lineCount += floor($messageLineLength / $this->terminal->getWidth());
  56774. }
  56775. }
  56776. $this->output->clear($lineCount);
  56777. } else {
  56778. for ($i = 0; $i < $this->formatLineCount; ++$i) {
  56779. $this->cursor->moveToColumn(1);
  56780. $this->cursor->clearLine();
  56781. $this->cursor->moveUp();
  56782. }
  56783. $this->cursor->moveToColumn(1);
  56784. $this->cursor->clearLine();
  56785. }
  56786. }
  56787. } elseif ($this->step > 0) {
  56788. $message = \PHP_EOL.$message;
  56789. }
  56790. $this->previousMessage = $originalMessage;
  56791. $this->lastWriteTime = microtime(true);
  56792. $this->output->write($message);
  56793. ++$this->writeCount;
  56794. }
  56795. private function determineBestFormat(): string
  56796. {
  56797. switch ($this->output->getVerbosity()) {
  56798. case OutputInterface::VERBOSITY_VERBOSE:
  56799. return $this->max ? self::FORMAT_VERBOSE : self::FORMAT_VERBOSE_NOMAX;
  56800. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  56801. return $this->max ? self::FORMAT_VERY_VERBOSE : self::FORMAT_VERY_VERBOSE_NOMAX;
  56802. case OutputInterface::VERBOSITY_DEBUG:
  56803. return $this->max ? self::FORMAT_DEBUG : self::FORMAT_DEBUG_NOMAX;
  56804. default:
  56805. return $this->max ? self::FORMAT_NORMAL : self::FORMAT_NORMAL_NOMAX;
  56806. }
  56807. }
  56808. private static function initPlaceholderFormatters(): array
  56809. {
  56810. return [
  56811. 'bar' => function (self $bar, OutputInterface $output) {
  56812. $completeBars = $bar->getBarOffset();
  56813. $display = str_repeat($bar->getBarCharacter(), $completeBars);
  56814. if ($completeBars < $bar->getBarWidth()) {
  56815. $emptyBars = $bar->getBarWidth() - $completeBars - Helper::length(Helper::removeDecoration($output->getFormatter(), $bar->getProgressCharacter()));
  56816. $display .= $bar->getProgressCharacter().str_repeat($bar->getEmptyBarCharacter(), $emptyBars);
  56817. }
  56818. return $display;
  56819. },
  56820. 'elapsed' => function (self $bar) {
  56821. return Helper::formatTime(time() - $bar->getStartTime());
  56822. },
  56823. 'remaining' => function (self $bar) {
  56824. if (!$bar->getMaxSteps()) {
  56825. throw new LogicException('Unable to display the remaining time if the maximum number of steps is not set.');
  56826. }
  56827. return Helper::formatTime($bar->getRemaining());
  56828. },
  56829. 'estimated' => function (self $bar) {
  56830. if (!$bar->getMaxSteps()) {
  56831. throw new LogicException('Unable to display the estimated time if the maximum number of steps is not set.');
  56832. }
  56833. return Helper::formatTime($bar->getEstimated());
  56834. },
  56835. 'memory' => function (self $bar) {
  56836. return Helper::formatMemory(memory_get_usage(true));
  56837. },
  56838. 'current' => function (self $bar) {
  56839. return str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', \STR_PAD_LEFT);
  56840. },
  56841. 'max' => function (self $bar) {
  56842. return $bar->getMaxSteps();
  56843. },
  56844. 'percent' => function (self $bar) {
  56845. return floor($bar->getProgressPercent() * 100);
  56846. },
  56847. ];
  56848. }
  56849. private static function initFormats(): array
  56850. {
  56851. return [
  56852. self::FORMAT_NORMAL => ' %current%/%max% [%bar%] %percent:3s%%',
  56853. self::FORMAT_NORMAL_NOMAX => ' %current% [%bar%]',
  56854. self::FORMAT_VERBOSE => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%',
  56855. self::FORMAT_VERBOSE_NOMAX => ' %current% [%bar%] %elapsed:6s%',
  56856. self::FORMAT_VERY_VERBOSE => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%',
  56857. self::FORMAT_VERY_VERBOSE_NOMAX => ' %current% [%bar%] %elapsed:6s%',
  56858. self::FORMAT_DEBUG => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%',
  56859. self::FORMAT_DEBUG_NOMAX => ' %current% [%bar%] %elapsed:6s% %memory:6s%',
  56860. ];
  56861. }
  56862. private function buildLine(): string
  56863. {
  56864. $regex = "{%([a-z\-_]+)(?:\:([^%]+))?%}i";
  56865. $callback = function ($matches) {
  56866. if ($formatter = $this::getPlaceholderFormatterDefinition($matches[1])) {
  56867. $text = $formatter($this, $this->output);
  56868. } elseif (isset($this->messages[$matches[1]])) {
  56869. $text = $this->messages[$matches[1]];
  56870. } else {
  56871. return $matches[0];
  56872. }
  56873. if (isset($matches[2])) {
  56874. $text = sprintf('%'.$matches[2], $text);
  56875. }
  56876. return $text;
  56877. };
  56878. $line = preg_replace_callback($regex, $callback, $this->format);
  56879. $linesLength = array_map(function ($subLine) {
  56880. return Helper::width(Helper::removeDecoration($this->output->getFormatter(), rtrim($subLine, "\r")));
  56881. }, explode("\n", $line));
  56882. $linesWidth = max($linesLength);
  56883. $terminalWidth = $this->terminal->getWidth();
  56884. if ($linesWidth <= $terminalWidth) {
  56885. return $line;
  56886. }
  56887. $this->setBarWidth($this->barWidth - $linesWidth + $terminalWidth);
  56888. return preg_replace_callback($regex, $callback, $this->format);
  56889. }
  56890. }
  56891. <?php
  56892. namespace Symfony\Component\Console\Helper;
  56893. use Symfony\Component\Console\Exception\InvalidArgumentException;
  56894. use Symfony\Component\Console\Exception\LogicException;
  56895. use Symfony\Component\Console\Output\OutputInterface;
  56896. class ProgressIndicator
  56897. {
  56898. private const FORMATS = [
  56899. 'normal' => ' %indicator% %message%',
  56900. 'normal_no_ansi' => ' %message%',
  56901. 'verbose' => ' %indicator% %message% (%elapsed:6s%)',
  56902. 'verbose_no_ansi' => ' %message% (%elapsed:6s%)',
  56903. 'very_verbose' => ' %indicator% %message% (%elapsed:6s%, %memory:6s%)',
  56904. 'very_verbose_no_ansi' => ' %message% (%elapsed:6s%, %memory:6s%)',
  56905. ];
  56906. private $output;
  56907. private $startTime;
  56908. private $format;
  56909. private $message;
  56910. private $indicatorValues;
  56911. private $indicatorCurrent;
  56912. private $indicatorChangeInterval;
  56913. private $indicatorUpdateTime;
  56914. private $started = false;
  56915. private static $formatters;
  56916. public function __construct(OutputInterface $output, string $format = null, int $indicatorChangeInterval = 100, array $indicatorValues = null)
  56917. {
  56918. $this->output = $output;
  56919. if (null === $format) {
  56920. $format = $this->determineBestFormat();
  56921. }
  56922. if (null === $indicatorValues) {
  56923. $indicatorValues = ['-', '\\', '|', '/'];
  56924. }
  56925. $indicatorValues = array_values($indicatorValues);
  56926. if (2 > \count($indicatorValues)) {
  56927. throw new InvalidArgumentException('Must have at least 2 indicator value characters.');
  56928. }
  56929. $this->format = self::getFormatDefinition($format);
  56930. $this->indicatorChangeInterval = $indicatorChangeInterval;
  56931. $this->indicatorValues = $indicatorValues;
  56932. $this->startTime = time();
  56933. }
  56934. public function setMessage(?string $message)
  56935. {
  56936. $this->message = $message;
  56937. $this->display();
  56938. }
  56939. public function start(string $message)
  56940. {
  56941. if ($this->started) {
  56942. throw new LogicException('Progress indicator already started.');
  56943. }
  56944. $this->message = $message;
  56945. $this->started = true;
  56946. $this->startTime = time();
  56947. $this->indicatorUpdateTime = $this->getCurrentTimeInMilliseconds() + $this->indicatorChangeInterval;
  56948. $this->indicatorCurrent = 0;
  56949. $this->display();
  56950. }
  56951. public function advance()
  56952. {
  56953. if (!$this->started) {
  56954. throw new LogicException('Progress indicator has not yet been started.');
  56955. }
  56956. if (!$this->output->isDecorated()) {
  56957. return;
  56958. }
  56959. $currentTime = $this->getCurrentTimeInMilliseconds();
  56960. if ($currentTime < $this->indicatorUpdateTime) {
  56961. return;
  56962. }
  56963. $this->indicatorUpdateTime = $currentTime + $this->indicatorChangeInterval;
  56964. ++$this->indicatorCurrent;
  56965. $this->display();
  56966. }
  56967. public function finish(string $message)
  56968. {
  56969. if (!$this->started) {
  56970. throw new LogicException('Progress indicator has not yet been started.');
  56971. }
  56972. $this->message = $message;
  56973. $this->display();
  56974. $this->output->writeln('');
  56975. $this->started = false;
  56976. }
  56977. public static function getFormatDefinition(string $name)
  56978. {
  56979. return self::FORMATS[$name] ?? null;
  56980. }
  56981. public static function setPlaceholderFormatterDefinition(string $name, callable $callable)
  56982. {
  56983. if (!self::$formatters) {
  56984. self::$formatters = self::initPlaceholderFormatters();
  56985. }
  56986. self::$formatters[$name] = $callable;
  56987. }
  56988. public static function getPlaceholderFormatterDefinition(string $name)
  56989. {
  56990. if (!self::$formatters) {
  56991. self::$formatters = self::initPlaceholderFormatters();
  56992. }
  56993. return self::$formatters[$name] ?? null;
  56994. }
  56995. private function display()
  56996. {
  56997. if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) {
  56998. return;
  56999. }
  57000. $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) {
  57001. if ($formatter = self::getPlaceholderFormatterDefinition($matches[1])) {
  57002. return $formatter($this);
  57003. }
  57004. return $matches[0];
  57005. }, $this->format ?? ''));
  57006. }
  57007. private function determineBestFormat(): string
  57008. {
  57009. switch ($this->output->getVerbosity()) {
  57010. case OutputInterface::VERBOSITY_VERBOSE:
  57011. return $this->output->isDecorated() ? 'verbose' : 'verbose_no_ansi';
  57012. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  57013. case OutputInterface::VERBOSITY_DEBUG:
  57014. return $this->output->isDecorated() ? 'very_verbose' : 'very_verbose_no_ansi';
  57015. default:
  57016. return $this->output->isDecorated() ? 'normal' : 'normal_no_ansi';
  57017. }
  57018. }
  57019. private function overwrite(string $message)
  57020. {
  57021. if ($this->output->isDecorated()) {
  57022. $this->output->write("\x0D\x1B[2K");
  57023. $this->output->write($message);
  57024. } else {
  57025. $this->output->writeln($message);
  57026. }
  57027. }
  57028. private function getCurrentTimeInMilliseconds(): float
  57029. {
  57030. return round(microtime(true) * 1000);
  57031. }
  57032. private static function initPlaceholderFormatters(): array
  57033. {
  57034. return [
  57035. 'indicator' => function (self $indicator) {
  57036. return $indicator->indicatorValues[$indicator->indicatorCurrent % \count($indicator->indicatorValues)];
  57037. },
  57038. 'message' => function (self $indicator) {
  57039. return $indicator->message;
  57040. },
  57041. 'elapsed' => function (self $indicator) {
  57042. return Helper::formatTime(time() - $indicator->startTime);
  57043. },
  57044. 'memory' => function () {
  57045. return Helper::formatMemory(memory_get_usage(true));
  57046. },
  57047. ];
  57048. }
  57049. }
  57050. <?php
  57051. namespace Symfony\Component\Console\Helper;
  57052. use Symfony\Component\Console\Cursor;
  57053. use Symfony\Component\Console\Exception\MissingInputException;
  57054. use Symfony\Component\Console\Exception\RuntimeException;
  57055. use Symfony\Component\Console\Formatter\OutputFormatter;
  57056. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  57057. use Symfony\Component\Console\Input\InputInterface;
  57058. use Symfony\Component\Console\Input\StreamableInputInterface;
  57059. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  57060. use Symfony\Component\Console\Output\ConsoleSectionOutput;
  57061. use Symfony\Component\Console\Output\OutputInterface;
  57062. use Symfony\Component\Console\Question\ChoiceQuestion;
  57063. use Symfony\Component\Console\Question\Question;
  57064. use Symfony\Component\Console\Terminal;
  57065. use function Symfony\Component\String\s;
  57066. class QuestionHelper extends Helper
  57067. {
  57068. private $inputStream;
  57069. private static $stty = true;
  57070. private static $stdinIsInteractive;
  57071. public function ask(InputInterface $input, OutputInterface $output, Question $question)
  57072. {
  57073. if ($output instanceof ConsoleOutputInterface) {
  57074. $output = $output->getErrorOutput();
  57075. }
  57076. if (!$input->isInteractive()) {
  57077. return $this->getDefaultAnswer($question);
  57078. }
  57079. if ($input instanceof StreamableInputInterface && $stream = $input->getStream()) {
  57080. $this->inputStream = $stream;
  57081. }
  57082. try {
  57083. if (!$question->getValidator()) {
  57084. return $this->doAsk($output, $question);
  57085. }
  57086. $interviewer = function () use ($output, $question) {
  57087. return $this->doAsk($output, $question);
  57088. };
  57089. return $this->validateAttempts($interviewer, $output, $question);
  57090. } catch (MissingInputException $exception) {
  57091. $input->setInteractive(false);
  57092. if (null === $fallbackOutput = $this->getDefaultAnswer($question)) {
  57093. throw $exception;
  57094. }
  57095. return $fallbackOutput;
  57096. }
  57097. }
  57098. public function getName()
  57099. {
  57100. return 'question';
  57101. }
  57102. public static function disableStty()
  57103. {
  57104. self::$stty = false;
  57105. }
  57106. private function doAsk(OutputInterface $output, Question $question)
  57107. {
  57108. $this->writePrompt($output, $question);
  57109. $inputStream = $this->inputStream ?: \STDIN;
  57110. $autocomplete = $question->getAutocompleterCallback();
  57111. if (null === $autocomplete || !self::$stty || !Terminal::hasSttyAvailable()) {
  57112. $ret = false;
  57113. if ($question->isHidden()) {
  57114. try {
  57115. $hiddenResponse = $this->getHiddenResponse($output, $inputStream, $question->isTrimmable());
  57116. $ret = $question->isTrimmable() ? trim($hiddenResponse) : $hiddenResponse;
  57117. } catch (RuntimeException $e) {
  57118. if (!$question->isHiddenFallback()) {
  57119. throw $e;
  57120. }
  57121. }
  57122. }
  57123. if (false === $ret) {
  57124. $ret = $this->readInput($inputStream, $question);
  57125. if (false === $ret) {
  57126. throw new MissingInputException('Aborted.');
  57127. }
  57128. if ($question->isTrimmable()) {
  57129. $ret = trim($ret);
  57130. }
  57131. }
  57132. } else {
  57133. $autocomplete = $this->autocomplete($output, $question, $inputStream, $autocomplete);
  57134. $ret = $question->isTrimmable() ? trim($autocomplete) : $autocomplete;
  57135. }
  57136. if ($output instanceof ConsoleSectionOutput) {
  57137. $output->addContent($ret);
  57138. }
  57139. $ret = \strlen($ret) > 0 ? $ret : $question->getDefault();
  57140. if ($normalizer = $question->getNormalizer()) {
  57141. return $normalizer($ret);
  57142. }
  57143. return $ret;
  57144. }
  57145. private function getDefaultAnswer(Question $question)
  57146. {
  57147. $default = $question->getDefault();
  57148. if (null === $default) {
  57149. return $default;
  57150. }
  57151. if ($validator = $question->getValidator()) {
  57152. return \call_user_func($question->getValidator(), $default);
  57153. } elseif ($question instanceof ChoiceQuestion) {
  57154. $choices = $question->getChoices();
  57155. if (!$question->isMultiselect()) {
  57156. return $choices[$default] ?? $default;
  57157. }
  57158. $default = explode(',', $default);
  57159. foreach ($default as $k => $v) {
  57160. $v = $question->isTrimmable() ? trim($v) : $v;
  57161. $default[$k] = $choices[$v] ?? $v;
  57162. }
  57163. }
  57164. return $default;
  57165. }
  57166. protected function writePrompt(OutputInterface $output, Question $question)
  57167. {
  57168. $message = $question->getQuestion();
  57169. if ($question instanceof ChoiceQuestion) {
  57170. $output->writeln(array_merge([
  57171. $question->getQuestion(),
  57172. ], $this->formatChoiceQuestionChoices($question, 'info')));
  57173. $message = $question->getPrompt();
  57174. }
  57175. $output->write($message);
  57176. }
  57177. protected function formatChoiceQuestionChoices(ChoiceQuestion $question, string $tag)
  57178. {
  57179. $messages = [];
  57180. $maxWidth = max(array_map([__CLASS__, 'width'], array_keys($choices = $question->getChoices())));
  57181. foreach ($choices as $key => $value) {
  57182. $padding = str_repeat(' ', $maxWidth - self::width($key));
  57183. $messages[] = sprintf(" [<$tag>%s$padding</$tag>] %s", $key, $value);
  57184. }
  57185. return $messages;
  57186. }
  57187. protected function writeError(OutputInterface $output, \Exception $error)
  57188. {
  57189. if (null !== $this->getHelperSet() && $this->getHelperSet()->has('formatter')) {
  57190. $message = $this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error');
  57191. } else {
  57192. $message = '<error>'.$error->getMessage().'</error>';
  57193. }
  57194. $output->writeln($message);
  57195. }
  57196. private function autocomplete(OutputInterface $output, Question $question, $inputStream, callable $autocomplete): string
  57197. {
  57198. $cursor = new Cursor($output, $inputStream);
  57199. $fullChoice = '';
  57200. $ret = '';
  57201. $i = 0;
  57202. $ofs = -1;
  57203. $matches = $autocomplete($ret);
  57204. $numMatches = \count($matches);
  57205. $sttyMode = shell_exec('stty -g');
  57206. $isStdin = 'php://stdin' === (stream_get_meta_data($inputStream)['uri'] ?? null);
  57207. $r = [$inputStream];
  57208. $w = [];
  57209. shell_exec('stty -icanon -echo');
  57210. $output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white'));
  57211. while (!feof($inputStream)) {
  57212. while ($isStdin && 0 === @stream_select($r, $w, $w, 0, 100)) {
  57213. $r = [$inputStream];
  57214. }
  57215. $c = fread($inputStream, 1);
  57216. if (false === $c || ('' === $ret && '' === $c && null === $question->getDefault())) {
  57217. shell_exec('stty '.$sttyMode);
  57218. throw new MissingInputException('Aborted.');
  57219. } elseif ("\177" === $c) {
  57220. if (0 === $numMatches && 0 !== $i) {
  57221. --$i;
  57222. $cursor->moveLeft(s($fullChoice)->slice(-1)->width(false));
  57223. $fullChoice = self::substr($fullChoice, 0, $i);
  57224. }
  57225. if (0 === $i) {
  57226. $ofs = -1;
  57227. $matches = $autocomplete($ret);
  57228. $numMatches = \count($matches);
  57229. } else {
  57230. $numMatches = 0;
  57231. }
  57232. $ret = self::substr($ret, 0, $i);
  57233. } elseif ("\033" === $c) {
  57234. $c .= fread($inputStream, 2);
  57235. if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) {
  57236. if ('A' === $c[2] && -1 === $ofs) {
  57237. $ofs = 0;
  57238. }
  57239. if (0 === $numMatches) {
  57240. continue;
  57241. }
  57242. $ofs += ('A' === $c[2]) ? -1 : 1;
  57243. $ofs = ($numMatches + $ofs) % $numMatches;
  57244. }
  57245. } elseif (\ord($c) < 32) {
  57246. if ("\t" === $c || "\n" === $c) {
  57247. if ($numMatches > 0 && -1 !== $ofs) {
  57248. $ret = (string) $matches[$ofs];
  57249. $remainingCharacters = substr($ret, \strlen(trim($this->mostRecentlyEnteredValue($fullChoice))));
  57250. $output->write($remainingCharacters);
  57251. $fullChoice .= $remainingCharacters;
  57252. $i = (false === $encoding = mb_detect_encoding($fullChoice, null, true)) ? \strlen($fullChoice) : mb_strlen($fullChoice, $encoding);
  57253. $matches = array_filter(
  57254. $autocomplete($ret),
  57255. function ($match) use ($ret) {
  57256. return '' === $ret || str_starts_with($match, $ret);
  57257. }
  57258. );
  57259. $numMatches = \count($matches);
  57260. $ofs = -1;
  57261. }
  57262. if ("\n" === $c) {
  57263. $output->write($c);
  57264. break;
  57265. }
  57266. $numMatches = 0;
  57267. }
  57268. continue;
  57269. } else {
  57270. if ("\x80" <= $c) {
  57271. $c .= fread($inputStream, ["\xC0" => 1, "\xD0" => 1, "\xE0" => 2, "\xF0" => 3][$c & "\xF0"]);
  57272. }
  57273. $output->write($c);
  57274. $ret .= $c;
  57275. $fullChoice .= $c;
  57276. ++$i;
  57277. $tempRet = $ret;
  57278. if ($question instanceof ChoiceQuestion && $question->isMultiselect()) {
  57279. $tempRet = $this->mostRecentlyEnteredValue($fullChoice);
  57280. }
  57281. $numMatches = 0;
  57282. $ofs = 0;
  57283. foreach ($autocomplete($ret) as $value) {
  57284. if (str_starts_with($value, $tempRet)) {
  57285. $matches[$numMatches++] = $value;
  57286. }
  57287. }
  57288. }
  57289. $cursor->clearLineAfter();
  57290. if ($numMatches > 0 && -1 !== $ofs) {
  57291. $cursor->savePosition();
  57292. $charactersEntered = \strlen(trim($this->mostRecentlyEnteredValue($fullChoice)));
  57293. $output->write('<hl>'.OutputFormatter::escapeTrailingBackslash(substr($matches[$ofs], $charactersEntered)).'</hl>');
  57294. $cursor->restorePosition();
  57295. }
  57296. }
  57297. shell_exec('stty '.$sttyMode);
  57298. return $fullChoice;
  57299. }
  57300. private function mostRecentlyEnteredValue(string $entered): string
  57301. {
  57302. if (!str_contains($entered, ',')) {
  57303. return $entered;
  57304. }
  57305. $choices = explode(',', $entered);
  57306. if ('' !== $lastChoice = trim($choices[\count($choices) - 1])) {
  57307. return $lastChoice;
  57308. }
  57309. return $entered;
  57310. }
  57311. private function getHiddenResponse(OutputInterface $output, $inputStream, bool $trimmable = true): string
  57312. {
  57313. if ('\\' === \DIRECTORY_SEPARATOR) {
  57314. $exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
  57315. if ('phar:' === substr(__FILE__, 0, 5)) {
  57316. $tmpExe = sys_get_temp_dir().'/hiddeninput.exe';
  57317. copy($exe, $tmpExe);
  57318. $exe = $tmpExe;
  57319. }
  57320. $sExec = shell_exec('"'.$exe.'"');
  57321. $value = $trimmable ? rtrim($sExec) : $sExec;
  57322. $output->writeln('');
  57323. if (isset($tmpExe)) {
  57324. unlink($tmpExe);
  57325. }
  57326. return $value;
  57327. }
  57328. if (self::$stty && Terminal::hasSttyAvailable()) {
  57329. $sttyMode = shell_exec('stty -g');
  57330. shell_exec('stty -echo');
  57331. } elseif ($this->isInteractiveInput($inputStream)) {
  57332. throw new RuntimeException('Unable to hide the response.');
  57333. }
  57334. $value = fgets($inputStream, 4096);
  57335. if (self::$stty && Terminal::hasSttyAvailable()) {
  57336. shell_exec('stty '.$sttyMode);
  57337. }
  57338. if (false === $value) {
  57339. throw new MissingInputException('Aborted.');
  57340. }
  57341. if ($trimmable) {
  57342. $value = trim($value);
  57343. }
  57344. $output->writeln('');
  57345. return $value;
  57346. }
  57347. private function validateAttempts(callable $interviewer, OutputInterface $output, Question $question)
  57348. {
  57349. $error = null;
  57350. $attempts = $question->getMaxAttempts();
  57351. while (null === $attempts || $attempts--) {
  57352. if (null !== $error) {
  57353. $this->writeError($output, $error);
  57354. }
  57355. try {
  57356. return $question->getValidator()($interviewer());
  57357. } catch (RuntimeException $e) {
  57358. throw $e;
  57359. } catch (\Exception $error) {
  57360. }
  57361. }
  57362. throw $error;
  57363. }
  57364. private function isInteractiveInput($inputStream): bool
  57365. {
  57366. if ('php://stdin' !== (stream_get_meta_data($inputStream)['uri'] ?? null)) {
  57367. return false;
  57368. }
  57369. if (null !== self::$stdinIsInteractive) {
  57370. return self::$stdinIsInteractive;
  57371. }
  57372. if (\function_exists('stream_isatty')) {
  57373. return self::$stdinIsInteractive = @stream_isatty(fopen('php://stdin', 'r'));
  57374. }
  57375. if (\function_exists('posix_isatty')) {
  57376. return self::$stdinIsInteractive = @posix_isatty(fopen('php://stdin', 'r'));
  57377. }
  57378. if (!\function_exists('exec')) {
  57379. return self::$stdinIsInteractive = true;
  57380. }
  57381. exec('stty 2> /dev/null', $output, $status);
  57382. return self::$stdinIsInteractive = 1 !== $status;
  57383. }
  57384. private function readInput($inputStream, Question $question)
  57385. {
  57386. if (!$question->isMultiline()) {
  57387. $cp = $this->setIOCodepage();
  57388. $ret = fgets($inputStream, 4096);
  57389. return $this->resetIOCodepage($cp, $ret);
  57390. }
  57391. $multiLineStreamReader = $this->cloneInputStream($inputStream);
  57392. if (null === $multiLineStreamReader) {
  57393. return false;
  57394. }
  57395. $ret = '';
  57396. $cp = $this->setIOCodepage();
  57397. while (false !== ($char = fgetc($multiLineStreamReader))) {
  57398. if (\PHP_EOL === "{$ret}{$char}") {
  57399. break;
  57400. }
  57401. $ret .= $char;
  57402. }
  57403. return $this->resetIOCodepage($cp, $ret);
  57404. }
  57405. private function setIOCodepage(): int
  57406. {
  57407. if (\function_exists('sapi_windows_cp_set')) {
  57408. $cp = sapi_windows_cp_get();
  57409. sapi_windows_cp_set(sapi_windows_cp_get('oem'));
  57410. return $cp;
  57411. }
  57412. return 0;
  57413. }
  57414. private function resetIOCodepage(int $cp, $input)
  57415. {
  57416. if (0 !== $cp) {
  57417. sapi_windows_cp_set($cp);
  57418. if (false !== $input && '' !== $input) {
  57419. $input = sapi_windows_cp_conv(sapi_windows_cp_get('oem'), $cp, $input);
  57420. }
  57421. }
  57422. return $input;
  57423. }
  57424. private function cloneInputStream($inputStream)
  57425. {
  57426. $streamMetaData = stream_get_meta_data($inputStream);
  57427. $seekable = $streamMetaData['seekable'] ?? false;
  57428. $mode = $streamMetaData['mode'] ?? 'rb';
  57429. $uri = $streamMetaData['uri'] ?? null;
  57430. if (null === $uri) {
  57431. return null;
  57432. }
  57433. $cloneStream = fopen($uri, $mode);
  57434. if (true === $seekable && !\in_array($mode, ['r', 'rb', 'rt'])) {
  57435. $offset = ftell($inputStream);
  57436. rewind($inputStream);
  57437. stream_copy_to_stream($inputStream, $cloneStream);
  57438. fseek($inputStream, $offset);
  57439. fseek($cloneStream, $offset);
  57440. }
  57441. return $cloneStream;
  57442. }
  57443. }
  57444. <?php
  57445. namespace Symfony\Component\Console\Helper;
  57446. use Symfony\Component\Console\Formatter\OutputFormatter;
  57447. use Symfony\Component\Console\Output\OutputInterface;
  57448. use Symfony\Component\Console\Question\ChoiceQuestion;
  57449. use Symfony\Component\Console\Question\ConfirmationQuestion;
  57450. use Symfony\Component\Console\Question\Question;
  57451. use Symfony\Component\Console\Style\SymfonyStyle;
  57452. class SymfonyQuestionHelper extends QuestionHelper
  57453. {
  57454. protected function writePrompt(OutputInterface $output, Question $question)
  57455. {
  57456. $text = OutputFormatter::escapeTrailingBackslash($question->getQuestion());
  57457. $default = $question->getDefault();
  57458. if ($question->isMultiline()) {
  57459. $text .= sprintf(' (press %s to continue)', $this->getEofShortcut());
  57460. }
  57461. switch (true) {
  57462. case null === $default:
  57463. $text = sprintf(' <info>%s</info>:', $text);
  57464. break;
  57465. case $question instanceof ConfirmationQuestion:
  57466. $text = sprintf(' <info>%s (yes/no)</info> [<comment>%s</comment>]:', $text, $default ? 'yes' : 'no');
  57467. break;
  57468. case $question instanceof ChoiceQuestion && $question->isMultiselect():
  57469. $choices = $question->getChoices();
  57470. $default = explode(',', $default);
  57471. foreach ($default as $key => $value) {
  57472. $default[$key] = $choices[trim($value)];
  57473. }
  57474. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(implode(', ', $default)));
  57475. break;
  57476. case $question instanceof ChoiceQuestion:
  57477. $choices = $question->getChoices();
  57478. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($choices[$default] ?? $default));
  57479. break;
  57480. default:
  57481. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($default));
  57482. }
  57483. $output->writeln($text);
  57484. $prompt = ' > ';
  57485. if ($question instanceof ChoiceQuestion) {
  57486. $output->writeln($this->formatChoiceQuestionChoices($question, 'comment'));
  57487. $prompt = $question->getPrompt();
  57488. }
  57489. $output->write($prompt);
  57490. }
  57491. protected function writeError(OutputInterface $output, \Exception $error)
  57492. {
  57493. if ($output instanceof SymfonyStyle) {
  57494. $output->newLine();
  57495. $output->error($error->getMessage());
  57496. return;
  57497. }
  57498. parent::writeError($output, $error);
  57499. }
  57500. private function getEofShortcut(): string
  57501. {
  57502. if ('Windows' === \PHP_OS_FAMILY) {
  57503. return '<comment>Ctrl+Z</comment> then <comment>Enter</comment>';
  57504. }
  57505. return '<comment>Ctrl+D</comment>';
  57506. }
  57507. }
  57508. <?php
  57509. namespace Symfony\Component\Console\Helper;
  57510. use Symfony\Component\Console\Exception\InvalidArgumentException;
  57511. use Symfony\Component\Console\Exception\RuntimeException;
  57512. use Symfony\Component\Console\Formatter\OutputFormatter;
  57513. use Symfony\Component\Console\Formatter\WrappableOutputFormatterInterface;
  57514. use Symfony\Component\Console\Output\ConsoleSectionOutput;
  57515. use Symfony\Component\Console\Output\OutputInterface;
  57516. class Table
  57517. {
  57518. private const SEPARATOR_TOP = 0;
  57519. private const SEPARATOR_TOP_BOTTOM = 1;
  57520. private const SEPARATOR_MID = 2;
  57521. private const SEPARATOR_BOTTOM = 3;
  57522. private const BORDER_OUTSIDE = 0;
  57523. private const BORDER_INSIDE = 1;
  57524. private $headerTitle;
  57525. private $footerTitle;
  57526. private $headers = [];
  57527. private $rows = [];
  57528. private $horizontal = false;
  57529. private $effectiveColumnWidths = [];
  57530. private $numberOfColumns;
  57531. private $output;
  57532. private $style;
  57533. private $columnStyles = [];
  57534. private $columnWidths = [];
  57535. private $columnMaxWidths = [];
  57536. private static $styles;
  57537. private $rendered = false;
  57538. public function __construct(OutputInterface $output)
  57539. {
  57540. $this->output = $output;
  57541. if (!self::$styles) {
  57542. self::$styles = self::initStyles();
  57543. }
  57544. $this->setStyle('default');
  57545. }
  57546. public static function setStyleDefinition(string $name, TableStyle $style)
  57547. {
  57548. if (!self::$styles) {
  57549. self::$styles = self::initStyles();
  57550. }
  57551. self::$styles[$name] = $style;
  57552. }
  57553. public static function getStyleDefinition(string $name)
  57554. {
  57555. if (!self::$styles) {
  57556. self::$styles = self::initStyles();
  57557. }
  57558. if (isset(self::$styles[$name])) {
  57559. return self::$styles[$name];
  57560. }
  57561. throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
  57562. }
  57563. public function setStyle($name)
  57564. {
  57565. $this->style = $this->resolveStyle($name);
  57566. return $this;
  57567. }
  57568. public function getStyle()
  57569. {
  57570. return $this->style;
  57571. }
  57572. public function setColumnStyle(int $columnIndex, $name)
  57573. {
  57574. $this->columnStyles[$columnIndex] = $this->resolveStyle($name);
  57575. return $this;
  57576. }
  57577. public function getColumnStyle(int $columnIndex)
  57578. {
  57579. return $this->columnStyles[$columnIndex] ?? $this->getStyle();
  57580. }
  57581. public function setColumnWidth(int $columnIndex, int $width)
  57582. {
  57583. $this->columnWidths[$columnIndex] = $width;
  57584. return $this;
  57585. }
  57586. public function setColumnWidths(array $widths)
  57587. {
  57588. $this->columnWidths = [];
  57589. foreach ($widths as $index => $width) {
  57590. $this->setColumnWidth($index, $width);
  57591. }
  57592. return $this;
  57593. }
  57594. public function setColumnMaxWidth(int $columnIndex, int $width): self
  57595. {
  57596. if (!$this->output->getFormatter() instanceof WrappableOutputFormatterInterface) {
  57597. throw new \LogicException(sprintf('Setting a maximum column width is only supported when using a "%s" formatter, got "%s".', WrappableOutputFormatterInterface::class, get_debug_type($this->output->getFormatter())));
  57598. }
  57599. $this->columnMaxWidths[$columnIndex] = $width;
  57600. return $this;
  57601. }
  57602. public function setHeaders(array $headers)
  57603. {
  57604. $headers = array_values($headers);
  57605. if (!empty($headers) && !\is_array($headers[0])) {
  57606. $headers = [$headers];
  57607. }
  57608. $this->headers = $headers;
  57609. return $this;
  57610. }
  57611. public function setRows(array $rows)
  57612. {
  57613. $this->rows = [];
  57614. return $this->addRows($rows);
  57615. }
  57616. public function addRows(array $rows)
  57617. {
  57618. foreach ($rows as $row) {
  57619. $this->addRow($row);
  57620. }
  57621. return $this;
  57622. }
  57623. public function addRow($row)
  57624. {
  57625. if ($row instanceof TableSeparator) {
  57626. $this->rows[] = $row;
  57627. return $this;
  57628. }
  57629. if (!\is_array($row)) {
  57630. throw new InvalidArgumentException('A row must be an array or a TableSeparator instance.');
  57631. }
  57632. $this->rows[] = array_values($row);
  57633. return $this;
  57634. }
  57635. public function appendRow($row): self
  57636. {
  57637. if (!$this->output instanceof ConsoleSectionOutput) {
  57638. throw new RuntimeException(sprintf('Output should be an instance of "%s" when calling "%s".', ConsoleSectionOutput::class, __METHOD__));
  57639. }
  57640. if ($this->rendered) {
  57641. $this->output->clear($this->calculateRowCount());
  57642. }
  57643. $this->addRow($row);
  57644. $this->render();
  57645. return $this;
  57646. }
  57647. public function setRow($column, array $row)
  57648. {
  57649. $this->rows[$column] = $row;
  57650. return $this;
  57651. }
  57652. public function setHeaderTitle(?string $title): self
  57653. {
  57654. $this->headerTitle = $title;
  57655. return $this;
  57656. }
  57657. public function setFooterTitle(?string $title): self
  57658. {
  57659. $this->footerTitle = $title;
  57660. return $this;
  57661. }
  57662. public function setHorizontal(bool $horizontal = true): self
  57663. {
  57664. $this->horizontal = $horizontal;
  57665. return $this;
  57666. }
  57667. public function render()
  57668. {
  57669. $divider = new TableSeparator();
  57670. if ($this->horizontal) {
  57671. $rows = [];
  57672. foreach ($this->headers[0] ?? [] as $i => $header) {
  57673. $rows[$i] = [$header];
  57674. foreach ($this->rows as $row) {
  57675. if ($row instanceof TableSeparator) {
  57676. continue;
  57677. }
  57678. if (isset($row[$i])) {
  57679. $rows[$i][] = $row[$i];
  57680. } elseif ($rows[$i][0] instanceof TableCell && $rows[$i][0]->getColspan() >= 2) {
  57681. } else {
  57682. $rows[$i][] = null;
  57683. }
  57684. }
  57685. }
  57686. } else {
  57687. $rows = array_merge($this->headers, [$divider], $this->rows);
  57688. }
  57689. $this->calculateNumberOfColumns($rows);
  57690. $rows = $this->buildTableRows($rows);
  57691. $this->calculateColumnsWidth($rows);
  57692. $isHeader = !$this->horizontal;
  57693. $isFirstRow = $this->horizontal;
  57694. $hasTitle = (bool) $this->headerTitle;
  57695. foreach ($rows as $row) {
  57696. if ($divider === $row) {
  57697. $isHeader = false;
  57698. $isFirstRow = true;
  57699. continue;
  57700. }
  57701. if ($row instanceof TableSeparator) {
  57702. $this->renderRowSeparator();
  57703. continue;
  57704. }
  57705. if (!$row) {
  57706. continue;
  57707. }
  57708. if ($isHeader || $isFirstRow) {
  57709. $this->renderRowSeparator(
  57710. $isHeader ? self::SEPARATOR_TOP : self::SEPARATOR_TOP_BOTTOM,
  57711. $hasTitle ? $this->headerTitle : null,
  57712. $hasTitle ? $this->style->getHeaderTitleFormat() : null
  57713. );
  57714. $isFirstRow = false;
  57715. $hasTitle = false;
  57716. }
  57717. if ($this->horizontal) {
  57718. $this->renderRow($row, $this->style->getCellRowFormat(), $this->style->getCellHeaderFormat());
  57719. } else {
  57720. $this->renderRow($row, $isHeader ? $this->style->getCellHeaderFormat() : $this->style->getCellRowFormat());
  57721. }
  57722. }
  57723. $this->renderRowSeparator(self::SEPARATOR_BOTTOM, $this->footerTitle, $this->style->getFooterTitleFormat());
  57724. $this->cleanup();
  57725. $this->rendered = true;
  57726. }
  57727. private function renderRowSeparator(int $type = self::SEPARATOR_MID, string $title = null, string $titleFormat = null)
  57728. {
  57729. if (0 === $count = $this->numberOfColumns) {
  57730. return;
  57731. }
  57732. $borders = $this->style->getBorderChars();
  57733. if (!$borders[0] && !$borders[2] && !$this->style->getCrossingChar()) {
  57734. return;
  57735. }
  57736. $crossings = $this->style->getCrossingChars();
  57737. if (self::SEPARATOR_MID === $type) {
  57738. [$horizontal, $leftChar, $midChar, $rightChar] = [$borders[2], $crossings[8], $crossings[0], $crossings[4]];
  57739. } elseif (self::SEPARATOR_TOP === $type) {
  57740. [$horizontal, $leftChar, $midChar, $rightChar] = [$borders[0], $crossings[1], $crossings[2], $crossings[3]];
  57741. } elseif (self::SEPARATOR_TOP_BOTTOM === $type) {
  57742. [$horizontal, $leftChar, $midChar, $rightChar] = [$borders[0], $crossings[9], $crossings[10], $crossings[11]];
  57743. } else {
  57744. [$horizontal, $leftChar, $midChar, $rightChar] = [$borders[0], $crossings[7], $crossings[6], $crossings[5]];
  57745. }
  57746. $markup = $leftChar;
  57747. for ($column = 0; $column < $count; ++$column) {
  57748. $markup .= str_repeat($horizontal, $this->effectiveColumnWidths[$column]);
  57749. $markup .= $column === $count - 1 ? $rightChar : $midChar;
  57750. }
  57751. if (null !== $title) {
  57752. $titleLength = Helper::width(Helper::removeDecoration($formatter = $this->output->getFormatter(), $formattedTitle = sprintf($titleFormat, $title)));
  57753. $markupLength = Helper::width($markup);
  57754. if ($titleLength > $limit = $markupLength - 4) {
  57755. $titleLength = $limit;
  57756. $formatLength = Helper::width(Helper::removeDecoration($formatter, sprintf($titleFormat, '')));
  57757. $formattedTitle = sprintf($titleFormat, Helper::substr($title, 0, $limit - $formatLength - 3).'...');
  57758. }
  57759. $titleStart = intdiv($markupLength - $titleLength, 2);
  57760. if (false === mb_detect_encoding($markup, null, true)) {
  57761. $markup = substr_replace($markup, $formattedTitle, $titleStart, $titleLength);
  57762. } else {
  57763. $markup = mb_substr($markup, 0, $titleStart).$formattedTitle.mb_substr($markup, $titleStart + $titleLength);
  57764. }
  57765. }
  57766. $this->output->writeln(sprintf($this->style->getBorderFormat(), $markup));
  57767. }
  57768. private function renderColumnSeparator(int $type = self::BORDER_OUTSIDE): string
  57769. {
  57770. $borders = $this->style->getBorderChars();
  57771. return sprintf($this->style->getBorderFormat(), self::BORDER_OUTSIDE === $type ? $borders[1] : $borders[3]);
  57772. }
  57773. private function renderRow(array $row, string $cellFormat, string $firstCellFormat = null)
  57774. {
  57775. $rowContent = $this->renderColumnSeparator(self::BORDER_OUTSIDE);
  57776. $columns = $this->getRowColumns($row);
  57777. $last = \count($columns) - 1;
  57778. foreach ($columns as $i => $column) {
  57779. if ($firstCellFormat && 0 === $i) {
  57780. $rowContent .= $this->renderCell($row, $column, $firstCellFormat);
  57781. } else {
  57782. $rowContent .= $this->renderCell($row, $column, $cellFormat);
  57783. }
  57784. $rowContent .= $this->renderColumnSeparator($last === $i ? self::BORDER_OUTSIDE : self::BORDER_INSIDE);
  57785. }
  57786. $this->output->writeln($rowContent);
  57787. }
  57788. private function renderCell(array $row, int $column, string $cellFormat): string
  57789. {
  57790. $cell = $row[$column] ?? '';
  57791. $width = $this->effectiveColumnWidths[$column];
  57792. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  57793. foreach (range($column + 1, $column + $cell->getColspan() - 1) as $nextColumn) {
  57794. $width += $this->getColumnSeparatorWidth() + $this->effectiveColumnWidths[$nextColumn];
  57795. }
  57796. }
  57797. if (false !== $encoding = mb_detect_encoding($cell, null, true)) {
  57798. $width += \strlen($cell) - mb_strwidth($cell, $encoding);
  57799. }
  57800. $style = $this->getColumnStyle($column);
  57801. if ($cell instanceof TableSeparator) {
  57802. return sprintf($style->getBorderFormat(), str_repeat($style->getBorderChars()[2], $width));
  57803. }
  57804. $width += Helper::length($cell) - Helper::length(Helper::removeDecoration($this->output->getFormatter(), $cell));
  57805. $content = sprintf($style->getCellRowContentFormat(), $cell);
  57806. $padType = $style->getPadType();
  57807. if ($cell instanceof TableCell && $cell->getStyle() instanceof TableCellStyle) {
  57808. $isNotStyledByTag = !preg_match('/^<(\w+|(\w+=[\w,]+;?)*)>.+<\/(\w+|(\w+=\w+;?)*)?>$/', $cell);
  57809. if ($isNotStyledByTag) {
  57810. $cellFormat = $cell->getStyle()->getCellFormat();
  57811. if (!\is_string($cellFormat)) {
  57812. $tag = http_build_query($cell->getStyle()->getTagOptions(), '', ';');
  57813. $cellFormat = '<'.$tag.'>%s</>';
  57814. }
  57815. if (strstr($content, '</>')) {
  57816. $content = str_replace('</>', '', $content);
  57817. $width -= 3;
  57818. }
  57819. if (strstr($content, '<fg=default;bg=default>')) {
  57820. $content = str_replace('<fg=default;bg=default>', '', $content);
  57821. $width -= \strlen('<fg=default;bg=default>');
  57822. }
  57823. }
  57824. $padType = $cell->getStyle()->getPadByAlign();
  57825. }
  57826. return sprintf($cellFormat, str_pad($content, $width, $style->getPaddingChar(), $padType));
  57827. }
  57828. private function calculateNumberOfColumns(array $rows)
  57829. {
  57830. $columns = [0];
  57831. foreach ($rows as $row) {
  57832. if ($row instanceof TableSeparator) {
  57833. continue;
  57834. }
  57835. $columns[] = $this->getNumberOfColumns($row);
  57836. }
  57837. $this->numberOfColumns = max($columns);
  57838. }
  57839. private function buildTableRows(array $rows): TableRows
  57840. {
  57841. $formatter = $this->output->getFormatter();
  57842. $unmergedRows = [];
  57843. for ($rowKey = 0; $rowKey < \count($rows); ++$rowKey) {
  57844. $rows = $this->fillNextRows($rows, $rowKey);
  57845. foreach ($rows[$rowKey] as $column => $cell) {
  57846. $colspan = $cell instanceof TableCell ? $cell->getColspan() : 1;
  57847. if (isset($this->columnMaxWidths[$column]) && Helper::width(Helper::removeDecoration($formatter, $cell)) > $this->columnMaxWidths[$column]) {
  57848. $cell = $formatter->formatAndWrap($cell, $this->columnMaxWidths[$column] * $colspan);
  57849. }
  57850. if (!strstr($cell ?? '', "\n")) {
  57851. continue;
  57852. }
  57853. $escaped = implode("\n", array_map([OutputFormatter::class, 'escapeTrailingBackslash'], explode("\n", $cell)));
  57854. $cell = $cell instanceof TableCell ? new TableCell($escaped, ['colspan' => $cell->getColspan()]) : $escaped;
  57855. $lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
  57856. foreach ($lines as $lineKey => $line) {
  57857. if ($colspan > 1) {
  57858. $line = new TableCell($line, ['colspan' => $colspan]);
  57859. }
  57860. if (0 === $lineKey) {
  57861. $rows[$rowKey][$column] = $line;
  57862. } else {
  57863. if (!\array_key_exists($rowKey, $unmergedRows) || !\array_key_exists($lineKey, $unmergedRows[$rowKey])) {
  57864. $unmergedRows[$rowKey][$lineKey] = $this->copyRow($rows, $rowKey);
  57865. }
  57866. $unmergedRows[$rowKey][$lineKey][$column] = $line;
  57867. }
  57868. }
  57869. }
  57870. }
  57871. return new TableRows(function () use ($rows, $unmergedRows): \Traversable {
  57872. foreach ($rows as $rowKey => $row) {
  57873. yield $row instanceof TableSeparator ? $row : $this->fillCells($row);
  57874. if (isset($unmergedRows[$rowKey])) {
  57875. foreach ($unmergedRows[$rowKey] as $row) {
  57876. yield $row instanceof TableSeparator ? $row : $this->fillCells($row);
  57877. }
  57878. }
  57879. }
  57880. });
  57881. }
  57882. private function calculateRowCount(): int
  57883. {
  57884. $numberOfRows = \count(iterator_to_array($this->buildTableRows(array_merge($this->headers, [new TableSeparator()], $this->rows))));
  57885. if ($this->headers) {
  57886. ++$numberOfRows;
  57887. }
  57888. if (\count($this->rows) > 0) {
  57889. ++$numberOfRows;
  57890. }
  57891. return $numberOfRows;
  57892. }
  57893. private function fillNextRows(array $rows, int $line): array
  57894. {
  57895. $unmergedRows = [];
  57896. foreach ($rows[$line] as $column => $cell) {
  57897. if (null !== $cell && !$cell instanceof TableCell && !is_scalar($cell) && !(\is_object($cell) && method_exists($cell, '__toString'))) {
  57898. throw new InvalidArgumentException(sprintf('A cell must be a TableCell, a scalar or an object implementing "__toString()", "%s" given.', get_debug_type($cell)));
  57899. }
  57900. if ($cell instanceof TableCell && $cell->getRowspan() > 1) {
  57901. $nbLines = $cell->getRowspan() - 1;
  57902. $lines = [$cell];
  57903. if (strstr($cell, "\n")) {
  57904. $lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
  57905. $nbLines = \count($lines) > $nbLines ? substr_count($cell, "\n") : $nbLines;
  57906. $rows[$line][$column] = new TableCell($lines[0], ['colspan' => $cell->getColspan(), 'style' => $cell->getStyle()]);
  57907. unset($lines[0]);
  57908. }
  57909. $unmergedRows = array_replace_recursive(array_fill($line + 1, $nbLines, []), $unmergedRows);
  57910. foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
  57911. $value = $lines[$unmergedRowKey - $line] ?? '';
  57912. $unmergedRows[$unmergedRowKey][$column] = new TableCell($value, ['colspan' => $cell->getColspan(), 'style' => $cell->getStyle()]);
  57913. if ($nbLines === $unmergedRowKey - $line) {
  57914. break;
  57915. }
  57916. }
  57917. }
  57918. }
  57919. foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
  57920. if (isset($rows[$unmergedRowKey]) && \is_array($rows[$unmergedRowKey]) && ($this->getNumberOfColumns($rows[$unmergedRowKey]) + $this->getNumberOfColumns($unmergedRows[$unmergedRowKey]) <= $this->numberOfColumns)) {
  57921. foreach ($unmergedRow as $cellKey => $cell) {
  57922. array_splice($rows[$unmergedRowKey], $cellKey, 0, [$cell]);
  57923. }
  57924. } else {
  57925. $row = $this->copyRow($rows, $unmergedRowKey - 1);
  57926. foreach ($unmergedRow as $column => $cell) {
  57927. if (!empty($cell)) {
  57928. $row[$column] = $unmergedRow[$column];
  57929. }
  57930. }
  57931. array_splice($rows, $unmergedRowKey, 0, [$row]);
  57932. }
  57933. }
  57934. return $rows;
  57935. }
  57936. private function fillCells(iterable $row)
  57937. {
  57938. $newRow = [];
  57939. foreach ($row as $column => $cell) {
  57940. $newRow[] = $cell;
  57941. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  57942. foreach (range($column + 1, $column + $cell->getColspan() - 1) as $position) {
  57943. $newRow[] = '';
  57944. }
  57945. }
  57946. }
  57947. return $newRow ?: $row;
  57948. }
  57949. private function copyRow(array $rows, int $line): array
  57950. {
  57951. $row = $rows[$line];
  57952. foreach ($row as $cellKey => $cellValue) {
  57953. $row[$cellKey] = '';
  57954. if ($cellValue instanceof TableCell) {
  57955. $row[$cellKey] = new TableCell('', ['colspan' => $cellValue->getColspan()]);
  57956. }
  57957. }
  57958. return $row;
  57959. }
  57960. private function getNumberOfColumns(array $row): int
  57961. {
  57962. $columns = \count($row);
  57963. foreach ($row as $column) {
  57964. $columns += $column instanceof TableCell ? ($column->getColspan() - 1) : 0;
  57965. }
  57966. return $columns;
  57967. }
  57968. private function getRowColumns(array $row): array
  57969. {
  57970. $columns = range(0, $this->numberOfColumns - 1);
  57971. foreach ($row as $cellKey => $cell) {
  57972. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  57973. $columns = array_diff($columns, range($cellKey + 1, $cellKey + $cell->getColspan() - 1));
  57974. }
  57975. }
  57976. return $columns;
  57977. }
  57978. private function calculateColumnsWidth(iterable $rows)
  57979. {
  57980. for ($column = 0; $column < $this->numberOfColumns; ++$column) {
  57981. $lengths = [];
  57982. foreach ($rows as $row) {
  57983. if ($row instanceof TableSeparator) {
  57984. continue;
  57985. }
  57986. foreach ($row as $i => $cell) {
  57987. if ($cell instanceof TableCell) {
  57988. $textContent = Helper::removeDecoration($this->output->getFormatter(), $cell);
  57989. $textLength = Helper::width($textContent);
  57990. if ($textLength > 0) {
  57991. $contentColumns = str_split($textContent, ceil($textLength / $cell->getColspan()));
  57992. foreach ($contentColumns as $position => $content) {
  57993. $row[$i + $position] = $content;
  57994. }
  57995. }
  57996. }
  57997. }
  57998. $lengths[] = $this->getCellWidth($row, $column);
  57999. }
  58000. $this->effectiveColumnWidths[$column] = max($lengths) + Helper::width($this->style->getCellRowContentFormat()) - 2;
  58001. }
  58002. }
  58003. private function getColumnSeparatorWidth(): int
  58004. {
  58005. return Helper::width(sprintf($this->style->getBorderFormat(), $this->style->getBorderChars()[3]));
  58006. }
  58007. private function getCellWidth(array $row, int $column): int
  58008. {
  58009. $cellWidth = 0;
  58010. if (isset($row[$column])) {
  58011. $cell = $row[$column];
  58012. $cellWidth = Helper::width(Helper::removeDecoration($this->output->getFormatter(), $cell));
  58013. }
  58014. $columnWidth = $this->columnWidths[$column] ?? 0;
  58015. $cellWidth = max($cellWidth, $columnWidth);
  58016. return isset($this->columnMaxWidths[$column]) ? min($this->columnMaxWidths[$column], $cellWidth) : $cellWidth;
  58017. }
  58018. private function cleanup()
  58019. {
  58020. $this->effectiveColumnWidths = [];
  58021. $this->numberOfColumns = null;
  58022. }
  58023. private static function initStyles(): array
  58024. {
  58025. $borderless = new TableStyle();
  58026. $borderless
  58027. ->setHorizontalBorderChars('=')
  58028. ->setVerticalBorderChars(' ')
  58029. ->setDefaultCrossingChar(' ')
  58030. ;
  58031. $compact = new TableStyle();
  58032. $compact
  58033. ->setHorizontalBorderChars('')
  58034. ->setVerticalBorderChars(' ')
  58035. ->setDefaultCrossingChar('')
  58036. ->setCellRowContentFormat('%s')
  58037. ;
  58038. $styleGuide = new TableStyle();
  58039. $styleGuide
  58040. ->setHorizontalBorderChars('-')
  58041. ->setVerticalBorderChars(' ')
  58042. ->setDefaultCrossingChar(' ')
  58043. ->setCellHeaderFormat('%s')
  58044. ;
  58045. $box = (new TableStyle())
  58046. ->setHorizontalBorderChars('─')
  58047. ->setVerticalBorderChars('│')
  58048. ->setCrossingChars('┼', '┌', '┬', '�', '┤', '┘', '┴', '└', '├')
  58049. ;
  58050. $boxDouble = (new TableStyle())
  58051. ->setHorizontalBorderChars('�', '─')
  58052. ->setVerticalBorderChars('║', '│')
  58053. ->setCrossingChars('┼', '╔', '╤', '╗', '╢', '�', '╧', '╚', '╟', '╠', '╪', '╣')
  58054. ;
  58055. return [
  58056. 'default' => new TableStyle(),
  58057. 'borderless' => $borderless,
  58058. 'compact' => $compact,
  58059. 'symfony-style-guide' => $styleGuide,
  58060. 'box' => $box,
  58061. 'box-double' => $boxDouble,
  58062. ];
  58063. }
  58064. private function resolveStyle($name): TableStyle
  58065. {
  58066. if ($name instanceof TableStyle) {
  58067. return $name;
  58068. }
  58069. if (isset(self::$styles[$name])) {
  58070. return self::$styles[$name];
  58071. }
  58072. throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
  58073. }
  58074. }
  58075. <?php
  58076. namespace Symfony\Component\Console\Helper;
  58077. use Symfony\Component\Console\Exception\InvalidArgumentException;
  58078. class TableCell
  58079. {
  58080. private $value;
  58081. private $options = [
  58082. 'rowspan' => 1,
  58083. 'colspan' => 1,
  58084. 'style' => null,
  58085. ];
  58086. public function __construct(string $value = '', array $options = [])
  58087. {
  58088. $this->value = $value;
  58089. if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
  58090. throw new InvalidArgumentException(sprintf('The TableCell does not support the following options: \'%s\'.', implode('\', \'', $diff)));
  58091. }
  58092. if (isset($options['style']) && !$options['style'] instanceof TableCellStyle) {
  58093. throw new InvalidArgumentException('The style option must be an instance of "TableCellStyle".');
  58094. }
  58095. $this->options = array_merge($this->options, $options);
  58096. }
  58097. public function __toString()
  58098. {
  58099. return $this->value;
  58100. }
  58101. public function getColspan()
  58102. {
  58103. return (int) $this->options['colspan'];
  58104. }
  58105. public function getRowspan()
  58106. {
  58107. return (int) $this->options['rowspan'];
  58108. }
  58109. public function getStyle(): ?TableCellStyle
  58110. {
  58111. return $this->options['style'];
  58112. }
  58113. }
  58114. <?php
  58115. namespace Symfony\Component\Console\Helper;
  58116. use Symfony\Component\Console\Exception\InvalidArgumentException;
  58117. class TableCellStyle
  58118. {
  58119. public const DEFAULT_ALIGN = 'left';
  58120. private const TAG_OPTIONS = [
  58121. 'fg',
  58122. 'bg',
  58123. 'options',
  58124. ];
  58125. private const ALIGN_MAP = [
  58126. 'left' => \STR_PAD_RIGHT,
  58127. 'center' => \STR_PAD_BOTH,
  58128. 'right' => \STR_PAD_LEFT,
  58129. ];
  58130. private $options = [
  58131. 'fg' => 'default',
  58132. 'bg' => 'default',
  58133. 'options' => null,
  58134. 'align' => self::DEFAULT_ALIGN,
  58135. 'cellFormat' => null,
  58136. ];
  58137. public function __construct(array $options = [])
  58138. {
  58139. if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
  58140. throw new InvalidArgumentException(sprintf('The TableCellStyle does not support the following options: \'%s\'.', implode('\', \'', $diff)));
  58141. }
  58142. if (isset($options['align']) && !\array_key_exists($options['align'], self::ALIGN_MAP)) {
  58143. throw new InvalidArgumentException(sprintf('Wrong align value. Value must be following: \'%s\'.', implode('\', \'', array_keys(self::ALIGN_MAP))));
  58144. }
  58145. $this->options = array_merge($this->options, $options);
  58146. }
  58147. public function getOptions(): array
  58148. {
  58149. return $this->options;
  58150. }
  58151. public function getTagOptions()
  58152. {
  58153. return array_filter(
  58154. $this->getOptions(),
  58155. function ($key) {
  58156. return \in_array($key, self::TAG_OPTIONS) && isset($this->options[$key]);
  58157. },
  58158. \ARRAY_FILTER_USE_KEY
  58159. );
  58160. }
  58161. public function getPadByAlign()
  58162. {
  58163. return self::ALIGN_MAP[$this->getOptions()['align']];
  58164. }
  58165. public function getCellFormat(): ?string
  58166. {
  58167. return $this->getOptions()['cellFormat'];
  58168. }
  58169. }
  58170. <?php
  58171. namespace Symfony\Component\Console\Helper;
  58172. class TableRows implements \IteratorAggregate
  58173. {
  58174. private $generator;
  58175. public function __construct(\Closure $generator)
  58176. {
  58177. $this->generator = $generator;
  58178. }
  58179. public function getIterator(): \Traversable
  58180. {
  58181. return ($this->generator)();
  58182. }
  58183. }
  58184. <?php
  58185. namespace Symfony\Component\Console\Helper;
  58186. class TableSeparator extends TableCell
  58187. {
  58188. public function __construct(array $options = [])
  58189. {
  58190. parent::__construct('', $options);
  58191. }
  58192. }
  58193. <?php
  58194. namespace Symfony\Component\Console\Helper;
  58195. use Symfony\Component\Console\Exception\InvalidArgumentException;
  58196. use Symfony\Component\Console\Exception\LogicException;
  58197. class TableStyle
  58198. {
  58199. private $paddingChar = ' ';
  58200. private $horizontalOutsideBorderChar = '-';
  58201. private $horizontalInsideBorderChar = '-';
  58202. private $verticalOutsideBorderChar = '|';
  58203. private $verticalInsideBorderChar = '|';
  58204. private $crossingChar = '+';
  58205. private $crossingTopRightChar = '+';
  58206. private $crossingTopMidChar = '+';
  58207. private $crossingTopLeftChar = '+';
  58208. private $crossingMidRightChar = '+';
  58209. private $crossingBottomRightChar = '+';
  58210. private $crossingBottomMidChar = '+';
  58211. private $crossingBottomLeftChar = '+';
  58212. private $crossingMidLeftChar = '+';
  58213. private $crossingTopLeftBottomChar = '+';
  58214. private $crossingTopMidBottomChar = '+';
  58215. private $crossingTopRightBottomChar = '+';
  58216. private $headerTitleFormat = '<fg=black;bg=white;options=bold> %s </>';
  58217. private $footerTitleFormat = '<fg=black;bg=white;options=bold> %s </>';
  58218. private $cellHeaderFormat = '<info>%s</info>';
  58219. private $cellRowFormat = '%s';
  58220. private $cellRowContentFormat = ' %s ';
  58221. private $borderFormat = '%s';
  58222. private $padType = \STR_PAD_RIGHT;
  58223. public function setPaddingChar(string $paddingChar)
  58224. {
  58225. if (!$paddingChar) {
  58226. throw new LogicException('The padding char must not be empty.');
  58227. }
  58228. $this->paddingChar = $paddingChar;
  58229. return $this;
  58230. }
  58231. public function getPaddingChar()
  58232. {
  58233. return $this->paddingChar;
  58234. }
  58235. public function setHorizontalBorderChars(string $outside, string $inside = null): self
  58236. {
  58237. $this->horizontalOutsideBorderChar = $outside;
  58238. $this->horizontalInsideBorderChar = $inside ?? $outside;
  58239. return $this;
  58240. }
  58241. public function setVerticalBorderChars(string $outside, string $inside = null): self
  58242. {
  58243. $this->verticalOutsideBorderChar = $outside;
  58244. $this->verticalInsideBorderChar = $inside ?? $outside;
  58245. return $this;
  58246. }
  58247. public function getBorderChars(): array
  58248. {
  58249. return [
  58250. $this->horizontalOutsideBorderChar,
  58251. $this->verticalOutsideBorderChar,
  58252. $this->horizontalInsideBorderChar,
  58253. $this->verticalInsideBorderChar,
  58254. ];
  58255. }
  58256. public function setCrossingChars(string $cross, string $topLeft, string $topMid, string $topRight, string $midRight, string $bottomRight, string $bottomMid, string $bottomLeft, string $midLeft, string $topLeftBottom = null, string $topMidBottom = null, string $topRightBottom = null): self
  58257. {
  58258. $this->crossingChar = $cross;
  58259. $this->crossingTopLeftChar = $topLeft;
  58260. $this->crossingTopMidChar = $topMid;
  58261. $this->crossingTopRightChar = $topRight;
  58262. $this->crossingMidRightChar = $midRight;
  58263. $this->crossingBottomRightChar = $bottomRight;
  58264. $this->crossingBottomMidChar = $bottomMid;
  58265. $this->crossingBottomLeftChar = $bottomLeft;
  58266. $this->crossingMidLeftChar = $midLeft;
  58267. $this->crossingTopLeftBottomChar = $topLeftBottom ?? $midLeft;
  58268. $this->crossingTopMidBottomChar = $topMidBottom ?? $cross;
  58269. $this->crossingTopRightBottomChar = $topRightBottom ?? $midRight;
  58270. return $this;
  58271. }
  58272. public function setDefaultCrossingChar(string $char): self
  58273. {
  58274. return $this->setCrossingChars($char, $char, $char, $char, $char, $char, $char, $char, $char);
  58275. }
  58276. public function getCrossingChar()
  58277. {
  58278. return $this->crossingChar;
  58279. }
  58280. public function getCrossingChars(): array
  58281. {
  58282. return [
  58283. $this->crossingChar,
  58284. $this->crossingTopLeftChar,
  58285. $this->crossingTopMidChar,
  58286. $this->crossingTopRightChar,
  58287. $this->crossingMidRightChar,
  58288. $this->crossingBottomRightChar,
  58289. $this->crossingBottomMidChar,
  58290. $this->crossingBottomLeftChar,
  58291. $this->crossingMidLeftChar,
  58292. $this->crossingTopLeftBottomChar,
  58293. $this->crossingTopMidBottomChar,
  58294. $this->crossingTopRightBottomChar,
  58295. ];
  58296. }
  58297. public function setCellHeaderFormat(string $cellHeaderFormat)
  58298. {
  58299. $this->cellHeaderFormat = $cellHeaderFormat;
  58300. return $this;
  58301. }
  58302. public function getCellHeaderFormat()
  58303. {
  58304. return $this->cellHeaderFormat;
  58305. }
  58306. public function setCellRowFormat(string $cellRowFormat)
  58307. {
  58308. $this->cellRowFormat = $cellRowFormat;
  58309. return $this;
  58310. }
  58311. public function getCellRowFormat()
  58312. {
  58313. return $this->cellRowFormat;
  58314. }
  58315. public function setCellRowContentFormat(string $cellRowContentFormat)
  58316. {
  58317. $this->cellRowContentFormat = $cellRowContentFormat;
  58318. return $this;
  58319. }
  58320. public function getCellRowContentFormat()
  58321. {
  58322. return $this->cellRowContentFormat;
  58323. }
  58324. public function setBorderFormat(string $borderFormat)
  58325. {
  58326. $this->borderFormat = $borderFormat;
  58327. return $this;
  58328. }
  58329. public function getBorderFormat()
  58330. {
  58331. return $this->borderFormat;
  58332. }
  58333. public function setPadType(int $padType)
  58334. {
  58335. if (!\in_array($padType, [\STR_PAD_LEFT, \STR_PAD_RIGHT, \STR_PAD_BOTH], true)) {
  58336. throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).');
  58337. }
  58338. $this->padType = $padType;
  58339. return $this;
  58340. }
  58341. public function getPadType()
  58342. {
  58343. return $this->padType;
  58344. }
  58345. public function getHeaderTitleFormat(): string
  58346. {
  58347. return $this->headerTitleFormat;
  58348. }
  58349. public function setHeaderTitleFormat(string $format): self
  58350. {
  58351. $this->headerTitleFormat = $format;
  58352. return $this;
  58353. }
  58354. public function getFooterTitleFormat(): string
  58355. {
  58356. return $this->footerTitleFormat;
  58357. }
  58358. public function setFooterTitleFormat(string $format): self
  58359. {
  58360. $this->footerTitleFormat = $format;
  58361. return $this;
  58362. }
  58363. }
  58364. <?php
  58365. namespace Symfony\Component\Console\Input;
  58366. use Symfony\Component\Console\Exception\RuntimeException;
  58367. class ArgvInput extends Input
  58368. {
  58369. private $tokens;
  58370. private $parsed;
  58371. public function __construct(array $argv = null, InputDefinition $definition = null)
  58372. {
  58373. $argv = $argv ?? $_SERVER['argv'] ?? [];
  58374. array_shift($argv);
  58375. $this->tokens = $argv;
  58376. parent::__construct($definition);
  58377. }
  58378. protected function setTokens(array $tokens)
  58379. {
  58380. $this->tokens = $tokens;
  58381. }
  58382. protected function parse()
  58383. {
  58384. $parseOptions = true;
  58385. $this->parsed = $this->tokens;
  58386. while (null !== $token = array_shift($this->parsed)) {
  58387. $parseOptions = $this->parseToken($token, $parseOptions);
  58388. }
  58389. }
  58390. protected function parseToken(string $token, bool $parseOptions): bool
  58391. {
  58392. if ($parseOptions && '' == $token) {
  58393. $this->parseArgument($token);
  58394. } elseif ($parseOptions && '--' == $token) {
  58395. return false;
  58396. } elseif ($parseOptions && str_starts_with($token, '--')) {
  58397. $this->parseLongOption($token);
  58398. } elseif ($parseOptions && '-' === $token[0] && '-' !== $token) {
  58399. $this->parseShortOption($token);
  58400. } else {
  58401. $this->parseArgument($token);
  58402. }
  58403. return $parseOptions;
  58404. }
  58405. private function parseShortOption(string $token)
  58406. {
  58407. $name = substr($token, 1);
  58408. if (\strlen($name) > 1) {
  58409. if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptValue()) {
  58410. $this->addShortOption($name[0], substr($name, 1));
  58411. } else {
  58412. $this->parseShortOptionSet($name);
  58413. }
  58414. } else {
  58415. $this->addShortOption($name, null);
  58416. }
  58417. }
  58418. private function parseShortOptionSet(string $name)
  58419. {
  58420. $len = \strlen($name);
  58421. for ($i = 0; $i < $len; ++$i) {
  58422. if (!$this->definition->hasShortcut($name[$i])) {
  58423. $encoding = mb_detect_encoding($name, null, true);
  58424. throw new RuntimeException(sprintf('The "-%s" option does not exist.', false === $encoding ? $name[$i] : mb_substr($name, $i, 1, $encoding)));
  58425. }
  58426. $option = $this->definition->getOptionForShortcut($name[$i]);
  58427. if ($option->acceptValue()) {
  58428. $this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1));
  58429. break;
  58430. } else {
  58431. $this->addLongOption($option->getName(), null);
  58432. }
  58433. }
  58434. }
  58435. private function parseLongOption(string $token)
  58436. {
  58437. $name = substr($token, 2);
  58438. if (false !== $pos = strpos($name, '=')) {
  58439. if ('' === $value = substr($name, $pos + 1)) {
  58440. array_unshift($this->parsed, $value);
  58441. }
  58442. $this->addLongOption(substr($name, 0, $pos), $value);
  58443. } else {
  58444. $this->addLongOption($name, null);
  58445. }
  58446. }
  58447. private function parseArgument(string $token)
  58448. {
  58449. $c = \count($this->arguments);
  58450. if ($this->definition->hasArgument($c)) {
  58451. $arg = $this->definition->getArgument($c);
  58452. $this->arguments[$arg->getName()] = $arg->isArray() ? [$token] : $token;
  58453. } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) {
  58454. $arg = $this->definition->getArgument($c - 1);
  58455. $this->arguments[$arg->getName()][] = $token;
  58456. } else {
  58457. $all = $this->definition->getArguments();
  58458. $symfonyCommandName = null;
  58459. if (($inputArgument = $all[$key = array_key_first($all)] ?? null) && 'command' === $inputArgument->getName()) {
  58460. $symfonyCommandName = $this->arguments['command'] ?? null;
  58461. unset($all[$key]);
  58462. }
  58463. if (\count($all)) {
  58464. if ($symfonyCommandName) {
  58465. $message = sprintf('Too many arguments to "%s" command, expected arguments "%s".', $symfonyCommandName, implode('" "', array_keys($all)));
  58466. } else {
  58467. $message = sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all)));
  58468. }
  58469. } elseif ($symfonyCommandName) {
  58470. $message = sprintf('No arguments expected for "%s" command, got "%s".', $symfonyCommandName, $token);
  58471. } else {
  58472. $message = sprintf('No arguments expected, got "%s".', $token);
  58473. }
  58474. throw new RuntimeException($message);
  58475. }
  58476. }
  58477. private function addShortOption(string $shortcut, $value)
  58478. {
  58479. if (!$this->definition->hasShortcut($shortcut)) {
  58480. throw new RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut));
  58481. }
  58482. $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
  58483. }
  58484. private function addLongOption(string $name, $value)
  58485. {
  58486. if (!$this->definition->hasOption($name)) {
  58487. if (!$this->definition->hasNegation($name)) {
  58488. throw new RuntimeException(sprintf('The "--%s" option does not exist.', $name));
  58489. }
  58490. $optionName = $this->definition->negationToName($name);
  58491. if (null !== $value) {
  58492. throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name));
  58493. }
  58494. $this->options[$optionName] = false;
  58495. return;
  58496. }
  58497. $option = $this->definition->getOption($name);
  58498. if (null !== $value && !$option->acceptValue()) {
  58499. throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name));
  58500. }
  58501. if (\in_array($value, ['', null], true) && $option->acceptValue() && \count($this->parsed)) {
  58502. $next = array_shift($this->parsed);
  58503. if ((isset($next[0]) && '-' !== $next[0]) || \in_array($next, ['', null], true)) {
  58504. $value = $next;
  58505. } else {
  58506. array_unshift($this->parsed, $next);
  58507. }
  58508. }
  58509. if (null === $value) {
  58510. if ($option->isValueRequired()) {
  58511. throw new RuntimeException(sprintf('The "--%s" option requires a value.', $name));
  58512. }
  58513. if (!$option->isArray() && !$option->isValueOptional()) {
  58514. $value = true;
  58515. }
  58516. }
  58517. if ($option->isArray()) {
  58518. $this->options[$name][] = $value;
  58519. } else {
  58520. $this->options[$name] = $value;
  58521. }
  58522. }
  58523. public function getFirstArgument()
  58524. {
  58525. $isOption = false;
  58526. foreach ($this->tokens as $i => $token) {
  58527. if ($token && '-' === $token[0]) {
  58528. if (str_contains($token, '=') || !isset($this->tokens[$i + 1])) {
  58529. continue;
  58530. }
  58531. $name = '-' === $token[1] ? substr($token, 2) : substr($token, -1);
  58532. if (!isset($this->options[$name]) && !$this->definition->hasShortcut($name)) {
  58533. } elseif ((isset($this->options[$name]) || isset($this->options[$name = $this->definition->shortcutToName($name)])) && $this->tokens[$i + 1] === $this->options[$name]) {
  58534. $isOption = true;
  58535. }
  58536. continue;
  58537. }
  58538. if ($isOption) {
  58539. $isOption = false;
  58540. continue;
  58541. }
  58542. return $token;
  58543. }
  58544. return null;
  58545. }
  58546. public function hasParameterOption($values, bool $onlyParams = false)
  58547. {
  58548. $values = (array) $values;
  58549. foreach ($this->tokens as $token) {
  58550. if ($onlyParams && '--' === $token) {
  58551. return false;
  58552. }
  58553. foreach ($values as $value) {
  58554. $leading = str_starts_with($value, '--') ? $value.'=' : $value;
  58555. if ($token === $value || '' !== $leading && str_starts_with($token, $leading)) {
  58556. return true;
  58557. }
  58558. }
  58559. }
  58560. return false;
  58561. }
  58562. public function getParameterOption($values, $default = false, bool $onlyParams = false)
  58563. {
  58564. $values = (array) $values;
  58565. $tokens = $this->tokens;
  58566. while (0 < \count($tokens)) {
  58567. $token = array_shift($tokens);
  58568. if ($onlyParams && '--' === $token) {
  58569. return $default;
  58570. }
  58571. foreach ($values as $value) {
  58572. if ($token === $value) {
  58573. return array_shift($tokens);
  58574. }
  58575. $leading = str_starts_with($value, '--') ? $value.'=' : $value;
  58576. if ('' !== $leading && str_starts_with($token, $leading)) {
  58577. return substr($token, \strlen($leading));
  58578. }
  58579. }
  58580. }
  58581. return $default;
  58582. }
  58583. public function __toString()
  58584. {
  58585. $tokens = array_map(function ($token) {
  58586. if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) {
  58587. return $match[1].$this->escapeToken($match[2]);
  58588. }
  58589. if ($token && '-' !== $token[0]) {
  58590. return $this->escapeToken($token);
  58591. }
  58592. return $token;
  58593. }, $this->tokens);
  58594. return implode(' ', $tokens);
  58595. }
  58596. }
  58597. <?php
  58598. namespace Symfony\Component\Console\Input;
  58599. use Symfony\Component\Console\Exception\InvalidArgumentException;
  58600. use Symfony\Component\Console\Exception\InvalidOptionException;
  58601. class ArrayInput extends Input
  58602. {
  58603. private $parameters;
  58604. public function __construct(array $parameters, InputDefinition $definition = null)
  58605. {
  58606. $this->parameters = $parameters;
  58607. parent::__construct($definition);
  58608. }
  58609. public function getFirstArgument()
  58610. {
  58611. foreach ($this->parameters as $param => $value) {
  58612. if ($param && \is_string($param) && '-' === $param[0]) {
  58613. continue;
  58614. }
  58615. return $value;
  58616. }
  58617. return null;
  58618. }
  58619. public function hasParameterOption($values, bool $onlyParams = false)
  58620. {
  58621. $values = (array) $values;
  58622. foreach ($this->parameters as $k => $v) {
  58623. if (!\is_int($k)) {
  58624. $v = $k;
  58625. }
  58626. if ($onlyParams && '--' === $v) {
  58627. return false;
  58628. }
  58629. if (\in_array($v, $values)) {
  58630. return true;
  58631. }
  58632. }
  58633. return false;
  58634. }
  58635. public function getParameterOption($values, $default = false, bool $onlyParams = false)
  58636. {
  58637. $values = (array) $values;
  58638. foreach ($this->parameters as $k => $v) {
  58639. if ($onlyParams && ('--' === $k || (\is_int($k) && '--' === $v))) {
  58640. return $default;
  58641. }
  58642. if (\is_int($k)) {
  58643. if (\in_array($v, $values)) {
  58644. return true;
  58645. }
  58646. } elseif (\in_array($k, $values)) {
  58647. return $v;
  58648. }
  58649. }
  58650. return $default;
  58651. }
  58652. public function __toString()
  58653. {
  58654. $params = [];
  58655. foreach ($this->parameters as $param => $val) {
  58656. if ($param && \is_string($param) && '-' === $param[0]) {
  58657. $glue = ('-' === $param[1]) ? '=' : ' ';
  58658. if (\is_array($val)) {
  58659. foreach ($val as $v) {
  58660. $params[] = $param.('' != $v ? $glue.$this->escapeToken($v) : '');
  58661. }
  58662. } else {
  58663. $params[] = $param.('' != $val ? $glue.$this->escapeToken($val) : '');
  58664. }
  58665. } else {
  58666. $params[] = \is_array($val) ? implode(' ', array_map([$this, 'escapeToken'], $val)) : $this->escapeToken($val);
  58667. }
  58668. }
  58669. return implode(' ', $params);
  58670. }
  58671. protected function parse()
  58672. {
  58673. foreach ($this->parameters as $key => $value) {
  58674. if ('--' === $key) {
  58675. return;
  58676. }
  58677. if (str_starts_with($key, '--')) {
  58678. $this->addLongOption(substr($key, 2), $value);
  58679. } elseif (str_starts_with($key, '-')) {
  58680. $this->addShortOption(substr($key, 1), $value);
  58681. } else {
  58682. $this->addArgument($key, $value);
  58683. }
  58684. }
  58685. }
  58686. private function addShortOption(string $shortcut, $value)
  58687. {
  58688. if (!$this->definition->hasShortcut($shortcut)) {
  58689. throw new InvalidOptionException(sprintf('The "-%s" option does not exist.', $shortcut));
  58690. }
  58691. $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
  58692. }
  58693. private function addLongOption(string $name, $value)
  58694. {
  58695. if (!$this->definition->hasOption($name)) {
  58696. if (!$this->definition->hasNegation($name)) {
  58697. throw new InvalidOptionException(sprintf('The "--%s" option does not exist.', $name));
  58698. }
  58699. $optionName = $this->definition->negationToName($name);
  58700. $this->options[$optionName] = false;
  58701. return;
  58702. }
  58703. $option = $this->definition->getOption($name);
  58704. if (null === $value) {
  58705. if ($option->isValueRequired()) {
  58706. throw new InvalidOptionException(sprintf('The "--%s" option requires a value.', $name));
  58707. }
  58708. if (!$option->isValueOptional()) {
  58709. $value = true;
  58710. }
  58711. }
  58712. $this->options[$name] = $value;
  58713. }
  58714. private function addArgument($name, $value)
  58715. {
  58716. if (!$this->definition->hasArgument($name)) {
  58717. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  58718. }
  58719. $this->arguments[$name] = $value;
  58720. }
  58721. }
  58722. <?php
  58723. namespace Symfony\Component\Console\Input;
  58724. use Symfony\Component\Console\Exception\InvalidArgumentException;
  58725. use Symfony\Component\Console\Exception\RuntimeException;
  58726. abstract class Input implements InputInterface, StreamableInputInterface
  58727. {
  58728. protected $definition;
  58729. protected $stream;
  58730. protected $options = [];
  58731. protected $arguments = [];
  58732. protected $interactive = true;
  58733. public function __construct(InputDefinition $definition = null)
  58734. {
  58735. if (null === $definition) {
  58736. $this->definition = new InputDefinition();
  58737. } else {
  58738. $this->bind($definition);
  58739. $this->validate();
  58740. }
  58741. }
  58742. public function bind(InputDefinition $definition)
  58743. {
  58744. $this->arguments = [];
  58745. $this->options = [];
  58746. $this->definition = $definition;
  58747. $this->parse();
  58748. }
  58749. abstract protected function parse();
  58750. public function validate()
  58751. {
  58752. $definition = $this->definition;
  58753. $givenArguments = $this->arguments;
  58754. $missingArguments = array_filter(array_keys($definition->getArguments()), function ($argument) use ($definition, $givenArguments) {
  58755. return !\array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired();
  58756. });
  58757. if (\count($missingArguments) > 0) {
  58758. throw new RuntimeException(sprintf('Not enough arguments (missing: "%s").', implode(', ', $missingArguments)));
  58759. }
  58760. }
  58761. public function isInteractive()
  58762. {
  58763. return $this->interactive;
  58764. }
  58765. public function setInteractive(bool $interactive)
  58766. {
  58767. $this->interactive = $interactive;
  58768. }
  58769. public function getArguments()
  58770. {
  58771. return array_merge($this->definition->getArgumentDefaults(), $this->arguments);
  58772. }
  58773. public function getArgument(string $name)
  58774. {
  58775. if (!$this->definition->hasArgument($name)) {
  58776. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  58777. }
  58778. return $this->arguments[$name] ?? $this->definition->getArgument($name)->getDefault();
  58779. }
  58780. public function setArgument(string $name, $value)
  58781. {
  58782. if (!$this->definition->hasArgument($name)) {
  58783. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  58784. }
  58785. $this->arguments[$name] = $value;
  58786. }
  58787. public function hasArgument(string $name)
  58788. {
  58789. return $this->definition->hasArgument($name);
  58790. }
  58791. public function getOptions()
  58792. {
  58793. return array_merge($this->definition->getOptionDefaults(), $this->options);
  58794. }
  58795. public function getOption(string $name)
  58796. {
  58797. if ($this->definition->hasNegation($name)) {
  58798. if (null === $value = $this->getOption($this->definition->negationToName($name))) {
  58799. return $value;
  58800. }
  58801. return !$value;
  58802. }
  58803. if (!$this->definition->hasOption($name)) {
  58804. throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
  58805. }
  58806. return \array_key_exists($name, $this->options) ? $this->options[$name] : $this->definition->getOption($name)->getDefault();
  58807. }
  58808. public function setOption(string $name, $value)
  58809. {
  58810. if ($this->definition->hasNegation($name)) {
  58811. $this->options[$this->definition->negationToName($name)] = !$value;
  58812. return;
  58813. } elseif (!$this->definition->hasOption($name)) {
  58814. throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
  58815. }
  58816. $this->options[$name] = $value;
  58817. }
  58818. public function hasOption(string $name)
  58819. {
  58820. return $this->definition->hasOption($name) || $this->definition->hasNegation($name);
  58821. }
  58822. public function escapeToken(string $token)
  58823. {
  58824. return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token);
  58825. }
  58826. public function setStream($stream)
  58827. {
  58828. $this->stream = $stream;
  58829. }
  58830. public function getStream()
  58831. {
  58832. return $this->stream;
  58833. }
  58834. }
  58835. <?php
  58836. namespace Symfony\Component\Console\Input;
  58837. use Symfony\Component\Console\Exception\InvalidArgumentException;
  58838. use Symfony\Component\Console\Exception\LogicException;
  58839. class InputArgument
  58840. {
  58841. public const REQUIRED = 1;
  58842. public const OPTIONAL = 2;
  58843. public const IS_ARRAY = 4;
  58844. private $name;
  58845. private $mode;
  58846. private $default;
  58847. private $description;
  58848. public function __construct(string $name, int $mode = null, string $description = '', $default = null)
  58849. {
  58850. if (null === $mode) {
  58851. $mode = self::OPTIONAL;
  58852. } elseif ($mode > 7 || $mode < 1) {
  58853. throw new InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode));
  58854. }
  58855. $this->name = $name;
  58856. $this->mode = $mode;
  58857. $this->description = $description;
  58858. $this->setDefault($default);
  58859. }
  58860. public function getName()
  58861. {
  58862. return $this->name;
  58863. }
  58864. public function isRequired()
  58865. {
  58866. return self::REQUIRED === (self::REQUIRED & $this->mode);
  58867. }
  58868. public function isArray()
  58869. {
  58870. return self::IS_ARRAY === (self::IS_ARRAY & $this->mode);
  58871. }
  58872. public function setDefault($default = null)
  58873. {
  58874. if (self::REQUIRED === $this->mode && null !== $default) {
  58875. throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.');
  58876. }
  58877. if ($this->isArray()) {
  58878. if (null === $default) {
  58879. $default = [];
  58880. } elseif (!\is_array($default)) {
  58881. throw new LogicException('A default value for an array argument must be an array.');
  58882. }
  58883. }
  58884. $this->default = $default;
  58885. }
  58886. public function getDefault()
  58887. {
  58888. return $this->default;
  58889. }
  58890. public function getDescription()
  58891. {
  58892. return $this->description;
  58893. }
  58894. }
  58895. <?php
  58896. namespace Symfony\Component\Console\Input;
  58897. interface InputAwareInterface
  58898. {
  58899. public function setInput(InputInterface $input);
  58900. }
  58901. <?php
  58902. namespace Symfony\Component\Console\Input;
  58903. use Symfony\Component\Console\Exception\InvalidArgumentException;
  58904. use Symfony\Component\Console\Exception\LogicException;
  58905. class InputDefinition
  58906. {
  58907. private $arguments;
  58908. private $requiredCount;
  58909. private $lastArrayArgument;
  58910. private $lastOptionalArgument;
  58911. private $options;
  58912. private $negations;
  58913. private $shortcuts;
  58914. public function __construct(array $definition = [])
  58915. {
  58916. $this->setDefinition($definition);
  58917. }
  58918. public function setDefinition(array $definition)
  58919. {
  58920. $arguments = [];
  58921. $options = [];
  58922. foreach ($definition as $item) {
  58923. if ($item instanceof InputOption) {
  58924. $options[] = $item;
  58925. } else {
  58926. $arguments[] = $item;
  58927. }
  58928. }
  58929. $this->setArguments($arguments);
  58930. $this->setOptions($options);
  58931. }
  58932. public function setArguments(array $arguments = [])
  58933. {
  58934. $this->arguments = [];
  58935. $this->requiredCount = 0;
  58936. $this->lastOptionalArgument = null;
  58937. $this->lastArrayArgument = null;
  58938. $this->addArguments($arguments);
  58939. }
  58940. public function addArguments(?array $arguments = [])
  58941. {
  58942. if (null !== $arguments) {
  58943. foreach ($arguments as $argument) {
  58944. $this->addArgument($argument);
  58945. }
  58946. }
  58947. }
  58948. public function addArgument(InputArgument $argument)
  58949. {
  58950. if (isset($this->arguments[$argument->getName()])) {
  58951. throw new LogicException(sprintf('An argument with name "%s" already exists.', $argument->getName()));
  58952. }
  58953. if (null !== $this->lastArrayArgument) {
  58954. throw new LogicException(sprintf('Cannot add a required argument "%s" after an array argument "%s".', $argument->getName(), $this->lastArrayArgument->getName()));
  58955. }
  58956. if ($argument->isRequired() && null !== $this->lastOptionalArgument) {
  58957. throw new LogicException(sprintf('Cannot add a required argument "%s" after an optional one "%s".', $argument->getName(), $this->lastOptionalArgument->getName()));
  58958. }
  58959. if ($argument->isArray()) {
  58960. $this->lastArrayArgument = $argument;
  58961. }
  58962. if ($argument->isRequired()) {
  58963. ++$this->requiredCount;
  58964. } else {
  58965. $this->lastOptionalArgument = $argument;
  58966. }
  58967. $this->arguments[$argument->getName()] = $argument;
  58968. }
  58969. public function getArgument($name)
  58970. {
  58971. if (!$this->hasArgument($name)) {
  58972. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  58973. }
  58974. $arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
  58975. return $arguments[$name];
  58976. }
  58977. public function hasArgument($name)
  58978. {
  58979. $arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
  58980. return isset($arguments[$name]);
  58981. }
  58982. public function getArguments()
  58983. {
  58984. return $this->arguments;
  58985. }
  58986. public function getArgumentCount()
  58987. {
  58988. return null !== $this->lastArrayArgument ? \PHP_INT_MAX : \count($this->arguments);
  58989. }
  58990. public function getArgumentRequiredCount()
  58991. {
  58992. return $this->requiredCount;
  58993. }
  58994. public function getArgumentDefaults()
  58995. {
  58996. $values = [];
  58997. foreach ($this->arguments as $argument) {
  58998. $values[$argument->getName()] = $argument->getDefault();
  58999. }
  59000. return $values;
  59001. }
  59002. public function setOptions(array $options = [])
  59003. {
  59004. $this->options = [];
  59005. $this->shortcuts = [];
  59006. $this->negations = [];
  59007. $this->addOptions($options);
  59008. }
  59009. public function addOptions(array $options = [])
  59010. {
  59011. foreach ($options as $option) {
  59012. $this->addOption($option);
  59013. }
  59014. }
  59015. public function addOption(InputOption $option)
  59016. {
  59017. if (isset($this->options[$option->getName()]) && !$option->equals($this->options[$option->getName()])) {
  59018. throw new LogicException(sprintf('An option named "%s" already exists.', $option->getName()));
  59019. }
  59020. if (isset($this->negations[$option->getName()])) {
  59021. throw new LogicException(sprintf('An option named "%s" already exists.', $option->getName()));
  59022. }
  59023. if ($option->getShortcut()) {
  59024. foreach (explode('|', $option->getShortcut()) as $shortcut) {
  59025. if (isset($this->shortcuts[$shortcut]) && !$option->equals($this->options[$this->shortcuts[$shortcut]])) {
  59026. throw new LogicException(sprintf('An option with shortcut "%s" already exists.', $shortcut));
  59027. }
  59028. }
  59029. }
  59030. $this->options[$option->getName()] = $option;
  59031. if ($option->getShortcut()) {
  59032. foreach (explode('|', $option->getShortcut()) as $shortcut) {
  59033. $this->shortcuts[$shortcut] = $option->getName();
  59034. }
  59035. }
  59036. if ($option->isNegatable()) {
  59037. $negatedName = 'no-'.$option->getName();
  59038. if (isset($this->options[$negatedName])) {
  59039. throw new LogicException(sprintf('An option named "%s" already exists.', $negatedName));
  59040. }
  59041. $this->negations[$negatedName] = $option->getName();
  59042. }
  59043. }
  59044. public function getOption(string $name)
  59045. {
  59046. if (!$this->hasOption($name)) {
  59047. throw new InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name));
  59048. }
  59049. return $this->options[$name];
  59050. }
  59051. public function hasOption(string $name)
  59052. {
  59053. return isset($this->options[$name]);
  59054. }
  59055. public function getOptions()
  59056. {
  59057. return $this->options;
  59058. }
  59059. public function hasShortcut(string $name)
  59060. {
  59061. return isset($this->shortcuts[$name]);
  59062. }
  59063. public function hasNegation(string $name): bool
  59064. {
  59065. return isset($this->negations[$name]);
  59066. }
  59067. public function getOptionForShortcut(string $shortcut)
  59068. {
  59069. return $this->getOption($this->shortcutToName($shortcut));
  59070. }
  59071. public function getOptionDefaults()
  59072. {
  59073. $values = [];
  59074. foreach ($this->options as $option) {
  59075. $values[$option->getName()] = $option->getDefault();
  59076. }
  59077. return $values;
  59078. }
  59079. public function shortcutToName(string $shortcut): string
  59080. {
  59081. if (!isset($this->shortcuts[$shortcut])) {
  59082. throw new InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut));
  59083. }
  59084. return $this->shortcuts[$shortcut];
  59085. }
  59086. public function negationToName(string $negation): string
  59087. {
  59088. if (!isset($this->negations[$negation])) {
  59089. throw new InvalidArgumentException(sprintf('The "--%s" option does not exist.', $negation));
  59090. }
  59091. return $this->negations[$negation];
  59092. }
  59093. public function getSynopsis(bool $short = false)
  59094. {
  59095. $elements = [];
  59096. if ($short && $this->getOptions()) {
  59097. $elements[] = '[options]';
  59098. } elseif (!$short) {
  59099. foreach ($this->getOptions() as $option) {
  59100. $value = '';
  59101. if ($option->acceptValue()) {
  59102. $value = sprintf(
  59103. ' %s%s%s',
  59104. $option->isValueOptional() ? '[' : '',
  59105. strtoupper($option->getName()),
  59106. $option->isValueOptional() ? ']' : ''
  59107. );
  59108. }
  59109. $shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : '';
  59110. $negation = $option->isNegatable() ? sprintf('|--no-%s', $option->getName()) : '';
  59111. $elements[] = sprintf('[%s--%s%s%s]', $shortcut, $option->getName(), $value, $negation);
  59112. }
  59113. }
  59114. if (\count($elements) && $this->getArguments()) {
  59115. $elements[] = '[--]';
  59116. }
  59117. $tail = '';
  59118. foreach ($this->getArguments() as $argument) {
  59119. $element = '<'.$argument->getName().'>';
  59120. if ($argument->isArray()) {
  59121. $element .= '...';
  59122. }
  59123. if (!$argument->isRequired()) {
  59124. $element = '['.$element;
  59125. $tail .= ']';
  59126. }
  59127. $elements[] = $element;
  59128. }
  59129. return implode(' ', $elements).$tail;
  59130. }
  59131. }
  59132. <?php
  59133. namespace Symfony\Component\Console\Input;
  59134. use Symfony\Component\Console\Exception\InvalidArgumentException;
  59135. use Symfony\Component\Console\Exception\RuntimeException;
  59136. interface InputInterface
  59137. {
  59138. public function getFirstArgument();
  59139. public function hasParameterOption($values, bool $onlyParams = false);
  59140. public function getParameterOption($values, $default = false, bool $onlyParams = false);
  59141. public function bind(InputDefinition $definition);
  59142. public function validate();
  59143. public function getArguments();
  59144. public function getArgument(string $name);
  59145. public function setArgument(string $name, $value);
  59146. public function hasArgument(string $name);
  59147. public function getOptions();
  59148. public function getOption(string $name);
  59149. public function setOption(string $name, $value);
  59150. public function hasOption(string $name);
  59151. public function isInteractive();
  59152. public function setInteractive(bool $interactive);
  59153. }
  59154. <?php
  59155. namespace Symfony\Component\Console\Input;
  59156. use Symfony\Component\Console\Exception\InvalidArgumentException;
  59157. use Symfony\Component\Console\Exception\LogicException;
  59158. class InputOption
  59159. {
  59160. public const VALUE_NONE = 1;
  59161. public const VALUE_REQUIRED = 2;
  59162. public const VALUE_OPTIONAL = 4;
  59163. public const VALUE_IS_ARRAY = 8;
  59164. public const VALUE_NEGATABLE = 16;
  59165. private $name;
  59166. private $shortcut;
  59167. private $mode;
  59168. private $default;
  59169. private $description;
  59170. public function __construct(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null)
  59171. {
  59172. if (str_starts_with($name, '--')) {
  59173. $name = substr($name, 2);
  59174. }
  59175. if (empty($name)) {
  59176. throw new InvalidArgumentException('An option name cannot be empty.');
  59177. }
  59178. if (empty($shortcut)) {
  59179. $shortcut = null;
  59180. }
  59181. if (null !== $shortcut) {
  59182. if (\is_array($shortcut)) {
  59183. $shortcut = implode('|', $shortcut);
  59184. }
  59185. $shortcuts = preg_split('{(\|)-?}', ltrim($shortcut, '-'));
  59186. $shortcuts = array_filter($shortcuts);
  59187. $shortcut = implode('|', $shortcuts);
  59188. if (empty($shortcut)) {
  59189. throw new InvalidArgumentException('An option shortcut cannot be empty.');
  59190. }
  59191. }
  59192. if (null === $mode) {
  59193. $mode = self::VALUE_NONE;
  59194. } elseif ($mode >= (self::VALUE_NEGATABLE << 1) || $mode < 1) {
  59195. throw new InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode));
  59196. }
  59197. $this->name = $name;
  59198. $this->shortcut = $shortcut;
  59199. $this->mode = $mode;
  59200. $this->description = $description;
  59201. if ($this->isArray() && !$this->acceptValue()) {
  59202. throw new InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.');
  59203. }
  59204. if ($this->isNegatable() && $this->acceptValue()) {
  59205. throw new InvalidArgumentException('Impossible to have an option mode VALUE_NEGATABLE if the option also accepts a value.');
  59206. }
  59207. $this->setDefault($default);
  59208. }
  59209. public function getShortcut()
  59210. {
  59211. return $this->shortcut;
  59212. }
  59213. public function getName()
  59214. {
  59215. return $this->name;
  59216. }
  59217. public function acceptValue()
  59218. {
  59219. return $this->isValueRequired() || $this->isValueOptional();
  59220. }
  59221. public function isValueRequired()
  59222. {
  59223. return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode);
  59224. }
  59225. public function isValueOptional()
  59226. {
  59227. return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode);
  59228. }
  59229. public function isArray()
  59230. {
  59231. return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode);
  59232. }
  59233. public function isNegatable(): bool
  59234. {
  59235. return self::VALUE_NEGATABLE === (self::VALUE_NEGATABLE & $this->mode);
  59236. }
  59237. public function setDefault($default = null)
  59238. {
  59239. if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) {
  59240. throw new LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.');
  59241. }
  59242. if ($this->isArray()) {
  59243. if (null === $default) {
  59244. $default = [];
  59245. } elseif (!\is_array($default)) {
  59246. throw new LogicException('A default value for an array option must be an array.');
  59247. }
  59248. }
  59249. $this->default = $this->acceptValue() || $this->isNegatable() ? $default : false;
  59250. }
  59251. public function getDefault()
  59252. {
  59253. return $this->default;
  59254. }
  59255. public function getDescription()
  59256. {
  59257. return $this->description;
  59258. }
  59259. public function equals(self $option)
  59260. {
  59261. return $option->getName() === $this->getName()
  59262. && $option->getShortcut() === $this->getShortcut()
  59263. && $option->getDefault() === $this->getDefault()
  59264. && $option->isNegatable() === $this->isNegatable()
  59265. && $option->isArray() === $this->isArray()
  59266. && $option->isValueRequired() === $this->isValueRequired()
  59267. && $option->isValueOptional() === $this->isValueOptional()
  59268. ;
  59269. }
  59270. }
  59271. <?php
  59272. namespace Symfony\Component\Console\Input;
  59273. interface StreamableInputInterface extends InputInterface
  59274. {
  59275. public function setStream($stream);
  59276. public function getStream();
  59277. }
  59278. <?php
  59279. namespace Symfony\Component\Console\Input;
  59280. use Symfony\Component\Console\Exception\InvalidArgumentException;
  59281. class StringInput extends ArgvInput
  59282. {
  59283. public const REGEX_STRING = '([^\s]+?)(?:\s|(?<!\\\\)"|(?<!\\\\)\'|$)';
  59284. public const REGEX_UNQUOTED_STRING = '([^\s\\\\]+?)';
  59285. public const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')';
  59286. public function __construct(string $input)
  59287. {
  59288. parent::__construct([]);
  59289. $this->setTokens($this->tokenize($input));
  59290. }
  59291. private function tokenize(string $input): array
  59292. {
  59293. $tokens = [];
  59294. $length = \strlen($input);
  59295. $cursor = 0;
  59296. $token = null;
  59297. while ($cursor < $length) {
  59298. if ('\\' === $input[$cursor]) {
  59299. $token .= $input[++$cursor] ?? '';
  59300. ++$cursor;
  59301. continue;
  59302. }
  59303. if (preg_match('/\s+/A', $input, $match, 0, $cursor)) {
  59304. if (null !== $token) {
  59305. $tokens[] = $token;
  59306. $token = null;
  59307. }
  59308. } elseif (preg_match('/([^="\'\s]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, 0, $cursor)) {
  59309. $token .= $match[1].$match[2].stripcslashes(str_replace(['"\'', '\'"', '\'\'', '""'], '', substr($match[3], 1, -1)));
  59310. } elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, 0, $cursor)) {
  59311. $token .= stripcslashes(substr($match[0], 1, -1));
  59312. } elseif (preg_match('/'.self::REGEX_UNQUOTED_STRING.'/A', $input, $match, 0, $cursor)) {
  59313. $token .= $match[1];
  59314. } else {
  59315. throw new InvalidArgumentException(sprintf('Unable to parse input near "... %s ...".', substr($input, $cursor, 10)));
  59316. }
  59317. $cursor += \strlen($match[0]);
  59318. }
  59319. if (null !== $token) {
  59320. $tokens[] = $token;
  59321. }
  59322. return $tokens;
  59323. }
  59324. }
  59325. Copyright (c) 2004-2022 Fabien Potencier
  59326. Permission is hereby granted, free of charge, to any person obtaining a copy
  59327. of this software and associated documentation files (the "Software"), to deal
  59328. in the Software without restriction, including without limitation the rights
  59329. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  59330. copies of the Software, and to permit persons to whom the Software is furnished
  59331. to do so, subject to the following conditions:
  59332. The above copyright notice and this permission notice shall be included in all
  59333. copies or substantial portions of the Software.
  59334. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  59335. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  59336. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  59337. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  59338. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  59339. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  59340. THE SOFTWARE.
  59341. <?php
  59342. namespace Symfony\Component\Console\Logger;
  59343. use Psr\Log\AbstractLogger;
  59344. use Psr\Log\InvalidArgumentException;
  59345. use Psr\Log\LogLevel;
  59346. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  59347. use Symfony\Component\Console\Output\OutputInterface;
  59348. class ConsoleLogger extends AbstractLogger
  59349. {
  59350. public const INFO = 'info';
  59351. public const ERROR = 'error';
  59352. private $output;
  59353. private $verbosityLevelMap = [
  59354. LogLevel::EMERGENCY => OutputInterface::VERBOSITY_NORMAL,
  59355. LogLevel::ALERT => OutputInterface::VERBOSITY_NORMAL,
  59356. LogLevel::CRITICAL => OutputInterface::VERBOSITY_NORMAL,
  59357. LogLevel::ERROR => OutputInterface::VERBOSITY_NORMAL,
  59358. LogLevel::WARNING => OutputInterface::VERBOSITY_NORMAL,
  59359. LogLevel::NOTICE => OutputInterface::VERBOSITY_VERBOSE,
  59360. LogLevel::INFO => OutputInterface::VERBOSITY_VERY_VERBOSE,
  59361. LogLevel::DEBUG => OutputInterface::VERBOSITY_DEBUG,
  59362. ];
  59363. private $formatLevelMap = [
  59364. LogLevel::EMERGENCY => self::ERROR,
  59365. LogLevel::ALERT => self::ERROR,
  59366. LogLevel::CRITICAL => self::ERROR,
  59367. LogLevel::ERROR => self::ERROR,
  59368. LogLevel::WARNING => self::INFO,
  59369. LogLevel::NOTICE => self::INFO,
  59370. LogLevel::INFO => self::INFO,
  59371. LogLevel::DEBUG => self::INFO,
  59372. ];
  59373. private $errored = false;
  59374. public function __construct(OutputInterface $output, array $verbosityLevelMap = [], array $formatLevelMap = [])
  59375. {
  59376. $this->output = $output;
  59377. $this->verbosityLevelMap = $verbosityLevelMap + $this->verbosityLevelMap;
  59378. $this->formatLevelMap = $formatLevelMap + $this->formatLevelMap;
  59379. }
  59380. public function log($level, $message, array $context = [])
  59381. {
  59382. if (!isset($this->verbosityLevelMap[$level])) {
  59383. throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
  59384. }
  59385. $output = $this->output;
  59386. if (self::ERROR === $this->formatLevelMap[$level]) {
  59387. if ($this->output instanceof ConsoleOutputInterface) {
  59388. $output = $output->getErrorOutput();
  59389. }
  59390. $this->errored = true;
  59391. }
  59392. if ($output->getVerbosity() >= $this->verbosityLevelMap[$level]) {
  59393. $output->writeln(sprintf('<%1$s>[%2$s] %3$s</%1$s>', $this->formatLevelMap[$level], $level, $this->interpolate($message, $context)), $this->verbosityLevelMap[$level]);
  59394. }
  59395. }
  59396. public function hasErrored()
  59397. {
  59398. return $this->errored;
  59399. }
  59400. private function interpolate(string $message, array $context): string
  59401. {
  59402. if (!str_contains($message, '{')) {
  59403. return $message;
  59404. }
  59405. $replacements = [];
  59406. foreach ($context as $key => $val) {
  59407. if (null === $val || is_scalar($val) || (\is_object($val) && method_exists($val, '__toString'))) {
  59408. $replacements["{{$key}}"] = $val;
  59409. } elseif ($val instanceof \DateTimeInterface) {
  59410. $replacements["{{$key}}"] = $val->format(\DateTime::RFC3339);
  59411. } elseif (\is_object($val)) {
  59412. $replacements["{{$key}}"] = '[object '.\get_class($val).']';
  59413. } else {
  59414. $replacements["{{$key}}"] = '['.\gettype($val).']';
  59415. }
  59416. }
  59417. return strtr($message, $replacements);
  59418. }
  59419. }
  59420. <?php
  59421. namespace Symfony\Component\Console\Output;
  59422. class BufferedOutput extends Output
  59423. {
  59424. private $buffer = '';
  59425. public function fetch()
  59426. {
  59427. $content = $this->buffer;
  59428. $this->buffer = '';
  59429. return $content;
  59430. }
  59431. protected function doWrite(string $message, bool $newline)
  59432. {
  59433. $this->buffer .= $message;
  59434. if ($newline) {
  59435. $this->buffer .= \PHP_EOL;
  59436. }
  59437. }
  59438. }
  59439. <?php
  59440. namespace Symfony\Component\Console\Output;
  59441. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  59442. class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
  59443. {
  59444. private $stderr;
  59445. private $consoleSectionOutputs = [];
  59446. public function __construct(int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = null, OutputFormatterInterface $formatter = null)
  59447. {
  59448. parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter);
  59449. if (null === $formatter) {
  59450. $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated);
  59451. return;
  59452. }
  59453. $actualDecorated = $this->isDecorated();
  59454. $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated, $this->getFormatter());
  59455. if (null === $decorated) {
  59456. $this->setDecorated($actualDecorated && $this->stderr->isDecorated());
  59457. }
  59458. }
  59459. public function section(): ConsoleSectionOutput
  59460. {
  59461. return new ConsoleSectionOutput($this->getStream(), $this->consoleSectionOutputs, $this->getVerbosity(), $this->isDecorated(), $this->getFormatter());
  59462. }
  59463. public function setDecorated(bool $decorated)
  59464. {
  59465. parent::setDecorated($decorated);
  59466. $this->stderr->setDecorated($decorated);
  59467. }
  59468. public function setFormatter(OutputFormatterInterface $formatter)
  59469. {
  59470. parent::setFormatter($formatter);
  59471. $this->stderr->setFormatter($formatter);
  59472. }
  59473. public function setVerbosity(int $level)
  59474. {
  59475. parent::setVerbosity($level);
  59476. $this->stderr->setVerbosity($level);
  59477. }
  59478. public function getErrorOutput()
  59479. {
  59480. return $this->stderr;
  59481. }
  59482. public function setErrorOutput(OutputInterface $error)
  59483. {
  59484. $this->stderr = $error;
  59485. }
  59486. protected function hasStdoutSupport()
  59487. {
  59488. return false === $this->isRunningOS400();
  59489. }
  59490. protected function hasStderrSupport()
  59491. {
  59492. return false === $this->isRunningOS400();
  59493. }
  59494. private function isRunningOS400(): bool
  59495. {
  59496. $checks = [
  59497. \function_exists('php_uname') ? php_uname('s') : '',
  59498. getenv('OSTYPE'),
  59499. \PHP_OS,
  59500. ];
  59501. return false !== stripos(implode(';', $checks), 'OS400');
  59502. }
  59503. private function openOutputStream()
  59504. {
  59505. if (!$this->hasStdoutSupport()) {
  59506. return fopen('php://output', 'w');
  59507. }
  59508. return \defined('STDOUT') ? \STDOUT : (@fopen('php://stdout', 'w') ?: fopen('php://output', 'w'));
  59509. }
  59510. private function openErrorStream()
  59511. {
  59512. if (!$this->hasStderrSupport()) {
  59513. return fopen('php://output', 'w');
  59514. }
  59515. return \defined('STDERR') ? \STDERR : (@fopen('php://stderr', 'w') ?: fopen('php://output', 'w'));
  59516. }
  59517. }
  59518. <?php
  59519. namespace Symfony\Component\Console\Output;
  59520. interface ConsoleOutputInterface extends OutputInterface
  59521. {
  59522. public function getErrorOutput();
  59523. public function setErrorOutput(OutputInterface $error);
  59524. public function section(): ConsoleSectionOutput;
  59525. }
  59526. <?php
  59527. namespace Symfony\Component\Console\Output;
  59528. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  59529. use Symfony\Component\Console\Helper\Helper;
  59530. use Symfony\Component\Console\Terminal;
  59531. class ConsoleSectionOutput extends StreamOutput
  59532. {
  59533. private $content = [];
  59534. private $lines = 0;
  59535. private $sections;
  59536. private $terminal;
  59537. public function __construct($stream, array &$sections, int $verbosity, bool $decorated, OutputFormatterInterface $formatter)
  59538. {
  59539. parent::__construct($stream, $verbosity, $decorated, $formatter);
  59540. array_unshift($sections, $this);
  59541. $this->sections = &$sections;
  59542. $this->terminal = new Terminal();
  59543. }
  59544. public function clear(int $lines = null)
  59545. {
  59546. if (empty($this->content) || !$this->isDecorated()) {
  59547. return;
  59548. }
  59549. if ($lines) {
  59550. array_splice($this->content, -($lines * 2));
  59551. } else {
  59552. $lines = $this->lines;
  59553. $this->content = [];
  59554. }
  59555. $this->lines -= $lines;
  59556. parent::doWrite($this->popStreamContentUntilCurrentSection($lines), false);
  59557. }
  59558. public function overwrite($message)
  59559. {
  59560. $this->clear();
  59561. $this->writeln($message);
  59562. }
  59563. public function getContent(): string
  59564. {
  59565. return implode('', $this->content);
  59566. }
  59567. public function addContent(string $input)
  59568. {
  59569. foreach (explode(\PHP_EOL, $input) as $lineContent) {
  59570. $this->lines += ceil($this->getDisplayLength($lineContent) / $this->terminal->getWidth()) ?: 1;
  59571. $this->content[] = $lineContent;
  59572. $this->content[] = \PHP_EOL;
  59573. }
  59574. }
  59575. protected function doWrite(string $message, bool $newline)
  59576. {
  59577. if (!$this->isDecorated()) {
  59578. parent::doWrite($message, $newline);
  59579. return;
  59580. }
  59581. $erasedContent = $this->popStreamContentUntilCurrentSection();
  59582. $this->addContent($message);
  59583. parent::doWrite($message, true);
  59584. parent::doWrite($erasedContent, false);
  59585. }
  59586. private function popStreamContentUntilCurrentSection(int $numberOfLinesToClearFromCurrentSection = 0): string
  59587. {
  59588. $numberOfLinesToClear = $numberOfLinesToClearFromCurrentSection;
  59589. $erasedContent = [];
  59590. foreach ($this->sections as $section) {
  59591. if ($section === $this) {
  59592. break;
  59593. }
  59594. $numberOfLinesToClear += $section->lines;
  59595. $erasedContent[] = $section->getContent();
  59596. }
  59597. if ($numberOfLinesToClear > 0) {
  59598. parent::doWrite(sprintf("\x1b[%dA", $numberOfLinesToClear), false);
  59599. parent::doWrite("\x1b[0J", false);
  59600. }
  59601. return implode('', array_reverse($erasedContent));
  59602. }
  59603. private function getDisplayLength(string $text): int
  59604. {
  59605. return Helper::width(Helper::removeDecoration($this->getFormatter(), str_replace("\t", ' ', $text)));
  59606. }
  59607. }
  59608. <?php
  59609. namespace Symfony\Component\Console\Output;
  59610. use Symfony\Component\Console\Formatter\NullOutputFormatter;
  59611. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  59612. class NullOutput implements OutputInterface
  59613. {
  59614. private $formatter;
  59615. public function setFormatter(OutputFormatterInterface $formatter)
  59616. {
  59617. }
  59618. public function getFormatter()
  59619. {
  59620. if ($this->formatter) {
  59621. return $this->formatter;
  59622. }
  59623. return $this->formatter = new NullOutputFormatter();
  59624. }
  59625. public function setDecorated(bool $decorated)
  59626. {
  59627. }
  59628. public function isDecorated()
  59629. {
  59630. return false;
  59631. }
  59632. public function setVerbosity(int $level)
  59633. {
  59634. }
  59635. public function getVerbosity()
  59636. {
  59637. return self::VERBOSITY_QUIET;
  59638. }
  59639. public function isQuiet()
  59640. {
  59641. return true;
  59642. }
  59643. public function isVerbose()
  59644. {
  59645. return false;
  59646. }
  59647. public function isVeryVerbose()
  59648. {
  59649. return false;
  59650. }
  59651. public function isDebug()
  59652. {
  59653. return false;
  59654. }
  59655. public function writeln($messages, int $options = self::OUTPUT_NORMAL)
  59656. {
  59657. }
  59658. public function write($messages, bool $newline = false, int $options = self::OUTPUT_NORMAL)
  59659. {
  59660. }
  59661. }
  59662. <?php
  59663. namespace Symfony\Component\Console\Output;
  59664. use Symfony\Component\Console\Formatter\OutputFormatter;
  59665. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  59666. abstract class Output implements OutputInterface
  59667. {
  59668. private $verbosity;
  59669. private $formatter;
  59670. public function __construct(?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, OutputFormatterInterface $formatter = null)
  59671. {
  59672. $this->verbosity = $verbosity ?? self::VERBOSITY_NORMAL;
  59673. $this->formatter = $formatter ?? new OutputFormatter();
  59674. $this->formatter->setDecorated($decorated);
  59675. }
  59676. public function setFormatter(OutputFormatterInterface $formatter)
  59677. {
  59678. $this->formatter = $formatter;
  59679. }
  59680. public function getFormatter()
  59681. {
  59682. return $this->formatter;
  59683. }
  59684. public function setDecorated(bool $decorated)
  59685. {
  59686. $this->formatter->setDecorated($decorated);
  59687. }
  59688. public function isDecorated()
  59689. {
  59690. return $this->formatter->isDecorated();
  59691. }
  59692. public function setVerbosity(int $level)
  59693. {
  59694. $this->verbosity = $level;
  59695. }
  59696. public function getVerbosity()
  59697. {
  59698. return $this->verbosity;
  59699. }
  59700. public function isQuiet()
  59701. {
  59702. return self::VERBOSITY_QUIET === $this->verbosity;
  59703. }
  59704. public function isVerbose()
  59705. {
  59706. return self::VERBOSITY_VERBOSE <= $this->verbosity;
  59707. }
  59708. public function isVeryVerbose()
  59709. {
  59710. return self::VERBOSITY_VERY_VERBOSE <= $this->verbosity;
  59711. }
  59712. public function isDebug()
  59713. {
  59714. return self::VERBOSITY_DEBUG <= $this->verbosity;
  59715. }
  59716. public function writeln($messages, int $options = self::OUTPUT_NORMAL)
  59717. {
  59718. $this->write($messages, true, $options);
  59719. }
  59720. public function write($messages, bool $newline = false, int $options = self::OUTPUT_NORMAL)
  59721. {
  59722. if (!is_iterable($messages)) {
  59723. $messages = [$messages];
  59724. }
  59725. $types = self::OUTPUT_NORMAL | self::OUTPUT_RAW | self::OUTPUT_PLAIN;
  59726. $type = $types & $options ?: self::OUTPUT_NORMAL;
  59727. $verbosities = self::VERBOSITY_QUIET | self::VERBOSITY_NORMAL | self::VERBOSITY_VERBOSE | self::VERBOSITY_VERY_VERBOSE | self::VERBOSITY_DEBUG;
  59728. $verbosity = $verbosities & $options ?: self::VERBOSITY_NORMAL;
  59729. if ($verbosity > $this->getVerbosity()) {
  59730. return;
  59731. }
  59732. foreach ($messages as $message) {
  59733. switch ($type) {
  59734. case OutputInterface::OUTPUT_NORMAL:
  59735. $message = $this->formatter->format($message);
  59736. break;
  59737. case OutputInterface::OUTPUT_RAW:
  59738. break;
  59739. case OutputInterface::OUTPUT_PLAIN:
  59740. $message = strip_tags($this->formatter->format($message));
  59741. break;
  59742. }
  59743. $this->doWrite($message ?? '', $newline);
  59744. }
  59745. }
  59746. abstract protected function doWrite(string $message, bool $newline);
  59747. }
  59748. <?php
  59749. namespace Symfony\Component\Console\Output;
  59750. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  59751. interface OutputInterface
  59752. {
  59753. public const VERBOSITY_QUIET = 16;
  59754. public const VERBOSITY_NORMAL = 32;
  59755. public const VERBOSITY_VERBOSE = 64;
  59756. public const VERBOSITY_VERY_VERBOSE = 128;
  59757. public const VERBOSITY_DEBUG = 256;
  59758. public const OUTPUT_NORMAL = 1;
  59759. public const OUTPUT_RAW = 2;
  59760. public const OUTPUT_PLAIN = 4;
  59761. public function write($messages, bool $newline = false, int $options = 0);
  59762. public function writeln($messages, int $options = 0);
  59763. public function setVerbosity(int $level);
  59764. public function getVerbosity();
  59765. public function isQuiet();
  59766. public function isVerbose();
  59767. public function isVeryVerbose();
  59768. public function isDebug();
  59769. public function setDecorated(bool $decorated);
  59770. public function isDecorated();
  59771. public function setFormatter(OutputFormatterInterface $formatter);
  59772. public function getFormatter();
  59773. }
  59774. <?php
  59775. namespace Symfony\Component\Console\Output;
  59776. use Symfony\Component\Console\Exception\InvalidArgumentException;
  59777. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  59778. class StreamOutput extends Output
  59779. {
  59780. private $stream;
  59781. public function __construct($stream, int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = null, OutputFormatterInterface $formatter = null)
  59782. {
  59783. if (!\is_resource($stream) || 'stream' !== get_resource_type($stream)) {
  59784. throw new InvalidArgumentException('The StreamOutput class needs a stream as its first argument.');
  59785. }
  59786. $this->stream = $stream;
  59787. if (null === $decorated) {
  59788. $decorated = $this->hasColorSupport();
  59789. }
  59790. parent::__construct($verbosity, $decorated, $formatter);
  59791. }
  59792. public function getStream()
  59793. {
  59794. return $this->stream;
  59795. }
  59796. protected function doWrite(string $message, bool $newline)
  59797. {
  59798. if ($newline) {
  59799. $message .= \PHP_EOL;
  59800. }
  59801. @fwrite($this->stream, $message);
  59802. fflush($this->stream);
  59803. }
  59804. protected function hasColorSupport()
  59805. {
  59806. if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) {
  59807. return false;
  59808. }
  59809. if ('Hyper' === getenv('TERM_PROGRAM')) {
  59810. return true;
  59811. }
  59812. if (\DIRECTORY_SEPARATOR === '\\') {
  59813. return (\function_exists('sapi_windows_vt100_support')
  59814. && @sapi_windows_vt100_support($this->stream))
  59815. || false !== getenv('ANSICON')
  59816. || 'ON' === getenv('ConEmuANSI')
  59817. || 'xterm' === getenv('TERM');
  59818. }
  59819. return stream_isatty($this->stream);
  59820. }
  59821. }
  59822. <?php
  59823. namespace Symfony\Component\Console\Output;
  59824. use Symfony\Component\Console\Exception\InvalidArgumentException;
  59825. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  59826. class TrimmedBufferOutput extends Output
  59827. {
  59828. private $maxLength;
  59829. private $buffer = '';
  59830. public function __construct(int $maxLength, ?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, OutputFormatterInterface $formatter = null)
  59831. {
  59832. if ($maxLength <= 0) {
  59833. throw new InvalidArgumentException(sprintf('"%s()" expects a strictly positive maxLength. Got %d.', __METHOD__, $maxLength));
  59834. }
  59835. parent::__construct($verbosity, $decorated, $formatter);
  59836. $this->maxLength = $maxLength;
  59837. }
  59838. public function fetch()
  59839. {
  59840. $content = $this->buffer;
  59841. $this->buffer = '';
  59842. return $content;
  59843. }
  59844. protected function doWrite(string $message, bool $newline)
  59845. {
  59846. $this->buffer .= $message;
  59847. if ($newline) {
  59848. $this->buffer .= \PHP_EOL;
  59849. }
  59850. $this->buffer = substr($this->buffer, 0 - $this->maxLength);
  59851. }
  59852. }
  59853. <?php
  59854. namespace Symfony\Component\Console\Question;
  59855. use Symfony\Component\Console\Exception\InvalidArgumentException;
  59856. class ChoiceQuestion extends Question
  59857. {
  59858. private $choices;
  59859. private $multiselect = false;
  59860. private $prompt = ' > ';
  59861. private $errorMessage = 'Value "%s" is invalid';
  59862. public function __construct(string $question, array $choices, $default = null)
  59863. {
  59864. if (!$choices) {
  59865. throw new \LogicException('Choice question must have at least 1 choice available.');
  59866. }
  59867. parent::__construct($question, $default);
  59868. $this->choices = $choices;
  59869. $this->setValidator($this->getDefaultValidator());
  59870. $this->setAutocompleterValues($choices);
  59871. }
  59872. public function getChoices()
  59873. {
  59874. return $this->choices;
  59875. }
  59876. public function setMultiselect(bool $multiselect)
  59877. {
  59878. $this->multiselect = $multiselect;
  59879. $this->setValidator($this->getDefaultValidator());
  59880. return $this;
  59881. }
  59882. public function isMultiselect()
  59883. {
  59884. return $this->multiselect;
  59885. }
  59886. public function getPrompt()
  59887. {
  59888. return $this->prompt;
  59889. }
  59890. public function setPrompt(string $prompt)
  59891. {
  59892. $this->prompt = $prompt;
  59893. return $this;
  59894. }
  59895. public function setErrorMessage(string $errorMessage)
  59896. {
  59897. $this->errorMessage = $errorMessage;
  59898. $this->setValidator($this->getDefaultValidator());
  59899. return $this;
  59900. }
  59901. private function getDefaultValidator(): callable
  59902. {
  59903. $choices = $this->choices;
  59904. $errorMessage = $this->errorMessage;
  59905. $multiselect = $this->multiselect;
  59906. $isAssoc = $this->isAssoc($choices);
  59907. return function ($selected) use ($choices, $errorMessage, $multiselect, $isAssoc) {
  59908. if ($multiselect) {
  59909. if (!preg_match('/^[^,]+(?:,[^,]+)*$/', (string) $selected, $matches)) {
  59910. throw new InvalidArgumentException(sprintf($errorMessage, $selected));
  59911. }
  59912. $selectedChoices = explode(',', (string) $selected);
  59913. } else {
  59914. $selectedChoices = [$selected];
  59915. }
  59916. if ($this->isTrimmable()) {
  59917. foreach ($selectedChoices as $k => $v) {
  59918. $selectedChoices[$k] = trim((string) $v);
  59919. }
  59920. }
  59921. $multiselectChoices = [];
  59922. foreach ($selectedChoices as $value) {
  59923. $results = [];
  59924. foreach ($choices as $key => $choice) {
  59925. if ($choice === $value) {
  59926. $results[] = $key;
  59927. }
  59928. }
  59929. if (\count($results) > 1) {
  59930. throw new InvalidArgumentException(sprintf('The provided answer is ambiguous. Value should be one of "%s".', implode('" or "', $results)));
  59931. }
  59932. $result = array_search($value, $choices);
  59933. if (!$isAssoc) {
  59934. if (false !== $result) {
  59935. $result = $choices[$result];
  59936. } elseif (isset($choices[$value])) {
  59937. $result = $choices[$value];
  59938. }
  59939. } elseif (false === $result && isset($choices[$value])) {
  59940. $result = $value;
  59941. }
  59942. if (false === $result) {
  59943. throw new InvalidArgumentException(sprintf($errorMessage, $value));
  59944. }
  59945. $multiselectChoices[] = $isAssoc ? (string) $result : $result;
  59946. }
  59947. if ($multiselect) {
  59948. return $multiselectChoices;
  59949. }
  59950. return current($multiselectChoices);
  59951. };
  59952. }
  59953. }
  59954. <?php
  59955. namespace Symfony\Component\Console\Question;
  59956. class ConfirmationQuestion extends Question
  59957. {
  59958. private $trueAnswerRegex;
  59959. public function __construct(string $question, bool $default = true, string $trueAnswerRegex = '/^y/i')
  59960. {
  59961. parent::__construct($question, $default);
  59962. $this->trueAnswerRegex = $trueAnswerRegex;
  59963. $this->setNormalizer($this->getDefaultNormalizer());
  59964. }
  59965. private function getDefaultNormalizer(): callable
  59966. {
  59967. $default = $this->getDefault();
  59968. $regex = $this->trueAnswerRegex;
  59969. return function ($answer) use ($default, $regex) {
  59970. if (\is_bool($answer)) {
  59971. return $answer;
  59972. }
  59973. $answerIsTrue = (bool) preg_match($regex, $answer);
  59974. if (false === $default) {
  59975. return $answer && $answerIsTrue;
  59976. }
  59977. return '' === $answer || $answerIsTrue;
  59978. };
  59979. }
  59980. }
  59981. <?php
  59982. namespace Symfony\Component\Console\Question;
  59983. use Symfony\Component\Console\Exception\InvalidArgumentException;
  59984. use Symfony\Component\Console\Exception\LogicException;
  59985. class Question
  59986. {
  59987. private $question;
  59988. private $attempts;
  59989. private $hidden = false;
  59990. private $hiddenFallback = true;
  59991. private $autocompleterCallback;
  59992. private $validator;
  59993. private $default;
  59994. private $normalizer;
  59995. private $trimmable = true;
  59996. private $multiline = false;
  59997. public function __construct(string $question, $default = null)
  59998. {
  59999. $this->question = $question;
  60000. $this->default = $default;
  60001. }
  60002. public function getQuestion()
  60003. {
  60004. return $this->question;
  60005. }
  60006. public function getDefault()
  60007. {
  60008. return $this->default;
  60009. }
  60010. public function isMultiline(): bool
  60011. {
  60012. return $this->multiline;
  60013. }
  60014. public function setMultiline(bool $multiline): self
  60015. {
  60016. $this->multiline = $multiline;
  60017. return $this;
  60018. }
  60019. public function isHidden()
  60020. {
  60021. return $this->hidden;
  60022. }
  60023. public function setHidden(bool $hidden)
  60024. {
  60025. if ($this->autocompleterCallback) {
  60026. throw new LogicException('A hidden question cannot use the autocompleter.');
  60027. }
  60028. $this->hidden = $hidden;
  60029. return $this;
  60030. }
  60031. public function isHiddenFallback()
  60032. {
  60033. return $this->hiddenFallback;
  60034. }
  60035. public function setHiddenFallback(bool $fallback)
  60036. {
  60037. $this->hiddenFallback = $fallback;
  60038. return $this;
  60039. }
  60040. public function getAutocompleterValues()
  60041. {
  60042. $callback = $this->getAutocompleterCallback();
  60043. return $callback ? $callback('') : null;
  60044. }
  60045. public function setAutocompleterValues(?iterable $values)
  60046. {
  60047. if (\is_array($values)) {
  60048. $values = $this->isAssoc($values) ? array_merge(array_keys($values), array_values($values)) : array_values($values);
  60049. $callback = static function () use ($values) {
  60050. return $values;
  60051. };
  60052. } elseif ($values instanceof \Traversable) {
  60053. $valueCache = null;
  60054. $callback = static function () use ($values, &$valueCache) {
  60055. return $valueCache ?? $valueCache = iterator_to_array($values, false);
  60056. };
  60057. } else {
  60058. $callback = null;
  60059. }
  60060. return $this->setAutocompleterCallback($callback);
  60061. }
  60062. public function getAutocompleterCallback(): ?callable
  60063. {
  60064. return $this->autocompleterCallback;
  60065. }
  60066. public function setAutocompleterCallback(callable $callback = null): self
  60067. {
  60068. if ($this->hidden && null !== $callback) {
  60069. throw new LogicException('A hidden question cannot use the autocompleter.');
  60070. }
  60071. $this->autocompleterCallback = $callback;
  60072. return $this;
  60073. }
  60074. public function setValidator(callable $validator = null)
  60075. {
  60076. $this->validator = $validator;
  60077. return $this;
  60078. }
  60079. public function getValidator()
  60080. {
  60081. return $this->validator;
  60082. }
  60083. public function setMaxAttempts(?int $attempts)
  60084. {
  60085. if (null !== $attempts && $attempts < 1) {
  60086. throw new InvalidArgumentException('Maximum number of attempts must be a positive value.');
  60087. }
  60088. $this->attempts = $attempts;
  60089. return $this;
  60090. }
  60091. public function getMaxAttempts()
  60092. {
  60093. return $this->attempts;
  60094. }
  60095. public function setNormalizer(callable $normalizer)
  60096. {
  60097. $this->normalizer = $normalizer;
  60098. return $this;
  60099. }
  60100. public function getNormalizer()
  60101. {
  60102. return $this->normalizer;
  60103. }
  60104. protected function isAssoc(array $array)
  60105. {
  60106. return (bool) \count(array_filter(array_keys($array), 'is_string'));
  60107. }
  60108. public function isTrimmable(): bool
  60109. {
  60110. return $this->trimmable;
  60111. }
  60112. public function setTrimmable(bool $trimmable): self
  60113. {
  60114. $this->trimmable = $trimmable;
  60115. return $this;
  60116. }
  60117. }
  60118. MZ��������ÿÿ��¸�������@�����������������������������������è���º�´ Í!¸LÍ!This program cannot be run in DOS mode.
  60119. $�������Æ,Í;§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��������à�  ��
  60120. ���������8������ ����@����������������������`�����?œ���@�����������������������������"��P����@�� �������������������P��p���!�����������������������������8!��@������������ ��Ø���������������������������.text��� ������
  60121. ����������������� ��`.rdata����� ���
  60122. �����������������@��@.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
  60123. 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
  60124. 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
  60125. 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">
  60126. <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
  60127. <security>
  60128. <requestedPrivileges>
  60129. <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
  60130. </requestedPrivileges>
  60131. </security>
  60132. </trustInfo>
  60133. <dependency>
  60134. <dependentAssembly>
  60135. <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
  60136. </dependentAssembly>
  60137. </dependency>
  60138. </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
  60139. namespace Symfony\Component\Console\SignalRegistry;
  60140. final class SignalRegistry
  60141. {
  60142. private $signalHandlers = [];
  60143. public function __construct()
  60144. {
  60145. if (\function_exists('pcntl_async_signals')) {
  60146. pcntl_async_signals(true);
  60147. }
  60148. }
  60149. public function register(int $signal, callable $signalHandler): void
  60150. {
  60151. if (!isset($this->signalHandlers[$signal])) {
  60152. $previousCallback = pcntl_signal_get_handler($signal);
  60153. if (\is_callable($previousCallback)) {
  60154. $this->signalHandlers[$signal][] = $previousCallback;
  60155. }
  60156. }
  60157. $this->signalHandlers[$signal][] = $signalHandler;
  60158. pcntl_signal($signal, [$this, 'handle']);
  60159. }
  60160. public static function isSupported(): bool
  60161. {
  60162. if (!\function_exists('pcntl_signal')) {
  60163. return false;
  60164. }
  60165. if (\in_array('pcntl_signal', explode(',', ini_get('disable_functions')))) {
  60166. return false;
  60167. }
  60168. return true;
  60169. }
  60170. public function handle(int $signal): void
  60171. {
  60172. $count = \count($this->signalHandlers[$signal]);
  60173. foreach ($this->signalHandlers[$signal] as $i => $signalHandler) {
  60174. $hasNext = $i !== $count - 1;
  60175. $signalHandler($signal, $hasNext);
  60176. }
  60177. }
  60178. }
  60179. <?php
  60180. namespace Symfony\Component\Console;
  60181. use Symfony\Component\Console\Command\Command;
  60182. use Symfony\Component\Console\Input\InputInterface;
  60183. use Symfony\Component\Console\Output\OutputInterface;
  60184. class SingleCommandApplication extends Command
  60185. {
  60186. private $version = 'UNKNOWN';
  60187. private $autoExit = true;
  60188. private $running = false;
  60189. public function setVersion(string $version): self
  60190. {
  60191. $this->version = $version;
  60192. return $this;
  60193. }
  60194. public function setAutoExit(bool $autoExit): self
  60195. {
  60196. $this->autoExit = $autoExit;
  60197. return $this;
  60198. }
  60199. public function run(InputInterface $input = null, OutputInterface $output = null): int
  60200. {
  60201. if ($this->running) {
  60202. return parent::run($input, $output);
  60203. }
  60204. $application = new Application($this->getName() ?: 'UNKNOWN', $this->version);
  60205. $application->setAutoExit($this->autoExit);
  60206. $this->setName($_SERVER['argv'][0]);
  60207. $application->add($this);
  60208. $application->setDefaultCommand($this->getName(), true);
  60209. $this->running = true;
  60210. try {
  60211. $ret = $application->run($input, $output);
  60212. } finally {
  60213. $this->running = false;
  60214. }
  60215. return $ret ?? 1;
  60216. }
  60217. }
  60218. <?php
  60219. namespace Symfony\Component\Console\Style;
  60220. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  60221. use Symfony\Component\Console\Helper\ProgressBar;
  60222. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  60223. use Symfony\Component\Console\Output\OutputInterface;
  60224. abstract class OutputStyle implements OutputInterface, StyleInterface
  60225. {
  60226. private $output;
  60227. public function __construct(OutputInterface $output)
  60228. {
  60229. $this->output = $output;
  60230. }
  60231. public function newLine(int $count = 1)
  60232. {
  60233. $this->output->write(str_repeat(\PHP_EOL, $count));
  60234. }
  60235. public function createProgressBar(int $max = 0)
  60236. {
  60237. return new ProgressBar($this->output, $max);
  60238. }
  60239. public function write($messages, bool $newline = false, int $type = self::OUTPUT_NORMAL)
  60240. {
  60241. $this->output->write($messages, $newline, $type);
  60242. }
  60243. public function writeln($messages, int $type = self::OUTPUT_NORMAL)
  60244. {
  60245. $this->output->writeln($messages, $type);
  60246. }
  60247. public function setVerbosity(int $level)
  60248. {
  60249. $this->output->setVerbosity($level);
  60250. }
  60251. public function getVerbosity()
  60252. {
  60253. return $this->output->getVerbosity();
  60254. }
  60255. public function setDecorated(bool $decorated)
  60256. {
  60257. $this->output->setDecorated($decorated);
  60258. }
  60259. public function isDecorated()
  60260. {
  60261. return $this->output->isDecorated();
  60262. }
  60263. public function setFormatter(OutputFormatterInterface $formatter)
  60264. {
  60265. $this->output->setFormatter($formatter);
  60266. }
  60267. public function getFormatter()
  60268. {
  60269. return $this->output->getFormatter();
  60270. }
  60271. public function isQuiet()
  60272. {
  60273. return $this->output->isQuiet();
  60274. }
  60275. public function isVerbose()
  60276. {
  60277. return $this->output->isVerbose();
  60278. }
  60279. public function isVeryVerbose()
  60280. {
  60281. return $this->output->isVeryVerbose();
  60282. }
  60283. public function isDebug()
  60284. {
  60285. return $this->output->isDebug();
  60286. }
  60287. protected function getErrorOutput()
  60288. {
  60289. if (!$this->output instanceof ConsoleOutputInterface) {
  60290. return $this->output;
  60291. }
  60292. return $this->output->getErrorOutput();
  60293. }
  60294. }
  60295. <?php
  60296. namespace Symfony\Component\Console\Style;
  60297. interface StyleInterface
  60298. {
  60299. public function title(string $message);
  60300. public function section(string $message);
  60301. public function listing(array $elements);
  60302. public function text($message);
  60303. public function success($message);
  60304. public function error($message);
  60305. public function warning($message);
  60306. public function note($message);
  60307. public function caution($message);
  60308. public function table(array $headers, array $rows);
  60309. public function ask(string $question, string $default = null, callable $validator = null);
  60310. public function askHidden(string $question, callable $validator = null);
  60311. public function confirm(string $question, bool $default = true);
  60312. public function choice(string $question, array $choices, $default = null);
  60313. public function newLine(int $count = 1);
  60314. public function progressStart(int $max = 0);
  60315. public function progressAdvance(int $step = 1);
  60316. public function progressFinish();
  60317. }
  60318. <?php
  60319. namespace Symfony\Component\Console\Style;
  60320. use Symfony\Component\Console\Exception\InvalidArgumentException;
  60321. use Symfony\Component\Console\Exception\RuntimeException;
  60322. use Symfony\Component\Console\Formatter\OutputFormatter;
  60323. use Symfony\Component\Console\Helper\Helper;
  60324. use Symfony\Component\Console\Helper\ProgressBar;
  60325. use Symfony\Component\Console\Helper\SymfonyQuestionHelper;
  60326. use Symfony\Component\Console\Helper\Table;
  60327. use Symfony\Component\Console\Helper\TableCell;
  60328. use Symfony\Component\Console\Helper\TableSeparator;
  60329. use Symfony\Component\Console\Input\InputInterface;
  60330. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  60331. use Symfony\Component\Console\Output\OutputInterface;
  60332. use Symfony\Component\Console\Output\TrimmedBufferOutput;
  60333. use Symfony\Component\Console\Question\ChoiceQuestion;
  60334. use Symfony\Component\Console\Question\ConfirmationQuestion;
  60335. use Symfony\Component\Console\Question\Question;
  60336. use Symfony\Component\Console\Terminal;
  60337. class SymfonyStyle extends OutputStyle
  60338. {
  60339. public const MAX_LINE_LENGTH = 120;
  60340. private $input;
  60341. private $output;
  60342. private $questionHelper;
  60343. private $progressBar;
  60344. private $lineLength;
  60345. private $bufferedOutput;
  60346. public function __construct(InputInterface $input, OutputInterface $output)
  60347. {
  60348. $this->input = $input;
  60349. $this->bufferedOutput = new TrimmedBufferOutput(\DIRECTORY_SEPARATOR === '\\' ? 4 : 2, $output->getVerbosity(), false, clone $output->getFormatter());
  60350. $width = (new Terminal())->getWidth() ?: self::MAX_LINE_LENGTH;
  60351. $this->lineLength = min($width - (int) (\DIRECTORY_SEPARATOR === '\\'), self::MAX_LINE_LENGTH);
  60352. parent::__construct($this->output = $output);
  60353. }
  60354. public function block($messages, string $type = null, string $style = null, string $prefix = ' ', bool $padding = false, bool $escape = true)
  60355. {
  60356. $messages = \is_array($messages) ? array_values($messages) : [$messages];
  60357. $this->autoPrependBlock();
  60358. $this->writeln($this->createBlock($messages, $type, $style, $prefix, $padding, $escape));
  60359. $this->newLine();
  60360. }
  60361. public function title(string $message)
  60362. {
  60363. $this->autoPrependBlock();
  60364. $this->writeln([
  60365. sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
  60366. sprintf('<comment>%s</>', str_repeat('=', Helper::width(Helper::removeDecoration($this->getFormatter(), $message)))),
  60367. ]);
  60368. $this->newLine();
  60369. }
  60370. public function section(string $message)
  60371. {
  60372. $this->autoPrependBlock();
  60373. $this->writeln([
  60374. sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
  60375. sprintf('<comment>%s</>', str_repeat('-', Helper::width(Helper::removeDecoration($this->getFormatter(), $message)))),
  60376. ]);
  60377. $this->newLine();
  60378. }
  60379. public function listing(array $elements)
  60380. {
  60381. $this->autoPrependText();
  60382. $elements = array_map(function ($element) {
  60383. return sprintf(' * %s', $element);
  60384. }, $elements);
  60385. $this->writeln($elements);
  60386. $this->newLine();
  60387. }
  60388. public function text($message)
  60389. {
  60390. $this->autoPrependText();
  60391. $messages = \is_array($message) ? array_values($message) : [$message];
  60392. foreach ($messages as $message) {
  60393. $this->writeln(sprintf(' %s', $message));
  60394. }
  60395. }
  60396. public function comment($message)
  60397. {
  60398. $this->block($message, null, null, '<fg=default;bg=default> // </>', false, false);
  60399. }
  60400. public function success($message)
  60401. {
  60402. $this->block($message, 'OK', 'fg=black;bg=green', ' ', true);
  60403. }
  60404. public function error($message)
  60405. {
  60406. $this->block($message, 'ERROR', 'fg=white;bg=red', ' ', true);
  60407. }
  60408. public function warning($message)
  60409. {
  60410. $this->block($message, 'WARNING', 'fg=black;bg=yellow', ' ', true);
  60411. }
  60412. public function note($message)
  60413. {
  60414. $this->block($message, 'NOTE', 'fg=yellow', ' ! ');
  60415. }
  60416. public function info($message)
  60417. {
  60418. $this->block($message, 'INFO', 'fg=green', ' ', true);
  60419. }
  60420. public function caution($message)
  60421. {
  60422. $this->block($message, 'CAUTION', 'fg=white;bg=red', ' ! ', true);
  60423. }
  60424. public function table(array $headers, array $rows)
  60425. {
  60426. $this->createTable()
  60427. ->setHeaders($headers)
  60428. ->setRows($rows)
  60429. ->render()
  60430. ;
  60431. $this->newLine();
  60432. }
  60433. public function horizontalTable(array $headers, array $rows)
  60434. {
  60435. $this->createTable()
  60436. ->setHorizontal(true)
  60437. ->setHeaders($headers)
  60438. ->setRows($rows)
  60439. ->render()
  60440. ;
  60441. $this->newLine();
  60442. }
  60443. public function definitionList(...$list)
  60444. {
  60445. $headers = [];
  60446. $row = [];
  60447. foreach ($list as $value) {
  60448. if ($value instanceof TableSeparator) {
  60449. $headers[] = $value;
  60450. $row[] = $value;
  60451. continue;
  60452. }
  60453. if (\is_string($value)) {
  60454. $headers[] = new TableCell($value, ['colspan' => 2]);
  60455. $row[] = null;
  60456. continue;
  60457. }
  60458. if (!\is_array($value)) {
  60459. throw new InvalidArgumentException('Value should be an array, string, or an instance of TableSeparator.');
  60460. }
  60461. $headers[] = key($value);
  60462. $row[] = current($value);
  60463. }
  60464. $this->horizontalTable($headers, [$row]);
  60465. }
  60466. public function ask(string $question, string $default = null, callable $validator = null)
  60467. {
  60468. $question = new Question($question, $default);
  60469. $question->setValidator($validator);
  60470. return $this->askQuestion($question);
  60471. }
  60472. public function askHidden(string $question, callable $validator = null)
  60473. {
  60474. $question = new Question($question);
  60475. $question->setHidden(true);
  60476. $question->setValidator($validator);
  60477. return $this->askQuestion($question);
  60478. }
  60479. public function confirm(string $question, bool $default = true)
  60480. {
  60481. return $this->askQuestion(new ConfirmationQuestion($question, $default));
  60482. }
  60483. public function choice(string $question, array $choices, $default = null)
  60484. {
  60485. if (null !== $default) {
  60486. $values = array_flip($choices);
  60487. $default = $values[$default] ?? $default;
  60488. }
  60489. return $this->askQuestion(new ChoiceQuestion($question, $choices, $default));
  60490. }
  60491. public function progressStart(int $max = 0)
  60492. {
  60493. $this->progressBar = $this->createProgressBar($max);
  60494. $this->progressBar->start();
  60495. }
  60496. public function progressAdvance(int $step = 1)
  60497. {
  60498. $this->getProgressBar()->advance($step);
  60499. }
  60500. public function progressFinish()
  60501. {
  60502. $this->getProgressBar()->finish();
  60503. $this->newLine(2);
  60504. $this->progressBar = null;
  60505. }
  60506. public function createProgressBar(int $max = 0)
  60507. {
  60508. $progressBar = parent::createProgressBar($max);
  60509. if ('\\' !== \DIRECTORY_SEPARATOR || 'Hyper' === getenv('TERM_PROGRAM')) {
  60510. $progressBar->setEmptyBarCharacter('â–‘');
  60511. $progressBar->setProgressCharacter('');
  60512. $progressBar->setBarCharacter('â–“');
  60513. }
  60514. return $progressBar;
  60515. }
  60516. public function progressIterate(iterable $iterable, int $max = null): iterable
  60517. {
  60518. yield from $this->createProgressBar()->iterate($iterable, $max);
  60519. $this->newLine(2);
  60520. }
  60521. public function askQuestion(Question $question)
  60522. {
  60523. if ($this->input->isInteractive()) {
  60524. $this->autoPrependBlock();
  60525. }
  60526. if (!$this->questionHelper) {
  60527. $this->questionHelper = new SymfonyQuestionHelper();
  60528. }
  60529. $answer = $this->questionHelper->ask($this->input, $this, $question);
  60530. if ($this->input->isInteractive()) {
  60531. $this->newLine();
  60532. $this->bufferedOutput->write("\n");
  60533. }
  60534. return $answer;
  60535. }
  60536. public function writeln($messages, int $type = self::OUTPUT_NORMAL)
  60537. {
  60538. if (!is_iterable($messages)) {
  60539. $messages = [$messages];
  60540. }
  60541. foreach ($messages as $message) {
  60542. parent::writeln($message, $type);
  60543. $this->writeBuffer($message, true, $type);
  60544. }
  60545. }
  60546. public function write($messages, bool $newline = false, int $type = self::OUTPUT_NORMAL)
  60547. {
  60548. if (!is_iterable($messages)) {
  60549. $messages = [$messages];
  60550. }
  60551. foreach ($messages as $message) {
  60552. parent::write($message, $newline, $type);
  60553. $this->writeBuffer($message, $newline, $type);
  60554. }
  60555. }
  60556. public function newLine(int $count = 1)
  60557. {
  60558. parent::newLine($count);
  60559. $this->bufferedOutput->write(str_repeat("\n", $count));
  60560. }
  60561. public function getErrorStyle()
  60562. {
  60563. return new self($this->input, $this->getErrorOutput());
  60564. }
  60565. public function createTable(): Table
  60566. {
  60567. $output = $this->output instanceof ConsoleOutputInterface ? $this->output->section() : $this->output;
  60568. $style = clone Table::getStyleDefinition('symfony-style-guide');
  60569. $style->setCellHeaderFormat('<info>%s</info>');
  60570. return (new Table($output))->setStyle($style);
  60571. }
  60572. private function getProgressBar(): ProgressBar
  60573. {
  60574. if (!$this->progressBar) {
  60575. throw new RuntimeException('The ProgressBar is not started.');
  60576. }
  60577. return $this->progressBar;
  60578. }
  60579. private function autoPrependBlock(): void
  60580. {
  60581. $chars = substr(str_replace(\PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2);
  60582. if (!isset($chars[0])) {
  60583. $this->newLine();
  60584. return;
  60585. }
  60586. $this->newLine(2 - substr_count($chars, "\n"));
  60587. }
  60588. private function autoPrependText(): void
  60589. {
  60590. $fetched = $this->bufferedOutput->fetch();
  60591. if (!str_ends_with($fetched, "\n")) {
  60592. $this->newLine();
  60593. }
  60594. }
  60595. private function writeBuffer(string $message, bool $newLine, int $type): void
  60596. {
  60597. $this->bufferedOutput->write($message, $newLine, $type);
  60598. }
  60599. private function createBlock(iterable $messages, string $type = null, string $style = null, string $prefix = ' ', bool $padding = false, bool $escape = false): array
  60600. {
  60601. $indentLength = 0;
  60602. $prefixLength = Helper::width(Helper::removeDecoration($this->getFormatter(), $prefix));
  60603. $lines = [];
  60604. if (null !== $type) {
  60605. $type = sprintf('[%s] ', $type);
  60606. $indentLength = \strlen($type);
  60607. $lineIndentation = str_repeat(' ', $indentLength);
  60608. }
  60609. foreach ($messages as $key => $message) {
  60610. if ($escape) {
  60611. $message = OutputFormatter::escape($message);
  60612. }
  60613. $decorationLength = Helper::width($message) - Helper::width(Helper::removeDecoration($this->getFormatter(), $message));
  60614. $messageLineLength = min($this->lineLength - $prefixLength - $indentLength + $decorationLength, $this->lineLength);
  60615. $messageLines = explode(\PHP_EOL, wordwrap($message, $messageLineLength, \PHP_EOL, true));
  60616. foreach ($messageLines as $messageLine) {
  60617. $lines[] = $messageLine;
  60618. }
  60619. if (\count($messages) > 1 && $key < \count($messages) - 1) {
  60620. $lines[] = '';
  60621. }
  60622. }
  60623. $firstLineIndex = 0;
  60624. if ($padding && $this->isDecorated()) {
  60625. $firstLineIndex = 1;
  60626. array_unshift($lines, '');
  60627. $lines[] = '';
  60628. }
  60629. foreach ($lines as $i => &$line) {
  60630. if (null !== $type) {
  60631. $line = $firstLineIndex === $i ? $type.$line : $lineIndentation.$line;
  60632. }
  60633. $line = $prefix.$line;
  60634. $line .= str_repeat(' ', max($this->lineLength - Helper::width(Helper::removeDecoration($this->getFormatter(), $line)), 0));
  60635. if ($style) {
  60636. $line = sprintf('<%s>%s</>', $style, $line);
  60637. }
  60638. }
  60639. return $lines;
  60640. }
  60641. }
  60642. <?php
  60643. namespace Symfony\Component\Console;
  60644. class Terminal
  60645. {
  60646. private static $width;
  60647. private static $height;
  60648. private static $stty;
  60649. public function getWidth()
  60650. {
  60651. $width = getenv('COLUMNS');
  60652. if (false !== $width) {
  60653. return (int) trim($width);
  60654. }
  60655. if (null === self::$width) {
  60656. self::initDimensions();
  60657. }
  60658. return self::$width ?: 80;
  60659. }
  60660. public function getHeight()
  60661. {
  60662. $height = getenv('LINES');
  60663. if (false !== $height) {
  60664. return (int) trim($height);
  60665. }
  60666. if (null === self::$height) {
  60667. self::initDimensions();
  60668. }
  60669. return self::$height ?: 50;
  60670. }
  60671. public static function hasSttyAvailable(): bool
  60672. {
  60673. if (null !== self::$stty) {
  60674. return self::$stty;
  60675. }
  60676. if (!\function_exists('exec')) {
  60677. return false;
  60678. }
  60679. exec('stty 2>&1', $output, $exitcode);
  60680. return self::$stty = 0 === $exitcode;
  60681. }
  60682. private static function initDimensions()
  60683. {
  60684. if ('\\' === \DIRECTORY_SEPARATOR) {
  60685. if (preg_match('/^(\d+)x(\d+)(?: \((\d+)x(\d+)\))?$/', trim(getenv('ANSICON')), $matches)) {
  60686. self::$width = (int) $matches[1];
  60687. self::$height = isset($matches[4]) ? (int) $matches[4] : (int) $matches[2];
  60688. } elseif (!self::hasVt100Support() && self::hasSttyAvailable()) {
  60689. self::initDimensionsUsingStty();
  60690. } elseif (null !== $dimensions = self::getConsoleMode()) {
  60691. self::$width = (int) $dimensions[0];
  60692. self::$height = (int) $dimensions[1];
  60693. }
  60694. } else {
  60695. self::initDimensionsUsingStty();
  60696. }
  60697. }
  60698. private static function hasVt100Support(): bool
  60699. {
  60700. return \function_exists('sapi_windows_vt100_support') && sapi_windows_vt100_support(fopen('php://stdout', 'w'));
  60701. }
  60702. private static function initDimensionsUsingStty()
  60703. {
  60704. if ($sttyString = self::getSttyColumns()) {
  60705. if (preg_match('/rows.(\d+);.columns.(\d+);/i', $sttyString, $matches)) {
  60706. self::$width = (int) $matches[2];
  60707. self::$height = (int) $matches[1];
  60708. } elseif (preg_match('/;.(\d+).rows;.(\d+).columns/i', $sttyString, $matches)) {
  60709. self::$width = (int) $matches[2];
  60710. self::$height = (int) $matches[1];
  60711. }
  60712. }
  60713. }
  60714. private static function getConsoleMode(): ?array
  60715. {
  60716. $info = self::readFromProcess('mode CON');
  60717. if (null === $info || !preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) {
  60718. return null;
  60719. }
  60720. return [(int) $matches[2], (int) $matches[1]];
  60721. }
  60722. private static function getSttyColumns(): ?string
  60723. {
  60724. return self::readFromProcess('stty -a | grep columns');
  60725. }
  60726. private static function readFromProcess(string $command): ?string
  60727. {
  60728. if (!\function_exists('proc_open')) {
  60729. return null;
  60730. }
  60731. $descriptorspec = [
  60732. 1 => ['pipe', 'w'],
  60733. 2 => ['pipe', 'w'],
  60734. ];
  60735. $process = proc_open($command, $descriptorspec, $pipes, null, null, ['suppress_errors' => true]);
  60736. if (!\is_resource($process)) {
  60737. return null;
  60738. }
  60739. $info = stream_get_contents($pipes[1]);
  60740. fclose($pipes[1]);
  60741. fclose($pipes[2]);
  60742. proc_close($process);
  60743. return $info;
  60744. }
  60745. }
  60746. <?php
  60747. namespace Symfony\Component\Console\Tester;
  60748. use Symfony\Component\Console\Application;
  60749. use Symfony\Component\Console\Input\ArrayInput;
  60750. class ApplicationTester
  60751. {
  60752. use TesterTrait;
  60753. private $application;
  60754. public function __construct(Application $application)
  60755. {
  60756. $this->application = $application;
  60757. }
  60758. public function run(array $input, array $options = [])
  60759. {
  60760. $this->input = new ArrayInput($input);
  60761. if (isset($options['interactive'])) {
  60762. $this->input->setInteractive($options['interactive']);
  60763. }
  60764. if ($this->inputs) {
  60765. $this->input->setStream(self::createStream($this->inputs));
  60766. }
  60767. $this->initOutput($options);
  60768. return $this->statusCode = $this->application->run($this->input, $this->output);
  60769. }
  60770. }
  60771. <?php
  60772. namespace Symfony\Component\Console\Tester;
  60773. use Symfony\Component\Console\Command\Command;
  60774. use Symfony\Component\Console\Completion\CompletionInput;
  60775. use Symfony\Component\Console\Completion\CompletionSuggestions;
  60776. class CommandCompletionTester
  60777. {
  60778. private $command;
  60779. public function __construct(Command $command)
  60780. {
  60781. $this->command = $command;
  60782. }
  60783. public function complete(array $input): array
  60784. {
  60785. $currentIndex = \count($input);
  60786. if ('' === end($input)) {
  60787. array_pop($input);
  60788. }
  60789. array_unshift($input, $this->command->getName());
  60790. $completionInput = CompletionInput::fromTokens($input, $currentIndex);
  60791. $completionInput->bind($this->command->getDefinition());
  60792. $suggestions = new CompletionSuggestions();
  60793. $this->command->complete($completionInput, $suggestions);
  60794. $options = [];
  60795. foreach ($suggestions->getOptionSuggestions() as $option) {
  60796. $options[] = '--'.$option->getName();
  60797. }
  60798. return array_map('strval', array_merge($options, $suggestions->getValueSuggestions()));
  60799. }
  60800. }
  60801. <?php
  60802. namespace Symfony\Component\Console\Tester;
  60803. use Symfony\Component\Console\Command\Command;
  60804. use Symfony\Component\Console\Input\ArrayInput;
  60805. class CommandTester
  60806. {
  60807. use TesterTrait;
  60808. private $command;
  60809. public function __construct(Command $command)
  60810. {
  60811. $this->command = $command;
  60812. }
  60813. public function execute(array $input, array $options = [])
  60814. {
  60815. if (!isset($input['command'])
  60816. && (null !== $application = $this->command->getApplication())
  60817. && $application->getDefinition()->hasArgument('command')
  60818. ) {
  60819. $input = array_merge(['command' => $this->command->getName()], $input);
  60820. }
  60821. $this->input = new ArrayInput($input);
  60822. $this->input->setStream(self::createStream($this->inputs));
  60823. if (isset($options['interactive'])) {
  60824. $this->input->setInteractive($options['interactive']);
  60825. }
  60826. if (!isset($options['decorated'])) {
  60827. $options['decorated'] = false;
  60828. }
  60829. $this->initOutput($options);
  60830. return $this->statusCode = $this->command->run($this->input, $this->output);
  60831. }
  60832. }
  60833. <?php
  60834. namespace Symfony\Component\Console\Tester\Constraint;
  60835. use PHPUnit\Framework\Constraint\Constraint;
  60836. use Symfony\Component\Console\Command\Command;
  60837. final class CommandIsSuccessful extends Constraint
  60838. {
  60839. public function toString(): string
  60840. {
  60841. return 'is successful';
  60842. }
  60843. protected function matches($other): bool
  60844. {
  60845. return Command::SUCCESS === $other;
  60846. }
  60847. protected function failureDescription($other): string
  60848. {
  60849. return 'the command '.$this->toString();
  60850. }
  60851. protected function additionalFailureDescription($other): string
  60852. {
  60853. $mapping = [
  60854. Command::FAILURE => 'Command failed.',
  60855. Command::INVALID => 'Command was invalid.',
  60856. ];
  60857. return $mapping[$other] ?? sprintf('Command returned exit status %d.', $other);
  60858. }
  60859. }
  60860. <?php
  60861. namespace Symfony\Component\Console\Tester;
  60862. use PHPUnit\Framework\Assert;
  60863. use Symfony\Component\Console\Input\InputInterface;
  60864. use Symfony\Component\Console\Output\ConsoleOutput;
  60865. use Symfony\Component\Console\Output\OutputInterface;
  60866. use Symfony\Component\Console\Output\StreamOutput;
  60867. use Symfony\Component\Console\Tester\Constraint\CommandIsSuccessful;
  60868. trait TesterTrait
  60869. {
  60870. private $output;
  60871. private $inputs = [];
  60872. private $captureStreamsIndependently = false;
  60873. private $input;
  60874. private $statusCode;
  60875. public function getDisplay(bool $normalize = false)
  60876. {
  60877. if (null === $this->output) {
  60878. throw new \RuntimeException('Output not initialized, did you execute the command before requesting the display?');
  60879. }
  60880. rewind($this->output->getStream());
  60881. $display = stream_get_contents($this->output->getStream());
  60882. if ($normalize) {
  60883. $display = str_replace(\PHP_EOL, "\n", $display);
  60884. }
  60885. return $display;
  60886. }
  60887. public function getErrorOutput(bool $normalize = false)
  60888. {
  60889. if (!$this->captureStreamsIndependently) {
  60890. throw new \LogicException('The error output is not available when the tester is run without "capture_stderr_separately" option set.');
  60891. }
  60892. rewind($this->output->getErrorOutput()->getStream());
  60893. $display = stream_get_contents($this->output->getErrorOutput()->getStream());
  60894. if ($normalize) {
  60895. $display = str_replace(\PHP_EOL, "\n", $display);
  60896. }
  60897. return $display;
  60898. }
  60899. public function getInput()
  60900. {
  60901. return $this->input;
  60902. }
  60903. public function getOutput()
  60904. {
  60905. return $this->output;
  60906. }
  60907. public function getStatusCode()
  60908. {
  60909. if (null === $this->statusCode) {
  60910. throw new \RuntimeException('Status code not initialized, did you execute the command before requesting the status code?');
  60911. }
  60912. return $this->statusCode;
  60913. }
  60914. public function assertCommandIsSuccessful(string $message = ''): void
  60915. {
  60916. Assert::assertThat($this->statusCode, new CommandIsSuccessful(), $message);
  60917. }
  60918. public function setInputs(array $inputs)
  60919. {
  60920. $this->inputs = $inputs;
  60921. return $this;
  60922. }
  60923. private function initOutput(array $options)
  60924. {
  60925. $this->captureStreamsIndependently = \array_key_exists('capture_stderr_separately', $options) && $options['capture_stderr_separately'];
  60926. if (!$this->captureStreamsIndependently) {
  60927. $this->output = new StreamOutput(fopen('php://memory', 'w', false));
  60928. if (isset($options['decorated'])) {
  60929. $this->output->setDecorated($options['decorated']);
  60930. }
  60931. if (isset($options['verbosity'])) {
  60932. $this->output->setVerbosity($options['verbosity']);
  60933. }
  60934. } else {
  60935. $this->output = new ConsoleOutput(
  60936. $options['verbosity'] ?? ConsoleOutput::VERBOSITY_NORMAL,
  60937. $options['decorated'] ?? null
  60938. );
  60939. $errorOutput = new StreamOutput(fopen('php://memory', 'w', false));
  60940. $errorOutput->setFormatter($this->output->getFormatter());
  60941. $errorOutput->setVerbosity($this->output->getVerbosity());
  60942. $errorOutput->setDecorated($this->output->isDecorated());
  60943. $reflectedOutput = new \ReflectionObject($this->output);
  60944. $strErrProperty = $reflectedOutput->getProperty('stderr');
  60945. $strErrProperty->setAccessible(true);
  60946. $strErrProperty->setValue($this->output, $errorOutput);
  60947. $reflectedParent = $reflectedOutput->getParentClass();
  60948. $streamProperty = $reflectedParent->getProperty('stream');
  60949. $streamProperty->setAccessible(true);
  60950. $streamProperty->setValue($this->output, fopen('php://memory', 'w', false));
  60951. }
  60952. }
  60953. private static function createStream(array $inputs)
  60954. {
  60955. $stream = fopen('php://memory', 'r+', false);
  60956. foreach ($inputs as $input) {
  60957. fwrite($stream, $input.\PHP_EOL);
  60958. }
  60959. rewind($stream);
  60960. return $stream;
  60961. }
  60962. }
  60963. Copyright (c) 2020-2021 Fabien Potencier
  60964. Permission is hereby granted, free of charge, to any person obtaining a copy
  60965. of this software and associated documentation files (the "Software"), to deal
  60966. in the Software without restriction, including without limitation the rights
  60967. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  60968. copies of the Software, and to permit persons to whom the Software is furnished
  60969. to do so, subject to the following conditions:
  60970. The above copyright notice and this permission notice shall be included in all
  60971. copies or substantial portions of the Software.
  60972. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  60973. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  60974. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  60975. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  60976. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  60977. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  60978. THE SOFTWARE.
  60979. <?php
  60980. if (!function_exists('trigger_deprecation')) {
  60981. function trigger_deprecation(string $package, string $version, string $message, ...$args): void
  60982. {
  60983. @trigger_error(($package || $version ? "Since $package $version: " : '').($args ? vsprintf($message, $args) : $message), \E_USER_DEPRECATED);
  60984. }
  60985. }
  60986. <?php
  60987. namespace Symfony\Component\Filesystem\Exception;
  60988. interface ExceptionInterface extends \Throwable
  60989. {
  60990. }
  60991. <?php
  60992. namespace Symfony\Component\Filesystem\Exception;
  60993. class FileNotFoundException extends IOException
  60994. {
  60995. public function __construct(string $message = null, int $code = 0, \Throwable $previous = null, string $path = null)
  60996. {
  60997. if (null === $message) {
  60998. if (null === $path) {
  60999. $message = 'File could not be found.';
  61000. } else {
  61001. $message = sprintf('File "%s" could not be found.', $path);
  61002. }
  61003. }
  61004. parent::__construct($message, $code, $previous, $path);
  61005. }
  61006. }
  61007. <?php
  61008. namespace Symfony\Component\Filesystem\Exception;
  61009. class IOException extends \RuntimeException implements IOExceptionInterface
  61010. {
  61011. private $path;
  61012. public function __construct(string $message, int $code = 0, \Throwable $previous = null, string $path = null)
  61013. {
  61014. $this->path = $path;
  61015. parent::__construct($message, $code, $previous);
  61016. }
  61017. public function getPath()
  61018. {
  61019. return $this->path;
  61020. }
  61021. }
  61022. <?php
  61023. namespace Symfony\Component\Filesystem\Exception;
  61024. interface IOExceptionInterface extends ExceptionInterface
  61025. {
  61026. public function getPath();
  61027. }
  61028. <?php
  61029. namespace Symfony\Component\Filesystem\Exception;
  61030. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  61031. {
  61032. }
  61033. <?php
  61034. namespace Symfony\Component\Filesystem\Exception;
  61035. class RuntimeException extends \RuntimeException implements ExceptionInterface
  61036. {
  61037. }
  61038. <?php
  61039. namespace Symfony\Component\Filesystem;
  61040. use Symfony\Component\Filesystem\Exception\FileNotFoundException;
  61041. use Symfony\Component\Filesystem\Exception\InvalidArgumentException;
  61042. use Symfony\Component\Filesystem\Exception\IOException;
  61043. class Filesystem
  61044. {
  61045. private static $lastError;
  61046. public function copy(string $originFile, string $targetFile, bool $overwriteNewerFiles = false)
  61047. {
  61048. $originIsLocal = stream_is_local($originFile) || 0 === stripos($originFile, 'file://');
  61049. if ($originIsLocal && !is_file($originFile)) {
  61050. throw new FileNotFoundException(sprintf('Failed to copy "%s" because file does not exist.', $originFile), 0, null, $originFile);
  61051. }
  61052. $this->mkdir(\dirname($targetFile));
  61053. $doCopy = true;
  61054. if (!$overwriteNewerFiles && null === parse_url($originFile, \PHP_URL_HOST) && is_file($targetFile)) {
  61055. $doCopy = filemtime($originFile) > filemtime($targetFile);
  61056. }
  61057. if ($doCopy) {
  61058. if (!$source = self::box('fopen', $originFile, 'r')) {
  61059. throw new IOException(sprintf('Failed to copy "%s" to "%s" because source file could not be opened for reading: ', $originFile, $targetFile).self::$lastError, 0, null, $originFile);
  61060. }
  61061. if (!$target = self::box('fopen', $targetFile, 'w', false, stream_context_create(['ftp' => ['overwrite' => true]]))) {
  61062. throw new IOException(sprintf('Failed to copy "%s" to "%s" because target file could not be opened for writing: ', $originFile, $targetFile).self::$lastError, 0, null, $originFile);
  61063. }
  61064. $bytesCopied = stream_copy_to_stream($source, $target);
  61065. fclose($source);
  61066. fclose($target);
  61067. unset($source, $target);
  61068. if (!is_file($targetFile)) {
  61069. throw new IOException(sprintf('Failed to copy "%s" to "%s".', $originFile, $targetFile), 0, null, $originFile);
  61070. }
  61071. if ($originIsLocal) {
  61072. self::box('chmod', $targetFile, fileperms($targetFile) | (fileperms($originFile) & 0111));
  61073. if ($bytesCopied !== $bytesOrigin = filesize($originFile)) {
  61074. 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);
  61075. }
  61076. }
  61077. }
  61078. }
  61079. public function mkdir($dirs, int $mode = 0777)
  61080. {
  61081. foreach ($this->toIterable($dirs) as $dir) {
  61082. if (is_dir($dir)) {
  61083. continue;
  61084. }
  61085. if (!self::box('mkdir', $dir, $mode, true) && !is_dir($dir)) {
  61086. throw new IOException(sprintf('Failed to create "%s": ', $dir).self::$lastError, 0, null, $dir);
  61087. }
  61088. }
  61089. }
  61090. public function exists($files)
  61091. {
  61092. $maxPathLength = \PHP_MAXPATHLEN - 2;
  61093. foreach ($this->toIterable($files) as $file) {
  61094. if (\strlen($file) > $maxPathLength) {
  61095. throw new IOException(sprintf('Could not check if file exist because path length exceeds %d characters.', $maxPathLength), 0, null, $file);
  61096. }
  61097. if (!file_exists($file)) {
  61098. return false;
  61099. }
  61100. }
  61101. return true;
  61102. }
  61103. public function touch($files, int $time = null, int $atime = null)
  61104. {
  61105. foreach ($this->toIterable($files) as $file) {
  61106. if (!($time ? self::box('touch', $file, $time, $atime) : self::box('touch', $file))) {
  61107. throw new IOException(sprintf('Failed to touch "%s": ', $file).self::$lastError, 0, null, $file);
  61108. }
  61109. }
  61110. }
  61111. public function remove($files)
  61112. {
  61113. if ($files instanceof \Traversable) {
  61114. $files = iterator_to_array($files, false);
  61115. } elseif (!\is_array($files)) {
  61116. $files = [$files];
  61117. }
  61118. self::doRemove($files, false);
  61119. }
  61120. private static function doRemove(array $files, bool $isRecursive): void
  61121. {
  61122. $files = array_reverse($files);
  61123. foreach ($files as $file) {
  61124. if (is_link($file)) {
  61125. if (!(self::box('unlink', $file) || '\\' !== \DIRECTORY_SEPARATOR || self::box('rmdir', $file)) && file_exists($file)) {
  61126. throw new IOException(sprintf('Failed to remove symlink "%s": ', $file).self::$lastError);
  61127. }
  61128. } elseif (is_dir($file)) {
  61129. if (!$isRecursive) {
  61130. $tmpName = \dirname(realpath($file)).'/.'.strrev(strtr(base64_encode(random_bytes(2)), '/=', '-.'));
  61131. if (file_exists($tmpName)) {
  61132. try {
  61133. self::doRemove([$tmpName], true);
  61134. } catch (IOException $e) {
  61135. }
  61136. }
  61137. if (!file_exists($tmpName) && self::box('rename', $file, $tmpName)) {
  61138. $origFile = $file;
  61139. $file = $tmpName;
  61140. } else {
  61141. $origFile = null;
  61142. }
  61143. }
  61144. $files = new \FilesystemIterator($file, \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS);
  61145. self::doRemove(iterator_to_array($files, true), true);
  61146. if (!self::box('rmdir', $file) && file_exists($file) && !$isRecursive) {
  61147. $lastError = self::$lastError;
  61148. if (null !== $origFile && self::box('rename', $file, $origFile)) {
  61149. $file = $origFile;
  61150. }
  61151. throw new IOException(sprintf('Failed to remove directory "%s": ', $file).$lastError);
  61152. }
  61153. } elseif (!self::box('unlink', $file) && (str_contains(self::$lastError, 'Permission denied') || file_exists($file))) {
  61154. throw new IOException(sprintf('Failed to remove file "%s": ', $file).self::$lastError);
  61155. }
  61156. }
  61157. }
  61158. public function chmod($files, int $mode, int $umask = 0000, bool $recursive = false)
  61159. {
  61160. foreach ($this->toIterable($files) as $file) {
  61161. if ((\PHP_VERSION_ID < 80000 || \is_int($mode)) && !self::box('chmod', $file, $mode & ~$umask)) {
  61162. throw new IOException(sprintf('Failed to chmod file "%s": ', $file).self::$lastError, 0, null, $file);
  61163. }
  61164. if ($recursive && is_dir($file) && !is_link($file)) {
  61165. $this->chmod(new \FilesystemIterator($file), $mode, $umask, true);
  61166. }
  61167. }
  61168. }
  61169. public function chown($files, $user, bool $recursive = false)
  61170. {
  61171. foreach ($this->toIterable($files) as $file) {
  61172. if ($recursive && is_dir($file) && !is_link($file)) {
  61173. $this->chown(new \FilesystemIterator($file), $user, true);
  61174. }
  61175. if (is_link($file) && \function_exists('lchown')) {
  61176. if (!self::box('lchown', $file, $user)) {
  61177. throw new IOException(sprintf('Failed to chown file "%s": ', $file).self::$lastError, 0, null, $file);
  61178. }
  61179. } else {
  61180. if (!self::box('chown', $file, $user)) {
  61181. throw new IOException(sprintf('Failed to chown file "%s": ', $file).self::$lastError, 0, null, $file);
  61182. }
  61183. }
  61184. }
  61185. }
  61186. public function chgrp($files, $group, bool $recursive = false)
  61187. {
  61188. foreach ($this->toIterable($files) as $file) {
  61189. if ($recursive && is_dir($file) && !is_link($file)) {
  61190. $this->chgrp(new \FilesystemIterator($file), $group, true);
  61191. }
  61192. if (is_link($file) && \function_exists('lchgrp')) {
  61193. if (!self::box('lchgrp', $file, $group)) {
  61194. throw new IOException(sprintf('Failed to chgrp file "%s": ', $file).self::$lastError, 0, null, $file);
  61195. }
  61196. } else {
  61197. if (!self::box('chgrp', $file, $group)) {
  61198. throw new IOException(sprintf('Failed to chgrp file "%s": ', $file).self::$lastError, 0, null, $file);
  61199. }
  61200. }
  61201. }
  61202. }
  61203. public function rename(string $origin, string $target, bool $overwrite = false)
  61204. {
  61205. if (!$overwrite && $this->isReadable($target)) {
  61206. throw new IOException(sprintf('Cannot rename because the target "%s" already exists.', $target), 0, null, $target);
  61207. }
  61208. if (!self::box('rename', $origin, $target)) {
  61209. if (is_dir($origin)) {
  61210. $this->mirror($origin, $target, null, ['override' => $overwrite, 'delete' => $overwrite]);
  61211. $this->remove($origin);
  61212. return;
  61213. }
  61214. throw new IOException(sprintf('Cannot rename "%s" to "%s": ', $origin, $target).self::$lastError, 0, null, $target);
  61215. }
  61216. }
  61217. private function isReadable(string $filename): bool
  61218. {
  61219. $maxPathLength = \PHP_MAXPATHLEN - 2;
  61220. if (\strlen($filename) > $maxPathLength) {
  61221. throw new IOException(sprintf('Could not check if file is readable because path length exceeds %d characters.', $maxPathLength), 0, null, $filename);
  61222. }
  61223. return is_readable($filename);
  61224. }
  61225. public function symlink(string $originDir, string $targetDir, bool $copyOnWindows = false)
  61226. {
  61227. if ('\\' === \DIRECTORY_SEPARATOR) {
  61228. $originDir = strtr($originDir, '/', '\\');
  61229. $targetDir = strtr($targetDir, '/', '\\');
  61230. if ($copyOnWindows) {
  61231. $this->mirror($originDir, $targetDir);
  61232. return;
  61233. }
  61234. }
  61235. $this->mkdir(\dirname($targetDir));
  61236. if (is_link($targetDir)) {
  61237. if (readlink($targetDir) === $originDir) {
  61238. return;
  61239. }
  61240. $this->remove($targetDir);
  61241. }
  61242. if (!self::box('symlink', $originDir, $targetDir)) {
  61243. $this->linkException($originDir, $targetDir, 'symbolic');
  61244. }
  61245. }
  61246. public function hardlink(string $originFile, $targetFiles)
  61247. {
  61248. if (!$this->exists($originFile)) {
  61249. throw new FileNotFoundException(null, 0, null, $originFile);
  61250. }
  61251. if (!is_file($originFile)) {
  61252. throw new FileNotFoundException(sprintf('Origin file "%s" is not a file.', $originFile));
  61253. }
  61254. foreach ($this->toIterable($targetFiles) as $targetFile) {
  61255. if (is_file($targetFile)) {
  61256. if (fileinode($originFile) === fileinode($targetFile)) {
  61257. continue;
  61258. }
  61259. $this->remove($targetFile);
  61260. }
  61261. if (!self::box('link', $originFile, $targetFile)) {
  61262. $this->linkException($originFile, $targetFile, 'hard');
  61263. }
  61264. }
  61265. }
  61266. private function linkException(string $origin, string $target, string $linkType)
  61267. {
  61268. if (self::$lastError) {
  61269. if ('\\' === \DIRECTORY_SEPARATOR && str_contains(self::$lastError, 'error code(1314)')) {
  61270. throw new IOException(sprintf('Unable to create "%s" link due to error code 1314: \'A required privilege is not held by the client\'. Do you have the required Administrator-rights?', $linkType), 0, null, $target);
  61271. }
  61272. }
  61273. throw new IOException(sprintf('Failed to create "%s" link from "%s" to "%s": ', $linkType, $origin, $target).self::$lastError, 0, null, $target);
  61274. }
  61275. public function readlink(string $path, bool $canonicalize = false)
  61276. {
  61277. if (!$canonicalize && !is_link($path)) {
  61278. return null;
  61279. }
  61280. if ($canonicalize) {
  61281. if (!$this->exists($path)) {
  61282. return null;
  61283. }
  61284. if ('\\' === \DIRECTORY_SEPARATOR && \PHP_VERSION_ID < 70410) {
  61285. $path = readlink($path);
  61286. }
  61287. return realpath($path);
  61288. }
  61289. if ('\\' === \DIRECTORY_SEPARATOR && \PHP_VERSION_ID < 70400) {
  61290. return realpath($path);
  61291. }
  61292. return readlink($path);
  61293. }
  61294. public function makePathRelative(string $endPath, string $startPath)
  61295. {
  61296. if (!$this->isAbsolutePath($startPath)) {
  61297. throw new InvalidArgumentException(sprintf('The start path "%s" is not absolute.', $startPath));
  61298. }
  61299. if (!$this->isAbsolutePath($endPath)) {
  61300. throw new InvalidArgumentException(sprintf('The end path "%s" is not absolute.', $endPath));
  61301. }
  61302. if ('\\' === \DIRECTORY_SEPARATOR) {
  61303. $endPath = str_replace('\\', '/', $endPath);
  61304. $startPath = str_replace('\\', '/', $startPath);
  61305. }
  61306. $splitDriveLetter = function ($path) {
  61307. return (\strlen($path) > 2 && ':' === $path[1] && '/' === $path[2] && ctype_alpha($path[0]))
  61308. ? [substr($path, 2), strtoupper($path[0])]
  61309. : [$path, null];
  61310. };
  61311. $splitPath = function ($path) {
  61312. $result = [];
  61313. foreach (explode('/', trim($path, '/')) as $segment) {
  61314. if ('..' === $segment) {
  61315. array_pop($result);
  61316. } elseif ('.' !== $segment && '' !== $segment) {
  61317. $result[] = $segment;
  61318. }
  61319. }
  61320. return $result;
  61321. };
  61322. [$endPath, $endDriveLetter] = $splitDriveLetter($endPath);
  61323. [$startPath, $startDriveLetter] = $splitDriveLetter($startPath);
  61324. $startPathArr = $splitPath($startPath);
  61325. $endPathArr = $splitPath($endPath);
  61326. if ($endDriveLetter && $startDriveLetter && $endDriveLetter != $startDriveLetter) {
  61327. return $endDriveLetter.':/'.($endPathArr ? implode('/', $endPathArr).'/' : '');
  61328. }
  61329. $index = 0;
  61330. while (isset($startPathArr[$index]) && isset($endPathArr[$index]) && $startPathArr[$index] === $endPathArr[$index]) {
  61331. ++$index;
  61332. }
  61333. if (1 === \count($startPathArr) && '' === $startPathArr[0]) {
  61334. $depth = 0;
  61335. } else {
  61336. $depth = \count($startPathArr) - $index;
  61337. }
  61338. $traverser = str_repeat('../', $depth);
  61339. $endPathRemainder = implode('/', \array_slice($endPathArr, $index));
  61340. $relativePath = $traverser.('' !== $endPathRemainder ? $endPathRemainder.'/' : '');
  61341. return '' === $relativePath ? './' : $relativePath;
  61342. }
  61343. public function mirror(string $originDir, string $targetDir, \Traversable $iterator = null, array $options = [])
  61344. {
  61345. $targetDir = rtrim($targetDir, '/\\');
  61346. $originDir = rtrim($originDir, '/\\');
  61347. $originDirLen = \strlen($originDir);
  61348. if (!$this->exists($originDir)) {
  61349. throw new IOException(sprintf('The origin directory specified "%s" was not found.', $originDir), 0, null, $originDir);
  61350. }
  61351. if ($this->exists($targetDir) && isset($options['delete']) && $options['delete']) {
  61352. $deleteIterator = $iterator;
  61353. if (null === $deleteIterator) {
  61354. $flags = \FilesystemIterator::SKIP_DOTS;
  61355. $deleteIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($targetDir, $flags), \RecursiveIteratorIterator::CHILD_FIRST);
  61356. }
  61357. $targetDirLen = \strlen($targetDir);
  61358. foreach ($deleteIterator as $file) {
  61359. $origin = $originDir.substr($file->getPathname(), $targetDirLen);
  61360. if (!$this->exists($origin)) {
  61361. $this->remove($file);
  61362. }
  61363. }
  61364. }
  61365. $copyOnWindows = $options['copy_on_windows'] ?? false;
  61366. if (null === $iterator) {
  61367. $flags = $copyOnWindows ? \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS : \FilesystemIterator::SKIP_DOTS;
  61368. $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($originDir, $flags), \RecursiveIteratorIterator::SELF_FIRST);
  61369. }
  61370. $this->mkdir($targetDir);
  61371. $filesCreatedWhileMirroring = [];
  61372. foreach ($iterator as $file) {
  61373. if ($file->getPathname() === $targetDir || $file->getRealPath() === $targetDir || isset($filesCreatedWhileMirroring[$file->getRealPath()])) {
  61374. continue;
  61375. }
  61376. $target = $targetDir.substr($file->getPathname(), $originDirLen);
  61377. $filesCreatedWhileMirroring[$target] = true;
  61378. if (!$copyOnWindows && is_link($file)) {
  61379. $this->symlink($file->getLinkTarget(), $target);
  61380. } elseif (is_dir($file)) {
  61381. $this->mkdir($target);
  61382. } elseif (is_file($file)) {
  61383. $this->copy($file, $target, $options['override'] ?? false);
  61384. } else {
  61385. throw new IOException(sprintf('Unable to guess "%s" file type.', $file), 0, null, $file);
  61386. }
  61387. }
  61388. }
  61389. public function isAbsolutePath(string $file)
  61390. {
  61391. return '' !== $file && (strspn($file, '/\\', 0, 1)
  61392. || (\strlen($file) > 3 && ctype_alpha($file[0])
  61393. && ':' === $file[1]
  61394. && strspn($file, '/\\', 2, 1)
  61395. )
  61396. || null !== parse_url($file, \PHP_URL_SCHEME)
  61397. );
  61398. }
  61399. public function tempnam(string $dir, string $prefix)
  61400. {
  61401. $suffix = \func_num_args() > 2 ? func_get_arg(2) : '';
  61402. [$scheme, $hierarchy] = $this->getSchemeAndHierarchy($dir);
  61403. if ((null === $scheme || 'file' === $scheme || 'gs' === $scheme) && '' === $suffix) {
  61404. if ($tmpFile = self::box('tempnam', $hierarchy, $prefix)) {
  61405. if (null !== $scheme && 'gs' !== $scheme) {
  61406. return $scheme.'://'.$tmpFile;
  61407. }
  61408. return $tmpFile;
  61409. }
  61410. throw new IOException('A temporary file could not be created: '.self::$lastError);
  61411. }
  61412. for ($i = 0; $i < 10; ++$i) {
  61413. $tmpFile = $dir.'/'.$prefix.uniqid(mt_rand(), true).$suffix;
  61414. if (!$handle = self::box('fopen', $tmpFile, 'x+')) {
  61415. continue;
  61416. }
  61417. self::box('fclose', $handle);
  61418. return $tmpFile;
  61419. }
  61420. throw new IOException('A temporary file could not be created: '.self::$lastError);
  61421. }
  61422. public function dumpFile(string $filename, $content)
  61423. {
  61424. if (\is_array($content)) {
  61425. throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be string or resource, array given.', __METHOD__));
  61426. }
  61427. $dir = \dirname($filename);
  61428. if (!is_dir($dir)) {
  61429. $this->mkdir($dir);
  61430. }
  61431. $tmpFile = $this->tempnam($dir, basename($filename));
  61432. try {
  61433. if (false === self::box('file_put_contents', $tmpFile, $content)) {
  61434. throw new IOException(sprintf('Failed to write file "%s": ', $filename).self::$lastError, 0, null, $filename);
  61435. }
  61436. self::box('chmod', $tmpFile, file_exists($filename) ? fileperms($filename) : 0666 & ~umask());
  61437. $this->rename($tmpFile, $filename, true);
  61438. } finally {
  61439. if (file_exists($tmpFile)) {
  61440. self::box('unlink', $tmpFile);
  61441. }
  61442. }
  61443. }
  61444. public function appendToFile(string $filename, $content)
  61445. {
  61446. if (\is_array($content)) {
  61447. throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be string or resource, array given.', __METHOD__));
  61448. }
  61449. $dir = \dirname($filename);
  61450. if (!is_dir($dir)) {
  61451. $this->mkdir($dir);
  61452. }
  61453. $lock = \func_num_args() > 2 && func_get_arg(2);
  61454. if (false === self::box('file_put_contents', $filename, $content, \FILE_APPEND | ($lock ? \LOCK_EX : 0))) {
  61455. throw new IOException(sprintf('Failed to write file "%s": ', $filename).self::$lastError, 0, null, $filename);
  61456. }
  61457. }
  61458. private function toIterable($files): iterable
  61459. {
  61460. return is_iterable($files) ? $files : [$files];
  61461. }
  61462. private function getSchemeAndHierarchy(string $filename): array
  61463. {
  61464. $components = explode('://', $filename, 2);
  61465. return 2 === \count($components) ? [$components[0], $components[1]] : [null, $components[0]];
  61466. }
  61467. private static function box(callable $func, ...$args)
  61468. {
  61469. self::$lastError = null;
  61470. set_error_handler(__CLASS__.'::handleError');
  61471. try {
  61472. return $func(...$args);
  61473. } finally {
  61474. restore_error_handler();
  61475. }
  61476. }
  61477. public static function handleError(int $type, string $msg)
  61478. {
  61479. self::$lastError = $msg;
  61480. }
  61481. }
  61482. Copyright (c) 2004-2022 Fabien Potencier
  61483. Permission is hereby granted, free of charge, to any person obtaining a copy
  61484. of this software and associated documentation files (the "Software"), to deal
  61485. in the Software without restriction, including without limitation the rights
  61486. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  61487. copies of the Software, and to permit persons to whom the Software is furnished
  61488. to do so, subject to the following conditions:
  61489. The above copyright notice and this permission notice shall be included in all
  61490. copies or substantial portions of the Software.
  61491. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  61492. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  61493. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  61494. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  61495. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  61496. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  61497. THE SOFTWARE.
  61498. <?php
  61499. namespace Symfony\Component\Filesystem;
  61500. use Symfony\Component\Filesystem\Exception\InvalidArgumentException;
  61501. use Symfony\Component\Filesystem\Exception\RuntimeException;
  61502. final class Path
  61503. {
  61504. private const CLEANUP_THRESHOLD = 1250;
  61505. private const CLEANUP_SIZE = 1000;
  61506. private static $buffer = [];
  61507. private static $bufferSize = 0;
  61508. public static function canonicalize(string $path): string
  61509. {
  61510. if ('' === $path) {
  61511. return '';
  61512. }
  61513. if (isset(self::$buffer[$path])) {
  61514. return self::$buffer[$path];
  61515. }
  61516. if ('~' === $path[0]) {
  61517. $path = self::getHomeDirectory().mb_substr($path, 1);
  61518. }
  61519. $path = self::normalize($path);
  61520. [$root, $pathWithoutRoot] = self::split($path);
  61521. $canonicalParts = self::findCanonicalParts($root, $pathWithoutRoot);
  61522. self::$buffer[$path] = $canonicalPath = $root.implode('/', $canonicalParts);
  61523. ++self::$bufferSize;
  61524. if (self::$bufferSize > self::CLEANUP_THRESHOLD) {
  61525. self::$buffer = \array_slice(self::$buffer, -self::CLEANUP_SIZE, null, true);
  61526. self::$bufferSize = self::CLEANUP_SIZE;
  61527. }
  61528. return $canonicalPath;
  61529. }
  61530. public static function normalize(string $path): string
  61531. {
  61532. return str_replace('\\', '/', $path);
  61533. }
  61534. public static function getDirectory(string $path): string
  61535. {
  61536. if ('' === $path) {
  61537. return '';
  61538. }
  61539. $path = self::canonicalize($path);
  61540. if (false !== ($schemeSeparatorPosition = mb_strpos($path, '://'))) {
  61541. $scheme = mb_substr($path, 0, $schemeSeparatorPosition + 3);
  61542. $path = mb_substr($path, $schemeSeparatorPosition + 3);
  61543. } else {
  61544. $scheme = '';
  61545. }
  61546. if (false === ($dirSeparatorPosition = strrpos($path, '/'))) {
  61547. return '';
  61548. }
  61549. if (0 === $dirSeparatorPosition) {
  61550. return $scheme.'/';
  61551. }
  61552. if (2 === $dirSeparatorPosition && ctype_alpha($path[0]) && ':' === $path[1]) {
  61553. return $scheme.mb_substr($path, 0, 3);
  61554. }
  61555. return $scheme.mb_substr($path, 0, $dirSeparatorPosition);
  61556. }
  61557. public static function getHomeDirectory(): string
  61558. {
  61559. if (getenv('HOME')) {
  61560. return self::canonicalize(getenv('HOME'));
  61561. }
  61562. if (getenv('HOMEDRIVE') && getenv('HOMEPATH')) {
  61563. return self::canonicalize(getenv('HOMEDRIVE').getenv('HOMEPATH'));
  61564. }
  61565. throw new RuntimeException("Cannot find the home directory path: Your environment or operating system isn't supported.");
  61566. }
  61567. public static function getRoot(string $path): string
  61568. {
  61569. if ('' === $path) {
  61570. return '';
  61571. }
  61572. if (false !== ($schemeSeparatorPosition = strpos($path, '://'))) {
  61573. $scheme = substr($path, 0, $schemeSeparatorPosition + 3);
  61574. $path = substr($path, $schemeSeparatorPosition + 3);
  61575. } else {
  61576. $scheme = '';
  61577. }
  61578. $firstCharacter = $path[0];
  61579. if ('/' === $firstCharacter || '\\' === $firstCharacter) {
  61580. return $scheme.'/';
  61581. }
  61582. $length = mb_strlen($path);
  61583. if ($length > 1 && ':' === $path[1] && ctype_alpha($firstCharacter)) {
  61584. if (2 === $length) {
  61585. return $scheme.$path.'/';
  61586. }
  61587. if ('/' === $path[2] || '\\' === $path[2]) {
  61588. return $scheme.$firstCharacter.$path[1].'/';
  61589. }
  61590. }
  61591. return '';
  61592. }
  61593. public static function getFilenameWithoutExtension(string $path, string $extension = null)
  61594. {
  61595. if ('' === $path) {
  61596. return '';
  61597. }
  61598. if (null !== $extension) {
  61599. return rtrim(basename($path, $extension), '.');
  61600. }
  61601. return pathinfo($path, \PATHINFO_FILENAME);
  61602. }
  61603. public static function getExtension(string $path, bool $forceLowerCase = false): string
  61604. {
  61605. if ('' === $path) {
  61606. return '';
  61607. }
  61608. $extension = pathinfo($path, \PATHINFO_EXTENSION);
  61609. if ($forceLowerCase) {
  61610. $extension = self::toLower($extension);
  61611. }
  61612. return $extension;
  61613. }
  61614. public static function hasExtension(string $path, $extensions = null, bool $ignoreCase = false): bool
  61615. {
  61616. if ('' === $path) {
  61617. return false;
  61618. }
  61619. $actualExtension = self::getExtension($path, $ignoreCase);
  61620. if ([] === $extensions || null === $extensions) {
  61621. return '' !== $actualExtension;
  61622. }
  61623. if (\is_string($extensions)) {
  61624. $extensions = [$extensions];
  61625. }
  61626. foreach ($extensions as $key => $extension) {
  61627. if ($ignoreCase) {
  61628. $extension = self::toLower($extension);
  61629. }
  61630. $extensions[$key] = ltrim($extension, '.');
  61631. }
  61632. return \in_array($actualExtension, $extensions, true);
  61633. }
  61634. public static function changeExtension(string $path, string $extension): string
  61635. {
  61636. if ('' === $path) {
  61637. return '';
  61638. }
  61639. $actualExtension = self::getExtension($path);
  61640. $extension = ltrim($extension, '.');
  61641. if ('/' === mb_substr($path, -1)) {
  61642. return $path;
  61643. }
  61644. if (empty($actualExtension)) {
  61645. return $path.('.' === mb_substr($path, -1) ? '' : '.').$extension;
  61646. }
  61647. return mb_substr($path, 0, -mb_strlen($actualExtension)).$extension;
  61648. }
  61649. public static function isAbsolute(string $path): bool
  61650. {
  61651. if ('' === $path) {
  61652. return false;
  61653. }
  61654. if (false !== ($schemeSeparatorPosition = mb_strpos($path, '://'))) {
  61655. $path = mb_substr($path, $schemeSeparatorPosition + 3);
  61656. }
  61657. $firstCharacter = $path[0];
  61658. if ('/' === $firstCharacter || '\\' === $firstCharacter) {
  61659. return true;
  61660. }
  61661. if (mb_strlen($path) > 1 && ctype_alpha($firstCharacter) && ':' === $path[1]) {
  61662. if (2 === mb_strlen($path)) {
  61663. return true;
  61664. }
  61665. if ('/' === $path[2] || '\\' === $path[2]) {
  61666. return true;
  61667. }
  61668. }
  61669. return false;
  61670. }
  61671. public static function isRelative(string $path): bool
  61672. {
  61673. return !self::isAbsolute($path);
  61674. }
  61675. public static function makeAbsolute(string $path, string $basePath): string
  61676. {
  61677. if ('' === $basePath) {
  61678. throw new InvalidArgumentException(sprintf('The base path must be a non-empty string. Got: "%s".', $basePath));
  61679. }
  61680. if (!self::isAbsolute($basePath)) {
  61681. throw new InvalidArgumentException(sprintf('The base path "%s" is not an absolute path.', $basePath));
  61682. }
  61683. if (self::isAbsolute($path)) {
  61684. return self::canonicalize($path);
  61685. }
  61686. if (false !== ($schemeSeparatorPosition = mb_strpos($basePath, '://'))) {
  61687. $scheme = mb_substr($basePath, 0, $schemeSeparatorPosition + 3);
  61688. $basePath = mb_substr($basePath, $schemeSeparatorPosition + 3);
  61689. } else {
  61690. $scheme = '';
  61691. }
  61692. return $scheme.self::canonicalize(rtrim($basePath, '/\\').'/'.$path);
  61693. }
  61694. public static function makeRelative(string $path, string $basePath): string
  61695. {
  61696. $path = self::canonicalize($path);
  61697. $basePath = self::canonicalize($basePath);
  61698. [$root, $relativePath] = self::split($path);
  61699. [$baseRoot, $relativeBasePath] = self::split($basePath);
  61700. if ('' === $root && '' !== $baseRoot) {
  61701. if ('' === $relativeBasePath) {
  61702. $relativePath = ltrim($relativePath, './\\');
  61703. }
  61704. return $relativePath;
  61705. }
  61706. if ('' !== $root && '' === $baseRoot) {
  61707. throw new InvalidArgumentException(sprintf('The absolute path "%s" cannot be made relative to the relative path "%s". You should provide an absolute base path instead.', $path, $basePath));
  61708. }
  61709. if ($baseRoot && $root !== $baseRoot) {
  61710. throw new InvalidArgumentException(sprintf('The path "%s" cannot be made relative to "%s", because they have different roots ("%s" and "%s").', $path, $basePath, $root, $baseRoot));
  61711. }
  61712. if ('' === $relativeBasePath) {
  61713. return $relativePath;
  61714. }
  61715. $parts = explode('/', $relativePath);
  61716. $baseParts = explode('/', $relativeBasePath);
  61717. $dotDotPrefix = '';
  61718. $match = true;
  61719. foreach ($baseParts as $index => $basePart) {
  61720. if ($match && isset($parts[$index]) && $basePart === $parts[$index]) {
  61721. unset($parts[$index]);
  61722. continue;
  61723. }
  61724. $match = false;
  61725. $dotDotPrefix .= '../';
  61726. }
  61727. return rtrim($dotDotPrefix.implode('/', $parts), '/');
  61728. }
  61729. public static function isLocal(string $path): bool
  61730. {
  61731. return '' !== $path && false === mb_strpos($path, '://');
  61732. }
  61733. public static function getLongestCommonBasePath(string ...$paths): ?string
  61734. {
  61735. [$bpRoot, $basePath] = self::split(self::canonicalize(reset($paths)));
  61736. for (next($paths); null !== key($paths) && '' !== $basePath; next($paths)) {
  61737. [$root, $path] = self::split(self::canonicalize(current($paths)));
  61738. if ($root !== $bpRoot) {
  61739. return null;
  61740. }
  61741. while (true) {
  61742. if ('.' === $basePath) {
  61743. $basePath = '';
  61744. continue 2;
  61745. }
  61746. if (0 === mb_strpos($path.'/', $basePath.'/')) {
  61747. continue 2;
  61748. }
  61749. $basePath = \dirname($basePath);
  61750. }
  61751. }
  61752. return $bpRoot.$basePath;
  61753. }
  61754. public static function join(string ...$paths): string
  61755. {
  61756. $finalPath = null;
  61757. $wasScheme = false;
  61758. foreach ($paths as $path) {
  61759. if ('' === $path) {
  61760. continue;
  61761. }
  61762. if (null === $finalPath) {
  61763. $finalPath = $path;
  61764. $wasScheme = (false !== mb_strpos($path, '://'));
  61765. continue;
  61766. }
  61767. if (!\in_array(mb_substr($finalPath, -1), ['/', '\\'])) {
  61768. $finalPath .= '/';
  61769. }
  61770. $finalPath .= $wasScheme ? $path : ltrim($path, '/');
  61771. $wasScheme = false;
  61772. }
  61773. if (null === $finalPath) {
  61774. return '';
  61775. }
  61776. return self::canonicalize($finalPath);
  61777. }
  61778. public static function isBasePath(string $basePath, string $ofPath): bool
  61779. {
  61780. $basePath = self::canonicalize($basePath);
  61781. $ofPath = self::canonicalize($ofPath);
  61782. return 0 === mb_strpos($ofPath.'/', rtrim($basePath, '/').'/');
  61783. }
  61784. private static function findCanonicalParts(string $root, string $pathWithoutRoot): array
  61785. {
  61786. $parts = explode('/', $pathWithoutRoot);
  61787. $canonicalParts = [];
  61788. foreach ($parts as $part) {
  61789. if ('.' === $part || '' === $part) {
  61790. continue;
  61791. }
  61792. if ('..' === $part && \count($canonicalParts) > 0 && '..' !== $canonicalParts[\count($canonicalParts) - 1]) {
  61793. array_pop($canonicalParts);
  61794. continue;
  61795. }
  61796. if ('..' !== $part || '' === $root) {
  61797. $canonicalParts[] = $part;
  61798. }
  61799. }
  61800. return $canonicalParts;
  61801. }
  61802. private static function split(string $path): array
  61803. {
  61804. if ('' === $path) {
  61805. return ['', ''];
  61806. }
  61807. if (false !== ($schemeSeparatorPosition = mb_strpos($path, '://'))) {
  61808. $root = mb_substr($path, 0, $schemeSeparatorPosition + 3);
  61809. $path = mb_substr($path, $schemeSeparatorPosition + 3);
  61810. } else {
  61811. $root = '';
  61812. }
  61813. $length = mb_strlen($path);
  61814. if (0 === mb_strpos($path, '/')) {
  61815. $root .= '/';
  61816. $path = $length > 1 ? mb_substr($path, 1) : '';
  61817. } elseif ($length > 1 && ctype_alpha($path[0]) && ':' === $path[1]) {
  61818. if (2 === $length) {
  61819. $root .= $path.'/';
  61820. $path = '';
  61821. } elseif ('/' === $path[2]) {
  61822. $root .= mb_substr($path, 0, 3);
  61823. $path = $length > 3 ? mb_substr($path, 3) : '';
  61824. }
  61825. }
  61826. return [$root, $path];
  61827. }
  61828. private static function toLower(string $string): string
  61829. {
  61830. if (false !== $encoding = mb_detect_encoding($string)) {
  61831. return mb_strtolower($string, $encoding);
  61832. }
  61833. return strtolower($string, $encoding);
  61834. }
  61835. private function __construct()
  61836. {
  61837. }
  61838. }
  61839. <?php
  61840. namespace Symfony\Component\Finder\Comparator;
  61841. class Comparator
  61842. {
  61843. private $target;
  61844. private $operator = '==';
  61845. public function __construct(string $target = null, string $operator = '==')
  61846. {
  61847. if (null === $target) {
  61848. trigger_deprecation('symfony/finder', '5.4', 'Constructing a "%s" without setting "$target" is deprecated.', __CLASS__);
  61849. }
  61850. $this->target = $target;
  61851. $this->doSetOperator($operator);
  61852. }
  61853. public function getTarget()
  61854. {
  61855. if (null === $this->target) {
  61856. trigger_deprecation('symfony/finder', '5.4', 'Calling "%s" without initializing the target is deprecated.', __METHOD__);
  61857. }
  61858. return $this->target;
  61859. }
  61860. public function setTarget(string $target)
  61861. {
  61862. trigger_deprecation('symfony/finder', '5.4', '"%s" is deprecated. Set the target via the constructor instead.', __METHOD__);
  61863. $this->target = $target;
  61864. }
  61865. public function getOperator()
  61866. {
  61867. return $this->operator;
  61868. }
  61869. public function setOperator(string $operator)
  61870. {
  61871. trigger_deprecation('symfony/finder', '5.4', '"%s" is deprecated. Set the operator via the constructor instead.', __METHOD__);
  61872. $this->doSetOperator('' === $operator ? '==' : $operator);
  61873. }
  61874. public function test($test)
  61875. {
  61876. if (null === $this->target) {
  61877. trigger_deprecation('symfony/finder', '5.4', 'Calling "%s" without initializing the target is deprecated.', __METHOD__);
  61878. }
  61879. switch ($this->operator) {
  61880. case '>':
  61881. return $test > $this->target;
  61882. case '>=':
  61883. return $test >= $this->target;
  61884. case '<':
  61885. return $test < $this->target;
  61886. case '<=':
  61887. return $test <= $this->target;
  61888. case '!=':
  61889. return $test != $this->target;
  61890. }
  61891. return $test == $this->target;
  61892. }
  61893. private function doSetOperator(string $operator): void
  61894. {
  61895. if (!\in_array($operator, ['>', '<', '>=', '<=', '==', '!='])) {
  61896. throw new \InvalidArgumentException(sprintf('Invalid operator "%s".', $operator));
  61897. }
  61898. $this->operator = $operator;
  61899. }
  61900. }
  61901. <?php
  61902. namespace Symfony\Component\Finder\Comparator;
  61903. class DateComparator extends Comparator
  61904. {
  61905. public function __construct(string $test)
  61906. {
  61907. if (!preg_match('#^\s*(==|!=|[<>]=?|after|since|before|until)?\s*(.+?)\s*$#i', $test, $matches)) {
  61908. throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a date test.', $test));
  61909. }
  61910. try {
  61911. $date = new \DateTime($matches[2]);
  61912. $target = $date->format('U');
  61913. } catch (\Exception $e) {
  61914. throw new \InvalidArgumentException(sprintf('"%s" is not a valid date.', $matches[2]));
  61915. }
  61916. $operator = $matches[1] ?? '==';
  61917. if ('since' === $operator || 'after' === $operator) {
  61918. $operator = '>';
  61919. }
  61920. if ('until' === $operator || 'before' === $operator) {
  61921. $operator = '<';
  61922. }
  61923. parent::__construct($target, $operator);
  61924. }
  61925. }
  61926. <?php
  61927. namespace Symfony\Component\Finder\Comparator;
  61928. class NumberComparator extends Comparator
  61929. {
  61930. public function __construct(?string $test)
  61931. {
  61932. if (null === $test || !preg_match('#^\s*(==|!=|[<>]=?)?\s*([0-9\.]+)\s*([kmg]i?)?\s*$#i', $test, $matches)) {
  61933. throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a number test.', $test ?? 'null'));
  61934. }
  61935. $target = $matches[2];
  61936. if (!is_numeric($target)) {
  61937. throw new \InvalidArgumentException(sprintf('Invalid number "%s".', $target));
  61938. }
  61939. if (isset($matches[3])) {
  61940. switch (strtolower($matches[3])) {
  61941. case 'k':
  61942. $target *= 1000;
  61943. break;
  61944. case 'ki':
  61945. $target *= 1024;
  61946. break;
  61947. case 'm':
  61948. $target *= 1000000;
  61949. break;
  61950. case 'mi':
  61951. $target *= 1024 * 1024;
  61952. break;
  61953. case 'g':
  61954. $target *= 1000000000;
  61955. break;
  61956. case 'gi':
  61957. $target *= 1024 * 1024 * 1024;
  61958. break;
  61959. }
  61960. }
  61961. parent::__construct($target, $matches[1] ?: '==');
  61962. }
  61963. }
  61964. <?php
  61965. namespace Symfony\Component\Finder\Exception;
  61966. class AccessDeniedException extends \UnexpectedValueException
  61967. {
  61968. }
  61969. <?php
  61970. namespace Symfony\Component\Finder\Exception;
  61971. class DirectoryNotFoundException extends \InvalidArgumentException
  61972. {
  61973. }
  61974. <?php
  61975. namespace Symfony\Component\Finder;
  61976. use Symfony\Component\Finder\Comparator\DateComparator;
  61977. use Symfony\Component\Finder\Comparator\NumberComparator;
  61978. use Symfony\Component\Finder\Exception\DirectoryNotFoundException;
  61979. use Symfony\Component\Finder\Iterator\CustomFilterIterator;
  61980. use Symfony\Component\Finder\Iterator\DateRangeFilterIterator;
  61981. use Symfony\Component\Finder\Iterator\DepthRangeFilterIterator;
  61982. use Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator;
  61983. use Symfony\Component\Finder\Iterator\FilecontentFilterIterator;
  61984. use Symfony\Component\Finder\Iterator\FilenameFilterIterator;
  61985. use Symfony\Component\Finder\Iterator\LazyIterator;
  61986. use Symfony\Component\Finder\Iterator\SizeRangeFilterIterator;
  61987. use Symfony\Component\Finder\Iterator\SortableIterator;
  61988. class Finder implements \IteratorAggregate, \Countable
  61989. {
  61990. public const IGNORE_VCS_FILES = 1;
  61991. public const IGNORE_DOT_FILES = 2;
  61992. public const IGNORE_VCS_IGNORED_FILES = 4;
  61993. private $mode = 0;
  61994. private $names = [];
  61995. private $notNames = [];
  61996. private $exclude = [];
  61997. private $filters = [];
  61998. private $depths = [];
  61999. private $sizes = [];
  62000. private $followLinks = false;
  62001. private $reverseSorting = false;
  62002. private $sort = false;
  62003. private $ignore = 0;
  62004. private $dirs = [];
  62005. private $dates = [];
  62006. private $iterators = [];
  62007. private $contains = [];
  62008. private $notContains = [];
  62009. private $paths = [];
  62010. private $notPaths = [];
  62011. private $ignoreUnreadableDirs = false;
  62012. private static $vcsPatterns = ['.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg'];
  62013. public function __construct()
  62014. {
  62015. $this->ignore = static::IGNORE_VCS_FILES | static::IGNORE_DOT_FILES;
  62016. }
  62017. public static function create()
  62018. {
  62019. return new static();
  62020. }
  62021. public function directories()
  62022. {
  62023. $this->mode = Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES;
  62024. return $this;
  62025. }
  62026. public function files()
  62027. {
  62028. $this->mode = Iterator\FileTypeFilterIterator::ONLY_FILES;
  62029. return $this;
  62030. }
  62031. public function depth($levels)
  62032. {
  62033. foreach ((array) $levels as $level) {
  62034. $this->depths[] = new Comparator\NumberComparator($level);
  62035. }
  62036. return $this;
  62037. }
  62038. public function date($dates)
  62039. {
  62040. foreach ((array) $dates as $date) {
  62041. $this->dates[] = new Comparator\DateComparator($date);
  62042. }
  62043. return $this;
  62044. }
  62045. public function name($patterns)
  62046. {
  62047. $this->names = array_merge($this->names, (array) $patterns);
  62048. return $this;
  62049. }
  62050. public function notName($patterns)
  62051. {
  62052. $this->notNames = array_merge($this->notNames, (array) $patterns);
  62053. return $this;
  62054. }
  62055. public function contains($patterns)
  62056. {
  62057. $this->contains = array_merge($this->contains, (array) $patterns);
  62058. return $this;
  62059. }
  62060. public function notContains($patterns)
  62061. {
  62062. $this->notContains = array_merge($this->notContains, (array) $patterns);
  62063. return $this;
  62064. }
  62065. public function path($patterns)
  62066. {
  62067. $this->paths = array_merge($this->paths, (array) $patterns);
  62068. return $this;
  62069. }
  62070. public function notPath($patterns)
  62071. {
  62072. $this->notPaths = array_merge($this->notPaths, (array) $patterns);
  62073. return $this;
  62074. }
  62075. public function size($sizes)
  62076. {
  62077. foreach ((array) $sizes as $size) {
  62078. $this->sizes[] = new Comparator\NumberComparator($size);
  62079. }
  62080. return $this;
  62081. }
  62082. public function exclude($dirs)
  62083. {
  62084. $this->exclude = array_merge($this->exclude, (array) $dirs);
  62085. return $this;
  62086. }
  62087. public function ignoreDotFiles(bool $ignoreDotFiles)
  62088. {
  62089. if ($ignoreDotFiles) {
  62090. $this->ignore |= static::IGNORE_DOT_FILES;
  62091. } else {
  62092. $this->ignore &= ~static::IGNORE_DOT_FILES;
  62093. }
  62094. return $this;
  62095. }
  62096. public function ignoreVCS(bool $ignoreVCS)
  62097. {
  62098. if ($ignoreVCS) {
  62099. $this->ignore |= static::IGNORE_VCS_FILES;
  62100. } else {
  62101. $this->ignore &= ~static::IGNORE_VCS_FILES;
  62102. }
  62103. return $this;
  62104. }
  62105. public function ignoreVCSIgnored(bool $ignoreVCSIgnored)
  62106. {
  62107. if ($ignoreVCSIgnored) {
  62108. $this->ignore |= static::IGNORE_VCS_IGNORED_FILES;
  62109. } else {
  62110. $this->ignore &= ~static::IGNORE_VCS_IGNORED_FILES;
  62111. }
  62112. return $this;
  62113. }
  62114. public static function addVCSPattern($pattern)
  62115. {
  62116. foreach ((array) $pattern as $p) {
  62117. self::$vcsPatterns[] = $p;
  62118. }
  62119. self::$vcsPatterns = array_unique(self::$vcsPatterns);
  62120. }
  62121. public function sort(\Closure $closure)
  62122. {
  62123. $this->sort = $closure;
  62124. return $this;
  62125. }
  62126. public function sortByName(bool $useNaturalSort = false)
  62127. {
  62128. $this->sort = $useNaturalSort ? Iterator\SortableIterator::SORT_BY_NAME_NATURAL : Iterator\SortableIterator::SORT_BY_NAME;
  62129. return $this;
  62130. }
  62131. public function sortByType()
  62132. {
  62133. $this->sort = Iterator\SortableIterator::SORT_BY_TYPE;
  62134. return $this;
  62135. }
  62136. public function sortByAccessedTime()
  62137. {
  62138. $this->sort = Iterator\SortableIterator::SORT_BY_ACCESSED_TIME;
  62139. return $this;
  62140. }
  62141. public function reverseSorting()
  62142. {
  62143. $this->reverseSorting = true;
  62144. return $this;
  62145. }
  62146. public function sortByChangedTime()
  62147. {
  62148. $this->sort = Iterator\SortableIterator::SORT_BY_CHANGED_TIME;
  62149. return $this;
  62150. }
  62151. public function sortByModifiedTime()
  62152. {
  62153. $this->sort = Iterator\SortableIterator::SORT_BY_MODIFIED_TIME;
  62154. return $this;
  62155. }
  62156. public function filter(\Closure $closure)
  62157. {
  62158. $this->filters[] = $closure;
  62159. return $this;
  62160. }
  62161. public function followLinks()
  62162. {
  62163. $this->followLinks = true;
  62164. return $this;
  62165. }
  62166. public function ignoreUnreadableDirs(bool $ignore = true)
  62167. {
  62168. $this->ignoreUnreadableDirs = $ignore;
  62169. return $this;
  62170. }
  62171. public function in($dirs)
  62172. {
  62173. $resolvedDirs = [];
  62174. foreach ((array) $dirs as $dir) {
  62175. if (is_dir($dir)) {
  62176. $resolvedDirs[] = [$this->normalizeDir($dir)];
  62177. } elseif ($glob = glob($dir, (\defined('GLOB_BRACE') ? \GLOB_BRACE : 0) | \GLOB_ONLYDIR | \GLOB_NOSORT)) {
  62178. sort($glob);
  62179. $resolvedDirs[] = array_map([$this, 'normalizeDir'], $glob);
  62180. } else {
  62181. throw new DirectoryNotFoundException(sprintf('The "%s" directory does not exist.', $dir));
  62182. }
  62183. }
  62184. $this->dirs = array_merge($this->dirs, ...$resolvedDirs);
  62185. return $this;
  62186. }
  62187. #[\ReturnTypeWillChange]
  62188. public function getIterator()
  62189. {
  62190. if (0 === \count($this->dirs) && 0 === \count($this->iterators)) {
  62191. throw new \LogicException('You must call one of in() or append() methods before iterating over a Finder.');
  62192. }
  62193. if (1 === \count($this->dirs) && 0 === \count($this->iterators)) {
  62194. $iterator = $this->searchInDirectory($this->dirs[0]);
  62195. if ($this->sort || $this->reverseSorting) {
  62196. $iterator = (new Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting))->getIterator();
  62197. }
  62198. return $iterator;
  62199. }
  62200. $iterator = new \AppendIterator();
  62201. foreach ($this->dirs as $dir) {
  62202. $iterator->append(new \IteratorIterator(new LazyIterator(function () use ($dir) {
  62203. return $this->searchInDirectory($dir);
  62204. })));
  62205. }
  62206. foreach ($this->iterators as $it) {
  62207. $iterator->append($it);
  62208. }
  62209. if ($this->sort || $this->reverseSorting) {
  62210. $iterator = (new Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting))->getIterator();
  62211. }
  62212. return $iterator;
  62213. }
  62214. public function append(iterable $iterator)
  62215. {
  62216. if ($iterator instanceof \IteratorAggregate) {
  62217. $this->iterators[] = $iterator->getIterator();
  62218. } elseif ($iterator instanceof \Iterator) {
  62219. $this->iterators[] = $iterator;
  62220. } elseif (is_iterable($iterator)) {
  62221. $it = new \ArrayIterator();
  62222. foreach ($iterator as $file) {
  62223. $file = $file instanceof \SplFileInfo ? $file : new \SplFileInfo($file);
  62224. $it[$file->getPathname()] = $file;
  62225. }
  62226. $this->iterators[] = $it;
  62227. } else {
  62228. throw new \InvalidArgumentException('Finder::append() method wrong argument type.');
  62229. }
  62230. return $this;
  62231. }
  62232. public function hasResults()
  62233. {
  62234. foreach ($this->getIterator() as $_) {
  62235. return true;
  62236. }
  62237. return false;
  62238. }
  62239. #[\ReturnTypeWillChange]
  62240. public function count()
  62241. {
  62242. return iterator_count($this->getIterator());
  62243. }
  62244. private function searchInDirectory(string $dir): \Iterator
  62245. {
  62246. $exclude = $this->exclude;
  62247. $notPaths = $this->notPaths;
  62248. if (static::IGNORE_VCS_FILES === (static::IGNORE_VCS_FILES & $this->ignore)) {
  62249. $exclude = array_merge($exclude, self::$vcsPatterns);
  62250. }
  62251. if (static::IGNORE_DOT_FILES === (static::IGNORE_DOT_FILES & $this->ignore)) {
  62252. $notPaths[] = '#(^|/)\..+(/|$)#';
  62253. }
  62254. $minDepth = 0;
  62255. $maxDepth = \PHP_INT_MAX;
  62256. foreach ($this->depths as $comparator) {
  62257. switch ($comparator->getOperator()) {
  62258. case '>':
  62259. $minDepth = $comparator->getTarget() + 1;
  62260. break;
  62261. case '>=':
  62262. $minDepth = $comparator->getTarget();
  62263. break;
  62264. case '<':
  62265. $maxDepth = $comparator->getTarget() - 1;
  62266. break;
  62267. case '<=':
  62268. $maxDepth = $comparator->getTarget();
  62269. break;
  62270. default:
  62271. $minDepth = $maxDepth = $comparator->getTarget();
  62272. }
  62273. }
  62274. $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
  62275. if ($this->followLinks) {
  62276. $flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
  62277. }
  62278. $iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
  62279. if ($exclude) {
  62280. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $exclude);
  62281. }
  62282. $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
  62283. if ($minDepth > 0 || $maxDepth < \PHP_INT_MAX) {
  62284. $iterator = new Iterator\DepthRangeFilterIterator($iterator, $minDepth, $maxDepth);
  62285. }
  62286. if ($this->mode) {
  62287. $iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
  62288. }
  62289. if ($this->names || $this->notNames) {
  62290. $iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
  62291. }
  62292. if ($this->contains || $this->notContains) {
  62293. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  62294. }
  62295. if ($this->sizes) {
  62296. $iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes);
  62297. }
  62298. if ($this->dates) {
  62299. $iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates);
  62300. }
  62301. if ($this->filters) {
  62302. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  62303. }
  62304. if ($this->paths || $notPaths) {
  62305. $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $notPaths);
  62306. }
  62307. if (static::IGNORE_VCS_IGNORED_FILES === (static::IGNORE_VCS_IGNORED_FILES & $this->ignore)) {
  62308. $iterator = new Iterator\VcsIgnoredFilterIterator($iterator, $dir);
  62309. }
  62310. return $iterator;
  62311. }
  62312. private function normalizeDir(string $dir): string
  62313. {
  62314. if ('/' === $dir) {
  62315. return $dir;
  62316. }
  62317. $dir = rtrim($dir, '/'.\DIRECTORY_SEPARATOR);
  62318. if (preg_match('#^(ssh2\.)?s?ftp://#', $dir)) {
  62319. $dir .= '/';
  62320. }
  62321. return $dir;
  62322. }
  62323. }
  62324. <?php
  62325. namespace Symfony\Component\Finder;
  62326. class Gitignore
  62327. {
  62328. public static function toRegex(string $gitignoreFileContent): string
  62329. {
  62330. return self::buildRegex($gitignoreFileContent, false);
  62331. }
  62332. public static function toRegexMatchingNegatedPatterns(string $gitignoreFileContent): string
  62333. {
  62334. return self::buildRegex($gitignoreFileContent, true);
  62335. }
  62336. private static function buildRegex(string $gitignoreFileContent, bool $inverted): string
  62337. {
  62338. $gitignoreFileContent = preg_replace('~(?<!\\\\)#[^\n\r]*~', '', $gitignoreFileContent);
  62339. $gitignoreLines = preg_split('~\r\n?|\n~', $gitignoreFileContent);
  62340. $res = self::lineToRegex('');
  62341. foreach ($gitignoreLines as $line) {
  62342. $line = preg_replace('~(?<!\\\\)[ \t]+$~', '', $line);
  62343. if ('!' === substr($line, 0, 1)) {
  62344. $line = substr($line, 1);
  62345. $isNegative = true;
  62346. } else {
  62347. $isNegative = false;
  62348. }
  62349. if ('' !== $line) {
  62350. if ($isNegative xor $inverted) {
  62351. $res = '(?!'.self::lineToRegex($line).'$)'.$res;
  62352. } else {
  62353. $res = '(?:'.$res.'|'.self::lineToRegex($line).')';
  62354. }
  62355. }
  62356. }
  62357. return '~^(?:'.$res.')~s';
  62358. }
  62359. private static function lineToRegex(string $gitignoreLine): string
  62360. {
  62361. if ('' === $gitignoreLine) {
  62362. return '$f';
  62363. }
  62364. $slashPos = strpos($gitignoreLine, '/');
  62365. if (false !== $slashPos && \strlen($gitignoreLine) - 1 !== $slashPos) {
  62366. if (0 === $slashPos) {
  62367. $gitignoreLine = substr($gitignoreLine, 1);
  62368. }
  62369. $isAbsolute = true;
  62370. } else {
  62371. $isAbsolute = false;
  62372. }
  62373. $regex = preg_quote(str_replace('\\', '', $gitignoreLine), '~');
  62374. $regex = preg_replace_callback('~\\\\\[((?:\\\\!)?)([^\[\]]*)\\\\\]~', function (array $matches): string {
  62375. return '['.('' !== $matches[1] ? '^' : '').str_replace('\\-', '-', $matches[2]).']';
  62376. }, $regex);
  62377. $regex = preg_replace('~(?:(?:\\\\\*){2,}(/?))+~', '(?:(?:(?!//).(?<!//))+$1)?', $regex);
  62378. $regex = preg_replace('~\\\\\*~', '[^/]*', $regex);
  62379. $regex = preg_replace('~\\\\\?~', '[^/]', $regex);
  62380. return ($isAbsolute ? '' : '(?:[^/]+/)*')
  62381. .$regex
  62382. .(!str_ends_with($gitignoreLine, '/') ? '(?:$|/)' : '');
  62383. }
  62384. }
  62385. <?php
  62386. namespace Symfony\Component\Finder;
  62387. class Glob
  62388. {
  62389. public static function toRegex(string $glob, bool $strictLeadingDot = true, bool $strictWildcardSlash = true, string $delimiter = '#')
  62390. {
  62391. $firstByte = true;
  62392. $escaping = false;
  62393. $inCurlies = 0;
  62394. $regex = '';
  62395. $sizeGlob = \strlen($glob);
  62396. for ($i = 0; $i < $sizeGlob; ++$i) {
  62397. $car = $glob[$i];
  62398. if ($firstByte && $strictLeadingDot && '.' !== $car) {
  62399. $regex .= '(?=[^\.])';
  62400. }
  62401. $firstByte = '/' === $car;
  62402. if ($firstByte && $strictWildcardSlash && isset($glob[$i + 2]) && '**' === $glob[$i + 1].$glob[$i + 2] && (!isset($glob[$i + 3]) || '/' === $glob[$i + 3])) {
  62403. $car = '[^/]++/';
  62404. if (!isset($glob[$i + 3])) {
  62405. $car .= '?';
  62406. }
  62407. if ($strictLeadingDot) {
  62408. $car = '(?=[^\.])'.$car;
  62409. }
  62410. $car = '/(?:'.$car.')*';
  62411. $i += 2 + isset($glob[$i + 3]);
  62412. if ('/' === $delimiter) {
  62413. $car = str_replace('/', '\\/', $car);
  62414. }
  62415. }
  62416. if ($delimiter === $car || '.' === $car || '(' === $car || ')' === $car || '|' === $car || '+' === $car || '^' === $car || '$' === $car) {
  62417. $regex .= "\\$car";
  62418. } elseif ('*' === $car) {
  62419. $regex .= $escaping ? '\\*' : ($strictWildcardSlash ? '[^/]*' : '.*');
  62420. } elseif ('?' === $car) {
  62421. $regex .= $escaping ? '\\?' : ($strictWildcardSlash ? '[^/]' : '.');
  62422. } elseif ('{' === $car) {
  62423. $regex .= $escaping ? '\\{' : '(';
  62424. if (!$escaping) {
  62425. ++$inCurlies;
  62426. }
  62427. } elseif ('}' === $car && $inCurlies) {
  62428. $regex .= $escaping ? '}' : ')';
  62429. if (!$escaping) {
  62430. --$inCurlies;
  62431. }
  62432. } elseif (',' === $car && $inCurlies) {
  62433. $regex .= $escaping ? ',' : '|';
  62434. } elseif ('\\' === $car) {
  62435. if ($escaping) {
  62436. $regex .= '\\\\';
  62437. $escaping = false;
  62438. } else {
  62439. $escaping = true;
  62440. }
  62441. continue;
  62442. } else {
  62443. $regex .= $car;
  62444. }
  62445. $escaping = false;
  62446. }
  62447. return $delimiter.'^'.$regex.'$'.$delimiter;
  62448. }
  62449. }
  62450. <?php
  62451. namespace Symfony\Component\Finder\Iterator;
  62452. class CustomFilterIterator extends \FilterIterator
  62453. {
  62454. private $filters = [];
  62455. public function __construct(\Iterator $iterator, array $filters)
  62456. {
  62457. foreach ($filters as $filter) {
  62458. if (!\is_callable($filter)) {
  62459. throw new \InvalidArgumentException('Invalid PHP callback.');
  62460. }
  62461. }
  62462. $this->filters = $filters;
  62463. parent::__construct($iterator);
  62464. }
  62465. #[\ReturnTypeWillChange]
  62466. public function accept()
  62467. {
  62468. $fileinfo = $this->current();
  62469. foreach ($this->filters as $filter) {
  62470. if (false === $filter($fileinfo)) {
  62471. return false;
  62472. }
  62473. }
  62474. return true;
  62475. }
  62476. }
  62477. <?php
  62478. namespace Symfony\Component\Finder\Iterator;
  62479. use Symfony\Component\Finder\Comparator\DateComparator;
  62480. class DateRangeFilterIterator extends \FilterIterator
  62481. {
  62482. private $comparators = [];
  62483. public function __construct(\Iterator $iterator, array $comparators)
  62484. {
  62485. $this->comparators = $comparators;
  62486. parent::__construct($iterator);
  62487. }
  62488. #[\ReturnTypeWillChange]
  62489. public function accept()
  62490. {
  62491. $fileinfo = $this->current();
  62492. if (!file_exists($fileinfo->getPathname())) {
  62493. return false;
  62494. }
  62495. $filedate = $fileinfo->getMTime();
  62496. foreach ($this->comparators as $compare) {
  62497. if (!$compare->test($filedate)) {
  62498. return false;
  62499. }
  62500. }
  62501. return true;
  62502. }
  62503. }
  62504. <?php
  62505. namespace Symfony\Component\Finder\Iterator;
  62506. class DepthRangeFilterIterator extends \FilterIterator
  62507. {
  62508. private $minDepth = 0;
  62509. public function __construct(\RecursiveIteratorIterator $iterator, int $minDepth = 0, int $maxDepth = \PHP_INT_MAX)
  62510. {
  62511. $this->minDepth = $minDepth;
  62512. $iterator->setMaxDepth(\PHP_INT_MAX === $maxDepth ? -1 : $maxDepth);
  62513. parent::__construct($iterator);
  62514. }
  62515. #[\ReturnTypeWillChange]
  62516. public function accept()
  62517. {
  62518. return $this->getInnerIterator()->getDepth() >= $this->minDepth;
  62519. }
  62520. }
  62521. <?php
  62522. namespace Symfony\Component\Finder\Iterator;
  62523. class ExcludeDirectoryFilterIterator extends \FilterIterator implements \RecursiveIterator
  62524. {
  62525. private $iterator;
  62526. private $isRecursive;
  62527. private $excludedDirs = [];
  62528. private $excludedPattern;
  62529. public function __construct(\Iterator $iterator, array $directories)
  62530. {
  62531. $this->iterator = $iterator;
  62532. $this->isRecursive = $iterator instanceof \RecursiveIterator;
  62533. $patterns = [];
  62534. foreach ($directories as $directory) {
  62535. $directory = rtrim($directory, '/');
  62536. if (!$this->isRecursive || str_contains($directory, '/')) {
  62537. $patterns[] = preg_quote($directory, '#');
  62538. } else {
  62539. $this->excludedDirs[$directory] = true;
  62540. }
  62541. }
  62542. if ($patterns) {
  62543. $this->excludedPattern = '#(?:^|/)(?:'.implode('|', $patterns).')(?:/|$)#';
  62544. }
  62545. parent::__construct($iterator);
  62546. }
  62547. #[\ReturnTypeWillChange]
  62548. public function accept()
  62549. {
  62550. if ($this->isRecursive && isset($this->excludedDirs[$this->getFilename()]) && $this->isDir()) {
  62551. return false;
  62552. }
  62553. if ($this->excludedPattern) {
  62554. $path = $this->isDir() ? $this->current()->getRelativePathname() : $this->current()->getRelativePath();
  62555. $path = str_replace('\\', '/', $path);
  62556. return !preg_match($this->excludedPattern, $path);
  62557. }
  62558. return true;
  62559. }
  62560. #[\ReturnTypeWillChange]
  62561. public function hasChildren()
  62562. {
  62563. return $this->isRecursive && $this->iterator->hasChildren();
  62564. }
  62565. #[\ReturnTypeWillChange]
  62566. public function getChildren()
  62567. {
  62568. $children = new self($this->iterator->getChildren(), []);
  62569. $children->excludedDirs = $this->excludedDirs;
  62570. $children->excludedPattern = $this->excludedPattern;
  62571. return $children;
  62572. }
  62573. }
  62574. <?php
  62575. namespace Symfony\Component\Finder\Iterator;
  62576. class FileTypeFilterIterator extends \FilterIterator
  62577. {
  62578. public const ONLY_FILES = 1;
  62579. public const ONLY_DIRECTORIES = 2;
  62580. private $mode;
  62581. public function __construct(\Iterator $iterator, int $mode)
  62582. {
  62583. $this->mode = $mode;
  62584. parent::__construct($iterator);
  62585. }
  62586. #[\ReturnTypeWillChange]
  62587. public function accept()
  62588. {
  62589. $fileinfo = $this->current();
  62590. if (self::ONLY_DIRECTORIES === (self::ONLY_DIRECTORIES & $this->mode) && $fileinfo->isFile()) {
  62591. return false;
  62592. } elseif (self::ONLY_FILES === (self::ONLY_FILES & $this->mode) && $fileinfo->isDir()) {
  62593. return false;
  62594. }
  62595. return true;
  62596. }
  62597. }
  62598. <?php
  62599. namespace Symfony\Component\Finder\Iterator;
  62600. class FilecontentFilterIterator extends MultiplePcreFilterIterator
  62601. {
  62602. #[\ReturnTypeWillChange]
  62603. public function accept()
  62604. {
  62605. if (!$this->matchRegexps && !$this->noMatchRegexps) {
  62606. return true;
  62607. }
  62608. $fileinfo = $this->current();
  62609. if ($fileinfo->isDir() || !$fileinfo->isReadable()) {
  62610. return false;
  62611. }
  62612. $content = $fileinfo->getContents();
  62613. if (!$content) {
  62614. return false;
  62615. }
  62616. return $this->isAccepted($content);
  62617. }
  62618. protected function toRegex(string $str)
  62619. {
  62620. return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
  62621. }
  62622. }
  62623. <?php
  62624. namespace Symfony\Component\Finder\Iterator;
  62625. use Symfony\Component\Finder\Glob;
  62626. class FilenameFilterIterator extends MultiplePcreFilterIterator
  62627. {
  62628. #[\ReturnTypeWillChange]
  62629. public function accept()
  62630. {
  62631. return $this->isAccepted($this->current()->getFilename());
  62632. }
  62633. protected function toRegex(string $str)
  62634. {
  62635. return $this->isRegex($str) ? $str : Glob::toRegex($str);
  62636. }
  62637. }
  62638. <?php
  62639. namespace Symfony\Component\Finder\Iterator;
  62640. class LazyIterator implements \IteratorAggregate
  62641. {
  62642. private $iteratorFactory;
  62643. public function __construct(callable $iteratorFactory)
  62644. {
  62645. $this->iteratorFactory = $iteratorFactory;
  62646. }
  62647. public function getIterator(): \Traversable
  62648. {
  62649. yield from ($this->iteratorFactory)();
  62650. }
  62651. }
  62652. <?php
  62653. namespace Symfony\Component\Finder\Iterator;
  62654. abstract class MultiplePcreFilterIterator extends \FilterIterator
  62655. {
  62656. protected $matchRegexps = [];
  62657. protected $noMatchRegexps = [];
  62658. public function __construct(\Iterator $iterator, array $matchPatterns, array $noMatchPatterns)
  62659. {
  62660. foreach ($matchPatterns as $pattern) {
  62661. $this->matchRegexps[] = $this->toRegex($pattern);
  62662. }
  62663. foreach ($noMatchPatterns as $pattern) {
  62664. $this->noMatchRegexps[] = $this->toRegex($pattern);
  62665. }
  62666. parent::__construct($iterator);
  62667. }
  62668. protected function isAccepted(string $string)
  62669. {
  62670. foreach ($this->noMatchRegexps as $regex) {
  62671. if (preg_match($regex, $string)) {
  62672. return false;
  62673. }
  62674. }
  62675. if ($this->matchRegexps) {
  62676. foreach ($this->matchRegexps as $regex) {
  62677. if (preg_match($regex, $string)) {
  62678. return true;
  62679. }
  62680. }
  62681. return false;
  62682. }
  62683. return true;
  62684. }
  62685. protected function isRegex(string $str)
  62686. {
  62687. if (preg_match('/^(.{3,}?)[imsxuADU]*$/', $str, $m)) {
  62688. $start = substr($m[1], 0, 1);
  62689. $end = substr($m[1], -1);
  62690. if ($start === $end) {
  62691. return !preg_match('/[*?[:alnum:] \\\\]/', $start);
  62692. }
  62693. foreach ([['{', '}'], ['(', ')'], ['[', ']'], ['<', '>']] as $delimiters) {
  62694. if ($start === $delimiters[0] && $end === $delimiters[1]) {
  62695. return true;
  62696. }
  62697. }
  62698. }
  62699. return false;
  62700. }
  62701. abstract protected function toRegex(string $str);
  62702. }
  62703. <?php
  62704. namespace Symfony\Component\Finder\Iterator;
  62705. class PathFilterIterator extends MultiplePcreFilterIterator
  62706. {
  62707. #[\ReturnTypeWillChange]
  62708. public function accept()
  62709. {
  62710. $filename = $this->current()->getRelativePathname();
  62711. if ('\\' === \DIRECTORY_SEPARATOR) {
  62712. $filename = str_replace('\\', '/', $filename);
  62713. }
  62714. return $this->isAccepted($filename);
  62715. }
  62716. protected function toRegex(string $str)
  62717. {
  62718. return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
  62719. }
  62720. }
  62721. <?php
  62722. namespace Symfony\Component\Finder\Iterator;
  62723. use Symfony\Component\Finder\Exception\AccessDeniedException;
  62724. use Symfony\Component\Finder\SplFileInfo;
  62725. class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
  62726. {
  62727. private $ignoreUnreadableDirs;
  62728. private $rewindable;
  62729. private $rootPath;
  62730. private $subPath;
  62731. private $directorySeparator = '/';
  62732. public function __construct(string $path, int $flags, bool $ignoreUnreadableDirs = false)
  62733. {
  62734. if ($flags & (self::CURRENT_AS_PATHNAME | self::CURRENT_AS_SELF)) {
  62735. throw new \RuntimeException('This iterator only support returning current as fileinfo.');
  62736. }
  62737. parent::__construct($path, $flags);
  62738. $this->ignoreUnreadableDirs = $ignoreUnreadableDirs;
  62739. $this->rootPath = $path;
  62740. if ('/' !== \DIRECTORY_SEPARATOR && !($flags & self::UNIX_PATHS)) {
  62741. $this->directorySeparator = \DIRECTORY_SEPARATOR;
  62742. }
  62743. }
  62744. #[\ReturnTypeWillChange]
  62745. public function current()
  62746. {
  62747. if (null === $subPathname = $this->subPath) {
  62748. $subPathname = $this->subPath = $this->getSubPath();
  62749. }
  62750. if ('' !== $subPathname) {
  62751. $subPathname .= $this->directorySeparator;
  62752. }
  62753. $subPathname .= $this->getFilename();
  62754. if ('/' !== $basePath = $this->rootPath) {
  62755. $basePath .= $this->directorySeparator;
  62756. }
  62757. return new SplFileInfo($basePath.$subPathname, $this->subPath, $subPathname);
  62758. }
  62759. #[\ReturnTypeWillChange]
  62760. public function hasChildren($allowLinks = false)
  62761. {
  62762. $hasChildren = parent::hasChildren($allowLinks);
  62763. if (!$hasChildren || !$this->ignoreUnreadableDirs) {
  62764. return $hasChildren;
  62765. }
  62766. try {
  62767. parent::getChildren();
  62768. return true;
  62769. } catch (\UnexpectedValueException $e) {
  62770. return false;
  62771. }
  62772. }
  62773. #[\ReturnTypeWillChange]
  62774. public function getChildren()
  62775. {
  62776. try {
  62777. $children = parent::getChildren();
  62778. if ($children instanceof self) {
  62779. $children->ignoreUnreadableDirs = $this->ignoreUnreadableDirs;
  62780. $children->rewindable = &$this->rewindable;
  62781. $children->rootPath = $this->rootPath;
  62782. }
  62783. return $children;
  62784. } catch (\UnexpectedValueException $e) {
  62785. throw new AccessDeniedException($e->getMessage(), $e->getCode(), $e);
  62786. }
  62787. }
  62788. #[\ReturnTypeWillChange]
  62789. public function rewind()
  62790. {
  62791. if (false === $this->isRewindable()) {
  62792. return;
  62793. }
  62794. parent::rewind();
  62795. }
  62796. public function isRewindable()
  62797. {
  62798. if (null !== $this->rewindable) {
  62799. return $this->rewindable;
  62800. }
  62801. if (false !== $stream = @opendir($this->getPath())) {
  62802. $infos = stream_get_meta_data($stream);
  62803. closedir($stream);
  62804. if ($infos['seekable']) {
  62805. return $this->rewindable = true;
  62806. }
  62807. }
  62808. return $this->rewindable = false;
  62809. }
  62810. }
  62811. <?php
  62812. namespace Symfony\Component\Finder\Iterator;
  62813. use Symfony\Component\Finder\Comparator\NumberComparator;
  62814. class SizeRangeFilterIterator extends \FilterIterator
  62815. {
  62816. private $comparators = [];
  62817. public function __construct(\Iterator $iterator, array $comparators)
  62818. {
  62819. $this->comparators = $comparators;
  62820. parent::__construct($iterator);
  62821. }
  62822. #[\ReturnTypeWillChange]
  62823. public function accept()
  62824. {
  62825. $fileinfo = $this->current();
  62826. if (!$fileinfo->isFile()) {
  62827. return true;
  62828. }
  62829. $filesize = $fileinfo->getSize();
  62830. foreach ($this->comparators as $compare) {
  62831. if (!$compare->test($filesize)) {
  62832. return false;
  62833. }
  62834. }
  62835. return true;
  62836. }
  62837. }
  62838. <?php
  62839. namespace Symfony\Component\Finder\Iterator;
  62840. class SortableIterator implements \IteratorAggregate
  62841. {
  62842. public const SORT_BY_NONE = 0;
  62843. public const SORT_BY_NAME = 1;
  62844. public const SORT_BY_TYPE = 2;
  62845. public const SORT_BY_ACCESSED_TIME = 3;
  62846. public const SORT_BY_CHANGED_TIME = 4;
  62847. public const SORT_BY_MODIFIED_TIME = 5;
  62848. public const SORT_BY_NAME_NATURAL = 6;
  62849. private $iterator;
  62850. private $sort;
  62851. public function __construct(\Traversable $iterator, $sort, bool $reverseOrder = false)
  62852. {
  62853. $this->iterator = $iterator;
  62854. $order = $reverseOrder ? -1 : 1;
  62855. if (self::SORT_BY_NAME === $sort) {
  62856. $this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
  62857. return $order * strcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
  62858. };
  62859. } elseif (self::SORT_BY_NAME_NATURAL === $sort) {
  62860. $this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
  62861. return $order * strnatcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
  62862. };
  62863. } elseif (self::SORT_BY_TYPE === $sort) {
  62864. $this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
  62865. if ($a->isDir() && $b->isFile()) {
  62866. return -$order;
  62867. } elseif ($a->isFile() && $b->isDir()) {
  62868. return $order;
  62869. }
  62870. return $order * strcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
  62871. };
  62872. } elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
  62873. $this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
  62874. return $order * ($a->getATime() - $b->getATime());
  62875. };
  62876. } elseif (self::SORT_BY_CHANGED_TIME === $sort) {
  62877. $this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
  62878. return $order * ($a->getCTime() - $b->getCTime());
  62879. };
  62880. } elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
  62881. $this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
  62882. return $order * ($a->getMTime() - $b->getMTime());
  62883. };
  62884. } elseif (self::SORT_BY_NONE === $sort) {
  62885. $this->sort = $order;
  62886. } elseif (\is_callable($sort)) {
  62887. $this->sort = $reverseOrder ? static function (\SplFileInfo $a, \SplFileInfo $b) use ($sort) { return -$sort($a, $b); } : $sort;
  62888. } else {
  62889. throw new \InvalidArgumentException('The SortableIterator takes a PHP callable or a valid built-in sort algorithm as an argument.');
  62890. }
  62891. }
  62892. #[\ReturnTypeWillChange]
  62893. public function getIterator()
  62894. {
  62895. if (1 === $this->sort) {
  62896. return $this->iterator;
  62897. }
  62898. $array = iterator_to_array($this->iterator, true);
  62899. if (-1 === $this->sort) {
  62900. $array = array_reverse($array);
  62901. } else {
  62902. uasort($array, $this->sort);
  62903. }
  62904. return new \ArrayIterator($array);
  62905. }
  62906. }
  62907. <?php
  62908. namespace Symfony\Component\Finder\Iterator;
  62909. use Symfony\Component\Finder\Gitignore;
  62910. final class VcsIgnoredFilterIterator extends \FilterIterator
  62911. {
  62912. private $baseDir;
  62913. private $gitignoreFilesCache = [];
  62914. private $ignoredPathsCache = [];
  62915. public function __construct(\Iterator $iterator, string $baseDir)
  62916. {
  62917. $this->baseDir = $this->normalizePath($baseDir);
  62918. parent::__construct($iterator);
  62919. }
  62920. public function accept(): bool
  62921. {
  62922. $file = $this->current();
  62923. $fileRealPath = $this->normalizePath($file->getRealPath());
  62924. return !$this->isIgnored($fileRealPath);
  62925. }
  62926. private function isIgnored(string $fileRealPath): bool
  62927. {
  62928. if (is_dir($fileRealPath) && !str_ends_with($fileRealPath, '/')) {
  62929. $fileRealPath .= '/';
  62930. }
  62931. if (isset($this->ignoredPathsCache[$fileRealPath])) {
  62932. return $this->ignoredPathsCache[$fileRealPath];
  62933. }
  62934. $ignored = false;
  62935. foreach ($this->parentsDirectoryDownward($fileRealPath) as $parentDirectory) {
  62936. if ($this->isIgnored($parentDirectory)) {
  62937. break;
  62938. }
  62939. $fileRelativePath = substr($fileRealPath, \strlen($parentDirectory) + 1);
  62940. if (null === $regexps = $this->readGitignoreFile("{$parentDirectory}/.gitignore")) {
  62941. continue;
  62942. }
  62943. [$exclusionRegex, $inclusionRegex] = $regexps;
  62944. if (preg_match($exclusionRegex, $fileRelativePath)) {
  62945. $ignored = true;
  62946. continue;
  62947. }
  62948. if (preg_match($inclusionRegex, $fileRelativePath)) {
  62949. $ignored = false;
  62950. }
  62951. }
  62952. return $this->ignoredPathsCache[$fileRealPath] = $ignored;
  62953. }
  62954. private function parentsDirectoryDownward(string $fileRealPath): array
  62955. {
  62956. $parentDirectories = [];
  62957. $parentDirectory = $fileRealPath;
  62958. while (true) {
  62959. $newParentDirectory = \dirname($parentDirectory);
  62960. if ($newParentDirectory === $parentDirectory) {
  62961. break;
  62962. }
  62963. $parentDirectory = $newParentDirectory;
  62964. if (0 !== strpos($parentDirectory, $this->baseDir)) {
  62965. break;
  62966. }
  62967. $parentDirectories[] = $parentDirectory;
  62968. }
  62969. return array_reverse($parentDirectories);
  62970. }
  62971. private function readGitignoreFile(string $path): ?array
  62972. {
  62973. if (\array_key_exists($path, $this->gitignoreFilesCache)) {
  62974. return $this->gitignoreFilesCache[$path];
  62975. }
  62976. if (!file_exists($path)) {
  62977. return $this->gitignoreFilesCache[$path] = null;
  62978. }
  62979. if (!is_file($path) || !is_readable($path)) {
  62980. throw new \RuntimeException("The \"ignoreVCSIgnored\" option cannot be used by the Finder as the \"{$path}\" file is not readable.");
  62981. }
  62982. $gitignoreFileContent = file_get_contents($path);
  62983. return $this->gitignoreFilesCache[$path] = [
  62984. Gitignore::toRegex($gitignoreFileContent),
  62985. Gitignore::toRegexMatchingNegatedPatterns($gitignoreFileContent),
  62986. ];
  62987. }
  62988. private function normalizePath(string $path): string
  62989. {
  62990. if ('\\' === \DIRECTORY_SEPARATOR) {
  62991. return str_replace('\\', '/', $path);
  62992. }
  62993. return $path;
  62994. }
  62995. }
  62996. Copyright (c) 2004-2022 Fabien Potencier
  62997. Permission is hereby granted, free of charge, to any person obtaining a copy
  62998. of this software and associated documentation files (the "Software"), to deal
  62999. in the Software without restriction, including without limitation the rights
  63000. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  63001. copies of the Software, and to permit persons to whom the Software is furnished
  63002. to do so, subject to the following conditions:
  63003. The above copyright notice and this permission notice shall be included in all
  63004. copies or substantial portions of the Software.
  63005. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  63006. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  63007. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  63008. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  63009. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  63010. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  63011. THE SOFTWARE.
  63012. <?php
  63013. namespace Symfony\Component\Finder;
  63014. class SplFileInfo extends \SplFileInfo
  63015. {
  63016. private $relativePath;
  63017. private $relativePathname;
  63018. public function __construct(string $file, string $relativePath, string $relativePathname)
  63019. {
  63020. parent::__construct($file);
  63021. $this->relativePath = $relativePath;
  63022. $this->relativePathname = $relativePathname;
  63023. }
  63024. public function getRelativePath()
  63025. {
  63026. return $this->relativePath;
  63027. }
  63028. public function getRelativePathname()
  63029. {
  63030. return $this->relativePathname;
  63031. }
  63032. public function getFilenameWithoutExtension(): string
  63033. {
  63034. $filename = $this->getFilename();
  63035. return pathinfo($filename, \PATHINFO_FILENAME);
  63036. }
  63037. public function getContents()
  63038. {
  63039. set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
  63040. try {
  63041. $content = file_get_contents($this->getPathname());
  63042. } finally {
  63043. restore_error_handler();
  63044. }
  63045. if (false === $content) {
  63046. throw new \RuntimeException($error);
  63047. }
  63048. return $content;
  63049. }
  63050. }
  63051. <?php
  63052. namespace Symfony\Polyfill\Ctype;
  63053. final class Ctype
  63054. {
  63055. public static function ctype_alnum($text)
  63056. {
  63057. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  63058. return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z0-9]/', $text);
  63059. }
  63060. public static function ctype_alpha($text)
  63061. {
  63062. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  63063. return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z]/', $text);
  63064. }
  63065. public static function ctype_cntrl($text)
  63066. {
  63067. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  63068. return \is_string($text) && '' !== $text && !preg_match('/[^\x00-\x1f\x7f]/', $text);
  63069. }
  63070. public static function ctype_digit($text)
  63071. {
  63072. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  63073. return \is_string($text) && '' !== $text && !preg_match('/[^0-9]/', $text);
  63074. }
  63075. public static function ctype_graph($text)
  63076. {
  63077. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  63078. return \is_string($text) && '' !== $text && !preg_match('/[^!-~]/', $text);
  63079. }
  63080. public static function ctype_lower($text)
  63081. {
  63082. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  63083. return \is_string($text) && '' !== $text && !preg_match('/[^a-z]/', $text);
  63084. }
  63085. public static function ctype_print($text)
  63086. {
  63087. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  63088. return \is_string($text) && '' !== $text && !preg_match('/[^ -~]/', $text);
  63089. }
  63090. public static function ctype_punct($text)
  63091. {
  63092. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  63093. return \is_string($text) && '' !== $text && !preg_match('/[^!-\/\:-@\[-`\{-~]/', $text);
  63094. }
  63095. public static function ctype_space($text)
  63096. {
  63097. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  63098. return \is_string($text) && '' !== $text && !preg_match('/[^\s]/', $text);
  63099. }
  63100. public static function ctype_upper($text)
  63101. {
  63102. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  63103. return \is_string($text) && '' !== $text && !preg_match('/[^A-Z]/', $text);
  63104. }
  63105. public static function ctype_xdigit($text)
  63106. {
  63107. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  63108. return \is_string($text) && '' !== $text && !preg_match('/[^A-Fa-f0-9]/', $text);
  63109. }
  63110. private static function convert_int_to_char_for_ctype($int, $function)
  63111. {
  63112. if (!\is_int($int)) {
  63113. return $int;
  63114. }
  63115. if ($int < -128 || $int > 255) {
  63116. return (string) $int;
  63117. }
  63118. if (\PHP_VERSION_ID >= 80100) {
  63119. @trigger_error($function.'(): Argument of type int will be interpreted as string in the future', \E_USER_DEPRECATED);
  63120. }
  63121. if ($int < 0) {
  63122. $int += 256;
  63123. }
  63124. return \chr($int);
  63125. }
  63126. }
  63127. Copyright (c) 2018-2019 Fabien Potencier
  63128. Permission is hereby granted, free of charge, to any person obtaining a copy
  63129. of this software and associated documentation files (the "Software"), to deal
  63130. in the Software without restriction, including without limitation the rights
  63131. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  63132. copies of the Software, and to permit persons to whom the Software is furnished
  63133. to do so, subject to the following conditions:
  63134. The above copyright notice and this permission notice shall be included in all
  63135. copies or substantial portions of the Software.
  63136. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  63137. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  63138. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  63139. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  63140. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  63141. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  63142. THE SOFTWARE.
  63143. <?php
  63144. use Symfony\Polyfill\Ctype as p;
  63145. if (\PHP_VERSION_ID >= 80000) {
  63146. return require __DIR__.'/bootstrap80.php';
  63147. }
  63148. if (!function_exists('ctype_alnum')) {
  63149. function ctype_alnum($text) { return p\Ctype::ctype_alnum($text); }
  63150. }
  63151. if (!function_exists('ctype_alpha')) {
  63152. function ctype_alpha($text) { return p\Ctype::ctype_alpha($text); }
  63153. }
  63154. if (!function_exists('ctype_cntrl')) {
  63155. function ctype_cntrl($text) { return p\Ctype::ctype_cntrl($text); }
  63156. }
  63157. if (!function_exists('ctype_digit')) {
  63158. function ctype_digit($text) { return p\Ctype::ctype_digit($text); }
  63159. }
  63160. if (!function_exists('ctype_graph')) {
  63161. function ctype_graph($text) { return p\Ctype::ctype_graph($text); }
  63162. }
  63163. if (!function_exists('ctype_lower')) {
  63164. function ctype_lower($text) { return p\Ctype::ctype_lower($text); }
  63165. }
  63166. if (!function_exists('ctype_print')) {
  63167. function ctype_print($text) { return p\Ctype::ctype_print($text); }
  63168. }
  63169. if (!function_exists('ctype_punct')) {
  63170. function ctype_punct($text) { return p\Ctype::ctype_punct($text); }
  63171. }
  63172. if (!function_exists('ctype_space')) {
  63173. function ctype_space($text) { return p\Ctype::ctype_space($text); }
  63174. }
  63175. if (!function_exists('ctype_upper')) {
  63176. function ctype_upper($text) { return p\Ctype::ctype_upper($text); }
  63177. }
  63178. if (!function_exists('ctype_xdigit')) {
  63179. function ctype_xdigit($text) { return p\Ctype::ctype_xdigit($text); }
  63180. }
  63181. <?php
  63182. use Symfony\Polyfill\Ctype as p;
  63183. if (!function_exists('ctype_alnum')) {
  63184. function ctype_alnum(mixed $text): bool { return p\Ctype::ctype_alnum($text); }
  63185. }
  63186. if (!function_exists('ctype_alpha')) {
  63187. function ctype_alpha(mixed $text): bool { return p\Ctype::ctype_alpha($text); }
  63188. }
  63189. if (!function_exists('ctype_cntrl')) {
  63190. function ctype_cntrl(mixed $text): bool { return p\Ctype::ctype_cntrl($text); }
  63191. }
  63192. if (!function_exists('ctype_digit')) {
  63193. function ctype_digit(mixed $text): bool { return p\Ctype::ctype_digit($text); }
  63194. }
  63195. if (!function_exists('ctype_graph')) {
  63196. function ctype_graph(mixed $text): bool { return p\Ctype::ctype_graph($text); }
  63197. }
  63198. if (!function_exists('ctype_lower')) {
  63199. function ctype_lower(mixed $text): bool { return p\Ctype::ctype_lower($text); }
  63200. }
  63201. if (!function_exists('ctype_print')) {
  63202. function ctype_print(mixed $text): bool { return p\Ctype::ctype_print($text); }
  63203. }
  63204. if (!function_exists('ctype_punct')) {
  63205. function ctype_punct(mixed $text): bool { return p\Ctype::ctype_punct($text); }
  63206. }
  63207. if (!function_exists('ctype_space')) {
  63208. function ctype_space(mixed $text): bool { return p\Ctype::ctype_space($text); }
  63209. }
  63210. if (!function_exists('ctype_upper')) {
  63211. function ctype_upper(mixed $text): bool { return p\Ctype::ctype_upper($text); }
  63212. }
  63213. if (!function_exists('ctype_xdigit')) {
  63214. function ctype_xdigit(mixed $text): bool { return p\Ctype::ctype_xdigit($text); }
  63215. }
  63216. <?php
  63217. namespace Symfony\Polyfill\Intl\Grapheme;
  63218. \define('SYMFONY_GRAPHEME_CLUSTER_RX', ((float) \PCRE_VERSION < 10 ? (float) \PCRE_VERSION >= 8.32 : (float) \PCRE_VERSION >= 10.39) ? '\X' : Grapheme::GRAPHEME_CLUSTER_RX);
  63219. final class Grapheme
  63220. {
  63221. public const GRAPHEME_CLUSTER_RX = '(?:\r\n|(?:[ -~\x{200C}\x{200D}]|[ᆨ-ᇹ]+|[ᄀ-ᅟ]*(?:[가개갸걔거게겨계고과괘괴�구궈궤귀규그긔기까깨꺄꺠꺼께껴�꼬꽈꽤꾀꾜꾸꿔꿰뀌뀨���나내�냬너네녀녜노놔놰뇌뇨누눠눼뉘뉴�늬니다대댜댸��뎌뎨������둬뒈뒤듀드듸디따때땨떄떠떼뗘뗴�똬뙈뙤뚀뚜뚸뛔뛰뜌뜨���래랴�러레려례로롸뢔뢰료루뤄뤠뤼류르�리마매먀먜머메며몌모뫄뫠뫼묘무�뭬뮈뮤므믜미바배뱌뱨버베벼볘보�봬뵈뵤부붜붸뷔뷰브븨비빠빼뺘뺴�뻬뼈뼤뽀뽜뽸뾔뾰뿌뿨쀄쀠쀼���사새샤섀서세셔셰소솨쇄쇠쇼수숴�쉬슈스싀시싸쌔쌰��쎄쎠쎼����쑈쑤쒀쒜쒸쓔쓰씌씨아애야얘어�여예오와왜외요우워웨위유으���재쟈쟤저제져졔조좌좨죄죠주줘줴�쥬즈즤지짜째쨔쨰쩌쩨쪄쪠쪼쫘쫴�쬬쭈쭤쮀쮜쮸쯔쯰찌차채챠챼처체�쳬초촤쵀최쵸추춰췌취츄츠츼치카�캬컈커케켜켸코콰쾌쾨쿄쿠쿼퀘퀴��킈키타태탸턔터테텨톄토톼퇘퇴�투퉈퉤튀튜트틔티파패���페펴����푀표푸풔풰퓌퓨프픠피하해�햬허헤혀혜호화홰회효후훠훼휘휴��히]?[ᅠ-ᆢ]+|[가-힣])[ᆨ-ᇹ]*|[ᄀ-ᅟ]+|[^\p{Cc}\p{Cf}\p{Zl}\p{Zp}])[\p{Mn}\p{Me}\x{09BE}\x{09D7}\x{0B3E}\x{0B57}\x{0BBE}\x{0BD7}\x{0CC2}\x{0CD5}\x{0CD6}\x{0D3E}\x{0D57}\x{0DCF}\x{0DDF}\x{200C}\x{200D}\x{1D165}\x{1D16E}-\x{1D172}]*|[\p{Cc}\p{Cf}\p{Zl}\p{Zp}])';
  63222. private const CASE_FOLD = [
  63223. ['µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"],
  63224. ['μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', '�', 'ε', "\xE1\xB9\xA1", 'ι'],
  63225. ];
  63226. public static function grapheme_extract($s, $size, $type = \GRAPHEME_EXTR_COUNT, $start = 0, &$next = 0)
  63227. {
  63228. if (0 > $start) {
  63229. $start = \strlen($s) + $start;
  63230. }
  63231. if (!is_scalar($s)) {
  63232. $hasError = false;
  63233. set_error_handler(function () use (&$hasError) { $hasError = true; });
  63234. $next = substr($s, $start);
  63235. restore_error_handler();
  63236. if ($hasError) {
  63237. substr($s, $start);
  63238. $s = '';
  63239. } else {
  63240. $s = $next;
  63241. }
  63242. } else {
  63243. $s = substr($s, $start);
  63244. }
  63245. $size = (int) $size;
  63246. $type = (int) $type;
  63247. $start = (int) $start;
  63248. if (\GRAPHEME_EXTR_COUNT !== $type && \GRAPHEME_EXTR_MAXBYTES !== $type && \GRAPHEME_EXTR_MAXCHARS !== $type) {
  63249. if (80000 > \PHP_VERSION_ID) {
  63250. return false;
  63251. }
  63252. throw new \ValueError('grapheme_extract(): Argument #3 ($type) must be one of GRAPHEME_EXTR_COUNT, GRAPHEME_EXTR_MAXBYTES, or GRAPHEME_EXTR_MAXCHARS');
  63253. }
  63254. if (!isset($s[0]) || 0 > $size || 0 > $start) {
  63255. return false;
  63256. }
  63257. if (0 === $size) {
  63258. return '';
  63259. }
  63260. $next = $start;
  63261. $s = preg_split('/('.SYMFONY_GRAPHEME_CLUSTER_RX.')/u', "\r\n".$s, $size + 1, \PREG_SPLIT_NO_EMPTY | \PREG_SPLIT_DELIM_CAPTURE);
  63262. if (!isset($s[1])) {
  63263. return false;
  63264. }
  63265. $i = 1;
  63266. $ret = '';
  63267. do {
  63268. if (\GRAPHEME_EXTR_COUNT === $type) {
  63269. --$size;
  63270. } elseif (\GRAPHEME_EXTR_MAXBYTES === $type) {
  63271. $size -= \strlen($s[$i]);
  63272. } else {
  63273. $size -= iconv_strlen($s[$i], 'UTF-8//IGNORE');
  63274. }
  63275. if ($size >= 0) {
  63276. $ret .= $s[$i];
  63277. }
  63278. } while (isset($s[++$i]) && $size > 0);
  63279. $next += \strlen($ret);
  63280. return $ret;
  63281. }
  63282. public static function grapheme_strlen($s)
  63283. {
  63284. preg_replace('/'.SYMFONY_GRAPHEME_CLUSTER_RX.'/u', '', $s, -1, $len);
  63285. return 0 === $len && '' !== $s ? null : $len;
  63286. }
  63287. public static function grapheme_substr($s, $start, $len = null)
  63288. {
  63289. if (null === $len) {
  63290. $len = 2147483647;
  63291. }
  63292. preg_match_all('/'.SYMFONY_GRAPHEME_CLUSTER_RX.'/u', $s, $s);
  63293. $slen = \count($s[0]);
  63294. $start = (int) $start;
  63295. if (0 > $start) {
  63296. $start += $slen;
  63297. }
  63298. if (0 > $start) {
  63299. if (\PHP_VERSION_ID < 80000) {
  63300. return false;
  63301. }
  63302. $start = 0;
  63303. }
  63304. if ($start >= $slen) {
  63305. return \PHP_VERSION_ID >= 80000 ? '' : false;
  63306. }
  63307. $rem = $slen - $start;
  63308. if (0 > $len) {
  63309. $len += $rem;
  63310. }
  63311. if (0 === $len) {
  63312. return '';
  63313. }
  63314. if (0 > $len) {
  63315. return \PHP_VERSION_ID >= 80000 ? '' : false;
  63316. }
  63317. if ($len > $rem) {
  63318. $len = $rem;
  63319. }
  63320. return implode('', \array_slice($s[0], $start, $len));
  63321. }
  63322. public static function grapheme_strpos($s, $needle, $offset = 0)
  63323. {
  63324. return self::grapheme_position($s, $needle, $offset, 0);
  63325. }
  63326. public static function grapheme_stripos($s, $needle, $offset = 0)
  63327. {
  63328. return self::grapheme_position($s, $needle, $offset, 1);
  63329. }
  63330. public static function grapheme_strrpos($s, $needle, $offset = 0)
  63331. {
  63332. return self::grapheme_position($s, $needle, $offset, 2);
  63333. }
  63334. public static function grapheme_strripos($s, $needle, $offset = 0)
  63335. {
  63336. return self::grapheme_position($s, $needle, $offset, 3);
  63337. }
  63338. public static function grapheme_stristr($s, $needle, $beforeNeedle = false)
  63339. {
  63340. return mb_stristr($s, $needle, $beforeNeedle, 'UTF-8');
  63341. }
  63342. public static function grapheme_strstr($s, $needle, $beforeNeedle = false)
  63343. {
  63344. return mb_strstr($s, $needle, $beforeNeedle, 'UTF-8');
  63345. }
  63346. private static function grapheme_position($s, $needle, $offset, $mode)
  63347. {
  63348. $needle = (string) $needle;
  63349. if (80000 > \PHP_VERSION_ID && !preg_match('/./us', $needle)) {
  63350. return false;
  63351. }
  63352. $s = (string) $s;
  63353. if (!preg_match('/./us', $s)) {
  63354. return false;
  63355. }
  63356. if ($offset > 0) {
  63357. $s = self::grapheme_substr($s, $offset);
  63358. } elseif ($offset < 0) {
  63359. if (2 > $mode) {
  63360. $offset += self::grapheme_strlen($s);
  63361. $s = self::grapheme_substr($s, $offset);
  63362. if (0 > $offset) {
  63363. $offset = 0;
  63364. }
  63365. } elseif (0 > $offset += self::grapheme_strlen($needle)) {
  63366. $s = self::grapheme_substr($s, 0, $offset);
  63367. $offset = 0;
  63368. } else {
  63369. $offset = 0;
  63370. }
  63371. }
  63372. $caseInsensitive = $mode & 1;
  63373. $reverse = $mode & 2;
  63374. if ($caseInsensitive) {
  63375. $mode = \defined('MB_CASE_FOLD_SIMPLE') ? \MB_CASE_FOLD_SIMPLE : \MB_CASE_LOWER;
  63376. $s = mb_convert_case($s, $mode, 'UTF-8');
  63377. $needle = mb_convert_case($needle, $mode, 'UTF-8');
  63378. if (!\defined('MB_CASE_FOLD_SIMPLE')) {
  63379. $s = str_replace(self::CASE_FOLD[0], self::CASE_FOLD[1], $s);
  63380. $needle = str_replace(self::CASE_FOLD[0], self::CASE_FOLD[1], $needle);
  63381. }
  63382. }
  63383. if ($reverse) {
  63384. $needlePos = strrpos($s, $needle);
  63385. } else {
  63386. $needlePos = strpos($s, $needle);
  63387. }
  63388. return false !== $needlePos ? self::grapheme_strlen(substr($s, 0, $needlePos)) + $offset : false;
  63389. }
  63390. }
  63391. Copyright (c) 2015-2019 Fabien Potencier
  63392. Permission is hereby granted, free of charge, to any person obtaining a copy
  63393. of this software and associated documentation files (the "Software"), to deal
  63394. in the Software without restriction, including without limitation the rights
  63395. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  63396. copies of the Software, and to permit persons to whom the Software is furnished
  63397. to do so, subject to the following conditions:
  63398. The above copyright notice and this permission notice shall be included in all
  63399. copies or substantial portions of the Software.
  63400. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  63401. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  63402. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  63403. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  63404. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  63405. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  63406. THE SOFTWARE.
  63407. <?php
  63408. use Symfony\Polyfill\Intl\Grapheme as p;
  63409. if (extension_loaded('intl')) {
  63410. return;
  63411. }
  63412. if (\PHP_VERSION_ID >= 80000) {
  63413. return require __DIR__.'/bootstrap80.php';
  63414. }
  63415. if (!defined('GRAPHEME_EXTR_COUNT')) {
  63416. define('GRAPHEME_EXTR_COUNT', 0);
  63417. }
  63418. if (!defined('GRAPHEME_EXTR_MAXBYTES')) {
  63419. define('GRAPHEME_EXTR_MAXBYTES', 1);
  63420. }
  63421. if (!defined('GRAPHEME_EXTR_MAXCHARS')) {
  63422. define('GRAPHEME_EXTR_MAXCHARS', 2);
  63423. }
  63424. if (!function_exists('grapheme_extract')) {
  63425. function grapheme_extract($haystack, $size, $type = 0, $start = 0, &$next = 0) { return p\Grapheme::grapheme_extract($haystack, $size, $type, $start, $next); }
  63426. }
  63427. if (!function_exists('grapheme_stripos')) {
  63428. function grapheme_stripos($haystack, $needle, $offset = 0) { return p\Grapheme::grapheme_stripos($haystack, $needle, $offset); }
  63429. }
  63430. if (!function_exists('grapheme_stristr')) {
  63431. function grapheme_stristr($haystack, $needle, $beforeNeedle = false) { return p\Grapheme::grapheme_stristr($haystack, $needle, $beforeNeedle); }
  63432. }
  63433. if (!function_exists('grapheme_strlen')) {
  63434. function grapheme_strlen($input) { return p\Grapheme::grapheme_strlen($input); }
  63435. }
  63436. if (!function_exists('grapheme_strpos')) {
  63437. function grapheme_strpos($haystack, $needle, $offset = 0) { return p\Grapheme::grapheme_strpos($haystack, $needle, $offset); }
  63438. }
  63439. if (!function_exists('grapheme_strripos')) {
  63440. function grapheme_strripos($haystack, $needle, $offset = 0) { return p\Grapheme::grapheme_strripos($haystack, $needle, $offset); }
  63441. }
  63442. if (!function_exists('grapheme_strrpos')) {
  63443. function grapheme_strrpos($haystack, $needle, $offset = 0) { return p\Grapheme::grapheme_strrpos($haystack, $needle, $offset); }
  63444. }
  63445. if (!function_exists('grapheme_strstr')) {
  63446. function grapheme_strstr($haystack, $needle, $beforeNeedle = false) { return p\Grapheme::grapheme_strstr($haystack, $needle, $beforeNeedle); }
  63447. }
  63448. if (!function_exists('grapheme_substr')) {
  63449. function grapheme_substr($string, $offset, $length = null) { return p\Grapheme::grapheme_substr($string, $offset, $length); }
  63450. }
  63451. <?php
  63452. use Symfony\Polyfill\Intl\Grapheme as p;
  63453. if (!defined('GRAPHEME_EXTR_COUNT')) {
  63454. define('GRAPHEME_EXTR_COUNT', 0);
  63455. }
  63456. if (!defined('GRAPHEME_EXTR_MAXBYTES')) {
  63457. define('GRAPHEME_EXTR_MAXBYTES', 1);
  63458. }
  63459. if (!defined('GRAPHEME_EXTR_MAXCHARS')) {
  63460. define('GRAPHEME_EXTR_MAXCHARS', 2);
  63461. }
  63462. if (!function_exists('grapheme_extract')) {
  63463. function grapheme_extract(?string $haystack, ?int $size, ?int $type = GRAPHEME_EXTR_COUNT, ?int $offset = 0, &$next = null): string|false { return p\Grapheme::grapheme_extract((string) $haystack, (int) $size, (int) $type, (int) $offset, $next); }
  63464. }
  63465. if (!function_exists('grapheme_stripos')) {
  63466. function grapheme_stripos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_stripos((string) $haystack, (string) $needle, (int) $offset); }
  63467. }
  63468. if (!function_exists('grapheme_stristr')) {
  63469. function grapheme_stristr(?string $haystack, ?string $needle, ?bool $beforeNeedle = false): string|false { return p\Grapheme::grapheme_stristr((string) $haystack, (string) $needle, (bool) $beforeNeedle); }
  63470. }
  63471. if (!function_exists('grapheme_strlen')) {
  63472. function grapheme_strlen(?string $string): int|false|null { return p\Grapheme::grapheme_strlen((string) $string); }
  63473. }
  63474. if (!function_exists('grapheme_strpos')) {
  63475. function grapheme_strpos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_strpos((string) $haystack, (string) $needle, (int) $offset); }
  63476. }
  63477. if (!function_exists('grapheme_strripos')) {
  63478. function grapheme_strripos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_strripos((string) $haystack, (string) $needle, (int) $offset); }
  63479. }
  63480. if (!function_exists('grapheme_strrpos')) {
  63481. function grapheme_strrpos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_strrpos((string) $haystack, (string) $needle, (int) $offset); }
  63482. }
  63483. if (!function_exists('grapheme_strstr')) {
  63484. function grapheme_strstr(?string $haystack, ?string $needle, ?bool $beforeNeedle = false): string|false { return p\Grapheme::grapheme_strstr((string) $haystack, (string) $needle, (bool) $beforeNeedle); }
  63485. }
  63486. if (!function_exists('grapheme_substr')) {
  63487. function grapheme_substr(?string $string, ?int $offset, ?int $length = null): string|false { return p\Grapheme::grapheme_substr((string) $string, (int) $offset, $length); }
  63488. }
  63489. Copyright (c) 2015-2019 Fabien Potencier
  63490. Permission is hereby granted, free of charge, to any person obtaining a copy
  63491. of this software and associated documentation files (the "Software"), to deal
  63492. in the Software without restriction, including without limitation the rights
  63493. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  63494. copies of the Software, and to permit persons to whom the Software is furnished
  63495. to do so, subject to the following conditions:
  63496. The above copyright notice and this permission notice shall be included in all
  63497. copies or substantial portions of the Software.
  63498. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  63499. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  63500. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  63501. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  63502. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  63503. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  63504. THE SOFTWARE.
  63505. <?php
  63506. namespace Symfony\Polyfill\Intl\Normalizer;
  63507. class Normalizer
  63508. {
  63509. public const FORM_D = \Normalizer::FORM_D;
  63510. public const FORM_KD = \Normalizer::FORM_KD;
  63511. public const FORM_C = \Normalizer::FORM_C;
  63512. public const FORM_KC = \Normalizer::FORM_KC;
  63513. public const NFD = \Normalizer::NFD;
  63514. public const NFKD = \Normalizer::NFKD;
  63515. public const NFC = \Normalizer::NFC;
  63516. public const NFKC = \Normalizer::NFKC;
  63517. private static $C;
  63518. private static $D;
  63519. private static $KD;
  63520. private static $cC;
  63521. private static $ulenMask = ["\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4];
  63522. private static $ASCII = "\x20\x65\x69\x61\x73\x6E\x74\x72\x6F\x6C\x75\x64\x5D\x5B\x63\x6D\x70\x27\x0A\x67\x7C\x68\x76\x2E\x66\x62\x2C\x3A\x3D\x2D\x71\x31\x30\x43\x32\x2A\x79\x78\x29\x28\x4C\x39\x41\x53\x2F\x50\x22\x45\x6A\x4D\x49\x6B\x33\x3E\x35\x54\x3C\x44\x34\x7D\x42\x7B\x38\x46\x77\x52\x36\x37\x55\x47\x4E\x3B\x4A\x7A\x56\x23\x48\x4F\x57\x5F\x26\x21\x4B\x3F\x58\x51\x25\x59\x5C\x09\x5A\x2B\x7E\x5E\x24\x40\x60\x7F\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F";
  63523. public static function isNormalized(string $s, int $form = self::FORM_C)
  63524. {
  63525. if (!\in_array($form, [self::NFD, self::NFKD, self::NFC, self::NFKC])) {
  63526. return false;
  63527. }
  63528. if (!isset($s[strspn($s, self::$ASCII)])) {
  63529. return true;
  63530. }
  63531. if (self::NFC == $form && preg_match('//u', $s) && !preg_match('/[^\x00-\x{2FF}]/u', $s)) {
  63532. return true;
  63533. }
  63534. return self::normalize($s, $form) === $s;
  63535. }
  63536. public static function normalize(string $s, int $form = self::FORM_C)
  63537. {
  63538. if (!preg_match('//u', $s)) {
  63539. return false;
  63540. }
  63541. switch ($form) {
  63542. case self::NFC: $C = true; $K = false; break;
  63543. case self::NFD: $C = false; $K = false; break;
  63544. case self::NFKC: $C = true; $K = true; break;
  63545. case self::NFKD: $C = false; $K = true; break;
  63546. default:
  63547. if (\defined('Normalizer::NONE') && \Normalizer::NONE == $form) {
  63548. return $s;
  63549. }
  63550. if (80000 > \PHP_VERSION_ID) {
  63551. return false;
  63552. }
  63553. throw new \ValueError('normalizer_normalize(): Argument #2 ($form) must be a a valid normalization form');
  63554. }
  63555. if ('' === $s) {
  63556. return '';
  63557. }
  63558. if ($K && null === self::$KD) {
  63559. self::$KD = self::getData('compatibilityDecomposition');
  63560. }
  63561. if (null === self::$D) {
  63562. self::$D = self::getData('canonicalDecomposition');
  63563. self::$cC = self::getData('combiningClass');
  63564. }
  63565. if (null !== $mbEncoding = (2 & (int) ini_get('mbstring.func_overload')) ? mb_internal_encoding() : null) {
  63566. mb_internal_encoding('8bit');
  63567. }
  63568. $r = self::decompose($s, $K);
  63569. if ($C) {
  63570. if (null === self::$C) {
  63571. self::$C = self::getData('canonicalComposition');
  63572. }
  63573. $r = self::recompose($r);
  63574. }
  63575. if (null !== $mbEncoding) {
  63576. mb_internal_encoding($mbEncoding);
  63577. }
  63578. return $r;
  63579. }
  63580. private static function recompose($s)
  63581. {
  63582. $ASCII = self::$ASCII;
  63583. $compMap = self::$C;
  63584. $combClass = self::$cC;
  63585. $ulenMask = self::$ulenMask;
  63586. $result = $tail = '';
  63587. $i = $s[0] < "\x80" ? 1 : $ulenMask[$s[0] & "\xF0"];
  63588. $len = \strlen($s);
  63589. $lastUchr = substr($s, 0, $i);
  63590. $lastUcls = isset($combClass[$lastUchr]) ? 256 : 0;
  63591. while ($i < $len) {
  63592. if ($s[$i] < "\x80") {
  63593. if ($tail) {
  63594. $lastUchr .= $tail;
  63595. $tail = '';
  63596. }
  63597. if ($j = strspn($s, $ASCII, $i + 1)) {
  63598. $lastUchr .= substr($s, $i, $j);
  63599. $i += $j;
  63600. }
  63601. $result .= $lastUchr;
  63602. $lastUchr = $s[$i];
  63603. $lastUcls = 0;
  63604. ++$i;
  63605. continue;
  63606. }
  63607. $ulen = $ulenMask[$s[$i] & "\xF0"];
  63608. $uchr = substr($s, $i, $ulen);
  63609. if ($lastUchr < "\xE1\x84\x80" || "\xE1\x84\x92" < $lastUchr
  63610. || $uchr < "\xE1\x85\xA1" || "\xE1\x85\xB5" < $uchr
  63611. || $lastUcls) {
  63612. $ucls = $combClass[$uchr] ?? 0;
  63613. if (isset($compMap[$lastUchr.$uchr]) && (!$lastUcls || $lastUcls < $ucls)) {
  63614. $lastUchr = $compMap[$lastUchr.$uchr];
  63615. } elseif ($lastUcls = $ucls) {
  63616. $tail .= $uchr;
  63617. } else {
  63618. if ($tail) {
  63619. $lastUchr .= $tail;
  63620. $tail = '';
  63621. }
  63622. $result .= $lastUchr;
  63623. $lastUchr = $uchr;
  63624. }
  63625. } else {
  63626. $L = \ord($lastUchr[2]) - 0x80;
  63627. $V = \ord($uchr[2]) - 0xA1;
  63628. $T = 0;
  63629. $uchr = substr($s, $i + $ulen, 3);
  63630. if ("\xE1\x86\xA7" <= $uchr && $uchr <= "\xE1\x87\x82") {
  63631. $T = \ord($uchr[2]) - 0xA7;
  63632. 0 > $T && $T += 0x40;
  63633. $ulen += 3;
  63634. }
  63635. $L = 0xAC00 + ($L * 21 + $V) * 28 + $T;
  63636. $lastUchr = \chr(0xE0 | $L >> 12).\chr(0x80 | $L >> 6 & 0x3F).\chr(0x80 | $L & 0x3F);
  63637. }
  63638. $i += $ulen;
  63639. }
  63640. return $result.$lastUchr.$tail;
  63641. }
  63642. private static function decompose($s, $c)
  63643. {
  63644. $result = '';
  63645. $ASCII = self::$ASCII;
  63646. $decompMap = self::$D;
  63647. $combClass = self::$cC;
  63648. $ulenMask = self::$ulenMask;
  63649. if ($c) {
  63650. $compatMap = self::$KD;
  63651. }
  63652. $c = [];
  63653. $i = 0;
  63654. $len = \strlen($s);
  63655. while ($i < $len) {
  63656. if ($s[$i] < "\x80") {
  63657. if ($c) {
  63658. ksort($c);
  63659. $result .= implode('', $c);
  63660. $c = [];
  63661. }
  63662. $j = 1 + strspn($s, $ASCII, $i + 1);
  63663. $result .= substr($s, $i, $j);
  63664. $i += $j;
  63665. continue;
  63666. }
  63667. $ulen = $ulenMask[$s[$i] & "\xF0"];
  63668. $uchr = substr($s, $i, $ulen);
  63669. $i += $ulen;
  63670. if ($uchr < "\xEA\xB0\x80" || "\xED\x9E\xA3" < $uchr) {
  63671. if ($uchr !== $j = $compatMap[$uchr] ?? ($decompMap[$uchr] ?? $uchr)) {
  63672. $uchr = $j;
  63673. $j = \strlen($uchr);
  63674. $ulen = $uchr[0] < "\x80" ? 1 : $ulenMask[$uchr[0] & "\xF0"];
  63675. if ($ulen != $j) {
  63676. $j -= $ulen;
  63677. $i -= $j;
  63678. if (0 > $i) {
  63679. $s = str_repeat(' ', -$i).$s;
  63680. $len -= $i;
  63681. $i = 0;
  63682. }
  63683. while ($j--) {
  63684. $s[$i + $j] = $uchr[$ulen + $j];
  63685. }
  63686. $uchr = substr($uchr, 0, $ulen);
  63687. }
  63688. }
  63689. if (isset($combClass[$uchr])) {
  63690. if (!isset($c[$combClass[$uchr]])) {
  63691. $c[$combClass[$uchr]] = '';
  63692. }
  63693. $c[$combClass[$uchr]] .= $uchr;
  63694. continue;
  63695. }
  63696. } else {
  63697. $uchr = unpack('C*', $uchr);
  63698. $j = (($uchr[1] - 224) << 12) + (($uchr[2] - 128) << 6) + $uchr[3] - 0xAC80;
  63699. $uchr = "\xE1\x84".\chr(0x80 + (int) ($j / 588))
  63700. ."\xE1\x85".\chr(0xA1 + (int) (($j % 588) / 28));
  63701. if ($j %= 28) {
  63702. $uchr .= $j < 25
  63703. ? ("\xE1\x86".\chr(0xA7 + $j))
  63704. : ("\xE1\x87".\chr(0x67 + $j));
  63705. }
  63706. }
  63707. if ($c) {
  63708. ksort($c);
  63709. $result .= implode('', $c);
  63710. $c = [];
  63711. }
  63712. $result .= $uchr;
  63713. }
  63714. if ($c) {
  63715. ksort($c);
  63716. $result .= implode('', $c);
  63717. }
  63718. return $result;
  63719. }
  63720. private static function getData($file)
  63721. {
  63722. if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) {
  63723. return require $file;
  63724. }
  63725. return false;
  63726. }
  63727. }
  63728. <?php
  63729. class Normalizer extends Symfony\Polyfill\Intl\Normalizer\Normalizer
  63730. {
  63731. public const NONE = 2;
  63732. public const FORM_D = 4;
  63733. public const FORM_KD = 8;
  63734. public const FORM_C = 16;
  63735. public const FORM_KC = 32;
  63736. public const NFD = 4;
  63737. public const NFKD = 8;
  63738. public const NFC = 16;
  63739. public const NFKC = 32;
  63740. }
  63741. <?php
  63742. return array (
  63743. 'À' => 'À',
  63744. 'A�' => '�',
  63745. 'Â' => 'Â',
  63746. 'Ã' => 'Ã',
  63747. 'Ä' => 'Ä',
  63748. 'AÌŠ' => 'Ã…',
  63749. 'Ç' => 'Ç',
  63750. 'È' => 'È',
  63751. 'E�' => 'É',
  63752. 'Ê' => 'Ê',
  63753. 'Ë' => 'Ë',
  63754. 'Ì' => 'Ì',
  63755. 'I�' => '�',
  63756. 'IÌ‚' => 'ÃŽ',
  63757. 'Ï' => '�',
  63758. 'Ñ' => 'Ñ',
  63759. 'OÌ€' => 'Ã’',
  63760. 'O�' => 'Ó',
  63761. 'Ô' => 'Ô',
  63762. 'Õ' => 'Õ',
  63763. 'Ö' => 'Ö',
  63764. 'Ù' => 'Ù',
  63765. 'U�' => 'Ú',
  63766. 'Û' => 'Û',
  63767. 'Ü' => 'Ü',
  63768. 'Y�' => '�',
  63769. 'à' => 'à',
  63770. 'a�' => 'á',
  63771. 'â' => 'â',
  63772. 'ã' => 'ã',
  63773. 'ä' => 'ä',
  63774. 'aÌŠ' => 'Ã¥',
  63775. 'ç' => 'ç',
  63776. 'è' => 'è',
  63777. 'e�' => 'é',
  63778. 'ê' => 'ê',
  63779. 'ë' => 'ë',
  63780. 'ì' => 'ì',
  63781. 'i�' => 'í',
  63782. 'î' => 'î',
  63783. 'ï' => 'ï',
  63784. 'ñ' => 'ñ',
  63785. 'ò' => 'ò',
  63786. 'o�' => 'ó',
  63787. 'ô' => 'ô',
  63788. 'õ' => 'õ',
  63789. 'ö' => 'ö',
  63790. 'ù' => 'ù',
  63791. 'u�' => 'ú',
  63792. 'û' => 'û',
  63793. 'ü' => 'ü',
  63794. 'y�' => 'ý',
  63795. 'ÿ' => 'ÿ',
  63796. 'AÌ„' => 'Ä€',
  63797. 'ā' => '�',
  63798. 'Ă' => 'Ă',
  63799. 'ă' => 'ă',
  63800. 'Ą' => 'Ą',
  63801. 'ą' => 'ą',
  63802. 'C�' => 'Ć',
  63803. 'c�' => 'ć',
  63804. 'Ĉ' => 'Ĉ',
  63805. 'ĉ' => 'ĉ',
  63806. 'Ċ' => 'Ċ',
  63807. 'ċ' => 'ċ',
  63808. 'Č' => 'Č',
  63809. 'č' => '�',
  63810. 'Ď' => 'Ď',
  63811. 'ď' => '�',
  63812. 'EÌ„' => 'Ä’',
  63813. 'ē' => 'ē',
  63814. 'Ĕ' => 'Ĕ',
  63815. 'ĕ' => 'ĕ',
  63816. 'Ė' => 'Ė',
  63817. 'ė' => 'ė',
  63818. 'Ę' => 'Ę',
  63819. 'ę' => 'ę',
  63820. 'Ě' => 'Ě',
  63821. 'ě' => 'ě',
  63822. 'Ĝ' => 'Ĝ',
  63823. 'ĝ' => '�',
  63824. 'Ğ' => 'Ğ',
  63825. 'ğ' => 'ğ',
  63826. 'Ġ' => 'Ġ',
  63827. 'ġ' => 'ġ',
  63828. 'Ģ' => 'Ģ',
  63829. 'ģ' => 'ģ',
  63830. 'Ĥ' => 'Ĥ',
  63831. 'ĥ' => 'ĥ',
  63832. 'Ĩ' => 'Ĩ',
  63833. 'ĩ' => 'ĩ',
  63834. 'Ī' => 'Ī',
  63835. 'ī' => 'ī',
  63836. 'Ĭ' => 'Ĭ',
  63837. 'ĭ' => 'ĭ',
  63838. 'Į' => 'Į',
  63839. 'į' => 'į',
  63840. 'İ' => 'İ',
  63841. 'JÌ‚' => 'Ä´',
  63842. 'ĵ' => 'ĵ',
  63843. 'Ķ' => 'Ķ',
  63844. 'ķ' => 'ķ',
  63845. 'L�' => 'Ĺ',
  63846. 'l�' => 'ĺ',
  63847. 'Ļ' => 'Ļ',
  63848. 'ļ' => 'ļ',
  63849. 'Ľ' => 'Ľ',
  63850. 'ľ' => 'ľ',
  63851. 'N�' => 'Ń',
  63852. 'n�' => 'ń',
  63853. 'Ņ' => 'Ņ',
  63854. 'ņ' => 'ņ',
  63855. 'Ň' => 'Ň',
  63856. 'ň' => 'ň',
  63857. 'Ō' => 'Ō',
  63858. 'ō' => '�',
  63859. 'Ŏ' => 'Ŏ',
  63860. 'ŏ' => '�',
  63861. 'Ő' => '�',
  63862. 'ő' => 'ő',
  63863. 'R�' => 'Ŕ',
  63864. 'r�' => 'ŕ',
  63865. 'Ŗ' => 'Ŗ',
  63866. 'ŗ' => 'ŗ',
  63867. 'Ř' => 'Ř',
  63868. 'ř' => 'ř',
  63869. 'S�' => 'Ś',
  63870. 's�' => 'ś',
  63871. 'Ŝ' => 'Ŝ',
  63872. 'ŝ' => '�',
  63873. 'Ş' => 'Ş',
  63874. 'ş' => 'ş',
  63875. 'Š' => 'Š',
  63876. 'š' => 'š',
  63877. 'Ţ' => 'Ţ',
  63878. 'ţ' => 'ţ',
  63879. 'Ť' => 'Ť',
  63880. 'ť' => 'ť',
  63881. 'Ũ' => 'Ũ',
  63882. 'ũ' => 'ũ',
  63883. 'Ū' => 'Ū',
  63884. 'ū' => 'ū',
  63885. 'Ŭ' => 'Ŭ',
  63886. 'ŭ' => 'ŭ',
  63887. 'UÌŠ' => 'Å®',
  63888. 'ů' => 'ů',
  63889. 'Ű' => 'Ű',
  63890. 'ű' => 'ű',
  63891. 'Ų' => 'Ų',
  63892. 'ų' => 'ų',
  63893. 'WÌ‚' => 'Å´',
  63894. 'ŵ' => 'ŵ',
  63895. 'Ŷ' => 'Ŷ',
  63896. 'ŷ' => 'ŷ',
  63897. 'Ÿ' => 'Ÿ',
  63898. 'Z�' => 'Ź',
  63899. 'z�' => 'ź',
  63900. 'Ż' => 'Ż',
  63901. 'ż' => 'ż',
  63902. 'Ž' => 'Ž',
  63903. 'ž' => 'ž',
  63904. 'OÌ›' => 'Æ ',
  63905. 'oÌ›' => 'Æ¡',
  63906. 'Ư' => 'Ư',
  63907. 'ư' => 'ư',
  63908. 'Ǎ' => '�',
  63909. 'ǎ' => 'ǎ',
  63910. 'Ǐ' => '�',
  63911. 'ǐ' => '�',
  63912. 'Ǒ' => 'Ǒ',
  63913. 'ǒ' => 'ǒ',
  63914. 'Ǔ' => 'Ǔ',
  63915. 'ǔ' => 'ǔ',
  63916. 'Ǖ' => 'Ǖ',
  63917. 'ǖ' => 'ǖ',
  63918. 'Ü�' => 'Ǘ',
  63919. 'ü�' => 'ǘ',
  63920. 'Ǚ' => 'Ǚ',
  63921. 'ǚ' => 'ǚ',
  63922. 'Ǜ' => 'Ǜ',
  63923. 'ǜ' => 'ǜ',
  63924. 'Ǟ' => 'Ǟ',
  63925. 'ǟ' => 'ǟ',
  63926. 'Ǡ' => 'Ǡ',
  63927. 'ǡ' => 'ǡ',
  63928. 'Ǣ' => 'Ǣ',
  63929. 'ǣ' => 'ǣ',
  63930. 'Ǧ' => 'Ǧ',
  63931. 'ǧ' => 'ǧ',
  63932. 'Ǩ' => 'Ǩ',
  63933. 'ǩ' => 'ǩ',
  63934. 'Ǫ' => 'Ǫ',
  63935. 'ǫ' => 'ǫ',
  63936. 'Ǭ' => 'Ǭ',
  63937. 'ǭ' => 'ǭ',
  63938. 'Ǯ' => 'Ǯ',
  63939. 'ǯ' => 'ǯ',
  63940. 'ǰ' => 'ǰ',
  63941. 'G�' => 'Ǵ',
  63942. 'g�' => 'ǵ',
  63943. 'Ǹ' => 'Ǹ',
  63944. 'ǹ' => 'ǹ',
  63945. 'Å�' => 'Ǻ',
  63946. 'å�' => 'ǻ',
  63947. 'Æ�' => 'Ǽ',
  63948. 'æ�' => 'ǽ',
  63949. 'Ø�' => 'Ǿ',
  63950. 'ø�' => 'ǿ',
  63951. 'A�' => 'Ȁ',
  63952. 'a�' => '�',
  63953. 'AÌ‘' => 'È‚',
  63954. 'ȃ' => 'ȃ',
  63955. 'E�' => 'Ȅ',
  63956. 'e�' => 'ȅ',
  63957. 'Ȇ' => 'Ȇ',
  63958. 'ȇ' => 'ȇ',
  63959. 'I�' => 'Ȉ',
  63960. 'i�' => 'ȉ',
  63961. 'IÌ‘' => 'ÈŠ',
  63962. 'ȋ' => 'ȋ',
  63963. 'O�' => 'Ȍ',
  63964. 'o�' => '�',
  63965. 'OÌ‘' => 'ÈŽ',
  63966. 'ȏ' => '�',
  63967. 'R�' => '�',
  63968. 'r�' => 'ȑ',
  63969. 'RÌ‘' => 'È’',
  63970. 'ȓ' => 'ȓ',
  63971. 'U�' => 'Ȕ',
  63972. 'u�' => 'ȕ',
  63973. 'UÌ‘' => 'È–',
  63974. 'ȗ' => 'ȗ',
  63975. 'Ș' => 'Ș',
  63976. 'ș' => 'ș',
  63977. 'Ț' => 'Ț',
  63978. 'ț' => 'ț',
  63979. 'Ȟ' => 'Ȟ',
  63980. 'ȟ' => 'ȟ',
  63981. 'Ȧ' => 'Ȧ',
  63982. 'ȧ' => 'ȧ',
  63983. 'Ȩ' => 'Ȩ',
  63984. 'ȩ' => 'ȩ',
  63985. 'Ȫ' => 'Ȫ',
  63986. 'ȫ' => 'ȫ',
  63987. 'Ȭ' => 'Ȭ',
  63988. 'ȭ' => 'ȭ',
  63989. 'Ȯ' => 'Ȯ',
  63990. 'ȯ' => 'ȯ',
  63991. 'Ȱ' => 'Ȱ',
  63992. 'ȱ' => 'ȱ',
  63993. 'Ȳ' => 'Ȳ',
  63994. 'ȳ' => 'ȳ',
  63995. '¨�' => '΅',
  63996. 'Α�' => 'Ά',
  63997. 'Ε�' => 'Έ',
  63998. 'Η�' => 'Ή',
  63999. 'Ι�' => 'Ί',
  64000. 'Ο�' => 'Ό',
  64001. 'Υ�' => 'Ύ',
  64002. 'Ω�' => '�',
  64003. 'ϊ�' => '�',
  64004. 'Ϊ' => 'Ϊ',
  64005. 'Ϋ' => 'Ϋ',
  64006. 'α�' => 'ά',
  64007. 'ε�' => 'έ',
  64008. 'η�' => 'ή',
  64009. 'ι�' => 'ί',
  64010. 'ϋ�' => 'ΰ',
  64011. 'ϊ' => 'ϊ',
  64012. 'ϋ' => 'ϋ',
  64013. 'ο�' => 'ό',
  64014. 'υ�' => '�',
  64015. 'ω�' => 'ώ',
  64016. 'ϒ�' => 'ϓ',
  64017. 'ϔ' => 'ϔ',
  64018. 'Ѐ' => 'Ѐ',
  64019. 'Ё' => '�',
  64020. 'Г�' => 'Ѓ',
  64021. 'Ї' => 'Ї',
  64022. 'К�' => 'Ќ',
  64023. 'Ѝ' => '�',
  64024. 'Ў' => 'Ў',
  64025. 'Й' => 'Й',
  64026. 'й' => 'й',
  64027. 'ѐ' => '�',
  64028. 'ё' => 'ё',
  64029. 'г�' => 'ѓ',
  64030. 'ї' => 'ї',
  64031. 'к�' => 'ќ',
  64032. 'ѝ' => '�',
  64033. 'ў' => 'ў',
  64034. 'Ѵ�' => 'Ѷ',
  64035. 'ѵ�' => 'ѷ',
  64036. 'Ӂ' => '�',
  64037. 'ӂ' => 'ӂ',
  64038. '�̆' => '�',
  64039. 'ӑ' => 'ӑ',
  64040. '�̈' => 'Ӓ',
  64041. 'ӓ' => 'ӓ',
  64042. 'Ӗ' => 'Ӗ',
  64043. 'ӗ' => 'ӗ',
  64044. 'Ӛ' => 'Ӛ',
  64045. 'ӛ' => 'ӛ',
  64046. 'Ӝ' => 'Ӝ',
  64047. 'ӝ' => '�',
  64048. 'Ӟ' => 'Ӟ',
  64049. 'ӟ' => 'ӟ',
  64050. 'Ӣ' => 'Ӣ',
  64051. 'ӣ' => 'ӣ',
  64052. 'Ӥ' => 'Ӥ',
  64053. 'ӥ' => 'ӥ',
  64054. 'Ӧ' => 'Ӧ',
  64055. 'ӧ' => 'ӧ',
  64056. 'Ӫ' => 'Ӫ',
  64057. 'ӫ' => 'ӫ',
  64058. 'Ӭ' => 'Ӭ',
  64059. '�̈' => 'ӭ',
  64060. 'Ӯ' => 'Ӯ',
  64061. 'ӯ' => 'ӯ',
  64062. 'Ӱ' => 'Ӱ',
  64063. 'ӱ' => 'ӱ',
  64064. 'Ӳ' => 'Ӳ',
  64065. 'ӳ' => 'ӳ',
  64066. 'Ӵ' => 'Ӵ',
  64067. 'ӵ' => 'ӵ',
  64068. 'Ӹ' => 'Ӹ',
  64069. 'ӹ' => 'ӹ',
  64070. 'آ' => 'آ',
  64071. 'أ' => 'أ',
  64072. 'ؤ' => 'ؤ',
  64073. 'إ' => 'إ',
  64074. 'ئ' => 'ئ',
  64075. 'Û•Ù”' => 'Û€',
  64076. 'Û�Ù”' => 'Û‚',
  64077. 'Û’Ù”' => 'Û“',
  64078. 'ऩ' => 'ऩ',
  64079. 'ऱ' => 'ऱ',
  64080. 'ऴ' => 'ऴ',
  64081. 'ো' => 'ো',
  64082. 'ৌ' => 'ৌ',
  64083. 'ୈ' => 'ୈ',
  64084. 'ୋ' => 'ୋ',
  64085. 'ୌ' => 'ୌ',
  64086. 'ஔ' => 'ஔ',
  64087. 'ொ' => 'ொ',
  64088. 'ோ' => 'ோ',
  64089. 'ௌ' => 'ௌ',
  64090. 'ై' => 'ై',
  64091. 'ೀ' => 'ೀ',
  64092. 'ೇ' => 'ೇ',
  64093. 'ೈ' => 'ೈ',
  64094. 'ೊ' => 'ೊ',
  64095. 'ೋ' => 'ೋ',
  64096. 'ൊ' => 'ൊ',
  64097. 'ോ' => 'ോ',
  64098. 'ൌ' => 'ൌ',
  64099. 'ේ' => 'ේ',
  64100. 'ෙ�' => 'ො',
  64101. 'ෝ' => '�',
  64102. 'ෞ' => 'ෞ',
  64103. 'ဦ' => 'ဦ',
  64104. 'ᬆ' => 'ᬆ',
  64105. 'ᬈ' => 'ᬈ',
  64106. 'ᬊ' => 'ᬊ',
  64107. 'ᬌ' => 'ᬌ',
  64108. '�ᬵ' => 'ᬎ',
  64109. 'ᬒ' => 'ᬒ',
  64110. 'ᬻ' => 'ᬻ',
  64111. 'ᬽ' => 'ᬽ',
  64112. 'ᭀ' => 'ᭀ',
  64113. 'ᭁ' => '�',
  64114. 'ᭃ' => 'ᭃ',
  64115. 'Ḁ' => 'Ḁ',
  64116. 'ḁ' => '�',
  64117. 'Ḃ' => 'Ḃ',
  64118. 'ḃ' => 'ḃ',
  64119. 'Ḅ' => 'Ḅ',
  64120. 'ḅ' => 'ḅ',
  64121. 'Ḇ' => 'Ḇ',
  64122. 'ḇ' => 'ḇ',
  64123. 'Ç�' => 'Ḉ',
  64124. 'ç�' => 'ḉ',
  64125. 'Ḋ' => 'Ḋ',
  64126. 'ḋ' => 'ḋ',
  64127. 'Ḍ' => 'Ḍ',
  64128. 'ḍ' => '�',
  64129. 'Ḏ' => 'Ḏ',
  64130. 'ḏ' => '�',
  64131. 'Ḑ' => '�',
  64132. 'ḑ' => 'ḑ',
  64133. 'Ḓ' => 'Ḓ',
  64134. 'ḓ' => 'ḓ',
  64135. 'Ḕ' => 'Ḕ',
  64136. 'ḕ' => 'ḕ',
  64137. 'Ē�' => 'Ḗ',
  64138. 'ē�' => 'ḗ',
  64139. 'Ḙ' => 'Ḙ',
  64140. 'ḙ' => 'ḙ',
  64141. 'Ḛ' => 'Ḛ',
  64142. 'ḛ' => 'ḛ',
  64143. 'Ḝ' => 'Ḝ',
  64144. 'ḝ' => '�',
  64145. 'Ḟ' => 'Ḟ',
  64146. 'ḟ' => 'ḟ',
  64147. 'Ḡ' => 'Ḡ',
  64148. 'ḡ' => 'ḡ',
  64149. 'Ḣ' => 'Ḣ',
  64150. 'ḣ' => 'ḣ',
  64151. 'Ḥ' => 'Ḥ',
  64152. 'ḥ' => 'ḥ',
  64153. 'Ḧ' => 'Ḧ',
  64154. 'ḧ' => 'ḧ',
  64155. 'Ḩ' => 'Ḩ',
  64156. 'ḩ' => 'ḩ',
  64157. 'Ḫ' => 'Ḫ',
  64158. 'ḫ' => 'ḫ',
  64159. 'Ḭ' => 'Ḭ',
  64160. 'ḭ' => 'ḭ',
  64161. '��' => 'Ḯ',
  64162. 'ï�' => 'ḯ',
  64163. 'K�' => 'Ḱ',
  64164. 'k�' => 'ḱ',
  64165. 'Ḳ' => 'Ḳ',
  64166. 'ḳ' => 'ḳ',
  64167. 'Ḵ' => 'Ḵ',
  64168. 'ḵ' => 'ḵ',
  64169. 'Ḷ' => 'Ḷ',
  64170. 'ḷ' => 'ḷ',
  64171. 'Ḹ' => 'Ḹ',
  64172. 'ḹ' => 'ḹ',
  64173. 'Ḻ' => 'Ḻ',
  64174. 'ḻ' => 'ḻ',
  64175. 'Ḽ' => 'Ḽ',
  64176. 'ḽ' => 'ḽ',
  64177. 'M�' => 'Ḿ',
  64178. 'm�' => 'ḿ',
  64179. 'Ṁ' => 'Ṁ',
  64180. 'ṁ' => '�',
  64181. 'Ṃ' => 'Ṃ',
  64182. 'ṃ' => 'ṃ',
  64183. 'Ṅ' => 'Ṅ',
  64184. 'ṅ' => 'ṅ',
  64185. 'Ṇ' => 'Ṇ',
  64186. 'ṇ' => 'ṇ',
  64187. 'Ṉ' => 'Ṉ',
  64188. 'ṉ' => 'ṉ',
  64189. 'Ṋ' => 'Ṋ',
  64190. 'ṋ' => 'ṋ',
  64191. 'Õ�' => 'Ṍ',
  64192. 'õ�' => '�',
  64193. 'Ṏ' => 'Ṏ',
  64194. 'ṏ' => '�',
  64195. 'Ṑ' => '�',
  64196. '�̀' => 'ṑ',
  64197. 'Ō�' => 'Ṓ',
  64198. '��' => 'ṓ',
  64199. 'P�' => 'Ṕ',
  64200. 'p�' => 'ṕ',
  64201. 'Ṗ' => 'Ṗ',
  64202. 'ṗ' => 'ṗ',
  64203. 'Ṙ' => 'Ṙ',
  64204. 'ṙ' => 'ṙ',
  64205. 'Ṛ' => 'Ṛ',
  64206. 'ṛ' => 'ṛ',
  64207. 'Ṝ' => 'Ṝ',
  64208. 'ṝ' => '�',
  64209. 'Ṟ' => 'Ṟ',
  64210. 'ṟ' => 'ṟ',
  64211. 'Ṡ' => 'Ṡ',
  64212. 'ṡ' => 'ṡ',
  64213. 'SÌ£' => 'á¹¢',
  64214. 'ṣ' => 'ṣ',
  64215. 'Ṥ' => 'Ṥ',
  64216. 'ṥ' => 'ṥ',
  64217. 'Ṧ' => 'Ṧ',
  64218. 'ṧ' => 'ṧ',
  64219. 'Ṩ' => 'Ṩ',
  64220. 'ṩ' => 'ṩ',
  64221. 'Ṫ' => 'Ṫ',
  64222. 'ṫ' => 'ṫ',
  64223. 'Ṭ' => 'Ṭ',
  64224. 'ṭ' => 'ṭ',
  64225. 'Ṯ' => 'Ṯ',
  64226. 'ṯ' => 'ṯ',
  64227. 'TÌ­' => 'á¹°',
  64228. 'tÌ­' => 'á¹±',
  64229. 'Ṳ' => 'Ṳ',
  64230. 'ṳ' => 'ṳ',
  64231. 'Ṵ' => 'Ṵ',
  64232. 'ṵ' => 'ṵ',
  64233. 'UÌ­' => 'á¹¶',
  64234. 'uÌ­' => 'á¹·',
  64235. 'Ũ�' => 'Ṹ',
  64236. 'ũ�' => 'ṹ',
  64237. 'Ṻ' => 'Ṻ',
  64238. 'ṻ' => 'ṻ',
  64239. 'Ṽ' => 'Ṽ',
  64240. 'ṽ' => 'ṽ',
  64241. 'VÌ£' => 'á¹¾',
  64242. 'ṿ' => 'ṿ',
  64243. 'Ẁ' => 'Ẁ',
  64244. 'ẁ' => '�',
  64245. 'W�' => 'Ẃ',
  64246. 'w�' => 'ẃ',
  64247. 'Ẅ' => 'Ẅ',
  64248. 'ẅ' => 'ẅ',
  64249. 'Ẇ' => 'Ẇ',
  64250. 'ẇ' => 'ẇ',
  64251. 'Ẉ' => 'Ẉ',
  64252. 'ẉ' => 'ẉ',
  64253. 'Ẋ' => 'Ẋ',
  64254. 'ẋ' => 'ẋ',
  64255. 'Ẍ' => 'Ẍ',
  64256. 'ẍ' => '�',
  64257. 'Ẏ' => 'Ẏ',
  64258. 'ẏ' => '�',
  64259. 'Ẑ' => '�',
  64260. 'ẑ' => 'ẑ',
  64261. 'Ẓ' => 'Ẓ',
  64262. 'ẓ' => 'ẓ',
  64263. 'Ẕ' => 'Ẕ',
  64264. 'ẕ' => 'ẕ',
  64265. 'ẖ' => 'ẖ',
  64266. 'ẗ' => 'ẗ',
  64267. 'ẘ' => 'ẘ',
  64268. 'ẙ' => 'ẙ',
  64269. 'ẛ' => 'ẛ',
  64270. 'Ạ' => 'Ạ',
  64271. 'ạ' => 'ạ',
  64272. 'Ả' => 'Ả',
  64273. 'ả' => 'ả',
  64274. 'Â�' => 'Ấ',
  64275. 'â�' => 'ấ',
  64276. 'Ầ' => 'Ầ',
  64277. 'ầ' => 'ầ',
  64278. 'Ẩ' => 'Ẩ',
  64279. 'ẩ' => 'ẩ',
  64280. 'Ẫ' => 'Ẫ',
  64281. 'ẫ' => 'ẫ',
  64282. 'Ậ' => 'Ậ',
  64283. 'ậ' => 'ậ',
  64284. 'Ă�' => 'Ắ',
  64285. 'ă�' => 'ắ',
  64286. 'Ằ' => 'Ằ',
  64287. 'ằ' => 'ằ',
  64288. 'Ẳ' => 'Ẳ',
  64289. 'ẳ' => 'ẳ',
  64290. 'Ẵ' => 'Ẵ',
  64291. 'ẵ' => 'ẵ',
  64292. 'Ặ' => 'Ặ',
  64293. 'ặ' => 'ặ',
  64294. 'Ẹ' => 'Ẹ',
  64295. 'ẹ' => 'ẹ',
  64296. 'Ẻ' => 'Ẻ',
  64297. 'ẻ' => 'ẻ',
  64298. 'Ẽ' => 'Ẽ',
  64299. 'ẽ' => 'ẽ',
  64300. 'Ê�' => 'Ế',
  64301. 'ê�' => 'ế',
  64302. 'Ề' => 'Ề',
  64303. 'ề' => '�',
  64304. 'Ể' => 'Ể',
  64305. 'ể' => 'ể',
  64306. 'Ễ' => 'Ễ',
  64307. 'ễ' => 'ễ',
  64308. 'Ệ' => 'Ệ',
  64309. 'ệ' => 'ệ',
  64310. 'Ỉ' => 'Ỉ',
  64311. 'ỉ' => 'ỉ',
  64312. 'Ị' => 'Ị',
  64313. 'ị' => 'ị',
  64314. 'Ọ' => 'Ọ',
  64315. 'ọ' => '�',
  64316. 'Ỏ' => 'Ỏ',
  64317. 'ỏ' => '�',
  64318. 'Ô�' => '�',
  64319. 'ô�' => 'ố',
  64320. 'Ồ' => 'Ồ',
  64321. 'ồ' => 'ồ',
  64322. 'Ổ' => 'Ổ',
  64323. 'ổ' => 'ổ',
  64324. 'Ỗ' => 'Ỗ',
  64325. 'ỗ' => 'ỗ',
  64326. 'Ộ' => 'Ộ',
  64327. '�̂' => 'ộ',
  64328. 'Ơ�' => 'Ớ',
  64329. 'ơ�' => 'ớ',
  64330. 'Ờ' => 'Ờ',
  64331. 'ờ' => '�',
  64332. 'Ở' => 'Ở',
  64333. 'ở' => 'ở',
  64334. 'Ỡ' => 'Ỡ',
  64335. 'ỡ' => 'ỡ',
  64336. 'Ợ' => 'Ợ',
  64337. 'ợ' => 'ợ',
  64338. 'Ụ' => 'Ụ',
  64339. 'ụ' => 'ụ',
  64340. 'Ủ' => 'Ủ',
  64341. 'ủ' => 'ủ',
  64342. 'Ư�' => 'Ứ',
  64343. 'ư�' => 'ứ',
  64344. 'Ừ' => 'Ừ',
  64345. 'ừ' => 'ừ',
  64346. 'Ử' => 'Ử',
  64347. 'ử' => 'ử',
  64348. 'Ữ' => 'Ữ',
  64349. 'ữ' => 'ữ',
  64350. 'Ự' => 'Ự',
  64351. 'ự' => 'ự',
  64352. 'Ỳ' => 'Ỳ',
  64353. 'ỳ' => 'ỳ',
  64354. 'YÌ£' => 'á»´',
  64355. 'ỵ' => 'ỵ',
  64356. 'Ỷ' => 'Ỷ',
  64357. 'ỷ' => 'ỷ',
  64358. 'Ỹ' => 'Ỹ',
  64359. 'ỹ' => 'ỹ',
  64360. 'ἀ' => 'ἀ',
  64361. 'ἁ' => '�',
  64362. 'ἂ' => 'ἂ',
  64363. '�̀' => 'ἃ',
  64364. 'ἀ�' => 'ἄ',
  64365. '��' => 'ἅ',
  64366. 'ἆ' => 'ἆ',
  64367. '�͂' => 'ἇ',
  64368. 'Ἀ' => 'Ἀ',
  64369. 'Ἁ' => 'Ἁ',
  64370. 'Ἂ' => 'Ἂ',
  64371. 'Ἃ' => 'Ἃ',
  64372. 'Ἀ�' => 'Ἄ',
  64373. 'Ἁ�' => '�',
  64374. 'Ἆ' => 'Ἆ',
  64375. 'Ἇ' => '�',
  64376. 'ἐ' => '�',
  64377. 'ἑ' => 'ἑ',
  64378. '�̀' => 'ἒ',
  64379. 'ἓ' => 'ἓ',
  64380. '��' => 'ἔ',
  64381. 'ἑ�' => 'ἕ',
  64382. 'Ἐ' => 'Ἐ',
  64383. 'Ἑ' => 'Ἑ',
  64384. 'Ἒ' => 'Ἒ',
  64385. 'Ἓ' => 'Ἓ',
  64386. 'Ἐ�' => 'Ἔ',
  64387. 'Ἑ�' => '�',
  64388. 'ἠ' => 'ἠ',
  64389. 'ἡ' => 'ἡ',
  64390. 'ἢ' => 'ἢ',
  64391. 'ἣ' => 'ἣ',
  64392. 'ἠ�' => 'ἤ',
  64393. 'ἡ�' => 'ἥ',
  64394. 'ἦ' => 'ἦ',
  64395. 'ἧ' => 'ἧ',
  64396. 'Ἠ' => 'Ἠ',
  64397. 'Ἡ' => 'Ἡ',
  64398. 'Ἢ' => 'Ἢ',
  64399. 'Ἣ' => 'Ἣ',
  64400. 'Ἠ�' => 'Ἤ',
  64401. 'Ἡ�' => 'Ἥ',
  64402. 'Ἦ' => 'Ἦ',
  64403. 'Ἧ' => 'Ἧ',
  64404. 'ἰ' => 'ἰ',
  64405. 'ἱ' => 'ἱ',
  64406. 'á¼°Ì€' => 'á¼²',
  64407. 'ἳ' => 'ἳ',
  64408. 'ἰ�' => 'ἴ',
  64409. 'ἱ�' => 'ἵ',
  64410. 'á¼°Í‚' => 'á¼¶',
  64411. 'ἷ' => 'ἷ',
  64412. 'Ἰ' => 'Ἰ',
  64413. 'Ἱ' => 'Ἱ',
  64414. 'Ἲ' => 'Ἲ',
  64415. 'Ἳ' => 'Ἳ',
  64416. 'Ἰ�' => 'Ἴ',
  64417. 'Ἱ�' => 'Ἵ',
  64418. 'Ἶ' => 'Ἶ',
  64419. 'Ἷ' => 'Ἷ',
  64420. 'ὀ' => 'ὀ',
  64421. 'ὁ' => '�',
  64422. 'ὂ' => 'ὂ',
  64423. '�̀' => 'ὃ',
  64424. 'ὀ�' => 'ὄ',
  64425. '��' => 'ὅ',
  64426. 'Ὀ' => 'Ὀ',
  64427. 'Ὁ' => 'Ὁ',
  64428. 'Ὂ' => 'Ὂ',
  64429. 'Ὃ' => 'Ὃ',
  64430. 'Ὀ�' => 'Ὄ',
  64431. 'Ὁ�' => '�',
  64432. 'ὐ' => '�',
  64433. 'ὑ' => 'ὑ',
  64434. '�̀' => 'ὒ',
  64435. 'ὓ' => 'ὓ',
  64436. '��' => 'ὔ',
  64437. 'ὑ�' => 'ὕ',
  64438. '�͂' => 'ὖ',
  64439. 'ὗ' => 'ὗ',
  64440. 'Ὑ' => 'Ὑ',
  64441. 'Ὓ' => 'Ὓ',
  64442. 'Ὑ�' => '�',
  64443. 'Ὗ' => 'Ὗ',
  64444. 'ὠ' => 'ὠ',
  64445. 'ὡ' => 'ὡ',
  64446. 'ὢ' => 'ὢ',
  64447. 'ὣ' => 'ὣ',
  64448. 'ὠ�' => 'ὤ',
  64449. 'ὡ�' => 'ὥ',
  64450. 'ὦ' => 'ὦ',
  64451. 'ὧ' => 'ὧ',
  64452. 'Ὠ' => 'Ὠ',
  64453. 'Ὡ' => 'Ὡ',
  64454. 'Ὢ' => 'Ὢ',
  64455. 'Ὣ' => 'Ὣ',
  64456. 'Ὠ�' => 'Ὤ',
  64457. 'Ὡ�' => 'Ὥ',
  64458. 'Ὦ' => 'Ὦ',
  64459. 'Ὧ' => 'Ὧ',
  64460. 'ὰ' => 'ὰ',
  64461. 'ὲ' => 'ὲ',
  64462. 'ὴ' => 'ὴ',
  64463. 'ὶ' => 'ὶ',
  64464. 'ὸ' => 'ὸ',
  64465. 'ὺ' => 'ὺ',
  64466. 'ὼ' => 'ὼ',
  64467. 'ᾀ' => 'ᾀ',
  64468. '�ͅ' => '�',
  64469. 'ᾂ' => 'ᾂ',
  64470. 'ᾃ' => 'ᾃ',
  64471. 'ᾄ' => 'ᾄ',
  64472. 'á¼…Í…' => 'á¾…',
  64473. 'ᾆ' => 'ᾆ',
  64474. 'ᾇ' => 'ᾇ',
  64475. 'ᾈ' => 'ᾈ',
  64476. 'ᾉ' => 'ᾉ',
  64477. 'ᾊ' => 'ᾊ',
  64478. 'ᾋ' => 'ᾋ',
  64479. 'ᾌ' => 'ᾌ',
  64480. '�ͅ' => '�',
  64481. 'ᾎ' => 'ᾎ',
  64482. '�ͅ' => '�',
  64483. 'ᾐ' => '�',
  64484. 'ᾑ' => 'ᾑ',
  64485. 'ᾒ' => 'ᾒ',
  64486. 'ᾓ' => 'ᾓ',
  64487. 'ᾔ' => 'ᾔ',
  64488. 'ᾕ' => 'ᾕ',
  64489. 'ᾖ' => 'ᾖ',
  64490. 'á¼§Í…' => 'á¾—',
  64491. 'ᾘ' => 'ᾘ',
  64492. 'ᾙ' => 'ᾙ',
  64493. 'ᾚ' => 'ᾚ',
  64494. 'ᾛ' => 'ᾛ',
  64495. 'ᾜ' => 'ᾜ',
  64496. 'ᾝ' => '�',
  64497. 'ᾞ' => 'ᾞ',
  64498. 'ᾟ' => 'ᾟ',
  64499. 'á½ Í…' => 'á¾ ',
  64500. 'ᾡ' => 'ᾡ',
  64501. 'ᾢ' => 'ᾢ',
  64502. 'ᾣ' => 'ᾣ',
  64503. 'ᾤ' => 'ᾤ',
  64504. 'ᾥ' => 'ᾥ',
  64505. 'ᾦ' => 'ᾦ',
  64506. 'á½§Í…' => 'á¾§',
  64507. 'ᾨ' => 'ᾨ',
  64508. 'ᾩ' => 'ᾩ',
  64509. 'ᾪ' => 'ᾪ',
  64510. 'ᾫ' => 'ᾫ',
  64511. 'ᾬ' => 'ᾬ',
  64512. 'á½­Í…' => 'á¾­',
  64513. 'ᾮ' => 'ᾮ',
  64514. 'ᾯ' => 'ᾯ',
  64515. 'ᾰ' => 'ᾰ',
  64516. 'ᾱ' => 'ᾱ',
  64517. 'á½°Í…' => 'á¾²',
  64518. 'ᾳ' => 'ᾳ',
  64519. 'ᾴ' => 'ᾴ',
  64520. 'ᾶ' => 'ᾶ',
  64521. 'á¾¶Í…' => 'á¾·',
  64522. 'Ᾰ' => 'Ᾰ',
  64523. 'Ᾱ' => 'Ᾱ',
  64524. 'Ὰ' => 'Ὰ',
  64525. 'ᾼ' => 'ᾼ',
  64526. '῁' => '�',
  64527. 'á½´Í…' => 'á¿‚',
  64528. 'ῃ' => 'ῃ',
  64529. 'ῄ' => 'ῄ',
  64530. 'ῆ' => 'ῆ',
  64531. 'ῇ' => 'ῇ',
  64532. 'Ὲ' => 'Ὲ',
  64533. 'Ὴ' => 'Ὴ',
  64534. 'ῌ' => 'ῌ',
  64535. '῍' => '�',
  64536. '᾿�' => '῎',
  64537. '῏' => '�',
  64538. 'ῐ' => '�',
  64539. 'ῑ' => 'ῑ',
  64540. 'ÏŠÌ€' => 'á¿’',
  64541. 'ῖ' => 'ῖ',
  64542. 'ÏŠÍ‚' => 'á¿—',
  64543. 'Ῐ' => 'Ῐ',
  64544. 'Ῑ' => 'Ῑ',
  64545. 'Ὶ' => 'Ὶ',
  64546. '῝' => '�',
  64547. '῾�' => '῞',
  64548. '῟' => '῟',
  64549. 'ῠ' => 'ῠ',
  64550. 'Ï…Ì„' => 'á¿¡',
  64551. 'ῢ' => 'ῢ',
  64552. '�̓' => 'ῤ',
  64553. '�̔' => 'ῥ',
  64554. 'ῦ' => 'ῦ',
  64555. 'ῧ' => 'ῧ',
  64556. 'Ῠ' => 'Ῠ',
  64557. 'Ῡ' => 'Ῡ',
  64558. 'Ὺ' => 'Ὺ',
  64559. 'Ῥ' => 'Ῥ',
  64560. '῭' => '῭',
  64561. 'ῲ' => 'ῲ',
  64562. 'ῳ' => 'ῳ',
  64563. 'ÏŽÍ…' => 'á¿´',
  64564. 'ῶ' => 'ῶ',
  64565. 'á¿¶Í…' => 'á¿·',
  64566. 'Ὸ' => 'Ὸ',
  64567. 'Ὼ' => 'Ὼ',
  64568. 'ῼ' => 'ῼ',
  64569. '�̸' => '↚',
  64570. '↛' => '↛',
  64571. '↮' => '↮',
  64572. '�̸' => '�',
  64573. '⇎' => '⇎',
  64574. '⇏' => '�',
  64575. '∄' => '∄',
  64576. '∉' => '∉',
  64577. '∌' => '∌',
  64578. '∤' => '∤',
  64579. '∦' => '∦',
  64580. '≁' => '�',
  64581. '≄' => '≄',
  64582. '≇' => '≇',
  64583. '≉' => '≉',
  64584. '≠' => '≠',
  64585. '≢' => '≢',
  64586. '�̸' => '≭',
  64587. '≮' => '≮',
  64588. '≯' => '≯',
  64589. '≰' => '≰',
  64590. '≱' => '≱',
  64591. '≴' => '≴',
  64592. '≵' => '≵',
  64593. '≸' => '≸',
  64594. '≹' => '≹',
  64595. '⊀' => '⊀',
  64596. '⊁' => '�',
  64597. '⊄' => '⊄',
  64598. '⊅' => '⊅',
  64599. '⊈' => '⊈',
  64600. '⊉' => '⊉',
  64601. '⊬' => '⊬',
  64602. '⊭' => '⊭',
  64603. '⊮' => '⊮',
  64604. '⊯' => '⊯',
  64605. '⋠' => '⋠',
  64606. '⋡' => '⋡',
  64607. '⋢' => '⋢',
  64608. '⋣' => '⋣',
  64609. '⋪' => '⋪',
  64610. '⋫' => '⋫',
  64611. '⋬' => '⋬',
  64612. '⋭' => '⋭',
  64613. '�゙' => '�',
  64614. '�゙' => '�',
  64615. '�゙' => '�',
  64616. '�゙' => '�',
  64617. '�゙' => '�',
  64618. '�゙' => '�',
  64619. '�゙' => '�',
  64620. '�゙' => '�',
  64621. '�゙' => '�',
  64622. '�゙' => '�',
  64623. '�゙' => '�',
  64624. '�゙' => '�',
  64625. '�゙' => '�',
  64626. '�゙' => '�',
  64627. '�゙' => '�',
  64628. '�゙' => '�',
  64629. '�゚' => '�',
  64630. '�゙' => '�',
  64631. '�゚' => '�',
  64632. '�゙' => '�',
  64633. '�゚' => '�',
  64634. '�゙' => '�',
  64635. '�゚' => '�',
  64636. '�゙' => '�',
  64637. '�゚' => '�',
  64638. '�゙' => 'ゔ',
  64639. '�゙' => 'ゞ',
  64640. 'ガ' => 'ガ',
  64641. 'ã‚­ã‚™' => 'ã‚®',
  64642. 'グ' => 'グ',
  64643. 'ゲ' => 'ゲ',
  64644. 'ゴ' => 'ゴ',
  64645. 'ザ' => 'ザ',
  64646. 'ジ' => 'ジ',
  64647. 'ズ' => 'ズ',
  64648. 'ゼ' => 'ゼ',
  64649. 'ゾ' => 'ゾ',
  64650. 'ダ' => 'ダ',
  64651. '�゙' => 'ヂ',
  64652. 'ヅ' => 'ヅ',
  64653. 'デ' => 'デ',
  64654. 'ド' => 'ド',
  64655. '�゙' => '�',
  64656. '�゚' => 'パ',
  64657. 'ビ' => 'ビ',
  64658. 'ピ' => 'ピ',
  64659. 'ブ' => 'ブ',
  64660. 'プ' => 'プ',
  64661. 'ベ' => 'ベ',
  64662. 'ペ' => 'ペ',
  64663. 'ボ' => 'ボ',
  64664. 'ポ' => '�',
  64665. 'ヴ' => 'ヴ',
  64666. 'ヷ' => 'ヷ',
  64667. 'ヸ' => 'ヸ',
  64668. 'ヹ' => 'ヹ',
  64669. 'ヺ' => 'ヺ',
  64670. 'ヾ' => 'ヾ',
  64671. '𑂚' => '𑂚',
  64672. '𑂜' => '𑂜',
  64673. '𑂫' => '𑂫',
  64674. '𑄮' => '𑄮',
  64675. '𑄯' => '𑄯',
  64676. '�𑌾' => '�',
  64677. '��' => '�',
  64678. '𑒻' => '𑒻',
  64679. '𑒼' => '𑒼',
  64680. '𑒾' => '𑒾',
  64681. '𑖺' => '𑖺',
  64682. '𑖻' => '𑖻',
  64683. '𑤸' => '𑤸',
  64684. );
  64685. <?php
  64686. return array (
  64687. 'À' => 'À',
  64688. '�' => 'A�',
  64689. 'Â' => 'Â',
  64690. 'Ã' => 'Ã',
  64691. 'Ä' => 'Ä',
  64692. 'Ã…' => 'AÌŠ',
  64693. 'Ç' => 'Ç',
  64694. 'È' => 'È',
  64695. 'É' => 'E�',
  64696. 'Ê' => 'Ê',
  64697. 'Ë' => 'Ë',
  64698. 'Ì' => 'Ì',
  64699. '�' => 'I�',
  64700. 'ÃŽ' => 'IÌ‚',
  64701. '�' => 'Ï',
  64702. 'Ñ' => 'Ñ',
  64703. 'Ã’' => 'OÌ€',
  64704. 'Ó' => 'O�',
  64705. 'Ô' => 'Ô',
  64706. 'Õ' => 'Õ',
  64707. 'Ö' => 'Ö',
  64708. 'Ù' => 'Ù',
  64709. 'Ú' => 'U�',
  64710. 'Û' => 'Û',
  64711. 'Ü' => 'Ü',
  64712. '�' => 'Y�',
  64713. 'à' => 'à',
  64714. 'á' => 'a�',
  64715. 'â' => 'â',
  64716. 'ã' => 'ã',
  64717. 'ä' => 'ä',
  64718. 'Ã¥' => 'aÌŠ',
  64719. 'ç' => 'ç',
  64720. 'è' => 'è',
  64721. 'é' => 'e�',
  64722. 'ê' => 'ê',
  64723. 'ë' => 'ë',
  64724. 'ì' => 'ì',
  64725. 'í' => 'i�',
  64726. 'î' => 'î',
  64727. 'ï' => 'ï',
  64728. 'ñ' => 'ñ',
  64729. 'ò' => 'ò',
  64730. 'ó' => 'o�',
  64731. 'ô' => 'ô',
  64732. 'õ' => 'õ',
  64733. 'ö' => 'ö',
  64734. 'ù' => 'ù',
  64735. 'ú' => 'u�',
  64736. 'û' => 'û',
  64737. 'ü' => 'ü',
  64738. 'ý' => 'y�',
  64739. 'ÿ' => 'ÿ',
  64740. 'Ä€' => 'AÌ„',
  64741. '�' => 'ā',
  64742. 'Ă' => 'Ă',
  64743. 'ă' => 'ă',
  64744. 'Ą' => 'Ą',
  64745. 'ą' => 'ą',
  64746. 'Ć' => 'C�',
  64747. 'ć' => 'c�',
  64748. 'Ĉ' => 'Ĉ',
  64749. 'ĉ' => 'ĉ',
  64750. 'Ċ' => 'Ċ',
  64751. 'ċ' => 'ċ',
  64752. 'Č' => 'Č',
  64753. '�' => 'č',
  64754. 'Ď' => 'Ď',
  64755. '�' => 'ď',
  64756. 'Ä’' => 'EÌ„',
  64757. 'ē' => 'ē',
  64758. 'Ĕ' => 'Ĕ',
  64759. 'ĕ' => 'ĕ',
  64760. 'Ė' => 'Ė',
  64761. 'ė' => 'ė',
  64762. 'Ę' => 'Ę',
  64763. 'ę' => 'ę',
  64764. 'Ě' => 'Ě',
  64765. 'ě' => 'ě',
  64766. 'Ĝ' => 'Ĝ',
  64767. '�' => 'ĝ',
  64768. 'Ğ' => 'Ğ',
  64769. 'ğ' => 'ğ',
  64770. 'Ġ' => 'Ġ',
  64771. 'ġ' => 'ġ',
  64772. 'Ģ' => 'Ģ',
  64773. 'ģ' => 'ģ',
  64774. 'Ĥ' => 'Ĥ',
  64775. 'ĥ' => 'ĥ',
  64776. 'Ĩ' => 'Ĩ',
  64777. 'ĩ' => 'ĩ',
  64778. 'Ī' => 'Ī',
  64779. 'ī' => 'ī',
  64780. 'Ĭ' => 'Ĭ',
  64781. 'ĭ' => 'ĭ',
  64782. 'Į' => 'Į',
  64783. 'į' => 'į',
  64784. 'İ' => 'İ',
  64785. 'Ä´' => 'JÌ‚',
  64786. 'ĵ' => 'ĵ',
  64787. 'Ķ' => 'Ķ',
  64788. 'ķ' => 'ķ',
  64789. 'Ĺ' => 'L�',
  64790. 'ĺ' => 'l�',
  64791. 'Ļ' => 'Ļ',
  64792. 'ļ' => 'ļ',
  64793. 'Ľ' => 'Ľ',
  64794. 'ľ' => 'ľ',
  64795. 'Ń' => 'N�',
  64796. 'ń' => 'n�',
  64797. 'Ņ' => 'Ņ',
  64798. 'ņ' => 'ņ',
  64799. 'Ň' => 'Ň',
  64800. 'ň' => 'ň',
  64801. 'Ō' => 'Ō',
  64802. '�' => 'ō',
  64803. 'Ŏ' => 'Ŏ',
  64804. '�' => 'ŏ',
  64805. '�' => 'Ő',
  64806. 'ő' => 'ő',
  64807. 'Ŕ' => 'R�',
  64808. 'ŕ' => 'r�',
  64809. 'Ŗ' => 'Ŗ',
  64810. 'ŗ' => 'ŗ',
  64811. 'Ř' => 'Ř',
  64812. 'ř' => 'ř',
  64813. 'Ś' => 'S�',
  64814. 'ś' => 's�',
  64815. 'Ŝ' => 'Ŝ',
  64816. '�' => 'ŝ',
  64817. 'Ş' => 'Ş',
  64818. 'ş' => 'ş',
  64819. 'Š' => 'Š',
  64820. 'š' => 'š',
  64821. 'Ţ' => 'Ţ',
  64822. 'ţ' => 'ţ',
  64823. 'Ť' => 'Ť',
  64824. 'ť' => 'ť',
  64825. 'Ũ' => 'Ũ',
  64826. 'ũ' => 'ũ',
  64827. 'Ū' => 'Ū',
  64828. 'ū' => 'ū',
  64829. 'Ŭ' => 'Ŭ',
  64830. 'ŭ' => 'ŭ',
  64831. 'Å®' => 'UÌŠ',
  64832. 'ů' => 'ů',
  64833. 'Ű' => 'Ű',
  64834. 'ű' => 'ű',
  64835. 'Ų' => 'Ų',
  64836. 'ų' => 'ų',
  64837. 'Å´' => 'WÌ‚',
  64838. 'ŵ' => 'ŵ',
  64839. 'Ŷ' => 'Ŷ',
  64840. 'ŷ' => 'ŷ',
  64841. 'Ÿ' => 'Ÿ',
  64842. 'Ź' => 'Z�',
  64843. 'ź' => 'z�',
  64844. 'Ż' => 'Ż',
  64845. 'ż' => 'ż',
  64846. 'Ž' => 'Ž',
  64847. 'ž' => 'ž',
  64848. 'Æ ' => 'OÌ›',
  64849. 'Æ¡' => 'oÌ›',
  64850. 'Ư' => 'Ư',
  64851. 'ư' => 'ư',
  64852. '�' => 'Ǎ',
  64853. 'ǎ' => 'ǎ',
  64854. '�' => 'Ǐ',
  64855. '�' => 'ǐ',
  64856. 'Ǒ' => 'Ǒ',
  64857. 'ǒ' => 'ǒ',
  64858. 'Ǔ' => 'Ǔ',
  64859. 'ǔ' => 'ǔ',
  64860. 'Ǖ' => 'Ǖ',
  64861. 'ǖ' => 'ǖ',
  64862. 'Ǘ' => 'Ü�',
  64863. 'ǘ' => 'ü�',
  64864. 'Ǚ' => 'Ǚ',
  64865. 'ǚ' => 'ǚ',
  64866. 'Ǜ' => 'Ǜ',
  64867. 'ǜ' => 'ǜ',
  64868. 'Ǟ' => 'Ǟ',
  64869. 'ǟ' => 'ǟ',
  64870. 'Ǡ' => 'Ǡ',
  64871. 'ǡ' => 'ǡ',
  64872. 'Ǣ' => 'Ǣ',
  64873. 'ǣ' => 'ǣ',
  64874. 'Ǧ' => 'Ǧ',
  64875. 'ǧ' => 'ǧ',
  64876. 'Ǩ' => 'Ǩ',
  64877. 'ǩ' => 'ǩ',
  64878. 'Ǫ' => 'Ǫ',
  64879. 'ǫ' => 'ǫ',
  64880. 'Ǭ' => 'Ǭ',
  64881. 'ǭ' => 'ǭ',
  64882. 'Ǯ' => 'Ǯ',
  64883. 'ǯ' => 'ǯ',
  64884. 'ǰ' => 'ǰ',
  64885. 'Ǵ' => 'G�',
  64886. 'ǵ' => 'g�',
  64887. 'Ǹ' => 'Ǹ',
  64888. 'ǹ' => 'ǹ',
  64889. 'Ǻ' => 'Å�',
  64890. 'ǻ' => 'å�',
  64891. 'Ǽ' => 'Æ�',
  64892. 'ǽ' => 'æ�',
  64893. 'Ǿ' => 'Ø�',
  64894. 'ǿ' => 'ø�',
  64895. 'Ȁ' => 'A�',
  64896. '�' => 'a�',
  64897. 'È‚' => 'AÌ‘',
  64898. 'ȃ' => 'ȃ',
  64899. 'Ȅ' => 'E�',
  64900. 'ȅ' => 'e�',
  64901. 'Ȇ' => 'Ȇ',
  64902. 'ȇ' => 'ȇ',
  64903. 'Ȉ' => 'I�',
  64904. 'ȉ' => 'i�',
  64905. 'ÈŠ' => 'IÌ‘',
  64906. 'ȋ' => 'ȋ',
  64907. 'Ȍ' => 'O�',
  64908. '�' => 'o�',
  64909. 'ÈŽ' => 'OÌ‘',
  64910. '�' => 'ȏ',
  64911. '�' => 'R�',
  64912. 'ȑ' => 'r�',
  64913. 'È’' => 'RÌ‘',
  64914. 'ȓ' => 'ȓ',
  64915. 'Ȕ' => 'U�',
  64916. 'ȕ' => 'u�',
  64917. 'È–' => 'UÌ‘',
  64918. 'ȗ' => 'ȗ',
  64919. 'Ș' => 'Ș',
  64920. 'ș' => 'ș',
  64921. 'Ț' => 'Ț',
  64922. 'ț' => 'ț',
  64923. 'Ȟ' => 'Ȟ',
  64924. 'ȟ' => 'ȟ',
  64925. 'Ȧ' => 'Ȧ',
  64926. 'ȧ' => 'ȧ',
  64927. 'Ȩ' => 'Ȩ',
  64928. 'ȩ' => 'ȩ',
  64929. 'Ȫ' => 'Ȫ',
  64930. 'ȫ' => 'ȫ',
  64931. 'Ȭ' => 'Ȭ',
  64932. 'ȭ' => 'ȭ',
  64933. 'Ȯ' => 'Ȯ',
  64934. 'ȯ' => 'ȯ',
  64935. 'Ȱ' => 'Ȱ',
  64936. 'ȱ' => 'ȱ',
  64937. 'Ȳ' => 'Ȳ',
  64938. 'ȳ' => 'ȳ',
  64939. 'Í€' => 'Ì€',
  64940. '�' => '�',
  64941. '̓' => '̓',
  64942. '̈́' => '̈�',
  64943. 'ʹ' => 'ʹ',
  64944. ';' => ';',
  64945. '΅' => '¨�',
  64946. 'Ά' => 'Α�',
  64947. '·' => '·',
  64948. 'Έ' => 'Ε�',
  64949. 'Ή' => 'Η�',
  64950. 'Ί' => 'Ι�',
  64951. 'Ό' => 'Ο�',
  64952. 'Ύ' => 'Υ�',
  64953. '�' => 'Ω�',
  64954. '�' => 'ϊ�',
  64955. 'Ϊ' => 'Ϊ',
  64956. 'Ϋ' => 'Ϋ',
  64957. 'ά' => 'α�',
  64958. 'έ' => 'ε�',
  64959. 'ή' => 'η�',
  64960. 'ί' => 'ι�',
  64961. 'ΰ' => 'ϋ�',
  64962. 'ϊ' => 'ϊ',
  64963. 'ϋ' => 'ϋ',
  64964. 'ό' => 'ο�',
  64965. '�' => 'υ�',
  64966. 'ώ' => 'ω�',
  64967. 'ϓ' => 'ϒ�',
  64968. 'ϔ' => 'ϔ',
  64969. 'Ѐ' => 'Ѐ',
  64970. '�' => 'Ё',
  64971. 'Ѓ' => 'Г�',
  64972. 'Ї' => 'Ї',
  64973. 'Ќ' => 'К�',
  64974. '�' => 'Ѝ',
  64975. 'Ў' => 'Ў',
  64976. 'Й' => 'Й',
  64977. 'й' => 'й',
  64978. '�' => 'ѐ',
  64979. 'ё' => 'ё',
  64980. 'ѓ' => 'г�',
  64981. 'ї' => 'ї',
  64982. 'ќ' => 'к�',
  64983. '�' => 'ѝ',
  64984. 'ў' => 'ў',
  64985. 'Ѷ' => 'Ѵ�',
  64986. 'ѷ' => 'ѵ�',
  64987. '�' => 'Ӂ',
  64988. 'ӂ' => 'ӂ',
  64989. '�' => '�̆',
  64990. 'ӑ' => 'ӑ',
  64991. 'Ӓ' => '�̈',
  64992. 'ӓ' => 'ӓ',
  64993. 'Ӗ' => 'Ӗ',
  64994. 'ӗ' => 'ӗ',
  64995. 'Ӛ' => 'Ӛ',
  64996. 'ӛ' => 'ӛ',
  64997. 'Ӝ' => 'Ӝ',
  64998. '�' => 'ӝ',
  64999. 'Ӟ' => 'Ӟ',
  65000. 'ӟ' => 'ӟ',
  65001. 'Ӣ' => 'Ӣ',
  65002. 'ӣ' => 'ӣ',
  65003. 'Ӥ' => 'Ӥ',
  65004. 'ӥ' => 'ӥ',
  65005. 'Ӧ' => 'Ӧ',
  65006. 'ӧ' => 'ӧ',
  65007. 'Ӫ' => 'Ӫ',
  65008. 'ӫ' => 'ӫ',
  65009. 'Ӭ' => 'Ӭ',
  65010. 'ӭ' => '�̈',
  65011. 'Ӯ' => 'Ӯ',
  65012. 'ӯ' => 'ӯ',
  65013. 'Ӱ' => 'Ӱ',
  65014. 'ӱ' => 'ӱ',
  65015. 'Ӳ' => 'Ӳ',
  65016. 'ӳ' => 'ӳ',
  65017. 'Ӵ' => 'Ӵ',
  65018. 'ӵ' => 'ӵ',
  65019. 'Ӹ' => 'Ӹ',
  65020. 'ӹ' => 'ӹ',
  65021. 'آ' => 'آ',
  65022. 'أ' => 'أ',
  65023. 'ؤ' => 'ؤ',
  65024. 'إ' => 'إ',
  65025. 'ئ' => 'ئ',
  65026. 'Û€' => 'Û•Ù”',
  65027. 'Û‚' => 'Û�Ù”',
  65028. 'Û“' => 'Û’Ù”',
  65029. 'ऩ' => 'ऩ',
  65030. 'ऱ' => 'ऱ',
  65031. 'ऴ' => 'ऴ',
  65032. 'क़' => 'क़',
  65033. 'ख़' => 'ख़',
  65034. 'ग़' => 'ग़',
  65035. 'ज़' => 'ज़',
  65036. 'ड़' => 'ड़',
  65037. '�' => 'ढ़',
  65038. 'फ़' => 'फ़',
  65039. 'य़' => 'य़',
  65040. 'ো' => 'ো',
  65041. 'ৌ' => 'ৌ',
  65042. 'ড়' => 'ড়',
  65043. '�' => 'ঢ়',
  65044. 'য়' => 'য়',
  65045. 'ਲ਼' => 'ਲ਼',
  65046. 'ਸ਼' => 'ਸ਼',
  65047. 'ਖ਼' => 'ਖ਼',
  65048. 'ਗ਼' => 'ਗ਼',
  65049. 'ਜ਼' => 'ਜ਼',
  65050. 'ਫ਼' => 'ਫ਼',
  65051. 'ୈ' => 'ୈ',
  65052. 'ୋ' => 'ୋ',
  65053. 'ୌ' => 'ୌ',
  65054. 'ଡ଼' => 'ଡ଼',
  65055. '�' => 'ଢ଼',
  65056. 'ஔ' => 'ஔ',
  65057. 'ொ' => 'ொ',
  65058. 'ோ' => 'ோ',
  65059. 'ௌ' => 'ௌ',
  65060. 'ై' => 'ై',
  65061. 'ೀ' => 'ೀ',
  65062. 'ೇ' => 'ೇ',
  65063. 'ೈ' => 'ೈ',
  65064. 'ೊ' => 'ೊ',
  65065. 'ೋ' => 'ೋ',
  65066. 'ൊ' => 'ൊ',
  65067. 'ോ' => 'ോ',
  65068. 'ൌ' => 'ൌ',
  65069. 'ේ' => 'ේ',
  65070. 'ො' => 'ෙ�',
  65071. '�' => 'ෙ�්',
  65072. 'ෞ' => 'ෞ',
  65073. 'གྷ' => 'གྷ',
  65074. '�' => 'ཌྷ',
  65075. 'དྷ' => 'དྷ',
  65076. 'བྷ' => 'བྷ',
  65077. 'ཛྷ' => 'ཛྷ',
  65078. 'ཀྵ' => 'ཀྵ',
  65079. 'ཱི' => 'ཱི',
  65080. 'ཱུ' => 'ཱུ',
  65081. 'ྲྀ' => 'ྲྀ',
  65082. 'ླྀ' => 'ླྀ',
  65083. '�' => 'ཱྀ',
  65084. 'ྒྷ' => 'ྒྷ',
  65085. '�' => 'ྜྷ',
  65086. 'ྡྷ' => 'ྡྷ',
  65087. 'ྦྷ' => 'ྦྷ',
  65088. 'ྫྷ' => 'ྫྷ',
  65089. 'ྐྵ' => '�ྵ',
  65090. 'ဦ' => 'ဦ',
  65091. 'ᬆ' => 'ᬆ',
  65092. 'ᬈ' => 'ᬈ',
  65093. 'ᬊ' => 'ᬊ',
  65094. 'ᬌ' => 'ᬌ',
  65095. 'ᬎ' => '�ᬵ',
  65096. 'ᬒ' => 'ᬒ',
  65097. 'ᬻ' => 'ᬻ',
  65098. 'ᬽ' => 'ᬽ',
  65099. 'ᭀ' => 'ᭀ',
  65100. '�' => 'ᭁ',
  65101. 'ᭃ' => 'ᭃ',
  65102. 'Ḁ' => 'Ḁ',
  65103. '�' => 'ḁ',
  65104. 'Ḃ' => 'Ḃ',
  65105. 'ḃ' => 'ḃ',
  65106. 'Ḅ' => 'Ḅ',
  65107. 'ḅ' => 'ḅ',
  65108. 'Ḇ' => 'Ḇ',
  65109. 'ḇ' => 'ḇ',
  65110. 'Ḉ' => 'Ç�',
  65111. 'ḉ' => 'ç�',
  65112. 'Ḋ' => 'Ḋ',
  65113. 'ḋ' => 'ḋ',
  65114. 'Ḍ' => 'Ḍ',
  65115. '�' => 'ḍ',
  65116. 'Ḏ' => 'Ḏ',
  65117. '�' => 'ḏ',
  65118. '�' => 'Ḑ',
  65119. 'ḑ' => 'ḑ',
  65120. 'Ḓ' => 'Ḓ',
  65121. 'ḓ' => 'ḓ',
  65122. 'Ḕ' => 'Ḕ',
  65123. 'ḕ' => 'ḕ',
  65124. 'Ḗ' => 'Ē�',
  65125. 'ḗ' => 'ē�',
  65126. 'Ḙ' => 'Ḙ',
  65127. 'ḙ' => 'ḙ',
  65128. 'Ḛ' => 'Ḛ',
  65129. 'ḛ' => 'ḛ',
  65130. 'Ḝ' => 'Ḝ',
  65131. '�' => 'ḝ',
  65132. 'Ḟ' => 'Ḟ',
  65133. 'ḟ' => 'ḟ',
  65134. 'Ḡ' => 'Ḡ',
  65135. 'ḡ' => 'ḡ',
  65136. 'Ḣ' => 'Ḣ',
  65137. 'ḣ' => 'ḣ',
  65138. 'Ḥ' => 'Ḥ',
  65139. 'ḥ' => 'ḥ',
  65140. 'Ḧ' => 'Ḧ',
  65141. 'ḧ' => 'ḧ',
  65142. 'Ḩ' => 'Ḩ',
  65143. 'ḩ' => 'ḩ',
  65144. 'Ḫ' => 'Ḫ',
  65145. 'ḫ' => 'ḫ',
  65146. 'Ḭ' => 'Ḭ',
  65147. 'ḭ' => 'ḭ',
  65148. 'Ḯ' => 'Ï�',
  65149. 'ḯ' => 'ï�',
  65150. 'Ḱ' => 'K�',
  65151. 'ḱ' => 'k�',
  65152. 'Ḳ' => 'Ḳ',
  65153. 'ḳ' => 'ḳ',
  65154. 'Ḵ' => 'Ḵ',
  65155. 'ḵ' => 'ḵ',
  65156. 'Ḷ' => 'Ḷ',
  65157. 'ḷ' => 'ḷ',
  65158. 'Ḹ' => 'Ḹ',
  65159. 'ḹ' => 'ḹ',
  65160. 'Ḻ' => 'Ḻ',
  65161. 'ḻ' => 'ḻ',
  65162. 'Ḽ' => 'Ḽ',
  65163. 'ḽ' => 'ḽ',
  65164. 'Ḿ' => 'M�',
  65165. 'ḿ' => 'm�',
  65166. 'Ṁ' => 'Ṁ',
  65167. '�' => 'ṁ',
  65168. 'Ṃ' => 'Ṃ',
  65169. 'ṃ' => 'ṃ',
  65170. 'Ṅ' => 'Ṅ',
  65171. 'ṅ' => 'ṅ',
  65172. 'Ṇ' => 'Ṇ',
  65173. 'ṇ' => 'ṇ',
  65174. 'Ṉ' => 'Ṉ',
  65175. 'ṉ' => 'ṉ',
  65176. 'Ṋ' => 'Ṋ',
  65177. 'ṋ' => 'ṋ',
  65178. 'Ṍ' => 'Õ�',
  65179. '�' => 'õ�',
  65180. 'Ṏ' => 'Ṏ',
  65181. '�' => 'ṏ',
  65182. '�' => 'Ṑ',
  65183. 'ṑ' => 'ṑ',
  65184. 'Ṓ' => 'Ō�',
  65185. 'ṓ' => 'ō�',
  65186. 'Ṕ' => 'P�',
  65187. 'ṕ' => 'p�',
  65188. 'Ṗ' => 'Ṗ',
  65189. 'ṗ' => 'ṗ',
  65190. 'Ṙ' => 'Ṙ',
  65191. 'ṙ' => 'ṙ',
  65192. 'Ṛ' => 'Ṛ',
  65193. 'ṛ' => 'ṛ',
  65194. 'Ṝ' => 'Ṝ',
  65195. '�' => 'ṝ',
  65196. 'Ṟ' => 'Ṟ',
  65197. 'ṟ' => 'ṟ',
  65198. 'Ṡ' => 'Ṡ',
  65199. 'ṡ' => 'ṡ',
  65200. 'á¹¢' => 'SÌ£',
  65201. 'ṣ' => 'ṣ',
  65202. 'Ṥ' => 'S�̇',
  65203. 'ṥ' => 's�̇',
  65204. 'Ṧ' => 'Ṧ',
  65205. 'ṧ' => 'ṧ',
  65206. 'Ṩ' => 'Ṩ',
  65207. 'ṩ' => 'ṩ',
  65208. 'Ṫ' => 'Ṫ',
  65209. 'ṫ' => 'ṫ',
  65210. 'Ṭ' => 'Ṭ',
  65211. 'ṭ' => 'ṭ',
  65212. 'Ṯ' => 'Ṯ',
  65213. 'ṯ' => 'ṯ',
  65214. 'á¹°' => 'TÌ­',
  65215. 'á¹±' => 'tÌ­',
  65216. 'Ṳ' => 'Ṳ',
  65217. 'ṳ' => 'ṳ',
  65218. 'Ṵ' => 'Ṵ',
  65219. 'ṵ' => 'ṵ',
  65220. 'á¹¶' => 'UÌ­',
  65221. 'á¹·' => 'uÌ­',
  65222. 'Ṹ' => 'Ũ�',
  65223. 'ṹ' => 'ũ�',
  65224. 'Ṻ' => 'Ṻ',
  65225. 'ṻ' => 'ṻ',
  65226. 'Ṽ' => 'Ṽ',
  65227. 'ṽ' => 'ṽ',
  65228. 'á¹¾' => 'VÌ£',
  65229. 'ṿ' => 'ṿ',
  65230. 'Ẁ' => 'Ẁ',
  65231. '�' => 'ẁ',
  65232. 'Ẃ' => 'W�',
  65233. 'ẃ' => 'w�',
  65234. 'Ẅ' => 'Ẅ',
  65235. 'ẅ' => 'ẅ',
  65236. 'Ẇ' => 'Ẇ',
  65237. 'ẇ' => 'ẇ',
  65238. 'Ẉ' => 'Ẉ',
  65239. 'ẉ' => 'ẉ',
  65240. 'Ẋ' => 'Ẋ',
  65241. 'ẋ' => 'ẋ',
  65242. 'Ẍ' => 'Ẍ',
  65243. '�' => 'ẍ',
  65244. 'Ẏ' => 'Ẏ',
  65245. '�' => 'ẏ',
  65246. '�' => 'Ẑ',
  65247. 'ẑ' => 'ẑ',
  65248. 'Ẓ' => 'Ẓ',
  65249. 'ẓ' => 'ẓ',
  65250. 'Ẕ' => 'Ẕ',
  65251. 'ẕ' => 'ẕ',
  65252. 'ẖ' => 'ẖ',
  65253. 'ẗ' => 'ẗ',
  65254. 'ẘ' => 'ẘ',
  65255. 'ẙ' => 'ẙ',
  65256. 'ẛ' => 'ẛ',
  65257. 'Ạ' => 'Ạ',
  65258. 'ạ' => 'ạ',
  65259. 'Ả' => 'Ả',
  65260. 'ả' => 'ả',
  65261. 'Ấ' => 'Â�',
  65262. 'ấ' => 'â�',
  65263. 'Ầ' => 'Ầ',
  65264. 'ầ' => 'ầ',
  65265. 'Ẩ' => 'Ẩ',
  65266. 'ẩ' => 'ẩ',
  65267. 'Ẫ' => 'Ẫ',
  65268. 'ẫ' => 'ẫ',
  65269. 'Ậ' => 'Ậ',
  65270. 'ậ' => 'ậ',
  65271. 'Ắ' => 'Ă�',
  65272. 'ắ' => 'ă�',
  65273. 'Ằ' => 'Ằ',
  65274. 'ằ' => 'ằ',
  65275. 'Ẳ' => 'Ẳ',
  65276. 'ẳ' => 'ẳ',
  65277. 'Ẵ' => 'Ẵ',
  65278. 'ẵ' => 'ẵ',
  65279. 'Ặ' => 'Ặ',
  65280. 'ặ' => 'ặ',
  65281. 'Ẹ' => 'Ẹ',
  65282. 'ẹ' => 'ẹ',
  65283. 'Ẻ' => 'Ẻ',
  65284. 'ẻ' => 'ẻ',
  65285. 'Ẽ' => 'Ẽ',
  65286. 'ẽ' => 'ẽ',
  65287. 'Ế' => 'Ê�',
  65288. 'ế' => 'ê�',
  65289. 'Ề' => 'Ề',
  65290. '�' => 'ề',
  65291. 'Ể' => 'Ể',
  65292. 'ể' => 'ể',
  65293. 'Ễ' => 'Ễ',
  65294. 'ễ' => 'ễ',
  65295. 'Ệ' => 'Ệ',
  65296. 'ệ' => 'ệ',
  65297. 'Ỉ' => 'Ỉ',
  65298. 'ỉ' => 'ỉ',
  65299. 'Ị' => 'Ị',
  65300. 'ị' => 'ị',
  65301. 'Ọ' => 'Ọ',
  65302. '�' => 'ọ',
  65303. 'Ỏ' => 'Ỏ',
  65304. '�' => 'ỏ',
  65305. '�' => 'Ô�',
  65306. 'ố' => 'ô�',
  65307. 'Ồ' => 'Ồ',
  65308. 'ồ' => 'ồ',
  65309. 'Ổ' => 'Ổ',
  65310. 'ổ' => 'ổ',
  65311. 'Ỗ' => 'Ỗ',
  65312. 'ỗ' => 'ỗ',
  65313. 'Ộ' => 'Ộ',
  65314. 'ộ' => 'ộ',
  65315. 'Ớ' => 'Ơ�',
  65316. 'ớ' => 'ơ�',
  65317. 'Ờ' => 'Ờ',
  65318. '�' => 'ờ',
  65319. 'Ở' => 'Ở',
  65320. 'ở' => 'ở',
  65321. 'Ỡ' => 'Ỡ',
  65322. 'ỡ' => 'ỡ',
  65323. 'Ợ' => 'Ợ',
  65324. 'ợ' => 'ợ',
  65325. 'Ụ' => 'Ụ',
  65326. 'ụ' => 'ụ',
  65327. 'Ủ' => 'Ủ',
  65328. 'ủ' => 'ủ',
  65329. 'Ứ' => 'Ư�',
  65330. 'ứ' => 'ư�',
  65331. 'Ừ' => 'Ừ',
  65332. 'ừ' => 'ừ',
  65333. 'Ử' => 'Ử',
  65334. 'ử' => 'ử',
  65335. 'Ữ' => 'Ữ',
  65336. 'ữ' => 'ữ',
  65337. 'Ự' => 'Ự',
  65338. 'ự' => 'ự',
  65339. 'Ỳ' => 'Ỳ',
  65340. 'ỳ' => 'ỳ',
  65341. 'á»´' => 'YÌ£',
  65342. 'ỵ' => 'ỵ',
  65343. 'Ỷ' => 'Ỷ',
  65344. 'ỷ' => 'ỷ',
  65345. 'Ỹ' => 'Ỹ',
  65346. 'ỹ' => 'ỹ',
  65347. 'ἀ' => 'ἀ',
  65348. '�' => 'ἁ',
  65349. 'ἂ' => 'ἂ',
  65350. 'ἃ' => 'ἃ',
  65351. 'ἄ' => 'ἀ�',
  65352. 'ἅ' => 'ἁ�',
  65353. 'ἆ' => 'ἆ',
  65354. 'ἇ' => 'ἇ',
  65355. 'Ἀ' => 'Ἀ',
  65356. 'Ἁ' => 'Ἁ',
  65357. 'Ἂ' => 'Ἂ',
  65358. 'Ἃ' => 'Ἃ',
  65359. 'Ἄ' => 'Ἀ�',
  65360. '�' => 'Ἁ�',
  65361. 'Ἆ' => 'Ἆ',
  65362. '�' => 'Ἇ',
  65363. '�' => 'ἐ',
  65364. 'ἑ' => 'ἑ',
  65365. 'ἒ' => 'ἒ',
  65366. 'ἓ' => 'ἓ',
  65367. 'ἔ' => 'ἐ�',
  65368. 'ἕ' => 'ἑ�',
  65369. 'Ἐ' => 'Ἐ',
  65370. 'Ἑ' => 'Ἑ',
  65371. 'Ἒ' => 'Ἒ',
  65372. 'Ἓ' => 'Ἓ',
  65373. 'Ἔ' => 'Ἐ�',
  65374. '�' => 'Ἑ�',
  65375. 'ἠ' => 'ἠ',
  65376. 'ἡ' => 'ἡ',
  65377. 'ἢ' => 'ἢ',
  65378. 'ἣ' => 'ἣ',
  65379. 'ἤ' => 'ἠ�',
  65380. 'ἥ' => 'ἡ�',
  65381. 'ἦ' => 'ἦ',
  65382. 'ἧ' => 'ἧ',
  65383. 'Ἠ' => 'Ἠ',
  65384. 'Ἡ' => 'Ἡ',
  65385. 'Ἢ' => 'Ἢ',
  65386. 'Ἣ' => 'Ἣ',
  65387. 'Ἤ' => 'Ἠ�',
  65388. 'Ἥ' => 'Ἡ�',
  65389. 'Ἦ' => 'Ἦ',
  65390. 'Ἧ' => 'Ἧ',
  65391. 'ἰ' => 'ἰ',
  65392. 'ἱ' => 'ἱ',
  65393. 'ἲ' => 'ἲ',
  65394. 'ἳ' => 'ἳ',
  65395. 'ἴ' => 'ἰ�',
  65396. 'ἵ' => 'ἱ�',
  65397. 'ἶ' => 'ἶ',
  65398. 'ἷ' => 'ἷ',
  65399. 'Ἰ' => 'Ἰ',
  65400. 'Ἱ' => 'Ἱ',
  65401. 'Ἲ' => 'Ἲ',
  65402. 'Ἳ' => 'Ἳ',
  65403. 'Ἴ' => 'Ἰ�',
  65404. 'Ἵ' => 'Ἱ�',
  65405. 'Ἶ' => 'Ἶ',
  65406. 'Ἷ' => 'Ἷ',
  65407. 'ὀ' => 'ὀ',
  65408. '�' => 'ὁ',
  65409. 'ὂ' => 'ὂ',
  65410. 'ὃ' => 'ὃ',
  65411. 'ὄ' => 'ὀ�',
  65412. 'ὅ' => 'ὁ�',
  65413. 'Ὀ' => 'Ὀ',
  65414. 'Ὁ' => 'Ὁ',
  65415. 'Ὂ' => 'Ὂ',
  65416. 'Ὃ' => 'Ὃ',
  65417. 'Ὄ' => 'Ὀ�',
  65418. '�' => 'Ὁ�',
  65419. '�' => 'ὐ',
  65420. 'ὑ' => 'ὑ',
  65421. 'ὒ' => 'ὒ',
  65422. 'ὓ' => 'ὓ',
  65423. 'ὔ' => 'ὐ�',
  65424. 'ὕ' => 'ὑ�',
  65425. 'ὖ' => 'ὖ',
  65426. 'ὗ' => 'ὗ',
  65427. 'Ὑ' => 'Ὑ',
  65428. 'Ὓ' => 'Ὓ',
  65429. '�' => 'Ὑ�',
  65430. 'Ὗ' => 'Ὗ',
  65431. 'ὠ' => 'ὠ',
  65432. 'ὡ' => 'ὡ',
  65433. 'ὢ' => 'ὢ',
  65434. 'ὣ' => 'ὣ',
  65435. 'ὤ' => 'ὠ�',
  65436. 'ὥ' => 'ὡ�',
  65437. 'ὦ' => 'ὦ',
  65438. 'ὧ' => 'ὧ',
  65439. 'Ὠ' => 'Ὠ',
  65440. 'Ὡ' => 'Ὡ',
  65441. 'Ὢ' => 'Ὢ',
  65442. 'Ὣ' => 'Ὣ',
  65443. 'Ὤ' => 'Ὠ�',
  65444. 'Ὥ' => 'Ὡ�',
  65445. 'Ὦ' => 'Ὦ',
  65446. 'Ὧ' => 'Ὧ',
  65447. 'ὰ' => 'ὰ',
  65448. 'ά' => 'α�',
  65449. 'ὲ' => 'ὲ',
  65450. 'έ' => 'ε�',
  65451. 'ὴ' => 'ὴ',
  65452. 'ή' => 'η�',
  65453. 'ὶ' => 'ὶ',
  65454. 'ί' => 'ι�',
  65455. 'ὸ' => 'ὸ',
  65456. 'ό' => 'ο�',
  65457. 'ὺ' => 'ὺ',
  65458. 'ύ' => 'υ�',
  65459. 'ὼ' => 'ὼ',
  65460. 'ώ' => 'ω�',
  65461. 'ᾀ' => 'ᾀ',
  65462. '�' => 'ᾁ',
  65463. 'ᾂ' => 'ᾂ',
  65464. 'ᾃ' => 'ᾃ',
  65465. 'ᾄ' => 'ἀ�ͅ',
  65466. 'ᾅ' => 'ἁ�ͅ',
  65467. 'ᾆ' => 'ᾆ',
  65468. 'ᾇ' => 'ᾇ',
  65469. 'ᾈ' => 'ᾈ',
  65470. 'ᾉ' => 'ᾉ',
  65471. 'ᾊ' => 'ᾊ',
  65472. 'ᾋ' => 'ᾋ',
  65473. 'ᾌ' => 'Ἀ�ͅ',
  65474. '�' => 'Ἁ�ͅ',
  65475. 'ᾎ' => 'ᾎ',
  65476. '�' => 'ᾏ',
  65477. '�' => 'ᾐ',
  65478. 'ᾑ' => 'ᾑ',
  65479. 'ᾒ' => 'ᾒ',
  65480. 'ᾓ' => 'ᾓ',
  65481. 'ᾔ' => 'ἠ�ͅ',
  65482. 'ᾕ' => 'ἡ�ͅ',
  65483. 'ᾖ' => 'ᾖ',
  65484. 'ᾗ' => 'ᾗ',
  65485. 'ᾘ' => 'ᾘ',
  65486. 'ᾙ' => 'ᾙ',
  65487. 'ᾚ' => 'ᾚ',
  65488. 'ᾛ' => 'ᾛ',
  65489. 'ᾜ' => 'Ἠ�ͅ',
  65490. '�' => 'Ἡ�ͅ',
  65491. 'ᾞ' => 'ᾞ',
  65492. 'ᾟ' => 'ᾟ',
  65493. 'ᾠ' => 'ᾠ',
  65494. 'ᾡ' => 'ᾡ',
  65495. 'ᾢ' => 'ᾢ',
  65496. 'ᾣ' => 'ᾣ',
  65497. 'ᾤ' => 'ὠ�ͅ',
  65498. 'ᾥ' => 'ὡ�ͅ',
  65499. 'ᾦ' => 'ᾦ',
  65500. 'ᾧ' => 'ᾧ',
  65501. 'ᾨ' => 'ᾨ',
  65502. 'ᾩ' => 'ᾩ',
  65503. 'ᾪ' => 'ᾪ',
  65504. 'ᾫ' => 'ᾫ',
  65505. 'ᾬ' => 'Ὠ�ͅ',
  65506. 'ᾭ' => 'Ὡ�ͅ',
  65507. 'ᾮ' => 'ᾮ',
  65508. 'ᾯ' => 'ᾯ',
  65509. 'ᾰ' => 'ᾰ',
  65510. 'ᾱ' => 'ᾱ',
  65511. 'ᾲ' => 'ᾲ',
  65512. 'ᾳ' => 'ᾳ',
  65513. 'ᾴ' => 'α�ͅ',
  65514. 'ᾶ' => 'ᾶ',
  65515. 'ᾷ' => 'ᾷ',
  65516. 'Ᾰ' => 'Ᾰ',
  65517. 'Ᾱ' => 'Ᾱ',
  65518. 'Ὰ' => 'Ὰ',
  65519. 'Ά' => 'Α�',
  65520. 'ᾼ' => 'ᾼ',
  65521. 'ι' => 'ι',
  65522. '�' => '῁',
  65523. 'ῂ' => 'ῂ',
  65524. 'ῃ' => 'ῃ',
  65525. 'ῄ' => 'η�ͅ',
  65526. 'ῆ' => 'ῆ',
  65527. 'ῇ' => 'ῇ',
  65528. 'Ὲ' => 'Ὲ',
  65529. 'Έ' => 'Ε�',
  65530. 'Ὴ' => 'Ὴ',
  65531. 'Ή' => 'Η�',
  65532. 'ῌ' => 'ῌ',
  65533. '�' => '῍',
  65534. '῎' => '᾿�',
  65535. '�' => '῏',
  65536. '�' => 'ῐ',
  65537. 'ῑ' => 'ῑ',
  65538. 'ῒ' => 'ῒ',
  65539. 'ΐ' => 'ϊ�',
  65540. 'ῖ' => 'ῖ',
  65541. 'ῗ' => 'ῗ',
  65542. 'Ῐ' => 'Ῐ',
  65543. 'Ῑ' => 'Ῑ',
  65544. 'Ὶ' => 'Ὶ',
  65545. 'Ί' => 'Ι�',
  65546. '�' => '῝',
  65547. '῞' => '῾�',
  65548. '῟' => '῟',
  65549. 'ῠ' => 'ῠ',
  65550. 'á¿¡' => 'Ï…Ì„',
  65551. 'ῢ' => 'ῢ',
  65552. 'ΰ' => 'ϋ�',
  65553. 'ῤ' => '�̓',
  65554. 'ῥ' => '�̔',
  65555. 'ῦ' => 'ῦ',
  65556. 'ῧ' => 'ῧ',
  65557. 'Ῠ' => 'Ῠ',
  65558. 'Ῡ' => 'Ῡ',
  65559. 'Ὺ' => 'Ὺ',
  65560. 'Ύ' => 'Υ�',
  65561. 'Ῥ' => 'Ῥ',
  65562. '῭' => '῭',
  65563. '΅' => '¨�',
  65564. '`' => '`',
  65565. 'ῲ' => 'ῲ',
  65566. 'ῳ' => 'ῳ',
  65567. 'ῴ' => 'ω�ͅ',
  65568. 'ῶ' => 'ῶ',
  65569. 'ῷ' => 'ῷ',
  65570. 'Ὸ' => 'Ὸ',
  65571. 'Ό' => 'Ο�',
  65572. 'Ὼ' => 'Ὼ',
  65573. 'Ώ' => 'Ω�',
  65574. 'ῼ' => 'ῼ',
  65575. '´' => '´',
  65576. ' ' => ' ',
  65577. '�' => ' ',
  65578. 'Ω' => 'Ω',
  65579. 'K' => 'K',
  65580. 'â„«' => 'AÌŠ',
  65581. '↚' => '�̸',
  65582. '↛' => '↛',
  65583. '↮' => '↮',
  65584. '�' => '�̸',
  65585. '⇎' => '⇎',
  65586. '�' => '⇏',
  65587. '∄' => '∄',
  65588. '∉' => '∉',
  65589. '∌' => '∌',
  65590. '∤' => '∤',
  65591. '∦' => '∦',
  65592. '�' => '≁',
  65593. '≄' => '≄',
  65594. '≇' => '≇',
  65595. '≉' => '≉',
  65596. '≠' => '≠',
  65597. '≢' => '≢',
  65598. '≭' => '�̸',
  65599. '≮' => '≮',
  65600. '≯' => '≯',
  65601. '≰' => '≰',
  65602. '≱' => '≱',
  65603. '≴' => '≴',
  65604. '≵' => '≵',
  65605. '≸' => '≸',
  65606. '≹' => '≹',
  65607. '⊀' => '⊀',
  65608. '�' => '⊁',
  65609. '⊄' => '⊄',
  65610. '⊅' => '⊅',
  65611. '⊈' => '⊈',
  65612. '⊉' => '⊉',
  65613. '⊬' => '⊬',
  65614. '⊭' => '⊭',
  65615. '⊮' => '⊮',
  65616. '⊯' => '⊯',
  65617. '⋠' => '⋠',
  65618. '⋡' => '⋡',
  65619. '⋢' => '⋢',
  65620. '⋣' => '⋣',
  65621. '⋪' => '⋪',
  65622. '⋫' => '⋫',
  65623. '⋬' => '⋬',
  65624. '⋭' => '⋭',
  65625. '〈' => '〈',
  65626. '〉' => '〉',
  65627. '⫝̸' => '�̸',
  65628. '�' => '�゙',
  65629. '�' => '�゙',
  65630. '�' => '�゙',
  65631. '�' => '�゙',
  65632. '�' => '�゙',
  65633. '�' => '�゙',
  65634. '�' => '�゙',
  65635. '�' => '�゙',
  65636. '�' => '�゙',
  65637. '�' => '�゙',
  65638. '�' => '�゙',
  65639. '�' => '�゙',
  65640. '�' => '�゙',
  65641. '�' => '�゙',
  65642. '�' => '�゙',
  65643. '�' => '�゙',
  65644. '�' => '�゚',
  65645. '�' => '�゙',
  65646. '�' => '�゚',
  65647. '�' => '�゙',
  65648. '�' => '�゚',
  65649. '�' => '�゙',
  65650. '�' => '�゚',
  65651. '�' => '�゙',
  65652. '�' => '�゚',
  65653. 'ゔ' => '�゙',
  65654. 'ゞ' => '�゙',
  65655. 'ガ' => 'ガ',
  65656. 'ã‚®' => 'ã‚­ã‚™',
  65657. 'グ' => 'グ',
  65658. 'ゲ' => 'ゲ',
  65659. 'ゴ' => 'ゴ',
  65660. 'ザ' => 'ザ',
  65661. 'ジ' => 'ジ',
  65662. 'ズ' => 'ズ',
  65663. 'ゼ' => 'ゼ',
  65664. 'ゾ' => 'ゾ',
  65665. 'ダ' => 'ダ',
  65666. 'ヂ' => '�゙',
  65667. 'ヅ' => 'ヅ',
  65668. 'デ' => 'デ',
  65669. 'ド' => 'ド',
  65670. '�' => '�゙',
  65671. 'パ' => '�゚',
  65672. 'ビ' => 'ビ',
  65673. 'ピ' => 'ピ',
  65674. 'ブ' => 'ブ',
  65675. 'プ' => 'プ',
  65676. 'ベ' => 'ベ',
  65677. 'ペ' => 'ペ',
  65678. 'ボ' => 'ボ',
  65679. '�' => 'ポ',
  65680. 'ヴ' => 'ヴ',
  65681. 'ヷ' => 'ヷ',
  65682. 'ヸ' => 'ヸ',
  65683. 'ヹ' => 'ヹ',
  65684. 'ヺ' => 'ヺ',
  65685. 'ヾ' => 'ヾ',
  65686. '豈' => '豈',
  65687. '�' => '更',
  65688. '車' => '車',
  65689. '賈' => '賈',
  65690. '滑' => '滑',
  65691. '串' => '串',
  65692. '句' => '�',
  65693. '龜' => '龜',
  65694. '龜' => '龜',
  65695. '契' => '契',
  65696. '金' => '金',
  65697. '喇' => '喇',
  65698. '奈' => '奈',
  65699. '�' => '懶',
  65700. '癩' => '癩',
  65701. '�' => '羅',
  65702. '�' => '蘿',
  65703. '螺' => '螺',
  65704. '裸' => '裸',
  65705. '邏' => '�',
  65706. '樂' => '樂',
  65707. '洛' => '洛',
  65708. '烙' => '烙',
  65709. '珞' => '�',
  65710. '落' => '�',
  65711. '酪' => '酪',
  65712. '駱' => '駱',
  65713. '亂' => '亂',
  65714. '卵' => '�',
  65715. '�' => '欄',
  65716. '爛' => '爛',
  65717. '蘭' => '蘭',
  65718. '鸞' => '鸞',
  65719. '嵐' => '�',
  65720. '濫' => '濫',
  65721. '藍' => '�',
  65722. '襤' => '襤',
  65723. '拉' => '拉',
  65724. '臘' => '臘',
  65725. '蠟' => '蠟',
  65726. '廊' => '廊',
  65727. '朗' => '朗',
  65728. '浪' => '浪',
  65729. '狼' => '狼',
  65730. '郎' => '郎',
  65731. '來' => '來',
  65732. '冷' => '冷',
  65733. '勞' => '勞',
  65734. '擄' => '擄',
  65735. '櫓' => '櫓',
  65736. '爐' => '�',
  65737. '盧' => '盧',
  65738. '老' => '�',
  65739. '蘆' => '蘆',
  65740. '虜' => '虜',
  65741. '路' => '路',
  65742. '露' => '露',
  65743. '魯' => '魯',
  65744. '鷺' => '鷺',
  65745. '碌' => '碌',
  65746. '祿' => '祿',
  65747. '綠' => '綠',
  65748. '菉' => '�',
  65749. '錄' => '錄',
  65750. '鹿' => '鹿',
  65751. '�' => '論',
  65752. '壟' => '壟',
  65753. '弄' => '弄',
  65754. '籠' => '籠',
  65755. '聾' => '�',
  65756. '牢' => '牢',
  65757. '磊' => '磊',
  65758. '賂' => '賂',
  65759. '雷' => '雷',
  65760. '壘' => '壘',
  65761. '屢' => '屢',
  65762. '樓' => '樓',
  65763. '�' => '淚',
  65764. '漏' => '�',
  65765. '�' => '累',
  65766. '�' => '縷',
  65767. '陋' => '陋',
  65768. '勒' => '勒',
  65769. '肋' => '肋',
  65770. '凜' => '凜',
  65771. '凌' => '凌',
  65772. '稜' => '稜',
  65773. '綾' => '綾',
  65774. '菱' => '�',
  65775. '陵' => '陵',
  65776. '讀' => '讀',
  65777. '拏' => '�',
  65778. '樂' => '樂',
  65779. '�' => '諾',
  65780. '丹' => '丹',
  65781. '寧' => '寧',
  65782. '怒' => '怒',
  65783. '率' => '率',
  65784. '異' => '異',
  65785. '北' => '北',
  65786. '磻' => '磻',
  65787. '便' => '便',
  65788. '復' => '復',
  65789. '不' => '�',
  65790. '泌' => '泌',
  65791. '數' => '數',
  65792. '索' => '索',
  65793. '參' => '�',
  65794. '塞' => '塞',
  65795. '省' => '�',
  65796. '葉' => '葉',
  65797. '說' => '說',
  65798. '殺' => '殺',
  65799. '辰' => '辰',
  65800. '沈' => '沈',
  65801. '拾' => '拾',
  65802. '若' => '若',
  65803. '掠' => '掠',
  65804. '略' => '略',
  65805. '亮' => '亮',
  65806. '兩' => '兩',
  65807. '凉' => '凉',
  65808. '梁' => '�',
  65809. '糧' => '糧',
  65810. '良' => '良',
  65811. '諒' => '諒',
  65812. '量' => '�',
  65813. '勵' => '勵',
  65814. '呂' => '呂',
  65815. '�' => '女',
  65816. '廬' => '廬',
  65817. '旅' => '旅',
  65818. '濾' => '濾',
  65819. '礪' => '礪',
  65820. '閭' => '閭',
  65821. '驪' => '驪',
  65822. '麗' => '麗',
  65823. '黎' => '黎',
  65824. '力' => '力',
  65825. '曆' => '曆',
  65826. '歷' => '歷',
  65827. '�' => '轢',
  65828. '年' => '年',
  65829. '�' => '�',
  65830. '�' => '戀',
  65831. '撚' => '撚',
  65832. '漣' => '漣',
  65833. '煉' => '煉',
  65834. '璉' => '璉',
  65835. '秊' => '秊',
  65836. '練' => '練',
  65837. '聯' => '�',
  65838. '輦' => '輦',
  65839. '蓮' => '蓮',
  65840. '連' => '連',
  65841. '鍊' => '�',
  65842. '列' => '列',
  65843. '�' => '劣',
  65844. '咽' => '咽',
  65845. '烈' => '烈',
  65846. '裂' => '裂',
  65847. '說' => '說',
  65848. '廉' => '廉',
  65849. '念' => '念',
  65850. '捻' => '�',
  65851. '殮' => '殮',
  65852. '簾' => '簾',
  65853. '獵' => '�',
  65854. '令' => '令',
  65855. '囹' => '囹',
  65856. '寧' => '寧',
  65857. '嶺' => '嶺',
  65858. '怜' => '怜',
  65859. '玲' => '玲',
  65860. '瑩' => '瑩',
  65861. '羚' => '羚',
  65862. '聆' => '�',
  65863. '鈴' => '鈴',
  65864. '零' => '零',
  65865. '靈' => '�',
  65866. '領' => '領',
  65867. '例' => '例',
  65868. '禮' => '禮',
  65869. '醴' => '醴',
  65870. '隸' => '隸',
  65871. '惡' => '惡',
  65872. '了' => '了',
  65873. '僚' => '僚',
  65874. '寮' => '寮',
  65875. '尿' => '尿',
  65876. '料' => '料',
  65877. '樂' => '樂',
  65878. '燎' => '燎',
  65879. '�' => '療',
  65880. '蓼' => '蓼',
  65881. '遼' => '�',
  65882. '龍' => '�',
  65883. '暈' => '暈',
  65884. '阮' => '阮',
  65885. '劉' => '劉',
  65886. '杻' => '�',
  65887. '柳' => '柳',
  65888. '流' => '�',
  65889. '溜' => '溜',
  65890. '琉' => '�',
  65891. '�' => '留',
  65892. 'ï§Ž' => 'ç¡«',
  65893. '�' => '�',
  65894. '�' => '類',
  65895. 'ï§‘' => 'å…­',
  65896. '戮' => '戮',
  65897. '陸' => '陸',
  65898. '倫' => '倫',
  65899. 'ï§•' => 'å´™',
  65900. 'ï§–' => 'æ·ª',
  65901. '輪' => '輪',
  65902. '律' => '律',
  65903. 'ï§™' => 'æ…„',
  65904. 'ï§š' => 'æ —',
  65905. '率' => '率',
  65906. '隆' => '隆',
  65907. '�' => '利',
  65908. '吏' => '�',
  65909. 'ï§Ÿ' => 'å±¥',
  65910. '易' => '易',
  65911. '李' => '�',
  65912. '梨' => '梨',
  65913. 'ï§£' => 'æ³¥',
  65914. '理' => '�',
  65915. 'ï§¥' => 'ç—¢',
  65916. '罹' => '罹',
  65917. '裏' => '�',
  65918. '裡' => '裡',
  65919. '里' => '里',
  65920. '離' => '離',
  65921. '匿' => '匿',
  65922. '溺' => '溺',
  65923. '吝' => '�',
  65924. '燐' => '�',
  65925. '璘' => '璘',
  65926. 'ï§°' => 'è—º',
  65927. '隣' => '隣',
  65928. 'ï§²' => 'é±—',
  65929. '麟' => '麟',
  65930. 'ï§´' => 'æž—',
  65931. 'ï§µ' => 'æ·‹',
  65932. '臨' => '臨',
  65933. 'ï§·' => 'ç«‹',
  65934. '笠' => '笠',
  65935. 'ï§¹' => 'ç²’',
  65936. '狀' => '狀',
  65937. 'ï§»' => 'ç‚™',
  65938. 'ï§¼' => 'è­˜',
  65939. '什' => '什',
  65940. '茶' => '茶',
  65941. '刺' => '刺',
  65942. '切' => '切',
  65943. '�' => '度',
  65944. '拓' => '拓',
  65945. '糖' => '糖',
  65946. '宅' => '宅',
  65947. '洞' => '洞',
  65948. '暴' => '暴',
  65949. '輻' => '輻',
  65950. '行' => '行',
  65951. '降' => '�',
  65952. '見' => '見',
  65953. '廓' => '廓',
  65954. '兀' => '兀',
  65955. '�' => '嗀',
  65956. '�' => '塚',
  65957. '晴' => '晴',
  65958. '凞' => '凞',
  65959. '猪' => '猪',
  65960. '益' => '益',
  65961. '礼' => '礼',
  65962. '神' => '神',
  65963. '祥' => '祥',
  65964. '福' => '�',
  65965. '靖' => '�',
  65966. '�' => '精',
  65967. '羽' => '羽',
  65968. '蘒' => '蘒',
  65969. '諸' => '諸',
  65970. '逸' => '逸',
  65971. '都' => '都',
  65972. '飯' => '飯',
  65973. '飼' => '飼',
  65974. '館' => '館',
  65975. '鶴' => '鶴',
  65976. '郞' => '郞',
  65977. '隷' => '隷',
  65978. '侮' => '侮',
  65979. '僧' => '僧',
  65980. '免' => '�',
  65981. '勉' => '勉',
  65982. '勤' => '勤',
  65983. '卑' => '�',
  65984. '喝' => '�',
  65985. '嘆' => '嘆',
  65986. '器' => '器',
  65987. '塀' => '塀',
  65988. '墨' => '墨',
  65989. '層' => '層',
  65990. '屮' => '屮',
  65991. '悔' => '悔',
  65992. '慨' => '慨',
  65993. '憎' => '憎',
  65994. '懲' => '懲',
  65995. '�' => '�',
  65996. 'ï©‚' => 'æ—¢',
  65997. '暑' => '暑',
  65998. '梅' => '梅',
  65999. 'ï©…' => 'æµ·',
  66000. '渚' => '渚',
  66001. '漢' => '漢',
  66002. '煮' => '煮',
  66003. '爫' => '爫',
  66004. '琢' => '�',
  66005. '碑' => '碑',
  66006. '社' => '社',
  66007. '�' => '祉',
  66008. '祈' => '祈',
  66009. '�' => '�',
  66010. '�' => '祖',
  66011. '祝' => '�',
  66012. '禍' => '�',
  66013. '禎' => '禎',
  66014. 'ï©”' => 'ç©€',
  66015. '突' => '�',
  66016. '節' => '節',
  66017. 'ï©—' => 'ç·´',
  66018. '縉' => '縉',
  66019. '繁' => '�',
  66020. '署' => '署',
  66021. '者' => '者',
  66022. '臭' => '臭',
  66023. '�' => '艹',
  66024. '艹' => '艹',
  66025. '著' => '著',
  66026. '褐' => '�',
  66027. '視' => '視',
  66028. '謁' => '�',
  66029. '謹' => '謹',
  66030. '賓' => '賓',
  66031. 'ï©¥' => 'è´ˆ',
  66032. '辶' => '辶',
  66033. '逸' => '逸',
  66034. '難' => '難',
  66035. '響' => '響',
  66036. '頻' => '頻',
  66037. '恵' => '�',
  66038. '𤋮' => '𤋮',
  66039. '舘' => '舘',
  66040. '並' => '並',
  66041. '况' => '况',
  66042. '全' => '全',
  66043. '侀' => '侀',
  66044. 'ï©´' => 'å……',
  66045. '冀' => '冀',
  66046. '勇' => '勇',
  66047. '勺' => '勺',
  66048. '喝' => '�',
  66049. '啕' => '啕',
  66050. '喙' => '喙',
  66051. 'ï©»' => 'å—¢',
  66052. '塚' => '塚',
  66053. '墳' => '墳',
  66054. '奄' => '奄',
  66055. '奔' => '奔',
  66056. '婢' => '婢',
  66057. '�' => '嬨',
  66058. '廒' => '廒',
  66059. '廙' => '廙',
  66060. '彩' => '彩',
  66061. '徭' => '徭',
  66062. '惘' => '惘',
  66063. '慎' => '慎',
  66064. '愈' => '愈',
  66065. '憎' => '憎',
  66066. '慠' => '慠',
  66067. '懲' => '懲',
  66068. '戴' => '戴',
  66069. '�' => '�',
  66070. '搜' => '�',
  66071. '�' => '摒',
  66072. '�' => '敖',
  66073. '晴' => '晴',
  66074. '朗' => '朗',
  66075. '望' => '望',
  66076. '杖' => '�',
  66077. '歹' => '歹',
  66078. '殺' => '殺',
  66079. '流' => '�',
  66080. '滛' => '滛',
  66081. '滋' => '滋',
  66082. '漢' => '漢',
  66083. '瀞' => '瀞',
  66084. '煮' => '煮',
  66085. '�' => '瞧',
  66086. '爵' => '爵',
  66087. '犯' => '犯',
  66088. '猪' => '猪',
  66089. '瑱' => '瑱',
  66090. '甆' => '甆',
  66091. '画' => '画',
  66092. '瘝' => '�',
  66093. '瘟' => '瘟',
  66094. '益' => '益',
  66095. '盛' => '盛',
  66096. '直' => '直',
  66097. '睊' => '�',
  66098. '着' => '�',
  66099. '磌' => '磌',
  66100. '窱' => '窱',
  66101. '節' => '節',
  66102. '类' => '类',
  66103. '絛' => '絛',
  66104. '練' => '練',
  66105. '缾' => '缾',
  66106. '者' => '者',
  66107. '荒' => '�',
  66108. '華' => '�',
  66109. '蝹' => '�',
  66110. '襁' => '�',
  66111. '覆' => '覆',
  66112. '視' => '視',
  66113. '調' => '調',
  66114. '諸' => '諸',
  66115. '請' => '請',
  66116. '謁' => '�',
  66117. '諾' => '諾',
  66118. '諭' => '諭',
  66119. '謹' => '謹',
  66120. '變' => '變',
  66121. '�' => '贈',
  66122. '輸' => '輸',
  66123. '遲' => '�',
  66124. '醙' => '醙',
  66125. '鉶' => '鉶',
  66126. '陼' => '陼',
  66127. '難' => '難',
  66128. '靖' => '�',
  66129. '韛' => '韛',
  66130. '響' => '響',
  66131. 'ï«‹' => 'é ‹',
  66132. '頻' => '頻',
  66133. '�' => '鬒',
  66134. '龜' => '龜',
  66135. '�' => '𢡊',
  66136. '�' => '𢡄',
  66137. '𣏕' => '�',
  66138. '㮝' => '�',
  66139. '䀘' => '䀘',
  66140. '䀹' => '䀹',
  66141. '𥉉' => '𥉉',
  66142. '𥳐' => '�',
  66143. '𧻓' => '𧻓',
  66144. '齃' => '齃',
  66145. '龎' => '龎',
  66146. '�' => 'יִ',
  66147. 'ײַ' => 'ײַ',
  66148. 'שׁ' => 'ש�',
  66149. 'שׂ' => 'שׂ',
  66150. 'שּׁ' => 'שּ�',
  66151. 'שּׂ' => 'שּׂ',
  66152. 'אַ' => '�ַ',
  66153. 'אָ' => '�ָ',
  66154. 'אּ' => '�ּ',
  66155. 'בּ' => 'בּ',
  66156. 'גּ' => 'גּ',
  66157. 'דּ' => 'דּ',
  66158. 'הּ' => 'הּ',
  66159. 'וּ' => 'וּ',
  66160. 'זּ' => 'זּ',
  66161. 'טּ' => 'טּ',
  66162. 'יּ' => 'יּ',
  66163. 'ךּ' => 'ךּ',
  66164. 'כּ' => 'כּ',
  66165. 'לּ' => 'לּ',
  66166. 'מּ' => 'מּ',
  66167. 'ï­€' => '× Ö¼',
  66168. '�' => 'סּ',
  66169. 'ï­ƒ' => '×£Ö¼',
  66170. 'פּ' => 'פּ',
  66171. 'צּ' => 'צּ',
  66172. 'ï­‡' => '×§Ö¼',
  66173. 'רּ' => 'רּ',
  66174. 'שּ' => 'שּ',
  66175. 'תּ' => 'תּ',
  66176. 'וֹ' => 'וֹ',
  66177. 'בֿ' => 'בֿ',
  66178. 'ï­�' => '×›Ö¿',
  66179. 'פֿ' => 'פֿ',
  66180. '𑂚' => '𑂚',
  66181. '𑂜' => '𑂜',
  66182. '𑂫' => '𑂫',
  66183. '𑄮' => '𑄮',
  66184. '𑄯' => '𑄯',
  66185. '�' => '�𑌾',
  66186. '�' => '��',
  66187. '𑒻' => '𑒻',
  66188. '𑒼' => '𑒼',
  66189. '𑒾' => '𑒾',
  66190. '𑖺' => '𑖺',
  66191. '𑖻' => '𑖻',
  66192. '𑤸' => '𑤸',
  66193. '�' => '��',
  66194. '�' => '��',
  66195. '�' => '���',
  66196. '�' => '���',
  66197. '�' => '���',
  66198. '�' => '���',
  66199. '�' => '���',
  66200. '�' => '��',
  66201. '�' => '��',
  66202. '�' => '���',
  66203. '�' => '���',
  66204. '�' => '���',
  66205. '�' => '���',
  66206. '丽' => '丽',
  66207. '�' => '丸',
  66208. '乁' => '�',
  66209. '𠄢' => '𠄢',
  66210. '你' => '你',
  66211. '侮' => '侮',
  66212. '侻' => '侻',
  66213. '倂' => '倂',
  66214. '偺' => '�',
  66215. '備' => '備',
  66216. '僧' => '僧',
  66217. '像' => '�',
  66218. '㒞' => '㒞',
  66219. '�' => '𠘺',
  66220. '免' => '�',
  66221. '�' => '兔',
  66222. '�' => '兤',
  66223. '具' => '具',
  66224. '𠔜' => '𠔜',
  66225. '㒹' => '㒹',
  66226. '內' => '內',
  66227. '再' => '�',
  66228. '𠕋' => '𠕋',
  66229. '冗' => '冗',
  66230. '冤' => '冤',
  66231. '仌' => '仌',
  66232. '冬' => '冬',
  66233. '况' => '况',
  66234. '𩇟' => '𩇟',
  66235. '�' => '凵',
  66236. '刃' => '刃',
  66237. '㓟' => '㓟',
  66238. '刻' => '刻',
  66239. '剆' => '剆',
  66240. '割' => '割',
  66241. '剷' => '剷',
  66242. '㔕' => '㔕',
  66243. '勇' => '勇',
  66244. '勉' => '勉',
  66245. '勤' => '勤',
  66246. '勺' => '勺',
  66247. '包' => '包',
  66248. '匆' => '匆',
  66249. '北' => '北',
  66250. '卉' => '�',
  66251. '卑' => '�',
  66252. '博' => '�',
  66253. '即' => '�',
  66254. '卽' => '�',
  66255. '卿' => '�',
  66256. '卿' => '�',
  66257. '卿' => '�',
  66258. '𠨬' => '𠨬',
  66259. '灰' => '�',
  66260. '及' => '�',
  66261. '叟' => '�',
  66262. '𠭣' => '𠭣',
  66263. '叫' => '�',
  66264. '叱' => '�',
  66265. '吆' => '�',
  66266. '咞' => '咞',
  66267. '吸' => '�',
  66268. '呈' => '呈',
  66269. '周' => '周',
  66270. '咢' => '咢',
  66271. '�' => '哶',
  66272. '唐' => '�',
  66273. '啓' => '啓',
  66274. '啣' => '啣',
  66275. '善' => '善',
  66276. '善' => '善',
  66277. '喙' => '喙',
  66278. '喫' => '喫',
  66279. '喳' => '喳',
  66280. '嗂' => '嗂',
  66281. '圖' => '圖',
  66282. '嘆' => '嘆',
  66283. '�' => '圗',
  66284. '噑' => '噑',
  66285. '�' => '噴',
  66286. '�' => '切',
  66287. '壮' => '壮',
  66288. '城' => '城',
  66289. '埴' => '埴',
  66290. '堍' => '�',
  66291. '型' => '型',
  66292. '堲' => '堲',
  66293. '報' => '報',
  66294. '墬' => '墬',
  66295. '𡓤' => '𡓤',
  66296. '売' => '売',
  66297. '壷' => '壷',
  66298. '夆' => '夆',
  66299. '�' => '多',
  66300. '夢' => '夢',
  66301. '奢' => '奢',
  66302. '𡚨' => '𡚨',
  66303. '𡛪' => '𡛪',
  66304. '姬' => '姬',
  66305. '娛' => '娛',
  66306. '娧' => '娧',
  66307. '姘' => '姘',
  66308. '婦' => '婦',
  66309. '㛮' => '㛮',
  66310. '㛼' => '㛼',
  66311. '嬈' => '嬈',
  66312. '嬾' => '嬾',
  66313. '嬾' => '嬾',
  66314. '𡧈' => '𡧈',
  66315. '寃' => '寃',
  66316. '寘' => '寘',
  66317. '寧' => '寧',
  66318. '寳' => '寳',
  66319. '𡬘' => '𡬘',
  66320. '寿' => '寿',
  66321. '将' => '将',
  66322. '当' => '当',
  66323. '尢' => '尢',
  66324. '㞁' => '�',
  66325. '屠' => '屠',
  66326. '屮' => '屮',
  66327. '峀' => '峀',
  66328. '岍' => '�',
  66329. '𡷤' => '𡷤',
  66330. '嵃' => '嵃',
  66331. '𡷦' => '𡷦',
  66332. '嵮' => '嵮',
  66333. '嵫' => '嵫',
  66334. '嵼' => '嵼',
  66335. '�' => '巡',
  66336. '巢' => '巢',
  66337. '㠯' => '㠯',
  66338. '巽' => '巽',
  66339. '帨' => '帨',
  66340. '帽' => '帽',
  66341. '幩' => '幩',
  66342. '㡢' => '㡢',
  66343. '𢆃' => '𢆃',
  66344. '㡼' => '㡼',
  66345. '庰' => '庰',
  66346. '庳' => '庳',
  66347. '�' => '庶',
  66348. '廊' => '廊',
  66349. '�' => '𪎒',
  66350. '�' => '廾',
  66351. '𢌱' => '𢌱',
  66352. '𢌱' => '𢌱',
  66353. '舁' => '�',
  66354. '弢' => '弢',
  66355. '弢' => '弢',
  66356. '㣇' => '㣇',
  66357. '𣊸' => '𣊸',
  66358. '𦇚' => '𦇚',
  66359. '形' => '形',
  66360. '彫' => '彫',
  66361. '㣣' => '㣣',
  66362. '徚' => '徚',
  66363. '�' => '�',
  66364. '志' => '志',
  66365. '忹' => '忹',
  66366. '悁' => '�',
  66367. '㤺' => '㤺',
  66368. '㤜' => '㤜',
  66369. '悔' => '悔',
  66370. '𢛔' => '𢛔',
  66371. '惇' => '惇',
  66372. '慈' => '慈',
  66373. '慌' => '慌',
  66374. '慎' => '慎',
  66375. '慌' => '慌',
  66376. '慺' => '慺',
  66377. '憎' => '憎',
  66378. '憲' => '憲',
  66379. '憤' => '憤',
  66380. '憯' => '憯',
  66381. '懞' => '懞',
  66382. '懲' => '懲',
  66383. '懶' => '懶',
  66384. '成' => '�',
  66385. '戛' => '戛',
  66386. '扝' => '�',
  66387. '抱' => '抱',
  66388. '拔' => '拔',
  66389. '捐' => '�',
  66390. '𢬌' => '𢬌',
  66391. '挽' => '挽',
  66392. '拼' => '拼',
  66393. '捨' => '�',
  66394. '掃' => '掃',
  66395. '揤' => '�',
  66396. '𢯱' => '𢯱',
  66397. '搢' => '�',
  66398. '揅' => '�',
  66399. '�' => '掩',
  66400. '㨮' => '㨮',
  66401. '摩' => '摩',
  66402. '摾' => '摾',
  66403. '撝' => '�',
  66404. '摷' => '摷',
  66405. '㩬' => '㩬',
  66406. '敏' => '�',
  66407. '敬' => '敬',
  66408. '𣀊' => '𣀊',
  66409. '旣' => '旣',
  66410. '書' => '書',
  66411. '�' => '晉',
  66412. '㬙' => '㬙',
  66413. '�' => '暑',
  66414. '�' => '㬈',
  66415. '㫤' => '㫤',
  66416. '冒' => '冒',
  66417. '冕' => '冕',
  66418. '最' => '最',
  66419. '暜' => '暜',
  66420. '肭' => '肭',
  66421. '䏙' => '�',
  66422. '朗' => '朗',
  66423. '望' => '望',
  66424. '朡' => '朡',
  66425. '杞' => '�',
  66426. '杓' => '�',
  66427. '�' => '�',
  66428. '㭉' => '㭉',
  66429. '柺' => '柺',
  66430. '枅' => '枅',
  66431. '桒' => '桒',
  66432. '梅' => '梅',
  66433. '𣑭' => '𣑭',
  66434. '梎' => '梎',
  66435. '栟' => '栟',
  66436. '椔' => '椔',
  66437. '㮝' => '�',
  66438. '楂' => '楂',
  66439. '榣' => '榣',
  66440. '槪' => '槪',
  66441. '檨' => '檨',
  66442. '𣚣' => '𣚣',
  66443. '櫛' => '櫛',
  66444. '㰘' => '㰘',
  66445. '次' => '次',
  66446. '𣢧' => '𣢧',
  66447. '歔' => '歔',
  66448. '㱎' => '㱎',
  66449. '歲' => '歲',
  66450. '殟' => '殟',
  66451. '殺' => '殺',
  66452. '殻' => '殻',
  66453. '𣪍' => '�',
  66454. '𡴋' => '𡴋',
  66455. '𣫺' => '𣫺',
  66456. '汎' => '汎',
  66457. '𣲼' => '𣲼',
  66458. '沿' => '沿',
  66459. '泍' => '�',
  66460. '汧' => '汧',
  66461. '洖' => '洖',
  66462. '派' => '派',
  66463. '�' => '海',
  66464. '流' => '�',
  66465. '浩' => '浩',
  66466. '浸' => '浸',
  66467. '涅' => '涅',
  66468. '𣴞' => '𣴞',
  66469. '洴' => '洴',
  66470. '港' => '港',
  66471. '湮' => '湮',
  66472. '㴳' => '㴳',
  66473. '滋' => '滋',
  66474. '滇' => '滇',
  66475. '�' => '𣻑',
  66476. '淹' => '淹',
  66477. '�' => '潮',
  66478. '�' => '𣽞',
  66479. '𣾎' => '𣾎',
  66480. '濆' => '濆',
  66481. '瀹' => '瀹',
  66482. '瀞' => '瀞',
  66483. '瀛' => '瀛',
  66484. '㶖' => '㶖',
  66485. '灊' => '�',
  66486. '災' => '�',
  66487. '灷' => '�',
  66488. '炭' => '炭',
  66489. '𠔥' => '𠔥',
  66490. '煅' => '煅',
  66491. '�' => '𤉣',
  66492. '熜' => '熜',
  66493. '𤎫' => '𤎫',
  66494. '爨' => '爨',
  66495. '爵' => '爵',
  66496. '牐' => '�',
  66497. '𤘈' => '𤘈',
  66498. '犀' => '犀',
  66499. '犕' => '犕',
  66500. '𤜵' => '𤜵',
  66501. '𤠔' => '𤠔',
  66502. '獺' => '�',
  66503. '王' => '王',
  66504. '㺬' => '㺬',
  66505. '玥' => '玥',
  66506. '㺸' => '㺸',
  66507. '㺸' => '㺸',
  66508. '瑇' => '瑇',
  66509. '瑜' => '瑜',
  66510. '瑱' => '瑱',
  66511. '璅' => '璅',
  66512. '瓊' => '瓊',
  66513. '㼛' => '㼛',
  66514. '甤' => '甤',
  66515. '𤰶' => '𤰶',
  66516. '甾' => '甾',
  66517. '𤲒' => '𤲒',
  66518. '異' => '異',
  66519. '𢆟' => '𢆟',
  66520. '瘐' => '�',
  66521. '𤾡' => '𤾡',
  66522. '𤾸' => '𤾸',
  66523. '𥁄' => '�',
  66524. '㿼' => '㿼',
  66525. '䀈' => '䀈',
  66526. '直' => '直',
  66527. '�' => '𥃳',
  66528. '𥃲' => '𥃲',
  66529. '𥄙' => '𥄙',
  66530. '𥄳' => '𥄳',
  66531. '眞' => '眞',
  66532. '真' => '真',
  66533. '真' => '真',
  66534. '睊' => '�',
  66535. '䀹' => '䀹',
  66536. '瞋' => '瞋',
  66537. '䁆' => '�',
  66538. '䂖' => '䂖',
  66539. '�' => '�',
  66540. '硎' => '硎',
  66541. '�' => '碌',
  66542. '�' => '磌',
  66543. '䃣' => '䃣',
  66544. '𥘦' => '𥘦',
  66545. '祖' => '祖',
  66546. '𥚚' => '𥚚',
  66547. '𥛅' => '𥛅',
  66548. '福' => '�',
  66549. '秫' => '秫',
  66550. '䄯' => '䄯',
  66551. '穀' => '穀',
  66552. '穊' => '穊',
  66553. '穏' => '�',
  66554. '𥥼' => '𥥼',
  66555. '�' => '𥪧',
  66556. '𥪧' => '𥪧',
  66557. '竮' => '竮',
  66558. '䈂' => '䈂',
  66559. '𥮫' => '𥮫',
  66560. '篆' => '篆',
  66561. '築' => '築',
  66562. '䈧' => '䈧',
  66563. '𥲀' => '𥲀',
  66564. '糒' => '糒',
  66565. '䊠' => '䊠',
  66566. '糨' => '糨',
  66567. '糣' => '糣',
  66568. '紀' => '紀',
  66569. '𥾆' => '𥾆',
  66570. '絣' => '絣',
  66571. '䌁' => '�',
  66572. '緇' => '緇',
  66573. '縂' => '縂',
  66574. '繅' => '繅',
  66575. '䌴' => '䌴',
  66576. '𦈨' => '𦈨',
  66577. '𦉇' => '𦉇',
  66578. '䍙' => '�',
  66579. '𦋙' => '𦋙',
  66580. '罺' => '罺',
  66581. '𦌾' => '𦌾',
  66582. '羕' => '羕',
  66583. '翺' => '翺',
  66584. '者' => '者',
  66585. '𦓚' => '𦓚',
  66586. '𦔣' => '𦔣',
  66587. '聠' => '�',
  66588. '𦖨' => '𦖨',
  66589. '聰' => '�',
  66590. '𣍟' => '�',
  66591. '�' => '�',
  66592. '育' => '育',
  66593. '脃' => '脃',
  66594. '䐋' => '�',
  66595. '脾' => '脾',
  66596. '媵' => '媵',
  66597. '𦞧' => '𦞧',
  66598. '𦞵' => '𦞵',
  66599. '𣎓' => '𣎓',
  66600. '𣎜' => '𣎜',
  66601. '舁' => '�',
  66602. '舄' => '舄',
  66603. '�' => '辞',
  66604. '䑫' => '䑫',
  66605. '�' => '芑',
  66606. '�' => '芋',
  66607. '芝' => '�',
  66608. '劳' => '劳',
  66609. '花' => '花',
  66610. '芳' => '芳',
  66611. '芽' => '芽',
  66612. '苦' => '苦',
  66613. '𦬼' => '𦬼',
  66614. '若' => '若',
  66615. '茝' => '�',
  66616. '荣' => '�',
  66617. '莭' => '莭',
  66618. '茣' => '茣',
  66619. '�' => '莽',
  66620. '菧' => '�',
  66621. '著' => '著',
  66622. '荓' => '�',
  66623. '菊' => '�',
  66624. '菌' => '�',
  66625. '菜' => '�',
  66626. '𦰶' => '𦰶',
  66627. '𦵫' => '𦵫',
  66628. '𦳕' => '𦳕',
  66629. '䔫' => '䔫',
  66630. '蓱' => '蓱',
  66631. '蓳' => '蓳',
  66632. '蔖' => '蔖',
  66633. '𧏊' => '�',
  66634. '蕤' => '蕤',
  66635. '𦼬' => '𦼬',
  66636. '䕝' => '�',
  66637. '䕡' => '䕡',
  66638. '𦾱' => '𦾱',
  66639. '𧃒' => '𧃒',
  66640. '䕫' => '䕫',
  66641. '虐' => '�',
  66642. '虜' => '虜',
  66643. '虧' => '虧',
  66644. '虩' => '虩',
  66645. '蚩' => '蚩',
  66646. '蚈' => '蚈',
  66647. '蜎' => '蜎',
  66648. '蛢' => '蛢',
  66649. '蝹' => '�',
  66650. '蜨' => '蜨',
  66651. '蝫' => '�',
  66652. '螆' => '螆',
  66653. '䗗' => '䗗',
  66654. '蟡' => '蟡',
  66655. '�' => '�',
  66656. '䗹' => '䗹',
  66657. '衠' => '衠',
  66658. '衣' => '衣',
  66659. '𧙧' => '𧙧',
  66660. '裗' => '裗',
  66661. '裞' => '裞',
  66662. '䘵' => '䘵',
  66663. '裺' => '裺',
  66664. '㒻' => '㒻',
  66665. '𧢮' => '𧢮',
  66666. '𧥦' => '𧥦',
  66667. '�' => '䚾',
  66668. '䛇' => '䛇',
  66669. '�' => '誠',
  66670. '�' => '諭',
  66671. '變' => '變',
  66672. '豕' => '豕',
  66673. '𧲨' => '𧲨',
  66674. '貫' => '貫',
  66675. '賁' => '�',
  66676. '贛' => '贛',
  66677. '起' => '起',
  66678. '𧼯' => '𧼯',
  66679. '𠠄' => '𠠄',
  66680. '跋' => '跋',
  66681. '趼' => '趼',
  66682. '跰' => '跰',
  66683. '�' => '𠣞',
  66684. '軔' => '軔',
  66685. '輸' => '輸',
  66686. '𨗒' => '𨗒',
  66687. '𨗭' => '𨗭',
  66688. '邔' => '邔',
  66689. '郱' => '郱',
  66690. '鄑' => '鄑',
  66691. '𨜮' => '𨜮',
  66692. '鄛' => '鄛',
  66693. '鈸' => '鈸',
  66694. '鋗' => '鋗',
  66695. '鋘' => '鋘',
  66696. '鉼' => '鉼',
  66697. '鏹' => '�',
  66698. '鐕' => '�',
  66699. '𨯺' => '𨯺',
  66700. '開' => '開',
  66701. '䦕' => '䦕',
  66702. '閷' => '閷',
  66703. '𨵷' => '𨵷',
  66704. '䧦' => '䧦',
  66705. '雃' => '雃',
  66706. '嶲' => '嶲',
  66707. '霣' => '霣',
  66708. '𩅅' => '𩅅',
  66709. '𩈚' => '𩈚',
  66710. '䩮' => '䩮',
  66711. '䩶' => '䩶',
  66712. '韠' => '韠',
  66713. '𩐊' => '�',
  66714. '䪲' => '䪲',
  66715. '𩒖' => '𩒖',
  66716. '頋' => '頋',
  66717. '頋' => '頋',
  66718. '頩' => '頩',
  66719. '�' => '𩖶',
  66720. '飢' => '飢',
  66721. '䬳' => '䬳',
  66722. '餩' => '餩',
  66723. '馧' => '馧',
  66724. '駂' => '駂',
  66725. '駾' => '駾',
  66726. '䯎' => '䯎',
  66727. '𩬰' => '𩬰',
  66728. '鬒' => '鬒',
  66729. '鱀' => '鱀',
  66730. '鳽' => '鳽',
  66731. '�' => '䳎',
  66732. '䳭' => '䳭',
  66733. '�' => '鵧',
  66734. '�' => '𪃎',
  66735. '䳸' => '䳸',
  66736. '𪄅' => '𪄅',
  66737. '𪈎' => '𪈎',
  66738. '𪊑' => '𪊑',
  66739. '麻' => '麻',
  66740. '䵖' => '䵖',
  66741. '黹' => '黹',
  66742. '黾' => '黾',
  66743. '鼅' => '鼅',
  66744. '鼏' => '�',
  66745. '鼖' => '鼖',
  66746. '鼻' => '鼻',
  66747. '�' => '𪘀',
  66748. );
  66749. <?php
  66750. return array (
  66751. 'Ì€' => 230,
  66752. '�' => 230,
  66753. 'Ì‚' => 230,
  66754. '̃' => 230,
  66755. 'Ì„' => 230,
  66756. 'Ì…' => 230,
  66757. '̆' => 230,
  66758. '̇' => 230,
  66759. '̈' => 230,
  66760. '̉' => 230,
  66761. 'ÌŠ' => 230,
  66762. 'Ì‹' => 230,
  66763. '̌' => 230,
  66764. '�' => 230,
  66765. 'ÌŽ' => 230,
  66766. '�' => 230,
  66767. '�' => 230,
  66768. 'Ì‘' => 230,
  66769. 'Ì’' => 230,
  66770. 'Ì“' => 230,
  66771. 'Ì”' => 230,
  66772. 'Ì•' => 232,
  66773. 'Ì–' => 220,
  66774. 'Ì—' => 220,
  66775. '̘' => 220,
  66776. 'Ì™' => 220,
  66777. 'Ìš' => 232,
  66778. 'Ì›' => 216,
  66779. '̜' => 220,
  66780. '�' => 220,
  66781. 'Ìž' => 220,
  66782. 'ÌŸ' => 220,
  66783. 'Ì ' => 220,
  66784. 'Ì¡' => 202,
  66785. 'Ì¢' => 202,
  66786. 'Ì£' => 220,
  66787. '̤' => 220,
  66788. 'Ì¥' => 220,
  66789. '̦' => 220,
  66790. '̧' => 202,
  66791. '̨' => 202,
  66792. 'Ì©' => 220,
  66793. '̪' => 220,
  66794. 'Ì«' => 220,
  66795. '̬' => 220,
  66796. 'Ì­' => 220,
  66797. 'Ì®' => 220,
  66798. '̯' => 220,
  66799. '̰' => 220,
  66800. '̱' => 220,
  66801. '̲' => 220,
  66802. '̳' => 220,
  66803. 'Ì´' => 1,
  66804. '̵' => 1,
  66805. '̶' => 1,
  66806. 'Ì·' => 1,
  66807. '̸' => 1,
  66808. '̹' => 220,
  66809. '̺' => 220,
  66810. 'Ì»' => 220,
  66811. '̼' => 220,
  66812. '̽' => 230,
  66813. '̾' => 230,
  66814. 'Ì¿' => 230,
  66815. 'Í€' => 230,
  66816. '�' => 230,
  66817. 'Í‚' => 230,
  66818. '̓' => 230,
  66819. 'Í„' => 230,
  66820. 'Í…' => 240,
  66821. '͆' => 230,
  66822. '͇' => 220,
  66823. '͈' => 220,
  66824. '͉' => 220,
  66825. 'ÍŠ' => 230,
  66826. 'Í‹' => 230,
  66827. '͌' => 230,
  66828. '�' => 220,
  66829. 'ÍŽ' => 220,
  66830. '�' => 230,
  66831. 'Í‘' => 230,
  66832. 'Í’' => 230,
  66833. 'Í“' => 220,
  66834. 'Í”' => 220,
  66835. 'Í•' => 220,
  66836. 'Í–' => 220,
  66837. 'Í—' => 230,
  66838. '͘' => 232,
  66839. 'Í™' => 220,
  66840. 'Íš' => 220,
  66841. 'Í›' => 230,
  66842. '͜' => 233,
  66843. '�' => 234,
  66844. 'Íž' => 234,
  66845. 'ÍŸ' => 233,
  66846. 'Í ' => 234,
  66847. 'Í¡' => 234,
  66848. 'Í¢' => 233,
  66849. 'Í£' => 230,
  66850. 'ͤ' => 230,
  66851. 'Í¥' => 230,
  66852. 'ͦ' => 230,
  66853. 'ͧ' => 230,
  66854. 'ͨ' => 230,
  66855. 'Í©' => 230,
  66856. 'ͪ' => 230,
  66857. 'Í«' => 230,
  66858. 'ͬ' => 230,
  66859. 'Í­' => 230,
  66860. 'Í®' => 230,
  66861. 'ͯ' => 230,
  66862. 'Òƒ' => 230,
  66863. 'Ò„' => 230,
  66864. 'Ò…' => 230,
  66865. 'Ò†' => 230,
  66866. 'Ò‡' => 230,
  66867. 'Ö‘' => 220,
  66868. 'Ö’' => 230,
  66869. 'Ö“' => 230,
  66870. 'Ö”' => 230,
  66871. 'Ö•' => 230,
  66872. 'Ö–' => 220,
  66873. 'Ö—' => 230,
  66874. 'Ö˜' => 230,
  66875. 'Ö™' => 230,
  66876. 'Öš' => 222,
  66877. 'Ö›' => 220,
  66878. '֜' => 230,
  66879. 'Ö�' => 230,
  66880. 'Öž' => 230,
  66881. 'ÖŸ' => 230,
  66882. 'Ö ' => 230,
  66883. 'Ö¡' => 230,
  66884. 'Ö¢' => 220,
  66885. 'Ö£' => 220,
  66886. 'Ö¤' => 220,
  66887. 'Ö¥' => 220,
  66888. 'Ö¦' => 220,
  66889. 'Ö§' => 220,
  66890. 'Ö¨' => 230,
  66891. 'Ö©' => 230,
  66892. 'Öª' => 220,
  66893. 'Ö«' => 230,
  66894. 'Ö¬' => 230,
  66895. 'Ö­' => 222,
  66896. 'Ö®' => 228,
  66897. 'Ö¯' => 230,
  66898. 'Ö°' => 10,
  66899. 'Ö±' => 11,
  66900. 'Ö²' => 12,
  66901. 'Ö³' => 13,
  66902. 'Ö´' => 14,
  66903. 'Öµ' => 15,
  66904. 'Ö¶' => 16,
  66905. 'Ö·' => 17,
  66906. 'Ö¸' => 18,
  66907. 'Ö¹' => 19,
  66908. 'Öº' => 19,
  66909. 'Ö»' => 20,
  66910. 'Ö¼' => 21,
  66911. 'Ö½' => 22,
  66912. 'Ö¿' => 23,
  66913. '�' => 24,
  66914. 'ׂ' => 25,
  66915. 'ׄ' => 230,
  66916. '×…' => 220,
  66917. 'ׇ' => 18,
  66918. '�' => 230,
  66919. 'Ø‘' => 230,
  66920. 'Ø’' => 230,
  66921. 'Ø“' => 230,
  66922. 'Ø”' => 230,
  66923. 'Ø•' => 230,
  66924. 'Ø–' => 230,
  66925. 'Ø—' => 230,
  66926. 'ؘ' => 30,
  66927. 'Ø™' => 31,
  66928. 'Øš' => 32,
  66929. 'Ù‹' => 27,
  66930. 'ٌ' => 28,
  66931. 'Ù�' => 29,
  66932. 'ÙŽ' => 30,
  66933. 'Ù�' => 31,
  66934. 'Ù�' => 32,
  66935. 'Ù‘' => 33,
  66936. 'Ù’' => 34,
  66937. 'Ù“' => 230,
  66938. 'Ù”' => 230,
  66939. 'Ù•' => 220,
  66940. 'Ù–' => 220,
  66941. 'Ù—' => 230,
  66942. 'Ù˜' => 230,
  66943. 'Ù™' => 230,
  66944. 'Ùš' => 230,
  66945. 'Ù›' => 230,
  66946. 'ٜ' => 220,
  66947. 'Ù�' => 230,
  66948. 'Ùž' => 230,
  66949. 'ÙŸ' => 220,
  66950. 'Ù°' => 35,
  66951. 'Û–' => 230,
  66952. 'Û—' => 230,
  66953. 'Û˜' => 230,
  66954. 'Û™' => 230,
  66955. 'Ûš' => 230,
  66956. 'Û›' => 230,
  66957. 'ۜ' => 230,
  66958. 'ÛŸ' => 230,
  66959. 'Û ' => 230,
  66960. 'Û¡' => 230,
  66961. 'Û¢' => 230,
  66962. 'Û£' => 220,
  66963. 'Û¤' => 230,
  66964. 'Û§' => 230,
  66965. 'Û¨' => 230,
  66966. 'Ûª' => 220,
  66967. 'Û«' => 230,
  66968. 'Û¬' => 230,
  66969. 'Û­' => 220,
  66970. 'Ü‘' => 36,
  66971. 'ܰ' => 230,
  66972. 'ܱ' => 220,
  66973. 'ܲ' => 230,
  66974. 'ܳ' => 230,
  66975. 'Ü´' => 220,
  66976. 'ܵ' => 230,
  66977. 'ܶ' => 230,
  66978. 'Ü·' => 220,
  66979. 'ܸ' => 220,
  66980. 'ܹ' => 220,
  66981. 'ܺ' => 230,
  66982. 'Ü»' => 220,
  66983. 'ܼ' => 220,
  66984. 'ܽ' => 230,
  66985. 'ܾ' => 220,
  66986. 'Ü¿' => 230,
  66987. 'Ý€' => 230,
  66988. '�' => 230,
  66989. 'Ý‚' => 220,
  66990. '݃' => 230,
  66991. 'Ý„' => 220,
  66992. 'Ý…' => 230,
  66993. '݆' => 220,
  66994. '݇' => 230,
  66995. '݈' => 220,
  66996. '݉' => 230,
  66997. 'ÝŠ' => 230,
  66998. 'ß«' => 230,
  66999. '߬' => 230,
  67000. 'ß­' => 230,
  67001. 'ß®' => 230,
  67002. '߯' => 230,
  67003. 'ß°' => 230,
  67004. 'ß±' => 230,
  67005. 'ß²' => 220,
  67006. 'ß³' => 230,
  67007. 'ß½' => 220,
  67008. 'à –' => 230,
  67009. 'à —' => 230,
  67010. 'à ˜' => 230,
  67011. 'à ™' => 230,
  67012. 'à ›' => 230,
  67013. 'ࠜ' => 230,
  67014. 'à �' => 230,
  67015. 'à ž' => 230,
  67016. 'à Ÿ' => 230,
  67017. 'à  ' => 230,
  67018. 'à ¡' => 230,
  67019. 'à ¢' => 230,
  67020. 'à £' => 230,
  67021. 'à ¥' => 230,
  67022. 'à ¦' => 230,
  67023. 'à §' => 230,
  67024. 'à ©' => 230,
  67025. 'à ª' => 230,
  67026. 'à «' => 230,
  67027. 'à ¬' => 230,
  67028. 'à ­' => 230,
  67029. 'à¡™' => 220,
  67030. '࡚' => 220,
  67031. 'à¡›' => 220,
  67032. '࣓' => 220,
  67033. 'ࣔ' => 230,
  67034. 'ࣕ' => 230,
  67035. 'ࣖ' => 230,
  67036. 'ࣗ' => 230,
  67037. 'ࣘ' => 230,
  67038. 'ࣙ' => 230,
  67039. 'ࣚ' => 230,
  67040. 'ࣛ' => 230,
  67041. 'ࣜ' => 230,
  67042. '�' => 230,
  67043. 'ࣞ' => 230,
  67044. 'ࣟ' => 230,
  67045. '࣠' => 230,
  67046. '࣡' => 230,
  67047. 'ࣣ' => 220,
  67048. 'ࣤ' => 230,
  67049. 'ࣥ' => 230,
  67050. 'ࣦ' => 220,
  67051. 'ࣧ' => 230,
  67052. 'ࣨ' => 230,
  67053. 'ࣩ' => 220,
  67054. '࣪' => 230,
  67055. '࣫' => 230,
  67056. '࣬' => 230,
  67057. '࣭' => 220,
  67058. '࣮' => 220,
  67059. '࣯' => 220,
  67060. 'ࣰ' => 27,
  67061. 'ࣱ' => 28,
  67062. 'ࣲ' => 29,
  67063. 'ࣳ' => 230,
  67064. 'ࣴ' => 230,
  67065. 'ࣵ' => 230,
  67066. 'ࣶ' => 220,
  67067. 'ࣷ' => 230,
  67068. 'ࣸ' => 230,
  67069. 'ࣹ' => 220,
  67070. 'ࣺ' => 220,
  67071. 'ࣻ' => 230,
  67072. 'ࣼ' => 230,
  67073. 'ࣽ' => 230,
  67074. 'ࣾ' => 230,
  67075. 'ࣿ' => 230,
  67076. '़' => 7,
  67077. '�' => 9,
  67078. '॑' => 230,
  67079. '॒' => 220,
  67080. '॓' => 230,
  67081. '॔' => 230,
  67082. '়' => 7,
  67083. '�' => 9,
  67084. 'à§¾' => 230,
  67085. '਼' => 7,
  67086. '�' => 9,
  67087. '઼' => 7,
  67088. '�' => 9,
  67089. '଼' => 7,
  67090. 'à­�' => 9,
  67091. '�' => 9,
  67092. '�' => 9,
  67093. 'ౕ' => 84,
  67094. 'à±–' => 91,
  67095. '಼' => 7,
  67096. '�' => 9,
  67097. 'à´»' => 9,
  67098. 'à´¼' => 9,
  67099. '�' => 9,
  67100. 'à·Š' => 9,
  67101. 'ุ' => 103,
  67102. 'ู' => 103,
  67103. 'ฺ' => 9,
  67104. '่' => 107,
  67105. '้' => 107,
  67106. '๊' => 107,
  67107. '๋' => 107,
  67108. 'ຸ' => 118,
  67109. 'ູ' => 118,
  67110. '຺' => 9,
  67111. '່' => 122,
  67112. '້' => 122,
  67113. '໊' => 122,
  67114. '໋' => 122,
  67115. '༘' => 220,
  67116. '༙' => 220,
  67117. '༵' => 220,
  67118. '༷' => 220,
  67119. '༹' => 216,
  67120. 'ཱ' => 129,
  67121. 'ི' => 130,
  67122. 'ུ' => 132,
  67123. 'ེ' => 130,
  67124. 'ཻ' => 130,
  67125. 'ོ' => 130,
  67126. 'ཽ' => 130,
  67127. 'ྀ' => 130,
  67128. 'ྂ' => 230,
  67129. 'ྃ' => 230,
  67130. '྄' => 9,
  67131. '྆' => 230,
  67132. '྇' => 230,
  67133. '࿆' => 220,
  67134. '့' => 7,
  67135. '္' => 9,
  67136. '်' => 9,
  67137. '�' => 220,
  67138. '�' => 230,
  67139. '�' => 230,
  67140. '�' => 230,
  67141. '᜔' => 9,
  67142. '᜴' => 9,
  67143. '្' => 9,
  67144. '�' => 230,
  67145. 'ᢩ' => 228,
  67146. '᤹' => 222,
  67147. '᤺' => 230,
  67148. '᤻' => 220,
  67149. 'ᨗ' => 230,
  67150. 'ᨘ' => 220,
  67151. 'á© ' => 9,
  67152. '᩵' => 230,
  67153. 'á©¶' => 230,
  67154. 'á©·' => 230,
  67155. '᩸' => 230,
  67156. '᩹' => 230,
  67157. '᩺' => 230,
  67158. 'á©»' => 230,
  67159. '᩼' => 230,
  67160. 'á©¿' => 220,
  67161. '᪰' => 230,
  67162. '᪱' => 230,
  67163. '᪲' => 230,
  67164. '᪳' => 230,
  67165. '᪴' => 230,
  67166. '᪵' => 220,
  67167. '᪶' => 220,
  67168. '᪷' => 220,
  67169. '᪸' => 220,
  67170. '᪹' => 220,
  67171. '᪺' => 220,
  67172. '᪻' => 230,
  67173. '᪼' => 230,
  67174. '᪽' => 220,
  67175. 'ᪿ' => 220,
  67176. 'á«€' => 220,
  67177. '᬴' => 7,
  67178. 'á­„' => 9,
  67179. 'á­«' => 230,
  67180. 'á­¬' => 220,
  67181. 'á­­' => 230,
  67182. 'á­®' => 230,
  67183. 'á­¯' => 230,
  67184. 'á­°' => 230,
  67185. 'á­±' => 230,
  67186. 'á­²' => 230,
  67187. 'á­³' => 230,
  67188. '᮪' => 9,
  67189. '᮫' => 9,
  67190. '᯦' => 7,
  67191. '᯲' => 9,
  67192. '᯳' => 9,
  67193. 'á°·' => 7,
  67194. '�' => 230,
  67195. '᳑' => 230,
  67196. 'á³’' => 230,
  67197. 'á³”' => 1,
  67198. '᳕' => 220,
  67199. 'á³–' => 220,
  67200. 'á³—' => 220,
  67201. '᳘' => 220,
  67202. 'á³™' => 220,
  67203. '᳚' => 230,
  67204. 'á³›' => 230,
  67205. '᳜' => 220,
  67206. '�' => 220,
  67207. '᳞' => 220,
  67208. '᳟' => 220,
  67209. 'á³ ' => 230,
  67210. 'á³¢' => 1,
  67211. 'á³£' => 1,
  67212. '᳤' => 1,
  67213. 'á³¥' => 1,
  67214. '᳦' => 1,
  67215. 'á³§' => 1,
  67216. '᳨' => 1,
  67217. 'á³­' => 220,
  67218. 'á³´' => 230,
  67219. '᳸' => 230,
  67220. 'á³¹' => 230,
  67221. 'á·€' => 230,
  67222. 'á·�' => 230,
  67223. 'á·‚' => 220,
  67224. 'á·ƒ' => 230,
  67225. 'á·„' => 230,
  67226. 'á·…' => 230,
  67227. 'á·†' => 230,
  67228. 'á·‡' => 230,
  67229. 'á·ˆ' => 230,
  67230. 'á·‰' => 230,
  67231. 'á·Š' => 220,
  67232. 'á·‹' => 230,
  67233. '᷌' => 230,
  67234. 'á·�' => 234,
  67235. 'á·Ž' => 214,
  67236. 'á·�' => 220,
  67237. 'á·�' => 202,
  67238. 'á·‘' => 230,
  67239. 'á·’' => 230,
  67240. 'á·“' => 230,
  67241. 'á·”' => 230,
  67242. 'á·•' => 230,
  67243. 'á·–' => 230,
  67244. 'á·—' => 230,
  67245. 'á·˜' => 230,
  67246. 'á·™' => 230,
  67247. 'á·š' => 230,
  67248. 'á·›' => 230,
  67249. 'ᷜ' => 230,
  67250. 'á·�' => 230,
  67251. 'á·ž' => 230,
  67252. 'á·Ÿ' => 230,
  67253. 'á· ' => 230,
  67254. 'á·¡' => 230,
  67255. 'á·¢' => 230,
  67256. 'á·£' => 230,
  67257. 'á·¤' => 230,
  67258. 'á·¥' => 230,
  67259. 'á·¦' => 230,
  67260. 'á·§' => 230,
  67261. 'á·¨' => 230,
  67262. 'á·©' => 230,
  67263. 'á·ª' => 230,
  67264. 'á·«' => 230,
  67265. 'á·¬' => 230,
  67266. 'á·­' => 230,
  67267. 'á·®' => 230,
  67268. 'á·¯' => 230,
  67269. 'á·°' => 230,
  67270. 'á·±' => 230,
  67271. 'á·²' => 230,
  67272. 'á·³' => 230,
  67273. 'á·´' => 230,
  67274. 'á·µ' => 230,
  67275. 'á·¶' => 232,
  67276. 'á··' => 228,
  67277. 'á·¸' => 228,
  67278. 'á·¹' => 220,
  67279. 'á·»' => 230,
  67280. 'á·¼' => 233,
  67281. 'á·½' => 220,
  67282. 'á·¾' => 230,
  67283. 'á·¿' => 220,
  67284. '�' => 230,
  67285. '⃑' => 230,
  67286. '⃒' => 1,
  67287. '⃓' => 1,
  67288. '⃔' => 230,
  67289. '⃕' => 230,
  67290. '⃖' => 230,
  67291. '⃗' => 230,
  67292. '⃘' => 1,
  67293. '⃙' => 1,
  67294. '⃚' => 1,
  67295. '⃛' => 230,
  67296. '⃜' => 230,
  67297. '⃡' => 230,
  67298. '⃥' => 1,
  67299. '⃦' => 1,
  67300. '⃧' => 230,
  67301. '⃨' => 220,
  67302. '⃩' => 230,
  67303. '⃪' => 1,
  67304. '⃫' => 1,
  67305. '⃬' => 220,
  67306. '⃭' => 220,
  67307. '⃮' => 220,
  67308. '⃯' => 220,
  67309. '⃰' => 230,
  67310. '⳯' => 230,
  67311. 'â³°' => 230,
  67312. 'â³±' => 230,
  67313. '⵿' => 9,
  67314. 'â· ' => 230,
  67315. 'â·¡' => 230,
  67316. 'â·¢' => 230,
  67317. 'â·£' => 230,
  67318. 'â·¤' => 230,
  67319. 'â·¥' => 230,
  67320. 'â·¦' => 230,
  67321. 'â·§' => 230,
  67322. 'â·¨' => 230,
  67323. 'â·©' => 230,
  67324. 'â·ª' => 230,
  67325. 'â·«' => 230,
  67326. 'â·¬' => 230,
  67327. 'â·­' => 230,
  67328. 'â·®' => 230,
  67329. 'â·¯' => 230,
  67330. 'â·°' => 230,
  67331. 'â·±' => 230,
  67332. 'â·²' => 230,
  67333. 'â·³' => 230,
  67334. 'â·´' => 230,
  67335. 'â·µ' => 230,
  67336. 'â·¶' => 230,
  67337. 'â··' => 230,
  67338. 'â·¸' => 230,
  67339. 'â·¹' => 230,
  67340. 'â·º' => 230,
  67341. 'â·»' => 230,
  67342. 'â·¼' => 230,
  67343. 'â·½' => 230,
  67344. 'â·¾' => 230,
  67345. 'â·¿' => 230,
  67346. '〪' => 218,
  67347. '〫' => 228,
  67348. '〬' => 232,
  67349. '〭' => 222,
  67350. '〮' => 224,
  67351. '〯' => 224,
  67352. 'ã‚™' => 8,
  67353. '゚' => 8,
  67354. '꙯' => 230,
  67355. 'ê™´' => 230,
  67356. 'ꙵ' => 230,
  67357. 'ê™¶' => 230,
  67358. 'ê™·' => 230,
  67359. 'ꙸ' => 230,
  67360. 'ꙹ' => 230,
  67361. 'ꙺ' => 230,
  67362. 'ê™»' => 230,
  67363. '꙼' => 230,
  67364. '꙽' => 230,
  67365. 'êšž' => 230,
  67366. 'ꚟ' => 230,
  67367. 'ê›°' => 230,
  67368. 'ê›±' => 230,
  67369. 'ê †' => 9,
  67370. 'ê ¬' => 9,
  67371. '꣄' => 9,
  67372. '꣠' => 230,
  67373. '꣡' => 230,
  67374. '꣢' => 230,
  67375. '꣣' => 230,
  67376. '꣤' => 230,
  67377. '꣥' => 230,
  67378. '꣦' => 230,
  67379. '꣧' => 230,
  67380. '꣨' => 230,
  67381. '꣩' => 230,
  67382. '꣪' => 230,
  67383. '꣫' => 230,
  67384. '꣬' => 230,
  67385. '꣭' => 230,
  67386. '꣮' => 230,
  67387. '꣯' => 230,
  67388. '꣰' => 230,
  67389. '꣱' => 230,
  67390. '꤫' => 220,
  67391. '꤬' => 220,
  67392. '꤭' => 220,
  67393. '꥓' => 9,
  67394. '꦳' => 7,
  67395. 'ê§€' => 9,
  67396. 'ꪰ' => 230,
  67397. 'ꪲ' => 230,
  67398. 'ꪳ' => 230,
  67399. 'ꪴ' => 220,
  67400. 'ꪷ' => 230,
  67401. 'ꪸ' => 230,
  67402. 'ꪾ' => 230,
  67403. '꪿' => 230,
  67404. '�' => 230,
  67405. 'ê«¶' => 9,
  67406. '꯭' => 9,
  67407. 'ﬞ' => 26,
  67408. '︠' => 230,
  67409. '︡' => 230,
  67410. '︢' => 230,
  67411. '︣' => 230,
  67412. '︤' => 230,
  67413. '︥' => 230,
  67414. '︦' => 230,
  67415. '︧' => 220,
  67416. '︨' => 220,
  67417. '︩' => 220,
  67418. '︪' => 220,
  67419. '︫' => 220,
  67420. '︬' => 220,
  67421. '︭' => 220,
  67422. '︮' => 230,
  67423. '︯' => 230,
  67424. '�' => 220,
  67425. '�' => 220,
  67426. '�' => 230,
  67427. '�' => 230,
  67428. '�' => 230,
  67429. '�' => 230,
  67430. '�' => 230,
  67431. '�' => 220,
  67432. '�' => 230,
  67433. '�' => 230,
  67434. '�' => 1,
  67435. '�' => 220,
  67436. '�' => 9,
  67437. '�' => 230,
  67438. '�' => 220,
  67439. '�' => 230,
  67440. '�' => 230,
  67441. '�' => 230,
  67442. '�' => 230,
  67443. '�' => 230,
  67444. '�' => 230,
  67445. '�' => 220,
  67446. '�' => 220,
  67447. '�' => 230,
  67448. '�' => 230,
  67449. '�' => 230,
  67450. '�' => 220,
  67451. '�' => 230,
  67452. '�' => 220,
  67453. '�' => 220,
  67454. '�' => 220,
  67455. '�' => 220,
  67456. '�' => 9,
  67457. '�' => 9,
  67458. 'ð‘‚¹' => 9,
  67459. '𑂺' => 7,
  67460. 'ð‘„€' => 230,
  67461. '�' => 230,
  67462. 'ð‘„‚' => 230,
  67463. 'ð‘„³' => 9,
  67464. 'ð‘„´' => 9,
  67465. 'ð‘…³' => 7,
  67466. '𑇀' => 9,
  67467. '𑇊' => 7,
  67468. '𑈵' => 9,
  67469. '𑈶' => 7,
  67470. 'ð‘‹©' => 7,
  67471. '𑋪' => 9,
  67472. '𑌻' => 7,
  67473. '𑌼' => 7,
  67474. '�' => 9,
  67475. '�' => 230,
  67476. '�' => 230,
  67477. '�' => 230,
  67478. '�' => 230,
  67479. '�' => 230,
  67480. '�' => 230,
  67481. '�' => 230,
  67482. '�' => 230,
  67483. '�' => 230,
  67484. '�' => 230,
  67485. '�' => 230,
  67486. '�' => 230,
  67487. 'ð‘‘‚' => 9,
  67488. '𑑆' => 7,
  67489. 'ð‘‘ž' => 230,
  67490. 'ð‘“‚' => 9,
  67491. '𑓃' => 7,
  67492. 'ð‘–¿' => 9,
  67493. 'ð‘—€' => 7,
  67494. '𑘿' => 9,
  67495. '𑚶' => 9,
  67496. '𑚷' => 7,
  67497. '𑜫' => 9,
  67498. 'ð‘ ¹' => 9,
  67499. 'ð‘ º' => 7,
  67500. '𑤽' => 9,
  67501. '𑤾' => 9,
  67502. '𑥃' => 7,
  67503. 'ð‘§ ' => 9,
  67504. '𑨴' => 9,
  67505. '𑩇' => 9,
  67506. '𑪙' => 9,
  67507. 'ð‘°¿' => 9,
  67508. '𑵂' => 7,
  67509. '𑵄' => 9,
  67510. '𑵅' => 9,
  67511. 'ð‘¶—' => 9,
  67512. 'ð–«°' => 1,
  67513. 'ð–«±' => 1,
  67514. 'ð–«²' => 1,
  67515. 'ð–«³' => 1,
  67516. 'ð–«´' => 1,
  67517. 'ð–¬°' => 230,
  67518. '𖬱' => 230,
  67519. '𖬲' => 230,
  67520. '𖬳' => 230,
  67521. 'ð–¬´' => 230,
  67522. '𖬵' => 230,
  67523. '𖬶' => 230,
  67524. 'ð–¿°' => 6,
  67525. 'ð–¿±' => 6,
  67526. '𛲞' => 1,
  67527. '�' => 216,
  67528. '�' => 216,
  67529. '�' => 1,
  67530. '�' => 1,
  67531. '�' => 1,
  67532. '�' => 226,
  67533. '�' => 216,
  67534. '�' => 216,
  67535. '�' => 216,
  67536. '�' => 216,
  67537. '�' => 216,
  67538. '�' => 220,
  67539. '�' => 220,
  67540. '�' => 220,
  67541. '�' => 220,
  67542. '�' => 220,
  67543. '�' => 220,
  67544. '�' => 220,
  67545. '�' => 220,
  67546. '�' => 230,
  67547. '�' => 230,
  67548. '�' => 230,
  67549. '�' => 230,
  67550. '�' => 230,
  67551. '�' => 220,
  67552. '�' => 220,
  67553. '�' => 230,
  67554. '�' => 230,
  67555. '�' => 230,
  67556. '�' => 230,
  67557. '�' => 230,
  67558. '�' => 230,
  67559. '�' => 230,
  67560. '𞀀' => 230,
  67561. '�' => 230,
  67562. '𞀂' => 230,
  67563. '𞀃' => 230,
  67564. '𞀄' => 230,
  67565. '𞀅' => 230,
  67566. '𞀆' => 230,
  67567. '𞀈' => 230,
  67568. '𞀉' => 230,
  67569. '𞀊' => 230,
  67570. '𞀋' => 230,
  67571. '𞀌' => 230,
  67572. '�' => 230,
  67573. '𞀎' => 230,
  67574. '�' => 230,
  67575. '�' => 230,
  67576. '𞀑' => 230,
  67577. '𞀒' => 230,
  67578. '𞀓' => 230,
  67579. '𞀔' => 230,
  67580. '𞀕' => 230,
  67581. '𞀖' => 230,
  67582. '𞀗' => 230,
  67583. '𞀘' => 230,
  67584. '𞀛' => 230,
  67585. '𞀜' => 230,
  67586. '�' => 230,
  67587. '𞀞' => 230,
  67588. '𞀟' => 230,
  67589. '𞀠' => 230,
  67590. '𞀡' => 230,
  67591. '𞀣' => 230,
  67592. '𞀤' => 230,
  67593. '𞀦' => 230,
  67594. '𞀧' => 230,
  67595. '𞀨' => 230,
  67596. '𞀩' => 230,
  67597. '𞀪' => 230,
  67598. 'ðž„°' => 230,
  67599. '𞄱' => 230,
  67600. '𞄲' => 230,
  67601. '𞄳' => 230,
  67602. 'ðž„´' => 230,
  67603. '𞄵' => 230,
  67604. 'ðž„¶' => 230,
  67605. '𞋬' => 230,
  67606. 'ðž‹­' => 230,
  67607. 'ðž‹®' => 230,
  67608. '𞋯' => 230,
  67609. '�' => 220,
  67610. '𞣑' => 220,
  67611. '𞣒' => 220,
  67612. '𞣓' => 220,
  67613. '𞣔' => 220,
  67614. '𞣕' => 220,
  67615. '𞣖' => 220,
  67616. '𞥄' => 230,
  67617. '𞥅' => 230,
  67618. '𞥆' => 230,
  67619. '𞥇' => 230,
  67620. '𞥈' => 230,
  67621. '𞥉' => 230,
  67622. '𞥊' => 7,
  67623. );
  67624. <?php
  67625. return array (
  67626. ' ' => ' ',
  67627. '¨' => ' ̈',
  67628. 'ª' => 'a',
  67629. '¯' => ' ̄',
  67630. '²' => '2',
  67631. '³' => '3',
  67632. '´' => ' �',
  67633. 'µ' => 'μ',
  67634. '¸' => ' ̧',
  67635. '¹' => '1',
  67636. 'º' => 'o',
  67637. '¼' => '1�4',
  67638. '½' => '1�2',
  67639. '¾' => '3�4',
  67640. 'IJ' => 'IJ',
  67641. 'ij' => 'ij',
  67642. 'Ŀ' => 'L·',
  67643. 'ŀ' => 'l·',
  67644. 'ʼn' => 'ʼn',
  67645. 'Å¿' => 's',
  67646. 'DŽ' => 'DŽ',
  67647. 'Dž' => 'Dž',
  67648. 'dž' => 'dž',
  67649. 'LJ' => 'LJ',
  67650. 'Lj' => 'Lj',
  67651. 'lj' => 'lj',
  67652. 'ÇŠ' => 'NJ',
  67653. 'Ç‹' => 'Nj',
  67654. 'nj' => 'nj',
  67655. 'DZ' => 'DZ',
  67656. 'Dz' => 'Dz',
  67657. 'dz' => 'dz',
  67658. 'ʰ' => 'h',
  67659. 'ʱ' => 'ɦ',
  67660. 'ʲ' => 'j',
  67661. 'ʳ' => 'r',
  67662. 'ʴ' => 'ɹ',
  67663. 'ʵ' => 'ɻ',
  67664. 'ʶ' => '�',
  67665. 'Ê·' => 'w',
  67666. 'ʸ' => 'y',
  67667. '˘' => ' ̆',
  67668. '˙' => ' ̇',
  67669. 'Ëš' => ' ÌŠ',
  67670. '˛' => ' ̨',
  67671. '˜' => ' ̃',
  67672. '�' => ' ̋',
  67673. 'Ë ' => 'É£',
  67674. 'Ë¡' => 'l',
  67675. 'Ë¢' => 's',
  67676. 'Ë£' => 'x',
  67677. 'ˤ' => 'ʕ',
  67678. 'ͺ' => ' ͅ',
  67679. '΄' => ' �',
  67680. '΅' => ' ̈�',
  67681. '�' => 'β',
  67682. 'ϑ' => 'θ',
  67683. 'Ï’' => 'Î¥',
  67684. 'ϓ' => 'Υ�',
  67685. 'ϔ' => 'Ϋ',
  67686. 'ϕ' => 'φ',
  67687. 'Ï–' => 'Ï€',
  67688. 'ϰ' => 'κ',
  67689. 'ϱ' => '�',
  67690. 'ϲ' => 'ς',
  67691. 'ϴ' => 'Θ',
  67692. 'ϵ' => 'ε',
  67693. 'Ϲ' => 'Σ',
  67694. 'Ö‡' => 'Õ¥Ö‚',
  67695. 'ٵ' => 'اٴ',
  67696. 'ٶ' => 'وٴ',
  67697. 'Ù·' => 'Û‡Ù´',
  67698. 'ٸ' => 'يٴ',
  67699. 'ำ' => '�า',
  67700. 'ຳ' => '�າ',
  67701. 'ໜ' => 'ຫນ',
  67702. '�' => 'ຫມ',
  67703. '༌' => '་',
  67704. 'ཷ' => 'ྲཱྀ',
  67705. 'ཹ' => 'ླཱྀ',
  67706. 'ჼ' => 'ნ',
  67707. 'á´¬' => 'A',
  67708. 'ᴭ' => 'Æ',
  67709. 'á´®' => 'B',
  67710. 'á´°' => 'D',
  67711. 'á´±' => 'E',
  67712. 'á´²' => 'ÆŽ',
  67713. 'á´³' => 'G',
  67714. 'á´´' => 'H',
  67715. 'á´µ' => 'I',
  67716. 'á´¶' => 'J',
  67717. 'á´·' => 'K',
  67718. 'á´¸' => 'L',
  67719. 'á´¹' => 'M',
  67720. 'á´º' => 'N',
  67721. 'á´¼' => 'O',
  67722. 'á´½' => 'È¢',
  67723. 'á´¾' => 'P',
  67724. 'á´¿' => 'R',
  67725. 'áµ€' => 'T',
  67726. '�' => 'U',
  67727. 'ᵂ' => 'W',
  67728. 'ᵃ' => 'a',
  67729. 'ᵄ' => '�',
  67730. 'áµ…' => 'É‘',
  67731. 'ᵆ' => 'ᴂ',
  67732. 'ᵇ' => 'b',
  67733. 'ᵈ' => 'd',
  67734. 'ᵉ' => 'e',
  67735. 'ᵊ' => 'ə',
  67736. 'ᵋ' => 'ɛ',
  67737. 'ᵌ' => 'ɜ',
  67738. '�' => 'g',
  67739. '�' => 'k',
  67740. '�' => 'm',
  67741. 'ᵑ' => 'ŋ',
  67742. 'áµ’' => 'o',
  67743. 'ᵓ' => 'ɔ',
  67744. 'áµ”' => 'á´–',
  67745. 'ᵕ' => 'ᴗ',
  67746. 'áµ–' => 'p',
  67747. 'áµ—' => 't',
  67748. 'ᵘ' => 'u',
  67749. 'áµ™' => 'á´�',
  67750. 'ᵚ' => 'ɯ',
  67751. 'áµ›' => 'v',
  67752. 'ᵜ' => 'ᴥ',
  67753. '�' => 'β',
  67754. 'ᵞ' => 'γ',
  67755. 'ᵟ' => 'δ',
  67756. 'ᵠ' => 'φ',
  67757. 'ᵡ' => 'χ',
  67758. 'áµ¢' => 'i',
  67759. 'áµ£' => 'r',
  67760. 'ᵤ' => 'u',
  67761. 'áµ¥' => 'v',
  67762. 'ᵦ' => 'β',
  67763. 'ᵧ' => 'γ',
  67764. 'ᵨ' => '�',
  67765. 'ᵩ' => 'φ',
  67766. 'ᵪ' => 'χ',
  67767. 'ᵸ' => 'н',
  67768. 'á¶›' => 'É’',
  67769. 'ᶜ' => 'c',
  67770. '�' => 'ɕ',
  67771. 'ᶞ' => 'ð',
  67772. 'ᶟ' => 'ɜ',
  67773. 'á¶ ' => 'f',
  67774. 'á¶¡' => 'ÉŸ',
  67775. 'á¶¢' => 'É¡',
  67776. 'á¶£' => 'É¥',
  67777. 'ᶤ' => 'ɨ',
  67778. 'á¶¥' => 'É©',
  67779. 'ᶦ' => 'ɪ',
  67780. 'á¶§' => 'áµ»',
  67781. 'ᶨ' => '�',
  67782. 'á¶©' => 'É­',
  67783. 'ᶪ' => 'ᶅ',
  67784. 'á¶«' => 'ÊŸ',
  67785. 'ᶬ' => 'ɱ',
  67786. 'ᶭ' => 'ɰ',
  67787. 'ᶮ' => 'ɲ',
  67788. 'ᶯ' => 'ɳ',
  67789. 'á¶°' => 'É´',
  67790. 'ᶱ' => 'ɵ',
  67791. 'ᶲ' => 'ɸ',
  67792. 'á¶³' => 'Ê‚',
  67793. 'ᶴ' => 'ʃ',
  67794. 'á¶µ' => 'Æ«',
  67795. 'ᶶ' => 'ʉ',
  67796. 'á¶·' => 'ÊŠ',
  67797. 'ᶸ' => 'ᴜ',
  67798. 'á¶¹' => 'Ê‹',
  67799. 'ᶺ' => 'ʌ',
  67800. 'á¶»' => 'z',
  67801. 'ᶼ' => '�',
  67802. 'á¶½' => 'Ê‘',
  67803. 'á¶¾' => 'Ê’',
  67804. 'ᶿ' => 'θ',
  67805. 'ẚ' => 'aʾ',
  67806. 'ẛ' => 'ṡ',
  67807. 'á¾½' => ' Ì“',
  67808. '᾿' => ' ̓',
  67809. 'á¿€' => ' Í‚',
  67810. '�' => ' ̈͂',
  67811. '�' => ' ̓̀',
  67812. '῎' => ' ̓�',
  67813. '�' => ' ̓͂',
  67814. '�' => ' ̔̀',
  67815. '῞' => ' ̔�',
  67816. '῟' => ' ̔͂',
  67817. '῭' => ' ̈̀',
  67818. '΅' => ' ̈�',
  67819. '´' => ' �',
  67820. '῾' => ' ̔',
  67821. ' ' => ' ',
  67822. '�' => ' ',
  67823. ' ' => ' ',
  67824. ' ' => ' ',
  67825. ' ' => ' ',
  67826. ' ' => ' ',
  67827. ' ' => ' ',
  67828. ' ' => ' ',
  67829. ' ' => ' ',
  67830. ' ' => ' ',
  67831. ' ' => ' ',
  67832. '‑' => '�',
  67833. '‗' => ' ̳',
  67834. '․' => '.',
  67835. '‥' => '..',
  67836. '…' => '...',
  67837. ' ' => ' ',
  67838. '″' => '′′',
  67839. '‴' => '′′′',
  67840. '‶' => '‵‵',
  67841. '‷' => '‵‵‵',
  67842. '‼' => '!!',
  67843. '‾' => ' ̅',
  67844. '�' => '??',
  67845. '�' => '?!',
  67846. '�' => '!?',
  67847. '�' => '′′′′',
  67848. '�' => ' ',
  67849. '�' => '0',
  67850. '�' => 'i',
  67851. '�' => '4',
  67852. '�' => '5',
  67853. '�' => '6',
  67854. '�' => '7',
  67855. '�' => '8',
  67856. '�' => '9',
  67857. '�' => '+',
  67858. '�' => '−',
  67859. '�' => '=',
  67860. '�' => '(',
  67861. '�' => ')',
  67862. '�' => 'n',
  67863. 'â‚€' => '0',
  67864. '�' => '1',
  67865. 'â‚‚' => '2',
  67866. '₃' => '3',
  67867. 'â‚„' => '4',
  67868. 'â‚…' => '5',
  67869. '₆' => '6',
  67870. '₇' => '7',
  67871. '₈' => '8',
  67872. '₉' => '9',
  67873. '₊' => '+',
  67874. '₋' => '−',
  67875. '₌' => '=',
  67876. '�' => '(',
  67877. '₎' => ')',
  67878. '�' => 'a',
  67879. 'â‚‘' => 'e',
  67880. 'â‚’' => 'o',
  67881. 'â‚“' => 'x',
  67882. 'â‚”' => 'É™',
  67883. 'â‚•' => 'h',
  67884. 'â‚–' => 'k',
  67885. 'â‚—' => 'l',
  67886. 'ₘ' => 'm',
  67887. 'â‚™' => 'n',
  67888. 'ₚ' => 'p',
  67889. 'â‚›' => 's',
  67890. 'ₜ' => 't',
  67891. '₨' => 'Rs',
  67892. 'â„€' => 'a/c',
  67893. '�' => 'a/s',
  67894. 'â„‚' => 'C',
  67895. '℃' => '°C',
  67896. 'â„…' => 'c/o',
  67897. '℆' => 'c/u',
  67898. 'ℇ' => '�',
  67899. '℉' => '°F',
  67900. 'ℊ' => 'g',
  67901. 'â„‹' => 'H',
  67902. 'ℌ' => 'H',
  67903. '�' => 'H',
  67904. 'ℎ' => 'h',
  67905. '�' => 'ħ',
  67906. '�' => 'I',
  67907. 'â„‘' => 'I',
  67908. 'â„’' => 'L',
  67909. 'â„“' => 'l',
  67910. 'â„•' => 'N',
  67911. 'â„–' => 'No',
  67912. 'â„™' => 'P',
  67913. 'ℚ' => 'Q',
  67914. 'â„›' => 'R',
  67915. 'ℜ' => 'R',
  67916. '�' => 'R',
  67917. 'â„ ' => 'SM',
  67918. 'â„¡' => 'TEL',
  67919. 'â„¢' => 'TM',
  67920. 'ℤ' => 'Z',
  67921. 'ℨ' => 'Z',
  67922. 'ℬ' => 'B',
  67923. 'â„­' => 'C',
  67924. 'ℯ' => 'e',
  67925. 'â„°' => 'E',
  67926. 'ℱ' => 'F',
  67927. 'ℳ' => 'M',
  67928. 'â„´' => 'o',
  67929. 'ℵ' => '�',
  67930. 'ℶ' => 'ב',
  67931. 'â„·' => '×’',
  67932. 'ℸ' => 'ד',
  67933. 'ℹ' => 'i',
  67934. 'â„»' => 'FAX',
  67935. 'ℼ' => 'π',
  67936. 'ℽ' => 'γ',
  67937. 'ℾ' => 'Γ',
  67938. 'ℿ' => 'Π',
  67939. '⅀' => '∑',
  67940. 'â……' => 'D',
  67941. 'â…†' => 'd',
  67942. 'â…‡' => 'e',
  67943. 'â…ˆ' => 'i',
  67944. 'â…‰' => 'j',
  67945. '�' => '1�7',
  67946. '⅑' => '1�9',
  67947. '⅒' => '1�10',
  67948. '⅓' => '1�3',
  67949. '⅔' => '2�3',
  67950. '⅕' => '1�5',
  67951. '⅖' => '2�5',
  67952. '⅗' => '3�5',
  67953. '⅘' => '4�5',
  67954. '⅙' => '1�6',
  67955. '⅚' => '5�6',
  67956. '⅛' => '1�8',
  67957. '⅜' => '3�8',
  67958. '�' => '5�8',
  67959. '⅞' => '7�8',
  67960. '⅟' => '1�',
  67961. 'â… ' => 'I',
  67962. 'â…¡' => 'II',
  67963. 'â…¢' => 'III',
  67964. 'â…£' => 'IV',
  67965. 'â…¤' => 'V',
  67966. 'â…¥' => 'VI',
  67967. 'â…¦' => 'VII',
  67968. 'â…§' => 'VIII',
  67969. 'â…¨' => 'IX',
  67970. 'â…©' => 'X',
  67971. 'â…ª' => 'XI',
  67972. 'â…«' => 'XII',
  67973. 'â…¬' => 'L',
  67974. 'â…­' => 'C',
  67975. 'â…®' => 'D',
  67976. 'â…¯' => 'M',
  67977. 'â…°' => 'i',
  67978. 'â…±' => 'ii',
  67979. 'â…²' => 'iii',
  67980. 'â…³' => 'iv',
  67981. 'â…´' => 'v',
  67982. 'â…µ' => 'vi',
  67983. 'â…¶' => 'vii',
  67984. 'â…·' => 'viii',
  67985. 'â…¸' => 'ix',
  67986. 'â…¹' => 'x',
  67987. 'â…º' => 'xi',
  67988. 'â…»' => 'xii',
  67989. 'â…¼' => 'l',
  67990. 'â…½' => 'c',
  67991. 'â…¾' => 'd',
  67992. 'â…¿' => 'm',
  67993. '↉' => '0�3',
  67994. '∬' => '∫∫',
  67995. '∭' => '∫∫∫',
  67996. '∯' => '∮∮',
  67997. '∰' => '∮∮∮',
  67998. 'â‘ ' => '1',
  67999. 'â‘¡' => '2',
  68000. 'â‘¢' => '3',
  68001. 'â‘£' => '4',
  68002. '⑤' => '5',
  68003. 'â‘¥' => '6',
  68004. '⑦' => '7',
  68005. 'â‘§' => '8',
  68006. '⑨' => '9',
  68007. 'â‘©' => '10',
  68008. '⑪' => '11',
  68009. 'â‘«' => '12',
  68010. '⑬' => '13',
  68011. 'â‘­' => '14',
  68012. 'â‘®' => '15',
  68013. '⑯' => '16',
  68014. 'â‘°' => '17',
  68015. '⑱' => '18',
  68016. '⑲' => '19',
  68017. '⑳' => '20',
  68018. 'â‘´' => '(1)',
  68019. '⑵' => '(2)',
  68020. 'â‘¶' => '(3)',
  68021. 'â‘·' => '(4)',
  68022. '⑸' => '(5)',
  68023. '⑹' => '(6)',
  68024. '⑺' => '(7)',
  68025. 'â‘»' => '(8)',
  68026. '⑼' => '(9)',
  68027. '⑽' => '(10)',
  68028. '⑾' => '(11)',
  68029. 'â‘¿' => '(12)',
  68030. 'â’€' => '(13)',
  68031. 'â’�' => '(14)',
  68032. 'â’‚' => '(15)',
  68033. 'â’ƒ' => '(16)',
  68034. 'â’„' => '(17)',
  68035. 'â’…' => '(18)',
  68036. 'â’†' => '(19)',
  68037. 'â’‡' => '(20)',
  68038. 'â’ˆ' => '1.',
  68039. 'â’‰' => '2.',
  68040. 'â’Š' => '3.',
  68041. 'â’‹' => '4.',
  68042. '⒌' => '5.',
  68043. 'â’�' => '6.',
  68044. 'â’Ž' => '7.',
  68045. 'â’�' => '8.',
  68046. 'â’�' => '9.',
  68047. 'â’‘' => '10.',
  68048. 'â’’' => '11.',
  68049. 'â’“' => '12.',
  68050. 'â’”' => '13.',
  68051. 'â’•' => '14.',
  68052. 'â’–' => '15.',
  68053. 'â’—' => '16.',
  68054. 'â’˜' => '17.',
  68055. 'â’™' => '18.',
  68056. 'â’š' => '19.',
  68057. 'â’›' => '20.',
  68058. '⒜' => '(a)',
  68059. 'â’�' => '(b)',
  68060. 'â’ž' => '(c)',
  68061. 'â’Ÿ' => '(d)',
  68062. 'â’ ' => '(e)',
  68063. 'â’¡' => '(f)',
  68064. 'â’¢' => '(g)',
  68065. 'â’£' => '(h)',
  68066. 'â’¤' => '(i)',
  68067. 'â’¥' => '(j)',
  68068. 'â’¦' => '(k)',
  68069. 'â’§' => '(l)',
  68070. 'â’¨' => '(m)',
  68071. 'â’©' => '(n)',
  68072. 'â’ª' => '(o)',
  68073. 'â’«' => '(p)',
  68074. 'â’¬' => '(q)',
  68075. 'â’­' => '(r)',
  68076. 'â’®' => '(s)',
  68077. 'â’¯' => '(t)',
  68078. 'â’°' => '(u)',
  68079. 'â’±' => '(v)',
  68080. 'â’²' => '(w)',
  68081. 'â’³' => '(x)',
  68082. 'â’´' => '(y)',
  68083. 'â’µ' => '(z)',
  68084. 'â’¶' => 'A',
  68085. 'â’·' => 'B',
  68086. 'â’¸' => 'C',
  68087. 'â’¹' => 'D',
  68088. 'â’º' => 'E',
  68089. 'â’»' => 'F',
  68090. 'â’¼' => 'G',
  68091. 'â’½' => 'H',
  68092. 'â’¾' => 'I',
  68093. 'â’¿' => 'J',
  68094. 'â“€' => 'K',
  68095. '�' => 'L',
  68096. 'â“‚' => 'M',
  68097. 'Ⓝ' => 'N',
  68098. 'â“„' => 'O',
  68099. 'â“…' => 'P',
  68100. 'Ⓠ' => 'Q',
  68101. 'Ⓡ' => 'R',
  68102. 'Ⓢ' => 'S',
  68103. 'Ⓣ' => 'T',
  68104. 'Ⓤ' => 'U',
  68105. 'â“‹' => 'V',
  68106. 'Ⓦ' => 'W',
  68107. '�' => 'X',
  68108. 'Ⓨ' => 'Y',
  68109. '�' => 'Z',
  68110. '�' => 'a',
  68111. 'â“‘' => 'b',
  68112. 'â“’' => 'c',
  68113. 'â““' => 'd',
  68114. 'â“”' => 'e',
  68115. 'â“•' => 'f',
  68116. 'â“–' => 'g',
  68117. 'â“—' => 'h',
  68118. 'ⓘ' => 'i',
  68119. 'â“™' => 'j',
  68120. 'ⓚ' => 'k',
  68121. 'â“›' => 'l',
  68122. 'ⓜ' => 'm',
  68123. '�' => 'n',
  68124. 'ⓞ' => 'o',
  68125. 'ⓟ' => 'p',
  68126. 'â“ ' => 'q',
  68127. 'â“¡' => 'r',
  68128. 'â“¢' => 's',
  68129. 'â“£' => 't',
  68130. 'ⓤ' => 'u',
  68131. 'â“¥' => 'v',
  68132. 'ⓦ' => 'w',
  68133. 'â“§' => 'x',
  68134. 'ⓨ' => 'y',
  68135. 'â“©' => 'z',
  68136. '⓪' => '0',
  68137. '⨌' => '∫∫∫∫',
  68138. 'â©´' => '::=',
  68139. '⩵' => '==',
  68140. 'â©¶' => '===',
  68141. 'â±¼' => 'j',
  68142. 'â±½' => 'V',
  68143. 'ⵯ' => 'ⵡ',
  68144. '⺟' => '�',
  68145. '⻳' => '龟',
  68146. '⼀' => '一',
  68147. '�' => '丨',
  68148. '⼂' => '丶',
  68149. '⼃' => '丿',
  68150. '⼄' => '乙',
  68151. '⼅' => '亅',
  68152. '⼆' => '二',
  68153. '⼇' => '亠',
  68154. '⼈' => '人',
  68155. '⼉' => '儿',
  68156. '⼊' => '入',
  68157. '⼋' => '八',
  68158. '⼌' => '冂',
  68159. '�' => '冖',
  68160. '⼎' => '冫',
  68161. '�' => '几',
  68162. '�' => '凵',
  68163. '⼑' => '刀',
  68164. '⼒' => '力',
  68165. '⼓' => '勹',
  68166. '⼔' => '匕',
  68167. '⼕' => '匚',
  68168. '⼖' => '匸',
  68169. '⼗' => '�',
  68170. '⼘' => '�',
  68171. '⼙' => '�',
  68172. '⼚' => '厂',
  68173. '⼛' => '厶',
  68174. '⼜' => '�',
  68175. '�' => '�',
  68176. '⼞' => '囗',
  68177. '⼟' => '土',
  68178. '⼠' => '士',
  68179. '⼡' => '夂',
  68180. '⼢' => '夊',
  68181. '⼣' => '夕',
  68182. '⼤' => '大',
  68183. '⼥' => '女',
  68184. '⼦' => '�',
  68185. '⼧' => '宀',
  68186. '⼨' => '寸',
  68187. '⼩' => '�',
  68188. '⼪' => '尢',
  68189. '⼫' => '尸',
  68190. '⼬' => '屮',
  68191. 'â¼­' => 'å±±',
  68192. 'â¼®' => 'å·›',
  68193. '⼯' => '工',
  68194. 'â¼°' => 'å·±',
  68195. 'â¼±' => 'å·¾',
  68196. 'â¼²' => 'å¹²',
  68197. '⼳' => '幺',
  68198. '⼴' => '广',
  68199. 'â¼µ' => 'å»´',
  68200. '⼶' => '廾',
  68201. '⼷' => '弋',
  68202. '⼸' => '弓',
  68203. '⼹' => '�',
  68204. '⼺' => '彡',
  68205. 'â¼»' => 'å½³',
  68206. '⼼' => '心',
  68207. '⼽' => '戈',
  68208. '⼾' => '戶',
  68209. '⼿' => '手',
  68210. '⽀' => '支',
  68211. '�' => '攴',
  68212. '⽂' => '文',
  68213. '⽃' => '斗',
  68214. '⽄' => '斤',
  68215. 'â½…' => 'æ–¹',
  68216. '⽆' => '无',
  68217. '⽇' => '日',
  68218. '⽈' => '曰',
  68219. '⽉' => '月',
  68220. '⽊' => '木',
  68221. '⽋' => '欠',
  68222. '⽌' => '止',
  68223. '�' => '歹',
  68224. '⽎' => '殳',
  68225. '�' => '毋',
  68226. '�' => '比',
  68227. '⽑' => '毛',
  68228. 'â½’' => 'æ°�',
  68229. '⽓' => '气',
  68230. 'â½”' => 'æ°´',
  68231. '⽕' => '�',
  68232. '⽖' => '爪',
  68233. '⽗' => '父',
  68234. '⽘' => '爻',
  68235. '⽙' => '爿',
  68236. '⽚' => '片',
  68237. '⽛' => '牙',
  68238. '⽜' => '牛',
  68239. '�' => '犬',
  68240. '⽞' => '玄',
  68241. '⽟' => '玉',
  68242. '⽠' => '瓜',
  68243. '⽡' => '瓦',
  68244. '⽢' => '甘',
  68245. '⽣' => '生',
  68246. '⽤' => '用',
  68247. 'â½¥' => 'ç”°',
  68248. '⽦' => '疋',
  68249. 'â½§' => 'ç–’',
  68250. '⽨' => '癶',
  68251. '⽩' => '白',
  68252. '⽪' => '皮',
  68253. '⽫' => '皿',
  68254. '⽬' => '目',
  68255. '⽭' => '矛',
  68256. '⽮' => '矢',
  68257. '⽯' => '石',
  68258. '⽰' => '示',
  68259. '⽱' => '禸',
  68260. '⽲' => '禾',
  68261. 'â½³' => 'ç©´',
  68262. 'â½´' => 'ç«‹',
  68263. '⽵' => '竹',
  68264. 'â½¶' => 'ç±³',
  68265. '⽷' => '糸',
  68266. '⽸' => '缶',
  68267. '⽹' => '网',
  68268. '⽺' => '羊',
  68269. 'â½»' => 'ç¾½',
  68270. '⽼' => '�',
  68271. '⽽' => '而',
  68272. '⽾' => '耒',
  68273. '⽿' => '耳',
  68274. '⾀' => '�',
  68275. '�' => '肉',
  68276. '⾂' => '臣',
  68277. '⾃' => '自',
  68278. '⾄' => '至',
  68279. '⾅' => '臼',
  68280. '⾆' => '舌',
  68281. '⾇' => '舛',
  68282. '⾈' => '舟',
  68283. '⾉' => '艮',
  68284. '⾊' => '色',
  68285. '⾋' => '艸',
  68286. '⾌' => '�',
  68287. '�' => '虫',
  68288. '⾎' => '血',
  68289. '�' => '行',
  68290. '�' => '衣',
  68291. '⾑' => '襾',
  68292. '⾒' => '見',
  68293. '⾓' => '角',
  68294. '⾔' => '言',
  68295. '⾕' => '谷',
  68296. '⾖' => '豆',
  68297. '⾗' => '豕',
  68298. '⾘' => '豸',
  68299. '⾙' => '�',
  68300. '⾚' => '赤',
  68301. 'â¾›' => 'èµ°',
  68302. '⾜' => '足',
  68303. '�' => '身',
  68304. '⾞' => '車',
  68305. '⾟' => '辛',
  68306. 'â¾ ' => 'è¾°',
  68307. '⾡' => '辵',
  68308. 'â¾¢' => 'é‚‘',
  68309. 'â¾£' => 'é…‰',
  68310. '⾤' => '釆',
  68311. '⾥' => '里',
  68312. '⾦' => '金',
  68313. 'â¾§' => 'é•·',
  68314. '⾨' => '門',
  68315. '⾩' => '阜',
  68316. '⾪' => '隶',
  68317. '⾫' => '隹',
  68318. '⾬' => '雨',
  68319. '⾭' => '�',
  68320. '⾮' => '�',
  68321. '⾯' => '�',
  68322. '⾰' => '�',
  68323. '⾱' => '韋',
  68324. '⾲' => '韭',
  68325. '⾳' => '音',
  68326. 'â¾´' => 'é �',
  68327. '⾵' => '風',
  68328. '⾶' => '飛',
  68329. '⾷' => '食',
  68330. '⾸' => '首',
  68331. '⾹' => '香',
  68332. '⾺' => '馬',
  68333. '⾻' => '骨',
  68334. '⾼' => '高',
  68335. '⾽' => '髟',
  68336. '⾾' => '鬥',
  68337. '⾿' => '鬯',
  68338. '⿀' => '鬲',
  68339. '�' => '鬼',
  68340. 'â¿‚' => 'é­š',
  68341. '⿃' => '鳥',
  68342. 'â¿„' => 'é¹µ',
  68343. '⿅' => '鹿',
  68344. '⿆' => '麥',
  68345. '⿇' => '麻',
  68346. '⿈' => '黃',
  68347. '⿉' => '�',
  68348. '⿊' => '黑',
  68349. '⿋' => '黹',
  68350. '⿌' => '黽',
  68351. '�' => '鼎',
  68352. '⿎' => '鼓',
  68353. '�' => '鼠',
  68354. '�' => '鼻',
  68355. '⿑' => '齊',
  68356. 'â¿’' => 'é½’',
  68357. '⿓' => '�',
  68358. '⿔' => '龜',
  68359. 'â¿•' => 'é¾ ',
  68360. ' ' => ' ',
  68361. '〶' => '〒',
  68362. '〸' => '�',
  68363. '〹' => '�',
  68364. '〺' => '�',
  68365. 'ã‚›' => ' ã‚™',
  68366. '゜' => ' ゚',
  68367. 'ゟ' => 'より',
  68368. 'ヿ' => 'コト',
  68369. 'ㄱ' => 'ᄀ',
  68370. 'ㄲ' => '�',
  68371. 'ㄳ' => 'ᆪ',
  68372. 'ã„´' => 'á„‚',
  68373. 'ㄵ' => 'ᆬ',
  68374. 'ㄶ' => 'ᆭ',
  68375. 'ㄷ' => 'ᄃ',
  68376. 'ㄸ' => 'ᄄ',
  68377. 'ㄹ' => 'ᄅ',
  68378. 'ㄺ' => 'ᆰ',
  68379. 'ㄻ' => 'ᆱ',
  68380. 'ㄼ' => 'ᆲ',
  68381. 'ㄽ' => 'ᆳ',
  68382. 'ㄾ' => 'ᆴ',
  68383. 'ㄿ' => 'ᆵ',
  68384. 'ㅀ' => 'ᄚ',
  68385. '�' => 'ᄆ',
  68386. 'ㅂ' => 'ᄇ',
  68387. 'ㅃ' => 'ᄈ',
  68388. 'ã…„' => 'á„¡',
  68389. 'ㅅ' => 'ᄉ',
  68390. 'ㅆ' => 'ᄊ',
  68391. 'ã…‡' => 'á„‹',
  68392. 'ㅈ' => 'ᄌ',
  68393. 'ㅉ' => '�',
  68394. 'ㅊ' => 'ᄎ',
  68395. 'ㅋ' => '�',
  68396. 'ㅌ' => '�',
  68397. 'ã…�' => 'á„‘',
  68398. 'ã…Ž' => 'á„’',
  68399. 'ã…�' => 'á…¡',
  68400. 'ã…�' => 'á…¢',
  68401. 'ã…‘' => 'á…£',
  68402. 'ã…’' => 'á…¤',
  68403. 'ã…“' => 'á…¥',
  68404. 'ã…”' => 'á…¦',
  68405. 'ã…•' => 'á…§',
  68406. 'ã…–' => 'á…¨',
  68407. 'ã…—' => 'á…©',
  68408. 'ã…˜' => 'á…ª',
  68409. 'ã…™' => 'á…«',
  68410. 'ã…š' => 'á…¬',
  68411. 'ã…›' => 'á…­',
  68412. 'ㅜ' => 'ᅮ',
  68413. 'ã…�' => 'á…¯',
  68414. 'ã…ž' => 'á…°',
  68415. 'ã…Ÿ' => 'á…±',
  68416. 'ã… ' => 'á…²',
  68417. 'ã…¡' => 'á…³',
  68418. 'ã…¢' => 'á…´',
  68419. 'ã…£' => 'á…µ',
  68420. 'ã…¤' => 'á… ',
  68421. 'ã…¥' => 'á„”',
  68422. 'ã…¦' => 'á„•',
  68423. 'ㅧ' => 'ᇇ',
  68424. 'ㅨ' => 'ᇈ',
  68425. 'ㅩ' => 'ᇌ',
  68426. 'ㅪ' => 'ᇎ',
  68427. 'ㅫ' => 'ᇓ',
  68428. 'ㅬ' => 'ᇗ',
  68429. 'ㅭ' => 'ᇙ',
  68430. 'ㅮ' => 'ᄜ',
  68431. 'ㅯ' => '�',
  68432. 'ㅰ' => 'ᇟ',
  68433. 'ㅱ' => '�',
  68434. 'ㅲ' => 'ᄞ',
  68435. 'ã…³' => 'á„ ',
  68436. 'ã…´' => 'á„¢',
  68437. 'ã…µ' => 'á„£',
  68438. 'ã…¶' => 'á„§',
  68439. 'ã…·' => 'á„©',
  68440. 'ã…¸' => 'á„«',
  68441. 'ㅹ' => 'ᄬ',
  68442. 'ã…º' => 'á„­',
  68443. 'ã…»' => 'á„®',
  68444. 'ㅼ' => 'ᄯ',
  68445. 'ㅽ' => 'ᄲ',
  68446. 'ã…¾' => 'á„¶',
  68447. 'ã…¿' => 'á…€',
  68448. 'ㆀ' => 'ᅇ',
  68449. '�' => 'ᅌ',
  68450. 'ㆂ' => 'ᇱ',
  68451. 'ㆃ' => 'ᇲ',
  68452. 'ㆄ' => 'ᅗ',
  68453. 'ㆅ' => 'ᅘ',
  68454. 'ㆆ' => 'ᅙ',
  68455. 'ㆇ' => 'ᆄ',
  68456. 'ㆈ' => 'ᆅ',
  68457. 'ㆉ' => 'ᆈ',
  68458. 'ㆊ' => 'ᆑ',
  68459. 'ㆋ' => 'ᆒ',
  68460. 'ㆌ' => 'ᆔ',
  68461. '�' => 'ᆞ',
  68462. 'ㆎ' => 'ᆡ',
  68463. '㆒' => '一',
  68464. '㆓' => '二',
  68465. '㆔' => '三',
  68466. '㆕' => '四',
  68467. '㆖' => '上',
  68468. '㆗' => '中',
  68469. '㆘' => '下',
  68470. '㆙' => '甲',
  68471. '㆚' => '乙',
  68472. '㆛' => '丙',
  68473. '㆜' => '�',
  68474. '�' => '天',
  68475. '㆞' => '地',
  68476. '㆟' => '人',
  68477. '㈀' => '(ᄀ)',
  68478. '�' => '(ᄂ)',
  68479. '㈂' => '(ᄃ)',
  68480. '㈃' => '(ᄅ)',
  68481. '㈄' => '(ᄆ)',
  68482. '㈅' => '(ᄇ)',
  68483. '㈆' => '(ᄉ)',
  68484. '㈇' => '(ᄋ)',
  68485. '㈈' => '(ᄌ)',
  68486. '㈉' => '(ᄎ)',
  68487. '㈊' => '(�)',
  68488. '㈋' => '(�)',
  68489. '㈌' => '(ᄑ)',
  68490. '�' => '(ᄒ)',
  68491. '㈎' => '(가)',
  68492. '�' => '(나)',
  68493. '�' => '(다)',
  68494. '㈑' => '(라)',
  68495. '㈒' => '(마)',
  68496. '㈓' => '(바)',
  68497. '㈔' => '(사)',
  68498. '㈕' => '(아)',
  68499. '㈖' => '(자)',
  68500. '㈗' => '(차)',
  68501. '㈘' => '(�ᅡ)',
  68502. '㈙' => '(�ᅡ)',
  68503. '㈚' => '(파)',
  68504. '㈛' => '(하)',
  68505. '㈜' => '(주)',
  68506. '�' => '(오전)',
  68507. '㈞' => '(오후)',
  68508. '㈠' => '(一)',
  68509. '㈡' => '(二)',
  68510. '㈢' => '(三)',
  68511. '㈣' => '(四)',
  68512. '㈤' => '(五)',
  68513. '㈥' => '(六)',
  68514. '㈦' => '(七)',
  68515. '㈧' => '(八)',
  68516. '㈨' => '(�)',
  68517. '㈩' => '(�)',
  68518. '㈪' => '(月)',
  68519. '㈫' => '(�)',
  68520. '㈬' => '(水)',
  68521. '㈭' => '(木)',
  68522. '㈮' => '(金)',
  68523. '㈯' => '(土)',
  68524. '㈰' => '(日)',
  68525. '㈱' => '(株)',
  68526. '㈲' => '(有)',
  68527. '㈳' => '(社)',
  68528. '㈴' => '(�)',
  68529. '㈵' => '(特)',
  68530. '㈶' => '(財)',
  68531. '㈷' => '(�)',
  68532. '㈸' => '(労)',
  68533. '㈹' => '(代)',
  68534. '㈺' => '(呼)',
  68535. '㈻' => '(学)',
  68536. '㈼' => '(監)',
  68537. '㈽' => '(�)',
  68538. '㈾' => '(資)',
  68539. '㈿' => '(�)',
  68540. '㉀' => '(祭)',
  68541. '�' => '(休)',
  68542. '㉂' => '(自)',
  68543. '㉃' => '(至)',
  68544. '㉄' => '�',
  68545. '㉅' => '幼',
  68546. '㉆' => '文',
  68547. '㉇' => '�',
  68548. '�' => 'PTE',
  68549. '㉑' => '21',
  68550. '㉒' => '22',
  68551. '㉓' => '23',
  68552. '㉔' => '24',
  68553. '㉕' => '25',
  68554. '㉖' => '26',
  68555. '㉗' => '27',
  68556. '㉘' => '28',
  68557. '㉙' => '29',
  68558. '㉚' => '30',
  68559. '㉛' => '31',
  68560. '㉜' => '32',
  68561. '�' => '33',
  68562. '㉞' => '34',
  68563. '㉟' => '35',
  68564. '㉠' => 'ᄀ',
  68565. '㉡' => 'ᄂ',
  68566. '㉢' => 'ᄃ',
  68567. '㉣' => 'ᄅ',
  68568. '㉤' => 'ᄆ',
  68569. '㉥' => 'ᄇ',
  68570. '㉦' => 'ᄉ',
  68571. '㉧' => 'ᄋ',
  68572. '㉨' => 'ᄌ',
  68573. '㉩' => 'ᄎ',
  68574. '㉪' => '�',
  68575. '㉫' => '�',
  68576. '㉬' => 'ᄑ',
  68577. '㉭' => 'ᄒ',
  68578. '㉮' => '가',
  68579. '㉯' => '나',
  68580. '㉰' => '다',
  68581. '㉱' => '라',
  68582. '㉲' => '마',
  68583. '㉳' => '바',
  68584. '㉴' => '사',
  68585. '㉵' => '아',
  68586. '㉶' => '자',
  68587. '㉷' => '차',
  68588. '㉸' => '�ᅡ',
  68589. '㉹' => '�ᅡ',
  68590. '㉺' => '파',
  68591. '㉻' => '하',
  68592. '㉼' => '참고',
  68593. '㉽' => '주의',
  68594. '㉾' => '우',
  68595. '㊀' => '一',
  68596. '�' => '二',
  68597. '㊂' => '三',
  68598. '㊃' => '四',
  68599. '㊄' => '五',
  68600. '㊅' => '六',
  68601. '㊆' => '七',
  68602. '㊇' => '八',
  68603. '㊈' => '�',
  68604. '㊉' => '�',
  68605. '㊊' => '月',
  68606. '㊋' => '�',
  68607. '㊌' => '水',
  68608. '�' => '木',
  68609. '㊎' => '金',
  68610. '�' => '土',
  68611. '�' => '日',
  68612. '㊑' => '株',
  68613. '㊒' => '有',
  68614. '㊓' => '社',
  68615. '㊔' => '�',
  68616. '㊕' => '特',
  68617. '㊖' => '財',
  68618. '㊗' => '�',
  68619. '㊘' => '労',
  68620. '㊙' => '秘',
  68621. '㊚' => '男',
  68622. '㊛' => '女',
  68623. '㊜' => '�',
  68624. '�' => '優',
  68625. '㊞' => '�',
  68626. '㊟' => '注',
  68627. '㊠' => '項',
  68628. '㊡' => '休',
  68629. '㊢' => '写',
  68630. '㊣' => '正',
  68631. '㊤' => '上',
  68632. '㊥' => '中',
  68633. '㊦' => '下',
  68634. '㊧' => '左',
  68635. '㊨' => '�',
  68636. '㊩' => '医',
  68637. '㊪' => '宗',
  68638. '㊫' => '学',
  68639. '㊬' => '監',
  68640. '㊭' => '�',
  68641. '㊮' => '資',
  68642. '㊯' => '�',
  68643. '㊰' => '夜',
  68644. '㊱' => '36',
  68645. '㊲' => '37',
  68646. '㊳' => '38',
  68647. '㊴' => '39',
  68648. '㊵' => '40',
  68649. '㊶' => '41',
  68650. '㊷' => '42',
  68651. '㊸' => '43',
  68652. '㊹' => '44',
  68653. '㊺' => '45',
  68654. '㊻' => '46',
  68655. '㊼' => '47',
  68656. '㊽' => '48',
  68657. '㊾' => '49',
  68658. '㊿' => '50',
  68659. '㋀' => '1月',
  68660. '�' => '2月',
  68661. '㋂' => '3月',
  68662. '㋃' => '4月',
  68663. '㋄' => '5月',
  68664. '㋅' => '6月',
  68665. '㋆' => '7月',
  68666. '㋇' => '8月',
  68667. '㋈' => '9月',
  68668. '㋉' => '10月',
  68669. '㋊' => '11月',
  68670. '㋋' => '12月',
  68671. '㋌' => 'Hg',
  68672. '�' => 'erg',
  68673. '㋎' => 'eV',
  68674. '�' => 'LTD',
  68675. '�' => 'ア',
  68676. '㋑' => 'イ',
  68677. '㋒' => 'ウ',
  68678. '㋓' => 'エ',
  68679. '㋔' => 'オ',
  68680. 'ã‹•' => 'ã‚«',
  68681. 'ã‹–' => 'ã‚­',
  68682. '㋗' => 'ク',
  68683. '㋘' => 'ケ',
  68684. '㋙' => 'コ',
  68685. '㋚' => 'サ',
  68686. 'ã‹›' => 'ã‚·',
  68687. '㋜' => 'ス',
  68688. '�' => 'セ',
  68689. '㋞' => 'ソ',
  68690. '㋟' => 'タ',
  68691. '㋠' => '�',
  68692. '㋡' => 'ツ',
  68693. '㋢' => 'テ',
  68694. '㋣' => 'ト',
  68695. '㋤' => 'ナ',
  68696. '㋥' => 'ニ',
  68697. '㋦' => 'ヌ',
  68698. '㋧' => '�',
  68699. '㋨' => 'ノ',
  68700. '㋩' => '�',
  68701. '㋪' => 'ヒ',
  68702. '㋫' => 'フ',
  68703. '㋬' => 'ヘ',
  68704. '㋭' => 'ホ',
  68705. '㋮' => 'マ',
  68706. '㋯' => 'ミ',
  68707. '㋰' => 'ム',
  68708. '㋱' => 'メ',
  68709. '㋲' => 'モ',
  68710. '㋳' => 'ヤ',
  68711. '㋴' => 'ユ',
  68712. '㋵' => 'ヨ',
  68713. '㋶' => 'ラ',
  68714. '㋷' => 'リ',
  68715. '㋸' => 'ル',
  68716. '㋹' => 'レ',
  68717. '㋺' => 'ロ',
  68718. '㋻' => 'ワ',
  68719. '㋼' => 'ヰ',
  68720. '㋽' => 'ヱ',
  68721. '㋾' => 'ヲ',
  68722. '㋿' => '令和',
  68723. '㌀' => 'ア�゚ート',
  68724. '�' => 'アルファ',
  68725. '㌂' => 'アンペア',
  68726. '㌃' => 'アール',
  68727. '㌄' => 'イニング',
  68728. '㌅' => 'イン�',
  68729. '㌆' => 'ウォン',
  68730. '㌇' => 'エスクード',
  68731. '㌈' => 'エーカー',
  68732. '㌉' => 'オンス',
  68733. '㌊' => 'オーム',
  68734. '㌋' => 'カイリ',
  68735. '㌌' => 'カラット',
  68736. '�' => 'カロリー',
  68737. '㌎' => 'ガロン',
  68738. '�' => 'ガンマ',
  68739. '�' => 'ギガ',
  68740. '㌑' => 'ギニー',
  68741. '㌒' => 'キュリー',
  68742. '㌓' => 'ギルダー',
  68743. '㌔' => 'キロ',
  68744. '㌕' => 'キログラム',
  68745. '㌖' => 'キロメートル',
  68746. '㌗' => 'キロワット',
  68747. '㌘' => 'グラム',
  68748. '㌙' => 'グラムトン',
  68749. '㌚' => 'クルゼイロ',
  68750. '㌛' => 'クロー�',
  68751. '㌜' => 'ケース',
  68752. '�' => 'コルナ',
  68753. '㌞' => 'コーポ',
  68754. '㌟' => 'サイクル',
  68755. '㌠' => 'サン�ーム',
  68756. '㌡' => 'シリング',
  68757. '㌢' => 'セン�',
  68758. '㌣' => 'セント',
  68759. '㌤' => 'ダース',
  68760. '㌥' => 'デシ',
  68761. '㌦' => 'ドル',
  68762. '㌧' => 'トン',
  68763. '㌨' => 'ナノ',
  68764. '㌩' => 'ノット',
  68765. '㌪' => '�イツ',
  68766. '㌫' => '�゚ーセント',
  68767. '㌬' => '�゚ーツ',
  68768. '㌭' => '�゙ーレル',
  68769. '㌮' => 'ピアストル',
  68770. '㌯' => 'ピクル',
  68771. '㌰' => 'ピコ',
  68772. '㌱' => 'ビル',
  68773. '㌲' => 'ファラッド',
  68774. '㌳' => 'フィート',
  68775. '㌴' => 'ブッシェル',
  68776. '㌵' => 'フラン',
  68777. '㌶' => 'ヘクタール',
  68778. '㌷' => 'ペソ',
  68779. '㌸' => 'ペニヒ',
  68780. '㌹' => 'ヘルツ',
  68781. '㌺' => 'ペンス',
  68782. '㌻' => 'ページ',
  68783. '㌼' => 'ベータ',
  68784. '㌽' => 'ポイント',
  68785. '㌾' => 'ボルト',
  68786. '㌿' => 'ホン',
  68787. '�' => 'ポンド',
  68788. '�' => 'ホール',
  68789. '�' => 'ホーン',
  68790. '�' => 'マイクロ',
  68791. '�' => 'マイル',
  68792. '�' => 'マッ�',
  68793. '�' => 'マルク',
  68794. '�' => 'マンション',
  68795. '�' => 'ミクロン',
  68796. '�' => 'ミリ',
  68797. '�' => 'ミリ�゙ール',
  68798. '�' => 'メガ',
  68799. '�' => 'メガトン',
  68800. '�' => 'メートル',
  68801. '�' => 'ヤード',
  68802. '�' => 'ヤール',
  68803. '�' => 'ユアン',
  68804. '�' => 'リットル',
  68805. '�' => 'リラ',
  68806. '�' => 'ルピー',
  68807. '�' => 'ルーブル',
  68808. '�' => 'レム',
  68809. '�' => 'レントゲン',
  68810. '�' => 'ワット',
  68811. '�' => '0点',
  68812. '�' => '1点',
  68813. '�' => '2点',
  68814. '�' => '3点',
  68815. '�' => '4点',
  68816. '�' => '5点',
  68817. '�' => '6点',
  68818. '�' => '7点',
  68819. '�' => '8点',
  68820. '�' => '9点',
  68821. '�' => '10点',
  68822. '�' => '11点',
  68823. '�' => '12点',
  68824. '�' => '13点',
  68825. '�' => '14点',
  68826. '�' => '15点',
  68827. '�' => '16点',
  68828. '�' => '17点',
  68829. '�' => '18点',
  68830. '�' => '19点',
  68831. '�' => '20点',
  68832. '�' => '21点',
  68833. '�' => '22点',
  68834. '�' => '23点',
  68835. '�' => '24点',
  68836. '�' => 'hPa',
  68837. '�' => 'da',
  68838. '�' => 'AU',
  68839. '�' => 'bar',
  68840. '�' => 'oV',
  68841. '�' => 'pc',
  68842. '�' => 'dm',
  68843. '�' => 'dm2',
  68844. '�' => 'dm3',
  68845. '�' => 'IU',
  68846. '�' => '平�',
  68847. '�' => '昭和',
  68848. '�' => '大正',
  68849. '�' => '明治',
  68850. '�' => '株�会社',
  68851. '㎀' => 'pA',
  68852. '�' => 'nA',
  68853. '㎂' => 'μA',
  68854. '㎃' => 'mA',
  68855. '㎄' => 'kA',
  68856. '㎅' => 'KB',
  68857. '㎆' => 'MB',
  68858. '㎇' => 'GB',
  68859. '㎈' => 'cal',
  68860. '㎉' => 'kcal',
  68861. '㎊' => 'pF',
  68862. '㎋' => 'nF',
  68863. '㎌' => 'μF',
  68864. '�' => 'μg',
  68865. '㎎' => 'mg',
  68866. '�' => 'kg',
  68867. '�' => 'Hz',
  68868. '㎑' => 'kHz',
  68869. '㎒' => 'MHz',
  68870. '㎓' => 'GHz',
  68871. '㎔' => 'THz',
  68872. '㎕' => 'μl',
  68873. '㎖' => 'ml',
  68874. '㎗' => 'dl',
  68875. '㎘' => 'kl',
  68876. '㎙' => 'fm',
  68877. '㎚' => 'nm',
  68878. '㎛' => 'μm',
  68879. '㎜' => 'mm',
  68880. '�' => 'cm',
  68881. '㎞' => 'km',
  68882. '㎟' => 'mm2',
  68883. '㎠' => 'cm2',
  68884. '㎡' => 'm2',
  68885. '㎢' => 'km2',
  68886. '㎣' => 'mm3',
  68887. '㎤' => 'cm3',
  68888. '㎥' => 'm3',
  68889. '㎦' => 'km3',
  68890. '㎧' => 'm∕s',
  68891. '㎨' => 'm∕s2',
  68892. '㎩' => 'Pa',
  68893. '㎪' => 'kPa',
  68894. '㎫' => 'MPa',
  68895. '㎬' => 'GPa',
  68896. '㎭' => 'rad',
  68897. '㎮' => 'rad∕s',
  68898. '㎯' => 'rad∕s2',
  68899. '㎰' => 'ps',
  68900. '㎱' => 'ns',
  68901. '㎲' => 'μs',
  68902. '㎳' => 'ms',
  68903. '㎴' => 'pV',
  68904. '㎵' => 'nV',
  68905. '㎶' => 'μV',
  68906. '㎷' => 'mV',
  68907. '㎸' => 'kV',
  68908. '㎹' => 'MV',
  68909. '㎺' => 'pW',
  68910. '㎻' => 'nW',
  68911. '㎼' => 'μW',
  68912. '㎽' => 'mW',
  68913. '㎾' => 'kW',
  68914. '㎿' => 'MW',
  68915. '�' => 'kΩ',
  68916. '�' => 'MΩ',
  68917. '�' => 'a.m.',
  68918. '�' => 'Bq',
  68919. '�' => 'cc',
  68920. '�' => 'cd',
  68921. '�' => 'C∕kg',
  68922. '�' => 'Co.',
  68923. '�' => 'dB',
  68924. '�' => 'Gy',
  68925. '�' => 'ha',
  68926. '�' => 'HP',
  68927. '�' => 'in',
  68928. '�' => 'KK',
  68929. '�' => 'KM',
  68930. '�' => 'kt',
  68931. '�' => 'lm',
  68932. '�' => 'ln',
  68933. '�' => 'log',
  68934. '�' => 'lx',
  68935. '�' => 'mb',
  68936. '�' => 'mil',
  68937. '�' => 'mol',
  68938. '�' => 'PH',
  68939. '�' => 'p.m.',
  68940. '�' => 'PPM',
  68941. '�' => 'PR',
  68942. '�' => 'sr',
  68943. '�' => 'Sv',
  68944. '�' => 'Wb',
  68945. '�' => 'V∕m',
  68946. '�' => 'A∕m',
  68947. '�' => '1日',
  68948. '�' => '2日',
  68949. '�' => '3日',
  68950. '�' => '4日',
  68951. '�' => '5日',
  68952. '�' => '6日',
  68953. '�' => '7日',
  68954. '�' => '8日',
  68955. '�' => '9日',
  68956. '�' => '10日',
  68957. '�' => '11日',
  68958. '�' => '12日',
  68959. '�' => '13日',
  68960. '�' => '14日',
  68961. '�' => '15日',
  68962. '�' => '16日',
  68963. '�' => '17日',
  68964. '�' => '18日',
  68965. '�' => '19日',
  68966. '�' => '20日',
  68967. '�' => '21日',
  68968. '�' => '22日',
  68969. '�' => '23日',
  68970. '�' => '24日',
  68971. '�' => '25日',
  68972. '�' => '26日',
  68973. '�' => '27日',
  68974. '�' => '28日',
  68975. '�' => '29日',
  68976. '�' => '30日',
  68977. '�' => '31日',
  68978. '�' => 'gal',
  68979. 'ꚜ' => 'ъ',
  68980. '�' => 'ь',
  68981. '�' => '�',
  68982. 'ꟸ' => 'Ħ',
  68983. 'ꟹ' => 'œ',
  68984. 'ꭜ' => 'ꜧ',
  68985. '�' => 'ꬷ',
  68986. 'ê­ž' => 'É«',
  68987. 'ê­Ÿ' => 'ê­’',
  68988. 'ꭩ' => '�',
  68989. 'ff' => 'ff',
  68990. '�' => 'fi',
  68991. 'fl' => 'fl',
  68992. 'ffi' => 'ffi',
  68993. 'ffl' => 'ffl',
  68994. 'ſt' => 'st',
  68995. 'st' => 'st',
  68996. 'ﬓ' => 'մն',
  68997. 'ﬔ' => 'մե',
  68998. 'ﬕ' => 'մի',
  68999. 'ﬖ' => 'վն',
  69000. 'ﬗ' => 'մխ',
  69001. 'ﬠ' => 'ע',
  69002. 'ﬡ' => '�',
  69003. 'ﬢ' => 'ד',
  69004. 'ﬣ' => 'ה',
  69005. 'ﬤ' => 'כ',
  69006. 'ﬥ' => 'ל',
  69007. 'ﬦ' => '�',
  69008. 'ﬧ' => 'ר',
  69009. 'ﬨ' => 'ת',
  69010. '﬩' => '+',
  69011. '�' => '�ל',
  69012. 'ï­�' => 'Ù±',
  69013. 'ï­‘' => 'Ù±',
  69014. 'ï­’' => 'Ù»',
  69015. 'ï­“' => 'Ù»',
  69016. 'ï­”' => 'Ù»',
  69017. 'ï­•' => 'Ù»',
  69018. 'ï­–' => 'Ù¾',
  69019. 'ï­—' => 'Ù¾',
  69020. 'ï­˜' => 'Ù¾',
  69021. 'ï­™' => 'Ù¾',
  69022. 'ï­š' => 'Ú€',
  69023. 'ï­›' => 'Ú€',
  69024. 'ﭜ' => 'ڀ',
  69025. 'ï­�' => 'Ú€',
  69026. 'ï­ž' => 'Ùº',
  69027. 'ï­Ÿ' => 'Ùº',
  69028. 'ï­ ' => 'Ùº',
  69029. 'ï­¡' => 'Ùº',
  69030. 'ï­¢' => 'Ù¿',
  69031. 'ï­£' => 'Ù¿',
  69032. 'ï­¤' => 'Ù¿',
  69033. 'ï­¥' => 'Ù¿',
  69034. 'ï­¦' => 'Ù¹',
  69035. 'ï­§' => 'Ù¹',
  69036. 'ï­¨' => 'Ù¹',
  69037. 'ï­©' => 'Ù¹',
  69038. 'ï­ª' => 'Ú¤',
  69039. 'ï­«' => 'Ú¤',
  69040. 'ï­¬' => 'Ú¤',
  69041. 'ï­­' => 'Ú¤',
  69042. 'ï­®' => 'Ú¦',
  69043. 'ï­¯' => 'Ú¦',
  69044. 'ï­°' => 'Ú¦',
  69045. 'ï­±' => 'Ú¦',
  69046. 'ï­²' => 'Ú„',
  69047. 'ï­³' => 'Ú„',
  69048. 'ï­´' => 'Ú„',
  69049. 'ï­µ' => 'Ú„',
  69050. 'ï­¶' => 'Úƒ',
  69051. 'ï­·' => 'Úƒ',
  69052. 'ï­¸' => 'Úƒ',
  69053. 'ï­¹' => 'Úƒ',
  69054. 'ï­º' => 'Ú†',
  69055. 'ï­»' => 'Ú†',
  69056. 'ï­¼' => 'Ú†',
  69057. 'ï­½' => 'Ú†',
  69058. 'ï­¾' => 'Ú‡',
  69059. 'ï­¿' => 'Ú‡',
  69060. 'ﮀ' => 'ڇ',
  69061. '�' => 'ڇ',
  69062. 'ﮂ' => '�',
  69063. 'ﮃ' => '�',
  69064. 'ﮄ' => 'ڌ',
  69065. 'ﮅ' => 'ڌ',
  69066. 'ﮆ' => 'ڎ',
  69067. 'ﮇ' => 'ڎ',
  69068. 'ﮈ' => 'ڈ',
  69069. 'ﮉ' => 'ڈ',
  69070. 'ﮊ' => 'ژ',
  69071. 'ﮋ' => 'ژ',
  69072. 'ﮌ' => 'ڑ',
  69073. '�' => 'ڑ',
  69074. 'ﮎ' => 'ک',
  69075. '�' => 'ک',
  69076. '�' => 'ک',
  69077. 'ﮑ' => 'ک',
  69078. 'ï®’' => 'Ú¯',
  69079. 'ﮓ' => 'گ',
  69080. 'ï®”' => 'Ú¯',
  69081. 'ﮕ' => 'گ',
  69082. 'ï®–' => 'Ú³',
  69083. 'ï®—' => 'Ú³',
  69084. 'ﮘ' => 'ڳ',
  69085. 'ï®™' => 'Ú³',
  69086. 'ﮚ' => 'ڱ',
  69087. 'ï®›' => 'Ú±',
  69088. 'ﮜ' => 'ڱ',
  69089. '�' => 'ڱ',
  69090. 'ﮞ' => 'ں',
  69091. 'ﮟ' => 'ں',
  69092. 'ï® ' => 'Ú»',
  69093. 'ﮡ' => 'ڻ',
  69094. 'ﮢ' => 'ڻ',
  69095. 'ﮣ' => 'ڻ',
  69096. 'ﮤ' => 'ۀ',
  69097. 'ﮥ' => 'ۀ',
  69098. 'ﮦ' => '�',
  69099. 'ï®§' => 'Û�',
  69100. 'ﮨ' => '�',
  69101. 'ﮩ' => '�',
  69102. 'ﮪ' => 'ھ',
  69103. 'ﮫ' => 'ھ',
  69104. 'ﮬ' => 'ھ',
  69105. 'ï®­' => 'Ú¾',
  69106. 'ï®®' => 'Û’',
  69107. 'ﮯ' => 'ے',
  69108. 'ï®°' => 'Û’Ù”',
  69109. 'ï®±' => 'Û’Ù”',
  69110. 'ﯓ' => 'ڭ',
  69111. 'ﯔ' => 'ڭ',
  69112. 'ﯕ' => 'ڭ',
  69113. 'ﯖ' => 'ڭ',
  69114. 'ﯗ' => 'ۇ',
  69115. 'ﯘ' => 'ۇ',
  69116. 'ﯙ' => 'ۆ',
  69117. 'ﯚ' => 'ۆ',
  69118. 'ﯛ' => 'ۈ',
  69119. 'ﯜ' => 'ۈ',
  69120. '�' => 'ۇٴ',
  69121. 'ﯞ' => 'ۋ',
  69122. 'ﯟ' => 'ۋ',
  69123. 'ﯠ' => 'ۅ',
  69124. 'ﯡ' => 'ۅ',
  69125. 'ﯢ' => 'ۉ',
  69126. 'ﯣ' => 'ۉ',
  69127. 'ﯤ' => '�',
  69128. 'ﯥ' => '�',
  69129. 'ﯦ' => '�',
  69130. 'ﯧ' => '�',
  69131. 'ﯨ' => 'ى',
  69132. 'ﯩ' => 'ى',
  69133. 'ﯪ' => 'ئا',
  69134. 'ﯫ' => 'ئا',
  69135. 'ﯬ' => 'ئە',
  69136. 'ﯭ' => 'ئە',
  69137. 'ﯮ' => 'ئو',
  69138. 'ﯯ' => 'ئو',
  69139. 'ﯰ' => 'ئۇ',
  69140. 'ﯱ' => 'ئۇ',
  69141. 'ﯲ' => 'ئۆ',
  69142. 'ﯳ' => 'ئۆ',
  69143. 'ﯴ' => 'ئۈ',
  69144. 'ﯵ' => 'ئۈ',
  69145. 'ﯶ' => 'ئ�',
  69146. 'ﯷ' => 'ئ�',
  69147. 'ﯸ' => 'ئ�',
  69148. 'ﯹ' => 'ئى',
  69149. 'ﯺ' => 'ئى',
  69150. 'ﯻ' => 'ئى',
  69151. 'ﯼ' => 'ی',
  69152. 'ﯽ' => 'ی',
  69153. 'ﯾ' => 'ی',
  69154. 'ﯿ' => 'ی',
  69155. 'ﰀ' => 'ئج',
  69156. '�' => 'ئح',
  69157. 'ï°‚' => 'ÙŠÙ”Ù…',
  69158. 'ï°ƒ' => 'ÙŠÙ”Ù‰',
  69159. 'ï°„' => 'ÙŠÙ”ÙŠ',
  69160. 'ﰅ' => 'بج',
  69161. 'ﰆ' => 'بح',
  69162. 'ﰇ' => 'بخ',
  69163. 'ﰈ' => 'بم',
  69164. 'ﰉ' => 'بى',
  69165. 'ﰊ' => 'بي',
  69166. 'ﰋ' => 'تج',
  69167. 'ﰌ' => 'تح',
  69168. '�' => 'تخ',
  69169. 'ﰎ' => 'تم',
  69170. '�' => 'تى',
  69171. '�' => 'تي',
  69172. 'ﰑ' => 'ثج',
  69173. 'ﰒ' => 'ثم',
  69174. 'ﰓ' => 'ثى',
  69175. 'ﰔ' => 'ثي',
  69176. 'ﰕ' => 'جح',
  69177. 'ﰖ' => 'جم',
  69178. 'ﰗ' => 'حج',
  69179. 'ﰘ' => 'حم',
  69180. 'ﰙ' => 'خج',
  69181. 'ﰚ' => 'خح',
  69182. 'ﰛ' => 'خم',
  69183. 'ﰜ' => 'سج',
  69184. '�' => 'سح',
  69185. 'ﰞ' => 'سخ',
  69186. 'ﰟ' => 'سم',
  69187. 'ﰠ' => 'صح',
  69188. 'ﰡ' => 'صم',
  69189. 'ﰢ' => 'ضج',
  69190. 'ﰣ' => 'ضح',
  69191. 'ﰤ' => 'ضخ',
  69192. 'ﰥ' => 'ضم',
  69193. 'ﰦ' => 'طح',
  69194. 'ﰧ' => 'طم',
  69195. 'ﰨ' => 'ظم',
  69196. 'ﰩ' => 'عج',
  69197. 'ﰪ' => 'عم',
  69198. 'ﰫ' => 'غج',
  69199. 'ﰬ' => 'غم',
  69200. 'ﰭ' => '�ج',
  69201. 'ﰮ' => '�ح',
  69202. 'ﰯ' => '�خ',
  69203. 'ﰰ' => '�م',
  69204. 'ﰱ' => '�ى',
  69205. 'ﰲ' => '�ي',
  69206. 'ﰳ' => 'قح',
  69207. 'ﰴ' => 'قم',
  69208. 'ﰵ' => 'قى',
  69209. 'ﰶ' => 'قي',
  69210. 'ﰷ' => 'كا',
  69211. 'ﰸ' => 'كج',
  69212. 'ﰹ' => 'كح',
  69213. 'ﰺ' => 'كخ',
  69214. 'ﰻ' => 'كل',
  69215. 'ﰼ' => 'كم',
  69216. 'ﰽ' => 'كى',
  69217. 'ﰾ' => 'كي',
  69218. 'ﰿ' => 'لج',
  69219. 'ﱀ' => 'لح',
  69220. '�' => 'لخ',
  69221. 'ﱂ' => 'لم',
  69222. 'ﱃ' => 'لى',
  69223. 'ﱄ' => 'لي',
  69224. 'ﱅ' => 'مج',
  69225. 'ﱆ' => 'مح',
  69226. 'ﱇ' => 'مخ',
  69227. 'ﱈ' => 'مم',
  69228. 'ﱉ' => 'مى',
  69229. 'ﱊ' => 'مي',
  69230. 'ﱋ' => 'نج',
  69231. 'ﱌ' => 'نح',
  69232. '�' => 'نخ',
  69233. 'ﱎ' => 'نم',
  69234. '�' => 'نى',
  69235. '�' => 'ني',
  69236. 'ﱑ' => 'هج',
  69237. 'ﱒ' => 'هم',
  69238. 'ﱓ' => 'هى',
  69239. 'ﱔ' => 'هي',
  69240. 'ﱕ' => 'يج',
  69241. 'ﱖ' => 'يح',
  69242. 'ﱗ' => 'يخ',
  69243. 'ﱘ' => 'يم',
  69244. 'ﱙ' => 'يى',
  69245. 'ﱚ' => 'يي',
  69246. 'ﱛ' => 'ذٰ',
  69247. 'ﱜ' => 'رٰ',
  69248. '�' => 'ىٰ',
  69249. 'ﱞ' => ' ٌّ',
  69250. 'ﱟ' => ' �ّ',
  69251. 'ï± ' => ' ÙŽÙ‘',
  69252. 'ﱡ' => ' �ّ',
  69253. 'ﱢ' => ' �ّ',
  69254. 'ﱣ' => ' ّٰ',
  69255. 'ﱤ' => 'ئر',
  69256. 'ﱥ' => 'ئز',
  69257. 'ﱦ' => 'ئم',
  69258. 'ï±§' => 'ÙŠÙ”Ù†',
  69259. 'ﱨ' => 'ئى',
  69260. 'ﱩ' => 'ئي',
  69261. 'ﱪ' => 'بر',
  69262. 'ﱫ' => 'بز',
  69263. 'ﱬ' => 'بم',
  69264. 'ﱭ' => 'بن',
  69265. 'ﱮ' => 'بى',
  69266. 'ﱯ' => 'بي',
  69267. 'ﱰ' => 'تر',
  69268. 'ﱱ' => 'تز',
  69269. 'ﱲ' => 'تم',
  69270. 'ﱳ' => 'تن',
  69271. 'ﱴ' => 'تى',
  69272. 'ﱵ' => 'تي',
  69273. 'ﱶ' => 'ثر',
  69274. 'ﱷ' => 'ثز',
  69275. 'ﱸ' => 'ثم',
  69276. 'ﱹ' => 'ثن',
  69277. 'ﱺ' => 'ثى',
  69278. 'ﱻ' => 'ثي',
  69279. 'ﱼ' => '�ى',
  69280. 'ﱽ' => '�ي',
  69281. 'ﱾ' => 'قى',
  69282. 'ﱿ' => 'قي',
  69283. 'ﲀ' => 'كا',
  69284. '�' => 'كل',
  69285. 'ﲂ' => 'كم',
  69286. 'ﲃ' => 'كى',
  69287. 'ﲄ' => 'كي',
  69288. 'ﲅ' => 'لم',
  69289. 'ﲆ' => 'لى',
  69290. 'ﲇ' => 'لي',
  69291. 'ﲈ' => 'ما',
  69292. 'ﲉ' => 'مم',
  69293. 'ﲊ' => 'نر',
  69294. 'ﲋ' => 'نز',
  69295. 'ﲌ' => 'نم',
  69296. '�' => 'نن',
  69297. 'ﲎ' => 'نى',
  69298. '�' => 'ني',
  69299. '�' => 'ىٰ',
  69300. 'ﲑ' => 'ير',
  69301. 'ﲒ' => 'يز',
  69302. 'ﲓ' => 'يم',
  69303. 'ﲔ' => 'ين',
  69304. 'ﲕ' => 'يى',
  69305. 'ﲖ' => 'يي',
  69306. 'ﲗ' => 'ئج',
  69307. 'ﲘ' => 'ئح',
  69308. 'ﲙ' => 'ئخ',
  69309. 'ﲚ' => 'ئم',
  69310. 'ï²›' => 'ÙŠÙ”Ù‡',
  69311. 'ﲜ' => 'بج',
  69312. '�' => 'بح',
  69313. 'ﲞ' => 'بخ',
  69314. 'ﲟ' => 'بم',
  69315. 'ﲠ' => 'به',
  69316. 'ﲡ' => 'تج',
  69317. 'ﲢ' => 'تح',
  69318. 'ﲣ' => 'تخ',
  69319. 'ﲤ' => 'تم',
  69320. 'ﲥ' => 'ته',
  69321. 'ﲦ' => 'ثم',
  69322. 'ﲧ' => 'جح',
  69323. 'ﲨ' => 'جم',
  69324. 'ﲩ' => 'حج',
  69325. 'ﲪ' => 'حم',
  69326. 'ﲫ' => 'خج',
  69327. 'ﲬ' => 'خم',
  69328. 'ﲭ' => 'سج',
  69329. 'ﲮ' => 'سح',
  69330. 'ﲯ' => 'سخ',
  69331. 'ﲰ' => 'سم',
  69332. 'ﲱ' => 'صح',
  69333. 'ﲲ' => 'صخ',
  69334. 'ﲳ' => 'صم',
  69335. 'ﲴ' => 'ضج',
  69336. 'ﲵ' => 'ضح',
  69337. 'ﲶ' => 'ضخ',
  69338. 'ﲷ' => 'ضم',
  69339. 'ﲸ' => 'طح',
  69340. 'ﲹ' => 'ظم',
  69341. 'ﲺ' => 'عج',
  69342. 'ﲻ' => 'عم',
  69343. 'ﲼ' => 'غج',
  69344. 'ﲽ' => 'غم',
  69345. 'ﲾ' => '�ج',
  69346. 'ﲿ' => '�ح',
  69347. 'ﳀ' => '�خ',
  69348. '�' => '�م',
  69349. 'ﳂ' => 'قح',
  69350. 'ﳃ' => 'قم',
  69351. 'ﳄ' => 'كج',
  69352. 'ﳅ' => 'كح',
  69353. 'ﳆ' => 'كخ',
  69354. 'ﳇ' => 'كل',
  69355. 'ﳈ' => 'كم',
  69356. 'ﳉ' => 'لج',
  69357. 'ﳊ' => 'لح',
  69358. 'ﳋ' => 'لخ',
  69359. 'ﳌ' => 'لم',
  69360. '�' => 'له',
  69361. 'ﳎ' => 'مج',
  69362. '�' => 'مح',
  69363. '�' => 'مخ',
  69364. 'ﳑ' => 'مم',
  69365. 'ﳒ' => 'نج',
  69366. 'ﳓ' => 'نح',
  69367. 'ﳔ' => 'نخ',
  69368. 'ﳕ' => 'نم',
  69369. 'ﳖ' => 'نه',
  69370. 'ﳗ' => 'هج',
  69371. 'ﳘ' => 'هم',
  69372. 'ﳙ' => 'هٰ',
  69373. 'ﳚ' => 'يج',
  69374. 'ﳛ' => 'يح',
  69375. 'ﳜ' => 'يخ',
  69376. '�' => 'يم',
  69377. 'ﳞ' => 'يه',
  69378. 'ﳟ' => 'ئم',
  69379. 'ï³ ' => 'ÙŠÙ”Ù‡',
  69380. 'ﳡ' => 'بم',
  69381. 'ﳢ' => 'به',
  69382. 'ﳣ' => 'تم',
  69383. 'ﳤ' => 'ته',
  69384. 'ﳥ' => 'ثم',
  69385. 'ﳦ' => 'ثه',
  69386. 'ﳧ' => 'سم',
  69387. 'ﳨ' => 'سه',
  69388. 'ﳩ' => 'شم',
  69389. 'ﳪ' => 'شه',
  69390. 'ﳫ' => 'كل',
  69391. 'ﳬ' => 'كم',
  69392. 'ﳭ' => 'لم',
  69393. 'ﳮ' => 'نم',
  69394. 'ﳯ' => 'نه',
  69395. 'ﳰ' => 'يم',
  69396. 'ﳱ' => 'يه',
  69397. 'ï³²' => 'Ù€ÙŽÙ‘',
  69398. 'ﳳ' => 'ـ�ّ',
  69399. 'ﳴ' => 'ـ�ّ',
  69400. 'ﳵ' => 'طى',
  69401. 'ﳶ' => 'طي',
  69402. 'ﳷ' => 'عى',
  69403. 'ﳸ' => 'عي',
  69404. 'ﳹ' => 'غى',
  69405. 'ﳺ' => 'غي',
  69406. 'ﳻ' => 'سى',
  69407. 'ﳼ' => 'سي',
  69408. 'ﳽ' => 'شى',
  69409. 'ﳾ' => 'شي',
  69410. 'ﳿ' => 'حى',
  69411. 'ﴀ' => 'حي',
  69412. '�' => 'جى',
  69413. 'ﴂ' => 'جي',
  69414. 'ﴃ' => 'خى',
  69415. 'ﴄ' => 'خي',
  69416. 'ﴅ' => 'صى',
  69417. 'ﴆ' => 'صي',
  69418. 'ﴇ' => 'ضى',
  69419. 'ﴈ' => 'ضي',
  69420. 'ﴉ' => 'شج',
  69421. 'ﴊ' => 'شح',
  69422. 'ﴋ' => 'شخ',
  69423. 'ﴌ' => 'شم',
  69424. '�' => 'شر',
  69425. 'ﴎ' => 'سر',
  69426. '�' => 'صر',
  69427. '�' => 'ضر',
  69428. 'ﴑ' => 'طى',
  69429. 'ﴒ' => 'طي',
  69430. 'ﴓ' => 'عى',
  69431. 'ﴔ' => 'عي',
  69432. 'ﴕ' => 'غى',
  69433. 'ﴖ' => 'غي',
  69434. 'ﴗ' => 'سى',
  69435. 'ﴘ' => 'سي',
  69436. 'ﴙ' => 'شى',
  69437. 'ﴚ' => 'شي',
  69438. 'ﴛ' => 'حى',
  69439. 'ﴜ' => 'حي',
  69440. '�' => 'جى',
  69441. 'ﴞ' => 'جي',
  69442. 'ﴟ' => 'خى',
  69443. 'ﴠ' => 'خي',
  69444. 'ﴡ' => 'صى',
  69445. 'ﴢ' => 'صي',
  69446. 'ﴣ' => 'ضى',
  69447. 'ﴤ' => 'ضي',
  69448. 'ﴥ' => 'شج',
  69449. 'ﴦ' => 'شح',
  69450. 'ﴧ' => 'شخ',
  69451. 'ﴨ' => 'شم',
  69452. 'ﴩ' => 'شر',
  69453. 'ﴪ' => 'سر',
  69454. 'ﴫ' => 'صر',
  69455. 'ﴬ' => 'ضر',
  69456. 'ﴭ' => 'شج',
  69457. 'ﴮ' => 'شح',
  69458. 'ﴯ' => 'شخ',
  69459. 'ﴰ' => 'شم',
  69460. 'ﴱ' => 'سه',
  69461. 'ﴲ' => 'شه',
  69462. 'ﴳ' => 'طم',
  69463. 'ﴴ' => 'سج',
  69464. 'ﴵ' => 'سح',
  69465. 'ﴶ' => 'سخ',
  69466. 'ﴷ' => 'شج',
  69467. 'ﴸ' => 'شح',
  69468. 'ﴹ' => 'شخ',
  69469. 'ﴺ' => 'طم',
  69470. 'ﴻ' => 'ظم',
  69471. 'ﴼ' => 'اً',
  69472. 'ﴽ' => 'اً',
  69473. '�' => 'تجم',
  69474. 'ﵑ' => 'تحج',
  69475. 'ﵒ' => 'تحج',
  69476. 'ﵓ' => 'تحم',
  69477. 'ﵔ' => 'تخم',
  69478. 'ﵕ' => 'تمج',
  69479. 'ﵖ' => 'تمح',
  69480. 'ﵗ' => 'تمخ',
  69481. 'ﵘ' => 'جمح',
  69482. 'ﵙ' => 'جمح',
  69483. 'ﵚ' => 'حمي',
  69484. 'ﵛ' => 'حمى',
  69485. 'ﵜ' => 'سحج',
  69486. '�' => 'سجح',
  69487. 'ﵞ' => 'سجى',
  69488. 'ﵟ' => 'سمح',
  69489. 'ﵠ' => 'سمح',
  69490. 'ﵡ' => 'سمج',
  69491. 'ﵢ' => 'سمم',
  69492. 'ﵣ' => 'سمم',
  69493. 'ﵤ' => 'صحح',
  69494. 'ﵥ' => 'صحح',
  69495. 'ﵦ' => 'صمم',
  69496. 'ﵧ' => 'شحم',
  69497. 'ﵨ' => 'شحم',
  69498. 'ﵩ' => 'شجي',
  69499. 'ﵪ' => 'شمخ',
  69500. 'ﵫ' => 'شمخ',
  69501. 'ﵬ' => 'شمم',
  69502. 'ﵭ' => 'شمم',
  69503. 'ﵮ' => 'ضحى',
  69504. 'ﵯ' => 'ضخم',
  69505. 'ﵰ' => 'ضخم',
  69506. 'ﵱ' => 'طمح',
  69507. 'ﵲ' => 'طمح',
  69508. 'ﵳ' => 'طمم',
  69509. 'ﵴ' => 'طمي',
  69510. 'ﵵ' => 'عجم',
  69511. 'ﵶ' => 'عمم',
  69512. 'ﵷ' => 'عمم',
  69513. 'ﵸ' => 'عمى',
  69514. 'ﵹ' => 'غمم',
  69515. 'ﵺ' => 'غمي',
  69516. 'ﵻ' => 'غمى',
  69517. 'ﵼ' => '�خم',
  69518. 'ﵽ' => '�خم',
  69519. 'ﵾ' => 'قمح',
  69520. 'ﵿ' => 'قمم',
  69521. 'ﶀ' => 'لحم',
  69522. '�' => 'لحي',
  69523. 'ﶂ' => 'لحى',
  69524. 'ﶃ' => 'لجج',
  69525. 'ﶄ' => 'لجج',
  69526. 'ﶅ' => 'لخم',
  69527. 'ﶆ' => 'لخم',
  69528. 'ﶇ' => 'لمح',
  69529. 'ﶈ' => 'لمح',
  69530. 'ﶉ' => 'محج',
  69531. 'ﶊ' => 'محم',
  69532. 'ﶋ' => 'محي',
  69533. 'ﶌ' => 'مجح',
  69534. '�' => 'مجم',
  69535. 'ﶎ' => 'مخج',
  69536. '�' => 'مخم',
  69537. 'ﶒ' => 'مجخ',
  69538. 'ﶓ' => 'همج',
  69539. 'ﶔ' => 'همم',
  69540. 'ﶕ' => 'نحم',
  69541. 'ﶖ' => 'نحى',
  69542. 'ﶗ' => 'نجم',
  69543. 'ﶘ' => 'نجم',
  69544. 'ﶙ' => 'نجى',
  69545. 'ﶚ' => 'نمي',
  69546. 'ﶛ' => 'نمى',
  69547. 'ﶜ' => 'يمم',
  69548. '�' => 'يمم',
  69549. 'ﶞ' => 'بخي',
  69550. 'ﶟ' => 'تجي',
  69551. 'ﶠ' => 'تجى',
  69552. 'ﶡ' => 'تخي',
  69553. 'ﶢ' => 'تخى',
  69554. 'ﶣ' => 'تمي',
  69555. 'ﶤ' => 'تمى',
  69556. 'ﶥ' => 'جمي',
  69557. 'ﶦ' => 'جحى',
  69558. 'ﶧ' => 'جمى',
  69559. 'ﶨ' => 'سخى',
  69560. 'ﶩ' => 'صحي',
  69561. 'ﶪ' => 'شحي',
  69562. 'ﶫ' => 'ضحي',
  69563. 'ﶬ' => 'لجي',
  69564. 'ﶭ' => 'لمي',
  69565. 'ﶮ' => 'يحي',
  69566. 'ﶯ' => 'يجي',
  69567. 'ﶰ' => 'يمي',
  69568. 'ﶱ' => 'ممي',
  69569. 'ﶲ' => 'قمي',
  69570. 'ﶳ' => 'نحي',
  69571. 'ﶴ' => 'قمح',
  69572. 'ﶵ' => 'لحم',
  69573. 'ﶶ' => 'عمي',
  69574. 'ﶷ' => 'كمي',
  69575. 'ﶸ' => 'نجح',
  69576. 'ﶹ' => 'مخي',
  69577. 'ﶺ' => 'لجم',
  69578. 'ﶻ' => 'كمم',
  69579. 'ﶼ' => 'لجم',
  69580. 'ﶽ' => 'نجح',
  69581. 'ﶾ' => 'جحي',
  69582. 'ﶿ' => 'حجي',
  69583. 'ﷀ' => 'مجي',
  69584. '�' => '�مي',
  69585. 'ﷂ' => 'بحي',
  69586. 'ﷃ' => 'كمم',
  69587. 'ﷄ' => 'عجم',
  69588. 'ﷅ' => 'صمم',
  69589. 'ﷆ' => 'سخي',
  69590. 'ﷇ' => 'نجي',
  69591. 'ﷰ' => 'صلے',
  69592. 'ﷱ' => 'قلے',
  69593. 'ﷲ' => 'الله',
  69594. 'ﷳ' => 'اكبر',
  69595. 'ﷴ' => 'محمد',
  69596. 'ﷵ' => 'صلعم',
  69597. 'ﷶ' => 'رسول',
  69598. 'ﷷ' => 'عليه',
  69599. 'ﷸ' => 'وسلم',
  69600. 'ﷹ' => 'صلى',
  69601. 'ﷺ' => 'صلى الله عليه وسلم',
  69602. 'ﷻ' => 'جل جلاله',
  69603. '﷼' => 'ریال',
  69604. '�' => ',',
  69605. '︑' => '�',
  69606. '︒' => '。',
  69607. '︓' => ':',
  69608. '︔' => ';',
  69609. '︕' => '!',
  69610. '︖' => '?',
  69611. '︗' => '〖',
  69612. '︘' => '〗',
  69613. '︙' => '...',
  69614. '︰' => '..',
  69615. '︱' => '—',
  69616. '︲' => '–',
  69617. '︳' => '_',
  69618. '︴' => '_',
  69619. '︵' => '(',
  69620. '︶' => ')',
  69621. '︷' => '{',
  69622. '︸' => '}',
  69623. '︹' => '〔',
  69624. '︺' => '〕',
  69625. '︻' => '�',
  69626. '︼' => '】',
  69627. '︽' => '《',
  69628. '︾' => '》',
  69629. '︿' => '〈',
  69630. '﹀' => '〉',
  69631. '�' => '「',
  69632. '﹂' => '�',
  69633. '﹃' => '『',
  69634. '﹄' => '�',
  69635. '﹇' => '[',
  69636. '﹈' => ']',
  69637. '﹉' => ' ̅',
  69638. '﹊' => ' ̅',
  69639. '﹋' => ' ̅',
  69640. '﹌' => ' ̅',
  69641. '�' => '_',
  69642. '﹎' => '_',
  69643. '�' => '_',
  69644. '�' => ',',
  69645. '﹑' => '�',
  69646. 'ï¹’' => '.',
  69647. 'ï¹”' => ';',
  69648. '﹕' => ':',
  69649. 'ï¹–' => '?',
  69650. 'ï¹—' => '!',
  69651. '﹘' => '—',
  69652. 'ï¹™' => '(',
  69653. '﹚' => ')',
  69654. 'ï¹›' => '{',
  69655. '﹜' => '}',
  69656. '�' => '〔',
  69657. '﹞' => '〕',
  69658. '﹟' => '#',
  69659. 'ï¹ ' => '&',
  69660. '﹡' => '*',
  69661. 'ï¹¢' => '+',
  69662. 'ï¹£' => '-',
  69663. '﹤' => '<',
  69664. 'ï¹¥' => '>',
  69665. '﹦' => '=',
  69666. '﹨' => '\\',
  69667. '﹩' => '$',
  69668. '﹪' => '%',
  69669. '﹫' => '@',
  69670. 'ï¹°' => ' Ù‹',
  69671. 'ﹱ' => 'ـً',
  69672. 'ﹲ' => ' ٌ',
  69673. 'ï¹´' => ' Ù�',
  69674. 'ï¹¶' => ' ÙŽ',
  69675. 'ï¹·' => 'Ù€ÙŽ',
  69676. 'ﹸ' => ' �',
  69677. 'ﹹ' => 'ـ�',
  69678. 'ﹺ' => ' �',
  69679. 'ﹻ' => 'ـ�',
  69680. 'ï¹¼' => ' Ù‘',
  69681. 'ﹽ' => 'ـّ',
  69682. 'ï¹¾' => ' Ù’',
  69683. 'ﹿ' => 'ـْ',
  69684. 'ﺀ' => 'ء',
  69685. '�' => 'آ',
  69686. 'ﺂ' => 'آ',
  69687. 'ﺃ' => 'أ',
  69688. 'ﺄ' => 'أ',
  69689. 'ﺅ' => 'ؤ',
  69690. 'ﺆ' => 'ؤ',
  69691. 'ﺇ' => 'إ',
  69692. 'ﺈ' => 'إ',
  69693. 'ﺉ' => 'ئ',
  69694. 'ﺊ' => 'ئ',
  69695. 'ﺋ' => 'ئ',
  69696. 'ﺌ' => 'ئ',
  69697. '�' => 'ا',
  69698. 'ﺎ' => 'ا',
  69699. '�' => 'ب',
  69700. '�' => 'ب',
  69701. 'ﺑ' => 'ب',
  69702. 'ﺒ' => 'ب',
  69703. 'ﺓ' => 'ة',
  69704. 'ﺔ' => 'ة',
  69705. 'ﺕ' => 'ت',
  69706. 'ﺖ' => 'ت',
  69707. 'ﺗ' => 'ت',
  69708. 'ﺘ' => 'ت',
  69709. 'ﺙ' => 'ث',
  69710. 'ﺚ' => 'ث',
  69711. 'ﺛ' => 'ث',
  69712. 'ﺜ' => 'ث',
  69713. '�' => 'ج',
  69714. 'ﺞ' => 'ج',
  69715. 'ﺟ' => 'ج',
  69716. 'ﺠ' => 'ج',
  69717. 'ﺡ' => 'ح',
  69718. 'ﺢ' => 'ح',
  69719. 'ﺣ' => 'ح',
  69720. 'ﺤ' => 'ح',
  69721. 'ﺥ' => 'خ',
  69722. 'ﺦ' => 'خ',
  69723. 'ﺧ' => 'خ',
  69724. 'ﺨ' => 'خ',
  69725. 'ﺩ' => 'د',
  69726. 'ﺪ' => 'د',
  69727. 'ﺫ' => 'ذ',
  69728. 'ﺬ' => 'ذ',
  69729. 'ﺭ' => 'ر',
  69730. 'ﺮ' => 'ر',
  69731. 'ﺯ' => 'ز',
  69732. 'ﺰ' => 'ز',
  69733. 'ﺱ' => 'س',
  69734. 'ﺲ' => 'س',
  69735. 'ﺳ' => 'س',
  69736. 'ﺴ' => 'س',
  69737. 'ﺵ' => 'ش',
  69738. 'ﺶ' => 'ش',
  69739. 'ﺷ' => 'ش',
  69740. 'ﺸ' => 'ش',
  69741. 'ﺹ' => 'ص',
  69742. 'ﺺ' => 'ص',
  69743. 'ﺻ' => 'ص',
  69744. 'ﺼ' => 'ص',
  69745. 'ﺽ' => 'ض',
  69746. 'ﺾ' => 'ض',
  69747. 'ﺿ' => 'ض',
  69748. 'ﻀ' => 'ض',
  69749. '�' => 'ط',
  69750. 'ﻂ' => 'ط',
  69751. 'ﻃ' => 'ط',
  69752. 'ﻄ' => 'ط',
  69753. 'ﻅ' => 'ظ',
  69754. 'ﻆ' => 'ظ',
  69755. 'ﻇ' => 'ظ',
  69756. 'ﻈ' => 'ظ',
  69757. 'ﻉ' => 'ع',
  69758. 'ﻊ' => 'ع',
  69759. 'ﻋ' => 'ع',
  69760. 'ﻌ' => 'ع',
  69761. '�' => 'غ',
  69762. 'ﻎ' => 'غ',
  69763. '�' => 'غ',
  69764. '�' => 'غ',
  69765. 'ﻑ' => '�',
  69766. 'ï»’' => 'Ù�',
  69767. 'ﻓ' => '�',
  69768. 'ï»”' => 'Ù�',
  69769. 'ﻕ' => 'ق',
  69770. 'ï»–' => 'Ù‚',
  69771. 'ï»—' => 'Ù‚',
  69772. 'ﻘ' => 'ق',
  69773. 'ï»™' => 'Ùƒ',
  69774. 'ﻚ' => 'ك',
  69775. 'ï»›' => 'Ùƒ',
  69776. 'ﻜ' => 'ك',
  69777. '�' => 'ل',
  69778. 'ﻞ' => 'ل',
  69779. 'ﻟ' => 'ل',
  69780. 'ï» ' => 'Ù„',
  69781. 'ﻡ' => 'م',
  69782. 'ﻢ' => 'م',
  69783. 'ﻣ' => 'م',
  69784. 'ﻤ' => 'م',
  69785. 'ﻥ' => 'ن',
  69786. 'ﻦ' => 'ن',
  69787. 'ï»§' => 'Ù†',
  69788. 'ﻨ' => 'ن',
  69789. 'ﻩ' => 'ه',
  69790. 'ﻪ' => 'ه',
  69791. 'ﻫ' => 'ه',
  69792. 'ﻬ' => 'ه',
  69793. 'ï»­' => 'Ùˆ',
  69794. 'ï»®' => 'Ùˆ',
  69795. 'ﻯ' => 'ى',
  69796. 'ï»°' => 'Ù‰',
  69797. 'ï»±' => 'ÙŠ',
  69798. 'ﻲ' => 'ي',
  69799. 'ﻳ' => 'ي',
  69800. 'ï»´' => 'ÙŠ',
  69801. 'ﻵ' => 'لآ',
  69802. 'ﻶ' => 'لآ',
  69803. 'ﻷ' => 'لأ',
  69804. 'ﻸ' => 'لأ',
  69805. 'ﻹ' => 'لإ',
  69806. 'ﻺ' => 'لإ',
  69807. 'ﻻ' => 'لا',
  69808. 'ﻼ' => 'لا',
  69809. '�' => '!',
  69810. '"' => '"',
  69811. '#' => '#',
  69812. '$' => '$',
  69813. 'ï¼…' => '%',
  69814. '&' => '&',
  69815. ''' => '\'',
  69816. '(' => '(',
  69817. ')' => ')',
  69818. '*' => '*',
  69819. '+' => '+',
  69820. ',' => ',',
  69821. '�' => '-',
  69822. '.' => '.',
  69823. '�' => '/',
  69824. '�' => '0',
  69825. '1' => '1',
  69826. 'ï¼’' => '2',
  69827. '3' => '3',
  69828. 'ï¼”' => '4',
  69829. '5' => '5',
  69830. 'ï¼–' => '6',
  69831. 'ï¼—' => '7',
  69832. '8' => '8',
  69833. 'ï¼™' => '9',
  69834. ':' => ':',
  69835. 'ï¼›' => ';',
  69836. '<' => '<',
  69837. '�' => '=',
  69838. '>' => '>',
  69839. '?' => '?',
  69840. 'ï¼ ' => '@',
  69841. 'A' => 'A',
  69842. 'ï¼¢' => 'B',
  69843. 'ï¼£' => 'C',
  69844. 'D' => 'D',
  69845. 'ï¼¥' => 'E',
  69846. 'F' => 'F',
  69847. 'ï¼§' => 'G',
  69848. 'H' => 'H',
  69849. 'I' => 'I',
  69850. 'J' => 'J',
  69851. 'K' => 'K',
  69852. 'L' => 'L',
  69853. 'ï¼­' => 'M',
  69854. 'ï¼®' => 'N',
  69855. 'O' => 'O',
  69856. 'ï¼°' => 'P',
  69857. 'ï¼±' => 'Q',
  69858. 'ï¼²' => 'R',
  69859. 'ï¼³' => 'S',
  69860. 'ï¼´' => 'T',
  69861. 'ï¼µ' => 'U',
  69862. 'ï¼¶' => 'V',
  69863. 'ï¼·' => 'W',
  69864. 'X' => 'X',
  69865. 'ï¼¹' => 'Y',
  69866. 'Z' => 'Z',
  69867. 'ï¼»' => '[',
  69868. 'ï¼¼' => '\\',
  69869. 'ï¼½' => ']',
  69870. 'ï¼¾' => '^',
  69871. '_' => '_',
  69872. 'ï½€' => '`',
  69873. '�' => 'a',
  69874. 'b' => 'b',
  69875. 'c' => 'c',
  69876. 'd' => 'd',
  69877. 'ï½…' => 'e',
  69878. 'f' => 'f',
  69879. 'g' => 'g',
  69880. 'h' => 'h',
  69881. 'i' => 'i',
  69882. 'j' => 'j',
  69883. 'k' => 'k',
  69884. 'l' => 'l',
  69885. '�' => 'm',
  69886. 'n' => 'n',
  69887. '�' => 'o',
  69888. '�' => 'p',
  69889. 'q' => 'q',
  69890. 'ï½’' => 'r',
  69891. 's' => 's',
  69892. 'ï½”' => 't',
  69893. 'u' => 'u',
  69894. 'ï½–' => 'v',
  69895. 'ï½—' => 'w',
  69896. 'x' => 'x',
  69897. 'ï½™' => 'y',
  69898. 'z' => 'z',
  69899. 'ï½›' => '{',
  69900. '|' => '|',
  69901. '�' => '}',
  69902. '~' => '~',
  69903. '⦅' => '⦅',
  69904. '⦆' => '⦆',
  69905. '。' => '。',
  69906. '「' => '「',
  69907. '」' => '�',
  69908. '、' => '�',
  69909. '・' => '・',
  69910. 'ヲ' => 'ヲ',
  69911. 'ï½§' => 'ã‚¡',
  69912. 'ィ' => 'ィ',
  69913. 'ゥ' => 'ゥ',
  69914. 'ェ' => 'ェ',
  69915. 'ォ' => 'ォ',
  69916. 'ャ' => 'ャ',
  69917. 'ュ' => 'ュ',
  69918. 'ョ' => 'ョ',
  69919. 'ッ' => 'ッ',
  69920. 'ー' => 'ー',
  69921. 'ï½±' => 'ã‚¢',
  69922. 'イ' => 'イ',
  69923. 'ウ' => 'ウ',
  69924. 'エ' => 'エ',
  69925. 'オ' => 'オ',
  69926. 'ï½¶' => 'ã‚«',
  69927. 'ï½·' => 'ã‚­',
  69928. 'ク' => 'ク',
  69929. 'ケ' => 'ケ',
  69930. 'コ' => 'コ',
  69931. 'サ' => 'サ',
  69932. 'ï½¼' => 'ã‚·',
  69933. 'ス' => 'ス',
  69934. 'ï½¾' => 'ã‚»',
  69935. 'ソ' => 'ソ',
  69936. 'ï¾€' => 'ã‚¿',
  69937. '�' => '�',
  69938. 'ツ' => 'ツ',
  69939. 'テ' => 'テ',
  69940. 'ト' => 'ト',
  69941. 'ナ' => 'ナ',
  69942. 'ニ' => 'ニ',
  69943. 'ヌ' => 'ヌ',
  69944. 'ネ' => '�',
  69945. 'ノ' => 'ノ',
  69946. 'ハ' => '�',
  69947. 'ヒ' => 'ヒ',
  69948. 'フ' => 'フ',
  69949. '�' => 'ヘ',
  69950. 'ホ' => 'ホ',
  69951. '�' => 'マ',
  69952. '�' => 'ミ',
  69953. 'ム' => 'ム',
  69954. 'メ' => 'メ',
  69955. 'モ' => 'モ',
  69956. 'ヤ' => 'ヤ',
  69957. 'ユ' => 'ユ',
  69958. 'ヨ' => 'ヨ',
  69959. 'ラ' => 'ラ',
  69960. 'リ' => 'リ',
  69961. 'ル' => 'ル',
  69962. 'レ' => 'レ',
  69963. 'ロ' => 'ロ',
  69964. 'ワ' => 'ワ',
  69965. '�' => 'ン',
  69966. '゙' => '゙',
  69967. '゚' => '゚',
  69968. 'ï¾ ' => 'á… ',
  69969. 'ᄀ' => 'ᄀ',
  69970. 'ᄁ' => '�',
  69971. 'ᆪ' => 'ᆪ',
  69972. 'ᄂ' => 'ᄂ',
  69973. 'ᆬ' => 'ᆬ',
  69974. 'ᆭ' => 'ᆭ',
  69975. 'ᄃ' => 'ᄃ',
  69976. 'ᄄ' => 'ᄄ',
  69977. 'ᄅ' => 'ᄅ',
  69978. 'ᆰ' => 'ᆰ',
  69979. 'ᆱ' => 'ᆱ',
  69980. 'ᆲ' => 'ᆲ',
  69981. 'ᆳ' => 'ᆳ',
  69982. 'ᆴ' => 'ᆴ',
  69983. 'ᆵ' => 'ᆵ',
  69984. 'ᄚ' => 'ᄚ',
  69985. 'ᄆ' => 'ᄆ',
  69986. 'ᄇ' => 'ᄇ',
  69987. 'ᄈ' => 'ᄈ',
  69988. 'ï¾´' => 'á„¡',
  69989. 'ᄉ' => 'ᄉ',
  69990. 'ᄊ' => 'ᄊ',
  69991. 'ï¾·' => 'á„‹',
  69992. 'ᄌ' => 'ᄌ',
  69993. 'ᄍ' => '�',
  69994. 'ᄎ' => 'ᄎ',
  69995. 'ᄏ' => '�',
  69996. 'ᄐ' => '�',
  69997. 'ï¾½' => 'á„‘',
  69998. 'ï¾¾' => 'á„’',
  69999. 'ï¿‚' => 'á…¡',
  70000. 'ᅢ' => 'ᅢ',
  70001. 'ï¿„' => 'á…£',
  70002. 'ï¿…' => 'á…¤',
  70003. 'ᅥ' => 'ᅥ',
  70004. 'ᅦ' => 'ᅦ',
  70005. 'ᅧ' => 'ᅧ',
  70006. 'ï¿‹' => 'á…¨',
  70007. 'ᅩ' => 'ᅩ',
  70008. '�' => 'ᅪ',
  70009. 'ᅫ' => 'ᅫ',
  70010. '�' => 'ᅬ',
  70011. 'ï¿’' => 'á…­',
  70012. 'ï¿“' => 'á…®',
  70013. 'ï¿”' => 'á…¯',
  70014. 'ï¿•' => 'á…°',
  70015. 'ï¿–' => 'á…±',
  70016. 'ï¿—' => 'á…²',
  70017. 'ᅳ' => 'ᅳ',
  70018. 'ï¿›' => 'á…´',
  70019. 'ᅵ' => 'ᅵ',
  70020. '¢' => '¢',
  70021. '£' => '£',
  70022. '¬' => '¬',
  70023. 'ï¿£' => ' Ì„',
  70024. '¦' => '¦',
  70025. 'ï¿¥' => 'Â¥',
  70026. '₩' => '₩',
  70027. '│' => '│',
  70028. '←' => '�',
  70029. '↑' => '↑',
  70030. '→' => '→',
  70031. '↓' => '↓',
  70032. 'ï¿­' => 'â– ',
  70033. 'ï¿®' => 'â—‹',
  70034. '�' => 'A',
  70035. '�' => 'B',
  70036. '�' => 'C',
  70037. '�' => 'D',
  70038. '�' => 'E',
  70039. '�' => 'F',
  70040. '�' => 'G',
  70041. '�' => 'H',
  70042. '�' => 'I',
  70043. '�' => 'J',
  70044. '�' => 'K',
  70045. '�' => 'L',
  70046. '�' => 'M',
  70047. '�' => 'N',
  70048. '�' => 'O',
  70049. '�' => 'P',
  70050. '�' => 'Q',
  70051. '�' => 'R',
  70052. '�' => 'S',
  70053. '�' => 'T',
  70054. '�' => 'U',
  70055. '�' => 'V',
  70056. '�' => 'W',
  70057. '�' => 'X',
  70058. '�' => 'Y',
  70059. '�' => 'Z',
  70060. '�' => 'a',
  70061. '�' => 'b',
  70062. '�' => 'c',
  70063. '�' => 'd',
  70064. '�' => 'e',
  70065. '�' => 'f',
  70066. '�' => 'g',
  70067. '�' => 'h',
  70068. '�' => 'i',
  70069. '�' => 'j',
  70070. '�' => 'k',
  70071. '�' => 'l',
  70072. '�' => 'm',
  70073. '�' => 'n',
  70074. '�' => 'o',
  70075. '�' => 'p',
  70076. '�' => 'q',
  70077. '�' => 'r',
  70078. '�' => 's',
  70079. '�' => 't',
  70080. '�' => 'u',
  70081. '�' => 'v',
  70082. '�' => 'w',
  70083. '�' => 'x',
  70084. '�' => 'y',
  70085. '�' => 'z',
  70086. '�' => 'A',
  70087. '�' => 'B',
  70088. '�' => 'C',
  70089. '�' => 'D',
  70090. '�' => 'E',
  70091. '�' => 'F',
  70092. '�' => 'G',
  70093. '�' => 'H',
  70094. '�' => 'I',
  70095. '�' => 'J',
  70096. '�' => 'K',
  70097. '�' => 'L',
  70098. '�' => 'M',
  70099. '�' => 'N',
  70100. '�' => 'O',
  70101. '�' => 'P',
  70102. '�' => 'Q',
  70103. '�' => 'R',
  70104. '�' => 'S',
  70105. '�' => 'T',
  70106. '�' => 'U',
  70107. '�' => 'V',
  70108. '�' => 'W',
  70109. '�' => 'X',
  70110. '�' => 'Y',
  70111. '�' => 'Z',
  70112. '�' => 'a',
  70113. '�' => 'b',
  70114. '�' => 'c',
  70115. '�' => 'd',
  70116. '�' => 'e',
  70117. '�' => 'f',
  70118. '�' => 'g',
  70119. '�' => 'i',
  70120. '�' => 'j',
  70121. '�' => 'k',
  70122. '�' => 'l',
  70123. '�' => 'm',
  70124. '�' => 'n',
  70125. '�' => 'o',
  70126. '�' => 'p',
  70127. '�' => 'q',
  70128. '�' => 'r',
  70129. '�' => 's',
  70130. '�' => 't',
  70131. '�' => 'u',
  70132. '�' => 'v',
  70133. '�' => 'w',
  70134. '�' => 'x',
  70135. '�' => 'y',
  70136. '�' => 'z',
  70137. '�' => 'A',
  70138. '�' => 'B',
  70139. '�' => 'C',
  70140. '�' => 'D',
  70141. '�' => 'E',
  70142. '�' => 'F',
  70143. '�' => 'G',
  70144. '�' => 'H',
  70145. '�' => 'I',
  70146. '�' => 'J',
  70147. '�' => 'K',
  70148. '�' => 'L',
  70149. '�' => 'M',
  70150. '�' => 'N',
  70151. '�' => 'O',
  70152. '�' => 'P',
  70153. '�' => 'Q',
  70154. '�' => 'R',
  70155. '�' => 'S',
  70156. '�' => 'T',
  70157. '�' => 'U',
  70158. '�' => 'V',
  70159. '�' => 'W',
  70160. '�' => 'X',
  70161. '�' => 'Y',
  70162. '�' => 'Z',
  70163. '�' => 'a',
  70164. '�' => 'b',
  70165. '�' => 'c',
  70166. '�' => 'd',
  70167. '�' => 'e',
  70168. '�' => 'f',
  70169. '�' => 'g',
  70170. '�' => 'h',
  70171. '�' => 'i',
  70172. '�' => 'j',
  70173. '�' => 'k',
  70174. '�' => 'l',
  70175. '�' => 'm',
  70176. '�' => 'n',
  70177. '�' => 'o',
  70178. '�' => 'p',
  70179. '�' => 'q',
  70180. '�' => 'r',
  70181. '�' => 's',
  70182. '�' => 't',
  70183. '�' => 'u',
  70184. '�' => 'v',
  70185. '�' => 'w',
  70186. '�' => 'x',
  70187. '�' => 'y',
  70188. '�' => 'z',
  70189. '�' => 'A',
  70190. '�' => 'C',
  70191. '�' => 'D',
  70192. '�' => 'G',
  70193. '�' => 'J',
  70194. '�' => 'K',
  70195. '�' => 'N',
  70196. '�' => 'O',
  70197. '�' => 'P',
  70198. '�' => 'Q',
  70199. '�' => 'S',
  70200. '�' => 'T',
  70201. '�' => 'U',
  70202. '�' => 'V',
  70203. '�' => 'W',
  70204. '�' => 'X',
  70205. '�' => 'Y',
  70206. '�' => 'Z',
  70207. '�' => 'a',
  70208. '�' => 'b',
  70209. '�' => 'c',
  70210. '�' => 'd',
  70211. '�' => 'f',
  70212. '�' => 'h',
  70213. '�' => 'i',
  70214. '�' => 'j',
  70215. '�' => 'k',
  70216. '�' => 'l',
  70217. '�' => 'm',
  70218. '�' => 'n',
  70219. '�' => 'p',
  70220. '�' => 'q',
  70221. '�' => 'r',
  70222. '�' => 's',
  70223. '�' => 't',
  70224. '�' => 'u',
  70225. '�' => 'v',
  70226. '�' => 'w',
  70227. '�' => 'x',
  70228. '�' => 'y',
  70229. '�' => 'z',
  70230. '�' => 'A',
  70231. '�' => 'B',
  70232. '�' => 'C',
  70233. '�' => 'D',
  70234. '�' => 'E',
  70235. '�' => 'F',
  70236. '�' => 'G',
  70237. '�' => 'H',
  70238. '�' => 'I',
  70239. '�' => 'J',
  70240. '�' => 'K',
  70241. '�' => 'L',
  70242. '�' => 'M',
  70243. '�' => 'N',
  70244. '�' => 'O',
  70245. '�' => 'P',
  70246. '�' => 'Q',
  70247. '�' => 'R',
  70248. '�' => 'S',
  70249. '�' => 'T',
  70250. '�' => 'U',
  70251. '�' => 'V',
  70252. '�' => 'W',
  70253. '�' => 'X',
  70254. '�' => 'Y',
  70255. '�' => 'Z',
  70256. '�' => 'a',
  70257. '�' => 'b',
  70258. '�' => 'c',
  70259. '�' => 'd',
  70260. '�' => 'e',
  70261. '�' => 'f',
  70262. '�' => 'g',
  70263. '�' => 'h',
  70264. '�' => 'i',
  70265. '�' => 'j',
  70266. '�' => 'k',
  70267. '�' => 'l',
  70268. '�' => 'm',
  70269. '�' => 'n',
  70270. '�' => 'o',
  70271. '�' => 'p',
  70272. '�' => 'q',
  70273. '�' => 'r',
  70274. '�' => 's',
  70275. '�' => 't',
  70276. '�' => 'u',
  70277. '�' => 'v',
  70278. '�' => 'w',
  70279. '�' => 'x',
  70280. '�' => 'y',
  70281. '�' => 'z',
  70282. '�' => 'A',
  70283. '�' => 'B',
  70284. '�' => 'D',
  70285. '�' => 'E',
  70286. '�' => 'F',
  70287. '�' => 'G',
  70288. '�' => 'J',
  70289. '�' => 'K',
  70290. '�' => 'L',
  70291. '�' => 'M',
  70292. '�' => 'N',
  70293. '�' => 'O',
  70294. '�' => 'P',
  70295. '�' => 'Q',
  70296. '�' => 'S',
  70297. '�' => 'T',
  70298. '�' => 'U',
  70299. '�' => 'V',
  70300. '�' => 'W',
  70301. '�' => 'X',
  70302. '�' => 'Y',
  70303. '�' => 'a',
  70304. '�' => 'b',
  70305. '�' => 'c',
  70306. '�' => 'd',
  70307. '�' => 'e',
  70308. '�' => 'f',
  70309. '�' => 'g',
  70310. '�' => 'h',
  70311. '�' => 'i',
  70312. '�' => 'j',
  70313. '�' => 'k',
  70314. '�' => 'l',
  70315. '�' => 'm',
  70316. '�' => 'n',
  70317. '�' => 'o',
  70318. '�' => 'p',
  70319. '�' => 'q',
  70320. '�' => 'r',
  70321. '�' => 's',
  70322. '�' => 't',
  70323. '�' => 'u',
  70324. '�' => 'v',
  70325. '�' => 'w',
  70326. '�' => 'x',
  70327. '�' => 'y',
  70328. '�' => 'z',
  70329. '�' => 'A',
  70330. '�' => 'B',
  70331. '�' => 'D',
  70332. '�' => 'E',
  70333. '�' => 'F',
  70334. '�' => 'G',
  70335. '�' => 'I',
  70336. '�' => 'J',
  70337. '�' => 'K',
  70338. '�' => 'L',
  70339. '�' => 'M',
  70340. '�' => 'O',
  70341. '�' => 'S',
  70342. '�' => 'T',
  70343. '�' => 'U',
  70344. '�' => 'V',
  70345. '�' => 'W',
  70346. '�' => 'X',
  70347. '�' => 'Y',
  70348. '�' => 'a',
  70349. '�' => 'b',
  70350. '�' => 'c',
  70351. '�' => 'd',
  70352. '�' => 'e',
  70353. '�' => 'f',
  70354. '�' => 'g',
  70355. '�' => 'h',
  70356. '�' => 'i',
  70357. '�' => 'j',
  70358. '�' => 'k',
  70359. '�' => 'l',
  70360. '�' => 'm',
  70361. '�' => 'n',
  70362. '�' => 'o',
  70363. '�' => 'p',
  70364. '�' => 'q',
  70365. '�' => 'r',
  70366. '�' => 's',
  70367. '�' => 't',
  70368. '�' => 'u',
  70369. '�' => 'v',
  70370. '�' => 'w',
  70371. '�' => 'x',
  70372. '�' => 'y',
  70373. '�' => 'z',
  70374. '�' => 'A',
  70375. '�' => 'B',
  70376. '�' => 'C',
  70377. '�' => 'D',
  70378. '�' => 'E',
  70379. '�' => 'F',
  70380. '�' => 'G',
  70381. '�' => 'H',
  70382. '�' => 'I',
  70383. '�' => 'J',
  70384. '�' => 'K',
  70385. '�' => 'L',
  70386. '�' => 'M',
  70387. '�' => 'N',
  70388. '�' => 'O',
  70389. '�' => 'P',
  70390. '�' => 'Q',
  70391. '�' => 'R',
  70392. '�' => 'S',
  70393. '�' => 'T',
  70394. '�' => 'U',
  70395. '�' => 'V',
  70396. '�' => 'W',
  70397. '�' => 'X',
  70398. '�' => 'Y',
  70399. '�' => 'Z',
  70400. '�' => 'a',
  70401. '�' => 'b',
  70402. '�' => 'c',
  70403. '�' => 'd',
  70404. '�' => 'e',
  70405. '�' => 'f',
  70406. '�' => 'g',
  70407. '�' => 'h',
  70408. '�' => 'i',
  70409. '�' => 'j',
  70410. '�' => 'k',
  70411. '�' => 'l',
  70412. '�' => 'm',
  70413. '�' => 'n',
  70414. '�' => 'o',
  70415. '�' => 'p',
  70416. '�' => 'q',
  70417. '�' => 'r',
  70418. '�' => 's',
  70419. '�' => 't',
  70420. '�' => 'u',
  70421. '�' => 'v',
  70422. '�' => 'w',
  70423. '�' => 'x',
  70424. '�' => 'y',
  70425. '�' => 'z',
  70426. '�' => 'A',
  70427. '�' => 'B',
  70428. '�' => 'C',
  70429. '�' => 'D',
  70430. '�' => 'E',
  70431. '�' => 'F',
  70432. '�' => 'G',
  70433. '�' => 'H',
  70434. '�' => 'I',
  70435. '�' => 'J',
  70436. '�' => 'K',
  70437. '�' => 'L',
  70438. '�' => 'M',
  70439. '�' => 'N',
  70440. '�' => 'O',
  70441. '�' => 'P',
  70442. '�' => 'Q',
  70443. '�' => 'R',
  70444. '�' => 'S',
  70445. '�' => 'T',
  70446. '�' => 'U',
  70447. '�' => 'V',
  70448. '�' => 'W',
  70449. '�' => 'X',
  70450. '�' => 'Y',
  70451. '�' => 'Z',
  70452. '�' => 'a',
  70453. '�' => 'b',
  70454. '�' => 'c',
  70455. '�' => 'd',
  70456. '�' => 'e',
  70457. '�' => 'f',
  70458. '�' => 'g',
  70459. '�' => 'h',
  70460. '�' => 'i',
  70461. '�' => 'j',
  70462. '�' => 'k',
  70463. '�' => 'l',
  70464. '�' => 'm',
  70465. '�' => 'n',
  70466. '�' => 'o',
  70467. '�' => 'p',
  70468. '�' => 'q',
  70469. '�' => 'r',
  70470. '�' => 's',
  70471. '�' => 't',
  70472. '�' => 'u',
  70473. '�' => 'v',
  70474. '�' => 'w',
  70475. '�' => 'x',
  70476. '�' => 'y',
  70477. '�' => 'z',
  70478. '�' => 'A',
  70479. '�' => 'B',
  70480. '�' => 'C',
  70481. '�' => 'D',
  70482. '�' => 'E',
  70483. '�' => 'F',
  70484. '�' => 'G',
  70485. '�' => 'H',
  70486. '�' => 'I',
  70487. '�' => 'J',
  70488. '�' => 'K',
  70489. '�' => 'L',
  70490. '�' => 'M',
  70491. '�' => 'N',
  70492. '�' => 'O',
  70493. '�' => 'P',
  70494. '�' => 'Q',
  70495. '�' => 'R',
  70496. '�' => 'S',
  70497. '�' => 'T',
  70498. '�' => 'U',
  70499. '�' => 'V',
  70500. '�' => 'W',
  70501. '�' => 'X',
  70502. '�' => 'Y',
  70503. '�' => 'Z',
  70504. '�' => 'a',
  70505. '�' => 'b',
  70506. '�' => 'c',
  70507. '�' => 'd',
  70508. '�' => 'e',
  70509. '�' => 'f',
  70510. '�' => 'g',
  70511. '�' => 'h',
  70512. '�' => 'i',
  70513. '�' => 'j',
  70514. '�' => 'k',
  70515. '�' => 'l',
  70516. '�' => 'm',
  70517. '�' => 'n',
  70518. '�' => 'o',
  70519. '�' => 'p',
  70520. '�' => 'q',
  70521. '�' => 'r',
  70522. '�' => 's',
  70523. '�' => 't',
  70524. '�' => 'u',
  70525. '�' => 'v',
  70526. '�' => 'w',
  70527. '�' => 'x',
  70528. '�' => 'y',
  70529. '�' => 'z',
  70530. '�' => 'A',
  70531. '�' => 'B',
  70532. '�' => 'C',
  70533. '�' => 'D',
  70534. '�' => 'E',
  70535. '�' => 'F',
  70536. '�' => 'G',
  70537. '�' => 'H',
  70538. '�' => 'I',
  70539. '�' => 'J',
  70540. '�' => 'K',
  70541. '�' => 'L',
  70542. '�' => 'M',
  70543. '�' => 'N',
  70544. '�' => 'O',
  70545. '�' => 'P',
  70546. '�' => 'Q',
  70547. '�' => 'R',
  70548. '�' => 'S',
  70549. '�' => 'T',
  70550. '�' => 'U',
  70551. '�' => 'V',
  70552. '�' => 'W',
  70553. '�' => 'X',
  70554. '�' => 'Y',
  70555. '�' => 'Z',
  70556. '�' => 'a',
  70557. '�' => 'b',
  70558. '�' => 'c',
  70559. '�' => 'd',
  70560. '�' => 'e',
  70561. '�' => 'f',
  70562. '�' => 'g',
  70563. '�' => 'h',
  70564. '�' => 'i',
  70565. '�' => 'j',
  70566. '�' => 'k',
  70567. '�' => 'l',
  70568. '�' => 'm',
  70569. '�' => 'n',
  70570. '�' => 'o',
  70571. '�' => 'p',
  70572. '�' => 'q',
  70573. '�' => 'r',
  70574. '�' => 's',
  70575. '�' => 't',
  70576. '�' => 'u',
  70577. '�' => 'v',
  70578. '�' => 'w',
  70579. '�' => 'x',
  70580. '�' => 'y',
  70581. '�' => 'z',
  70582. '�' => 'A',
  70583. '�' => 'B',
  70584. '�' => 'C',
  70585. '�' => 'D',
  70586. '�' => 'E',
  70587. '�' => 'F',
  70588. '�' => 'G',
  70589. '�' => 'H',
  70590. '�' => 'I',
  70591. '�' => 'J',
  70592. '�' => 'K',
  70593. '�' => 'L',
  70594. '�' => 'M',
  70595. '�' => 'N',
  70596. '�' => 'O',
  70597. '�' => 'P',
  70598. '�' => 'Q',
  70599. '�' => 'R',
  70600. '�' => 'S',
  70601. '�' => 'T',
  70602. '�' => 'U',
  70603. '�' => 'V',
  70604. '�' => 'W',
  70605. '�' => 'X',
  70606. '�' => 'Y',
  70607. '�' => 'Z',
  70608. '�' => 'a',
  70609. '�' => 'b',
  70610. '�' => 'c',
  70611. '�' => 'd',
  70612. '�' => 'e',
  70613. '�' => 'f',
  70614. '�' => 'g',
  70615. '�' => 'h',
  70616. '�' => 'i',
  70617. '�' => 'j',
  70618. '�' => 'k',
  70619. '�' => 'l',
  70620. '�' => 'm',
  70621. '�' => 'n',
  70622. '�' => 'o',
  70623. '�' => 'p',
  70624. '�' => 'q',
  70625. '�' => 'r',
  70626. '�' => 's',
  70627. '�' => 't',
  70628. '�' => 'u',
  70629. '�' => 'v',
  70630. '�' => 'w',
  70631. '�' => 'x',
  70632. '�' => 'y',
  70633. '�' => 'z',
  70634. '�' => 'A',
  70635. '�' => 'B',
  70636. '�' => 'C',
  70637. '�' => 'D',
  70638. '�' => 'E',
  70639. '�' => 'F',
  70640. '�' => 'G',
  70641. '�' => 'H',
  70642. '�' => 'I',
  70643. '�' => 'J',
  70644. '�' => 'K',
  70645. '�' => 'L',
  70646. '�' => 'M',
  70647. '�' => 'N',
  70648. '�' => 'O',
  70649. '�' => 'P',
  70650. '�' => 'Q',
  70651. '�' => 'R',
  70652. '�' => 'S',
  70653. '�' => 'T',
  70654. '�' => 'U',
  70655. '�' => 'V',
  70656. '�' => 'W',
  70657. '�' => 'X',
  70658. '�' => 'Y',
  70659. '�' => 'Z',
  70660. '�' => 'a',
  70661. '�' => 'b',
  70662. '�' => 'c',
  70663. '�' => 'd',
  70664. '�' => 'e',
  70665. '�' => 'f',
  70666. '�' => 'g',
  70667. '�' => 'h',
  70668. '�' => 'i',
  70669. '�' => 'j',
  70670. '�' => 'k',
  70671. '�' => 'l',
  70672. '�' => 'm',
  70673. '�' => 'n',
  70674. '�' => 'o',
  70675. '�' => 'p',
  70676. '�' => 'q',
  70677. '�' => 'r',
  70678. '�' => 's',
  70679. '�' => 't',
  70680. '�' => 'u',
  70681. '�' => 'v',
  70682. '�' => 'w',
  70683. '�' => 'x',
  70684. '�' => 'y',
  70685. '�' => 'z',
  70686. '�' => 'ı',
  70687. '�' => 'ȷ',
  70688. '�' => 'Α',
  70689. '�' => 'Β',
  70690. '�' => 'Γ',
  70691. '�' => 'Δ',
  70692. '�' => 'Ε',
  70693. '�' => 'Ζ',
  70694. '�' => 'Η',
  70695. '�' => 'Θ',
  70696. '�' => 'Ι',
  70697. '�' => 'Κ',
  70698. '�' => 'Λ',
  70699. '�' => 'Μ',
  70700. '�' => '�',
  70701. '�' => 'Ξ',
  70702. '�' => 'Ο',
  70703. '�' => 'Π',
  70704. '�' => 'Ρ',
  70705. '�' => 'Θ',
  70706. '�' => 'Σ',
  70707. '�' => 'Τ',
  70708. '�' => 'Υ',
  70709. '�' => 'Φ',
  70710. '�' => 'Χ',
  70711. '�' => 'Ψ',
  70712. '�' => 'Ω',
  70713. '�' => '∇',
  70714. '�' => 'α',
  70715. '�' => 'β',
  70716. '�' => 'γ',
  70717. '�' => 'δ',
  70718. '�' => 'ε',
  70719. '�' => 'ζ',
  70720. '�' => 'η',
  70721. '�' => 'θ',
  70722. '�' => 'ι',
  70723. '�' => 'κ',
  70724. '�' => 'λ',
  70725. '�' => 'μ',
  70726. '�' => 'ν',
  70727. '�' => 'ξ',
  70728. '�' => 'ο',
  70729. '�' => 'π',
  70730. '�' => '�',
  70731. '�' => 'ς',
  70732. '�' => 'σ',
  70733. '�' => 'τ',
  70734. '�' => 'υ',
  70735. '�' => 'φ',
  70736. '�' => 'χ',
  70737. '�' => 'ψ',
  70738. '�' => 'ω',
  70739. '�' => '∂',
  70740. '�' => 'ε',
  70741. '�' => 'θ',
  70742. '�' => 'κ',
  70743. '�' => 'φ',
  70744. '�' => '�',
  70745. '�' => 'π',
  70746. '�' => 'Α',
  70747. '�' => 'Β',
  70748. '�' => 'Γ',
  70749. '�' => 'Δ',
  70750. '�' => 'Ε',
  70751. '�' => 'Ζ',
  70752. '�' => 'Η',
  70753. '�' => 'Θ',
  70754. '�' => 'Ι',
  70755. '�' => 'Κ',
  70756. '�' => 'Λ',
  70757. '�' => 'Μ',
  70758. '�' => '�',
  70759. '�' => 'Ξ',
  70760. '�' => 'Ο',
  70761. '�' => 'Π',
  70762. '�' => 'Ρ',
  70763. '�' => 'Θ',
  70764. '�' => 'Σ',
  70765. '�' => 'Τ',
  70766. '�' => 'Υ',
  70767. '�' => 'Φ',
  70768. '�' => 'Χ',
  70769. '�' => 'Ψ',
  70770. '�' => 'Ω',
  70771. '�' => '∇',
  70772. '�' => 'α',
  70773. '�' => 'β',
  70774. '�' => 'γ',
  70775. '�' => 'δ',
  70776. '�' => 'ε',
  70777. '�' => 'ζ',
  70778. '�' => 'η',
  70779. '�' => 'θ',
  70780. '�' => 'ι',
  70781. '�' => 'κ',
  70782. '�' => 'λ',
  70783. '�' => 'μ',
  70784. '�' => 'ν',
  70785. '�' => 'ξ',
  70786. '�' => 'ο',
  70787. '�' => 'π',
  70788. '�' => '�',
  70789. '�' => 'ς',
  70790. '�' => 'σ',
  70791. '�' => 'τ',
  70792. '�' => 'υ',
  70793. '�' => 'φ',
  70794. '�' => 'χ',
  70795. '�' => 'ψ',
  70796. '�' => 'ω',
  70797. '�' => '∂',
  70798. '�' => 'ε',
  70799. '�' => 'θ',
  70800. '�' => 'κ',
  70801. '�' => 'φ',
  70802. '�' => '�',
  70803. '�' => 'π',
  70804. '�' => 'Α',
  70805. '�' => 'Β',
  70806. '�' => 'Γ',
  70807. '�' => 'Δ',
  70808. '�' => 'Ε',
  70809. '�' => 'Ζ',
  70810. '�' => 'Η',
  70811. '�' => 'Θ',
  70812. '�' => 'Ι',
  70813. '�' => 'Κ',
  70814. '�' => 'Λ',
  70815. '�' => 'Μ',
  70816. '�' => '�',
  70817. '�' => 'Ξ',
  70818. '�' => 'Ο',
  70819. '�' => 'Π',
  70820. '�' => 'Ρ',
  70821. '�' => 'Θ',
  70822. '�' => 'Σ',
  70823. '�' => 'Τ',
  70824. '�' => 'Υ',
  70825. '�' => 'Φ',
  70826. '�' => 'Χ',
  70827. '�' => 'Ψ',
  70828. '�' => 'Ω',
  70829. '�' => '∇',
  70830. '�' => 'α',
  70831. '�' => 'β',
  70832. '�' => 'γ',
  70833. '�' => 'δ',
  70834. '�' => 'ε',
  70835. '�' => 'ζ',
  70836. '�' => 'η',
  70837. '�' => 'θ',
  70838. '�' => 'ι',
  70839. '�' => 'κ',
  70840. '�' => 'λ',
  70841. '�' => 'μ',
  70842. '�' => 'ν',
  70843. '�' => 'ξ',
  70844. '�' => 'ο',
  70845. '�' => 'π',
  70846. '�' => '�',
  70847. '�' => 'ς',
  70848. '�' => 'σ',
  70849. '�' => 'τ',
  70850. '�' => 'υ',
  70851. '�' => 'φ',
  70852. '�' => 'χ',
  70853. '�' => 'ψ',
  70854. '�' => 'ω',
  70855. '�' => '∂',
  70856. '�' => 'ε',
  70857. '�' => 'θ',
  70858. '�' => 'κ',
  70859. '�' => 'φ',
  70860. '�' => '�',
  70861. '�' => 'π',
  70862. '�' => 'Α',
  70863. '�' => 'Β',
  70864. '�' => 'Γ',
  70865. '�' => 'Δ',
  70866. '�' => 'Ε',
  70867. '�' => 'Ζ',
  70868. '�' => 'Η',
  70869. '�' => 'Θ',
  70870. '�' => 'Ι',
  70871. '�' => 'Κ',
  70872. '�' => 'Λ',
  70873. '�' => 'Μ',
  70874. '�' => '�',
  70875. '�' => 'Ξ',
  70876. '�' => 'Ο',
  70877. '�' => 'Π',
  70878. '�' => 'Ρ',
  70879. '�' => 'Θ',
  70880. '�' => 'Σ',
  70881. '�' => 'Τ',
  70882. '�' => 'Υ',
  70883. '�' => 'Φ',
  70884. '�' => 'Χ',
  70885. '�' => 'Ψ',
  70886. '�' => 'Ω',
  70887. '�' => '∇',
  70888. '�' => 'α',
  70889. '�' => 'β',
  70890. '�' => 'γ',
  70891. '�' => 'δ',
  70892. '�' => 'ε',
  70893. '�' => 'ζ',
  70894. '�' => 'η',
  70895. '�' => 'θ',
  70896. '�' => 'ι',
  70897. '�' => 'κ',
  70898. '�' => 'λ',
  70899. '�' => 'μ',
  70900. '�' => 'ν',
  70901. '�' => 'ξ',
  70902. '�' => 'ο',
  70903. '�' => 'π',
  70904. '�' => '�',
  70905. '�' => 'ς',
  70906. '�' => 'σ',
  70907. '�' => 'τ',
  70908. '�' => 'υ',
  70909. '�' => 'φ',
  70910. '�' => 'χ',
  70911. '�' => 'ψ',
  70912. '�' => 'ω',
  70913. '�' => '∂',
  70914. '�' => 'ε',
  70915. '�' => 'θ',
  70916. '�' => 'κ',
  70917. '�' => 'φ',
  70918. '�' => '�',
  70919. '�' => 'π',
  70920. '�' => 'Α',
  70921. '�' => 'Β',
  70922. '�' => 'Γ',
  70923. '�' => 'Δ',
  70924. '�' => 'Ε',
  70925. '�' => 'Ζ',
  70926. '�' => 'Η',
  70927. '�' => 'Θ',
  70928. '�' => 'Ι',
  70929. '�' => 'Κ',
  70930. '�' => 'Λ',
  70931. '�' => 'Μ',
  70932. '�' => '�',
  70933. '�' => 'Ξ',
  70934. '�' => 'Ο',
  70935. '�' => 'Π',
  70936. '�' => 'Ρ',
  70937. '�' => 'Θ',
  70938. '�' => 'Σ',
  70939. '�' => 'Τ',
  70940. '�' => 'Υ',
  70941. '�' => 'Φ',
  70942. '�' => 'Χ',
  70943. '�' => 'Ψ',
  70944. '�' => 'Ω',
  70945. '�' => '∇',
  70946. '�' => 'α',
  70947. '�' => 'β',
  70948. '�' => 'γ',
  70949. '�' => 'δ',
  70950. '�' => 'ε',
  70951. '�' => 'ζ',
  70952. '�' => 'η',
  70953. '�' => 'θ',
  70954. '�' => 'ι',
  70955. '�' => 'κ',
  70956. '�' => 'λ',
  70957. '�' => 'μ',
  70958. '�' => 'ν',
  70959. '�' => 'ξ',
  70960. '�' => 'ο',
  70961. '�' => 'π',
  70962. '�' => '�',
  70963. '�' => 'ς',
  70964. '�' => 'σ',
  70965. '�' => 'τ',
  70966. '�' => 'υ',
  70967. '�' => 'φ',
  70968. '�' => 'χ',
  70969. '�' => 'ψ',
  70970. '�' => 'ω',
  70971. '�' => '∂',
  70972. '�' => 'ε',
  70973. '�' => 'θ',
  70974. '�' => 'κ',
  70975. '�' => 'φ',
  70976. '�' => '�',
  70977. '�' => 'π',
  70978. '�' => 'Ϝ',
  70979. '�' => '�',
  70980. '�' => '0',
  70981. '�' => '1',
  70982. '�' => '2',
  70983. '�' => '3',
  70984. '�' => '4',
  70985. '�' => '5',
  70986. '�' => '6',
  70987. '�' => '7',
  70988. '�' => '8',
  70989. '�' => '9',
  70990. '�' => '0',
  70991. '�' => '1',
  70992. '�' => '2',
  70993. '�' => '3',
  70994. '�' => '4',
  70995. '�' => '5',
  70996. '�' => '6',
  70997. '�' => '7',
  70998. '�' => '8',
  70999. '�' => '9',
  71000. '�' => '0',
  71001. '�' => '1',
  71002. '�' => '2',
  71003. '�' => '3',
  71004. '�' => '4',
  71005. '�' => '5',
  71006. '�' => '6',
  71007. '�' => '7',
  71008. '�' => '8',
  71009. '�' => '9',
  71010. '�' => '0',
  71011. '�' => '1',
  71012. '�' => '2',
  71013. '�' => '3',
  71014. '�' => '4',
  71015. '�' => '5',
  71016. '�' => '6',
  71017. '�' => '7',
  71018. '�' => '8',
  71019. '�' => '9',
  71020. '�' => '0',
  71021. '�' => '1',
  71022. '�' => '2',
  71023. '�' => '3',
  71024. '�' => '4',
  71025. '�' => '5',
  71026. '�' => '6',
  71027. '�' => '7',
  71028. '�' => '8',
  71029. '�' => '9',
  71030. '𞸀' => 'ا',
  71031. '�' => 'ب',
  71032. '𞸂' => 'ج',
  71033. '𞸃' => 'د',
  71034. '𞸅' => 'و',
  71035. '𞸆' => 'ز',
  71036. '𞸇' => 'ح',
  71037. '𞸈' => 'ط',
  71038. '𞸉' => 'ي',
  71039. '𞸊' => 'ك',
  71040. '𞸋' => 'ل',
  71041. '𞸌' => 'م',
  71042. '�' => 'ن',
  71043. '𞸎' => 'س',
  71044. '�' => 'ع',
  71045. '�' => '�',
  71046. '𞸑' => 'ص',
  71047. '𞸒' => 'ق',
  71048. '𞸓' => 'ر',
  71049. '𞸔' => 'ش',
  71050. '𞸕' => 'ت',
  71051. '𞸖' => 'ث',
  71052. '𞸗' => 'خ',
  71053. '𞸘' => 'ذ',
  71054. '𞸙' => 'ض',
  71055. '𞸚' => 'ظ',
  71056. '𞸛' => 'غ',
  71057. '𞸜' => 'ٮ',
  71058. '�' => 'ں',
  71059. '𞸞' => 'ڡ',
  71060. '𞸟' => 'ٯ',
  71061. '𞸡' => 'ب',
  71062. '𞸢' => 'ج',
  71063. '𞸤' => 'ه',
  71064. '𞸧' => 'ح',
  71065. '𞸩' => 'ي',
  71066. '𞸪' => 'ك',
  71067. '𞸫' => 'ل',
  71068. '𞸬' => 'م',
  71069. '𞸭' => 'ن',
  71070. '𞸮' => 'س',
  71071. '𞸯' => 'ع',
  71072. '𞸰' => '�',
  71073. '𞸱' => 'ص',
  71074. '𞸲' => 'ق',
  71075. '𞸴' => 'ش',
  71076. '𞸵' => 'ت',
  71077. '𞸶' => 'ث',
  71078. '𞸷' => 'خ',
  71079. '𞸹' => 'ض',
  71080. '𞸻' => 'غ',
  71081. '𞹂' => 'ج',
  71082. '𞹇' => 'ح',
  71083. '𞹉' => 'ي',
  71084. '𞹋' => 'ل',
  71085. '�' => 'ن',
  71086. '𞹎' => 'س',
  71087. '�' => 'ع',
  71088. '𞹑' => 'ص',
  71089. 'ðž¹’' => 'Ù‚',
  71090. 'ðž¹”' => 'Ø´',
  71091. 'ðž¹—' => 'Ø®',
  71092. '𞹙' => 'ض',
  71093. '𞹛' => 'غ',
  71094. '�' => 'ں',
  71095. '𞹟' => 'ٯ',
  71096. '𞹡' => 'ب',
  71097. '𞹢' => 'ج',
  71098. '𞹤' => 'ه',
  71099. 'ðž¹§' => 'Ø­',
  71100. '𞹨' => 'ط',
  71101. '𞹩' => 'ي',
  71102. '𞹪' => 'ك',
  71103. '𞹬' => 'م',
  71104. 'ðž¹­' => 'Ù†',
  71105. '𞹮' => 'س',
  71106. '𞹯' => 'ع',
  71107. 'ðž¹°' => 'Ù�',
  71108. '𞹱' => 'ص',
  71109. 'ðž¹²' => 'Ù‚',
  71110. 'ðž¹´' => 'Ø´',
  71111. '𞹵' => 'ت',
  71112. 'ðž¹¶' => 'Ø«',
  71113. 'ðž¹·' => 'Ø®',
  71114. '𞹹' => 'ض',
  71115. '𞹺' => 'ظ',
  71116. '𞹻' => 'غ',
  71117. 'ðž¹¼' => 'Ù®',
  71118. 'ðž¹¾' => 'Ú¡',
  71119. '𞺀' => 'ا',
  71120. '�' => 'ب',
  71121. '𞺂' => 'ج',
  71122. '𞺃' => 'د',
  71123. '𞺄' => 'ه',
  71124. '𞺅' => 'و',
  71125. '𞺆' => 'ز',
  71126. '𞺇' => 'ح',
  71127. '𞺈' => 'ط',
  71128. '𞺉' => 'ي',
  71129. '𞺋' => 'ل',
  71130. '𞺌' => 'م',
  71131. '�' => 'ن',
  71132. '𞺎' => 'س',
  71133. '�' => 'ع',
  71134. '�' => '�',
  71135. '𞺑' => 'ص',
  71136. '𞺒' => 'ق',
  71137. '𞺓' => 'ر',
  71138. '𞺔' => 'ش',
  71139. '𞺕' => 'ت',
  71140. '𞺖' => 'ث',
  71141. '𞺗' => 'خ',
  71142. '𞺘' => 'ذ',
  71143. '𞺙' => 'ض',
  71144. '𞺚' => 'ظ',
  71145. '𞺛' => 'غ',
  71146. '𞺡' => 'ب',
  71147. '𞺢' => 'ج',
  71148. '𞺣' => 'د',
  71149. '𞺥' => 'و',
  71150. '𞺦' => 'ز',
  71151. '𞺧' => 'ح',
  71152. '𞺨' => 'ط',
  71153. '𞺩' => 'ي',
  71154. '𞺫' => 'ل',
  71155. '𞺬' => 'م',
  71156. '𞺭' => 'ن',
  71157. '𞺮' => 'س',
  71158. '𞺯' => 'ع',
  71159. '𞺰' => '�',
  71160. '𞺱' => 'ص',
  71161. '𞺲' => 'ق',
  71162. '𞺳' => 'ر',
  71163. '𞺴' => 'ش',
  71164. '𞺵' => 'ت',
  71165. '𞺶' => 'ث',
  71166. '𞺷' => 'خ',
  71167. '𞺸' => 'ذ',
  71168. '𞺹' => 'ض',
  71169. '𞺺' => 'ظ',
  71170. '𞺻' => 'غ',
  71171. '🄀' => '0.',
  71172. '�' => '0,',
  71173. '🄂' => '1,',
  71174. '🄃' => '2,',
  71175. '🄄' => '3,',
  71176. '🄅' => '4,',
  71177. '🄆' => '5,',
  71178. '🄇' => '6,',
  71179. '🄈' => '7,',
  71180. '🄉' => '8,',
  71181. '🄊' => '9,',
  71182. '�' => '(A)',
  71183. '🄑' => '(B)',
  71184. '🄒' => '(C)',
  71185. '🄓' => '(D)',
  71186. '🄔' => '(E)',
  71187. '🄕' => '(F)',
  71188. '🄖' => '(G)',
  71189. '🄗' => '(H)',
  71190. '🄘' => '(I)',
  71191. '🄙' => '(J)',
  71192. '🄚' => '(K)',
  71193. '🄛' => '(L)',
  71194. '🄜' => '(M)',
  71195. '�' => '(N)',
  71196. '🄞' => '(O)',
  71197. '🄟' => '(P)',
  71198. '🄠' => '(Q)',
  71199. '🄡' => '(R)',
  71200. '🄢' => '(S)',
  71201. '🄣' => '(T)',
  71202. '🄤' => '(U)',
  71203. '🄥' => '(V)',
  71204. '🄦' => '(W)',
  71205. '🄧' => '(X)',
  71206. '🄨' => '(Y)',
  71207. '🄩' => '(Z)',
  71208. '🄪' => '〔S〕',
  71209. '🄫' => 'C',
  71210. '🄬' => 'R',
  71211. '🄭' => 'CD',
  71212. '🄮' => 'WZ',
  71213. '🄰' => 'A',
  71214. '🄱' => 'B',
  71215. '🄲' => 'C',
  71216. '🄳' => 'D',
  71217. '🄴' => 'E',
  71218. '🄵' => 'F',
  71219. '🄶' => 'G',
  71220. '🄷' => 'H',
  71221. '🄸' => 'I',
  71222. '🄹' => 'J',
  71223. '🄺' => 'K',
  71224. '🄻' => 'L',
  71225. '🄼' => 'M',
  71226. '🄽' => 'N',
  71227. '🄾' => 'O',
  71228. '🄿' => 'P',
  71229. '🅀' => 'Q',
  71230. '�' => 'R',
  71231. '🅂' => 'S',
  71232. '🅃' => 'T',
  71233. '🅄' => 'U',
  71234. '🅅' => 'V',
  71235. '🅆' => 'W',
  71236. '🅇' => 'X',
  71237. '🅈' => 'Y',
  71238. '🅉' => 'Z',
  71239. '🅊' => 'HV',
  71240. '🅋' => 'MV',
  71241. '🅌' => 'SD',
  71242. '�' => 'SS',
  71243. '🅎' => 'PPV',
  71244. '�' => 'WC',
  71245. '🅪' => 'MC',
  71246. '🅫' => 'MD',
  71247. '🅬' => 'MR',
  71248. '�' => 'DJ',
  71249. '🈀' => '��',
  71250. '�' => 'ココ',
  71251. '🈂' => 'サ',
  71252. '�' => '手',
  71253. '🈑' => '字',
  71254. '🈒' => '�',
  71255. '🈓' => 'デ',
  71256. '🈔' => '二',
  71257. '🈕' => '多',
  71258. '🈖' => '解',
  71259. '🈗' => '天',
  71260. '🈘' => '交',
  71261. '🈙' => '映',
  71262. '🈚' => '無',
  71263. '🈛' => '料',
  71264. '🈜' => '�',
  71265. '�' => '後',
  71266. '🈞' => '�',
  71267. '🈟' => '新',
  71268. '🈠' => '�',
  71269. '🈡' => '終',
  71270. '🈢' => '生',
  71271. '🈣' => '販',
  71272. '🈤' => '声',
  71273. '🈥' => '�',
  71274. '🈦' => '演',
  71275. '🈧' => '投',
  71276. '🈨' => '�',
  71277. '🈩' => '一',
  71278. '🈪' => '三',
  71279. '🈫' => '�',
  71280. '🈬' => '左',
  71281. '🈭' => '中',
  71282. '🈮' => '�',
  71283. '🈯' => '指',
  71284. '🈰' => '走',
  71285. '🈱' => '打',
  71286. '🈲' => '�',
  71287. '🈳' => '空',
  71288. '🈴' => '�',
  71289. '🈵' => '満',
  71290. '🈶' => '有',
  71291. '🈷' => '月',
  71292. '🈸' => '申',
  71293. '🈹' => '割',
  71294. '🈺' => '営',
  71295. '🈻' => '�',
  71296. '🉀' => '〔本〕',
  71297. '�' => '〔三〕',
  71298. '🉂' => '〔二〕',
  71299. '🉃' => '〔安〕',
  71300. '🉄' => '〔点〕',
  71301. '🉅' => '〔打〕',
  71302. '🉆' => '〔盗〕',
  71303. '🉇' => '〔�〕',
  71304. '🉈' => '〔敗〕',
  71305. '�' => '得',
  71306. '🉑' => '�',
  71307. '🯰' => '0',
  71308. '🯱' => '1',
  71309. '🯲' => '2',
  71310. '🯳' => '3',
  71311. '🯴' => '4',
  71312. '🯵' => '5',
  71313. '🯶' => '6',
  71314. '🯷' => '7',
  71315. '🯸' => '8',
  71316. '🯹' => '9',
  71317. );
  71318. <?php
  71319. use Symfony\Polyfill\Intl\Normalizer as p;
  71320. if (\PHP_VERSION_ID >= 80000) {
  71321. return require __DIR__.'/bootstrap80.php';
  71322. }
  71323. if (!function_exists('normalizer_is_normalized')) {
  71324. function normalizer_is_normalized($string, $form = p\Normalizer::FORM_C) { return p\Normalizer::isNormalized($string, $form); }
  71325. }
  71326. if (!function_exists('normalizer_normalize')) {
  71327. function normalizer_normalize($string, $form = p\Normalizer::FORM_C) { return p\Normalizer::normalize($string, $form); }
  71328. }
  71329. <?php
  71330. use Symfony\Polyfill\Intl\Normalizer as p;
  71331. if (!function_exists('normalizer_is_normalized')) {
  71332. function normalizer_is_normalized(?string $string, ?int $form = p\Normalizer::FORM_C): bool { return p\Normalizer::isNormalized((string) $string, (int) $form); }
  71333. }
  71334. if (!function_exists('normalizer_normalize')) {
  71335. function normalizer_normalize(?string $string, ?int $form = p\Normalizer::FORM_C): string|false { return p\Normalizer::normalize((string) $string, (int) $form); }
  71336. }
  71337. Copyright (c) 2015-2019 Fabien Potencier
  71338. Permission is hereby granted, free of charge, to any person obtaining a copy
  71339. of this software and associated documentation files (the "Software"), to deal
  71340. in the Software without restriction, including without limitation the rights
  71341. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  71342. copies of the Software, and to permit persons to whom the Software is furnished
  71343. to do so, subject to the following conditions:
  71344. The above copyright notice and this permission notice shall be included in all
  71345. copies or substantial portions of the Software.
  71346. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  71347. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  71348. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  71349. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  71350. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  71351. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  71352. THE SOFTWARE.
  71353. <?php
  71354. namespace Symfony\Polyfill\Mbstring;
  71355. final class Mbstring
  71356. {
  71357. public const MB_CASE_FOLD = \PHP_INT_MAX;
  71358. private const CASE_FOLD = [
  71359. ['µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"],
  71360. ['μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', '�', 'ε', "\xE1\xB9\xA1", 'ι'],
  71361. ];
  71362. private static $encodingList = ['ASCII', 'UTF-8'];
  71363. private static $language = 'neutral';
  71364. private static $internalEncoding = 'UTF-8';
  71365. public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
  71366. {
  71367. if (\is_array($fromEncoding) || ($fromEncoding !== null && false !== strpos($fromEncoding, ','))) {
  71368. $fromEncoding = self::mb_detect_encoding($s, $fromEncoding);
  71369. } else {
  71370. $fromEncoding = self::getEncoding($fromEncoding);
  71371. }
  71372. $toEncoding = self::getEncoding($toEncoding);
  71373. if ('BASE64' === $fromEncoding) {
  71374. $s = base64_decode($s);
  71375. $fromEncoding = $toEncoding;
  71376. }
  71377. if ('BASE64' === $toEncoding) {
  71378. return base64_encode($s);
  71379. }
  71380. if ('HTML-ENTITIES' === $toEncoding || 'HTML' === $toEncoding) {
  71381. if ('HTML-ENTITIES' === $fromEncoding || 'HTML' === $fromEncoding) {
  71382. $fromEncoding = 'Windows-1252';
  71383. }
  71384. if ('UTF-8' !== $fromEncoding) {
  71385. $s = \iconv($fromEncoding, 'UTF-8//IGNORE', $s);
  71386. }
  71387. return preg_replace_callback('/[\x80-\xFF]+/', [__CLASS__, 'html_encoding_callback'], $s);
  71388. }
  71389. if ('HTML-ENTITIES' === $fromEncoding) {
  71390. $s = html_entity_decode($s, \ENT_COMPAT, 'UTF-8');
  71391. $fromEncoding = 'UTF-8';
  71392. }
  71393. return \iconv($fromEncoding, $toEncoding.'//IGNORE', $s);
  71394. }
  71395. public static function mb_convert_variables($toEncoding, $fromEncoding, &...$vars)
  71396. {
  71397. $ok = true;
  71398. array_walk_recursive($vars, function (&$v) use (&$ok, $toEncoding, $fromEncoding) {
  71399. if (false === $v = self::mb_convert_encoding($v, $toEncoding, $fromEncoding)) {
  71400. $ok = false;
  71401. }
  71402. });
  71403. return $ok ? $fromEncoding : false;
  71404. }
  71405. public static function mb_decode_mimeheader($s)
  71406. {
  71407. return \iconv_mime_decode($s, 2, self::$internalEncoding);
  71408. }
  71409. public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null)
  71410. {
  71411. trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', \E_USER_WARNING);
  71412. }
  71413. public static function mb_decode_numericentity($s, $convmap, $encoding = null)
  71414. {
  71415. if (null !== $s && !is_scalar($s) && !(\is_object($s) && method_exists($s, '__toString'))) {
  71416. trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', \E_USER_WARNING);
  71417. return null;
  71418. }
  71419. if (!\is_array($convmap) || (80000 > \PHP_VERSION_ID && !$convmap)) {
  71420. return false;
  71421. }
  71422. if (null !== $encoding && !is_scalar($encoding)) {
  71423. trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', \E_USER_WARNING);
  71424. return '';
  71425. }
  71426. $s = (string) $s;
  71427. if ('' === $s) {
  71428. return '';
  71429. }
  71430. $encoding = self::getEncoding($encoding);
  71431. if ('UTF-8' === $encoding) {
  71432. $encoding = null;
  71433. if (!preg_match('//u', $s)) {
  71434. $s = @\iconv('UTF-8', 'UTF-8//IGNORE', $s);
  71435. }
  71436. } else {
  71437. $s = \iconv($encoding, 'UTF-8//IGNORE', $s);
  71438. }
  71439. $cnt = floor(\count($convmap) / 4) * 4;
  71440. for ($i = 0; $i < $cnt; $i += 4) {
  71441. $convmap[$i] += $convmap[$i + 2];
  71442. $convmap[$i + 1] += $convmap[$i + 2];
  71443. }
  71444. $s = preg_replace_callback('/&#(?:0*([0-9]+)|x0*([0-9a-fA-F]+))(?!&);?/', function (array $m) use ($cnt, $convmap) {
  71445. $c = isset($m[2]) ? (int) hexdec($m[2]) : $m[1];
  71446. for ($i = 0; $i < $cnt; $i += 4) {
  71447. if ($c >= $convmap[$i] && $c <= $convmap[$i + 1]) {
  71448. return self::mb_chr($c - $convmap[$i + 2]);
  71449. }
  71450. }
  71451. return $m[0];
  71452. }, $s);
  71453. if (null === $encoding) {
  71454. return $s;
  71455. }
  71456. return \iconv('UTF-8', $encoding.'//IGNORE', $s);
  71457. }
  71458. public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false)
  71459. {
  71460. if (null !== $s && !is_scalar($s) && !(\is_object($s) && method_exists($s, '__toString'))) {
  71461. trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', \E_USER_WARNING);
  71462. return null;
  71463. }
  71464. if (!\is_array($convmap) || (80000 > \PHP_VERSION_ID && !$convmap)) {
  71465. return false;
  71466. }
  71467. if (null !== $encoding && !is_scalar($encoding)) {
  71468. trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', \E_USER_WARNING);
  71469. return null;
  71470. }
  71471. if (null !== $is_hex && !is_scalar($is_hex)) {
  71472. trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.\gettype($s).' given', \E_USER_WARNING);
  71473. return null;
  71474. }
  71475. $s = (string) $s;
  71476. if ('' === $s) {
  71477. return '';
  71478. }
  71479. $encoding = self::getEncoding($encoding);
  71480. if ('UTF-8' === $encoding) {
  71481. $encoding = null;
  71482. if (!preg_match('//u', $s)) {
  71483. $s = @\iconv('UTF-8', 'UTF-8//IGNORE', $s);
  71484. }
  71485. } else {
  71486. $s = \iconv($encoding, 'UTF-8//IGNORE', $s);
  71487. }
  71488. static $ulenMask = ["\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4];
  71489. $cnt = floor(\count($convmap) / 4) * 4;
  71490. $i = 0;
  71491. $len = \strlen($s);
  71492. $result = '';
  71493. while ($i < $len) {
  71494. $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
  71495. $uchr = substr($s, $i, $ulen);
  71496. $i += $ulen;
  71497. $c = self::mb_ord($uchr);
  71498. for ($j = 0; $j < $cnt; $j += 4) {
  71499. if ($c >= $convmap[$j] && $c <= $convmap[$j + 1]) {
  71500. $cOffset = ($c + $convmap[$j + 2]) & $convmap[$j + 3];
  71501. $result .= $is_hex ? sprintf('&#x%X;', $cOffset) : '&#'.$cOffset.';';
  71502. continue 2;
  71503. }
  71504. }
  71505. $result .= $uchr;
  71506. }
  71507. if (null === $encoding) {
  71508. return $result;
  71509. }
  71510. return \iconv('UTF-8', $encoding.'//IGNORE', $result);
  71511. }
  71512. public static function mb_convert_case($s, $mode, $encoding = null)
  71513. {
  71514. $s = (string) $s;
  71515. if ('' === $s) {
  71516. return '';
  71517. }
  71518. $encoding = self::getEncoding($encoding);
  71519. if ('UTF-8' === $encoding) {
  71520. $encoding = null;
  71521. if (!preg_match('//u', $s)) {
  71522. $s = @\iconv('UTF-8', 'UTF-8//IGNORE', $s);
  71523. }
  71524. } else {
  71525. $s = \iconv($encoding, 'UTF-8//IGNORE', $s);
  71526. }
  71527. if (\MB_CASE_TITLE == $mode) {
  71528. static $titleRegexp = null;
  71529. if (null === $titleRegexp) {
  71530. $titleRegexp = self::getData('titleCaseRegexp');
  71531. }
  71532. $s = preg_replace_callback($titleRegexp, [__CLASS__, 'title_case'], $s);
  71533. } else {
  71534. if (\MB_CASE_UPPER == $mode) {
  71535. static $upper = null;
  71536. if (null === $upper) {
  71537. $upper = self::getData('upperCase');
  71538. }
  71539. $map = $upper;
  71540. } else {
  71541. if (self::MB_CASE_FOLD === $mode) {
  71542. $s = str_replace(self::CASE_FOLD[0], self::CASE_FOLD[1], $s);
  71543. }
  71544. static $lower = null;
  71545. if (null === $lower) {
  71546. $lower = self::getData('lowerCase');
  71547. }
  71548. $map = $lower;
  71549. }
  71550. static $ulenMask = ["\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4];
  71551. $i = 0;
  71552. $len = \strlen($s);
  71553. while ($i < $len) {
  71554. $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
  71555. $uchr = substr($s, $i, $ulen);
  71556. $i += $ulen;
  71557. if (isset($map[$uchr])) {
  71558. $uchr = $map[$uchr];
  71559. $nlen = \strlen($uchr);
  71560. if ($nlen == $ulen) {
  71561. $nlen = $i;
  71562. do {
  71563. $s[--$nlen] = $uchr[--$ulen];
  71564. } while ($ulen);
  71565. } else {
  71566. $s = substr_replace($s, $uchr, $i - $ulen, $ulen);
  71567. $len += $nlen - $ulen;
  71568. $i += $nlen - $ulen;
  71569. }
  71570. }
  71571. }
  71572. }
  71573. if (null === $encoding) {
  71574. return $s;
  71575. }
  71576. return \iconv('UTF-8', $encoding.'//IGNORE', $s);
  71577. }
  71578. public static function mb_internal_encoding($encoding = null)
  71579. {
  71580. if (null === $encoding) {
  71581. return self::$internalEncoding;
  71582. }
  71583. $normalizedEncoding = self::getEncoding($encoding);
  71584. if ('UTF-8' === $normalizedEncoding || false !== @\iconv($normalizedEncoding, $normalizedEncoding, ' ')) {
  71585. self::$internalEncoding = $normalizedEncoding;
  71586. return true;
  71587. }
  71588. if (80000 > \PHP_VERSION_ID) {
  71589. return false;
  71590. }
  71591. throw new \ValueError(sprintf('Argument #1 ($encoding) must be a valid encoding, "%s" given', $encoding));
  71592. }
  71593. public static function mb_language($lang = null)
  71594. {
  71595. if (null === $lang) {
  71596. return self::$language;
  71597. }
  71598. switch ($normalizedLang = strtolower($lang)) {
  71599. case 'uni':
  71600. case 'neutral':
  71601. self::$language = $normalizedLang;
  71602. return true;
  71603. }
  71604. if (80000 > \PHP_VERSION_ID) {
  71605. return false;
  71606. }
  71607. throw new \ValueError(sprintf('Argument #1 ($language) must be a valid language, "%s" given', $lang));
  71608. }
  71609. public static function mb_list_encodings()
  71610. {
  71611. return ['UTF-8'];
  71612. }
  71613. public static function mb_encoding_aliases($encoding)
  71614. {
  71615. switch (strtoupper($encoding)) {
  71616. case 'UTF8':
  71617. case 'UTF-8':
  71618. return ['utf8'];
  71619. }
  71620. return false;
  71621. }
  71622. public static function mb_check_encoding($var = null, $encoding = null)
  71623. {
  71624. if (null === $encoding) {
  71625. if (null === $var) {
  71626. return false;
  71627. }
  71628. $encoding = self::$internalEncoding;
  71629. }
  71630. return self::mb_detect_encoding($var, [$encoding]) || false !== @\iconv($encoding, $encoding, $var);
  71631. }
  71632. public static function mb_detect_encoding($str, $encodingList = null, $strict = false)
  71633. {
  71634. if (null === $encodingList) {
  71635. $encodingList = self::$encodingList;
  71636. } else {
  71637. if (!\is_array($encodingList)) {
  71638. $encodingList = array_map('trim', explode(',', $encodingList));
  71639. }
  71640. $encodingList = array_map('strtoupper', $encodingList);
  71641. }
  71642. foreach ($encodingList as $enc) {
  71643. switch ($enc) {
  71644. case 'ASCII':
  71645. if (!preg_match('/[\x80-\xFF]/', $str)) {
  71646. return $enc;
  71647. }
  71648. break;
  71649. case 'UTF8':
  71650. case 'UTF-8':
  71651. if (preg_match('//u', $str)) {
  71652. return 'UTF-8';
  71653. }
  71654. break;
  71655. default:
  71656. if (0 === strncmp($enc, 'ISO-8859-', 9)) {
  71657. return $enc;
  71658. }
  71659. }
  71660. }
  71661. return false;
  71662. }
  71663. public static function mb_detect_order($encodingList = null)
  71664. {
  71665. if (null === $encodingList) {
  71666. return self::$encodingList;
  71667. }
  71668. if (!\is_array($encodingList)) {
  71669. $encodingList = array_map('trim', explode(',', $encodingList));
  71670. }
  71671. $encodingList = array_map('strtoupper', $encodingList);
  71672. foreach ($encodingList as $enc) {
  71673. switch ($enc) {
  71674. default:
  71675. if (strncmp($enc, 'ISO-8859-', 9)) {
  71676. return false;
  71677. }
  71678. case 'ASCII':
  71679. case 'UTF8':
  71680. case 'UTF-8':
  71681. }
  71682. }
  71683. self::$encodingList = $encodingList;
  71684. return true;
  71685. }
  71686. public static function mb_strlen($s, $encoding = null)
  71687. {
  71688. $encoding = self::getEncoding($encoding);
  71689. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  71690. return \strlen($s);
  71691. }
  71692. return @\iconv_strlen($s, $encoding);
  71693. }
  71694. public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null)
  71695. {
  71696. $encoding = self::getEncoding($encoding);
  71697. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  71698. return strpos($haystack, $needle, $offset);
  71699. }
  71700. $needle = (string) $needle;
  71701. if ('' === $needle) {
  71702. if (80000 > \PHP_VERSION_ID) {
  71703. trigger_error(__METHOD__.': Empty delimiter', \E_USER_WARNING);
  71704. return false;
  71705. }
  71706. return 0;
  71707. }
  71708. return \iconv_strpos($haystack, $needle, $offset, $encoding);
  71709. }
  71710. public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null)
  71711. {
  71712. $encoding = self::getEncoding($encoding);
  71713. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  71714. return strrpos($haystack, $needle, $offset);
  71715. }
  71716. if ($offset != (int) $offset) {
  71717. $offset = 0;
  71718. } elseif ($offset = (int) $offset) {
  71719. if ($offset < 0) {
  71720. if (0 > $offset += self::mb_strlen($needle)) {
  71721. $haystack = self::mb_substr($haystack, 0, $offset, $encoding);
  71722. }
  71723. $offset = 0;
  71724. } else {
  71725. $haystack = self::mb_substr($haystack, $offset, 2147483647, $encoding);
  71726. }
  71727. }
  71728. $pos = '' !== $needle || 80000 > \PHP_VERSION_ID
  71729. ? \iconv_strrpos($haystack, $needle, $encoding)
  71730. : self::mb_strlen($haystack, $encoding);
  71731. return false !== $pos ? $offset + $pos : false;
  71732. }
  71733. public static function mb_str_split($string, $split_length = 1, $encoding = null)
  71734. {
  71735. if (null !== $string && !is_scalar($string) && !(\is_object($string) && method_exists($string, '__toString'))) {
  71736. trigger_error('mb_str_split() expects parameter 1 to be string, '.\gettype($string).' given', \E_USER_WARNING);
  71737. return null;
  71738. }
  71739. if (1 > $split_length = (int) $split_length) {
  71740. if (80000 > \PHP_VERSION_ID) {
  71741. trigger_error('The length of each segment must be greater than zero', \E_USER_WARNING);
  71742. return false;
  71743. }
  71744. throw new \ValueError('Argument #2 ($length) must be greater than 0');
  71745. }
  71746. if (null === $encoding) {
  71747. $encoding = mb_internal_encoding();
  71748. }
  71749. if ('UTF-8' === $encoding = self::getEncoding($encoding)) {
  71750. $rx = '/(';
  71751. while (65535 < $split_length) {
  71752. $rx .= '.{65535}';
  71753. $split_length -= 65535;
  71754. }
  71755. $rx .= '.{'.$split_length.'})/us';
  71756. return preg_split($rx, $string, null, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY);
  71757. }
  71758. $result = [];
  71759. $length = mb_strlen($string, $encoding);
  71760. for ($i = 0; $i < $length; $i += $split_length) {
  71761. $result[] = mb_substr($string, $i, $split_length, $encoding);
  71762. }
  71763. return $result;
  71764. }
  71765. public static function mb_strtolower($s, $encoding = null)
  71766. {
  71767. return self::mb_convert_case($s, \MB_CASE_LOWER, $encoding);
  71768. }
  71769. public static function mb_strtoupper($s, $encoding = null)
  71770. {
  71771. return self::mb_convert_case($s, \MB_CASE_UPPER, $encoding);
  71772. }
  71773. public static function mb_substitute_character($c = null)
  71774. {
  71775. if (null === $c) {
  71776. return 'none';
  71777. }
  71778. if (0 === strcasecmp($c, 'none')) {
  71779. return true;
  71780. }
  71781. if (80000 > \PHP_VERSION_ID) {
  71782. return false;
  71783. }
  71784. if (\is_int($c) || 'long' === $c || 'entity' === $c) {
  71785. return false;
  71786. }
  71787. throw new \ValueError('Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint');
  71788. }
  71789. public static function mb_substr($s, $start, $length = null, $encoding = null)
  71790. {
  71791. $encoding = self::getEncoding($encoding);
  71792. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  71793. return (string) substr($s, $start, null === $length ? 2147483647 : $length);
  71794. }
  71795. if ($start < 0) {
  71796. $start = \iconv_strlen($s, $encoding) + $start;
  71797. if ($start < 0) {
  71798. $start = 0;
  71799. }
  71800. }
  71801. if (null === $length) {
  71802. $length = 2147483647;
  71803. } elseif ($length < 0) {
  71804. $length = \iconv_strlen($s, $encoding) + $length - $start;
  71805. if ($length < 0) {
  71806. return '';
  71807. }
  71808. }
  71809. return (string) \iconv_substr($s, $start, $length, $encoding);
  71810. }
  71811. public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null)
  71812. {
  71813. $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
  71814. $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
  71815. return self::mb_strpos($haystack, $needle, $offset, $encoding);
  71816. }
  71817. public static function mb_stristr($haystack, $needle, $part = false, $encoding = null)
  71818. {
  71819. $pos = self::mb_stripos($haystack, $needle, 0, $encoding);
  71820. return self::getSubpart($pos, $part, $haystack, $encoding);
  71821. }
  71822. public static function mb_strrchr($haystack, $needle, $part = false, $encoding = null)
  71823. {
  71824. $encoding = self::getEncoding($encoding);
  71825. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  71826. $pos = strrpos($haystack, $needle);
  71827. } else {
  71828. $needle = self::mb_substr($needle, 0, 1, $encoding);
  71829. $pos = \iconv_strrpos($haystack, $needle, $encoding);
  71830. }
  71831. return self::getSubpart($pos, $part, $haystack, $encoding);
  71832. }
  71833. public static function mb_strrichr($haystack, $needle, $part = false, $encoding = null)
  71834. {
  71835. $needle = self::mb_substr($needle, 0, 1, $encoding);
  71836. $pos = self::mb_strripos($haystack, $needle, $encoding);
  71837. return self::getSubpart($pos, $part, $haystack, $encoding);
  71838. }
  71839. public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null)
  71840. {
  71841. $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
  71842. $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
  71843. return self::mb_strrpos($haystack, $needle, $offset, $encoding);
  71844. }
  71845. public static function mb_strstr($haystack, $needle, $part = false, $encoding = null)
  71846. {
  71847. $pos = strpos($haystack, $needle);
  71848. if (false === $pos) {
  71849. return false;
  71850. }
  71851. if ($part) {
  71852. return substr($haystack, 0, $pos);
  71853. }
  71854. return substr($haystack, $pos);
  71855. }
  71856. public static function mb_get_info($type = 'all')
  71857. {
  71858. $info = [
  71859. 'internal_encoding' => self::$internalEncoding,
  71860. 'http_output' => 'pass',
  71861. 'http_output_conv_mimetypes' => '^(text/|application/xhtml\+xml)',
  71862. 'func_overload' => 0,
  71863. 'func_overload_list' => 'no overload',
  71864. 'mail_charset' => 'UTF-8',
  71865. 'mail_header_encoding' => 'BASE64',
  71866. 'mail_body_encoding' => 'BASE64',
  71867. 'illegal_chars' => 0,
  71868. 'encoding_translation' => 'Off',
  71869. 'language' => self::$language,
  71870. 'detect_order' => self::$encodingList,
  71871. 'substitute_character' => 'none',
  71872. 'strict_detection' => 'Off',
  71873. ];
  71874. if ('all' === $type) {
  71875. return $info;
  71876. }
  71877. if (isset($info[$type])) {
  71878. return $info[$type];
  71879. }
  71880. return false;
  71881. }
  71882. public static function mb_http_input($type = '')
  71883. {
  71884. return false;
  71885. }
  71886. public static function mb_http_output($encoding = null)
  71887. {
  71888. return null !== $encoding ? 'pass' === $encoding : 'pass';
  71889. }
  71890. public static function mb_strwidth($s, $encoding = null)
  71891. {
  71892. $encoding = self::getEncoding($encoding);
  71893. if ('UTF-8' !== $encoding) {
  71894. $s = \iconv($encoding, 'UTF-8//IGNORE', $s);
  71895. }
  71896. $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);
  71897. return ($wide << 1) + \iconv_strlen($s, 'UTF-8');
  71898. }
  71899. public static function mb_substr_count($haystack, $needle, $encoding = null)
  71900. {
  71901. return substr_count($haystack, $needle);
  71902. }
  71903. public static function mb_output_handler($contents, $status)
  71904. {
  71905. return $contents;
  71906. }
  71907. public static function mb_chr($code, $encoding = null)
  71908. {
  71909. if (0x80 > $code %= 0x200000) {
  71910. $s = \chr($code);
  71911. } elseif (0x800 > $code) {
  71912. $s = \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
  71913. } elseif (0x10000 > $code) {
  71914. $s = \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  71915. } else {
  71916. $s = \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  71917. }
  71918. if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
  71919. $s = mb_convert_encoding($s, $encoding, 'UTF-8');
  71920. }
  71921. return $s;
  71922. }
  71923. public static function mb_ord($s, $encoding = null)
  71924. {
  71925. if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
  71926. $s = mb_convert_encoding($s, 'UTF-8', $encoding);
  71927. }
  71928. if (1 === \strlen($s)) {
  71929. return \ord($s);
  71930. }
  71931. $code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0;
  71932. if (0xF0 <= $code) {
  71933. return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80;
  71934. }
  71935. if (0xE0 <= $code) {
  71936. return (($code - 0xE0) << 12) + (($s[2] - 0x80) << 6) + $s[3] - 0x80;
  71937. }
  71938. if (0xC0 <= $code) {
  71939. return (($code - 0xC0) << 6) + $s[2] - 0x80;
  71940. }
  71941. return $code;
  71942. }
  71943. private static function getSubpart($pos, $part, $haystack, $encoding)
  71944. {
  71945. if (false === $pos) {
  71946. return false;
  71947. }
  71948. if ($part) {
  71949. return self::mb_substr($haystack, 0, $pos, $encoding);
  71950. }
  71951. return self::mb_substr($haystack, $pos, null, $encoding);
  71952. }
  71953. private static function html_encoding_callback(array $m)
  71954. {
  71955. $i = 1;
  71956. $entities = '';
  71957. $m = unpack('C*', htmlentities($m[0], \ENT_COMPAT, 'UTF-8'));
  71958. while (isset($m[$i])) {
  71959. if (0x80 > $m[$i]) {
  71960. $entities .= \chr($m[$i++]);
  71961. continue;
  71962. }
  71963. if (0xF0 <= $m[$i]) {
  71964. $c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
  71965. } elseif (0xE0 <= $m[$i]) {
  71966. $c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
  71967. } else {
  71968. $c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80;
  71969. }
  71970. $entities .= '&#'.$c.';';
  71971. }
  71972. return $entities;
  71973. }
  71974. private static function title_case(array $s)
  71975. {
  71976. return self::mb_convert_case($s[1], \MB_CASE_UPPER, 'UTF-8').self::mb_convert_case($s[2], \MB_CASE_LOWER, 'UTF-8');
  71977. }
  71978. private static function getData($file)
  71979. {
  71980. if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) {
  71981. return require $file;
  71982. }
  71983. return false;
  71984. }
  71985. private static function getEncoding($encoding)
  71986. {
  71987. if (null === $encoding) {
  71988. return self::$internalEncoding;
  71989. }
  71990. if ('UTF-8' === $encoding) {
  71991. return 'UTF-8';
  71992. }
  71993. $encoding = strtoupper($encoding);
  71994. if ('8BIT' === $encoding || 'BINARY' === $encoding) {
  71995. return 'CP850';
  71996. }
  71997. if ('UTF8' === $encoding) {
  71998. return 'UTF-8';
  71999. }
  72000. return $encoding;
  72001. }
  72002. }
  72003. <?php
  72004. return array (
  72005. 'A' => 'a',
  72006. 'B' => 'b',
  72007. 'C' => 'c',
  72008. 'D' => 'd',
  72009. 'E' => 'e',
  72010. 'F' => 'f',
  72011. 'G' => 'g',
  72012. 'H' => 'h',
  72013. 'I' => 'i',
  72014. 'J' => 'j',
  72015. 'K' => 'k',
  72016. 'L' => 'l',
  72017. 'M' => 'm',
  72018. 'N' => 'n',
  72019. 'O' => 'o',
  72020. 'P' => 'p',
  72021. 'Q' => 'q',
  72022. 'R' => 'r',
  72023. 'S' => 's',
  72024. 'T' => 't',
  72025. 'U' => 'u',
  72026. 'V' => 'v',
  72027. 'W' => 'w',
  72028. 'X' => 'x',
  72029. 'Y' => 'y',
  72030. 'Z' => 'z',
  72031. 'À' => 'à',
  72032. '�' => 'á',
  72033. 'Â' => 'â',
  72034. 'Ã' => 'ã',
  72035. 'Ä' => 'ä',
  72036. 'Ã…' => 'Ã¥',
  72037. 'Æ' => 'æ',
  72038. 'Ç' => 'ç',
  72039. 'È' => 'è',
  72040. 'É' => 'é',
  72041. 'Ê' => 'ê',
  72042. 'Ë' => 'ë',
  72043. 'Ì' => 'ì',
  72044. '�' => 'í',
  72045. 'Î' => 'î',
  72046. '�' => 'ï',
  72047. '�' => 'ð',
  72048. 'Ñ' => 'ñ',
  72049. 'Ò' => 'ò',
  72050. 'Ó' => 'ó',
  72051. 'Ô' => 'ô',
  72052. 'Õ' => 'õ',
  72053. 'Ö' => 'ö',
  72054. 'Ø' => 'ø',
  72055. 'Ù' => 'ù',
  72056. 'Ú' => 'ú',
  72057. 'Û' => 'û',
  72058. 'Ü' => 'ü',
  72059. '�' => 'ý',
  72060. 'Þ' => 'þ',
  72061. 'Ā' => '�',
  72062. 'Ă' => 'ă',
  72063. 'Ä„' => 'Ä…',
  72064. 'Ć' => 'ć',
  72065. 'Ĉ' => 'ĉ',
  72066. 'ÄŠ' => 'Ä‹',
  72067. 'Č' => '�',
  72068. 'Ď' => '�',
  72069. '�' => 'đ',
  72070. 'Ä’' => 'Ä“',
  72071. 'Ä”' => 'Ä•',
  72072. 'Ä–' => 'Ä—',
  72073. 'Ę' => 'ę',
  72074. 'Äš' => 'Ä›',
  72075. 'Ĝ' => '�',
  72076. 'Äž' => 'ÄŸ',
  72077. 'Ä ' => 'Ä¡',
  72078. 'Ä¢' => 'Ä£',
  72079. 'Ĥ' => 'ĥ',
  72080. 'Ħ' => 'ħ',
  72081. 'Ĩ' => 'ĩ',
  72082. 'Ī' => 'ī',
  72083. 'Ĭ' => 'ĭ',
  72084. 'Į' => 'į',
  72085. 'İ' => 'i̇',
  72086. 'IJ' => 'ij',
  72087. 'Ĵ' => 'ĵ',
  72088. 'Ķ' => 'ķ',
  72089. 'Ĺ' => 'ĺ',
  72090. 'Ļ' => 'ļ',
  72091. 'Ľ' => 'ľ',
  72092. 'Ä¿' => 'Å€',
  72093. '�' => 'ł',
  72094. 'Ń' => 'ń',
  72095. 'Ņ' => 'ņ',
  72096. 'Ň' => 'ň',
  72097. 'ÅŠ' => 'Å‹',
  72098. 'Ō' => '�',
  72099. 'Ŏ' => '�',
  72100. '�' => 'ő',
  72101. 'Å’' => 'Å“',
  72102. 'Å”' => 'Å•',
  72103. 'Å–' => 'Å—',
  72104. 'Ř' => 'ř',
  72105. 'Åš' => 'Å›',
  72106. 'Ŝ' => '�',
  72107. 'Åž' => 'ÅŸ',
  72108. 'Å ' => 'Å¡',
  72109. 'Å¢' => 'Å£',
  72110. 'Ť' => 'ť',
  72111. 'Ŧ' => 'ŧ',
  72112. 'Ũ' => 'ũ',
  72113. 'Ū' => 'ū',
  72114. 'Ŭ' => 'ŭ',
  72115. 'Ů' => 'ů',
  72116. 'Ű' => 'ű',
  72117. 'Ų' => 'ų',
  72118. 'Ŵ' => 'ŵ',
  72119. 'Ŷ' => 'ŷ',
  72120. 'Ÿ' => 'ÿ',
  72121. 'Ź' => 'ź',
  72122. 'Ż' => 'ż',
  72123. 'Ž' => 'ž',
  72124. '�' => 'ɓ',
  72125. 'Ƃ' => 'ƃ',
  72126. 'Æ„' => 'Æ…',
  72127. 'Ɔ' => 'ɔ',
  72128. 'Ƈ' => 'ƈ',
  72129. 'Ɖ' => 'ɖ',
  72130. 'ÆŠ' => 'É—',
  72131. 'Ƌ' => 'ƌ',
  72132. 'Ǝ' => '�',
  72133. '�' => 'ə',
  72134. '�' => 'ɛ',
  72135. 'Æ‘' => 'Æ’',
  72136. 'Æ“' => 'É ',
  72137. 'Æ”' => 'É£',
  72138. 'Æ–' => 'É©',
  72139. 'Ɨ' => 'ɨ',
  72140. 'Ƙ' => 'ƙ',
  72141. 'Ɯ' => 'ɯ',
  72142. '�' => 'ɲ',
  72143. 'Ɵ' => 'ɵ',
  72144. 'Æ ' => 'Æ¡',
  72145. 'Æ¢' => 'Æ£',
  72146. 'Ƥ' => 'ƥ',
  72147. 'Ʀ' => 'ʀ',
  72148. 'Ƨ' => 'ƨ',
  72149. 'Ʃ' => 'ʃ',
  72150. 'Ƭ' => 'ƭ',
  72151. 'Ʈ' => 'ʈ',
  72152. 'Ư' => 'ư',
  72153. 'Ʊ' => 'ʊ',
  72154. 'Ʋ' => 'ʋ',
  72155. 'Ƴ' => 'ƴ',
  72156. 'Ƶ' => 'ƶ',
  72157. 'Æ·' => 'Ê’',
  72158. 'Ƹ' => 'ƹ',
  72159. 'Ƽ' => 'ƽ',
  72160. 'DŽ' => 'dž',
  72161. 'Dž' => 'dž',
  72162. 'LJ' => 'lj',
  72163. 'Lj' => 'lj',
  72164. 'NJ' => 'nj',
  72165. 'Nj' => 'nj',
  72166. '�' => 'ǎ',
  72167. '�' => '�',
  72168. 'Ç‘' => 'Ç’',
  72169. 'Ç“' => 'Ç”',
  72170. 'Ç•' => 'Ç–',
  72171. 'Ǘ' => 'ǘ',
  72172. 'Ç™' => 'Çš',
  72173. 'Ǜ' => 'ǜ',
  72174. 'Çž' => 'ÇŸ',
  72175. 'Ç ' => 'Ç¡',
  72176. 'Ç¢' => 'Ç£',
  72177. 'Ǥ' => 'ǥ',
  72178. 'Ǧ' => 'ǧ',
  72179. 'Ǩ' => 'ǩ',
  72180. 'Ǫ' => 'ǫ',
  72181. 'Ǭ' => 'ǭ',
  72182. 'Ǯ' => 'ǯ',
  72183. 'DZ' => 'dz',
  72184. 'Dz' => 'dz',
  72185. 'Ǵ' => 'ǵ',
  72186. 'Ƕ' => 'ƕ',
  72187. 'Ç·' => 'Æ¿',
  72188. 'Ǹ' => 'ǹ',
  72189. 'Ǻ' => 'ǻ',
  72190. 'Ǽ' => 'ǽ',
  72191. 'Ǿ' => 'ǿ',
  72192. 'Ȁ' => '�',
  72193. 'Ȃ' => 'ȃ',
  72194. 'È„' => 'È…',
  72195. 'Ȇ' => 'ȇ',
  72196. 'Ȉ' => 'ȉ',
  72197. 'ÈŠ' => 'È‹',
  72198. 'Ȍ' => '�',
  72199. 'Ȏ' => '�',
  72200. '�' => 'ȑ',
  72201. 'È’' => 'È“',
  72202. 'È”' => 'È•',
  72203. 'È–' => 'È—',
  72204. 'Ș' => 'ș',
  72205. 'Èš' => 'È›',
  72206. 'Ȝ' => '�',
  72207. 'Èž' => 'ÈŸ',
  72208. 'È ' => 'Æž',
  72209. 'È¢' => 'È£',
  72210. 'Ȥ' => 'ȥ',
  72211. 'Ȧ' => 'ȧ',
  72212. 'Ȩ' => 'ȩ',
  72213. 'Ȫ' => 'ȫ',
  72214. 'Ȭ' => 'ȭ',
  72215. 'Ȯ' => 'ȯ',
  72216. 'Ȱ' => 'ȱ',
  72217. 'Ȳ' => 'ȳ',
  72218. 'Ⱥ' => 'ⱥ',
  72219. 'Ȼ' => 'ȼ',
  72220. 'Ƚ' => 'ƚ',
  72221. 'Ⱦ' => 'ⱦ',
  72222. '�' => 'ɂ',
  72223. 'Ƀ' => 'ƀ',
  72224. 'Ʉ' => 'ʉ',
  72225. 'Ʌ' => 'ʌ',
  72226. 'Ɇ' => 'ɇ',
  72227. 'Ɉ' => 'ɉ',
  72228. 'ÉŠ' => 'É‹',
  72229. 'Ɍ' => '�',
  72230. 'Ɏ' => '�',
  72231. 'Ͱ' => 'ͱ',
  72232. 'Ͳ' => 'ͳ',
  72233. 'Ͷ' => 'ͷ',
  72234. 'Ϳ' => 'ϳ',
  72235. 'Ά' => 'ά',
  72236. 'Έ' => 'έ',
  72237. 'Ή' => 'ή',
  72238. 'Ί' => 'ί',
  72239. 'Ό' => 'ό',
  72240. 'Ύ' => '�',
  72241. '�' => 'ώ',
  72242. 'Α' => 'α',
  72243. 'Β' => 'β',
  72244. 'Γ' => 'γ',
  72245. 'Δ' => 'δ',
  72246. 'Ε' => 'ε',
  72247. 'Ζ' => 'ζ',
  72248. 'Η' => 'η',
  72249. 'Θ' => 'θ',
  72250. 'Ι' => 'ι',
  72251. 'Κ' => 'κ',
  72252. 'Λ' => 'λ',
  72253. 'Μ' => 'μ',
  72254. '�' => 'ν',
  72255. 'Ξ' => 'ξ',
  72256. 'Ο' => 'ο',
  72257. 'Π' => 'π',
  72258. 'Ρ' => '�',
  72259. 'Σ' => 'σ',
  72260. 'Τ' => 'τ',
  72261. 'Î¥' => 'Ï…',
  72262. 'Φ' => 'φ',
  72263. 'Χ' => 'χ',
  72264. 'Ψ' => 'ψ',
  72265. 'Ω' => 'ω',
  72266. 'Ϊ' => 'ϊ',
  72267. 'Ϋ' => 'ϋ',
  72268. '�' => 'ϗ',
  72269. 'Ϙ' => 'ϙ',
  72270. 'Ïš' => 'Ï›',
  72271. 'Ϝ' => '�',
  72272. 'Ïž' => 'ÏŸ',
  72273. 'Ï ' => 'Ï¡',
  72274. 'Ï¢' => 'Ï£',
  72275. 'Ϥ' => 'ϥ',
  72276. 'Ϧ' => 'ϧ',
  72277. 'Ϩ' => 'ϩ',
  72278. 'Ϫ' => 'ϫ',
  72279. 'Ϭ' => 'ϭ',
  72280. 'Ϯ' => 'ϯ',
  72281. 'ϴ' => 'θ',
  72282. 'Ϸ' => 'ϸ',
  72283. 'Ϲ' => 'ϲ',
  72284. 'Ϻ' => 'ϻ',
  72285. 'Ͻ' => 'ͻ',
  72286. 'Ͼ' => 'ͼ',
  72287. 'Ͽ' => 'ͽ',
  72288. 'Ѐ' => '�',
  72289. '�' => 'ё',
  72290. 'Ђ' => 'ђ',
  72291. 'Ѓ' => 'ѓ',
  72292. 'Є' => 'є',
  72293. 'Ð…' => 'Ñ•',
  72294. 'І' => 'і',
  72295. 'Ї' => 'ї',
  72296. 'Ј' => 'ј',
  72297. 'Љ' => 'љ',
  72298. 'Њ' => 'њ',
  72299. 'Ћ' => 'ћ',
  72300. 'Ќ' => 'ќ',
  72301. '�' => '�',
  72302. 'ÐŽ' => 'Ñž',
  72303. '�' => 'џ',
  72304. '�' => 'а',
  72305. 'Б' => 'б',
  72306. 'В' => 'в',
  72307. 'Г' => 'г',
  72308. 'Д' => 'д',
  72309. 'Е' => 'е',
  72310. 'Ж' => 'ж',
  72311. 'З' => 'з',
  72312. 'И' => 'и',
  72313. 'Й' => 'й',
  72314. 'К' => 'к',
  72315. 'Л' => 'л',
  72316. 'М' => 'м',
  72317. '�' => 'н',
  72318. 'О' => 'о',
  72319. 'П' => 'п',
  72320. 'Р' => 'р',
  72321. 'С' => '�',
  72322. 'Т' => 'т',
  72323. 'У' => 'у',
  72324. 'Ф' => 'ф',
  72325. 'Ð¥' => 'Ñ…',
  72326. 'Ц' => 'ц',
  72327. 'Ч' => 'ч',
  72328. 'Ш' => 'ш',
  72329. 'Щ' => 'щ',
  72330. 'Ъ' => 'ъ',
  72331. 'Ы' => 'ы',
  72332. 'Ь' => 'ь',
  72333. 'Э' => '�',
  72334. 'Ю' => 'ю',
  72335. 'Я' => '�',
  72336. 'Ñ ' => 'Ñ¡',
  72337. 'Ñ¢' => 'Ñ£',
  72338. 'Ѥ' => 'ѥ',
  72339. 'Ѧ' => 'ѧ',
  72340. 'Ѩ' => 'ѩ',
  72341. 'Ѫ' => 'ѫ',
  72342. 'Ѭ' => 'ѭ',
  72343. 'Ѯ' => 'ѯ',
  72344. 'Ѱ' => 'ѱ',
  72345. 'Ѳ' => 'ѳ',
  72346. 'Ѵ' => 'ѵ',
  72347. 'Ѷ' => 'ѷ',
  72348. 'Ѹ' => 'ѹ',
  72349. 'Ѻ' => 'ѻ',
  72350. 'Ѽ' => 'ѽ',
  72351. 'Ѿ' => 'ѿ',
  72352. 'Ò€' => 'Ò�',
  72353. 'ÒŠ' => 'Ò‹',
  72354. 'Ҍ' => '�',
  72355. 'ÒŽ' => 'Ò�',
  72356. 'Ò�' => 'Ò‘',
  72357. 'Ò’' => 'Ò“',
  72358. 'Ò”' => 'Ò•',
  72359. 'Ò–' => 'Ò—',
  72360. 'Ò˜' => 'Ò™',
  72361. 'Òš' => 'Ò›',
  72362. 'Ҝ' => '�',
  72363. 'Òž' => 'ÒŸ',
  72364. 'Ò ' => 'Ò¡',
  72365. 'Ò¢' => 'Ò£',
  72366. 'Ò¤' => 'Ò¥',
  72367. 'Ò¦' => 'Ò§',
  72368. 'Ò¨' => 'Ò©',
  72369. 'Òª' => 'Ò«',
  72370. 'Ò¬' => 'Ò­',
  72371. 'Ò®' => 'Ò¯',
  72372. 'Ò°' => 'Ò±',
  72373. 'Ò²' => 'Ò³',
  72374. 'Ò´' => 'Òµ',
  72375. 'Ò¶' => 'Ò·',
  72376. 'Ò¸' => 'Ò¹',
  72377. 'Òº' => 'Ò»',
  72378. 'Ò¼' => 'Ò½',
  72379. 'Ò¾' => 'Ò¿',
  72380. 'Ó€' => 'Ó�',
  72381. 'Ó�' => 'Ó‚',
  72382. 'Óƒ' => 'Ó„',
  72383. 'Ó…' => 'Ó†',
  72384. 'Ó‡' => 'Óˆ',
  72385. 'Ó‰' => 'ÓŠ',
  72386. 'Ӌ' => 'ӌ',
  72387. 'Ó�' => 'ÓŽ',
  72388. 'Ó�' => 'Ó‘',
  72389. 'Ó’' => 'Ó“',
  72390. 'Ó”' => 'Ó•',
  72391. 'Ó–' => 'Ó—',
  72392. 'Ó˜' => 'Ó™',
  72393. 'Óš' => 'Ó›',
  72394. 'Ӝ' => '�',
  72395. 'Óž' => 'ÓŸ',
  72396. 'Ó ' => 'Ó¡',
  72397. 'Ó¢' => 'Ó£',
  72398. 'Ó¤' => 'Ó¥',
  72399. 'Ó¦' => 'Ó§',
  72400. 'Ó¨' => 'Ó©',
  72401. 'Óª' => 'Ó«',
  72402. 'Ó¬' => 'Ó­',
  72403. 'Ó®' => 'Ó¯',
  72404. 'Ó°' => 'Ó±',
  72405. 'Ó²' => 'Ó³',
  72406. 'Ó´' => 'Óµ',
  72407. 'Ó¶' => 'Ó·',
  72408. 'Ó¸' => 'Ó¹',
  72409. 'Óº' => 'Ó»',
  72410. 'Ó¼' => 'Ó½',
  72411. 'Ó¾' => 'Ó¿',
  72412. 'Ô€' => 'Ô�',
  72413. 'Ô‚' => 'Ôƒ',
  72414. 'Ô„' => 'Ô…',
  72415. 'Ô†' => 'Ô‡',
  72416. 'Ôˆ' => 'Ô‰',
  72417. 'ÔŠ' => 'Ô‹',
  72418. 'Ԍ' => '�',
  72419. 'ÔŽ' => 'Ô�',
  72420. 'Ô�' => 'Ô‘',
  72421. 'Ô’' => 'Ô“',
  72422. 'Ô”' => 'Ô•',
  72423. 'Ô–' => 'Ô—',
  72424. 'Ô˜' => 'Ô™',
  72425. 'Ôš' => 'Ô›',
  72426. 'Ԝ' => '�',
  72427. 'Ôž' => 'ÔŸ',
  72428. 'Ô ' => 'Ô¡',
  72429. 'Ô¢' => 'Ô£',
  72430. 'Ô¤' => 'Ô¥',
  72431. 'Ô¦' => 'Ô§',
  72432. 'Ô¨' => 'Ô©',
  72433. 'Ôª' => 'Ô«',
  72434. 'Ô¬' => 'Ô­',
  72435. 'Ô®' => 'Ô¯',
  72436. 'Ô±' => 'Õ¡',
  72437. 'Ô²' => 'Õ¢',
  72438. 'Ô³' => 'Õ£',
  72439. 'Ô´' => 'Õ¤',
  72440. 'Ôµ' => 'Õ¥',
  72441. 'Ô¶' => 'Õ¦',
  72442. 'Ô·' => 'Õ§',
  72443. 'Ô¸' => 'Õ¨',
  72444. 'Ô¹' => 'Õ©',
  72445. 'Ôº' => 'Õª',
  72446. 'Ô»' => 'Õ«',
  72447. 'Ô¼' => 'Õ¬',
  72448. 'Ô½' => 'Õ­',
  72449. 'Ô¾' => 'Õ®',
  72450. 'Ô¿' => 'Õ¯',
  72451. 'Õ€' => 'Õ°',
  72452. 'Õ�' => 'Õ±',
  72453. 'Õ‚' => 'Õ²',
  72454. 'Õƒ' => 'Õ³',
  72455. 'Õ„' => 'Õ´',
  72456. 'Õ…' => 'Õµ',
  72457. 'Õ†' => 'Õ¶',
  72458. 'Õ‡' => 'Õ·',
  72459. 'Õˆ' => 'Õ¸',
  72460. 'Õ‰' => 'Õ¹',
  72461. 'ÕŠ' => 'Õº',
  72462. 'Õ‹' => 'Õ»',
  72463. 'Ռ' => 'ռ',
  72464. 'Õ�' => 'Õ½',
  72465. 'ÕŽ' => 'Õ¾',
  72466. 'Õ�' => 'Õ¿',
  72467. 'Õ�' => 'Ö€',
  72468. 'Õ‘' => 'Ö�',
  72469. 'Õ’' => 'Ö‚',
  72470. 'Õ“' => 'Öƒ',
  72471. 'Õ”' => 'Ö„',
  72472. 'Õ•' => 'Ö…',
  72473. 'Õ–' => 'Ö†',
  72474. 'á‚ ' => 'â´€',
  72475. 'á‚¡' => 'â´�',
  72476. 'á‚¢' => 'â´‚',
  72477. 'á‚£' => 'â´ƒ',
  72478. 'Ⴄ' => 'ⴄ',
  72479. 'á‚¥' => 'â´…',
  72480. 'Ⴆ' => 'ⴆ',
  72481. 'á‚§' => 'â´‡',
  72482. 'Ⴈ' => 'ⴈ',
  72483. 'á‚©' => 'â´‰',
  72484. 'Ⴊ' => 'ⴊ',
  72485. 'á‚«' => 'â´‹',
  72486. 'Ⴌ' => 'ⴌ',
  72487. 'á‚­' => 'â´�',
  72488. 'á‚®' => 'â´Ž',
  72489. 'Ⴏ' => '�',
  72490. 'á‚°' => 'â´�',
  72491. 'Ⴑ' => 'ⴑ',
  72492. 'Ⴒ' => 'ⴒ',
  72493. 'Ⴓ' => 'ⴓ',
  72494. 'á‚´' => 'â´”',
  72495. 'Ⴕ' => 'ⴕ',
  72496. 'á‚¶' => 'â´–',
  72497. 'á‚·' => 'â´—',
  72498. 'Ⴘ' => 'ⴘ',
  72499. 'Ⴙ' => 'ⴙ',
  72500. 'Ⴚ' => 'ⴚ',
  72501. 'á‚»' => 'â´›',
  72502. 'Ⴜ' => 'ⴜ',
  72503. 'Ⴝ' => '�',
  72504. 'Ⴞ' => 'ⴞ',
  72505. 'á‚¿' => 'â´Ÿ',
  72506. 'Ⴠ' => 'ⴠ',
  72507. '�' => 'ⴡ',
  72508. 'Ⴢ' => 'ⴢ',
  72509. 'Ⴣ' => 'ⴣ',
  72510. 'Ⴤ' => 'ⴤ',
  72511. 'Ⴥ' => 'ⴥ',
  72512. 'Ⴧ' => 'ⴧ',
  72513. '�' => 'ⴭ',
  72514. 'Ꭰ' => 'ꭰ',
  72515. 'Ꭱ' => 'ꭱ',
  72516. 'Ꭲ' => 'ꭲ',
  72517. 'Ꭳ' => 'ꭳ',
  72518. 'Ꭴ' => 'ꭴ',
  72519. 'Ꭵ' => 'ꭵ',
  72520. 'Ꭶ' => 'ꭶ',
  72521. 'Ꭷ' => 'ꭷ',
  72522. 'Ꭸ' => 'ꭸ',
  72523. 'Ꭹ' => 'ꭹ',
  72524. 'Ꭺ' => 'ꭺ',
  72525. 'Ꭻ' => 'ꭻ',
  72526. 'Ꭼ' => 'ꭼ',
  72527. 'Ꭽ' => 'ꭽ',
  72528. 'Ꭾ' => 'ꭾ',
  72529. 'Ꭿ' => 'ꭿ',
  72530. 'Ꮀ' => 'ꮀ',
  72531. 'Ꮁ' => '�',
  72532. 'Ꮂ' => 'ꮂ',
  72533. 'Ꮃ' => 'ꮃ',
  72534. 'Ꮄ' => 'ꮄ',
  72535. 'Ꮅ' => 'ꮅ',
  72536. 'Ꮆ' => 'ꮆ',
  72537. 'Ꮇ' => 'ꮇ',
  72538. 'Ꮈ' => 'ꮈ',
  72539. 'Ꮉ' => 'ꮉ',
  72540. 'Ꮊ' => 'ꮊ',
  72541. 'Ꮋ' => 'ꮋ',
  72542. 'Ꮌ' => 'ꮌ',
  72543. 'Ꮍ' => '�',
  72544. 'Ꮎ' => 'ꮎ',
  72545. 'Ꮏ' => '�',
  72546. '�' => '�',
  72547. '�' => 'ꮑ',
  72548. '�' => 'ꮒ',
  72549. '�' => 'ꮓ',
  72550. '�' => 'ꮔ',
  72551. '�' => 'ꮕ',
  72552. '�' => 'ꮖ',
  72553. '�' => 'ꮗ',
  72554. '�' => 'ꮘ',
  72555. '�' => 'ꮙ',
  72556. '�' => 'ꮚ',
  72557. '�' => 'ꮛ',
  72558. '�' => 'ꮜ',
  72559. '�' => '�',
  72560. '�' => 'ꮞ',
  72561. '�' => 'ꮟ',
  72562. '�' => 'ꮠ',
  72563. '�' => 'ꮡ',
  72564. '�' => 'ꮢ',
  72565. '�' => 'ꮣ',
  72566. '�' => 'ꮤ',
  72567. '�' => 'ꮥ',
  72568. '�' => 'ꮦ',
  72569. '�' => 'ꮧ',
  72570. '�' => 'ꮨ',
  72571. '�' => 'ꮩ',
  72572. '�' => 'ꮪ',
  72573. '�' => 'ꮫ',
  72574. '�' => 'ꮬ',
  72575. '�' => 'ꮭ',
  72576. '�' => 'ꮮ',
  72577. '�' => 'ꮯ',
  72578. '�' => 'ꮰ',
  72579. '�' => 'ꮱ',
  72580. '�' => 'ꮲ',
  72581. '�' => 'ꮳ',
  72582. '�' => 'ꮴ',
  72583. '�' => 'ꮵ',
  72584. '�' => 'ꮶ',
  72585. '�' => 'ꮷ',
  72586. '�' => 'ꮸ',
  72587. '�' => 'ꮹ',
  72588. '�' => 'ꮺ',
  72589. '�' => 'ꮻ',
  72590. '�' => 'ꮼ',
  72591. '�' => 'ꮽ',
  72592. '�' => 'ꮾ',
  72593. '�' => 'ꮿ',
  72594. '�' => '�',
  72595. '�' => '�',
  72596. '�' => '�',
  72597. '�' => '�',
  72598. '�' => '�',
  72599. '�' => '�',
  72600. '�' => '�',
  72601. 'Ბ' => 'ბ',
  72602. 'Გ' => 'გ',
  72603. 'Დ' => 'დ',
  72604. 'Ე' => 'ე',
  72605. 'Ვ' => 'ვ',
  72606. 'Ზ' => 'ზ',
  72607. 'Თ' => 'თ',
  72608. 'Ი' => 'ი',
  72609. 'Კ' => 'კ',
  72610. 'Ლ' => 'ლ',
  72611. 'Მ' => 'მ',
  72612. 'Ნ' => 'ნ',
  72613. '�' => '�',
  72614. 'Პ' => 'პ',
  72615. 'Ჟ' => 'ჟ',
  72616. 'Რ' => 'რ',
  72617. 'Ს' => 'ს',
  72618. 'Ტ' => 'ტ',
  72619. 'Უ' => 'უ',
  72620. 'Ფ' => 'ფ',
  72621. 'Ქ' => 'ქ',
  72622. 'Ღ' => 'ღ',
  72623. 'Ყ' => 'ყ',
  72624. 'Შ' => 'შ',
  72625. 'Ჩ' => 'ჩ',
  72626. 'Ც' => 'ც',
  72627. 'Ძ' => 'ძ',
  72628. 'Წ' => 'წ',
  72629. 'Ჭ' => 'ჭ',
  72630. 'Ხ' => 'ხ',
  72631. 'Ჯ' => 'ჯ',
  72632. 'Ჰ' => 'ჰ',
  72633. 'Ჱ' => 'ჱ',
  72634. 'Ჲ' => 'ჲ',
  72635. 'Ჳ' => 'ჳ',
  72636. 'Ჴ' => 'ჴ',
  72637. 'Ჵ' => 'ჵ',
  72638. 'Ჶ' => 'ჶ',
  72639. 'Ჷ' => 'ჷ',
  72640. 'Ჸ' => 'ჸ',
  72641. 'Ჹ' => 'ჹ',
  72642. 'Ჺ' => 'ჺ',
  72643. 'Ჽ' => 'ჽ',
  72644. 'Ჾ' => 'ჾ',
  72645. 'Ჿ' => 'ჿ',
  72646. 'Ḁ' => '�',
  72647. 'Ḃ' => 'ḃ',
  72648. 'Ḅ' => 'ḅ',
  72649. 'Ḇ' => 'ḇ',
  72650. 'Ḉ' => 'ḉ',
  72651. 'Ḋ' => 'ḋ',
  72652. 'Ḍ' => '�',
  72653. 'Ḏ' => '�',
  72654. '�' => 'ḑ',
  72655. 'Ḓ' => 'ḓ',
  72656. 'Ḕ' => 'ḕ',
  72657. 'Ḗ' => 'ḗ',
  72658. 'Ḙ' => 'ḙ',
  72659. 'Ḛ' => 'ḛ',
  72660. 'Ḝ' => '�',
  72661. 'Ḟ' => 'ḟ',
  72662. 'Ḡ' => 'ḡ',
  72663. 'Ḣ' => 'ḣ',
  72664. 'Ḥ' => 'ḥ',
  72665. 'Ḧ' => 'ḧ',
  72666. 'Ḩ' => 'ḩ',
  72667. 'Ḫ' => 'ḫ',
  72668. 'Ḭ' => 'ḭ',
  72669. 'Ḯ' => 'ḯ',
  72670. 'Ḱ' => 'ḱ',
  72671. 'Ḳ' => 'ḳ',
  72672. 'Ḵ' => 'ḵ',
  72673. 'Ḷ' => 'ḷ',
  72674. 'Ḹ' => 'ḹ',
  72675. 'Ḻ' => 'ḻ',
  72676. 'Ḽ' => 'ḽ',
  72677. 'Ḿ' => 'ḿ',
  72678. 'Ṁ' => '�',
  72679. 'Ṃ' => 'ṃ',
  72680. 'Ṅ' => 'ṅ',
  72681. 'Ṇ' => 'ṇ',
  72682. 'Ṉ' => 'ṉ',
  72683. 'Ṋ' => 'ṋ',
  72684. 'Ṍ' => '�',
  72685. 'Ṏ' => '�',
  72686. '�' => 'ṑ',
  72687. 'Ṓ' => 'ṓ',
  72688. 'Ṕ' => 'ṕ',
  72689. 'á¹–' => 'á¹—',
  72690. 'Ṙ' => 'ṙ',
  72691. 'Ṛ' => 'ṛ',
  72692. 'Ṝ' => '�',
  72693. 'Ṟ' => 'ṟ',
  72694. 'Ṡ' => 'ṡ',
  72695. 'á¹¢' => 'á¹£',
  72696. 'Ṥ' => 'ṥ',
  72697. 'Ṧ' => 'ṧ',
  72698. 'Ṩ' => 'ṩ',
  72699. 'Ṫ' => 'ṫ',
  72700. 'Ṭ' => 'ṭ',
  72701. 'Ṯ' => 'ṯ',
  72702. 'á¹°' => 'á¹±',
  72703. 'á¹²' => 'á¹³',
  72704. 'á¹´' => 'á¹µ',
  72705. 'á¹¶' => 'á¹·',
  72706. 'Ṹ' => 'ṹ',
  72707. 'Ṻ' => 'ṻ',
  72708. 'á¹¼' => 'á¹½',
  72709. 'Ṿ' => 'ṿ',
  72710. 'Ẁ' => '�',
  72711. 'Ẃ' => 'ẃ',
  72712. 'Ẅ' => 'ẅ',
  72713. 'Ẇ' => 'ẇ',
  72714. 'Ẉ' => 'ẉ',
  72715. 'Ẋ' => 'ẋ',
  72716. 'Ẍ' => '�',
  72717. 'Ẏ' => '�',
  72718. '�' => 'ẑ',
  72719. 'Ẓ' => 'ẓ',
  72720. 'Ẕ' => 'ẕ',
  72721. 'ẞ' => 'ß',
  72722. 'Ạ' => 'ạ',
  72723. 'Ả' => 'ả',
  72724. 'Ấ' => 'ấ',
  72725. 'Ầ' => 'ầ',
  72726. 'Ẩ' => 'ẩ',
  72727. 'Ẫ' => 'ẫ',
  72728. 'Ậ' => 'ậ',
  72729. 'Ắ' => 'ắ',
  72730. 'Ằ' => 'ằ',
  72731. 'Ẳ' => 'ẳ',
  72732. 'Ẵ' => 'ẵ',
  72733. 'Ặ' => 'ặ',
  72734. 'Ẹ' => 'ẹ',
  72735. 'Ẻ' => 'ẻ',
  72736. 'Ẽ' => 'ẽ',
  72737. 'Ế' => 'ế',
  72738. 'Ề' => '�',
  72739. 'Ể' => 'ể',
  72740. 'Ễ' => 'ễ',
  72741. 'Ệ' => 'ệ',
  72742. 'Ỉ' => 'ỉ',
  72743. 'Ị' => 'ị',
  72744. 'Ọ' => '�',
  72745. 'Ỏ' => '�',
  72746. '�' => 'ố',
  72747. 'Ồ' => 'ồ',
  72748. 'Ổ' => 'ổ',
  72749. 'á»–' => 'á»—',
  72750. 'Ộ' => 'ộ',
  72751. 'Ớ' => 'ớ',
  72752. 'Ờ' => '�',
  72753. 'Ở' => 'ở',
  72754. 'Ỡ' => 'ỡ',
  72755. 'Ợ' => 'ợ',
  72756. 'Ụ' => 'ụ',
  72757. 'Ủ' => 'ủ',
  72758. 'Ứ' => 'ứ',
  72759. 'Ừ' => 'ừ',
  72760. 'Ử' => 'ử',
  72761. 'Ữ' => 'ữ',
  72762. 'á»°' => 'á»±',
  72763. 'Ỳ' => 'ỳ',
  72764. 'Ỵ' => 'ỵ',
  72765. 'á»¶' => 'á»·',
  72766. 'Ỹ' => 'ỹ',
  72767. 'Ỻ' => 'ỻ',
  72768. 'Ỽ' => 'ỽ',
  72769. 'Ỿ' => 'ỿ',
  72770. 'Ἀ' => 'ἀ',
  72771. 'Ἁ' => '�',
  72772. 'Ἂ' => 'ἂ',
  72773. 'Ἃ' => 'ἃ',
  72774. 'Ἄ' => 'ἄ',
  72775. '�' => 'ἅ',
  72776. 'Ἆ' => 'ἆ',
  72777. '�' => 'ἇ',
  72778. 'Ἐ' => '�',
  72779. 'Ἑ' => 'ἑ',
  72780. 'Ἒ' => 'ἒ',
  72781. 'Ἓ' => 'ἓ',
  72782. 'Ἔ' => 'ἔ',
  72783. '�' => 'ἕ',
  72784. 'Ἠ' => 'ἠ',
  72785. 'Ἡ' => 'ἡ',
  72786. 'Ἢ' => 'ἢ',
  72787. 'Ἣ' => 'ἣ',
  72788. 'Ἤ' => 'ἤ',
  72789. 'á¼­' => 'á¼¥',
  72790. 'Ἦ' => 'ἦ',
  72791. 'Ἧ' => 'ἧ',
  72792. 'Ἰ' => 'ἰ',
  72793. 'á¼¹' => 'á¼±',
  72794. 'Ἲ' => 'ἲ',
  72795. 'á¼»' => 'á¼³',
  72796. 'á¼¼' => 'á¼´',
  72797. 'á¼½' => 'á¼µ',
  72798. 'á¼¾' => 'á¼¶',
  72799. 'Ἷ' => 'ἷ',
  72800. 'Ὀ' => 'ὀ',
  72801. 'Ὁ' => '�',
  72802. 'Ὂ' => 'ὂ',
  72803. 'Ὃ' => 'ὃ',
  72804. 'Ὄ' => 'ὄ',
  72805. '�' => 'ὅ',
  72806. 'Ὑ' => 'ὑ',
  72807. 'Ὓ' => 'ὓ',
  72808. '�' => 'ὕ',
  72809. 'Ὗ' => 'ὗ',
  72810. 'Ὠ' => 'ὠ',
  72811. 'Ὡ' => 'ὡ',
  72812. 'Ὢ' => 'ὢ',
  72813. 'Ὣ' => 'ὣ',
  72814. 'Ὤ' => 'ὤ',
  72815. 'á½­' => 'á½¥',
  72816. 'Ὦ' => 'ὦ',
  72817. 'Ὧ' => 'ὧ',
  72818. 'ᾈ' => 'ᾀ',
  72819. 'ᾉ' => '�',
  72820. 'ᾊ' => 'ᾂ',
  72821. 'ᾋ' => 'ᾃ',
  72822. 'ᾌ' => 'ᾄ',
  72823. '�' => 'ᾅ',
  72824. 'ᾎ' => 'ᾆ',
  72825. '�' => 'ᾇ',
  72826. 'ᾘ' => '�',
  72827. 'ᾙ' => 'ᾑ',
  72828. 'ᾚ' => 'ᾒ',
  72829. 'ᾛ' => 'ᾓ',
  72830. 'ᾜ' => 'ᾔ',
  72831. '�' => 'ᾕ',
  72832. 'ᾞ' => 'ᾖ',
  72833. 'ᾟ' => 'ᾗ',
  72834. 'ᾨ' => 'ᾠ',
  72835. 'ᾩ' => 'ᾡ',
  72836. 'ᾪ' => 'ᾢ',
  72837. 'ᾫ' => 'ᾣ',
  72838. 'ᾬ' => 'ᾤ',
  72839. 'á¾­' => 'á¾¥',
  72840. 'ᾮ' => 'ᾦ',
  72841. 'ᾯ' => 'ᾧ',
  72842. 'Ᾰ' => 'ᾰ',
  72843. 'á¾¹' => 'á¾±',
  72844. 'Ὰ' => 'ὰ',
  72845. 'á¾»' => 'á½±',
  72846. 'á¾¼' => 'á¾³',
  72847. 'Ὲ' => 'ὲ',
  72848. 'Έ' => 'έ',
  72849. 'Ὴ' => 'ὴ',
  72850. 'á¿‹' => 'á½µ',
  72851. 'ῌ' => 'ῃ',
  72852. 'Ῐ' => '�',
  72853. 'á¿™' => 'á¿‘',
  72854. 'Ὶ' => 'ὶ',
  72855. 'á¿›' => 'á½·',
  72856. 'Ῠ' => 'ῠ',
  72857. 'á¿©' => 'á¿¡',
  72858. 'Ὺ' => 'ὺ',
  72859. 'á¿«' => 'á½»',
  72860. 'Ῥ' => 'ῥ',
  72861. 'Ὸ' => 'ὸ',
  72862. 'Ό' => 'ό',
  72863. 'Ὼ' => 'ὼ',
  72864. 'á¿»' => 'á½½',
  72865. 'ῼ' => 'ῳ',
  72866. 'Ω' => 'ω',
  72867. 'K' => 'k',
  72868. 'â„«' => 'Ã¥',
  72869. 'Ⅎ' => 'ⅎ',
  72870. 'â… ' => 'â…°',
  72871. 'â…¡' => 'â…±',
  72872. 'â…¢' => 'â…²',
  72873. 'â…£' => 'â…³',
  72874. 'â…¤' => 'â…´',
  72875. 'â…¥' => 'â…µ',
  72876. 'â…¦' => 'â…¶',
  72877. 'â…§' => 'â…·',
  72878. 'â…¨' => 'â…¸',
  72879. 'â…©' => 'â…¹',
  72880. 'â…ª' => 'â…º',
  72881. 'â…«' => 'â…»',
  72882. 'â…¬' => 'â…¼',
  72883. 'â…­' => 'â…½',
  72884. 'â…®' => 'â…¾',
  72885. 'â…¯' => 'â…¿',
  72886. 'Ↄ' => 'ↄ',
  72887. 'Ⓐ' => '�',
  72888. 'â’·' => 'â“‘',
  72889. 'â’¸' => 'â“’',
  72890. 'â’¹' => 'â““',
  72891. 'â’º' => 'â“”',
  72892. 'â’»' => 'â“•',
  72893. 'â’¼' => 'â“–',
  72894. 'â’½' => 'â“—',
  72895. 'Ⓘ' => 'ⓘ',
  72896. 'â’¿' => 'â“™',
  72897. 'Ⓚ' => 'ⓚ',
  72898. '�' => 'ⓛ',
  72899. 'Ⓜ' => 'ⓜ',
  72900. 'Ⓝ' => '�',
  72901. 'Ⓞ' => 'ⓞ',
  72902. 'Ⓟ' => 'ⓟ',
  72903. 'Ⓠ' => 'ⓠ',
  72904. 'Ⓡ' => 'ⓡ',
  72905. 'Ⓢ' => 'ⓢ',
  72906. 'Ⓣ' => 'ⓣ',
  72907. 'Ⓤ' => 'ⓤ',
  72908. 'â“‹' => 'â“¥',
  72909. 'Ⓦ' => 'ⓦ',
  72910. '�' => 'ⓧ',
  72911. 'Ⓨ' => 'ⓨ',
  72912. '�' => 'ⓩ',
  72913. 'â°€' => 'â°°',
  72914. 'â°�' => 'â°±',
  72915. 'â°‚' => 'â°²',
  72916. 'â°ƒ' => 'â°³',
  72917. 'â°„' => 'â°´',
  72918. 'â°…' => 'â°µ',
  72919. 'â°†' => 'â°¶',
  72920. 'â°‡' => 'â°·',
  72921. 'â°ˆ' => 'â°¸',
  72922. 'â°‰' => 'â°¹',
  72923. 'â°Š' => 'â°º',
  72924. 'â°‹' => 'â°»',
  72925. 'Ⰼ' => 'ⰼ',
  72926. 'â°�' => 'â°½',
  72927. 'â°Ž' => 'â°¾',
  72928. 'â°�' => 'â°¿',
  72929. 'â°�' => 'â±€',
  72930. 'Ⱁ' => '�',
  72931. 'Ⱂ' => 'ⱂ',
  72932. 'Ⱃ' => 'ⱃ',
  72933. 'Ⱄ' => 'ⱄ',
  72934. 'â°•' => 'â±…',
  72935. 'Ⱆ' => 'ⱆ',
  72936. 'Ⱇ' => 'ⱇ',
  72937. 'Ⱈ' => 'ⱈ',
  72938. 'Ⱉ' => 'ⱉ',
  72939. 'Ⱊ' => 'ⱊ',
  72940. 'Ⱋ' => 'ⱋ',
  72941. 'Ⱌ' => 'ⱌ',
  72942. '�' => '�',
  72943. 'Ⱎ' => 'ⱎ',
  72944. 'Ⱏ' => '�',
  72945. 'Ⱐ' => '�',
  72946. 'Ⱑ' => 'ⱑ',
  72947. 'â°¢' => 'â±’',
  72948. 'Ⱓ' => 'ⱓ',
  72949. 'â°¤' => 'â±”',
  72950. 'Ⱕ' => 'ⱕ',
  72951. 'â°¦' => 'â±–',
  72952. 'â°§' => 'â±—',
  72953. 'Ⱘ' => 'ⱘ',
  72954. 'â°©' => 'â±™',
  72955. 'Ⱚ' => 'ⱚ',
  72956. 'â°«' => 'â±›',
  72957. 'Ⱜ' => 'ⱜ',
  72958. 'Ⱝ' => '�',
  72959. 'Ⱞ' => 'ⱞ',
  72960. 'Ⱡ' => 'ⱡ',
  72961. 'â±¢' => 'É«',
  72962. 'â±£' => 'áµ½',
  72963. 'Ɽ' => 'ɽ',
  72964. 'Ⱨ' => 'ⱨ',
  72965. 'Ⱪ' => 'ⱪ',
  72966. 'Ⱬ' => 'ⱬ',
  72967. 'â±­' => 'É‘',
  72968. 'Ɱ' => 'ɱ',
  72969. 'Ɐ' => '�',
  72970. 'â±°' => 'É’',
  72971. 'â±²' => 'â±³',
  72972. 'â±µ' => 'â±¶',
  72973. 'â±¾' => 'È¿',
  72974. 'Ɀ' => 'ɀ',
  72975. 'Ⲁ' => '�',
  72976. 'Ⲃ' => 'ⲃ',
  72977. 'Ⲅ' => 'ⲅ',
  72978. 'Ⲇ' => 'ⲇ',
  72979. 'Ⲉ' => 'ⲉ',
  72980. 'Ⲋ' => 'ⲋ',
  72981. 'Ⲍ' => '�',
  72982. 'Ⲏ' => '�',
  72983. '�' => 'ⲑ',
  72984. 'Ⲓ' => 'ⲓ',
  72985. 'Ⲕ' => 'ⲕ',
  72986. 'â²–' => 'â²—',
  72987. 'Ⲙ' => 'ⲙ',
  72988. 'Ⲛ' => 'ⲛ',
  72989. 'Ⲝ' => '�',
  72990. 'Ⲟ' => 'ⲟ',
  72991. 'Ⲡ' => 'ⲡ',
  72992. 'â²¢' => 'â²£',
  72993. 'Ⲥ' => 'ⲥ',
  72994. 'Ⲧ' => 'ⲧ',
  72995. 'Ⲩ' => 'ⲩ',
  72996. 'Ⲫ' => 'ⲫ',
  72997. 'Ⲭ' => 'ⲭ',
  72998. 'Ⲯ' => 'ⲯ',
  72999. 'â²°' => 'â²±',
  73000. 'â²²' => 'â²³',
  73001. 'â²´' => 'â²µ',
  73002. 'â²¶' => 'â²·',
  73003. 'Ⲹ' => 'ⲹ',
  73004. 'Ⲻ' => 'ⲻ',
  73005. 'â²¼' => 'â²½',
  73006. 'Ⲿ' => 'ⲿ',
  73007. 'Ⳁ' => '�',
  73008. 'Ⳃ' => 'ⳃ',
  73009. 'Ⳅ' => 'ⳅ',
  73010. 'Ⳇ' => 'ⳇ',
  73011. 'Ⳉ' => 'ⳉ',
  73012. 'Ⳋ' => 'ⳋ',
  73013. 'Ⳍ' => '�',
  73014. 'Ⳏ' => '�',
  73015. '�' => 'ⳑ',
  73016. 'Ⳓ' => 'ⳓ',
  73017. 'Ⳕ' => 'ⳕ',
  73018. 'â³–' => 'â³—',
  73019. 'Ⳙ' => 'ⳙ',
  73020. 'Ⳛ' => 'ⳛ',
  73021. 'Ⳝ' => '�',
  73022. 'Ⳟ' => 'ⳟ',
  73023. 'Ⳡ' => 'ⳡ',
  73024. 'â³¢' => 'â³£',
  73025. 'Ⳬ' => 'ⳬ',
  73026. 'â³­' => 'â³®',
  73027. 'â³²' => 'â³³',
  73028. 'Ꙁ' => '�',
  73029. 'Ꙃ' => 'ꙃ',
  73030. 'Ꙅ' => 'ꙅ',
  73031. 'Ꙇ' => 'ꙇ',
  73032. 'Ꙉ' => 'ꙉ',
  73033. 'Ꙋ' => 'ꙋ',
  73034. 'Ꙍ' => '�',
  73035. 'Ꙏ' => '�',
  73036. '�' => 'ꙑ',
  73037. 'Ꙓ' => 'ꙓ',
  73038. 'Ꙕ' => 'ꙕ',
  73039. 'ê™–' => 'ê™—',
  73040. 'Ꙙ' => 'ꙙ',
  73041. 'Ꙛ' => 'ꙛ',
  73042. 'Ꙝ' => '�',
  73043. 'Ꙟ' => 'ꙟ',
  73044. 'Ꙡ' => 'ꙡ',
  73045. 'Ꙣ' => 'ꙣ',
  73046. 'Ꙥ' => 'ꙥ',
  73047. 'Ꙧ' => 'ꙧ',
  73048. 'Ꙩ' => 'ꙩ',
  73049. 'Ꙫ' => 'ꙫ',
  73050. 'Ꙭ' => 'ꙭ',
  73051. 'Ꚁ' => '�',
  73052. 'Ꚃ' => 'ꚃ',
  73053. 'êš„' => 'êš…',
  73054. 'Ꚇ' => 'ꚇ',
  73055. 'Ꚉ' => 'ꚉ',
  73056. 'Ꚋ' => 'ꚋ',
  73057. 'Ꚍ' => '�',
  73058. 'Ꚏ' => '�',
  73059. '�' => 'ꚑ',
  73060. 'êš’' => 'êš“',
  73061. 'êš”' => 'êš•',
  73062. 'êš–' => 'êš—',
  73063. 'Ꚙ' => 'ꚙ',
  73064. 'êšš' => 'êš›',
  73065. 'Ꜣ' => 'ꜣ',
  73066. 'Ꜥ' => 'ꜥ',
  73067. 'Ꜧ' => 'ꜧ',
  73068. 'Ꜩ' => 'ꜩ',
  73069. 'Ꜫ' => 'ꜫ',
  73070. 'Ꜭ' => 'ꜭ',
  73071. 'Ꜯ' => 'ꜯ',
  73072. 'Ꜳ' => 'ꜳ',
  73073. 'Ꜵ' => 'ꜵ',
  73074. 'Ꜷ' => 'ꜷ',
  73075. 'Ꜹ' => 'ꜹ',
  73076. 'Ꜻ' => 'ꜻ',
  73077. 'Ꜽ' => 'ꜽ',
  73078. 'Ꜿ' => 'ꜿ',
  73079. '�' => '�',
  73080. '�' => '�',
  73081. '�' => '�',
  73082. '�' => '�',
  73083. '�' => '�',
  73084. '�' => '�',
  73085. '�' => '�',
  73086. '�' => '�',
  73087. '�' => '�',
  73088. '�' => '�',
  73089. '�' => '�',
  73090. '�' => '�',
  73091. '�' => '�',
  73092. '�' => '�',
  73093. '�' => '�',
  73094. '�' => '�',
  73095. '�' => '�',
  73096. '�' => '�',
  73097. '�' => '�',
  73098. '�' => '�',
  73099. '�' => '�',
  73100. '�' => '�',
  73101. '�' => '�',
  73102. '�' => '�',
  73103. '�' => '�',
  73104. '�' => '�',
  73105. '�' => 'ᵹ',
  73106. '�' => '�',
  73107. 'Ꞁ' => '�',
  73108. 'Ꞃ' => 'ꞃ',
  73109. 'êž„' => 'êž…',
  73110. 'Ꞇ' => 'ꞇ',
  73111. 'Ꞌ' => 'ꞌ',
  73112. '�' => 'ɥ',
  73113. '�' => 'ꞑ',
  73114. 'êž’' => 'êž“',
  73115. 'êž–' => 'êž—',
  73116. 'Ꞙ' => 'ꞙ',
  73117. 'êžš' => 'êž›',
  73118. 'Ꞝ' => '�',
  73119. 'Ꞟ' => 'ꞟ',
  73120. 'êž ' => 'êž¡',
  73121. 'Ꞣ' => 'ꞣ',
  73122. 'Ꞥ' => 'ꞥ',
  73123. 'Ꞧ' => 'ꞧ',
  73124. 'Ꞩ' => 'ꞩ',
  73125. 'Ɦ' => 'ɦ',
  73126. 'Ɜ' => 'ɜ',
  73127. 'Ɡ' => 'ɡ',
  73128. 'Ɬ' => 'ɬ',
  73129. 'Ɪ' => 'ɪ',
  73130. 'êž°' => 'Êž',
  73131. 'Ʇ' => 'ʇ',
  73132. 'Ʝ' => '�',
  73133. 'êž³' => 'ê­“',
  73134. 'êž´' => 'êžµ',
  73135. 'êž¶' => 'êž·',
  73136. 'Ꞹ' => 'ꞹ',
  73137. 'Ꞻ' => 'ꞻ',
  73138. 'êž¼' => 'êž½',
  73139. 'êž¾' => 'êž¿',
  73140. 'Ꟃ' => 'ꟃ',
  73141. 'Ꞔ' => 'ꞔ',
  73142. 'Ʂ' => 'ʂ',
  73143. 'Ᶎ' => 'ᶎ',
  73144. 'Ꟈ' => 'ꟈ',
  73145. 'Ꟊ' => 'ꟊ',
  73146. 'Ꟶ' => 'ꟶ',
  73147. 'A' => '�',
  73148. 'B' => 'b',
  73149. 'C' => 'c',
  73150. 'D' => 'd',
  73151. 'ï¼¥' => 'ï½…',
  73152. 'F' => 'f',
  73153. 'G' => 'g',
  73154. 'H' => 'h',
  73155. 'I' => 'i',
  73156. 'J' => 'j',
  73157. 'K' => 'k',
  73158. 'L' => 'l',
  73159. 'M' => '�',
  73160. 'N' => 'n',
  73161. 'O' => '�',
  73162. 'P' => '�',
  73163. 'Q' => 'q',
  73164. 'ï¼²' => 'ï½’',
  73165. 'S' => 's',
  73166. 'ï¼´' => 'ï½”',
  73167. 'U' => 'u',
  73168. 'ï¼¶' => 'ï½–',
  73169. 'ï¼·' => 'ï½—',
  73170. 'X' => 'x',
  73171. 'ï¼¹' => 'ï½™',
  73172. 'Z' => 'z',
  73173. '�' => '�',
  73174. '�' => '�',
  73175. '�' => '�',
  73176. '�' => '�',
  73177. '�' => '�',
  73178. '�' => '�',
  73179. '�' => '�',
  73180. '�' => '�',
  73181. '�' => '�',
  73182. '�' => '�',
  73183. '�' => '�',
  73184. '�' => '�',
  73185. '�' => '�',
  73186. '�' => '�',
  73187. '�' => '�',
  73188. '�' => '�',
  73189. '�' => '�',
  73190. '�' => '�',
  73191. '�' => '�',
  73192. '�' => '�',
  73193. '�' => '�',
  73194. '�' => '�',
  73195. '�' => '�',
  73196. '�' => '�',
  73197. '�' => '�',
  73198. '�' => '�',
  73199. '�' => '�',
  73200. '�' => '�',
  73201. '�' => '�',
  73202. '�' => '�',
  73203. '�' => '�',
  73204. '�' => '�',
  73205. '�' => '�',
  73206. '�' => '�',
  73207. '�' => '�',
  73208. '�' => '�',
  73209. '�' => '�',
  73210. '�' => '�',
  73211. '�' => '�',
  73212. '�' => '�',
  73213. '�' => '�',
  73214. '�' => '�',
  73215. '�' => '�',
  73216. '�' => '�',
  73217. '�' => '�',
  73218. '�' => '�',
  73219. '�' => '�',
  73220. '�' => '�',
  73221. '�' => '�',
  73222. '�' => '�',
  73223. '�' => '�',
  73224. '�' => '�',
  73225. '�' => '�',
  73226. '�' => '�',
  73227. '�' => '�',
  73228. '�' => '�',
  73229. '�' => '�',
  73230. '�' => '�',
  73231. '�' => '�',
  73232. '�' => '�',
  73233. '�' => '�',
  73234. '�' => '�',
  73235. '�' => '�',
  73236. '�' => '�',
  73237. '�' => '�',
  73238. '�' => '�',
  73239. '�' => '�',
  73240. '�' => '�',
  73241. '�' => '�',
  73242. '�' => '�',
  73243. '�' => '�',
  73244. '�' => '�',
  73245. '�' => '�',
  73246. '�' => '�',
  73247. '�' => '�',
  73248. '�' => '�',
  73249. '�' => '�',
  73250. '�' => '�',
  73251. '�' => '�',
  73252. '�' => '�',
  73253. '�' => '�',
  73254. '�' => '�',
  73255. '�' => '�',
  73256. '�' => '�',
  73257. '�' => '�',
  73258. '�' => '�',
  73259. '�' => '�',
  73260. '�' => '�',
  73261. '�' => '�',
  73262. '�' => '�',
  73263. '�' => '�',
  73264. '�' => '�',
  73265. '�' => '�',
  73266. '�' => '�',
  73267. '�' => '�',
  73268. '�' => '�',
  73269. '�' => '�',
  73270. '�' => '�',
  73271. '�' => '�',
  73272. '�' => '�',
  73273. '�' => '�',
  73274. '�' => '�',
  73275. '�' => '�',
  73276. '�' => '�',
  73277. '�' => '�',
  73278. '�' => '�',
  73279. '�' => '�',
  73280. '�' => '�',
  73281. '�' => '�',
  73282. '�' => '�',
  73283. '�' => '�',
  73284. '�' => '�',
  73285. '�' => '�',
  73286. '�' => '�',
  73287. '�' => '�',
  73288. '�' => '�',
  73289. '�' => '�',
  73290. '�' => '�',
  73291. '�' => '�',
  73292. '�' => '�',
  73293. '�' => '�',
  73294. '�' => '�',
  73295. '�' => '�',
  73296. '�' => '�',
  73297. '�' => '�',
  73298. '�' => '�',
  73299. '�' => '�',
  73300. 'ð‘¢ ' => 'ð‘£€',
  73301. '𑢡' => '�',
  73302. '𑢢' => '𑣂',
  73303. '𑢣' => '𑣃',
  73304. '𑢤' => '𑣄',
  73305. 'ð‘¢¥' => 'ð‘£…',
  73306. '𑢦' => '𑣆',
  73307. '𑢧' => '𑣇',
  73308. '𑢨' => '𑣈',
  73309. '𑢩' => '𑣉',
  73310. '𑢪' => '𑣊',
  73311. '𑢫' => '𑣋',
  73312. '𑢬' => '𑣌',
  73313. '𑢭' => '�',
  73314. '𑢮' => '𑣎',
  73315. '𑢯' => '�',
  73316. '𑢰' => '�',
  73317. '𑢱' => '𑣑',
  73318. 'ð‘¢²' => 'ð‘£’',
  73319. '𑢳' => '𑣓',
  73320. 'ð‘¢´' => 'ð‘£”',
  73321. '𑢵' => '𑣕',
  73322. 'ð‘¢¶' => 'ð‘£–',
  73323. 'ð‘¢·' => 'ð‘£—',
  73324. '𑢸' => '𑣘',
  73325. 'ð‘¢¹' => 'ð‘£™',
  73326. '𑢺' => '𑣚',
  73327. 'ð‘¢»' => 'ð‘£›',
  73328. '𑢼' => '𑣜',
  73329. '𑢽' => '�',
  73330. '𑢾' => '𑣞',
  73331. '𑢿' => '𑣟',
  73332. 'ð–¹€' => 'ð–¹ ',
  73333. '�' => '𖹡',
  73334. '𖹂' => '𖹢',
  73335. '𖹃' => '𖹣',
  73336. '𖹄' => '𖹤',
  73337. 'ð–¹…' => 'ð–¹¥',
  73338. '𖹆' => '𖹦',
  73339. '𖹇' => '𖹧',
  73340. '𖹈' => '𖹨',
  73341. '𖹉' => '𖹩',
  73342. '𖹊' => '𖹪',
  73343. '𖹋' => '𖹫',
  73344. '𖹌' => '𖹬',
  73345. '�' => '𖹭',
  73346. '𖹎' => '𖹮',
  73347. '�' => '𖹯',
  73348. '�' => '𖹰',
  73349. '𖹑' => '𖹱',
  73350. 'ð–¹’' => 'ð–¹²',
  73351. '𖹓' => '𖹳',
  73352. 'ð–¹”' => 'ð–¹´',
  73353. '𖹕' => '𖹵',
  73354. 'ð–¹–' => 'ð–¹¶',
  73355. 'ð–¹—' => 'ð–¹·',
  73356. '𖹘' => '𖹸',
  73357. 'ð–¹™' => 'ð–¹¹',
  73358. '𖹚' => '𖹺',
  73359. 'ð–¹›' => 'ð–¹»',
  73360. '𖹜' => '𖹼',
  73361. '�' => '𖹽',
  73362. '𖹞' => '𖹾',
  73363. '𖹟' => '𖹿',
  73364. '𞤀' => '𞤢',
  73365. '�' => '𞤣',
  73366. '𞤂' => '𞤤',
  73367. '𞤃' => '𞤥',
  73368. '𞤄' => '𞤦',
  73369. '𞤅' => '𞤧',
  73370. '𞤆' => '𞤨',
  73371. '𞤇' => '𞤩',
  73372. '𞤈' => '𞤪',
  73373. '𞤉' => '𞤫',
  73374. '𞤊' => '𞤬',
  73375. '𞤋' => '𞤭',
  73376. '𞤌' => '𞤮',
  73377. '�' => '𞤯',
  73378. '𞤎' => '𞤰',
  73379. '�' => '𞤱',
  73380. '�' => '𞤲',
  73381. '𞤑' => '𞤳',
  73382. '𞤒' => '𞤴',
  73383. '𞤓' => '𞤵',
  73384. '𞤔' => '𞤶',
  73385. '𞤕' => '𞤷',
  73386. '𞤖' => '𞤸',
  73387. '𞤗' => '𞤹',
  73388. '𞤘' => '𞤺',
  73389. '𞤙' => '𞤻',
  73390. '𞤚' => '𞤼',
  73391. '𞤛' => '𞤽',
  73392. '𞤜' => '𞤾',
  73393. '�' => '𞤿',
  73394. '𞤞' => '𞥀',
  73395. '𞤟' => '�',
  73396. '𞤠' => '𞥂',
  73397. '𞤡' => '𞥃',
  73398. );
  73399. <?php
  73400. 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';
  73401. <?php
  73402. return array (
  73403. 'a' => 'A',
  73404. 'b' => 'B',
  73405. 'c' => 'C',
  73406. 'd' => 'D',
  73407. 'e' => 'E',
  73408. 'f' => 'F',
  73409. 'g' => 'G',
  73410. 'h' => 'H',
  73411. 'i' => 'I',
  73412. 'j' => 'J',
  73413. 'k' => 'K',
  73414. 'l' => 'L',
  73415. 'm' => 'M',
  73416. 'n' => 'N',
  73417. 'o' => 'O',
  73418. 'p' => 'P',
  73419. 'q' => 'Q',
  73420. 'r' => 'R',
  73421. 's' => 'S',
  73422. 't' => 'T',
  73423. 'u' => 'U',
  73424. 'v' => 'V',
  73425. 'w' => 'W',
  73426. 'x' => 'X',
  73427. 'y' => 'Y',
  73428. 'z' => 'Z',
  73429. 'µ' => 'Μ',
  73430. 'à' => 'À',
  73431. 'á' => '�',
  73432. 'â' => 'Â',
  73433. 'ã' => 'Ã',
  73434. 'ä' => 'Ä',
  73435. 'Ã¥' => 'Ã…',
  73436. 'æ' => 'Æ',
  73437. 'ç' => 'Ç',
  73438. 'è' => 'È',
  73439. 'é' => 'É',
  73440. 'ê' => 'Ê',
  73441. 'ë' => 'Ë',
  73442. 'ì' => 'Ì',
  73443. 'í' => '�',
  73444. 'î' => 'Î',
  73445. 'ï' => '�',
  73446. 'ð' => '�',
  73447. 'ñ' => 'Ñ',
  73448. 'ò' => 'Ò',
  73449. 'ó' => 'Ó',
  73450. 'ô' => 'Ô',
  73451. 'õ' => 'Õ',
  73452. 'ö' => 'Ö',
  73453. 'ø' => 'Ø',
  73454. 'ù' => 'Ù',
  73455. 'ú' => 'Ú',
  73456. 'û' => 'Û',
  73457. 'ü' => 'Ü',
  73458. 'ý' => '�',
  73459. 'þ' => 'Þ',
  73460. 'ÿ' => 'Ÿ',
  73461. '�' => 'Ā',
  73462. 'ă' => 'Ă',
  73463. 'Ä…' => 'Ä„',
  73464. 'ć' => 'Ć',
  73465. 'ĉ' => 'Ĉ',
  73466. 'Ä‹' => 'ÄŠ',
  73467. '�' => 'Č',
  73468. '�' => 'Ď',
  73469. 'đ' => '�',
  73470. 'Ä“' => 'Ä’',
  73471. 'Ä•' => 'Ä”',
  73472. 'Ä—' => 'Ä–',
  73473. 'ę' => 'Ę',
  73474. 'Ä›' => 'Äš',
  73475. '�' => 'Ĝ',
  73476. 'ÄŸ' => 'Äž',
  73477. 'Ä¡' => 'Ä ',
  73478. 'Ä£' => 'Ä¢',
  73479. 'ĥ' => 'Ĥ',
  73480. 'ħ' => 'Ħ',
  73481. 'ĩ' => 'Ĩ',
  73482. 'ī' => 'Ī',
  73483. 'ĭ' => 'Ĭ',
  73484. 'į' => 'Į',
  73485. 'ı' => 'I',
  73486. 'ij' => 'IJ',
  73487. 'ĵ' => 'Ĵ',
  73488. 'ķ' => 'Ķ',
  73489. 'ĺ' => 'Ĺ',
  73490. 'ļ' => 'Ļ',
  73491. 'ľ' => 'Ľ',
  73492. 'Å€' => 'Ä¿',
  73493. 'ł' => '�',
  73494. 'ń' => 'Ń',
  73495. 'ņ' => 'Ņ',
  73496. 'ň' => 'Ň',
  73497. 'Å‹' => 'ÅŠ',
  73498. '�' => 'Ō',
  73499. '�' => 'Ŏ',
  73500. 'ő' => '�',
  73501. 'Å“' => 'Å’',
  73502. 'Å•' => 'Å”',
  73503. 'Å—' => 'Å–',
  73504. 'ř' => 'Ř',
  73505. 'Å›' => 'Åš',
  73506. '�' => 'Ŝ',
  73507. 'ÅŸ' => 'Åž',
  73508. 'Å¡' => 'Å ',
  73509. 'Å£' => 'Å¢',
  73510. 'ť' => 'Ť',
  73511. 'ŧ' => 'Ŧ',
  73512. 'ũ' => 'Ũ',
  73513. 'ū' => 'Ū',
  73514. 'ŭ' => 'Ŭ',
  73515. 'ů' => 'Ů',
  73516. 'ű' => 'Ű',
  73517. 'ų' => 'Ų',
  73518. 'ŵ' => 'Ŵ',
  73519. 'ŷ' => 'Ŷ',
  73520. 'ź' => 'Ź',
  73521. 'ż' => 'Ż',
  73522. 'ž' => 'Ž',
  73523. 'Å¿' => 'S',
  73524. 'ƀ' => 'Ƀ',
  73525. 'ƃ' => 'Ƃ',
  73526. 'Æ…' => 'Æ„',
  73527. 'ƈ' => 'Ƈ',
  73528. 'ƌ' => 'Ƌ',
  73529. 'Æ’' => 'Æ‘',
  73530. 'ƕ' => 'Ƕ',
  73531. 'ƙ' => 'Ƙ',
  73532. 'ƚ' => 'Ƚ',
  73533. 'Æž' => 'È ',
  73534. 'Æ¡' => 'Æ ',
  73535. 'Æ£' => 'Æ¢',
  73536. 'ƥ' => 'Ƥ',
  73537. 'ƨ' => 'Ƨ',
  73538. 'ƭ' => 'Ƭ',
  73539. 'ư' => 'Ư',
  73540. 'ƴ' => 'Ƴ',
  73541. 'ƶ' => 'Ƶ',
  73542. 'ƹ' => 'Ƹ',
  73543. 'ƽ' => 'Ƽ',
  73544. 'Æ¿' => 'Ç·',
  73545. 'Ç…' => 'Ç„',
  73546. 'dž' => 'DŽ',
  73547. 'Lj' => 'LJ',
  73548. 'lj' => 'LJ',
  73549. 'Ç‹' => 'ÇŠ',
  73550. 'nj' => 'NJ',
  73551. 'ǎ' => '�',
  73552. '�' => '�',
  73553. 'Ç’' => 'Ç‘',
  73554. 'Ç”' => 'Ç“',
  73555. 'Ç–' => 'Ç•',
  73556. 'ǘ' => 'Ǘ',
  73557. 'Çš' => 'Ç™',
  73558. 'ǜ' => 'Ǜ',
  73559. '�' => 'Ǝ',
  73560. 'ÇŸ' => 'Çž',
  73561. 'Ç¡' => 'Ç ',
  73562. 'Ç£' => 'Ç¢',
  73563. 'ǥ' => 'Ǥ',
  73564. 'ǧ' => 'Ǧ',
  73565. 'ǩ' => 'Ǩ',
  73566. 'ǫ' => 'Ǫ',
  73567. 'ǭ' => 'Ǭ',
  73568. 'ǯ' => 'Ǯ',
  73569. 'Dz' => 'DZ',
  73570. 'dz' => 'DZ',
  73571. 'ǵ' => 'Ǵ',
  73572. 'ǹ' => 'Ǹ',
  73573. 'ǻ' => 'Ǻ',
  73574. 'ǽ' => 'Ǽ',
  73575. 'ǿ' => 'Ǿ',
  73576. '�' => 'Ȁ',
  73577. 'ȃ' => 'Ȃ',
  73578. 'È…' => 'È„',
  73579. 'ȇ' => 'Ȇ',
  73580. 'ȉ' => 'Ȉ',
  73581. 'È‹' => 'ÈŠ',
  73582. '�' => 'Ȍ',
  73583. '�' => 'Ȏ',
  73584. 'ȑ' => '�',
  73585. 'È“' => 'È’',
  73586. 'È•' => 'È”',
  73587. 'È—' => 'È–',
  73588. 'ș' => 'Ș',
  73589. 'È›' => 'Èš',
  73590. '�' => 'Ȝ',
  73591. 'ÈŸ' => 'Èž',
  73592. 'È£' => 'È¢',
  73593. 'ȥ' => 'Ȥ',
  73594. 'ȧ' => 'Ȧ',
  73595. 'ȩ' => 'Ȩ',
  73596. 'ȫ' => 'Ȫ',
  73597. 'ȭ' => 'Ȭ',
  73598. 'ȯ' => 'Ȯ',
  73599. 'ȱ' => 'Ȱ',
  73600. 'ȳ' => 'Ȳ',
  73601. 'ȼ' => 'Ȼ',
  73602. 'È¿' => 'â±¾',
  73603. 'ɀ' => 'Ɀ',
  73604. 'ɂ' => '�',
  73605. 'ɇ' => 'Ɇ',
  73606. 'ɉ' => 'Ɉ',
  73607. 'É‹' => 'ÉŠ',
  73608. '�' => 'Ɍ',
  73609. '�' => 'Ɏ',
  73610. '�' => 'Ɐ',
  73611. 'É‘' => 'â±­',
  73612. 'É’' => 'â±°',
  73613. 'ɓ' => '�',
  73614. 'ɔ' => 'Ɔ',
  73615. 'ɖ' => 'Ɖ',
  73616. 'É—' => 'ÆŠ',
  73617. 'ə' => '�',
  73618. 'ɛ' => '�',
  73619. 'ɜ' => 'Ɜ',
  73620. 'É ' => 'Æ“',
  73621. 'ɡ' => 'Ɡ',
  73622. 'É£' => 'Æ”',
  73623. 'ɥ' => '�',
  73624. 'ɦ' => 'Ɦ',
  73625. 'ɨ' => 'Ɨ',
  73626. 'É©' => 'Æ–',
  73627. 'ɪ' => 'Ɪ',
  73628. 'É«' => 'â±¢',
  73629. 'ɬ' => 'Ɬ',
  73630. 'ɯ' => 'Ɯ',
  73631. 'ɱ' => 'Ɱ',
  73632. 'ɲ' => '�',
  73633. 'ɵ' => 'Ɵ',
  73634. 'ɽ' => 'Ɽ',
  73635. 'ʀ' => 'Ʀ',
  73636. 'ʂ' => 'Ʂ',
  73637. 'ʃ' => 'Ʃ',
  73638. 'ʇ' => 'Ʇ',
  73639. 'ʈ' => 'Ʈ',
  73640. 'ʉ' => 'Ʉ',
  73641. 'ʊ' => 'Ʊ',
  73642. 'ʋ' => 'Ʋ',
  73643. 'ʌ' => 'Ʌ',
  73644. 'Ê’' => 'Æ·',
  73645. '�' => 'Ʝ',
  73646. 'Êž' => 'êž°',
  73647. 'ͅ' => 'Ι',
  73648. 'ͱ' => 'Ͱ',
  73649. 'ͳ' => 'Ͳ',
  73650. 'ͷ' => 'Ͷ',
  73651. 'ͻ' => 'Ͻ',
  73652. 'ͼ' => 'Ͼ',
  73653. 'ͽ' => 'Ͽ',
  73654. 'ά' => 'Ά',
  73655. 'έ' => 'Έ',
  73656. 'ή' => 'Ή',
  73657. 'ί' => 'Ί',
  73658. 'α' => 'Α',
  73659. 'β' => 'Β',
  73660. 'γ' => 'Γ',
  73661. 'δ' => 'Δ',
  73662. 'ε' => 'Ε',
  73663. 'ζ' => 'Ζ',
  73664. 'η' => 'Η',
  73665. 'θ' => 'Θ',
  73666. 'ι' => 'Ι',
  73667. 'κ' => 'Κ',
  73668. 'λ' => 'Λ',
  73669. 'μ' => 'Μ',
  73670. 'ν' => '�',
  73671. 'ξ' => 'Ξ',
  73672. 'ο' => 'Ο',
  73673. 'π' => 'Π',
  73674. '�' => 'Ρ',
  73675. 'ς' => 'Σ',
  73676. 'σ' => 'Σ',
  73677. 'τ' => 'Τ',
  73678. 'Ï…' => 'Î¥',
  73679. 'φ' => 'Φ',
  73680. 'χ' => 'Χ',
  73681. 'ψ' => 'Ψ',
  73682. 'ω' => 'Ω',
  73683. 'ϊ' => 'Ϊ',
  73684. 'ϋ' => 'Ϋ',
  73685. 'ό' => 'Ό',
  73686. '�' => 'Ύ',
  73687. 'ώ' => '�',
  73688. '�' => 'Β',
  73689. 'ϑ' => 'Θ',
  73690. 'ϕ' => 'Φ',
  73691. 'ϖ' => 'Π',
  73692. 'ϗ' => '�',
  73693. 'ϙ' => 'Ϙ',
  73694. 'Ï›' => 'Ïš',
  73695. '�' => 'Ϝ',
  73696. 'ÏŸ' => 'Ïž',
  73697. 'Ï¡' => 'Ï ',
  73698. 'Ï£' => 'Ï¢',
  73699. 'ϥ' => 'Ϥ',
  73700. 'ϧ' => 'Ϧ',
  73701. 'ϩ' => 'Ϩ',
  73702. 'ϫ' => 'Ϫ',
  73703. 'ϭ' => 'Ϭ',
  73704. 'ϯ' => 'Ϯ',
  73705. 'ϰ' => 'Κ',
  73706. 'ϱ' => 'Ρ',
  73707. 'ϲ' => 'Ϲ',
  73708. 'ϳ' => 'Ϳ',
  73709. 'ϵ' => 'Ε',
  73710. 'ϸ' => 'Ϸ',
  73711. 'ϻ' => 'Ϻ',
  73712. 'а' => '�',
  73713. 'б' => 'Б',
  73714. 'в' => 'В',
  73715. 'г' => 'Г',
  73716. 'д' => 'Д',
  73717. 'е' => 'Е',
  73718. 'ж' => 'Ж',
  73719. 'з' => 'З',
  73720. 'и' => 'И',
  73721. 'й' => 'Й',
  73722. 'к' => 'К',
  73723. 'л' => 'Л',
  73724. 'м' => 'М',
  73725. 'н' => '�',
  73726. 'о' => 'О',
  73727. 'п' => 'П',
  73728. 'р' => 'Р',
  73729. '�' => 'С',
  73730. 'т' => 'Т',
  73731. 'у' => 'У',
  73732. 'ф' => 'Ф',
  73733. 'Ñ…' => 'Ð¥',
  73734. 'ц' => 'Ц',
  73735. 'ч' => 'Ч',
  73736. 'ш' => 'Ш',
  73737. 'щ' => 'Щ',
  73738. 'ъ' => 'Ъ',
  73739. 'ы' => 'Ы',
  73740. 'ь' => 'Ь',
  73741. '�' => 'Э',
  73742. 'ю' => 'Ю',
  73743. '�' => 'Я',
  73744. '�' => 'Ѐ',
  73745. 'ё' => '�',
  73746. 'ђ' => 'Ђ',
  73747. 'ѓ' => 'Ѓ',
  73748. 'є' => 'Є',
  73749. 'Ñ•' => 'Ð…',
  73750. 'і' => 'І',
  73751. 'ї' => 'Ї',
  73752. 'ј' => 'Ј',
  73753. 'љ' => 'Љ',
  73754. 'њ' => 'Њ',
  73755. 'ћ' => 'Ћ',
  73756. 'ќ' => 'Ќ',
  73757. '�' => '�',
  73758. 'Ñž' => 'ÐŽ',
  73759. 'џ' => '�',
  73760. 'Ñ¡' => 'Ñ ',
  73761. 'Ñ£' => 'Ñ¢',
  73762. 'ѥ' => 'Ѥ',
  73763. 'ѧ' => 'Ѧ',
  73764. 'ѩ' => 'Ѩ',
  73765. 'ѫ' => 'Ѫ',
  73766. 'ѭ' => 'Ѭ',
  73767. 'ѯ' => 'Ѯ',
  73768. 'ѱ' => 'Ѱ',
  73769. 'ѳ' => 'Ѳ',
  73770. 'ѵ' => 'Ѵ',
  73771. 'ѷ' => 'Ѷ',
  73772. 'ѹ' => 'Ѹ',
  73773. 'ѻ' => 'Ѻ',
  73774. 'ѽ' => 'Ѽ',
  73775. 'ѿ' => 'Ѿ',
  73776. 'Ò�' => 'Ò€',
  73777. 'Ò‹' => 'ÒŠ',
  73778. '�' => 'Ҍ',
  73779. 'Ò�' => 'ÒŽ',
  73780. 'Ò‘' => 'Ò�',
  73781. 'Ò“' => 'Ò’',
  73782. 'Ò•' => 'Ò”',
  73783. 'Ò—' => 'Ò–',
  73784. 'Ò™' => 'Ò˜',
  73785. 'Ò›' => 'Òš',
  73786. '�' => 'Ҝ',
  73787. 'ÒŸ' => 'Òž',
  73788. 'Ò¡' => 'Ò ',
  73789. 'Ò£' => 'Ò¢',
  73790. 'Ò¥' => 'Ò¤',
  73791. 'Ò§' => 'Ò¦',
  73792. 'Ò©' => 'Ò¨',
  73793. 'Ò«' => 'Òª',
  73794. 'Ò­' => 'Ò¬',
  73795. 'Ò¯' => 'Ò®',
  73796. 'Ò±' => 'Ò°',
  73797. 'Ò³' => 'Ò²',
  73798. 'Òµ' => 'Ò´',
  73799. 'Ò·' => 'Ò¶',
  73800. 'Ò¹' => 'Ò¸',
  73801. 'Ò»' => 'Òº',
  73802. 'Ò½' => 'Ò¼',
  73803. 'Ò¿' => 'Ò¾',
  73804. 'Ó‚' => 'Ó�',
  73805. 'Ó„' => 'Óƒ',
  73806. 'Ó†' => 'Ó…',
  73807. 'Óˆ' => 'Ó‡',
  73808. 'ÓŠ' => 'Ó‰',
  73809. 'ӌ' => 'Ӌ',
  73810. 'ÓŽ' => 'Ó�',
  73811. 'Ó�' => 'Ó€',
  73812. 'Ó‘' => 'Ó�',
  73813. 'Ó“' => 'Ó’',
  73814. 'Ó•' => 'Ó”',
  73815. 'Ó—' => 'Ó–',
  73816. 'Ó™' => 'Ó˜',
  73817. 'Ó›' => 'Óš',
  73818. '�' => 'Ӝ',
  73819. 'ÓŸ' => 'Óž',
  73820. 'Ó¡' => 'Ó ',
  73821. 'Ó£' => 'Ó¢',
  73822. 'Ó¥' => 'Ó¤',
  73823. 'Ó§' => 'Ó¦',
  73824. 'Ó©' => 'Ó¨',
  73825. 'Ó«' => 'Óª',
  73826. 'Ó­' => 'Ó¬',
  73827. 'Ó¯' => 'Ó®',
  73828. 'Ó±' => 'Ó°',
  73829. 'Ó³' => 'Ó²',
  73830. 'Óµ' => 'Ó´',
  73831. 'Ó·' => 'Ó¶',
  73832. 'Ó¹' => 'Ó¸',
  73833. 'Ó»' => 'Óº',
  73834. 'Ó½' => 'Ó¼',
  73835. 'Ó¿' => 'Ó¾',
  73836. 'Ô�' => 'Ô€',
  73837. 'Ôƒ' => 'Ô‚',
  73838. 'Ô…' => 'Ô„',
  73839. 'Ô‡' => 'Ô†',
  73840. 'Ô‰' => 'Ôˆ',
  73841. 'Ô‹' => 'ÔŠ',
  73842. '�' => 'Ԍ',
  73843. 'Ô�' => 'ÔŽ',
  73844. 'Ô‘' => 'Ô�',
  73845. 'Ô“' => 'Ô’',
  73846. 'Ô•' => 'Ô”',
  73847. 'Ô—' => 'Ô–',
  73848. 'Ô™' => 'Ô˜',
  73849. 'Ô›' => 'Ôš',
  73850. '�' => 'Ԝ',
  73851. 'ÔŸ' => 'Ôž',
  73852. 'Ô¡' => 'Ô ',
  73853. 'Ô£' => 'Ô¢',
  73854. 'Ô¥' => 'Ô¤',
  73855. 'Ô§' => 'Ô¦',
  73856. 'Ô©' => 'Ô¨',
  73857. 'Ô«' => 'Ôª',
  73858. 'Ô­' => 'Ô¬',
  73859. 'Ô¯' => 'Ô®',
  73860. 'Õ¡' => 'Ô±',
  73861. 'Õ¢' => 'Ô²',
  73862. 'Õ£' => 'Ô³',
  73863. 'Õ¤' => 'Ô´',
  73864. 'Õ¥' => 'Ôµ',
  73865. 'Õ¦' => 'Ô¶',
  73866. 'Õ§' => 'Ô·',
  73867. 'Õ¨' => 'Ô¸',
  73868. 'Õ©' => 'Ô¹',
  73869. 'Õª' => 'Ôº',
  73870. 'Õ«' => 'Ô»',
  73871. 'Õ¬' => 'Ô¼',
  73872. 'Õ­' => 'Ô½',
  73873. 'Õ®' => 'Ô¾',
  73874. 'Õ¯' => 'Ô¿',
  73875. 'Õ°' => 'Õ€',
  73876. 'Õ±' => 'Õ�',
  73877. 'Õ²' => 'Õ‚',
  73878. 'Õ³' => 'Õƒ',
  73879. 'Õ´' => 'Õ„',
  73880. 'Õµ' => 'Õ…',
  73881. 'Õ¶' => 'Õ†',
  73882. 'Õ·' => 'Õ‡',
  73883. 'Õ¸' => 'Õˆ',
  73884. 'Õ¹' => 'Õ‰',
  73885. 'Õº' => 'ÕŠ',
  73886. 'Õ»' => 'Õ‹',
  73887. 'ռ' => 'Ռ',
  73888. 'Õ½' => 'Õ�',
  73889. 'Õ¾' => 'ÕŽ',
  73890. 'Õ¿' => 'Õ�',
  73891. 'Ö€' => 'Õ�',
  73892. 'Ö�' => 'Õ‘',
  73893. 'Ö‚' => 'Õ’',
  73894. 'Öƒ' => 'Õ“',
  73895. 'Ö„' => 'Õ”',
  73896. 'Ö…' => 'Õ•',
  73897. 'Ö†' => 'Õ–',
  73898. '�' => '�',
  73899. 'ბ' => 'Ბ',
  73900. 'გ' => 'Გ',
  73901. 'დ' => 'Დ',
  73902. 'ე' => 'Ე',
  73903. 'ვ' => 'Ვ',
  73904. 'ზ' => 'Ზ',
  73905. 'თ' => 'Თ',
  73906. 'ი' => 'Ი',
  73907. 'კ' => 'Კ',
  73908. 'ლ' => 'Ლ',
  73909. 'მ' => 'Მ',
  73910. 'ნ' => 'Ნ',
  73911. '�' => '�',
  73912. 'პ' => 'Პ',
  73913. 'ჟ' => 'Ჟ',
  73914. 'რ' => 'Რ',
  73915. 'ს' => 'Ს',
  73916. 'ტ' => 'Ტ',
  73917. 'უ' => 'Უ',
  73918. 'ფ' => 'Ფ',
  73919. 'ქ' => 'Ქ',
  73920. 'ღ' => 'Ღ',
  73921. 'ყ' => 'Ყ',
  73922. 'შ' => 'Შ',
  73923. 'ჩ' => 'Ჩ',
  73924. 'ც' => 'Ც',
  73925. 'ძ' => 'Ძ',
  73926. 'წ' => 'Წ',
  73927. 'ჭ' => 'Ჭ',
  73928. 'ხ' => 'Ხ',
  73929. 'ჯ' => 'Ჯ',
  73930. 'ჰ' => 'Ჰ',
  73931. 'ჱ' => 'Ჱ',
  73932. 'ჲ' => 'Ჲ',
  73933. 'ჳ' => 'Ჳ',
  73934. 'ჴ' => 'Ჴ',
  73935. 'ჵ' => 'Ჵ',
  73936. 'ჶ' => 'Ჶ',
  73937. 'ჷ' => 'Ჷ',
  73938. 'ჸ' => 'Ჸ',
  73939. 'ჹ' => 'Ჹ',
  73940. 'ჺ' => 'Ჺ',
  73941. 'ჽ' => 'Ჽ',
  73942. 'ჾ' => 'Ჾ',
  73943. 'ჿ' => 'Ჿ',
  73944. '�' => '�',
  73945. '�' => '�',
  73946. '�' => '�',
  73947. '�' => '�',
  73948. '�' => '�',
  73949. '�' => '�',
  73950. 'á²€' => 'Ð’',
  73951. '�' => 'Д',
  73952. 'ᲂ' => 'О',
  73953. 'ᲃ' => 'С',
  73954. 'ᲄ' => 'Т',
  73955. 'ᲅ' => 'Т',
  73956. 'ᲆ' => 'Ъ',
  73957. 'ᲇ' => 'Ѣ',
  73958. 'ᲈ' => 'Ꙋ',
  73959. 'ᵹ' => '�',
  73960. 'áµ½' => 'â±£',
  73961. 'ᶎ' => 'Ᶎ',
  73962. '�' => 'Ḁ',
  73963. 'ḃ' => 'Ḃ',
  73964. 'ḅ' => 'Ḅ',
  73965. 'ḇ' => 'Ḇ',
  73966. 'ḉ' => 'Ḉ',
  73967. 'ḋ' => 'Ḋ',
  73968. '�' => 'Ḍ',
  73969. '�' => 'Ḏ',
  73970. 'ḑ' => '�',
  73971. 'ḓ' => 'Ḓ',
  73972. 'ḕ' => 'Ḕ',
  73973. 'ḗ' => 'Ḗ',
  73974. 'ḙ' => 'Ḙ',
  73975. 'ḛ' => 'Ḛ',
  73976. '�' => 'Ḝ',
  73977. 'ḟ' => 'Ḟ',
  73978. 'ḡ' => 'Ḡ',
  73979. 'ḣ' => 'Ḣ',
  73980. 'ḥ' => 'Ḥ',
  73981. 'ḧ' => 'Ḧ',
  73982. 'ḩ' => 'Ḩ',
  73983. 'ḫ' => 'Ḫ',
  73984. 'ḭ' => 'Ḭ',
  73985. 'ḯ' => 'Ḯ',
  73986. 'ḱ' => 'Ḱ',
  73987. 'ḳ' => 'Ḳ',
  73988. 'ḵ' => 'Ḵ',
  73989. 'ḷ' => 'Ḷ',
  73990. 'ḹ' => 'Ḹ',
  73991. 'ḻ' => 'Ḻ',
  73992. 'ḽ' => 'Ḽ',
  73993. 'ḿ' => 'Ḿ',
  73994. '�' => 'Ṁ',
  73995. 'ṃ' => 'Ṃ',
  73996. 'ṅ' => 'Ṅ',
  73997. 'ṇ' => 'Ṇ',
  73998. 'ṉ' => 'Ṉ',
  73999. 'ṋ' => 'Ṋ',
  74000. '�' => 'Ṍ',
  74001. '�' => 'Ṏ',
  74002. 'ṑ' => '�',
  74003. 'ṓ' => 'Ṓ',
  74004. 'ṕ' => 'Ṕ',
  74005. 'á¹—' => 'á¹–',
  74006. 'ṙ' => 'Ṙ',
  74007. 'ṛ' => 'Ṛ',
  74008. '�' => 'Ṝ',
  74009. 'ṟ' => 'Ṟ',
  74010. 'ṡ' => 'Ṡ',
  74011. 'á¹£' => 'á¹¢',
  74012. 'ṥ' => 'Ṥ',
  74013. 'ṧ' => 'Ṧ',
  74014. 'ṩ' => 'Ṩ',
  74015. 'ṫ' => 'Ṫ',
  74016. 'ṭ' => 'Ṭ',
  74017. 'ṯ' => 'Ṯ',
  74018. 'á¹±' => 'á¹°',
  74019. 'á¹³' => 'á¹²',
  74020. 'á¹µ' => 'á¹´',
  74021. 'á¹·' => 'á¹¶',
  74022. 'ṹ' => 'Ṹ',
  74023. 'ṻ' => 'Ṻ',
  74024. 'á¹½' => 'á¹¼',
  74025. 'ṿ' => 'Ṿ',
  74026. '�' => 'Ẁ',
  74027. 'ẃ' => 'Ẃ',
  74028. 'ẅ' => 'Ẅ',
  74029. 'ẇ' => 'Ẇ',
  74030. 'ẉ' => 'Ẉ',
  74031. 'ẋ' => 'Ẋ',
  74032. '�' => 'Ẍ',
  74033. '�' => 'Ẏ',
  74034. 'ẑ' => '�',
  74035. 'ẓ' => 'Ẓ',
  74036. 'ẕ' => 'Ẕ',
  74037. 'ẛ' => 'Ṡ',
  74038. 'ạ' => 'Ạ',
  74039. 'ả' => 'Ả',
  74040. 'ấ' => 'Ấ',
  74041. 'ầ' => 'Ầ',
  74042. 'ẩ' => 'Ẩ',
  74043. 'ẫ' => 'Ẫ',
  74044. 'ậ' => 'Ậ',
  74045. 'ắ' => 'Ắ',
  74046. 'ằ' => 'Ằ',
  74047. 'ẳ' => 'Ẳ',
  74048. 'ẵ' => 'Ẵ',
  74049. 'ặ' => 'Ặ',
  74050. 'ẹ' => 'Ẹ',
  74051. 'ẻ' => 'Ẻ',
  74052. 'ẽ' => 'Ẽ',
  74053. 'ế' => 'Ế',
  74054. '�' => 'Ề',
  74055. 'ể' => 'Ể',
  74056. 'ễ' => 'Ễ',
  74057. 'ệ' => 'Ệ',
  74058. 'ỉ' => 'Ỉ',
  74059. 'ị' => 'Ị',
  74060. '�' => 'Ọ',
  74061. '�' => 'Ỏ',
  74062. 'ố' => '�',
  74063. 'ồ' => 'Ồ',
  74064. 'ổ' => 'Ổ',
  74065. 'á»—' => 'á»–',
  74066. 'ộ' => 'Ộ',
  74067. 'ớ' => 'Ớ',
  74068. '�' => 'Ờ',
  74069. 'ở' => 'Ở',
  74070. 'ỡ' => 'Ỡ',
  74071. 'ợ' => 'Ợ',
  74072. 'ụ' => 'Ụ',
  74073. 'ủ' => 'Ủ',
  74074. 'ứ' => 'Ứ',
  74075. 'ừ' => 'Ừ',
  74076. 'ử' => 'Ử',
  74077. 'ữ' => 'Ữ',
  74078. 'á»±' => 'á»°',
  74079. 'ỳ' => 'Ỳ',
  74080. 'ỵ' => 'Ỵ',
  74081. 'á»·' => 'á»¶',
  74082. 'ỹ' => 'Ỹ',
  74083. 'ỻ' => 'Ỻ',
  74084. 'ỽ' => 'Ỽ',
  74085. 'ỿ' => 'Ỿ',
  74086. 'ἀ' => 'Ἀ',
  74087. '�' => 'Ἁ',
  74088. 'ἂ' => 'Ἂ',
  74089. 'ἃ' => 'Ἃ',
  74090. 'ἄ' => 'Ἄ',
  74091. 'ἅ' => '�',
  74092. 'ἆ' => 'Ἆ',
  74093. 'ἇ' => '�',
  74094. '�' => 'Ἐ',
  74095. 'ἑ' => 'Ἑ',
  74096. 'ἒ' => 'Ἒ',
  74097. 'ἓ' => 'Ἓ',
  74098. 'ἔ' => 'Ἔ',
  74099. 'ἕ' => '�',
  74100. 'ἠ' => 'Ἠ',
  74101. 'ἡ' => 'Ἡ',
  74102. 'ἢ' => 'Ἢ',
  74103. 'ἣ' => 'Ἣ',
  74104. 'ἤ' => 'Ἤ',
  74105. 'á¼¥' => 'á¼­',
  74106. 'ἦ' => 'Ἦ',
  74107. 'ἧ' => 'Ἧ',
  74108. 'ἰ' => 'Ἰ',
  74109. 'á¼±' => 'á¼¹',
  74110. 'ἲ' => 'Ἲ',
  74111. 'á¼³' => 'á¼»',
  74112. 'á¼´' => 'á¼¼',
  74113. 'á¼µ' => 'á¼½',
  74114. 'á¼¶' => 'á¼¾',
  74115. 'ἷ' => 'Ἷ',
  74116. 'ὀ' => 'Ὀ',
  74117. '�' => 'Ὁ',
  74118. 'ὂ' => 'Ὂ',
  74119. 'ὃ' => 'Ὃ',
  74120. 'ὄ' => 'Ὄ',
  74121. 'ὅ' => '�',
  74122. 'ὑ' => 'Ὑ',
  74123. 'ὓ' => 'Ὓ',
  74124. 'ὕ' => '�',
  74125. 'ὗ' => 'Ὗ',
  74126. 'ὠ' => 'Ὠ',
  74127. 'ὡ' => 'Ὡ',
  74128. 'ὢ' => 'Ὢ',
  74129. 'ὣ' => 'Ὣ',
  74130. 'ὤ' => 'Ὤ',
  74131. 'á½¥' => 'á½­',
  74132. 'ὦ' => 'Ὦ',
  74133. 'ὧ' => 'Ὧ',
  74134. 'ὰ' => 'Ὰ',
  74135. 'á½±' => 'á¾»',
  74136. 'ὲ' => 'Ὲ',
  74137. 'έ' => 'Έ',
  74138. 'ὴ' => 'Ὴ',
  74139. 'á½µ' => 'á¿‹',
  74140. 'ὶ' => 'Ὶ',
  74141. 'á½·' => 'á¿›',
  74142. 'ὸ' => 'Ὸ',
  74143. 'ό' => 'Ό',
  74144. 'ὺ' => 'Ὺ',
  74145. 'á½»' => 'á¿«',
  74146. 'ὼ' => 'Ὼ',
  74147. 'á½½' => 'á¿»',
  74148. 'ᾀ' => 'ἈΙ',
  74149. '�' => 'ἉΙ',
  74150. 'ᾂ' => 'ἊΙ',
  74151. 'ᾃ' => 'ἋΙ',
  74152. 'ᾄ' => 'ἌΙ',
  74153. 'ᾅ' => '�Ι',
  74154. 'ᾆ' => 'ἎΙ',
  74155. 'ᾇ' => '�Ι',
  74156. '�' => 'ἨΙ',
  74157. 'ᾑ' => 'ἩΙ',
  74158. 'ᾒ' => 'ἪΙ',
  74159. 'ᾓ' => 'ἫΙ',
  74160. 'ᾔ' => 'ἬΙ',
  74161. 'ᾕ' => 'ἭΙ',
  74162. 'ᾖ' => 'ἮΙ',
  74163. 'ᾗ' => 'ἯΙ',
  74164. 'ᾠ' => 'ὨΙ',
  74165. 'ᾡ' => 'ὩΙ',
  74166. 'ᾢ' => 'ὪΙ',
  74167. 'ᾣ' => 'ὫΙ',
  74168. 'ᾤ' => 'ὬΙ',
  74169. 'ᾥ' => 'ὭΙ',
  74170. 'ᾦ' => 'ὮΙ',
  74171. 'ᾧ' => 'ὯΙ',
  74172. 'ᾰ' => 'Ᾰ',
  74173. 'á¾±' => 'á¾¹',
  74174. 'ᾳ' => 'ΑΙ',
  74175. 'ι' => 'Ι',
  74176. 'ῃ' => 'ΗΙ',
  74177. '�' => 'Ῐ',
  74178. 'á¿‘' => 'á¿™',
  74179. 'ῠ' => 'Ῠ',
  74180. 'á¿¡' => 'á¿©',
  74181. 'ῥ' => 'Ῥ',
  74182. 'ῳ' => 'ΩΙ',
  74183. 'ⅎ' => 'Ⅎ',
  74184. 'â…°' => 'â… ',
  74185. 'â…±' => 'â…¡',
  74186. 'â…²' => 'â…¢',
  74187. 'â…³' => 'â…£',
  74188. 'â…´' => 'â…¤',
  74189. 'â…µ' => 'â…¥',
  74190. 'â…¶' => 'â…¦',
  74191. 'â…·' => 'â…§',
  74192. 'â…¸' => 'â…¨',
  74193. 'â…¹' => 'â…©',
  74194. 'â…º' => 'â…ª',
  74195. 'â…»' => 'â…«',
  74196. 'â…¼' => 'â…¬',
  74197. 'â…½' => 'â…­',
  74198. 'â…¾' => 'â…®',
  74199. 'â…¿' => 'â…¯',
  74200. 'ↄ' => 'Ↄ',
  74201. '�' => 'Ⓐ',
  74202. 'â“‘' => 'â’·',
  74203. 'â“’' => 'â’¸',
  74204. 'â““' => 'â’¹',
  74205. 'â“”' => 'â’º',
  74206. 'â“•' => 'â’»',
  74207. 'â“–' => 'â’¼',
  74208. 'â“—' => 'â’½',
  74209. 'ⓘ' => 'Ⓘ',
  74210. 'â“™' => 'â’¿',
  74211. 'ⓚ' => 'Ⓚ',
  74212. 'ⓛ' => '�',
  74213. 'ⓜ' => 'Ⓜ',
  74214. '�' => 'Ⓝ',
  74215. 'ⓞ' => 'Ⓞ',
  74216. 'ⓟ' => 'Ⓟ',
  74217. 'ⓠ' => 'Ⓠ',
  74218. 'ⓡ' => 'Ⓡ',
  74219. 'ⓢ' => 'Ⓢ',
  74220. 'ⓣ' => 'Ⓣ',
  74221. 'ⓤ' => 'Ⓤ',
  74222. 'â“¥' => 'â“‹',
  74223. 'ⓦ' => 'Ⓦ',
  74224. 'ⓧ' => '�',
  74225. 'ⓨ' => 'Ⓨ',
  74226. 'ⓩ' => '�',
  74227. 'â°°' => 'â°€',
  74228. 'â°±' => 'â°�',
  74229. 'â°²' => 'â°‚',
  74230. 'â°³' => 'â°ƒ',
  74231. 'â°´' => 'â°„',
  74232. 'â°µ' => 'â°…',
  74233. 'â°¶' => 'â°†',
  74234. 'â°·' => 'â°‡',
  74235. 'â°¸' => 'â°ˆ',
  74236. 'â°¹' => 'â°‰',
  74237. 'â°º' => 'â°Š',
  74238. 'â°»' => 'â°‹',
  74239. 'ⰼ' => 'Ⰼ',
  74240. 'â°½' => 'â°�',
  74241. 'â°¾' => 'â°Ž',
  74242. 'â°¿' => 'â°�',
  74243. 'â±€' => 'â°�',
  74244. '�' => 'Ⱁ',
  74245. 'ⱂ' => 'Ⱂ',
  74246. 'ⱃ' => 'Ⱃ',
  74247. 'ⱄ' => 'Ⱄ',
  74248. 'â±…' => 'â°•',
  74249. 'ⱆ' => 'Ⱆ',
  74250. 'ⱇ' => 'Ⱇ',
  74251. 'ⱈ' => 'Ⱈ',
  74252. 'ⱉ' => 'Ⱉ',
  74253. 'ⱊ' => 'Ⱊ',
  74254. 'ⱋ' => 'Ⱋ',
  74255. 'ⱌ' => 'Ⱌ',
  74256. '�' => '�',
  74257. 'ⱎ' => 'Ⱎ',
  74258. '�' => 'Ⱏ',
  74259. '�' => 'Ⱐ',
  74260. 'ⱑ' => 'Ⱑ',
  74261. 'â±’' => 'â°¢',
  74262. 'ⱓ' => 'Ⱓ',
  74263. 'â±”' => 'â°¤',
  74264. 'ⱕ' => 'Ⱕ',
  74265. 'â±–' => 'â°¦',
  74266. 'â±—' => 'â°§',
  74267. 'ⱘ' => 'Ⱘ',
  74268. 'â±™' => 'â°©',
  74269. 'ⱚ' => 'Ⱚ',
  74270. 'â±›' => 'â°«',
  74271. 'ⱜ' => 'Ⱜ',
  74272. '�' => 'Ⱝ',
  74273. 'ⱞ' => 'Ⱞ',
  74274. 'ⱡ' => 'Ⱡ',
  74275. 'ⱥ' => 'Ⱥ',
  74276. 'ⱦ' => 'Ⱦ',
  74277. 'ⱨ' => 'Ⱨ',
  74278. 'ⱪ' => 'Ⱪ',
  74279. 'ⱬ' => 'Ⱬ',
  74280. 'â±³' => 'â±²',
  74281. 'â±¶' => 'â±µ',
  74282. '�' => 'Ⲁ',
  74283. 'ⲃ' => 'Ⲃ',
  74284. 'ⲅ' => 'Ⲅ',
  74285. 'ⲇ' => 'Ⲇ',
  74286. 'ⲉ' => 'Ⲉ',
  74287. 'ⲋ' => 'Ⲋ',
  74288. '�' => 'Ⲍ',
  74289. '�' => 'Ⲏ',
  74290. 'ⲑ' => '�',
  74291. 'ⲓ' => 'Ⲓ',
  74292. 'ⲕ' => 'Ⲕ',
  74293. 'â²—' => 'â²–',
  74294. 'ⲙ' => 'Ⲙ',
  74295. 'ⲛ' => 'Ⲛ',
  74296. '�' => 'Ⲝ',
  74297. 'ⲟ' => 'Ⲟ',
  74298. 'ⲡ' => 'Ⲡ',
  74299. 'â²£' => 'â²¢',
  74300. 'ⲥ' => 'Ⲥ',
  74301. 'ⲧ' => 'Ⲧ',
  74302. 'ⲩ' => 'Ⲩ',
  74303. 'ⲫ' => 'Ⲫ',
  74304. 'ⲭ' => 'Ⲭ',
  74305. 'ⲯ' => 'Ⲯ',
  74306. 'â²±' => 'â²°',
  74307. 'â²³' => 'â²²',
  74308. 'â²µ' => 'â²´',
  74309. 'â²·' => 'â²¶',
  74310. 'ⲹ' => 'Ⲹ',
  74311. 'ⲻ' => 'Ⲻ',
  74312. 'â²½' => 'â²¼',
  74313. 'ⲿ' => 'Ⲿ',
  74314. '�' => 'Ⳁ',
  74315. 'ⳃ' => 'Ⳃ',
  74316. 'ⳅ' => 'Ⳅ',
  74317. 'ⳇ' => 'Ⳇ',
  74318. 'ⳉ' => 'Ⳉ',
  74319. 'ⳋ' => 'Ⳋ',
  74320. '�' => 'Ⳍ',
  74321. '�' => 'Ⳏ',
  74322. 'ⳑ' => '�',
  74323. 'ⳓ' => 'Ⳓ',
  74324. 'ⳕ' => 'Ⳕ',
  74325. 'â³—' => 'â³–',
  74326. 'ⳙ' => 'Ⳙ',
  74327. 'ⳛ' => 'Ⳛ',
  74328. '�' => 'Ⳝ',
  74329. 'ⳟ' => 'Ⳟ',
  74330. 'ⳡ' => 'Ⳡ',
  74331. 'â³£' => 'â³¢',
  74332. 'ⳬ' => 'Ⳬ',
  74333. 'â³®' => 'â³­',
  74334. 'â³³' => 'â³²',
  74335. 'â´€' => 'á‚ ',
  74336. 'â´�' => 'á‚¡',
  74337. 'â´‚' => 'á‚¢',
  74338. 'â´ƒ' => 'á‚£',
  74339. 'ⴄ' => 'Ⴄ',
  74340. 'â´…' => 'á‚¥',
  74341. 'ⴆ' => 'Ⴆ',
  74342. 'â´‡' => 'á‚§',
  74343. 'ⴈ' => 'Ⴈ',
  74344. 'â´‰' => 'á‚©',
  74345. 'ⴊ' => 'Ⴊ',
  74346. 'â´‹' => 'á‚«',
  74347. 'ⴌ' => 'Ⴌ',
  74348. 'â´�' => 'á‚­',
  74349. 'â´Ž' => 'á‚®',
  74350. '�' => 'Ⴏ',
  74351. 'â´�' => 'á‚°',
  74352. 'ⴑ' => 'Ⴑ',
  74353. 'ⴒ' => 'Ⴒ',
  74354. 'ⴓ' => 'Ⴓ',
  74355. 'â´”' => 'á‚´',
  74356. 'ⴕ' => 'Ⴕ',
  74357. 'â´–' => 'á‚¶',
  74358. 'â´—' => 'á‚·',
  74359. 'ⴘ' => 'Ⴘ',
  74360. 'ⴙ' => 'Ⴙ',
  74361. 'ⴚ' => 'Ⴚ',
  74362. 'â´›' => 'á‚»',
  74363. 'ⴜ' => 'Ⴜ',
  74364. '�' => 'Ⴝ',
  74365. 'ⴞ' => 'Ⴞ',
  74366. 'â´Ÿ' => 'á‚¿',
  74367. 'ⴠ' => 'Ⴠ',
  74368. 'ⴡ' => '�',
  74369. 'ⴢ' => 'Ⴢ',
  74370. 'ⴣ' => 'Ⴣ',
  74371. 'ⴤ' => 'Ⴤ',
  74372. 'ⴥ' => 'Ⴥ',
  74373. 'ⴧ' => 'Ⴧ',
  74374. 'ⴭ' => '�',
  74375. '�' => 'Ꙁ',
  74376. 'ꙃ' => 'Ꙃ',
  74377. 'ꙅ' => 'Ꙅ',
  74378. 'ꙇ' => 'Ꙇ',
  74379. 'ꙉ' => 'Ꙉ',
  74380. 'ꙋ' => 'Ꙋ',
  74381. '�' => 'Ꙍ',
  74382. '�' => 'Ꙏ',
  74383. 'ꙑ' => '�',
  74384. 'ꙓ' => 'Ꙓ',
  74385. 'ꙕ' => 'Ꙕ',
  74386. 'ê™—' => 'ê™–',
  74387. 'ꙙ' => 'Ꙙ',
  74388. 'ꙛ' => 'Ꙛ',
  74389. '�' => 'Ꙝ',
  74390. 'ꙟ' => 'Ꙟ',
  74391. 'ꙡ' => 'Ꙡ',
  74392. 'ꙣ' => 'Ꙣ',
  74393. 'ꙥ' => 'Ꙥ',
  74394. 'ꙧ' => 'Ꙧ',
  74395. 'ꙩ' => 'Ꙩ',
  74396. 'ꙫ' => 'Ꙫ',
  74397. 'ꙭ' => 'Ꙭ',
  74398. '�' => 'Ꚁ',
  74399. 'ꚃ' => 'Ꚃ',
  74400. 'êš…' => 'êš„',
  74401. 'ꚇ' => 'Ꚇ',
  74402. 'ꚉ' => 'Ꚉ',
  74403. 'ꚋ' => 'Ꚋ',
  74404. '�' => 'Ꚍ',
  74405. '�' => 'Ꚏ',
  74406. 'ꚑ' => '�',
  74407. 'êš“' => 'êš’',
  74408. 'êš•' => 'êš”',
  74409. 'êš—' => 'êš–',
  74410. 'ꚙ' => 'Ꚙ',
  74411. 'êš›' => 'êšš',
  74412. 'ꜣ' => 'Ꜣ',
  74413. 'ꜥ' => 'Ꜥ',
  74414. 'ꜧ' => 'Ꜧ',
  74415. 'ꜩ' => 'Ꜩ',
  74416. 'ꜫ' => 'Ꜫ',
  74417. 'ꜭ' => 'Ꜭ',
  74418. 'ꜯ' => 'Ꜯ',
  74419. 'ꜳ' => 'Ꜳ',
  74420. 'ꜵ' => 'Ꜵ',
  74421. 'ꜷ' => 'Ꜷ',
  74422. 'ꜹ' => 'Ꜹ',
  74423. 'ꜻ' => 'Ꜻ',
  74424. 'ꜽ' => 'Ꜽ',
  74425. 'ꜿ' => 'Ꜿ',
  74426. '�' => '�',
  74427. '�' => '�',
  74428. '�' => '�',
  74429. '�' => '�',
  74430. '�' => '�',
  74431. '�' => '�',
  74432. '�' => '�',
  74433. '�' => '�',
  74434. '�' => '�',
  74435. '�' => '�',
  74436. '�' => '�',
  74437. '�' => '�',
  74438. '�' => '�',
  74439. '�' => '�',
  74440. '�' => '�',
  74441. '�' => '�',
  74442. '�' => '�',
  74443. '�' => '�',
  74444. '�' => '�',
  74445. '�' => '�',
  74446. '�' => '�',
  74447. '�' => '�',
  74448. '�' => '�',
  74449. '�' => '�',
  74450. '�' => '�',
  74451. '�' => '�',
  74452. '�' => '�',
  74453. '�' => 'Ꞁ',
  74454. 'ꞃ' => 'Ꞃ',
  74455. 'êž…' => 'êž„',
  74456. 'ꞇ' => 'Ꞇ',
  74457. 'ꞌ' => 'Ꞌ',
  74458. 'ꞑ' => '�',
  74459. 'êž“' => 'êž’',
  74460. 'ꞔ' => 'Ꞔ',
  74461. 'êž—' => 'êž–',
  74462. 'ꞙ' => 'Ꞙ',
  74463. 'êž›' => 'êžš',
  74464. '�' => 'Ꞝ',
  74465. 'ꞟ' => 'Ꞟ',
  74466. 'êž¡' => 'êž ',
  74467. 'ꞣ' => 'Ꞣ',
  74468. 'ꞥ' => 'Ꞥ',
  74469. 'ꞧ' => 'Ꞧ',
  74470. 'ꞩ' => 'Ꞩ',
  74471. 'êžµ' => 'êž´',
  74472. 'êž·' => 'êž¶',
  74473. 'ꞹ' => 'Ꞹ',
  74474. 'ꞻ' => 'Ꞻ',
  74475. 'êž½' => 'êž¼',
  74476. 'êž¿' => 'êž¾',
  74477. 'ꟃ' => 'Ꟃ',
  74478. 'ꟈ' => 'Ꟈ',
  74479. 'ꟊ' => 'Ꟊ',
  74480. 'ꟶ' => 'Ꟶ',
  74481. 'ê­“' => 'êž³',
  74482. 'ꭰ' => 'Ꭰ',
  74483. 'ꭱ' => 'Ꭱ',
  74484. 'ꭲ' => 'Ꭲ',
  74485. 'ꭳ' => 'Ꭳ',
  74486. 'ꭴ' => 'Ꭴ',
  74487. 'ꭵ' => 'Ꭵ',
  74488. 'ꭶ' => 'Ꭶ',
  74489. 'ꭷ' => 'Ꭷ',
  74490. 'ꭸ' => 'Ꭸ',
  74491. 'ꭹ' => 'Ꭹ',
  74492. 'ꭺ' => 'Ꭺ',
  74493. 'ꭻ' => 'Ꭻ',
  74494. 'ꭼ' => 'Ꭼ',
  74495. 'ꭽ' => 'Ꭽ',
  74496. 'ꭾ' => 'Ꭾ',
  74497. 'ꭿ' => 'Ꭿ',
  74498. 'ꮀ' => 'Ꮀ',
  74499. '�' => 'Ꮁ',
  74500. 'ꮂ' => 'Ꮂ',
  74501. 'ꮃ' => 'Ꮃ',
  74502. 'ꮄ' => 'Ꮄ',
  74503. 'ꮅ' => 'Ꮅ',
  74504. 'ꮆ' => 'Ꮆ',
  74505. 'ꮇ' => 'Ꮇ',
  74506. 'ꮈ' => 'Ꮈ',
  74507. 'ꮉ' => 'Ꮉ',
  74508. 'ꮊ' => 'Ꮊ',
  74509. 'ꮋ' => 'Ꮋ',
  74510. 'ꮌ' => 'Ꮌ',
  74511. '�' => 'Ꮍ',
  74512. 'ꮎ' => 'Ꮎ',
  74513. '�' => 'Ꮏ',
  74514. '�' => '�',
  74515. 'ꮑ' => '�',
  74516. 'ꮒ' => '�',
  74517. 'ꮓ' => '�',
  74518. 'ꮔ' => '�',
  74519. 'ꮕ' => '�',
  74520. 'ꮖ' => '�',
  74521. 'ꮗ' => '�',
  74522. 'ꮘ' => '�',
  74523. 'ꮙ' => '�',
  74524. 'ꮚ' => '�',
  74525. 'ꮛ' => '�',
  74526. 'ꮜ' => '�',
  74527. '�' => '�',
  74528. 'ꮞ' => '�',
  74529. 'ꮟ' => '�',
  74530. 'ꮠ' => '�',
  74531. 'ꮡ' => '�',
  74532. 'ꮢ' => '�',
  74533. 'ꮣ' => '�',
  74534. 'ꮤ' => '�',
  74535. 'ꮥ' => '�',
  74536. 'ꮦ' => '�',
  74537. 'ꮧ' => '�',
  74538. 'ꮨ' => '�',
  74539. 'ꮩ' => '�',
  74540. 'ꮪ' => '�',
  74541. 'ꮫ' => '�',
  74542. 'ꮬ' => '�',
  74543. 'ꮭ' => '�',
  74544. 'ꮮ' => '�',
  74545. 'ꮯ' => '�',
  74546. 'ꮰ' => '�',
  74547. 'ꮱ' => '�',
  74548. 'ꮲ' => '�',
  74549. 'ꮳ' => '�',
  74550. 'ꮴ' => '�',
  74551. 'ꮵ' => '�',
  74552. 'ꮶ' => '�',
  74553. 'ꮷ' => '�',
  74554. 'ꮸ' => '�',
  74555. 'ꮹ' => '�',
  74556. 'ꮺ' => '�',
  74557. 'ꮻ' => '�',
  74558. 'ꮼ' => '�',
  74559. 'ꮽ' => '�',
  74560. 'ꮾ' => '�',
  74561. 'ꮿ' => '�',
  74562. '�' => 'A',
  74563. 'b' => 'B',
  74564. 'c' => 'C',
  74565. 'd' => 'D',
  74566. 'ï½…' => 'ï¼¥',
  74567. 'f' => 'F',
  74568. 'g' => 'G',
  74569. 'h' => 'H',
  74570. 'i' => 'I',
  74571. 'j' => 'J',
  74572. 'k' => 'K',
  74573. 'l' => 'L',
  74574. '�' => 'M',
  74575. 'n' => 'N',
  74576. '�' => 'O',
  74577. '�' => 'P',
  74578. 'q' => 'Q',
  74579. 'ï½’' => 'ï¼²',
  74580. 's' => 'S',
  74581. 'ï½”' => 'ï¼´',
  74582. 'u' => 'U',
  74583. 'ï½–' => 'ï¼¶',
  74584. 'ï½—' => 'ï¼·',
  74585. 'x' => 'X',
  74586. 'ï½™' => 'ï¼¹',
  74587. 'z' => 'Z',
  74588. '�' => '�',
  74589. '�' => '�',
  74590. '�' => '�',
  74591. '�' => '�',
  74592. '�' => '�',
  74593. '�' => '�',
  74594. '�' => '�',
  74595. '�' => '�',
  74596. '�' => '�',
  74597. '�' => '�',
  74598. '�' => '�',
  74599. '�' => '�',
  74600. '�' => '�',
  74601. '�' => '�',
  74602. '�' => '�',
  74603. '�' => '�',
  74604. '�' => '�',
  74605. '�' => '�',
  74606. '�' => '�',
  74607. '�' => '�',
  74608. '�' => '�',
  74609. '�' => '�',
  74610. '�' => '�',
  74611. '�' => '�',
  74612. '�' => '�',
  74613. '�' => '�',
  74614. '�' => '�',
  74615. '�' => '�',
  74616. '�' => '�',
  74617. '�' => '�',
  74618. '�' => '�',
  74619. '�' => '�',
  74620. '�' => '�',
  74621. '�' => '�',
  74622. '�' => '�',
  74623. '�' => '�',
  74624. '�' => '�',
  74625. '�' => '�',
  74626. '�' => '�',
  74627. '�' => '�',
  74628. '�' => '�',
  74629. '�' => '�',
  74630. '�' => '�',
  74631. '�' => '�',
  74632. '�' => '�',
  74633. '�' => '�',
  74634. '�' => '�',
  74635. '�' => '�',
  74636. '�' => '�',
  74637. '�' => '�',
  74638. '�' => '�',
  74639. '�' => '�',
  74640. '�' => '�',
  74641. '�' => '�',
  74642. '�' => '�',
  74643. '�' => '�',
  74644. '�' => '�',
  74645. '�' => '�',
  74646. '�' => '�',
  74647. '�' => '�',
  74648. '�' => '�',
  74649. '�' => '�',
  74650. '�' => '�',
  74651. '�' => '�',
  74652. '�' => '�',
  74653. '�' => '�',
  74654. '�' => '�',
  74655. '�' => '�',
  74656. '�' => '�',
  74657. '�' => '�',
  74658. '�' => '�',
  74659. '�' => '�',
  74660. '�' => '�',
  74661. '�' => '�',
  74662. '�' => '�',
  74663. '�' => '�',
  74664. '�' => '�',
  74665. '�' => '�',
  74666. '�' => '�',
  74667. '�' => '�',
  74668. '�' => '�',
  74669. '�' => '�',
  74670. '�' => '�',
  74671. '�' => '�',
  74672. '�' => '�',
  74673. '�' => '�',
  74674. '�' => '�',
  74675. '�' => '�',
  74676. '�' => '�',
  74677. '�' => '�',
  74678. '�' => '�',
  74679. '�' => '�',
  74680. '�' => '�',
  74681. '�' => '�',
  74682. '�' => '�',
  74683. '�' => '�',
  74684. '�' => '�',
  74685. '�' => '�',
  74686. '�' => '�',
  74687. '�' => '�',
  74688. '�' => '�',
  74689. '�' => '�',
  74690. '�' => '�',
  74691. '�' => '�',
  74692. '�' => '�',
  74693. '�' => '�',
  74694. '�' => '�',
  74695. '�' => '�',
  74696. '�' => '�',
  74697. '�' => '�',
  74698. '�' => '�',
  74699. '�' => '�',
  74700. '�' => '�',
  74701. '�' => '�',
  74702. '�' => '�',
  74703. '�' => '�',
  74704. '�' => '�',
  74705. '�' => '�',
  74706. '�' => '�',
  74707. '�' => '�',
  74708. '�' => '�',
  74709. '�' => '�',
  74710. '�' => '�',
  74711. '�' => '�',
  74712. '�' => '�',
  74713. '�' => '�',
  74714. '�' => '�',
  74715. 'ð‘£€' => 'ð‘¢ ',
  74716. '�' => '𑢡',
  74717. '𑣂' => '𑢢',
  74718. '𑣃' => '𑢣',
  74719. '𑣄' => '𑢤',
  74720. 'ð‘£…' => 'ð‘¢¥',
  74721. '𑣆' => '𑢦',
  74722. '𑣇' => '𑢧',
  74723. '𑣈' => '𑢨',
  74724. '𑣉' => '𑢩',
  74725. '𑣊' => '𑢪',
  74726. '𑣋' => '𑢫',
  74727. '𑣌' => '𑢬',
  74728. '�' => '𑢭',
  74729. '𑣎' => '𑢮',
  74730. '�' => '𑢯',
  74731. '�' => '𑢰',
  74732. '𑣑' => '𑢱',
  74733. 'ð‘£’' => 'ð‘¢²',
  74734. '𑣓' => '𑢳',
  74735. 'ð‘£”' => 'ð‘¢´',
  74736. '𑣕' => '𑢵',
  74737. 'ð‘£–' => 'ð‘¢¶',
  74738. 'ð‘£—' => 'ð‘¢·',
  74739. '𑣘' => '𑢸',
  74740. 'ð‘£™' => 'ð‘¢¹',
  74741. '𑣚' => '𑢺',
  74742. 'ð‘£›' => 'ð‘¢»',
  74743. '𑣜' => '𑢼',
  74744. '�' => '𑢽',
  74745. '𑣞' => '𑢾',
  74746. '𑣟' => '𑢿',
  74747. 'ð–¹ ' => 'ð–¹€',
  74748. '𖹡' => '�',
  74749. '𖹢' => '𖹂',
  74750. '𖹣' => '𖹃',
  74751. '𖹤' => '𖹄',
  74752. 'ð–¹¥' => 'ð–¹…',
  74753. '𖹦' => '𖹆',
  74754. '𖹧' => '𖹇',
  74755. '𖹨' => '𖹈',
  74756. '𖹩' => '𖹉',
  74757. '𖹪' => '𖹊',
  74758. '𖹫' => '𖹋',
  74759. '𖹬' => '𖹌',
  74760. '𖹭' => '�',
  74761. '𖹮' => '𖹎',
  74762. '𖹯' => '�',
  74763. '𖹰' => '�',
  74764. '𖹱' => '𖹑',
  74765. 'ð–¹²' => 'ð–¹’',
  74766. '𖹳' => '𖹓',
  74767. 'ð–¹´' => 'ð–¹”',
  74768. '𖹵' => '𖹕',
  74769. 'ð–¹¶' => 'ð–¹–',
  74770. 'ð–¹·' => 'ð–¹—',
  74771. '𖹸' => '𖹘',
  74772. 'ð–¹¹' => 'ð–¹™',
  74773. '𖹺' => '𖹚',
  74774. 'ð–¹»' => 'ð–¹›',
  74775. '𖹼' => '𖹜',
  74776. '𖹽' => '�',
  74777. '𖹾' => '𖹞',
  74778. '𖹿' => '𖹟',
  74779. '𞤢' => '𞤀',
  74780. '𞤣' => '�',
  74781. '𞤤' => '𞤂',
  74782. '𞤥' => '𞤃',
  74783. '𞤦' => '𞤄',
  74784. '𞤧' => '𞤅',
  74785. '𞤨' => '𞤆',
  74786. '𞤩' => '𞤇',
  74787. '𞤪' => '𞤈',
  74788. '𞤫' => '𞤉',
  74789. '𞤬' => '𞤊',
  74790. '𞤭' => '𞤋',
  74791. '𞤮' => '𞤌',
  74792. '𞤯' => '�',
  74793. '𞤰' => '𞤎',
  74794. '𞤱' => '�',
  74795. '𞤲' => '�',
  74796. '𞤳' => '𞤑',
  74797. '𞤴' => '𞤒',
  74798. '𞤵' => '𞤓',
  74799. '𞤶' => '𞤔',
  74800. '𞤷' => '𞤕',
  74801. '𞤸' => '𞤖',
  74802. '𞤹' => '𞤗',
  74803. '𞤺' => '𞤘',
  74804. '𞤻' => '𞤙',
  74805. '𞤼' => '𞤚',
  74806. '𞤽' => '𞤛',
  74807. '𞤾' => '𞤜',
  74808. '𞤿' => '�',
  74809. '𞥀' => '𞤞',
  74810. '�' => '𞤟',
  74811. '𞥂' => '𞤠',
  74812. '𞥃' => '𞤡',
  74813. 'ß' => 'SS',
  74814. 'ff' => 'FF',
  74815. '�' => 'FI',
  74816. 'fl' => 'FL',
  74817. 'ffi' => 'FFI',
  74818. 'ffl' => 'FFL',
  74819. 'ſt' => 'ST',
  74820. 'st' => 'ST',
  74821. 'Ö‡' => 'ÔµÕ’',
  74822. 'ﬓ' => 'ՄՆ',
  74823. 'ﬔ' => 'ՄԵ',
  74824. 'ﬕ' => 'ՄԻ',
  74825. 'ﬖ' => 'ՎՆ',
  74826. 'ﬗ' => 'ՄԽ',
  74827. 'ʼn' => 'ʼN',
  74828. '�' => 'Ϊ�',
  74829. 'ΰ' => 'Ϋ�',
  74830. 'ǰ' => 'J̌',
  74831. 'ẖ' => 'H̱',
  74832. 'ẗ' => 'T̈',
  74833. 'ẘ' => 'W̊',
  74834. 'ẙ' => 'Y̊',
  74835. 'ẚ' => 'Aʾ',
  74836. '�' => 'Υ̓',
  74837. 'ὒ' => 'Υ̓̀',
  74838. 'ὔ' => 'Υ̓�',
  74839. 'ὖ' => 'Υ̓͂',
  74840. 'ᾶ' => 'Α͂',
  74841. 'ῆ' => 'Η͂',
  74842. 'ῒ' => 'Ϊ̀',
  74843. 'ΐ' => 'Ϊ�',
  74844. 'ῖ' => 'Ι͂',
  74845. 'ῗ' => 'Ϊ͂',
  74846. 'ῢ' => 'Ϋ̀',
  74847. 'ΰ' => 'Ϋ�',
  74848. 'ῤ' => 'Ρ̓',
  74849. 'ῦ' => 'Υ͂',
  74850. 'ῧ' => 'Ϋ͂',
  74851. 'ῶ' => 'Ω͂',
  74852. 'ᾈ' => 'ἈΙ',
  74853. 'ᾉ' => 'ἉΙ',
  74854. 'ᾊ' => 'ἊΙ',
  74855. 'ᾋ' => 'ἋΙ',
  74856. 'ᾌ' => 'ἌΙ',
  74857. '�' => '�Ι',
  74858. 'ᾎ' => 'ἎΙ',
  74859. '�' => '�Ι',
  74860. 'ᾘ' => 'ἨΙ',
  74861. 'ᾙ' => 'ἩΙ',
  74862. 'ᾚ' => 'ἪΙ',
  74863. 'ᾛ' => 'ἫΙ',
  74864. 'ᾜ' => 'ἬΙ',
  74865. '�' => 'ἭΙ',
  74866. 'ᾞ' => 'ἮΙ',
  74867. 'ᾟ' => 'ἯΙ',
  74868. 'ᾨ' => 'ὨΙ',
  74869. 'ᾩ' => 'ὩΙ',
  74870. 'ᾪ' => 'ὪΙ',
  74871. 'ᾫ' => 'ὫΙ',
  74872. 'ᾬ' => 'ὬΙ',
  74873. 'ᾭ' => 'ὭΙ',
  74874. 'ᾮ' => 'ὮΙ',
  74875. 'ᾯ' => 'ὯΙ',
  74876. 'ᾼ' => 'ΑΙ',
  74877. 'ῌ' => 'ΗΙ',
  74878. 'ῼ' => 'ΩΙ',
  74879. 'ᾲ' => 'ᾺΙ',
  74880. 'ᾴ' => 'ΆΙ',
  74881. 'ῂ' => 'ῊΙ',
  74882. 'ῄ' => 'ΉΙ',
  74883. 'ῲ' => 'ῺΙ',
  74884. 'ῴ' => '�Ι',
  74885. 'ᾷ' => 'Α͂Ι',
  74886. 'ῇ' => 'Η͂Ι',
  74887. 'ῷ' => 'Ω͂Ι',
  74888. );
  74889. <?php
  74890. use Symfony\Polyfill\Mbstring as p;
  74891. if (\PHP_VERSION_ID >= 80000) {
  74892. return require __DIR__.'/bootstrap80.php';
  74893. }
  74894. if (!function_exists('mb_convert_encoding')) {
  74895. function mb_convert_encoding($string, $to_encoding, $from_encoding = null) { return p\Mbstring::mb_convert_encoding($string, $to_encoding, $from_encoding); }
  74896. }
  74897. if (!function_exists('mb_decode_mimeheader')) {
  74898. function mb_decode_mimeheader($string) { return p\Mbstring::mb_decode_mimeheader($string); }
  74899. }
  74900. if (!function_exists('mb_encode_mimeheader')) {
  74901. function mb_encode_mimeheader($string, $charset = null, $transfer_encoding = null, $newline = "\r\n", $indent = 0) { return p\Mbstring::mb_encode_mimeheader($string, $charset, $transfer_encoding, $newline, $indent); }
  74902. }
  74903. if (!function_exists('mb_decode_numericentity')) {
  74904. function mb_decode_numericentity($string, $map, $encoding = null) { return p\Mbstring::mb_decode_numericentity($string, $map, $encoding); }
  74905. }
  74906. if (!function_exists('mb_encode_numericentity')) {
  74907. function mb_encode_numericentity($string, $map, $encoding = null, $hex = false) { return p\Mbstring::mb_encode_numericentity($string, $map, $encoding, $hex); }
  74908. }
  74909. if (!function_exists('mb_convert_case')) {
  74910. function mb_convert_case($string, $mode, $encoding = null) { return p\Mbstring::mb_convert_case($string, $mode, $encoding); }
  74911. }
  74912. if (!function_exists('mb_internal_encoding')) {
  74913. function mb_internal_encoding($encoding = null) { return p\Mbstring::mb_internal_encoding($encoding); }
  74914. }
  74915. if (!function_exists('mb_language')) {
  74916. function mb_language($language = null) { return p\Mbstring::mb_language($language); }
  74917. }
  74918. if (!function_exists('mb_list_encodings')) {
  74919. function mb_list_encodings() { return p\Mbstring::mb_list_encodings(); }
  74920. }
  74921. if (!function_exists('mb_encoding_aliases')) {
  74922. function mb_encoding_aliases($encoding) { return p\Mbstring::mb_encoding_aliases($encoding); }
  74923. }
  74924. if (!function_exists('mb_check_encoding')) {
  74925. function mb_check_encoding($value = null, $encoding = null) { return p\Mbstring::mb_check_encoding($value, $encoding); }
  74926. }
  74927. if (!function_exists('mb_detect_encoding')) {
  74928. function mb_detect_encoding($string, $encodings = null, $strict = false) { return p\Mbstring::mb_detect_encoding($string, $encodings, $strict); }
  74929. }
  74930. if (!function_exists('mb_detect_order')) {
  74931. function mb_detect_order($encoding = null) { return p\Mbstring::mb_detect_order($encoding); }
  74932. }
  74933. if (!function_exists('mb_parse_str')) {
  74934. function mb_parse_str($string, &$result = []) { parse_str($string, $result); return (bool) $result; }
  74935. }
  74936. if (!function_exists('mb_strlen')) {
  74937. function mb_strlen($string, $encoding = null) { return p\Mbstring::mb_strlen($string, $encoding); }
  74938. }
  74939. if (!function_exists('mb_strpos')) {
  74940. function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strpos($haystack, $needle, $offset, $encoding); }
  74941. }
  74942. if (!function_exists('mb_strtolower')) {
  74943. function mb_strtolower($string, $encoding = null) { return p\Mbstring::mb_strtolower($string, $encoding); }
  74944. }
  74945. if (!function_exists('mb_strtoupper')) {
  74946. function mb_strtoupper($string, $encoding = null) { return p\Mbstring::mb_strtoupper($string, $encoding); }
  74947. }
  74948. if (!function_exists('mb_substitute_character')) {
  74949. function mb_substitute_character($substitute_character = null) { return p\Mbstring::mb_substitute_character($substitute_character); }
  74950. }
  74951. if (!function_exists('mb_substr')) {
  74952. function mb_substr($string, $start, $length = 2147483647, $encoding = null) { return p\Mbstring::mb_substr($string, $start, $length, $encoding); }
  74953. }
  74954. if (!function_exists('mb_stripos')) {
  74955. function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_stripos($haystack, $needle, $offset, $encoding); }
  74956. }
  74957. if (!function_exists('mb_stristr')) {
  74958. function mb_stristr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_stristr($haystack, $needle, $before_needle, $encoding); }
  74959. }
  74960. if (!function_exists('mb_strrchr')) {
  74961. function mb_strrchr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strrchr($haystack, $needle, $before_needle, $encoding); }
  74962. }
  74963. if (!function_exists('mb_strrichr')) {
  74964. function mb_strrichr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strrichr($haystack, $needle, $before_needle, $encoding); }
  74965. }
  74966. if (!function_exists('mb_strripos')) {
  74967. function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strripos($haystack, $needle, $offset, $encoding); }
  74968. }
  74969. if (!function_exists('mb_strrpos')) {
  74970. function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strrpos($haystack, $needle, $offset, $encoding); }
  74971. }
  74972. if (!function_exists('mb_strstr')) {
  74973. function mb_strstr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strstr($haystack, $needle, $before_needle, $encoding); }
  74974. }
  74975. if (!function_exists('mb_get_info')) {
  74976. function mb_get_info($type = 'all') { return p\Mbstring::mb_get_info($type); }
  74977. }
  74978. if (!function_exists('mb_http_output')) {
  74979. function mb_http_output($encoding = null) { return p\Mbstring::mb_http_output($encoding); }
  74980. }
  74981. if (!function_exists('mb_strwidth')) {
  74982. function mb_strwidth($string, $encoding = null) { return p\Mbstring::mb_strwidth($string, $encoding); }
  74983. }
  74984. if (!function_exists('mb_substr_count')) {
  74985. function mb_substr_count($haystack, $needle, $encoding = null) { return p\Mbstring::mb_substr_count($haystack, $needle, $encoding); }
  74986. }
  74987. if (!function_exists('mb_output_handler')) {
  74988. function mb_output_handler($string, $status) { return p\Mbstring::mb_output_handler($string, $status); }
  74989. }
  74990. if (!function_exists('mb_http_input')) {
  74991. function mb_http_input($type = null) { return p\Mbstring::mb_http_input($type); }
  74992. }
  74993. if (!function_exists('mb_convert_variables')) {
  74994. function mb_convert_variables($to_encoding, $from_encoding, &...$vars) { return p\Mbstring::mb_convert_variables($to_encoding, $from_encoding, ...$vars); }
  74995. }
  74996. if (!function_exists('mb_ord')) {
  74997. function mb_ord($string, $encoding = null) { return p\Mbstring::mb_ord($string, $encoding); }
  74998. }
  74999. if (!function_exists('mb_chr')) {
  75000. function mb_chr($codepoint, $encoding = null) { return p\Mbstring::mb_chr($codepoint, $encoding); }
  75001. }
  75002. if (!function_exists('mb_scrub')) {
  75003. function mb_scrub($string, $encoding = null) { $encoding = null === $encoding ? mb_internal_encoding() : $encoding; return mb_convert_encoding($string, $encoding, $encoding); }
  75004. }
  75005. if (!function_exists('mb_str_split')) {
  75006. function mb_str_split($string, $length = 1, $encoding = null) { return p\Mbstring::mb_str_split($string, $length, $encoding); }
  75007. }
  75008. if (extension_loaded('mbstring')) {
  75009. return;
  75010. }
  75011. if (!defined('MB_CASE_UPPER')) {
  75012. define('MB_CASE_UPPER', 0);
  75013. }
  75014. if (!defined('MB_CASE_LOWER')) {
  75015. define('MB_CASE_LOWER', 1);
  75016. }
  75017. if (!defined('MB_CASE_TITLE')) {
  75018. define('MB_CASE_TITLE', 2);
  75019. }
  75020. <?php
  75021. use Symfony\Polyfill\Mbstring as p;
  75022. if (!function_exists('mb_convert_encoding')) {
  75023. function mb_convert_encoding(array|string|null $string, ?string $to_encoding, array|string|null $from_encoding = null): array|string|false { return p\Mbstring::mb_convert_encoding($string ?? '', (string) $to_encoding, $from_encoding); }
  75024. }
  75025. if (!function_exists('mb_decode_mimeheader')) {
  75026. function mb_decode_mimeheader(?string $string): string { return p\Mbstring::mb_decode_mimeheader((string) $string); }
  75027. }
  75028. if (!function_exists('mb_encode_mimeheader')) {
  75029. function mb_encode_mimeheader(?string $string, ?string $charset = null, ?string $transfer_encoding = null, ?string $newline = "\r\n", ?int $indent = 0): string { return p\Mbstring::mb_encode_mimeheader((string) $string, $charset, $transfer_encoding, (string) $newline, (int) $indent); }
  75030. }
  75031. if (!function_exists('mb_decode_numericentity')) {
  75032. function mb_decode_numericentity(?string $string, array $map, ?string $encoding = null): string { return p\Mbstring::mb_decode_numericentity((string) $string, $map, $encoding); }
  75033. }
  75034. if (!function_exists('mb_encode_numericentity')) {
  75035. function mb_encode_numericentity(?string $string, array $map, ?string $encoding = null, ?bool $hex = false): string { return p\Mbstring::mb_encode_numericentity((string) $string, $map, $encoding, (bool) $hex); }
  75036. }
  75037. if (!function_exists('mb_convert_case')) {
  75038. function mb_convert_case(?string $string, ?int $mode, ?string $encoding = null): string { return p\Mbstring::mb_convert_case((string) $string, (int) $mode, $encoding); }
  75039. }
  75040. if (!function_exists('mb_internal_encoding')) {
  75041. function mb_internal_encoding(?string $encoding = null): string|bool { return p\Mbstring::mb_internal_encoding($encoding); }
  75042. }
  75043. if (!function_exists('mb_language')) {
  75044. function mb_language(?string $language = null): string|bool { return p\Mbstring::mb_language($language); }
  75045. }
  75046. if (!function_exists('mb_list_encodings')) {
  75047. function mb_list_encodings(): array { return p\Mbstring::mb_list_encodings(); }
  75048. }
  75049. if (!function_exists('mb_encoding_aliases')) {
  75050. function mb_encoding_aliases(?string $encoding): array { return p\Mbstring::mb_encoding_aliases((string) $encoding); }
  75051. }
  75052. if (!function_exists('mb_check_encoding')) {
  75053. function mb_check_encoding(array|string|null $value = null, ?string $encoding = null): bool { return p\Mbstring::mb_check_encoding($value, $encoding); }
  75054. }
  75055. if (!function_exists('mb_detect_encoding')) {
  75056. function mb_detect_encoding(?string $string, array|string|null $encodings = null, ?bool $strict = false): string|false { return p\Mbstring::mb_detect_encoding((string) $string, $encodings, (bool) $strict); }
  75057. }
  75058. if (!function_exists('mb_detect_order')) {
  75059. function mb_detect_order(array|string|null $encoding = null): array|bool { return p\Mbstring::mb_detect_order($encoding); }
  75060. }
  75061. if (!function_exists('mb_parse_str')) {
  75062. function mb_parse_str(?string $string, &$result = []): bool { parse_str((string) $string, $result); return (bool) $result; }
  75063. }
  75064. if (!function_exists('mb_strlen')) {
  75065. function mb_strlen(?string $string, ?string $encoding = null): int { return p\Mbstring::mb_strlen((string) $string, $encoding); }
  75066. }
  75067. if (!function_exists('mb_strpos')) {
  75068. function mb_strpos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null): int|false { return p\Mbstring::mb_strpos((string) $haystack, (string) $needle, (int) $offset, $encoding); }
  75069. }
  75070. if (!function_exists('mb_strtolower')) {
  75071. function mb_strtolower(?string $string, ?string $encoding = null): string { return p\Mbstring::mb_strtolower((string) $string, $encoding); }
  75072. }
  75073. if (!function_exists('mb_strtoupper')) {
  75074. function mb_strtoupper(?string $string, ?string $encoding = null): string { return p\Mbstring::mb_strtoupper((string) $string, $encoding); }
  75075. }
  75076. if (!function_exists('mb_substitute_character')) {
  75077. function mb_substitute_character(string|int|null $substitute_character = null): string|int|bool { return p\Mbstring::mb_substitute_character($substitute_character); }
  75078. }
  75079. if (!function_exists('mb_substr')) {
  75080. function mb_substr(?string $string, ?int $start, ?int $length = null, ?string $encoding = null): string { return p\Mbstring::mb_substr((string) $string, (int) $start, $length, $encoding); }
  75081. }
  75082. if (!function_exists('mb_stripos')) {
  75083. function mb_stripos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null): int|false { return p\Mbstring::mb_stripos((string) $haystack, (string) $needle, (int) $offset, $encoding); }
  75084. }
  75085. if (!function_exists('mb_stristr')) {
  75086. function mb_stristr(?string $haystack, ?string $needle, ?bool $before_needle = false, ?string $encoding = null): string|false { return p\Mbstring::mb_stristr((string) $haystack, (string) $needle, (bool) $before_needle, $encoding); }
  75087. }
  75088. if (!function_exists('mb_strrchr')) {
  75089. function mb_strrchr(?string $haystack, ?string $needle, ?bool $before_needle = false, ?string $encoding = null): string|false { return p\Mbstring::mb_strrchr((string) $haystack, (string) $needle, (bool) $before_needle, $encoding); }
  75090. }
  75091. if (!function_exists('mb_strrichr')) {
  75092. function mb_strrichr(?string $haystack, ?string $needle, ?bool $before_needle = false, ?string $encoding = null): string|false { return p\Mbstring::mb_strrichr((string) $haystack, (string) $needle, (bool) $before_needle, $encoding); }
  75093. }
  75094. if (!function_exists('mb_strripos')) {
  75095. function mb_strripos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null): int|false { return p\Mbstring::mb_strripos((string) $haystack, (string) $needle, (int) $offset, $encoding); }
  75096. }
  75097. if (!function_exists('mb_strrpos')) {
  75098. function mb_strrpos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null): int|false { return p\Mbstring::mb_strrpos((string) $haystack, (string) $needle, (int) $offset, $encoding); }
  75099. }
  75100. if (!function_exists('mb_strstr')) {
  75101. function mb_strstr(?string $haystack, ?string $needle, ?bool $before_needle = false, ?string $encoding = null): string|false { return p\Mbstring::mb_strstr((string) $haystack, (string) $needle, (bool) $before_needle, $encoding); }
  75102. }
  75103. if (!function_exists('mb_get_info')) {
  75104. function mb_get_info(?string $type = 'all'): array|string|int|false { return p\Mbstring::mb_get_info((string) $type); }
  75105. }
  75106. if (!function_exists('mb_http_output')) {
  75107. function mb_http_output(?string $encoding = null): string|bool { return p\Mbstring::mb_http_output($encoding); }
  75108. }
  75109. if (!function_exists('mb_strwidth')) {
  75110. function mb_strwidth(?string $string, ?string $encoding = null): int { return p\Mbstring::mb_strwidth((string) $string, $encoding); }
  75111. }
  75112. if (!function_exists('mb_substr_count')) {
  75113. function mb_substr_count(?string $haystack, ?string $needle, ?string $encoding = null): int { return p\Mbstring::mb_substr_count((string) $haystack, (string) $needle, $encoding); }
  75114. }
  75115. if (!function_exists('mb_output_handler')) {
  75116. function mb_output_handler(?string $string, ?int $status): string { return p\Mbstring::mb_output_handler((string) $string, (int) $status); }
  75117. }
  75118. if (!function_exists('mb_http_input')) {
  75119. function mb_http_input(?string $type = null): array|string|false { return p\Mbstring::mb_http_input($type); }
  75120. }
  75121. if (!function_exists('mb_convert_variables')) {
  75122. function mb_convert_variables(?string $to_encoding, array|string|null $from_encoding, mixed &$var, mixed &...$vars): string|false { return p\Mbstring::mb_convert_variables((string) $to_encoding, $from_encoding ?? '', $var, ...$vars); }
  75123. }
  75124. if (!function_exists('mb_ord')) {
  75125. function mb_ord(?string $string, ?string $encoding = null): int|false { return p\Mbstring::mb_ord((string) $string, $encoding); }
  75126. }
  75127. if (!function_exists('mb_chr')) {
  75128. function mb_chr(?int $codepoint, ?string $encoding = null): string|false { return p\Mbstring::mb_chr((int) $codepoint, $encoding); }
  75129. }
  75130. if (!function_exists('mb_scrub')) {
  75131. function mb_scrub(?string $string, ?string $encoding = null): string { $encoding ??= mb_internal_encoding(); return mb_convert_encoding((string) $string, $encoding, $encoding); }
  75132. }
  75133. if (!function_exists('mb_str_split')) {
  75134. function mb_str_split(?string $string, ?int $length = 1, ?string $encoding = null): array { return p\Mbstring::mb_str_split((string) $string, (int) $length, $encoding); }
  75135. }
  75136. if (extension_loaded('mbstring')) {
  75137. return;
  75138. }
  75139. if (!defined('MB_CASE_UPPER')) {
  75140. define('MB_CASE_UPPER', 0);
  75141. }
  75142. if (!defined('MB_CASE_LOWER')) {
  75143. define('MB_CASE_LOWER', 1);
  75144. }
  75145. if (!defined('MB_CASE_TITLE')) {
  75146. define('MB_CASE_TITLE', 2);
  75147. }
  75148. Copyright (c) 2018-2019 Fabien Potencier
  75149. Permission is hereby granted, free of charge, to any person obtaining a copy
  75150. of this software and associated documentation files (the "Software"), to deal
  75151. in the Software without restriction, including without limitation the rights
  75152. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  75153. copies of the Software, and to permit persons to whom the Software is furnished
  75154. to do so, subject to the following conditions:
  75155. The above copyright notice and this permission notice shall be included in all
  75156. copies or substantial portions of the Software.
  75157. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  75158. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  75159. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  75160. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  75161. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  75162. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  75163. THE SOFTWARE.
  75164. <?php
  75165. namespace Symfony\Polyfill\Php73;
  75166. final class Php73
  75167. {
  75168. public static $startAt = 1533462603;
  75169. public static function hrtime($asNum = false)
  75170. {
  75171. $ns = microtime(false);
  75172. $s = substr($ns, 11) - self::$startAt;
  75173. $ns = 1E9 * (float) $ns;
  75174. if ($asNum) {
  75175. $ns += $s * 1E9;
  75176. return \PHP_INT_SIZE === 4 ? $ns : (int) $ns;
  75177. }
  75178. return [$s, (int) $ns];
  75179. }
  75180. }
  75181. <?php
  75182. if (\PHP_VERSION_ID < 70300) {
  75183. class JsonException extends Exception
  75184. {
  75185. }
  75186. }
  75187. <?php
  75188. use Symfony\Polyfill\Php73 as p;
  75189. if (\PHP_VERSION_ID >= 70300) {
  75190. return;
  75191. }
  75192. if (!function_exists('is_countable')) {
  75193. function is_countable($value) { return is_array($value) || $value instanceof Countable || $value instanceof ResourceBundle || $value instanceof SimpleXmlElement; }
  75194. }
  75195. if (!function_exists('hrtime')) {
  75196. require_once __DIR__.'/Php73.php';
  75197. p\Php73::$startAt = (int) microtime(true);
  75198. function hrtime($as_number = false) { return p\Php73::hrtime($as_number); }
  75199. }
  75200. if (!function_exists('array_key_first')) {
  75201. function array_key_first(array $array) { foreach ($array as $key => $value) { return $key; } }
  75202. }
  75203. if (!function_exists('array_key_last')) {
  75204. function array_key_last(array $array) { return key(array_slice($array, -1, 1, true)); }
  75205. }
  75206. Copyright (c) 2020 Fabien Potencier
  75207. Permission is hereby granted, free of charge, to any person obtaining a copy
  75208. of this software and associated documentation files (the "Software"), to deal
  75209. in the Software without restriction, including without limitation the rights
  75210. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  75211. copies of the Software, and to permit persons to whom the Software is furnished
  75212. to do so, subject to the following conditions:
  75213. The above copyright notice and this permission notice shall be included in all
  75214. copies or substantial portions of the Software.
  75215. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  75216. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  75217. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  75218. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  75219. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  75220. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  75221. THE SOFTWARE.
  75222. <?php
  75223. namespace Symfony\Polyfill\Php80;
  75224. final class Php80
  75225. {
  75226. public static function fdiv(float $dividend, float $divisor): float
  75227. {
  75228. return @($dividend / $divisor);
  75229. }
  75230. public static function get_debug_type($value): string
  75231. {
  75232. switch (true) {
  75233. case null === $value: return 'null';
  75234. case \is_bool($value): return 'bool';
  75235. case \is_string($value): return 'string';
  75236. case \is_array($value): return 'array';
  75237. case \is_int($value): return 'int';
  75238. case \is_float($value): return 'float';
  75239. case \is_object($value): break;
  75240. case $value instanceof \__PHP_Incomplete_Class: return '__PHP_Incomplete_Class';
  75241. default:
  75242. if (null === $type = @get_resource_type($value)) {
  75243. return 'unknown';
  75244. }
  75245. if ('Unknown' === $type) {
  75246. $type = 'closed';
  75247. }
  75248. return "resource ($type)";
  75249. }
  75250. $class = \get_class($value);
  75251. if (false === strpos($class, '@')) {
  75252. return $class;
  75253. }
  75254. return (get_parent_class($class) ?: key(class_implements($class)) ?: 'class').'@anonymous';
  75255. }
  75256. public static function get_resource_id($res): int
  75257. {
  75258. if (!\is_resource($res) && null === @get_resource_type($res)) {
  75259. throw new \TypeError(sprintf('Argument 1 passed to get_resource_id() must be of the type resource, %s given', get_debug_type($res)));
  75260. }
  75261. return (int) $res;
  75262. }
  75263. public static function preg_last_error_msg(): string
  75264. {
  75265. switch (preg_last_error()) {
  75266. case \PREG_INTERNAL_ERROR:
  75267. return 'Internal error';
  75268. case \PREG_BAD_UTF8_ERROR:
  75269. return 'Malformed UTF-8 characters, possibly incorrectly encoded';
  75270. case \PREG_BAD_UTF8_OFFSET_ERROR:
  75271. return 'The offset did not correspond to the beginning of a valid UTF-8 code point';
  75272. case \PREG_BACKTRACK_LIMIT_ERROR:
  75273. return 'Backtrack limit exhausted';
  75274. case \PREG_RECURSION_LIMIT_ERROR:
  75275. return 'Recursion limit exhausted';
  75276. case \PREG_JIT_STACKLIMIT_ERROR:
  75277. return 'JIT stack limit exhausted';
  75278. case \PREG_NO_ERROR:
  75279. return 'No error';
  75280. default:
  75281. return 'Unknown error';
  75282. }
  75283. }
  75284. public static function str_contains(string $haystack, string $needle): bool
  75285. {
  75286. return '' === $needle || false !== strpos($haystack, $needle);
  75287. }
  75288. public static function str_starts_with(string $haystack, string $needle): bool
  75289. {
  75290. return 0 === strncmp($haystack, $needle, \strlen($needle));
  75291. }
  75292. public static function str_ends_with(string $haystack, string $needle): bool
  75293. {
  75294. if ('' === $needle || $needle === $haystack) {
  75295. return true;
  75296. }
  75297. if ('' === $haystack) {
  75298. return false;
  75299. }
  75300. $needleLength = \strlen($needle);
  75301. return $needleLength <= \strlen($haystack) && 0 === substr_compare($haystack, $needle, -$needleLength);
  75302. }
  75303. }
  75304. <?php
  75305. namespace Symfony\Polyfill\Php80;
  75306. class PhpToken implements \Stringable
  75307. {
  75308. public $id;
  75309. public $text;
  75310. public $line;
  75311. public $pos;
  75312. public function __construct(int $id, string $text, int $line = -1, int $position = -1)
  75313. {
  75314. $this->id = $id;
  75315. $this->text = $text;
  75316. $this->line = $line;
  75317. $this->pos = $position;
  75318. }
  75319. public function getTokenName(): ?string
  75320. {
  75321. if ('UNKNOWN' === $name = token_name($this->id)) {
  75322. $name = \strlen($this->text) > 1 || \ord($this->text) < 32 ? null : $this->text;
  75323. }
  75324. return $name;
  75325. }
  75326. public function is($kind): bool
  75327. {
  75328. foreach ((array) $kind as $value) {
  75329. if (\in_array($value, [$this->id, $this->text], true)) {
  75330. return true;
  75331. }
  75332. }
  75333. return false;
  75334. }
  75335. public function isIgnorable(): bool
  75336. {
  75337. return \in_array($this->id, [\T_WHITESPACE, \T_COMMENT, \T_DOC_COMMENT, \T_OPEN_TAG], true);
  75338. }
  75339. public function __toString(): string
  75340. {
  75341. return (string) $this->text;
  75342. }
  75343. public static function tokenize(string $code, int $flags = 0): array
  75344. {
  75345. $line = 1;
  75346. $position = 0;
  75347. $tokens = token_get_all($code, $flags);
  75348. foreach ($tokens as $index => $token) {
  75349. if (\is_string($token)) {
  75350. $id = \ord($token);
  75351. $text = $token;
  75352. } else {
  75353. [$id, $text, $line] = $token;
  75354. }
  75355. $tokens[$index] = new static($id, $text, $line, $position);
  75356. $position += \strlen($text);
  75357. }
  75358. return $tokens;
  75359. }
  75360. }
  75361. <?php
  75362. #[Attribute(Attribute::TARGET_CLASS)]
  75363. final class Attribute
  75364. {
  75365. public const TARGET_CLASS = 1;
  75366. public const TARGET_FUNCTION = 2;
  75367. public const TARGET_METHOD = 4;
  75368. public const TARGET_PROPERTY = 8;
  75369. public const TARGET_CLASS_CONSTANT = 16;
  75370. public const TARGET_PARAMETER = 32;
  75371. public const TARGET_ALL = 63;
  75372. public const IS_REPEATABLE = 64;
  75373. public $flags;
  75374. public function __construct(int $flags = self::TARGET_ALL)
  75375. {
  75376. $this->flags = $flags;
  75377. }
  75378. }
  75379. <?php
  75380. if (\PHP_VERSION_ID < 80000 && \extension_loaded('tokenizer')) {
  75381. class PhpToken extends Symfony\Polyfill\Php80\PhpToken
  75382. {
  75383. }
  75384. }
  75385. <?php
  75386. if (\PHP_VERSION_ID < 80000) {
  75387. interface Stringable
  75388. {
  75389. public function __toString();
  75390. }
  75391. }
  75392. <?php
  75393. if (\PHP_VERSION_ID < 80000) {
  75394. class UnhandledMatchError extends Error
  75395. {
  75396. }
  75397. }
  75398. <?php
  75399. if (\PHP_VERSION_ID < 80000) {
  75400. class ValueError extends Error
  75401. {
  75402. }
  75403. }
  75404. <?php
  75405. use Symfony\Polyfill\Php80 as p;
  75406. if (\PHP_VERSION_ID >= 80000) {
  75407. return;
  75408. }
  75409. if (!defined('FILTER_VALIDATE_BOOL') && defined('FILTER_VALIDATE_BOOLEAN')) {
  75410. define('FILTER_VALIDATE_BOOL', \FILTER_VALIDATE_BOOLEAN);
  75411. }
  75412. if (!function_exists('fdiv')) {
  75413. function fdiv(float $num1, float $num2): float { return p\Php80::fdiv($num1, $num2); }
  75414. }
  75415. if (!function_exists('preg_last_error_msg')) {
  75416. function preg_last_error_msg(): string { return p\Php80::preg_last_error_msg(); }
  75417. }
  75418. if (!function_exists('str_contains')) {
  75419. function str_contains(?string $haystack, ?string $needle): bool { return p\Php80::str_contains($haystack ?? '', $needle ?? ''); }
  75420. }
  75421. if (!function_exists('str_starts_with')) {
  75422. function str_starts_with(?string $haystack, ?string $needle): bool { return p\Php80::str_starts_with($haystack ?? '', $needle ?? ''); }
  75423. }
  75424. if (!function_exists('str_ends_with')) {
  75425. function str_ends_with(?string $haystack, ?string $needle): bool { return p\Php80::str_ends_with($haystack ?? '', $needle ?? ''); }
  75426. }
  75427. if (!function_exists('get_debug_type')) {
  75428. function get_debug_type($value): string { return p\Php80::get_debug_type($value); }
  75429. }
  75430. if (!function_exists('get_resource_id')) {
  75431. function get_resource_id($resource): int { return p\Php80::get_resource_id($resource); }
  75432. }
  75433. <?php
  75434. namespace Symfony\Component\Process\Exception;
  75435. interface ExceptionInterface extends \Throwable
  75436. {
  75437. }
  75438. <?php
  75439. namespace Symfony\Component\Process\Exception;
  75440. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  75441. {
  75442. }
  75443. <?php
  75444. namespace Symfony\Component\Process\Exception;
  75445. class LogicException extends \LogicException implements ExceptionInterface
  75446. {
  75447. }
  75448. <?php
  75449. namespace Symfony\Component\Process\Exception;
  75450. use Symfony\Component\Process\Process;
  75451. class ProcessFailedException extends RuntimeException
  75452. {
  75453. private $process;
  75454. public function __construct(Process $process)
  75455. {
  75456. if ($process->isSuccessful()) {
  75457. throw new InvalidArgumentException('Expected a failed process, but the given process was successful.');
  75458. }
  75459. $error = sprintf('The command "%s" failed.'."\n\nExit Code: %s(%s)\n\nWorking directory: %s",
  75460. $process->getCommandLine(),
  75461. $process->getExitCode(),
  75462. $process->getExitCodeText(),
  75463. $process->getWorkingDirectory()
  75464. );
  75465. if (!$process->isOutputDisabled()) {
  75466. $error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s",
  75467. $process->getOutput(),
  75468. $process->getErrorOutput()
  75469. );
  75470. }
  75471. parent::__construct($error);
  75472. $this->process = $process;
  75473. }
  75474. public function getProcess()
  75475. {
  75476. return $this->process;
  75477. }
  75478. }
  75479. <?php
  75480. namespace Symfony\Component\Process\Exception;
  75481. use Symfony\Component\Process\Process;
  75482. final class ProcessSignaledException extends RuntimeException
  75483. {
  75484. private $process;
  75485. public function __construct(Process $process)
  75486. {
  75487. $this->process = $process;
  75488. parent::__construct(sprintf('The process has been signaled with signal "%s".', $process->getTermSignal()));
  75489. }
  75490. public function getProcess(): Process
  75491. {
  75492. return $this->process;
  75493. }
  75494. public function getSignal(): int
  75495. {
  75496. return $this->getProcess()->getTermSignal();
  75497. }
  75498. }
  75499. <?php
  75500. namespace Symfony\Component\Process\Exception;
  75501. use Symfony\Component\Process\Process;
  75502. class ProcessTimedOutException extends RuntimeException
  75503. {
  75504. public const TYPE_GENERAL = 1;
  75505. public const TYPE_IDLE = 2;
  75506. private $process;
  75507. private $timeoutType;
  75508. public function __construct(Process $process, int $timeoutType)
  75509. {
  75510. $this->process = $process;
  75511. $this->timeoutType = $timeoutType;
  75512. parent::__construct(sprintf(
  75513. 'The process "%s" exceeded the timeout of %s seconds.',
  75514. $process->getCommandLine(),
  75515. $this->getExceededTimeout()
  75516. ));
  75517. }
  75518. public function getProcess()
  75519. {
  75520. return $this->process;
  75521. }
  75522. public function isGeneralTimeout()
  75523. {
  75524. return self::TYPE_GENERAL === $this->timeoutType;
  75525. }
  75526. public function isIdleTimeout()
  75527. {
  75528. return self::TYPE_IDLE === $this->timeoutType;
  75529. }
  75530. public function getExceededTimeout()
  75531. {
  75532. switch ($this->timeoutType) {
  75533. case self::TYPE_GENERAL:
  75534. return $this->process->getTimeout();
  75535. case self::TYPE_IDLE:
  75536. return $this->process->getIdleTimeout();
  75537. default:
  75538. throw new \LogicException(sprintf('Unknown timeout type "%d".', $this->timeoutType));
  75539. }
  75540. }
  75541. }
  75542. <?php
  75543. namespace Symfony\Component\Process\Exception;
  75544. class RuntimeException extends \RuntimeException implements ExceptionInterface
  75545. {
  75546. }
  75547. <?php
  75548. namespace Symfony\Component\Process;
  75549. class ExecutableFinder
  75550. {
  75551. private $suffixes = ['.exe', '.bat', '.cmd', '.com'];
  75552. public function setSuffixes(array $suffixes)
  75553. {
  75554. $this->suffixes = $suffixes;
  75555. }
  75556. public function addSuffix(string $suffix)
  75557. {
  75558. $this->suffixes[] = $suffix;
  75559. }
  75560. public function find(string $name, string $default = null, array $extraDirs = [])
  75561. {
  75562. if (ini_get('open_basedir')) {
  75563. $searchPath = array_merge(explode(\PATH_SEPARATOR, ini_get('open_basedir')), $extraDirs);
  75564. $dirs = [];
  75565. foreach ($searchPath as $path) {
  75566. if (@is_dir($path)) {
  75567. $dirs[] = $path;
  75568. } else {
  75569. if (basename($path) == $name && @is_executable($path)) {
  75570. return $path;
  75571. }
  75572. }
  75573. }
  75574. } else {
  75575. $dirs = array_merge(
  75576. explode(\PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')),
  75577. $extraDirs
  75578. );
  75579. }
  75580. $suffixes = [''];
  75581. if ('\\' === \DIRECTORY_SEPARATOR) {
  75582. $pathExt = getenv('PATHEXT');
  75583. $suffixes = array_merge($pathExt ? explode(\PATH_SEPARATOR, $pathExt) : $this->suffixes, $suffixes);
  75584. }
  75585. foreach ($suffixes as $suffix) {
  75586. foreach ($dirs as $dir) {
  75587. if (@is_file($file = $dir.\DIRECTORY_SEPARATOR.$name.$suffix) && ('\\' === \DIRECTORY_SEPARATOR || @is_executable($file))) {
  75588. return $file;
  75589. }
  75590. }
  75591. }
  75592. return $default;
  75593. }
  75594. }
  75595. <?php
  75596. namespace Symfony\Component\Process;
  75597. use Symfony\Component\Process\Exception\RuntimeException;
  75598. class InputStream implements \IteratorAggregate
  75599. {
  75600. private $onEmpty = null;
  75601. private $input = [];
  75602. private $open = true;
  75603. public function onEmpty(callable $onEmpty = null)
  75604. {
  75605. $this->onEmpty = $onEmpty;
  75606. }
  75607. public function write($input)
  75608. {
  75609. if (null === $input) {
  75610. return;
  75611. }
  75612. if ($this->isClosed()) {
  75613. throw new RuntimeException(sprintf('"%s" is closed.', static::class));
  75614. }
  75615. $this->input[] = ProcessUtils::validateInput(__METHOD__, $input);
  75616. }
  75617. public function close()
  75618. {
  75619. $this->open = false;
  75620. }
  75621. public function isClosed()
  75622. {
  75623. return !$this->open;
  75624. }
  75625. #[\ReturnTypeWillChange]
  75626. public function getIterator()
  75627. {
  75628. $this->open = true;
  75629. while ($this->open || $this->input) {
  75630. if (!$this->input) {
  75631. yield '';
  75632. continue;
  75633. }
  75634. $current = array_shift($this->input);
  75635. if ($current instanceof \Iterator) {
  75636. yield from $current;
  75637. } else {
  75638. yield $current;
  75639. }
  75640. if (!$this->input && $this->open && null !== $onEmpty = $this->onEmpty) {
  75641. $this->write($onEmpty($this));
  75642. }
  75643. }
  75644. }
  75645. }
  75646. Copyright (c) 2004-2022 Fabien Potencier
  75647. Permission is hereby granted, free of charge, to any person obtaining a copy
  75648. of this software and associated documentation files (the "Software"), to deal
  75649. in the Software without restriction, including without limitation the rights
  75650. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  75651. copies of the Software, and to permit persons to whom the Software is furnished
  75652. to do so, subject to the following conditions:
  75653. The above copyright notice and this permission notice shall be included in all
  75654. copies or substantial portions of the Software.
  75655. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  75656. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  75657. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  75658. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  75659. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  75660. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  75661. THE SOFTWARE.
  75662. <?php
  75663. namespace Symfony\Component\Process;
  75664. class PhpExecutableFinder
  75665. {
  75666. private $executableFinder;
  75667. public function __construct()
  75668. {
  75669. $this->executableFinder = new ExecutableFinder();
  75670. }
  75671. public function find(bool $includeArgs = true)
  75672. {
  75673. if ($php = getenv('PHP_BINARY')) {
  75674. if (!is_executable($php)) {
  75675. $command = '\\' === \DIRECTORY_SEPARATOR ? 'where' : 'command -v';
  75676. if ($php = strtok(exec($command.' '.escapeshellarg($php)), \PHP_EOL)) {
  75677. if (!is_executable($php)) {
  75678. return false;
  75679. }
  75680. } else {
  75681. return false;
  75682. }
  75683. }
  75684. return $php;
  75685. }
  75686. $args = $this->findArguments();
  75687. $args = $includeArgs && $args ? ' '.implode(' ', $args) : '';
  75688. if (\PHP_BINARY && \in_array(\PHP_SAPI, ['cgi-fcgi', 'cli', 'cli-server', 'phpdbg'], true)) {
  75689. return \PHP_BINARY.$args;
  75690. }
  75691. if ($php = getenv('PHP_PATH')) {
  75692. if (!@is_executable($php)) {
  75693. return false;
  75694. }
  75695. return $php;
  75696. }
  75697. if ($php = getenv('PHP_PEAR_PHP_BIN')) {
  75698. if (@is_executable($php)) {
  75699. return $php;
  75700. }
  75701. }
  75702. if (@is_executable($php = \PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php'))) {
  75703. return $php;
  75704. }
  75705. $dirs = [\PHP_BINDIR];
  75706. if ('\\' === \DIRECTORY_SEPARATOR) {
  75707. $dirs[] = 'C:\xampp\php\\';
  75708. }
  75709. return $this->executableFinder->find('php', false, $dirs);
  75710. }
  75711. public function findArguments()
  75712. {
  75713. $arguments = [];
  75714. if ('phpdbg' === \PHP_SAPI) {
  75715. $arguments[] = '-qrr';
  75716. }
  75717. return $arguments;
  75718. }
  75719. }
  75720. <?php
  75721. namespace Symfony\Component\Process;
  75722. use Symfony\Component\Process\Exception\LogicException;
  75723. use Symfony\Component\Process\Exception\RuntimeException;
  75724. class PhpProcess extends Process
  75725. {
  75726. public function __construct(string $script, string $cwd = null, array $env = null, int $timeout = 60, array $php = null)
  75727. {
  75728. if (null === $php) {
  75729. $executableFinder = new PhpExecutableFinder();
  75730. $php = $executableFinder->find(false);
  75731. $php = false === $php ? null : array_merge([$php], $executableFinder->findArguments());
  75732. }
  75733. if ('phpdbg' === \PHP_SAPI) {
  75734. $file = tempnam(sys_get_temp_dir(), 'dbg');
  75735. file_put_contents($file, $script);
  75736. register_shutdown_function('unlink', $file);
  75737. $php[] = $file;
  75738. $script = null;
  75739. }
  75740. parent::__construct($php, $cwd, $env, $script, $timeout);
  75741. }
  75742. public static function fromShellCommandline(string $command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60)
  75743. {
  75744. throw new LogicException(sprintf('The "%s()" method cannot be called when using "%s".', __METHOD__, self::class));
  75745. }
  75746. public function start(callable $callback = null, array $env = [])
  75747. {
  75748. if (null === $this->getCommandLine()) {
  75749. throw new RuntimeException('Unable to find the PHP executable.');
  75750. }
  75751. parent::start($callback, $env);
  75752. }
  75753. }
  75754. <?php
  75755. namespace Symfony\Component\Process\Pipes;
  75756. use Symfony\Component\Process\Exception\InvalidArgumentException;
  75757. abstract class AbstractPipes implements PipesInterface
  75758. {
  75759. public $pipes = [];
  75760. private $inputBuffer = '';
  75761. private $input;
  75762. private $blocked = true;
  75763. private $lastError;
  75764. public function __construct($input)
  75765. {
  75766. if (\is_resource($input) || $input instanceof \Iterator) {
  75767. $this->input = $input;
  75768. } elseif (\is_string($input)) {
  75769. $this->inputBuffer = $input;
  75770. } else {
  75771. $this->inputBuffer = (string) $input;
  75772. }
  75773. }
  75774. public function close()
  75775. {
  75776. foreach ($this->pipes as $pipe) {
  75777. if (\is_resource($pipe)) {
  75778. fclose($pipe);
  75779. }
  75780. }
  75781. $this->pipes = [];
  75782. }
  75783. protected function hasSystemCallBeenInterrupted(): bool
  75784. {
  75785. $lastError = $this->lastError;
  75786. $this->lastError = null;
  75787. return null !== $lastError && false !== stripos($lastError, 'interrupted system call');
  75788. }
  75789. protected function unblock()
  75790. {
  75791. if (!$this->blocked) {
  75792. return;
  75793. }
  75794. foreach ($this->pipes as $pipe) {
  75795. stream_set_blocking($pipe, 0);
  75796. }
  75797. if (\is_resource($this->input)) {
  75798. stream_set_blocking($this->input, 0);
  75799. }
  75800. $this->blocked = false;
  75801. }
  75802. protected function write(): ?array
  75803. {
  75804. if (!isset($this->pipes[0])) {
  75805. return null;
  75806. }
  75807. $input = $this->input;
  75808. if ($input instanceof \Iterator) {
  75809. if (!$input->valid()) {
  75810. $input = null;
  75811. } elseif (\is_resource($input = $input->current())) {
  75812. stream_set_blocking($input, 0);
  75813. } elseif (!isset($this->inputBuffer[0])) {
  75814. if (!\is_string($input)) {
  75815. if (!is_scalar($input)) {
  75816. throw new InvalidArgumentException(sprintf('"%s" yielded a value of type "%s", but only scalars and stream resources are supported.', get_debug_type($this->input), get_debug_type($input)));
  75817. }
  75818. $input = (string) $input;
  75819. }
  75820. $this->inputBuffer = $input;
  75821. $this->input->next();
  75822. $input = null;
  75823. } else {
  75824. $input = null;
  75825. }
  75826. }
  75827. $r = $e = [];
  75828. $w = [$this->pipes[0]];
  75829. if (false === @stream_select($r, $w, $e, 0, 0)) {
  75830. return null;
  75831. }
  75832. foreach ($w as $stdin) {
  75833. if (isset($this->inputBuffer[0])) {
  75834. $written = fwrite($stdin, $this->inputBuffer);
  75835. $this->inputBuffer = substr($this->inputBuffer, $written);
  75836. if (isset($this->inputBuffer[0])) {
  75837. return [$this->pipes[0]];
  75838. }
  75839. }
  75840. if ($input) {
  75841. while (true) {
  75842. $data = fread($input, self::CHUNK_SIZE);
  75843. if (!isset($data[0])) {
  75844. break;
  75845. }
  75846. $written = fwrite($stdin, $data);
  75847. $data = substr($data, $written);
  75848. if (isset($data[0])) {
  75849. $this->inputBuffer = $data;
  75850. return [$this->pipes[0]];
  75851. }
  75852. }
  75853. if (feof($input)) {
  75854. if ($this->input instanceof \Iterator) {
  75855. $this->input->next();
  75856. } else {
  75857. $this->input = null;
  75858. }
  75859. }
  75860. }
  75861. }
  75862. if (!isset($this->inputBuffer[0]) && !($this->input instanceof \Iterator ? $this->input->valid() : $this->input)) {
  75863. $this->input = null;
  75864. fclose($this->pipes[0]);
  75865. unset($this->pipes[0]);
  75866. } elseif (!$w) {
  75867. return [$this->pipes[0]];
  75868. }
  75869. return null;
  75870. }
  75871. public function handleError(int $type, string $msg)
  75872. {
  75873. $this->lastError = $msg;
  75874. }
  75875. }
  75876. <?php
  75877. namespace Symfony\Component\Process\Pipes;
  75878. interface PipesInterface
  75879. {
  75880. public const CHUNK_SIZE = 16384;
  75881. public function getDescriptors(): array;
  75882. public function getFiles(): array;
  75883. public function readAndWrite(bool $blocking, bool $close = false): array;
  75884. public function areOpen(): bool;
  75885. public function haveReadSupport(): bool;
  75886. public function close();
  75887. }
  75888. <?php
  75889. namespace Symfony\Component\Process\Pipes;
  75890. use Symfony\Component\Process\Process;
  75891. class UnixPipes extends AbstractPipes
  75892. {
  75893. private $ttyMode;
  75894. private $ptyMode;
  75895. private $haveReadSupport;
  75896. public function __construct(?bool $ttyMode, bool $ptyMode, $input, bool $haveReadSupport)
  75897. {
  75898. $this->ttyMode = $ttyMode;
  75899. $this->ptyMode = $ptyMode;
  75900. $this->haveReadSupport = $haveReadSupport;
  75901. parent::__construct($input);
  75902. }
  75903. public function __sleep(): array
  75904. {
  75905. throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
  75906. }
  75907. public function __wakeup()
  75908. {
  75909. throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
  75910. }
  75911. public function __destruct()
  75912. {
  75913. $this->close();
  75914. }
  75915. public function getDescriptors(): array
  75916. {
  75917. if (!$this->haveReadSupport) {
  75918. $nullstream = fopen('/dev/null', 'c');
  75919. return [
  75920. ['pipe', 'r'],
  75921. $nullstream,
  75922. $nullstream,
  75923. ];
  75924. }
  75925. if ($this->ttyMode) {
  75926. return [
  75927. ['file', '/dev/tty', 'r'],
  75928. ['file', '/dev/tty', 'w'],
  75929. ['file', '/dev/tty', 'w'],
  75930. ];
  75931. }
  75932. if ($this->ptyMode && Process::isPtySupported()) {
  75933. return [
  75934. ['pty'],
  75935. ['pty'],
  75936. ['pty'],
  75937. ];
  75938. }
  75939. return [
  75940. ['pipe', 'r'],
  75941. ['pipe', 'w'],
  75942. ['pipe', 'w'],
  75943. ];
  75944. }
  75945. public function getFiles(): array
  75946. {
  75947. return [];
  75948. }
  75949. public function readAndWrite(bool $blocking, bool $close = false): array
  75950. {
  75951. $this->unblock();
  75952. $w = $this->write();
  75953. $read = $e = [];
  75954. $r = $this->pipes;
  75955. unset($r[0]);
  75956. set_error_handler([$this, 'handleError']);
  75957. if (($r || $w) && false === stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1E6 : 0)) {
  75958. restore_error_handler();
  75959. if (!$this->hasSystemCallBeenInterrupted()) {
  75960. $this->pipes = [];
  75961. }
  75962. return $read;
  75963. }
  75964. restore_error_handler();
  75965. foreach ($r as $pipe) {
  75966. $read[$type = array_search($pipe, $this->pipes, true)] = '';
  75967. do {
  75968. $data = @fread($pipe, self::CHUNK_SIZE);
  75969. $read[$type] .= $data;
  75970. } while (isset($data[0]) && ($close || isset($data[self::CHUNK_SIZE - 1])));
  75971. if (!isset($read[$type][0])) {
  75972. unset($read[$type]);
  75973. }
  75974. if ($close && feof($pipe)) {
  75975. fclose($pipe);
  75976. unset($this->pipes[$type]);
  75977. }
  75978. }
  75979. return $read;
  75980. }
  75981. public function haveReadSupport(): bool
  75982. {
  75983. return $this->haveReadSupport;
  75984. }
  75985. public function areOpen(): bool
  75986. {
  75987. return (bool) $this->pipes;
  75988. }
  75989. }
  75990. <?php
  75991. namespace Symfony\Component\Process\Pipes;
  75992. use Symfony\Component\Process\Exception\RuntimeException;
  75993. use Symfony\Component\Process\Process;
  75994. class WindowsPipes extends AbstractPipes
  75995. {
  75996. private $files = [];
  75997. private $fileHandles = [];
  75998. private $lockHandles = [];
  75999. private $readBytes = [
  76000. Process::STDOUT => 0,
  76001. Process::STDERR => 0,
  76002. ];
  76003. private $haveReadSupport;
  76004. public function __construct($input, bool $haveReadSupport)
  76005. {
  76006. $this->haveReadSupport = $haveReadSupport;
  76007. if ($this->haveReadSupport) {
  76008. $pipes = [
  76009. Process::STDOUT => Process::OUT,
  76010. Process::STDERR => Process::ERR,
  76011. ];
  76012. $tmpDir = sys_get_temp_dir();
  76013. $lastError = 'unknown reason';
  76014. set_error_handler(function ($type, $msg) use (&$lastError) { $lastError = $msg; });
  76015. for ($i = 0;; ++$i) {
  76016. foreach ($pipes as $pipe => $name) {
  76017. $file = sprintf('%s\\sf_proc_%02X.%s', $tmpDir, $i, $name);
  76018. if (!$h = fopen($file.'.lock', 'w')) {
  76019. if (file_exists($file.'.lock')) {
  76020. continue 2;
  76021. }
  76022. restore_error_handler();
  76023. throw new RuntimeException('A temporary file could not be opened to write the process output: '.$lastError);
  76024. }
  76025. if (!flock($h, \LOCK_EX | \LOCK_NB)) {
  76026. continue 2;
  76027. }
  76028. if (isset($this->lockHandles[$pipe])) {
  76029. flock($this->lockHandles[$pipe], \LOCK_UN);
  76030. fclose($this->lockHandles[$pipe]);
  76031. }
  76032. $this->lockHandles[$pipe] = $h;
  76033. if (!($h = fopen($file, 'w')) || !fclose($h) || !$h = fopen($file, 'r')) {
  76034. flock($this->lockHandles[$pipe], \LOCK_UN);
  76035. fclose($this->lockHandles[$pipe]);
  76036. unset($this->lockHandles[$pipe]);
  76037. continue 2;
  76038. }
  76039. $this->fileHandles[$pipe] = $h;
  76040. $this->files[$pipe] = $file;
  76041. }
  76042. break;
  76043. }
  76044. restore_error_handler();
  76045. }
  76046. parent::__construct($input);
  76047. }
  76048. public function __sleep(): array
  76049. {
  76050. throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
  76051. }
  76052. public function __wakeup()
  76053. {
  76054. throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
  76055. }
  76056. public function __destruct()
  76057. {
  76058. $this->close();
  76059. }
  76060. public function getDescriptors(): array
  76061. {
  76062. if (!$this->haveReadSupport) {
  76063. $nullstream = fopen('NUL', 'c');
  76064. return [
  76065. ['pipe', 'r'],
  76066. $nullstream,
  76067. $nullstream,
  76068. ];
  76069. }
  76070. return [
  76071. ['pipe', 'r'],
  76072. ['file', 'NUL', 'w'],
  76073. ['file', 'NUL', 'w'],
  76074. ];
  76075. }
  76076. public function getFiles(): array
  76077. {
  76078. return $this->files;
  76079. }
  76080. public function readAndWrite(bool $blocking, bool $close = false): array
  76081. {
  76082. $this->unblock();
  76083. $w = $this->write();
  76084. $read = $r = $e = [];
  76085. if ($blocking) {
  76086. if ($w) {
  76087. @stream_select($r, $w, $e, 0, Process::TIMEOUT_PRECISION * 1E6);
  76088. } elseif ($this->fileHandles) {
  76089. usleep(Process::TIMEOUT_PRECISION * 1E6);
  76090. }
  76091. }
  76092. foreach ($this->fileHandles as $type => $fileHandle) {
  76093. $data = stream_get_contents($fileHandle, -1, $this->readBytes[$type]);
  76094. if (isset($data[0])) {
  76095. $this->readBytes[$type] += \strlen($data);
  76096. $read[$type] = $data;
  76097. }
  76098. if ($close) {
  76099. ftruncate($fileHandle, 0);
  76100. fclose($fileHandle);
  76101. flock($this->lockHandles[$type], \LOCK_UN);
  76102. fclose($this->lockHandles[$type]);
  76103. unset($this->fileHandles[$type], $this->lockHandles[$type]);
  76104. }
  76105. }
  76106. return $read;
  76107. }
  76108. public function haveReadSupport(): bool
  76109. {
  76110. return $this->haveReadSupport;
  76111. }
  76112. public function areOpen(): bool
  76113. {
  76114. return $this->pipes && $this->fileHandles;
  76115. }
  76116. public function close()
  76117. {
  76118. parent::close();
  76119. foreach ($this->fileHandles as $type => $handle) {
  76120. ftruncate($handle, 0);
  76121. fclose($handle);
  76122. flock($this->lockHandles[$type], \LOCK_UN);
  76123. fclose($this->lockHandles[$type]);
  76124. }
  76125. $this->fileHandles = $this->lockHandles = [];
  76126. }
  76127. }
  76128. <?php
  76129. namespace Symfony\Component\Process;
  76130. use Symfony\Component\Process\Exception\InvalidArgumentException;
  76131. use Symfony\Component\Process\Exception\LogicException;
  76132. use Symfony\Component\Process\Exception\ProcessFailedException;
  76133. use Symfony\Component\Process\Exception\ProcessSignaledException;
  76134. use Symfony\Component\Process\Exception\ProcessTimedOutException;
  76135. use Symfony\Component\Process\Exception\RuntimeException;
  76136. use Symfony\Component\Process\Pipes\PipesInterface;
  76137. use Symfony\Component\Process\Pipes\UnixPipes;
  76138. use Symfony\Component\Process\Pipes\WindowsPipes;
  76139. class Process implements \IteratorAggregate
  76140. {
  76141. public const ERR = 'err';
  76142. public const OUT = 'out';
  76143. public const STATUS_READY = 'ready';
  76144. public const STATUS_STARTED = 'started';
  76145. public const STATUS_TERMINATED = 'terminated';
  76146. public const STDIN = 0;
  76147. public const STDOUT = 1;
  76148. public const STDERR = 2;
  76149. public const TIMEOUT_PRECISION = 0.2;
  76150. public const ITER_NON_BLOCKING = 1;
  76151. public const ITER_KEEP_OUTPUT = 2;
  76152. public const ITER_SKIP_OUT = 4;
  76153. public const ITER_SKIP_ERR = 8;
  76154. private $callback;
  76155. private $hasCallback = false;
  76156. private $commandline;
  76157. private $cwd;
  76158. private $env;
  76159. private $input;
  76160. private $starttime;
  76161. private $lastOutputTime;
  76162. private $timeout;
  76163. private $idleTimeout;
  76164. private $exitcode;
  76165. private $fallbackStatus = [];
  76166. private $processInformation;
  76167. private $outputDisabled = false;
  76168. private $stdout;
  76169. private $stderr;
  76170. private $process;
  76171. private $status = self::STATUS_READY;
  76172. private $incrementalOutputOffset = 0;
  76173. private $incrementalErrorOutputOffset = 0;
  76174. private $tty = false;
  76175. private $pty;
  76176. private $options = ['suppress_errors' => true, 'bypass_shell' => true];
  76177. private $useFileHandles = false;
  76178. private $processPipes;
  76179. private $latestSignal;
  76180. private static $sigchild;
  76181. public static $exitCodes = [
  76182. 0 => 'OK',
  76183. 1 => 'General error',
  76184. 2 => 'Misuse of shell builtins',
  76185. 126 => 'Invoked command cannot execute',
  76186. 127 => 'Command not found',
  76187. 128 => 'Invalid exit argument',
  76188. 129 => 'Hangup',
  76189. 130 => 'Interrupt',
  76190. 131 => 'Quit and dump core',
  76191. 132 => 'Illegal instruction',
  76192. 133 => 'Trace/breakpoint trap',
  76193. 134 => 'Process aborted',
  76194. 135 => 'Bus error: "access to undefined portion of memory object"',
  76195. 136 => 'Floating point exception: "erroneous arithmetic operation"',
  76196. 137 => 'Kill (terminate immediately)',
  76197. 138 => 'User-defined 1',
  76198. 139 => 'Segmentation violation',
  76199. 140 => 'User-defined 2',
  76200. 141 => 'Write to pipe with no one reading',
  76201. 142 => 'Signal raised by alarm',
  76202. 143 => 'Termination (request to terminate)',
  76203. 145 => 'Child process terminated, stopped (or continued*)',
  76204. 146 => 'Continue if stopped',
  76205. 147 => 'Stop executing temporarily',
  76206. 148 => 'Terminal stop signal',
  76207. 149 => 'Background process attempting to read from tty ("in")',
  76208. 150 => 'Background process attempting to write to tty ("out")',
  76209. 151 => 'Urgent data available on socket',
  76210. 152 => 'CPU time limit exceeded',
  76211. 153 => 'File size limit exceeded',
  76212. 154 => 'Signal raised by timer counting virtual time: "virtual timer expired"',
  76213. 155 => 'Profiling timer expired',
  76214. 157 => 'Pollable event',
  76215. 159 => 'Bad syscall',
  76216. ];
  76217. public function __construct(array $command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60)
  76218. {
  76219. if (!\function_exists('proc_open')) {
  76220. throw new LogicException('The Process class relies on proc_open, which is not available on your PHP installation.');
  76221. }
  76222. $this->commandline = $command;
  76223. $this->cwd = $cwd;
  76224. if (null === $this->cwd && (\defined('ZEND_THREAD_SAFE') || '\\' === \DIRECTORY_SEPARATOR)) {
  76225. $this->cwd = getcwd();
  76226. }
  76227. if (null !== $env) {
  76228. $this->setEnv($env);
  76229. }
  76230. $this->setInput($input);
  76231. $this->setTimeout($timeout);
  76232. $this->useFileHandles = '\\' === \DIRECTORY_SEPARATOR;
  76233. $this->pty = false;
  76234. }
  76235. public static function fromShellCommandline(string $command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60)
  76236. {
  76237. $process = new static([], $cwd, $env, $input, $timeout);
  76238. $process->commandline = $command;
  76239. return $process;
  76240. }
  76241. public function __sleep()
  76242. {
  76243. throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
  76244. }
  76245. public function __wakeup()
  76246. {
  76247. throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
  76248. }
  76249. public function __destruct()
  76250. {
  76251. if ($this->options['create_new_console'] ?? false) {
  76252. $this->processPipes->close();
  76253. } else {
  76254. $this->stop(0);
  76255. }
  76256. }
  76257. public function __clone()
  76258. {
  76259. $this->resetProcessData();
  76260. }
  76261. public function run(callable $callback = null, array $env = []): int
  76262. {
  76263. $this->start($callback, $env);
  76264. return $this->wait();
  76265. }
  76266. public function mustRun(callable $callback = null, array $env = []): self
  76267. {
  76268. if (0 !== $this->run($callback, $env)) {
  76269. throw new ProcessFailedException($this);
  76270. }
  76271. return $this;
  76272. }
  76273. public function start(callable $callback = null, array $env = [])
  76274. {
  76275. if ($this->isRunning()) {
  76276. throw new RuntimeException('Process is already running.');
  76277. }
  76278. $this->resetProcessData();
  76279. $this->starttime = $this->lastOutputTime = microtime(true);
  76280. $this->callback = $this->buildCallback($callback);
  76281. $this->hasCallback = null !== $callback;
  76282. $descriptors = $this->getDescriptors();
  76283. if ($this->env) {
  76284. $env += '\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($this->env, $env, 'strcasecmp') : $this->env;
  76285. }
  76286. $env += '\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($this->getDefaultEnv(), $env, 'strcasecmp') : $this->getDefaultEnv();
  76287. if (\is_array($commandline = $this->commandline)) {
  76288. $commandline = implode(' ', array_map([$this, 'escapeArgument'], $commandline));
  76289. if ('\\' !== \DIRECTORY_SEPARATOR) {
  76290. $commandline = 'exec '.$commandline;
  76291. }
  76292. } else {
  76293. $commandline = $this->replacePlaceholders($commandline, $env);
  76294. }
  76295. if ('\\' === \DIRECTORY_SEPARATOR) {
  76296. $commandline = $this->prepareWindowsCommandLine($commandline, $env);
  76297. } elseif (!$this->useFileHandles && $this->isSigchildEnabled()) {
  76298. $descriptors[3] = ['pipe', 'w'];
  76299. $commandline = '{ ('.$commandline.') <&3 3<&- 3>/dev/null & } 3<&0;';
  76300. $commandline .= 'pid=$!; echo $pid >&3; wait $pid; code=$?; echo $code >&3; exit $code';
  76301. $ptsWorkaround = fopen(__FILE__, 'r');
  76302. }
  76303. $envPairs = [];
  76304. foreach ($env as $k => $v) {
  76305. if (false !== $v && false === \in_array($k, ['argc', 'argv', 'ARGC', 'ARGV'], true)) {
  76306. $envPairs[] = $k.'='.$v;
  76307. }
  76308. }
  76309. if (!is_dir($this->cwd)) {
  76310. throw new RuntimeException(sprintf('The provided cwd "%s" does not exist.', $this->cwd));
  76311. }
  76312. $this->process = @proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options);
  76313. if (!\is_resource($this->process)) {
  76314. throw new RuntimeException('Unable to launch a new process.');
  76315. }
  76316. $this->status = self::STATUS_STARTED;
  76317. if (isset($descriptors[3])) {
  76318. $this->fallbackStatus['pid'] = (int) fgets($this->processPipes->pipes[3]);
  76319. }
  76320. if ($this->tty) {
  76321. return;
  76322. }
  76323. $this->updateStatus(false);
  76324. $this->checkTimeout();
  76325. }
  76326. public function restart(callable $callback = null, array $env = []): self
  76327. {
  76328. if ($this->isRunning()) {
  76329. throw new RuntimeException('Process is already running.');
  76330. }
  76331. $process = clone $this;
  76332. $process->start($callback, $env);
  76333. return $process;
  76334. }
  76335. public function wait(callable $callback = null)
  76336. {
  76337. $this->requireProcessIsStarted(__FUNCTION__);
  76338. $this->updateStatus(false);
  76339. if (null !== $callback) {
  76340. if (!$this->processPipes->haveReadSupport()) {
  76341. $this->stop(0);
  76342. throw new LogicException('Pass the callback to the "Process::start" method or call enableOutput to use a callback with "Process::wait".');
  76343. }
  76344. $this->callback = $this->buildCallback($callback);
  76345. }
  76346. do {
  76347. $this->checkTimeout();
  76348. $running = '\\' === \DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen();
  76349. $this->readPipes($running, '\\' !== \DIRECTORY_SEPARATOR || !$running);
  76350. } while ($running);
  76351. while ($this->isRunning()) {
  76352. $this->checkTimeout();
  76353. usleep(1000);
  76354. }
  76355. if ($this->processInformation['signaled'] && $this->processInformation['termsig'] !== $this->latestSignal) {
  76356. throw new ProcessSignaledException($this);
  76357. }
  76358. return $this->exitcode;
  76359. }
  76360. public function waitUntil(callable $callback): bool
  76361. {
  76362. $this->requireProcessIsStarted(__FUNCTION__);
  76363. $this->updateStatus(false);
  76364. if (!$this->processPipes->haveReadSupport()) {
  76365. $this->stop(0);
  76366. throw new LogicException('Pass the callback to the "Process::start" method or call enableOutput to use a callback with "Process::waitUntil".');
  76367. }
  76368. $callback = $this->buildCallback($callback);
  76369. $ready = false;
  76370. while (true) {
  76371. $this->checkTimeout();
  76372. $running = '\\' === \DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen();
  76373. $output = $this->processPipes->readAndWrite($running, '\\' !== \DIRECTORY_SEPARATOR || !$running);
  76374. foreach ($output as $type => $data) {
  76375. if (3 !== $type) {
  76376. $ready = $callback(self::STDOUT === $type ? self::OUT : self::ERR, $data) || $ready;
  76377. } elseif (!isset($this->fallbackStatus['signaled'])) {
  76378. $this->fallbackStatus['exitcode'] = (int) $data;
  76379. }
  76380. }
  76381. if ($ready) {
  76382. return true;
  76383. }
  76384. if (!$running) {
  76385. return false;
  76386. }
  76387. usleep(1000);
  76388. }
  76389. }
  76390. public function getPid()
  76391. {
  76392. return $this->isRunning() ? $this->processInformation['pid'] : null;
  76393. }
  76394. public function signal(int $signal)
  76395. {
  76396. $this->doSignal($signal, true);
  76397. return $this;
  76398. }
  76399. public function disableOutput()
  76400. {
  76401. if ($this->isRunning()) {
  76402. throw new RuntimeException('Disabling output while the process is running is not possible.');
  76403. }
  76404. if (null !== $this->idleTimeout) {
  76405. throw new LogicException('Output cannot be disabled while an idle timeout is set.');
  76406. }
  76407. $this->outputDisabled = true;
  76408. return $this;
  76409. }
  76410. public function enableOutput()
  76411. {
  76412. if ($this->isRunning()) {
  76413. throw new RuntimeException('Enabling output while the process is running is not possible.');
  76414. }
  76415. $this->outputDisabled = false;
  76416. return $this;
  76417. }
  76418. public function isOutputDisabled()
  76419. {
  76420. return $this->outputDisabled;
  76421. }
  76422. public function getOutput()
  76423. {
  76424. $this->readPipesForOutput(__FUNCTION__);
  76425. if (false === $ret = stream_get_contents($this->stdout, -1, 0)) {
  76426. return '';
  76427. }
  76428. return $ret;
  76429. }
  76430. public function getIncrementalOutput()
  76431. {
  76432. $this->readPipesForOutput(__FUNCTION__);
  76433. $latest = stream_get_contents($this->stdout, -1, $this->incrementalOutputOffset);
  76434. $this->incrementalOutputOffset = ftell($this->stdout);
  76435. if (false === $latest) {
  76436. return '';
  76437. }
  76438. return $latest;
  76439. }
  76440. #[\ReturnTypeWillChange]
  76441. public function getIterator(int $flags = 0)
  76442. {
  76443. $this->readPipesForOutput(__FUNCTION__, false);
  76444. $clearOutput = !(self::ITER_KEEP_OUTPUT & $flags);
  76445. $blocking = !(self::ITER_NON_BLOCKING & $flags);
  76446. $yieldOut = !(self::ITER_SKIP_OUT & $flags);
  76447. $yieldErr = !(self::ITER_SKIP_ERR & $flags);
  76448. while (null !== $this->callback || ($yieldOut && !feof($this->stdout)) || ($yieldErr && !feof($this->stderr))) {
  76449. if ($yieldOut) {
  76450. $out = stream_get_contents($this->stdout, -1, $this->incrementalOutputOffset);
  76451. if (isset($out[0])) {
  76452. if ($clearOutput) {
  76453. $this->clearOutput();
  76454. } else {
  76455. $this->incrementalOutputOffset = ftell($this->stdout);
  76456. }
  76457. yield self::OUT => $out;
  76458. }
  76459. }
  76460. if ($yieldErr) {
  76461. $err = stream_get_contents($this->stderr, -1, $this->incrementalErrorOutputOffset);
  76462. if (isset($err[0])) {
  76463. if ($clearOutput) {
  76464. $this->clearErrorOutput();
  76465. } else {
  76466. $this->incrementalErrorOutputOffset = ftell($this->stderr);
  76467. }
  76468. yield self::ERR => $err;
  76469. }
  76470. }
  76471. if (!$blocking && !isset($out[0]) && !isset($err[0])) {
  76472. yield self::OUT => '';
  76473. }
  76474. $this->checkTimeout();
  76475. $this->readPipesForOutput(__FUNCTION__, $blocking);
  76476. }
  76477. }
  76478. public function clearOutput()
  76479. {
  76480. ftruncate($this->stdout, 0);
  76481. fseek($this->stdout, 0);
  76482. $this->incrementalOutputOffset = 0;
  76483. return $this;
  76484. }
  76485. public function getErrorOutput()
  76486. {
  76487. $this->readPipesForOutput(__FUNCTION__);
  76488. if (false === $ret = stream_get_contents($this->stderr, -1, 0)) {
  76489. return '';
  76490. }
  76491. return $ret;
  76492. }
  76493. public function getIncrementalErrorOutput()
  76494. {
  76495. $this->readPipesForOutput(__FUNCTION__);
  76496. $latest = stream_get_contents($this->stderr, -1, $this->incrementalErrorOutputOffset);
  76497. $this->incrementalErrorOutputOffset = ftell($this->stderr);
  76498. if (false === $latest) {
  76499. return '';
  76500. }
  76501. return $latest;
  76502. }
  76503. public function clearErrorOutput()
  76504. {
  76505. ftruncate($this->stderr, 0);
  76506. fseek($this->stderr, 0);
  76507. $this->incrementalErrorOutputOffset = 0;
  76508. return $this;
  76509. }
  76510. public function getExitCode()
  76511. {
  76512. $this->updateStatus(false);
  76513. return $this->exitcode;
  76514. }
  76515. public function getExitCodeText()
  76516. {
  76517. if (null === $exitcode = $this->getExitCode()) {
  76518. return null;
  76519. }
  76520. return self::$exitCodes[$exitcode] ?? 'Unknown error';
  76521. }
  76522. public function isSuccessful()
  76523. {
  76524. return 0 === $this->getExitCode();
  76525. }
  76526. public function hasBeenSignaled()
  76527. {
  76528. $this->requireProcessIsTerminated(__FUNCTION__);
  76529. return $this->processInformation['signaled'];
  76530. }
  76531. public function getTermSignal()
  76532. {
  76533. $this->requireProcessIsTerminated(__FUNCTION__);
  76534. if ($this->isSigchildEnabled() && -1 === $this->processInformation['termsig']) {
  76535. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal cannot be retrieved.');
  76536. }
  76537. return $this->processInformation['termsig'];
  76538. }
  76539. public function hasBeenStopped()
  76540. {
  76541. $this->requireProcessIsTerminated(__FUNCTION__);
  76542. return $this->processInformation['stopped'];
  76543. }
  76544. public function getStopSignal()
  76545. {
  76546. $this->requireProcessIsTerminated(__FUNCTION__);
  76547. return $this->processInformation['stopsig'];
  76548. }
  76549. public function isRunning()
  76550. {
  76551. if (self::STATUS_STARTED !== $this->status) {
  76552. return false;
  76553. }
  76554. $this->updateStatus(false);
  76555. return $this->processInformation['running'];
  76556. }
  76557. public function isStarted()
  76558. {
  76559. return self::STATUS_READY != $this->status;
  76560. }
  76561. public function isTerminated()
  76562. {
  76563. $this->updateStatus(false);
  76564. return self::STATUS_TERMINATED == $this->status;
  76565. }
  76566. public function getStatus()
  76567. {
  76568. $this->updateStatus(false);
  76569. return $this->status;
  76570. }
  76571. public function stop(float $timeout = 10, int $signal = null)
  76572. {
  76573. $timeoutMicro = microtime(true) + $timeout;
  76574. if ($this->isRunning()) {
  76575. $this->doSignal(15, false);
  76576. do {
  76577. usleep(1000);
  76578. } while ($this->isRunning() && microtime(true) < $timeoutMicro);
  76579. if ($this->isRunning()) {
  76580. $this->doSignal($signal ?: 9, false);
  76581. }
  76582. }
  76583. if ($this->isRunning()) {
  76584. if (isset($this->fallbackStatus['pid'])) {
  76585. unset($this->fallbackStatus['pid']);
  76586. return $this->stop(0, $signal);
  76587. }
  76588. $this->close();
  76589. }
  76590. return $this->exitcode;
  76591. }
  76592. public function addOutput(string $line)
  76593. {
  76594. $this->lastOutputTime = microtime(true);
  76595. fseek($this->stdout, 0, \SEEK_END);
  76596. fwrite($this->stdout, $line);
  76597. fseek($this->stdout, $this->incrementalOutputOffset);
  76598. }
  76599. public function addErrorOutput(string $line)
  76600. {
  76601. $this->lastOutputTime = microtime(true);
  76602. fseek($this->stderr, 0, \SEEK_END);
  76603. fwrite($this->stderr, $line);
  76604. fseek($this->stderr, $this->incrementalErrorOutputOffset);
  76605. }
  76606. public function getLastOutputTime(): ?float
  76607. {
  76608. return $this->lastOutputTime;
  76609. }
  76610. public function getCommandLine()
  76611. {
  76612. return \is_array($this->commandline) ? implode(' ', array_map([$this, 'escapeArgument'], $this->commandline)) : $this->commandline;
  76613. }
  76614. public function getTimeout()
  76615. {
  76616. return $this->timeout;
  76617. }
  76618. public function getIdleTimeout()
  76619. {
  76620. return $this->idleTimeout;
  76621. }
  76622. public function setTimeout(?float $timeout)
  76623. {
  76624. $this->timeout = $this->validateTimeout($timeout);
  76625. return $this;
  76626. }
  76627. public function setIdleTimeout(?float $timeout)
  76628. {
  76629. if (null !== $timeout && $this->outputDisabled) {
  76630. throw new LogicException('Idle timeout cannot be set while the output is disabled.');
  76631. }
  76632. $this->idleTimeout = $this->validateTimeout($timeout);
  76633. return $this;
  76634. }
  76635. public function setTty(bool $tty)
  76636. {
  76637. if ('\\' === \DIRECTORY_SEPARATOR && $tty) {
  76638. throw new RuntimeException('TTY mode is not supported on Windows platform.');
  76639. }
  76640. if ($tty && !self::isTtySupported()) {
  76641. throw new RuntimeException('TTY mode requires /dev/tty to be read/writable.');
  76642. }
  76643. $this->tty = $tty;
  76644. return $this;
  76645. }
  76646. public function isTty()
  76647. {
  76648. return $this->tty;
  76649. }
  76650. public function setPty(bool $bool)
  76651. {
  76652. $this->pty = $bool;
  76653. return $this;
  76654. }
  76655. public function isPty()
  76656. {
  76657. return $this->pty;
  76658. }
  76659. public function getWorkingDirectory()
  76660. {
  76661. if (null === $this->cwd) {
  76662. return getcwd() ?: null;
  76663. }
  76664. return $this->cwd;
  76665. }
  76666. public function setWorkingDirectory(string $cwd)
  76667. {
  76668. $this->cwd = $cwd;
  76669. return $this;
  76670. }
  76671. public function getEnv()
  76672. {
  76673. return $this->env;
  76674. }
  76675. public function setEnv(array $env)
  76676. {
  76677. $this->env = $env;
  76678. return $this;
  76679. }
  76680. public function getInput()
  76681. {
  76682. return $this->input;
  76683. }
  76684. public function setInput($input)
  76685. {
  76686. if ($this->isRunning()) {
  76687. throw new LogicException('Input cannot be set while the process is running.');
  76688. }
  76689. $this->input = ProcessUtils::validateInput(__METHOD__, $input);
  76690. return $this;
  76691. }
  76692. public function checkTimeout()
  76693. {
  76694. if (self::STATUS_STARTED !== $this->status) {
  76695. return;
  76696. }
  76697. if (null !== $this->timeout && $this->timeout < microtime(true) - $this->starttime) {
  76698. $this->stop(0);
  76699. throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_GENERAL);
  76700. }
  76701. if (null !== $this->idleTimeout && $this->idleTimeout < microtime(true) - $this->lastOutputTime) {
  76702. $this->stop(0);
  76703. throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_IDLE);
  76704. }
  76705. }
  76706. public function getStartTime(): float
  76707. {
  76708. if (!$this->isStarted()) {
  76709. throw new LogicException('Start time is only available after process start.');
  76710. }
  76711. return $this->starttime;
  76712. }
  76713. public function setOptions(array $options)
  76714. {
  76715. if ($this->isRunning()) {
  76716. throw new RuntimeException('Setting options while the process is running is not possible.');
  76717. }
  76718. $defaultOptions = $this->options;
  76719. $existingOptions = ['blocking_pipes', 'create_process_group', 'create_new_console'];
  76720. foreach ($options as $key => $value) {
  76721. if (!\in_array($key, $existingOptions)) {
  76722. $this->options = $defaultOptions;
  76723. throw new LogicException(sprintf('Invalid option "%s" passed to "%s()". Supported options are "%s".', $key, __METHOD__, implode('", "', $existingOptions)));
  76724. }
  76725. $this->options[$key] = $value;
  76726. }
  76727. }
  76728. public static function isTtySupported(): bool
  76729. {
  76730. static $isTtySupported;
  76731. if (null === $isTtySupported) {
  76732. $isTtySupported = (bool) @proc_open('echo 1 >/dev/null', [['file', '/dev/tty', 'r'], ['file', '/dev/tty', 'w'], ['file', '/dev/tty', 'w']], $pipes);
  76733. }
  76734. return $isTtySupported;
  76735. }
  76736. public static function isPtySupported()
  76737. {
  76738. static $result;
  76739. if (null !== $result) {
  76740. return $result;
  76741. }
  76742. if ('\\' === \DIRECTORY_SEPARATOR) {
  76743. return $result = false;
  76744. }
  76745. return $result = (bool) @proc_open('echo 1 >/dev/null', [['pty'], ['pty'], ['pty']], $pipes);
  76746. }
  76747. private function getDescriptors(): array
  76748. {
  76749. if ($this->input instanceof \Iterator) {
  76750. $this->input->rewind();
  76751. }
  76752. if ('\\' === \DIRECTORY_SEPARATOR) {
  76753. $this->processPipes = new WindowsPipes($this->input, !$this->outputDisabled || $this->hasCallback);
  76754. } else {
  76755. $this->processPipes = new UnixPipes($this->isTty(), $this->isPty(), $this->input, !$this->outputDisabled || $this->hasCallback);
  76756. }
  76757. return $this->processPipes->getDescriptors();
  76758. }
  76759. protected function buildCallback(callable $callback = null)
  76760. {
  76761. if ($this->outputDisabled) {
  76762. return function ($type, $data) use ($callback): bool {
  76763. return null !== $callback && $callback($type, $data);
  76764. };
  76765. }
  76766. $out = self::OUT;
  76767. return function ($type, $data) use ($callback, $out): bool {
  76768. if ($out == $type) {
  76769. $this->addOutput($data);
  76770. } else {
  76771. $this->addErrorOutput($data);
  76772. }
  76773. return null !== $callback && $callback($type, $data);
  76774. };
  76775. }
  76776. protected function updateStatus(bool $blocking)
  76777. {
  76778. if (self::STATUS_STARTED !== $this->status) {
  76779. return;
  76780. }
  76781. $this->processInformation = proc_get_status($this->process);
  76782. $running = $this->processInformation['running'];
  76783. $this->readPipes($running && $blocking, '\\' !== \DIRECTORY_SEPARATOR || !$running);
  76784. if ($this->fallbackStatus && $this->isSigchildEnabled()) {
  76785. $this->processInformation = $this->fallbackStatus + $this->processInformation;
  76786. }
  76787. if (!$running) {
  76788. $this->close();
  76789. }
  76790. }
  76791. protected function isSigchildEnabled()
  76792. {
  76793. if (null !== self::$sigchild) {
  76794. return self::$sigchild;
  76795. }
  76796. if (!\function_exists('phpinfo')) {
  76797. return self::$sigchild = false;
  76798. }
  76799. ob_start();
  76800. phpinfo(\INFO_GENERAL);
  76801. return self::$sigchild = str_contains(ob_get_clean(), '--enable-sigchild');
  76802. }
  76803. private function readPipesForOutput(string $caller, bool $blocking = false)
  76804. {
  76805. if ($this->outputDisabled) {
  76806. throw new LogicException('Output has been disabled.');
  76807. }
  76808. $this->requireProcessIsStarted($caller);
  76809. $this->updateStatus($blocking);
  76810. }
  76811. private function validateTimeout(?float $timeout): ?float
  76812. {
  76813. $timeout = (float) $timeout;
  76814. if (0.0 === $timeout) {
  76815. $timeout = null;
  76816. } elseif ($timeout < 0) {
  76817. throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
  76818. }
  76819. return $timeout;
  76820. }
  76821. private function readPipes(bool $blocking, bool $close)
  76822. {
  76823. $result = $this->processPipes->readAndWrite($blocking, $close);
  76824. $callback = $this->callback;
  76825. foreach ($result as $type => $data) {
  76826. if (3 !== $type) {
  76827. $callback(self::STDOUT === $type ? self::OUT : self::ERR, $data);
  76828. } elseif (!isset($this->fallbackStatus['signaled'])) {
  76829. $this->fallbackStatus['exitcode'] = (int) $data;
  76830. }
  76831. }
  76832. }
  76833. private function close(): int
  76834. {
  76835. $this->processPipes->close();
  76836. if (\is_resource($this->process)) {
  76837. proc_close($this->process);
  76838. }
  76839. $this->exitcode = $this->processInformation['exitcode'];
  76840. $this->status = self::STATUS_TERMINATED;
  76841. if (-1 === $this->exitcode) {
  76842. if ($this->processInformation['signaled'] && 0 < $this->processInformation['termsig']) {
  76843. $this->exitcode = 128 + $this->processInformation['termsig'];
  76844. } elseif ($this->isSigchildEnabled()) {
  76845. $this->processInformation['signaled'] = true;
  76846. $this->processInformation['termsig'] = -1;
  76847. }
  76848. }
  76849. $this->callback = null;
  76850. return $this->exitcode;
  76851. }
  76852. private function resetProcessData()
  76853. {
  76854. $this->starttime = null;
  76855. $this->callback = null;
  76856. $this->exitcode = null;
  76857. $this->fallbackStatus = [];
  76858. $this->processInformation = null;
  76859. $this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+');
  76860. $this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+');
  76861. $this->process = null;
  76862. $this->latestSignal = null;
  76863. $this->status = self::STATUS_READY;
  76864. $this->incrementalOutputOffset = 0;
  76865. $this->incrementalErrorOutputOffset = 0;
  76866. }
  76867. private function doSignal(int $signal, bool $throwException): bool
  76868. {
  76869. if (null === $pid = $this->getPid()) {
  76870. if ($throwException) {
  76871. throw new LogicException('Cannot send signal on a non running process.');
  76872. }
  76873. return false;
  76874. }
  76875. if ('\\' === \DIRECTORY_SEPARATOR) {
  76876. exec(sprintf('taskkill /F /T /PID %d 2>&1', $pid), $output, $exitCode);
  76877. if ($exitCode && $this->isRunning()) {
  76878. if ($throwException) {
  76879. throw new RuntimeException(sprintf('Unable to kill the process (%s).', implode(' ', $output)));
  76880. }
  76881. return false;
  76882. }
  76883. } else {
  76884. if (!$this->isSigchildEnabled()) {
  76885. $ok = @proc_terminate($this->process, $signal);
  76886. } elseif (\function_exists('posix_kill')) {
  76887. $ok = @posix_kill($pid, $signal);
  76888. } elseif ($ok = proc_open(sprintf('kill -%d %d', $signal, $pid), [2 => ['pipe', 'w']], $pipes)) {
  76889. $ok = false === fgets($pipes[2]);
  76890. }
  76891. if (!$ok) {
  76892. if ($throwException) {
  76893. throw new RuntimeException(sprintf('Error while sending signal "%s".', $signal));
  76894. }
  76895. return false;
  76896. }
  76897. }
  76898. $this->latestSignal = $signal;
  76899. $this->fallbackStatus['signaled'] = true;
  76900. $this->fallbackStatus['exitcode'] = -1;
  76901. $this->fallbackStatus['termsig'] = $this->latestSignal;
  76902. return true;
  76903. }
  76904. private function prepareWindowsCommandLine(string $cmd, array &$env): string
  76905. {
  76906. $uid = uniqid('', true);
  76907. $varCount = 0;
  76908. $varCache = [];
  76909. $cmd = preg_replace_callback(
  76910. '/"(?:(
  76911. [^"%!^]*+
  76912. (?:
  76913. (?: !LF! | "(?:\^[%!^])?+" )
  76914. [^"%!^]*+
  76915. )++
  76916. ) | [^"]*+ )"/x',
  76917. function ($m) use (&$env, &$varCache, &$varCount, $uid) {
  76918. if (!isset($m[1])) {
  76919. return $m[0];
  76920. }
  76921. if (isset($varCache[$m[0]])) {
  76922. return $varCache[$m[0]];
  76923. }
  76924. if (str_contains($value = $m[1], "\0")) {
  76925. $value = str_replace("\0", '?', $value);
  76926. }
  76927. if (false === strpbrk($value, "\"%!\n")) {
  76928. return '"'.$value.'"';
  76929. }
  76930. $value = str_replace(['!LF!', '"^!"', '"^%"', '"^^"', '""'], ["\n", '!', '%', '^', '"'], $value);
  76931. $value = '"'.preg_replace('/(\\\\*)"/', '$1$1\\"', $value).'"';
  76932. $var = $uid.++$varCount;
  76933. $env[$var] = $value;
  76934. return $varCache[$m[0]] = '!'.$var.'!';
  76935. },
  76936. $cmd
  76937. );
  76938. $cmd = 'cmd /V:ON /E:ON /D /C ('.str_replace("\n", ' ', $cmd).')';
  76939. foreach ($this->processPipes->getFiles() as $offset => $filename) {
  76940. $cmd .= ' '.$offset.'>"'.$filename.'"';
  76941. }
  76942. return $cmd;
  76943. }
  76944. private function requireProcessIsStarted(string $functionName)
  76945. {
  76946. if (!$this->isStarted()) {
  76947. throw new LogicException(sprintf('Process must be started before calling "%s()".', $functionName));
  76948. }
  76949. }
  76950. private function requireProcessIsTerminated(string $functionName)
  76951. {
  76952. if (!$this->isTerminated()) {
  76953. throw new LogicException(sprintf('Process must be terminated before calling "%s()".', $functionName));
  76954. }
  76955. }
  76956. private function escapeArgument(?string $argument): string
  76957. {
  76958. if ('' === $argument || null === $argument) {
  76959. return '""';
  76960. }
  76961. if ('\\' !== \DIRECTORY_SEPARATOR) {
  76962. return "'".str_replace("'", "'\\''", $argument)."'";
  76963. }
  76964. if (str_contains($argument, "\0")) {
  76965. $argument = str_replace("\0", '?', $argument);
  76966. }
  76967. if (!preg_match('/[\/()%!^"<>&|\s]/', $argument)) {
  76968. return $argument;
  76969. }
  76970. $argument = preg_replace('/(\\\\+)$/', '$1$1', $argument);
  76971. return '"'.str_replace(['"', '^', '%', '!', "\n"], ['""', '"^^"', '"^%"', '"^!"', '!LF!'], $argument).'"';
  76972. }
  76973. private function replacePlaceholders(string $commandline, array $env)
  76974. {
  76975. return preg_replace_callback('/"\$\{:([_a-zA-Z]++[_a-zA-Z0-9]*+)\}"/', function ($matches) use ($commandline, $env) {
  76976. if (!isset($env[$matches[1]]) || false === $env[$matches[1]]) {
  76977. throw new InvalidArgumentException(sprintf('Command line is missing a value for parameter "%s": ', $matches[1]).$commandline);
  76978. }
  76979. return $this->escapeArgument($env[$matches[1]]);
  76980. }, $commandline);
  76981. }
  76982. private function getDefaultEnv(): array
  76983. {
  76984. $env = getenv();
  76985. $env = ('\\' === \DIRECTORY_SEPARATOR ? array_intersect_ukey($env, $_SERVER, 'strcasecmp') : array_intersect_key($env, $_SERVER)) ?: $env;
  76986. return $_ENV + ('\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($env, $_ENV, 'strcasecmp') : $env);
  76987. }
  76988. }
  76989. <?php
  76990. namespace Symfony\Component\Process;
  76991. use Symfony\Component\Process\Exception\InvalidArgumentException;
  76992. class ProcessUtils
  76993. {
  76994. private function __construct()
  76995. {
  76996. }
  76997. public static function validateInput(string $caller, $input)
  76998. {
  76999. if (null !== $input) {
  77000. if (\is_resource($input)) {
  77001. return $input;
  77002. }
  77003. if (\is_string($input)) {
  77004. return $input;
  77005. }
  77006. if (is_scalar($input)) {
  77007. return (string) $input;
  77008. }
  77009. if ($input instanceof Process) {
  77010. return $input->getIterator($input::ITER_SKIP_ERR);
  77011. }
  77012. if ($input instanceof \Iterator) {
  77013. return $input;
  77014. }
  77015. if ($input instanceof \Traversable) {
  77016. return new \IteratorIterator($input);
  77017. }
  77018. throw new InvalidArgumentException(sprintf('"%s" only accepts strings, Traversable objects or stream resources.', $caller));
  77019. }
  77020. return $input;
  77021. }
  77022. }
  77023. <?php
  77024. namespace Symfony\Contracts\Service\Attribute;
  77025. #[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
  77026. final class Required
  77027. {
  77028. }
  77029. <?php
  77030. namespace Symfony\Contracts\Service\Attribute;
  77031. use Symfony\Contracts\Service\ServiceSubscriberTrait;
  77032. #[\Attribute(\Attribute::TARGET_METHOD)]
  77033. final class SubscribedService
  77034. {
  77035. public function __construct(
  77036. public ?string $key = null
  77037. ) {
  77038. }
  77039. }
  77040. Copyright (c) 2018-2021 Fabien Potencier
  77041. Permission is hereby granted, free of charge, to any person obtaining a copy
  77042. of this software and associated documentation files (the "Software"), to deal
  77043. in the Software without restriction, including without limitation the rights
  77044. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  77045. copies of the Software, and to permit persons to whom the Software is furnished
  77046. to do so, subject to the following conditions:
  77047. The above copyright notice and this permission notice shall be included in all
  77048. copies or substantial portions of the Software.
  77049. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  77050. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  77051. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  77052. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  77053. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  77054. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  77055. THE SOFTWARE.
  77056. <?php
  77057. namespace Symfony\Contracts\Service;
  77058. interface ResetInterface
  77059. {
  77060. public function reset();
  77061. }
  77062. <?php
  77063. namespace Symfony\Contracts\Service;
  77064. use Psr\Container\ContainerExceptionInterface;
  77065. use Psr\Container\NotFoundExceptionInterface;
  77066. class_exists(ContainerExceptionInterface::class);
  77067. class_exists(NotFoundExceptionInterface::class);
  77068. trait ServiceLocatorTrait
  77069. {
  77070. private $factories;
  77071. private $loading = [];
  77072. private $providedTypes;
  77073. public function __construct(array $factories)
  77074. {
  77075. $this->factories = $factories;
  77076. }
  77077. public function has(string $id)
  77078. {
  77079. return isset($this->factories[$id]);
  77080. }
  77081. public function get(string $id)
  77082. {
  77083. if (!isset($this->factories[$id])) {
  77084. throw $this->createNotFoundException($id);
  77085. }
  77086. if (isset($this->loading[$id])) {
  77087. $ids = array_values($this->loading);
  77088. $ids = \array_slice($this->loading, array_search($id, $ids));
  77089. $ids[] = $id;
  77090. throw $this->createCircularReferenceException($id, $ids);
  77091. }
  77092. $this->loading[$id] = $id;
  77093. try {
  77094. return $this->factories[$id]($this);
  77095. } finally {
  77096. unset($this->loading[$id]);
  77097. }
  77098. }
  77099. public function getProvidedServices(): array
  77100. {
  77101. if (null === $this->providedTypes) {
  77102. $this->providedTypes = [];
  77103. foreach ($this->factories as $name => $factory) {
  77104. if (!\is_callable($factory)) {
  77105. $this->providedTypes[$name] = '?';
  77106. } else {
  77107. $type = (new \ReflectionFunction($factory))->getReturnType();
  77108. $this->providedTypes[$name] = $type ? ($type->allowsNull() ? '?' : '').($type instanceof \ReflectionNamedType ? $type->getName() : $type) : '?';
  77109. }
  77110. }
  77111. }
  77112. return $this->providedTypes;
  77113. }
  77114. private function createNotFoundException(string $id): NotFoundExceptionInterface
  77115. {
  77116. if (!$alternatives = array_keys($this->factories)) {
  77117. $message = 'is empty...';
  77118. } else {
  77119. $last = array_pop($alternatives);
  77120. if ($alternatives) {
  77121. $message = sprintf('only knows about the "%s" and "%s" services.', implode('", "', $alternatives), $last);
  77122. } else {
  77123. $message = sprintf('only knows about the "%s" service.', $last);
  77124. }
  77125. }
  77126. if ($this->loading) {
  77127. $message = sprintf('The service "%s" has a dependency on a non-existent service "%s". This locator %s', end($this->loading), $id, $message);
  77128. } else {
  77129. $message = sprintf('Service "%s" not found: the current service locator %s', $id, $message);
  77130. }
  77131. return new class($message) extends \InvalidArgumentException implements NotFoundExceptionInterface {
  77132. };
  77133. }
  77134. private function createCircularReferenceException(string $id, array $path): ContainerExceptionInterface
  77135. {
  77136. return new class(sprintf('Circular reference detected for service "%s", path: "%s".', $id, implode(' -> ', $path))) extends \RuntimeException implements ContainerExceptionInterface {
  77137. };
  77138. }
  77139. }
  77140. <?php
  77141. namespace Symfony\Contracts\Service;
  77142. use Psr\Container\ContainerInterface;
  77143. interface ServiceProviderInterface extends ContainerInterface
  77144. {
  77145. public function getProvidedServices(): array;
  77146. }
  77147. <?php
  77148. namespace Symfony\Contracts\Service;
  77149. interface ServiceSubscriberInterface
  77150. {
  77151. public static function getSubscribedServices();
  77152. }
  77153. <?php
  77154. namespace Symfony\Contracts\Service;
  77155. use Psr\Container\ContainerInterface;
  77156. use Symfony\Contracts\Service\Attribute\SubscribedService;
  77157. trait ServiceSubscriberTrait
  77158. {
  77159. protected $container;
  77160. public static function getSubscribedServices(): array
  77161. {
  77162. static $services;
  77163. if (null !== $services) {
  77164. return $services;
  77165. }
  77166. $services = \is_callable(['parent', __FUNCTION__]) ? parent::getSubscribedServices() : [];
  77167. $attributeOptIn = false;
  77168. if (\PHP_VERSION_ID >= 80000) {
  77169. foreach ((new \ReflectionClass(self::class))->getMethods() as $method) {
  77170. if (self::class !== $method->getDeclaringClass()->name) {
  77171. continue;
  77172. }
  77173. if (!$attribute = $method->getAttributes(SubscribedService::class)[0] ?? null) {
  77174. continue;
  77175. }
  77176. if ($method->isStatic() || $method->isAbstract() || $method->isGenerator() || $method->isInternal() || $method->getNumberOfRequiredParameters()) {
  77177. throw new \LogicException(sprintf('Cannot use "%s" on method "%s::%s()" (can only be used on non-static, non-abstract methods with no parameters).', SubscribedService::class, self::class, $method->name));
  77178. }
  77179. if (!$returnType = $method->getReturnType()) {
  77180. throw new \LogicException(sprintf('Cannot use "%s" on methods without a return type in "%s::%s()".', SubscribedService::class, $method->name, self::class));
  77181. }
  77182. $serviceId = $returnType instanceof \ReflectionNamedType ? $returnType->getName() : (string) $returnType;
  77183. if ($returnType->allowsNull()) {
  77184. $serviceId = '?'.$serviceId;
  77185. }
  77186. $services[$attribute->newInstance()->key ?? self::class.'::'.$method->name] = $serviceId;
  77187. $attributeOptIn = true;
  77188. }
  77189. }
  77190. if (!$attributeOptIn) {
  77191. foreach ((new \ReflectionClass(self::class))->getMethods() as $method) {
  77192. if ($method->isStatic() || $method->isAbstract() || $method->isGenerator() || $method->isInternal() || $method->getNumberOfRequiredParameters()) {
  77193. continue;
  77194. }
  77195. if (self::class !== $method->getDeclaringClass()->name) {
  77196. continue;
  77197. }
  77198. if (!($returnType = $method->getReturnType()) instanceof \ReflectionNamedType) {
  77199. continue;
  77200. }
  77201. if ($returnType->isBuiltin()) {
  77202. continue;
  77203. }
  77204. if (\PHP_VERSION_ID >= 80000) {
  77205. trigger_deprecation('symfony/service-contracts', '2.5', 'Using "%s" in "%s" without using the "%s" attribute on any method is deprecated.', ServiceSubscriberTrait::class, self::class, SubscribedService::class);
  77206. }
  77207. $services[self::class.'::'.$method->name] = '?'.($returnType instanceof \ReflectionNamedType ? $returnType->getName() : $returnType);
  77208. }
  77209. }
  77210. return $services;
  77211. }
  77212. public function setContainer(ContainerInterface $container)
  77213. {
  77214. $this->container = $container;
  77215. if (\is_callable(['parent', __FUNCTION__])) {
  77216. return parent::setContainer($container);
  77217. }
  77218. return null;
  77219. }
  77220. }
  77221. <?php
  77222. namespace Symfony\Contracts\Service\Test;
  77223. use PHPUnit\Framework\TestCase;
  77224. use Psr\Container\ContainerInterface;
  77225. use Symfony\Contracts\Service\ServiceLocatorTrait;
  77226. abstract class ServiceLocatorTest extends TestCase
  77227. {
  77228. protected function getServiceLocator(array $factories)
  77229. {
  77230. return new class($factories) implements ContainerInterface {
  77231. use ServiceLocatorTrait;
  77232. };
  77233. }
  77234. public function testHas()
  77235. {
  77236. $locator = $this->getServiceLocator([
  77237. 'foo' => function () { return 'bar'; },
  77238. 'bar' => function () { return 'baz'; },
  77239. function () { return 'dummy'; },
  77240. ]);
  77241. $this->assertTrue($locator->has('foo'));
  77242. $this->assertTrue($locator->has('bar'));
  77243. $this->assertFalse($locator->has('dummy'));
  77244. }
  77245. public function testGet()
  77246. {
  77247. $locator = $this->getServiceLocator([
  77248. 'foo' => function () { return 'bar'; },
  77249. 'bar' => function () { return 'baz'; },
  77250. ]);
  77251. $this->assertSame('bar', $locator->get('foo'));
  77252. $this->assertSame('baz', $locator->get('bar'));
  77253. }
  77254. public function testGetDoesNotMemoize()
  77255. {
  77256. $i = 0;
  77257. $locator = $this->getServiceLocator([
  77258. 'foo' => function () use (&$i) {
  77259. ++$i;
  77260. return 'bar';
  77261. },
  77262. ]);
  77263. $this->assertSame('bar', $locator->get('foo'));
  77264. $this->assertSame('bar', $locator->get('foo'));
  77265. $this->assertSame(2, $i);
  77266. }
  77267. public function testThrowsOnUndefinedInternalService()
  77268. {
  77269. if (!$this->getExpectedException()) {
  77270. $this->expectException(\Psr\Container\NotFoundExceptionInterface::class);
  77271. $this->expectExceptionMessage('The service "foo" has a dependency on a non-existent service "bar". This locator only knows about the "foo" service.');
  77272. }
  77273. $locator = $this->getServiceLocator([
  77274. 'foo' => function () use (&$locator) { return $locator->get('bar'); },
  77275. ]);
  77276. $locator->get('foo');
  77277. }
  77278. public function testThrowsOnCircularReference()
  77279. {
  77280. $this->expectException(\Psr\Container\ContainerExceptionInterface::class);
  77281. $this->expectExceptionMessage('Circular reference detected for service "bar", path: "bar -> baz -> bar".');
  77282. $locator = $this->getServiceLocator([
  77283. 'foo' => function () use (&$locator) { return $locator->get('bar'); },
  77284. 'bar' => function () use (&$locator) { return $locator->get('baz'); },
  77285. 'baz' => function () use (&$locator) { return $locator->get('bar'); },
  77286. ]);
  77287. $locator->get('foo');
  77288. }
  77289. }
  77290. <?php
  77291. namespace Symfony\Component\String;
  77292. use Symfony\Component\String\Exception\ExceptionInterface;
  77293. use Symfony\Component\String\Exception\InvalidArgumentException;
  77294. use Symfony\Component\String\Exception\RuntimeException;
  77295. abstract class AbstractString implements \Stringable, \JsonSerializable
  77296. {
  77297. public const PREG_PATTERN_ORDER = \PREG_PATTERN_ORDER;
  77298. public const PREG_SET_ORDER = \PREG_SET_ORDER;
  77299. public const PREG_OFFSET_CAPTURE = \PREG_OFFSET_CAPTURE;
  77300. public const PREG_UNMATCHED_AS_NULL = \PREG_UNMATCHED_AS_NULL;
  77301. public const PREG_SPLIT = 0;
  77302. public const PREG_SPLIT_NO_EMPTY = \PREG_SPLIT_NO_EMPTY;
  77303. public const PREG_SPLIT_DELIM_CAPTURE = \PREG_SPLIT_DELIM_CAPTURE;
  77304. public const PREG_SPLIT_OFFSET_CAPTURE = \PREG_SPLIT_OFFSET_CAPTURE;
  77305. protected $string = '';
  77306. protected $ignoreCase = false;
  77307. abstract public function __construct(string $string = '');
  77308. public static function unwrap(array $values): array
  77309. {
  77310. foreach ($values as $k => $v) {
  77311. if ($v instanceof self) {
  77312. $values[$k] = $v->__toString();
  77313. } elseif (\is_array($v) && $values[$k] !== $v = static::unwrap($v)) {
  77314. $values[$k] = $v;
  77315. }
  77316. }
  77317. return $values;
  77318. }
  77319. public static function wrap(array $values): array
  77320. {
  77321. $i = 0;
  77322. $keys = null;
  77323. foreach ($values as $k => $v) {
  77324. if (\is_string($k) && '' !== $k && $k !== $j = (string) new static($k)) {
  77325. $keys = $keys ?? array_keys($values);
  77326. $keys[$i] = $j;
  77327. }
  77328. if (\is_string($v)) {
  77329. $values[$k] = new static($v);
  77330. } elseif (\is_array($v) && $values[$k] !== $v = static::wrap($v)) {
  77331. $values[$k] = $v;
  77332. }
  77333. ++$i;
  77334. }
  77335. return null !== $keys ? array_combine($keys, $values) : $values;
  77336. }
  77337. public function after($needle, bool $includeNeedle = false, int $offset = 0): self
  77338. {
  77339. $str = clone $this;
  77340. $i = \PHP_INT_MAX;
  77341. foreach ((array) $needle as $n) {
  77342. $n = (string) $n;
  77343. $j = $this->indexOf($n, $offset);
  77344. if (null !== $j && $j < $i) {
  77345. $i = $j;
  77346. $str->string = $n;
  77347. }
  77348. }
  77349. if (\PHP_INT_MAX === $i) {
  77350. return $str;
  77351. }
  77352. if (!$includeNeedle) {
  77353. $i += $str->length();
  77354. }
  77355. return $this->slice($i);
  77356. }
  77357. public function afterLast($needle, bool $includeNeedle = false, int $offset = 0): self
  77358. {
  77359. $str = clone $this;
  77360. $i = null;
  77361. foreach ((array) $needle as $n) {
  77362. $n = (string) $n;
  77363. $j = $this->indexOfLast($n, $offset);
  77364. if (null !== $j && $j >= $i) {
  77365. $i = $offset = $j;
  77366. $str->string = $n;
  77367. }
  77368. }
  77369. if (null === $i) {
  77370. return $str;
  77371. }
  77372. if (!$includeNeedle) {
  77373. $i += $str->length();
  77374. }
  77375. return $this->slice($i);
  77376. }
  77377. abstract public function append(string ...$suffix): self;
  77378. public function before($needle, bool $includeNeedle = false, int $offset = 0): self
  77379. {
  77380. $str = clone $this;
  77381. $i = \PHP_INT_MAX;
  77382. foreach ((array) $needle as $n) {
  77383. $n = (string) $n;
  77384. $j = $this->indexOf($n, $offset);
  77385. if (null !== $j && $j < $i) {
  77386. $i = $j;
  77387. $str->string = $n;
  77388. }
  77389. }
  77390. if (\PHP_INT_MAX === $i) {
  77391. return $str;
  77392. }
  77393. if ($includeNeedle) {
  77394. $i += $str->length();
  77395. }
  77396. return $this->slice(0, $i);
  77397. }
  77398. public function beforeLast($needle, bool $includeNeedle = false, int $offset = 0): self
  77399. {
  77400. $str = clone $this;
  77401. $i = null;
  77402. foreach ((array) $needle as $n) {
  77403. $n = (string) $n;
  77404. $j = $this->indexOfLast($n, $offset);
  77405. if (null !== $j && $j >= $i) {
  77406. $i = $offset = $j;
  77407. $str->string = $n;
  77408. }
  77409. }
  77410. if (null === $i) {
  77411. return $str;
  77412. }
  77413. if ($includeNeedle) {
  77414. $i += $str->length();
  77415. }
  77416. return $this->slice(0, $i);
  77417. }
  77418. public function bytesAt(int $offset): array
  77419. {
  77420. $str = $this->slice($offset, 1);
  77421. return '' === $str->string ? [] : array_values(unpack('C*', $str->string));
  77422. }
  77423. abstract public function camel(): self;
  77424. abstract public function chunk(int $length = 1): array;
  77425. public function collapseWhitespace(): self
  77426. {
  77427. $str = clone $this;
  77428. $str->string = trim(preg_replace('/(?:\s{2,}+|[^\S ])/', ' ', $str->string));
  77429. return $str;
  77430. }
  77431. public function containsAny($needle): bool
  77432. {
  77433. return null !== $this->indexOf($needle);
  77434. }
  77435. public function endsWith($suffix): bool
  77436. {
  77437. if (!\is_array($suffix) && !$suffix instanceof \Traversable) {
  77438. throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
  77439. }
  77440. foreach ($suffix as $s) {
  77441. if ($this->endsWith((string) $s)) {
  77442. return true;
  77443. }
  77444. }
  77445. return false;
  77446. }
  77447. public function ensureEnd(string $suffix): self
  77448. {
  77449. if (!$this->endsWith($suffix)) {
  77450. return $this->append($suffix);
  77451. }
  77452. $suffix = preg_quote($suffix);
  77453. $regex = '{('.$suffix.')(?:'.$suffix.')++$}D';
  77454. return $this->replaceMatches($regex.($this->ignoreCase ? 'i' : ''), '$1');
  77455. }
  77456. public function ensureStart(string $prefix): self
  77457. {
  77458. $prefix = new static($prefix);
  77459. if (!$this->startsWith($prefix)) {
  77460. return $this->prepend($prefix);
  77461. }
  77462. $str = clone $this;
  77463. $i = $prefixLen = $prefix->length();
  77464. while ($this->indexOf($prefix, $i) === $i) {
  77465. $str = $str->slice($prefixLen);
  77466. $i += $prefixLen;
  77467. }
  77468. return $str;
  77469. }
  77470. public function equalsTo($string): bool
  77471. {
  77472. if (!\is_array($string) && !$string instanceof \Traversable) {
  77473. throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
  77474. }
  77475. foreach ($string as $s) {
  77476. if ($this->equalsTo((string) $s)) {
  77477. return true;
  77478. }
  77479. }
  77480. return false;
  77481. }
  77482. abstract public function folded(): self;
  77483. public function ignoreCase(): self
  77484. {
  77485. $str = clone $this;
  77486. $str->ignoreCase = true;
  77487. return $str;
  77488. }
  77489. public function indexOf($needle, int $offset = 0): ?int
  77490. {
  77491. if (!\is_array($needle) && !$needle instanceof \Traversable) {
  77492. throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
  77493. }
  77494. $i = \PHP_INT_MAX;
  77495. foreach ($needle as $n) {
  77496. $j = $this->indexOf((string) $n, $offset);
  77497. if (null !== $j && $j < $i) {
  77498. $i = $j;
  77499. }
  77500. }
  77501. return \PHP_INT_MAX === $i ? null : $i;
  77502. }
  77503. public function indexOfLast($needle, int $offset = 0): ?int
  77504. {
  77505. if (!\is_array($needle) && !$needle instanceof \Traversable) {
  77506. throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
  77507. }
  77508. $i = null;
  77509. foreach ($needle as $n) {
  77510. $j = $this->indexOfLast((string) $n, $offset);
  77511. if (null !== $j && $j >= $i) {
  77512. $i = $offset = $j;
  77513. }
  77514. }
  77515. return $i;
  77516. }
  77517. public function isEmpty(): bool
  77518. {
  77519. return '' === $this->string;
  77520. }
  77521. abstract public function join(array $strings, string $lastGlue = null): self;
  77522. public function jsonSerialize(): string
  77523. {
  77524. return $this->string;
  77525. }
  77526. abstract public function length(): int;
  77527. abstract public function lower(): self;
  77528. abstract public function match(string $regexp, int $flags = 0, int $offset = 0): array;
  77529. abstract public function padBoth(int $length, string $padStr = ' '): self;
  77530. abstract public function padEnd(int $length, string $padStr = ' '): self;
  77531. abstract public function padStart(int $length, string $padStr = ' '): self;
  77532. abstract public function prepend(string ...$prefix): self;
  77533. public function repeat(int $multiplier): self
  77534. {
  77535. if (0 > $multiplier) {
  77536. throw new InvalidArgumentException(sprintf('Multiplier must be positive, %d given.', $multiplier));
  77537. }
  77538. $str = clone $this;
  77539. $str->string = str_repeat($str->string, $multiplier);
  77540. return $str;
  77541. }
  77542. abstract public function replace(string $from, string $to): self;
  77543. abstract public function replaceMatches(string $fromRegexp, $to): self;
  77544. abstract public function reverse(): self;
  77545. abstract public function slice(int $start = 0, int $length = null): self;
  77546. abstract public function snake(): self;
  77547. abstract public function splice(string $replacement, int $start = 0, int $length = null): self;
  77548. public function split(string $delimiter, int $limit = null, int $flags = null): array
  77549. {
  77550. if (null === $flags) {
  77551. throw new \TypeError('Split behavior when $flags is null must be implemented by child classes.');
  77552. }
  77553. if ($this->ignoreCase) {
  77554. $delimiter .= 'i';
  77555. }
  77556. set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
  77557. try {
  77558. if (false === $chunks = preg_split($delimiter, $this->string, $limit, $flags)) {
  77559. $lastError = preg_last_error();
  77560. foreach (get_defined_constants(true)['pcre'] as $k => $v) {
  77561. if ($lastError === $v && '_ERROR' === substr($k, -6)) {
  77562. throw new RuntimeException('Splitting failed with '.$k.'.');
  77563. }
  77564. }
  77565. throw new RuntimeException('Splitting failed with unknown error code.');
  77566. }
  77567. } finally {
  77568. restore_error_handler();
  77569. }
  77570. $str = clone $this;
  77571. if (self::PREG_SPLIT_OFFSET_CAPTURE & $flags) {
  77572. foreach ($chunks as &$chunk) {
  77573. $str->string = $chunk[0];
  77574. $chunk[0] = clone $str;
  77575. }
  77576. } else {
  77577. foreach ($chunks as &$chunk) {
  77578. $str->string = $chunk;
  77579. $chunk = clone $str;
  77580. }
  77581. }
  77582. return $chunks;
  77583. }
  77584. public function startsWith($prefix): bool
  77585. {
  77586. if (!\is_array($prefix) && !$prefix instanceof \Traversable) {
  77587. throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
  77588. }
  77589. foreach ($prefix as $prefix) {
  77590. if ($this->startsWith((string) $prefix)) {
  77591. return true;
  77592. }
  77593. }
  77594. return false;
  77595. }
  77596. abstract public function title(bool $allWords = false): self;
  77597. public function toByteString(string $toEncoding = null): ByteString
  77598. {
  77599. $b = new ByteString();
  77600. $toEncoding = \in_array($toEncoding, ['utf8', 'utf-8', 'UTF8'], true) ? 'UTF-8' : $toEncoding;
  77601. if (null === $toEncoding || $toEncoding === $fromEncoding = $this instanceof AbstractUnicodeString || preg_match('//u', $b->string) ? 'UTF-8' : 'Windows-1252') {
  77602. $b->string = $this->string;
  77603. return $b;
  77604. }
  77605. set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
  77606. try {
  77607. try {
  77608. $b->string = mb_convert_encoding($this->string, $toEncoding, 'UTF-8');
  77609. } catch (InvalidArgumentException $e) {
  77610. if (!\function_exists('iconv')) {
  77611. throw $e;
  77612. }
  77613. $b->string = iconv('UTF-8', $toEncoding, $this->string);
  77614. }
  77615. } finally {
  77616. restore_error_handler();
  77617. }
  77618. return $b;
  77619. }
  77620. public function toCodePointString(): CodePointString
  77621. {
  77622. return new CodePointString($this->string);
  77623. }
  77624. public function toString(): string
  77625. {
  77626. return $this->string;
  77627. }
  77628. public function toUnicodeString(): UnicodeString
  77629. {
  77630. return new UnicodeString($this->string);
  77631. }
  77632. abstract public function trim(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): self;
  77633. abstract public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): self;
  77634. public function trimPrefix($prefix): self
  77635. {
  77636. if (\is_array($prefix) || $prefix instanceof \Traversable) {
  77637. foreach ($prefix as $s) {
  77638. $t = $this->trimPrefix($s);
  77639. if ($t->string !== $this->string) {
  77640. return $t;
  77641. }
  77642. }
  77643. return clone $this;
  77644. }
  77645. $str = clone $this;
  77646. if ($prefix instanceof self) {
  77647. $prefix = $prefix->string;
  77648. } else {
  77649. $prefix = (string) $prefix;
  77650. }
  77651. if ('' !== $prefix && \strlen($this->string) >= \strlen($prefix) && 0 === substr_compare($this->string, $prefix, 0, \strlen($prefix), $this->ignoreCase)) {
  77652. $str->string = substr($this->string, \strlen($prefix));
  77653. }
  77654. return $str;
  77655. }
  77656. abstract public function trimStart(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): self;
  77657. public function trimSuffix($suffix): self
  77658. {
  77659. if (\is_array($suffix) || $suffix instanceof \Traversable) {
  77660. foreach ($suffix as $s) {
  77661. $t = $this->trimSuffix($s);
  77662. if ($t->string !== $this->string) {
  77663. return $t;
  77664. }
  77665. }
  77666. return clone $this;
  77667. }
  77668. $str = clone $this;
  77669. if ($suffix instanceof self) {
  77670. $suffix = $suffix->string;
  77671. } else {
  77672. $suffix = (string) $suffix;
  77673. }
  77674. if ('' !== $suffix && \strlen($this->string) >= \strlen($suffix) && 0 === substr_compare($this->string, $suffix, -\strlen($suffix), null, $this->ignoreCase)) {
  77675. $str->string = substr($this->string, 0, -\strlen($suffix));
  77676. }
  77677. return $str;
  77678. }
  77679. public function truncate(int $length, string $ellipsis = '', bool $cut = true): self
  77680. {
  77681. $stringLength = $this->length();
  77682. if ($stringLength <= $length) {
  77683. return clone $this;
  77684. }
  77685. $ellipsisLength = '' !== $ellipsis ? (new static($ellipsis))->length() : 0;
  77686. if ($length < $ellipsisLength) {
  77687. $ellipsisLength = 0;
  77688. }
  77689. if (!$cut) {
  77690. if (null === $length = $this->indexOf([' ', "\r", "\n", "\t"], ($length ?: 1) - 1)) {
  77691. return clone $this;
  77692. }
  77693. $length += $ellipsisLength;
  77694. }
  77695. $str = $this->slice(0, $length - $ellipsisLength);
  77696. return $ellipsisLength ? $str->trimEnd()->append($ellipsis) : $str;
  77697. }
  77698. abstract public function upper(): self;
  77699. abstract public function width(bool $ignoreAnsiDecoration = true): int;
  77700. public function wordwrap(int $width = 75, string $break = "\n", bool $cut = false): self
  77701. {
  77702. $lines = '' !== $break ? $this->split($break) : [clone $this];
  77703. $chars = [];
  77704. $mask = '';
  77705. if (1 === \count($lines) && '' === $lines[0]->string) {
  77706. return $lines[0];
  77707. }
  77708. foreach ($lines as $i => $line) {
  77709. if ($i) {
  77710. $chars[] = $break;
  77711. $mask .= '#';
  77712. }
  77713. foreach ($line->chunk() as $char) {
  77714. $chars[] = $char->string;
  77715. $mask .= ' ' === $char->string ? ' ' : '?';
  77716. }
  77717. }
  77718. $string = '';
  77719. $j = 0;
  77720. $b = $i = -1;
  77721. $mask = wordwrap($mask, $width, '#', $cut);
  77722. while (false !== $b = strpos($mask, '#', $b + 1)) {
  77723. for (++$i; $i < $b; ++$i) {
  77724. $string .= $chars[$j];
  77725. unset($chars[$j++]);
  77726. }
  77727. if ($break === $chars[$j] || ' ' === $chars[$j]) {
  77728. unset($chars[$j++]);
  77729. }
  77730. $string .= $break;
  77731. }
  77732. $str = clone $this;
  77733. $str->string = $string.implode('', $chars);
  77734. return $str;
  77735. }
  77736. public function __sleep(): array
  77737. {
  77738. return ['string'];
  77739. }
  77740. public function __clone()
  77741. {
  77742. $this->ignoreCase = false;
  77743. }
  77744. public function __toString(): string
  77745. {
  77746. return $this->string;
  77747. }
  77748. }
  77749. <?php
  77750. namespace Symfony\Component\String;
  77751. use Symfony\Component\String\Exception\ExceptionInterface;
  77752. use Symfony\Component\String\Exception\InvalidArgumentException;
  77753. use Symfony\Component\String\Exception\RuntimeException;
  77754. abstract class AbstractUnicodeString extends AbstractString
  77755. {
  77756. public const NFC = \Normalizer::NFC;
  77757. public const NFD = \Normalizer::NFD;
  77758. public const NFKC = \Normalizer::NFKC;
  77759. public const NFKD = \Normalizer::NFKD;
  77760. private const ASCII = "\x20\x65\x69\x61\x73\x6E\x74\x72\x6F\x6C\x75\x64\x5D\x5B\x63\x6D\x70\x27\x0A\x67\x7C\x68\x76\x2E\x66\x62\x2C\x3A\x3D\x2D\x71\x31\x30\x43\x32\x2A\x79\x78\x29\x28\x4C\x39\x41\x53\x2F\x50\x22\x45\x6A\x4D\x49\x6B\x33\x3E\x35\x54\x3C\x44\x34\x7D\x42\x7B\x38\x46\x77\x52\x36\x37\x55\x47\x4E\x3B\x4A\x7A\x56\x23\x48\x4F\x57\x5F\x26\x21\x4B\x3F\x58\x51\x25\x59\x5C\x09\x5A\x2B\x7E\x5E\x24\x40\x60\x7F\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F";
  77761. private const FOLD_FROM = ['İ', 'µ', 'ſ', "\xCD\x85", 'ς', '�', 'ϑ', 'ϕ', 'ϖ', 'ϰ', 'ϱ', 'ϵ', 'ẛ', "\xE1\xBE\xBE", 'ß', 'İ', 'ʼn', 'ǰ', '�', 'ΰ', 'և', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'ẚ', 'ẞ', '�', 'ὒ', 'ὔ', 'ὖ', 'ᾀ', '�', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ', '�', 'ᾎ', '�', '�', 'ᾑ', 'ᾒ', 'ᾓ', 'ᾔ', 'ᾕ', 'ᾖ', 'ᾗ', 'ᾘ', 'ᾙ', 'ᾚ', 'ᾛ', 'ᾜ', '�', 'ᾞ', 'ᾟ', 'ᾠ', 'ᾡ', 'ᾢ', 'ᾣ', 'ᾤ', 'ᾥ', 'ᾦ', 'ᾧ', 'ᾨ', 'ᾩ', 'ᾪ', 'ᾫ', 'ᾬ', 'ᾭ', 'ᾮ', 'ᾯ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'ᾼ', 'ῂ', 'ῃ', 'ῄ', 'ῆ', 'ῇ', 'ῌ', 'ῒ', '�', 'ῖ', 'ῗ', 'ῢ', 'ΰ', 'ῤ', 'ῦ', 'ῧ', 'ῲ', 'ῳ', 'ῴ', 'ῶ', 'ῷ', 'ῼ', 'ff', '�', 'fl', 'ffi', 'ffl', 'ſt', 'st', 'ﬓ', 'ﬔ', 'ﬕ', 'ﬖ', 'ﬗ'];
  77762. private const FOLD_TO = ['i̇', 'μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', '�', 'ε', 'ṡ', 'ι', 'ss', 'i̇', 'ʼn', 'ǰ', '�', 'ΰ', 'եւ', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'aʾ', 'ss', '�', 'ὒ', 'ὔ', 'ὖ', 'ἀι', '�ι', 'ἂι', 'ἃι', 'ἄι', 'ἅι', 'ἆι', 'ἇι', 'ἀι', '�ι', 'ἂι', 'ἃι', 'ἄι', 'ἅι', 'ἆι', 'ἇι', 'ἠι', 'ἡι', 'ἢι', 'ἣι', 'ἤι', 'ἥι', 'ἦι', 'ἧι', 'ἠι', 'ἡι', 'ἢι', 'ἣι', 'ἤι', 'ἥι', 'ἦι', 'ἧι', 'ὠι', 'ὡι', 'ὢι', 'ὣι', 'ὤι', 'ὥι', 'ὦι', 'ὧι', 'ὠι', 'ὡι', 'ὢι', 'ὣι', 'ὤι', 'ὥι', 'ὦι', 'ὧι', 'ὰι', 'αι', 'άι', 'ᾶ', 'ᾶι', 'αι', 'ὴι', 'ηι', 'ήι', 'ῆ', 'ῆι', 'ηι', 'ῒ', '�', 'ῖ', 'ῗ', 'ῢ', 'ΰ', 'ῤ', 'ῦ', 'ῧ', 'ὼι', 'ωι', 'ώι', 'ῶ', 'ῶι', 'ωι', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'st', 'st', 'մն', 'մե', 'մի', 'վն', 'մխ'];
  77763. private const UPPER_FROM = ['ß', 'ff', '�', 'fl', 'ffi', 'ffl', 'ſt', 'st', 'և', 'ﬓ', 'ﬔ', 'ﬕ', 'ﬖ', 'ﬗ', 'ʼn', '�', 'ΰ', 'ǰ', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'ẚ', '�', 'ὒ', 'ὔ', 'ὖ', 'ᾶ', 'ῆ', 'ῒ', 'ΐ', 'ῖ', 'ῗ', 'ῢ', 'ΰ', 'ῤ', 'ῦ', 'ῧ', 'ῶ'];
  77764. private const UPPER_TO = ['SS', 'FF', 'FI', 'FL', 'FFI', 'FFL', 'ST', 'ST', 'ԵՒ', 'ՄՆ', 'ՄԵ', 'ՄԻ', 'ՎՆ', 'ՄԽ', 'ʼN', 'Ϊ�', 'Ϋ�', 'J̌', 'H̱', 'T̈', 'W̊', 'Y̊', 'Aʾ', 'Υ̓', 'Υ̓̀', 'Υ̓�', 'Υ̓͂', 'Α͂', 'Η͂', 'Ϊ̀', 'Ϊ�', 'Ι͂', 'Ϊ͂', 'Ϋ̀', 'Ϋ�', 'Ρ̓', 'Υ͂', 'Ϋ͂', 'Ω͂'];
  77765. private const TRANSLIT_FROM = ['Æ', '�', 'Ø', 'Þ', 'ß', 'æ', 'ð', 'ø', 'þ', '�', 'đ', 'Ħ', 'ħ', 'ı', 'ĸ', 'Ŀ', 'ŀ', '�', 'ł', 'ʼn', 'Ŋ', 'ŋ', 'Œ', 'œ', 'Ŧ', 'ŧ', 'ƀ', '�', 'Ƃ', 'ƃ', 'Ƈ', 'ƈ', 'Ɖ', 'Ɗ', 'Ƌ', 'ƌ', '�', 'Ƒ', 'ƒ', 'Ɠ', 'ƕ', 'Ɩ', 'Ɨ', 'Ƙ', 'ƙ', 'ƚ', '�', 'ƞ', 'Ƣ', 'ƣ', 'Ƥ', 'ƥ', 'ƫ', 'Ƭ', 'ƭ', 'Ʈ', 'Ʋ', 'Ƴ', 'ƴ', 'Ƶ', 'ƶ', 'DŽ', 'Dž', 'dž', 'Ǥ', 'ǥ', 'ȡ', 'Ȥ', 'ȥ', 'ȴ', 'ȵ', 'ȶ', 'ȷ', 'ȸ', 'ȹ', 'Ⱥ', 'Ȼ', 'ȼ', 'Ƚ', 'Ⱦ', 'ȿ', 'ɀ', 'Ƀ', 'Ʉ', 'Ɇ', 'ɇ', 'Ɉ', 'ɉ', 'Ɍ', '�', 'Ɏ', '�', 'ɓ', 'ɕ', 'ɖ', 'ɗ', 'ɛ', 'ɟ', 'ɠ', 'ɡ', 'ɢ', 'ɦ', 'ɧ', 'ɨ', 'ɪ', 'ɫ', 'ɬ', 'ɭ', 'ɱ', 'ɲ', 'ɳ', 'ɴ', 'ɶ', 'ɼ', 'ɽ', 'ɾ', 'ʀ', 'ʂ', 'ʈ', 'ʉ', 'ʋ', '�', '�', 'ʑ', 'ʙ', 'ʛ', 'ʜ', '�', 'ʟ', 'ʠ', 'ʣ', 'ʥ', 'ʦ', 'ʪ', 'ʫ', 'ᴀ', '�', 'ᴃ', 'ᴄ', 'ᴅ', 'ᴆ', 'ᴇ', 'ᴊ', 'ᴋ', 'ᴌ', '�', '�', 'ᴘ', 'ᴛ', 'ᴜ', 'ᴠ', 'ᴡ', 'ᴢ', 'ᵫ', 'ᵬ', 'ᵭ', 'ᵮ', 'ᵯ', 'ᵰ', 'ᵱ', 'ᵲ', 'ᵳ', 'ᵴ', 'ᵵ', 'ᵶ', 'ᵺ', 'ᵻ', 'ᵽ', 'ᵾ', 'ᶀ', '�', 'ᶂ', 'ᶃ', 'ᶄ', 'ᶅ', 'ᶆ', 'ᶇ', 'ᶈ', 'ᶉ', 'ᶊ', 'ᶌ', '�', 'ᶎ', '�', 'ᶑ', 'ᶒ', 'ᶓ', 'ᶖ', 'ᶙ', 'ẚ', 'ẜ', '�', 'ẞ', 'Ỻ', 'ỻ', 'Ỽ', 'ỽ', 'Ỿ', 'ỿ', '©', '®', '₠', '₢', '₣', '₤', '₧', '₺', '₹', 'ℌ', '℞', '㎧', '㎮', '�', '�', '�', '�', '¼', '½', '¾', '⅓', '⅔', '⅕', '⅖', '⅗', '⅘', '⅙', '⅚', '⅛', '⅜', '�', '⅞', '⅟', '〇', '‘', '’', '‚', '‛', '“', '�', '„', '‟', '′', '″', '�', '〞', '«', '»', '‹', '›', '�', '‑', '‒', '–', '—', '―', '︱', '︲', '﹘', '‖', '�', '�', '�', '�', '�', '。', '〈', '〉', '《', '》', '〔', '〕', '〘', '〙', '〚', '〛', '︑', '︒', '︹', '︺', '︽', '︾', '︿', '﹀', '﹑', '�', '﹞', '⦅', '⦆', '。', '、', '×', '÷', '−', '∕', '∖', '∣', '∥', '≪', '≫', '⦅', '⦆'];
  77766. private const TRANSLIT_TO = ['AE', 'D', 'O', 'TH', 'ss', 'ae', 'd', 'o', 'th', 'D', 'd', 'H', 'h', 'i', 'q', 'L', 'l', 'L', 'l', '\'n', 'N', 'n', 'OE', 'oe', 'T', 't', 'b', 'B', 'B', 'b', 'C', 'c', 'D', 'D', 'D', 'd', 'E', 'F', 'f', 'G', 'hv', 'I', 'I', 'K', 'k', 'l', 'N', 'n', 'OI', 'oi', 'P', 'p', 't', 'T', 't', 'T', 'V', 'Y', 'y', 'Z', 'z', 'DZ', 'Dz', 'dz', 'G', 'g', 'd', 'Z', 'z', 'l', 'n', 't', 'j', 'db', 'qp', 'A', 'C', 'c', 'L', 'T', 's', 'z', 'B', 'U', 'E', 'e', 'J', 'j', 'R', 'r', 'Y', 'y', 'b', 'c', 'd', 'd', 'e', 'j', 'g', 'g', 'G', 'h', 'h', 'i', 'I', 'l', 'l', 'l', 'm', 'n', 'n', 'N', 'OE', 'r', 'r', 'r', 'R', 's', 't', 'u', 'v', 'Y', 'z', 'z', 'B', 'G', 'H', 'j', 'L', 'q', 'dz', 'dz', 'ts', 'ls', 'lz', 'A', 'AE', 'B', 'C', 'D', 'D', 'E', 'J', 'K', 'L', 'M', 'O', 'P', 'T', 'U', 'V', 'W', 'Z', 'ue', 'b', 'd', 'f', 'm', 'n', 'p', 'r', 'r', 's', 't', 'z', 'th', 'I', 'p', 'U', 'b', 'd', 'f', 'g', 'k', 'l', 'm', 'n', 'p', 'r', 's', 'v', 'x', 'z', 'a', 'd', 'e', 'e', 'i', 'u', 'a', 's', 's', 'SS', 'LL', 'll', 'V', 'v', 'Y', 'y', '(C)', '(R)', 'CE', 'Cr', 'Fr.', 'L.', 'Pts', 'TL', 'Rs', 'x', 'Rx', 'm/s', 'rad/s', 'C/kg', 'pH', 'V/m', 'A/m', ' 1/4', ' 1/2', ' 3/4', ' 1/3', ' 2/3', ' 1/5', ' 2/5', ' 3/5', ' 4/5', ' 1/6', ' 5/6', ' 1/8', ' 3/8', ' 5/8', ' 7/8', ' 1/', '0', '\'', '\'', ',', '\'', '"', '"', ',,', '"', '\'', '"', '"', '"', '<<', '>>', '<', '>', '-', '-', '-', '-', '-', '-', '-', '-', '-', '||', '/', '[', ']', '*', ',', '.', '<', '>', '<<', '>>', '[', ']', '[', ']', '[', ']', ',', '.', '[', ']', '<<', '>>', '<', '>', ',', '[', ']', '((', '))', '.', ',', '*', '/', '-', '/', '\\', '|', '||', '<<', '>>', '((', '))'];
  77767. private static $transliterators = [];
  77768. private static $tableZero;
  77769. private static $tableWide;
  77770. public static function fromCodePoints(int ...$codes): self
  77771. {
  77772. $string = '';
  77773. foreach ($codes as $code) {
  77774. if (0x80 > $code %= 0x200000) {
  77775. $string .= \chr($code);
  77776. } elseif (0x800 > $code) {
  77777. $string .= \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
  77778. } elseif (0x10000 > $code) {
  77779. $string .= \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  77780. } else {
  77781. $string .= \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  77782. }
  77783. }
  77784. return new static($string);
  77785. }
  77786. public function ascii(array $rules = []): self
  77787. {
  77788. $str = clone $this;
  77789. $s = $str->string;
  77790. $str->string = '';
  77791. array_unshift($rules, 'nfd');
  77792. $rules[] = 'latin-ascii';
  77793. if (\function_exists('transliterator_transliterate')) {
  77794. $rules[] = 'any-latin/bgn';
  77795. }
  77796. $rules[] = 'nfkd';
  77797. $rules[] = '[:nonspacing mark:] remove';
  77798. while (\strlen($s) - 1 > $i = strspn($s, self::ASCII)) {
  77799. if (0 < --$i) {
  77800. $str->string .= substr($s, 0, $i);
  77801. $s = substr($s, $i);
  77802. }
  77803. if (!$rule = array_shift($rules)) {
  77804. $rules = [];
  77805. }
  77806. if ($rule instanceof \Transliterator) {
  77807. $s = $rule->transliterate($s);
  77808. } elseif ($rule instanceof \Closure) {
  77809. $s = $rule($s);
  77810. } elseif ($rule) {
  77811. if ('nfd' === $rule = strtolower($rule)) {
  77812. normalizer_is_normalized($s, self::NFD) ?: $s = normalizer_normalize($s, self::NFD);
  77813. } elseif ('nfkd' === $rule) {
  77814. normalizer_is_normalized($s, self::NFKD) ?: $s = normalizer_normalize($s, self::NFKD);
  77815. } elseif ('[:nonspacing mark:] remove' === $rule) {
  77816. $s = preg_replace('/\p{Mn}++/u', '', $s);
  77817. } elseif ('latin-ascii' === $rule) {
  77818. $s = str_replace(self::TRANSLIT_FROM, self::TRANSLIT_TO, $s);
  77819. } elseif ('de-ascii' === $rule) {
  77820. $s = preg_replace("/([AUO])\u{0308}(?=\p{Ll})/u", '$1e', $s);
  77821. $s = str_replace(["a\u{0308}", "o\u{0308}", "u\u{0308}", "A\u{0308}", "O\u{0308}", "U\u{0308}"], ['ae', 'oe', 'ue', 'AE', 'OE', 'UE'], $s);
  77822. } elseif (\function_exists('transliterator_transliterate')) {
  77823. if (null === $transliterator = self::$transliterators[$rule] ?? self::$transliterators[$rule] = \Transliterator::create($rule)) {
  77824. if ('any-latin/bgn' === $rule) {
  77825. $rule = 'any-latin';
  77826. $transliterator = self::$transliterators[$rule] ?? self::$transliterators[$rule] = \Transliterator::create($rule);
  77827. }
  77828. if (null === $transliterator) {
  77829. throw new InvalidArgumentException(sprintf('Unknown transliteration rule "%s".', $rule));
  77830. }
  77831. self::$transliterators['any-latin/bgn'] = $transliterator;
  77832. }
  77833. $s = $transliterator->transliterate($s);
  77834. }
  77835. } elseif (!\function_exists('iconv')) {
  77836. $s = preg_replace('/[^\x00-\x7F]/u', '?', $s);
  77837. } else {
  77838. $s = @preg_replace_callback('/[^\x00-\x7F]/u', static function ($c) {
  77839. $c = (string) iconv('UTF-8', 'ASCII//TRANSLIT', $c[0]);
  77840. if ('' === $c && '' === iconv('UTF-8', 'ASCII//TRANSLIT', '²')) {
  77841. throw new \LogicException(sprintf('"%s" requires a translit-able iconv implementation, try installing "gnu-libiconv" if you\'re using Alpine Linux.', static::class));
  77842. }
  77843. return 1 < \strlen($c) ? ltrim($c, '\'`"^~') : ('' !== $c ? $c : '?');
  77844. }, $s);
  77845. }
  77846. }
  77847. $str->string .= $s;
  77848. return $str;
  77849. }
  77850. public function camel(): parent
  77851. {
  77852. $str = clone $this;
  77853. $str->string = str_replace(' ', '', preg_replace_callback('/\b./u', static function ($m) use (&$i) {
  77854. return 1 === ++$i ? ('İ' === $m[0] ? 'i̇' : mb_strtolower($m[0], 'UTF-8')) : mb_convert_case($m[0], \MB_CASE_TITLE, 'UTF-8');
  77855. }, preg_replace('/[^\pL0-9]++/u', ' ', $this->string)));
  77856. return $str;
  77857. }
  77858. public function codePointsAt(int $offset): array
  77859. {
  77860. $str = $this->slice($offset, 1);
  77861. if ('' === $str->string) {
  77862. return [];
  77863. }
  77864. $codePoints = [];
  77865. foreach (preg_split('//u', $str->string, -1, \PREG_SPLIT_NO_EMPTY) as $c) {
  77866. $codePoints[] = mb_ord($c, 'UTF-8');
  77867. }
  77868. return $codePoints;
  77869. }
  77870. public function folded(bool $compat = true): parent
  77871. {
  77872. $str = clone $this;
  77873. if (!$compat || \PHP_VERSION_ID < 70300 || !\defined('Normalizer::NFKC_CF')) {
  77874. $str->string = normalizer_normalize($str->string, $compat ? \Normalizer::NFKC : \Normalizer::NFC);
  77875. $str->string = mb_strtolower(str_replace(self::FOLD_FROM, self::FOLD_TO, $this->string), 'UTF-8');
  77876. } else {
  77877. $str->string = normalizer_normalize($str->string, \Normalizer::NFKC_CF);
  77878. }
  77879. return $str;
  77880. }
  77881. public function join(array $strings, string $lastGlue = null): parent
  77882. {
  77883. $str = clone $this;
  77884. $tail = null !== $lastGlue && 1 < \count($strings) ? $lastGlue.array_pop($strings) : '';
  77885. $str->string = implode($this->string, $strings).$tail;
  77886. if (!preg_match('//u', $str->string)) {
  77887. throw new InvalidArgumentException('Invalid UTF-8 string.');
  77888. }
  77889. return $str;
  77890. }
  77891. public function lower(): parent
  77892. {
  77893. $str = clone $this;
  77894. $str->string = mb_strtolower(str_replace('İ', 'i̇', $str->string), 'UTF-8');
  77895. return $str;
  77896. }
  77897. public function match(string $regexp, int $flags = 0, int $offset = 0): array
  77898. {
  77899. $match = ((\PREG_PATTERN_ORDER | \PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match';
  77900. if ($this->ignoreCase) {
  77901. $regexp .= 'i';
  77902. }
  77903. set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
  77904. try {
  77905. if (false === $match($regexp.'u', $this->string, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset)) {
  77906. $lastError = preg_last_error();
  77907. foreach (get_defined_constants(true)['pcre'] as $k => $v) {
  77908. if ($lastError === $v && '_ERROR' === substr($k, -6)) {
  77909. throw new RuntimeException('Matching failed with '.$k.'.');
  77910. }
  77911. }
  77912. throw new RuntimeException('Matching failed with unknown error code.');
  77913. }
  77914. } finally {
  77915. restore_error_handler();
  77916. }
  77917. return $matches;
  77918. }
  77919. public function normalize(int $form = self::NFC): self
  77920. {
  77921. if (!\in_array($form, [self::NFC, self::NFD, self::NFKC, self::NFKD])) {
  77922. throw new InvalidArgumentException('Unsupported normalization form.');
  77923. }
  77924. $str = clone $this;
  77925. normalizer_is_normalized($str->string, $form) ?: $str->string = normalizer_normalize($str->string, $form);
  77926. return $str;
  77927. }
  77928. public function padBoth(int $length, string $padStr = ' '): parent
  77929. {
  77930. if ('' === $padStr || !preg_match('//u', $padStr)) {
  77931. throw new InvalidArgumentException('Invalid UTF-8 string.');
  77932. }
  77933. $pad = clone $this;
  77934. $pad->string = $padStr;
  77935. return $this->pad($length, $pad, \STR_PAD_BOTH);
  77936. }
  77937. public function padEnd(int $length, string $padStr = ' '): parent
  77938. {
  77939. if ('' === $padStr || !preg_match('//u', $padStr)) {
  77940. throw new InvalidArgumentException('Invalid UTF-8 string.');
  77941. }
  77942. $pad = clone $this;
  77943. $pad->string = $padStr;
  77944. return $this->pad($length, $pad, \STR_PAD_RIGHT);
  77945. }
  77946. public function padStart(int $length, string $padStr = ' '): parent
  77947. {
  77948. if ('' === $padStr || !preg_match('//u', $padStr)) {
  77949. throw new InvalidArgumentException('Invalid UTF-8 string.');
  77950. }
  77951. $pad = clone $this;
  77952. $pad->string = $padStr;
  77953. return $this->pad($length, $pad, \STR_PAD_LEFT);
  77954. }
  77955. public function replaceMatches(string $fromRegexp, $to): parent
  77956. {
  77957. if ($this->ignoreCase) {
  77958. $fromRegexp .= 'i';
  77959. }
  77960. if (\is_array($to) || $to instanceof \Closure) {
  77961. if (!\is_callable($to)) {
  77962. throw new \TypeError(sprintf('Argument 2 passed to "%s::replaceMatches()" must be callable, array given.', static::class));
  77963. }
  77964. $replace = 'preg_replace_callback';
  77965. $to = static function (array $m) use ($to): string {
  77966. $to = $to($m);
  77967. if ('' !== $to && (!\is_string($to) || !preg_match('//u', $to))) {
  77968. throw new InvalidArgumentException('Replace callback must return a valid UTF-8 string.');
  77969. }
  77970. return $to;
  77971. };
  77972. } elseif ('' !== $to && !preg_match('//u', $to)) {
  77973. throw new InvalidArgumentException('Invalid UTF-8 string.');
  77974. } else {
  77975. $replace = 'preg_replace';
  77976. }
  77977. set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
  77978. try {
  77979. if (null === $string = $replace($fromRegexp.'u', $to, $this->string)) {
  77980. $lastError = preg_last_error();
  77981. foreach (get_defined_constants(true)['pcre'] as $k => $v) {
  77982. if ($lastError === $v && '_ERROR' === substr($k, -6)) {
  77983. throw new RuntimeException('Matching failed with '.$k.'.');
  77984. }
  77985. }
  77986. throw new RuntimeException('Matching failed with unknown error code.');
  77987. }
  77988. } finally {
  77989. restore_error_handler();
  77990. }
  77991. $str = clone $this;
  77992. $str->string = $string;
  77993. return $str;
  77994. }
  77995. public function reverse(): parent
  77996. {
  77997. $str = clone $this;
  77998. $str->string = implode('', array_reverse(preg_split('/(\X)/u', $str->string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY)));
  77999. return $str;
  78000. }
  78001. public function snake(): parent
  78002. {
  78003. $str = $this->camel()->title();
  78004. $str->string = mb_strtolower(preg_replace(['/(\p{Lu}+)(\p{Lu}\p{Ll})/u', '/([\p{Ll}0-9])(\p{Lu})/u'], '\1_\2', $str->string), 'UTF-8');
  78005. return $str;
  78006. }
  78007. public function title(bool $allWords = false): parent
  78008. {
  78009. $str = clone $this;
  78010. $limit = $allWords ? -1 : 1;
  78011. $str->string = preg_replace_callback('/\b./u', static function (array $m): string {
  78012. return mb_convert_case($m[0], \MB_CASE_TITLE, 'UTF-8');
  78013. }, $str->string, $limit);
  78014. return $str;
  78015. }
  78016. public function trim(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): parent
  78017. {
  78018. if (" \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}" !== $chars && !preg_match('//u', $chars)) {
  78019. throw new InvalidArgumentException('Invalid UTF-8 chars.');
  78020. }
  78021. $chars = preg_quote($chars);
  78022. $str = clone $this;
  78023. $str->string = preg_replace("{^[$chars]++|[$chars]++$}uD", '', $str->string);
  78024. return $str;
  78025. }
  78026. public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): parent
  78027. {
  78028. if (" \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}" !== $chars && !preg_match('//u', $chars)) {
  78029. throw new InvalidArgumentException('Invalid UTF-8 chars.');
  78030. }
  78031. $chars = preg_quote($chars);
  78032. $str = clone $this;
  78033. $str->string = preg_replace("{[$chars]++$}uD", '', $str->string);
  78034. return $str;
  78035. }
  78036. public function trimPrefix($prefix): parent
  78037. {
  78038. if (!$this->ignoreCase) {
  78039. return parent::trimPrefix($prefix);
  78040. }
  78041. $str = clone $this;
  78042. if ($prefix instanceof \Traversable) {
  78043. $prefix = iterator_to_array($prefix, false);
  78044. } elseif ($prefix instanceof parent) {
  78045. $prefix = $prefix->string;
  78046. }
  78047. $prefix = implode('|', array_map('preg_quote', (array) $prefix));
  78048. $str->string = preg_replace("{^(?:$prefix)}iuD", '', $this->string);
  78049. return $str;
  78050. }
  78051. public function trimStart(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): parent
  78052. {
  78053. if (" \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}" !== $chars && !preg_match('//u', $chars)) {
  78054. throw new InvalidArgumentException('Invalid UTF-8 chars.');
  78055. }
  78056. $chars = preg_quote($chars);
  78057. $str = clone $this;
  78058. $str->string = preg_replace("{^[$chars]++}uD", '', $str->string);
  78059. return $str;
  78060. }
  78061. public function trimSuffix($suffix): parent
  78062. {
  78063. if (!$this->ignoreCase) {
  78064. return parent::trimSuffix($suffix);
  78065. }
  78066. $str = clone $this;
  78067. if ($suffix instanceof \Traversable) {
  78068. $suffix = iterator_to_array($suffix, false);
  78069. } elseif ($suffix instanceof parent) {
  78070. $suffix = $suffix->string;
  78071. }
  78072. $suffix = implode('|', array_map('preg_quote', (array) $suffix));
  78073. $str->string = preg_replace("{(?:$suffix)$}iuD", '', $this->string);
  78074. return $str;
  78075. }
  78076. public function upper(): parent
  78077. {
  78078. $str = clone $this;
  78079. $str->string = mb_strtoupper($str->string, 'UTF-8');
  78080. if (\PHP_VERSION_ID < 70300) {
  78081. $str->string = str_replace(self::UPPER_FROM, self::UPPER_TO, $str->string);
  78082. }
  78083. return $str;
  78084. }
  78085. public function width(bool $ignoreAnsiDecoration = true): int
  78086. {
  78087. $width = 0;
  78088. $s = str_replace(["\x00", "\x05", "\x07"], '', $this->string);
  78089. if (false !== strpos($s, "\r")) {
  78090. $s = str_replace(["\r\n", "\r"], "\n", $s);
  78091. }
  78092. if (!$ignoreAnsiDecoration) {
  78093. $s = preg_replace('/[\p{Cc}\x7F]++/u', '', $s);
  78094. }
  78095. foreach (explode("\n", $s) as $s) {
  78096. if ($ignoreAnsiDecoration) {
  78097. $s = preg_replace('/(?:\x1B(?:
  78098. \[ [\x30-\x3F]*+ [\x20-\x2F]*+ [0x40-\x7E]
  78099. | [P\]X^_] .*? \x1B\\\\
  78100. | [\x41-\x7E]
  78101. )|[\p{Cc}\x7F]++)/xu', '', $s);
  78102. }
  78103. $width += $this->wcswidth($s);
  78104. }
  78105. return $width;
  78106. }
  78107. private function pad(int $len, self $pad, int $type): parent
  78108. {
  78109. $sLen = $this->length();
  78110. if ($len <= $sLen) {
  78111. return clone $this;
  78112. }
  78113. $padLen = $pad->length();
  78114. $freeLen = $len - $sLen;
  78115. $len = $freeLen % $padLen;
  78116. switch ($type) {
  78117. case \STR_PAD_RIGHT:
  78118. return $this->append(str_repeat($pad->string, intdiv($freeLen, $padLen)).($len ? $pad->slice(0, $len) : ''));
  78119. case \STR_PAD_LEFT:
  78120. return $this->prepend(str_repeat($pad->string, intdiv($freeLen, $padLen)).($len ? $pad->slice(0, $len) : ''));
  78121. case \STR_PAD_BOTH:
  78122. $freeLen /= 2;
  78123. $rightLen = ceil($freeLen);
  78124. $len = $rightLen % $padLen;
  78125. $str = $this->append(str_repeat($pad->string, intdiv($rightLen, $padLen)).($len ? $pad->slice(0, $len) : ''));
  78126. $leftLen = floor($freeLen);
  78127. $len = $leftLen % $padLen;
  78128. return $str->prepend(str_repeat($pad->string, intdiv($leftLen, $padLen)).($len ? $pad->slice(0, $len) : ''));
  78129. default:
  78130. throw new InvalidArgumentException('Invalid padding type.');
  78131. }
  78132. }
  78133. private function wcswidth(string $string): int
  78134. {
  78135. $width = 0;
  78136. foreach (preg_split('//u', $string, -1, \PREG_SPLIT_NO_EMPTY) as $c) {
  78137. $codePoint = mb_ord($c, 'UTF-8');
  78138. if (0 === $codePoint
  78139. || 0x034F === $codePoint
  78140. || (0x200B <= $codePoint && 0x200F >= $codePoint)
  78141. || 0x2028 === $codePoint
  78142. || 0x2029 === $codePoint
  78143. || (0x202A <= $codePoint && 0x202E >= $codePoint)
  78144. || (0x2060 <= $codePoint && 0x2063 >= $codePoint)
  78145. ) {
  78146. continue;
  78147. }
  78148. if (32 > $codePoint
  78149. || (0x07F <= $codePoint && 0x0A0 > $codePoint)
  78150. ) {
  78151. return -1;
  78152. }
  78153. if (null === self::$tableZero) {
  78154. self::$tableZero = require __DIR__.'/Resources/data/wcswidth_table_zero.php';
  78155. }
  78156. if ($codePoint >= self::$tableZero[0][0] && $codePoint <= self::$tableZero[$ubound = \count(self::$tableZero) - 1][1]) {
  78157. $lbound = 0;
  78158. while ($ubound >= $lbound) {
  78159. $mid = floor(($lbound + $ubound) / 2);
  78160. if ($codePoint > self::$tableZero[$mid][1]) {
  78161. $lbound = $mid + 1;
  78162. } elseif ($codePoint < self::$tableZero[$mid][0]) {
  78163. $ubound = $mid - 1;
  78164. } else {
  78165. continue 2;
  78166. }
  78167. }
  78168. }
  78169. if (null === self::$tableWide) {
  78170. self::$tableWide = require __DIR__.'/Resources/data/wcswidth_table_wide.php';
  78171. }
  78172. if ($codePoint >= self::$tableWide[0][0] && $codePoint <= self::$tableWide[$ubound = \count(self::$tableWide) - 1][1]) {
  78173. $lbound = 0;
  78174. while ($ubound >= $lbound) {
  78175. $mid = floor(($lbound + $ubound) / 2);
  78176. if ($codePoint > self::$tableWide[$mid][1]) {
  78177. $lbound = $mid + 1;
  78178. } elseif ($codePoint < self::$tableWide[$mid][0]) {
  78179. $ubound = $mid - 1;
  78180. } else {
  78181. $width += 2;
  78182. continue 2;
  78183. }
  78184. }
  78185. }
  78186. ++$width;
  78187. }
  78188. return $width;
  78189. }
  78190. }
  78191. <?php
  78192. namespace Symfony\Component\String;
  78193. use Symfony\Component\String\Exception\ExceptionInterface;
  78194. use Symfony\Component\String\Exception\InvalidArgumentException;
  78195. use Symfony\Component\String\Exception\RuntimeException;
  78196. class ByteString extends AbstractString
  78197. {
  78198. private const ALPHABET_ALPHANUMERIC = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
  78199. public function __construct(string $string = '')
  78200. {
  78201. $this->string = $string;
  78202. }
  78203. public static function fromRandom(int $length = 16, string $alphabet = null): self
  78204. {
  78205. if ($length <= 0) {
  78206. throw new InvalidArgumentException(sprintf('A strictly positive length is expected, "%d" given.', $length));
  78207. }
  78208. $alphabet = $alphabet ?? self::ALPHABET_ALPHANUMERIC;
  78209. $alphabetSize = \strlen($alphabet);
  78210. $bits = (int) ceil(log($alphabetSize, 2.0));
  78211. if ($bits <= 0 || $bits > 56) {
  78212. throw new InvalidArgumentException('The length of the alphabet must in the [2^1, 2^56] range.');
  78213. }
  78214. $ret = '';
  78215. while ($length > 0) {
  78216. $urandomLength = (int) ceil(2 * $length * $bits / 8.0);
  78217. $data = random_bytes($urandomLength);
  78218. $unpackedData = 0;
  78219. $unpackedBits = 0;
  78220. for ($i = 0; $i < $urandomLength && $length > 0; ++$i) {
  78221. $unpackedData = ($unpackedData << 8) | \ord($data[$i]);
  78222. $unpackedBits += 8;
  78223. for (; $unpackedBits >= $bits && $length > 0; $unpackedBits -= $bits) {
  78224. $index = ($unpackedData & ((1 << $bits) - 1));
  78225. $unpackedData >>= $bits;
  78226. if ($index < $alphabetSize) {
  78227. $ret .= $alphabet[$index];
  78228. --$length;
  78229. }
  78230. }
  78231. }
  78232. }
  78233. return new static($ret);
  78234. }
  78235. public function bytesAt(int $offset): array
  78236. {
  78237. $str = $this->string[$offset] ?? '';
  78238. return '' === $str ? [] : [\ord($str)];
  78239. }
  78240. public function append(string ...$suffix): parent
  78241. {
  78242. $str = clone $this;
  78243. $str->string .= 1 >= \count($suffix) ? ($suffix[0] ?? '') : implode('', $suffix);
  78244. return $str;
  78245. }
  78246. public function camel(): parent
  78247. {
  78248. $str = clone $this;
  78249. $str->string = lcfirst(str_replace(' ', '', ucwords(preg_replace('/[^a-zA-Z0-9\x7f-\xff]++/', ' ', $this->string))));
  78250. return $str;
  78251. }
  78252. public function chunk(int $length = 1): array
  78253. {
  78254. if (1 > $length) {
  78255. throw new InvalidArgumentException('The chunk length must be greater than zero.');
  78256. }
  78257. if ('' === $this->string) {
  78258. return [];
  78259. }
  78260. $str = clone $this;
  78261. $chunks = [];
  78262. foreach (str_split($this->string, $length) as $chunk) {
  78263. $str->string = $chunk;
  78264. $chunks[] = clone $str;
  78265. }
  78266. return $chunks;
  78267. }
  78268. public function endsWith($suffix): bool
  78269. {
  78270. if ($suffix instanceof parent) {
  78271. $suffix = $suffix->string;
  78272. } elseif (\is_array($suffix) || $suffix instanceof \Traversable) {
  78273. return parent::endsWith($suffix);
  78274. } else {
  78275. $suffix = (string) $suffix;
  78276. }
  78277. return '' !== $suffix && \strlen($this->string) >= \strlen($suffix) && 0 === substr_compare($this->string, $suffix, -\strlen($suffix), null, $this->ignoreCase);
  78278. }
  78279. public function equalsTo($string): bool
  78280. {
  78281. if ($string instanceof parent) {
  78282. $string = $string->string;
  78283. } elseif (\is_array($string) || $string instanceof \Traversable) {
  78284. return parent::equalsTo($string);
  78285. } else {
  78286. $string = (string) $string;
  78287. }
  78288. if ('' !== $string && $this->ignoreCase) {
  78289. return 0 === strcasecmp($string, $this->string);
  78290. }
  78291. return $string === $this->string;
  78292. }
  78293. public function folded(): parent
  78294. {
  78295. $str = clone $this;
  78296. $str->string = strtolower($str->string);
  78297. return $str;
  78298. }
  78299. public function indexOf($needle, int $offset = 0): ?int
  78300. {
  78301. if ($needle instanceof parent) {
  78302. $needle = $needle->string;
  78303. } elseif (\is_array($needle) || $needle instanceof \Traversable) {
  78304. return parent::indexOf($needle, $offset);
  78305. } else {
  78306. $needle = (string) $needle;
  78307. }
  78308. if ('' === $needle) {
  78309. return null;
  78310. }
  78311. $i = $this->ignoreCase ? stripos($this->string, $needle, $offset) : strpos($this->string, $needle, $offset);
  78312. return false === $i ? null : $i;
  78313. }
  78314. public function indexOfLast($needle, int $offset = 0): ?int
  78315. {
  78316. if ($needle instanceof parent) {
  78317. $needle = $needle->string;
  78318. } elseif (\is_array($needle) || $needle instanceof \Traversable) {
  78319. return parent::indexOfLast($needle, $offset);
  78320. } else {
  78321. $needle = (string) $needle;
  78322. }
  78323. if ('' === $needle) {
  78324. return null;
  78325. }
  78326. $i = $this->ignoreCase ? strripos($this->string, $needle, $offset) : strrpos($this->string, $needle, $offset);
  78327. return false === $i ? null : $i;
  78328. }
  78329. public function isUtf8(): bool
  78330. {
  78331. return '' === $this->string || preg_match('//u', $this->string);
  78332. }
  78333. public function join(array $strings, string $lastGlue = null): parent
  78334. {
  78335. $str = clone $this;
  78336. $tail = null !== $lastGlue && 1 < \count($strings) ? $lastGlue.array_pop($strings) : '';
  78337. $str->string = implode($this->string, $strings).$tail;
  78338. return $str;
  78339. }
  78340. public function length(): int
  78341. {
  78342. return \strlen($this->string);
  78343. }
  78344. public function lower(): parent
  78345. {
  78346. $str = clone $this;
  78347. $str->string = strtolower($str->string);
  78348. return $str;
  78349. }
  78350. public function match(string $regexp, int $flags = 0, int $offset = 0): array
  78351. {
  78352. $match = ((\PREG_PATTERN_ORDER | \PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match';
  78353. if ($this->ignoreCase) {
  78354. $regexp .= 'i';
  78355. }
  78356. set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
  78357. try {
  78358. if (false === $match($regexp, $this->string, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset)) {
  78359. $lastError = preg_last_error();
  78360. foreach (get_defined_constants(true)['pcre'] as $k => $v) {
  78361. if ($lastError === $v && '_ERROR' === substr($k, -6)) {
  78362. throw new RuntimeException('Matching failed with '.$k.'.');
  78363. }
  78364. }
  78365. throw new RuntimeException('Matching failed with unknown error code.');
  78366. }
  78367. } finally {
  78368. restore_error_handler();
  78369. }
  78370. return $matches;
  78371. }
  78372. public function padBoth(int $length, string $padStr = ' '): parent
  78373. {
  78374. $str = clone $this;
  78375. $str->string = str_pad($this->string, $length, $padStr, \STR_PAD_BOTH);
  78376. return $str;
  78377. }
  78378. public function padEnd(int $length, string $padStr = ' '): parent
  78379. {
  78380. $str = clone $this;
  78381. $str->string = str_pad($this->string, $length, $padStr, \STR_PAD_RIGHT);
  78382. return $str;
  78383. }
  78384. public function padStart(int $length, string $padStr = ' '): parent
  78385. {
  78386. $str = clone $this;
  78387. $str->string = str_pad($this->string, $length, $padStr, \STR_PAD_LEFT);
  78388. return $str;
  78389. }
  78390. public function prepend(string ...$prefix): parent
  78391. {
  78392. $str = clone $this;
  78393. $str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$str->string;
  78394. return $str;
  78395. }
  78396. public function replace(string $from, string $to): parent
  78397. {
  78398. $str = clone $this;
  78399. if ('' !== $from) {
  78400. $str->string = $this->ignoreCase ? str_ireplace($from, $to, $this->string) : str_replace($from, $to, $this->string);
  78401. }
  78402. return $str;
  78403. }
  78404. public function replaceMatches(string $fromRegexp, $to): parent
  78405. {
  78406. if ($this->ignoreCase) {
  78407. $fromRegexp .= 'i';
  78408. }
  78409. if (\is_array($to)) {
  78410. if (!\is_callable($to)) {
  78411. throw new \TypeError(sprintf('Argument 2 passed to "%s::replaceMatches()" must be callable, array given.', static::class));
  78412. }
  78413. $replace = 'preg_replace_callback';
  78414. } else {
  78415. $replace = $to instanceof \Closure ? 'preg_replace_callback' : 'preg_replace';
  78416. }
  78417. set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
  78418. try {
  78419. if (null === $string = $replace($fromRegexp, $to, $this->string)) {
  78420. $lastError = preg_last_error();
  78421. foreach (get_defined_constants(true)['pcre'] as $k => $v) {
  78422. if ($lastError === $v && '_ERROR' === substr($k, -6)) {
  78423. throw new RuntimeException('Matching failed with '.$k.'.');
  78424. }
  78425. }
  78426. throw new RuntimeException('Matching failed with unknown error code.');
  78427. }
  78428. } finally {
  78429. restore_error_handler();
  78430. }
  78431. $str = clone $this;
  78432. $str->string = $string;
  78433. return $str;
  78434. }
  78435. public function reverse(): parent
  78436. {
  78437. $str = clone $this;
  78438. $str->string = strrev($str->string);
  78439. return $str;
  78440. }
  78441. public function slice(int $start = 0, int $length = null): parent
  78442. {
  78443. $str = clone $this;
  78444. $str->string = (string) substr($this->string, $start, $length ?? \PHP_INT_MAX);
  78445. return $str;
  78446. }
  78447. public function snake(): parent
  78448. {
  78449. $str = $this->camel()->title();
  78450. $str->string = strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], '\1_\2', $str->string));
  78451. return $str;
  78452. }
  78453. public function splice(string $replacement, int $start = 0, int $length = null): parent
  78454. {
  78455. $str = clone $this;
  78456. $str->string = substr_replace($this->string, $replacement, $start, $length ?? \PHP_INT_MAX);
  78457. return $str;
  78458. }
  78459. public function split(string $delimiter, int $limit = null, int $flags = null): array
  78460. {
  78461. if (1 > $limit = $limit ?? \PHP_INT_MAX) {
  78462. throw new InvalidArgumentException('Split limit must be a positive integer.');
  78463. }
  78464. if ('' === $delimiter) {
  78465. throw new InvalidArgumentException('Split delimiter is empty.');
  78466. }
  78467. if (null !== $flags) {
  78468. return parent::split($delimiter, $limit, $flags);
  78469. }
  78470. $str = clone $this;
  78471. $chunks = $this->ignoreCase
  78472. ? preg_split('{'.preg_quote($delimiter).'}iD', $this->string, $limit)
  78473. : explode($delimiter, $this->string, $limit);
  78474. foreach ($chunks as &$chunk) {
  78475. $str->string = $chunk;
  78476. $chunk = clone $str;
  78477. }
  78478. return $chunks;
  78479. }
  78480. public function startsWith($prefix): bool
  78481. {
  78482. if ($prefix instanceof parent) {
  78483. $prefix = $prefix->string;
  78484. } elseif (!\is_string($prefix)) {
  78485. return parent::startsWith($prefix);
  78486. }
  78487. return '' !== $prefix && 0 === ($this->ignoreCase ? strncasecmp($this->string, $prefix, \strlen($prefix)) : strncmp($this->string, $prefix, \strlen($prefix)));
  78488. }
  78489. public function title(bool $allWords = false): parent
  78490. {
  78491. $str = clone $this;
  78492. $str->string = $allWords ? ucwords($str->string) : ucfirst($str->string);
  78493. return $str;
  78494. }
  78495. public function toUnicodeString(string $fromEncoding = null): UnicodeString
  78496. {
  78497. return new UnicodeString($this->toCodePointString($fromEncoding)->string);
  78498. }
  78499. public function toCodePointString(string $fromEncoding = null): CodePointString
  78500. {
  78501. $u = new CodePointString();
  78502. if (\in_array($fromEncoding, [null, 'utf8', 'utf-8', 'UTF8', 'UTF-8'], true) && preg_match('//u', $this->string)) {
  78503. $u->string = $this->string;
  78504. return $u;
  78505. }
  78506. set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
  78507. try {
  78508. try {
  78509. $validEncoding = false !== mb_detect_encoding($this->string, $fromEncoding ?? 'Windows-1252', true);
  78510. } catch (InvalidArgumentException $e) {
  78511. if (!\function_exists('iconv')) {
  78512. throw $e;
  78513. }
  78514. $u->string = iconv($fromEncoding ?? 'Windows-1252', 'UTF-8', $this->string);
  78515. return $u;
  78516. }
  78517. } finally {
  78518. restore_error_handler();
  78519. }
  78520. if (!$validEncoding) {
  78521. throw new InvalidArgumentException(sprintf('Invalid "%s" string.', $fromEncoding ?? 'Windows-1252'));
  78522. }
  78523. $u->string = mb_convert_encoding($this->string, 'UTF-8', $fromEncoding ?? 'Windows-1252');
  78524. return $u;
  78525. }
  78526. public function trim(string $chars = " \t\n\r\0\x0B\x0C"): parent
  78527. {
  78528. $str = clone $this;
  78529. $str->string = trim($str->string, $chars);
  78530. return $str;
  78531. }
  78532. public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C"): parent
  78533. {
  78534. $str = clone $this;
  78535. $str->string = rtrim($str->string, $chars);
  78536. return $str;
  78537. }
  78538. public function trimStart(string $chars = " \t\n\r\0\x0B\x0C"): parent
  78539. {
  78540. $str = clone $this;
  78541. $str->string = ltrim($str->string, $chars);
  78542. return $str;
  78543. }
  78544. public function upper(): parent
  78545. {
  78546. $str = clone $this;
  78547. $str->string = strtoupper($str->string);
  78548. return $str;
  78549. }
  78550. public function width(bool $ignoreAnsiDecoration = true): int
  78551. {
  78552. $string = preg_match('//u', $this->string) ? $this->string : preg_replace('/[\x80-\xFF]/', '?', $this->string);
  78553. return (new CodePointString($string))->width($ignoreAnsiDecoration);
  78554. }
  78555. }
  78556. <?php
  78557. namespace Symfony\Component\String;
  78558. use Symfony\Component\String\Exception\ExceptionInterface;
  78559. use Symfony\Component\String\Exception\InvalidArgumentException;
  78560. class CodePointString extends AbstractUnicodeString
  78561. {
  78562. public function __construct(string $string = '')
  78563. {
  78564. if ('' !== $string && !preg_match('//u', $string)) {
  78565. throw new InvalidArgumentException('Invalid UTF-8 string.');
  78566. }
  78567. $this->string = $string;
  78568. }
  78569. public function append(string ...$suffix): AbstractString
  78570. {
  78571. $str = clone $this;
  78572. $str->string .= 1 >= \count($suffix) ? ($suffix[0] ?? '') : implode('', $suffix);
  78573. if (!preg_match('//u', $str->string)) {
  78574. throw new InvalidArgumentException('Invalid UTF-8 string.');
  78575. }
  78576. return $str;
  78577. }
  78578. public function chunk(int $length = 1): array
  78579. {
  78580. if (1 > $length) {
  78581. throw new InvalidArgumentException('The chunk length must be greater than zero.');
  78582. }
  78583. if ('' === $this->string) {
  78584. return [];
  78585. }
  78586. $rx = '/(';
  78587. while (65535 < $length) {
  78588. $rx .= '.{65535}';
  78589. $length -= 65535;
  78590. }
  78591. $rx .= '.{'.$length.'})/us';
  78592. $str = clone $this;
  78593. $chunks = [];
  78594. foreach (preg_split($rx, $this->string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY) as $chunk) {
  78595. $str->string = $chunk;
  78596. $chunks[] = clone $str;
  78597. }
  78598. return $chunks;
  78599. }
  78600. public function codePointsAt(int $offset): array
  78601. {
  78602. $str = $offset ? $this->slice($offset, 1) : $this;
  78603. return '' === $str->string ? [] : [mb_ord($str->string, 'UTF-8')];
  78604. }
  78605. public function endsWith($suffix): bool
  78606. {
  78607. if ($suffix instanceof AbstractString) {
  78608. $suffix = $suffix->string;
  78609. } elseif (\is_array($suffix) || $suffix instanceof \Traversable) {
  78610. return parent::endsWith($suffix);
  78611. } else {
  78612. $suffix = (string) $suffix;
  78613. }
  78614. if ('' === $suffix || !preg_match('//u', $suffix)) {
  78615. return false;
  78616. }
  78617. if ($this->ignoreCase) {
  78618. return preg_match('{'.preg_quote($suffix).'$}iuD', $this->string);
  78619. }
  78620. return \strlen($this->string) >= \strlen($suffix) && 0 === substr_compare($this->string, $suffix, -\strlen($suffix));
  78621. }
  78622. public function equalsTo($string): bool
  78623. {
  78624. if ($string instanceof AbstractString) {
  78625. $string = $string->string;
  78626. } elseif (\is_array($string) || $string instanceof \Traversable) {
  78627. return parent::equalsTo($string);
  78628. } else {
  78629. $string = (string) $string;
  78630. }
  78631. if ('' !== $string && $this->ignoreCase) {
  78632. return \strlen($string) === \strlen($this->string) && 0 === mb_stripos($this->string, $string, 0, 'UTF-8');
  78633. }
  78634. return $string === $this->string;
  78635. }
  78636. public function indexOf($needle, int $offset = 0): ?int
  78637. {
  78638. if ($needle instanceof AbstractString) {
  78639. $needle = $needle->string;
  78640. } elseif (\is_array($needle) || $needle instanceof \Traversable) {
  78641. return parent::indexOf($needle, $offset);
  78642. } else {
  78643. $needle = (string) $needle;
  78644. }
  78645. if ('' === $needle) {
  78646. return null;
  78647. }
  78648. $i = $this->ignoreCase ? mb_stripos($this->string, $needle, $offset, 'UTF-8') : mb_strpos($this->string, $needle, $offset, 'UTF-8');
  78649. return false === $i ? null : $i;
  78650. }
  78651. public function indexOfLast($needle, int $offset = 0): ?int
  78652. {
  78653. if ($needle instanceof AbstractString) {
  78654. $needle = $needle->string;
  78655. } elseif (\is_array($needle) || $needle instanceof \Traversable) {
  78656. return parent::indexOfLast($needle, $offset);
  78657. } else {
  78658. $needle = (string) $needle;
  78659. }
  78660. if ('' === $needle) {
  78661. return null;
  78662. }
  78663. $i = $this->ignoreCase ? mb_strripos($this->string, $needle, $offset, 'UTF-8') : mb_strrpos($this->string, $needle, $offset, 'UTF-8');
  78664. return false === $i ? null : $i;
  78665. }
  78666. public function length(): int
  78667. {
  78668. return mb_strlen($this->string, 'UTF-8');
  78669. }
  78670. public function prepend(string ...$prefix): AbstractString
  78671. {
  78672. $str = clone $this;
  78673. $str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$this->string;
  78674. if (!preg_match('//u', $str->string)) {
  78675. throw new InvalidArgumentException('Invalid UTF-8 string.');
  78676. }
  78677. return $str;
  78678. }
  78679. public function replace(string $from, string $to): AbstractString
  78680. {
  78681. $str = clone $this;
  78682. if ('' === $from || !preg_match('//u', $from)) {
  78683. return $str;
  78684. }
  78685. if ('' !== $to && !preg_match('//u', $to)) {
  78686. throw new InvalidArgumentException('Invalid UTF-8 string.');
  78687. }
  78688. if ($this->ignoreCase) {
  78689. $str->string = implode($to, preg_split('{'.preg_quote($from).'}iuD', $this->string));
  78690. } else {
  78691. $str->string = str_replace($from, $to, $this->string);
  78692. }
  78693. return $str;
  78694. }
  78695. public function slice(int $start = 0, int $length = null): AbstractString
  78696. {
  78697. $str = clone $this;
  78698. $str->string = mb_substr($this->string, $start, $length, 'UTF-8');
  78699. return $str;
  78700. }
  78701. public function splice(string $replacement, int $start = 0, int $length = null): AbstractString
  78702. {
  78703. if (!preg_match('//u', $replacement)) {
  78704. throw new InvalidArgumentException('Invalid UTF-8 string.');
  78705. }
  78706. $str = clone $this;
  78707. $start = $start ? \strlen(mb_substr($this->string, 0, $start, 'UTF-8')) : 0;
  78708. $length = $length ? \strlen(mb_substr($this->string, $start, $length, 'UTF-8')) : $length;
  78709. $str->string = substr_replace($this->string, $replacement, $start, $length ?? \PHP_INT_MAX);
  78710. return $str;
  78711. }
  78712. public function split(string $delimiter, int $limit = null, int $flags = null): array
  78713. {
  78714. if (1 > $limit = $limit ?? \PHP_INT_MAX) {
  78715. throw new InvalidArgumentException('Split limit must be a positive integer.');
  78716. }
  78717. if ('' === $delimiter) {
  78718. throw new InvalidArgumentException('Split delimiter is empty.');
  78719. }
  78720. if (null !== $flags) {
  78721. return parent::split($delimiter.'u', $limit, $flags);
  78722. }
  78723. if (!preg_match('//u', $delimiter)) {
  78724. throw new InvalidArgumentException('Split delimiter is not a valid UTF-8 string.');
  78725. }
  78726. $str = clone $this;
  78727. $chunks = $this->ignoreCase
  78728. ? preg_split('{'.preg_quote($delimiter).'}iuD', $this->string, $limit)
  78729. : explode($delimiter, $this->string, $limit);
  78730. foreach ($chunks as &$chunk) {
  78731. $str->string = $chunk;
  78732. $chunk = clone $str;
  78733. }
  78734. return $chunks;
  78735. }
  78736. public function startsWith($prefix): bool
  78737. {
  78738. if ($prefix instanceof AbstractString) {
  78739. $prefix = $prefix->string;
  78740. } elseif (\is_array($prefix) || $prefix instanceof \Traversable) {
  78741. return parent::startsWith($prefix);
  78742. } else {
  78743. $prefix = (string) $prefix;
  78744. }
  78745. if ('' === $prefix || !preg_match('//u', $prefix)) {
  78746. return false;
  78747. }
  78748. if ($this->ignoreCase) {
  78749. return 0 === mb_stripos($this->string, $prefix, 0, 'UTF-8');
  78750. }
  78751. return 0 === strncmp($this->string, $prefix, \strlen($prefix));
  78752. }
  78753. }
  78754. <?php
  78755. namespace Symfony\Component\String\Exception;
  78756. interface ExceptionInterface extends \Throwable
  78757. {
  78758. }
  78759. <?php
  78760. namespace Symfony\Component\String\Exception;
  78761. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  78762. {
  78763. }
  78764. <?php
  78765. namespace Symfony\Component\String\Exception;
  78766. class RuntimeException extends \RuntimeException implements ExceptionInterface
  78767. {
  78768. }
  78769. <?php
  78770. namespace Symfony\Component\String\Inflector;
  78771. final class EnglishInflector implements InflectorInterface
  78772. {
  78773. private const PLURAL_MAP = [
  78774. ['a', 1, true, true, ['on', 'um']],
  78775. ['ea', 2, true, true, 'a'],
  78776. ['secivres', 8, true, true, 'service'],
  78777. ['eci', 3, false, true, 'ouse'],
  78778. ['esee', 4, false, true, 'oose'],
  78779. ['i', 1, true, true, 'us'],
  78780. ['nem', 3, true, true, 'man'],
  78781. ['nerdlihc', 8, true, true, 'child'],
  78782. ['nexo', 4, false, false, 'ox'],
  78783. ['seci', 4, false, true, ['ex', 'ix', 'ice']],
  78784. ['seifles', 7, true, true, 'selfie'],
  78785. ['seibmoz', 7, true, true, 'zombie'],
  78786. ['seivom', 6, true, true, 'movie'],
  78787. ['sesutcep', 8, true, true, 'pectus'],
  78788. ['teef', 4, true, true, 'foot'],
  78789. ['eseeg', 5, true, true, 'goose'],
  78790. ['hteet', 5, true, true, 'tooth'],
  78791. ['swen', 4, true, true, 'news'],
  78792. ['seires', 6, true, true, 'series'],
  78793. ['sei', 3, false, true, 'y'],
  78794. ['sess', 4, true, false, 'ss'],
  78795. ['ses', 3, true, true, ['s', 'se', 'sis']],
  78796. ['sevit', 5, true, true, 'tive'],
  78797. ['sevird', 6, false, true, 'drive'],
  78798. ['sevi', 4, false, true, 'ife'],
  78799. ['sevom', 5, true, true, 'move'],
  78800. ['sev', 3, true, true, ['f', 've', 'ff']],
  78801. ['sexa', 4, false, false, ['ax', 'axe', 'axis']],
  78802. ['sex', 3, true, false, 'x'],
  78803. ['sezz', 4, true, false, 'z'],
  78804. ['suae', 4, false, true, 'eau'],
  78805. ['see', 3, true, true, 'ee'],
  78806. ['segd', 4, true, true, 'dge'],
  78807. ['se', 2, true, true, ['', 'e']],
  78808. ['s', 1, true, true, ''],
  78809. ['xuae', 4, false, true, 'eau'],
  78810. ['elpoep', 6, true, true, 'person'],
  78811. ];
  78812. private const SINGULAR_MAP = [
  78813. ['airetirc', 8, false, false, 'criterion'],
  78814. ['aluben', 6, false, false, 'nebulae'],
  78815. ['dlihc', 5, true, true, 'children'],
  78816. ['eci', 3, false, true, 'ices'],
  78817. ['ecivres', 7, true, true, 'services'],
  78818. ['efi', 3, false, true, 'ives'],
  78819. ['eifles', 6, true, true, 'selfies'],
  78820. ['eivom', 5, true, true, 'movies'],
  78821. ['esuol', 5, false, true, 'lice'],
  78822. ['esuom', 5, false, true, 'mice'],
  78823. ['esoo', 4, false, true, 'eese'],
  78824. ['es', 2, true, true, 'ses'],
  78825. ['esoog', 5, true, true, 'geese'],
  78826. ['ev', 2, true, true, 'ves'],
  78827. ['evird', 5, false, true, 'drives'],
  78828. ['evit', 4, true, true, 'tives'],
  78829. ['evom', 4, true, true, 'moves'],
  78830. ['ffats', 5, true, true, 'staves'],
  78831. ['ff', 2, true, true, 'ffs'],
  78832. ['f', 1, true, true, ['fs', 'ves']],
  78833. ['hc', 2, true, true, 'ches'],
  78834. ['hs', 2, true, true, 'shes'],
  78835. ['htoot', 5, true, true, 'teeth'],
  78836. ['mu', 2, true, true, 'a'],
  78837. ['nam', 3, true, true, 'men'],
  78838. ['nosrep', 6, true, true, ['persons', 'people']],
  78839. ['noi', 3, true, true, 'ions'],
  78840. ['nop', 3, true, true, 'pons'],
  78841. ['nos', 3, true, true, 'sons'],
  78842. ['no', 2, true, true, 'a'],
  78843. ['ohce', 4, true, true, 'echoes'],
  78844. ['oreh', 4, true, true, 'heroes'],
  78845. ['salta', 5, true, true, 'atlases'],
  78846. ['siri', 4, true, true, 'irises'],
  78847. ['sis', 3, true, true, 'ses'],
  78848. ['ss', 2, true, false, 'sses'],
  78849. ['suballys', 8, true, true, 'syllabi'],
  78850. ['sub', 3, true, true, 'buses'],
  78851. ['suc', 3, true, true, 'cuses'],
  78852. ['sutcep', 6, true, true, 'pectuses'],
  78853. ['su', 2, true, true, 'i'],
  78854. ['swen', 4, true, true, 'news'],
  78855. ['toof', 4, true, true, 'feet'],
  78856. ['uae', 3, false, true, ['eaus', 'eaux']],
  78857. ['xo', 2, false, false, 'oxen'],
  78858. ['xaoh', 4, true, false, 'hoaxes'],
  78859. ['xedni', 5, false, true, ['indicies', 'indexes']],
  78860. ['xo', 2, false, true, 'oxes'],
  78861. ['x', 1, true, false, ['cies', 'xes']],
  78862. ['xi', 2, false, true, 'ices'],
  78863. ['y', 1, false, true, 'ies'],
  78864. ['ziuq', 4, true, false, 'quizzes'],
  78865. ['z', 1, true, true, 'zes'],
  78866. ];
  78867. private const UNINFLECTED = [
  78868. '',
  78869. 'atad',
  78870. 'reed',
  78871. 'kcabdeef',
  78872. 'hsif',
  78873. 'ofni',
  78874. 'esoom',
  78875. 'seires',
  78876. 'peehs',
  78877. 'seiceps',
  78878. ];
  78879. public function singularize(string $plural): array
  78880. {
  78881. $pluralRev = strrev($plural);
  78882. $lowerPluralRev = strtolower($pluralRev);
  78883. $pluralLength = \strlen($lowerPluralRev);
  78884. if (\in_array($lowerPluralRev, self::UNINFLECTED, true)) {
  78885. return [$plural];
  78886. }
  78887. foreach (self::PLURAL_MAP as $map) {
  78888. $suffix = $map[0];
  78889. $suffixLength = $map[1];
  78890. $j = 0;
  78891. while ($suffix[$j] === $lowerPluralRev[$j]) {
  78892. ++$j;
  78893. if ($j === $suffixLength) {
  78894. if ($j < $pluralLength) {
  78895. $nextIsVocal = false !== strpos('aeiou', $lowerPluralRev[$j]);
  78896. if (!$map[2] && $nextIsVocal) {
  78897. break;
  78898. }
  78899. if (!$map[3] && !$nextIsVocal) {
  78900. break;
  78901. }
  78902. }
  78903. $newBase = substr($plural, 0, $pluralLength - $suffixLength);
  78904. $newSuffix = $map[4];
  78905. $firstUpper = ctype_upper($pluralRev[$j - 1]);
  78906. if (\is_array($newSuffix)) {
  78907. $singulars = [];
  78908. foreach ($newSuffix as $newSuffixEntry) {
  78909. $singulars[] = $newBase.($firstUpper ? ucfirst($newSuffixEntry) : $newSuffixEntry);
  78910. }
  78911. return $singulars;
  78912. }
  78913. return [$newBase.($firstUpper ? ucfirst($newSuffix) : $newSuffix)];
  78914. }
  78915. if ($j === $pluralLength) {
  78916. break;
  78917. }
  78918. }
  78919. }
  78920. return [$plural];
  78921. }
  78922. public function pluralize(string $singular): array
  78923. {
  78924. $singularRev = strrev($singular);
  78925. $lowerSingularRev = strtolower($singularRev);
  78926. $singularLength = \strlen($lowerSingularRev);
  78927. if (\in_array($lowerSingularRev, self::UNINFLECTED, true)) {
  78928. return [$singular];
  78929. }
  78930. foreach (self::SINGULAR_MAP as $map) {
  78931. $suffix = $map[0];
  78932. $suffixLength = $map[1];
  78933. $j = 0;
  78934. while ($suffix[$j] === $lowerSingularRev[$j]) {
  78935. ++$j;
  78936. if ($j === $suffixLength) {
  78937. if ($j < $singularLength) {
  78938. $nextIsVocal = false !== strpos('aeiou', $lowerSingularRev[$j]);
  78939. if (!$map[2] && $nextIsVocal) {
  78940. break;
  78941. }
  78942. if (!$map[3] && !$nextIsVocal) {
  78943. break;
  78944. }
  78945. }
  78946. $newBase = substr($singular, 0, $singularLength - $suffixLength);
  78947. $newSuffix = $map[4];
  78948. $firstUpper = ctype_upper($singularRev[$j - 1]);
  78949. if (\is_array($newSuffix)) {
  78950. $plurals = [];
  78951. foreach ($newSuffix as $newSuffixEntry) {
  78952. $plurals[] = $newBase.($firstUpper ? ucfirst($newSuffixEntry) : $newSuffixEntry);
  78953. }
  78954. return $plurals;
  78955. }
  78956. return [$newBase.($firstUpper ? ucfirst($newSuffix) : $newSuffix)];
  78957. }
  78958. if ($j === $singularLength) {
  78959. break;
  78960. }
  78961. }
  78962. }
  78963. return [$singular.'s'];
  78964. }
  78965. }
  78966. <?php
  78967. namespace Symfony\Component\String\Inflector;
  78968. final class FrenchInflector implements InflectorInterface
  78969. {
  78970. private const PLURALIZE_REGEXP = [
  78971. ['/(s|x|z)$/i', '\1'],
  78972. ['/(eau)$/i', '\1x'],
  78973. ['/^(landau)$/i', '\1s'],
  78974. ['/(au)$/i', '\1x'],
  78975. ['/^(pneu|bleu|émeu)$/i', '\1s'],
  78976. ['/(eu)$/i', '\1x'],
  78977. ['/^(bal|carnaval|caracal|chacal|choral|corral|étal|festival|récital|val)$/i', '\1s'],
  78978. ['/al$/i', '\1aux'],
  78979. ['/^(aspir|b|cor|ém|ferm|soupir|trav|vant|vitr)ail$/i', '\1aux'],
  78980. ['/^(bij|caill|ch|gen|hib|jouj|p)ou$/i', '\1oux'],
  78981. ['/^(cinquante|soixante|mille)$/i', '\1'],
  78982. ['/^(mon|ma)(sieur|dame|demoiselle|seigneur)$/', 'mes\2s'],
  78983. ['/^(Mon|Ma)(sieur|dame|demoiselle|seigneur)$/', 'Mes\2s'],
  78984. ];
  78985. private const SINGULARIZE_REGEXP = [
  78986. ['/((aspir|b|cor|ém|ferm|soupir|trav|vant|vitr))aux$/i', '\1ail'],
  78987. ['/(eau)x$/i', '\1'],
  78988. ['/(amir|anim|arsen|boc|can|capit|capor|chev|crist|génér|hopit|hôpit|idé|journ|littor|loc|m|mét|minér|princip|radic|termin)aux$/i', '\1al'],
  78989. ['/(au)x$/i', '\1'],
  78990. ['/(eu)x$/i', '\1'],
  78991. ['/(bij|caill|ch|gen|hib|jouj|p)oux$/i', '\1ou'],
  78992. ['/^mes(dame|demoiselle)s$/', 'ma\1'],
  78993. ['/^Mes(dame|demoiselle)s$/', 'Ma\1'],
  78994. ['/^mes(sieur|seigneur)s$/', 'mon\1'],
  78995. ['/^Mes(sieur|seigneur)s$/', 'Mon\1'],
  78996. ['/s$/i', ''],
  78997. ];
  78998. private const UNINFLECTED = '/^(abcès|accès|abus|albatros|anchois|anglais|autobus|bois|brebis|carquois|cas|chas|colis|concours|corps|cours|cyprès|décès|devis|discours|dos|embarras|engrais|entrelacs|excès|fils|fois|gâchis|gars|glas|héros|intrus|jars|jus|kermès|lacis|legs|lilas|marais|mars|matelas|mépris|mets|mois|mors|obus|os|palais|paradis|parcours|pardessus|pays|plusieurs|poids|pois|pouls|printemps|processus|progrès|puits|pus|rabais|radis|recors|recours|refus|relais|remords|remous|rictus|rhinocéros|repas|rubis|sas|secours|sens|souris|succès|talus|tapis|tas|taudis|temps|tiers|univers|velours|verglas|vernis|virus)$/i';
  78999. public function singularize(string $plural): array
  79000. {
  79001. if ($this->isInflectedWord($plural)) {
  79002. return [$plural];
  79003. }
  79004. foreach (self::SINGULARIZE_REGEXP as $rule) {
  79005. [$regexp, $replace] = $rule;
  79006. if (1 === preg_match($regexp, $plural)) {
  79007. return [preg_replace($regexp, $replace, $plural)];
  79008. }
  79009. }
  79010. return [$plural];
  79011. }
  79012. public function pluralize(string $singular): array
  79013. {
  79014. if ($this->isInflectedWord($singular)) {
  79015. return [$singular];
  79016. }
  79017. foreach (self::PLURALIZE_REGEXP as $rule) {
  79018. [$regexp, $replace] = $rule;
  79019. if (1 === preg_match($regexp, $singular)) {
  79020. return [preg_replace($regexp, $replace, $singular)];
  79021. }
  79022. }
  79023. return [$singular.'s'];
  79024. }
  79025. private function isInflectedWord(string $word): bool
  79026. {
  79027. return 1 === preg_match(self::UNINFLECTED, $word);
  79028. }
  79029. }
  79030. <?php
  79031. namespace Symfony\Component\String\Inflector;
  79032. interface InflectorInterface
  79033. {
  79034. public function singularize(string $plural): array;
  79035. public function pluralize(string $singular): array;
  79036. }
  79037. Copyright (c) 2019-2022 Fabien Potencier
  79038. Permission is hereby granted, free of charge, to any person obtaining a copy
  79039. of this software and associated documentation files (the "Software"), to deal
  79040. in the Software without restriction, including without limitation the rights
  79041. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  79042. copies of the Software, and to permit persons to whom the Software is furnished
  79043. to do so, subject to the following conditions:
  79044. The above copyright notice and this permission notice shall be included in all
  79045. copies or substantial portions of the Software.
  79046. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  79047. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  79048. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  79049. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  79050. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  79051. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  79052. THE SOFTWARE.
  79053. <?php
  79054. namespace Symfony\Component\String;
  79055. class LazyString implements \Stringable, \JsonSerializable
  79056. {
  79057. private $value;
  79058. public static function fromCallable($callback, ...$arguments): self
  79059. {
  79060. if (!\is_callable($callback) && !(\is_array($callback) && isset($callback[0]) && $callback[0] instanceof \Closure && 2 >= \count($callback))) {
  79061. throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a callable or a [Closure, method] lazy-callable, "%s" given.', __METHOD__, get_debug_type($callback)));
  79062. }
  79063. $lazyString = new static();
  79064. $lazyString->value = static function () use (&$callback, &$arguments, &$value): string {
  79065. if (null !== $arguments) {
  79066. if (!\is_callable($callback)) {
  79067. $callback[0] = $callback[0]();
  79068. $callback[1] = $callback[1] ?? '__invoke';
  79069. }
  79070. $value = $callback(...$arguments);
  79071. $callback = self::getPrettyName($callback);
  79072. $arguments = null;
  79073. }
  79074. return $value ?? '';
  79075. };
  79076. return $lazyString;
  79077. }
  79078. public static function fromStringable($value): self
  79079. {
  79080. if (!self::isStringable($value)) {
  79081. throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a scalar or a stringable object, "%s" given.', __METHOD__, get_debug_type($value)));
  79082. }
  79083. if (\is_object($value)) {
  79084. return static::fromCallable([$value, '__toString']);
  79085. }
  79086. $lazyString = new static();
  79087. $lazyString->value = (string) $value;
  79088. return $lazyString;
  79089. }
  79090. final public static function isStringable($value): bool
  79091. {
  79092. return \is_string($value) || $value instanceof self || (\is_object($value) ? method_exists($value, '__toString') : is_scalar($value));
  79093. }
  79094. final public static function resolve($value): string
  79095. {
  79096. return $value;
  79097. }
  79098. public function __toString()
  79099. {
  79100. if (\is_string($this->value)) {
  79101. return $this->value;
  79102. }
  79103. try {
  79104. return $this->value = ($this->value)();
  79105. } catch (\Throwable $e) {
  79106. if (\TypeError::class === \get_class($e) && __FILE__ === $e->getFile()) {
  79107. $type = explode(', ', $e->getMessage());
  79108. $type = substr(array_pop($type), 0, -\strlen(' returned'));
  79109. $r = new \ReflectionFunction($this->value);
  79110. $callback = $r->getStaticVariables()['callback'];
  79111. $e = new \TypeError(sprintf('Return value of %s() passed to %s::fromCallable() must be of the type string, %s returned.', $callback, static::class, $type));
  79112. }
  79113. if (\PHP_VERSION_ID < 70400) {
  79114. return trigger_error($e, \E_USER_ERROR);
  79115. }
  79116. throw $e;
  79117. }
  79118. }
  79119. public function __sleep(): array
  79120. {
  79121. $this->__toString();
  79122. return ['value'];
  79123. }
  79124. public function jsonSerialize(): string
  79125. {
  79126. return $this->__toString();
  79127. }
  79128. private function __construct()
  79129. {
  79130. }
  79131. private static function getPrettyName(callable $callback): string
  79132. {
  79133. if (\is_string($callback)) {
  79134. return $callback;
  79135. }
  79136. if (\is_array($callback)) {
  79137. $class = \is_object($callback[0]) ? get_debug_type($callback[0]) : $callback[0];
  79138. $method = $callback[1];
  79139. } elseif ($callback instanceof \Closure) {
  79140. $r = new \ReflectionFunction($callback);
  79141. if (false !== strpos($r->name, '{closure}') || !$class = $r->getClosureScopeClass()) {
  79142. return $r->name;
  79143. }
  79144. $class = $class->name;
  79145. $method = $r->name;
  79146. } else {
  79147. $class = get_debug_type($callback);
  79148. $method = '__invoke';
  79149. }
  79150. return $class.'::'.$method;
  79151. }
  79152. }
  79153. <?php
  79154. return [
  79155. [
  79156. 4352,
  79157. 4447,
  79158. ],
  79159. [
  79160. 8986,
  79161. 8987,
  79162. ],
  79163. [
  79164. 9001,
  79165. 9001,
  79166. ],
  79167. [
  79168. 9002,
  79169. 9002,
  79170. ],
  79171. [
  79172. 9193,
  79173. 9196,
  79174. ],
  79175. [
  79176. 9200,
  79177. 9200,
  79178. ],
  79179. [
  79180. 9203,
  79181. 9203,
  79182. ],
  79183. [
  79184. 9725,
  79185. 9726,
  79186. ],
  79187. [
  79188. 9748,
  79189. 9749,
  79190. ],
  79191. [
  79192. 9800,
  79193. 9811,
  79194. ],
  79195. [
  79196. 9855,
  79197. 9855,
  79198. ],
  79199. [
  79200. 9875,
  79201. 9875,
  79202. ],
  79203. [
  79204. 9889,
  79205. 9889,
  79206. ],
  79207. [
  79208. 9898,
  79209. 9899,
  79210. ],
  79211. [
  79212. 9917,
  79213. 9918,
  79214. ],
  79215. [
  79216. 9924,
  79217. 9925,
  79218. ],
  79219. [
  79220. 9934,
  79221. 9934,
  79222. ],
  79223. [
  79224. 9940,
  79225. 9940,
  79226. ],
  79227. [
  79228. 9962,
  79229. 9962,
  79230. ],
  79231. [
  79232. 9970,
  79233. 9971,
  79234. ],
  79235. [
  79236. 9973,
  79237. 9973,
  79238. ],
  79239. [
  79240. 9978,
  79241. 9978,
  79242. ],
  79243. [
  79244. 9981,
  79245. 9981,
  79246. ],
  79247. [
  79248. 9989,
  79249. 9989,
  79250. ],
  79251. [
  79252. 9994,
  79253. 9995,
  79254. ],
  79255. [
  79256. 10024,
  79257. 10024,
  79258. ],
  79259. [
  79260. 10060,
  79261. 10060,
  79262. ],
  79263. [
  79264. 10062,
  79265. 10062,
  79266. ],
  79267. [
  79268. 10067,
  79269. 10069,
  79270. ],
  79271. [
  79272. 10071,
  79273. 10071,
  79274. ],
  79275. [
  79276. 10133,
  79277. 10135,
  79278. ],
  79279. [
  79280. 10160,
  79281. 10160,
  79282. ],
  79283. [
  79284. 10175,
  79285. 10175,
  79286. ],
  79287. [
  79288. 11035,
  79289. 11036,
  79290. ],
  79291. [
  79292. 11088,
  79293. 11088,
  79294. ],
  79295. [
  79296. 11093,
  79297. 11093,
  79298. ],
  79299. [
  79300. 11904,
  79301. 11929,
  79302. ],
  79303. [
  79304. 11931,
  79305. 12019,
  79306. ],
  79307. [
  79308. 12032,
  79309. 12245,
  79310. ],
  79311. [
  79312. 12272,
  79313. 12283,
  79314. ],
  79315. [
  79316. 12288,
  79317. 12288,
  79318. ],
  79319. [
  79320. 12289,
  79321. 12291,
  79322. ],
  79323. [
  79324. 12292,
  79325. 12292,
  79326. ],
  79327. [
  79328. 12293,
  79329. 12293,
  79330. ],
  79331. [
  79332. 12294,
  79333. 12294,
  79334. ],
  79335. [
  79336. 12295,
  79337. 12295,
  79338. ],
  79339. [
  79340. 12296,
  79341. 12296,
  79342. ],
  79343. [
  79344. 12297,
  79345. 12297,
  79346. ],
  79347. [
  79348. 12298,
  79349. 12298,
  79350. ],
  79351. [
  79352. 12299,
  79353. 12299,
  79354. ],
  79355. [
  79356. 12300,
  79357. 12300,
  79358. ],
  79359. [
  79360. 12301,
  79361. 12301,
  79362. ],
  79363. [
  79364. 12302,
  79365. 12302,
  79366. ],
  79367. [
  79368. 12303,
  79369. 12303,
  79370. ],
  79371. [
  79372. 12304,
  79373. 12304,
  79374. ],
  79375. [
  79376. 12305,
  79377. 12305,
  79378. ],
  79379. [
  79380. 12306,
  79381. 12307,
  79382. ],
  79383. [
  79384. 12308,
  79385. 12308,
  79386. ],
  79387. [
  79388. 12309,
  79389. 12309,
  79390. ],
  79391. [
  79392. 12310,
  79393. 12310,
  79394. ],
  79395. [
  79396. 12311,
  79397. 12311,
  79398. ],
  79399. [
  79400. 12312,
  79401. 12312,
  79402. ],
  79403. [
  79404. 12313,
  79405. 12313,
  79406. ],
  79407. [
  79408. 12314,
  79409. 12314,
  79410. ],
  79411. [
  79412. 12315,
  79413. 12315,
  79414. ],
  79415. [
  79416. 12316,
  79417. 12316,
  79418. ],
  79419. [
  79420. 12317,
  79421. 12317,
  79422. ],
  79423. [
  79424. 12318,
  79425. 12319,
  79426. ],
  79427. [
  79428. 12320,
  79429. 12320,
  79430. ],
  79431. [
  79432. 12321,
  79433. 12329,
  79434. ],
  79435. [
  79436. 12330,
  79437. 12333,
  79438. ],
  79439. [
  79440. 12334,
  79441. 12335,
  79442. ],
  79443. [
  79444. 12336,
  79445. 12336,
  79446. ],
  79447. [
  79448. 12337,
  79449. 12341,
  79450. ],
  79451. [
  79452. 12342,
  79453. 12343,
  79454. ],
  79455. [
  79456. 12344,
  79457. 12346,
  79458. ],
  79459. [
  79460. 12347,
  79461. 12347,
  79462. ],
  79463. [
  79464. 12348,
  79465. 12348,
  79466. ],
  79467. [
  79468. 12349,
  79469. 12349,
  79470. ],
  79471. [
  79472. 12350,
  79473. 12350,
  79474. ],
  79475. [
  79476. 12353,
  79477. 12438,
  79478. ],
  79479. [
  79480. 12441,
  79481. 12442,
  79482. ],
  79483. [
  79484. 12443,
  79485. 12444,
  79486. ],
  79487. [
  79488. 12445,
  79489. 12446,
  79490. ],
  79491. [
  79492. 12447,
  79493. 12447,
  79494. ],
  79495. [
  79496. 12448,
  79497. 12448,
  79498. ],
  79499. [
  79500. 12449,
  79501. 12538,
  79502. ],
  79503. [
  79504. 12539,
  79505. 12539,
  79506. ],
  79507. [
  79508. 12540,
  79509. 12542,
  79510. ],
  79511. [
  79512. 12543,
  79513. 12543,
  79514. ],
  79515. [
  79516. 12549,
  79517. 12591,
  79518. ],
  79519. [
  79520. 12593,
  79521. 12686,
  79522. ],
  79523. [
  79524. 12688,
  79525. 12689,
  79526. ],
  79527. [
  79528. 12690,
  79529. 12693,
  79530. ],
  79531. [
  79532. 12694,
  79533. 12703,
  79534. ],
  79535. [
  79536. 12704,
  79537. 12735,
  79538. ],
  79539. [
  79540. 12736,
  79541. 12771,
  79542. ],
  79543. [
  79544. 12784,
  79545. 12799,
  79546. ],
  79547. [
  79548. 12800,
  79549. 12830,
  79550. ],
  79551. [
  79552. 12832,
  79553. 12841,
  79554. ],
  79555. [
  79556. 12842,
  79557. 12871,
  79558. ],
  79559. [
  79560. 12880,
  79561. 12880,
  79562. ],
  79563. [
  79564. 12881,
  79565. 12895,
  79566. ],
  79567. [
  79568. 12896,
  79569. 12927,
  79570. ],
  79571. [
  79572. 12928,
  79573. 12937,
  79574. ],
  79575. [
  79576. 12938,
  79577. 12976,
  79578. ],
  79579. [
  79580. 12977,
  79581. 12991,
  79582. ],
  79583. [
  79584. 12992,
  79585. 13055,
  79586. ],
  79587. [
  79588. 13056,
  79589. 13311,
  79590. ],
  79591. [
  79592. 13312,
  79593. 19903,
  79594. ],
  79595. [
  79596. 19968,
  79597. 40959,
  79598. ],
  79599. [
  79600. 40960,
  79601. 40980,
  79602. ],
  79603. [
  79604. 40981,
  79605. 40981,
  79606. ],
  79607. [
  79608. 40982,
  79609. 42124,
  79610. ],
  79611. [
  79612. 42128,
  79613. 42182,
  79614. ],
  79615. [
  79616. 43360,
  79617. 43388,
  79618. ],
  79619. [
  79620. 44032,
  79621. 55203,
  79622. ],
  79623. [
  79624. 63744,
  79625. 64109,
  79626. ],
  79627. [
  79628. 64110,
  79629. 64111,
  79630. ],
  79631. [
  79632. 64112,
  79633. 64217,
  79634. ],
  79635. [
  79636. 64218,
  79637. 64255,
  79638. ],
  79639. [
  79640. 65040,
  79641. 65046,
  79642. ],
  79643. [
  79644. 65047,
  79645. 65047,
  79646. ],
  79647. [
  79648. 65048,
  79649. 65048,
  79650. ],
  79651. [
  79652. 65049,
  79653. 65049,
  79654. ],
  79655. [
  79656. 65072,
  79657. 65072,
  79658. ],
  79659. [
  79660. 65073,
  79661. 65074,
  79662. ],
  79663. [
  79664. 65075,
  79665. 65076,
  79666. ],
  79667. [
  79668. 65077,
  79669. 65077,
  79670. ],
  79671. [
  79672. 65078,
  79673. 65078,
  79674. ],
  79675. [
  79676. 65079,
  79677. 65079,
  79678. ],
  79679. [
  79680. 65080,
  79681. 65080,
  79682. ],
  79683. [
  79684. 65081,
  79685. 65081,
  79686. ],
  79687. [
  79688. 65082,
  79689. 65082,
  79690. ],
  79691. [
  79692. 65083,
  79693. 65083,
  79694. ],
  79695. [
  79696. 65084,
  79697. 65084,
  79698. ],
  79699. [
  79700. 65085,
  79701. 65085,
  79702. ],
  79703. [
  79704. 65086,
  79705. 65086,
  79706. ],
  79707. [
  79708. 65087,
  79709. 65087,
  79710. ],
  79711. [
  79712. 65088,
  79713. 65088,
  79714. ],
  79715. [
  79716. 65089,
  79717. 65089,
  79718. ],
  79719. [
  79720. 65090,
  79721. 65090,
  79722. ],
  79723. [
  79724. 65091,
  79725. 65091,
  79726. ],
  79727. [
  79728. 65092,
  79729. 65092,
  79730. ],
  79731. [
  79732. 65093,
  79733. 65094,
  79734. ],
  79735. [
  79736. 65095,
  79737. 65095,
  79738. ],
  79739. [
  79740. 65096,
  79741. 65096,
  79742. ],
  79743. [
  79744. 65097,
  79745. 65100,
  79746. ],
  79747. [
  79748. 65101,
  79749. 65103,
  79750. ],
  79751. [
  79752. 65104,
  79753. 65106,
  79754. ],
  79755. [
  79756. 65108,
  79757. 65111,
  79758. ],
  79759. [
  79760. 65112,
  79761. 65112,
  79762. ],
  79763. [
  79764. 65113,
  79765. 65113,
  79766. ],
  79767. [
  79768. 65114,
  79769. 65114,
  79770. ],
  79771. [
  79772. 65115,
  79773. 65115,
  79774. ],
  79775. [
  79776. 65116,
  79777. 65116,
  79778. ],
  79779. [
  79780. 65117,
  79781. 65117,
  79782. ],
  79783. [
  79784. 65118,
  79785. 65118,
  79786. ],
  79787. [
  79788. 65119,
  79789. 65121,
  79790. ],
  79791. [
  79792. 65122,
  79793. 65122,
  79794. ],
  79795. [
  79796. 65123,
  79797. 65123,
  79798. ],
  79799. [
  79800. 65124,
  79801. 65126,
  79802. ],
  79803. [
  79804. 65128,
  79805. 65128,
  79806. ],
  79807. [
  79808. 65129,
  79809. 65129,
  79810. ],
  79811. [
  79812. 65130,
  79813. 65131,
  79814. ],
  79815. [
  79816. 65281,
  79817. 65283,
  79818. ],
  79819. [
  79820. 65284,
  79821. 65284,
  79822. ],
  79823. [
  79824. 65285,
  79825. 65287,
  79826. ],
  79827. [
  79828. 65288,
  79829. 65288,
  79830. ],
  79831. [
  79832. 65289,
  79833. 65289,
  79834. ],
  79835. [
  79836. 65290,
  79837. 65290,
  79838. ],
  79839. [
  79840. 65291,
  79841. 65291,
  79842. ],
  79843. [
  79844. 65292,
  79845. 65292,
  79846. ],
  79847. [
  79848. 65293,
  79849. 65293,
  79850. ],
  79851. [
  79852. 65294,
  79853. 65295,
  79854. ],
  79855. [
  79856. 65296,
  79857. 65305,
  79858. ],
  79859. [
  79860. 65306,
  79861. 65307,
  79862. ],
  79863. [
  79864. 65308,
  79865. 65310,
  79866. ],
  79867. [
  79868. 65311,
  79869. 65312,
  79870. ],
  79871. [
  79872. 65313,
  79873. 65338,
  79874. ],
  79875. [
  79876. 65339,
  79877. 65339,
  79878. ],
  79879. [
  79880. 65340,
  79881. 65340,
  79882. ],
  79883. [
  79884. 65341,
  79885. 65341,
  79886. ],
  79887. [
  79888. 65342,
  79889. 65342,
  79890. ],
  79891. [
  79892. 65343,
  79893. 65343,
  79894. ],
  79895. [
  79896. 65344,
  79897. 65344,
  79898. ],
  79899. [
  79900. 65345,
  79901. 65370,
  79902. ],
  79903. [
  79904. 65371,
  79905. 65371,
  79906. ],
  79907. [
  79908. 65372,
  79909. 65372,
  79910. ],
  79911. [
  79912. 65373,
  79913. 65373,
  79914. ],
  79915. [
  79916. 65374,
  79917. 65374,
  79918. ],
  79919. [
  79920. 65375,
  79921. 65375,
  79922. ],
  79923. [
  79924. 65376,
  79925. 65376,
  79926. ],
  79927. [
  79928. 65504,
  79929. 65505,
  79930. ],
  79931. [
  79932. 65506,
  79933. 65506,
  79934. ],
  79935. [
  79936. 65507,
  79937. 65507,
  79938. ],
  79939. [
  79940. 65508,
  79941. 65508,
  79942. ],
  79943. [
  79944. 65509,
  79945. 65510,
  79946. ],
  79947. [
  79948. 94176,
  79949. 94177,
  79950. ],
  79951. [
  79952. 94178,
  79953. 94178,
  79954. ],
  79955. [
  79956. 94179,
  79957. 94179,
  79958. ],
  79959. [
  79960. 94180,
  79961. 94180,
  79962. ],
  79963. [
  79964. 94192,
  79965. 94193,
  79966. ],
  79967. [
  79968. 94208,
  79969. 100343,
  79970. ],
  79971. [
  79972. 100352,
  79973. 101119,
  79974. ],
  79975. [
  79976. 101120,
  79977. 101589,
  79978. ],
  79979. [
  79980. 101632,
  79981. 101640,
  79982. ],
  79983. [
  79984. 110576,
  79985. 110579,
  79986. ],
  79987. [
  79988. 110581,
  79989. 110587,
  79990. ],
  79991. [
  79992. 110589,
  79993. 110590,
  79994. ],
  79995. [
  79996. 110592,
  79997. 110847,
  79998. ],
  79999. [
  80000. 110848,
  80001. 110882,
  80002. ],
  80003. [
  80004. 110928,
  80005. 110930,
  80006. ],
  80007. [
  80008. 110948,
  80009. 110951,
  80010. ],
  80011. [
  80012. 110960,
  80013. 111355,
  80014. ],
  80015. [
  80016. 126980,
  80017. 126980,
  80018. ],
  80019. [
  80020. 127183,
  80021. 127183,
  80022. ],
  80023. [
  80024. 127374,
  80025. 127374,
  80026. ],
  80027. [
  80028. 127377,
  80029. 127386,
  80030. ],
  80031. [
  80032. 127488,
  80033. 127490,
  80034. ],
  80035. [
  80036. 127504,
  80037. 127547,
  80038. ],
  80039. [
  80040. 127552,
  80041. 127560,
  80042. ],
  80043. [
  80044. 127568,
  80045. 127569,
  80046. ],
  80047. [
  80048. 127584,
  80049. 127589,
  80050. ],
  80051. [
  80052. 127744,
  80053. 127776,
  80054. ],
  80055. [
  80056. 127789,
  80057. 127797,
  80058. ],
  80059. [
  80060. 127799,
  80061. 127868,
  80062. ],
  80063. [
  80064. 127870,
  80065. 127891,
  80066. ],
  80067. [
  80068. 127904,
  80069. 127946,
  80070. ],
  80071. [
  80072. 127951,
  80073. 127955,
  80074. ],
  80075. [
  80076. 127968,
  80077. 127984,
  80078. ],
  80079. [
  80080. 127988,
  80081. 127988,
  80082. ],
  80083. [
  80084. 127992,
  80085. 127994,
  80086. ],
  80087. [
  80088. 127995,
  80089. 127999,
  80090. ],
  80091. [
  80092. 128000,
  80093. 128062,
  80094. ],
  80095. [
  80096. 128064,
  80097. 128064,
  80098. ],
  80099. [
  80100. 128066,
  80101. 128252,
  80102. ],
  80103. [
  80104. 128255,
  80105. 128317,
  80106. ],
  80107. [
  80108. 128331,
  80109. 128334,
  80110. ],
  80111. [
  80112. 128336,
  80113. 128359,
  80114. ],
  80115. [
  80116. 128378,
  80117. 128378,
  80118. ],
  80119. [
  80120. 128405,
  80121. 128406,
  80122. ],
  80123. [
  80124. 128420,
  80125. 128420,
  80126. ],
  80127. [
  80128. 128507,
  80129. 128511,
  80130. ],
  80131. [
  80132. 128512,
  80133. 128591,
  80134. ],
  80135. [
  80136. 128640,
  80137. 128709,
  80138. ],
  80139. [
  80140. 128716,
  80141. 128716,
  80142. ],
  80143. [
  80144. 128720,
  80145. 128722,
  80146. ],
  80147. [
  80148. 128725,
  80149. 128727,
  80150. ],
  80151. [
  80152. 128733,
  80153. 128735,
  80154. ],
  80155. [
  80156. 128747,
  80157. 128748,
  80158. ],
  80159. [
  80160. 128756,
  80161. 128764,
  80162. ],
  80163. [
  80164. 128992,
  80165. 129003,
  80166. ],
  80167. [
  80168. 129008,
  80169. 129008,
  80170. ],
  80171. [
  80172. 129292,
  80173. 129338,
  80174. ],
  80175. [
  80176. 129340,
  80177. 129349,
  80178. ],
  80179. [
  80180. 129351,
  80181. 129535,
  80182. ],
  80183. [
  80184. 129648,
  80185. 129652,
  80186. ],
  80187. [
  80188. 129656,
  80189. 129660,
  80190. ],
  80191. [
  80192. 129664,
  80193. 129670,
  80194. ],
  80195. [
  80196. 129680,
  80197. 129708,
  80198. ],
  80199. [
  80200. 129712,
  80201. 129722,
  80202. ],
  80203. [
  80204. 129728,
  80205. 129733,
  80206. ],
  80207. [
  80208. 129744,
  80209. 129753,
  80210. ],
  80211. [
  80212. 129760,
  80213. 129767,
  80214. ],
  80215. [
  80216. 129776,
  80217. 129782,
  80218. ],
  80219. [
  80220. 131072,
  80221. 173791,
  80222. ],
  80223. [
  80224. 173792,
  80225. 173823,
  80226. ],
  80227. [
  80228. 173824,
  80229. 177976,
  80230. ],
  80231. [
  80232. 177977,
  80233. 177983,
  80234. ],
  80235. [
  80236. 177984,
  80237. 178205,
  80238. ],
  80239. [
  80240. 178206,
  80241. 178207,
  80242. ],
  80243. [
  80244. 178208,
  80245. 183969,
  80246. ],
  80247. [
  80248. 183970,
  80249. 183983,
  80250. ],
  80251. [
  80252. 183984,
  80253. 191456,
  80254. ],
  80255. [
  80256. 191457,
  80257. 194559,
  80258. ],
  80259. [
  80260. 194560,
  80261. 195101,
  80262. ],
  80263. [
  80264. 195102,
  80265. 195103,
  80266. ],
  80267. [
  80268. 195104,
  80269. 196605,
  80270. ],
  80271. [
  80272. 196608,
  80273. 201546,
  80274. ],
  80275. [
  80276. 201547,
  80277. 262141,
  80278. ],
  80279. ];
  80280. <?php
  80281. return [
  80282. [
  80283. 768,
  80284. 879,
  80285. ],
  80286. [
  80287. 1155,
  80288. 1159,
  80289. ],
  80290. [
  80291. 1160,
  80292. 1161,
  80293. ],
  80294. [
  80295. 1425,
  80296. 1469,
  80297. ],
  80298. [
  80299. 1471,
  80300. 1471,
  80301. ],
  80302. [
  80303. 1473,
  80304. 1474,
  80305. ],
  80306. [
  80307. 1476,
  80308. 1477,
  80309. ],
  80310. [
  80311. 1479,
  80312. 1479,
  80313. ],
  80314. [
  80315. 1552,
  80316. 1562,
  80317. ],
  80318. [
  80319. 1611,
  80320. 1631,
  80321. ],
  80322. [
  80323. 1648,
  80324. 1648,
  80325. ],
  80326. [
  80327. 1750,
  80328. 1756,
  80329. ],
  80330. [
  80331. 1759,
  80332. 1764,
  80333. ],
  80334. [
  80335. 1767,
  80336. 1768,
  80337. ],
  80338. [
  80339. 1770,
  80340. 1773,
  80341. ],
  80342. [
  80343. 1809,
  80344. 1809,
  80345. ],
  80346. [
  80347. 1840,
  80348. 1866,
  80349. ],
  80350. [
  80351. 1958,
  80352. 1968,
  80353. ],
  80354. [
  80355. 2027,
  80356. 2035,
  80357. ],
  80358. [
  80359. 2045,
  80360. 2045,
  80361. ],
  80362. [
  80363. 2070,
  80364. 2073,
  80365. ],
  80366. [
  80367. 2075,
  80368. 2083,
  80369. ],
  80370. [
  80371. 2085,
  80372. 2087,
  80373. ],
  80374. [
  80375. 2089,
  80376. 2093,
  80377. ],
  80378. [
  80379. 2137,
  80380. 2139,
  80381. ],
  80382. [
  80383. 2200,
  80384. 2207,
  80385. ],
  80386. [
  80387. 2250,
  80388. 2273,
  80389. ],
  80390. [
  80391. 2275,
  80392. 2306,
  80393. ],
  80394. [
  80395. 2362,
  80396. 2362,
  80397. ],
  80398. [
  80399. 2364,
  80400. 2364,
  80401. ],
  80402. [
  80403. 2369,
  80404. 2376,
  80405. ],
  80406. [
  80407. 2381,
  80408. 2381,
  80409. ],
  80410. [
  80411. 2385,
  80412. 2391,
  80413. ],
  80414. [
  80415. 2402,
  80416. 2403,
  80417. ],
  80418. [
  80419. 2433,
  80420. 2433,
  80421. ],
  80422. [
  80423. 2492,
  80424. 2492,
  80425. ],
  80426. [
  80427. 2497,
  80428. 2500,
  80429. ],
  80430. [
  80431. 2509,
  80432. 2509,
  80433. ],
  80434. [
  80435. 2530,
  80436. 2531,
  80437. ],
  80438. [
  80439. 2558,
  80440. 2558,
  80441. ],
  80442. [
  80443. 2561,
  80444. 2562,
  80445. ],
  80446. [
  80447. 2620,
  80448. 2620,
  80449. ],
  80450. [
  80451. 2625,
  80452. 2626,
  80453. ],
  80454. [
  80455. 2631,
  80456. 2632,
  80457. ],
  80458. [
  80459. 2635,
  80460. 2637,
  80461. ],
  80462. [
  80463. 2641,
  80464. 2641,
  80465. ],
  80466. [
  80467. 2672,
  80468. 2673,
  80469. ],
  80470. [
  80471. 2677,
  80472. 2677,
  80473. ],
  80474. [
  80475. 2689,
  80476. 2690,
  80477. ],
  80478. [
  80479. 2748,
  80480. 2748,
  80481. ],
  80482. [
  80483. 2753,
  80484. 2757,
  80485. ],
  80486. [
  80487. 2759,
  80488. 2760,
  80489. ],
  80490. [
  80491. 2765,
  80492. 2765,
  80493. ],
  80494. [
  80495. 2786,
  80496. 2787,
  80497. ],
  80498. [
  80499. 2810,
  80500. 2815,
  80501. ],
  80502. [
  80503. 2817,
  80504. 2817,
  80505. ],
  80506. [
  80507. 2876,
  80508. 2876,
  80509. ],
  80510. [
  80511. 2879,
  80512. 2879,
  80513. ],
  80514. [
  80515. 2881,
  80516. 2884,
  80517. ],
  80518. [
  80519. 2893,
  80520. 2893,
  80521. ],
  80522. [
  80523. 2901,
  80524. 2902,
  80525. ],
  80526. [
  80527. 2914,
  80528. 2915,
  80529. ],
  80530. [
  80531. 2946,
  80532. 2946,
  80533. ],
  80534. [
  80535. 3008,
  80536. 3008,
  80537. ],
  80538. [
  80539. 3021,
  80540. 3021,
  80541. ],
  80542. [
  80543. 3072,
  80544. 3072,
  80545. ],
  80546. [
  80547. 3076,
  80548. 3076,
  80549. ],
  80550. [
  80551. 3132,
  80552. 3132,
  80553. ],
  80554. [
  80555. 3134,
  80556. 3136,
  80557. ],
  80558. [
  80559. 3142,
  80560. 3144,
  80561. ],
  80562. [
  80563. 3146,
  80564. 3149,
  80565. ],
  80566. [
  80567. 3157,
  80568. 3158,
  80569. ],
  80570. [
  80571. 3170,
  80572. 3171,
  80573. ],
  80574. [
  80575. 3201,
  80576. 3201,
  80577. ],
  80578. [
  80579. 3260,
  80580. 3260,
  80581. ],
  80582. [
  80583. 3263,
  80584. 3263,
  80585. ],
  80586. [
  80587. 3270,
  80588. 3270,
  80589. ],
  80590. [
  80591. 3276,
  80592. 3277,
  80593. ],
  80594. [
  80595. 3298,
  80596. 3299,
  80597. ],
  80598. [
  80599. 3328,
  80600. 3329,
  80601. ],
  80602. [
  80603. 3387,
  80604. 3388,
  80605. ],
  80606. [
  80607. 3393,
  80608. 3396,
  80609. ],
  80610. [
  80611. 3405,
  80612. 3405,
  80613. ],
  80614. [
  80615. 3426,
  80616. 3427,
  80617. ],
  80618. [
  80619. 3457,
  80620. 3457,
  80621. ],
  80622. [
  80623. 3530,
  80624. 3530,
  80625. ],
  80626. [
  80627. 3538,
  80628. 3540,
  80629. ],
  80630. [
  80631. 3542,
  80632. 3542,
  80633. ],
  80634. [
  80635. 3633,
  80636. 3633,
  80637. ],
  80638. [
  80639. 3636,
  80640. 3642,
  80641. ],
  80642. [
  80643. 3655,
  80644. 3662,
  80645. ],
  80646. [
  80647. 3761,
  80648. 3761,
  80649. ],
  80650. [
  80651. 3764,
  80652. 3772,
  80653. ],
  80654. [
  80655. 3784,
  80656. 3789,
  80657. ],
  80658. [
  80659. 3864,
  80660. 3865,
  80661. ],
  80662. [
  80663. 3893,
  80664. 3893,
  80665. ],
  80666. [
  80667. 3895,
  80668. 3895,
  80669. ],
  80670. [
  80671. 3897,
  80672. 3897,
  80673. ],
  80674. [
  80675. 3953,
  80676. 3966,
  80677. ],
  80678. [
  80679. 3968,
  80680. 3972,
  80681. ],
  80682. [
  80683. 3974,
  80684. 3975,
  80685. ],
  80686. [
  80687. 3981,
  80688. 3991,
  80689. ],
  80690. [
  80691. 3993,
  80692. 4028,
  80693. ],
  80694. [
  80695. 4038,
  80696. 4038,
  80697. ],
  80698. [
  80699. 4141,
  80700. 4144,
  80701. ],
  80702. [
  80703. 4146,
  80704. 4151,
  80705. ],
  80706. [
  80707. 4153,
  80708. 4154,
  80709. ],
  80710. [
  80711. 4157,
  80712. 4158,
  80713. ],
  80714. [
  80715. 4184,
  80716. 4185,
  80717. ],
  80718. [
  80719. 4190,
  80720. 4192,
  80721. ],
  80722. [
  80723. 4209,
  80724. 4212,
  80725. ],
  80726. [
  80727. 4226,
  80728. 4226,
  80729. ],
  80730. [
  80731. 4229,
  80732. 4230,
  80733. ],
  80734. [
  80735. 4237,
  80736. 4237,
  80737. ],
  80738. [
  80739. 4253,
  80740. 4253,
  80741. ],
  80742. [
  80743. 4957,
  80744. 4959,
  80745. ],
  80746. [
  80747. 5906,
  80748. 5908,
  80749. ],
  80750. [
  80751. 5938,
  80752. 5939,
  80753. ],
  80754. [
  80755. 5970,
  80756. 5971,
  80757. ],
  80758. [
  80759. 6002,
  80760. 6003,
  80761. ],
  80762. [
  80763. 6068,
  80764. 6069,
  80765. ],
  80766. [
  80767. 6071,
  80768. 6077,
  80769. ],
  80770. [
  80771. 6086,
  80772. 6086,
  80773. ],
  80774. [
  80775. 6089,
  80776. 6099,
  80777. ],
  80778. [
  80779. 6109,
  80780. 6109,
  80781. ],
  80782. [
  80783. 6155,
  80784. 6157,
  80785. ],
  80786. [
  80787. 6159,
  80788. 6159,
  80789. ],
  80790. [
  80791. 6277,
  80792. 6278,
  80793. ],
  80794. [
  80795. 6313,
  80796. 6313,
  80797. ],
  80798. [
  80799. 6432,
  80800. 6434,
  80801. ],
  80802. [
  80803. 6439,
  80804. 6440,
  80805. ],
  80806. [
  80807. 6450,
  80808. 6450,
  80809. ],
  80810. [
  80811. 6457,
  80812. 6459,
  80813. ],
  80814. [
  80815. 6679,
  80816. 6680,
  80817. ],
  80818. [
  80819. 6683,
  80820. 6683,
  80821. ],
  80822. [
  80823. 6742,
  80824. 6742,
  80825. ],
  80826. [
  80827. 6744,
  80828. 6750,
  80829. ],
  80830. [
  80831. 6752,
  80832. 6752,
  80833. ],
  80834. [
  80835. 6754,
  80836. 6754,
  80837. ],
  80838. [
  80839. 6757,
  80840. 6764,
  80841. ],
  80842. [
  80843. 6771,
  80844. 6780,
  80845. ],
  80846. [
  80847. 6783,
  80848. 6783,
  80849. ],
  80850. [
  80851. 6832,
  80852. 6845,
  80853. ],
  80854. [
  80855. 6846,
  80856. 6846,
  80857. ],
  80858. [
  80859. 6847,
  80860. 6862,
  80861. ],
  80862. [
  80863. 6912,
  80864. 6915,
  80865. ],
  80866. [
  80867. 6964,
  80868. 6964,
  80869. ],
  80870. [
  80871. 6966,
  80872. 6970,
  80873. ],
  80874. [
  80875. 6972,
  80876. 6972,
  80877. ],
  80878. [
  80879. 6978,
  80880. 6978,
  80881. ],
  80882. [
  80883. 7019,
  80884. 7027,
  80885. ],
  80886. [
  80887. 7040,
  80888. 7041,
  80889. ],
  80890. [
  80891. 7074,
  80892. 7077,
  80893. ],
  80894. [
  80895. 7080,
  80896. 7081,
  80897. ],
  80898. [
  80899. 7083,
  80900. 7085,
  80901. ],
  80902. [
  80903. 7142,
  80904. 7142,
  80905. ],
  80906. [
  80907. 7144,
  80908. 7145,
  80909. ],
  80910. [
  80911. 7149,
  80912. 7149,
  80913. ],
  80914. [
  80915. 7151,
  80916. 7153,
  80917. ],
  80918. [
  80919. 7212,
  80920. 7219,
  80921. ],
  80922. [
  80923. 7222,
  80924. 7223,
  80925. ],
  80926. [
  80927. 7376,
  80928. 7378,
  80929. ],
  80930. [
  80931. 7380,
  80932. 7392,
  80933. ],
  80934. [
  80935. 7394,
  80936. 7400,
  80937. ],
  80938. [
  80939. 7405,
  80940. 7405,
  80941. ],
  80942. [
  80943. 7412,
  80944. 7412,
  80945. ],
  80946. [
  80947. 7416,
  80948. 7417,
  80949. ],
  80950. [
  80951. 7616,
  80952. 7679,
  80953. ],
  80954. [
  80955. 8400,
  80956. 8412,
  80957. ],
  80958. [
  80959. 8413,
  80960. 8416,
  80961. ],
  80962. [
  80963. 8417,
  80964. 8417,
  80965. ],
  80966. [
  80967. 8418,
  80968. 8420,
  80969. ],
  80970. [
  80971. 8421,
  80972. 8432,
  80973. ],
  80974. [
  80975. 11503,
  80976. 11505,
  80977. ],
  80978. [
  80979. 11647,
  80980. 11647,
  80981. ],
  80982. [
  80983. 11744,
  80984. 11775,
  80985. ],
  80986. [
  80987. 12330,
  80988. 12333,
  80989. ],
  80990. [
  80991. 12441,
  80992. 12442,
  80993. ],
  80994. [
  80995. 42607,
  80996. 42607,
  80997. ],
  80998. [
  80999. 42608,
  81000. 42610,
  81001. ],
  81002. [
  81003. 42612,
  81004. 42621,
  81005. ],
  81006. [
  81007. 42654,
  81008. 42655,
  81009. ],
  81010. [
  81011. 42736,
  81012. 42737,
  81013. ],
  81014. [
  81015. 43010,
  81016. 43010,
  81017. ],
  81018. [
  81019. 43014,
  81020. 43014,
  81021. ],
  81022. [
  81023. 43019,
  81024. 43019,
  81025. ],
  81026. [
  81027. 43045,
  81028. 43046,
  81029. ],
  81030. [
  81031. 43052,
  81032. 43052,
  81033. ],
  81034. [
  81035. 43204,
  81036. 43205,
  81037. ],
  81038. [
  81039. 43232,
  81040. 43249,
  81041. ],
  81042. [
  81043. 43263,
  81044. 43263,
  81045. ],
  81046. [
  81047. 43302,
  81048. 43309,
  81049. ],
  81050. [
  81051. 43335,
  81052. 43345,
  81053. ],
  81054. [
  81055. 43392,
  81056. 43394,
  81057. ],
  81058. [
  81059. 43443,
  81060. 43443,
  81061. ],
  81062. [
  81063. 43446,
  81064. 43449,
  81065. ],
  81066. [
  81067. 43452,
  81068. 43453,
  81069. ],
  81070. [
  81071. 43493,
  81072. 43493,
  81073. ],
  81074. [
  81075. 43561,
  81076. 43566,
  81077. ],
  81078. [
  81079. 43569,
  81080. 43570,
  81081. ],
  81082. [
  81083. 43573,
  81084. 43574,
  81085. ],
  81086. [
  81087. 43587,
  81088. 43587,
  81089. ],
  81090. [
  81091. 43596,
  81092. 43596,
  81093. ],
  81094. [
  81095. 43644,
  81096. 43644,
  81097. ],
  81098. [
  81099. 43696,
  81100. 43696,
  81101. ],
  81102. [
  81103. 43698,
  81104. 43700,
  81105. ],
  81106. [
  81107. 43703,
  81108. 43704,
  81109. ],
  81110. [
  81111. 43710,
  81112. 43711,
  81113. ],
  81114. [
  81115. 43713,
  81116. 43713,
  81117. ],
  81118. [
  81119. 43756,
  81120. 43757,
  81121. ],
  81122. [
  81123. 43766,
  81124. 43766,
  81125. ],
  81126. [
  81127. 44005,
  81128. 44005,
  81129. ],
  81130. [
  81131. 44008,
  81132. 44008,
  81133. ],
  81134. [
  81135. 44013,
  81136. 44013,
  81137. ],
  81138. [
  81139. 64286,
  81140. 64286,
  81141. ],
  81142. [
  81143. 65024,
  81144. 65039,
  81145. ],
  81146. [
  81147. 65056,
  81148. 65071,
  81149. ],
  81150. [
  81151. 66045,
  81152. 66045,
  81153. ],
  81154. [
  81155. 66272,
  81156. 66272,
  81157. ],
  81158. [
  81159. 66422,
  81160. 66426,
  81161. ],
  81162. [
  81163. 68097,
  81164. 68099,
  81165. ],
  81166. [
  81167. 68101,
  81168. 68102,
  81169. ],
  81170. [
  81171. 68108,
  81172. 68111,
  81173. ],
  81174. [
  81175. 68152,
  81176. 68154,
  81177. ],
  81178. [
  81179. 68159,
  81180. 68159,
  81181. ],
  81182. [
  81183. 68325,
  81184. 68326,
  81185. ],
  81186. [
  81187. 68900,
  81188. 68903,
  81189. ],
  81190. [
  81191. 69291,
  81192. 69292,
  81193. ],
  81194. [
  81195. 69446,
  81196. 69456,
  81197. ],
  81198. [
  81199. 69506,
  81200. 69509,
  81201. ],
  81202. [
  81203. 69633,
  81204. 69633,
  81205. ],
  81206. [
  81207. 69688,
  81208. 69702,
  81209. ],
  81210. [
  81211. 69744,
  81212. 69744,
  81213. ],
  81214. [
  81215. 69747,
  81216. 69748,
  81217. ],
  81218. [
  81219. 69759,
  81220. 69761,
  81221. ],
  81222. [
  81223. 69811,
  81224. 69814,
  81225. ],
  81226. [
  81227. 69817,
  81228. 69818,
  81229. ],
  81230. [
  81231. 69826,
  81232. 69826,
  81233. ],
  81234. [
  81235. 69888,
  81236. 69890,
  81237. ],
  81238. [
  81239. 69927,
  81240. 69931,
  81241. ],
  81242. [
  81243. 69933,
  81244. 69940,
  81245. ],
  81246. [
  81247. 70003,
  81248. 70003,
  81249. ],
  81250. [
  81251. 70016,
  81252. 70017,
  81253. ],
  81254. [
  81255. 70070,
  81256. 70078,
  81257. ],
  81258. [
  81259. 70089,
  81260. 70092,
  81261. ],
  81262. [
  81263. 70095,
  81264. 70095,
  81265. ],
  81266. [
  81267. 70191,
  81268. 70193,
  81269. ],
  81270. [
  81271. 70196,
  81272. 70196,
  81273. ],
  81274. [
  81275. 70198,
  81276. 70199,
  81277. ],
  81278. [
  81279. 70206,
  81280. 70206,
  81281. ],
  81282. [
  81283. 70367,
  81284. 70367,
  81285. ],
  81286. [
  81287. 70371,
  81288. 70378,
  81289. ],
  81290. [
  81291. 70400,
  81292. 70401,
  81293. ],
  81294. [
  81295. 70459,
  81296. 70460,
  81297. ],
  81298. [
  81299. 70464,
  81300. 70464,
  81301. ],
  81302. [
  81303. 70502,
  81304. 70508,
  81305. ],
  81306. [
  81307. 70512,
  81308. 70516,
  81309. ],
  81310. [
  81311. 70712,
  81312. 70719,
  81313. ],
  81314. [
  81315. 70722,
  81316. 70724,
  81317. ],
  81318. [
  81319. 70726,
  81320. 70726,
  81321. ],
  81322. [
  81323. 70750,
  81324. 70750,
  81325. ],
  81326. [
  81327. 70835,
  81328. 70840,
  81329. ],
  81330. [
  81331. 70842,
  81332. 70842,
  81333. ],
  81334. [
  81335. 70847,
  81336. 70848,
  81337. ],
  81338. [
  81339. 70850,
  81340. 70851,
  81341. ],
  81342. [
  81343. 71090,
  81344. 71093,
  81345. ],
  81346. [
  81347. 71100,
  81348. 71101,
  81349. ],
  81350. [
  81351. 71103,
  81352. 71104,
  81353. ],
  81354. [
  81355. 71132,
  81356. 71133,
  81357. ],
  81358. [
  81359. 71219,
  81360. 71226,
  81361. ],
  81362. [
  81363. 71229,
  81364. 71229,
  81365. ],
  81366. [
  81367. 71231,
  81368. 71232,
  81369. ],
  81370. [
  81371. 71339,
  81372. 71339,
  81373. ],
  81374. [
  81375. 71341,
  81376. 71341,
  81377. ],
  81378. [
  81379. 71344,
  81380. 71349,
  81381. ],
  81382. [
  81383. 71351,
  81384. 71351,
  81385. ],
  81386. [
  81387. 71453,
  81388. 71455,
  81389. ],
  81390. [
  81391. 71458,
  81392. 71461,
  81393. ],
  81394. [
  81395. 71463,
  81396. 71467,
  81397. ],
  81398. [
  81399. 71727,
  81400. 71735,
  81401. ],
  81402. [
  81403. 71737,
  81404. 71738,
  81405. ],
  81406. [
  81407. 71995,
  81408. 71996,
  81409. ],
  81410. [
  81411. 71998,
  81412. 71998,
  81413. ],
  81414. [
  81415. 72003,
  81416. 72003,
  81417. ],
  81418. [
  81419. 72148,
  81420. 72151,
  81421. ],
  81422. [
  81423. 72154,
  81424. 72155,
  81425. ],
  81426. [
  81427. 72160,
  81428. 72160,
  81429. ],
  81430. [
  81431. 72193,
  81432. 72202,
  81433. ],
  81434. [
  81435. 72243,
  81436. 72248,
  81437. ],
  81438. [
  81439. 72251,
  81440. 72254,
  81441. ],
  81442. [
  81443. 72263,
  81444. 72263,
  81445. ],
  81446. [
  81447. 72273,
  81448. 72278,
  81449. ],
  81450. [
  81451. 72281,
  81452. 72283,
  81453. ],
  81454. [
  81455. 72330,
  81456. 72342,
  81457. ],
  81458. [
  81459. 72344,
  81460. 72345,
  81461. ],
  81462. [
  81463. 72752,
  81464. 72758,
  81465. ],
  81466. [
  81467. 72760,
  81468. 72765,
  81469. ],
  81470. [
  81471. 72767,
  81472. 72767,
  81473. ],
  81474. [
  81475. 72850,
  81476. 72871,
  81477. ],
  81478. [
  81479. 72874,
  81480. 72880,
  81481. ],
  81482. [
  81483. 72882,
  81484. 72883,
  81485. ],
  81486. [
  81487. 72885,
  81488. 72886,
  81489. ],
  81490. [
  81491. 73009,
  81492. 73014,
  81493. ],
  81494. [
  81495. 73018,
  81496. 73018,
  81497. ],
  81498. [
  81499. 73020,
  81500. 73021,
  81501. ],
  81502. [
  81503. 73023,
  81504. 73029,
  81505. ],
  81506. [
  81507. 73031,
  81508. 73031,
  81509. ],
  81510. [
  81511. 73104,
  81512. 73105,
  81513. ],
  81514. [
  81515. 73109,
  81516. 73109,
  81517. ],
  81518. [
  81519. 73111,
  81520. 73111,
  81521. ],
  81522. [
  81523. 73459,
  81524. 73460,
  81525. ],
  81526. [
  81527. 92912,
  81528. 92916,
  81529. ],
  81530. [
  81531. 92976,
  81532. 92982,
  81533. ],
  81534. [
  81535. 94031,
  81536. 94031,
  81537. ],
  81538. [
  81539. 94095,
  81540. 94098,
  81541. ],
  81542. [
  81543. 94180,
  81544. 94180,
  81545. ],
  81546. [
  81547. 113821,
  81548. 113822,
  81549. ],
  81550. [
  81551. 118528,
  81552. 118573,
  81553. ],
  81554. [
  81555. 118576,
  81556. 118598,
  81557. ],
  81558. [
  81559. 119143,
  81560. 119145,
  81561. ],
  81562. [
  81563. 119163,
  81564. 119170,
  81565. ],
  81566. [
  81567. 119173,
  81568. 119179,
  81569. ],
  81570. [
  81571. 119210,
  81572. 119213,
  81573. ],
  81574. [
  81575. 119362,
  81576. 119364,
  81577. ],
  81578. [
  81579. 121344,
  81580. 121398,
  81581. ],
  81582. [
  81583. 121403,
  81584. 121452,
  81585. ],
  81586. [
  81587. 121461,
  81588. 121461,
  81589. ],
  81590. [
  81591. 121476,
  81592. 121476,
  81593. ],
  81594. [
  81595. 121499,
  81596. 121503,
  81597. ],
  81598. [
  81599. 121505,
  81600. 121519,
  81601. ],
  81602. [
  81603. 122880,
  81604. 122886,
  81605. ],
  81606. [
  81607. 122888,
  81608. 122904,
  81609. ],
  81610. [
  81611. 122907,
  81612. 122913,
  81613. ],
  81614. [
  81615. 122915,
  81616. 122916,
  81617. ],
  81618. [
  81619. 122918,
  81620. 122922,
  81621. ],
  81622. [
  81623. 123184,
  81624. 123190,
  81625. ],
  81626. [
  81627. 123566,
  81628. 123566,
  81629. ],
  81630. [
  81631. 123628,
  81632. 123631,
  81633. ],
  81634. [
  81635. 125136,
  81636. 125142,
  81637. ],
  81638. [
  81639. 125252,
  81640. 125258,
  81641. ],
  81642. [
  81643. 917760,
  81644. 917999,
  81645. ],
  81646. ];
  81647. <?php
  81648. namespace Symfony\Component\String;
  81649. if (!\function_exists(u::class)) {
  81650. function u(?string $string = ''): UnicodeString
  81651. {
  81652. return new UnicodeString($string ?? '');
  81653. }
  81654. }
  81655. if (!\function_exists(b::class)) {
  81656. function b(?string $string = ''): ByteString
  81657. {
  81658. return new ByteString($string ?? '');
  81659. }
  81660. }
  81661. if (!\function_exists(s::class)) {
  81662. function s(?string $string = ''): AbstractString
  81663. {
  81664. $string = $string ?? '';
  81665. return preg_match('//u', $string) ? new UnicodeString($string) : new ByteString($string);
  81666. }
  81667. }
  81668. <?php
  81669. namespace Symfony\Component\String\Slugger;
  81670. use Symfony\Component\String\AbstractUnicodeString;
  81671. use Symfony\Component\String\UnicodeString;
  81672. use Symfony\Contracts\Translation\LocaleAwareInterface;
  81673. if (!interface_exists(LocaleAwareInterface::class)) {
  81674. throw new \LogicException('You cannot use the "Symfony\Component\String\Slugger\AsciiSlugger" as the "symfony/translation-contracts" package is not installed. Try running "composer require symfony/translation-contracts".');
  81675. }
  81676. class AsciiSlugger implements SluggerInterface, LocaleAwareInterface
  81677. {
  81678. private const LOCALE_TO_TRANSLITERATOR_ID = [
  81679. 'am' => 'Amharic-Latin',
  81680. 'ar' => 'Arabic-Latin',
  81681. 'az' => 'Azerbaijani-Latin',
  81682. 'be' => 'Belarusian-Latin',
  81683. 'bg' => 'Bulgarian-Latin',
  81684. 'bn' => 'Bengali-Latin',
  81685. 'de' => 'de-ASCII',
  81686. 'el' => 'Greek-Latin',
  81687. 'fa' => 'Persian-Latin',
  81688. 'he' => 'Hebrew-Latin',
  81689. 'hy' => 'Armenian-Latin',
  81690. 'ka' => 'Georgian-Latin',
  81691. 'kk' => 'Kazakh-Latin',
  81692. 'ky' => 'Kirghiz-Latin',
  81693. 'ko' => 'Korean-Latin',
  81694. 'mk' => 'Macedonian-Latin',
  81695. 'mn' => 'Mongolian-Latin',
  81696. 'or' => 'Oriya-Latin',
  81697. 'ps' => 'Pashto-Latin',
  81698. 'ru' => 'Russian-Latin',
  81699. 'sr' => 'Serbian-Latin',
  81700. 'sr_Cyrl' => 'Serbian-Latin',
  81701. 'th' => 'Thai-Latin',
  81702. 'tk' => 'Turkmen-Latin',
  81703. 'uk' => 'Ukrainian-Latin',
  81704. 'uz' => 'Uzbek-Latin',
  81705. 'zh' => 'Han-Latin',
  81706. ];
  81707. private $defaultLocale;
  81708. private $symbolsMap = [
  81709. 'en' => ['@' => 'at', '&' => 'and'],
  81710. ];
  81711. private $transliterators = [];
  81712. public function __construct(string $defaultLocale = null, $symbolsMap = null)
  81713. {
  81714. if (null !== $symbolsMap && !\is_array($symbolsMap) && !$symbolsMap instanceof \Closure) {
  81715. throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be array, Closure or null, "%s" given.', __METHOD__, \gettype($symbolsMap)));
  81716. }
  81717. $this->defaultLocale = $defaultLocale;
  81718. $this->symbolsMap = $symbolsMap ?? $this->symbolsMap;
  81719. }
  81720. public function setLocale($locale)
  81721. {
  81722. $this->defaultLocale = $locale;
  81723. }
  81724. public function getLocale()
  81725. {
  81726. return $this->defaultLocale;
  81727. }
  81728. public function slug(string $string, string $separator = '-', string $locale = null): AbstractUnicodeString
  81729. {
  81730. $locale = $locale ?? $this->defaultLocale;
  81731. $transliterator = [];
  81732. if ($locale && ('de' === $locale || 0 === strpos($locale, 'de_'))) {
  81733. $transliterator = ['de-ASCII'];
  81734. } elseif (\function_exists('transliterator_transliterate') && $locale) {
  81735. $transliterator = (array) $this->createTransliterator($locale);
  81736. }
  81737. if ($this->symbolsMap instanceof \Closure) {
  81738. $symbolsMap = $this->symbolsMap;
  81739. array_unshift($transliterator, static function ($s) use ($symbolsMap, $locale) {
  81740. return $symbolsMap($s, $locale);
  81741. });
  81742. }
  81743. $unicodeString = (new UnicodeString($string))->ascii($transliterator);
  81744. if (\is_array($this->symbolsMap)) {
  81745. $map = null;
  81746. if (isset($this->symbolsMap[$locale])) {
  81747. $map = $this->symbolsMap[$locale];
  81748. } else {
  81749. $parent = self::getParentLocale($locale);
  81750. if ($parent && isset($this->symbolsMap[$parent])) {
  81751. $map = $this->symbolsMap[$parent];
  81752. }
  81753. }
  81754. if ($map) {
  81755. foreach ($map as $char => $replace) {
  81756. $unicodeString = $unicodeString->replace($char, ' '.$replace.' ');
  81757. }
  81758. }
  81759. }
  81760. return $unicodeString
  81761. ->replaceMatches('/[^A-Za-z0-9]++/', $separator)
  81762. ->trim($separator)
  81763. ;
  81764. }
  81765. private function createTransliterator(string $locale): ?\Transliterator
  81766. {
  81767. if (\array_key_exists($locale, $this->transliterators)) {
  81768. return $this->transliterators[$locale];
  81769. }
  81770. if ($id = self::LOCALE_TO_TRANSLITERATOR_ID[$locale] ?? null) {
  81771. return $this->transliterators[$locale] = \Transliterator::create($id.'/BGN') ?? \Transliterator::create($id);
  81772. }
  81773. if (!$parent = self::getParentLocale($locale)) {
  81774. return $this->transliterators[$locale] = null;
  81775. }
  81776. if ($id = self::LOCALE_TO_TRANSLITERATOR_ID[$parent] ?? null) {
  81777. $transliterator = \Transliterator::create($id.'/BGN') ?? \Transliterator::create($id);
  81778. }
  81779. return $this->transliterators[$locale] = $this->transliterators[$parent] = $transliterator ?? null;
  81780. }
  81781. private static function getParentLocale(?string $locale): ?string
  81782. {
  81783. if (!$locale) {
  81784. return null;
  81785. }
  81786. if (false === $str = strrchr($locale, '_')) {
  81787. return null;
  81788. }
  81789. return substr($locale, 0, -\strlen($str));
  81790. }
  81791. }
  81792. <?php
  81793. namespace Symfony\Component\String\Slugger;
  81794. use Symfony\Component\String\AbstractUnicodeString;
  81795. interface SluggerInterface
  81796. {
  81797. public function slug(string $string, string $separator = '-', string $locale = null): AbstractUnicodeString;
  81798. }
  81799. <?php
  81800. namespace Symfony\Component\String;
  81801. use Symfony\Component\String\Exception\ExceptionInterface;
  81802. use Symfony\Component\String\Exception\InvalidArgumentException;
  81803. class UnicodeString extends AbstractUnicodeString
  81804. {
  81805. public function __construct(string $string = '')
  81806. {
  81807. $this->string = normalizer_is_normalized($string) ? $string : normalizer_normalize($string);
  81808. if (false === $this->string) {
  81809. throw new InvalidArgumentException('Invalid UTF-8 string.');
  81810. }
  81811. }
  81812. public function append(string ...$suffix): AbstractString
  81813. {
  81814. $str = clone $this;
  81815. $str->string = $this->string.(1 >= \count($suffix) ? ($suffix[0] ?? '') : implode('', $suffix));
  81816. normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
  81817. if (false === $str->string) {
  81818. throw new InvalidArgumentException('Invalid UTF-8 string.');
  81819. }
  81820. return $str;
  81821. }
  81822. public function chunk(int $length = 1): array
  81823. {
  81824. if (1 > $length) {
  81825. throw new InvalidArgumentException('The chunk length must be greater than zero.');
  81826. }
  81827. if ('' === $this->string) {
  81828. return [];
  81829. }
  81830. $rx = '/(';
  81831. while (65535 < $length) {
  81832. $rx .= '\X{65535}';
  81833. $length -= 65535;
  81834. }
  81835. $rx .= '\X{'.$length.'})/u';
  81836. $str = clone $this;
  81837. $chunks = [];
  81838. foreach (preg_split($rx, $this->string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY) as $chunk) {
  81839. $str->string = $chunk;
  81840. $chunks[] = clone $str;
  81841. }
  81842. return $chunks;
  81843. }
  81844. public function endsWith($suffix): bool
  81845. {
  81846. if ($suffix instanceof AbstractString) {
  81847. $suffix = $suffix->string;
  81848. } elseif (\is_array($suffix) || $suffix instanceof \Traversable) {
  81849. return parent::endsWith($suffix);
  81850. } else {
  81851. $suffix = (string) $suffix;
  81852. }
  81853. $form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
  81854. normalizer_is_normalized($suffix, $form) ?: $suffix = normalizer_normalize($suffix, $form);
  81855. if ('' === $suffix || false === $suffix) {
  81856. return false;
  81857. }
  81858. if ($this->ignoreCase) {
  81859. return 0 === mb_stripos(grapheme_extract($this->string, \strlen($suffix), \GRAPHEME_EXTR_MAXBYTES, \strlen($this->string) - \strlen($suffix)), $suffix, 0, 'UTF-8');
  81860. }
  81861. return $suffix === grapheme_extract($this->string, \strlen($suffix), \GRAPHEME_EXTR_MAXBYTES, \strlen($this->string) - \strlen($suffix));
  81862. }
  81863. public function equalsTo($string): bool
  81864. {
  81865. if ($string instanceof AbstractString) {
  81866. $string = $string->string;
  81867. } elseif (\is_array($string) || $string instanceof \Traversable) {
  81868. return parent::equalsTo($string);
  81869. } else {
  81870. $string = (string) $string;
  81871. }
  81872. $form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
  81873. normalizer_is_normalized($string, $form) ?: $string = normalizer_normalize($string, $form);
  81874. if ('' !== $string && false !== $string && $this->ignoreCase) {
  81875. return \strlen($string) === \strlen($this->string) && 0 === mb_stripos($this->string, $string, 0, 'UTF-8');
  81876. }
  81877. return $string === $this->string;
  81878. }
  81879. public function indexOf($needle, int $offset = 0): ?int
  81880. {
  81881. if ($needle instanceof AbstractString) {
  81882. $needle = $needle->string;
  81883. } elseif (\is_array($needle) || $needle instanceof \Traversable) {
  81884. return parent::indexOf($needle, $offset);
  81885. } else {
  81886. $needle = (string) $needle;
  81887. }
  81888. $form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
  81889. normalizer_is_normalized($needle, $form) ?: $needle = normalizer_normalize($needle, $form);
  81890. if ('' === $needle || false === $needle) {
  81891. return null;
  81892. }
  81893. try {
  81894. $i = $this->ignoreCase ? grapheme_stripos($this->string, $needle, $offset) : grapheme_strpos($this->string, $needle, $offset);
  81895. } catch (\ValueError $e) {
  81896. return null;
  81897. }
  81898. return false === $i ? null : $i;
  81899. }
  81900. public function indexOfLast($needle, int $offset = 0): ?int
  81901. {
  81902. if ($needle instanceof AbstractString) {
  81903. $needle = $needle->string;
  81904. } elseif (\is_array($needle) || $needle instanceof \Traversable) {
  81905. return parent::indexOfLast($needle, $offset);
  81906. } else {
  81907. $needle = (string) $needle;
  81908. }
  81909. $form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
  81910. normalizer_is_normalized($needle, $form) ?: $needle = normalizer_normalize($needle, $form);
  81911. if ('' === $needle || false === $needle) {
  81912. return null;
  81913. }
  81914. $string = $this->string;
  81915. if (0 > $offset) {
  81916. if (0 > $offset += grapheme_strlen($needle)) {
  81917. $string = grapheme_substr($string, 0, $offset);
  81918. }
  81919. $offset = 0;
  81920. }
  81921. $i = $this->ignoreCase ? grapheme_strripos($string, $needle, $offset) : grapheme_strrpos($string, $needle, $offset);
  81922. return false === $i ? null : $i;
  81923. }
  81924. public function join(array $strings, string $lastGlue = null): AbstractString
  81925. {
  81926. $str = parent::join($strings, $lastGlue);
  81927. normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
  81928. return $str;
  81929. }
  81930. public function length(): int
  81931. {
  81932. return grapheme_strlen($this->string);
  81933. }
  81934. public function normalize(int $form = self::NFC): parent
  81935. {
  81936. $str = clone $this;
  81937. if (\in_array($form, [self::NFC, self::NFKC], true)) {
  81938. normalizer_is_normalized($str->string, $form) ?: $str->string = normalizer_normalize($str->string, $form);
  81939. } elseif (!\in_array($form, [self::NFD, self::NFKD], true)) {
  81940. throw new InvalidArgumentException('Unsupported normalization form.');
  81941. } elseif (!normalizer_is_normalized($str->string, $form)) {
  81942. $str->string = normalizer_normalize($str->string, $form);
  81943. $str->ignoreCase = null;
  81944. }
  81945. return $str;
  81946. }
  81947. public function prepend(string ...$prefix): AbstractString
  81948. {
  81949. $str = clone $this;
  81950. $str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$this->string;
  81951. normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
  81952. if (false === $str->string) {
  81953. throw new InvalidArgumentException('Invalid UTF-8 string.');
  81954. }
  81955. return $str;
  81956. }
  81957. public function replace(string $from, string $to): AbstractString
  81958. {
  81959. $str = clone $this;
  81960. normalizer_is_normalized($from) ?: $from = normalizer_normalize($from);
  81961. if ('' !== $from && false !== $from) {
  81962. $tail = $str->string;
  81963. $result = '';
  81964. $indexOf = $this->ignoreCase ? 'grapheme_stripos' : 'grapheme_strpos';
  81965. while ('' !== $tail && false !== $i = $indexOf($tail, $from)) {
  81966. $slice = grapheme_substr($tail, 0, $i);
  81967. $result .= $slice.$to;
  81968. $tail = substr($tail, \strlen($slice) + \strlen($from));
  81969. }
  81970. $str->string = $result.$tail;
  81971. normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
  81972. if (false === $str->string) {
  81973. throw new InvalidArgumentException('Invalid UTF-8 string.');
  81974. }
  81975. }
  81976. return $str;
  81977. }
  81978. public function replaceMatches(string $fromRegexp, $to): AbstractString
  81979. {
  81980. $str = parent::replaceMatches($fromRegexp, $to);
  81981. normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
  81982. return $str;
  81983. }
  81984. public function slice(int $start = 0, int $length = null): AbstractString
  81985. {
  81986. $str = clone $this;
  81987. if (\PHP_VERSION_ID < 80000 && 0 > $start && grapheme_strlen($this->string) < -$start) {
  81988. $start = 0;
  81989. }
  81990. $str->string = (string) grapheme_substr($this->string, $start, $length ?? 2147483647);
  81991. return $str;
  81992. }
  81993. public function splice(string $replacement, int $start = 0, int $length = null): AbstractString
  81994. {
  81995. $str = clone $this;
  81996. if (\PHP_VERSION_ID < 80000 && 0 > $start && grapheme_strlen($this->string) < -$start) {
  81997. $start = 0;
  81998. }
  81999. $start = $start ? \strlen(grapheme_substr($this->string, 0, $start)) : 0;
  82000. $length = $length ? \strlen(grapheme_substr($this->string, $start, $length ?? 2147483647)) : $length;
  82001. $str->string = substr_replace($this->string, $replacement, $start, $length ?? 2147483647);
  82002. normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
  82003. if (false === $str->string) {
  82004. throw new InvalidArgumentException('Invalid UTF-8 string.');
  82005. }
  82006. return $str;
  82007. }
  82008. public function split(string $delimiter, int $limit = null, int $flags = null): array
  82009. {
  82010. if (1 > $limit = $limit ?? 2147483647) {
  82011. throw new InvalidArgumentException('Split limit must be a positive integer.');
  82012. }
  82013. if ('' === $delimiter) {
  82014. throw new InvalidArgumentException('Split delimiter is empty.');
  82015. }
  82016. if (null !== $flags) {
  82017. return parent::split($delimiter.'u', $limit, $flags);
  82018. }
  82019. normalizer_is_normalized($delimiter) ?: $delimiter = normalizer_normalize($delimiter);
  82020. if (false === $delimiter) {
  82021. throw new InvalidArgumentException('Split delimiter is not a valid UTF-8 string.');
  82022. }
  82023. $str = clone $this;
  82024. $tail = $this->string;
  82025. $chunks = [];
  82026. $indexOf = $this->ignoreCase ? 'grapheme_stripos' : 'grapheme_strpos';
  82027. while (1 < $limit && false !== $i = $indexOf($tail, $delimiter)) {
  82028. $str->string = grapheme_substr($tail, 0, $i);
  82029. $chunks[] = clone $str;
  82030. $tail = substr($tail, \strlen($str->string) + \strlen($delimiter));
  82031. --$limit;
  82032. }
  82033. $str->string = $tail;
  82034. $chunks[] = clone $str;
  82035. return $chunks;
  82036. }
  82037. public function startsWith($prefix): bool
  82038. {
  82039. if ($prefix instanceof AbstractString) {
  82040. $prefix = $prefix->string;
  82041. } elseif (\is_array($prefix) || $prefix instanceof \Traversable) {
  82042. return parent::startsWith($prefix);
  82043. } else {
  82044. $prefix = (string) $prefix;
  82045. }
  82046. $form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
  82047. normalizer_is_normalized($prefix, $form) ?: $prefix = normalizer_normalize($prefix, $form);
  82048. if ('' === $prefix || false === $prefix) {
  82049. return false;
  82050. }
  82051. if ($this->ignoreCase) {
  82052. return 0 === mb_stripos(grapheme_extract($this->string, \strlen($prefix), \GRAPHEME_EXTR_MAXBYTES), $prefix, 0, 'UTF-8');
  82053. }
  82054. return $prefix === grapheme_extract($this->string, \strlen($prefix), \GRAPHEME_EXTR_MAXBYTES);
  82055. }
  82056. public function __wakeup()
  82057. {
  82058. if (!\is_string($this->string)) {
  82059. throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
  82060. }
  82061. normalizer_is_normalized($this->string) ?: $this->string = normalizer_normalize($this->string);
  82062. }
  82063. public function __clone()
  82064. {
  82065. if (null === $this->ignoreCase) {
  82066. normalizer_is_normalized($this->string) ?: $this->string = normalizer_normalize($this->string);
  82067. }
  82068. $this->ignoreCase = false;
  82069. }
  82070. }
  82071. <?php
  82072. if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
  82073. echo 'Warning: Composer should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
  82074. }
  82075. if (PHP_VERSION_ID < 70205) {
  82076. echo 'Composer 2.3.0 dropped support for PHP <7.2.5 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
  82077. exit(1);
  82078. }
  82079. setlocale(LC_ALL, 'C');
  82080. require __DIR__.'/../src/bootstrap.php';
  82081. use Composer\Console\Application;
  82082. use Composer\XdebugHandler\XdebugHandler;
  82083. use Composer\Util\Platform;
  82084. use Composer\Util\ErrorHandler;
  82085. error_reporting(-1);
  82086. // Restart without Xdebug
  82087. $xdebug = new XdebugHandler('Composer');
  82088. $xdebug->check();
  82089. unset($xdebug);
  82090. if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '4.0', '>=')) {
  82091. echo 'HHVM 4.0 has dropped support for Composer, please use PHP instead. Aborting.'.PHP_EOL;
  82092. exit(1);
  82093. }
  82094. if (!extension_loaded('iconv') && !extension_loaded('mbstring')) {
  82095. echo 'The iconv OR mbstring extension is required and both are missing.'
  82096. .PHP_EOL.'Install either of them or recompile php without --disable-iconv.'
  82097. .PHP_EOL.'Aborting.'.PHP_EOL;
  82098. exit(1);
  82099. }
  82100. if (function_exists('ini_set')) {
  82101. @ini_set('display_errors', '1');
  82102. // Set user defined memory limit
  82103. if ($memoryLimit = getenv('COMPOSER_MEMORY_LIMIT')) {
  82104. @ini_set('memory_limit', $memoryLimit);
  82105. } else {
  82106. $memoryInBytes = function ($value) {
  82107. $unit = strtolower(substr($value, -1, 1));
  82108. $value = (int) $value;
  82109. switch($unit) {
  82110. case 'g':
  82111. $value *= 1024;
  82112. // no break (cumulative multiplier)
  82113. case 'm':
  82114. $value *= 1024;
  82115. // no break (cumulative multiplier)
  82116. case 'k':
  82117. $value *= 1024;
  82118. }
  82119. return $value;
  82120. };
  82121. $memoryLimit = trim(ini_get('memory_limit'));
  82122. // Increase memory_limit if it is lower than 1.5GB
  82123. if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1536) {
  82124. @ini_set('memory_limit', '1536M');
  82125. }
  82126. unset($memoryInBytes);
  82127. }
  82128. unset($memoryLimit);
  82129. }
  82130. // Workaround PHP bug on Windows where env vars containing Unicode chars are mangled in $_SERVER
  82131. // see https://github.com/php/php-src/issues/7896
  82132. if (PHP_VERSION_ID >= 70113 && (PHP_VERSION_ID < 80016 || (PHP_VERSION_ID >= 80100 && PHP_VERSION_ID < 80103)) && Platform::isWindows()) {
  82133. foreach ($_SERVER as $serverVar => $serverVal) {
  82134. if (($serverVal = getenv($serverVar)) !== false) {
  82135. $_SERVER[$serverVar] = $serverVal;
  82136. }
  82137. }
  82138. }
  82139. Platform::putEnv('COMPOSER_BINARY', realpath($_SERVER['argv'][0]));
  82140. ErrorHandler::register();
  82141. // run the command application
  82142. $application = new Application();
  82143. $application->run();
  82144. Copyright (c) Nils Adermann, Jordi Boggiano
  82145. Permission is hereby granted, free of charge, to any person obtaining a copy
  82146. of this software and associated documentation files (the "Software"), to deal
  82147. in the Software without restriction, including without limitation the rights
  82148. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  82149. copies of the Software, and to permit persons to whom the Software is furnished
  82150. to do so, subject to the following conditions:
  82151. The above copyright notice and this permission notice shall be included in all
  82152. copies or substantial portions of the Software.
  82153. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  82154. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  82155. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  82156. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  82157. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  82158. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  82159. THE SOFTWARE.
  82160. |鎷”©Š¢Oªd‘±ºËõq¾Šä[Ÿ {È„ÌZÁ:"Ckù^å»ñÄgDn³2ÃUý:À*¿ =M*Ã���GBMB