composer.phar 2.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677
  1. #!/usr/bin/env php
  2. <?php
  3. /*
  4. * This file is part of Composer.
  5. *
  6. * (c) Nils Adermann <naderman@naderman.de>
  7. * Jordi Boggiano <j.boggiano@seld.be>
  8. *
  9. * For the full copyright and license information, please view
  10. * the license that is located at the bottom of this file.
  11. */
  12. // Avoid APC causing random fatal errors per https://github.com/composer/composer/issues/264
  13. if (extension_loaded('apc') && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.cache_by_default'), FILTER_VALIDATE_BOOLEAN)) {
  14. if (version_compare(phpversion('apc'), '3.0.12', '>=')) {
  15. ini_set('apc.cache_by_default', 0);
  16. } else {
  17. fwrite(STDERR, 'Warning: APC <= 3.0.12 may cause fatal errors when running composer commands.'.PHP_EOL);
  18. fwrite(STDERR, 'Update APC, or set apc.enable_cli or apc.cache_by_default to 0 in your php.ini.'.PHP_EOL);
  19. }
  20. }
  21. if (!class_exists('Phar')) {
  22. echo 'PHP\'s phar extension is missing. Composer requires it to run. Enable the extension or recompile php without --disable-phar then try again.' . PHP_EOL;
  23. exit(1);
  24. }
  25. Phar::mapPhar('composer.phar');
  26. require 'phar://composer.phar/bin/composer';
  27. __HALT_COMPILER(); ?>
  28. ‡Á��‰������ ���composer.phar����!���src/Composer/Advisory/Auditor.phpn$��*Ssen$��›R€f¤������1���src/Composer/Advisory/IgnoredSecurityAdvisory.php/��*Sse/��´È¤������1���src/Composer/Advisory/PartialSecurityAdvisory.phpí��*Sseí��è‚2¤������*���src/Composer/Advisory/SecurityAdvisory.php���*Sse���Äg>¤������+���src/Composer/Autoload/AutoloadGenerator.phpÞ†��*SseÞ†��pÞV¤������+���src/Composer/Autoload/ClassMapGenerator.php’��*Sse’���¨|S¤���������src/Composer/Cache.phpQ��*SseQ��Ã;"|¤������%���src/Composer/Command/AboutCommand.phpW��*SseW��â:†!¤������'���src/Composer/Command/ArchiveCommand.php$��*Sse$��dSWA¤������%���src/Composer/Command/AuditCommand.php¾
  29. ��*Sse¾
  30. ��† Ñ5¤������$���src/Composer/Command/BaseCommand.phpä&��*Sseä&�� ^/E¤������.���src/Composer/Command/BaseDependencyCommand.phpö��*Sseö��ý)¢¹¤������$���src/Composer/Command/BumpCommand.phpŽ��*SseŽ��{V'}¤������1���src/Composer/Command/CheckPlatformReqsCommand.php`��*Sse`��ù<t¤������*���src/Composer/Command/ClearCacheCommand.php ��*Sse ��Å*¤������(���src/Composer/Command/CompletionTrait.phpW��*SseW��@Ίö¤������&���src/Composer/Command/ConfigCommand.php%p��*Sse%p��ëpú¤������-���src/Composer/Command/CreateProjectCommand.php�J��*Sse�J��6Jb‡¤������'���src/Composer/Command/DependsCommand.phpE��*SseE���z¤������(���src/Composer/Command/DiagnoseCommand.php®Q��*Sse®Q��Õ} ›¤������,���src/Composer/Command/DumpAutoloadCommand.phpÍ��*SseÍ��2«ÐB¤������$���src/Composer/Command/ExecCommand.php ��*Sse ��ÏW¦�¤������$���src/Composer/Command/FundCommand.phpÁ��*SseÁ��5`ÈG¤������&���src/Composer/Command/GlobalCommand.php���*Sse���!Ûº¤������$���src/Composer/Command/HomeCommand.php^��*Sse^��ë"+C¤������$���src/Composer/Command/InitCommand.php¤B��*Sse¤B��dñ³¤������'���src/Composer/Command/InstallCommand.php\��*Sse\��ö��·¤������(���src/Composer/Command/LicensesCommand.php½��*Sse½��ƃi]¤������(���src/Composer/Command/OutdatedCommand.php…��*Sse…��¦¶…÷¤������.���src/Composer/Command/PackageDiscoveryTrait.phpk6��*Ssek6��V,!å¤������)���src/Composer/Command/ProhibitsCommand.phpå��*Sseå��ÊDrø¤������)���src/Composer/Command/ReinstallCommand.php„��*Sse„��(!»e¤������&���src/Composer/Command/RemoveCommand.php#-��*Sse#-��8£[¢¤������'���src/Composer/Command/RequireCommand.phpïX��*SseïX��¼%÷‰¤������)���src/Composer/Command/RunScriptCommand.php��*Sse��f¿¤������+���src/Composer/Command/ScriptAliasCommand.phpà��*Sseà��8ÉTõ¤������&���src/Composer/Command/SearchCommand.phpo��*Sseo��ÇO�¨¤������*���src/Composer/Command/SelfUpdateCommand.php˜K��*Sse˜K��aÊÓߤ������$���src/Composer/Command/ShowCommand.phpÓª��*SseÓª��‘jy¤������&���src/Composer/Command/StatusCommand.php²��*Sse²��ºoĤ������(���src/Composer/Command/SuggestsCommand.phpÉ ��*SseÉ ��ùÏfk¤������&���src/Composer/Command/UpdateCommand.php·5��*Sse·5��ÞÛÒߤ������(���src/Composer/Command/ValidateCommand.php��*Sse��˘ä¤���������src/Composer/Composer.php���*Sse���òU”8¤���������src/Composer/Config.php¥7��*Sse¥7���ür¤������-���src/Composer/Config/ConfigSourceInterface.phpº��*Sseº��½Ó¤������(���src/Composer/Config/JsonConfigSource.phpc��*Ssec��È!T-¤������$���src/Composer/Console/Application.phpªM��*SseªM��ð²—¤������*���src/Composer/Console/GithubActionError.php��*Sse��`±‰æ¤������,���src/Composer/Console/HtmlOutputFormatter.php>��*Sse>��Ò ïR¤������,���src/Composer/Console/Input/InputArgument.php¶��*Sse¶��ª¼K¤������*���src/Composer/Console/Input/InputOption.phpg��*Sseg��ˆ7'4¤������-���src/Composer/DependencyResolver/Decisions.php���*Sse���)ƒ²&¤������1���src/Composer/DependencyResolver/DefaultPolicy.phpl��*Ssel��<G‘¤������/���src/Composer/DependencyResolver/GenericRule.php–��*Sse–��Z)í¤������8���src/Composer/DependencyResolver/LocalRepoTransaction.php½��*Sse½��ßšHš¤������3���src/Composer/DependencyResolver/LockTransaction.phpI ��*SseI ��Vè�¯¤������5���src/Composer/DependencyResolver/MultiConflictRule.php+��*Sse+��Ãwì¤������>���src/Composer/DependencyResolver/Operation/InstallOperation.phpÿ��*Sseÿ��=ú§§¤������I���src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php��*Sse���1NJ¤������K���src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php��*Sse��tw ¤������@���src/Composer/DependencyResolver/Operation/OperationInterface.phpø���*Sseø���÷Wý¤������=���src/Composer/DependencyResolver/Operation/SolverOperation.phpH��*SseH��§¤������@���src/Composer/DependencyResolver/Operation/UninstallOperation.phpç��*Sseç��|ÁR¤������=���src/Composer/DependencyResolver/Operation/UpdateOperation.phpŸ��*SseŸ��Ü7椤������3���src/Composer/DependencyResolver/PolicyInterface.phpž��*Ssež��øÎá¤������(���src/Composer/DependencyResolver/Pool.php ��*Sse ��xF!¤������/���src/Composer/DependencyResolver/PoolBuilder.phpRF��*SseRF��ìLûì¤������1���src/Composer/DependencyResolver/PoolOptimizer.phpÛ)��*SseÛ)��¥!\¤������+���src/Composer/DependencyResolver/Problem.phpøN��*SseøN��âÈò1¤������+���src/Composer/DependencyResolver/Request.php���*Sse���À›sܤ������(���src/Composer/DependencyResolver/Rule.php<0��*Sse<0��À³ù¤������1���src/Composer/DependencyResolver/Rule2Literals.php��*Sse��3vþ¤������+���src/Composer/DependencyResolver/RuleSet.php£ ��*Sse£ ��uò©Ä¤������4���src/Composer/DependencyResolver/RuleSetGenerator.php=��*Sse=��kŤ������3���src/Composer/DependencyResolver/RuleSetIterator.phpõ��*Sseõ��œ y¤������2���src/Composer/DependencyResolver/RuleWatchChain.php{��*Sse{��‚hóD¤������2���src/Composer/DependencyResolver/RuleWatchGraph.phpœ ��*Sseœ ��Zœ{|¤������1���src/Composer/DependencyResolver/RuleWatchNode.phpv��*Ssev��p™·¤������*���src/Composer/DependencyResolver/Solver.php³7��*Sse³7��²{פ������6���src/Composer/DependencyResolver/SolverBugException.php¹��*Sse¹��z­=¤������;���src/Composer/DependencyResolver/SolverProblemsException.phpœ��*Sseœ��¼.½À¤������/���src/Composer/DependencyResolver/Transaction.php-��*Sse-��É铤������-���src/Composer/Downloader/ArchiveDownloader.phpú��*Sseú��Ó�%š¤������1���src/Composer/Downloader/ChangeReportInterface.phpõ���*Sseõ���­ÃÂB¤������+���src/Composer/Downloader/DownloadManager.phpª��*Sseª��²œ?g¤������/���src/Composer/Downloader/DownloaderInterface.phpÓ��*SseÓ��bm[Ȥ������3���src/Composer/Downloader/DvcsDownloaderInterface.phpú���*Sseú���à%'¤������*���src/Composer/Downloader/FileDownloader.php2��*Sse2��WcÊD¤������/���src/Composer/Downloader/FilesystemException.php/��*Sse/��!‹å&¤������,���src/Composer/Downloader/FossilDownloader.phpi ��*Ssei ��¡‹Z¤������)���src/Composer/Downloader/GitDownloader.php�E��*Sse�E��Aõ›@¤������*���src/Composer/Downloader/GzipDownloader.php±��*Sse±��í‰v÷¤������(���src/Composer/Downloader/HgDownloader.php? ��*Sse? ��€/Œ¤������8���src/Composer/Downloader/MaxFileSizeExceededException.phpŒ���*SseŒ���ÚºÔ¤������*���src/Composer/Downloader/PathDownloader.php*��*Sse*��¯?a¤������.���src/Composer/Downloader/PerforceDownloader.php‹ ��*Sse‹ ���<­�¤������*���src/Composer/Downloader/PharDownloader.phpª��*Sseª��XÈȤ������)���src/Composer/Downloader/RarDownloader.php›��*Sse›��GU¤������)���src/Composer/Downloader/SvnDownloader.phpƒ��*Sseƒ��…}%"¤������)���src/Composer/Downloader/TarDownloader.php¨��*Sse¨��×rß‚¤������.���src/Composer/Downloader/TransportException.phps��*Sses��ø ¤������9���src/Composer/Downloader/VcsCapableDownloaderInterface.phpý���*Sseý���ä6¤¤������)���src/Composer/Downloader/VcsDownloader.php6��*Sse6��_w˜ø¤������(���src/Composer/Downloader/XzDownloader.php­��*Sse­��&Ør‚¤������)���src/Composer/Downloader/ZipDownloader.php—#��*Sse—#��žÖÊ›¤������&���src/Composer/EventDispatcher/Event.phpØ��*SseØ��…÷¡ð¤������0���src/Composer/EventDispatcher/EventDispatcher.php²@��*Sse²@��A…8À¤������9���src/Composer/EventDispatcher/EventSubscriberInterface.phpÂ���*SseÂ���}=é¤������9���src/Composer/EventDispatcher/ScriptExecutionException.php‘���*Sse‘���XvèϤ������9���src/Composer/Exception/IrrecoverableDownloadException.php����*Sse����0Þ4 ¤������)���src/Composer/Exception/NoSslException.php����*Sse����ØU¦Ò¤���������src/Composer/Factory.php’O��*Sse’O��øTl©¤������T���src/Composer/Filter/PlatformRequirementFilter/IgnoreAllPlatformRequirementFilter.phpS��*SseS��~Jå¤������U���src/Composer/Filter/PlatformRequirementFilter/IgnoreListPlatformRequirementFilter.phpY��*SseY��ш¤¤������X���src/Composer/Filter/PlatformRequirementFilter/IgnoreNothingPlatformRequirementFilter.php��*Sse��~º&#¤������R���src/Composer/Filter/PlatformRequirementFilter/PlatformRequirementFilterFactory.phpw��*Ssew��ÑT¿¤������T���src/Composer/Filter/PlatformRequirementFilter/PlatformRequirementFilterInterface.php¿���*Sse¿���×€n¤���������src/Composer/IO/BaseIO.phpØ��*SseØ�� „¤���������src/Composer/IO/BufferIO.php{��*Sse{��@M¤���������src/Composer/IO/ConsoleIO.phpë��*Sseë��«ýâ¤���������src/Composer/IO/IOInterface.phpÐ��*SseÐ��~ÿh­¤���������src/Composer/IO/NullIO.phpO��*SseO��bˆ¨s¤���������src/Composer/Installer.php‹ˆ��*Sse‹ˆ��C.7¤������*���src/Composer/Installer/BinaryInstaller.phpp)��*Ssep)��|ÛâK¤������2���src/Composer/Installer/BinaryPresenceInterface.phpæ���*Sseæ���®3—Œ¤������.���src/Composer/Installer/InstallationManager.php�5��*Sse�5��%ֽפ������)���src/Composer/Installer/InstallerEvent.php*��*Sse*��FZäÙ¤������*���src/Composer/Installer/InstallerEvents.php¥���*Sse¥���>•íǤ������-���src/Composer/Installer/InstallerInterface.php~��*Sse~���͔դ������+���src/Composer/Installer/LibraryInstaller.php��*Sse��ºc2¤������/���src/Composer/Installer/MetapackageInstaller.phpÖ��*SseÖ��û
  31. õ"¤������(���src/Composer/Installer/NoopInstaller.phpa��*Ssea��êxQn¤������'���src/Composer/Installer/PackageEvent.phpô��*Sseô��b‘\A¤������(���src/Composer/Installer/PackageEvents.phpû��*Sseû��ò«K¤������*���src/Composer/Installer/PluginInstaller.php4 ��*Sse4 ��Åó¤������+���src/Composer/Installer/ProjectInstaller.php9 ��*Sse9 ��Uц¤������4���src/Composer/Installer/SuggestedPackagesReporter.php¥��*Sse¥��ö”Oë¤���������src/Composer/Json/JsonFile.phpY��*SseY��8òh¤������#���src/Composer/Json/JsonFormatter.phpÀ��*SseÀ��øAqå¤������%���src/Composer/Json/JsonManipulator.phpL6��*SseL6��ĵð¤������-���src/Composer/Json/JsonValidationException.php—��*Sse—���^^´¤������2���src/Composer/PHPStan/ConfigReturnTypeExtension.php–��*Sse–��uoü¤������:���src/Composer/PHPStan/RuleReasonDataReturnTypeExtension.php~��*Sse~��¦ç¬H¤������%���src/Composer/Package/AliasPackage.phpk��*Ssek��®‰é¤������7���src/Composer/Package/Archiver/ArchivableFilesFilter.phpS��*SseS��'25f¤������7���src/Composer/Package/Archiver/ArchivableFilesFinder.phpl��*Ssel��mu!¤������0���src/Composer/Package/Archiver/ArchiveManager.php!��*Sse!��jè*Þ¤������3���src/Composer/Package/Archiver/ArchiverInterface.phpS��*SseS��ÿì?î¤������3���src/Composer/Package/Archiver/BaseExcludeFilter.php��*Sse��xÆ6Ȥ������7���src/Composer/Package/Archiver/ComposerExcludeFilter.php?��*Sse?��?�`^¤������2���src/Composer/Package/Archiver/GitExcludeFilter.php$��*Sse$��t�8N¤������.���src/Composer/Package/Archiver/PharArchiver.phpÆ��*SseÆ��-íÙª¤������-���src/Composer/Package/Archiver/ZipArchiver.phpŽ��*SseŽ��aEФ������$���src/Composer/Package/BasePackage.phpö��*Sseö��ÿ¡Â̤������*���src/Composer/Package/Comparer/Comparer.php¦ ��*Sse¦ ��7Fâ¤������-���src/Composer/Package/CompleteAliasPackage.phpq
  32. ��*Sseq
  33. ��ú #·¤������(���src/Composer/Package/CompletePackage.php
  34. ��*Sse
  35. ��† J±¤������1���src/Composer/Package/CompletePackageInterface.php���*Sse���‰‘”¤������+���src/Composer/Package/Dumper/ArrayDumper.phpH ��*SseH ��(ª ¤���������src/Composer/Package/Link.phpö��*Sseö�� "j¥¤������+���src/Composer/Package/Loader/ArrayLoader.phpÛ-��*SseÛ-��uÐäǤ������7���src/Composer/Package/Loader/InvalidPackageException.php„��*Sse„��èMü•¤������*���src/Composer/Package/Loader/JsonLoader.php“��*Sse“��褢4¤������/���src/Composer/Package/Loader/LoaderInterface.phpž��*Ssež��FB¤¤������1���src/Composer/Package/Loader/RootPackageLoader.php��*Sse��Ñh›½¤������5���src/Composer/Package/Loader/ValidatingArrayLoader.php N��*Sse N��Ló'¤���������src/Composer/Package/Locker.php›/��*Sse›/��꧉ù¤������ ���src/Composer/Package/Package.php_$��*Sse_$��RóBJ¤������)���src/Composer/Package/PackageInterface.phpÓ ��*SseÓ ��]ÀÄá¤������)���src/Composer/Package/RootAliasPackage.phpç ��*Sseç ��A:–D¤������$���src/Composer/Package/RootPackage.php©��*Sse©�� º¤������-���src/Composer/Package/RootPackageInterface.php9��*Sse9��ˆ¨ì¤������0���src/Composer/Package/Version/StabilityFilter.php��*Sse��µêrú¤������.���src/Composer/Package/Version/VersionBumper.php ��*Sse ��`Oñ¤������/���src/Composer/Package/Version/VersionGuesser.phpå'��*Sseå'��H¬‘¤������.���src/Composer/Package/Version/VersionParser.phpÔ��*SseÔ��Øà’æ¤������0���src/Composer/Package/Version/VersionSelector.php‰��*Sse‰��Q¨4œ¤������ ���src/Composer/PartialComposer.phpþ��*Sseþ��¨ù š¤������&���src/Composer/Platform/HhvmDetector.php-��*Sse-���‚À#¤������!���src/Composer/Platform/Runtime.phpï��*Sseï��o^1%¤������!���src/Composer/Platform/Version.php¨��*Sse¨��»¤������-���src/Composer/Plugin/Capability/Capability.phpp���*Ssep���š#c;¤������2���src/Composer/Plugin/Capability/CommandProvider.php°���*Sse°���FüÙ¤¤���������src/Composer/Plugin/Capable.php˜���*Sse˜���û°hª¤������$���src/Composer/Plugin/CommandEvent.php?��*Sse?��|U`¤������.���src/Composer/Plugin/PluginBlockedException.php§���*Sse§���öùr¤������$���src/Composer/Plugin/PluginEvents.php¨��*Sse¨��\K“Ö¤������'���src/Composer/Plugin/PluginInterface.php«��*Sse«��õ1i ¤������%���src/Composer/Plugin/PluginManager.php�M��*Sse�M��v¥¤������-���src/Composer/Plugin/PostFileDownloadEvent.php¿��*Sse¿��à@>‰¤������*���src/Composer/Plugin/PreCommandRunEvent.php/��*Sse/��3 ±¤������,���src/Composer/Plugin/PreFileDownloadEvent.php ��*Sse ��´qŠl¤������*���src/Composer/Plugin/PrePoolCreateEvent.php±��*Sse±��ó¼Û¤������4���src/Composer/Question/StrictConfirmationQuestion.php•��*Sse•��x”»A¤������5���src/Composer/Repository/AdvisoryProviderInterface.php©��*Sse©��•а¤������+���src/Composer/Repository/ArrayRepository.php4��*Sse4��º�ÒÕ¤������.���src/Composer/Repository/ArtifactRepository.phpt ��*Sset ���Ôã¤������2���src/Composer/Repository/CanonicalPackagesTrait.phpÄ��*SseÄ��¦{ë¤������.���src/Composer/Repository/ComposerRepository.phpÔ²��*SseÔ²��’¾µ¼¤������/���src/Composer/Repository/CompositeRepository.php… ��*Sse… ��û«ߤ������;���src/Composer/Repository/ConfigurableRepositoryInterface.php¡���*Sse¡���ce*2¤������0���src/Composer/Repository/FilesystemRepository.php#��*Sse#��mý´s¤������,���src/Composer/Repository/FilterRepository.phpg��*Sseg��+¯F¾¤������4���src/Composer/Repository/InstalledArrayRepository.phpX��*SseX��¼,[¤������9���src/Composer/Repository/InstalledFilesystemRepository.phpJ��*SseJ��'kCè¤������/���src/Composer/Repository/InstalledRepository.phpK��*SseK��y™á’¤������8���src/Composer/Repository/InstalledRepositoryInterface.phpà���*Sseà���¾²ÿg¤������6���src/Composer/Repository/InvalidRepositoryException.php‡���*Sse‡��� W<_¤������/���src/Composer/Repository/LockArrayRepository.phpâ���*Sseâ����^†ú¤������-���src/Composer/Repository/PackageRepository.php ��*Sse ��\/*þ¤������*���src/Composer/Repository/PathRepository.php���*Sse���ç,j ¤������*���src/Composer/Repository/PearRepository.php��*Sse��QuÏj¤������.���src/Composer/Repository/PlatformRepository.phpVW��*SseVW��ÑYQ«¤������-���src/Composer/Repository/RepositoryFactory.phpW��*SseW��è(¤������/���src/Composer/Repository/RepositoryInterface.php¤��*Sse¤��, :¤������-���src/Composer/Repository/RepositoryManager.php¢ ��*Sse¢ ��,}~¤������7���src/Composer/Repository/RepositorySecurityException.phpˆ���*Sseˆ���qœ×t¤������)���src/Composer/Repository/RepositorySet.php0!��*Sse0!��Tdä¤������+���src/Composer/Repository/RepositoryUtils.php��*Sse��I³z¤������1���src/Composer/Repository/RootPackageRepository.php\��*Sse\��¾`9ü¤������,���src/Composer/Repository/Vcs/FossilDriver.phpB��*SseB��~*�¦¤������2���src/Composer/Repository/Vcs/GitBitbucketDriver.phpÖ&��*SseÖ&��ëy!†¤������)���src/Composer/Repository/Vcs/GitDriver.phps��*Sses��¼„%ݤ������,���src/Composer/Repository/Vcs/GitHubDriver.php!9��*Sse!9��º”7¾¤������,���src/Composer/Repository/Vcs/GitLabDriver.php†2��*Sse†2��à„ܸ¤������(���src/Composer/Repository/Vcs/HgDriver.phpå��*Sseå��lëñ9¤������.���src/Composer/Repository/Vcs/PerforceDriver.php ��*Sse ��Î%ÿÚ¤������)���src/Composer/Repository/Vcs/SvnDriver.php+��*Sse+��ßTc¬¤������)���src/Composer/Repository/Vcs/VcsDriver.php ��*Sse ��Î&þ:¤������2���src/Composer/Repository/Vcs/VcsDriverInterface.php±��*Sse±��TŠ„ø¤������)���src/Composer/Repository/VcsRepository.php~4��*Sse~4��
  36. 0À¯¤������1���src/Composer/Repository/VersionCacheInterface.php¹���*Sse¹���‚h‡¤������3���src/Composer/Repository/WritableArrayRepository.phpÙ��*SseÙ��l&´#¤������7���src/Composer/Repository/WritableRepositoryInterface.phpw��*Ssew��Õ~¼0¤���������src/Composer/Script/Event.phpå��*Sseå��м y¤������$���src/Composer/Script/ScriptEvents.phpI��*SseI��¤£D4¤������ ���src/Composer/SelfUpdate/Keys.phpÙ��*SseÙ��É ¨s¤������$���src/Composer/SelfUpdate/Versions.php\ ��*Sse\ ��nMè0¤������ ���src/Composer/Util/AuthHelper.phpv#��*Ssev#��3̱¤���������src/Composer/Util/Bitbucket.php8��*Sse8��Y‚Ôë¤������$���src/Composer/Util/ComposerMirror.php ��*Sse ��·ÍIs¤������%���src/Composer/Util/ConfigValidator.phpe��*Ssee��Ñ3¶°¤������"���src/Composer/Util/ErrorHandler.phpL��*SseL��Q%Ìã¤������ ���src/Composer/Util/Filesystem.php–?��*Sse–?��ø½¯*¤���������src/Composer/Util/Git.php÷:��*Sse÷:��ÿe9¤���������src/Composer/Util/GitHub.php��*Sse��ïU눤���������src/Composer/Util/GitLab.phpŽ��*SseŽ��äs �¤���������src/Composer/Util/Hg.phpD��*SseD��ùºvA¤������)���src/Composer/Util/Http/CurlDownloader.phpL��*SseL��˜ãx‚¤������'���src/Composer/Util/Http/CurlResponse.php•��*Sse•��’;©¹¤������&���src/Composer/Util/Http/ProxyHelper.php‘
  37. ��*Sse‘
  38. ��/\_ ¤������'���src/Composer/Util/Http/ProxyManager.phpz
  39. ��*Ssez
  40. ��F¨Q¤������'���src/Composer/Util/Http/RequestProxy.phpg��*Sseg��̇òµ¤������#���src/Composer/Util/Http/Response.phpã��*Sseã��ÖmR^¤������$���src/Composer/Util/HttpDownloader.phpï)��*Sseï)��ó'kö¤���������src/Composer/Util/IniHelper.phpŽ��*SseŽ��™m®B¤���������src/Composer/Util/Loop.phpý��*Sseý��Ÿû£¤������&���src/Composer/Util/MetadataMinifier.phpC��*SseC��d ˜¤������$���src/Composer/Util/NoProxyPattern.php(��*Sse(��Mû ¡¤������!���src/Composer/Util/PackageInfo.phpà��*Sseà���RX¤������#���src/Composer/Util/PackageSorter.phpÅ��*SseÅ��öµ›ž¤���������src/Composer/Util/Perforce.php"4��*Sse"4��E�Q[¤���������src/Composer/Util/Platform.phpÔ��*SseÔ��ˆ“’ͤ������%���src/Composer/Util/ProcessExecutor.php› ��*Sse› ��®ŸûÞ¤������&���src/Composer/Util/RemoteFilesystem.phpÖ@��*SseÖ@��
  41. ŠRU¤���������src/Composer/Util/Silencer.phpü��*Sseü��Ðå•À¤������*���src/Composer/Util/StreamContextFactory.php€��*Sse€��ý)Ť���������src/Composer/Util/Svn.phpô��*Sseô��ÕL¥8¤������ ���src/Composer/Util/SyncHelper.phpÿ��*Sseÿ��ÐzA¤���������src/Composer/Util/Tar.php…��*Sse…��÷Ìt?¤���������src/Composer/Util/TlsHelper.phpj ��*Ssej ��Ч†Q¤���������src/Composer/Util/Url.phpÙ ��*SseÙ ��Q—_O¤���������src/Composer/Util/Zip.php��*Sse��£DÙ‘¤���������src/bootstrap.php
  42. ��*Sse
  43. ��ÑÄ-Ȥ������%���src/Composer/Autoload/ClassLoader.phpú?��*Sseú?��2@u¤������"���src/Composer/InstalledVersions.php?��*Sse?�� 2ªÅ¤������#���res/composer-repository-schema.jsonñ��*Sseñ��|0à„¤���������res/composer-schema.jsonÅ��*SseÅ��´sP˜¤���������vendor/autoload.phpo��*Sseo��G9b¤���������vendor/composer/ClassLoader.php/��*Sse/��˜Õâ’¤������%���vendor/composer/InstalledVersions.php��*Sse���xG¤������%���vendor/composer/autoload_classmap.phpò��*Sseò��êðÙפ������"���vendor/composer/autoload_files.php��*Sse��‹ebd¤������'���vendor/composer/autoload_namespaces.phpZ���*SseZ���ë¦á–¤������!���vendor/composer/autoload_psr4.php®��*Sse®��úYI¤������!���vendor/composer/autoload_real.phpÆ��*SseÆ��Xk]¤������#���vendor/composer/autoload_static.php0��*Sse0���ËÍ«¤������!���vendor/composer/ca-bundle/LICENSE��*Sse��G _¤������(���vendor/composer/ca-bundle/res/cacert.pema�*Ssea�"M7Õ¤������*���vendor/composer/ca-bundle/src/CaBundle.php•$��*Sse•$��ÛnÓ¤������+���vendor/composer/class-map-generator/LICENSE��*Sse��=ù¾õ¤������4���vendor/composer/class-map-generator/src/ClassMap.phpÀ��*SseÀ��c¾Ã[¤������=���vendor/composer/class-map-generator/src/ClassMapGenerator.php›��*Sse›��´A M¤������4���vendor/composer/class-map-generator/src/FileList.php$��*Sse$��hôSq¤������:���vendor/composer/class-map-generator/src/PhpFileCleaner.php��*Sse��š5]¤������9���vendor/composer/class-map-generator/src/PhpFileParser.phpQ ��*SseQ ��òoay¤���������vendor/composer/installed.php� ��*Sse� ��³ùs¤������)���vendor/composer/metadata-minifier/LICENSE��*Sse��½£ëǤ������:���vendor/composer/metadata-minifier/src/MetadataMinifier.phpÐ��*SseÐ��Â0&À¤���������vendor/composer/pcre/LICENSE��*Sse��½£ëǤ������+���vendor/composer/pcre/src/MatchAllResult.php��*Sse�� \9ÿ¤������7���vendor/composer/pcre/src/MatchAllStrictGroupsResult.php)��*Sse)��hIŸ…¤������6���vendor/composer/pcre/src/MatchAllWithOffsetsResult.php*��*Sse*��øA à¤������(���vendor/composer/pcre/src/MatchResult.phpï���*Sseï���<äÀ¤������4���vendor/composer/pcre/src/MatchStrictGroupsResult.phpû���*Sseû���§Ë0Q¤������3���vendor/composer/pcre/src/MatchWithOffsetsResult.phpü���*Sseü���{*,o¤������*���vendor/composer/pcre/src/PcreException.phpI��*SseI��Ìà
  44. 7¤������!���vendor/composer/pcre/src/Preg.phpû!��*Sseû!�� ƒƒ¤������"���vendor/composer/pcre/src/Regex.php ��*Sse ��à}]¤������*���vendor/composer/pcre/src/ReplaceResult.php��*Sse��'±Èð¤������9���vendor/composer/pcre/src/UnexpectedNullMatchException.php��*Sse�� îÀò¤���������vendor/composer/semver/LICENSE��*Sse��ÇSRm¤������)���vendor/composer/semver/src/Comparator.php��*Sse��^_E“¤������/���vendor/composer/semver/src/CompilingMatcher.phpc��*Ssec��„€¦¤������/���vendor/composer/semver/src/Constraint/Bound.phpw��*Ssew��W4]W¤������4���vendor/composer/semver/src/Constraint/Constraint.phpø��*Sseø��’‹ˆ½¤������=���vendor/composer/semver/src/Constraint/ConstraintInterface.php¡��*Sse¡��Ž5´y¤������<���vendor/composer/semver/src/Constraint/MatchAllConstraint.php¯��*Sse¯��²Eú¤������=���vendor/composer/semver/src/Constraint/MatchNoneConstraint.phpÉ��*SseÉ��֯خ¤������9���vendor/composer/semver/src/Constraint/MultiConstraint.phpŠ��*SseŠ��ÍÕĤ������'���vendor/composer/semver/src/Interval.phpæ��*Sseæ��=[i¤������(���vendor/composer/semver/src/Intervals.php¤+��*Sse¤+��@1º«¤������%���vendor/composer/semver/src/Semver.phpù��*Sseù��á-i¤������,���vendor/composer/semver/src/VersionParser.phpÿ,��*Sseÿ,��¦3ªÐ¤������%���vendor/composer/spdx-licenses/LICENSE��*Sse��ÇSRm¤������6���vendor/composer/spdx-licenses/res/spdx-exceptions.json¸ ��*Sse¸ ��Â4DC¤������4���vendor/composer/spdx-licenses/res/spdx-licenses.json<Â��*Sse<Â��=ë8¤������2���vendor/composer/spdx-licenses/src/SpdxLicenses.php{��*Sse{��cE�¤������&���vendor/composer/xdebug-handler/LICENSE+��*Sse+��Öã@T¤������0���vendor/composer/xdebug-handler/src/PhpConfig.php‰��*Sse‰��gÔ�v¤������.���vendor/composer/xdebug-handler/src/Process.phpÖ��*SseÖ��o7¾¤������-���vendor/composer/xdebug-handler/src/Status.phpº ��*Sseº ��xf17¤������4���vendor/composer/xdebug-handler/src/XdebugHandler.phpr)��*Sser)��8Õc6¤������(���vendor/justinrainbow/json-schema/LICENSE"��*Sse"�� |»™¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/BaseConstraint.php¡ ��*Sse¡ ��†wÌl¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/CollectionConstraint.phpƒ
  45. ��*Sseƒ
  46. ��ž¸=š¤������J���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Constraint.phpÁ ��*SseÁ ��–PFF¤������S���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ConstraintInterface.php¼��*Sse¼��ÿ Qœ¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/EnumConstraint.php\��*Sse\��_}ý¤������G���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Factory.phpà ��*Sseà ��ë’_”¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/FormatConstraint.phps��*Sses��d Þ¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/NumberConstraint.phpƒ ��*Sseƒ ��e� ¨¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ObjectConstraint.php·��*Sse·��%l¬ö¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/SchemaConstraint.php& ��*Sse& ��78÷¬¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/StringConstraint.phpz��*Ssez��ùfÅ~¤������X���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/LooseTypeCheck.phpa��*Ssea�� qä������Y���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/StrictTypeCheck.php—��*Sse—��4~¾ ¤������\���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/TypeCheckInterface.php‰��*Sse‰��“µ+j¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeConstraint.php*��*Sse*��1–4N¤������S���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/UndefinedConstraint.phpG"��*SseG"��@‹?¤������F���vendor/justinrainbow/json-schema/src/JsonSchema/Entity/JsonPointer.phpè��*Sseè��{N–¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ExceptionInterface.phpI���*SseI���%|°¤������V���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidArgumentException.php•���*Sse•���‹àG¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidConfigException.phpl���*Ssel���A!Lפ������T���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSchemaException.phpl���*Ssel���è2÷þ¤������]���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSchemaMediaTypeException.phpu���*Sseu���=hç¤������W���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSourceUriException.phpw���*Ssew���N-ò[¤������S���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/JsonDecodingException.phpÞ��*SseÞ��\¸
  47. ¤������W���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ResourceNotFoundException.phpo���*Sseo���píÛù¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/RuntimeException.php…���*Sse…���%…—¤������^���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/UnresolvableJsonPointerException.php€���*Sse€���u-#1¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/UriResolverException.phpj���*Ssej���å>�¤������Q���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ValidationException.phpf���*Ssef���¬¤„þ¤������K���vendor/justinrainbow/json-schema/src/JsonSchema/Iterator/ObjectIterator.phpþ��*Sseþ��M�„õ¤������;���vendor/justinrainbow/json-schema/src/JsonSchema/Rfc3339.php ��*Sse ��f4÷³¤������A���vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.php“ ��*Sse“ ��&zß^¤������J���vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorageInterface.php��*Sse��oŠ+}¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/AbstractRetriever.phpá���*Sseá���[þA�¤������G���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/Curl.php£��*Sse£��Ç’ô¦¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/FileGetContents.php ��*Sse ��£Á¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/PredefinedArray.php,��*Sse,��1•5þ¤������X���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/UriRetrieverInterface.php®���*Sse®���ÿ‹Áå¤������C���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriResolver.php ��*Sse ��æP¤������D���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriRetriever.php@��*Sse@��5Î3¤������H���vendor/justinrainbow/json-schema/src/JsonSchema/UriResolverInterface.phpƒ���*Sseƒ���J€¤������I���vendor/justinrainbow/json-schema/src/JsonSchema/UriRetrieverInterface.php…���*Sse…���íæe¤������=���vendor/justinrainbow/json-schema/src/JsonSchema/Validator.phps��*Sses��ßÁ‘#¤���������vendor/psr/container/LICENSE{��*Sse{��ÕÓ�e¤������8���vendor/psr/container/src/ContainerExceptionInterface.phpN���*SseN���üLƒ¤������/���vendor/psr/container/src/ContainerInterface.php·���*Sse·���Šã¼¤������7���vendor/psr/container/src/NotFoundExceptionInterface.phpq���*Sseq���Rúõ¤���������vendor/psr/log/LICENSE?��*Sse?��„ù ¤������)���vendor/psr/log/Psr/Log/AbstractLogger.php;��*Sse;��ñ>3[¤������3���vendor/psr/log/Psr/Log/InvalidArgumentException.php`���*Sse`��� ˆX1¤������#���vendor/psr/log/Psr/Log/LogLevel.phpû���*Sseû���jðñ8¤������/���vendor/psr/log/Psr/Log/LoggerAwareInterface.php|���*Sse|���$£ˆ¤������+���vendor/psr/log/Psr/Log/LoggerAwareTrait.php§���*Sse§���T½úB¤������*���vendor/psr/log/Psr/Log/LoggerInterface.phpÈ��*SseÈ��šx¤������&���vendor/psr/log/Psr/Log/LoggerTrait.phpk��*Ssek��£}‰’¤������%���vendor/psr/log/Psr/Log/NullLogger.phpŸ���*SseŸ����Xóª¤������)���vendor/psr/log/Psr/Log/Test/DummyTest.phpp���*Ssep���Τ������3���vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php ��*Sse ��$/Ò¤������*���vendor/psr/log/Psr/Log/Test/TestLogger.php<��*Sse<��þ(åI¤���������vendor/react/promise/LICENSEi��*Ssei��3}‹¤������%���vendor/react/promise/src/Deferred.phpO��*SseO��ìú]O¤������9���vendor/react/promise/src/Exception/CompositeException.phpŒ��*SseŒ��!ŒÏâ¤������6���vendor/react/promise/src/Exception/LengthException.php^���*Sse^���?q¤������7���vendor/react/promise/src/Internal/CancellationQueue.phpr��*Sser���x_±¤������6���vendor/react/promise/src/Internal/FulfilledPromise.phpu��*Sseu��oV™¤������5���vendor/react/promise/src/Internal/RejectedPromise.phpâ��*Sseâ��_ Û¤������$���vendor/react/promise/src/Promise.php��*Sse��=¿H¤������-���vendor/react/promise/src/PromiseInterface.phpi��*Ssei��&](¤������&���vendor/react/promise/src/functions.php���*Sse���l:ͤ������.���vendor/react/promise/src/functions_include.php]���*Sse]���QÑ<¡¤���������vendor/seld/jsonlint/LICENSE$��*Sse$��4:‡~¤������@���vendor/seld/jsonlint/src/Seld/JsonLint/DuplicateKeyException.php}��*Sse}��Û…Dê¤������5���vendor/seld/jsonlint/src/Seld/JsonLint/JsonParser.php5��*Sse5��(æ¤������0���vendor/seld/jsonlint/src/Seld/JsonLint/Lexer.php3��*Sse3��ön[¤������;���vendor/seld/jsonlint/src/Seld/JsonLint/ParsingException.php(��*Sse(��>Ûv}¤������4���vendor/seld/jsonlint/src/Seld/JsonLint/Undefined.php>���*Sse>���ÿqŸŸ¤���������vendor/seld/phar-utils/LICENSE$��*Sse$��š,M§¤������%���vendor/seld/phar-utils/src/Linter.phpi��*Ssei�� �Þ¤������)���vendor/seld/phar-utils/src/Timestamps.php^ ��*Sse^ ���åÃD¤������"���vendor/seld/signal-handler/LICENSE$��*Sse$��š,M§¤������0���vendor/seld/signal-handler/src/SignalHandler.php°��*Sse°����
  48. ¤������&���vendor/symfony/console/Application.phpq��*Sseq��õ¿-Ö¤������.���vendor/symfony/console/Attribute/AsCommand.phpÔ��*SseÔ��½3Üþ¤������2���vendor/symfony/console/CI/GithubActionReporter.phpé��*Sseé��’ 5¤������ ���vendor/symfony/console/Color.phph��*Sseh��Gbç—¤������*���vendor/symfony/console/Command/Command.phpF'��*SseF'��û¹þ¤������2���vendor/symfony/console/Command/CompleteCommand.php‹��*Sse‹��¾}¤������8���vendor/symfony/console/Command/DumpCompletionCommand.php���*Sse���9›9¤������.���vendor/symfony/console/Command/HelpCommand.php ��*Sse ��}—¥¤������.���vendor/symfony/console/Command/LazyCommand.php˜��*Sse˜��ä~¤������.���vendor/symfony/console/Command/ListCommand.php1 ��*Sse1 ��$D»|¤������0���vendor/symfony/console/Command/LockableTrait.php��*Sse��.ºV¤������=���vendor/symfony/console/Command/SignalableCommandInterface.phpÓ���*SseÓ���»B`¾¤������?���vendor/symfony/console/CommandLoader/CommandLoaderInterface.phpQ��*SseQ��›žH¤������?���vendor/symfony/console/CommandLoader/ContainerCommandLoader.phpU��*SseU��Ë_ü¤������=���vendor/symfony/console/CommandLoader/FactoryCommandLoader.php¯��*Sse¯��d¼"z¤������5���vendor/symfony/console/Completion/CompletionInput.php��*Sse��”$„k¤������;���vendor/symfony/console/Completion/CompletionSuggestions.phpÂ��*SseÂ��A¡¤������A���vendor/symfony/console/Completion/Output/BashCompletionOutput.phpg��*Sseg��‡ìùW¤������F���vendor/symfony/console/Completion/Output/CompletionOutputInterface.phpF��*SseF��Ô2nM¤������0���vendor/symfony/console/Completion/Suggestion.php3��*Sse3��̆ ¤������(���vendor/symfony/console/ConsoleEvents.phpÕ��*SseÕ���gw]¤������!���vendor/symfony/console/Cursor.php� ��*Sse� ��Æ«§Ž¤������D���vendor/symfony/console/DependencyInjection/AddConsoleCommandPass.phpf��*Ssef��#Ô $¤������<���vendor/symfony/console/Descriptor/ApplicationDescription.phpØ ��*SseØ ��=¬Ä¥¤������0���vendor/symfony/console/Descriptor/Descriptor.php}��*Sse}��±ê3^¤������9���vendor/symfony/console/Descriptor/DescriptorInterface.php÷���*Sse÷���µå@à¤������4���vendor/symfony/console/Descriptor/JsonDescriptor.phpë��*Sseë��1%è�¤������8���vendor/symfony/console/Descriptor/MarkdownDescriptor.phpQ��*SseQ��t ˆv¤������4���vendor/symfony/console/Descriptor/TextDescriptor.phpç"��*Sseç"��ȸÌˤ������3���vendor/symfony/console/Descriptor/XmlDescriptor.php��*Sse��‡¶¤������4���vendor/symfony/console/Event/ConsoleCommandEvent.phpÆ��*SseÆ�� ¼O~¤������2���vendor/symfony/console/Event/ConsoleErrorEvent.phpü��*Sseü��À©–²¤������-���vendor/symfony/console/Event/ConsoleEvent.phpÆ��*SseÆ��ÅoÛÙ¤������3���vendor/symfony/console/Event/ConsoleSignalEvent.phpG��*SseG��Žû ¤������6���vendor/symfony/console/Event/ConsoleTerminateEvent.php~��*Sse~��hr½Ö¤������6���vendor/symfony/console/EventListener/ErrorListener.php&��*Sse&��Xö뮤������=���vendor/symfony/console/Exception/CommandNotFoundException.phpÚ��*SseÚ��ˆwêí¤������7���vendor/symfony/console/Exception/ExceptionInterface.phpy���*Ssey���Ù9[&¤������=���vendor/symfony/console/Exception/InvalidArgumentException.php¦���*Sse¦���Ö̽Z¤������;���vendor/symfony/console/Exception/InvalidOptionException.php¦���*Sse¦���Ë×H¤������3���vendor/symfony/console/Exception/LogicException.php’���*Sse’���ÍO\e¤������:���vendor/symfony/console/Exception/MissingInputException.phpœ���*Sseœ���æS
  49. þ¤������?���vendor/symfony/console/Exception/NamespaceNotFoundException.php‹���*Sse‹���‚ón©¤������5���vendor/symfony/console/Exception/RuntimeException.php–���*Sse–���Ùí,6¤������8���vendor/symfony/console/Formatter/NullOutputFormatter.php���*Sse���!& u¤������=���vendor/symfony/console/Formatter/NullOutputFormatterStyle.php
  50. ��*Sse
  51. ��ÔÇ%h¤������4���vendor/symfony/console/Formatter/OutputFormatter.php��*Sse��Üæ¥¤������=���vendor/symfony/console/Formatter/OutputFormatterInterface.php£��*Sse£��Y §ß¤������9���vendor/symfony/console/Formatter/OutputFormatterStyle.phpv��*Ssev�� kÓ�¤������B���vendor/symfony/console/Formatter/OutputFormatterStyleInterface.php���*Sse���ÌZä������>���vendor/symfony/console/Formatter/OutputFormatterStyleStack.phpƒ��*Sseƒ��F—x±¤������F���vendor/symfony/console/Formatter/WrappableOutputFormatterInterface.phpÖ���*SseÖ���¡Z·¤������6���vendor/symfony/console/Helper/DebugFormatterHelper.php¸��*Sse¸��¤ð6 ¤������2���vendor/symfony/console/Helper/DescriptorHelper.phpÀ��*SseÀ��¦gÌ„¤������(���vendor/symfony/console/Helper/Dumper.php��*Sse��þÒܽ¤������1���vendor/symfony/console/Helper/FormatterHelper.phpi��*Ssei��¤¶€w¤������(���vendor/symfony/console/Helper/Helper.php‹ ��*Sse‹ ��4ßáe¤������1���vendor/symfony/console/Helper/HelperInterface.phpå���*Sseå���Š ¤������+���vendor/symfony/console/Helper/HelperSet.phpG��*SseG��›ÝË�¤������2���vendor/symfony/console/Helper/InputAwareHelper.phpc��*Ssec��Ìøƒ¤������/���vendor/symfony/console/Helper/ProcessHelper.phpW ��*SseW ��eÂÑ ¤������-���vendor/symfony/console/Helper/ProgressBar.phpK/��*SseK/��VÒî¤������3���vendor/symfony/console/Helper/ProgressIndicator.phpÀ��*SseÀ��‘=ÞÖ¤������0���vendor/symfony/console/Helper/QuestionHelper.phpÁ.��*SseÁ.��Ú×ó¤������7���vendor/symfony/console/Helper/SymfonyQuestionHelper.php ��*Sse ��à�dÿ¤������'���vendor/symfony/console/Helper/Table.php:J��*Sse:J��–Ðÿ¶¤������+���vendor/symfony/console/Helper/TableCell.phpA��*SseA��èÓ ¤������0���vendor/symfony/console/Helper/TableCellStyle.phpî��*Sseî��Ñ�¹_¤������+���vendor/symfony/console/Helper/TableRows.php)��*Sse)��WŠ3z¤������0���vendor/symfony/console/Helper/TableSeparator.phpÅ���*SseÅ���¼õËü¤������,���vendor/symfony/console/Helper/TableStyle.phpˆ��*Sseˆ��¥Ö¤������*���vendor/symfony/console/Input/ArgvInput.php)��*Sse)��Àd£ï¤������+���vendor/symfony/console/Input/ArrayInput.php ��*Sse �� $©¤������&���vendor/symfony/console/Input/Input.php£ ��*Sse£ ��ë1¤������.���vendor/symfony/console/Input/InputArgument.php��*Sse��„Ý& ¤������4���vendor/symfony/console/Input/InputAwareInterface.php˜���*Sse˜���­O°¤������0���vendor/symfony/console/Input/InputDefinition.php#��*Sse#�� Œ!3¤������/���vendor/symfony/console/Input/InputInterface.phpü��*Sseü��G¶ô¨¤������,���vendor/symfony/console/Input/InputOption.phpç ��*Sseç ��¾ùB@¤������9���vendor/symfony/console/Input/StreamableInputInterface.phpÎ���*SseÎ���ÖÕB›¤������,���vendor/symfony/console/Input/StringInput.php?��*Sse?��±’ˤ���������vendor/symfony/console/LICENSE.��*Sse.��÷ºk¤������/���vendor/symfony/console/Logger/ConsoleLogger.php ��*Sse ��Ç Q¤������0���vendor/symfony/console/Output/BufferedOutput.phpl��*Ssel��y:¸¤������/���vendor/symfony/console/Output/ConsoleOutput.php� ��*Sse� ��Âܤ������8���vendor/symfony/console/Output/ConsoleOutputInterface.php��*Sse��‰ê÷´¤������6���vendor/symfony/console/Output/ConsoleSectionOutput.php“ ��*Sse“ ��OÖ0ɤ������,���vendor/symfony/console/Output/NullOutput.phpB��*SseB��%#RƤ������(���vendor/symfony/console/Output/Output.phpÇ ��*SseÇ �� C,°¤������1���vendor/symfony/console/Output/OutputInterface.phpí��*Sseí��ð޾¤������.���vendor/symfony/console/Output/StreamOutput.php§��*Sse§��1Xòƒ¤������5���vendor/symfony/console/Output/TrimmedBufferOutput.phpÚ��*SseÚ��Å±í ¤������2���vendor/symfony/console/Question/ChoiceQuestion.phpÝ
  52. ��*SseÝ
  53. �� c䦤������8���vendor/symfony/console/Question/ConfirmationQuestion.php��*Sse��îyÅ„¤������,���vendor/symfony/console/Question/Question.php ��*Sse ��µ�µT¤������4���vendor/symfony/console/Resources/bin/hiddeninput.exe�$��*Sse�$��•�¥v¤������0���vendor/symfony/console/Resources/completion.bashÉ
  54. ��*SseÉ
  55. �� z(¤������8���vendor/symfony/console/SignalRegistry/SignalRegistry.php!��*Sse!��~.:¯¤������3���vendor/symfony/console/SingleCommandApplication.php5��*Sse5��Â⢤������,���vendor/symfony/console/Style/OutputStyle.phpt��*Sset��O;Ƥ������/���vendor/symfony/console/Style/StyleInterface.php ��*Sse ��Ý¡ˆ¤������-���vendor/symfony/console/Style/SymfonyStyle.php-'��*Sse-'���½À¿¤������#���vendor/symfony/console/Terminal.php„ ��*Sse„ ��Î9®?¤������3���vendor/symfony/console/Tester/ApplicationTester.phpŒ��*SseŒ��Iû¤������9���vendor/symfony/console/Tester/CommandCompletionTester.phpÚ��*SseÚ��Ê›;°¤������/���vendor/symfony/console/Tester/CommandTester.phpÙ��*SseÙ��D¶¤������@���vendor/symfony/console/Tester/Constraint/CommandIsSuccessful.phpÖ��*SseÖ��ƃ‚¤������-���vendor/symfony/console/Tester/TesterTrait.php¬ ��*Sse¬ ��2'L²¤������,���vendor/symfony/deprecation-contracts/LICENSE+��*Sse+��†vù±¤������1���vendor/symfony/deprecation-contracts/function.php=��*Sse=��žÁ´ ¤������:���vendor/symfony/filesystem/Exception/ExceptionInterface.php|���*Sse|����éD¤������=���vendor/symfony/filesystem/Exception/FileNotFoundException.phpÎ��*SseÎ��&�ò—¤������3���vendor/symfony/filesystem/Exception/IOException.php™��*Sse™��¯à\Τ������<���vendor/symfony/filesystem/Exception/IOExceptionInterface.php¦���*Sse¦���jÙwM¤������@���vendor/symfony/filesystem/Exception/InvalidArgumentException.php©���*Sse©����!Ǥ������8���vendor/symfony/filesystem/Exception/RuntimeException.php™���*Sse™���ÝUUH¤������(���vendor/symfony/filesystem/Filesystem.phpQA��*SseQA��ºÖؤ������!���vendor/symfony/filesystem/LICENSE.��*Sse.��÷ºk¤������"���vendor/symfony/filesystem/Path.php='��*Sse='��õ†4L¤������/���vendor/symfony/finder/Comparator/Comparator.php3��*Sse3��¿Èh¤������3���vendor/symfony/finder/Comparator/DateComparator.php��*Sse��Ï%úe¤������5���vendor/symfony/finder/Comparator/NumberComparator.phpz��*Ssez��+¼�h¤������9���vendor/symfony/finder/Exception/AccessDeniedException.php„���*Sse„���½¾sœ¤������>���vendor/symfony/finder/Exception/DirectoryNotFoundException.php‰���*Sse‰���a)ÿ¤������ ���vendor/symfony/finder/Finder.phpÖ'��*SseÖ'��Ž?ä¤������#���vendor/symfony/finder/Gitignore.php³��*Sse³��s 4¤���������vendor/symfony/finder/Glob.phpÇ��*SseÇ��Db‡³¤������7���vendor/symfony/finder/Iterator/CustomFilterIterator.phpc��*Ssec��7ð™¤������:���vendor/symfony/finder/Iterator/DateRangeFilterIterator.php���*Sse���Pšs¤������;���vendor/symfony/finder/Iterator/DepthRangeFilterIterator.php��*Sse��§Ž¤������A���vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.php0��*Sse0��.wv¤������9���vendor/symfony/finder/Iterator/FileTypeFilterIterator.phpˆ��*Sseˆ��^¶"û¤������<���vendor/symfony/finder/Iterator/FilecontentFilterIterator.phpW��*SseW��ÂÅÙ¤������9���vendor/symfony/finder/Iterator/FilenameFilterIterator.php”��*Sse”��=™Üô¤������/���vendor/symfony/finder/Iterator/LazyIterator.phpQ��*SseQ��n]¿¼¤������=���vendor/symfony/finder/Iterator/MultiplePcreFilterIterator.php���*Sse���¢€×¤������5���vendor/symfony/finder/Iterator/PathFilterIterator.phpò��*Sseò��g"_¤������=���vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.phpæ��*Sseæ��Ú4ùD¤������:���vendor/symfony/finder/Iterator/SizeRangeFilterIterator.php|��*Sse|��3ÙŸ¤������3���vendor/symfony/finder/Iterator/SortableIterator.php(
  56. ��*Sse(
  57. ��Ó⮤������;���vendor/symfony/finder/Iterator/VcsIgnoredFilterIterator.phpw
  58. ��*Ssew
  59. ��ŵ3¤���������vendor/symfony/finder/LICENSE.��*Sse.��÷ºk¤������%���vendor/symfony/finder/SplFileInfo.php½��*Sse½��y¤������'���vendor/symfony/polyfill-ctype/Ctype.php‡
  60. ��*Sse‡
  61. ��~¶d¸¤������%���vendor/symfony/polyfill-ctype/LICENSE.��*Sse.��¦¸©X¤������+���vendor/symfony/polyfill-ctype/bootstrap.php2��*Sse2��Èa­8¤������-���vendor/symfony/polyfill-ctype/bootstrap80.phph��*Sseh��K¿y¸¤������2���vendor/symfony/polyfill-intl-grapheme/Grapheme.phpÚ��*SseÚ��� ›¤������-���vendor/symfony/polyfill-intl-grapheme/LICENSE.��*Sse.��Ëk¤������3���vendor/symfony/polyfill-intl-grapheme/bootstrap.phpÏ��*SseÏ��ý9À|¤������5���vendor/symfony/polyfill-intl-grapheme/bootstrap80.phpY ��*SseY ��¨! ¤������/���vendor/symfony/polyfill-intl-normalizer/LICENSE.��*Sse.��Ëk¤������6���vendor/symfony/polyfill-intl-normalizer/Normalizer.phpö��*Sseö��êiÝe¤������F���vendor/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php.��*Sse.��Qs$—¤������R���vendor/symfony/polyfill-intl-normalizer/Resources/unidata/canonicalComposition.php‰=��*Sse‰=��*ïo?¤������T���vendor/symfony/polyfill-intl-normalizer/Resources/unidata/canonicalDecomposition.phpaˆ��*Sseaˆ��çR½}¤������L���vendor/symfony/polyfill-intl-normalizer/Resources/unidata/combiningClass.phpt.��*Sset.�� q�ܤ������X���vendor/symfony/polyfill-intl-normalizer/Resources/unidata/compatibilityDecomposition.php™è��*Sse™è��o”e)¤������5���vendor/symfony/polyfill-intl-normalizer/bootstrap.phpë��*Sseë��Pú£D¤������7���vendor/symfony/polyfill-intl-normalizer/bootstrap80.phpé��*Sseé��=år´¤������(���vendor/symfony/polyfill-mbstring/LICENSE.��*Sse.��Ëk¤������-���vendor/symfony/polyfill-mbstring/Mbstring.php˜S��*Sse˜S��3ê f¤������B���vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php•��*Sse•��ô¶³ã¤������@���vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.phpùT��*SseùT��•±+¤������F���vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.phpã��*Sseã��öy_•¤������@���vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php8[��*Sse8[��+RØ*¤������.���vendor/symfony/polyfill-mbstring/bootstrap.phpÈ��*SseÈ��'w@0¤������0���vendor/symfony/polyfill-mbstring/bootstrap80.php×!��*Sse×!��ã .Ѥ������%���vendor/symfony/polyfill-php73/LICENSE.��*Sse.��¦¸©X¤������'���vendor/symfony/polyfill-php73/Php73.phpn��*Ssen��Cs¥l¤������?���vendor/symfony/polyfill-php73/Resources/stubs/JsonException.php[���*Sse[���M²Ü¤������+���vendor/symfony/polyfill-php73/bootstrap.phpù��*Sseù��AY8Ƥ������%���vendor/symfony/polyfill-php80/LICENSE.��*Sse.��äôˆ¤������'���vendor/symfony/polyfill-php80/Php80.php¡ ��*Sse¡ ��[Âk ¤������*���vendor/symfony/polyfill-php80/PhpToken.php��*Sse��M£�I¤������;���vendor/symfony/polyfill-php80/Resources/stubs/Attribute.phpÇ��*SseÇ��ÝÞíû¤������:���vendor/symfony/polyfill-php80/Resources/stubs/PhpToken.php����*Sse����Ú”ݤ������<���vendor/symfony/polyfill-php80/Resources/stubs/Stringable.phpk���*Ssek���Ðý+¤������E���vendor/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php]���*Sse]���ºgä������<���vendor/symfony/polyfill-php80/Resources/stubs/ValueError.phpT���*SseT���‘Öw—¤������+���vendor/symfony/polyfill-php80/bootstrap.phpú��*Sseú��×îå¤������%���vendor/symfony/polyfill-php81/LICENSE.��*Sse.��;c©§¤������'���vendor/symfony/polyfill-php81/Php81.php;��*Sse;��ù«d¤������@���vendor/symfony/polyfill-php81/Resources/stubs/CURLStringFile.phpƒ��*Sseƒ��hؤ������F���vendor/symfony/polyfill-php81/Resources/stubs/ReturnTypeWillChange.phpŸ���*SseŸ���ÎÀ¾ü¤������+���vendor/symfony/polyfill-php81/bootstrap.phpô��*Sseô��ˆÓÐ\¤������7���vendor/symfony/process/Exception/ExceptionInterface.phpy���*Ssey���qVXJ¤������=���vendor/symfony/process/Exception/InvalidArgumentException.php¨���*Sse¨���ÐÀ+_¤������3���vendor/symfony/process/Exception/LogicException.php”���*Sse”��� ³ãñ¤������;���vendor/symfony/process/Exception/ProcessFailedException.phpx��*Ssex��¨Ìzy¤������=���vendor/symfony/process/Exception/ProcessSignaledException.php��*Sse��Yשâ¤������=���vendor/symfony/process/Exception/ProcessTimedOutException.php1��*Sse1��‚'Z¤������5���vendor/symfony/process/Exception/RuntimeException.php˜���*Sse˜���¢Ø:¤������+���vendor/symfony/process/ExecutableFinder.php¹��*Sse¹��“„�=¤������&���vendor/symfony/process/InputStream.php/��*Sse/��¦¹e‡¤���������vendor/symfony/process/LICENSE.��*Sse.��÷ºk¤������.���vendor/symfony/process/PhpExecutableFinder.php’��*Sse’��À¸,x¤������%���vendor/symfony/process/PhpProcess.phpò��*Sseò��’sÿ¤������.���vendor/symfony/process/Pipes/AbstractPipes.php ��*Sse ��kSQ¤������/���vendor/symfony/process/Pipes/PipesInterface.php™��*Sse™��fQÚ ¤������*���vendor/symfony/process/Pipes/UnixPipes.php€��*Sse€��¾”Vv¤������-���vendor/symfony/process/Pipes/WindowsPipes.php, ��*Sse, ��xQjä������"���vendor/symfony/process/Process.phpf��*Ssef��2äÃ|¤������'���vendor/symfony/process/ProcessUtils.php��*Sse��ÓXì¤������7���vendor/symfony/service-contracts/Attribute/Required.php¨���*Sse¨���xj네������@���vendor/symfony/service-contracts/Attribute/SubscribedService.php
  62. ��*Sse
  63. ��1I®T¤������(���vendor/symfony/service-contracts/LICENSE+��*Sse+��JˆE ¤������3���vendor/symfony/service-contracts/ResetInterface.phpy���*Ssey���°·jå¤������8���vendor/symfony/service-contracts/ServiceLocatorTrait.phpã ��*Sseã ��"�5é¤������=���vendor/symfony/service-contracts/ServiceProviderInterface.phpÞ���*SseÞ���úRèk¤������?���vendor/symfony/service-contracts/ServiceSubscriberInterface.php³���*Sse³���—öd ¤������;���vendor/symfony/service-contracts/ServiceSubscriberTrait.phpS
  64. ��*SseS
  65. ��ªë4£¤������<���vendor/symfony/service-contracts/Test/ServiceLocatorTest.php˜��*Sse˜��W7|G¤������(���vendor/symfony/string/AbstractString.php¬3��*Sse¬3��˜óŠÖ¤������/���vendor/symfony/string/AbstractUnicodeString.php»R��*Sse»R��! ’Ó¤������$���vendor/symfony/string/ByteString.php÷+��*Sse÷+��@À»’¤������)���vendor/symfony/string/CodePointString.phpñ��*Sseñ��Ÿ;3ˤ������6���vendor/symfony/string/Exception/ExceptionInterface.phps���*Sses���qHV‘¤������<���vendor/symfony/string/Exception/InvalidArgumentException.php¢���*Sse¢���¥A¤������4���vendor/symfony/string/Exception/RuntimeException.php’���*Sse’���u‘g¤������4���vendor/symfony/string/Inflector/EnglishInflector.phpÈ��*SseÈ��WÔzP¤������3���vendor/symfony/string/Inflector/FrenchInflector.phpˆ
  66. ��*Sseˆ
  67. ��·ŠH¤������6���vendor/symfony/string/Inflector/InflectorInterface.php×���*Sse×���hD£¤���������vendor/symfony/string/LICENSE.��*Sse.��š?ôw¤������$���vendor/symfony/string/LazyString.phpH ��*SseH ��ÓOï¤������<���vendor/symfony/string/Resources/data/wcswidth_table_wide.phpÅ��*SseÅ��ð:†Ì¤������<���vendor/symfony/string/Resources/data/wcswidth_table_zero.php��*Sse�� k¤������-���vendor/symfony/string/Resources/functions.php��*Sse��cÚª"¤������.���vendor/symfony/string/Slugger/AsciiSlugger.phpê��*Sseê��×Ú3¤������2���vendor/symfony/string/Slugger/SluggerInterface.php��*Sse��÷¯Q¤������'���vendor/symfony/string/UnicodeString.phpè%��*Sseè%��Ùó פ������ ���bin/composer5 ��*Sse5 ��á?â¤���������LICENSE.��*Sse.�� Õ¤������<?php declare(strict_types=1);
  68. namespace Composer\Advisory;
  69. use Composer\IO\ConsoleIO;
  70. use Composer\IO\IOInterface;
  71. use Composer\Json\JsonFile;
  72. use Composer\Package\CompletePackageInterface;
  73. use Composer\Package\PackageInterface;
  74. use Composer\Repository\RepositorySet;
  75. use Composer\Util\PackageInfo;
  76. use InvalidArgumentException;
  77. use Symfony\Component\Console\Formatter\OutputFormatter;
  78. class Auditor
  79. {
  80. public const FORMAT_TABLE = 'table';
  81. public const FORMAT_PLAIN = 'plain';
  82. public const FORMAT_JSON = 'json';
  83. public const FORMAT_SUMMARY = 'summary';
  84. public const FORMATS = [
  85. self::FORMAT_TABLE,
  86. self::FORMAT_PLAIN,
  87. self::FORMAT_JSON,
  88. self::FORMAT_SUMMARY,
  89. ];
  90. public const ABANDONED_IGNORE = 'ignore';
  91. public const ABANDONED_REPORT = 'report';
  92. public const ABANDONED_FAIL = 'fail';
  93. public function audit(IOInterface $io, RepositorySet $repoSet, array $packages, string $format, bool $warningOnly = true, array $ignoreList = [], string $abandoned = self::ABANDONED_REPORT): int
  94. {
  95. if ($abandoned === 'default' && $format !== self::FORMAT_SUMMARY) {
  96. $io->writeError('<warning>The new audit.abandoned setting (currently defaulting to "report" will default to "fail" in Composer 2.7, make sure to set it to "report" or "ignore" explicitly by then if you do not want this.</warning>');
  97. }
  98. $allAdvisories = $repoSet->getMatchingSecurityAdvisories($packages, $format === self::FORMAT_SUMMARY);
  99. if (count($allAdvisories) > 0 && $ignoreList !== [] && $format === self::FORMAT_SUMMARY) {
  100. $allAdvisories = $repoSet->getMatchingSecurityAdvisories($packages, false);
  101. }
  102. ['advisories' => $advisories, 'ignoredAdvisories' => $ignoredAdvisories] = $this->processAdvisories($allAdvisories, $ignoreList);
  103. $abandonedCount = 0;
  104. $affectedPackagesCount = 0;
  105. if ($abandoned === self::ABANDONED_IGNORE) {
  106. $abandonedPackages = [];
  107. } else {
  108. $abandonedPackages = $this->filterAbandonedPackages($packages);
  109. if ($abandoned === self::ABANDONED_FAIL) {
  110. $abandonedCount = count($abandonedPackages);
  111. }
  112. }
  113. if (self::FORMAT_JSON === $format) {
  114. $json = ['advisories' => $advisories];
  115. if ($ignoredAdvisories !== []) {
  116. $json['ignored-advisories'] = $ignoredAdvisories;
  117. }
  118. $json['abandoned'] = array_reduce($abandonedPackages, static function(array $carry, CompletePackageInterface $package): array {
  119. $carry[$package->getPrettyName()] = $package->getReplacementPackage();
  120. return $carry;
  121. }, []);
  122. $io->write(JsonFile::encode($json));
  123. return count($advisories) + $abandonedCount;
  124. }
  125. $errorOrWarn = $warningOnly ? 'warning' : 'error';
  126. if (count($advisories) > 0 || count($ignoredAdvisories) > 0) {
  127. $passes = [
  128. [$ignoredAdvisories, "<info>Found %d ignored security vulnerability advisor%s affecting %d package%s%s</info>"],
  129. [$advisories, "<$errorOrWarn>Found %d security vulnerability advisor%s affecting %d package%s%s</$errorOrWarn>"],
  130. ];
  131. foreach ($passes as [$advisoriesToOutput, $message]) {
  132. [$affectedPackagesCount, $totalAdvisoryCount] = $this->countAdvisories($advisoriesToOutput);
  133. if ($affectedPackagesCount > 0) {
  134. $plurality = $totalAdvisoryCount === 1 ? 'y' : 'ies';
  135. $pkgPlurality = $affectedPackagesCount === 1 ? '' : 's';
  136. $punctuation = $format === 'summary' ? '.' : ':';
  137. $io->writeError(sprintf($message, $totalAdvisoryCount, $plurality, $affectedPackagesCount, $pkgPlurality, $punctuation));
  138. $this->outputAdvisories($io, $advisoriesToOutput, $format);
  139. }
  140. }
  141. if ($format === self::FORMAT_SUMMARY) {
  142. $io->writeError('Run "composer audit" for a full list of advisories.');
  143. }
  144. } else {
  145. $io->writeError('<info>No security vulnerability advisories found.</info>');
  146. }
  147. if (count($abandonedPackages) > 0 && $format !== self::FORMAT_SUMMARY) {
  148. $this->outputAbandonedPackages($io, $abandonedPackages, $format);
  149. }
  150. return $affectedPackagesCount + $abandonedCount;
  151. }
  152. private function filterAbandonedPackages(array $packages): array
  153. {
  154. return array_filter($packages, static function (PackageInterface $pkg) {
  155. return $pkg instanceof CompletePackageInterface && $pkg->isAbandoned();
  156. });
  157. }
  158. private function processAdvisories(array $allAdvisories, array $ignoreList): array
  159. {
  160. if ($ignoreList === []) {
  161. return ['advisories' => $allAdvisories, 'ignoredAdvisories' => []];
  162. }
  163. if (\count($ignoreList) > 0 && !\array_is_list($ignoreList)) {
  164. $ignoredIds = array_keys($ignoreList);
  165. } else {
  166. $ignoredIds = $ignoreList;
  167. }
  168. $advisories = [];
  169. $ignored = [];
  170. $ignoreReason = null;
  171. foreach ($allAdvisories as $package => $pkgAdvisories) {
  172. foreach ($pkgAdvisories as $advisory) {
  173. $isActive = true;
  174. if (in_array($advisory->advisoryId, $ignoredIds, true)) {
  175. $isActive = false;
  176. $ignoreReason = $ignoreList[$advisory->advisoryId] ?? null;
  177. }
  178. if ($advisory instanceof SecurityAdvisory) {
  179. if (in_array($advisory->cve, $ignoredIds, true)) {
  180. $isActive = false;
  181. $ignoreReason = $ignoreList[$advisory->cve] ?? null;
  182. }
  183. foreach ($advisory->sources as $source) {
  184. if (in_array($source['remoteId'], $ignoredIds, true)) {
  185. $isActive = false;
  186. $ignoreReason = $ignoreList[$source['remoteId']] ?? null;
  187. break;
  188. }
  189. }
  190. }
  191. if ($isActive) {
  192. $advisories[$package][] = $advisory;
  193. continue;
  194. }
  195. if ($advisory instanceof SecurityAdvisory) {
  196. $advisory = $advisory->toIgnoredAdvisory($ignoreReason);
  197. }
  198. $ignored[$package][] = $advisory;
  199. }
  200. }
  201. return ['advisories' => $advisories, 'ignoredAdvisories' => $ignored];
  202. }
  203. private function countAdvisories(array $advisories): array
  204. {
  205. $count = 0;
  206. foreach ($advisories as $packageAdvisories) {
  207. $count += count($packageAdvisories);
  208. }
  209. return [count($advisories), $count];
  210. }
  211. private function outputAdvisories(IOInterface $io, array $advisories, string $format): void
  212. {
  213. switch ($format) {
  214. case self::FORMAT_TABLE:
  215. if (!($io instanceof ConsoleIO)) {
  216. throw new InvalidArgumentException('Cannot use table format with ' . get_class($io));
  217. }
  218. $this->outputAdvisoriesTable($io, $advisories);
  219. return;
  220. case self::FORMAT_PLAIN:
  221. $this->outputAdvisoriesPlain($io, $advisories);
  222. return;
  223. case self::FORMAT_SUMMARY:
  224. return;
  225. default:
  226. throw new InvalidArgumentException('Invalid format "'.$format.'".');
  227. }
  228. }
  229. private function outputAdvisoriesTable(ConsoleIO $io, array $advisories): void
  230. {
  231. foreach ($advisories as $packageAdvisories) {
  232. foreach ($packageAdvisories as $advisory) {
  233. $headers = [
  234. 'Package',
  235. 'CVE',
  236. 'Title',
  237. 'URL',
  238. 'Affected versions',
  239. 'Reported at',
  240. ];
  241. $row = [
  242. $advisory->packageName,
  243. $this->getCVE($advisory),
  244. $advisory->title,
  245. $this->getURL($advisory),
  246. $advisory->affectedVersions->getPrettyString(),
  247. $advisory->reportedAt->format(DATE_ATOM),
  248. ];
  249. if ($advisory instanceof IgnoredSecurityAdvisory) {
  250. $headers[] = 'Ignore reason';
  251. $row[] = $advisory->ignoreReason ?? 'None specified';
  252. }
  253. $io->getTable()
  254. ->setHorizontal()
  255. ->setHeaders($headers)
  256. ->addRow($row)
  257. ->setColumnWidth(1, 80)
  258. ->setColumnMaxWidth(1, 80)
  259. ->render();
  260. }
  261. }
  262. }
  263. private function outputAdvisoriesPlain(IOInterface $io, array $advisories): void
  264. {
  265. $error = [];
  266. $firstAdvisory = true;
  267. foreach ($advisories as $packageAdvisories) {
  268. foreach ($packageAdvisories as $advisory) {
  269. if (!$firstAdvisory) {
  270. $error[] = '--------';
  271. }
  272. $error[] = "Package: ".$advisory->packageName;
  273. $error[] = "CVE: ".$this->getCVE($advisory);
  274. $error[] = "Title: ".OutputFormatter::escape($advisory->title);
  275. $error[] = "URL: ".$this->getURL($advisory);
  276. $error[] = "Affected versions: ".OutputFormatter::escape($advisory->affectedVersions->getPrettyString());
  277. $error[] = "Reported at: ".$advisory->reportedAt->format(DATE_ATOM);
  278. if ($advisory instanceof IgnoredSecurityAdvisory) {
  279. $error[] = "Ignore reason: ".($advisory->ignoreReason ?? 'None specified');
  280. }
  281. $firstAdvisory = false;
  282. }
  283. }
  284. $io->writeError($error);
  285. }
  286. private function outputAbandonedPackages(IOInterface $io, array $packages, string $format): void
  287. {
  288. $io->writeError(sprintf('<error>Found %d abandoned package%s:</error>', count($packages), count($packages) > 1 ? 's' : ''));
  289. if ($format === self::FORMAT_PLAIN) {
  290. foreach ($packages as $pkg) {
  291. $replacement = $pkg->getReplacementPackage() !== null
  292. ? 'Use '.$pkg->getReplacementPackage().' instead'
  293. : 'No replacement was suggested';
  294. $io->writeError(sprintf(
  295. '%s is abandoned. %s.',
  296. $this->getPackageNameWithLink($pkg),
  297. $replacement
  298. ));
  299. }
  300. return;
  301. }
  302. if (!($io instanceof ConsoleIO)) {
  303. throw new InvalidArgumentException('Cannot use table format with ' . get_class($io));
  304. }
  305. $table = $io->getTable()
  306. ->setHeaders(['Abandoned Package', 'Suggested Replacement'])
  307. ->setColumnWidth(1, 80)
  308. ->setColumnMaxWidth(1, 80);
  309. foreach ($packages as $pkg) {
  310. $replacement = $pkg->getReplacementPackage() !== null ? $pkg->getReplacementPackage() : 'none';
  311. $table->addRow([$this->getPackageNameWithLink($pkg), $replacement]);
  312. }
  313. $table->render();
  314. }
  315. private function getPackageNameWithLink(PackageInterface $package): string
  316. {
  317. $packageUrl = PackageInfo::getViewSourceOrHomepageUrl($package);
  318. return $packageUrl !== null ? '<href=' . OutputFormatter::escape($packageUrl) . '>' . $package->getPrettyName() . '</>' : $package->getPrettyName();
  319. }
  320. private function getCVE(SecurityAdvisory $advisory): string
  321. {
  322. if ($advisory->cve === null) {
  323. return 'NO CVE';
  324. }
  325. return '<href=https://cve.mitre.org/cgi-bin/cvename.cgi?name='.$advisory->cve.'>'.$advisory->cve.'</>';
  326. }
  327. private function getURL(SecurityAdvisory $advisory): string
  328. {
  329. if ($advisory->link === null) {
  330. return '';
  331. }
  332. return '<href='.OutputFormatter::escape($advisory->link).'>'.OutputFormatter::escape($advisory->link).'</>';
  333. }
  334. }
  335. <?php declare(strict_types=1);
  336. namespace Composer\Advisory;
  337. use Composer\Semver\Constraint\ConstraintInterface;
  338. use DateTimeImmutable;
  339. class IgnoredSecurityAdvisory extends SecurityAdvisory
  340. {
  341. public $ignoreReason;
  342. public function __construct(string $packageName, string $advisoryId, ConstraintInterface $affectedVersions, string $title, array $sources, DateTimeImmutable $reportedAt, ?string $cve = null, ?string $link = null, ?string $ignoreReason = null)
  343. {
  344. parent::__construct($packageName, $advisoryId, $affectedVersions, $title, $sources, $reportedAt, $cve, $link);
  345. $this->ignoreReason = $ignoreReason;
  346. }
  347. #[\ReturnTypeWillChange]
  348. public function jsonSerialize()
  349. {
  350. $data = parent::jsonSerialize();
  351. if ($this->ignoreReason === NULL) {
  352. unset($data['ignoreReason']);
  353. }
  354. return $data;
  355. }
  356. }
  357. <?php declare(strict_types=1);
  358. namespace Composer\Advisory;
  359. use Composer\Semver\Constraint\ConstraintInterface;
  360. use Composer\Semver\VersionParser;
  361. use JsonSerializable;
  362. class PartialSecurityAdvisory implements JsonSerializable
  363. {
  364. public $advisoryId;
  365. public $packageName;
  366. public $affectedVersions;
  367. public static function create(string $packageName, array $data, VersionParser $parser): self
  368. {
  369. $constraint = $parser->parseConstraints($data['affectedVersions']);
  370. if (isset($data['title'], $data['sources'], $data['reportedAt'])) {
  371. return new SecurityAdvisory($packageName, $data['advisoryId'], $constraint, $data['title'], $data['sources'], new \DateTimeImmutable($data['reportedAt'], new \DateTimeZone('UTC')), $data['cve'] ?? null, $data['link'] ?? null);
  372. }
  373. return new self($packageName, $data['advisoryId'], $constraint);
  374. }
  375. public function __construct(string $packageName, string $advisoryId, ConstraintInterface $affectedVersions)
  376. {
  377. $this->advisoryId = $advisoryId;
  378. $this->packageName = $packageName;
  379. $this->affectedVersions = $affectedVersions;
  380. }
  381. #[\ReturnTypeWillChange]
  382. public function jsonSerialize()
  383. {
  384. $data = (array) $this;
  385. $data['affectedVersions'] = $data['affectedVersions']->getPrettyString();
  386. return $data;
  387. }
  388. }
  389. <?php declare(strict_types=1);
  390. namespace Composer\Advisory;
  391. use Composer\Semver\Constraint\ConstraintInterface;
  392. use DateTimeImmutable;
  393. class SecurityAdvisory extends PartialSecurityAdvisory
  394. {
  395. public $title;
  396. public $cve;
  397. public $link;
  398. public $reportedAt;
  399. public $sources;
  400. public function __construct(string $packageName, string $advisoryId, ConstraintInterface $affectedVersions, string $title, array $sources, DateTimeImmutable $reportedAt, ?string $cve = null, ?string $link = null)
  401. {
  402. parent::__construct($packageName, $advisoryId, $affectedVersions);
  403. $this->title = $title;
  404. $this->sources = $sources;
  405. $this->reportedAt = $reportedAt;
  406. $this->cve = $cve;
  407. $this->link = $link;
  408. }
  409. public function toIgnoredAdvisory(?string $ignoreReason): IgnoredSecurityAdvisory
  410. {
  411. return new IgnoredSecurityAdvisory(
  412. $this->packageName,
  413. $this->advisoryId,
  414. $this->affectedVersions,
  415. $this->title,
  416. $this->sources,
  417. $this->reportedAt,
  418. $this->cve,
  419. $this->link,
  420. $ignoreReason
  421. );
  422. }
  423. #[\ReturnTypeWillChange]
  424. public function jsonSerialize()
  425. {
  426. $data = parent::jsonSerialize();
  427. $data['reportedAt'] = $data['reportedAt']->format(DATE_RFC3339);
  428. return $data;
  429. }
  430. }
  431. <?php declare(strict_types=1);
  432. namespace Composer\Autoload;
  433. use Composer\ClassMapGenerator\ClassMap;
  434. use Composer\ClassMapGenerator\ClassMapGenerator;
  435. use Composer\Config;
  436. use Composer\EventDispatcher\EventDispatcher;
  437. use Composer\Filter\PlatformRequirementFilter\IgnoreAllPlatformRequirementFilter;
  438. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  439. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  440. use Composer\Installer\InstallationManager;
  441. use Composer\IO\IOInterface;
  442. use Composer\IO\NullIO;
  443. use Composer\Package\AliasPackage;
  444. use Composer\Package\PackageInterface;
  445. use Composer\Package\RootPackageInterface;
  446. use Composer\Pcre\Preg;
  447. use Composer\Repository\InstalledRepositoryInterface;
  448. use Composer\Semver\Constraint\Bound;
  449. use Composer\Util\Filesystem;
  450. use Composer\Util\Platform;
  451. use Composer\Script\ScriptEvents;
  452. use Composer\Util\PackageSorter;
  453. use Composer\Json\JsonFile;
  454. use Composer\Package\Locker;
  455. class AutoloadGenerator
  456. {
  457. private $eventDispatcher;
  458. private $io;
  459. private $devMode = null;
  460. private $classMapAuthoritative = false;
  461. private $apcu = false;
  462. private $apcuPrefix;
  463. private $dryRun = false;
  464. private $runScripts = false;
  465. private $platformRequirementFilter;
  466. public function __construct(EventDispatcher $eventDispatcher, ?IOInterface $io = null)
  467. {
  468. $this->eventDispatcher = $eventDispatcher;
  469. $this->io = $io ?? new NullIO();
  470. $this->platformRequirementFilter = PlatformRequirementFilterFactory::ignoreNothing();
  471. }
  472. public function setDevMode(bool $devMode = true)
  473. {
  474. $this->devMode = $devMode;
  475. }
  476. public function setClassMapAuthoritative(bool $classMapAuthoritative)
  477. {
  478. $this->classMapAuthoritative = $classMapAuthoritative;
  479. }
  480. public function setApcu(bool $apcu, ?string $apcuPrefix = null)
  481. {
  482. $this->apcu = $apcu;
  483. $this->apcuPrefix = $apcuPrefix;
  484. }
  485. public function setRunScripts(bool $runScripts = true)
  486. {
  487. $this->runScripts = $runScripts;
  488. }
  489. public function setDryRun(bool $dryRun = true): void
  490. {
  491. $this->dryRun = $dryRun;
  492. }
  493. public function setIgnorePlatformRequirements($ignorePlatformReqs)
  494. {
  495. trigger_error('AutoloadGenerator::setIgnorePlatformRequirements is deprecated since Composer 2.2, use setPlatformRequirementFilter instead.', E_USER_DEPRECATED);
  496. $this->setPlatformRequirementFilter(PlatformRequirementFilterFactory::fromBoolOrList($ignorePlatformReqs));
  497. }
  498. public function setPlatformRequirementFilter(PlatformRequirementFilterInterface $platformRequirementFilter)
  499. {
  500. $this->platformRequirementFilter = $platformRequirementFilter;
  501. }
  502. public function dump(Config $config, InstalledRepositoryInterface $localRepo, RootPackageInterface $rootPackage, InstallationManager $installationManager, string $targetDir, bool $scanPsrPackages = false, ?string $suffix = null, ?Locker $locker = null)
  503. {
  504. if ($this->classMapAuthoritative) {
  505. $scanPsrPackages = true;
  506. }
  507. if (null === $this->devMode) {
  508. $this->devMode = false;
  509. $installedJson = new JsonFile($config->get('vendor-dir').'/composer/installed.json');
  510. if ($installedJson->exists()) {
  511. $installedJson = $installedJson->read();
  512. if (isset($installedJson['dev'])) {
  513. $this->devMode = $installedJson['dev'];
  514. }
  515. }
  516. }
  517. if ($this->runScripts) {
  518. if (!isset($_SERVER['COMPOSER_DEV_MODE'])) {
  519. Platform::putEnv('COMPOSER_DEV_MODE', $this->devMode ? '1' : '0');
  520. }
  521. $this->eventDispatcher->dispatchScript(ScriptEvents::PRE_AUTOLOAD_DUMP, $this->devMode, [], [
  522. 'optimize' => $scanPsrPackages,
  523. ]);
  524. }
  525. $classMapGenerator = new ClassMapGenerator(['php', 'inc', 'hh']);
  526. $classMapGenerator->avoidDuplicateScans();
  527. $filesystem = new Filesystem();
  528. $filesystem->ensureDirectoryExists($config->get('vendor-dir'));
  529. $basePath = $filesystem->normalizePath(realpath(realpath(Platform::getCwd())));
  530. $vendorPath = $filesystem->normalizePath(realpath(realpath($config->get('vendor-dir'))));
  531. $useGlobalIncludePath = $config->get('use-include-path');
  532. $prependAutoloader = $config->get('prepend-autoloader') === false ? 'false' : 'true';
  533. $targetDir = $vendorPath.'/'.$targetDir;
  534. $filesystem->ensureDirectoryExists($targetDir);
  535. $vendorPathCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true);
  536. $vendorPathToTargetDirCode = $filesystem->findShortestPathCode($vendorPath, realpath($targetDir), true);
  537. $appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, $basePath, true);
  538. $appBaseDirCode = str_replace('__DIR__', '$vendorDir', $appBaseDirCode);
  539. $namespacesFile = <<<EOF
  540. <?php
  541. // autoload_namespaces.php @generated by Composer
  542. \$vendorDir = $vendorPathCode;
  543. \$baseDir = $appBaseDirCode;
  544. return array(
  545. EOF;
  546. $psr4File = <<<EOF
  547. <?php
  548. // autoload_psr4.php @generated by Composer
  549. \$vendorDir = $vendorPathCode;
  550. \$baseDir = $appBaseDirCode;
  551. return array(
  552. EOF;
  553. $devPackageNames = $localRepo->getDevPackageNames();
  554. $packageMap = $this->buildPackageMap($installationManager, $rootPackage, $localRepo->getCanonicalPackages());
  555. if ($this->devMode) {
  556. $filteredDevPackages = false;
  557. } else {
  558. $filteredDevPackages = $devPackageNames ?: true;
  559. }
  560. $autoloads = $this->parseAutoloads($packageMap, $rootPackage, $filteredDevPackages);
  561. foreach ($autoloads['psr-0'] as $namespace => $paths) {
  562. $exportedPaths = [];
  563. foreach ($paths as $path) {
  564. $exportedPaths[] = $this->getPathCode($filesystem, $basePath, $vendorPath, $path);
  565. }
  566. $exportedPrefix = var_export($namespace, true);
  567. $namespacesFile .= " $exportedPrefix => ";
  568. $namespacesFile .= "array(".implode(', ', $exportedPaths)."),\n";
  569. }
  570. $namespacesFile .= ");\n";
  571. foreach ($autoloads['psr-4'] as $namespace => $paths) {
  572. $exportedPaths = [];
  573. foreach ($paths as $path) {
  574. $exportedPaths[] = $this->getPathCode($filesystem, $basePath, $vendorPath, $path);
  575. }
  576. $exportedPrefix = var_export($namespace, true);
  577. $psr4File .= " $exportedPrefix => ";
  578. $psr4File .= "array(".implode(', ', $exportedPaths)."),\n";
  579. }
  580. $psr4File .= ");\n";
  581. $targetDirLoader = null;
  582. $mainAutoload = $rootPackage->getAutoload();
  583. if ($rootPackage->getTargetDir() && !empty($mainAutoload['psr-0'])) {
  584. $levels = substr_count($filesystem->normalizePath($rootPackage->getTargetDir()), '/') + 1;
  585. $prefixes = implode(', ', array_map(static function ($prefix): string {
  586. return var_export($prefix, true);
  587. }, array_keys($mainAutoload['psr-0'])));
  588. $baseDirFromTargetDirCode = $filesystem->findShortestPathCode($targetDir, $basePath, true);
  589. $targetDirLoader = <<<EOF
  590. public static function autoload(\$class)
  591. {
  592. \$dir = $baseDirFromTargetDirCode . '/';
  593. \$prefixes = array($prefixes);
  594. foreach (\$prefixes as \$prefix) {
  595. if (0 !== strpos(\$class, \$prefix)) {
  596. continue;
  597. }
  598. \$path = \$dir . implode('/', array_slice(explode('\\\\', \$class), $levels)).'.php';
  599. if (!\$path = stream_resolve_include_path(\$path)) {
  600. return false;
  601. }
  602. require \$path;
  603. return true;
  604. }
  605. }
  606. EOF;
  607. }
  608. $excluded = null;
  609. if (!empty($autoloads['exclude-from-classmap'])) {
  610. $excluded = $autoloads['exclude-from-classmap'];
  611. }
  612. foreach ($autoloads['classmap'] as $dir) {
  613. $classMapGenerator->scanPaths($dir, $this->buildExclusionRegex($dir, $excluded));
  614. }
  615. if ($scanPsrPackages) {
  616. $namespacesToScan = [];
  617. foreach (['psr-4', 'psr-0'] as $psrType) {
  618. foreach ($autoloads[$psrType] as $namespace => $paths) {
  619. $namespacesToScan[$namespace][] = ['paths' => $paths, 'type' => $psrType];
  620. }
  621. }
  622. krsort($namespacesToScan);
  623. foreach ($namespacesToScan as $namespace => $groups) {
  624. foreach ($groups as $group) {
  625. foreach ($group['paths'] as $dir) {
  626. $dir = $filesystem->normalizePath($filesystem->isAbsolutePath($dir) ? $dir : $basePath.'/'.$dir);
  627. if (!is_dir($dir)) {
  628. continue;
  629. }
  630. $classMapGenerator->scanPaths($dir, $this->buildExclusionRegex($dir, $excluded), $group['type'], $namespace);
  631. }
  632. }
  633. }
  634. }
  635. $classMap = $classMapGenerator->getClassMap();
  636. foreach ($classMap->getAmbiguousClasses() as $className => $ambiguousPaths) {
  637. if (count($ambiguousPaths) > 1) {
  638. $this->io->writeError(
  639. '<warning>Warning: Ambiguous class resolution, "'.$className.'"'.
  640. ' was found '. (count($ambiguousPaths) + 1) .'x: in "'.$classMap->getClassPath($className).'" and "'. implode('", "', $ambiguousPaths) .'", the first will be used.</warning>'
  641. );
  642. } else {
  643. $this->io->writeError(
  644. '<warning>Warning: Ambiguous class resolution, "'.$className.'"'.
  645. ' was found in both "'.$classMap->getClassPath($className).'" and "'. implode('", "', $ambiguousPaths) .'", the first will be used.</warning>'
  646. );
  647. }
  648. }
  649. foreach ($classMap->getPsrViolations() as $msg) {
  650. $this->io->writeError("<warning>$msg</warning>");
  651. }
  652. $classMap->addClass('Composer\InstalledVersions', $vendorPath . '/composer/InstalledVersions.php');
  653. $classMap->sort();
  654. $classmapFile = <<<EOF
  655. <?php
  656. // autoload_classmap.php @generated by Composer
  657. \$vendorDir = $vendorPathCode;
  658. \$baseDir = $appBaseDirCode;
  659. return array(
  660. EOF;
  661. foreach ($classMap->getMap() as $className => $path) {
  662. $pathCode = $this->getPathCode($filesystem, $basePath, $vendorPath, $path).",\n";
  663. $classmapFile .= ' '.var_export($className, true).' => '.$pathCode;
  664. }
  665. $classmapFile .= ");\n";
  666. if ('' === $suffix) {
  667. $suffix = null;
  668. }
  669. if (null === $suffix) {
  670. $suffix = $config->get('autoloader-suffix');
  671. if (null === $suffix && Filesystem::isReadable($vendorPath.'/autoload.php')) {
  672. $content = file_get_contents($vendorPath.'/autoload.php');
  673. if (Preg::isMatch('{ComposerAutoloaderInit([^:\s]+)::}', $content, $match)) {
  674. $suffix = $match[1];
  675. }
  676. }
  677. if (null === $suffix) {
  678. $suffix = $locker !== null && $locker->isLocked() ? $locker->getLockData()['content-hash'] : md5(uniqid('', true));
  679. }
  680. }
  681. if ($this->dryRun) {
  682. return $classMap;
  683. }
  684. $filesystem->filePutContentsIfModified($targetDir.'/autoload_namespaces.php', $namespacesFile);
  685. $filesystem->filePutContentsIfModified($targetDir.'/autoload_psr4.php', $psr4File);
  686. $filesystem->filePutContentsIfModified($targetDir.'/autoload_classmap.php', $classmapFile);
  687. $includePathFilePath = $targetDir.'/include_paths.php';
  688. if ($includePathFileContents = $this->getIncludePathsFile($packageMap, $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)) {
  689. $filesystem->filePutContentsIfModified($includePathFilePath, $includePathFileContents);
  690. } elseif (file_exists($includePathFilePath)) {
  691. unlink($includePathFilePath);
  692. }
  693. $includeFilesFilePath = $targetDir.'/autoload_files.php';
  694. if ($includeFilesFileContents = $this->getIncludeFilesFile($autoloads['files'], $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)) {
  695. $filesystem->filePutContentsIfModified($includeFilesFilePath, $includeFilesFileContents);
  696. } elseif (file_exists($includeFilesFilePath)) {
  697. unlink($includeFilesFilePath);
  698. }
  699. $filesystem->filePutContentsIfModified($targetDir.'/autoload_static.php', $this->getStaticFile($suffix, $targetDir, $vendorPath, $basePath));
  700. $checkPlatform = $config->get('platform-check') !== false && !($this->platformRequirementFilter instanceof IgnoreAllPlatformRequirementFilter);
  701. $platformCheckContent = null;
  702. if ($checkPlatform) {
  703. $platformCheckContent = $this->getPlatformCheck($packageMap, $config->get('platform-check'), $devPackageNames);
  704. if (null === $platformCheckContent) {
  705. $checkPlatform = false;
  706. }
  707. }
  708. if ($checkPlatform) {
  709. $filesystem->filePutContentsIfModified($targetDir.'/platform_check.php', $platformCheckContent);
  710. } elseif (file_exists($targetDir.'/platform_check.php')) {
  711. unlink($targetDir.'/platform_check.php');
  712. }
  713. $filesystem->filePutContentsIfModified($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix));
  714. $filesystem->filePutContentsIfModified($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFileContents, $targetDirLoader, (bool) $includeFilesFileContents, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $checkPlatform));
  715. $filesystem->safeCopy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');
  716. $filesystem->safeCopy(__DIR__.'/../../../LICENSE', $targetDir.'/LICENSE');
  717. if ($this->runScripts) {
  718. $this->eventDispatcher->dispatchScript(ScriptEvents::POST_AUTOLOAD_DUMP, $this->devMode, [], [
  719. 'optimize' => $scanPsrPackages,
  720. ]);
  721. }
  722. return $classMap;
  723. }
  724. private function buildExclusionRegex(string $dir, ?array $excluded): ?string
  725. {
  726. if (null === $excluded) {
  727. return null;
  728. }
  729. if (file_exists($dir)) {
  730. $dirMatch = preg_quote(strtr(realpath($dir), '\\', '/'));
  731. foreach ($excluded as $index => $pattern) {
  732. $pattern = Preg::replace('{^(([^.+*?\[^\]$(){}=!<>|:\\\\#-]+|\\\\[.+*?\[^\]$(){}=!<>|:#-])*).*}', '$1', $pattern);
  733. if (0 !== strpos($pattern, $dirMatch) && 0 !== strpos($dirMatch, $pattern)) {
  734. unset($excluded[$index]);
  735. }
  736. }
  737. }
  738. return \count($excluded) > 0 ? '{(' . implode('|', $excluded) . ')}' : null;
  739. }
  740. public function buildPackageMap(InstallationManager $installationManager, PackageInterface $rootPackage, array $packages)
  741. {
  742. $packageMap = [[$rootPackage, '']];
  743. foreach ($packages as $package) {
  744. if ($package instanceof AliasPackage) {
  745. continue;
  746. }
  747. $this->validatePackage($package);
  748. $packageMap[] = [
  749. $package,
  750. $installationManager->getInstallPath($package),
  751. ];
  752. }
  753. return $packageMap;
  754. }
  755. protected function validatePackage(PackageInterface $package)
  756. {
  757. $autoload = $package->getAutoload();
  758. if (!empty($autoload['psr-4']) && null !== $package->getTargetDir()) {
  759. $name = $package->getName();
  760. $package->getTargetDir();
  761. throw new \InvalidArgumentException("PSR-4 autoloading is incompatible with the target-dir property, remove the target-dir in package '$name'.");
  762. }
  763. if (!empty($autoload['psr-4'])) {
  764. foreach ($autoload['psr-4'] as $namespace => $dirs) {
  765. if ($namespace !== '' && '\\' !== substr($namespace, -1)) {
  766. throw new \InvalidArgumentException("psr-4 namespaces must end with a namespace separator, '$namespace' does not, use '$namespace\\'.");
  767. }
  768. }
  769. }
  770. }
  771. public function parseAutoloads(array $packageMap, PackageInterface $rootPackage, $filteredDevPackages = false)
  772. {
  773. $rootPackageMap = array_shift($packageMap);
  774. if (is_array($filteredDevPackages)) {
  775. $packageMap = array_filter($packageMap, static function ($item) use ($filteredDevPackages): bool {
  776. return !in_array($item[0]->getName(), $filteredDevPackages, true);
  777. });
  778. } elseif ($filteredDevPackages) {
  779. $packageMap = $this->filterPackageMap($packageMap, $rootPackage);
  780. }
  781. $sortedPackageMap = $this->sortPackageMap($packageMap);
  782. $sortedPackageMap[] = $rootPackageMap;
  783. array_unshift($packageMap, $rootPackageMap);
  784. $psr0 = $this->parseAutoloadsType($packageMap, 'psr-0', $rootPackage);
  785. $psr4 = $this->parseAutoloadsType($packageMap, 'psr-4', $rootPackage);
  786. $classmap = $this->parseAutoloadsType(array_reverse($sortedPackageMap), 'classmap', $rootPackage);
  787. $files = $this->parseAutoloadsType($sortedPackageMap, 'files', $rootPackage);
  788. $exclude = $this->parseAutoloadsType($sortedPackageMap, 'exclude-from-classmap', $rootPackage);
  789. krsort($psr0);
  790. krsort($psr4);
  791. return [
  792. 'psr-0' => $psr0,
  793. 'psr-4' => $psr4,
  794. 'classmap' => $classmap,
  795. 'files' => $files,
  796. 'exclude-from-classmap' => $exclude,
  797. ];
  798. }
  799. public function createLoader(array $autoloads, ?string $vendorDir = null)
  800. {
  801. $loader = new ClassLoader($vendorDir);
  802. if (isset($autoloads['psr-0'])) {
  803. foreach ($autoloads['psr-0'] as $namespace => $path) {
  804. $loader->add($namespace, $path);
  805. }
  806. }
  807. if (isset($autoloads['psr-4'])) {
  808. foreach ($autoloads['psr-4'] as $namespace => $path) {
  809. $loader->addPsr4($namespace, $path);
  810. }
  811. }
  812. if (isset($autoloads['classmap'])) {
  813. $excluded = null;
  814. if (!empty($autoloads['exclude-from-classmap'])) {
  815. $excluded = $autoloads['exclude-from-classmap'];
  816. }
  817. $classMapGenerator = new ClassMapGenerator(['php', 'inc', 'hh']);
  818. $classMapGenerator->avoidDuplicateScans();
  819. foreach ($autoloads['classmap'] as $dir) {
  820. try {
  821. $classMapGenerator->scanPaths($dir, $this->buildExclusionRegex($dir, $excluded));
  822. } catch (\RuntimeException $e) {
  823. $this->io->writeError('<warning>'.$e->getMessage().'</warning>');
  824. }
  825. }
  826. $loader->addClassMap($classMapGenerator->getClassMap()->getMap());
  827. }
  828. return $loader;
  829. }
  830. protected function getIncludePathsFile(array $packageMap, Filesystem $filesystem, string $basePath, string $vendorPath, string $vendorPathCode, string $appBaseDirCode)
  831. {
  832. $includePaths = [];
  833. foreach ($packageMap as $item) {
  834. [$package, $installPath] = $item;
  835. if (null === $installPath) {
  836. continue;
  837. }
  838. if (null !== $package->getTargetDir() && strlen($package->getTargetDir()) > 0) {
  839. $installPath = substr($installPath, 0, -strlen('/'.$package->getTargetDir()));
  840. }
  841. foreach ($package->getIncludePaths() as $includePath) {
  842. $includePath = trim($includePath, '/');
  843. $includePaths[] = empty($installPath) ? $includePath : $installPath.'/'.$includePath;
  844. }
  845. }
  846. if (!$includePaths) {
  847. return null;
  848. }
  849. $includePathsCode = '';
  850. foreach ($includePaths as $path) {
  851. $includePathsCode .= " " . $this->getPathCode($filesystem, $basePath, $vendorPath, $path) . ",\n";
  852. }
  853. return <<<EOF
  854. <?php
  855. // include_paths.php @generated by Composer
  856. \$vendorDir = $vendorPathCode;
  857. \$baseDir = $appBaseDirCode;
  858. return array(
  859. $includePathsCode);
  860. EOF;
  861. }
  862. protected function getIncludeFilesFile(array $files, Filesystem $filesystem, string $basePath, string $vendorPath, string $vendorPathCode, string $appBaseDirCode)
  863. {
  864. $files = array_map(
  865. function (string $functionFile) use ($filesystem, $basePath, $vendorPath): string {
  866. return $this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile);
  867. },
  868. $files
  869. );
  870. $uniqueFiles = array_unique($files);
  871. if (count($uniqueFiles) < count($files)) {
  872. $this->io->writeError('<warning>The following "files" autoload rules are included multiple times, this may cause issues and should be resolved:</warning>');
  873. foreach (array_unique(array_diff_assoc($files, $uniqueFiles)) as $duplicateFile) {
  874. $this->io->writeError('<warning> - '.$duplicateFile.'</warning>');
  875. }
  876. }
  877. unset($uniqueFiles);
  878. $filesCode = '';
  879. foreach ($files as $fileIdentifier => $functionFile) {
  880. $filesCode .= ' ' . var_export($fileIdentifier, true) . ' => ' . $functionFile . ",\n";
  881. }
  882. if (!$filesCode) {
  883. return null;
  884. }
  885. return <<<EOF
  886. <?php
  887. // autoload_files.php @generated by Composer
  888. \$vendorDir = $vendorPathCode;
  889. \$baseDir = $appBaseDirCode;
  890. return array(
  891. $filesCode);
  892. EOF;
  893. }
  894. protected function getPathCode(Filesystem $filesystem, string $basePath, string $vendorPath, string $path)
  895. {
  896. if (!$filesystem->isAbsolutePath($path)) {
  897. $path = $basePath . '/' . $path;
  898. }
  899. $path = $filesystem->normalizePath($path);
  900. $baseDir = '';
  901. if (strpos($path.'/', $vendorPath.'/') === 0) {
  902. $path = (string) substr($path, strlen($vendorPath));
  903. $baseDir = '$vendorDir . ';
  904. } else {
  905. $path = $filesystem->normalizePath($filesystem->findShortestPath($basePath, $path, true));
  906. if (!$filesystem->isAbsolutePath($path)) {
  907. $baseDir = '$baseDir . ';
  908. $path = '/' . $path;
  909. }
  910. }
  911. if (strpos($path, '.phar') !== false) {
  912. $baseDir = "'phar://' . " . $baseDir;
  913. }
  914. return $baseDir . var_export($path, true);
  915. }
  916. protected function getPlatformCheck(array $packageMap, $checkPlatform, array $devPackageNames)
  917. {
  918. $lowestPhpVersion = Bound::zero();
  919. $requiredPhp64bit = false;
  920. $requiredExtensions = [];
  921. $extensionProviders = [];
  922. foreach ($packageMap as $item) {
  923. $package = $item[0];
  924. foreach (array_merge($package->getReplaces(), $package->getProvides()) as $link) {
  925. if (Preg::isMatch('{^ext-(.+)$}iD', $link->getTarget(), $match)) {
  926. $extensionProviders[$match[1]][] = $link->getConstraint();
  927. }
  928. }
  929. }
  930. foreach ($packageMap as $item) {
  931. $package = $item[0];
  932. if (in_array($package->getName(), $devPackageNames, true)) {
  933. continue;
  934. }
  935. foreach ($package->getRequires() as $link) {
  936. if ($this->platformRequirementFilter->isIgnored($link->getTarget())) {
  937. continue;
  938. }
  939. if (in_array($link->getTarget(), ['php', 'php-64bit'], true)) {
  940. $constraint = $link->getConstraint();
  941. if ($constraint->getLowerBound()->compareTo($lowestPhpVersion, '>')) {
  942. $lowestPhpVersion = $constraint->getLowerBound();
  943. }
  944. }
  945. if ('php-64bit' === $link->getTarget()) {
  946. $requiredPhp64bit = true;
  947. }
  948. if ($checkPlatform === true && Preg::isMatch('{^ext-(.+)$}iD', $link->getTarget(), $match)) {
  949. if (isset($extensionProviders[$match[1]])) {
  950. foreach ($extensionProviders[$match[1]] as $provided) {
  951. if ($provided->matches($link->getConstraint())) {
  952. continue 2;
  953. }
  954. }
  955. }
  956. if ($match[1] === 'zend-opcache') {
  957. $match[1] = 'zend opcache';
  958. }
  959. $extension = var_export($match[1], true);
  960. if ($match[1] === 'pcntl' || $match[1] === 'readline') {
  961. $requiredExtensions[$extension] = "PHP_SAPI !== 'cli' || extension_loaded($extension) || \$missingExtensions[] = $extension;\n";
  962. } else {
  963. $requiredExtensions[$extension] = "extension_loaded($extension) || \$missingExtensions[] = $extension;\n";
  964. }
  965. }
  966. }
  967. }
  968. ksort($requiredExtensions);
  969. $formatToPhpVersionId = static function (Bound $bound): int {
  970. if ($bound->isZero()) {
  971. return 0;
  972. }
  973. if ($bound->isPositiveInfinity()) {
  974. return 99999;
  975. }
  976. $version = str_replace('-', '.', $bound->getVersion());
  977. $chunks = array_map('intval', explode('.', $version));
  978. return $chunks[0] * 10000 + $chunks[1] * 100 + $chunks[2];
  979. };
  980. $formatToHumanReadable = static function (Bound $bound) {
  981. if ($bound->isZero()) {
  982. return 0;
  983. }
  984. if ($bound->isPositiveInfinity()) {
  985. return 99999;
  986. }
  987. $version = str_replace('-', '.', $bound->getVersion());
  988. $chunks = explode('.', $version);
  989. $chunks = array_slice($chunks, 0, 3);
  990. return implode('.', $chunks);
  991. };
  992. $requiredPhp = '';
  993. $requiredPhpError = '';
  994. if (!$lowestPhpVersion->isZero()) {
  995. $operator = $lowestPhpVersion->isInclusive() ? '>=' : '>';
  996. $requiredPhp = 'PHP_VERSION_ID '.$operator.' '.$formatToPhpVersionId($lowestPhpVersion);
  997. $requiredPhpError = '"'.$operator.' '.$formatToHumanReadable($lowestPhpVersion).'"';
  998. }
  999. if ($requiredPhp) {
  1000. $requiredPhp = <<<PHP_CHECK
  1001. if (!($requiredPhp)) {
  1002. \$issues[] = 'Your Composer dependencies require a PHP version $requiredPhpError. You are running ' . PHP_VERSION . '.';
  1003. }
  1004. PHP_CHECK;
  1005. }
  1006. if ($requiredPhp64bit) {
  1007. $requiredPhp .= <<<PHP_CHECK
  1008. if (PHP_INT_SIZE !== 8) {
  1009. \$issues[] = 'Your Composer dependencies require a 64-bit build of PHP.';
  1010. }
  1011. PHP_CHECK;
  1012. }
  1013. $requiredExtensions = implode('', $requiredExtensions);
  1014. if ('' !== $requiredExtensions) {
  1015. $requiredExtensions = <<<EXT_CHECKS
  1016. \$missingExtensions = array();
  1017. $requiredExtensions
  1018. if (\$missingExtensions) {
  1019. \$issues[] = 'Your Composer dependencies require the following PHP extensions to be installed: ' . implode(', ', \$missingExtensions) . '.';
  1020. }
  1021. EXT_CHECKS;
  1022. }
  1023. if (!$requiredPhp && !$requiredExtensions) {
  1024. return null;
  1025. }
  1026. return <<<PLATFORM_CHECK
  1027. <?php
  1028. // platform_check.php @generated by Composer
  1029. \$issues = array();
  1030. {$requiredPhp}{$requiredExtensions}
  1031. if (\$issues) {
  1032. if (!headers_sent()) {
  1033. header('HTTP/1.1 500 Internal Server Error');
  1034. }
  1035. if (!ini_get('display_errors')) {
  1036. if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
  1037. fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, \$issues) . PHP_EOL.PHP_EOL);
  1038. } elseif (!headers_sent()) {
  1039. 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;
  1040. }
  1041. }
  1042. trigger_error(
  1043. 'Composer detected issues in your platform: ' . implode(' ', \$issues),
  1044. E_USER_ERROR
  1045. );
  1046. }
  1047. PLATFORM_CHECK;
  1048. }
  1049. protected function getAutoloadFile(string $vendorPathToTargetDirCode, string $suffix)
  1050. {
  1051. $lastChar = $vendorPathToTargetDirCode[strlen($vendorPathToTargetDirCode) - 1];
  1052. if ("'" === $lastChar || '"' === $lastChar) {
  1053. $vendorPathToTargetDirCode = substr($vendorPathToTargetDirCode, 0, -1).'/autoload_real.php'.$lastChar;
  1054. } else {
  1055. $vendorPathToTargetDirCode .= " . '/autoload_real.php'";
  1056. }
  1057. return <<<AUTOLOAD
  1058. <?php
  1059. // autoload.php @generated by Composer
  1060. if (PHP_VERSION_ID < 50600) {
  1061. if (!headers_sent()) {
  1062. header('HTTP/1.1 500 Internal Server Error');
  1063. }
  1064. \$err = '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;
  1065. if (!ini_get('display_errors')) {
  1066. if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
  1067. fwrite(STDERR, \$err);
  1068. } elseif (!headers_sent()) {
  1069. echo \$err;
  1070. }
  1071. }
  1072. trigger_error(
  1073. \$err,
  1074. E_USER_ERROR
  1075. );
  1076. }
  1077. require_once $vendorPathToTargetDirCode;
  1078. return ComposerAutoloaderInit$suffix::getLoader();
  1079. AUTOLOAD;
  1080. }
  1081. protected function getAutoloadRealFile(bool $useClassMap, bool $useIncludePath, ?string $targetDirLoader, bool $useIncludeFiles, string $vendorPathCode, string $appBaseDirCode, string $suffix, bool $useGlobalIncludePath, string $prependAutoloader, bool $checkPlatform)
  1082. {
  1083. $file = <<<HEADER
  1084. <?php
  1085. // autoload_real.php @generated by Composer
  1086. class ComposerAutoloaderInit$suffix
  1087. {
  1088. private static \$loader;
  1089. public static function loadClassLoader(\$class)
  1090. {
  1091. if ('Composer\\Autoload\\ClassLoader' === \$class) {
  1092. require __DIR__ . '/ClassLoader.php';
  1093. }
  1094. }
  1095. /**
  1096. * @return \Composer\Autoload\ClassLoader
  1097. */
  1098. public static function getLoader()
  1099. {
  1100. if (null !== self::\$loader) {
  1101. return self::\$loader;
  1102. }
  1103. HEADER;
  1104. if ($checkPlatform) {
  1105. $file .= <<<'PLATFORM_CHECK'
  1106. require __DIR__ . '/platform_check.php';
  1107. PLATFORM_CHECK;
  1108. }
  1109. $file .= <<<CLASSLOADER_INIT
  1110. spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'), true, $prependAutoloader);
  1111. self::\$loader = \$loader = new \\Composer\\Autoload\\ClassLoader(\\dirname(__DIR__));
  1112. spl_autoload_unregister(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'));
  1113. CLASSLOADER_INIT;
  1114. if ($useIncludePath) {
  1115. $file .= <<<'INCLUDE_PATH'
  1116. $includePaths = require __DIR__ . '/include_paths.php';
  1117. $includePaths[] = get_include_path();
  1118. set_include_path(implode(PATH_SEPARATOR, $includePaths));
  1119. INCLUDE_PATH;
  1120. }
  1121. $file .= <<<STATIC_INIT
  1122. require __DIR__ . '/autoload_static.php';
  1123. call_user_func(\Composer\Autoload\ComposerStaticInit$suffix::getInitializer(\$loader));
  1124. STATIC_INIT;
  1125. if ($this->classMapAuthoritative) {
  1126. $file .= <<<'CLASSMAPAUTHORITATIVE'
  1127. $loader->setClassMapAuthoritative(true);
  1128. CLASSMAPAUTHORITATIVE;
  1129. }
  1130. if ($this->apcu) {
  1131. $apcuPrefix = var_export(($this->apcuPrefix !== null ? $this->apcuPrefix : substr(base64_encode(md5(uniqid('', true), true)), 0, -3)), true);
  1132. $file .= <<<APCU
  1133. \$loader->setApcuPrefix($apcuPrefix);
  1134. APCU;
  1135. }
  1136. if ($useGlobalIncludePath) {
  1137. $file .= <<<'INCLUDEPATH'
  1138. $loader->setUseIncludePath(true);
  1139. INCLUDEPATH;
  1140. }
  1141. if ($targetDirLoader) {
  1142. $file .= <<<REGISTER_TARGET_DIR_AUTOLOAD
  1143. spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'autoload'), true, true);
  1144. REGISTER_TARGET_DIR_AUTOLOAD;
  1145. }
  1146. $file .= <<<REGISTER_LOADER
  1147. \$loader->register($prependAutoloader);
  1148. REGISTER_LOADER;
  1149. if ($useIncludeFiles) {
  1150. $file .= <<<INCLUDE_FILES
  1151. \$filesToLoad = \Composer\Autoload\ComposerStaticInit$suffix::\$files;
  1152. \$requireFile = \Closure::bind(static function (\$fileIdentifier, \$file) {
  1153. if (empty(\$GLOBALS['__composer_autoload_files'][\$fileIdentifier])) {
  1154. \$GLOBALS['__composer_autoload_files'][\$fileIdentifier] = true;
  1155. require \$file;
  1156. }
  1157. }, null, null);
  1158. foreach (\$filesToLoad as \$fileIdentifier => \$file) {
  1159. \$requireFile(\$fileIdentifier, \$file);
  1160. }
  1161. INCLUDE_FILES;
  1162. }
  1163. $file .= <<<METHOD_FOOTER
  1164. return \$loader;
  1165. }
  1166. METHOD_FOOTER;
  1167. $file .= $targetDirLoader;
  1168. return $file . <<<FOOTER
  1169. }
  1170. FOOTER;
  1171. }
  1172. protected function getStaticFile(string $suffix, string $targetDir, string $vendorPath, string $basePath)
  1173. {
  1174. $file = <<<HEADER
  1175. <?php
  1176. // autoload_static.php @generated by Composer
  1177. namespace Composer\Autoload;
  1178. class ComposerStaticInit$suffix
  1179. {
  1180. HEADER;
  1181. $loader = new ClassLoader();
  1182. $map = require $targetDir . '/autoload_namespaces.php';
  1183. foreach ($map as $namespace => $path) {
  1184. $loader->set($namespace, $path);
  1185. }
  1186. $map = require $targetDir . '/autoload_psr4.php';
  1187. foreach ($map as $namespace => $path) {
  1188. $loader->setPsr4($namespace, $path);
  1189. }
  1190. $classMap = require $targetDir . '/autoload_classmap.php';
  1191. if ($classMap) {
  1192. $loader->addClassMap($classMap);
  1193. }
  1194. $filesystem = new Filesystem();
  1195. $vendorPathCode = ' => ' . $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true, true) . " . '/";
  1196. $vendorPharPathCode = ' => \'phar://\' . ' . $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true, true) . " . '/";
  1197. $appBaseDirCode = ' => ' . $filesystem->findShortestPathCode(realpath($targetDir), $basePath, true, true) . " . '/";
  1198. $appBaseDirPharCode = ' => \'phar://\' . ' . $filesystem->findShortestPathCode(realpath($targetDir), $basePath, true, true) . " . '/";
  1199. $absoluteVendorPathCode = ' => ' . substr(var_export(rtrim($vendorDir, '\\/') . '/', true), 0, -1);
  1200. $absoluteVendorPharPathCode = ' => ' . substr(var_export(rtrim('phar://' . $vendorDir, '\\/') . '/', true), 0, -1);
  1201. $absoluteAppBaseDirCode = ' => ' . substr(var_export(rtrim($baseDir, '\\/') . '/', true), 0, -1);
  1202. $absoluteAppBaseDirPharCode = ' => ' . substr(var_export(rtrim('phar://' . $baseDir, '\\/') . '/', true), 0, -1);
  1203. $initializer = '';
  1204. $prefix = "\0Composer\Autoload\ClassLoader\0";
  1205. $prefixLen = strlen($prefix);
  1206. if (file_exists($targetDir . '/autoload_files.php')) {
  1207. $maps = ['files' => require $targetDir . '/autoload_files.php'];
  1208. } else {
  1209. $maps = [];
  1210. }
  1211. foreach ((array) $loader as $prop => $value) {
  1212. if (!is_array($value) || \count($value) === 0 || !str_starts_with($prop, $prefix)) {
  1213. continue;
  1214. }
  1215. $maps[substr($prop, $prefixLen)] = $value;
  1216. }
  1217. foreach ($maps as $prop => $value) {
  1218. $value = strtr(
  1219. var_export($value, true),
  1220. [
  1221. $absoluteVendorPathCode => $vendorPathCode,
  1222. $absoluteVendorPharPathCode => $vendorPharPathCode,
  1223. $absoluteAppBaseDirCode => $appBaseDirCode,
  1224. $absoluteAppBaseDirPharCode => $appBaseDirPharCode,
  1225. ]
  1226. );
  1227. $value = ltrim(Preg::replace('/^ */m', ' $0$0', $value));
  1228. $file .= sprintf(" public static $%s = %s;\n\n", $prop, $value);
  1229. if ('files' !== $prop) {
  1230. $initializer .= " \$loader->$prop = ComposerStaticInit$suffix::\$$prop;\n";
  1231. }
  1232. }
  1233. return $file . <<<INITIALIZER
  1234. public static function getInitializer(ClassLoader \$loader)
  1235. {
  1236. return \Closure::bind(function () use (\$loader) {
  1237. $initializer
  1238. }, null, ClassLoader::class);
  1239. }
  1240. }
  1241. INITIALIZER;
  1242. }
  1243. protected function parseAutoloadsType(array $packageMap, string $type, RootPackageInterface $rootPackage)
  1244. {
  1245. $autoloads = [];
  1246. foreach ($packageMap as $item) {
  1247. [$package, $installPath] = $item;
  1248. if (null === $installPath) {
  1249. continue;
  1250. }
  1251. $autoload = $package->getAutoload();
  1252. if ($this->devMode && $package === $rootPackage) {
  1253. $autoload = array_merge_recursive($autoload, $package->getDevAutoload());
  1254. }
  1255. if (!isset($autoload[$type]) || !is_array($autoload[$type])) {
  1256. continue;
  1257. }
  1258. if (null !== $package->getTargetDir() && $package !== $rootPackage) {
  1259. $installPath = substr($installPath, 0, -strlen('/'.$package->getTargetDir()));
  1260. }
  1261. foreach ($autoload[$type] as $namespace => $paths) {
  1262. foreach ((array) $paths as $path) {
  1263. if (($type === 'files' || $type === 'classmap' || $type === 'exclude-from-classmap') && $package->getTargetDir() && !Filesystem::isReadable($installPath.'/'.$path)) {
  1264. if ($package === $rootPackage) {
  1265. $targetDir = str_replace('\\<dirsep\\>', '[\\\\/]', preg_quote(str_replace(['/', '\\'], '<dirsep>', $package->getTargetDir())));
  1266. $path = ltrim(Preg::replace('{^'.$targetDir.'}', '', ltrim($path, '\\/')), '\\/');
  1267. } else {
  1268. $path = $package->getTargetDir() . '/' . $path;
  1269. }
  1270. }
  1271. if ($type === 'exclude-from-classmap') {
  1272. $path = Preg::replace('{/+}', '/', preg_quote(trim(strtr($path, '\\', '/'), '/')));
  1273. $path = strtr($path, ['\\*\\*' => '.+?', '\\*' => '[^/]+?']);
  1274. $updir = null;
  1275. $path = Preg::replaceCallback(
  1276. '{^((?:(?:\\\\\\.){1,2}+/)+)}',
  1277. static function ($matches) use (&$updir): string {
  1278. if (isset($matches[1])) {
  1279. $updir = str_replace('\\.', '.', $matches[1]);
  1280. }
  1281. return '';
  1282. },
  1283. $path
  1284. );
  1285. if (empty($installPath)) {
  1286. $installPath = strtr(Platform::getCwd(), '\\', '/');
  1287. }
  1288. $resolvedPath = realpath($installPath . '/' . $updir);
  1289. if (false === $resolvedPath) {
  1290. continue;
  1291. }
  1292. $autoloads[] = preg_quote(strtr($resolvedPath, '\\', '/')) . '/' . $path . '($|/)';
  1293. continue;
  1294. }
  1295. $relativePath = empty($installPath) ? (empty($path) ? '.' : $path) : $installPath.'/'.$path;
  1296. if ($type === 'files') {
  1297. $autoloads[$this->getFileIdentifier($package, $path)] = $relativePath;
  1298. continue;
  1299. }
  1300. if ($type === 'classmap') {
  1301. $autoloads[] = $relativePath;
  1302. continue;
  1303. }
  1304. $autoloads[$namespace][] = $relativePath;
  1305. }
  1306. }
  1307. }
  1308. return $autoloads;
  1309. }
  1310. protected function getFileIdentifier(PackageInterface $package, string $path)
  1311. {
  1312. return md5($package->getName() . ':' . $path);
  1313. }
  1314. protected function filterPackageMap(array $packageMap, RootPackageInterface $rootPackage)
  1315. {
  1316. $packages = [];
  1317. $include = [];
  1318. $replacedBy = [];
  1319. foreach ($packageMap as $item) {
  1320. $package = $item[0];
  1321. $name = $package->getName();
  1322. $packages[$name] = $package;
  1323. foreach ($package->getReplaces() as $replace) {
  1324. $replacedBy[$replace->getTarget()] = $name;
  1325. }
  1326. }
  1327. $add = static function (PackageInterface $package) use (&$add, $packages, &$include, $replacedBy): void {
  1328. foreach ($package->getRequires() as $link) {
  1329. $target = $link->getTarget();
  1330. if (isset($replacedBy[$target])) {
  1331. $target = $replacedBy[$target];
  1332. }
  1333. if (!isset($include[$target])) {
  1334. $include[$target] = true;
  1335. if (isset($packages[$target])) {
  1336. $add($packages[$target]);
  1337. }
  1338. }
  1339. }
  1340. };
  1341. $add($rootPackage);
  1342. return array_filter(
  1343. $packageMap,
  1344. static function ($item) use ($include): bool {
  1345. $package = $item[0];
  1346. foreach ($package->getNames() as $name) {
  1347. if (isset($include[$name])) {
  1348. return true;
  1349. }
  1350. }
  1351. return false;
  1352. }
  1353. );
  1354. }
  1355. protected function sortPackageMap(array $packageMap)
  1356. {
  1357. $packages = [];
  1358. $paths = [];
  1359. foreach ($packageMap as $item) {
  1360. [$package, $path] = $item;
  1361. $name = $package->getName();
  1362. $packages[$name] = $package;
  1363. $paths[$name] = $path;
  1364. }
  1365. $sortedPackages = PackageSorter::sortPackages($packages);
  1366. $sortedPackageMap = [];
  1367. foreach ($sortedPackages as $package) {
  1368. $name = $package->getName();
  1369. $sortedPackageMap[] = [$packages[$name], $paths[$name]];
  1370. }
  1371. return $sortedPackageMap;
  1372. }
  1373. }
  1374. function composerRequire(string $fileIdentifier, string $file): void
  1375. {
  1376. if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  1377. $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
  1378. require $file;
  1379. }
  1380. }
  1381. <?php declare(strict_types=1);
  1382. namespace Composer\Autoload;
  1383. use Composer\ClassMapGenerator\FileList;
  1384. use Composer\IO\IOInterface;
  1385. class ClassMapGenerator
  1386. {
  1387. public static function dump(iterable $dirs, string $file): void
  1388. {
  1389. $maps = [];
  1390. foreach ($dirs as $dir) {
  1391. $maps = array_merge($maps, static::createMap($dir));
  1392. }
  1393. file_put_contents($file, sprintf('<?php return %s;', var_export($maps, true)));
  1394. }
  1395. public static function createMap($path, ?string $excluded = null, ?IOInterface $io = null, ?string $namespace = null, ?string $autoloadType = null, array &$scannedFiles = []): array
  1396. {
  1397. $generator = new \Composer\ClassMapGenerator\ClassMapGenerator(['php', 'inc', 'hh']);
  1398. $fileList = new FileList();
  1399. $fileList->files = $scannedFiles;
  1400. $generator->avoidDuplicateScans($fileList);
  1401. $generator->scanPaths($path, $excluded, $autoloadType ?? 'classmap', $namespace);
  1402. $classMap = $generator->getClassMap();
  1403. $scannedFiles = $fileList->files;
  1404. if ($io !== null) {
  1405. foreach ($classMap->getPsrViolations() as $msg) {
  1406. $io->writeError("<warning>$msg</warning>");
  1407. }
  1408. foreach ($classMap->getAmbiguousClasses() as $class => $paths) {
  1409. if (count($paths) > 1) {
  1410. $io->writeError(
  1411. '<warning>Warning: Ambiguous class resolution, "'.$class.'"'.
  1412. ' was found '. (count($paths) + 1) .'x: in "'.$classMap->getClassPath($class).'" and "'. implode('", "', $paths) .'", the first will be used.</warning>'
  1413. );
  1414. } else {
  1415. $io->writeError(
  1416. '<warning>Warning: Ambiguous class resolution, "'.$class.'"'.
  1417. ' was found in both "'.$classMap->getClassPath($class).'" and "'. implode('", "', $paths) .'", the first will be used.</warning>'
  1418. );
  1419. }
  1420. }
  1421. }
  1422. return $classMap->getMap();
  1423. }
  1424. }
  1425. <?php declare(strict_types=1);
  1426. namespace Composer;
  1427. use Composer\IO\IOInterface;
  1428. use Composer\Pcre\Preg;
  1429. use Composer\Util\Filesystem;
  1430. use Composer\Util\Platform;
  1431. use Composer\Util\Silencer;
  1432. use Symfony\Component\Finder\Finder;
  1433. class Cache
  1434. {
  1435. private static $cacheCollected = null;
  1436. private $io;
  1437. private $root;
  1438. private $enabled = null;
  1439. private $allowlist;
  1440. private $filesystem;
  1441. private $readOnly;
  1442. public function __construct(IOInterface $io, string $cacheDir, string $allowlist = 'a-z0-9._', ?Filesystem $filesystem = null, bool $readOnly = false)
  1443. {
  1444. $this->io = $io;
  1445. $this->root = rtrim($cacheDir, '/\\') . '/';
  1446. $this->allowlist = $allowlist;
  1447. $this->filesystem = $filesystem ?: new Filesystem();
  1448. $this->readOnly = (bool) $readOnly;
  1449. if (!self::isUsable($cacheDir)) {
  1450. $this->enabled = false;
  1451. }
  1452. }
  1453. public function setReadOnly(bool $readOnly)
  1454. {
  1455. $this->readOnly = (bool) $readOnly;
  1456. }
  1457. public function isReadOnly()
  1458. {
  1459. return $this->readOnly;
  1460. }
  1461. public static function isUsable(string $path)
  1462. {
  1463. return !Preg::isMatch('{(^|[\\\\/])(\$null|nul|NUL|/dev/null)([\\\\/]|$)}', $path);
  1464. }
  1465. public function isEnabled()
  1466. {
  1467. if ($this->enabled === null) {
  1468. $this->enabled = true;
  1469. if (
  1470. !$this->readOnly
  1471. && (
  1472. (!is_dir($this->root) && !Silencer::call('mkdir', $this->root, 0777, true))
  1473. || !is_writable($this->root)
  1474. )
  1475. ) {
  1476. $this->io->writeError('<warning>Cannot create cache directory ' . $this->root . ', or directory is not writable. Proceeding without cache. See also cache-read-only config if your filesystem is read-only.</warning>');
  1477. $this->enabled = false;
  1478. }
  1479. }
  1480. return $this->enabled;
  1481. }
  1482. public function getRoot()
  1483. {
  1484. return $this->root;
  1485. }
  1486. public function read(string $file)
  1487. {
  1488. if ($this->isEnabled()) {
  1489. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1490. if (file_exists($this->root . $file)) {
  1491. $this->io->writeError('Reading '.$this->root . $file.' from cache', true, IOInterface::DEBUG);
  1492. return file_get_contents($this->root . $file);
  1493. }
  1494. }
  1495. return false;
  1496. }
  1497. public function write(string $file, string $contents)
  1498. {
  1499. $wasEnabled = $this->enabled === true;
  1500. if ($this->isEnabled() && !$this->readOnly) {
  1501. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1502. $this->io->writeError('Writing '.$this->root . $file.' into cache', true, IOInterface::DEBUG);
  1503. $tempFileName = $this->root . $file . uniqid('.', true) . '.tmp';
  1504. try {
  1505. return file_put_contents($tempFileName, $contents) !== false && rename($tempFileName, $this->root . $file);
  1506. } catch (\ErrorException $e) {
  1507. if ($wasEnabled) {
  1508. clearstatcache();
  1509. $this->enabled = null;
  1510. return $this->write($file, $contents);
  1511. }
  1512. $this->io->writeError('<warning>Failed to write into cache: '.$e->getMessage().'</warning>', true, IOInterface::DEBUG);
  1513. if (Preg::isMatch('{^file_put_contents\(\): Only ([0-9]+) of ([0-9]+) bytes written}', $e->getMessage(), $m)) {
  1514. unlink($tempFileName);
  1515. $message = sprintf(
  1516. '<warning>Writing %1$s into cache failed after %2$u of %3$u bytes written, only %4$s bytes of free space available</warning>',
  1517. $tempFileName,
  1518. $m[1],
  1519. $m[2],
  1520. function_exists('disk_free_space') ? @disk_free_space(dirname($tempFileName)) : 'unknown'
  1521. );
  1522. $this->io->writeError($message);
  1523. return false;
  1524. }
  1525. throw $e;
  1526. }
  1527. }
  1528. return false;
  1529. }
  1530. public function copyFrom(string $file, string $source)
  1531. {
  1532. if ($this->isEnabled() && !$this->readOnly) {
  1533. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1534. $this->filesystem->ensureDirectoryExists(dirname($this->root . $file));
  1535. if (!file_exists($source)) {
  1536. $this->io->writeError('<error>'.$source.' does not exist, can not write into cache</error>');
  1537. } elseif ($this->io->isDebug()) {
  1538. $this->io->writeError('Writing '.$this->root . $file.' into cache from '.$source);
  1539. }
  1540. return copy($source, $this->root . $file);
  1541. }
  1542. return false;
  1543. }
  1544. public function copyTo(string $file, string $target)
  1545. {
  1546. if ($this->isEnabled()) {
  1547. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1548. if (file_exists($this->root . $file)) {
  1549. try {
  1550. touch($this->root . $file, (int) filemtime($this->root . $file), time());
  1551. } catch (\ErrorException $e) {
  1552. Silencer::call('touch', $this->root . $file);
  1553. }
  1554. $this->io->writeError('Reading '.$this->root . $file.' from cache', true, IOInterface::DEBUG);
  1555. return copy($this->root . $file, $target);
  1556. }
  1557. }
  1558. return false;
  1559. }
  1560. public function gcIsNecessary()
  1561. {
  1562. if (self::$cacheCollected) {
  1563. return false;
  1564. }
  1565. self::$cacheCollected = true;
  1566. if (Platform::getEnv('COMPOSER_TEST_SUITE')) {
  1567. return false;
  1568. }
  1569. if (Platform::isInputCompletionProcess()) {
  1570. return false;
  1571. }
  1572. return !random_int(0, 50);
  1573. }
  1574. public function remove(string $file)
  1575. {
  1576. if ($this->isEnabled() && !$this->readOnly) {
  1577. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1578. if (file_exists($this->root . $file)) {
  1579. return $this->filesystem->unlink($this->root . $file);
  1580. }
  1581. }
  1582. return false;
  1583. }
  1584. public function clear()
  1585. {
  1586. if ($this->isEnabled() && !$this->readOnly) {
  1587. $this->filesystem->emptyDirectory($this->root);
  1588. return true;
  1589. }
  1590. return false;
  1591. }
  1592. public function getAge(string $file)
  1593. {
  1594. if ($this->isEnabled()) {
  1595. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1596. if (file_exists($this->root . $file) && ($mtime = filemtime($this->root . $file)) !== false) {
  1597. return abs(time() - $mtime);
  1598. }
  1599. }
  1600. return false;
  1601. }
  1602. public function gc(int $ttl, int $maxSize)
  1603. {
  1604. if ($this->isEnabled() && !$this->readOnly) {
  1605. $expire = new \DateTime();
  1606. $expire->modify('-'.$ttl.' seconds');
  1607. $finder = $this->getFinder()->date('until '.$expire->format('Y-m-d H:i:s'));
  1608. foreach ($finder as $file) {
  1609. $this->filesystem->unlink($file->getPathname());
  1610. }
  1611. $totalSize = $this->filesystem->size($this->root);
  1612. if ($totalSize > $maxSize) {
  1613. $iterator = $this->getFinder()->sortByAccessedTime()->getIterator();
  1614. while ($totalSize > $maxSize && $iterator->valid()) {
  1615. $filepath = $iterator->current()->getPathname();
  1616. $totalSize -= $this->filesystem->size($filepath);
  1617. $this->filesystem->unlink($filepath);
  1618. $iterator->next();
  1619. }
  1620. }
  1621. self::$cacheCollected = true;
  1622. return true;
  1623. }
  1624. return false;
  1625. }
  1626. public function gcVcsCache(int $ttl): bool
  1627. {
  1628. if ($this->isEnabled()) {
  1629. $expire = new \DateTime();
  1630. $expire->modify('-'.$ttl.' seconds');
  1631. $finder = Finder::create()->in($this->root)->directories()->depth(0)->date('until '.$expire->format('Y-m-d H:i:s'));
  1632. foreach ($finder as $file) {
  1633. $this->filesystem->removeDirectory($file->getPathname());
  1634. }
  1635. self::$cacheCollected = true;
  1636. return true;
  1637. }
  1638. return false;
  1639. }
  1640. public function sha1(string $file)
  1641. {
  1642. if ($this->isEnabled()) {
  1643. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1644. if (file_exists($this->root . $file)) {
  1645. return sha1_file($this->root . $file);
  1646. }
  1647. }
  1648. return false;
  1649. }
  1650. public function sha256(string $file)
  1651. {
  1652. if ($this->isEnabled()) {
  1653. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1654. if (file_exists($this->root . $file)) {
  1655. return hash_file('sha256', $this->root . $file);
  1656. }
  1657. }
  1658. return false;
  1659. }
  1660. protected function getFinder()
  1661. {
  1662. return Finder::create()->in($this->root)->files();
  1663. }
  1664. }
  1665. <?php declare(strict_types=1);
  1666. namespace Composer\Command;
  1667. use Composer\Composer;
  1668. use Symfony\Component\Console\Input\InputInterface;
  1669. use Symfony\Component\Console\Output\OutputInterface;
  1670. class AboutCommand extends BaseCommand
  1671. {
  1672. protected function configure(): void
  1673. {
  1674. $this
  1675. ->setName('about')
  1676. ->setDescription('Shows a short information about Composer')
  1677. ->setHelp(
  1678. <<<EOT
  1679. <info>php composer.phar about</info>
  1680. EOT
  1681. )
  1682. ;
  1683. }
  1684. protected function execute(InputInterface $input, OutputInterface $output): int
  1685. {
  1686. $composerVersion = Composer::getVersion();
  1687. $this->getIO()->write(
  1688. <<<EOT
  1689. <info>Composer - Dependency Manager for PHP - version $composerVersion</info>
  1690. <comment>Composer is a dependency manager tracking local dependencies of your projects and libraries.
  1691. See https://getcomposer.org/ for more information.</comment>
  1692. EOT
  1693. );
  1694. return 0;
  1695. }
  1696. }
  1697. <?php declare(strict_types=1);
  1698. namespace Composer\Command;
  1699. use Composer\Factory;
  1700. use Composer\IO\IOInterface;
  1701. use Composer\Config;
  1702. use Composer\Composer;
  1703. use Composer\Package\BasePackage;
  1704. use Composer\Package\CompletePackageInterface;
  1705. use Composer\Package\Version\VersionParser;
  1706. use Composer\Package\Version\VersionSelector;
  1707. use Composer\Pcre\Preg;
  1708. use Composer\Repository\CompositeRepository;
  1709. use Composer\Repository\RepositoryFactory;
  1710. use Composer\Repository\RepositorySet;
  1711. use Composer\Script\ScriptEvents;
  1712. use Composer\Plugin\CommandEvent;
  1713. use Composer\Plugin\PluginEvents;
  1714. use Composer\Util\Filesystem;
  1715. use Composer\Util\Loop;
  1716. use Composer\Util\Platform;
  1717. use Composer\Util\ProcessExecutor;
  1718. use Composer\Console\Input\InputArgument;
  1719. use Symfony\Component\Console\Input\InputInterface;
  1720. use Composer\Console\Input\InputOption;
  1721. use Symfony\Component\Console\Output\OutputInterface;
  1722. class ArchiveCommand extends BaseCommand
  1723. {
  1724. use CompletionTrait;
  1725. private const FORMATS = ['tar', 'tar.gz', 'tar.bz2', 'zip'];
  1726. protected function configure(): void
  1727. {
  1728. $this
  1729. ->setName('archive')
  1730. ->setDescription('Creates an archive of this composer package')
  1731. ->setDefinition([
  1732. new InputArgument('package', InputArgument::OPTIONAL, 'The package to archive instead of the current project', null, $this->suggestAvailablePackage()),
  1733. new InputArgument('version', InputArgument::OPTIONAL, 'A version constraint to find the package to archive'),
  1734. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the resulting archive: tar, tar.gz, tar.bz2 or zip (default tar)', null, self::FORMATS),
  1735. new InputOption('dir', null, InputOption::VALUE_REQUIRED, 'Write the archive to this directory'),
  1736. new InputOption('file', null, InputOption::VALUE_REQUIRED, 'Write the archive with the given file name.'
  1737. .' Note that the format will be appended.'),
  1738. new InputOption('ignore-filters', null, InputOption::VALUE_NONE, 'Ignore filters when saving package'),
  1739. ])
  1740. ->setHelp(
  1741. <<<EOT
  1742. The <info>archive</info> command creates an archive of the specified format
  1743. containing the files and directories of the Composer project or the specified
  1744. package in the specified version and writes it to the specified directory.
  1745. <info>php composer.phar archive [--format=zip] [--dir=/foo] [--file=filename] [package [version]]</info>
  1746. Read more at https://getcomposer.org/doc/03-cli.md#archive
  1747. EOT
  1748. )
  1749. ;
  1750. }
  1751. protected function execute(InputInterface $input, OutputInterface $output): int
  1752. {
  1753. $composer = $this->tryComposer();
  1754. $config = null;
  1755. if ($composer) {
  1756. $config = $composer->getConfig();
  1757. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'archive', $input, $output);
  1758. $eventDispatcher = $composer->getEventDispatcher();
  1759. $eventDispatcher->dispatch($commandEvent->getName(), $commandEvent);
  1760. $eventDispatcher->dispatchScript(ScriptEvents::PRE_ARCHIVE_CMD);
  1761. }
  1762. if (!$config) {
  1763. $config = Factory::createConfig();
  1764. }
  1765. $format = $input->getOption('format') ?? $config->get('archive-format');
  1766. $dir = $input->getOption('dir') ?? $config->get('archive-dir');
  1767. $returnCode = $this->archive(
  1768. $this->getIO(),
  1769. $config,
  1770. $input->getArgument('package'),
  1771. $input->getArgument('version'),
  1772. $format,
  1773. $dir,
  1774. $input->getOption('file'),
  1775. $input->getOption('ignore-filters'),
  1776. $composer
  1777. );
  1778. if (0 === $returnCode && $composer) {
  1779. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ARCHIVE_CMD);
  1780. }
  1781. return $returnCode;
  1782. }
  1783. protected function archive(IOInterface $io, Config $config, ?string $packageName, ?string $version, string $format, string $dest, ?string $fileName, bool $ignoreFilters, ?Composer $composer): int
  1784. {
  1785. if ($composer) {
  1786. $archiveManager = $composer->getArchiveManager();
  1787. } else {
  1788. $factory = new Factory;
  1789. $process = new ProcessExecutor();
  1790. $httpDownloader = Factory::createHttpDownloader($io, $config);
  1791. $downloadManager = $factory->createDownloadManager($io, $config, $httpDownloader, $process);
  1792. $archiveManager = $factory->createArchiveManager($config, $downloadManager, new Loop($httpDownloader, $process));
  1793. }
  1794. if ($packageName) {
  1795. $package = $this->selectPackage($io, $packageName, $version);
  1796. if (!$package) {
  1797. return 1;
  1798. }
  1799. } else {
  1800. $package = $this->requireComposer()->getPackage();
  1801. }
  1802. $io->writeError('<info>Creating the archive into "'.$dest.'".</info>');
  1803. $packagePath = $archiveManager->archive($package, $format, $dest, $fileName, $ignoreFilters);
  1804. $fs = new Filesystem;
  1805. $shortPath = $fs->findShortestPath(Platform::getCwd(), $packagePath, true);
  1806. $io->writeError('Created: ', false);
  1807. $io->write(strlen($shortPath) < strlen($packagePath) ? $shortPath : $packagePath);
  1808. return 0;
  1809. }
  1810. protected function selectPackage(IOInterface $io, string $packageName, ?string $version = null)
  1811. {
  1812. $io->writeError('<info>Searching for the specified package.</info>');
  1813. if ($composer = $this->tryComposer()) {
  1814. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  1815. $repo = new CompositeRepository(array_merge([$localRepo], $composer->getRepositoryManager()->getRepositories()));
  1816. $minStability = $composer->getPackage()->getMinimumStability();
  1817. } else {
  1818. $defaultRepos = RepositoryFactory::defaultReposWithDefaultManager($io);
  1819. $io->writeError('No composer.json found in the current directory, searching packages from ' . implode(', ', array_keys($defaultRepos)));
  1820. $repo = new CompositeRepository($defaultRepos);
  1821. $minStability = 'stable';
  1822. }
  1823. if ($version !== null && Preg::isMatchStrictGroups('{@(stable|RC|beta|alpha|dev)$}i', $version, $match)) {
  1824. $minStability = $match[1];
  1825. $version = (string) substr($version, 0, -strlen($match[0]));
  1826. }
  1827. $repoSet = new RepositorySet($minStability);
  1828. $repoSet->addRepository($repo);
  1829. $parser = new VersionParser();
  1830. $constraint = $version !== null ? $parser->parseConstraints($version) : null;
  1831. $packages = $repoSet->findPackages(strtolower($packageName), $constraint);
  1832. if (count($packages) > 1) {
  1833. $versionSelector = new VersionSelector($repoSet);
  1834. $package = $versionSelector->findBestCandidate(strtolower($packageName), $version, $minStability);
  1835. if ($package === false) {
  1836. $package = reset($packages);
  1837. }
  1838. $io->writeError('<info>Found multiple matches, selected '.$package->getPrettyString().'.</info>');
  1839. $io->writeError('Alternatives were '.implode(', ', array_map(static function ($p): string {
  1840. return $p->getPrettyString();
  1841. }, $packages)).'.');
  1842. $io->writeError('<comment>Please use a more specific constraint to pick a different package.</comment>');
  1843. } elseif (count($packages) === 1) {
  1844. $package = reset($packages);
  1845. $io->writeError('<info>Found an exact match '.$package->getPrettyString().'.</info>');
  1846. } else {
  1847. $io->writeError('<error>Could not find a package matching '.$packageName.'.</error>');
  1848. return false;
  1849. }
  1850. if (!$package instanceof CompletePackageInterface) {
  1851. throw new \LogicException('Expected a CompletePackageInterface instance but found '.get_class($package));
  1852. }
  1853. if (!$package instanceof BasePackage) {
  1854. throw new \LogicException('Expected a BasePackage instance but found '.get_class($package));
  1855. }
  1856. return $package;
  1857. }
  1858. }
  1859. <?php declare(strict_types=1);
  1860. namespace Composer\Command;
  1861. use Composer\Composer;
  1862. use Composer\Repository\RepositorySet;
  1863. use Composer\Repository\RepositoryUtils;
  1864. use Symfony\Component\Console\Input\InputInterface;
  1865. use Symfony\Component\Console\Output\OutputInterface;
  1866. use Composer\Package\PackageInterface;
  1867. use Composer\Repository\InstalledRepository;
  1868. use Composer\Advisory\Auditor;
  1869. use Composer\Console\Input\InputOption;
  1870. class AuditCommand extends BaseCommand
  1871. {
  1872. protected function configure(): void
  1873. {
  1874. $this
  1875. ->setName('audit')
  1876. ->setDescription('Checks for security vulnerability advisories for installed packages')
  1877. ->setDefinition([
  1878. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables auditing of require-dev packages.'),
  1879. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Output format. Must be "table", "plain", "json", or "summary".', Auditor::FORMAT_TABLE, Auditor::FORMATS),
  1880. new InputOption('locked', null, InputOption::VALUE_NONE, 'Audit based on the lock file instead of the installed packages.'),
  1881. ])
  1882. ->setHelp(
  1883. <<<EOT
  1884. The <info>audit</info> command checks for security vulnerability advisories for installed packages.
  1885. If you do not want to include dev dependencies in the audit you can omit them with --no-dev
  1886. Read more at https://getcomposer.org/doc/03-cli.md#audit
  1887. EOT
  1888. )
  1889. ;
  1890. }
  1891. protected function execute(InputInterface $input, OutputInterface $output)
  1892. {
  1893. $composer = $this->requireComposer();
  1894. $packages = $this->getPackages($composer, $input);
  1895. if (count($packages) === 0) {
  1896. $this->getIO()->writeError('No packages - skipping audit.');
  1897. return 0;
  1898. }
  1899. $auditor = new Auditor();
  1900. $repoSet = new RepositorySet();
  1901. foreach ($composer->getRepositoryManager()->getRepositories() as $repo) {
  1902. $repoSet->addRepository($repo);
  1903. }
  1904. $auditConfig = $composer->getConfig()->get('audit');
  1905. return min(255, $auditor->audit($this->getIO(), $repoSet, $packages, $this->getAuditFormat($input, 'format'), false, $auditConfig['ignore'] ?? [], $auditConfig['abandoned'] ?? Auditor::ABANDONED_REPORT));
  1906. }
  1907. private function getPackages(Composer $composer, InputInterface $input): array
  1908. {
  1909. if ($input->getOption('locked')) {
  1910. if (!$composer->getLocker()->isLocked()) {
  1911. throw new \UnexpectedValueException('Valid composer.json and composer.lock files are required to run this command with --locked');
  1912. }
  1913. $locker = $composer->getLocker();
  1914. return $locker->getLockedRepository(!$input->getOption('no-dev'))->getPackages();
  1915. }
  1916. $rootPkg = $composer->getPackage();
  1917. $installedRepo = new InstalledRepository([$composer->getRepositoryManager()->getLocalRepository()]);
  1918. if ($input->getOption('no-dev')) {
  1919. return RepositoryUtils::filterRequiredPackages($installedRepo->getPackages(), $rootPkg);
  1920. }
  1921. return $installedRepo->getPackages();
  1922. }
  1923. }
  1924. <?php declare(strict_types=1);
  1925. namespace Composer\Command;
  1926. use Composer\Composer;
  1927. use Composer\Config;
  1928. use Composer\Console\Application;
  1929. use Composer\Console\Input\InputArgument;
  1930. use Composer\Console\Input\InputOption;
  1931. use Composer\Factory;
  1932. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  1933. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  1934. use Composer\IO\IOInterface;
  1935. use Composer\IO\NullIO;
  1936. use Composer\Plugin\PreCommandRunEvent;
  1937. use Composer\Package\Version\VersionParser;
  1938. use Composer\Plugin\PluginEvents;
  1939. use Composer\Advisory\Auditor;
  1940. use Composer\Util\Platform;
  1941. use Symfony\Component\Console\Completion\CompletionInput;
  1942. use Symfony\Component\Console\Completion\CompletionSuggestions;
  1943. use Symfony\Component\Console\Helper\Table;
  1944. use Symfony\Component\Console\Helper\TableSeparator;
  1945. use Symfony\Component\Console\Input\InputInterface;
  1946. use Symfony\Component\Console\Output\OutputInterface;
  1947. use Symfony\Component\Console\Command\Command;
  1948. use Symfony\Component\Console\Terminal;
  1949. abstract class BaseCommand extends Command
  1950. {
  1951. private $composer;
  1952. private $io;
  1953. public function getApplication(): Application
  1954. {
  1955. $application = parent::getApplication();
  1956. if (!$application instanceof Application) {
  1957. throw new \RuntimeException('Composer commands can only work with an '.Application::class.' instance set');
  1958. }
  1959. return $application;
  1960. }
  1961. public function getComposer(bool $required = true, ?bool $disablePlugins = null, ?bool $disableScripts = null)
  1962. {
  1963. if ($required) {
  1964. return $this->requireComposer($disablePlugins, $disableScripts);
  1965. }
  1966. return $this->tryComposer($disablePlugins, $disableScripts);
  1967. }
  1968. public function requireComposer(?bool $disablePlugins = null, ?bool $disableScripts = null): Composer
  1969. {
  1970. if (null === $this->composer) {
  1971. $application = parent::getApplication();
  1972. if ($application instanceof Application) {
  1973. $this->composer = $application->getComposer(true, $disablePlugins, $disableScripts);
  1974. assert($this->composer instanceof Composer);
  1975. } else {
  1976. throw new \RuntimeException(
  1977. 'Could not create a Composer\Composer instance, you must inject '.
  1978. 'one if this command is not used with a Composer\Console\Application instance'
  1979. );
  1980. }
  1981. }
  1982. return $this->composer;
  1983. }
  1984. public function tryComposer(?bool $disablePlugins = null, ?bool $disableScripts = null): ?Composer
  1985. {
  1986. if (null === $this->composer) {
  1987. $application = parent::getApplication();
  1988. if ($application instanceof Application) {
  1989. $this->composer = $application->getComposer(false, $disablePlugins, $disableScripts);
  1990. }
  1991. }
  1992. return $this->composer;
  1993. }
  1994. public function setComposer(Composer $composer)
  1995. {
  1996. $this->composer = $composer;
  1997. }
  1998. public function resetComposer()
  1999. {
  2000. $this->composer = null;
  2001. $this->getApplication()->resetComposer();
  2002. }
  2003. public function isProxyCommand()
  2004. {
  2005. return false;
  2006. }
  2007. public function getIO()
  2008. {
  2009. if (null === $this->io) {
  2010. $application = parent::getApplication();
  2011. if ($application instanceof Application) {
  2012. $this->io = $application->getIO();
  2013. } else {
  2014. $this->io = new NullIO();
  2015. }
  2016. }
  2017. return $this->io;
  2018. }
  2019. public function setIO(IOInterface $io)
  2020. {
  2021. $this->io = $io;
  2022. }
  2023. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  2024. {
  2025. $definition = $this->getDefinition();
  2026. $name = (string) $input->getCompletionName();
  2027. if (CompletionInput::TYPE_OPTION_VALUE === $input->getCompletionType()
  2028. && $definition->hasOption($name)
  2029. && ($option = $definition->getOption($name)) instanceof InputOption
  2030. ) {
  2031. $option->complete($input, $suggestions);
  2032. } elseif (CompletionInput::TYPE_ARGUMENT_VALUE === $input->getCompletionType()
  2033. && $definition->hasArgument($name)
  2034. && ($argument = $definition->getArgument($name)) instanceof InputArgument
  2035. ) {
  2036. $argument->complete($input, $suggestions);
  2037. } else {
  2038. parent::complete($input, $suggestions);
  2039. }
  2040. }
  2041. protected function initialize(InputInterface $input, OutputInterface $output)
  2042. {
  2043. $disablePlugins = $input->hasParameterOption('--no-plugins');
  2044. $disableScripts = $input->hasParameterOption('--no-scripts');
  2045. if ($this instanceof SelfUpdateCommand) {
  2046. $disablePlugins = true;
  2047. $disableScripts = true;
  2048. }
  2049. $composer = $this->tryComposer($disablePlugins, $disableScripts);
  2050. $io = $this->getIO();
  2051. if (null === $composer) {
  2052. $composer = Factory::createGlobal($this->getIO(), $disablePlugins, $disableScripts);
  2053. }
  2054. if ($composer) {
  2055. $preCommandRunEvent = new PreCommandRunEvent(PluginEvents::PRE_COMMAND_RUN, $input, $this->getName());
  2056. $composer->getEventDispatcher()->dispatch($preCommandRunEvent->getName(), $preCommandRunEvent);
  2057. }
  2058. if (true === $input->hasParameterOption(['--no-ansi']) && $input->hasOption('no-progress')) {
  2059. $input->setOption('no-progress', true);
  2060. }
  2061. $envOptions = [
  2062. 'COMPOSER_NO_AUDIT' => ['no-audit'],
  2063. 'COMPOSER_NO_DEV' => ['no-dev', 'update-no-dev'],
  2064. 'COMPOSER_PREFER_STABLE' => ['prefer-stable'],
  2065. 'COMPOSER_PREFER_LOWEST' => ['prefer-lowest'],
  2066. ];
  2067. foreach ($envOptions as $envName => $optionNames) {
  2068. foreach ($optionNames as $optionName) {
  2069. if (true === $input->hasOption($optionName)) {
  2070. if (false === $input->getOption($optionName) && (bool) Platform::getEnv($envName)) {
  2071. $input->setOption($optionName, true);
  2072. }
  2073. }
  2074. }
  2075. }
  2076. if (true === $input->hasOption('ignore-platform-reqs')) {
  2077. if (!$input->getOption('ignore-platform-reqs') && (bool) Platform::getEnv('COMPOSER_IGNORE_PLATFORM_REQS')) {
  2078. $input->setOption('ignore-platform-reqs', true);
  2079. $io->writeError('<warning>COMPOSER_IGNORE_PLATFORM_REQS is set. You may experience unexpected errors.</warning>');
  2080. }
  2081. }
  2082. if (true === $input->hasOption('ignore-platform-req') && (!$input->hasOption('ignore-platform-reqs') || !$input->getOption('ignore-platform-reqs'))) {
  2083. $ignorePlatformReqEnv = Platform::getEnv('COMPOSER_IGNORE_PLATFORM_REQ');
  2084. if (0 === count($input->getOption('ignore-platform-req')) && is_string($ignorePlatformReqEnv) && '' !== $ignorePlatformReqEnv) {
  2085. $input->setOption('ignore-platform-req', explode(',', $ignorePlatformReqEnv));
  2086. $io->writeError('<warning>COMPOSER_IGNORE_PLATFORM_REQ is set to ignore '.$ignorePlatformReqEnv.'. You may experience unexpected errors.</warning>');
  2087. }
  2088. }
  2089. parent::initialize($input, $output);
  2090. }
  2091. protected function getPreferredInstallOptions(Config $config, InputInterface $input, bool $keepVcsRequiresPreferSource = false)
  2092. {
  2093. $preferSource = false;
  2094. $preferDist = false;
  2095. switch ($config->get('preferred-install')) {
  2096. case 'source':
  2097. $preferSource = true;
  2098. break;
  2099. case 'dist':
  2100. $preferDist = true;
  2101. break;
  2102. case 'auto':
  2103. default:
  2104. break;
  2105. }
  2106. if (!$input->hasOption('prefer-dist') || !$input->hasOption('prefer-source')) {
  2107. return [$preferSource, $preferDist];
  2108. }
  2109. if ($input->hasOption('prefer-install') && is_string($input->getOption('prefer-install'))) {
  2110. if ($input->getOption('prefer-source')) {
  2111. throw new \InvalidArgumentException('--prefer-source can not be used together with --prefer-install');
  2112. }
  2113. if ($input->getOption('prefer-dist')) {
  2114. throw new \InvalidArgumentException('--prefer-dist can not be used together with --prefer-install');
  2115. }
  2116. switch ($input->getOption('prefer-install')) {
  2117. case 'dist':
  2118. $input->setOption('prefer-dist', true);
  2119. break;
  2120. case 'source':
  2121. $input->setOption('prefer-source', true);
  2122. break;
  2123. case 'auto':
  2124. $preferDist = false;
  2125. $preferSource = false;
  2126. break;
  2127. default:
  2128. throw new \UnexpectedValueException('--prefer-install accepts one of "dist", "source" or "auto", got '.$input->getOption('prefer-install'));
  2129. }
  2130. }
  2131. if ($input->getOption('prefer-source') || $input->getOption('prefer-dist') || ($keepVcsRequiresPreferSource && $input->hasOption('keep-vcs') && $input->getOption('keep-vcs'))) {
  2132. $preferSource = $input->getOption('prefer-source') || ($keepVcsRequiresPreferSource && $input->hasOption('keep-vcs') && $input->getOption('keep-vcs'));
  2133. $preferDist = $input->getOption('prefer-dist');
  2134. }
  2135. return [$preferSource, $preferDist];
  2136. }
  2137. protected function getPlatformRequirementFilter(InputInterface $input): PlatformRequirementFilterInterface
  2138. {
  2139. if (!$input->hasOption('ignore-platform-reqs') || !$input->hasOption('ignore-platform-req')) {
  2140. throw new \LogicException('Calling getPlatformRequirementFilter from a command which does not define the --ignore-platform-req[s] flags is not permitted.');
  2141. }
  2142. if (true === $input->getOption('ignore-platform-reqs')) {
  2143. return PlatformRequirementFilterFactory::ignoreAll();
  2144. }
  2145. $ignores = $input->getOption('ignore-platform-req');
  2146. if (count($ignores) > 0) {
  2147. return PlatformRequirementFilterFactory::fromBoolOrList($ignores);
  2148. }
  2149. return PlatformRequirementFilterFactory::ignoreNothing();
  2150. }
  2151. protected function formatRequirements(array $requirements)
  2152. {
  2153. $requires = [];
  2154. $requirements = $this->normalizeRequirements($requirements);
  2155. foreach ($requirements as $requirement) {
  2156. if (!isset($requirement['version'])) {
  2157. throw new \UnexpectedValueException('Option '.$requirement['name'] .' is missing a version constraint, use e.g. '.$requirement['name'].':^1.0');
  2158. }
  2159. $requires[$requirement['name']] = $requirement['version'];
  2160. }
  2161. return $requires;
  2162. }
  2163. protected function normalizeRequirements(array $requirements)
  2164. {
  2165. $parser = new VersionParser();
  2166. return $parser->parseNameVersionPairs($requirements);
  2167. }
  2168. protected function renderTable(array $table, OutputInterface $output)
  2169. {
  2170. $renderer = new Table($output);
  2171. $renderer->setStyle('compact');
  2172. $renderer->setRows($table)->render();
  2173. }
  2174. protected function getTerminalWidth()
  2175. {
  2176. $terminal = new Terminal();
  2177. $width = $terminal->getWidth();
  2178. if (Platform::isWindows()) {
  2179. $width--;
  2180. } else {
  2181. $width = max(80, $width);
  2182. }
  2183. return $width;
  2184. }
  2185. protected function getAuditFormat(InputInterface $input, string $optName = 'audit-format'): string
  2186. {
  2187. if (!$input->hasOption($optName)) {
  2188. throw new \LogicException('This should not be called on a Command which has no '.$optName.' option defined.');
  2189. }
  2190. $val = $input->getOption($optName);
  2191. if (!in_array($val, Auditor::FORMATS, true)) {
  2192. throw new \InvalidArgumentException('--'.$optName.' must be one of '.implode(', ', Auditor::FORMATS).'.');
  2193. }
  2194. return $val;
  2195. }
  2196. }
  2197. <?php declare(strict_types=1);
  2198. namespace Composer\Command;
  2199. use Composer\Package\Link;
  2200. use Composer\Package\PackageInterface;
  2201. use Composer\Package\CompletePackageInterface;
  2202. use Composer\Package\RootPackage;
  2203. use Composer\Repository\InstalledArrayRepository;
  2204. use Composer\Repository\CompositeRepository;
  2205. use Composer\Repository\RootPackageRepository;
  2206. use Composer\Repository\InstalledRepository;
  2207. use Composer\Repository\PlatformRepository;
  2208. use Composer\Repository\RepositoryFactory;
  2209. use Composer\Plugin\CommandEvent;
  2210. use Composer\Plugin\PluginEvents;
  2211. use Symfony\Component\Console\Formatter\OutputFormatter;
  2212. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  2213. use Composer\Package\Version\VersionParser;
  2214. use Symfony\Component\Console\Input\InputInterface;
  2215. use Symfony\Component\Console\Output\OutputInterface;
  2216. use Composer\Util\PackageInfo;
  2217. abstract class BaseDependencyCommand extends BaseCommand
  2218. {
  2219. protected const ARGUMENT_PACKAGE = 'package';
  2220. protected const ARGUMENT_CONSTRAINT = 'version';
  2221. protected const OPTION_RECURSIVE = 'recursive';
  2222. protected const OPTION_TREE = 'tree';
  2223. protected $colors;
  2224. protected function doExecute(InputInterface $input, OutputInterface $output, bool $inverted = false): int
  2225. {
  2226. $composer = $this->requireComposer();
  2227. $commandEvent = new CommandEvent(PluginEvents::COMMAND, $this->getName(), $input, $output);
  2228. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  2229. $repos = [];
  2230. $repos[] = new RootPackageRepository(clone $composer->getPackage());
  2231. if ($input->getOption('locked')) {
  2232. $locker = $composer->getLocker();
  2233. if (!$locker->isLocked()) {
  2234. throw new \UnexpectedValueException('A valid composer.lock file is required to run this command with --locked');
  2235. }
  2236. $repos[] = $locker->getLockedRepository(true);
  2237. $repos[] = new PlatformRepository([], $locker->getPlatformOverrides());
  2238. } else {
  2239. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  2240. $rootPkg = $composer->getPackage();
  2241. if (count($localRepo->getPackages()) === 0 && (count($rootPkg->getRequires()) > 0 || count($rootPkg->getDevRequires()) > 0)) {
  2242. $output->writeln('<warning>No dependencies installed. Try running composer install or update, or use --locked.</warning>');
  2243. return 1;
  2244. }
  2245. $repos[] = $localRepo;
  2246. $platformOverrides = $composer->getConfig()->get('platform') ?: [];
  2247. $repos[] = new PlatformRepository([], $platformOverrides);
  2248. }
  2249. $installedRepo = new InstalledRepository($repos);
  2250. $needle = $input->getArgument(self::ARGUMENT_PACKAGE);
  2251. $textConstraint = $input->hasArgument(self::ARGUMENT_CONSTRAINT) ? $input->getArgument(self::ARGUMENT_CONSTRAINT) : '*';
  2252. $packages = $installedRepo->findPackagesWithReplacersAndProviders($needle);
  2253. if (empty($packages)) {
  2254. throw new \InvalidArgumentException(sprintf('Could not find package "%s" in your project', $needle));
  2255. }
  2256. if (!$installedRepo->findPackage($needle, $textConstraint)) {
  2257. $defaultRepos = new CompositeRepository(RepositoryFactory::defaultRepos($this->getIO(), $composer->getConfig(), $composer->getRepositoryManager()));
  2258. if ($match = $defaultRepos->findPackage($needle, $textConstraint)) {
  2259. $installedRepo->addRepository(new InstalledArrayRepository([clone $match]));
  2260. } else {
  2261. $this->getIO()->writeError('<error>Package "'.$needle.'" could not be found with constraint "'.$textConstraint.'", results below will most likely be incomplete.</error>');
  2262. }
  2263. }
  2264. $needles = [$needle];
  2265. if ($inverted) {
  2266. foreach ($packages as $package) {
  2267. $needles = array_merge($needles, array_map(static function (Link $link): string {
  2268. return $link->getTarget();
  2269. }, $package->getReplaces()));
  2270. }
  2271. }
  2272. if ('*' !== $textConstraint) {
  2273. $versionParser = new VersionParser();
  2274. $constraint = $versionParser->parseConstraints($textConstraint);
  2275. } else {
  2276. $constraint = null;
  2277. }
  2278. $renderTree = $input->getOption(self::OPTION_TREE);
  2279. $recursive = $renderTree || $input->getOption(self::OPTION_RECURSIVE);
  2280. $results = $installedRepo->getDependents($needles, $constraint, $inverted, $recursive);
  2281. if (empty($results)) {
  2282. $extra = (null !== $constraint) ? sprintf(' in versions %smatching %s', $inverted ? 'not ' : '', $textConstraint) : '';
  2283. $this->getIO()->writeError(sprintf(
  2284. '<info>There is no installed package depending on "%s"%s</info>',
  2285. $needle,
  2286. $extra
  2287. ));
  2288. } elseif ($renderTree) {
  2289. $this->initStyles($output);
  2290. $root = $packages[0];
  2291. $this->getIO()->write(sprintf('<info>%s</info> %s %s', $root->getPrettyName(), $root->getPrettyVersion(), $root instanceof CompletePackageInterface ? $root->getDescription() : ''));
  2292. $this->printTree($results);
  2293. } else {
  2294. $this->printTable($output, $results);
  2295. }
  2296. if ($inverted && $input->hasArgument(self::ARGUMENT_CONSTRAINT)) {
  2297. $composerCommand = 'update';
  2298. foreach ($composer->getPackage()->getRequires() as $rootRequirement) {
  2299. if ($rootRequirement->getTarget() === $needle) {
  2300. $composerCommand = 'require';
  2301. break;
  2302. }
  2303. }
  2304. foreach ($composer->getPackage()->getDevRequires() as $rootRequirement) {
  2305. if ($rootRequirement->getTarget() === $needle) {
  2306. $composerCommand = 'require --dev';
  2307. break;
  2308. }
  2309. }
  2310. $this->getIO()->writeError('Not finding what you were looking for? Try calling `composer '.$composerCommand.' "'.$needle.':'.$textConstraint.'" --dry-run` to get another view on the problem.');
  2311. }
  2312. return 0;
  2313. }
  2314. protected function printTable(OutputInterface $output, $results): void
  2315. {
  2316. $table = [];
  2317. $doubles = [];
  2318. do {
  2319. $queue = [];
  2320. $rows = [];
  2321. foreach ($results as $result) {
  2322. [$package, $link, $children] = $result;
  2323. $unique = (string) $link;
  2324. if (isset($doubles[$unique])) {
  2325. continue;
  2326. }
  2327. $doubles[$unique] = true;
  2328. $version = $package->getPrettyVersion() === RootPackage::DEFAULT_PRETTY_VERSION ? '-' : $package->getPrettyVersion();
  2329. $packageUrl = PackageInfo::getViewSourceOrHomepageUrl($package);
  2330. $nameWithLink = $packageUrl !== null ? '<href=' . OutputFormatter::escape($packageUrl) . '>' . $package->getPrettyName() . '</>' : $package->getPrettyName();
  2331. $rows[] = [$nameWithLink, $version, $link->getDescription(), sprintf('%s (%s)', $link->getTarget(), $link->getPrettyConstraint())];
  2332. if ($children) {
  2333. $queue = array_merge($queue, $children);
  2334. }
  2335. }
  2336. $results = $queue;
  2337. $table = array_merge($rows, $table);
  2338. } while (!empty($results));
  2339. $this->renderTable($table, $output);
  2340. }
  2341. protected function initStyles(OutputInterface $output): void
  2342. {
  2343. $this->colors = [
  2344. 'green',
  2345. 'yellow',
  2346. 'cyan',
  2347. 'magenta',
  2348. 'blue',
  2349. ];
  2350. foreach ($this->colors as $color) {
  2351. $style = new OutputFormatterStyle($color);
  2352. $output->getFormatter()->setStyle($color, $style);
  2353. }
  2354. }
  2355. protected function printTree(array $results, string $prefix = '', int $level = 1): void
  2356. {
  2357. $count = count($results);
  2358. $idx = 0;
  2359. foreach ($results as $result) {
  2360. [$package, $link, $children] = $result;
  2361. $color = $this->colors[$level % count($this->colors)];
  2362. $prevColor = $this->colors[($level - 1) % count($this->colors)];
  2363. $isLast = (++$idx === $count);
  2364. $versionText = $package->getPrettyVersion() === RootPackage::DEFAULT_PRETTY_VERSION ? '' : $package->getPrettyVersion();
  2365. $packageUrl = PackageInfo::getViewSourceOrHomepageUrl($package);
  2366. $nameWithLink = $packageUrl !== null ? '<href=' . OutputFormatter::escape($packageUrl) . '>' . $package->getPrettyName() . '</>' : $package->getPrettyName();
  2367. $packageText = rtrim(sprintf('<%s>%s</%1$s> %s', $color, $nameWithLink, $versionText));
  2368. $linkText = sprintf('%s <%s>%s</%2$s> %s', $link->getDescription(), $prevColor, $link->getTarget(), $link->getPrettyConstraint());
  2369. $circularWarn = $children === false ? '(circular dependency aborted here)' : '';
  2370. $this->writeTreeLine(rtrim(sprintf("%s%s%s (%s) %s", $prefix, $isLast ? '└──' : '├──', $packageText, $linkText, $circularWarn)));
  2371. if ($children) {
  2372. $this->printTree($children, $prefix . ($isLast ? ' ' : '│ '), $level + 1);
  2373. }
  2374. }
  2375. }
  2376. private function writeTreeLine(string $line): void
  2377. {
  2378. $io = $this->getIO();
  2379. if (!$io->isDecorated()) {
  2380. $line = str_replace(['└', '├', '──', '│'], ['`-', '|-', '-', '|'], $line);
  2381. }
  2382. $io->write($line);
  2383. }
  2384. }
  2385. <?php declare(strict_types=1);
  2386. namespace Composer\Command;
  2387. use Composer\Package\AliasPackage;
  2388. use Composer\Package\BasePackage;
  2389. use Composer\Package\Locker;
  2390. use Composer\Package\Version\VersionBumper;
  2391. use Composer\Pcre\Preg;
  2392. use Composer\Util\Filesystem;
  2393. use Symfony\Component\Console\Input\InputInterface;
  2394. use Composer\Console\Input\InputArgument;
  2395. use Composer\Console\Input\InputOption;
  2396. use Symfony\Component\Console\Output\OutputInterface;
  2397. use Composer\Factory;
  2398. use Composer\Json\JsonFile;
  2399. use Composer\Json\JsonManipulator;
  2400. use Composer\Repository\PlatformRepository;
  2401. use Composer\Util\Silencer;
  2402. final class BumpCommand extends BaseCommand
  2403. {
  2404. private const ERROR_GENERIC = 1;
  2405. private const ERROR_LOCK_OUTDATED = 2;
  2406. use CompletionTrait;
  2407. protected function configure(): void
  2408. {
  2409. $this
  2410. ->setName('bump')
  2411. ->setDescription('Increases the lower limit of your composer.json requirements to the currently installed versions')
  2412. ->setDefinition([
  2413. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Optional package name(s) to restrict which packages are bumped.', null, $this->suggestRootRequirement()),
  2414. new InputOption('dev-only', 'D', InputOption::VALUE_NONE, 'Only bump requirements in "require-dev".'),
  2415. new InputOption('no-dev-only', 'R', InputOption::VALUE_NONE, 'Only bump requirements in "require".'),
  2416. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the packages to bump, but will not execute anything.'),
  2417. ])
  2418. ->setHelp(
  2419. <<<EOT
  2420. The <info>bump</info> command increases the lower limit of your composer.json requirements
  2421. to the currently installed versions. This helps to ensure your dependencies do not
  2422. accidentally get downgraded due to some other conflict, and can slightly improve
  2423. dependency resolution performance as it limits the amount of package versions
  2424. Composer has to look at.
  2425. Running this blindly on libraries is **NOT** recommended as it will narrow down
  2426. your allowed dependencies, which may cause dependency hell for your users.
  2427. Running it with <info>--dev-only</info> on libraries may be fine however as dev requirements
  2428. are local to the library and do not affect consumers of the package.
  2429. EOT
  2430. )
  2431. ;
  2432. }
  2433. protected function execute(InputInterface $input, OutputInterface $output)
  2434. {
  2435. $composerJsonPath = Factory::getComposerFile();
  2436. $io = $this->getIO();
  2437. if (!Filesystem::isReadable($composerJsonPath)) {
  2438. $io->writeError('<error>'.$composerJsonPath.' is not readable.</error>');
  2439. return self::ERROR_GENERIC;
  2440. }
  2441. $composerJson = new JsonFile($composerJsonPath);
  2442. $contents = file_get_contents($composerJson->getPath());
  2443. if (false === $contents) {
  2444. $io->writeError('<error>'.$composerJsonPath.' is not readable.</error>');
  2445. return self::ERROR_GENERIC;
  2446. }
  2447. if (!is_writable($composerJsonPath) && false === Silencer::call('file_put_contents', $composerJsonPath, $contents)) {
  2448. $io->writeError('<error>'.$composerJsonPath.' is not writable.</error>');
  2449. return self::ERROR_GENERIC;
  2450. }
  2451. unset($contents);
  2452. $composer = $this->requireComposer();
  2453. if ($composer->getLocker()->isLocked()) {
  2454. if (!$composer->getLocker()->isFresh()) {
  2455. $io->writeError('<error>The lock file is not up to date with the latest changes in composer.json. Run the appropriate `update` to fix that before you use the `bump` command.</error>');
  2456. return self::ERROR_LOCK_OUTDATED;
  2457. }
  2458. $repo = $composer->getLocker()->getLockedRepository(true);
  2459. } else {
  2460. $repo = $composer->getRepositoryManager()->getLocalRepository();
  2461. }
  2462. if ($composer->getPackage()->getType() !== 'project' && !$input->getOption('dev-only')) {
  2463. $io->writeError('<warning>Warning: Bumping dependency constraints is not recommended for libraries as it will narrow down your dependencies and may cause problems for your users.</warning>');
  2464. $contents = $composerJson->read();
  2465. if (!isset($contents['type'])) {
  2466. $io->writeError('<warning>If your package is not a library, you can explicitly specify the "type" by using "composer config type project".</warning>');
  2467. $io->writeError('<warning>Alternatively you can use --dev-only to only bump dependencies within "require-dev".</warning>');
  2468. }
  2469. unset($contents);
  2470. }
  2471. $bumper = new VersionBumper();
  2472. $tasks = [];
  2473. if (!$input->getOption('dev-only')) {
  2474. $tasks['require'] = $composer->getPackage()->getRequires();
  2475. }
  2476. if (!$input->getOption('no-dev-only')) {
  2477. $tasks['require-dev'] = $composer->getPackage()->getDevRequires();
  2478. }
  2479. $packagesFilter = $input->getArgument('packages');
  2480. if (count($packagesFilter) > 0) {
  2481. $pattern = BasePackage::packageNamesToRegexp(array_unique(array_map('strtolower', $packagesFilter)));
  2482. foreach ($tasks as $key => $reqs) {
  2483. foreach ($reqs as $pkgName => $link) {
  2484. if (!Preg::isMatch($pattern, $pkgName)) {
  2485. unset($tasks[$key][$pkgName]);
  2486. }
  2487. }
  2488. }
  2489. }
  2490. $updates = [];
  2491. foreach ($tasks as $key => $reqs) {
  2492. foreach ($reqs as $pkgName => $link) {
  2493. if (PlatformRepository::isPlatformPackage($pkgName)) {
  2494. continue;
  2495. }
  2496. $currentConstraint = $link->getPrettyConstraint();
  2497. $package = $repo->findPackage($pkgName, '*');
  2498. if (null === $package) {
  2499. continue;
  2500. }
  2501. while ($package instanceof AliasPackage) {
  2502. $package = $package->getAliasOf();
  2503. }
  2504. $bumped = $bumper->bumpRequirement($link->getConstraint(), $package);
  2505. if ($bumped === $currentConstraint) {
  2506. continue;
  2507. }
  2508. $updates[$key][$pkgName] = $bumped;
  2509. }
  2510. }
  2511. $dryRun = $input->getOption('dry-run');
  2512. if (!$dryRun && !$this->updateFileCleanly($composerJson, $updates)) {
  2513. $composerDefinition = $composerJson->read();
  2514. foreach ($updates as $key => $packages) {
  2515. foreach ($packages as $package => $version) {
  2516. $composerDefinition[$key][$package] = $version;
  2517. }
  2518. }
  2519. $composerJson->write($composerDefinition);
  2520. }
  2521. $changeCount = array_sum(array_map('count', $updates));
  2522. if ($changeCount > 0) {
  2523. if ($dryRun) {
  2524. $io->write('<info>' . $composerJsonPath . ' would be updated with:</info>');
  2525. foreach ($updates as $requireType => $packages) {
  2526. foreach ($packages as $package => $version) {
  2527. $io->write(sprintf('<info> - %s.%s: %s</info>', $requireType, $package, $version));
  2528. }
  2529. }
  2530. } else {
  2531. $io->write('<info>' . $composerJsonPath . ' has been updated (' . $changeCount . ' changes).</info>');
  2532. }
  2533. } else {
  2534. $io->write('<info>No requirements to update in '.$composerJsonPath.'.</info>');
  2535. }
  2536. if (!$dryRun && $composer->getLocker()->isLocked() && $changeCount > 0) {
  2537. $contents = file_get_contents($composerJson->getPath());
  2538. if (false === $contents) {
  2539. throw new \RuntimeException('Unable to read '.$composerJson->getPath().' contents to update the lock file hash.');
  2540. }
  2541. $lock = new JsonFile(Factory::getLockFile($composerJsonPath));
  2542. $lockData = $lock->read();
  2543. $lockData['content-hash'] = Locker::getContentHash($contents);
  2544. $lock->write($lockData);
  2545. }
  2546. if ($dryRun && $changeCount > 0) {
  2547. return self::ERROR_GENERIC;
  2548. }
  2549. return 0;
  2550. }
  2551. private function updateFileCleanly(JsonFile $json, array $updates): bool
  2552. {
  2553. $contents = file_get_contents($json->getPath());
  2554. if (false === $contents) {
  2555. throw new \RuntimeException('Unable to read '.$json->getPath().' contents.');
  2556. }
  2557. $manipulator = new JsonManipulator($contents);
  2558. foreach ($updates as $key => $packages) {
  2559. foreach ($packages as $package => $version) {
  2560. if (!$manipulator->addLink($key, $package, $version)) {
  2561. return false;
  2562. }
  2563. }
  2564. }
  2565. if (false === file_put_contents($json->getPath(), $manipulator->getContents())) {
  2566. throw new \RuntimeException('Unable to write new '.$json->getPath().' contents.');
  2567. }
  2568. return true;
  2569. }
  2570. }
  2571. <?php declare(strict_types=1);
  2572. namespace Composer\Command;
  2573. use Composer\Package\Link;
  2574. use Composer\Semver\Constraint\Constraint;
  2575. use Symfony\Component\Console\Input\InputInterface;
  2576. use Composer\Console\Input\InputOption;
  2577. use Symfony\Component\Console\Output\OutputInterface;
  2578. use Composer\Repository\PlatformRepository;
  2579. use Composer\Repository\RootPackageRepository;
  2580. use Composer\Repository\InstalledRepository;
  2581. use Composer\Json\JsonFile;
  2582. class CheckPlatformReqsCommand extends BaseCommand
  2583. {
  2584. protected function configure(): void
  2585. {
  2586. $this->setName('check-platform-reqs')
  2587. ->setDescription('Check that platform requirements are satisfied')
  2588. ->setDefinition([
  2589. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables checking of require-dev packages requirements.'),
  2590. new InputOption('lock', null, InputOption::VALUE_NONE, 'Checks requirements only from the lock file, not from installed packages.'),
  2591. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text', ['json', 'text']),
  2592. ])
  2593. ->setHelp(
  2594. <<<EOT
  2595. Checks that your PHP and extensions versions match the platform requirements of the installed packages.
  2596. 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.
  2597. <info>php composer.phar check-platform-reqs</info>
  2598. EOT
  2599. );
  2600. }
  2601. protected function execute(InputInterface $input, OutputInterface $output): int
  2602. {
  2603. $composer = $this->requireComposer();
  2604. $requires = [];
  2605. $removePackages = [];
  2606. if ($input->getOption('lock')) {
  2607. $this->getIO()->writeError('<info>Checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements using the lock file</info>');
  2608. $installedRepo = $composer->getLocker()->getLockedRepository(!$input->getOption('no-dev'));
  2609. } else {
  2610. $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
  2611. if (!$installedRepo->getPackages()) {
  2612. $this->getIO()->writeError('<warning>No vendor dir present, checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements from the lock file</warning>');
  2613. $installedRepo = $composer->getLocker()->getLockedRepository(!$input->getOption('no-dev'));
  2614. } else {
  2615. if ($input->getOption('no-dev')) {
  2616. $removePackages = $installedRepo->getDevPackageNames();
  2617. }
  2618. $this->getIO()->writeError('<info>Checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements for packages in the vendor dir</info>');
  2619. }
  2620. }
  2621. if (!$input->getOption('no-dev')) {
  2622. foreach ($composer->getPackage()->getDevRequires() as $require => $link) {
  2623. $requires[$require] = [$link];
  2624. }
  2625. }
  2626. $installedRepo = new InstalledRepository([$installedRepo, new RootPackageRepository(clone $composer->getPackage())]);
  2627. foreach ($installedRepo->getPackages() as $package) {
  2628. if (in_array($package->getName(), $removePackages, true)) {
  2629. continue;
  2630. }
  2631. foreach ($package->getRequires() as $require => $link) {
  2632. $requires[$require][] = $link;
  2633. }
  2634. }
  2635. ksort($requires);
  2636. $installedRepo->addRepository(new PlatformRepository([], []));
  2637. $results = [];
  2638. $exitCode = 0;
  2639. foreach ($requires as $require => $links) {
  2640. if (PlatformRepository::isPlatformPackage($require)) {
  2641. $candidates = $installedRepo->findPackagesWithReplacersAndProviders($require);
  2642. if ($candidates) {
  2643. $reqResults = [];
  2644. foreach ($candidates as $candidate) {
  2645. $candidateConstraint = null;
  2646. if ($candidate->getName() === $require) {
  2647. $candidateConstraint = new Constraint('=', $candidate->getVersion());
  2648. $candidateConstraint->setPrettyString($candidate->getPrettyVersion());
  2649. } else {
  2650. foreach (array_merge($candidate->getProvides(), $candidate->getReplaces()) as $link) {
  2651. if ($link->getTarget() === $require) {
  2652. $candidateConstraint = $link->getConstraint();
  2653. break;
  2654. }
  2655. }
  2656. }
  2657. if (!$candidateConstraint) {
  2658. continue;
  2659. }
  2660. foreach ($links as $link) {
  2661. if (!$link->getConstraint()->matches($candidateConstraint)) {
  2662. $reqResults[] = [
  2663. $candidate->getName() === $require ? $candidate->getPrettyName() : $require,
  2664. $candidateConstraint->getPrettyString(),
  2665. $link,
  2666. '<error>failed</error>',
  2667. $candidate->getName() === $require ? '' : '<comment>provided by '.$candidate->getPrettyName().'</comment>',
  2668. ];
  2669. continue 2;
  2670. }
  2671. }
  2672. $results[] = [
  2673. $candidate->getName() === $require ? $candidate->getPrettyName() : $require,
  2674. $candidateConstraint->getPrettyString(),
  2675. null,
  2676. '<info>success</info>',
  2677. $candidate->getName() === $require ? '' : '<comment>provided by '.$candidate->getPrettyName().'</comment>',
  2678. ];
  2679. continue 2;
  2680. }
  2681. $results = array_merge($results, $reqResults);
  2682. $exitCode = max($exitCode, 1);
  2683. continue;
  2684. }
  2685. $results[] = [
  2686. $require,
  2687. 'n/a',
  2688. $links[0],
  2689. '<error>missing</error>',
  2690. '',
  2691. ];
  2692. $exitCode = max($exitCode, 2);
  2693. }
  2694. }
  2695. $this->printTable($output, $results, $input->getOption('format'));
  2696. return $exitCode;
  2697. }
  2698. protected function printTable(OutputInterface $output, array $results, string $format): void
  2699. {
  2700. $rows = [];
  2701. foreach ($results as $result) {
  2702. [$platformPackage, $version, $link, $status, $provider] = $result;
  2703. if ('json' === $format) {
  2704. $rows[] = [
  2705. "name" => $platformPackage,
  2706. "version" => $version,
  2707. "status" => strip_tags($status),
  2708. "failed_requirement" => $link instanceof Link ? [
  2709. 'source' => $link->getSource(),
  2710. 'type' => $link->getDescription(),
  2711. 'target' => $link->getTarget(),
  2712. 'constraint' => $link->getPrettyConstraint(),
  2713. ] : null,
  2714. "provider" => $provider === '' ? null : strip_tags($provider),
  2715. ];
  2716. } else {
  2717. $rows[] = [
  2718. $platformPackage,
  2719. $version,
  2720. $link,
  2721. $link ? sprintf('%s %s %s (%s)', $link->getSource(), $link->getDescription(), $link->getTarget(), $link->getPrettyConstraint()) : '',
  2722. rtrim($status.' '.$provider),
  2723. ];
  2724. }
  2725. }
  2726. if ('json' === $format) {
  2727. $this->getIO()->write(JsonFile::encode($rows));
  2728. } else {
  2729. $this->renderTable($rows, $output);
  2730. }
  2731. }
  2732. }
  2733. <?php declare(strict_types=1);
  2734. namespace Composer\Command;
  2735. use Composer\Cache;
  2736. use Composer\Factory;
  2737. use Symfony\Component\Console\Input\InputInterface;
  2738. use Symfony\Component\Console\Input\InputOption;
  2739. use Symfony\Component\Console\Output\OutputInterface;
  2740. class ClearCacheCommand extends BaseCommand
  2741. {
  2742. protected function configure(): void
  2743. {
  2744. $this
  2745. ->setName('clear-cache')
  2746. ->setAliases(['clearcache', 'cc'])
  2747. ->setDescription('Clears composer\'s internal package cache')
  2748. ->setDefinition([
  2749. new InputOption('gc', null, InputOption::VALUE_NONE, 'Only run garbage collection, not a full cache clear'),
  2750. ])
  2751. ->setHelp(
  2752. <<<EOT
  2753. The <info>clear-cache</info> deletes all cached packages from composer's
  2754. cache directory.
  2755. Read more at https://getcomposer.org/doc/03-cli.md#clear-cache-clearcache-cc
  2756. EOT
  2757. )
  2758. ;
  2759. }
  2760. protected function execute(InputInterface $input, OutputInterface $output): int
  2761. {
  2762. $config = Factory::createConfig();
  2763. $io = $this->getIO();
  2764. $cachePaths = [
  2765. 'cache-vcs-dir' => $config->get('cache-vcs-dir'),
  2766. 'cache-repo-dir' => $config->get('cache-repo-dir'),
  2767. 'cache-files-dir' => $config->get('cache-files-dir'),
  2768. 'cache-dir' => $config->get('cache-dir'),
  2769. ];
  2770. foreach ($cachePaths as $key => $cachePath) {
  2771. if ($key === 'cache-dir' && $input->getOption('gc')) {
  2772. continue;
  2773. }
  2774. $cachePath = realpath($cachePath);
  2775. if (!$cachePath) {
  2776. $io->writeError("<info>Cache directory does not exist ($key): $cachePath</info>");
  2777. continue;
  2778. }
  2779. $cache = new Cache($io, $cachePath);
  2780. $cache->setReadOnly($config->get('cache-read-only'));
  2781. if (!$cache->isEnabled()) {
  2782. $io->writeError("<info>Cache is not enabled ($key): $cachePath</info>");
  2783. continue;
  2784. }
  2785. if ($input->getOption('gc')) {
  2786. $io->writeError("<info>Garbage-collecting cache ($key): $cachePath</info>");
  2787. if ($key === 'cache-files-dir') {
  2788. $cache->gc($config->get('cache-files-ttl'), $config->get('cache-files-maxsize'));
  2789. } elseif ($key === 'cache-repo-dir') {
  2790. $cache->gc($config->get('cache-ttl'), 1024 * 1024 * 1024 );
  2791. } elseif ($key === 'cache-vcs-dir') {
  2792. $cache->gcVcsCache($config->get('cache-ttl'));
  2793. }
  2794. } else {
  2795. $io->writeError("<info>Clearing cache ($key): $cachePath</info>");
  2796. $cache->clear();
  2797. }
  2798. }
  2799. if ($input->getOption('gc')) {
  2800. $io->writeError('<info>All caches garbage-collected.</info>');
  2801. } else {
  2802. $io->writeError('<info>All caches cleared.</info>');
  2803. }
  2804. return 0;
  2805. }
  2806. }
  2807. <?php declare(strict_types=1);
  2808. namespace Composer\Command;
  2809. use Composer\Composer;
  2810. use Composer\Package\BasePackage;
  2811. use Composer\Package\PackageInterface;
  2812. use Composer\Pcre\Preg;
  2813. use Composer\Repository\CompositeRepository;
  2814. use Composer\Repository\InstalledRepository;
  2815. use Composer\Repository\PlatformRepository;
  2816. use Composer\Repository\RepositoryInterface;
  2817. use Composer\Repository\RootPackageRepository;
  2818. use Symfony\Component\Console\Completion\CompletionInput;
  2819. trait CompletionTrait
  2820. {
  2821. abstract public function requireComposer(?bool $disablePlugins = null, ?bool $disableScripts = null): Composer;
  2822. private function suggestPreferInstall(): array
  2823. {
  2824. return ['dist', 'source', 'auto'];
  2825. }
  2826. private function suggestRootRequirement(): \Closure
  2827. {
  2828. return function (CompletionInput $input): array {
  2829. $composer = $this->requireComposer();
  2830. return array_merge(array_keys($composer->getPackage()->getRequires()), array_keys($composer->getPackage()->getDevRequires()));
  2831. };
  2832. }
  2833. private function suggestInstalledPackage(bool $includeRootPackage = true, bool $includePlatformPackages = false): \Closure
  2834. {
  2835. return function (CompletionInput $input) use ($includeRootPackage, $includePlatformPackages): array {
  2836. $composer = $this->requireComposer();
  2837. $installedRepos = [];
  2838. if ($includeRootPackage) {
  2839. $installedRepos[] = new RootPackageRepository(clone $composer->getPackage());
  2840. }
  2841. $locker = $composer->getLocker();
  2842. if ($locker->isLocked()) {
  2843. $installedRepos[] = $locker->getLockedRepository(true);
  2844. } else {
  2845. $installedRepos[] = $composer->getRepositoryManager()->getLocalRepository();
  2846. }
  2847. $platformHint = [];
  2848. if ($includePlatformPackages) {
  2849. if ($locker->isLocked()) {
  2850. $platformRepo = new PlatformRepository([], $locker->getPlatformOverrides());
  2851. } else {
  2852. $platformRepo = new PlatformRepository([], $composer->getConfig()->get('platform'));
  2853. }
  2854. if ($input->getCompletionValue() === '') {
  2855. $hintsToFind = ['ext-' => 0, 'lib-' => 0, 'php' => 99, 'composer' => 99];
  2856. foreach ($platformRepo->getPackages() as $pkg) {
  2857. foreach ($hintsToFind as $hintPrefix => $hintCount) {
  2858. if (str_starts_with($pkg->getName(), $hintPrefix)) {
  2859. if ($hintCount === 0 || $hintCount >= 99) {
  2860. $platformHint[] = $pkg->getName();
  2861. $hintsToFind[$hintPrefix]++;
  2862. } elseif ($hintCount === 1) {
  2863. unset($hintsToFind[$hintPrefix]);
  2864. $platformHint[] = substr($pkg->getName(), 0, max(strlen($pkg->getName()) - 3, strlen($hintPrefix) + 1)).'...';
  2865. }
  2866. continue 2;
  2867. }
  2868. }
  2869. }
  2870. } else {
  2871. $installedRepos[] = $platformRepo;
  2872. }
  2873. }
  2874. $installedRepo = new InstalledRepository($installedRepos);
  2875. return array_merge(
  2876. array_map(static function (PackageInterface $package) {
  2877. return $package->getName();
  2878. }, $installedRepo->getPackages()),
  2879. $platformHint
  2880. );
  2881. };
  2882. }
  2883. private function suggestAvailablePackage(int $max = 99): \Closure
  2884. {
  2885. return function (CompletionInput $input) use ($max): array {
  2886. if ($max < 1) {
  2887. return [];
  2888. }
  2889. $composer = $this->requireComposer();
  2890. $repos = new CompositeRepository($composer->getRepositoryManager()->getRepositories());
  2891. $results = [];
  2892. $showVendors = false;
  2893. if (!str_contains($input->getCompletionValue(), '/')) {
  2894. $results = $repos->search('^' . preg_quote($input->getCompletionValue()), RepositoryInterface::SEARCH_VENDOR);
  2895. $showVendors = true;
  2896. }
  2897. if (\count($results) <= 1) {
  2898. $results = $repos->search('^'.preg_quote($input->getCompletionValue()), RepositoryInterface::SEARCH_NAME);
  2899. $showVendors = false;
  2900. }
  2901. $results = array_column($results, 'name');
  2902. if ($showVendors) {
  2903. $results = array_map(static function (string $name): string {
  2904. return $name.'/';
  2905. }, $results);
  2906. usort($results, static function (string $a, string $b) {
  2907. $lenA = \strlen($a);
  2908. $lenB = \strlen($b);
  2909. if ($lenA === $lenB) {
  2910. return $a <=> $b;
  2911. }
  2912. return $lenA - $lenB;
  2913. });
  2914. $pinned = [];
  2915. $completionInput = $input->getCompletionValue().'/';
  2916. if (false !== ($exactIndex = array_search($completionInput, $results, true))) {
  2917. $pinned[] = $completionInput;
  2918. array_splice($results, $exactIndex, 1);
  2919. }
  2920. return array_merge($pinned, array_slice($results, 0, $max - \count($pinned)));
  2921. }
  2922. return array_slice($results, 0, $max);
  2923. };
  2924. }
  2925. private function suggestAvailablePackageInclPlatform(): \Closure
  2926. {
  2927. return function (CompletionInput $input): array {
  2928. if (Preg::isMatch('{^(ext|lib|php)(-|$)|^com}', $input->getCompletionValue())) {
  2929. $matches = $this->suggestPlatformPackage()($input);
  2930. } else {
  2931. $matches = [];
  2932. }
  2933. return array_merge($matches, $this->suggestAvailablePackage(99 - \count($matches))($input));
  2934. };
  2935. }
  2936. private function suggestPlatformPackage(): \Closure
  2937. {
  2938. return function (CompletionInput $input): array {
  2939. $repos = new PlatformRepository([], $this->requireComposer()->getConfig()->get('platform'));
  2940. $pattern = BasePackage::packageNameToRegexp($input->getCompletionValue().'*');
  2941. return array_filter(array_map(static function (PackageInterface $package) {
  2942. return $package->getName();
  2943. }, $repos->getPackages()), static function (string $name) use ($pattern): bool {
  2944. return Preg::isMatch($pattern, $name);
  2945. });
  2946. };
  2947. }
  2948. }
  2949. <?php declare(strict_types=1);
  2950. namespace Composer\Command;
  2951. use Composer\Advisory\Auditor;
  2952. use Composer\Pcre\Preg;
  2953. use Composer\Util\Filesystem;
  2954. use Composer\Util\Platform;
  2955. use Composer\Util\Silencer;
  2956. use Symfony\Component\Console\Input\InputInterface;
  2957. use Composer\Console\Input\InputArgument;
  2958. use Symfony\Component\Console\Completion\CompletionInput;
  2959. use Symfony\Component\Console\Input\InputOption;
  2960. use Symfony\Component\Console\Output\OutputInterface;
  2961. use Composer\Config;
  2962. use Composer\Config\JsonConfigSource;
  2963. use Composer\Factory;
  2964. use Composer\IO\IOInterface;
  2965. use Composer\Json\JsonFile;
  2966. use Composer\Semver\VersionParser;
  2967. use Composer\Package\BasePackage;
  2968. class ConfigCommand extends BaseCommand
  2969. {
  2970. protected const CONFIGURABLE_PACKAGE_PROPERTIES = [
  2971. 'name',
  2972. 'type',
  2973. 'description',
  2974. 'homepage',
  2975. 'version',
  2976. 'minimum-stability',
  2977. 'prefer-stable',
  2978. 'keywords',
  2979. 'license',
  2980. 'repositories',
  2981. 'suggest',
  2982. 'extra',
  2983. ];
  2984. protected $config;
  2985. protected $configFile;
  2986. protected $configSource;
  2987. protected $authConfigFile;
  2988. protected $authConfigSource;
  2989. protected function configure(): void
  2990. {
  2991. $this
  2992. ->setName('config')
  2993. ->setDescription('Sets config options')
  2994. ->setDefinition([
  2995. new InputOption('global', 'g', InputOption::VALUE_NONE, 'Apply command to the global config file'),
  2996. new InputOption('editor', 'e', InputOption::VALUE_NONE, 'Open editor'),
  2997. new InputOption('auth', 'a', InputOption::VALUE_NONE, 'Affect auth config file (only used for --editor)'),
  2998. new InputOption('unset', null, InputOption::VALUE_NONE, 'Unset the given setting-key'),
  2999. new InputOption('list', 'l', InputOption::VALUE_NONE, 'List configuration settings'),
  3000. new InputOption('file', 'f', InputOption::VALUE_REQUIRED, 'If you want to choose a different composer.json or config.json'),
  3001. new InputOption('absolute', null, InputOption::VALUE_NONE, 'Returns absolute paths when fetching *-dir config values instead of relative'),
  3002. new InputOption('json', 'j', InputOption::VALUE_NONE, 'JSON decode the setting value, to be used with extra.* keys'),
  3003. 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'),
  3004. 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)'),
  3005. new InputOption('source', null, InputOption::VALUE_NONE, 'Display where the config value is loaded from'),
  3006. new InputArgument('setting-key', null, 'Setting key', null, $this->suggestSettingKeys()),
  3007. new InputArgument('setting-value', InputArgument::IS_ARRAY, 'Setting value'),
  3008. ])
  3009. ->setHelp(
  3010. <<<EOT
  3011. This command allows you to edit composer config settings and repositories
  3012. in either the local composer.json file or the global config.json file.
  3013. Additionally it lets you edit most properties in the local composer.json.
  3014. To set a config setting:
  3015. <comment>%command.full_name% bin-dir bin/</comment>
  3016. To read a config setting:
  3017. <comment>%command.full_name% bin-dir</comment>
  3018. Outputs: <info>bin</info>
  3019. To edit the global config.json file:
  3020. <comment>%command.full_name% --global</comment>
  3021. To add a repository:
  3022. <comment>%command.full_name% repositories.foo vcs https://bar.com</comment>
  3023. To remove a repository (repo is a short alias for repositories):
  3024. <comment>%command.full_name% --unset repo.foo</comment>
  3025. To disable packagist:
  3026. <comment>%command.full_name% repo.packagist false</comment>
  3027. You can alter repositories in the global config.json file by passing in the
  3028. <info>--global</info> option.
  3029. To add or edit suggested packages you can use:
  3030. <comment>%command.full_name% suggest.package reason for the suggestion</comment>
  3031. To add or edit extra properties you can use:
  3032. <comment>%command.full_name% extra.property value</comment>
  3033. Or to add a complex value you can use json with:
  3034. <comment>%command.full_name% extra.property --json '{"foo":true, "bar": []}'</comment>
  3035. To edit the file in an external editor:
  3036. <comment>%command.full_name% --editor</comment>
  3037. To choose your editor you can set the "EDITOR" env variable.
  3038. To get a list of configuration values in the file:
  3039. <comment>%command.full_name% --list</comment>
  3040. You can always pass more than one option. As an example, if you want to edit the
  3041. global config.json file.
  3042. <comment>%command.full_name% --editor --global</comment>
  3043. Read more at https://getcomposer.org/doc/03-cli.md#config
  3044. EOT
  3045. )
  3046. ;
  3047. }
  3048. protected function initialize(InputInterface $input, OutputInterface $output): void
  3049. {
  3050. parent::initialize($input, $output);
  3051. if ($input->getOption('global') && null !== $input->getOption('file')) {
  3052. throw new \RuntimeException('--file and --global can not be combined');
  3053. }
  3054. $io = $this->getIO();
  3055. $this->config = Factory::createConfig($io);
  3056. $configFile = $this->getComposerConfigFile($input, $this->config);
  3057. if (
  3058. ($configFile === 'composer.json' || $configFile === './composer.json')
  3059. && !file_exists($configFile)
  3060. && realpath(Platform::getCwd()) === realpath($this->config->get('home'))
  3061. ) {
  3062. file_put_contents($configFile, "{\n}\n");
  3063. }
  3064. $this->configFile = new JsonFile($configFile, null, $io);
  3065. $this->configSource = new JsonConfigSource($this->configFile);
  3066. $authConfigFile = $this->getAuthConfigFile($input, $this->config);
  3067. $this->authConfigFile = new JsonFile($authConfigFile, null, $io);
  3068. $this->authConfigSource = new JsonConfigSource($this->authConfigFile, true);
  3069. if ($input->getOption('global') && !$this->configFile->exists()) {
  3070. touch($this->configFile->getPath());
  3071. $this->configFile->write(['config' => new \ArrayObject]);
  3072. Silencer::call('chmod', $this->configFile->getPath(), 0600);
  3073. }
  3074. if ($input->getOption('global') && !$this->authConfigFile->exists()) {
  3075. touch($this->authConfigFile->getPath());
  3076. $this->authConfigFile->write(['bitbucket-oauth' => new \ArrayObject, 'github-oauth' => new \ArrayObject, 'gitlab-oauth' => new \ArrayObject, 'gitlab-token' => new \ArrayObject, 'http-basic' => new \ArrayObject, 'bearer' => new \ArrayObject]);
  3077. Silencer::call('chmod', $this->authConfigFile->getPath(), 0600);
  3078. }
  3079. if (!$this->configFile->exists()) {
  3080. throw new \RuntimeException(sprintf('File "%s" cannot be found in the current directory', $configFile));
  3081. }
  3082. }
  3083. protected function execute(InputInterface $input, OutputInterface $output): int
  3084. {
  3085. if (true === $input->getOption('editor')) {
  3086. $editor = Platform::getEnv('EDITOR');
  3087. if (false === $editor || '' === $editor) {
  3088. if (Platform::isWindows()) {
  3089. $editor = 'notepad';
  3090. } else {
  3091. foreach (['editor', 'vim', 'vi', 'nano', 'pico', 'ed'] as $candidate) {
  3092. if (exec('which '.$candidate)) {
  3093. $editor = $candidate;
  3094. break;
  3095. }
  3096. }
  3097. }
  3098. } else {
  3099. $editor = escapeshellcmd($editor);
  3100. }
  3101. $file = $input->getOption('auth') ? $this->authConfigFile->getPath() : $this->configFile->getPath();
  3102. system($editor . ' ' . $file . (Platform::isWindows() ? '' : ' > `tty`'));
  3103. return 0;
  3104. }
  3105. if (false === $input->getOption('global')) {
  3106. $this->config->merge($this->configFile->read(), $this->configFile->getPath());
  3107. $this->config->merge(['config' => $this->authConfigFile->exists() ? $this->authConfigFile->read() : []], $this->authConfigFile->getPath());
  3108. }
  3109. $this->getIO()->loadConfiguration($this->config);
  3110. if (true === $input->getOption('list')) {
  3111. $this->listConfiguration($this->config->all(), $this->config->raw(), $output, null, $input->getOption('source'));
  3112. return 0;
  3113. }
  3114. $settingKey = $input->getArgument('setting-key');
  3115. if (!is_string($settingKey)) {
  3116. return 0;
  3117. }
  3118. if ([] !== $input->getArgument('setting-value') && $input->getOption('unset')) {
  3119. throw new \RuntimeException('You can not combine a setting value with --unset');
  3120. }
  3121. if ([] === $input->getArgument('setting-value') && !$input->getOption('unset')) {
  3122. $properties = self::CONFIGURABLE_PACKAGE_PROPERTIES;
  3123. $propertiesDefaults = [
  3124. 'type' => 'library',
  3125. 'description' => '',
  3126. 'homepage' => '',
  3127. 'minimum-stability' => 'stable',
  3128. 'prefer-stable' => false,
  3129. 'keywords' => [],
  3130. 'license' => [],
  3131. 'suggest' => [],
  3132. 'extra' => [],
  3133. ];
  3134. $rawData = $this->configFile->read();
  3135. $data = $this->config->all();
  3136. $source = $this->config->getSourceOfValue($settingKey);
  3137. if (Preg::isMatch('/^repos?(?:itories)?(?:\.(.+))?/', $settingKey, $matches)) {
  3138. if (!isset($matches[1]) || $matches[1] === '') {
  3139. $value = $data['repositories'] ?? [];
  3140. } else {
  3141. if (!isset($data['repositories'][$matches[1]])) {
  3142. throw new \InvalidArgumentException('There is no '.$matches[1].' repository defined');
  3143. }
  3144. $value = $data['repositories'][$matches[1]];
  3145. }
  3146. } elseif (strpos($settingKey, '.')) {
  3147. $bits = explode('.', $settingKey);
  3148. if ($bits[0] === 'extra' || $bits[0] === 'suggest') {
  3149. $data = $rawData;
  3150. } else {
  3151. $data = $data['config'];
  3152. }
  3153. $match = false;
  3154. foreach ($bits as $bit) {
  3155. $key = isset($key) ? $key.'.'.$bit : $bit;
  3156. $match = false;
  3157. if (isset($data[$key])) {
  3158. $match = true;
  3159. $data = $data[$key];
  3160. unset($key);
  3161. }
  3162. }
  3163. if (!$match) {
  3164. throw new \RuntimeException($settingKey.' is not defined.');
  3165. }
  3166. $value = $data;
  3167. } elseif (isset($data['config'][$settingKey])) {
  3168. $value = $this->config->get($settingKey, $input->getOption('absolute') ? 0 : Config::RELATIVE_PATHS);
  3169. if ($value === []) {
  3170. $schema = JsonFile::parseJson((string) file_get_contents(JsonFile::COMPOSER_SCHEMA_PATH));
  3171. if (
  3172. isset($schema['properties']['config']['properties'][$settingKey]['type'])
  3173. && in_array('object', (array) $schema['properties']['config']['properties'][$settingKey]['type'], true)
  3174. ) {
  3175. $value = new \stdClass;
  3176. }
  3177. }
  3178. } elseif (isset($rawData[$settingKey]) && in_array($settingKey, $properties, true)) {
  3179. $value = $rawData[$settingKey];
  3180. $source = $this->configFile->getPath();
  3181. } elseif (isset($propertiesDefaults[$settingKey])) {
  3182. $value = $propertiesDefaults[$settingKey];
  3183. $source = 'defaults';
  3184. } else {
  3185. throw new \RuntimeException($settingKey.' is not defined');
  3186. }
  3187. if (is_array($value) || is_object($value) || is_bool($value)) {
  3188. $value = JsonFile::encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
  3189. }
  3190. $sourceOfConfigValue = '';
  3191. if ($input->getOption('source')) {
  3192. $sourceOfConfigValue = ' (' . $source . ')';
  3193. }
  3194. $this->getIO()->write($value . $sourceOfConfigValue, true, IOInterface::QUIET);
  3195. return 0;
  3196. }
  3197. $values = $input->getArgument('setting-value');
  3198. $booleanValidator = static function ($val): bool {
  3199. return in_array($val, ['true', 'false', '1', '0'], true);
  3200. };
  3201. $booleanNormalizer = static function ($val): bool {
  3202. return $val !== 'false' && (bool) $val;
  3203. };
  3204. $uniqueConfigValues = [
  3205. 'process-timeout' => ['is_numeric', 'intval'],
  3206. 'use-include-path' => [$booleanValidator, $booleanNormalizer],
  3207. 'use-github-api' => [$booleanValidator, $booleanNormalizer],
  3208. 'preferred-install' => [
  3209. static function ($val): bool {
  3210. return in_array($val, ['auto', 'source', 'dist'], true);
  3211. },
  3212. static function ($val) {
  3213. return $val;
  3214. },
  3215. ],
  3216. 'gitlab-protocol' => [
  3217. static function ($val): bool {
  3218. return in_array($val, ['git', 'http', 'https'], true);
  3219. },
  3220. static function ($val) {
  3221. return $val;
  3222. },
  3223. ],
  3224. 'store-auths' => [
  3225. static function ($val): bool {
  3226. return in_array($val, ['true', 'false', 'prompt'], true);
  3227. },
  3228. static function ($val) {
  3229. if ('prompt' === $val) {
  3230. return 'prompt';
  3231. }
  3232. return $val !== 'false' && (bool) $val;
  3233. },
  3234. ],
  3235. 'notify-on-install' => [$booleanValidator, $booleanNormalizer],
  3236. 'vendor-dir' => ['is_string', static function ($val) {
  3237. return $val;
  3238. }],
  3239. 'bin-dir' => ['is_string', static function ($val) {
  3240. return $val;
  3241. }],
  3242. 'archive-dir' => ['is_string', static function ($val) {
  3243. return $val;
  3244. }],
  3245. 'archive-format' => ['is_string', static function ($val) {
  3246. return $val;
  3247. }],
  3248. 'data-dir' => ['is_string', static function ($val) {
  3249. return $val;
  3250. }],
  3251. 'cache-dir' => ['is_string', static function ($val) {
  3252. return $val;
  3253. }],
  3254. 'cache-files-dir' => ['is_string', static function ($val) {
  3255. return $val;
  3256. }],
  3257. 'cache-repo-dir' => ['is_string', static function ($val) {
  3258. return $val;
  3259. }],
  3260. 'cache-vcs-dir' => ['is_string', static function ($val) {
  3261. return $val;
  3262. }],
  3263. 'cache-ttl' => ['is_numeric', 'intval'],
  3264. 'cache-files-ttl' => ['is_numeric', 'intval'],
  3265. 'cache-files-maxsize' => [
  3266. static function ($val): bool {
  3267. return Preg::isMatch('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $val);
  3268. },
  3269. static function ($val) {
  3270. return $val;
  3271. },
  3272. ],
  3273. 'bin-compat' => [
  3274. static function ($val): bool {
  3275. return in_array($val, ['auto', 'full', 'proxy', 'symlink']);
  3276. },
  3277. static function ($val) {
  3278. return $val;
  3279. },
  3280. ],
  3281. 'discard-changes' => [
  3282. static function ($val): bool {
  3283. return in_array($val, ['stash', 'true', 'false', '1', '0'], true);
  3284. },
  3285. static function ($val) {
  3286. if ('stash' === $val) {
  3287. return 'stash';
  3288. }
  3289. return $val !== 'false' && (bool) $val;
  3290. },
  3291. ],
  3292. 'autoloader-suffix' => ['is_string', static function ($val) {
  3293. return $val === 'null' ? null : $val;
  3294. }],
  3295. 'sort-packages' => [$booleanValidator, $booleanNormalizer],
  3296. 'optimize-autoloader' => [$booleanValidator, $booleanNormalizer],
  3297. 'classmap-authoritative' => [$booleanValidator, $booleanNormalizer],
  3298. 'apcu-autoloader' => [$booleanValidator, $booleanNormalizer],
  3299. 'prepend-autoloader' => [$booleanValidator, $booleanNormalizer],
  3300. 'disable-tls' => [$booleanValidator, $booleanNormalizer],
  3301. 'secure-http' => [$booleanValidator, $booleanNormalizer],
  3302. 'cafile' => [
  3303. static function ($val): bool {
  3304. return file_exists($val) && Filesystem::isReadable($val);
  3305. },
  3306. static function ($val) {
  3307. return $val === 'null' ? null : $val;
  3308. },
  3309. ],
  3310. 'capath' => [
  3311. static function ($val): bool {
  3312. return is_dir($val) && Filesystem::isReadable($val);
  3313. },
  3314. static function ($val) {
  3315. return $val === 'null' ? null : $val;
  3316. },
  3317. ],
  3318. 'github-expose-hostname' => [$booleanValidator, $booleanNormalizer],
  3319. 'htaccess-protect' => [$booleanValidator, $booleanNormalizer],
  3320. 'lock' => [$booleanValidator, $booleanNormalizer],
  3321. 'allow-plugins' => [$booleanValidator, $booleanNormalizer],
  3322. 'platform-check' => [
  3323. static function ($val): bool {
  3324. return in_array($val, ['php-only', 'true', 'false', '1', '0'], true);
  3325. },
  3326. static function ($val) {
  3327. if ('php-only' === $val) {
  3328. return 'php-only';
  3329. }
  3330. return $val !== 'false' && (bool) $val;
  3331. },
  3332. ],
  3333. 'use-parent-dir' => [
  3334. static function ($val): bool {
  3335. return in_array($val, ['true', 'false', 'prompt'], true);
  3336. },
  3337. static function ($val) {
  3338. if ('prompt' === $val) {
  3339. return 'prompt';
  3340. }
  3341. return $val !== 'false' && (bool) $val;
  3342. },
  3343. ],
  3344. 'audit.abandoned' => [
  3345. static function ($val): bool {
  3346. return in_array($val, [Auditor::ABANDONED_IGNORE, Auditor::ABANDONED_REPORT, Auditor::ABANDONED_FAIL], true);
  3347. },
  3348. static function ($val) {
  3349. return $val;
  3350. },
  3351. ],
  3352. ];
  3353. $multiConfigValues = [
  3354. 'github-protocols' => [
  3355. static function ($vals) {
  3356. if (!is_array($vals)) {
  3357. return 'array expected';
  3358. }
  3359. foreach ($vals as $val) {
  3360. if (!in_array($val, ['git', 'https', 'ssh'])) {
  3361. return 'valid protocols include: git, https, ssh';
  3362. }
  3363. }
  3364. return true;
  3365. },
  3366. static function ($vals) {
  3367. return $vals;
  3368. },
  3369. ],
  3370. 'github-domains' => [
  3371. static function ($vals) {
  3372. if (!is_array($vals)) {
  3373. return 'array expected';
  3374. }
  3375. return true;
  3376. },
  3377. static function ($vals) {
  3378. return $vals;
  3379. },
  3380. ],
  3381. 'gitlab-domains' => [
  3382. static function ($vals) {
  3383. if (!is_array($vals)) {
  3384. return 'array expected';
  3385. }
  3386. return true;
  3387. },
  3388. static function ($vals) {
  3389. return $vals;
  3390. },
  3391. ],
  3392. 'audit.ignore' => [
  3393. static function ($vals) {
  3394. if (!is_array($vals)) {
  3395. return 'array expected';
  3396. }
  3397. return true;
  3398. },
  3399. static function ($vals) {
  3400. return $vals;
  3401. },
  3402. ],
  3403. ];
  3404. if ($input->getOption('unset') && $settingKey === 'audit') {
  3405. $this->configSource->removeConfigSetting($settingKey);
  3406. return 0;
  3407. }
  3408. if ($input->getOption('unset') && (isset($uniqueConfigValues[$settingKey]) || isset($multiConfigValues[$settingKey]))) {
  3409. if ($settingKey === 'disable-tls' && $this->config->get('disable-tls')) {
  3410. $this->getIO()->writeError('<info>You are now running Composer with SSL/TLS protection enabled.</info>');
  3411. }
  3412. $this->configSource->removeConfigSetting($settingKey);
  3413. return 0;
  3414. }
  3415. if (isset($uniqueConfigValues[$settingKey])) {
  3416. $this->handleSingleValue($settingKey, $uniqueConfigValues[$settingKey], $values, 'addConfigSetting');
  3417. return 0;
  3418. }
  3419. if (isset($multiConfigValues[$settingKey])) {
  3420. $this->handleMultiValue($settingKey, $multiConfigValues[$settingKey], $values, 'addConfigSetting');
  3421. return 0;
  3422. }
  3423. if (Preg::isMatch('/^preferred-install\.(.+)/', $settingKey, $matches)) {
  3424. if ($input->getOption('unset')) {
  3425. $this->configSource->removeConfigSetting($settingKey);
  3426. return 0;
  3427. }
  3428. [$validator] = $uniqueConfigValues['preferred-install'];
  3429. if (!$validator($values[0])) {
  3430. throw new \RuntimeException('Invalid value for '.$settingKey.'. Should be one of: auto, source, or dist');
  3431. }
  3432. $this->configSource->addConfigSetting($settingKey, $values[0]);
  3433. return 0;
  3434. }
  3435. if (Preg::isMatch('{^allow-plugins\.([a-zA-Z0-9/*-]+)}', $settingKey, $matches)) {
  3436. if ($input->getOption('unset')) {
  3437. $this->configSource->removeConfigSetting($settingKey);
  3438. return 0;
  3439. }
  3440. if (true !== $booleanValidator($values[0])) {
  3441. throw new \RuntimeException(sprintf(
  3442. '"%s" is an invalid value',
  3443. $values[0]
  3444. ));
  3445. }
  3446. $normalizedValue = $booleanNormalizer($values[0]);
  3447. $this->configSource->addConfigSetting($settingKey, $normalizedValue);
  3448. return 0;
  3449. }
  3450. $uniqueProps = [
  3451. 'name' => ['is_string', static function ($val) {
  3452. return $val;
  3453. }],
  3454. 'type' => ['is_string', static function ($val) {
  3455. return $val;
  3456. }],
  3457. 'description' => ['is_string', static function ($val) {
  3458. return $val;
  3459. }],
  3460. 'homepage' => ['is_string', static function ($val) {
  3461. return $val;
  3462. }],
  3463. 'version' => ['is_string', static function ($val) {
  3464. return $val;
  3465. }],
  3466. 'minimum-stability' => [
  3467. static function ($val): bool {
  3468. return isset(BasePackage::$stabilities[VersionParser::normalizeStability($val)]);
  3469. },
  3470. static function ($val): string {
  3471. return VersionParser::normalizeStability($val);
  3472. },
  3473. ],
  3474. 'prefer-stable' => [$booleanValidator, $booleanNormalizer],
  3475. ];
  3476. $multiProps = [
  3477. 'keywords' => [
  3478. static function ($vals) {
  3479. if (!is_array($vals)) {
  3480. return 'array expected';
  3481. }
  3482. return true;
  3483. },
  3484. static function ($vals) {
  3485. return $vals;
  3486. },
  3487. ],
  3488. 'license' => [
  3489. static function ($vals) {
  3490. if (!is_array($vals)) {
  3491. return 'array expected';
  3492. }
  3493. return true;
  3494. },
  3495. static function ($vals) {
  3496. return $vals;
  3497. },
  3498. ],
  3499. ];
  3500. if ($input->getOption('global') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]) || strpos($settingKey, 'extra.') === 0)) {
  3501. 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');
  3502. }
  3503. if ($input->getOption('unset') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]))) {
  3504. $this->configSource->removeProperty($settingKey);
  3505. return 0;
  3506. }
  3507. if (isset($uniqueProps[$settingKey])) {
  3508. $this->handleSingleValue($settingKey, $uniqueProps[$settingKey], $values, 'addProperty');
  3509. return 0;
  3510. }
  3511. if (isset($multiProps[$settingKey])) {
  3512. $this->handleMultiValue($settingKey, $multiProps[$settingKey], $values, 'addProperty');
  3513. return 0;
  3514. }
  3515. if (Preg::isMatchStrictGroups('/^repos?(?:itories)?\.(.+)/', $settingKey, $matches)) {
  3516. if ($input->getOption('unset')) {
  3517. $this->configSource->removeRepository($matches[1]);
  3518. return 0;
  3519. }
  3520. if (2 === count($values)) {
  3521. $this->configSource->addRepository($matches[1], [
  3522. 'type' => $values[0],
  3523. 'url' => $values[1],
  3524. ], $input->getOption('append'));
  3525. return 0;
  3526. }
  3527. if (1 === count($values)) {
  3528. $value = strtolower($values[0]);
  3529. if (true === $booleanValidator($value)) {
  3530. if (false === $booleanNormalizer($value)) {
  3531. $this->configSource->addRepository($matches[1], false, $input->getOption('append'));
  3532. return 0;
  3533. }
  3534. } else {
  3535. $value = JsonFile::parseJson($values[0]);
  3536. $this->configSource->addRepository($matches[1], $value, $input->getOption('append'));
  3537. return 0;
  3538. }
  3539. }
  3540. throw new \RuntimeException('You must pass the type and a url. Example: php composer.phar config repositories.foo vcs https://bar.com');
  3541. }
  3542. if (Preg::isMatch('/^extra\.(.+)/', $settingKey, $matches)) {
  3543. if ($input->getOption('unset')) {
  3544. $this->configSource->removeProperty($settingKey);
  3545. return 0;
  3546. }
  3547. $value = $values[0];
  3548. if ($input->getOption('json')) {
  3549. $value = JsonFile::parseJson($value);
  3550. if ($input->getOption('merge')) {
  3551. $currentValue = $this->configFile->read();
  3552. $bits = explode('.', $settingKey);
  3553. foreach ($bits as $bit) {
  3554. $currentValue = $currentValue[$bit] ?? null;
  3555. }
  3556. if (is_array($currentValue)) {
  3557. $value = array_merge($currentValue, $value);
  3558. }
  3559. }
  3560. }
  3561. $this->configSource->addProperty($settingKey, $value);
  3562. return 0;
  3563. }
  3564. if (Preg::isMatch('/^suggest\.(.+)/', $settingKey, $matches)) {
  3565. if ($input->getOption('unset')) {
  3566. $this->configSource->removeProperty($settingKey);
  3567. return 0;
  3568. }
  3569. $this->configSource->addProperty($settingKey, implode(' ', $values));
  3570. return 0;
  3571. }
  3572. if (in_array($settingKey, ['suggest', 'extra'], true) && $input->getOption('unset')) {
  3573. $this->configSource->removeProperty($settingKey);
  3574. return 0;
  3575. }
  3576. if (Preg::isMatch('/^platform\.(.+)/', $settingKey, $matches)) {
  3577. if ($input->getOption('unset')) {
  3578. $this->configSource->removeConfigSetting($settingKey);
  3579. return 0;
  3580. }
  3581. $this->configSource->addConfigSetting($settingKey, $values[0] === 'false' ? false : $values[0]);
  3582. return 0;
  3583. }
  3584. if ($settingKey === 'platform' && $input->getOption('unset')) {
  3585. $this->configSource->removeConfigSetting($settingKey);
  3586. return 0;
  3587. }
  3588. if (Preg::isMatch('/^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|http-basic|bearer)\.(.+)/', $settingKey, $matches)) {
  3589. if ($input->getOption('unset')) {
  3590. $this->authConfigSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  3591. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  3592. return 0;
  3593. }
  3594. if ($matches[1] === 'bitbucket-oauth') {
  3595. if (2 !== count($values)) {
  3596. throw new \RuntimeException('Expected two arguments (consumer-key, consumer-secret), got '.count($values));
  3597. }
  3598. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  3599. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], ['consumer-key' => $values[0], 'consumer-secret' => $values[1]]);
  3600. } elseif ($matches[1] === 'gitlab-token' && 2 === count($values)) {
  3601. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  3602. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], ['username' => $values[0], 'token' => $values[1]]);
  3603. } elseif (in_array($matches[1], ['github-oauth', 'gitlab-oauth', 'gitlab-token', 'bearer'], true)) {
  3604. if (1 !== count($values)) {
  3605. throw new \RuntimeException('Too many arguments, expected only one token');
  3606. }
  3607. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  3608. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], $values[0]);
  3609. } elseif ($matches[1] === 'http-basic') {
  3610. if (2 !== count($values)) {
  3611. throw new \RuntimeException('Expected two arguments (username, password), got '.count($values));
  3612. }
  3613. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  3614. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], ['username' => $values[0], 'password' => $values[1]]);
  3615. }
  3616. return 0;
  3617. }
  3618. if (Preg::isMatch('/^scripts\.(.+)/', $settingKey, $matches)) {
  3619. if ($input->getOption('unset')) {
  3620. $this->configSource->removeProperty($settingKey);
  3621. return 0;
  3622. }
  3623. $this->configSource->addProperty($settingKey, count($values) > 1 ? $values : $values[0]);
  3624. return 0;
  3625. }
  3626. if ($input->getOption('unset')) {
  3627. $this->configSource->removeProperty($settingKey);
  3628. return 0;
  3629. }
  3630. throw new \InvalidArgumentException('Setting '.$settingKey.' does not exist or is not supported by this command');
  3631. }
  3632. protected function handleSingleValue(string $key, array $callbacks, array $values, string $method): void
  3633. {
  3634. [$validator, $normalizer] = $callbacks;
  3635. if (1 !== count($values)) {
  3636. throw new \RuntimeException('You can only pass one value. Example: php composer.phar config process-timeout 300');
  3637. }
  3638. if (true !== $validation = $validator($values[0])) {
  3639. throw new \RuntimeException(sprintf(
  3640. '"%s" is an invalid value'.($validation ? ' ('.$validation.')' : ''),
  3641. $values[0]
  3642. ));
  3643. }
  3644. $normalizedValue = $normalizer($values[0]);
  3645. if ($key === 'disable-tls') {
  3646. if (!$normalizedValue && $this->config->get('disable-tls')) {
  3647. $this->getIO()->writeError('<info>You are now running Composer with SSL/TLS protection enabled.</info>');
  3648. } elseif ($normalizedValue && !$this->config->get('disable-tls')) {
  3649. $this->getIO()->writeError('<warning>You are now running Composer with SSL/TLS protection disabled.</warning>');
  3650. }
  3651. }
  3652. call_user_func([$this->configSource, $method], $key, $normalizedValue);
  3653. }
  3654. protected function handleMultiValue(string $key, array $callbacks, array $values, string $method): void
  3655. {
  3656. [$validator, $normalizer] = $callbacks;
  3657. if (true !== $validation = $validator($values)) {
  3658. throw new \RuntimeException(sprintf(
  3659. '%s is an invalid value'.($validation ? ' ('.$validation.')' : ''),
  3660. json_encode($values)
  3661. ));
  3662. }
  3663. call_user_func([$this->configSource, $method], $key, $normalizer($values));
  3664. }
  3665. protected function listConfiguration(array $contents, array $rawContents, OutputInterface $output, ?string $k = null, bool $showSource = false): void
  3666. {
  3667. $origK = $k;
  3668. $io = $this->getIO();
  3669. foreach ($contents as $key => $value) {
  3670. if ($k === null && !in_array($key, ['config', 'repositories'])) {
  3671. continue;
  3672. }
  3673. $rawVal = $rawContents[$key] ?? null;
  3674. if (is_array($value) && (!is_numeric(key($value)) || ($key === 'repositories' && null === $k))) {
  3675. $k .= Preg::replace('{^config\.}', '', $key . '.');
  3676. $this->listConfiguration($value, $rawVal, $output, $k, $showSource);
  3677. $k = $origK;
  3678. continue;
  3679. }
  3680. if (is_array($value)) {
  3681. $value = array_map(static function ($val) {
  3682. return is_array($val) ? json_encode($val) : $val;
  3683. }, $value);
  3684. $value = '['.implode(', ', $value).']';
  3685. }
  3686. if (is_bool($value)) {
  3687. $value = var_export($value, true);
  3688. }
  3689. $source = '';
  3690. if ($showSource) {
  3691. $source = ' (' . $this->config->getSourceOfValue($k . $key) . ')';
  3692. }
  3693. if (null !== $k && 0 === strpos($k, 'repositories')) {
  3694. $link = 'https://getcomposer.org/doc/05-repositories.md';
  3695. } else {
  3696. $id = Preg::replace('{\..*$}', '', $k === '' || $k === null ? (string) $key : $k);
  3697. $id = Preg::replace('{[^a-z0-9]}i', '-', strtolower(trim($id)));
  3698. $id = Preg::replace('{-+}', '-', $id);
  3699. $link = 'https://getcomposer.org/doc/06-config.md#' . $id;
  3700. }
  3701. if (is_string($rawVal) && $rawVal !== $value) {
  3702. $io->write('[<fg=yellow;href=' . $link .'>' . $k . $key . '</>] <info>' . $rawVal . ' (' . $value . ')</info>' . $source, true, IOInterface::QUIET);
  3703. } else {
  3704. $io->write('[<fg=yellow;href=' . $link .'>' . $k . $key . '</>] <info>' . $value . '</info>' . $source, true, IOInterface::QUIET);
  3705. }
  3706. }
  3707. }
  3708. private function getComposerConfigFile(InputInterface $input, Config $config): string
  3709. {
  3710. return $input->getOption('global')
  3711. ? ($config->get('home') . '/config.json')
  3712. : ($input->getOption('file') ?: Factory::getComposerFile())
  3713. ;
  3714. }
  3715. private function getAuthConfigFile(InputInterface $input, Config $config): string
  3716. {
  3717. return $input->getOption('global')
  3718. ? ($config->get('home') . '/auth.json')
  3719. : dirname($this->getComposerConfigFile($input, $config)) . '/auth.json'
  3720. ;
  3721. }
  3722. private function suggestSettingKeys(): \Closure
  3723. {
  3724. return function (CompletionInput $input): array {
  3725. if ($input->getOption('list') || $input->getOption('editor') || $input->getOption('auth')) {
  3726. return [];
  3727. }
  3728. $config = Factory::createConfig();
  3729. $configFile = new JsonFile($this->getComposerConfigFile($input, $config));
  3730. if ($configFile->exists()) {
  3731. $config->merge($configFile->read(), $configFile->getPath());
  3732. }
  3733. $authConfigFile = new JsonFile($this->getAuthConfigFile($input, $config));
  3734. if ($authConfigFile->exists()) {
  3735. $config->merge(['config' => $authConfigFile->read()], $authConfigFile->getPath());
  3736. }
  3737. $rawConfig = $config->raw();
  3738. $keys = array_merge(
  3739. $this->flattenSettingKeys($rawConfig['config']),
  3740. $this->flattenSettingKeys($rawConfig['repositories'], 'repositories.')
  3741. );
  3742. if ($input->getOption('unset')) {
  3743. $sources = [$configFile->getPath(), $authConfigFile->getPath()];
  3744. $keys = array_filter(
  3745. $keys,
  3746. static function (string $key) use ($config, $sources): bool {
  3747. return in_array($config->getSourceOfValue($key), $sources, true);
  3748. }
  3749. );
  3750. } else {
  3751. $keys = array_merge($keys, self::CONFIGURABLE_PACKAGE_PROPERTIES);
  3752. }
  3753. if ($configFile->exists()) {
  3754. $properties = array_filter(
  3755. $configFile->read(),
  3756. static function (string $key): bool {
  3757. return in_array($key, self::CONFIGURABLE_PACKAGE_PROPERTIES, true);
  3758. },
  3759. ARRAY_FILTER_USE_KEY
  3760. );
  3761. $keys = array_merge(
  3762. $keys,
  3763. $this->flattenSettingKeys($properties)
  3764. );
  3765. }
  3766. $completionValue = $input->getCompletionValue();
  3767. if ($completionValue !== '') {
  3768. $keys = array_filter(
  3769. $keys,
  3770. static function (string $key) use ($completionValue): bool {
  3771. return str_starts_with($key, $completionValue);
  3772. }
  3773. );
  3774. }
  3775. sort($keys);
  3776. return array_unique($keys);
  3777. };
  3778. }
  3779. private function flattenSettingKeys(array $config, string $prefix = ''): array
  3780. {
  3781. $keys = [];
  3782. foreach ($config as $key => $value) {
  3783. $keys[] = [$prefix . $key];
  3784. if (is_array($value) && !array_is_list($value) && $prefix !== 'repositories.') {
  3785. $keys[] = $this->flattenSettingKeys($value, $prefix . $key . '.');
  3786. }
  3787. }
  3788. return array_merge(...$keys);
  3789. }
  3790. }
  3791. <?php declare(strict_types=1);
  3792. namespace Composer\Command;
  3793. use Composer\Config;
  3794. use Composer\Factory;
  3795. use Composer\Filter\PlatformRequirementFilter\IgnoreAllPlatformRequirementFilter;
  3796. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  3797. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  3798. use Composer\Installer;
  3799. use Composer\Installer\ProjectInstaller;
  3800. use Composer\Installer\SuggestedPackagesReporter;
  3801. use Composer\IO\IOInterface;
  3802. use Composer\Package\BasePackage;
  3803. use Composer\DependencyResolver\Operation\InstallOperation;
  3804. use Composer\Package\Version\VersionSelector;
  3805. use Composer\Package\AliasPackage;
  3806. use Composer\Pcre\Preg;
  3807. use Composer\Plugin\PluginBlockedException;
  3808. use Composer\Repository\RepositoryFactory;
  3809. use Composer\Repository\CompositeRepository;
  3810. use Composer\Repository\PlatformRepository;
  3811. use Composer\Repository\InstalledArrayRepository;
  3812. use Composer\Repository\RepositorySet;
  3813. use Composer\Script\ScriptEvents;
  3814. use Composer\Util\Silencer;
  3815. use Composer\Console\Input\InputArgument;
  3816. use Seld\Signal\SignalHandler;
  3817. use Symfony\Component\Console\Input\InputInterface;
  3818. use Composer\Console\Input\InputOption;
  3819. use Symfony\Component\Console\Output\OutputInterface;
  3820. use Symfony\Component\Finder\Finder;
  3821. use Composer\Json\JsonFile;
  3822. use Composer\Config\JsonConfigSource;
  3823. use Composer\Util\Filesystem;
  3824. use Composer\Util\Platform;
  3825. use Composer\Util\ProcessExecutor;
  3826. use Composer\Package\Version\VersionParser;
  3827. use Composer\Advisory\Auditor;
  3828. class CreateProjectCommand extends BaseCommand
  3829. {
  3830. use CompletionTrait;
  3831. protected $suggestedPackagesReporter;
  3832. protected function configure(): void
  3833. {
  3834. $this
  3835. ->setName('create-project')
  3836. ->setDescription('Creates new project from a package into given directory')
  3837. ->setDefinition([
  3838. new InputArgument('package', InputArgument::OPTIONAL, 'Package name to be installed', null, $this->suggestAvailablePackage()),
  3839. new InputArgument('directory', InputArgument::OPTIONAL, 'Directory where the files should be created'),
  3840. new InputArgument('version', InputArgument::OPTIONAL, 'Version, will default to latest'),
  3841. new InputOption('stability', 's', InputOption::VALUE_REQUIRED, 'Minimum-stability allowed (unless a version is specified).'),
  3842. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  3843. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
  3844. 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).', null, $this->suggestPreferInstall()),
  3845. 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'),
  3846. new InputOption('repository-url', null, InputOption::VALUE_REQUIRED, 'DEPRECATED: Use --repository instead.'),
  3847. 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.'),
  3848. new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of require-dev packages (enabled by default, only present for BC).'),
  3849. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  3850. new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'DEPRECATED: Use no-plugins instead.'),
  3851. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Whether to prevent execution of all defined scripts in the root package.'),
  3852. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  3853. 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.'),
  3854. new InputOption('keep-vcs', null, InputOption::VALUE_NONE, 'Whether to prevent deleting the vcs folder.'),
  3855. new InputOption('remove-vcs', null, InputOption::VALUE_NONE, 'Whether to force deletion of the vcs folder without prompting.'),
  3856. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Whether to skip installation of the package dependencies.'),
  3857. new InputOption('no-audit', null, InputOption::VALUE_NONE, 'Whether to skip auditing of the installed package dependencies (can also be set via the COMPOSER_NO_AUDIT=1 env var).'),
  3858. new InputOption('audit-format', null, InputOption::VALUE_REQUIRED, 'Audit output format. Must be "table", "plain", "json" or "summary".', Auditor::FORMAT_SUMMARY, Auditor::FORMATS),
  3859. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  3860. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  3861. new InputOption('ask', null, InputOption::VALUE_NONE, 'Whether to ask for project directory.'),
  3862. ])
  3863. ->setHelp(
  3864. <<<EOT
  3865. The <info>create-project</info> command creates a new project from a given
  3866. package into a new directory. If executed without params and in a directory
  3867. with a composer.json file it installs the packages for the current project.
  3868. You can use this command to bootstrap new projects or setup a clean
  3869. version-controlled installation for developers of your project.
  3870. <info>php composer.phar create-project vendor/project target-directory [version]</info>
  3871. You can also specify the version with the package name using = or : as separator.
  3872. <info>php composer.phar create-project vendor/project:version target-directory</info>
  3873. To install unstable packages, either specify the version you want, or use the
  3874. --stability=dev (where dev can be one of RC, beta, alpha or dev).
  3875. To setup a developer workable version you should create the project using the source
  3876. controlled code by appending the <info>'--prefer-source'</info> flag.
  3877. To install a package from another repository than the default one you
  3878. can pass the <info>'--repository=https://myrepository.org'</info> flag.
  3879. Read more at https://getcomposer.org/doc/03-cli.md#create-project
  3880. EOT
  3881. )
  3882. ;
  3883. }
  3884. protected function execute(InputInterface $input, OutputInterface $output): int
  3885. {
  3886. $config = Factory::createConfig();
  3887. $io = $this->getIO();
  3888. [$preferSource, $preferDist] = $this->getPreferredInstallOptions($config, $input, true);
  3889. if ($input->getOption('dev')) {
  3890. $io->writeError('<warning>You are using the deprecated option "dev". Dev packages are installed by default now.</warning>');
  3891. }
  3892. if ($input->getOption('no-custom-installers')) {
  3893. $io->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
  3894. $input->setOption('no-plugins', true);
  3895. }
  3896. if ($input->isInteractive() && $input->getOption('ask')) {
  3897. $package = $input->getArgument('package');
  3898. if (null === $package) {
  3899. throw new \RuntimeException('Not enough arguments (missing: "package").');
  3900. }
  3901. $parts = explode("/", strtolower($package), 2);
  3902. $input->setArgument('directory', $io->ask('New project directory [<comment>'.array_pop($parts).'</comment>]: '));
  3903. }
  3904. return $this->installProject(
  3905. $io,
  3906. $config,
  3907. $input,
  3908. $input->getArgument('package'),
  3909. $input->getArgument('directory'),
  3910. $input->getArgument('version'),
  3911. $input->getOption('stability'),
  3912. $preferSource,
  3913. $preferDist,
  3914. !$input->getOption('no-dev'),
  3915. \count($input->getOption('repository')) > 0 ? $input->getOption('repository') : $input->getOption('repository-url'),
  3916. $input->getOption('no-plugins'),
  3917. $input->getOption('no-scripts'),
  3918. $input->getOption('no-progress'),
  3919. $input->getOption('no-install'),
  3920. $this->getPlatformRequirementFilter($input),
  3921. !$input->getOption('no-secure-http'),
  3922. $input->getOption('add-repository')
  3923. );
  3924. }
  3925. 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
  3926. {
  3927. $oldCwd = Platform::getCwd();
  3928. if ($repositories !== null && !is_array($repositories)) {
  3929. $repositories = (array) $repositories;
  3930. }
  3931. $platformRequirementFilter = $platformRequirementFilter ?? PlatformRequirementFilterFactory::ignoreNothing();
  3932. $io->loadConfiguration($config);
  3933. $this->suggestedPackagesReporter = new SuggestedPackagesReporter($io);
  3934. if ($packageName !== null) {
  3935. $installedFromVcs = $this->installRootPackage($io, $config, $packageName, $platformRequirementFilter, $directory, $packageVersion, $stability, $preferSource, $preferDist, $installDevPackages, $repositories, $disablePlugins, $disableScripts, $noProgress, $secureHttp);
  3936. } else {
  3937. $installedFromVcs = false;
  3938. }
  3939. if ($repositories !== null && $addRepository && is_file('composer.lock')) {
  3940. unlink('composer.lock');
  3941. }
  3942. $composer = Factory::create($io, null, $disablePlugins, $disableScripts);
  3943. if ($repositories !== null && $addRepository) {
  3944. foreach ($repositories as $index => $repo) {
  3945. $repoConfig = RepositoryFactory::configFromString($io, $composer->getConfig(), $repo, true);
  3946. $composerJsonRepositoriesConfig = $composer->getConfig()->getRepositories();
  3947. $name = RepositoryFactory::generateRepositoryName($index, $repoConfig, $composerJsonRepositoriesConfig);
  3948. $configSource = new JsonConfigSource(new JsonFile('composer.json'));
  3949. if (
  3950. (isset($repoConfig['packagist']) && $repoConfig === ['packagist' => false])
  3951. || (isset($repoConfig['packagist.org']) && $repoConfig === ['packagist.org' => false])
  3952. ) {
  3953. $configSource->addRepository('packagist.org', false);
  3954. } else {
  3955. $configSource->addRepository($name, $repoConfig, false);
  3956. }
  3957. $composer = Factory::create($io, null, $disablePlugins);
  3958. }
  3959. }
  3960. $process = $composer->getLoop()->getProcessExecutor();
  3961. $fs = new Filesystem($process);
  3962. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ROOT_PACKAGE_INSTALL, $installDevPackages);
  3963. $config = $composer->getConfig();
  3964. [$preferSource, $preferDist] = $this->getPreferredInstallOptions($config, $input);
  3965. if ($noInstall === false) {
  3966. $composer->getInstallationManager()->setOutputProgress(!$noProgress);
  3967. $installer = Installer::create($io, $composer);
  3968. $installer->setPreferSource($preferSource)
  3969. ->setPreferDist($preferDist)
  3970. ->setDevMode($installDevPackages)
  3971. ->setPlatformRequirementFilter($platformRequirementFilter)
  3972. ->setSuggestedPackagesReporter($this->suggestedPackagesReporter)
  3973. ->setOptimizeAutoloader($config->get('optimize-autoloader'))
  3974. ->setClassMapAuthoritative($config->get('classmap-authoritative'))
  3975. ->setApcuAutoloader($config->get('apcu-autoloader'))
  3976. ->setAudit(!$input->getOption('no-audit'))
  3977. ->setAuditFormat($this->getAuditFormat($input));
  3978. if (!$composer->getLocker()->isLocked()) {
  3979. $installer->setUpdate(true);
  3980. }
  3981. if ($disablePlugins) {
  3982. $installer->disablePlugins();
  3983. }
  3984. try {
  3985. $status = $installer->run();
  3986. if (0 !== $status) {
  3987. return $status;
  3988. }
  3989. } catch (PluginBlockedException $e) {
  3990. $io->writeError('<error>Hint: To allow running the config command recommended below before dependencies are installed, run create-project with --no-install.</error>');
  3991. $io->writeError('<error>You can then cd into '.getcwd().', configure allow-plugins, and finally run a composer install to complete the process.</error>');
  3992. throw $e;
  3993. }
  3994. }
  3995. $hasVcs = $installedFromVcs;
  3996. if (
  3997. !$input->getOption('keep-vcs')
  3998. && $installedFromVcs
  3999. && (
  4000. $input->getOption('remove-vcs')
  4001. || !$io->isInteractive()
  4002. || $io->askConfirmation('<info>Do you want to remove the existing VCS (.git, .svn..) history?</info> [<comment>Y,n</comment>]? ')
  4003. )
  4004. ) {
  4005. $finder = new Finder();
  4006. $finder->depth(0)->directories()->in(Platform::getCwd())->ignoreVCS(false)->ignoreDotFiles(false);
  4007. foreach (['.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg', '.fslckout', '_FOSSIL_'] as $vcsName) {
  4008. $finder->name($vcsName);
  4009. }
  4010. try {
  4011. $dirs = iterator_to_array($finder);
  4012. unset($finder);
  4013. foreach ($dirs as $dir) {
  4014. if (!$fs->removeDirectory((string) $dir)) {
  4015. throw new \RuntimeException('Could not remove '.$dir);
  4016. }
  4017. }
  4018. } catch (\Exception $e) {
  4019. $io->writeError('<error>An error occurred while removing the VCS metadata: '.$e->getMessage().'</error>');
  4020. }
  4021. $hasVcs = false;
  4022. }
  4023. if (!$hasVcs) {
  4024. $package = $composer->getPackage();
  4025. $configSource = new JsonConfigSource(new JsonFile('composer.json'));
  4026. foreach (BasePackage::$supportedLinkTypes as $type => $meta) {
  4027. foreach ($package->{'get'.$meta['method']}() as $link) {
  4028. if ($link->getPrettyConstraint() === 'self.version') {
  4029. $configSource->addLink($type, $link->getTarget(), $package->getPrettyVersion());
  4030. }
  4031. }
  4032. }
  4033. }
  4034. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_CREATE_PROJECT_CMD, $installDevPackages);
  4035. chdir($oldCwd);
  4036. $vendorComposerDir = $config->get('vendor-dir').'/composer';
  4037. if (is_dir($vendorComposerDir) && $fs->isDirEmpty($vendorComposerDir)) {
  4038. Silencer::call('rmdir', $vendorComposerDir);
  4039. $vendorDir = $config->get('vendor-dir');
  4040. if (is_dir($vendorDir) && $fs->isDirEmpty($vendorDir)) {
  4041. Silencer::call('rmdir', $vendorDir);
  4042. }
  4043. }
  4044. return 0;
  4045. }
  4046. 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
  4047. {
  4048. if (!$secureHttp) {
  4049. $config->merge(['config' => ['secure-http' => false]], Config::SOURCE_COMMAND);
  4050. }
  4051. $parser = new VersionParser();
  4052. $requirements = $parser->parseNameVersionPairs([$packageName]);
  4053. $name = strtolower($requirements[0]['name']);
  4054. if (!$packageVersion && isset($requirements[0]['version'])) {
  4055. $packageVersion = $requirements[0]['version'];
  4056. }
  4057. if (null === $directory) {
  4058. $parts = explode("/", $name, 2);
  4059. $directory = Platform::getCwd() . DIRECTORY_SEPARATOR . array_pop($parts);
  4060. }
  4061. $process = new ProcessExecutor($io);
  4062. $fs = new Filesystem($process);
  4063. if (!$fs->isAbsolutePath($directory)) {
  4064. $directory = Platform::getCwd() . DIRECTORY_SEPARATOR . $directory;
  4065. }
  4066. $io->writeError('<info>Creating a "' . $packageName . '" project at "' . $fs->findShortestPath(Platform::getCwd(), $directory, true) . '"</info>');
  4067. if (file_exists($directory)) {
  4068. if (!is_dir($directory)) {
  4069. throw new \InvalidArgumentException('Cannot create project directory at "'.$directory.'", it exists as a file.');
  4070. }
  4071. if (!$fs->isDirEmpty($directory)) {
  4072. throw new \InvalidArgumentException('Project directory "'.$directory.'" is not empty.');
  4073. }
  4074. }
  4075. if (null === $stability) {
  4076. if (null === $packageVersion) {
  4077. $stability = 'stable';
  4078. } elseif (Preg::isMatchStrictGroups('{^[^,\s]*?@('.implode('|', array_keys(BasePackage::$stabilities)).')$}i', $packageVersion, $match)) {
  4079. $stability = $match[1];
  4080. } else {
  4081. $stability = VersionParser::parseStability($packageVersion);
  4082. }
  4083. }
  4084. $stability = VersionParser::normalizeStability($stability);
  4085. if (!isset(BasePackage::$stabilities[$stability])) {
  4086. throw new \InvalidArgumentException('Invalid stability provided ('.$stability.'), must be one of: '.implode(', ', array_keys(BasePackage::$stabilities)));
  4087. }
  4088. $composer = Factory::create($io, $config->all(), $disablePlugins, $disableScripts);
  4089. $config = $composer->getConfig();
  4090. $rm = $composer->getRepositoryManager();
  4091. $repositorySet = new RepositorySet($stability);
  4092. if (null === $repositories) {
  4093. $repositorySet->addRepository(new CompositeRepository(RepositoryFactory::defaultRepos($io, $config, $rm)));
  4094. } else {
  4095. foreach ($repositories as $repo) {
  4096. $repoConfig = RepositoryFactory::configFromString($io, $config, $repo, true);
  4097. if (
  4098. (isset($repoConfig['packagist']) && $repoConfig === ['packagist' => false])
  4099. || (isset($repoConfig['packagist.org']) && $repoConfig === ['packagist.org' => false])
  4100. ) {
  4101. continue;
  4102. }
  4103. $repositorySet->addRepository(RepositoryFactory::createRepo($io, $config, $repoConfig, $rm));
  4104. }
  4105. }
  4106. $platformOverrides = $config->get('platform');
  4107. $platformRepo = new PlatformRepository([], $platformOverrides);
  4108. $versionSelector = new VersionSelector($repositorySet, $platformRepo);
  4109. $package = $versionSelector->findBestCandidate($name, $packageVersion, $stability, $platformRequirementFilter, 0, $io);
  4110. if (!$package) {
  4111. $errorMessage = "Could not find package $name with " . ($packageVersion ? "version $packageVersion" : "stability $stability");
  4112. if (!($platformRequirementFilter instanceof IgnoreAllPlatformRequirementFilter) && $versionSelector->findBestCandidate($name, $packageVersion, $stability, PlatformRequirementFilterFactory::ignoreAll())) {
  4113. throw new \InvalidArgumentException($errorMessage .' in a version installable using your PHP version, PHP extensions and Composer version.');
  4114. }
  4115. throw new \InvalidArgumentException($errorMessage .'.');
  4116. }
  4117. @mkdir($directory, 0777, true);
  4118. if (false !== ($realDir = realpath($directory))) {
  4119. $signalHandler = SignalHandler::create([SignalHandler::SIGINT, SignalHandler::SIGTERM, SignalHandler::SIGHUP], function (string $signal, SignalHandler $handler) use ($realDir) {
  4120. $this->getIO()->writeError('Received '.$signal.', aborting', true, IOInterface::DEBUG);
  4121. $fs = new Filesystem();
  4122. $fs->removeDirectory($realDir);
  4123. $handler->exitWithLastSignal();
  4124. });
  4125. }
  4126. if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  4127. $package = $package->getAliasOf();
  4128. }
  4129. $io->writeError('<info>Installing ' . $package->getName() . ' (' . $package->getFullPrettyVersion(false) . ')</info>');
  4130. if ($disablePlugins) {
  4131. $io->writeError('<info>Plugins have been disabled.</info>');
  4132. }
  4133. if ($package instanceof AliasPackage) {
  4134. $package = $package->getAliasOf();
  4135. }
  4136. $dm = $composer->getDownloadManager();
  4137. $dm->setPreferSource($preferSource)
  4138. ->setPreferDist($preferDist);
  4139. $projectInstaller = new ProjectInstaller($directory, $dm, $fs);
  4140. $im = $composer->getInstallationManager();
  4141. $im->setOutputProgress(!$noProgress);
  4142. $im->addInstaller($projectInstaller);
  4143. $im->execute(new InstalledArrayRepository(), [new InstallOperation($package)]);
  4144. $im->notifyInstalls($io);
  4145. $this->suggestedPackagesReporter->addSuggestionsFromPackage($package);
  4146. $installedFromVcs = 'source' === $package->getInstallationSource();
  4147. $io->writeError('<info>Created project in ' . $directory . '</info>');
  4148. chdir($directory);
  4149. if (file_exists($directory.'/composer.json') && Platform::getEnv('COMPOSER') !== false) {
  4150. Platform::clearEnv('COMPOSER');
  4151. }
  4152. Platform::putEnv('COMPOSER_ROOT_VERSION', $package->getPrettyVersion());
  4153. if (isset($signalHandler)) {
  4154. $signalHandler->unregister();
  4155. }
  4156. return $installedFromVcs;
  4157. }
  4158. }
  4159. <?php declare(strict_types=1);
  4160. namespace Composer\Command;
  4161. use Symfony\Component\Console\Input\InputInterface;
  4162. use Symfony\Component\Console\Output\OutputInterface;
  4163. use Composer\Console\Input\InputArgument;
  4164. use Composer\Console\Input\InputOption;
  4165. class DependsCommand extends BaseDependencyCommand
  4166. {
  4167. use CompletionTrait;
  4168. protected function configure(): void
  4169. {
  4170. $this
  4171. ->setName('depends')
  4172. ->setAliases(['why'])
  4173. ->setDescription('Shows which packages cause the given package to be installed')
  4174. ->setDefinition([
  4175. new InputArgument(self::ARGUMENT_PACKAGE, InputArgument::REQUIRED, 'Package to inspect', null, $this->suggestInstalledPackage(true, true)),
  4176. new InputOption(self::OPTION_RECURSIVE, 'r', InputOption::VALUE_NONE, 'Recursively resolves up to the root package'),
  4177. new InputOption(self::OPTION_TREE, 't', InputOption::VALUE_NONE, 'Prints the results as a nested tree'),
  4178. new InputOption('locked', null, InputOption::VALUE_NONE, 'Read dependency information from composer.lock'),
  4179. ])
  4180. ->setHelp(
  4181. <<<EOT
  4182. Displays detailed information about where a package is referenced.
  4183. <info>php composer.phar depends composer/composer</info>
  4184. Read more at https://getcomposer.org/doc/03-cli.md#depends-why
  4185. EOT
  4186. )
  4187. ;
  4188. }
  4189. protected function execute(InputInterface $input, OutputInterface $output): int
  4190. {
  4191. return parent::doExecute($input, $output);
  4192. }
  4193. }
  4194. <?php declare(strict_types=1);
  4195. namespace Composer\Command;
  4196. use Composer\Composer;
  4197. use Composer\Factory;
  4198. use Composer\Config;
  4199. use Composer\Downloader\TransportException;
  4200. use Composer\Pcre\Preg;
  4201. use Composer\Repository\PlatformRepository;
  4202. use Composer\Plugin\CommandEvent;
  4203. use Composer\Plugin\PluginEvents;
  4204. use Composer\Util\ConfigValidator;
  4205. use Composer\Util\Git;
  4206. use Composer\Util\IniHelper;
  4207. use Composer\Util\ProcessExecutor;
  4208. use Composer\Util\HttpDownloader;
  4209. use Composer\Util\StreamContextFactory;
  4210. use Composer\Util\Platform;
  4211. use Composer\SelfUpdate\Keys;
  4212. use Composer\SelfUpdate\Versions;
  4213. use Composer\IO\NullIO;
  4214. use Composer\Package\CompletePackageInterface;
  4215. use Composer\XdebugHandler\XdebugHandler;
  4216. use Symfony\Component\Console\Input\InputInterface;
  4217. use Symfony\Component\Console\Output\OutputInterface;
  4218. use Symfony\Component\Process\ExecutableFinder;
  4219. class DiagnoseCommand extends BaseCommand
  4220. {
  4221. protected $httpDownloader;
  4222. protected $process;
  4223. protected $exitCode = 0;
  4224. protected function configure(): void
  4225. {
  4226. $this
  4227. ->setName('diagnose')
  4228. ->setDescription('Diagnoses the system to identify common errors')
  4229. ->setHelp(
  4230. <<<EOT
  4231. The <info>diagnose</info> command checks common errors to help debugging problems.
  4232. The process exit code will be 1 in case of warnings and 2 for errors.
  4233. Read more at https://getcomposer.org/doc/03-cli.md#diagnose
  4234. EOT
  4235. )
  4236. ;
  4237. }
  4238. protected function execute(InputInterface $input, OutputInterface $output)
  4239. {
  4240. $composer = $this->tryComposer();
  4241. $io = $this->getIO();
  4242. if ($composer) {
  4243. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'diagnose', $input, $output);
  4244. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  4245. $io->write('Checking composer.json: ', false);
  4246. $this->outputResult($this->checkComposerSchema());
  4247. $this->process = $composer->getLoop()->getProcessExecutor() ?? new ProcessExecutor($io);
  4248. } else {
  4249. $this->process = new ProcessExecutor($io);
  4250. }
  4251. if ($composer) {
  4252. $config = $composer->getConfig();
  4253. } else {
  4254. $config = Factory::createConfig();
  4255. }
  4256. $config->merge(['config' => ['secure-http' => false]], Config::SOURCE_COMMAND);
  4257. $config->prohibitUrlByConfig('http://repo.packagist.org', new NullIO);
  4258. $this->httpDownloader = Factory::createHttpDownloader($io, $config);
  4259. $io->write('Checking platform settings: ', false);
  4260. $this->outputResult($this->checkPlatform());
  4261. $io->write('Checking git settings: ', false);
  4262. $this->outputResult($this->checkGit());
  4263. $io->write('Checking http connectivity to packagist: ', false);
  4264. $this->outputResult($this->checkHttp('http', $config));
  4265. $io->write('Checking https connectivity to packagist: ', false);
  4266. $this->outputResult($this->checkHttp('https', $config));
  4267. $opts = stream_context_get_options(StreamContextFactory::getContext('http://example.org'));
  4268. if (!empty($opts['http']['proxy'])) {
  4269. $io->write('Checking HTTP proxy: ', false);
  4270. $this->outputResult($this->checkHttpProxy());
  4271. }
  4272. if (count($oauth = $config->get('github-oauth')) > 0) {
  4273. foreach ($oauth as $domain => $token) {
  4274. $io->write('Checking '.$domain.' oauth access: ', false);
  4275. $this->outputResult($this->checkGithubOauth($domain, $token));
  4276. }
  4277. } else {
  4278. $io->write('Checking github.com rate limit: ', false);
  4279. try {
  4280. $rate = $this->getGithubRateLimit('github.com');
  4281. if (!is_array($rate)) {
  4282. $this->outputResult($rate);
  4283. } elseif (10 > $rate['remaining']) {
  4284. $io->write('<warning>WARNING</warning>');
  4285. $io->write(sprintf(
  4286. '<comment>Github has a rate limit on their API. '
  4287. . 'You currently have <options=bold>%u</options=bold> '
  4288. . 'out of <options=bold>%u</options=bold> requests left.' . PHP_EOL
  4289. . 'See https://developer.github.com/v3/#rate-limiting and also' . PHP_EOL
  4290. . ' https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens</comment>',
  4291. $rate['remaining'],
  4292. $rate['limit']
  4293. ));
  4294. } else {
  4295. $this->outputResult(true);
  4296. }
  4297. } catch (\Exception $e) {
  4298. if ($e instanceof TransportException && $e->getCode() === 401) {
  4299. $this->outputResult('<comment>The oauth token for github.com seems invalid, run "composer config --global --unset github-oauth.github.com" to remove it</comment>');
  4300. } else {
  4301. $this->outputResult($e);
  4302. }
  4303. }
  4304. }
  4305. $io->write('Checking disk free space: ', false);
  4306. $this->outputResult($this->checkDiskSpace($config));
  4307. if (strpos(__FILE__, 'phar:') === 0) {
  4308. $io->write('Checking pubkeys: ', false);
  4309. $this->outputResult($this->checkPubKeys($config));
  4310. $io->write('Checking composer version: ', false);
  4311. $this->outputResult($this->checkVersion($config));
  4312. }
  4313. $io->write(sprintf('Composer version: <comment>%s</comment>', Composer::getVersion()));
  4314. $platformOverrides = $config->get('platform') ?: [];
  4315. $platformRepo = new PlatformRepository([], $platformOverrides);
  4316. $phpPkg = $platformRepo->findPackage('php', '*');
  4317. $phpVersion = $phpPkg->getPrettyVersion();
  4318. if ($phpPkg instanceof CompletePackageInterface && str_contains((string) $phpPkg->getDescription(), 'overridden')) {
  4319. $phpVersion .= ' - ' . $phpPkg->getDescription();
  4320. }
  4321. $io->write(sprintf('PHP version: <comment>%s</comment>', $phpVersion));
  4322. if (defined('PHP_BINARY')) {
  4323. $io->write(sprintf('PHP binary path: <comment>%s</comment>', PHP_BINARY));
  4324. }
  4325. $io->write('OpenSSL version: ' . (defined('OPENSSL_VERSION_TEXT') ? '<comment>'.OPENSSL_VERSION_TEXT.'</comment>' : '<error>missing</error>'));
  4326. $io->write('cURL version: ' . $this->getCurlVersion());
  4327. $finder = new ExecutableFinder;
  4328. $hasSystemUnzip = (bool) $finder->find('unzip');
  4329. $bin7zip = '';
  4330. if ($hasSystem7zip = (bool) $finder->find('7z', null, ['C:\Program Files\7-Zip'])) {
  4331. $bin7zip = '7z';
  4332. }
  4333. if (!Platform::isWindows() && !$hasSystem7zip && $hasSystem7zip = (bool) $finder->find('7zz')) {
  4334. $bin7zip = '7zz';
  4335. }
  4336. $io->write(
  4337. 'zip: ' . (extension_loaded('zip') ? '<comment>extension present</comment>' : '<comment>extension not loaded</comment>')
  4338. . ', ' . ($hasSystemUnzip ? '<comment>unzip present</comment>' : '<comment>unzip not available</comment>')
  4339. . ', ' . ($hasSystem7zip ? '<comment>7-Zip present ('.$bin7zip.')</comment>' : '<comment>7-Zip not available</comment>')
  4340. . (($hasSystem7zip || $hasSystemUnzip) && !function_exists('proc_open') ? ', <warning>proc_open is disabled or not present, unzip/7-z will not be usable</warning>' : '')
  4341. );
  4342. return $this->exitCode;
  4343. }
  4344. private function checkComposerSchema()
  4345. {
  4346. $validator = new ConfigValidator($this->getIO());
  4347. [$errors, , $warnings] = $validator->validate(Factory::getComposerFile());
  4348. if ($errors || $warnings) {
  4349. $messages = [
  4350. 'error' => $errors,
  4351. 'warning' => $warnings,
  4352. ];
  4353. $output = '';
  4354. foreach ($messages as $style => $msgs) {
  4355. foreach ($msgs as $msg) {
  4356. $output .= '<' . $style . '>' . $msg . '</' . $style . '>' . PHP_EOL;
  4357. }
  4358. }
  4359. return rtrim($output);
  4360. }
  4361. return true;
  4362. }
  4363. private function checkGit(): string
  4364. {
  4365. if (!function_exists('proc_open')) {
  4366. return '<comment>proc_open is not available, git cannot be used</comment>';
  4367. }
  4368. $this->process->execute('git config color.ui', $output);
  4369. if (strtolower(trim($output)) === 'always') {
  4370. 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>';
  4371. }
  4372. $gitVersion = Git::getVersion($this->process);
  4373. if (null === $gitVersion) {
  4374. return '<comment>No git process found</>';
  4375. }
  4376. if (version_compare('2.24.0', $gitVersion, '>')) {
  4377. return '<warning>Your git version ('.$gitVersion.') is too old and possibly will cause issues. Please upgrade to git 2.24 or above</>';
  4378. }
  4379. return '<info>OK</> <comment>git version '.$gitVersion.'</>';
  4380. }
  4381. private function checkHttp(string $proto, Config $config)
  4382. {
  4383. $result = $this->checkConnectivityAndComposerNetworkHttpEnablement();
  4384. if ($result !== true) {
  4385. return $result;
  4386. }
  4387. $result = [];
  4388. if ($proto === 'https' && $config->get('disable-tls') === true) {
  4389. $tlsWarning = '<warning>Composer is configured to disable SSL/TLS protection. This will leave remote HTTPS requests vulnerable to Man-In-The-Middle attacks.</warning>';
  4390. }
  4391. try {
  4392. $this->httpDownloader->get($proto . '://repo.packagist.org/packages.json');
  4393. } catch (TransportException $e) {
  4394. $hints = HttpDownloader::getExceptionHints($e);
  4395. if (null !== $hints && count($hints) > 0) {
  4396. foreach ($hints as $hint) {
  4397. $result[] = $hint;
  4398. }
  4399. }
  4400. $result[] = '<error>[' . get_class($e) . '] ' . $e->getMessage() . '</error>';
  4401. }
  4402. if (isset($tlsWarning)) {
  4403. $result[] = $tlsWarning;
  4404. }
  4405. if (count($result) > 0) {
  4406. return $result;
  4407. }
  4408. return true;
  4409. }
  4410. private function checkHttpProxy()
  4411. {
  4412. $result = $this->checkConnectivityAndComposerNetworkHttpEnablement();
  4413. if ($result !== true) {
  4414. return $result;
  4415. }
  4416. $protocol = extension_loaded('openssl') ? 'https' : 'http';
  4417. try {
  4418. $json = $this->httpDownloader->get($protocol . '://repo.packagist.org/packages.json')->decodeJson();
  4419. $hash = reset($json['provider-includes']);
  4420. $hash = $hash['sha256'];
  4421. $path = str_replace('%hash%', $hash, key($json['provider-includes']));
  4422. $provider = $this->httpDownloader->get($protocol . '://repo.packagist.org/'.$path)->getBody();
  4423. if (hash('sha256', $provider) !== $hash) {
  4424. return 'It seems that your proxy is modifying http traffic on the fly';
  4425. }
  4426. } catch (\Exception $e) {
  4427. return $e;
  4428. }
  4429. return true;
  4430. }
  4431. private function checkGithubOauth(string $domain, string $token)
  4432. {
  4433. $result = $this->checkConnectivityAndComposerNetworkHttpEnablement();
  4434. if ($result !== true) {
  4435. return $result;
  4436. }
  4437. $this->getIO()->setAuthentication($domain, $token, 'x-oauth-basic');
  4438. try {
  4439. $url = $domain === 'github.com' ? 'https://api.'.$domain.'/' : 'https://'.$domain.'/api/v3/';
  4440. $this->httpDownloader->get($url, [
  4441. 'retry-auth-failure' => false,
  4442. ]);
  4443. return true;
  4444. } catch (\Exception $e) {
  4445. if ($e instanceof TransportException && $e->getCode() === 401) {
  4446. return '<comment>The oauth token for '.$domain.' seems invalid, run "composer config --global --unset github-oauth.'.$domain.'" to remove it</comment>';
  4447. }
  4448. return $e;
  4449. }
  4450. }
  4451. private function getGithubRateLimit(string $domain, ?string $token = null)
  4452. {
  4453. $result = $this->checkConnectivityAndComposerNetworkHttpEnablement();
  4454. if ($result !== true) {
  4455. return $result;
  4456. }
  4457. if ($token) {
  4458. $this->getIO()->setAuthentication($domain, $token, 'x-oauth-basic');
  4459. }
  4460. $url = $domain === 'github.com' ? 'https://api.'.$domain.'/rate_limit' : 'https://'.$domain.'/api/rate_limit';
  4461. $data = $this->httpDownloader->get($url, ['retry-auth-failure' => false])->decodeJson();
  4462. return $data['resources']['core'];
  4463. }
  4464. private function checkDiskSpace(Config $config)
  4465. {
  4466. if (!function_exists('disk_free_space')) {
  4467. return true;
  4468. }
  4469. $minSpaceFree = 1024 * 1024;
  4470. if ((($df = @disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree)
  4471. || (($df = @disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree)
  4472. ) {
  4473. return '<error>The disk hosting '.$dir.' is full</error>';
  4474. }
  4475. return true;
  4476. }
  4477. private function checkPubKeys(Config $config)
  4478. {
  4479. $home = $config->get('home');
  4480. $errors = [];
  4481. $io = $this->getIO();
  4482. if (file_exists($home.'/keys.tags.pub') && file_exists($home.'/keys.dev.pub')) {
  4483. $io->write('');
  4484. }
  4485. if (file_exists($home.'/keys.tags.pub')) {
  4486. $io->write('Tags Public Key Fingerprint: ' . Keys::fingerprint($home.'/keys.tags.pub'));
  4487. } else {
  4488. $errors[] = '<error>Missing pubkey for tags verification</error>';
  4489. }
  4490. if (file_exists($home.'/keys.dev.pub')) {
  4491. $io->write('Dev Public Key Fingerprint: ' . Keys::fingerprint($home.'/keys.dev.pub'));
  4492. } else {
  4493. $errors[] = '<error>Missing pubkey for dev verification</error>';
  4494. }
  4495. if ($errors) {
  4496. $errors[] = '<error>Run composer self-update --update-keys to set them up</error>';
  4497. }
  4498. return $errors ?: true;
  4499. }
  4500. private function checkVersion(Config $config)
  4501. {
  4502. $result = $this->checkConnectivityAndComposerNetworkHttpEnablement();
  4503. if ($result !== true) {
  4504. return $result;
  4505. }
  4506. $versionsUtil = new Versions($config, $this->httpDownloader);
  4507. try {
  4508. $latest = $versionsUtil->getLatest();
  4509. } catch (\Exception $e) {
  4510. return $e;
  4511. }
  4512. if (Composer::VERSION !== $latest['version'] && Composer::VERSION !== '@package_version@') {
  4513. return '<comment>You are not running the latest '.$versionsUtil->getChannel().' version, run `composer self-update` to update ('.Composer::VERSION.' => '.$latest['version'].')</comment>';
  4514. }
  4515. return true;
  4516. }
  4517. private function getCurlVersion(): string
  4518. {
  4519. if (extension_loaded('curl')) {
  4520. if (!HttpDownloader::isCurlEnabled()) {
  4521. return '<error>disabled via disable_functions, using php streams fallback, which reduces performance</error>';
  4522. }
  4523. $version = curl_version();
  4524. return '<comment>'.$version['version'].'</comment> '.
  4525. 'libz <comment>'.(!empty($version['libz_version']) ? $version['libz_version'] : 'missing').'</comment> '.
  4526. 'ssl <comment>'.($version['ssl_version'] ?? 'missing').'</comment>';
  4527. }
  4528. return '<error>missing, using php streams fallback, which reduces performance</error>';
  4529. }
  4530. private function outputResult($result): void
  4531. {
  4532. $io = $this->getIO();
  4533. if (true === $result) {
  4534. $io->write('<info>OK</info>');
  4535. return;
  4536. }
  4537. $hadError = false;
  4538. $hadWarning = false;
  4539. if ($result instanceof \Exception) {
  4540. $result = '<error>['.get_class($result).'] '.$result->getMessage().'</error>';
  4541. }
  4542. if (!$result) {
  4543. $hadError = true;
  4544. } else {
  4545. if (!is_array($result)) {
  4546. $result = [$result];
  4547. }
  4548. foreach ($result as $message) {
  4549. if (false !== strpos($message, '<error>')) {
  4550. $hadError = true;
  4551. } elseif (false !== strpos($message, '<warning>')) {
  4552. $hadWarning = true;
  4553. }
  4554. }
  4555. }
  4556. if ($hadError) {
  4557. $io->write('<error>FAIL</error>');
  4558. $this->exitCode = max($this->exitCode, 2);
  4559. } elseif ($hadWarning) {
  4560. $io->write('<warning>WARNING</warning>');
  4561. $this->exitCode = max($this->exitCode, 1);
  4562. }
  4563. if ($result) {
  4564. foreach ($result as $message) {
  4565. $io->write($message);
  4566. }
  4567. }
  4568. }
  4569. private function checkPlatform()
  4570. {
  4571. $output = '';
  4572. $out = static function ($msg, $style) use (&$output): void {
  4573. $output .= '<'.$style.'>'.$msg.'</'.$style.'>'.PHP_EOL;
  4574. };
  4575. $errors = [];
  4576. $warnings = [];
  4577. $displayIniMessage = false;
  4578. $iniMessage = PHP_EOL.PHP_EOL.IniHelper::getMessage();
  4579. $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.';
  4580. if (!function_exists('json_decode')) {
  4581. $errors['json'] = true;
  4582. }
  4583. if (!extension_loaded('Phar')) {
  4584. $errors['phar'] = true;
  4585. }
  4586. if (!extension_loaded('filter')) {
  4587. $errors['filter'] = true;
  4588. }
  4589. if (!extension_loaded('hash')) {
  4590. $errors['hash'] = true;
  4591. }
  4592. if (!extension_loaded('iconv') && !extension_loaded('mbstring')) {
  4593. $errors['iconv_mbstring'] = true;
  4594. }
  4595. if (!filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN)) {
  4596. $errors['allow_url_fopen'] = true;
  4597. }
  4598. if (extension_loaded('ionCube Loader') && ioncube_loader_iversion() < 40009) {
  4599. $errors['ioncube'] = ioncube_loader_version();
  4600. }
  4601. if (PHP_VERSION_ID < 70205) {
  4602. $errors['php'] = PHP_VERSION;
  4603. }
  4604. if (!extension_loaded('openssl')) {
  4605. $errors['openssl'] = true;
  4606. }
  4607. if (extension_loaded('openssl') && OPENSSL_VERSION_NUMBER < 0x1000100f) {
  4608. $warnings['openssl_version'] = true;
  4609. }
  4610. if (!defined('HHVM_VERSION') && !extension_loaded('apcu') && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
  4611. $warnings['apc_cli'] = true;
  4612. }
  4613. if (!extension_loaded('zlib')) {
  4614. $warnings['zlib'] = true;
  4615. }
  4616. ob_start();
  4617. phpinfo(INFO_GENERAL);
  4618. $phpinfo = ob_get_clean();
  4619. if (is_string($phpinfo) && Preg::isMatchStrictGroups('{Configure Command(?: *</td><td class="v">| *=> *)(.*?)(?:</td>|$)}m', $phpinfo, $match)) {
  4620. $configure = $match[1];
  4621. if (str_contains($configure, '--enable-sigchild')) {
  4622. $warnings['sigchild'] = true;
  4623. }
  4624. if (str_contains($configure, '--with-curlwrappers')) {
  4625. $warnings['curlwrappers'] = true;
  4626. }
  4627. }
  4628. if (filter_var(ini_get('xdebug.profiler_enabled'), FILTER_VALIDATE_BOOLEAN)) {
  4629. $warnings['xdebug_profile'] = true;
  4630. } elseif (XdebugHandler::isXdebugActive()) {
  4631. $warnings['xdebug_loaded'] = true;
  4632. }
  4633. if (defined('PHP_WINDOWS_VERSION_BUILD')
  4634. && (version_compare(PHP_VERSION, '7.2.23', '<')
  4635. || (version_compare(PHP_VERSION, '7.3.0', '>=')
  4636. && version_compare(PHP_VERSION, '7.3.10', '<')))) {
  4637. $warnings['onedrive'] = PHP_VERSION;
  4638. }
  4639. if (!empty($errors)) {
  4640. foreach ($errors as $error => $current) {
  4641. switch ($error) {
  4642. case 'json':
  4643. $text = PHP_EOL."The json extension is missing.".PHP_EOL;
  4644. $text .= "Install it or recompile php without --disable-json";
  4645. break;
  4646. case 'phar':
  4647. $text = PHP_EOL."The phar extension is missing.".PHP_EOL;
  4648. $text .= "Install it or recompile php without --disable-phar";
  4649. break;
  4650. case 'filter':
  4651. $text = PHP_EOL."The filter extension is missing.".PHP_EOL;
  4652. $text .= "Install it or recompile php without --disable-filter";
  4653. break;
  4654. case 'hash':
  4655. $text = PHP_EOL."The hash extension is missing.".PHP_EOL;
  4656. $text .= "Install it or recompile php without --disable-hash";
  4657. break;
  4658. case 'iconv_mbstring':
  4659. $text = PHP_EOL."The iconv OR mbstring extension is required and both are missing.".PHP_EOL;
  4660. $text .= "Install either of them or recompile php without --disable-iconv";
  4661. break;
  4662. case 'php':
  4663. $text = PHP_EOL."Your PHP ({$current}) is too old, you must upgrade to PHP 7.2.5 or higher.";
  4664. break;
  4665. case 'allow_url_fopen':
  4666. $text = PHP_EOL."The allow_url_fopen setting is incorrect.".PHP_EOL;
  4667. $text .= "Add the following to the end of your `php.ini`:".PHP_EOL;
  4668. $text .= " allow_url_fopen = On";
  4669. $displayIniMessage = true;
  4670. break;
  4671. case 'ioncube':
  4672. $text = PHP_EOL."Your ionCube Loader extension ($current) is incompatible with Phar files.".PHP_EOL;
  4673. $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;
  4674. $text .= " zend_extension = /usr/lib/php5/20090626+lfs/ioncube_loader_lin_5.3.so";
  4675. $displayIniMessage = true;
  4676. break;
  4677. case 'openssl':
  4678. $text = PHP_EOL."The openssl extension is missing, which means that secure HTTPS transfers are impossible.".PHP_EOL;
  4679. $text .= "If possible you should enable it or recompile php with --with-openssl";
  4680. break;
  4681. default:
  4682. throw new \InvalidArgumentException(sprintf("DiagnoseCommand: Unknown error type \"%s\". Please report at https://github.com/composer/composer/issues/new.", $error));
  4683. }
  4684. $out($text, 'error');
  4685. }
  4686. $output .= PHP_EOL;
  4687. }
  4688. if (!empty($warnings)) {
  4689. foreach ($warnings as $warning => $current) {
  4690. switch ($warning) {
  4691. case 'apc_cli':
  4692. $text = "The apc.enable_cli setting is incorrect.".PHP_EOL;
  4693. $text .= "Add the following to the end of your `php.ini`:".PHP_EOL;
  4694. $text .= " apc.enable_cli = Off";
  4695. $displayIniMessage = true;
  4696. break;
  4697. case 'zlib':
  4698. $text = 'The zlib extension is not loaded, this can slow down Composer a lot.'.PHP_EOL;
  4699. $text .= 'If possible, enable it or recompile php with --with-zlib'.PHP_EOL;
  4700. $displayIniMessage = true;
  4701. break;
  4702. case 'sigchild':
  4703. $text = "PHP was compiled with --enable-sigchild which can cause issues on some platforms.".PHP_EOL;
  4704. $text .= "Recompile it without this flag if possible, see also:".PHP_EOL;
  4705. $text .= " https://bugs.php.net/bug.php?id=22999";
  4706. break;
  4707. case 'curlwrappers':
  4708. $text = "PHP was compiled with --with-curlwrappers which will cause issues with HTTP authentication and GitHub.".PHP_EOL;
  4709. $text .= " Recompile it without this flag if possible";
  4710. break;
  4711. case 'openssl_version':
  4712. $opensslVersion = strstr(trim(strstr(OPENSSL_VERSION_TEXT, ' ')), ' ', true);
  4713. $opensslVersion = $opensslVersion ?: OPENSSL_VERSION_TEXT;
  4714. $text = "The OpenSSL library ({$opensslVersion}) used by PHP does not support TLSv1.2 or TLSv1.1.".PHP_EOL;
  4715. $text .= "If possible you should upgrade OpenSSL to version 1.0.1 or above.";
  4716. break;
  4717. case 'xdebug_loaded':
  4718. $text = "The xdebug extension is loaded, this can slow down Composer a little.".PHP_EOL;
  4719. $text .= " Disabling it when using Composer is recommended.";
  4720. break;
  4721. case 'xdebug_profile':
  4722. $text = "The xdebug.profiler_enabled setting is enabled, this can slow down Composer a lot.".PHP_EOL;
  4723. $text .= "Add the following to the end of your `php.ini` to disable it:".PHP_EOL;
  4724. $text .= " xdebug.profiler_enabled = 0";
  4725. $displayIniMessage = true;
  4726. break;
  4727. case 'onedrive':
  4728. $text = "The Windows OneDrive folder is not supported on PHP versions below 7.2.23 and 7.3.10.".PHP_EOL;
  4729. $text .= "Upgrade your PHP ({$current}) to use this location with Composer.".PHP_EOL;
  4730. break;
  4731. default:
  4732. throw new \InvalidArgumentException(sprintf("DiagnoseCommand: Unknown warning type \"%s\". Please report at https://github.com/composer/composer/issues/new.", $warning));
  4733. }
  4734. $out($text, 'comment');
  4735. }
  4736. }
  4737. if ($displayIniMessage) {
  4738. $out($iniMessage, 'comment');
  4739. }
  4740. return count($warnings) === 0 && count($errors) === 0 ? true : $output;
  4741. }
  4742. private function checkConnectivity()
  4743. {
  4744. if (!ini_get('allow_url_fopen')) {
  4745. return '<info>SKIP</> <comment>Because allow_url_fopen is missing.</>';
  4746. }
  4747. return true;
  4748. }
  4749. private function checkConnectivityAndComposerNetworkHttpEnablement()
  4750. {
  4751. $result = $this->checkConnectivity();
  4752. if ($result !== true) {
  4753. return $result;
  4754. }
  4755. $result = $this->checkComposerNetworkHttpEnablement();
  4756. if ($result !== true) {
  4757. return $result;
  4758. }
  4759. return true;
  4760. }
  4761. private function checkComposerNetworkHttpEnablement()
  4762. {
  4763. if ((bool) Platform::getEnv('COMPOSER_DISABLE_NETWORK')) {
  4764. return '<info>SKIP</> <comment>Network is disabled by COMPOSER_DISABLE_NETWORK.</>';
  4765. }
  4766. return true;
  4767. }
  4768. }
  4769. <?php declare(strict_types=1);
  4770. namespace Composer\Command;
  4771. use Composer\Plugin\CommandEvent;
  4772. use Composer\Plugin\PluginEvents;
  4773. use Symfony\Component\Console\Input\InputInterface;
  4774. use Symfony\Component\Console\Input\InputOption;
  4775. use Symfony\Component\Console\Output\OutputInterface;
  4776. class DumpAutoloadCommand extends BaseCommand
  4777. {
  4778. protected function configure()
  4779. {
  4780. $this
  4781. ->setName('dump-autoload')
  4782. ->setAliases(['dumpautoload'])
  4783. ->setDescription('Dumps the autoloader')
  4784. ->setDefinition([
  4785. new InputOption('optimize', 'o', InputOption::VALUE_NONE, 'Optimizes PSR0 and PSR4 packages to be loaded with classmaps too, good for production.'),
  4786. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize`.'),
  4787. new InputOption('apcu', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  4788. new InputOption('apcu-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu'),
  4789. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything.'),
  4790. 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.'),
  4791. 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.'),
  4792. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  4793. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  4794. new InputOption('strict-psr', null, InputOption::VALUE_NONE, 'Return a failed status code (1) if PSR-4 or PSR-0 mapping errors are present. Requires --optimize to work.'),
  4795. ])
  4796. ->setHelp(
  4797. <<<EOT
  4798. <info>php composer.phar dump-autoload</info>
  4799. Read more at https://getcomposer.org/doc/03-cli.md#dump-autoload-dumpautoload
  4800. EOT
  4801. )
  4802. ;
  4803. }
  4804. protected function execute(InputInterface $input, OutputInterface $output)
  4805. {
  4806. $composer = $this->requireComposer();
  4807. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'dump-autoload', $input, $output);
  4808. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  4809. $installationManager = $composer->getInstallationManager();
  4810. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  4811. $package = $composer->getPackage();
  4812. $config = $composer->getConfig();
  4813. $optimize = $input->getOption('optimize') || $config->get('optimize-autoloader');
  4814. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  4815. $apcuPrefix = $input->getOption('apcu-prefix');
  4816. $apcu = $apcuPrefix !== null || $input->getOption('apcu') || $config->get('apcu-autoloader');
  4817. if ($input->getOption('strict-psr') && !$optimize && !$authoritative) {
  4818. throw new \InvalidArgumentException('--strict-psr mode only works with optimized autoloader, use --optimize or --classmap-authoritative if you want a strict return value.');
  4819. }
  4820. if ($authoritative) {
  4821. $this->getIO()->write('<info>Generating optimized autoload files (authoritative)</info>');
  4822. } elseif ($optimize) {
  4823. $this->getIO()->write('<info>Generating optimized autoload files</info>');
  4824. } else {
  4825. $this->getIO()->write('<info>Generating autoload files</info>');
  4826. }
  4827. $generator = $composer->getAutoloadGenerator();
  4828. if ($input->getOption('dry-run')) {
  4829. $generator->setDryRun(true);
  4830. }
  4831. if ($input->getOption('no-dev')) {
  4832. $generator->setDevMode(false);
  4833. }
  4834. if ($input->getOption('dev')) {
  4835. if ($input->getOption('no-dev')) {
  4836. throw new \InvalidArgumentException('You can not use both --no-dev and --dev as they conflict with each other.');
  4837. }
  4838. $generator->setDevMode(true);
  4839. }
  4840. $generator->setClassMapAuthoritative($authoritative);
  4841. $generator->setRunScripts(true);
  4842. $generator->setApcu($apcu, $apcuPrefix);
  4843. $generator->setPlatformRequirementFilter($this->getPlatformRequirementFilter($input));
  4844. $classMap = $generator->dump(
  4845. $config,
  4846. $localRepo,
  4847. $package,
  4848. $installationManager,
  4849. 'composer',
  4850. $optimize,
  4851. null,
  4852. $composer->getLocker()
  4853. );
  4854. $numberOfClasses = count($classMap);
  4855. if ($authoritative) {
  4856. $this->getIO()->write('<info>Generated optimized autoload files (authoritative) containing '. $numberOfClasses .' classes</info>');
  4857. } elseif ($optimize) {
  4858. $this->getIO()->write('<info>Generated optimized autoload files containing '. $numberOfClasses .' classes</info>');
  4859. } else {
  4860. $this->getIO()->write('<info>Generated autoload files</info>');
  4861. }
  4862. if ($input->getOption('strict-psr') && count($classMap->getPsrViolations()) > 0) {
  4863. return 1;
  4864. }
  4865. return 0;
  4866. }
  4867. }
  4868. <?php declare(strict_types=1);
  4869. namespace Composer\Command;
  4870. use Symfony\Component\Console\Input\InputInterface;
  4871. use Composer\Console\Input\InputOption;
  4872. use Symfony\Component\Console\Output\OutputInterface;
  4873. use Composer\Console\Input\InputArgument;
  4874. class ExecCommand extends BaseCommand
  4875. {
  4876. protected function configure()
  4877. {
  4878. $this
  4879. ->setName('exec')
  4880. ->setDescription('Executes a vendored binary/script')
  4881. ->setDefinition([
  4882. new InputOption('list', 'l', InputOption::VALUE_NONE),
  4883. new InputArgument('binary', InputArgument::OPTIONAL, 'The binary to run, e.g. phpunit', null, function () {
  4884. return $this->getBinaries(false);
  4885. }),
  4886. new InputArgument(
  4887. 'args',
  4888. InputArgument::IS_ARRAY | InputArgument::OPTIONAL,
  4889. 'Arguments to pass to the binary. Use <info>--</info> to separate from composer arguments'
  4890. ),
  4891. ])
  4892. ->setHelp(
  4893. <<<EOT
  4894. Executes a vendored binary/script.
  4895. Read more at https://getcomposer.org/doc/03-cli.md#exec
  4896. EOT
  4897. )
  4898. ;
  4899. }
  4900. protected function interact(InputInterface $input, OutputInterface $output): void
  4901. {
  4902. $binaries = $this->getBinaries(false);
  4903. if (count($binaries) === 0) {
  4904. return;
  4905. }
  4906. if ($input->getArgument('binary') !== null || $input->getOption('list')) {
  4907. return;
  4908. }
  4909. $io = $this->getIO();
  4910. $binary = $io->select(
  4911. 'Binary to run: ',
  4912. $binaries,
  4913. '',
  4914. 1,
  4915. 'Invalid binary name "%s"'
  4916. );
  4917. $input->setArgument('binary', $binaries[$binary]);
  4918. }
  4919. protected function execute(InputInterface $input, OutputInterface $output)
  4920. {
  4921. $composer = $this->requireComposer();
  4922. if ($input->getOption('list') || null === $input->getArgument('binary')) {
  4923. $bins = $this->getBinaries(true);
  4924. if ([] === $bins) {
  4925. $binDir = $composer->getConfig()->get('bin-dir');
  4926. throw new \RuntimeException("No binaries found in composer.json or in bin-dir ($binDir)");
  4927. }
  4928. $this->getIO()->write(
  4929. <<<EOT
  4930. <comment>Available binaries:</comment>
  4931. EOT
  4932. );
  4933. foreach ($bins as $bin) {
  4934. $this->getIO()->write(
  4935. <<<EOT
  4936. <info>- $bin</info>
  4937. EOT
  4938. );
  4939. }
  4940. return 0;
  4941. }
  4942. $binary = $input->getArgument('binary');
  4943. $dispatcher = $composer->getEventDispatcher();
  4944. $dispatcher->addListener('__exec_command', $binary);
  4945. if (getcwd() !== $this->getApplication()->getInitialWorkingDirectory() && $this->getApplication()->getInitialWorkingDirectory() !== false) {
  4946. try {
  4947. chdir($this->getApplication()->getInitialWorkingDirectory());
  4948. } catch (\Exception $e) {
  4949. throw new \RuntimeException('Could not switch back to working directory "'.$this->getApplication()->getInitialWorkingDirectory().'"', 0, $e);
  4950. }
  4951. }
  4952. return $dispatcher->dispatchScript('__exec_command', true, $input->getArgument('args'));
  4953. }
  4954. private function getBinaries(bool $forDisplay): array
  4955. {
  4956. $composer = $this->requireComposer();
  4957. $binDir = $composer->getConfig()->get('bin-dir');
  4958. $bins = glob($binDir . '/*');
  4959. $localBins = $composer->getPackage()->getBinaries();
  4960. if ($forDisplay) {
  4961. $localBins = array_map(static function ($e) {
  4962. return "$e (local)";
  4963. }, $localBins);
  4964. }
  4965. $binaries = [];
  4966. foreach (array_merge($bins, $localBins) as $bin) {
  4967. if (isset($previousBin) && $bin === $previousBin.'.bat') {
  4968. continue;
  4969. }
  4970. $previousBin = $bin;
  4971. $binaries[] = basename($bin);
  4972. }
  4973. return $binaries;
  4974. }
  4975. }
  4976. <?php declare(strict_types=1);
  4977. namespace Composer\Command;
  4978. use Composer\Json\JsonFile;
  4979. use Composer\Package\AliasPackage;
  4980. use Composer\Package\BasePackage;
  4981. use Composer\Package\CompletePackageInterface;
  4982. use Composer\Pcre\Preg;
  4983. use Composer\Repository\CompositeRepository;
  4984. use Composer\Semver\Constraint\MatchAllConstraint;
  4985. use Symfony\Component\Console\Formatter\OutputFormatter;
  4986. use Symfony\Component\Console\Input\InputInterface;
  4987. use Composer\Console\Input\InputOption;
  4988. use Symfony\Component\Console\Output\OutputInterface;
  4989. class FundCommand extends BaseCommand
  4990. {
  4991. protected function configure(): void
  4992. {
  4993. $this->setName('fund')
  4994. ->setDescription('Discover how to help fund the maintenance of your dependencies')
  4995. ->setDefinition([
  4996. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text', ['text', 'json']),
  4997. ])
  4998. ;
  4999. }
  5000. protected function execute(InputInterface $input, OutputInterface $output): int
  5001. {
  5002. $composer = $this->requireComposer();
  5003. $repo = $composer->getRepositoryManager()->getLocalRepository();
  5004. $remoteRepos = new CompositeRepository($composer->getRepositoryManager()->getRepositories());
  5005. $fundings = [];
  5006. $packagesToLoad = [];
  5007. foreach ($repo->getPackages() as $package) {
  5008. if ($package instanceof AliasPackage) {
  5009. continue;
  5010. }
  5011. $packagesToLoad[$package->getName()] = new MatchAllConstraint();
  5012. }
  5013. $result = $remoteRepos->loadPackages($packagesToLoad, ['dev' => BasePackage::STABILITY_DEV], []);
  5014. foreach ($result['packages'] as $package) {
  5015. if (
  5016. !$package instanceof AliasPackage
  5017. && $package instanceof CompletePackageInterface
  5018. && $package->isDefaultBranch()
  5019. && $package->getFunding()
  5020. && isset($packagesToLoad[$package->getName()])
  5021. ) {
  5022. $fundings = $this->insertFundingData($fundings, $package);
  5023. unset($packagesToLoad[$package->getName()]);
  5024. }
  5025. }
  5026. foreach ($repo->getPackages() as $package) {
  5027. if ($package instanceof AliasPackage || !isset($packagesToLoad[$package->getName()])) {
  5028. continue;
  5029. }
  5030. if ($package instanceof CompletePackageInterface && $package->getFunding()) {
  5031. $fundings = $this->insertFundingData($fundings, $package);
  5032. }
  5033. }
  5034. ksort($fundings);
  5035. $io = $this->getIO();
  5036. $format = $input->getOption('format');
  5037. if (!in_array($format, ['text', 'json'])) {
  5038. $io->writeError(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  5039. return 1;
  5040. }
  5041. if ($fundings && $format === 'text') {
  5042. $prev = null;
  5043. $io->write('The following packages were found in your dependencies which publish funding information:');
  5044. foreach ($fundings as $vendor => $links) {
  5045. $io->write('');
  5046. $io->write(sprintf("<comment>%s</comment>", $vendor));
  5047. foreach ($links as $url => $packages) {
  5048. $line = sprintf(' <info>%s</info>', implode(', ', $packages));
  5049. if ($prev !== $line) {
  5050. $io->write($line);
  5051. $prev = $line;
  5052. }
  5053. $io->write(sprintf(' <href=%s>%s</>', OutputFormatter::escape($url), $url));
  5054. }
  5055. }
  5056. $io->write("");
  5057. $io->write("Please consider following these links and sponsoring the work of package authors!");
  5058. $io->write("Thank you!");
  5059. } elseif ($format === 'json') {
  5060. $io->write(JsonFile::encode($fundings));
  5061. } else {
  5062. $io->write("No funding links were found in your package dependencies. This doesn't mean they don't need your support!");
  5063. }
  5064. return 0;
  5065. }
  5066. private function insertFundingData(array $fundings, CompletePackageInterface $package): array
  5067. {
  5068. foreach ($package->getFunding() as $fundingOption) {
  5069. [$vendor, $packageName] = explode('/', $package->getPrettyName());
  5070. if (empty($fundingOption['url'])) {
  5071. continue;
  5072. }
  5073. $url = $fundingOption['url'];
  5074. if (!empty($fundingOption['type']) && $fundingOption['type'] === 'github' && Preg::isMatch('{^https://github.com/([^/]+)$}', $url, $match)) {
  5075. $url = 'https://github.com/sponsors/'.$match[1];
  5076. }
  5077. $fundings[$vendor][$url][] = $packageName;
  5078. }
  5079. return $fundings;
  5080. }
  5081. }
  5082. <?php declare(strict_types=1);
  5083. namespace Composer\Command;
  5084. use Composer\Factory;
  5085. use Composer\Pcre\Preg;
  5086. use Composer\Util\Filesystem;
  5087. use Composer\Util\Platform;
  5088. use Symfony\Component\Console\Command\Command;
  5089. use Symfony\Component\Console\Completion\CompletionInput;
  5090. use Symfony\Component\Console\Completion\CompletionSuggestions;
  5091. use Symfony\Component\Console\Input\InputInterface;
  5092. use Composer\Console\Input\InputArgument;
  5093. use Symfony\Component\Console\Input\StringInput;
  5094. use Symfony\Component\Console\Output\OutputInterface;
  5095. class GlobalCommand extends BaseCommand
  5096. {
  5097. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  5098. {
  5099. $application = $this->getApplication();
  5100. if ($input->mustSuggestArgumentValuesFor('command-name')) {
  5101. $suggestions->suggestValues(array_values(array_filter(array_map(static function (Command $command) {
  5102. return $command->isHidden() ? null : $command->getName();
  5103. }, $application->all()))));
  5104. return;
  5105. }
  5106. if ($application->has($commandName = $input->getArgument('command-name'))) {
  5107. $input = $this->prepareSubcommandInput($input, true);
  5108. $input = CompletionInput::fromString($input->__toString(), 2);
  5109. $command = $application->find($commandName);
  5110. $command->mergeApplicationDefinition();
  5111. $input->bind($command->getDefinition());
  5112. $command->complete($input, $suggestions);
  5113. }
  5114. }
  5115. protected function configure(): void
  5116. {
  5117. $this
  5118. ->setName('global')
  5119. ->setDescription('Allows running commands in the global composer dir ($COMPOSER_HOME)')
  5120. ->setDefinition([
  5121. new InputArgument('command-name', InputArgument::REQUIRED, ''),
  5122. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  5123. ])
  5124. ->setHelp(
  5125. <<<EOT
  5126. Use this command as a wrapper to run other Composer commands
  5127. within the global context of COMPOSER_HOME.
  5128. You can use this to install CLI utilities globally, all you need
  5129. is to add the COMPOSER_HOME/vendor/bin dir to your PATH env var.
  5130. COMPOSER_HOME is c:\Users\<user>\AppData\Roaming\Composer on Windows
  5131. and /home/<user>/.composer on unix systems.
  5132. If your system uses freedesktop.org standards, then it will first check
  5133. XDG_CONFIG_HOME or default to /home/<user>/.config/composer
  5134. Note: This path may vary depending on customizations to bin-dir in
  5135. composer.json or the environmental variable COMPOSER_BIN_DIR.
  5136. Read more at https://getcomposer.org/doc/03-cli.md#global
  5137. EOT
  5138. )
  5139. ;
  5140. }
  5141. public function run(InputInterface $input, OutputInterface $output): int
  5142. {
  5143. if (!method_exists($input, '__toString')) {
  5144. throw new \LogicException('Expected an Input instance that is stringable, got '.get_class($input));
  5145. }
  5146. $tokens = Preg::split('{\s+}', $input->__toString());
  5147. $args = [];
  5148. foreach ($tokens as $token) {
  5149. if ($token && $token[0] !== '-') {
  5150. $args[] = $token;
  5151. if (count($args) >= 2) {
  5152. break;
  5153. }
  5154. }
  5155. }
  5156. if (count($args) < 2) {
  5157. return parent::run($input, $output);
  5158. }
  5159. $input = $this->prepareSubcommandInput($input);
  5160. return $this->getApplication()->run($input, $output);
  5161. }
  5162. private function prepareSubcommandInput(InputInterface $input, bool $quiet = false): StringInput
  5163. {
  5164. if (!method_exists($input, '__toString')) {
  5165. throw new \LogicException('Expected an Input instance that is stringable, got '.get_class($input));
  5166. }
  5167. if (Platform::getEnv('COMPOSER')) {
  5168. Platform::clearEnv('COMPOSER');
  5169. }
  5170. $config = Factory::createConfig();
  5171. $home = $config->get('home');
  5172. if (!is_dir($home)) {
  5173. $fs = new Filesystem();
  5174. $fs->ensureDirectoryExists($home);
  5175. if (!is_dir($home)) {
  5176. throw new \RuntimeException('Could not create home directory');
  5177. }
  5178. }
  5179. try {
  5180. chdir($home);
  5181. } catch (\Exception $e) {
  5182. throw new \RuntimeException('Could not switch to home directory "'.$home.'"', 0, $e);
  5183. }
  5184. if (!$quiet) {
  5185. $this->getIO()->writeError('<info>Changed current directory to '.$home.'</info>');
  5186. }
  5187. $input = new StringInput(Preg::replace('{\bg(?:l(?:o(?:b(?:a(?:l)?)?)?)?)?\b}', '', $input->__toString(), 1));
  5188. $this->getApplication()->resetComposer();
  5189. return $input;
  5190. }
  5191. public function isProxyCommand(): bool
  5192. {
  5193. return true;
  5194. }
  5195. }
  5196. <?php declare(strict_types=1);
  5197. namespace Composer\Command;
  5198. use Composer\Package\CompletePackageInterface;
  5199. use Composer\Repository\RepositoryInterface;
  5200. use Composer\Repository\RootPackageRepository;
  5201. use Composer\Repository\RepositoryFactory;
  5202. use Composer\Util\Platform;
  5203. use Composer\Util\ProcessExecutor;
  5204. use Composer\Console\Input\InputArgument;
  5205. use Composer\Console\Input\InputOption;
  5206. use Symfony\Component\Console\Input\InputInterface;
  5207. use Symfony\Component\Console\Output\OutputInterface;
  5208. class HomeCommand extends BaseCommand
  5209. {
  5210. use CompletionTrait;
  5211. protected function configure(): void
  5212. {
  5213. $this
  5214. ->setName('browse')
  5215. ->setAliases(['home'])
  5216. ->setDescription('Opens the package\'s repository URL or homepage in your browser')
  5217. ->setDefinition([
  5218. new InputArgument('packages', InputArgument::IS_ARRAY, 'Package(s) to browse to.', null, $this->suggestInstalledPackage()),
  5219. new InputOption('homepage', 'H', InputOption::VALUE_NONE, 'Open the homepage instead of the repository URL.'),
  5220. new InputOption('show', 's', InputOption::VALUE_NONE, 'Only show the homepage or repository URL.'),
  5221. ])
  5222. ->setHelp(
  5223. <<<EOT
  5224. The home command opens or shows a package's repository URL or
  5225. homepage in your default browser.
  5226. To open the homepage by default, use -H or --homepage.
  5227. To show instead of open the repository or homepage URL, use -s or --show.
  5228. Read more at https://getcomposer.org/doc/03-cli.md#browse-home
  5229. EOT
  5230. );
  5231. }
  5232. protected function execute(InputInterface $input, OutputInterface $output): int
  5233. {
  5234. $repos = $this->initializeRepos();
  5235. $io = $this->getIO();
  5236. $return = 0;
  5237. $packages = $input->getArgument('packages');
  5238. if (count($packages) === 0) {
  5239. $io->writeError('No package specified, opening homepage for the root package');
  5240. $packages = [$this->requireComposer()->getPackage()->getName()];
  5241. }
  5242. foreach ($packages as $packageName) {
  5243. $handled = false;
  5244. $packageExists = false;
  5245. foreach ($repos as $repo) {
  5246. foreach ($repo->findPackages($packageName) as $package) {
  5247. $packageExists = true;
  5248. if ($package instanceof CompletePackageInterface && $this->handlePackage($package, $input->getOption('homepage'), $input->getOption('show'))) {
  5249. $handled = true;
  5250. break 2;
  5251. }
  5252. }
  5253. }
  5254. if (!$packageExists) {
  5255. $return = 1;
  5256. $io->writeError('<warning>Package '.$packageName.' not found</warning>');
  5257. }
  5258. if (!$handled) {
  5259. $return = 1;
  5260. $io->writeError('<warning>'.($input->getOption('homepage') ? 'Invalid or missing homepage' : 'Invalid or missing repository URL').' for '.$packageName.'</warning>');
  5261. }
  5262. }
  5263. return $return;
  5264. }
  5265. private function handlePackage(CompletePackageInterface $package, bool $showHomepage, bool $showOnly): bool
  5266. {
  5267. $support = $package->getSupport();
  5268. $url = $support['source'] ?? $package->getSourceUrl();
  5269. if (!$url || $showHomepage) {
  5270. $url = $package->getHomepage();
  5271. }
  5272. if (!$url || !filter_var($url, FILTER_VALIDATE_URL)) {
  5273. return false;
  5274. }
  5275. if ($showOnly) {
  5276. $this->getIO()->write(sprintf('<info>%s</info>', $url));
  5277. } else {
  5278. $this->openBrowser($url);
  5279. }
  5280. return true;
  5281. }
  5282. private function openBrowser(string $url): void
  5283. {
  5284. $url = ProcessExecutor::escape($url);
  5285. $process = new ProcessExecutor($this->getIO());
  5286. if (Platform::isWindows()) {
  5287. $process->execute('start "web" explorer ' . $url, $output);
  5288. return;
  5289. }
  5290. $linux = $process->execute('which xdg-open', $output);
  5291. $osx = $process->execute('which open', $output);
  5292. if (0 === $linux) {
  5293. $process->execute('xdg-open ' . $url, $output);
  5294. } elseif (0 === $osx) {
  5295. $process->execute('open ' . $url, $output);
  5296. } else {
  5297. $this->getIO()->writeError('No suitable browser opening command found, open yourself: ' . $url);
  5298. }
  5299. }
  5300. private function initializeRepos(): array
  5301. {
  5302. $composer = $this->tryComposer();
  5303. if ($composer) {
  5304. return array_merge(
  5305. [new RootPackageRepository(clone $composer->getPackage())],
  5306. [$composer->getRepositoryManager()->getLocalRepository()],
  5307. $composer->getRepositoryManager()->getRepositories()
  5308. );
  5309. }
  5310. return RepositoryFactory::defaultReposWithDefaultManager($this->getIO());
  5311. }
  5312. }
  5313. <?php declare(strict_types=1);
  5314. namespace Composer\Command;
  5315. use Composer\Factory;
  5316. use Composer\Json\JsonFile;
  5317. use Composer\Json\JsonValidationException;
  5318. use Composer\Package\BasePackage;
  5319. use Composer\Package\Package;
  5320. use Composer\Pcre\Preg;
  5321. use Composer\Repository\CompositeRepository;
  5322. use Composer\Repository\PlatformRepository;
  5323. use Composer\Repository\RepositoryFactory;
  5324. use Composer\Util\Filesystem;
  5325. use Composer\Util\Silencer;
  5326. use Symfony\Component\Console\Input\ArrayInput;
  5327. use Symfony\Component\Console\Input\InputInterface;
  5328. use Composer\Console\Input\InputOption;
  5329. use Symfony\Component\Console\Output\OutputInterface;
  5330. use Symfony\Component\Process\ExecutableFinder;
  5331. use Symfony\Component\Process\Process;
  5332. use Symfony\Component\Console\Helper\FormatterHelper;
  5333. class InitCommand extends BaseCommand
  5334. {
  5335. use CompletionTrait;
  5336. use PackageDiscoveryTrait;
  5337. private $gitConfig;
  5338. protected function configure()
  5339. {
  5340. $this
  5341. ->setName('init')
  5342. ->setDescription('Creates a basic composer.json file in current directory')
  5343. ->setDefinition([
  5344. new InputOption('name', null, InputOption::VALUE_REQUIRED, 'Name of the package'),
  5345. new InputOption('description', null, InputOption::VALUE_REQUIRED, 'Description of package'),
  5346. new InputOption('author', null, InputOption::VALUE_REQUIRED, 'Author name of package'),
  5347. new InputOption('type', null, InputOption::VALUE_OPTIONAL, 'Type of package (e.g. library, project, metapackage, composer-plugin)'),
  5348. new InputOption('homepage', null, InputOption::VALUE_REQUIRED, 'Homepage of package'),
  5349. 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"', null, $this->suggestAvailablePackageInclPlatform()),
  5350. 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"', null, $this->suggestAvailablePackageInclPlatform()),
  5351. new InputOption('stability', 's', InputOption::VALUE_REQUIRED, 'Minimum stability (empty or one of: '.implode(', ', array_keys(BasePackage::$stabilities)).')'),
  5352. new InputOption('license', 'l', InputOption::VALUE_REQUIRED, 'License of package'),
  5353. new InputOption('repository', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Add custom repositories, either by URL or using JSON arrays'),
  5354. 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/)'),
  5355. ])
  5356. ->setHelp(
  5357. <<<EOT
  5358. The <info>init</info> command creates a basic composer.json file
  5359. in the current directory.
  5360. <info>php composer.phar init</info>
  5361. Read more at https://getcomposer.org/doc/03-cli.md#init
  5362. EOT
  5363. )
  5364. ;
  5365. }
  5366. protected function execute(InputInterface $input, OutputInterface $output)
  5367. {
  5368. $io = $this->getIO();
  5369. $allowlist = ['name', 'description', 'author', 'type', 'homepage', 'require', 'require-dev', 'stability', 'license', 'autoload'];
  5370. $options = array_filter(array_intersect_key($input->getOptions(), array_flip($allowlist)));
  5371. if (isset($options['name']) && !Preg::isMatch('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}D', $options['name'])) {
  5372. throw new \InvalidArgumentException(
  5373. '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_.-]+'
  5374. );
  5375. }
  5376. if (isset($options['author'])) {
  5377. $options['authors'] = $this->formatAuthors($options['author']);
  5378. unset($options['author']);
  5379. }
  5380. $repositories = $input->getOption('repository');
  5381. if (count($repositories) > 0) {
  5382. $config = Factory::createConfig($io);
  5383. foreach ($repositories as $repo) {
  5384. $options['repositories'][] = RepositoryFactory::configFromString($io, $config, $repo, true);
  5385. }
  5386. }
  5387. if (isset($options['stability'])) {
  5388. $options['minimum-stability'] = $options['stability'];
  5389. unset($options['stability']);
  5390. }
  5391. $options['require'] = isset($options['require']) ? $this->formatRequirements($options['require']) : new \stdClass;
  5392. if ([] === $options['require']) {
  5393. $options['require'] = new \stdClass;
  5394. }
  5395. if (isset($options['require-dev'])) {
  5396. $options['require-dev'] = $this->formatRequirements($options['require-dev']);
  5397. if ([] === $options['require-dev']) {
  5398. $options['require-dev'] = new \stdClass;
  5399. }
  5400. }
  5401. $autoloadPath = null;
  5402. if (isset($options['autoload'])) {
  5403. $autoloadPath = $options['autoload'];
  5404. $namespace = $this->namespaceFromPackageName((string) $input->getOption('name'));
  5405. $options['autoload'] = (object) [
  5406. 'psr-4' => [
  5407. $namespace . '\\' => $autoloadPath,
  5408. ],
  5409. ];
  5410. }
  5411. $file = new JsonFile(Factory::getComposerFile());
  5412. $json = JsonFile::encode($options);
  5413. if ($input->isInteractive()) {
  5414. $io->writeError(['', $json, '']);
  5415. if (!$io->askConfirmation('Do you confirm generation [<comment>yes</comment>]? ')) {
  5416. $io->writeError('<error>Command aborted</error>');
  5417. return 1;
  5418. }
  5419. } else {
  5420. if (json_encode($options) === '{"require":{}}') {
  5421. throw new \RuntimeException('You have to run this command in interactive mode, or specify at least some data using --name, --require, etc.');
  5422. }
  5423. $io->writeError('Writing '.$file->getPath());
  5424. }
  5425. $file->write($options);
  5426. try {
  5427. $file->validateSchema(JsonFile::LAX_SCHEMA);
  5428. } catch (JsonValidationException $e) {
  5429. $io->writeError('<error>Schema validation error, aborting</error>');
  5430. $errors = ' - ' . implode(PHP_EOL . ' - ', $e->getErrors());
  5431. $io->writeError($e->getMessage() . ':' . PHP_EOL . $errors);
  5432. Silencer::call('unlink', $file->getPath());
  5433. return 1;
  5434. }
  5435. if ($autoloadPath) {
  5436. $filesystem = new Filesystem();
  5437. $filesystem->ensureDirectoryExists($autoloadPath);
  5438. if (!$this->hasDependencies($options)) {
  5439. $this->runDumpAutoloadCommand($output);
  5440. }
  5441. }
  5442. if ($input->isInteractive() && is_dir('.git')) {
  5443. $ignoreFile = realpath('.gitignore');
  5444. if (false === $ignoreFile) {
  5445. $ignoreFile = realpath('.') . '/.gitignore';
  5446. }
  5447. if (!$this->hasVendorIgnore($ignoreFile)) {
  5448. $question = 'Would you like the <info>vendor</info> directory added to your <info>.gitignore</info> [<comment>yes</comment>]? ';
  5449. if ($io->askConfirmation($question)) {
  5450. $this->addVendorIgnore($ignoreFile);
  5451. }
  5452. }
  5453. }
  5454. $question = 'Would you like to install dependencies now [<comment>yes</comment>]? ';
  5455. if ($input->isInteractive() && $this->hasDependencies($options) && $io->askConfirmation($question)) {
  5456. $this->updateDependencies($output);
  5457. }
  5458. if ($autoloadPath) {
  5459. $namespace = $this->namespaceFromPackageName((string) $input->getOption('name'));
  5460. $io->writeError('PSR-4 autoloading configured. Use "<comment>namespace '.$namespace.';</comment>" in '.$autoloadPath);
  5461. $io->writeError('Include the Composer autoloader with: <comment>require \'vendor/autoload.php\';</comment>');
  5462. }
  5463. return 0;
  5464. }
  5465. protected function interact(InputInterface $input, OutputInterface $output)
  5466. {
  5467. $git = $this->getGitConfig();
  5468. $io = $this->getIO();
  5469. $formatter = $this->getHelperSet()->get('formatter');
  5470. $repositories = $input->getOption('repository');
  5471. if (count($repositories) > 0) {
  5472. $config = Factory::createConfig($io);
  5473. $io->loadConfiguration($config);
  5474. $repoManager = RepositoryFactory::manager($io, $config);
  5475. $repos = [new PlatformRepository];
  5476. $createDefaultPackagistRepo = true;
  5477. foreach ($repositories as $repo) {
  5478. $repoConfig = RepositoryFactory::configFromString($io, $config, $repo, true);
  5479. if (
  5480. (isset($repoConfig['packagist']) && $repoConfig === ['packagist' => false])
  5481. || (isset($repoConfig['packagist.org']) && $repoConfig === ['packagist.org' => false])
  5482. ) {
  5483. $createDefaultPackagistRepo = false;
  5484. continue;
  5485. }
  5486. $repos[] = RepositoryFactory::createRepo($io, $config, $repoConfig, $repoManager);
  5487. }
  5488. if ($createDefaultPackagistRepo) {
  5489. $repos[] = RepositoryFactory::createRepo($io, $config, [
  5490. 'type' => 'composer',
  5491. 'url' => 'https://repo.packagist.org',
  5492. ], $repoManager);
  5493. }
  5494. $this->repos = new CompositeRepository($repos);
  5495. unset($repos, $config, $repositories);
  5496. }
  5497. $io->writeError([
  5498. '',
  5499. $formatter->formatBlock('Welcome to the Composer config generator', 'bg=blue;fg=white', true),
  5500. '',
  5501. ]);
  5502. $io->writeError([
  5503. '',
  5504. 'This command will guide you through creating your composer.json config.',
  5505. '',
  5506. ]);
  5507. $cwd = realpath(".");
  5508. $name = $input->getOption('name');
  5509. if (null === $name) {
  5510. $name = basename($cwd);
  5511. $name = Preg::replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name);
  5512. $name = strtolower($name);
  5513. if (!empty($_SERVER['COMPOSER_DEFAULT_VENDOR'])) {
  5514. $name = $_SERVER['COMPOSER_DEFAULT_VENDOR'] . '/' . $name;
  5515. } elseif (isset($git['github.user'])) {
  5516. $name = $git['github.user'] . '/' . $name;
  5517. } elseif (!empty($_SERVER['USERNAME'])) {
  5518. $name = $_SERVER['USERNAME'] . '/' . $name;
  5519. } elseif (!empty($_SERVER['USER'])) {
  5520. $name = $_SERVER['USER'] . '/' . $name;
  5521. } elseif (get_current_user()) {
  5522. $name = get_current_user() . '/' . $name;
  5523. } else {
  5524. $name .= '/' . $name;
  5525. }
  5526. $name = strtolower($name);
  5527. }
  5528. $name = $io->askAndValidate(
  5529. 'Package name (<vendor>/<name>) [<comment>'.$name.'</comment>]: ',
  5530. static function ($value) use ($name) {
  5531. if (null === $value) {
  5532. return $name;
  5533. }
  5534. if (!Preg::isMatch('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}D', $value)) {
  5535. throw new \InvalidArgumentException(
  5536. '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_.-]+'
  5537. );
  5538. }
  5539. return $value;
  5540. },
  5541. null,
  5542. $name
  5543. );
  5544. $input->setOption('name', $name);
  5545. $description = $input->getOption('description') ?: null;
  5546. $description = $io->ask(
  5547. 'Description [<comment>'.$description.'</comment>]: ',
  5548. $description
  5549. );
  5550. $input->setOption('description', $description);
  5551. if (null === $author = $input->getOption('author')) {
  5552. if (!empty($_SERVER['COMPOSER_DEFAULT_AUTHOR'])) {
  5553. $author_name = $_SERVER['COMPOSER_DEFAULT_AUTHOR'];
  5554. } elseif (isset($git['user.name'])) {
  5555. $author_name = $git['user.name'];
  5556. }
  5557. if (!empty($_SERVER['COMPOSER_DEFAULT_EMAIL'])) {
  5558. $author_email = $_SERVER['COMPOSER_DEFAULT_EMAIL'];
  5559. } elseif (isset($git['user.email'])) {
  5560. $author_email = $git['user.email'];
  5561. }
  5562. if (isset($author_name, $author_email)) {
  5563. $author = sprintf('%s <%s>', $author_name, $author_email);
  5564. }
  5565. }
  5566. $author = $io->askAndValidate(
  5567. 'Author ['.(is_string($author) ? '<comment>'.$author.'</comment>, ' : '') . 'n to skip]: ',
  5568. function ($value) use ($author) {
  5569. if ($value === 'n' || $value === 'no') {
  5570. return;
  5571. }
  5572. $value = $value ?: $author;
  5573. $author = $this->parseAuthorString($value ?? '');
  5574. if ($author['email'] === null) {
  5575. return $author['name'];
  5576. }
  5577. return sprintf('%s <%s>', $author['name'], $author['email']);
  5578. },
  5579. null,
  5580. $author
  5581. );
  5582. $input->setOption('author', $author);
  5583. $minimumStability = $input->getOption('stability') ?: null;
  5584. $minimumStability = $io->askAndValidate(
  5585. 'Minimum Stability [<comment>'.$minimumStability.'</comment>]: ',
  5586. static function ($value) use ($minimumStability) {
  5587. if (null === $value) {
  5588. return $minimumStability;
  5589. }
  5590. if (!isset(BasePackage::$stabilities[$value])) {
  5591. throw new \InvalidArgumentException(
  5592. 'Invalid minimum stability "'.$value.'". Must be empty or one of: '.
  5593. implode(', ', array_keys(BasePackage::$stabilities))
  5594. );
  5595. }
  5596. return $value;
  5597. },
  5598. null,
  5599. $minimumStability
  5600. );
  5601. $input->setOption('stability', $minimumStability);
  5602. $type = $input->getOption('type') ?: false;
  5603. $type = $io->ask(
  5604. 'Package Type (e.g. library, project, metapackage, composer-plugin) [<comment>'.$type.'</comment>]: ',
  5605. $type
  5606. );
  5607. $input->setOption('type', $type);
  5608. if (null === $license = $input->getOption('license')) {
  5609. if (!empty($_SERVER['COMPOSER_DEFAULT_LICENSE'])) {
  5610. $license = $_SERVER['COMPOSER_DEFAULT_LICENSE'];
  5611. }
  5612. }
  5613. $license = $io->ask(
  5614. 'License [<comment>'.$license.'</comment>]: ',
  5615. $license
  5616. );
  5617. $input->setOption('license', $license);
  5618. $io->writeError(['', 'Define your dependencies.', '']);
  5619. $repos = $this->getRepos();
  5620. $preferredStability = $minimumStability ?: 'stable';
  5621. $platformRepo = null;
  5622. if ($repos instanceof CompositeRepository) {
  5623. foreach ($repos->getRepositories() as $candidateRepo) {
  5624. if ($candidateRepo instanceof PlatformRepository) {
  5625. $platformRepo = $candidateRepo;
  5626. break;
  5627. }
  5628. }
  5629. }
  5630. $question = 'Would you like to define your dependencies (require) interactively [<comment>yes</comment>]? ';
  5631. $require = $input->getOption('require');
  5632. $requirements = [];
  5633. if (count($require) > 0 || $io->askConfirmation($question)) {
  5634. $requirements = $this->determineRequirements($input, $output, $require, $platformRepo, $preferredStability);
  5635. }
  5636. $input->setOption('require', $requirements);
  5637. $question = 'Would you like to define your dev dependencies (require-dev) interactively [<comment>yes</comment>]? ';
  5638. $requireDev = $input->getOption('require-dev');
  5639. $devRequirements = [];
  5640. if (count($requireDev) > 0 || $io->askConfirmation($question)) {
  5641. $devRequirements = $this->determineRequirements($input, $output, $requireDev, $platformRepo, $preferredStability);
  5642. }
  5643. $input->setOption('require-dev', $devRequirements);
  5644. $autoload = $input->getOption('autoload') ?: 'src/';
  5645. $namespace = $this->namespaceFromPackageName((string) $input->getOption('name'));
  5646. $autoload = $io->askAndValidate(
  5647. 'Add PSR-4 autoload mapping? Maps namespace "'.$namespace.'" to the entered relative path. [<comment>'.$autoload.'</comment>, n to skip]: ',
  5648. static function ($value) use ($autoload) {
  5649. if (null === $value) {
  5650. return $autoload;
  5651. }
  5652. if ($value === 'n' || $value === 'no') {
  5653. return;
  5654. }
  5655. $value = $value ?: $autoload;
  5656. if (!Preg::isMatch('{^[^/][A-Za-z0-9\-_/]+/$}', $value)) {
  5657. throw new \InvalidArgumentException(sprintf(
  5658. 'The src folder name "%s" is invalid. Please add a relative path with tailing forward slash. [A-Za-z0-9_-/]+/',
  5659. $value
  5660. ));
  5661. }
  5662. return $value;
  5663. },
  5664. null,
  5665. $autoload
  5666. );
  5667. $input->setOption('autoload', $autoload);
  5668. }
  5669. private function parseAuthorString(string $author): array
  5670. {
  5671. if (Preg::isMatch('/^(?P<name>[- .,\p{L}\p{N}\p{Mn}\'’"()]+)(?:\s+<(?P<email>.+?)>)?$/u', $author, $match)) {
  5672. assert(is_string($match['name']));
  5673. if (null !== $match['email'] && !$this->isValidEmail($match['email'])) {
  5674. throw new \InvalidArgumentException('Invalid email "'.$match['email'].'"');
  5675. }
  5676. return [
  5677. 'name' => trim($match['name']),
  5678. 'email' => $match['email'],
  5679. ];
  5680. }
  5681. throw new \InvalidArgumentException(
  5682. 'Invalid author string. Must be in the formats: '.
  5683. 'Jane Doe or John Smith <john@example.com>'
  5684. );
  5685. }
  5686. protected function formatAuthors(string $author): array
  5687. {
  5688. $author = $this->parseAuthorString($author);
  5689. if (null === $author['email']) {
  5690. unset($author['email']);
  5691. }
  5692. return [$author];
  5693. }
  5694. public function namespaceFromPackageName(string $packageName): ?string
  5695. {
  5696. if (!$packageName || strpos($packageName, '/') === false) {
  5697. return null;
  5698. }
  5699. $namespace = array_map(
  5700. static function ($part): string {
  5701. $part = Preg::replace('/[^a-z0-9]/i', ' ', $part);
  5702. $part = ucwords($part);
  5703. return str_replace(' ', '', $part);
  5704. },
  5705. explode('/', $packageName)
  5706. );
  5707. return implode('\\', $namespace);
  5708. }
  5709. protected function getGitConfig(): array
  5710. {
  5711. if (null !== $this->gitConfig) {
  5712. return $this->gitConfig;
  5713. }
  5714. $finder = new ExecutableFinder();
  5715. $gitBin = $finder->find('git');
  5716. $cmd = new Process([$gitBin, 'config', '-l']);
  5717. $cmd->run();
  5718. if ($cmd->isSuccessful()) {
  5719. $this->gitConfig = [];
  5720. Preg::matchAllStrictGroups('{^([^=]+)=(.*)$}m', $cmd->getOutput(), $matches);
  5721. foreach ($matches[1] as $key => $match) {
  5722. $this->gitConfig[$match] = $matches[2][$key];
  5723. }
  5724. return $this->gitConfig;
  5725. }
  5726. return $this->gitConfig = [];
  5727. }
  5728. protected function hasVendorIgnore(string $ignoreFile, string $vendor = 'vendor'): bool
  5729. {
  5730. if (!file_exists($ignoreFile)) {
  5731. return false;
  5732. }
  5733. $pattern = sprintf('{^/?%s(/\*?)?$}', preg_quote($vendor));
  5734. $lines = file($ignoreFile, FILE_IGNORE_NEW_LINES);
  5735. foreach ($lines as $line) {
  5736. if (Preg::isMatch($pattern, $line)) {
  5737. return true;
  5738. }
  5739. }
  5740. return false;
  5741. }
  5742. protected function addVendorIgnore(string $ignoreFile, string $vendor = '/vendor/'): void
  5743. {
  5744. $contents = "";
  5745. if (file_exists($ignoreFile)) {
  5746. $contents = file_get_contents($ignoreFile);
  5747. if (strpos($contents, "\n") !== 0) {
  5748. $contents .= "\n";
  5749. }
  5750. }
  5751. file_put_contents($ignoreFile, $contents . $vendor. "\n");
  5752. }
  5753. protected function isValidEmail(string $email): bool
  5754. {
  5755. if (!function_exists('filter_var')) {
  5756. return true;
  5757. }
  5758. return false !== filter_var($email, FILTER_VALIDATE_EMAIL);
  5759. }
  5760. private function updateDependencies(OutputInterface $output): void
  5761. {
  5762. try {
  5763. $updateCommand = $this->getApplication()->find('update');
  5764. $this->getApplication()->resetComposer();
  5765. $updateCommand->run(new ArrayInput([]), $output);
  5766. } catch (\Exception $e) {
  5767. $this->getIO()->writeError('Could not update dependencies. Run `composer update` to see more information.');
  5768. }
  5769. }
  5770. private function runDumpAutoloadCommand(OutputInterface $output): void
  5771. {
  5772. try {
  5773. $command = $this->getApplication()->find('dump-autoload');
  5774. $this->getApplication()->resetComposer();
  5775. $command->run(new ArrayInput([]), $output);
  5776. } catch (\Exception $e) {
  5777. $this->getIO()->writeError('Could not run dump-autoload.');
  5778. }
  5779. }
  5780. private function hasDependencies(array $options): bool
  5781. {
  5782. $requires = (array) $options['require'];
  5783. $devRequires = isset($options['require-dev']) ? (array) $options['require-dev'] : [];
  5784. return !empty($requires) || !empty($devRequires);
  5785. }
  5786. }
  5787. <?php declare(strict_types=1);
  5788. namespace Composer\Command;
  5789. use Composer\Installer;
  5790. use Composer\Plugin\CommandEvent;
  5791. use Composer\Plugin\PluginEvents;
  5792. use Composer\Advisory\Auditor;
  5793. use Composer\Util\HttpDownloader;
  5794. use Symfony\Component\Console\Input\InputInterface;
  5795. use Composer\Console\Input\InputOption;
  5796. use Composer\Console\Input\InputArgument;
  5797. use Symfony\Component\Console\Output\OutputInterface;
  5798. class InstallCommand extends BaseCommand
  5799. {
  5800. use CompletionTrait;
  5801. protected function configure()
  5802. {
  5803. $this
  5804. ->setName('install')
  5805. ->setAliases(['i'])
  5806. ->setDescription('Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json')
  5807. ->setDefinition([
  5808. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  5809. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
  5810. 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).', null, $this->suggestPreferInstall()),
  5811. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  5812. new InputOption('download-only', null, InputOption::VALUE_NONE, 'Download only, do not install packages.'),
  5813. new InputOption('dev', null, InputOption::VALUE_NONE, 'DEPRECATED: Enables installation of require-dev packages (enabled by default, only present for BC).'),
  5814. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  5815. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  5816. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  5817. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  5818. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Do not use, only defined here to catch misuse of the install command.'),
  5819. new InputOption('audit', null, InputOption::VALUE_NONE, 'Run an audit after installation is complete.'),
  5820. new InputOption('audit-format', null, InputOption::VALUE_REQUIRED, 'Audit output format. Must be "table", "plain", "json", or "summary".', Auditor::FORMAT_SUMMARY, Auditor::FORMATS),
  5821. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
  5822. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  5823. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  5824. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  5825. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  5826. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  5827. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  5828. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Should not be provided, use composer require instead to add a given package to composer.json.'),
  5829. ])
  5830. ->setHelp(
  5831. <<<EOT
  5832. The <info>install</info> command reads the composer.lock file from
  5833. the current directory, processes it, and downloads and installs all the
  5834. libraries and dependencies outlined in that file. If the file does not
  5835. exist it will look for composer.json and do the same.
  5836. <info>php composer.phar install</info>
  5837. Read more at https://getcomposer.org/doc/03-cli.md#install-i
  5838. EOT
  5839. )
  5840. ;
  5841. }
  5842. protected function execute(InputInterface $input, OutputInterface $output)
  5843. {
  5844. $io = $this->getIO();
  5845. if ($input->getOption('dev')) {
  5846. $io->writeError('<warning>You are using the deprecated option "--dev". It has no effect and will break in Composer 3.</warning>');
  5847. }
  5848. if ($input->getOption('no-suggest')) {
  5849. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  5850. }
  5851. $args = $input->getArgument('packages');
  5852. if (count($args) > 0) {
  5853. $io->writeError('<error>Invalid argument '.implode(' ', $args).'. Use "composer require '.implode(' ', $args).'" instead to add packages to your composer.json.</error>');
  5854. return 1;
  5855. }
  5856. if ($input->getOption('no-install')) {
  5857. $io->writeError('<error>Invalid option "--no-install". Use "composer update --no-install" instead if you are trying to update the composer.lock file.</error>');
  5858. return 1;
  5859. }
  5860. $composer = $this->requireComposer();
  5861. if (!$composer->getLocker()->isLocked() && !HttpDownloader::isCurlEnabled()) {
  5862. $io->writeError('<warning>Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.</warning>');
  5863. }
  5864. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'install', $input, $output);
  5865. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5866. $install = Installer::create($io, $composer);
  5867. $config = $composer->getConfig();
  5868. [$preferSource, $preferDist] = $this->getPreferredInstallOptions($config, $input);
  5869. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  5870. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  5871. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  5872. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  5873. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  5874. $install
  5875. ->setDryRun($input->getOption('dry-run'))
  5876. ->setDownloadOnly($input->getOption('download-only'))
  5877. ->setVerbose($input->getOption('verbose'))
  5878. ->setPreferSource($preferSource)
  5879. ->setPreferDist($preferDist)
  5880. ->setDevMode(!$input->getOption('no-dev'))
  5881. ->setDumpAutoloader(!$input->getOption('no-autoloader'))
  5882. ->setOptimizeAutoloader($optimize)
  5883. ->setClassMapAuthoritative($authoritative)
  5884. ->setApcuAutoloader($apcu, $apcuPrefix)
  5885. ->setPlatformRequirementFilter($this->getPlatformRequirementFilter($input))
  5886. ->setAudit($input->getOption('audit'))
  5887. ->setErrorOnAudit($input->getOption('audit'))
  5888. ->setAuditFormat($this->getAuditFormat($input))
  5889. ;
  5890. if ($input->getOption('no-plugins')) {
  5891. $install->disablePlugins();
  5892. }
  5893. return $install->run();
  5894. }
  5895. }
  5896. <?php declare(strict_types=1);
  5897. namespace Composer\Command;
  5898. use Composer\Console\Input\InputOption;
  5899. use Composer\Json\JsonFile;
  5900. use Composer\Package\CompletePackageInterface;
  5901. use Composer\Plugin\CommandEvent;
  5902. use Composer\Plugin\PluginEvents;
  5903. use Composer\Repository\RepositoryUtils;
  5904. use Composer\Util\PackageInfo;
  5905. use Composer\Util\PackageSorter;
  5906. use Symfony\Component\Console\Formatter\OutputFormatter;
  5907. use Symfony\Component\Console\Helper\Table;
  5908. use Symfony\Component\Console\Input\InputInterface;
  5909. use Symfony\Component\Console\Output\OutputInterface;
  5910. use Symfony\Component\Console\Style\SymfonyStyle;
  5911. class LicensesCommand extends BaseCommand
  5912. {
  5913. protected function configure(): void
  5914. {
  5915. $this
  5916. ->setName('licenses')
  5917. ->setDescription('Shows information about licenses of dependencies')
  5918. ->setDefinition([
  5919. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text, json or summary', 'text', ['text', 'json', 'summary']),
  5920. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  5921. ])
  5922. ->setHelp(
  5923. <<<EOT
  5924. The license command displays detailed information about the licenses of
  5925. the installed dependencies.
  5926. Read more at https://getcomposer.org/doc/03-cli.md#licenses
  5927. EOT
  5928. )
  5929. ;
  5930. }
  5931. protected function execute(InputInterface $input, OutputInterface $output): int
  5932. {
  5933. $composer = $this->requireComposer();
  5934. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'licenses', $input, $output);
  5935. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5936. $root = $composer->getPackage();
  5937. $repo = $composer->getRepositoryManager()->getLocalRepository();
  5938. if ($input->getOption('no-dev')) {
  5939. $packages = RepositoryUtils::filterRequiredPackages($repo->getPackages(), $root);
  5940. } else {
  5941. $packages = $repo->getPackages();
  5942. }
  5943. $packages = PackageSorter::sortPackagesAlphabetically($packages);
  5944. $io = $this->getIO();
  5945. switch ($format = $input->getOption('format')) {
  5946. case 'text':
  5947. $io->write('Name: <comment>'.$root->getPrettyName().'</comment>');
  5948. $io->write('Version: <comment>'.$root->getFullPrettyVersion().'</comment>');
  5949. $io->write('Licenses: <comment>'.(implode(', ', $root->getLicense()) ?: 'none').'</comment>');
  5950. $io->write('Dependencies:');
  5951. $io->write('');
  5952. $table = new Table($output);
  5953. $table->setStyle('compact');
  5954. $table->setHeaders(['Name', 'Version', 'Licenses']);
  5955. foreach ($packages as $package) {
  5956. $link = PackageInfo::getViewSourceOrHomepageUrl($package);
  5957. if ($link !== null) {
  5958. $name = '<href='.OutputFormatter::escape($link).'>'.$package->getPrettyName().'</>';
  5959. } else {
  5960. $name = $package->getPrettyName();
  5961. }
  5962. $table->addRow([
  5963. $name,
  5964. $package->getFullPrettyVersion(),
  5965. implode(', ', $package instanceof CompletePackageInterface ? $package->getLicense() : []) ?: 'none',
  5966. ]);
  5967. }
  5968. $table->render();
  5969. break;
  5970. case 'json':
  5971. $dependencies = [];
  5972. foreach ($packages as $package) {
  5973. $dependencies[$package->getPrettyName()] = [
  5974. 'version' => $package->getFullPrettyVersion(),
  5975. 'license' => $package instanceof CompletePackageInterface ? $package->getLicense() : [],
  5976. ];
  5977. }
  5978. $io->write(JsonFile::encode([
  5979. 'name' => $root->getPrettyName(),
  5980. 'version' => $root->getFullPrettyVersion(),
  5981. 'license' => $root->getLicense(),
  5982. 'dependencies' => $dependencies,
  5983. ]));
  5984. break;
  5985. case 'summary':
  5986. $usedLicenses = [];
  5987. foreach ($packages as $package) {
  5988. $licenses = $package instanceof CompletePackageInterface ? $package->getLicense() : [];
  5989. if (count($licenses) === 0) {
  5990. $licenses[] = 'none';
  5991. }
  5992. foreach ($licenses as $licenseName) {
  5993. if (!isset($usedLicenses[$licenseName])) {
  5994. $usedLicenses[$licenseName] = 0;
  5995. }
  5996. $usedLicenses[$licenseName]++;
  5997. }
  5998. }
  5999. arsort($usedLicenses, SORT_NUMERIC);
  6000. $rows = [];
  6001. foreach ($usedLicenses as $usedLicense => $numberOfDependencies) {
  6002. $rows[] = [$usedLicense, $numberOfDependencies];
  6003. }
  6004. $symfonyIo = new SymfonyStyle($input, $output);
  6005. $symfonyIo->table(
  6006. ['License', 'Number of dependencies'],
  6007. $rows
  6008. );
  6009. break;
  6010. default:
  6011. throw new \RuntimeException(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  6012. }
  6013. return 0;
  6014. }
  6015. }
  6016. <?php declare(strict_types=1);
  6017. namespace Composer\Command;
  6018. use Symfony\Component\Console\Input\InputInterface;
  6019. use Composer\Console\Input\InputArgument;
  6020. use Symfony\Component\Console\Input\ArrayInput;
  6021. use Composer\Console\Input\InputOption;
  6022. use Symfony\Component\Console\Output\OutputInterface;
  6023. class OutdatedCommand extends BaseCommand
  6024. {
  6025. use CompletionTrait;
  6026. protected function configure(): void
  6027. {
  6028. $this
  6029. ->setName('outdated')
  6030. ->setDescription('Shows a list of installed packages that have updates available, including their latest version')
  6031. ->setDefinition([
  6032. new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.', null, $this->suggestInstalledPackage(false)),
  6033. new InputOption('outdated', 'o', InputOption::VALUE_NONE, 'Show only packages that are outdated (this is the default, but present here for compat with `show`'),
  6034. new InputOption('all', 'a', InputOption::VALUE_NONE, 'Show all installed packages with their latest versions'),
  6035. new InputOption('locked', null, InputOption::VALUE_NONE, 'Shows updates for packages from the lock file, regardless of what is currently in vendor dir'),
  6036. new InputOption('direct', 'D', InputOption::VALUE_NONE, 'Shows only packages that are directly required by the root package'),
  6037. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code when there are outdated packages'),
  6038. new InputOption('major-only', 'M', InputOption::VALUE_NONE, 'Show only packages that have major SemVer-compatible updates.'),
  6039. new InputOption('minor-only', 'm', InputOption::VALUE_NONE, 'Show only packages that have minor SemVer-compatible updates.'),
  6040. new InputOption('patch-only', 'p', InputOption::VALUE_NONE, 'Show only packages that have patch SemVer-compatible updates.'),
  6041. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text', ['json', 'text']),
  6042. new InputOption('ignore', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore specified package(s). Use it if you don\'t want to be informed about new versions of some packages.', null, $this->suggestInstalledPackage(false)),
  6043. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  6044. 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'),
  6045. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages). Use with the --outdated option'),
  6046. ])
  6047. ->setHelp(
  6048. <<<EOT
  6049. The outdated command is just a proxy for `composer show -l`
  6050. The color coding (or signage if you have ANSI colors disabled) for dependency versions is as such:
  6051. - <info>green</info> (=): Dependency is in the latest version and is up to date.
  6052. - <comment>yellow</comment> (~): Dependency has a new version available that includes backwards
  6053. compatibility breaks according to semver, so upgrade when you can but it
  6054. may involve work.
  6055. - <highlight>red</highlight> (!): Dependency has a new version that is semver-compatible and you should upgrade it.
  6056. Read more at https://getcomposer.org/doc/03-cli.md#outdated
  6057. EOT
  6058. )
  6059. ;
  6060. }
  6061. protected function execute(InputInterface $input, OutputInterface $output): int
  6062. {
  6063. $args = [
  6064. 'command' => 'show',
  6065. '--latest' => true,
  6066. ];
  6067. if (!$input->getOption('all')) {
  6068. $args['--outdated'] = true;
  6069. }
  6070. if ($input->getOption('direct')) {
  6071. $args['--direct'] = true;
  6072. }
  6073. if (null !== $input->getArgument('package')) {
  6074. $args['package'] = $input->getArgument('package');
  6075. }
  6076. if ($input->getOption('strict')) {
  6077. $args['--strict'] = true;
  6078. }
  6079. if ($input->getOption('major-only')) {
  6080. $args['--major-only'] = true;
  6081. }
  6082. if ($input->getOption('minor-only')) {
  6083. $args['--minor-only'] = true;
  6084. }
  6085. if ($input->getOption('patch-only')) {
  6086. $args['--patch-only'] = true;
  6087. }
  6088. if ($input->getOption('locked')) {
  6089. $args['--locked'] = true;
  6090. }
  6091. if ($input->getOption('no-dev')) {
  6092. $args['--no-dev'] = true;
  6093. }
  6094. $args['--ignore-platform-req'] = $input->getOption('ignore-platform-req');
  6095. if ($input->getOption('ignore-platform-reqs')) {
  6096. $args['--ignore-platform-reqs'] = true;
  6097. }
  6098. $args['--format'] = $input->getOption('format');
  6099. $args['--ignore'] = $input->getOption('ignore');
  6100. $input = new ArrayInput($args);
  6101. return $this->getApplication()->run($input, $output);
  6102. }
  6103. public function isProxyCommand(): bool
  6104. {
  6105. return true;
  6106. }
  6107. }
  6108. <?php declare(strict_types=1);
  6109. namespace Composer\Command;
  6110. use Composer\Factory;
  6111. use Composer\Filter\PlatformRequirementFilter\IgnoreAllPlatformRequirementFilter;
  6112. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  6113. use Composer\IO\IOInterface;
  6114. use Composer\Package\CompletePackageInterface;
  6115. use Composer\Package\PackageInterface;
  6116. use Composer\Package\Version\VersionParser;
  6117. use Composer\Package\Version\VersionSelector;
  6118. use Composer\Pcre\Preg;
  6119. use Composer\Repository\CompositeRepository;
  6120. use Composer\Repository\PlatformRepository;
  6121. use Composer\Repository\RepositoryFactory;
  6122. use Composer\Repository\RepositorySet;
  6123. use Composer\Semver\Constraint\Constraint;
  6124. use Composer\Util\Filesystem;
  6125. use Symfony\Component\Console\Input\InputInterface;
  6126. use Symfony\Component\Console\Output\OutputInterface;
  6127. trait PackageDiscoveryTrait
  6128. {
  6129. private $repos;
  6130. private $repositorySets;
  6131. protected function getRepos(): CompositeRepository
  6132. {
  6133. if (null === $this->repos) {
  6134. $this->repos = new CompositeRepository(array_merge(
  6135. [new PlatformRepository],
  6136. RepositoryFactory::defaultReposWithDefaultManager($this->getIO())
  6137. ));
  6138. }
  6139. return $this->repos;
  6140. }
  6141. private function getRepositorySet(InputInterface $input, ?string $minimumStability = null): RepositorySet
  6142. {
  6143. $key = $minimumStability ?? 'default';
  6144. if (!isset($this->repositorySets[$key])) {
  6145. $this->repositorySets[$key] = $repositorySet = new RepositorySet($minimumStability ?? $this->getMinimumStability($input));
  6146. $repositorySet->addRepository($this->getRepos());
  6147. }
  6148. return $this->repositorySets[$key];
  6149. }
  6150. private function getMinimumStability(InputInterface $input): string
  6151. {
  6152. if ($input->hasOption('stability')) {
  6153. return VersionParser::normalizeStability($input->getOption('stability') ?? 'stable');
  6154. }
  6155. $file = Factory::getComposerFile();
  6156. if (is_file($file) && Filesystem::isReadable($file) && is_array($composer = json_decode((string) file_get_contents($file), true))) {
  6157. if (isset($composer['minimum-stability'])) {
  6158. return VersionParser::normalizeStability($composer['minimum-stability']);
  6159. }
  6160. }
  6161. return 'stable';
  6162. }
  6163. final protected function determineRequirements(InputInterface $input, OutputInterface $output, array $requires = [], ?PlatformRepository $platformRepo = null, string $preferredStability = 'stable', bool $useBestVersionConstraint = true, bool $fixed = false): array
  6164. {
  6165. if (count($requires) > 0) {
  6166. $requires = $this->normalizeRequirements($requires);
  6167. $result = [];
  6168. $io = $this->getIO();
  6169. foreach ($requires as $requirement) {
  6170. if (isset($requirement['version']) && Preg::isMatch('{^\d+(\.\d+)?$}', $requirement['version'])) {
  6171. $io->writeError('<warning>The "'.$requirement['version'].'" constraint for "'.$requirement['name'].'" appears too strict and will likely not match what you want. See https://getcomposer.org/constraints');
  6172. }
  6173. if (!isset($requirement['version'])) {
  6174. [$name, $version] = $this->findBestVersionAndNameForPackage($this->getIO(), $input, $requirement['name'], $platformRepo, $preferredStability, $fixed);
  6175. $requirement['name'] = $name;
  6176. if ($useBestVersionConstraint) {
  6177. $requirement['version'] = $version;
  6178. $io->writeError(sprintf(
  6179. 'Using version <info>%s</info> for <info>%s</info>',
  6180. $requirement['version'],
  6181. $requirement['name']
  6182. ));
  6183. } else {
  6184. $requirement['version'] = 'guess';
  6185. }
  6186. }
  6187. $result[] = $requirement['name'] . ' ' . $requirement['version'];
  6188. }
  6189. return $result;
  6190. }
  6191. $versionParser = new VersionParser();
  6192. $composer = $this->tryComposer();
  6193. $installedRepo = null;
  6194. if (null !== $composer) {
  6195. $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
  6196. }
  6197. $existingPackages = [];
  6198. if (null !== $installedRepo) {
  6199. foreach ($installedRepo->getPackages() as $package) {
  6200. $existingPackages[] = $package->getName();
  6201. }
  6202. }
  6203. unset($composer, $installedRepo);
  6204. $io = $this->getIO();
  6205. while (null !== $package = $io->ask('Search for a package: ')) {
  6206. $matches = $this->getRepos()->search($package);
  6207. if (count($matches) > 0) {
  6208. foreach ($matches as $position => $foundPackage) {
  6209. if (in_array($foundPackage['name'], $existingPackages, true)) {
  6210. unset($matches[$position]);
  6211. }
  6212. }
  6213. $matches = array_values($matches);
  6214. $exactMatch = false;
  6215. foreach ($matches as $match) {
  6216. if ($match['name'] === $package) {
  6217. $exactMatch = true;
  6218. break;
  6219. }
  6220. }
  6221. if (!$exactMatch) {
  6222. $providers = $this->getRepos()->getProviders($package);
  6223. if (count($providers) > 0) {
  6224. array_unshift($matches, ['name' => $package, 'description' => '']);
  6225. }
  6226. $choices = [];
  6227. foreach ($matches as $position => $foundPackage) {
  6228. $abandoned = '';
  6229. if (isset($foundPackage['abandoned'])) {
  6230. if (is_string($foundPackage['abandoned'])) {
  6231. $replacement = sprintf('Use %s instead', $foundPackage['abandoned']);
  6232. } else {
  6233. $replacement = 'No replacement was suggested';
  6234. }
  6235. $abandoned = sprintf('<warning>Abandoned. %s.</warning>', $replacement);
  6236. }
  6237. $choices[] = sprintf(' <info>%5s</info> %s %s', "[$position]", $foundPackage['name'], $abandoned);
  6238. }
  6239. $io->writeError([
  6240. '',
  6241. sprintf('Found <info>%s</info> packages matching <info>%s</info>', count($matches), $package),
  6242. '',
  6243. ]);
  6244. $io->writeError($choices);
  6245. $io->writeError('');
  6246. $validator = static function (string $selection) use ($matches, $versionParser) {
  6247. if ('' === $selection) {
  6248. return false;
  6249. }
  6250. if (is_numeric($selection) && isset($matches[(int) $selection])) {
  6251. $package = $matches[(int) $selection];
  6252. return $package['name'];
  6253. }
  6254. if (Preg::isMatch('{^\s*(?P<name>[\S/]+)(?:\s+(?P<version>\S+))?\s*$}', $selection, $packageMatches)) {
  6255. if (isset($packageMatches['version'])) {
  6256. $versionParser->parseConstraints($packageMatches['version']);
  6257. return $packageMatches['name'].' '.$packageMatches['version'];
  6258. }
  6259. return $packageMatches['name'];
  6260. }
  6261. throw new \Exception('Not a valid selection');
  6262. };
  6263. $package = $io->askAndValidate(
  6264. 'Enter package # to add, or the complete package name if it is not listed: ',
  6265. $validator,
  6266. 3,
  6267. ''
  6268. );
  6269. }
  6270. if (false !== $package && false === strpos($package, ' ')) {
  6271. $validator = static function (string $input) {
  6272. $input = trim($input);
  6273. return strlen($input) > 0 ? $input : false;
  6274. };
  6275. $constraint = $io->askAndValidate(
  6276. 'Enter the version constraint to require (or leave blank to use the latest version): ',
  6277. $validator,
  6278. 3,
  6279. ''
  6280. );
  6281. if (false === $constraint) {
  6282. [, $constraint] = $this->findBestVersionAndNameForPackage($this->getIO(), $input, $package, $platformRepo, $preferredStability);
  6283. $io->writeError(sprintf(
  6284. 'Using version <info>%s</info> for <info>%s</info>',
  6285. $constraint,
  6286. $package
  6287. ));
  6288. }
  6289. $package .= ' '.$constraint;
  6290. }
  6291. if (false !== $package) {
  6292. $requires[] = $package;
  6293. $existingPackages[] = explode(' ', $package)[0];
  6294. }
  6295. }
  6296. }
  6297. return $requires;
  6298. }
  6299. private function findBestVersionAndNameForPackage(IOInterface $io, InputInterface $input, string $name, ?PlatformRepository $platformRepo = null, string $preferredStability = 'stable', bool $fixed = false): array
  6300. {
  6301. if ($input->hasOption('ignore-platform-reqs') && $input->hasOption('ignore-platform-req')) {
  6302. $platformRequirementFilter = $this->getPlatformRequirementFilter($input);
  6303. } else {
  6304. $platformRequirementFilter = PlatformRequirementFilterFactory::ignoreNothing();
  6305. }
  6306. $repoSet = $this->getRepositorySet($input);
  6307. $versionSelector = new VersionSelector($repoSet, $platformRepo);
  6308. $effectiveMinimumStability = $this->getMinimumStability($input);
  6309. $package = $versionSelector->findBestCandidate($name, null, $preferredStability, $platformRequirementFilter, 0, $this->getIO());
  6310. if (false === $package) {
  6311. if ($platformRequirementFilter->isIgnored($name)) {
  6312. return [$name, '*'];
  6313. }
  6314. $providers = $repoSet->getProviders($name);
  6315. if (count($providers) > 0) {
  6316. $constraint = '*';
  6317. if ($input->isInteractive()) {
  6318. $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>] ', static function ($value) {
  6319. $parser = new VersionParser();
  6320. $parser->parseConstraints($value);
  6321. return $value;
  6322. }, 3, '*');
  6323. }
  6324. return [$name, $constraint];
  6325. }
  6326. if (!($platformRequirementFilter instanceof IgnoreAllPlatformRequirementFilter) && false !== ($candidate = $versionSelector->findBestCandidate($name, null, $preferredStability, PlatformRequirementFilterFactory::ignoreAll()))) {
  6327. throw new \InvalidArgumentException(sprintf(
  6328. 'Package %s has requirements incompatible with your PHP version, PHP extensions and Composer version' . $this->getPlatformExceptionDetails($candidate, $platformRepo),
  6329. $name
  6330. ));
  6331. }
  6332. if (false !== ($package = $versionSelector->findBestCandidate($name, null, $preferredStability, $platformRequirementFilter, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES))) {
  6333. if (false !== ($allReposPackage = $versionSelector->findBestCandidate($name, null, $preferredStability, $platformRequirementFilter, RepositorySet::ALLOW_SHADOWED_REPOSITORIES))) {
  6334. throw new \InvalidArgumentException(
  6335. '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.'
  6336. );
  6337. }
  6338. throw new \InvalidArgumentException(sprintf(
  6339. 'Could not find a version of package %s matching your minimum-stability (%s). Require it with an explicit version constraint allowing its desired stability.',
  6340. $name,
  6341. $effectiveMinimumStability
  6342. ));
  6343. }
  6344. if (!$platformRequirementFilter instanceof IgnoreAllPlatformRequirementFilter && false !== ($candidate = $versionSelector->findBestCandidate($name, null, $preferredStability, PlatformRequirementFilterFactory::ignoreAll(), RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES))) {
  6345. $additional = '';
  6346. if (false === $versionSelector->findBestCandidate($name, null, $preferredStability, PlatformRequirementFilterFactory::ignoreAll())) {
  6347. $additional = PHP_EOL.PHP_EOL.'Additionally, the package was only found with a stability of "'.$candidate->getStability().'" while your minimum stability is "'.$effectiveMinimumStability.'".';
  6348. }
  6349. throw new \InvalidArgumentException(sprintf(
  6350. 'Could not find package %s in any version matching your PHP version, PHP extensions and Composer version' . $this->getPlatformExceptionDetails($candidate, $platformRepo) . '%s',
  6351. $name,
  6352. $additional
  6353. ));
  6354. }
  6355. $similar = $this->findSimilar($name);
  6356. if (count($similar) > 0) {
  6357. if (in_array($name, $similar, true)) {
  6358. throw new \InvalidArgumentException(sprintf(
  6359. "Could not find package %s. It was however found via repository search, which indicates a consistency issue with the repository.",
  6360. $name
  6361. ));
  6362. }
  6363. if ($input->isInteractive()) {
  6364. $result = $io->select("<error>Could not find package $name.</error>\nPick one of these or leave empty to abort:", $similar, false, 1);
  6365. if ($result !== false) {
  6366. return $this->findBestVersionAndNameForPackage($io, $input, $similar[$result], $platformRepo, $preferredStability, $fixed);
  6367. }
  6368. }
  6369. throw new \InvalidArgumentException(sprintf(
  6370. "Could not find package %s.\n\nDid you mean " . (count($similar) > 1 ? 'one of these' : 'this') . "?\n %s",
  6371. $name,
  6372. implode("\n ", $similar)
  6373. ));
  6374. }
  6375. throw new \InvalidArgumentException(sprintf(
  6376. '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).',
  6377. $name,
  6378. $effectiveMinimumStability
  6379. ));
  6380. }
  6381. return [
  6382. $package->getPrettyName(),
  6383. $fixed ? $package->getPrettyVersion() : $versionSelector->findRecommendedRequireVersion($package),
  6384. ];
  6385. }
  6386. private function findSimilar(string $package): array
  6387. {
  6388. try {
  6389. if (null === $this->repos) {
  6390. throw new \LogicException('findSimilar was called before $this->repos was initialized');
  6391. }
  6392. $results = $this->repos->search($package);
  6393. } catch (\Throwable $e) {
  6394. if ($e instanceof \LogicException) {
  6395. throw $e;
  6396. }
  6397. return [];
  6398. }
  6399. $similarPackages = [];
  6400. $installedRepo = $this->requireComposer()->getRepositoryManager()->getLocalRepository();
  6401. foreach ($results as $result) {
  6402. if (null !== $installedRepo->findPackage($result['name'], '*')) {
  6403. continue;
  6404. }
  6405. $similarPackages[$result['name']] = levenshtein($package, $result['name']);
  6406. }
  6407. asort($similarPackages);
  6408. return array_keys(array_slice($similarPackages, 0, 5));
  6409. }
  6410. private function getPlatformExceptionDetails(PackageInterface $candidate, ?PlatformRepository $platformRepo = null): string
  6411. {
  6412. $details = [];
  6413. if (null === $platformRepo) {
  6414. return '';
  6415. }
  6416. foreach ($candidate->getRequires() as $link) {
  6417. if (!PlatformRepository::isPlatformPackage($link->getTarget())) {
  6418. continue;
  6419. }
  6420. $platformPkg = $platformRepo->findPackage($link->getTarget(), '*');
  6421. if (null === $platformPkg) {
  6422. if ($platformRepo->isPlatformPackageDisabled($link->getTarget())) {
  6423. $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".';
  6424. } else {
  6425. $details[] = $candidate->getPrettyName().' '.$candidate->getPrettyVersion().' requires '.$link->getTarget().' '.$link->getPrettyConstraint().' but it is not present.';
  6426. }
  6427. continue;
  6428. }
  6429. if (!$link->getConstraint()->matches(new Constraint('==', $platformPkg->getVersion()))) {
  6430. $platformPkgVersion = $platformPkg->getPrettyVersion();
  6431. $platformExtra = $platformPkg->getExtra();
  6432. if (isset($platformExtra['config.platform']) && $platformPkg instanceof CompletePackageInterface) {
  6433. $platformPkgVersion .= ' ('.$platformPkg->getDescription().')';
  6434. }
  6435. $details[] = $candidate->getPrettyName().' '.$candidate->getPrettyVersion().' requires '.$link->getTarget().' '.$link->getPrettyConstraint().' which does not match your installed version '.$platformPkgVersion.'.';
  6436. }
  6437. }
  6438. if (count($details) === 0) {
  6439. return '';
  6440. }
  6441. return ':'.PHP_EOL.' - ' . implode(PHP_EOL.' - ', $details);
  6442. }
  6443. }
  6444. <?php declare(strict_types=1);
  6445. namespace Composer\Command;
  6446. use Symfony\Component\Console\Input\InputInterface;
  6447. use Symfony\Component\Console\Output\OutputInterface;
  6448. use Composer\Console\Input\InputArgument;
  6449. use Composer\Console\Input\InputOption;
  6450. class ProhibitsCommand extends BaseDependencyCommand
  6451. {
  6452. use CompletionTrait;
  6453. protected function configure(): void
  6454. {
  6455. $this
  6456. ->setName('prohibits')
  6457. ->setAliases(['why-not'])
  6458. ->setDescription('Shows which packages prevent the given package from being installed')
  6459. ->setDefinition([
  6460. new InputArgument(self::ARGUMENT_PACKAGE, InputArgument::REQUIRED, 'Package to inspect', null, $this->suggestAvailablePackage()),
  6461. new InputArgument(self::ARGUMENT_CONSTRAINT, InputArgument::REQUIRED, 'Version constraint, which version you expected to be installed'),
  6462. new InputOption(self::OPTION_RECURSIVE, 'r', InputOption::VALUE_NONE, 'Recursively resolves up to the root package'),
  6463. new InputOption(self::OPTION_TREE, 't', InputOption::VALUE_NONE, 'Prints the results as a nested tree'),
  6464. new InputOption('locked', null, InputOption::VALUE_NONE, 'Read dependency information from composer.lock'),
  6465. ])
  6466. ->setHelp(
  6467. <<<EOT
  6468. Displays detailed information about why a package cannot be installed.
  6469. <info>php composer.phar prohibits composer/composer</info>
  6470. Read more at https://getcomposer.org/doc/03-cli.md#prohibits-why-not
  6471. EOT
  6472. )
  6473. ;
  6474. }
  6475. protected function execute(InputInterface $input, OutputInterface $output): int
  6476. {
  6477. return parent::doExecute($input, $output, true);
  6478. }
  6479. }
  6480. <?php declare(strict_types=1);
  6481. namespace Composer\Command;
  6482. use Composer\DependencyResolver\Operation\InstallOperation;
  6483. use Composer\DependencyResolver\Operation\UninstallOperation;
  6484. use Composer\DependencyResolver\Transaction;
  6485. use Composer\Package\AliasPackage;
  6486. use Composer\Package\BasePackage;
  6487. use Composer\Pcre\Preg;
  6488. use Composer\Plugin\CommandEvent;
  6489. use Composer\Plugin\PluginEvents;
  6490. use Composer\Script\ScriptEvents;
  6491. use Composer\Util\Platform;
  6492. use Symfony\Component\Console\Input\InputInterface;
  6493. use Composer\Console\Input\InputOption;
  6494. use Composer\Console\Input\InputArgument;
  6495. use Symfony\Component\Console\Output\OutputInterface;
  6496. class ReinstallCommand extends BaseCommand
  6497. {
  6498. use CompletionTrait;
  6499. protected function configure(): void
  6500. {
  6501. $this
  6502. ->setName('reinstall')
  6503. ->setDescription('Uninstalls and reinstalls the given package names')
  6504. ->setDefinition([
  6505. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  6506. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
  6507. 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).', null, $this->suggestPreferInstall()),
  6508. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  6509. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  6510. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  6511. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  6512. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  6513. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  6514. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  6515. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  6516. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'List of package names to reinstall, can include a wildcard (*) to match any substring.', null, $this->suggestInstalledPackage(false)),
  6517. ])
  6518. ->setHelp(
  6519. <<<EOT
  6520. The <info>reinstall</info> command looks up installed packages by name,
  6521. uninstalls them and reinstalls them. This lets you do a clean install
  6522. of a package if you messed with its files, or if you wish to change
  6523. the installation type using --prefer-install.
  6524. <info>php composer.phar reinstall acme/foo "acme/bar-*"</info>
  6525. Read more at https://getcomposer.org/doc/03-cli.md#reinstall
  6526. EOT
  6527. )
  6528. ;
  6529. }
  6530. protected function execute(InputInterface $input, OutputInterface $output): int
  6531. {
  6532. $io = $this->getIO();
  6533. $composer = $this->requireComposer();
  6534. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  6535. $packagesToReinstall = [];
  6536. $packageNamesToReinstall = [];
  6537. foreach ($input->getArgument('packages') as $pattern) {
  6538. $patternRegexp = BasePackage::packageNameToRegexp($pattern);
  6539. $matched = false;
  6540. foreach ($localRepo->getCanonicalPackages() as $package) {
  6541. if (Preg::isMatch($patternRegexp, $package->getName())) {
  6542. $matched = true;
  6543. $packagesToReinstall[] = $package;
  6544. $packageNamesToReinstall[] = $package->getName();
  6545. }
  6546. }
  6547. if (!$matched) {
  6548. $io->writeError('<warning>Pattern "' . $pattern . '" does not match any currently installed packages.</warning>');
  6549. }
  6550. }
  6551. if (!$packagesToReinstall) {
  6552. $io->writeError('<warning>Found no packages to reinstall, aborting.</warning>');
  6553. return 1;
  6554. }
  6555. $uninstallOperations = [];
  6556. foreach ($packagesToReinstall as $package) {
  6557. $uninstallOperations[] = new UninstallOperation($package);
  6558. }
  6559. $presentPackages = $localRepo->getPackages();
  6560. $resultPackages = $presentPackages;
  6561. foreach ($presentPackages as $index => $package) {
  6562. if (in_array($package->getName(), $packageNamesToReinstall, true)) {
  6563. unset($presentPackages[$index]);
  6564. }
  6565. }
  6566. $transaction = new Transaction($presentPackages, $resultPackages);
  6567. $installOperations = $transaction->getOperations();
  6568. $installOrder = [];
  6569. foreach ($installOperations as $index => $op) {
  6570. if ($op instanceof InstallOperation && !$op->getPackage() instanceof AliasPackage) {
  6571. $installOrder[$op->getPackage()->getName()] = $index;
  6572. }
  6573. }
  6574. usort($uninstallOperations, static function ($a, $b) use ($installOrder): int {
  6575. return $installOrder[$b->getPackage()->getName()] - $installOrder[$a->getPackage()->getName()];
  6576. });
  6577. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'reinstall', $input, $output);
  6578. $eventDispatcher = $composer->getEventDispatcher();
  6579. $eventDispatcher->dispatch($commandEvent->getName(), $commandEvent);
  6580. $config = $composer->getConfig();
  6581. [$preferSource, $preferDist] = $this->getPreferredInstallOptions($config, $input);
  6582. $installationManager = $composer->getInstallationManager();
  6583. $downloadManager = $composer->getDownloadManager();
  6584. $package = $composer->getPackage();
  6585. $installationManager->setOutputProgress(!$input->getOption('no-progress'));
  6586. if ($input->getOption('no-plugins')) {
  6587. $installationManager->disablePlugins();
  6588. }
  6589. $downloadManager->setPreferSource($preferSource);
  6590. $downloadManager->setPreferDist($preferDist);
  6591. $devMode = $localRepo->getDevMode() !== null ? $localRepo->getDevMode() : true;
  6592. Platform::putEnv('COMPOSER_DEV_MODE', $devMode ? '1' : '0');
  6593. $eventDispatcher->dispatchScript(ScriptEvents::PRE_INSTALL_CMD, $devMode);
  6594. $installationManager->execute($localRepo, $uninstallOperations, $devMode);
  6595. $installationManager->execute($localRepo, $installOperations, $devMode);
  6596. if (!$input->getOption('no-autoloader')) {
  6597. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  6598. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  6599. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  6600. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  6601. $generator = $composer->getAutoloadGenerator();
  6602. $generator->setClassMapAuthoritative($authoritative);
  6603. $generator->setApcu($apcu, $apcuPrefix);
  6604. $generator->setPlatformRequirementFilter($this->getPlatformRequirementFilter($input));
  6605. $generator->dump(
  6606. $config,
  6607. $localRepo,
  6608. $package,
  6609. $installationManager,
  6610. 'composer',
  6611. $optimize,
  6612. null,
  6613. $composer->getLocker()
  6614. );
  6615. }
  6616. $eventDispatcher->dispatchScript(ScriptEvents::POST_INSTALL_CMD, $devMode);
  6617. return 0;
  6618. }
  6619. }
  6620. <?php declare(strict_types=1);
  6621. namespace Composer\Command;
  6622. use Composer\Config\JsonConfigSource;
  6623. use Composer\DependencyResolver\Request;
  6624. use Composer\Installer;
  6625. use Composer\Pcre\Preg;
  6626. use Composer\Plugin\CommandEvent;
  6627. use Composer\Plugin\PluginEvents;
  6628. use Composer\Json\JsonFile;
  6629. use Composer\Factory;
  6630. use Symfony\Component\Console\Exception\InvalidArgumentException;
  6631. use Symfony\Component\Console\Input\InputInterface;
  6632. use Composer\Console\Input\InputOption;
  6633. use Composer\Console\Input\InputArgument;
  6634. use Symfony\Component\Console\Output\OutputInterface;
  6635. use Composer\Package\BasePackage;
  6636. use Composer\Advisory\Auditor;
  6637. class RemoveCommand extends BaseCommand
  6638. {
  6639. use CompletionTrait;
  6640. protected function configure()
  6641. {
  6642. $this
  6643. ->setName('remove')
  6644. ->setAliases(['rm'])
  6645. ->setDescription('Removes a package from the require or require-dev')
  6646. ->setDefinition([
  6647. new InputArgument('packages', InputArgument::IS_ARRAY, 'Packages that should be removed.', null, $this->suggestRootRequirement()),
  6648. new InputOption('dev', null, InputOption::VALUE_NONE, 'Removes a package from the require-dev section.'),
  6649. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  6650. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  6651. new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies (implies --no-install).'),
  6652. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  6653. new InputOption('no-audit', null, InputOption::VALUE_NONE, 'Skip the audit step after updating the composer.lock file (can also be set via the COMPOSER_NO_AUDIT=1 env var).'),
  6654. new InputOption('audit-format', null, InputOption::VALUE_REQUIRED, 'Audit output format. Must be "table", "plain", "json", or "summary".', Auditor::FORMAT_SUMMARY, Auditor::FORMATS),
  6655. new InputOption('update-no-dev', null, InputOption::VALUE_NONE, 'Run the dependency update with the --no-dev option.'),
  6656. new InputOption('update-with-dependencies', 'w', InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated with explicit dependencies. (Deprecated, is now default behavior)'),
  6657. new InputOption('update-with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Allows all inherited dependencies to be updated, including those that are root requirements.'),
  6658. new InputOption('with-all-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-all-dependencies'),
  6659. new InputOption('no-update-with-dependencies', null, InputOption::VALUE_NONE, 'Does not allow inherited dependencies to be updated with explicit dependencies.'),
  6660. new InputOption('unused', null, InputOption::VALUE_NONE, 'Remove all packages which are locked but not required by any other package.'),
  6661. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  6662. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  6663. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  6664. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  6665. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  6666. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  6667. ])
  6668. ->setHelp(
  6669. <<<EOT
  6670. The <info>remove</info> command removes a package from the current
  6671. list of installed packages
  6672. <info>php composer.phar remove</info>
  6673. Read more at https://getcomposer.org/doc/03-cli.md#remove-rm
  6674. EOT
  6675. )
  6676. ;
  6677. }
  6678. protected function execute(InputInterface $input, OutputInterface $output)
  6679. {
  6680. if ($input->getArgument('packages') === [] && !$input->getOption('unused')) {
  6681. throw new InvalidArgumentException('Not enough arguments (missing: "packages").');
  6682. }
  6683. $packages = $input->getArgument('packages');
  6684. $packages = array_map('strtolower', $packages);
  6685. if ($input->getOption('unused')) {
  6686. $composer = $this->requireComposer();
  6687. $locker = $composer->getLocker();
  6688. if (!$locker->isLocked()) {
  6689. throw new \UnexpectedValueException('A valid composer.lock file is required to run this command with --unused');
  6690. }
  6691. $lockedPackages = $locker->getLockedRepository()->getPackages();
  6692. $required = [];
  6693. foreach (array_merge($composer->getPackage()->getRequires(), $composer->getPackage()->getDevRequires()) as $link) {
  6694. $required[$link->getTarget()] = true;
  6695. }
  6696. do {
  6697. $found = false;
  6698. foreach ($lockedPackages as $index => $package) {
  6699. foreach ($package->getNames() as $name) {
  6700. if (isset($required[$name])) {
  6701. foreach ($package->getRequires() as $link) {
  6702. $required[$link->getTarget()] = true;
  6703. }
  6704. $found = true;
  6705. unset($lockedPackages[$index]);
  6706. break;
  6707. }
  6708. }
  6709. }
  6710. } while ($found);
  6711. $unused = [];
  6712. foreach ($lockedPackages as $package) {
  6713. $unused[] = $package->getName();
  6714. }
  6715. $packages = array_merge($packages, $unused);
  6716. if (count($packages) === 0) {
  6717. $this->getIO()->writeError('<info>No unused packages to remove</info>');
  6718. return 0;
  6719. }
  6720. }
  6721. $file = Factory::getComposerFile();
  6722. $jsonFile = new JsonFile($file);
  6723. $composer = $jsonFile->read();
  6724. $composerBackup = file_get_contents($jsonFile->getPath());
  6725. $json = new JsonConfigSource($jsonFile);
  6726. $type = $input->getOption('dev') ? 'require-dev' : 'require';
  6727. $altType = !$input->getOption('dev') ? 'require-dev' : 'require';
  6728. $io = $this->getIO();
  6729. if ($input->getOption('update-with-dependencies')) {
  6730. $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>');
  6731. }
  6732. foreach (['require', 'require-dev'] as $linkType) {
  6733. if (isset($composer[$linkType])) {
  6734. foreach ($composer[$linkType] as $name => $version) {
  6735. $composer[$linkType][strtolower($name)] = $name;
  6736. }
  6737. }
  6738. }
  6739. $dryRun = $input->getOption('dry-run');
  6740. $toRemove = [];
  6741. foreach ($packages as $package) {
  6742. if (isset($composer[$type][$package])) {
  6743. if ($dryRun) {
  6744. $toRemove[$type][] = $composer[$type][$package];
  6745. } else {
  6746. $json->removeLink($type, $composer[$type][$package]);
  6747. }
  6748. } elseif (isset($composer[$altType][$package])) {
  6749. $io->writeError('<warning>' . $composer[$altType][$package] . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
  6750. if ($io->isInteractive()) {
  6751. if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [<comment>yes</comment>]? ')) {
  6752. if ($dryRun) {
  6753. $toRemove[$altType][] = $composer[$altType][$package];
  6754. } else {
  6755. $json->removeLink($altType, $composer[$altType][$package]);
  6756. }
  6757. }
  6758. }
  6759. } elseif (isset($composer[$type]) && count($matches = Preg::grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$type]))) > 0) {
  6760. foreach ($matches as $matchedPackage) {
  6761. if ($dryRun) {
  6762. $toRemove[$type][] = $matchedPackage;
  6763. } else {
  6764. $json->removeLink($type, $matchedPackage);
  6765. }
  6766. }
  6767. } elseif (isset($composer[$altType]) && count($matches = Preg::grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$altType]))) > 0) {
  6768. foreach ($matches as $matchedPackage) {
  6769. $io->writeError('<warning>' . $matchedPackage . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
  6770. if ($io->isInteractive()) {
  6771. if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [<comment>yes</comment>]? ')) {
  6772. if ($dryRun) {
  6773. $toRemove[$altType][] = $matchedPackage;
  6774. } else {
  6775. $json->removeLink($altType, $matchedPackage);
  6776. }
  6777. }
  6778. }
  6779. }
  6780. } else {
  6781. $io->writeError('<warning>'.$package.' is not required in your composer.json and has not been removed</warning>');
  6782. }
  6783. }
  6784. $io->writeError('<info>'.$file.' has been updated</info>');
  6785. if ($input->getOption('no-update')) {
  6786. return 0;
  6787. }
  6788. if ($composer = $this->tryComposer()) {
  6789. $composer->getPluginManager()->deactivateInstalledPlugins();
  6790. }
  6791. $this->resetComposer();
  6792. $composer = $this->requireComposer();
  6793. if ($dryRun) {
  6794. $rootPackage = $composer->getPackage();
  6795. $links = [
  6796. 'require' => $rootPackage->getRequires(),
  6797. 'require-dev' => $rootPackage->getDevRequires(),
  6798. ];
  6799. foreach ($toRemove as $type => $names) {
  6800. foreach ($names as $name) {
  6801. unset($links[$type][$name]);
  6802. }
  6803. }
  6804. $rootPackage->setRequires($links['require']);
  6805. $rootPackage->setDevRequires($links['require-dev']);
  6806. }
  6807. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'remove', $input, $output);
  6808. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  6809. $allowPlugins = $composer->getConfig()->get('allow-plugins');
  6810. $removedPlugins = is_array($allowPlugins) ? array_intersect(array_keys($allowPlugins), $packages) : [];
  6811. if (!$dryRun && is_array($allowPlugins) && count($removedPlugins) > 0) {
  6812. if (count($allowPlugins) === count($removedPlugins)) {
  6813. $json->removeConfigSetting('allow-plugins');
  6814. } else {
  6815. foreach ($removedPlugins as $plugin) {
  6816. $json->removeConfigSetting('allow-plugins.'.$plugin);
  6817. }
  6818. }
  6819. }
  6820. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  6821. $install = Installer::create($io, $composer);
  6822. $updateDevMode = !$input->getOption('update-no-dev');
  6823. $optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader');
  6824. $authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative');
  6825. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  6826. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $composer->getConfig()->get('apcu-autoloader');
  6827. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  6828. $flags = '';
  6829. if ($input->getOption('update-with-all-dependencies') || $input->getOption('with-all-dependencies')) {
  6830. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  6831. $flags .= ' --with-all-dependencies';
  6832. } elseif ($input->getOption('no-update-with-dependencies')) {
  6833. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  6834. $flags .= ' --with-dependencies';
  6835. }
  6836. $io->writeError('<info>Running composer update '.implode(' ', $packages).$flags.'</info>');
  6837. $install
  6838. ->setVerbose($input->getOption('verbose'))
  6839. ->setDevMode($updateDevMode)
  6840. ->setOptimizeAutoloader($optimize)
  6841. ->setClassMapAuthoritative($authoritative)
  6842. ->setApcuAutoloader($apcu, $apcuPrefix)
  6843. ->setUpdate(true)
  6844. ->setInstall(!$input->getOption('no-install'))
  6845. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  6846. ->setPlatformRequirementFilter($this->getPlatformRequirementFilter($input))
  6847. ->setDryRun($dryRun)
  6848. ->setAudit(!$input->getOption('no-audit'))
  6849. ->setAuditFormat($this->getAuditFormat($input))
  6850. ;
  6851. if ($composer->getLocker()->isLocked()) {
  6852. $install->setUpdateAllowList($packages);
  6853. }
  6854. $status = $install->run();
  6855. if ($status !== 0) {
  6856. $io->writeError("\n".'<error>Removal failed, reverting '.$file.' to its original content.</error>');
  6857. file_put_contents($jsonFile->getPath(), $composerBackup);
  6858. }
  6859. if (!$dryRun) {
  6860. foreach ($packages as $package) {
  6861. if ($composer->getRepositoryManager()->getLocalRepository()->findPackages($package)) {
  6862. $io->writeError('<error>Removal failed, '.$package.' is still present, it may be required by another package. See `composer why '.$package.'`.</error>');
  6863. return 2;
  6864. }
  6865. }
  6866. }
  6867. return $status;
  6868. }
  6869. }
  6870. <?php declare(strict_types=1);
  6871. namespace Composer\Command;
  6872. use Composer\DependencyResolver\Request;
  6873. use Composer\Package\AliasPackage;
  6874. use Composer\Package\CompletePackageInterface;
  6875. use Composer\Package\Loader\RootPackageLoader;
  6876. use Composer\Package\Locker;
  6877. use Composer\Package\PackageInterface;
  6878. use Composer\Package\Version\VersionBumper;
  6879. use Composer\Package\Version\VersionSelector;
  6880. use Composer\Pcre\Preg;
  6881. use Composer\Repository\RepositorySet;
  6882. use Composer\Util\Filesystem;
  6883. use Composer\Util\PackageSorter;
  6884. use Seld\Signal\SignalHandler;
  6885. use Symfony\Component\Console\Input\InputInterface;
  6886. use Composer\Console\Input\InputArgument;
  6887. use Composer\Console\Input\InputOption;
  6888. use Symfony\Component\Console\Output\OutputInterface;
  6889. use Composer\Factory;
  6890. use Composer\Installer;
  6891. use Composer\Installer\InstallerEvents;
  6892. use Composer\Json\JsonFile;
  6893. use Composer\Json\JsonManipulator;
  6894. use Composer\Package\Version\VersionParser;
  6895. use Composer\Package\Loader\ArrayLoader;
  6896. use Composer\Package\BasePackage;
  6897. use Composer\Plugin\CommandEvent;
  6898. use Composer\Plugin\PluginEvents;
  6899. use Composer\Repository\CompositeRepository;
  6900. use Composer\Repository\PlatformRepository;
  6901. use Composer\IO\IOInterface;
  6902. use Composer\Advisory\Auditor;
  6903. use Composer\Util\Silencer;
  6904. class RequireCommand extends BaseCommand
  6905. {
  6906. use CompletionTrait;
  6907. use PackageDiscoveryTrait;
  6908. private $newlyCreated;
  6909. private $firstRequire;
  6910. private $json;
  6911. private $file;
  6912. private $composerBackup;
  6913. private $lock;
  6914. private $lockBackup;
  6915. private $dependencyResolutionCompleted = false;
  6916. protected function configure()
  6917. {
  6918. $this
  6919. ->setName('require')
  6920. ->setAliases(['r'])
  6921. ->setDescription('Adds required packages to your composer.json and installs them')
  6922. ->setDefinition([
  6923. 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"', null, $this->suggestAvailablePackageInclPlatform()),
  6924. new InputOption('dev', null, InputOption::VALUE_NONE, 'Add requirement to require-dev.'),
  6925. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  6926. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  6927. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
  6928. 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).', null, $this->suggestPreferInstall()),
  6929. new InputOption('fixed', null, InputOption::VALUE_NONE, 'Write fixed version to the composer.json.'),
  6930. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  6931. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  6932. new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies (implies --no-install).'),
  6933. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  6934. new InputOption('no-audit', null, InputOption::VALUE_NONE, 'Skip the audit step after updating the composer.lock file (can also be set via the COMPOSER_NO_AUDIT=1 env var).'),
  6935. new InputOption('audit-format', null, InputOption::VALUE_REQUIRED, 'Audit output format. Must be "table", "plain", "json", or "summary".', Auditor::FORMAT_SUMMARY, Auditor::FORMATS),
  6936. new InputOption('update-no-dev', null, InputOption::VALUE_NONE, 'Run the dependency update with the --no-dev option.'),
  6937. new InputOption('update-with-dependencies', 'w', InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated, except those that are root requirements.'),
  6938. new InputOption('update-with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Allows all inherited dependencies to be updated, including those that are root requirements.'),
  6939. new InputOption('with-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-dependencies'),
  6940. new InputOption('with-all-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-all-dependencies'),
  6941. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  6942. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  6943. new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies (can also be set via the COMPOSER_PREFER_STABLE=1 env var).'),
  6944. new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies (can also be set via the COMPOSER_PREFER_LOWEST=1 env var).'),
  6945. new InputOption('sort-packages', null, InputOption::VALUE_NONE, 'Sorts packages when adding/updating a new dependency'),
  6946. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  6947. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  6948. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  6949. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  6950. ])
  6951. ->setHelp(
  6952. <<<EOT
  6953. The require command adds required packages to your composer.json and installs them.
  6954. If you do not specify a package, composer will prompt you to search for a package, and given results, provide a list of
  6955. matches to require.
  6956. If you do not specify a version constraint, composer will choose a suitable one based on the available package versions.
  6957. If you do not want to install the new dependencies immediately you can call it with --no-update
  6958. Read more at https://getcomposer.org/doc/03-cli.md#require-r
  6959. EOT
  6960. )
  6961. ;
  6962. }
  6963. protected function execute(InputInterface $input, OutputInterface $output)
  6964. {
  6965. $this->file = Factory::getComposerFile();
  6966. $io = $this->getIO();
  6967. if ($input->getOption('no-suggest')) {
  6968. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  6969. }
  6970. $this->newlyCreated = !file_exists($this->file);
  6971. if ($this->newlyCreated && !file_put_contents($this->file, "{\n}\n")) {
  6972. $io->writeError('<error>'.$this->file.' could not be created.</error>');
  6973. return 1;
  6974. }
  6975. if (!Filesystem::isReadable($this->file)) {
  6976. $io->writeError('<error>'.$this->file.' is not readable.</error>');
  6977. return 1;
  6978. }
  6979. if (filesize($this->file) === 0) {
  6980. file_put_contents($this->file, "{\n}\n");
  6981. }
  6982. $this->json = new JsonFile($this->file);
  6983. $this->lock = Factory::getLockFile($this->file);
  6984. $this->composerBackup = file_get_contents($this->json->getPath());
  6985. $this->lockBackup = file_exists($this->lock) ? file_get_contents($this->lock) : null;
  6986. $signalHandler = SignalHandler::create([SignalHandler::SIGINT, SignalHandler::SIGTERM, SignalHandler::SIGHUP], function (string $signal, SignalHandler $handler) {
  6987. $this->getIO()->writeError('Received '.$signal.', aborting', true, IOInterface::DEBUG);
  6988. $this->revertComposerFile();
  6989. $handler->exitWithLastSignal();
  6990. });
  6991. if (!is_writable($this->file) && false === Silencer::call('file_put_contents', $this->file, $this->composerBackup)) {
  6992. $io->writeError('<error>'.$this->file.' is not writable.</error>');
  6993. return 1;
  6994. }
  6995. if ($input->getOption('fixed') === true) {
  6996. $config = $this->json->read();
  6997. $packageType = empty($config['type']) ? 'library' : $config['type'];
  6998. if ($packageType !== 'project' && !$input->getOption('dev')) {
  6999. $io->writeError('<error>The "--fixed" option is only allowed for packages with a "project" type or for dev dependencies to prevent possible misuses.</error>');
  7000. if (!isset($config['type'])) {
  7001. $io->writeError('<error>If your package is not a library, you can explicitly specify the "type" by using "composer config type project".</error>');
  7002. }
  7003. return 1;
  7004. }
  7005. }
  7006. $composer = $this->requireComposer();
  7007. $repos = $composer->getRepositoryManager()->getRepositories();
  7008. $platformOverrides = $composer->getConfig()->get('platform');
  7009. $this->repos = new CompositeRepository(array_merge(
  7010. [$platformRepo = new PlatformRepository([], $platformOverrides)],
  7011. $repos
  7012. ));
  7013. if ($composer->getPackage()->getPreferStable()) {
  7014. $preferredStability = 'stable';
  7015. } else {
  7016. $preferredStability = $composer->getPackage()->getMinimumStability();
  7017. }
  7018. try {
  7019. $requirements = $this->determineRequirements(
  7020. $input,
  7021. $output,
  7022. $input->getArgument('packages'),
  7023. $platformRepo,
  7024. $preferredStability,
  7025. $input->getOption('no-update'),
  7026. $input->getOption('fixed')
  7027. );
  7028. } catch (\Exception $e) {
  7029. if ($this->newlyCreated) {
  7030. $this->revertComposerFile();
  7031. throw new \RuntimeException('No composer.json present in the current directory ('.$this->file.'), this may be the cause of the following exception.', 0, $e);
  7032. }
  7033. throw $e;
  7034. }
  7035. $requirements = $this->formatRequirements($requirements);
  7036. if (!$input->getOption('dev') && $io->isInteractive()) {
  7037. $devPackages = [];
  7038. $devTags = ['dev', 'testing', 'static analysis'];
  7039. $currentRequiresByKey = $this->getPackagesByRequireKey();
  7040. foreach ($requirements as $name => $version) {
  7041. if (isset($currentRequiresByKey[$name])) {
  7042. continue;
  7043. }
  7044. $pkg = PackageSorter::getMostCurrentVersion($this->getRepos()->findPackages($name));
  7045. if ($pkg instanceof CompletePackageInterface) {
  7046. $pkgDevTags = array_intersect($devTags, array_map('strtolower', $pkg->getKeywords()));
  7047. if (count($pkgDevTags) > 0) {
  7048. $devPackages[] = $pkgDevTags;
  7049. }
  7050. }
  7051. }
  7052. if (count($devPackages) === count($requirements)) {
  7053. $plural = count($requirements) > 1 ? 's' : '';
  7054. $plural2 = count($requirements) > 1 ? 'are' : 'is';
  7055. $plural3 = count($requirements) > 1 ? 'they are' : 'it is';
  7056. $pkgDevTags = array_unique(array_merge(...$devPackages));
  7057. $io->warning('The package'.$plural.' you required '.$plural2.' recommended to be placed in require-dev (because '.$plural3.' tagged as "'.implode('", "', $pkgDevTags).'") but you did not use --dev.');
  7058. if ($io->askConfirmation('<info>Do you want to re-run the command with --dev?</> [<comment>yes</>]? ')) {
  7059. $input->setOption('dev', true);
  7060. }
  7061. }
  7062. unset($devPackages, $pkgDevTags);
  7063. }
  7064. $requireKey = $input->getOption('dev') ? 'require-dev' : 'require';
  7065. $removeKey = $input->getOption('dev') ? 'require' : 'require-dev';
  7066. $requirementsToGuess = [];
  7067. foreach ($requirements as $package => $constraint) {
  7068. if ($constraint === 'guess') {
  7069. $requirements[$package] = '*';
  7070. $requirementsToGuess[] = $package;
  7071. }
  7072. }
  7073. $versionParser = new VersionParser();
  7074. foreach ($requirements as $package => $constraint) {
  7075. if (strtolower($package) === $composer->getPackage()->getName()) {
  7076. $io->writeError(sprintf('<error>Root package \'%s\' cannot require itself in its composer.json</error>', $package));
  7077. return 1;
  7078. }
  7079. if ($constraint === 'self.version') {
  7080. continue;
  7081. }
  7082. $versionParser->parseConstraints($constraint);
  7083. }
  7084. $inconsistentRequireKeys = $this->getInconsistentRequireKeys($requirements, $requireKey);
  7085. if (count($inconsistentRequireKeys) > 0) {
  7086. foreach ($inconsistentRequireKeys as $package) {
  7087. $io->warning(sprintf(
  7088. '%s is currently present in the %s key and you ran the command %s the --dev flag, which will move it to the %s key.',
  7089. $package,
  7090. $removeKey,
  7091. $input->getOption('dev') ? 'with' : 'without',
  7092. $requireKey
  7093. ));
  7094. }
  7095. if ($io->isInteractive()) {
  7096. if (!$io->askConfirmation(sprintf('<info>Do you want to move %s?</info> [<comment>no</comment>]? ', count($inconsistentRequireKeys) > 1 ? 'these requirements' : 'this requirement'), false)) {
  7097. 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)) {
  7098. return 0;
  7099. }
  7100. $input->setOption('dev', true);
  7101. [$requireKey, $removeKey] = [$removeKey, $requireKey];
  7102. }
  7103. }
  7104. }
  7105. $sortPackages = $input->getOption('sort-packages') || $composer->getConfig()->get('sort-packages');
  7106. $this->firstRequire = $this->newlyCreated;
  7107. if (!$this->firstRequire) {
  7108. $composerDefinition = $this->json->read();
  7109. if (count($composerDefinition['require'] ?? []) === 0 && count($composerDefinition['require-dev'] ?? []) === 0) {
  7110. $this->firstRequire = true;
  7111. }
  7112. }
  7113. if (!$input->getOption('dry-run')) {
  7114. $this->updateFile($this->json, $requirements, $requireKey, $removeKey, $sortPackages);
  7115. }
  7116. $io->writeError('<info>'.$this->file.' has been '.($this->newlyCreated ? 'created' : 'updated').'</info>');
  7117. if ($input->getOption('no-update')) {
  7118. return 0;
  7119. }
  7120. $composer->getPluginManager()->deactivateInstalledPlugins();
  7121. try {
  7122. $result = $this->doUpdate($input, $output, $io, $requirements, $requireKey, $removeKey);
  7123. if ($result === 0 && count($requirementsToGuess) > 0) {
  7124. $result = $this->updateRequirementsAfterResolution($requirementsToGuess, $requireKey, $removeKey, $sortPackages, $input->getOption('dry-run'), $input->getOption('fixed'));
  7125. }
  7126. return $result;
  7127. } catch (\Exception $e) {
  7128. if (!$this->dependencyResolutionCompleted) {
  7129. $this->revertComposerFile();
  7130. }
  7131. throw $e;
  7132. } finally {
  7133. $signalHandler->unregister();
  7134. }
  7135. }
  7136. private function getInconsistentRequireKeys(array $newRequirements, string $requireKey): array
  7137. {
  7138. $requireKeys = $this->getPackagesByRequireKey();
  7139. $inconsistentRequirements = [];
  7140. foreach ($requireKeys as $package => $packageRequireKey) {
  7141. if (!isset($newRequirements[$package])) {
  7142. continue;
  7143. }
  7144. if ($requireKey !== $packageRequireKey) {
  7145. $inconsistentRequirements[] = $package;
  7146. }
  7147. }
  7148. return $inconsistentRequirements;
  7149. }
  7150. private function getPackagesByRequireKey(): array
  7151. {
  7152. $composerDefinition = $this->json->read();
  7153. $require = [];
  7154. $requireDev = [];
  7155. if (isset($composerDefinition['require'])) {
  7156. $require = $composerDefinition['require'];
  7157. }
  7158. if (isset($composerDefinition['require-dev'])) {
  7159. $requireDev = $composerDefinition['require-dev'];
  7160. }
  7161. return array_merge(
  7162. array_fill_keys(array_keys($require), 'require'),
  7163. array_fill_keys(array_keys($requireDev), 'require-dev')
  7164. );
  7165. }
  7166. private function doUpdate(InputInterface $input, OutputInterface $output, IOInterface $io, array $requirements, string $requireKey, string $removeKey): int
  7167. {
  7168. $this->resetComposer();
  7169. $composer = $this->requireComposer();
  7170. $this->dependencyResolutionCompleted = false;
  7171. $composer->getEventDispatcher()->addListener(InstallerEvents::PRE_OPERATIONS_EXEC, function (): void {
  7172. $this->dependencyResolutionCompleted = true;
  7173. }, 10000);
  7174. if ($input->getOption('dry-run')) {
  7175. $rootPackage = $composer->getPackage();
  7176. $links = [
  7177. 'require' => $rootPackage->getRequires(),
  7178. 'require-dev' => $rootPackage->getDevRequires(),
  7179. ];
  7180. $loader = new ArrayLoader();
  7181. $newLinks = $loader->parseLinks($rootPackage->getName(), $rootPackage->getPrettyVersion(), BasePackage::$supportedLinkTypes[$requireKey]['method'], $requirements);
  7182. $links[$requireKey] = array_merge($links[$requireKey], $newLinks);
  7183. foreach ($requirements as $package => $constraint) {
  7184. unset($links[$removeKey][$package]);
  7185. }
  7186. $rootPackage->setRequires($links['require']);
  7187. $rootPackage->setDevRequires($links['require-dev']);
  7188. $references = $rootPackage->getReferences();
  7189. $references = RootPackageLoader::extractReferences($requirements, $references);
  7190. $rootPackage->setReferences($references);
  7191. $stabilityFlags = $rootPackage->getStabilityFlags();
  7192. $stabilityFlags = RootPackageLoader::extractStabilityFlags($requirements, $rootPackage->getMinimumStability(), $stabilityFlags);
  7193. $rootPackage->setStabilityFlags($stabilityFlags);
  7194. unset($stabilityFlags, $references);
  7195. }
  7196. $updateDevMode = !$input->getOption('update-no-dev');
  7197. $optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader');
  7198. $authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative');
  7199. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  7200. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $composer->getConfig()->get('apcu-autoloader');
  7201. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  7202. $flags = '';
  7203. if ($input->getOption('update-with-all-dependencies') || $input->getOption('with-all-dependencies')) {
  7204. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  7205. $flags .= ' --with-all-dependencies';
  7206. } elseif ($input->getOption('update-with-dependencies') || $input->getOption('with-dependencies')) {
  7207. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  7208. $flags .= ' --with-dependencies';
  7209. }
  7210. $io->writeError('<info>Running composer update '.implode(' ', array_keys($requirements)).$flags.'</info>');
  7211. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'require', $input, $output);
  7212. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  7213. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  7214. $install = Installer::create($io, $composer);
  7215. [$preferSource, $preferDist] = $this->getPreferredInstallOptions($composer->getConfig(), $input);
  7216. $install
  7217. ->setDryRun($input->getOption('dry-run'))
  7218. ->setVerbose($input->getOption('verbose'))
  7219. ->setPreferSource($preferSource)
  7220. ->setPreferDist($preferDist)
  7221. ->setDevMode($updateDevMode)
  7222. ->setOptimizeAutoloader($optimize)
  7223. ->setClassMapAuthoritative($authoritative)
  7224. ->setApcuAutoloader($apcu, $apcuPrefix)
  7225. ->setUpdate(true)
  7226. ->setInstall(!$input->getOption('no-install'))
  7227. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  7228. ->setPlatformRequirementFilter($this->getPlatformRequirementFilter($input))
  7229. ->setPreferStable($input->getOption('prefer-stable'))
  7230. ->setPreferLowest($input->getOption('prefer-lowest'))
  7231. ->setAudit(!$input->getOption('no-audit'))
  7232. ->setAuditFormat($this->getAuditFormat($input))
  7233. ;
  7234. if (!$this->firstRequire && $composer->getLocker()->isLocked()) {
  7235. $install->setUpdateAllowList(array_keys($requirements));
  7236. }
  7237. $status = $install->run();
  7238. if ($status !== 0 && $status !== Installer::ERROR_AUDIT_FAILED) {
  7239. if ($status === Installer::ERROR_DEPENDENCY_RESOLUTION_FAILED) {
  7240. foreach ($this->normalizeRequirements($input->getArgument('packages')) as $req) {
  7241. if (!isset($req['version'])) {
  7242. $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.');
  7243. break;
  7244. }
  7245. }
  7246. }
  7247. $this->revertComposerFile();
  7248. }
  7249. return $status;
  7250. }
  7251. private function updateRequirementsAfterResolution(array $requirementsToUpdate, string $requireKey, string $removeKey, bool $sortPackages, bool $dryRun, bool $fixed): int
  7252. {
  7253. $composer = $this->requireComposer();
  7254. $locker = $composer->getLocker();
  7255. $requirements = [];
  7256. $versionSelector = new VersionSelector(new RepositorySet());
  7257. $repo = $locker->isLocked() ? $composer->getLocker()->getLockedRepository(true) : $composer->getRepositoryManager()->getLocalRepository();
  7258. foreach ($requirementsToUpdate as $packageName) {
  7259. $package = $repo->findPackage($packageName, '*');
  7260. while ($package instanceof AliasPackage) {
  7261. $package = $package->getAliasOf();
  7262. }
  7263. if (!$package instanceof PackageInterface) {
  7264. continue;
  7265. }
  7266. if ($fixed) {
  7267. $requirements[$packageName] = $package->getPrettyVersion();
  7268. } else {
  7269. $requirements[$packageName] = $versionSelector->findRecommendedRequireVersion($package);
  7270. }
  7271. $this->getIO()->writeError(sprintf(
  7272. 'Using version <info>%s</info> for <info>%s</info>',
  7273. $requirements[$packageName],
  7274. $packageName
  7275. ));
  7276. if (Preg::isMatch('{^dev-(?!main$|master$|trunk$|latest$)}', $requirements[$packageName])) {
  7277. $this->getIO()->warning('Version '.$requirements[$packageName].' looks like it may be a feature branch which is unlikely to keep working in the long run and may be in an unstable state');
  7278. if ($this->getIO()->isInteractive() && !$this->getIO()->askConfirmation('Are you sure you want to use this constraint (<comment>Y</comment>) or would you rather abort (<comment>n</comment>) the whole operation [<comment>Y,n</comment>]? ')) {
  7279. $this->revertComposerFile();
  7280. return 1;
  7281. }
  7282. }
  7283. }
  7284. if (!$dryRun) {
  7285. $this->updateFile($this->json, $requirements, $requireKey, $removeKey, $sortPackages);
  7286. if ($locker->isLocked()) {
  7287. $contents = file_get_contents($this->json->getPath());
  7288. if (false === $contents) {
  7289. throw new \RuntimeException('Unable to read '.$this->json->getPath().' contents to update the lock file hash.');
  7290. }
  7291. $lockFile = Factory::getLockFile($this->json->getPath());
  7292. $lockMtime = filemtime($lockFile);
  7293. $lock = new JsonFile($lockFile);
  7294. $lockData = $lock->read();
  7295. $lockData['content-hash'] = Locker::getContentHash($contents);
  7296. $lock->write($lockData);
  7297. if (is_int($lockMtime)) {
  7298. @touch($lockFile, $lockMtime);
  7299. }
  7300. }
  7301. }
  7302. return 0;
  7303. }
  7304. private function updateFile(JsonFile $json, array $new, string $requireKey, string $removeKey, bool $sortPackages): void
  7305. {
  7306. if ($this->updateFileCleanly($json, $new, $requireKey, $removeKey, $sortPackages)) {
  7307. return;
  7308. }
  7309. $composerDefinition = $this->json->read();
  7310. foreach ($new as $package => $version) {
  7311. $composerDefinition[$requireKey][$package] = $version;
  7312. unset($composerDefinition[$removeKey][$package]);
  7313. if (isset($composerDefinition[$removeKey]) && count($composerDefinition[$removeKey]) === 0) {
  7314. unset($composerDefinition[$removeKey]);
  7315. }
  7316. }
  7317. $this->json->write($composerDefinition);
  7318. }
  7319. private function updateFileCleanly(JsonFile $json, array $new, string $requireKey, string $removeKey, bool $sortPackages): bool
  7320. {
  7321. $contents = file_get_contents($json->getPath());
  7322. $manipulator = new JsonManipulator($contents);
  7323. foreach ($new as $package => $constraint) {
  7324. if (!$manipulator->addLink($requireKey, $package, $constraint, $sortPackages)) {
  7325. return false;
  7326. }
  7327. if (!$manipulator->removeSubNode($removeKey, $package)) {
  7328. return false;
  7329. }
  7330. }
  7331. $manipulator->removeMainKeyIfEmpty($removeKey);
  7332. file_put_contents($json->getPath(), $manipulator->getContents());
  7333. return true;
  7334. }
  7335. protected function interact(InputInterface $input, OutputInterface $output): void
  7336. {
  7337. }
  7338. private function revertComposerFile(): void
  7339. {
  7340. $io = $this->getIO();
  7341. if ($this->newlyCreated) {
  7342. $io->writeError("\n".'<error>Installation failed, deleting '.$this->file.'.</error>');
  7343. unlink($this->json->getPath());
  7344. if (file_exists($this->lock)) {
  7345. unlink($this->lock);
  7346. }
  7347. } else {
  7348. $msg = ' to its ';
  7349. if ($this->lockBackup) {
  7350. $msg = ' and '.$this->lock.' to their ';
  7351. }
  7352. $io->writeError("\n".'<error>Installation failed, reverting '.$this->file.$msg.'original content.</error>');
  7353. file_put_contents($this->json->getPath(), $this->composerBackup);
  7354. if ($this->lockBackup) {
  7355. file_put_contents($this->lock, $this->lockBackup);
  7356. }
  7357. }
  7358. }
  7359. }
  7360. <?php declare(strict_types=1);
  7361. namespace Composer\Command;
  7362. use Composer\Script\Event as ScriptEvent;
  7363. use Composer\Script\ScriptEvents;
  7364. use Composer\Util\ProcessExecutor;
  7365. use Composer\Util\Platform;
  7366. use Symfony\Component\Console\Input\InputInterface;
  7367. use Composer\Console\Input\InputOption;
  7368. use Composer\Console\Input\InputArgument;
  7369. use Symfony\Component\Console\Output\OutputInterface;
  7370. class RunScriptCommand extends BaseCommand
  7371. {
  7372. protected $scriptEvents = [
  7373. ScriptEvents::PRE_INSTALL_CMD,
  7374. ScriptEvents::POST_INSTALL_CMD,
  7375. ScriptEvents::PRE_UPDATE_CMD,
  7376. ScriptEvents::POST_UPDATE_CMD,
  7377. ScriptEvents::PRE_STATUS_CMD,
  7378. ScriptEvents::POST_STATUS_CMD,
  7379. ScriptEvents::POST_ROOT_PACKAGE_INSTALL,
  7380. ScriptEvents::POST_CREATE_PROJECT_CMD,
  7381. ScriptEvents::PRE_ARCHIVE_CMD,
  7382. ScriptEvents::POST_ARCHIVE_CMD,
  7383. ScriptEvents::PRE_AUTOLOAD_DUMP,
  7384. ScriptEvents::POST_AUTOLOAD_DUMP,
  7385. ];
  7386. protected function configure(): void
  7387. {
  7388. $this
  7389. ->setName('run-script')
  7390. ->setAliases(['run'])
  7391. ->setDescription('Runs the scripts defined in composer.json')
  7392. ->setDefinition([
  7393. new InputArgument('script', InputArgument::OPTIONAL, 'Script name to run.', null, function () {
  7394. return array_map(static function ($script) { return $script['name']; }, $this->getScripts());
  7395. }),
  7396. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  7397. new InputOption('timeout', null, InputOption::VALUE_REQUIRED, 'Sets script timeout in seconds, or 0 for never.'),
  7398. new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'),
  7399. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'),
  7400. new InputOption('list', 'l', InputOption::VALUE_NONE, 'List scripts.'),
  7401. ])
  7402. ->setHelp(
  7403. <<<EOT
  7404. The <info>run-script</info> command runs scripts defined in composer.json:
  7405. <info>php composer.phar run-script post-update-cmd</info>
  7406. Read more at https://getcomposer.org/doc/03-cli.md#run-script-run
  7407. EOT
  7408. )
  7409. ;
  7410. }
  7411. protected function interact(InputInterface $input, OutputInterface $output): void
  7412. {
  7413. $scripts = $this->getScripts();
  7414. if (count($scripts) === 0) {
  7415. return;
  7416. }
  7417. if ($input->getArgument('script') !== null || $input->getOption('list')) {
  7418. return;
  7419. }
  7420. $options = [];
  7421. foreach ($scripts as $script) {
  7422. $options[$script['name']] = $script['description'];
  7423. }
  7424. $io = $this->getIO();
  7425. $script = $io->select(
  7426. 'Script to run: ',
  7427. $options,
  7428. '',
  7429. 1,
  7430. 'Invalid script name "%s"'
  7431. );
  7432. $input->setArgument('script', $script);
  7433. }
  7434. protected function execute(InputInterface $input, OutputInterface $output): int
  7435. {
  7436. if ($input->getOption('list')) {
  7437. return $this->listScripts($output);
  7438. }
  7439. $script = $input->getArgument('script');
  7440. if ($script === null) {
  7441. throw new \RuntimeException('Missing required argument "script"');
  7442. }
  7443. if (!in_array($script, $this->scriptEvents)) {
  7444. if (defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
  7445. throw new \InvalidArgumentException(sprintf('Script "%s" cannot be run with this command', $script));
  7446. }
  7447. }
  7448. $composer = $this->requireComposer();
  7449. $devMode = $input->getOption('dev') || !$input->getOption('no-dev');
  7450. $event = new ScriptEvent($script, $composer, $this->getIO(), $devMode);
  7451. $hasListeners = $composer->getEventDispatcher()->hasEventListeners($event);
  7452. if (!$hasListeners) {
  7453. throw new \InvalidArgumentException(sprintf('Script "%s" is not defined in this package', $script));
  7454. }
  7455. $args = $input->getArgument('args');
  7456. if (null !== $timeout = $input->getOption('timeout')) {
  7457. if (!ctype_digit($timeout)) {
  7458. throw new \RuntimeException('Timeout value must be numeric and positive if defined, or 0 for forever');
  7459. }
  7460. ProcessExecutor::setTimeout((int) $timeout);
  7461. }
  7462. Platform::putEnv('COMPOSER_DEV_MODE', $devMode ? '1' : '0');
  7463. return $composer->getEventDispatcher()->dispatchScript($script, $devMode, $args);
  7464. }
  7465. protected function listScripts(OutputInterface $output): int
  7466. {
  7467. $scripts = $this->getScripts();
  7468. if (count($scripts) === 0) {
  7469. return 0;
  7470. }
  7471. $io = $this->getIO();
  7472. $io->writeError('<info>scripts:</info>');
  7473. $table = [];
  7474. foreach ($scripts as $script) {
  7475. $table[] = [' '.$script['name'], $script['description']];
  7476. }
  7477. $this->renderTable($table, $output);
  7478. return 0;
  7479. }
  7480. private function getScripts(): array
  7481. {
  7482. $scripts = $this->requireComposer()->getPackage()->getScripts();
  7483. if (count($scripts) === 0) {
  7484. return [];
  7485. }
  7486. $result = [];
  7487. foreach ($scripts as $name => $script) {
  7488. $description = '';
  7489. try {
  7490. $cmd = $this->getApplication()->find($name);
  7491. if ($cmd instanceof ScriptAliasCommand) {
  7492. $description = $cmd->getDescription();
  7493. }
  7494. } catch (\Symfony\Component\Console\Exception\CommandNotFoundException $e) {
  7495. }
  7496. $result[] = ['name' => $name, 'description' => $description];
  7497. }
  7498. return $result;
  7499. }
  7500. }
  7501. <?php declare(strict_types=1);
  7502. namespace Composer\Command;
  7503. use Composer\Pcre\Preg;
  7504. use Symfony\Component\Console\Input\InputInterface;
  7505. use Composer\Console\Input\InputOption;
  7506. use Composer\Console\Input\InputArgument;
  7507. use Symfony\Component\Console\Output\OutputInterface;
  7508. class ScriptAliasCommand extends BaseCommand
  7509. {
  7510. private $script;
  7511. private $description;
  7512. public function __construct(string $script, ?string $description)
  7513. {
  7514. $this->script = $script;
  7515. $this->description = $description ?? 'Runs the '.$script.' script as defined in composer.json';
  7516. $this->ignoreValidationErrors();
  7517. parent::__construct();
  7518. }
  7519. protected function configure(): void
  7520. {
  7521. $this
  7522. ->setName($this->script)
  7523. ->setDescription($this->description)
  7524. ->setDefinition([
  7525. new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'),
  7526. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'),
  7527. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  7528. ])
  7529. ->setHelp(
  7530. <<<EOT
  7531. The <info>run-script</info> command runs scripts defined in composer.json:
  7532. <info>php composer.phar run-script post-update-cmd</info>
  7533. Read more at https://getcomposer.org/doc/03-cli.md#run-script-run
  7534. EOT
  7535. )
  7536. ;
  7537. }
  7538. protected function execute(InputInterface $input, OutputInterface $output): int
  7539. {
  7540. $composer = $this->requireComposer();
  7541. $args = $input->getArguments();
  7542. if (!method_exists($input, '__toString')) {
  7543. throw new \LogicException('Expected an Input instance that is stringable, got '.get_class($input));
  7544. }
  7545. return $composer->getEventDispatcher()->dispatchScript($this->script, $input->getOption('dev') || !$input->getOption('no-dev'), $args['args'], ['script-alias-input' => Preg::replace('{^\S+ ?}', '', $input->__toString(), 1)]);
  7546. }
  7547. }
  7548. <?php declare(strict_types=1);
  7549. namespace Composer\Command;
  7550. use Composer\Factory;
  7551. use Composer\Json\JsonFile;
  7552. use Symfony\Component\Console\Formatter\OutputFormatter;
  7553. use Symfony\Component\Console\Input\InputInterface;
  7554. use Composer\Console\Input\InputArgument;
  7555. use Composer\Console\Input\InputOption;
  7556. use Symfony\Component\Console\Output\OutputInterface;
  7557. use Composer\Repository\CompositeRepository;
  7558. use Composer\Repository\PlatformRepository;
  7559. use Composer\Repository\RepositoryInterface;
  7560. use Composer\Plugin\CommandEvent;
  7561. use Composer\Plugin\PluginEvents;
  7562. class SearchCommand extends BaseCommand
  7563. {
  7564. protected function configure(): void
  7565. {
  7566. $this
  7567. ->setName('search')
  7568. ->setDescription('Searches for packages')
  7569. ->setDefinition([
  7570. new InputOption('only-name', 'N', InputOption::VALUE_NONE, 'Search only in package names'),
  7571. new InputOption('only-vendor', 'O', InputOption::VALUE_NONE, 'Search only for vendor / organization names, returns only "vendor" as result'),
  7572. new InputOption('type', 't', InputOption::VALUE_REQUIRED, 'Search for a specific package type'),
  7573. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text', ['json', 'text']),
  7574. new InputArgument('tokens', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'tokens to search for'),
  7575. ])
  7576. ->setHelp(
  7577. <<<EOT
  7578. The search command searches for packages by its name
  7579. <info>php composer.phar search symfony composer</info>
  7580. Read more at https://getcomposer.org/doc/03-cli.md#search
  7581. EOT
  7582. )
  7583. ;
  7584. }
  7585. protected function execute(InputInterface $input, OutputInterface $output): int
  7586. {
  7587. $platformRepo = new PlatformRepository;
  7588. $io = $this->getIO();
  7589. $format = $input->getOption('format');
  7590. if (!in_array($format, ['text', 'json'])) {
  7591. $io->writeError(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  7592. return 1;
  7593. }
  7594. if (!($composer = $this->tryComposer())) {
  7595. $composer = Factory::create($this->getIO(), [], $input->hasParameterOption('--no-plugins'));
  7596. }
  7597. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  7598. $installedRepo = new CompositeRepository([$localRepo, $platformRepo]);
  7599. $repos = new CompositeRepository(array_merge([$installedRepo], $composer->getRepositoryManager()->getRepositories()));
  7600. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'search', $input, $output);
  7601. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  7602. $mode = RepositoryInterface::SEARCH_FULLTEXT;
  7603. if ($input->getOption('only-name') === true) {
  7604. if ($input->getOption('only-vendor') === true) {
  7605. throw new \InvalidArgumentException('--only-name and --only-vendor cannot be used together');
  7606. }
  7607. $mode = RepositoryInterface::SEARCH_NAME;
  7608. } elseif ($input->getOption('only-vendor') === true) {
  7609. $mode = RepositoryInterface::SEARCH_VENDOR;
  7610. }
  7611. $type = $input->getOption('type');
  7612. $query = implode(' ', $input->getArgument('tokens'));
  7613. if ($mode !== RepositoryInterface::SEARCH_FULLTEXT) {
  7614. $query = preg_quote($query);
  7615. }
  7616. $results = $repos->search($query, $mode, $type);
  7617. if (\count($results) > 0 && $format === 'text') {
  7618. $width = $this->getTerminalWidth();
  7619. $nameLength = 0;
  7620. foreach ($results as $result) {
  7621. $nameLength = max(strlen($result['name']), $nameLength);
  7622. }
  7623. $nameLength += 1;
  7624. foreach ($results as $result) {
  7625. $description = $result['description'] ?? '';
  7626. $warning = !empty($result['abandoned']) ? '<warning>! Abandoned !</warning> ' : '';
  7627. $remaining = $width - $nameLength - strlen($warning) - 2;
  7628. if (strlen($description) > $remaining) {
  7629. $description = substr($description, 0, $remaining - 3) . '...';
  7630. }
  7631. $link = $result['url'] ?? null;
  7632. if ($link !== null) {
  7633. $io->write('<href='.OutputFormatter::escape($link).'>'.$result['name'].'</>'. str_repeat(' ', $nameLength - strlen($result['name'])) . $warning . $description);
  7634. } else {
  7635. $io->write(str_pad($result['name'], $nameLength, ' ') . $warning . $description);
  7636. }
  7637. }
  7638. } elseif ($format === 'json') {
  7639. $io->write(JsonFile::encode($results));
  7640. }
  7641. return 0;
  7642. }
  7643. }
  7644. <?php declare(strict_types=1);
  7645. namespace Composer\Command;
  7646. use Composer\Composer;
  7647. use Composer\Factory;
  7648. use Composer\Config;
  7649. use Composer\Pcre\Preg;
  7650. use Composer\Util\Filesystem;
  7651. use Composer\Util\Platform;
  7652. use Composer\SelfUpdate\Keys;
  7653. use Composer\SelfUpdate\Versions;
  7654. use Composer\IO\IOInterface;
  7655. use Composer\Downloader\FilesystemException;
  7656. use Composer\Downloader\TransportException;
  7657. use Symfony\Component\Console\Input\InputInterface;
  7658. use Composer\Console\Input\InputOption;
  7659. use Composer\Console\Input\InputArgument;
  7660. use Symfony\Component\Console\Output\OutputInterface;
  7661. use Symfony\Component\Finder\Finder;
  7662. class SelfUpdateCommand extends BaseCommand
  7663. {
  7664. private const HOMEPAGE = 'getcomposer.org';
  7665. private const OLD_INSTALL_EXT = '-old.phar';
  7666. protected function configure(): void
  7667. {
  7668. $this
  7669. ->setName('self-update')
  7670. ->setAliases(['selfupdate'])
  7671. ->setDescription('Updates composer.phar to the latest version')
  7672. ->setDefinition([
  7673. new InputOption('rollback', 'r', InputOption::VALUE_NONE, 'Revert to an older installation of composer'),
  7674. 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'),
  7675. new InputArgument('version', InputArgument::OPTIONAL, 'The version to update to'),
  7676. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  7677. new InputOption('update-keys', null, InputOption::VALUE_NONE, 'Prompt user for a key update'),
  7678. new InputOption('stable', null, InputOption::VALUE_NONE, 'Force an update to the stable channel'),
  7679. new InputOption('preview', null, InputOption::VALUE_NONE, 'Force an update to the preview channel'),
  7680. new InputOption('snapshot', null, InputOption::VALUE_NONE, 'Force an update to the snapshot channel'),
  7681. new InputOption('1', null, InputOption::VALUE_NONE, 'Force an update to the stable channel, but only use 1.x versions'),
  7682. new InputOption('2', null, InputOption::VALUE_NONE, 'Force an update to the stable channel, but only use 2.x versions'),
  7683. new InputOption('2.2', null, InputOption::VALUE_NONE, 'Force an update to the stable channel, but only use 2.2.x LTS versions'),
  7684. new InputOption('set-channel-only', null, InputOption::VALUE_NONE, 'Only store the channel as the default one and then exit'),
  7685. ])
  7686. ->setHelp(
  7687. <<<EOT
  7688. The <info>self-update</info> command checks getcomposer.org for newer
  7689. versions of composer and if found, installs the latest.
  7690. <info>php composer.phar self-update</info>
  7691. Read more at https://getcomposer.org/doc/03-cli.md#self-update-selfupdate
  7692. EOT
  7693. )
  7694. ;
  7695. }
  7696. protected function execute(InputInterface $input, OutputInterface $output): int
  7697. {
  7698. if ($_SERVER['argv'][0] === 'Standard input code') {
  7699. return 1;
  7700. }
  7701. class_exists('Composer\Util\Platform');
  7702. class_exists('Composer\Downloader\FilesystemException');
  7703. $config = Factory::createConfig();
  7704. if ($config->get('disable-tls') === true) {
  7705. $baseUrl = 'http://' . self::HOMEPAGE;
  7706. } else {
  7707. $baseUrl = 'https://' . self::HOMEPAGE;
  7708. }
  7709. $io = $this->getIO();
  7710. $httpDownloader = Factory::createHttpDownloader($io, $config);
  7711. $versionsUtil = new Versions($config, $httpDownloader);
  7712. $requestedChannel = null;
  7713. foreach (Versions::CHANNELS as $channel) {
  7714. if ($input->getOption($channel)) {
  7715. $requestedChannel = $channel;
  7716. $versionsUtil->setChannel($channel, $io);
  7717. break;
  7718. }
  7719. }
  7720. if ($input->getOption('set-channel-only')) {
  7721. return 0;
  7722. }
  7723. $cacheDir = $config->get('cache-dir');
  7724. $rollbackDir = $config->get('data-dir');
  7725. $home = $config->get('home');
  7726. $localFilename = realpath($_SERVER['argv'][0]);
  7727. if (false === $localFilename) {
  7728. $localFilename = $_SERVER['argv'][0];
  7729. }
  7730. if ($input->getOption('update-keys')) {
  7731. $this->fetchKeys($io, $config);
  7732. return 0;
  7733. }
  7734. if (!file_exists($localFilename)) {
  7735. throw new FilesystemException('Composer update failed: the "'.$localFilename.'" is not accessible');
  7736. }
  7737. $tmpDir = is_writable(dirname($localFilename)) ? dirname($localFilename) : $cacheDir;
  7738. if (!is_writable($tmpDir)) {
  7739. throw new FilesystemException('Composer update failed: the "'.$tmpDir.'" directory used to download the temp file could not be written');
  7740. }
  7741. if (function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
  7742. $composerUser = posix_getpwuid(posix_geteuid());
  7743. $homeDirOwnerId = fileowner($home);
  7744. if (is_array($composerUser) && $homeDirOwnerId !== false) {
  7745. $homeOwner = posix_getpwuid($homeDirOwnerId);
  7746. if (is_array($homeOwner) && isset($composerUser['name'], $homeOwner['name']) && $composerUser['name'] !== $homeOwner['name']) {
  7747. $io->writeError('<warning>You are running Composer as "'.$composerUser['name'].'", while "'.$home.'" is owned by "'.$homeOwner['name'].'"</warning>');
  7748. }
  7749. }
  7750. }
  7751. if ($input->getOption('rollback')) {
  7752. return $this->rollback($output, $rollbackDir, $localFilename);
  7753. }
  7754. $latest = $versionsUtil->getLatest();
  7755. $latestStable = $versionsUtil->getLatest('stable');
  7756. try {
  7757. $latestPreview = $versionsUtil->getLatest('preview');
  7758. } catch (\UnexpectedValueException $e) {
  7759. $latestPreview = $latestStable;
  7760. }
  7761. $latestVersion = $latest['version'];
  7762. $updateVersion = $input->getArgument('version') ?? $latestVersion;
  7763. $currentMajorVersion = Preg::replace('{^(\d+).*}', '$1', Composer::getVersion());
  7764. $updateMajorVersion = Preg::replace('{^(\d+).*}', '$1', $updateVersion);
  7765. $previewMajorVersion = Preg::replace('{^(\d+).*}', '$1', $latestPreview['version']);
  7766. if ($versionsUtil->getChannel() === 'stable' && null === $input->getArgument('version')) {
  7767. if ($currentMajorVersion < $updateMajorVersion) {
  7768. $skippedVersion = $updateVersion;
  7769. $versionsUtil->setChannel($currentMajorVersion);
  7770. $latest = $versionsUtil->getLatest();
  7771. $latestStable = $versionsUtil->getLatest('stable');
  7772. $latestVersion = $latest['version'];
  7773. $updateVersion = $latestVersion;
  7774. $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>');
  7775. } elseif ($currentMajorVersion < $previewMajorVersion) {
  7776. $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>');
  7777. }
  7778. }
  7779. $effectiveChannel = $requestedChannel === null ? $versionsUtil->getChannel() : $requestedChannel;
  7780. if (is_numeric($effectiveChannel) && strpos($latestStable['version'], $effectiveChannel) !== 0) {
  7781. $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>');
  7782. }
  7783. if (isset($latest['eol'])) {
  7784. $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>');
  7785. }
  7786. if (Preg::isMatch('{^[0-9a-f]{40}$}', $updateVersion) && $updateVersion !== $latestVersion) {
  7787. $io->writeError('<error>You can not update to a specific SHA-1 as those phars are not available for download</error>');
  7788. return 1;
  7789. }
  7790. $channelString = $versionsUtil->getChannel();
  7791. if (is_numeric($channelString)) {
  7792. $channelString .= '.x';
  7793. }
  7794. if (Composer::VERSION === $updateVersion) {
  7795. $io->writeError(
  7796. sprintf(
  7797. '<info>You are already using the latest available Composer version %s (%s channel).</info>',
  7798. $updateVersion,
  7799. $channelString
  7800. )
  7801. );
  7802. if ($input->getOption('clean-backups')) {
  7803. $this->cleanBackups($rollbackDir, $this->getLastBackupVersion($rollbackDir));
  7804. }
  7805. return 0;
  7806. }
  7807. $tempFilename = $tmpDir . '/' . basename($localFilename, '.phar').'-temp'.random_int(0, 10000000).'.phar';
  7808. $backupFile = sprintf(
  7809. '%s/%s-%s%s',
  7810. $rollbackDir,
  7811. strtr(Composer::RELEASE_DATE, ' :', '_-'),
  7812. Preg::replace('{^([0-9a-f]{7})[0-9a-f]{33}$}', '$1', Composer::VERSION),
  7813. self::OLD_INSTALL_EXT
  7814. );
  7815. $updatingToTag = !Preg::isMatch('{^[0-9a-f]{40}$}', $updateVersion);
  7816. $io->write(sprintf("Upgrading to version <info>%s</info> (%s channel).", $updateVersion, $channelString));
  7817. $remoteFilename = $baseUrl . ($updatingToTag ? "/download/{$updateVersion}/composer.phar" : '/composer.phar');
  7818. try {
  7819. $signature = $httpDownloader->get($remoteFilename.'.sig')->getBody();
  7820. } catch (TransportException $e) {
  7821. if ($e->getStatusCode() === 404) {
  7822. throw new \InvalidArgumentException('Version "'.$updateVersion.'" could not be found.', 0, $e);
  7823. }
  7824. throw $e;
  7825. }
  7826. $io->writeError(' ', false);
  7827. $httpDownloader->copy($remoteFilename, $tempFilename);
  7828. $io->writeError('');
  7829. if (!file_exists($tempFilename) || null === $signature || '' === $signature) {
  7830. $io->writeError('<error>The download of the new composer version failed for an unexpected reason</error>');
  7831. return 1;
  7832. }
  7833. if (!extension_loaded('openssl') && $config->get('disable-tls')) {
  7834. $io->writeError('<warning>Skipping phar signature verification as you have disabled OpenSSL via config.disable-tls</warning>');
  7835. } else {
  7836. if (!extension_loaded('openssl')) {
  7837. throw new \RuntimeException('The openssl extension is required for phar signatures to be verified but it is not available. '
  7838. . '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.');
  7839. }
  7840. $sigFile = 'file://'.$home.'/' . ($updatingToTag ? 'keys.tags.pub' : 'keys.dev.pub');
  7841. if (!file_exists($sigFile)) {
  7842. file_put_contents(
  7843. $home.'/keys.dev.pub',
  7844. <<<DEVPUBKEY
  7845. -----BEGIN PUBLIC KEY-----
  7846. MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAnBDHjZS6e0ZMoK3xTD7f
  7847. FNCzlXjX/Aie2dit8QXA03pSrOTbaMnxON3hUL47Lz3g1SC6YJEMVHr0zYq4elWi
  7848. i3ecFEgzLcj+pZM5X6qWu2Ozz4vWx3JYo1/a/HYdOuW9e3lwS8VtS0AVJA+U8X0A
  7849. hZnBmGpltHhO8hPKHgkJtkTUxCheTcbqn4wGHl8Z2SediDcPTLwqezWKUfrYzu1f
  7850. o/j3WFwFs6GtK4wdYtiXr+yspBZHO3y1udf8eFFGcb2V3EaLOrtfur6XQVizjOuk
  7851. 8lw5zzse1Qp/klHqbDRsjSzJ6iL6F4aynBc6Euqt/8ccNAIz0rLjLhOraeyj4eNn
  7852. 8iokwMKiXpcrQLTKH+RH1JCuOVxQ436bJwbSsp1VwiqftPQieN+tzqy+EiHJJmGf
  7853. TBAbWcncicCk9q2md+AmhNbvHO4PWbbz9TzC7HJb460jyWeuMEvw3gNIpEo2jYa9
  7854. pMV6cVqnSa+wOc0D7pC9a6bne0bvLcm3S+w6I5iDB3lZsb3A9UtRiSP7aGSo7D72
  7855. 8tC8+cIgZcI7k9vjvOqH+d7sdOU2yPCnRY6wFh62/g8bDnUpr56nZN1G89GwM4d4
  7856. r/TU7BQQIzsZgAiqOGXvVklIgAMiV0iucgf3rNBLjjeNEwNSTTG9F0CtQ+7JLwaE
  7857. wSEuAuRm+pRqi8BRnQ/GKUcCAwEAAQ==
  7858. -----END PUBLIC KEY-----
  7859. DEVPUBKEY
  7860. );
  7861. file_put_contents(
  7862. $home.'/keys.tags.pub',
  7863. <<<TAGSPUBKEY
  7864. -----BEGIN PUBLIC KEY-----
  7865. MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0Vi/2K6apCVj76nCnCl2
  7866. MQUPdK+A9eqkYBacXo2wQBYmyVlXm2/n/ZsX6pCLYPQTHyr5jXbkQzBw8SKqPdlh
  7867. vA7NpbMeNCz7wP/AobvUXM8xQuXKbMDTY2uZ4O7sM+PfGbptKPBGLe8Z8d2sUnTO
  7868. bXtX6Lrj13wkRto7st/w/Yp33RHe9SlqkiiS4MsH1jBkcIkEHsRaveZzedUaxY0M
  7869. mba0uPhGUInpPzEHwrYqBBEtWvP97t2vtfx8I5qv28kh0Y6t+jnjL1Urid2iuQZf
  7870. noCMFIOu4vksK5HxJxxrN0GOmGmwVQjOOtxkwikNiotZGPR4KsVj8NnBrLX7oGuM
  7871. nQvGciiu+KoC2r3HDBrpDeBVdOWxDzT5R4iI0KoLzFh2pKqwbY+obNPS2bj+2dgJ
  7872. rV3V5Jjry42QOCBN3c88wU1PKftOLj2ECpewY6vnE478IipiEu7EAdK8Zwj2LmTr
  7873. RKQUSa9k7ggBkYZWAeO/2Ag0ey3g2bg7eqk+sHEq5ynIXd5lhv6tC5PBdHlWipDK
  7874. tl2IxiEnejnOmAzGVivE1YGduYBjN+mjxDVy8KGBrjnz1JPgAvgdwJ2dYw4Rsc/e
  7875. TzCFWGk/HM6a4f0IzBWbJ5ot0PIi4amk07IotBXDWwqDiQTwyuGCym5EqWQ2BD95
  7876. RGv89BPD+2DLnJysngsvVaUCAwEAAQ==
  7877. -----END PUBLIC KEY-----
  7878. TAGSPUBKEY
  7879. );
  7880. }
  7881. $pubkeyid = openssl_pkey_get_public($sigFile);
  7882. if (false === $pubkeyid) {
  7883. throw new \RuntimeException('Failed loading the public key from '.$sigFile);
  7884. }
  7885. $algo = defined('OPENSSL_ALGO_SHA384') ? OPENSSL_ALGO_SHA384 : 'SHA384';
  7886. if (!in_array('sha384', array_map('strtolower', openssl_get_md_methods()), true)) {
  7887. throw new \RuntimeException('SHA384 is not supported by your openssl extension, could not verify the phar file integrity');
  7888. }
  7889. $signatureData = json_decode($signature, true);
  7890. $signatureSha384 = base64_decode($signatureData['sha384'], true);
  7891. if (false === $signatureSha384) {
  7892. throw new \RuntimeException('Failed loading the phar signature from '.$remoteFilename.'.sig, got '.$signature);
  7893. }
  7894. $verified = 1 === openssl_verify((string) file_get_contents($tempFilename), $signatureSha384, $pubkeyid, $algo);
  7895. if (PHP_VERSION_ID < 80000) {
  7896. openssl_free_key($pubkeyid);
  7897. }
  7898. if (!$verified) {
  7899. 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');
  7900. }
  7901. }
  7902. if ($input->getOption('clean-backups')) {
  7903. $this->cleanBackups($rollbackDir);
  7904. }
  7905. if (!$this->setLocalPhar($localFilename, $tempFilename, $backupFile)) {
  7906. @unlink($tempFilename);
  7907. return 1;
  7908. }
  7909. if (file_exists($backupFile)) {
  7910. $io->writeError(sprintf(
  7911. 'Use <info>composer self-update --rollback</info> to return to version <comment>%s</comment>',
  7912. Composer::VERSION
  7913. ));
  7914. } else {
  7915. $io->writeError('<warning>A backup of the current version could not be written to '.$backupFile.', no rollback possible</warning>');
  7916. }
  7917. return 0;
  7918. }
  7919. protected function fetchKeys(IOInterface $io, Config $config): void
  7920. {
  7921. if (!$io->isInteractive()) {
  7922. throw new \RuntimeException('Public keys can not be fetched in non-interactive mode, please run Composer interactively');
  7923. }
  7924. $io->write('Open <info>https://composer.github.io/pubkeys.html</info> to find the latest keys');
  7925. $validator = static function ($value): string {
  7926. $value = (string) $value;
  7927. if (!Preg::isMatch('{^-----BEGIN PUBLIC KEY-----$}', trim($value))) {
  7928. throw new \UnexpectedValueException('Invalid input');
  7929. }
  7930. return trim($value)."\n";
  7931. };
  7932. $devKey = '';
  7933. while (!Preg::isMatch('{(-----BEGIN PUBLIC KEY-----.+?-----END PUBLIC KEY-----)}s', $devKey, $match)) {
  7934. $devKey = $io->askAndValidate('Enter Dev / Snapshot Public Key (including lines with -----): ', $validator);
  7935. while ($line = $io->ask('', '')) {
  7936. $devKey .= trim($line)."\n";
  7937. if (trim($line) === '-----END PUBLIC KEY-----') {
  7938. break;
  7939. }
  7940. }
  7941. }
  7942. file_put_contents($keyPath = $config->get('home').'/keys.dev.pub', $match[0]);
  7943. $io->write('Stored key with fingerprint: ' . Keys::fingerprint($keyPath));
  7944. $tagsKey = '';
  7945. while (!Preg::isMatch('{(-----BEGIN PUBLIC KEY-----.+?-----END PUBLIC KEY-----)}s', $tagsKey, $match)) {
  7946. $tagsKey = $io->askAndValidate('Enter Tags Public Key (including lines with -----): ', $validator);
  7947. while ($line = $io->ask('', '')) {
  7948. $tagsKey .= trim($line)."\n";
  7949. if (trim($line) === '-----END PUBLIC KEY-----') {
  7950. break;
  7951. }
  7952. }
  7953. }
  7954. file_put_contents($keyPath = $config->get('home').'/keys.tags.pub', $match[0]);
  7955. $io->write('Stored key with fingerprint: ' . Keys::fingerprint($keyPath));
  7956. $io->write('Public keys stored in '.$config->get('home'));
  7957. }
  7958. protected function rollback(OutputInterface $output, string $rollbackDir, string $localFilename): int
  7959. {
  7960. $rollbackVersion = $this->getLastBackupVersion($rollbackDir);
  7961. if (null === $rollbackVersion) {
  7962. throw new \UnexpectedValueException('Composer rollback failed: no installation to roll back to in "'.$rollbackDir.'"');
  7963. }
  7964. $oldFile = $rollbackDir . '/' . $rollbackVersion . self::OLD_INSTALL_EXT;
  7965. if (!is_file($oldFile)) {
  7966. throw new FilesystemException('Composer rollback failed: "'.$oldFile.'" could not be found');
  7967. }
  7968. if (!Filesystem::isReadable($oldFile)) {
  7969. throw new FilesystemException('Composer rollback failed: "'.$oldFile.'" could not be read');
  7970. }
  7971. $io = $this->getIO();
  7972. $io->writeError(sprintf("Rolling back to version <info>%s</info>.", $rollbackVersion));
  7973. if (!$this->setLocalPhar($localFilename, $oldFile)) {
  7974. return 1;
  7975. }
  7976. return 0;
  7977. }
  7978. protected function setLocalPhar(string $localFilename, string $newFilename, ?string $backupTarget = null): bool
  7979. {
  7980. $io = $this->getIO();
  7981. $perms = @fileperms($localFilename);
  7982. if ($perms !== false) {
  7983. @chmod($newFilename, $perms);
  7984. }
  7985. if (!$this->validatePhar($newFilename, $error)) {
  7986. $io->writeError('<error>The '.($backupTarget !== null ? 'update' : 'backup').' file is corrupted ('.$error.')</error>');
  7987. if ($backupTarget !== null) {
  7988. $io->writeError('<error>Please re-run the self-update command to try again.</error>');
  7989. }
  7990. return false;
  7991. }
  7992. if ($backupTarget !== null) {
  7993. @copy($localFilename, $backupTarget);
  7994. }
  7995. try {
  7996. if (Platform::isWindows()) {
  7997. copy($newFilename, $localFilename);
  7998. @unlink($newFilename);
  7999. } else {
  8000. rename($newFilename, $localFilename);
  8001. }
  8002. return true;
  8003. } catch (\Exception $e) {
  8004. if (!is_writable(dirname($localFilename))
  8005. && $io->isInteractive()
  8006. && $this->isWindowsNonAdminUser()) {
  8007. return $this->tryAsWindowsAdmin($localFilename, $newFilename);
  8008. }
  8009. @unlink($newFilename);
  8010. $action = 'Composer '.($backupTarget !== null ? 'update' : 'rollback');
  8011. throw new FilesystemException($action.' failed: "'.$localFilename.'" could not be written.'.PHP_EOL.$e->getMessage());
  8012. }
  8013. }
  8014. protected function cleanBackups(string $rollbackDir, ?string $except = null): void
  8015. {
  8016. $finder = $this->getOldInstallationFinder($rollbackDir);
  8017. $io = $this->getIO();
  8018. $fs = new Filesystem;
  8019. foreach ($finder as $file) {
  8020. if ($file->getBasename(self::OLD_INSTALL_EXT) === $except) {
  8021. continue;
  8022. }
  8023. $file = (string) $file;
  8024. $io->writeError('<info>Removing: '.$file.'</info>');
  8025. $fs->remove($file);
  8026. }
  8027. }
  8028. protected function getLastBackupVersion(string $rollbackDir): ?string
  8029. {
  8030. $finder = $this->getOldInstallationFinder($rollbackDir);
  8031. $finder->sortByName();
  8032. $files = iterator_to_array($finder);
  8033. if (count($files) > 0) {
  8034. return end($files)->getBasename(self::OLD_INSTALL_EXT);
  8035. }
  8036. return null;
  8037. }
  8038. protected function getOldInstallationFinder(string $rollbackDir): Finder
  8039. {
  8040. return Finder::create()
  8041. ->depth(0)
  8042. ->files()
  8043. ->name('*' . self::OLD_INSTALL_EXT)
  8044. ->in($rollbackDir);
  8045. }
  8046. protected function validatePhar(string $pharFile, ?string &$error): bool
  8047. {
  8048. if ((bool) ini_get('phar.readonly')) {
  8049. return true;
  8050. }
  8051. try {
  8052. $phar = new \Phar($pharFile);
  8053. unset($phar);
  8054. $result = true;
  8055. } catch (\Exception $e) {
  8056. if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) {
  8057. throw $e;
  8058. }
  8059. $error = $e->getMessage();
  8060. $result = false;
  8061. }
  8062. return $result;
  8063. }
  8064. protected function isWindowsNonAdminUser(): bool
  8065. {
  8066. if (!Platform::isWindows()) {
  8067. return false;
  8068. }
  8069. exec('fltmc.exe filters', $output, $exitCode);
  8070. return $exitCode !== 0;
  8071. }
  8072. protected function tryAsWindowsAdmin(string $localFilename, string $newFilename): bool
  8073. {
  8074. $io = $this->getIO();
  8075. $io->writeError('<error>Unable to write "'.$localFilename.'". Access is denied.</error>');
  8076. $helpMessage = 'Please run the self-update command as an Administrator.';
  8077. $question = 'Complete this operation with Administrator privileges [<comment>Y,n</comment>]? ';
  8078. if (!$io->askConfirmation($question, true)) {
  8079. $io->writeError('<warning>Operation cancelled. '.$helpMessage.'</warning>');
  8080. return false;
  8081. }
  8082. $tmpFile = tempnam(sys_get_temp_dir(), '');
  8083. if (false === $tmpFile) {
  8084. $io->writeError('<error>Operation failed.'.$helpMessage.'</error>');
  8085. return false;
  8086. }
  8087. $script = $tmpFile.'.vbs';
  8088. rename($tmpFile, $script);
  8089. $checksum = hash_file('sha256', $newFilename);
  8090. $source = str_replace('/', '\\', $newFilename);
  8091. $destination = str_replace('/', '\\', $localFilename);
  8092. $vbs = <<<EOT
  8093. Set UAC = CreateObject("Shell.Application")
  8094. UAC.ShellExecute "cmd.exe", "/c copy /b /y ""$source"" ""$destination""", "", "runas", 0
  8095. Wscript.Sleep(300)
  8096. EOT;
  8097. file_put_contents($script, $vbs);
  8098. exec('"'.$script.'"');
  8099. @unlink($script);
  8100. if ($result = Filesystem::isReadable($localFilename) && (hash_file('sha256', $localFilename) === $checksum)) {
  8101. $io->writeError('<info>Operation succeeded.</info>');
  8102. @unlink($newFilename);
  8103. } else {
  8104. $io->writeError('<error>Operation failed.'.$helpMessage.'</error>');
  8105. }
  8106. return $result;
  8107. }
  8108. }
  8109. <?php declare(strict_types=1);
  8110. namespace Composer\Command;
  8111. use Composer\Composer;
  8112. use Composer\DependencyResolver\DefaultPolicy;
  8113. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  8114. use Composer\IO\IOInterface;
  8115. use Composer\Json\JsonFile;
  8116. use Composer\Package\BasePackage;
  8117. use Composer\Package\CompletePackageInterface;
  8118. use Composer\Package\Link;
  8119. use Composer\Package\AliasPackage;
  8120. use Composer\Package\PackageInterface;
  8121. use Composer\Package\Version\VersionParser;
  8122. use Composer\Package\Version\VersionSelector;
  8123. use Composer\Pcre\Preg;
  8124. use Composer\Plugin\CommandEvent;
  8125. use Composer\Plugin\PluginEvents;
  8126. use Composer\Repository\InstalledArrayRepository;
  8127. use Composer\Repository\ComposerRepository;
  8128. use Composer\Repository\CompositeRepository;
  8129. use Composer\Repository\FilterRepository;
  8130. use Composer\Repository\PlatformRepository;
  8131. use Composer\Repository\RepositoryFactory;
  8132. use Composer\Repository\InstalledRepository;
  8133. use Composer\Repository\RepositoryInterface;
  8134. use Composer\Repository\RepositorySet;
  8135. use Composer\Repository\RepositoryUtils;
  8136. use Composer\Repository\RootPackageRepository;
  8137. use Composer\Semver\Constraint\ConstraintInterface;
  8138. use Composer\Semver\Semver;
  8139. use Composer\Spdx\SpdxLicenses;
  8140. use Composer\Util\PackageInfo;
  8141. use Symfony\Component\Console\Completion\CompletionInput;
  8142. use Symfony\Component\Console\Formatter\OutputFormatter;
  8143. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  8144. use Composer\Console\Input\InputArgument;
  8145. use Symfony\Component\Console\Input\InputInterface;
  8146. use Composer\Console\Input\InputOption;
  8147. use Symfony\Component\Console\Output\OutputInterface;
  8148. class ShowCommand extends BaseCommand
  8149. {
  8150. use CompletionTrait;
  8151. protected $versionParser;
  8152. protected $colors;
  8153. private $repositorySet;
  8154. protected function configure()
  8155. {
  8156. $this
  8157. ->setName('show')
  8158. ->setAliases(['info'])
  8159. ->setDescription('Shows information about packages')
  8160. ->setDefinition([
  8161. new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.', null, $this->suggestPackageBasedOnMode()),
  8162. new InputArgument('version', InputArgument::OPTIONAL, 'Version or version constraint to inspect'),
  8163. new InputOption('all', null, InputOption::VALUE_NONE, 'List all packages'),
  8164. new InputOption('locked', null, InputOption::VALUE_NONE, 'List all locked packages'),
  8165. new InputOption('installed', 'i', InputOption::VALUE_NONE, 'List installed packages only (enabled by default, only present for BC).'),
  8166. new InputOption('platform', 'p', InputOption::VALUE_NONE, 'List platform packages only'),
  8167. new InputOption('available', 'a', InputOption::VALUE_NONE, 'List available packages only'),
  8168. new InputOption('self', 's', InputOption::VALUE_NONE, 'Show the root package information'),
  8169. new InputOption('name-only', 'N', InputOption::VALUE_NONE, 'List package names only'),
  8170. new InputOption('path', 'P', InputOption::VALUE_NONE, 'Show package paths'),
  8171. new InputOption('tree', 't', InputOption::VALUE_NONE, 'List the dependencies as a tree'),
  8172. new InputOption('latest', 'l', InputOption::VALUE_NONE, 'Show the latest version'),
  8173. new InputOption('outdated', 'o', InputOption::VALUE_NONE, 'Show the latest version but only for packages that are outdated'),
  8174. 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.', null, $this->suggestInstalledPackage(false)),
  8175. new InputOption('major-only', 'M', InputOption::VALUE_NONE, 'Show only packages that have major SemVer-compatible updates. Use with the --latest or --outdated option.'),
  8176. new InputOption('minor-only', 'm', InputOption::VALUE_NONE, 'Show only packages that have minor SemVer-compatible updates. Use with the --latest or --outdated option.'),
  8177. new InputOption('patch-only', null, InputOption::VALUE_NONE, 'Show only packages that have patch SemVer-compatible updates. Use with the --latest or --outdated option.'),
  8178. new InputOption('direct', 'D', InputOption::VALUE_NONE, 'Shows only packages that are directly required by the root package'),
  8179. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code when there are outdated packages'),
  8180. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text', ['json', 'text']),
  8181. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  8182. 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'),
  8183. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages). Use with the --outdated option'),
  8184. ])
  8185. ->setHelp(
  8186. <<<EOT
  8187. The show command displays detailed information about a package, or
  8188. lists all packages available.
  8189. Read more at https://getcomposer.org/doc/03-cli.md#show-info
  8190. EOT
  8191. )
  8192. ;
  8193. }
  8194. protected function suggestPackageBasedOnMode(): \Closure
  8195. {
  8196. return function (CompletionInput $input) {
  8197. if ($input->getOption('available') || $input->getOption('all')) {
  8198. return $this->suggestAvailablePackageInclPlatform()($input);
  8199. }
  8200. if ($input->getOption('platform')) {
  8201. return $this->suggestPlatformPackage()($input);
  8202. }
  8203. return $this->suggestInstalledPackage(false)($input);
  8204. };
  8205. }
  8206. protected function execute(InputInterface $input, OutputInterface $output)
  8207. {
  8208. $this->versionParser = new VersionParser;
  8209. if ($input->getOption('tree')) {
  8210. $this->initStyles($output);
  8211. }
  8212. $composer = $this->tryComposer();
  8213. $io = $this->getIO();
  8214. if ($input->getOption('installed')) {
  8215. $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>');
  8216. }
  8217. if ($input->getOption('outdated')) {
  8218. $input->setOption('latest', true);
  8219. } elseif (count($input->getOption('ignore')) > 0) {
  8220. $io->writeError('<warning>You are using the option "ignore" for action other than "outdated", it will be ignored.</warning>');
  8221. }
  8222. if ($input->getOption('direct') && ($input->getOption('all') || $input->getOption('available') || $input->getOption('platform'))) {
  8223. $io->writeError('The --direct (-D) option is not usable in combination with --all, --platform (-p) or --available (-a)');
  8224. return 1;
  8225. }
  8226. if ($input->getOption('tree') && ($input->getOption('all') || $input->getOption('available'))) {
  8227. $io->writeError('The --tree (-t) option is not usable in combination with --all or --available (-a)');
  8228. return 1;
  8229. }
  8230. if (count(array_filter([$input->getOption('patch-only'), $input->getOption('minor-only'), $input->getOption('major-only')])) > 1) {
  8231. $io->writeError('Only one of --major-only, --minor-only or --patch-only can be used at once');
  8232. return 1;
  8233. }
  8234. if ($input->getOption('tree') && $input->getOption('latest')) {
  8235. $io->writeError('The --tree (-t) option is not usable in combination with --latest (-l)');
  8236. return 1;
  8237. }
  8238. if ($input->getOption('tree') && $input->getOption('path')) {
  8239. $io->writeError('The --tree (-t) option is not usable in combination with --path (-P)');
  8240. return 1;
  8241. }
  8242. $format = $input->getOption('format');
  8243. if (!in_array($format, ['text', 'json'])) {
  8244. $io->writeError(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  8245. return 1;
  8246. }
  8247. $platformReqFilter = $this->getPlatformRequirementFilter($input);
  8248. $platformOverrides = [];
  8249. if ($composer) {
  8250. $platformOverrides = $composer->getConfig()->get('platform');
  8251. }
  8252. $platformRepo = new PlatformRepository([], $platformOverrides);
  8253. $lockedRepo = null;
  8254. if ($input->getOption('self')) {
  8255. $package = clone $this->requireComposer()->getPackage();
  8256. if ($input->getOption('name-only')) {
  8257. $io->write($package->getName());
  8258. return 0;
  8259. }
  8260. if ($input->getArgument('package')) {
  8261. throw new \InvalidArgumentException('You cannot use --self together with a package name');
  8262. }
  8263. $repos = $installedRepo = new InstalledRepository([new RootPackageRepository($package)]);
  8264. } elseif ($input->getOption('platform')) {
  8265. $repos = $installedRepo = new InstalledRepository([$platformRepo]);
  8266. } elseif ($input->getOption('available')) {
  8267. $installedRepo = new InstalledRepository([$platformRepo]);
  8268. if ($composer) {
  8269. $repos = new CompositeRepository($composer->getRepositoryManager()->getRepositories());
  8270. $installedRepo->addRepository($composer->getRepositoryManager()->getLocalRepository());
  8271. } else {
  8272. $defaultRepos = RepositoryFactory::defaultReposWithDefaultManager($io);
  8273. $repos = new CompositeRepository($defaultRepos);
  8274. $io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
  8275. }
  8276. } elseif ($input->getOption('all') && $composer) {
  8277. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  8278. $locker = $composer->getLocker();
  8279. if ($locker->isLocked()) {
  8280. $lockedRepo = $locker->getLockedRepository(true);
  8281. $installedRepo = new InstalledRepository([$lockedRepo, $localRepo, $platformRepo]);
  8282. } else {
  8283. $installedRepo = new InstalledRepository([$localRepo, $platformRepo]);
  8284. }
  8285. $repos = new CompositeRepository(array_merge([new FilterRepository($installedRepo, ['canonical' => false])], $composer->getRepositoryManager()->getRepositories()));
  8286. } elseif ($input->getOption('all')) {
  8287. $defaultRepos = RepositoryFactory::defaultReposWithDefaultManager($io);
  8288. $io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
  8289. $installedRepo = new InstalledRepository([$platformRepo]);
  8290. $repos = new CompositeRepository(array_merge([$installedRepo], $defaultRepos));
  8291. } elseif ($input->getOption('locked')) {
  8292. if (!$composer || !$composer->getLocker()->isLocked()) {
  8293. throw new \UnexpectedValueException('A valid composer.json and composer.lock files is required to run this command with --locked');
  8294. }
  8295. $locker = $composer->getLocker();
  8296. $lockedRepo = $locker->getLockedRepository(!$input->getOption('no-dev'));
  8297. $repos = $installedRepo = new InstalledRepository([$lockedRepo]);
  8298. } else {
  8299. if (!$composer) {
  8300. $composer = $this->requireComposer();
  8301. }
  8302. $rootPkg = $composer->getPackage();
  8303. $repos = $installedRepo = new InstalledRepository([$composer->getRepositoryManager()->getLocalRepository()]);
  8304. if ($input->getOption('no-dev')) {
  8305. $packages = RepositoryUtils::filterRequiredPackages($installedRepo->getPackages(), $rootPkg);
  8306. $repos = $installedRepo = new InstalledRepository([new InstalledArrayRepository(array_map(static function ($pkg): PackageInterface {
  8307. return clone $pkg;
  8308. }, $packages))]);
  8309. }
  8310. if (!$installedRepo->getPackages() && ($rootPkg->getRequires() || $rootPkg->getDevRequires())) {
  8311. $io->writeError('<warning>No dependencies installed. Try running composer install or update.</warning>');
  8312. }
  8313. }
  8314. if ($composer) {
  8315. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'show', $input, $output);
  8316. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  8317. }
  8318. if ($input->getOption('latest') && null === $composer) {
  8319. $io->writeError('No composer.json found in the current directory, disabling "latest" option');
  8320. $input->setOption('latest', false);
  8321. }
  8322. $packageFilter = $input->getArgument('package');
  8323. if (isset($package)) {
  8324. $versions = [$package->getPrettyVersion() => $package->getVersion()];
  8325. } elseif (null !== $packageFilter && !str_contains($packageFilter, '*')) {
  8326. [$package, $versions] = $this->getPackage($installedRepo, $repos, $packageFilter, $input->getArgument('version'));
  8327. if (!isset($package)) {
  8328. $options = $input->getOptions();
  8329. $hint = '';
  8330. if ($input->getOption('locked')) {
  8331. $hint .= ' in lock file';
  8332. }
  8333. if (isset($options['working-dir'])) {
  8334. $hint .= ' in ' . $options['working-dir'] . '/composer.json';
  8335. }
  8336. if (PlatformRepository::isPlatformPackage($packageFilter) && !$input->getOption('platform')) {
  8337. $hint .= ', try using --platform (-p) to show platform packages';
  8338. }
  8339. if (!$input->getOption('all')) {
  8340. $hint .= ', try using --available (-a) to show all available packages';
  8341. }
  8342. throw new \InvalidArgumentException('Package "' . $packageFilter . '" not found'.$hint.'.');
  8343. }
  8344. }
  8345. if (isset($package)) {
  8346. assert(isset($versions));
  8347. $exitCode = 0;
  8348. if ($input->getOption('tree')) {
  8349. $arrayTree = $this->generatePackageTree($package, $installedRepo, $repos);
  8350. if ('json' === $format) {
  8351. $io->write(JsonFile::encode(['installed' => [$arrayTree]]));
  8352. } else {
  8353. $this->displayPackageTree([$arrayTree]);
  8354. }
  8355. return $exitCode;
  8356. }
  8357. $latestPackage = null;
  8358. if ($input->getOption('latest')) {
  8359. $latestPackage = $this->findLatestPackage($package, $composer, $platformRepo, $input->getOption('major-only'), $input->getOption('minor-only'), $input->getOption('patch-only'), $platformReqFilter);
  8360. }
  8361. if (
  8362. $input->getOption('outdated')
  8363. && $input->getOption('strict')
  8364. && null !== $latestPackage
  8365. && $latestPackage->getFullPrettyVersion() !== $package->getFullPrettyVersion()
  8366. && (!$latestPackage instanceof CompletePackageInterface || !$latestPackage->isAbandoned())
  8367. ) {
  8368. $exitCode = 1;
  8369. }
  8370. if ($input->getOption('path')) {
  8371. $io->write($package->getName(), false);
  8372. $path = $composer->getInstallationManager()->getInstallPath($package);
  8373. if (is_string($path)) {
  8374. $io->write(' ' . strtok(realpath($path), "\r\n"));
  8375. } else {
  8376. $io->write(' null');
  8377. }
  8378. return $exitCode;
  8379. }
  8380. if ('json' === $format) {
  8381. $this->printPackageInfoAsJson($package, $versions, $installedRepo, $latestPackage ?: null);
  8382. } else {
  8383. $this->printPackageInfo($package, $versions, $installedRepo, $latestPackage ?: null);
  8384. }
  8385. return $exitCode;
  8386. }
  8387. if ($input->getOption('tree')) {
  8388. $rootRequires = $this->getRootRequires();
  8389. $packages = $installedRepo->getPackages();
  8390. usort($packages, static function (BasePackage $a, BasePackage $b): int {
  8391. return strcmp((string) $a, (string) $b);
  8392. });
  8393. $arrayTree = [];
  8394. foreach ($packages as $package) {
  8395. if (in_array($package->getName(), $rootRequires, true)) {
  8396. $arrayTree[] = $this->generatePackageTree($package, $installedRepo, $repos);
  8397. }
  8398. }
  8399. if ('json' === $format) {
  8400. $io->write(JsonFile::encode(['installed' => $arrayTree]));
  8401. } else {
  8402. $this->displayPackageTree($arrayTree);
  8403. }
  8404. return 0;
  8405. }
  8406. $packages = [];
  8407. $packageFilterRegex = null;
  8408. if (null !== $packageFilter) {
  8409. $packageFilterRegex = '{^'.str_replace('\\*', '.*?', preg_quote($packageFilter)).'$}i';
  8410. }
  8411. $packageListFilter = null;
  8412. if ($input->getOption('direct')) {
  8413. $packageListFilter = $this->getRootRequires();
  8414. }
  8415. if ($input->getOption('path') && null === $composer) {
  8416. $io->writeError('No composer.json found in the current directory, disabling "path" option');
  8417. $input->setOption('path', false);
  8418. }
  8419. foreach (RepositoryUtils::flattenRepositories($repos) as $repo) {
  8420. if ($repo === $platformRepo) {
  8421. $type = 'platform';
  8422. } elseif ($lockedRepo !== null && $repo === $lockedRepo) {
  8423. $type = 'locked';
  8424. } elseif ($repo === $installedRepo || in_array($repo, $installedRepo->getRepositories(), true)) {
  8425. $type = 'installed';
  8426. } else {
  8427. $type = 'available';
  8428. }
  8429. if ($repo instanceof ComposerRepository) {
  8430. foreach ($repo->getPackageNames($packageFilter) as $name) {
  8431. $packages[$type][$name] = $name;
  8432. }
  8433. } else {
  8434. foreach ($repo->getPackages() as $package) {
  8435. if (!isset($packages[$type][$package->getName()])
  8436. || !is_object($packages[$type][$package->getName()])
  8437. || version_compare($packages[$type][$package->getName()]->getVersion(), $package->getVersion(), '<')
  8438. ) {
  8439. while ($package instanceof AliasPackage) {
  8440. $package = $package->getAliasOf();
  8441. }
  8442. if (!$packageFilterRegex || Preg::isMatch($packageFilterRegex, $package->getName())) {
  8443. if (null === $packageListFilter || in_array($package->getName(), $packageListFilter, true)) {
  8444. $packages[$type][$package->getName()] = $package;
  8445. }
  8446. }
  8447. }
  8448. }
  8449. if ($repo === $platformRepo) {
  8450. foreach ($platformRepo->getDisabledPackages() as $name => $package) {
  8451. $packages[$type][$name] = $package;
  8452. }
  8453. }
  8454. }
  8455. }
  8456. $showAllTypes = $input->getOption('all');
  8457. $showLatest = $input->getOption('latest');
  8458. $showMajorOnly = $input->getOption('major-only');
  8459. $showMinorOnly = $input->getOption('minor-only');
  8460. $showPatchOnly = $input->getOption('patch-only');
  8461. $ignoredPackages = array_map('strtolower', $input->getOption('ignore'));
  8462. $indent = $showAllTypes ? ' ' : '';
  8463. $latestPackages = [];
  8464. $exitCode = 0;
  8465. $viewData = [];
  8466. $viewMetaData = [];
  8467. $writeVersion = false;
  8468. $writeDescription = false;
  8469. foreach (['platform' => true, 'locked' => true, 'available' => false, 'installed' => true] as $type => $showVersion) {
  8470. if (isset($packages[$type])) {
  8471. ksort($packages[$type]);
  8472. $nameLength = $versionLength = $latestLength = 0;
  8473. if ($showLatest && $showVersion) {
  8474. foreach ($packages[$type] as $package) {
  8475. if (is_object($package)) {
  8476. $latestPackage = $this->findLatestPackage($package, $composer, $platformRepo, $showMajorOnly, $showMinorOnly, $showPatchOnly, $platformReqFilter);
  8477. if ($latestPackage === null) {
  8478. continue;
  8479. }
  8480. $latestPackages[$package->getPrettyName()] = $latestPackage;
  8481. }
  8482. }
  8483. }
  8484. $writePath = !$input->getOption('name-only') && $input->getOption('path');
  8485. $writeVersion = !$input->getOption('name-only') && !$input->getOption('path') && $showVersion;
  8486. $writeLatest = $writeVersion && $showLatest;
  8487. $writeDescription = !$input->getOption('name-only') && !$input->getOption('path');
  8488. $hasOutdatedPackages = false;
  8489. $viewData[$type] = [];
  8490. foreach ($packages[$type] as $package) {
  8491. $packageViewData = [];
  8492. if (is_object($package)) {
  8493. $latestPackage = null;
  8494. if ($showLatest && isset($latestPackages[$package->getPrettyName()])) {
  8495. $latestPackage = $latestPackages[$package->getPrettyName()];
  8496. }
  8497. $packageIsUpToDate = $latestPackage && $latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion() && (!$latestPackage instanceof CompletePackageInterface || !$latestPackage->isAbandoned());
  8498. $packageIsUpToDate = $packageIsUpToDate || ($latestPackage === null && $showMajorOnly);
  8499. $packageIsIgnored = \in_array($package->getPrettyName(), $ignoredPackages, true);
  8500. if ($input->getOption('outdated') && ($packageIsUpToDate || $packageIsIgnored)) {
  8501. continue;
  8502. }
  8503. if ($input->getOption('outdated') || $input->getOption('strict')) {
  8504. $hasOutdatedPackages = true;
  8505. }
  8506. $packageViewData['name'] = $package->getPrettyName();
  8507. $packageViewData['direct-dependency'] = in_array($package->getName(), $this->getRootRequires(), true);
  8508. if ($format !== 'json' || true !== $input->getOption('name-only')) {
  8509. $packageViewData['homepage'] = $package instanceof CompletePackageInterface ? $package->getHomepage() : null;
  8510. $packageViewData['source'] = PackageInfo::getViewSourceUrl($package);
  8511. }
  8512. $nameLength = max($nameLength, strlen($package->getPrettyName()));
  8513. if ($writeVersion) {
  8514. $packageViewData['version'] = $package->getFullPrettyVersion();
  8515. $versionLength = max($versionLength, strlen($package->getFullPrettyVersion()));
  8516. }
  8517. if ($writeLatest && $latestPackage) {
  8518. $packageViewData['latest'] = $latestPackage->getFullPrettyVersion();
  8519. $packageViewData['latest-status'] = $this->getUpdateStatus($latestPackage, $package);
  8520. $latestLength = max($latestLength, strlen($packageViewData['latest']));
  8521. } elseif ($writeLatest) {
  8522. $packageViewData['latest'] = '[none matched]';
  8523. $packageViewData['latest-status'] = 'up-to-date';
  8524. $latestLength = max($latestLength, strlen($packageViewData['latest']));
  8525. }
  8526. if ($writeDescription && $package instanceof CompletePackageInterface) {
  8527. $packageViewData['description'] = $package->getDescription();
  8528. }
  8529. if ($writePath) {
  8530. $path = $composer->getInstallationManager()->getInstallPath($package);
  8531. if (is_string($path)) {
  8532. $packageViewData['path'] = strtok(realpath($path), "\r\n");
  8533. } else {
  8534. $packageViewData['path'] = null;
  8535. }
  8536. }
  8537. $packageIsAbandoned = false;
  8538. if ($latestPackage instanceof CompletePackageInterface && $latestPackage->isAbandoned()) {
  8539. $replacementPackageName = $latestPackage->getReplacementPackage();
  8540. $replacement = $replacementPackageName !== null
  8541. ? 'Use ' . $latestPackage->getReplacementPackage() . ' instead'
  8542. : 'No replacement was suggested';
  8543. $packageWarning = sprintf(
  8544. 'Package %s is abandoned, you should avoid using it. %s.',
  8545. $package->getPrettyName(),
  8546. $replacement
  8547. );
  8548. $packageViewData['warning'] = $packageWarning;
  8549. $packageIsAbandoned = $replacementPackageName ?? true;
  8550. }
  8551. $packageViewData['abandoned'] = $packageIsAbandoned;
  8552. } else {
  8553. $packageViewData['name'] = $package;
  8554. $nameLength = max($nameLength, strlen($package));
  8555. }
  8556. $viewData[$type][] = $packageViewData;
  8557. }
  8558. $viewMetaData[$type] = [
  8559. 'nameLength' => $nameLength,
  8560. 'versionLength' => $versionLength,
  8561. 'latestLength' => $latestLength,
  8562. 'writeLatest' => $writeLatest,
  8563. ];
  8564. if ($input->getOption('strict') && $hasOutdatedPackages) {
  8565. $exitCode = 1;
  8566. break;
  8567. }
  8568. }
  8569. }
  8570. if ('json' === $format) {
  8571. $io->write(JsonFile::encode($viewData));
  8572. } else {
  8573. if ($input->getOption('latest') && array_filter($viewData)) {
  8574. if (!$io->isDecorated()) {
  8575. $io->writeError('Legend:');
  8576. $io->writeError('! patch or minor release available - update recommended');
  8577. $io->writeError('~ major release available - update possible');
  8578. if (!$input->getOption('outdated')) {
  8579. $io->writeError('= up to date version');
  8580. }
  8581. } else {
  8582. $io->writeError('<info>Color legend:</info>');
  8583. $io->writeError('- <highlight>patch or minor</highlight> release available - update recommended');
  8584. $io->writeError('- <comment>major</comment> release available - update possible');
  8585. if (!$input->getOption('outdated')) {
  8586. $io->writeError('- <info>up to date</info> version');
  8587. }
  8588. }
  8589. }
  8590. $width = $this->getTerminalWidth();
  8591. foreach ($viewData as $type => $packages) {
  8592. $nameLength = $viewMetaData[$type]['nameLength'];
  8593. $versionLength = $viewMetaData[$type]['versionLength'];
  8594. $latestLength = $viewMetaData[$type]['latestLength'];
  8595. $writeLatest = $viewMetaData[$type]['writeLatest'];
  8596. $versionFits = $nameLength + $versionLength + 3 <= $width;
  8597. $latestFits = $nameLength + $versionLength + $latestLength + 3 <= $width;
  8598. $descriptionFits = $nameLength + $versionLength + $latestLength + 24 <= $width;
  8599. if ($latestFits && !$io->isDecorated()) {
  8600. $latestLength += 2;
  8601. }
  8602. if ($showAllTypes) {
  8603. if ('available' === $type) {
  8604. $io->write('<comment>' . $type . '</comment>:');
  8605. } else {
  8606. $io->write('<info>' . $type . '</info>:');
  8607. }
  8608. }
  8609. if ($writeLatest && !$input->getOption('direct')) {
  8610. $directDeps = [];
  8611. $transitiveDeps = [];
  8612. foreach ($packages as $pkg) {
  8613. if ($pkg['direct-dependency'] ?? false) {
  8614. $directDeps[] = $pkg;
  8615. } else {
  8616. $transitiveDeps[] = $pkg;
  8617. }
  8618. }
  8619. $io->writeError('');
  8620. $io->writeError('<info>Direct dependencies required in composer.json:</>');
  8621. if (\count($directDeps) > 0) {
  8622. $this->printPackages($io, $directDeps, $indent, $writeVersion && $versionFits, $latestFits, $writeDescription && $descriptionFits, $width, $versionLength, $nameLength, $latestLength);
  8623. } else {
  8624. $io->writeError('Everything up to date');
  8625. }
  8626. $io->writeError('');
  8627. $io->writeError('<info>Transitive dependencies not required in composer.json:</>');
  8628. if (\count($transitiveDeps) > 0) {
  8629. $this->printPackages($io, $transitiveDeps, $indent, $writeVersion && $versionFits, $latestFits, $writeDescription && $descriptionFits, $width, $versionLength, $nameLength, $latestLength);
  8630. } else {
  8631. $io->writeError('Everything up to date');
  8632. }
  8633. } else {
  8634. if ($writeLatest && \count($packages) === 0) {
  8635. $io->writeError('All your direct dependencies are up to date');
  8636. } else {
  8637. $this->printPackages($io, $packages, $indent, $writeVersion && $versionFits, $writeLatest && $latestFits, $writeDescription && $descriptionFits, $width, $versionLength, $nameLength, $latestLength);
  8638. }
  8639. }
  8640. if ($showAllTypes) {
  8641. $io->write('');
  8642. }
  8643. }
  8644. }
  8645. return $exitCode;
  8646. }
  8647. private function printPackages(IOInterface $io, array $packages, string $indent, bool $writeVersion, bool $writeLatest, bool $writeDescription, int $width, int $versionLength, int $nameLength, int $latestLength): void
  8648. {
  8649. $padName = $writeVersion || $writeLatest || $writeDescription;
  8650. $padVersion = $writeLatest || $writeDescription;
  8651. $padLatest = $writeDescription;
  8652. foreach ($packages as $package) {
  8653. $link = $package['source'] ?? $package['homepage'] ?? '';
  8654. if ($link !== '') {
  8655. $io->write($indent . '<href='.OutputFormatter::escape($link).'>'.$package['name'].'</>'. str_repeat(' ', ($padName ? $nameLength - strlen($package['name']) : 0)), false);
  8656. } else {
  8657. $io->write($indent . str_pad($package['name'], ($padName ? $nameLength : 0), ' '), false);
  8658. }
  8659. if (isset($package['version']) && $writeVersion) {
  8660. $io->write(' ' . str_pad($package['version'], ($padVersion ? $versionLength : 0), ' '), false);
  8661. }
  8662. if (isset($package['latest']) && isset($package['latest-status']) && $writeLatest) {
  8663. $latestVersion = $package['latest'];
  8664. $updateStatus = $package['latest-status'];
  8665. $style = $this->updateStatusToVersionStyle($updateStatus);
  8666. if (!$io->isDecorated()) {
  8667. $latestVersion = str_replace(['up-to-date', 'semver-safe-update', 'update-possible'], ['=', '!', '~'], $updateStatus) . ' ' . $latestVersion;
  8668. }
  8669. $io->write(' <' . $style . '>' . str_pad($latestVersion, ($padLatest ? $latestLength : 0), ' ') . '</' . $style . '>', false);
  8670. }
  8671. if (isset($package['description']) && $writeDescription) {
  8672. $description = strtok($package['description'], "\r\n");
  8673. $remaining = $width - $nameLength - $versionLength - 4;
  8674. if ($writeLatest) {
  8675. $remaining -= $latestLength;
  8676. }
  8677. if (strlen($description) > $remaining) {
  8678. $description = substr($description, 0, $remaining - 3) . '...';
  8679. }
  8680. $io->write(' ' . $description, false);
  8681. }
  8682. if (array_key_exists('path', $package)) {
  8683. $io->write(' '.(is_string($package['path']) ? $package['path'] : 'null'), false);
  8684. }
  8685. $io->write('');
  8686. if (isset($package['warning'])) {
  8687. $io->write('<warning>' . $package['warning'] . '</warning>');
  8688. }
  8689. }
  8690. }
  8691. protected function getRootRequires(): array
  8692. {
  8693. $composer = $this->tryComposer();
  8694. if ($composer === null) {
  8695. return [];
  8696. }
  8697. $rootPackage = $composer->getPackage();
  8698. return array_map(
  8699. 'strtolower',
  8700. array_keys(array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires()))
  8701. );
  8702. }
  8703. protected function getVersionStyle(PackageInterface $latestPackage, PackageInterface $package)
  8704. {
  8705. return $this->updateStatusToVersionStyle($this->getUpdateStatus($latestPackage, $package));
  8706. }
  8707. protected function getPackage(InstalledRepository $installedRepo, RepositoryInterface $repos, string $name, $version = null): array
  8708. {
  8709. $name = strtolower($name);
  8710. $constraint = is_string($version) ? $this->versionParser->parseConstraints($version) : $version;
  8711. $policy = new DefaultPolicy();
  8712. $repositorySet = new RepositorySet('dev');
  8713. $repositorySet->allowInstalledRepositories();
  8714. $repositorySet->addRepository($repos);
  8715. $matchedPackage = null;
  8716. $versions = [];
  8717. if (PlatformRepository::isPlatformPackage($name)) {
  8718. $pool = $repositorySet->createPoolWithAllPackages();
  8719. } else {
  8720. $pool = $repositorySet->createPoolForPackage($name);
  8721. }
  8722. $matches = $pool->whatProvides($name, $constraint);
  8723. foreach ($matches as $index => $package) {
  8724. if ($package instanceof AliasPackage && $package->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  8725. $package = $package->getAliasOf();
  8726. }
  8727. if (null === $version && $installedRepo->hasPackage($package)) {
  8728. $matchedPackage = $package;
  8729. }
  8730. $versions[$package->getPrettyVersion()] = $package->getVersion();
  8731. $matches[$index] = $package->getId();
  8732. }
  8733. if (null === $matchedPackage && $matches && $preferred = $policy->selectPreferredPackages($pool, $matches)) {
  8734. $matchedPackage = $pool->literalToPackage($preferred[0]);
  8735. }
  8736. if ($matchedPackage !== null && !$matchedPackage instanceof CompletePackageInterface) {
  8737. throw new \LogicException('ShowCommand::getPackage can only work with CompletePackageInterface, but got '.get_class($matchedPackage));
  8738. }
  8739. return [$matchedPackage, $versions];
  8740. }
  8741. protected function printPackageInfo(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, ?PackageInterface $latestPackage = null): void
  8742. {
  8743. $io = $this->getIO();
  8744. $this->printMeta($package, $versions, $installedRepo, $latestPackage ?: null);
  8745. $this->printLinks($package, Link::TYPE_REQUIRE);
  8746. $this->printLinks($package, Link::TYPE_DEV_REQUIRE, 'requires (dev)');
  8747. if ($package->getSuggests()) {
  8748. $io->write("\n<info>suggests</info>");
  8749. foreach ($package->getSuggests() as $suggested => $reason) {
  8750. $io->write($suggested . ' <comment>' . $reason . '</comment>');
  8751. }
  8752. }
  8753. $this->printLinks($package, Link::TYPE_PROVIDE);
  8754. $this->printLinks($package, Link::TYPE_CONFLICT);
  8755. $this->printLinks($package, Link::TYPE_REPLACE);
  8756. }
  8757. protected function printMeta(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, ?PackageInterface $latestPackage = null): void
  8758. {
  8759. $io = $this->getIO();
  8760. $io->write('<info>name</info> : ' . $package->getPrettyName());
  8761. $io->write('<info>descrip.</info> : ' . $package->getDescription());
  8762. $io->write('<info>keywords</info> : ' . implode(', ', $package->getKeywords() ?: []));
  8763. $this->printVersions($package, $versions, $installedRepo);
  8764. if ($latestPackage) {
  8765. $style = $this->getVersionStyle($latestPackage, $package);
  8766. $io->write('<info>latest</info> : <'.$style.'>' . $latestPackage->getPrettyVersion() . '</'.$style.'>');
  8767. } else {
  8768. $latestPackage = $package;
  8769. }
  8770. $io->write('<info>type</info> : ' . $package->getType());
  8771. $this->printLicenses($package);
  8772. $io->write('<info>homepage</info> : ' . $package->getHomepage());
  8773. $io->write('<info>source</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getSourceType(), $package->getSourceUrl(), $package->getSourceReference()));
  8774. $io->write('<info>dist</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getDistType(), $package->getDistUrl(), $package->getDistReference()));
  8775. if (!PlatformRepository::isPlatformPackage($package->getName()) && $installedRepo->hasPackage($package)) {
  8776. $path = $this->requireComposer()->getInstallationManager()->getInstallPath($package);
  8777. if (is_string($path)) {
  8778. $io->write('<info>path</info> : ' . realpath($path));
  8779. } else {
  8780. $io->write('<info>path</info> : null');
  8781. }
  8782. }
  8783. $io->write('<info>names</info> : ' . implode(', ', $package->getNames()));
  8784. if ($latestPackage instanceof CompletePackageInterface && $latestPackage->isAbandoned()) {
  8785. $replacement = ($latestPackage->getReplacementPackage() !== null)
  8786. ? ' The author suggests using the ' . $latestPackage->getReplacementPackage(). ' package instead.'
  8787. : null;
  8788. $io->writeError(
  8789. sprintf('<warning>Attention: This package is abandoned and no longer maintained.%s</warning>', $replacement)
  8790. );
  8791. }
  8792. if ($package->getSupport()) {
  8793. $io->write("\n<info>support</info>");
  8794. foreach ($package->getSupport() as $type => $value) {
  8795. $io->write('<comment>' . $type . '</comment> : '.$value);
  8796. }
  8797. }
  8798. if (\count($package->getAutoload()) > 0) {
  8799. $io->write("\n<info>autoload</info>");
  8800. $autoloadConfig = $package->getAutoload();
  8801. foreach ($autoloadConfig as $type => $autoloads) {
  8802. $io->write('<comment>' . $type . '</comment>');
  8803. if ($type === 'psr-0' || $type === 'psr-4') {
  8804. foreach ($autoloads as $name => $path) {
  8805. $io->write(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
  8806. }
  8807. } elseif ($type === 'classmap') {
  8808. $io->write(implode(', ', $autoloadConfig[$type]));
  8809. }
  8810. }
  8811. if ($package->getIncludePaths()) {
  8812. $io->write('<comment>include-path</comment>');
  8813. $io->write(implode(', ', $package->getIncludePaths()));
  8814. }
  8815. }
  8816. }
  8817. protected function printVersions(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo): void
  8818. {
  8819. $versions = array_keys($versions);
  8820. $versions = Semver::rsort($versions);
  8821. if ($installedPackages = $installedRepo->findPackages($package->getName())) {
  8822. foreach ($installedPackages as $installedPackage) {
  8823. $installedVersion = $installedPackage->getPrettyVersion();
  8824. $key = array_search($installedVersion, $versions);
  8825. if (false !== $key) {
  8826. $versions[$key] = '<info>* ' . $installedVersion . '</info>';
  8827. }
  8828. }
  8829. }
  8830. $versions = implode(', ', $versions);
  8831. $this->getIO()->write('<info>versions</info> : ' . $versions);
  8832. }
  8833. protected function printLinks(CompletePackageInterface $package, string $linkType, ?string $title = null): void
  8834. {
  8835. $title = $title ?: $linkType;
  8836. $io = $this->getIO();
  8837. if ($links = $package->{'get'.ucfirst($linkType)}()) {
  8838. $io->write("\n<info>" . $title . "</info>");
  8839. foreach ($links as $link) {
  8840. $io->write($link->getTarget() . ' <comment>' . $link->getPrettyConstraint() . '</comment>');
  8841. }
  8842. }
  8843. }
  8844. protected function printLicenses(CompletePackageInterface $package): void
  8845. {
  8846. $spdxLicenses = new SpdxLicenses();
  8847. $licenses = $package->getLicense();
  8848. $io = $this->getIO();
  8849. foreach ($licenses as $licenseId) {
  8850. $license = $spdxLicenses->getLicenseByIdentifier($licenseId);
  8851. if (!$license) {
  8852. $out = $licenseId;
  8853. } else {
  8854. if ($license[1] === true) {
  8855. $out = sprintf('%s (%s) (OSI approved) %s', $license[0], $licenseId, $license[2]);
  8856. } else {
  8857. $out = sprintf('%s (%s) %s', $license[0], $licenseId, $license[2]);
  8858. }
  8859. }
  8860. $io->write('<info>license</info> : ' . $out);
  8861. }
  8862. }
  8863. protected function printPackageInfoAsJson(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, ?PackageInterface $latestPackage = null): void
  8864. {
  8865. $json = [
  8866. 'name' => $package->getPrettyName(),
  8867. 'description' => $package->getDescription(),
  8868. 'keywords' => $package->getKeywords() ?: [],
  8869. 'type' => $package->getType(),
  8870. 'homepage' => $package->getHomepage(),
  8871. 'names' => $package->getNames(),
  8872. ];
  8873. $json = $this->appendVersions($json, $versions);
  8874. $json = $this->appendLicenses($json, $package);
  8875. if ($latestPackage) {
  8876. $json['latest'] = $latestPackage->getPrettyVersion();
  8877. } else {
  8878. $latestPackage = $package;
  8879. }
  8880. if (null !== $package->getSourceType()) {
  8881. $json['source'] = [
  8882. 'type' => $package->getSourceType(),
  8883. 'url' => $package->getSourceUrl(),
  8884. 'reference' => $package->getSourceReference(),
  8885. ];
  8886. }
  8887. if (null !== $package->getDistType()) {
  8888. $json['dist'] = [
  8889. 'type' => $package->getDistType(),
  8890. 'url' => $package->getDistUrl(),
  8891. 'reference' => $package->getDistReference(),
  8892. ];
  8893. }
  8894. if (!PlatformRepository::isPlatformPackage($package->getName()) && $installedRepo->hasPackage($package)) {
  8895. $path = $this->requireComposer()->getInstallationManager()->getInstallPath($package);
  8896. if (is_string($path)) {
  8897. $path = realpath($path);
  8898. if ($path !== false) {
  8899. $json['path'] = $path;
  8900. }
  8901. } else {
  8902. $json['path'] = null;
  8903. }
  8904. }
  8905. if ($latestPackage instanceof CompletePackageInterface && $latestPackage->isAbandoned()) {
  8906. $json['replacement'] = $latestPackage->getReplacementPackage();
  8907. }
  8908. if ($package->getSuggests()) {
  8909. $json['suggests'] = $package->getSuggests();
  8910. }
  8911. if ($package->getSupport()) {
  8912. $json['support'] = $package->getSupport();
  8913. }
  8914. $json = $this->appendAutoload($json, $package);
  8915. if ($package->getIncludePaths()) {
  8916. $json['include_path'] = $package->getIncludePaths();
  8917. }
  8918. $json = $this->appendLinks($json, $package);
  8919. $this->getIO()->write(JsonFile::encode($json));
  8920. }
  8921. private function appendVersions(array $json, array $versions): array
  8922. {
  8923. uasort($versions, 'version_compare');
  8924. $versions = array_keys(array_reverse($versions));
  8925. $json['versions'] = $versions;
  8926. return $json;
  8927. }
  8928. private function appendLicenses(array $json, CompletePackageInterface $package): array
  8929. {
  8930. if ($licenses = $package->getLicense()) {
  8931. $spdxLicenses = new SpdxLicenses();
  8932. $json['licenses'] = array_map(static function ($licenseId) use ($spdxLicenses) {
  8933. $license = $spdxLicenses->getLicenseByIdentifier($licenseId);
  8934. if (!$license) {
  8935. return $licenseId;
  8936. }
  8937. return [
  8938. 'name' => $license[0],
  8939. 'osi' => $licenseId,
  8940. 'url' => $license[2],
  8941. ];
  8942. }, $licenses);
  8943. }
  8944. return $json;
  8945. }
  8946. private function appendAutoload(array $json, CompletePackageInterface $package): array
  8947. {
  8948. if (\count($package->getAutoload()) > 0) {
  8949. $autoload = [];
  8950. foreach ($package->getAutoload() as $type => $autoloads) {
  8951. if ($type === 'psr-0' || $type === 'psr-4') {
  8952. $psr = [];
  8953. foreach ($autoloads as $name => $path) {
  8954. if (!$path) {
  8955. $path = '.';
  8956. }
  8957. $psr[$name ?: '*'] = $path;
  8958. }
  8959. $autoload[$type] = $psr;
  8960. } elseif ($type === 'classmap') {
  8961. $autoload['classmap'] = $autoloads;
  8962. }
  8963. }
  8964. $json['autoload'] = $autoload;
  8965. }
  8966. return $json;
  8967. }
  8968. private function appendLinks(array $json, CompletePackageInterface $package): array
  8969. {
  8970. foreach (Link::$TYPES as $linkType) {
  8971. $json = $this->appendLink($json, $package, $linkType);
  8972. }
  8973. return $json;
  8974. }
  8975. private function appendLink(array $json, CompletePackageInterface $package, string $linkType): array
  8976. {
  8977. $links = $package->{'get' . ucfirst($linkType)}();
  8978. if ($links) {
  8979. $json[$linkType] = [];
  8980. foreach ($links as $link) {
  8981. $json[$linkType][$link->getTarget()] = $link->getPrettyConstraint();
  8982. }
  8983. }
  8984. return $json;
  8985. }
  8986. protected function initStyles(OutputInterface $output): void
  8987. {
  8988. $this->colors = [
  8989. 'green',
  8990. 'yellow',
  8991. 'cyan',
  8992. 'magenta',
  8993. 'blue',
  8994. ];
  8995. foreach ($this->colors as $color) {
  8996. $style = new OutputFormatterStyle($color);
  8997. $output->getFormatter()->setStyle($color, $style);
  8998. }
  8999. }
  9000. protected function displayPackageTree(array $arrayTree): void
  9001. {
  9002. $io = $this->getIO();
  9003. foreach ($arrayTree as $package) {
  9004. $io->write(sprintf('<info>%s</info>', $package['name']), false);
  9005. $io->write(' ' . $package['version'], false);
  9006. if (isset($package['description'])) {
  9007. $io->write(' ' . strtok($package['description'], "\r\n"));
  9008. } else {
  9009. $io->write('');
  9010. }
  9011. if (isset($package['requires'])) {
  9012. $requires = $package['requires'];
  9013. $treeBar = '├';
  9014. $j = 0;
  9015. $total = count($requires);
  9016. foreach ($requires as $require) {
  9017. $requireName = $require['name'];
  9018. $j++;
  9019. if ($j === $total) {
  9020. $treeBar = 'â””';
  9021. }
  9022. $level = 1;
  9023. $color = $this->colors[$level];
  9024. $info = sprintf(
  9025. '%s──<%s>%s</%s> %s',
  9026. $treeBar,
  9027. $color,
  9028. $requireName,
  9029. $color,
  9030. $require['version']
  9031. );
  9032. $this->writeTreeLine($info);
  9033. $treeBar = str_replace('â””', ' ', $treeBar);
  9034. $packagesInTree = [$package['name'], $requireName];
  9035. $this->displayTree($require, $packagesInTree, $treeBar, $level + 1);
  9036. }
  9037. }
  9038. }
  9039. }
  9040. protected function generatePackageTree(
  9041. PackageInterface $package,
  9042. InstalledRepository $installedRepo,
  9043. RepositoryInterface $remoteRepos
  9044. ): array {
  9045. $requires = $package->getRequires();
  9046. ksort($requires);
  9047. $children = [];
  9048. foreach ($requires as $requireName => $require) {
  9049. $packagesInTree = [$package->getName(), $requireName];
  9050. $treeChildDesc = [
  9051. 'name' => $requireName,
  9052. 'version' => $require->getPrettyConstraint(),
  9053. ];
  9054. $deepChildren = $this->addTree($requireName, $require, $installedRepo, $remoteRepos, $packagesInTree);
  9055. if ($deepChildren) {
  9056. $treeChildDesc['requires'] = $deepChildren;
  9057. }
  9058. $children[] = $treeChildDesc;
  9059. }
  9060. $tree = [
  9061. 'name' => $package->getPrettyName(),
  9062. 'version' => $package->getPrettyVersion(),
  9063. 'description' => $package instanceof CompletePackageInterface ? $package->getDescription() : '',
  9064. ];
  9065. if ($children) {
  9066. $tree['requires'] = $children;
  9067. }
  9068. return $tree;
  9069. }
  9070. protected function displayTree(
  9071. $package,
  9072. array $packagesInTree,
  9073. string $previousTreeBar = '├',
  9074. int $level = 1
  9075. ): void {
  9076. $previousTreeBar = str_replace('├', '│', $previousTreeBar);
  9077. if (is_array($package) && isset($package['requires'])) {
  9078. $requires = $package['requires'];
  9079. $treeBar = $previousTreeBar . ' ├';
  9080. $i = 0;
  9081. $total = count($requires);
  9082. foreach ($requires as $require) {
  9083. $currentTree = $packagesInTree;
  9084. $i++;
  9085. if ($i === $total) {
  9086. $treeBar = $previousTreeBar . ' â””';
  9087. }
  9088. $colorIdent = $level % count($this->colors);
  9089. $color = $this->colors[$colorIdent];
  9090. assert(is_string($require['name']));
  9091. assert(is_string($require['version']));
  9092. $circularWarn = in_array(
  9093. $require['name'],
  9094. $currentTree,
  9095. true
  9096. ) ? '(circular dependency aborted here)' : '';
  9097. $info = rtrim(sprintf(
  9098. '%s──<%s>%s</%s> %s %s',
  9099. $treeBar,
  9100. $color,
  9101. $require['name'],
  9102. $color,
  9103. $require['version'],
  9104. $circularWarn
  9105. ));
  9106. $this->writeTreeLine($info);
  9107. $treeBar = str_replace('â””', ' ', $treeBar);
  9108. $currentTree[] = $require['name'];
  9109. $this->displayTree($require, $currentTree, $treeBar, $level + 1);
  9110. }
  9111. }
  9112. }
  9113. protected function addTree(
  9114. string $name,
  9115. Link $link,
  9116. InstalledRepository $installedRepo,
  9117. RepositoryInterface $remoteRepos,
  9118. array $packagesInTree
  9119. ): array {
  9120. $children = [];
  9121. [$package] = $this->getPackage(
  9122. $installedRepo,
  9123. $remoteRepos,
  9124. $name,
  9125. $link->getPrettyConstraint() === 'self.version' ? $link->getConstraint() : $link->getPrettyConstraint()
  9126. );
  9127. if (is_object($package)) {
  9128. $requires = $package->getRequires();
  9129. ksort($requires);
  9130. foreach ($requires as $requireName => $require) {
  9131. $currentTree = $packagesInTree;
  9132. $treeChildDesc = [
  9133. 'name' => $requireName,
  9134. 'version' => $require->getPrettyConstraint(),
  9135. ];
  9136. if (!in_array($requireName, $currentTree, true)) {
  9137. $currentTree[] = $requireName;
  9138. $deepChildren = $this->addTree($requireName, $require, $installedRepo, $remoteRepos, $currentTree);
  9139. if ($deepChildren) {
  9140. $treeChildDesc['requires'] = $deepChildren;
  9141. }
  9142. }
  9143. $children[] = $treeChildDesc;
  9144. }
  9145. }
  9146. return $children;
  9147. }
  9148. private function updateStatusToVersionStyle(string $updateStatus): string
  9149. {
  9150. return str_replace(['up-to-date', 'semver-safe-update', 'update-possible'], ['info', 'highlight', 'comment'], $updateStatus);
  9151. }
  9152. private function getUpdateStatus(PackageInterface $latestPackage, PackageInterface $package): string
  9153. {
  9154. if ($latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion()) {
  9155. return 'up-to-date';
  9156. }
  9157. $constraint = $package->getVersion();
  9158. if (0 !== strpos($constraint, 'dev-')) {
  9159. $constraint = '^'.$constraint;
  9160. }
  9161. if ($latestPackage->getVersion() && Semver::satisfies($latestPackage->getVersion(), $constraint)) {
  9162. return 'semver-safe-update';
  9163. }
  9164. return 'update-possible';
  9165. }
  9166. private function writeTreeLine(string $line): void
  9167. {
  9168. $io = $this->getIO();
  9169. if (!$io->isDecorated()) {
  9170. $line = str_replace(['└', '├', '──', '│'], ['`-', '|-', '-', '|'], $line);
  9171. }
  9172. $io->write($line);
  9173. }
  9174. private function findLatestPackage(PackageInterface $package, Composer $composer, PlatformRepository $platformRepo, bool $majorOnly, bool $minorOnly, bool $patchOnly, PlatformRequirementFilterInterface $platformReqFilter): ?PackageInterface
  9175. {
  9176. $name = $package->getName();
  9177. $versionSelector = new VersionSelector($this->getRepositorySet($composer), $platformRepo);
  9178. $stability = $composer->getPackage()->getMinimumStability();
  9179. $flags = $composer->getPackage()->getStabilityFlags();
  9180. if (isset($flags[$name])) {
  9181. $stability = array_search($flags[$name], BasePackage::$stabilities, true);
  9182. }
  9183. $bestStability = $stability;
  9184. if ($composer->getPackage()->getPreferStable()) {
  9185. $bestStability = $package->getStability();
  9186. }
  9187. $targetVersion = null;
  9188. if (0 === strpos($package->getVersion(), 'dev-')) {
  9189. $targetVersion = $package->getVersion();
  9190. if ($majorOnly) {
  9191. return null;
  9192. }
  9193. }
  9194. if ($targetVersion === null) {
  9195. if ($majorOnly && Preg::isMatch('{^(?P<zero_major>(?:0\.)+)?(?P<first_meaningful>\d+)\.}', $package->getVersion(), $match)) {
  9196. $targetVersion = '>='.$match['zero_major'].(((int) $match['first_meaningful']) + 1).',<9999999-dev';
  9197. }
  9198. if ($minorOnly) {
  9199. $targetVersion = '^'.$package->getVersion();
  9200. }
  9201. if ($patchOnly) {
  9202. $trimmedVersion = Preg::replace('{(\.0)+$}D', '', $package->getVersion());
  9203. $partsNeeded = substr($trimmedVersion, 0, 1) === '0' ? 4 : 3;
  9204. while (substr_count($trimmedVersion, '.') + 1 < $partsNeeded) {
  9205. $trimmedVersion .= '.0';
  9206. }
  9207. $targetVersion = '~'.$trimmedVersion;
  9208. }
  9209. }
  9210. if ($this->getIO()->isVerbose()) {
  9211. $showWarnings = true;
  9212. } else {
  9213. $showWarnings = static function (PackageInterface $candidate) use ($package): bool {
  9214. if (str_starts_with($candidate->getVersion(), 'dev-') || str_starts_with($package->getVersion(), 'dev-')) {
  9215. return false;
  9216. }
  9217. return version_compare($candidate->getVersion(), $package->getVersion(), '<=');
  9218. };
  9219. }
  9220. $candidate = $versionSelector->findBestCandidate($name, $targetVersion, $bestStability, $platformReqFilter, 0, $this->getIO(), $showWarnings);
  9221. while ($candidate instanceof AliasPackage) {
  9222. $candidate = $candidate->getAliasOf();
  9223. }
  9224. return $candidate !== false ? $candidate : null;
  9225. }
  9226. private function getRepositorySet(Composer $composer): RepositorySet
  9227. {
  9228. if (!$this->repositorySet) {
  9229. $this->repositorySet = new RepositorySet($composer->getPackage()->getMinimumStability(), $composer->getPackage()->getStabilityFlags());
  9230. $this->repositorySet->addRepository(new CompositeRepository($composer->getRepositoryManager()->getRepositories()));
  9231. }
  9232. return $this->repositorySet;
  9233. }
  9234. }
  9235. <?php declare(strict_types=1);
  9236. namespace Composer\Command;
  9237. use Symfony\Component\Console\Input\InputInterface;
  9238. use Composer\Console\Input\InputOption;
  9239. use Symfony\Component\Console\Output\OutputInterface;
  9240. use Composer\Downloader\ChangeReportInterface;
  9241. use Composer\Downloader\DvcsDownloaderInterface;
  9242. use Composer\Downloader\VcsCapableDownloaderInterface;
  9243. use Composer\Package\Dumper\ArrayDumper;
  9244. use Composer\Package\Version\VersionGuesser;
  9245. use Composer\Package\Version\VersionParser;
  9246. use Composer\Plugin\CommandEvent;
  9247. use Composer\Plugin\PluginEvents;
  9248. use Composer\Script\ScriptEvents;
  9249. use Composer\Util\ProcessExecutor;
  9250. class StatusCommand extends BaseCommand
  9251. {
  9252. private const EXIT_CODE_ERRORS = 1;
  9253. private const EXIT_CODE_UNPUSHED_CHANGES = 2;
  9254. private const EXIT_CODE_VERSION_CHANGES = 4;
  9255. protected function configure(): void
  9256. {
  9257. $this
  9258. ->setName('status')
  9259. ->setDescription('Shows a list of locally modified packages')
  9260. ->setDefinition([
  9261. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Show modified files for each directory that contains changes.'),
  9262. ])
  9263. ->setHelp(
  9264. <<<EOT
  9265. The status command displays a list of dependencies that have
  9266. been modified locally.
  9267. Read more at https://getcomposer.org/doc/03-cli.md#status
  9268. EOT
  9269. )
  9270. ;
  9271. }
  9272. protected function execute(InputInterface $input, OutputInterface $output): int
  9273. {
  9274. $composer = $this->requireComposer();
  9275. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'status', $input, $output);
  9276. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  9277. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::PRE_STATUS_CMD, true);
  9278. $exitCode = $this->doExecute($input);
  9279. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_STATUS_CMD, true);
  9280. return $exitCode;
  9281. }
  9282. private function doExecute(InputInterface $input): int
  9283. {
  9284. $composer = $this->requireComposer();
  9285. $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
  9286. $dm = $composer->getDownloadManager();
  9287. $im = $composer->getInstallationManager();
  9288. $errors = [];
  9289. $io = $this->getIO();
  9290. $unpushedChanges = [];
  9291. $vcsVersionChanges = [];
  9292. $parser = new VersionParser;
  9293. $guesser = new VersionGuesser($composer->getConfig(), $composer->getLoop()->getProcessExecutor() ?? new ProcessExecutor($io), $parser);
  9294. $dumper = new ArrayDumper;
  9295. foreach ($installedRepo->getCanonicalPackages() as $package) {
  9296. $downloader = $dm->getDownloaderForPackage($package);
  9297. $targetDir = $im->getInstallPath($package);
  9298. if ($targetDir === null) {
  9299. continue;
  9300. }
  9301. if ($downloader instanceof ChangeReportInterface) {
  9302. if (is_link($targetDir)) {
  9303. $errors[$targetDir] = $targetDir . ' is a symbolic link.';
  9304. }
  9305. if (null !== ($changes = $downloader->getLocalChanges($package, $targetDir))) {
  9306. $errors[$targetDir] = $changes;
  9307. }
  9308. }
  9309. if ($downloader instanceof VcsCapableDownloaderInterface) {
  9310. if ($downloader->getVcsReference($package, $targetDir)) {
  9311. switch ($package->getInstallationSource()) {
  9312. case 'source':
  9313. $previousRef = $package->getSourceReference();
  9314. break;
  9315. case 'dist':
  9316. $previousRef = $package->getDistReference();
  9317. break;
  9318. default:
  9319. $previousRef = null;
  9320. }
  9321. $currentVersion = $guesser->guessVersion($dumper->dump($package), $targetDir);
  9322. if ($previousRef && $currentVersion && $currentVersion['commit'] !== $previousRef && $currentVersion['pretty_version'] !== $previousRef) {
  9323. $vcsVersionChanges[$targetDir] = [
  9324. 'previous' => [
  9325. 'version' => $package->getPrettyVersion(),
  9326. 'ref' => $previousRef,
  9327. ],
  9328. 'current' => [
  9329. 'version' => $currentVersion['pretty_version'],
  9330. 'ref' => $currentVersion['commit'],
  9331. ],
  9332. ];
  9333. }
  9334. }
  9335. }
  9336. if ($downloader instanceof DvcsDownloaderInterface) {
  9337. if ($unpushed = $downloader->getUnpushedChanges($package, $targetDir)) {
  9338. $unpushedChanges[$targetDir] = $unpushed;
  9339. }
  9340. }
  9341. }
  9342. if (!$errors && !$unpushedChanges && !$vcsVersionChanges) {
  9343. $io->writeError('<info>No local changes</info>');
  9344. return 0;
  9345. }
  9346. if ($errors) {
  9347. $io->writeError('<error>You have changes in the following dependencies:</error>');
  9348. foreach ($errors as $path => $changes) {
  9349. if ($input->getOption('verbose')) {
  9350. $indentedChanges = implode("\n", array_map(static function ($line): string {
  9351. return ' ' . ltrim($line);
  9352. }, explode("\n", $changes)));
  9353. $io->write('<info>'.$path.'</info>:');
  9354. $io->write($indentedChanges);
  9355. } else {
  9356. $io->write($path);
  9357. }
  9358. }
  9359. }
  9360. if ($unpushedChanges) {
  9361. $io->writeError('<warning>You have unpushed changes on the current branch in the following dependencies:</warning>');
  9362. foreach ($unpushedChanges as $path => $changes) {
  9363. if ($input->getOption('verbose')) {
  9364. $indentedChanges = implode("\n", array_map(static function ($line): string {
  9365. return ' ' . ltrim($line);
  9366. }, explode("\n", $changes)));
  9367. $io->write('<info>'.$path.'</info>:');
  9368. $io->write($indentedChanges);
  9369. } else {
  9370. $io->write($path);
  9371. }
  9372. }
  9373. }
  9374. if ($vcsVersionChanges) {
  9375. $io->writeError('<warning>You have version variations in the following dependencies:</warning>');
  9376. foreach ($vcsVersionChanges as $path => $changes) {
  9377. if ($input->getOption('verbose')) {
  9378. $currentVersion = $changes['current']['version'] ?: $changes['current']['ref'];
  9379. $previousVersion = $changes['previous']['version'] ?: $changes['previous']['ref'];
  9380. if ($io->isVeryVerbose()) {
  9381. $currentVersion .= sprintf(' (%s)', $changes['current']['ref']);
  9382. $previousVersion .= sprintf(' (%s)', $changes['previous']['ref']);
  9383. }
  9384. $io->write('<info>'.$path.'</info>:');
  9385. $io->write(sprintf(' From <comment>%s</comment> to <comment>%s</comment>', $previousVersion, $currentVersion));
  9386. } else {
  9387. $io->write($path);
  9388. }
  9389. }
  9390. }
  9391. if (($errors || $unpushedChanges || $vcsVersionChanges) && !$input->getOption('verbose')) {
  9392. $io->writeError('Use --verbose (-v) to see a list of files');
  9393. }
  9394. return ($errors ? self::EXIT_CODE_ERRORS : 0) + ($unpushedChanges ? self::EXIT_CODE_UNPUSHED_CHANGES : 0) + ($vcsVersionChanges ? self::EXIT_CODE_VERSION_CHANGES : 0);
  9395. }
  9396. }
  9397. <?php declare(strict_types=1);
  9398. namespace Composer\Command;
  9399. use Composer\Repository\PlatformRepository;
  9400. use Composer\Repository\RootPackageRepository;
  9401. use Composer\Repository\InstalledRepository;
  9402. use Composer\Installer\SuggestedPackagesReporter;
  9403. use Composer\Console\Input\InputArgument;
  9404. use Symfony\Component\Console\Input\InputInterface;
  9405. use Composer\Console\Input\InputOption;
  9406. use Symfony\Component\Console\Output\OutputInterface;
  9407. class SuggestsCommand extends BaseCommand
  9408. {
  9409. use CompletionTrait;
  9410. protected function configure(): void
  9411. {
  9412. $this
  9413. ->setName('suggests')
  9414. ->setDescription('Shows package suggestions')
  9415. ->setDefinition([
  9416. new InputOption('by-package', null, InputOption::VALUE_NONE, 'Groups output by suggesting package (default)'),
  9417. new InputOption('by-suggestion', null, InputOption::VALUE_NONE, 'Groups output by suggested package'),
  9418. new InputOption('all', 'a', InputOption::VALUE_NONE, 'Show suggestions from all dependencies, including transitive ones'),
  9419. new InputOption('list', null, InputOption::VALUE_NONE, 'Show only list of suggested package names'),
  9420. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Exclude suggestions from require-dev packages'),
  9421. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that you want to list suggestions from.', null, $this->suggestInstalledPackage()),
  9422. ])
  9423. ->setHelp(
  9424. <<<EOT
  9425. The <info>%command.name%</info> command shows a sorted list of suggested packages.
  9426. Read more at https://getcomposer.org/doc/03-cli.md#suggests
  9427. EOT
  9428. )
  9429. ;
  9430. }
  9431. protected function execute(InputInterface $input, OutputInterface $output): int
  9432. {
  9433. $composer = $this->requireComposer();
  9434. $installedRepos = [
  9435. new RootPackageRepository(clone $composer->getPackage()),
  9436. ];
  9437. $locker = $composer->getLocker();
  9438. if ($locker->isLocked()) {
  9439. $installedRepos[] = new PlatformRepository([], $locker->getPlatformOverrides());
  9440. $installedRepos[] = $locker->getLockedRepository(!$input->getOption('no-dev'));
  9441. } else {
  9442. $installedRepos[] = new PlatformRepository([], $composer->getConfig()->get('platform'));
  9443. $installedRepos[] = $composer->getRepositoryManager()->getLocalRepository();
  9444. }
  9445. $installedRepo = new InstalledRepository($installedRepos);
  9446. $reporter = new SuggestedPackagesReporter($this->getIO());
  9447. $filter = $input->getArgument('packages');
  9448. $packages = $installedRepo->getPackages();
  9449. $packages[] = $composer->getPackage();
  9450. foreach ($packages as $package) {
  9451. if (!empty($filter) && !in_array($package->getName(), $filter)) {
  9452. continue;
  9453. }
  9454. $reporter->addSuggestionsFromPackage($package);
  9455. }
  9456. $mode = SuggestedPackagesReporter::MODE_BY_PACKAGE;
  9457. if ($input->getOption('by-suggestion')) {
  9458. $mode = SuggestedPackagesReporter::MODE_BY_SUGGESTION;
  9459. }
  9460. if ($input->getOption('by-package')) {
  9461. $mode |= SuggestedPackagesReporter::MODE_BY_PACKAGE;
  9462. }
  9463. if ($input->getOption('list')) {
  9464. $mode = SuggestedPackagesReporter::MODE_LIST;
  9465. }
  9466. $reporter->output($mode, $installedRepo, empty($filter) && !$input->getOption('all') ? $composer->getPackage() : null);
  9467. return 0;
  9468. }
  9469. }
  9470. <?php declare(strict_types=1);
  9471. namespace Composer\Command;
  9472. use Composer\Composer;
  9473. use Composer\DependencyResolver\Request;
  9474. use Composer\Installer;
  9475. use Composer\IO\IOInterface;
  9476. use Composer\Package\Loader\RootPackageLoader;
  9477. use Composer\Pcre\Preg;
  9478. use Composer\Plugin\CommandEvent;
  9479. use Composer\Plugin\PluginEvents;
  9480. use Composer\Package\Version\VersionParser;
  9481. use Composer\Semver\Intervals;
  9482. use Composer\Util\HttpDownloader;
  9483. use Composer\Advisory\Auditor;
  9484. use Symfony\Component\Console\Helper\Table;
  9485. use Symfony\Component\Console\Input\InputInterface;
  9486. use Composer\Console\Input\InputOption;
  9487. use Composer\Console\Input\InputArgument;
  9488. use Symfony\Component\Console\Output\OutputInterface;
  9489. use Symfony\Component\Console\Question\Question;
  9490. class UpdateCommand extends BaseCommand
  9491. {
  9492. use CompletionTrait;
  9493. protected function configure()
  9494. {
  9495. $this
  9496. ->setName('update')
  9497. ->setAliases(['u', 'upgrade'])
  9498. ->setDescription('Updates your dependencies to the latest version according to composer.json, and updates the composer.lock file')
  9499. ->setDefinition([
  9500. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that should be updated, if not provided all packages are.', null, $this->suggestInstalledPackage(false)),
  9501. 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'),
  9502. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  9503. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
  9504. 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).', null, $this->suggestPreferInstall()),
  9505. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  9506. new InputOption('dev', null, InputOption::VALUE_NONE, 'DEPRECATED: Enables installation of require-dev packages (enabled by default, only present for BC).'),
  9507. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  9508. 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.'),
  9509. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  9510. new InputOption('no-audit', null, InputOption::VALUE_NONE, 'Skip the audit step after updating the composer.lock file (can also be set via the COMPOSER_NO_AUDIT=1 env var).'),
  9511. new InputOption('audit-format', null, InputOption::VALUE_REQUIRED, 'Audit output format. Must be "table", "plain", "json", or "summary".', Auditor::FORMAT_SUMMARY, Auditor::FORMATS),
  9512. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  9513. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  9514. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  9515. new InputOption('with-dependencies', 'w', InputOption::VALUE_NONE, 'Update also dependencies of packages in the argument list, except those which are root requirements.'),
  9516. new InputOption('with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Update also dependencies of packages in the argument list, including those which are root requirements.'),
  9517. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
  9518. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump.'),
  9519. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  9520. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  9521. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  9522. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  9523. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  9524. new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies (can also be set via the COMPOSER_PREFER_STABLE=1 env var).'),
  9525. new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies (can also be set via the COMPOSER_PREFER_LOWEST=1 env var).'),
  9526. new InputOption('interactive', 'i', InputOption::VALUE_NONE, 'Interactive interface with autocompletion to select the packages to update.'),
  9527. new InputOption('root-reqs', null, InputOption::VALUE_NONE, 'Restricts the update to your first degree dependencies.'),
  9528. ])
  9529. ->setHelp(
  9530. <<<EOT
  9531. The <info>update</info> command reads the composer.json file from the
  9532. current directory, processes it, and updates, removes or installs all the
  9533. dependencies.
  9534. <info>php composer.phar update</info>
  9535. To limit the update operation to a few packages, you can list the package(s)
  9536. you want to update as such:
  9537. <info>php composer.phar update vendor/package1 foo/mypackage [...]</info>
  9538. You may also use an asterisk (*) pattern to limit the update operation to package(s)
  9539. from a specific vendor:
  9540. <info>php composer.phar update vendor/package1 foo/* [...]</info>
  9541. To run an update with more restrictive constraints you can use:
  9542. <info>php composer.phar update --with vendor/package:1.0.*</info>
  9543. To run a partial update with more restrictive constraints you can use the shorthand:
  9544. <info>php composer.phar update vendor/package:1.0.*</info>
  9545. To select packages names interactively with auto-completion use <info>-i</info>.
  9546. Read more at https://getcomposer.org/doc/03-cli.md#update-u-upgrade
  9547. EOT
  9548. )
  9549. ;
  9550. }
  9551. protected function execute(InputInterface $input, OutputInterface $output)
  9552. {
  9553. $io = $this->getIO();
  9554. if ($input->getOption('dev')) {
  9555. $io->writeError('<warning>You are using the deprecated option "--dev". It has no effect and will break in Composer 3.</warning>');
  9556. }
  9557. if ($input->getOption('no-suggest')) {
  9558. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  9559. }
  9560. $composer = $this->requireComposer();
  9561. if (!HttpDownloader::isCurlEnabled()) {
  9562. $io->writeError('<warning>Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.</warning>');
  9563. }
  9564. $packages = $input->getArgument('packages');
  9565. $reqs = $this->formatRequirements($input->getOption('with'));
  9566. if (count($packages) > 0) {
  9567. $allowlistPackagesWithRequirements = array_filter($packages, static function ($pkg): bool {
  9568. return Preg::isMatch('{\S+[ =:]\S+}', $pkg);
  9569. });
  9570. foreach ($this->formatRequirements($allowlistPackagesWithRequirements) as $package => $constraint) {
  9571. $reqs[$package] = $constraint;
  9572. }
  9573. foreach ($allowlistPackagesWithRequirements as $package) {
  9574. $packageName = Preg::replace('{^([^ =:]+)[ =:].*$}', '$1', $package);
  9575. $index = array_search($package, $packages);
  9576. $packages[$index] = $packageName;
  9577. }
  9578. }
  9579. $rootPackage = $composer->getPackage();
  9580. $rootPackage->setReferences(RootPackageLoader::extractReferences($reqs, $rootPackage->getReferences()));
  9581. $rootPackage->setStabilityFlags(RootPackageLoader::extractStabilityFlags($reqs, $rootPackage->getMinimumStability(), $rootPackage->getStabilityFlags()));
  9582. $parser = new VersionParser;
  9583. $temporaryConstraints = [];
  9584. $rootRequirements = array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires());
  9585. foreach ($reqs as $package => $constraint) {
  9586. $package = strtolower($package);
  9587. $parsedConstraint = $parser->parseConstraints($constraint);
  9588. $temporaryConstraints[$package] = $parsedConstraint;
  9589. if (isset($rootRequirements[$package]) && !Intervals::haveIntersections($parsedConstraint, $rootRequirements[$package]->getConstraint())) {
  9590. $io->writeError('<error>The temporary constraint "'.$constraint.'" for "'.$package.'" must be a subset of the constraint in your composer.json ('.$rootRequirements[$package]->getPrettyConstraint().')</error>');
  9591. $io->write('<info>Run `composer require '.$package.'` or `composer require '.$package.':'.$constraint.'` instead to replace the constraint</info>');
  9592. return self::FAILURE;
  9593. }
  9594. }
  9595. if ($input->getOption('interactive')) {
  9596. $packages = $this->getPackagesInteractively($io, $input, $output, $composer, $packages);
  9597. }
  9598. if ($input->getOption('root-reqs')) {
  9599. $requires = array_keys($rootPackage->getRequires());
  9600. if (!$input->getOption('no-dev')) {
  9601. $requires = array_merge($requires, array_keys($rootPackage->getDevRequires()));
  9602. }
  9603. if (!empty($packages)) {
  9604. $packages = array_intersect($packages, $requires);
  9605. } else {
  9606. $packages = $requires;
  9607. }
  9608. }
  9609. $filteredPackages = array_filter($packages, static function ($package): bool {
  9610. return !in_array($package, ['lock', 'nothing', 'mirrors'], true);
  9611. });
  9612. $updateMirrors = $input->getOption('lock') || count($filteredPackages) !== count($packages);
  9613. $packages = $filteredPackages;
  9614. if ($updateMirrors && !empty($packages)) {
  9615. $io->writeError('<error>You cannot simultaneously update only a selection of packages and regenerate the lock file metadata.</error>');
  9616. return -1;
  9617. }
  9618. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'update', $input, $output);
  9619. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  9620. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  9621. $install = Installer::create($io, $composer);
  9622. $config = $composer->getConfig();
  9623. [$preferSource, $preferDist] = $this->getPreferredInstallOptions($config, $input);
  9624. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  9625. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  9626. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  9627. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  9628. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  9629. if ($input->getOption('with-all-dependencies')) {
  9630. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  9631. } elseif ($input->getOption('with-dependencies')) {
  9632. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  9633. }
  9634. $install
  9635. ->setDryRun($input->getOption('dry-run'))
  9636. ->setVerbose($input->getOption('verbose'))
  9637. ->setPreferSource($preferSource)
  9638. ->setPreferDist($preferDist)
  9639. ->setDevMode(!$input->getOption('no-dev'))
  9640. ->setDumpAutoloader(!$input->getOption('no-autoloader'))
  9641. ->setOptimizeAutoloader($optimize)
  9642. ->setClassMapAuthoritative($authoritative)
  9643. ->setApcuAutoloader($apcu, $apcuPrefix)
  9644. ->setUpdate(true)
  9645. ->setInstall(!$input->getOption('no-install'))
  9646. ->setUpdateMirrors($updateMirrors)
  9647. ->setUpdateAllowList($packages)
  9648. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  9649. ->setPlatformRequirementFilter($this->getPlatformRequirementFilter($input))
  9650. ->setPreferStable($input->getOption('prefer-stable'))
  9651. ->setPreferLowest($input->getOption('prefer-lowest'))
  9652. ->setTemporaryConstraints($temporaryConstraints)
  9653. ->setAudit(!$input->getOption('no-audit'))
  9654. ->setAuditFormat($this->getAuditFormat($input))
  9655. ;
  9656. if ($input->getOption('no-plugins')) {
  9657. $install->disablePlugins();
  9658. }
  9659. return $install->run();
  9660. }
  9661. private function getPackagesInteractively(IOInterface $io, InputInterface $input, OutputInterface $output, Composer $composer, array $packages): array
  9662. {
  9663. if (!$input->isInteractive()) {
  9664. throw new \InvalidArgumentException('--interactive cannot be used in non-interactive terminals.');
  9665. }
  9666. $requires = array_merge(
  9667. $composer->getPackage()->getRequires(),
  9668. $composer->getPackage()->getDevRequires()
  9669. );
  9670. $autocompleterValues = [];
  9671. foreach ($requires as $require) {
  9672. $target = $require->getTarget();
  9673. $autocompleterValues[strtolower($target)] = $target;
  9674. }
  9675. $installedPackages = $composer->getRepositoryManager()->getLocalRepository()->getPackages();
  9676. foreach ($installedPackages as $package) {
  9677. $autocompleterValues[$package->getName()] = $package->getPrettyName();
  9678. }
  9679. $helper = $this->getHelper('question');
  9680. $question = new Question('<comment>Enter package name: </comment>', null);
  9681. $io->writeError('<info>Press enter without value to end submission</info>');
  9682. do {
  9683. $autocompleterValues = array_diff($autocompleterValues, $packages);
  9684. $question->setAutocompleterValues($autocompleterValues);
  9685. $addedPackage = $helper->ask($input, $output, $question);
  9686. if (!is_string($addedPackage) || empty($addedPackage)) {
  9687. break;
  9688. }
  9689. $addedPackage = strtolower($addedPackage);
  9690. if (!in_array($addedPackage, $packages)) {
  9691. $packages[] = $addedPackage;
  9692. }
  9693. } while (true);
  9694. $packages = array_filter($packages);
  9695. if (!$packages) {
  9696. throw new \InvalidArgumentException('You must enter minimum one package.');
  9697. }
  9698. $table = new Table($output);
  9699. $table->setHeaders(['Selected packages']);
  9700. foreach ($packages as $package) {
  9701. $table->addRow([$package]);
  9702. }
  9703. $table->render();
  9704. if ($io->askConfirmation(sprintf(
  9705. 'Would you like to continue and update the above package%s [<comment>yes</comment>]? ',
  9706. 1 === count($packages) ? '' : 's'
  9707. ))) {
  9708. return $packages;
  9709. }
  9710. throw new \RuntimeException('Installation aborted.');
  9711. }
  9712. }
  9713. <?php declare(strict_types=1);
  9714. namespace Composer\Command;
  9715. use Composer\Factory;
  9716. use Composer\IO\IOInterface;
  9717. use Composer\Package\Loader\ValidatingArrayLoader;
  9718. use Composer\Plugin\CommandEvent;
  9719. use Composer\Plugin\PluginEvents;
  9720. use Composer\Repository\InstalledRepository;
  9721. use Composer\Repository\PlatformRepository;
  9722. use Composer\Util\ConfigValidator;
  9723. use Composer\Util\Filesystem;
  9724. use Symfony\Component\Console\Input\InputArgument;
  9725. use Symfony\Component\Console\Input\InputInterface;
  9726. use Symfony\Component\Console\Input\InputOption;
  9727. use Symfony\Component\Console\Output\OutputInterface;
  9728. class ValidateCommand extends BaseCommand
  9729. {
  9730. protected function configure(): void
  9731. {
  9732. $this
  9733. ->setName('validate')
  9734. ->setDescription('Validates a composer.json and composer.lock')
  9735. ->setDefinition([
  9736. new InputOption('no-check-all', null, InputOption::VALUE_NONE, 'Do not validate requires for overly strict/loose constraints'),
  9737. new InputOption('check-lock', null, InputOption::VALUE_NONE, 'Check if lock file is up to date (even when config.lock is false)'),
  9738. new InputOption('no-check-lock', null, InputOption::VALUE_NONE, 'Do not check if lock file is up to date'),
  9739. new InputOption('no-check-publish', null, InputOption::VALUE_NONE, 'Do not check for publish errors'),
  9740. new InputOption('no-check-version', null, InputOption::VALUE_NONE, 'Do not report a warning if the version field is present'),
  9741. new InputOption('with-dependencies', 'A', InputOption::VALUE_NONE, 'Also validate the composer.json of all installed dependencies'),
  9742. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code for warnings as well as errors'),
  9743. new InputArgument('file', InputArgument::OPTIONAL, 'path to composer.json file'),
  9744. ])
  9745. ->setHelp(
  9746. <<<EOT
  9747. The validate command validates a given composer.json and composer.lock
  9748. Exit codes in case of errors are:
  9749. 1 validation warning(s), only when --strict is given
  9750. 2 validation error(s)
  9751. 3 file unreadable or missing
  9752. Read more at https://getcomposer.org/doc/03-cli.md#validate
  9753. EOT
  9754. );
  9755. }
  9756. protected function execute(InputInterface $input, OutputInterface $output): int
  9757. {
  9758. $file = $input->getArgument('file') ?: Factory::getComposerFile();
  9759. $io = $this->getIO();
  9760. if (!file_exists($file)) {
  9761. $io->writeError('<error>' . $file . ' not found.</error>');
  9762. return 3;
  9763. }
  9764. if (!Filesystem::isReadable($file)) {
  9765. $io->writeError('<error>' . $file . ' is not readable.</error>');
  9766. return 3;
  9767. }
  9768. $validator = new ConfigValidator($io);
  9769. $checkAll = $input->getOption('no-check-all') ? 0 : ValidatingArrayLoader::CHECK_ALL;
  9770. $checkPublish = !$input->getOption('no-check-publish');
  9771. $checkLock = !$input->getOption('no-check-lock');
  9772. $checkVersion = $input->getOption('no-check-version') ? 0 : ConfigValidator::CHECK_VERSION;
  9773. $isStrict = $input->getOption('strict');
  9774. [$errors, $publishErrors, $warnings] = $validator->validate($file, $checkAll, $checkVersion);
  9775. $lockErrors = [];
  9776. $composer = Factory::create($io, $file, $input->hasParameterOption('--no-plugins'));
  9777. $checkLock = ($checkLock && $composer->getConfig()->get('lock')) || $input->getOption('check-lock');
  9778. $locker = $composer->getLocker();
  9779. if ($locker->isLocked() && !$locker->isFresh()) {
  9780. $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>`.';
  9781. }
  9782. if ($locker->isLocked()) {
  9783. $lockErrors = array_merge($lockErrors, $locker->getMissingRequirementInfo($composer->getPackage(), true));
  9784. }
  9785. $this->outputResult($io, $file, $errors, $warnings, $checkPublish, $publishErrors, $checkLock, $lockErrors, true);
  9786. $exitCode = $errors ? 2 : ($isStrict && $warnings ? 1 : 0);
  9787. if ($input->getOption('with-dependencies')) {
  9788. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  9789. foreach ($localRepo->getPackages() as $package) {
  9790. $path = $composer->getInstallationManager()->getInstallPath($package);
  9791. if (null === $path) {
  9792. continue;
  9793. }
  9794. $file = $path . '/composer.json';
  9795. if (is_dir($path) && file_exists($file)) {
  9796. [$errors, $publishErrors, $warnings] = $validator->validate($file, $checkAll, $checkVersion);
  9797. $this->outputResult($io, $package->getPrettyName(), $errors, $warnings, $checkPublish, $publishErrors);
  9798. $depCode = $errors ? 2 : ($isStrict && $warnings ? 1 : 0);
  9799. $exitCode = max($depCode, $exitCode);
  9800. }
  9801. }
  9802. }
  9803. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'validate', $input, $output);
  9804. $eventCode = $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  9805. return max($eventCode, $exitCode);
  9806. }
  9807. private function outputResult(IOInterface $io, string $name, array &$errors, array &$warnings, bool $checkPublish = false, array $publishErrors = [], bool $checkLock = false, array $lockErrors = [], bool $printSchemaUrl = false): void
  9808. {
  9809. $doPrintSchemaUrl = false;
  9810. if ($errors) {
  9811. $io->writeError('<error>' . $name . ' is invalid, the following errors/warnings were found:</error>');
  9812. } elseif ($publishErrors) {
  9813. $io->writeError('<info>' . $name . ' is valid for simple usage with Composer but has</info>');
  9814. $io->writeError('<info>strict errors that make it unable to be published as a package</info>');
  9815. $doPrintSchemaUrl = $printSchemaUrl;
  9816. } elseif ($warnings) {
  9817. $io->writeError('<info>' . $name . ' is valid, but with a few warnings</info>');
  9818. $doPrintSchemaUrl = $printSchemaUrl;
  9819. } elseif ($lockErrors) {
  9820. $io->write('<info>' . $name . ' is valid but your composer.lock has some '.($checkLock ? 'errors' : 'warnings').'</info>');
  9821. } else {
  9822. $io->write('<info>' . $name . ' is valid</info>');
  9823. }
  9824. if ($doPrintSchemaUrl) {
  9825. $io->writeError('<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
  9826. }
  9827. if ($errors) {
  9828. $errors = array_map(static function ($err): string {
  9829. return '- ' . $err;
  9830. }, $errors);
  9831. array_unshift($errors, '# General errors');
  9832. }
  9833. if ($warnings) {
  9834. $warnings = array_map(static function ($err): string {
  9835. return '- ' . $err;
  9836. }, $warnings);
  9837. array_unshift($warnings, '# General warnings');
  9838. }
  9839. $extraWarnings = [];
  9840. if ($publishErrors) {
  9841. $publishErrors = array_map(static function ($err): string {
  9842. return '- ' . $err;
  9843. }, $publishErrors);
  9844. if ($checkPublish) {
  9845. array_unshift($publishErrors, '# Publish errors');
  9846. $errors = array_merge($errors, $publishErrors);
  9847. } else {
  9848. array_unshift($publishErrors, '# Publish warnings');
  9849. $extraWarnings = array_merge($extraWarnings, $publishErrors);
  9850. }
  9851. }
  9852. if ($lockErrors) {
  9853. if ($checkLock) {
  9854. array_unshift($lockErrors, '# Lock file errors');
  9855. $errors = array_merge($errors, $lockErrors);
  9856. } else {
  9857. array_unshift($lockErrors, '# Lock file warnings');
  9858. $extraWarnings = array_merge($extraWarnings, $lockErrors);
  9859. }
  9860. }
  9861. $messages = [
  9862. 'error' => $errors,
  9863. 'warning' => array_merge($warnings, $extraWarnings),
  9864. ];
  9865. foreach ($messages as $style => $msgs) {
  9866. foreach ($msgs as $msg) {
  9867. if (strpos($msg, '#') === 0) {
  9868. $io->writeError('<' . $style . '>' . $msg . '</' . $style . '>');
  9869. } else {
  9870. $io->writeError($msg);
  9871. }
  9872. }
  9873. }
  9874. }
  9875. }
  9876. <?php declare(strict_types=1);
  9877. namespace Composer;
  9878. use Composer\Package\Locker;
  9879. use Composer\Pcre\Preg;
  9880. use Composer\Plugin\PluginManager;
  9881. use Composer\Downloader\DownloadManager;
  9882. use Composer\Autoload\AutoloadGenerator;
  9883. use Composer\Package\Archiver\ArchiveManager;
  9884. class Composer extends PartialComposer
  9885. {
  9886. public const VERSION = '2.6.6';
  9887. public const BRANCH_ALIAS_VERSION = '';
  9888. public const RELEASE_DATE = '2023-12-08 18:32:26';
  9889. public const SOURCE_VERSION = '';
  9890. public const RUNTIME_API_VERSION = '2.2.2';
  9891. public static function getVersion(): string
  9892. {
  9893. if (self::VERSION === '@package_version'.'@') {
  9894. return self::SOURCE_VERSION;
  9895. }
  9896. if (self::BRANCH_ALIAS_VERSION !== '' && Preg::isMatch('{^[a-f0-9]{40}$}', self::VERSION)) {
  9897. return self::BRANCH_ALIAS_VERSION.'+'.self::VERSION;
  9898. }
  9899. return self::VERSION;
  9900. }
  9901. private $locker;
  9902. private $downloadManager;
  9903. private $pluginManager;
  9904. private $autoloadGenerator;
  9905. private $archiveManager;
  9906. public function setLocker(Locker $locker): void
  9907. {
  9908. $this->locker = $locker;
  9909. }
  9910. public function getLocker(): Locker
  9911. {
  9912. return $this->locker;
  9913. }
  9914. public function setDownloadManager(DownloadManager $manager): void
  9915. {
  9916. $this->downloadManager = $manager;
  9917. }
  9918. public function getDownloadManager(): DownloadManager
  9919. {
  9920. return $this->downloadManager;
  9921. }
  9922. public function setArchiveManager(ArchiveManager $manager): void
  9923. {
  9924. $this->archiveManager = $manager;
  9925. }
  9926. public function getArchiveManager(): ArchiveManager
  9927. {
  9928. return $this->archiveManager;
  9929. }
  9930. public function setPluginManager(PluginManager $manager): void
  9931. {
  9932. $this->pluginManager = $manager;
  9933. }
  9934. public function getPluginManager(): PluginManager
  9935. {
  9936. return $this->pluginManager;
  9937. }
  9938. public function setAutoloadGenerator(AutoloadGenerator $autoloadGenerator): void
  9939. {
  9940. $this->autoloadGenerator = $autoloadGenerator;
  9941. }
  9942. public function getAutoloadGenerator(): AutoloadGenerator
  9943. {
  9944. return $this->autoloadGenerator;
  9945. }
  9946. }
  9947. <?php declare(strict_types=1);
  9948. namespace Composer;
  9949. use Composer\Advisory\Auditor;
  9950. use Composer\Config\ConfigSourceInterface;
  9951. use Composer\Downloader\TransportException;
  9952. use Composer\IO\IOInterface;
  9953. use Composer\Pcre\Preg;
  9954. use Composer\Util\Platform;
  9955. use Composer\Util\ProcessExecutor;
  9956. class Config
  9957. {
  9958. public const SOURCE_DEFAULT = 'default';
  9959. public const SOURCE_COMMAND = 'command';
  9960. public const SOURCE_UNKNOWN = 'unknown';
  9961. public const RELATIVE_PATHS = 1;
  9962. public static $defaultConfig = [
  9963. 'process-timeout' => 300,
  9964. 'use-include-path' => false,
  9965. 'allow-plugins' => [],
  9966. 'use-parent-dir' => 'prompt',
  9967. 'preferred-install' => 'dist',
  9968. 'audit' => ['ignore' => [], 'abandoned' => 'default'],
  9969. 'notify-on-install' => true,
  9970. 'github-protocols' => ['https', 'ssh', 'git'],
  9971. 'gitlab-protocol' => null,
  9972. 'vendor-dir' => 'vendor',
  9973. 'bin-dir' => '{$vendor-dir}/bin',
  9974. 'cache-dir' => '{$home}/cache',
  9975. 'data-dir' => '{$home}',
  9976. 'cache-files-dir' => '{$cache-dir}/files',
  9977. 'cache-repo-dir' => '{$cache-dir}/repo',
  9978. 'cache-vcs-dir' => '{$cache-dir}/vcs',
  9979. 'cache-ttl' => 15552000,
  9980. 'cache-files-ttl' => null,
  9981. 'cache-files-maxsize' => '300MiB',
  9982. 'cache-read-only' => false,
  9983. 'bin-compat' => 'auto',
  9984. 'discard-changes' => false,
  9985. 'autoloader-suffix' => null,
  9986. 'sort-packages' => false,
  9987. 'optimize-autoloader' => false,
  9988. 'classmap-authoritative' => false,
  9989. 'apcu-autoloader' => false,
  9990. 'prepend-autoloader' => true,
  9991. 'github-domains' => ['github.com'],
  9992. 'bitbucket-expose-hostname' => true,
  9993. 'disable-tls' => false,
  9994. 'secure-http' => true,
  9995. 'secure-svn-domains' => [],
  9996. 'cafile' => null,
  9997. 'capath' => null,
  9998. 'github-expose-hostname' => true,
  9999. 'gitlab-domains' => ['gitlab.com'],
  10000. 'store-auths' => 'prompt',
  10001. 'platform' => [],
  10002. 'archive-format' => 'tar',
  10003. 'archive-dir' => '.',
  10004. 'htaccess-protect' => true,
  10005. 'use-github-api' => true,
  10006. 'lock' => true,
  10007. 'platform-check' => 'php-only',
  10008. 'bitbucket-oauth' => [],
  10009. 'github-oauth' => [],
  10010. 'gitlab-oauth' => [],
  10011. 'gitlab-token' => [],
  10012. 'http-basic' => [],
  10013. 'bearer' => [],
  10014. ];
  10015. public static $defaultRepositories = [
  10016. 'packagist.org' => [
  10017. 'type' => 'composer',
  10018. 'url' => 'https://repo.packagist.org',
  10019. ],
  10020. ];
  10021. private $config;
  10022. private $baseDir;
  10023. private $repositories;
  10024. private $configSource;
  10025. private $authConfigSource;
  10026. private $localAuthConfigSource = null;
  10027. private $useEnvironment;
  10028. private $warnedHosts = [];
  10029. private $sslVerifyWarnedHosts = [];
  10030. private $sourceOfConfigValue = [];
  10031. public function __construct(bool $useEnvironment = true, ?string $baseDir = null)
  10032. {
  10033. $this->config = static::$defaultConfig;
  10034. $this->repositories = static::$defaultRepositories;
  10035. $this->useEnvironment = (bool) $useEnvironment;
  10036. $this->baseDir = is_string($baseDir) && '' !== $baseDir ? $baseDir : null;
  10037. foreach ($this->config as $configKey => $configValue) {
  10038. $this->setSourceOfConfigValue($configValue, $configKey, self::SOURCE_DEFAULT);
  10039. }
  10040. foreach ($this->repositories as $configKey => $configValue) {
  10041. $this->setSourceOfConfigValue($configValue, 'repositories.' . $configKey, self::SOURCE_DEFAULT);
  10042. }
  10043. }
  10044. public function setConfigSource(ConfigSourceInterface $source): void
  10045. {
  10046. $this->configSource = $source;
  10047. }
  10048. public function getConfigSource(): ConfigSourceInterface
  10049. {
  10050. return $this->configSource;
  10051. }
  10052. public function setAuthConfigSource(ConfigSourceInterface $source): void
  10053. {
  10054. $this->authConfigSource = $source;
  10055. }
  10056. public function getAuthConfigSource(): ConfigSourceInterface
  10057. {
  10058. return $this->authConfigSource;
  10059. }
  10060. public function setLocalAuthConfigSource(ConfigSourceInterface $source): void
  10061. {
  10062. $this->localAuthConfigSource = $source;
  10063. }
  10064. public function getLocalAuthConfigSource(): ?ConfigSourceInterface
  10065. {
  10066. return $this->localAuthConfigSource;
  10067. }
  10068. public function merge(array $config, string $source = self::SOURCE_UNKNOWN): void
  10069. {
  10070. if (!empty($config['config']) && is_array($config['config'])) {
  10071. foreach ($config['config'] as $key => $val) {
  10072. if (in_array($key, ['bitbucket-oauth', 'github-oauth', 'gitlab-oauth', 'gitlab-token', 'http-basic', 'bearer'], true) && isset($this->config[$key])) {
  10073. $this->config[$key] = array_merge($this->config[$key], $val);
  10074. $this->setSourceOfConfigValue($val, $key, $source);
  10075. } elseif (in_array($key, ['allow-plugins'], true) && isset($this->config[$key]) && is_array($this->config[$key]) && is_array($val)) {
  10076. $this->config[$key] = array_merge($val, $this->config[$key], $val);
  10077. $this->setSourceOfConfigValue($val, $key, $source);
  10078. } elseif (in_array($key, ['gitlab-domains', 'github-domains'], true) && isset($this->config[$key])) {
  10079. $this->config[$key] = array_unique(array_merge($this->config[$key], $val));
  10080. $this->setSourceOfConfigValue($val, $key, $source);
  10081. } elseif ('preferred-install' === $key && isset($this->config[$key])) {
  10082. if (is_array($val) || is_array($this->config[$key])) {
  10083. if (is_string($val)) {
  10084. $val = ['*' => $val];
  10085. }
  10086. if (is_string($this->config[$key])) {
  10087. $this->config[$key] = ['*' => $this->config[$key]];
  10088. $this->sourceOfConfigValue[$key . '*'] = $source;
  10089. }
  10090. $this->config[$key] = array_merge($this->config[$key], $val);
  10091. $this->setSourceOfConfigValue($val, $key, $source);
  10092. if (isset($this->config[$key]['*'])) {
  10093. $wildcard = $this->config[$key]['*'];
  10094. unset($this->config[$key]['*']);
  10095. $this->config[$key]['*'] = $wildcard;
  10096. }
  10097. } else {
  10098. $this->config[$key] = $val;
  10099. $this->setSourceOfConfigValue($val, $key, $source);
  10100. }
  10101. } elseif ('audit' === $key) {
  10102. $currentIgnores = $this->config['audit']['ignore'];
  10103. $this->config[$key] = array_merge($this->config['audit'], $val);
  10104. $this->setSourceOfConfigValue($val, $key, $source);
  10105. $this->config['audit']['ignore'] = array_merge($currentIgnores, $val['ignore'] ?? []);
  10106. } else {
  10107. $this->config[$key] = $val;
  10108. $this->setSourceOfConfigValue($val, $key, $source);
  10109. }
  10110. }
  10111. }
  10112. if (!empty($config['repositories']) && is_array($config['repositories'])) {
  10113. $this->repositories = array_reverse($this->repositories, true);
  10114. $newRepos = array_reverse($config['repositories'], true);
  10115. foreach ($newRepos as $name => $repository) {
  10116. if (false === $repository) {
  10117. $this->disableRepoByName((string) $name);
  10118. continue;
  10119. }
  10120. if (is_array($repository) && 1 === count($repository) && false === current($repository)) {
  10121. $this->disableRepoByName((string) key($repository));
  10122. continue;
  10123. }
  10124. if (isset($repository['type'], $repository['url']) && $repository['type'] === 'composer' && Preg::isMatch('{^https?://(?:[a-z0-9-.]+\.)?packagist.org(/|$)}', $repository['url'])) {
  10125. $this->disableRepoByName('packagist.org');
  10126. }
  10127. if (is_int($name)) {
  10128. $this->repositories[] = $repository;
  10129. $this->setSourceOfConfigValue($repository, 'repositories.' . array_search($repository, $this->repositories, true), $source);
  10130. } else {
  10131. if ($name === 'packagist') {
  10132. $this->repositories[$name . '.org'] = $repository;
  10133. $this->setSourceOfConfigValue($repository, 'repositories.' . $name . '.org', $source);
  10134. } else {
  10135. $this->repositories[$name] = $repository;
  10136. $this->setSourceOfConfigValue($repository, 'repositories.' . $name, $source);
  10137. }
  10138. }
  10139. }
  10140. $this->repositories = array_reverse($this->repositories, true);
  10141. }
  10142. }
  10143. public function getRepositories(): array
  10144. {
  10145. return $this->repositories;
  10146. }
  10147. public function get(string $key, int $flags = 0)
  10148. {
  10149. switch ($key) {
  10150. case 'vendor-dir':
  10151. case 'bin-dir':
  10152. case 'process-timeout':
  10153. case 'data-dir':
  10154. case 'cache-dir':
  10155. case 'cache-files-dir':
  10156. case 'cache-repo-dir':
  10157. case 'cache-vcs-dir':
  10158. case 'cafile':
  10159. case 'capath':
  10160. $env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_'));
  10161. $val = $this->getComposerEnv($env);
  10162. if ($val !== false) {
  10163. $this->setSourceOfConfigValue($val, $key, $env);
  10164. }
  10165. if ($key === 'process-timeout') {
  10166. return max(0, false !== $val ? (int) $val : $this->config[$key]);
  10167. }
  10168. $val = rtrim((string) $this->process(false !== $val ? $val : $this->config[$key], $flags), '/\\');
  10169. $val = Platform::expandPath($val);
  10170. if (substr($key, -4) !== '-dir') {
  10171. return $val;
  10172. }
  10173. return (($flags & self::RELATIVE_PATHS) === self::RELATIVE_PATHS) ? $val : $this->realpath($val);
  10174. case 'cache-read-only':
  10175. case 'htaccess-protect':
  10176. $env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_'));
  10177. $val = $this->getComposerEnv($env);
  10178. if (false === $val) {
  10179. $val = $this->config[$key];
  10180. } else {
  10181. $this->setSourceOfConfigValue($val, $key, $env);
  10182. }
  10183. return $val !== 'false' && (bool) $val;
  10184. case 'disable-tls':
  10185. case 'secure-http':
  10186. case 'use-github-api':
  10187. case 'lock':
  10188. if ($key === 'secure-http' && $this->get('disable-tls') === true) {
  10189. return false;
  10190. }
  10191. return $this->config[$key] !== 'false' && (bool) $this->config[$key];
  10192. case 'cache-ttl':
  10193. return max(0, (int) $this->config[$key]);
  10194. case 'cache-files-maxsize':
  10195. if (!Preg::isMatch('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', (string) $this->config[$key], $matches)) {
  10196. throw new \RuntimeException(
  10197. "Could not parse the value of '$key': {$this->config[$key]}"
  10198. );
  10199. }
  10200. $size = (float) $matches[1];
  10201. if (isset($matches[2])) {
  10202. switch (strtolower($matches[2])) {
  10203. case 'g':
  10204. $size *= 1024;
  10205. case 'm':
  10206. $size *= 1024;
  10207. case 'k':
  10208. $size *= 1024;
  10209. break;
  10210. }
  10211. }
  10212. return max(0, (int) $size);
  10213. case 'cache-files-ttl':
  10214. if (isset($this->config[$key])) {
  10215. return max(0, (int) $this->config[$key]);
  10216. }
  10217. return $this->get('cache-ttl');
  10218. case 'home':
  10219. return rtrim($this->process(Platform::expandPath($this->config[$key]), $flags), '/\\');
  10220. case 'bin-compat':
  10221. $value = $this->getComposerEnv('COMPOSER_BIN_COMPAT') ?: $this->config[$key];
  10222. if (!in_array($value, ['auto', 'full', 'proxy', 'symlink'])) {
  10223. throw new \RuntimeException(
  10224. "Invalid value for 'bin-compat': {$value}. Expected auto, full or proxy"
  10225. );
  10226. }
  10227. if ($value === 'symlink') {
  10228. trigger_error('config.bin-compat "symlink" is deprecated since Composer 2.2, use auto, full (for Windows compatibility) or proxy instead.', E_USER_DEPRECATED);
  10229. }
  10230. return $value;
  10231. case 'discard-changes':
  10232. $env = $this->getComposerEnv('COMPOSER_DISCARD_CHANGES');
  10233. if ($env !== false) {
  10234. if (!in_array($env, ['stash', 'true', 'false', '1', '0'], true)) {
  10235. throw new \RuntimeException(
  10236. "Invalid value for COMPOSER_DISCARD_CHANGES: {$env}. Expected 1, 0, true, false or stash"
  10237. );
  10238. }
  10239. if ('stash' === $env) {
  10240. return 'stash';
  10241. }
  10242. return $env !== 'false' && (bool) $env;
  10243. }
  10244. if (!in_array($this->config[$key], [true, false, 'stash'], true)) {
  10245. throw new \RuntimeException(
  10246. "Invalid value for 'discard-changes': {$this->config[$key]}. Expected true, false or stash"
  10247. );
  10248. }
  10249. return $this->config[$key];
  10250. case 'github-protocols':
  10251. $protos = $this->config['github-protocols'];
  10252. if ($this->config['secure-http'] && false !== ($index = array_search('git', $protos))) {
  10253. unset($protos[$index]);
  10254. }
  10255. if (reset($protos) === 'http') {
  10256. throw new \RuntimeException('The http protocol for github is not available anymore, update your config\'s github-protocols to use "https", "git" or "ssh"');
  10257. }
  10258. return $protos;
  10259. case 'autoloader-suffix':
  10260. if ($this->config[$key] === '') {
  10261. return null;
  10262. }
  10263. return $this->process($this->config[$key], $flags);
  10264. default:
  10265. if (!isset($this->config[$key])) {
  10266. return null;
  10267. }
  10268. return $this->process($this->config[$key], $flags);
  10269. }
  10270. }
  10271. public function all(int $flags = 0): array
  10272. {
  10273. $all = [
  10274. 'repositories' => $this->getRepositories(),
  10275. ];
  10276. foreach (array_keys($this->config) as $key) {
  10277. $all['config'][$key] = $this->get($key, $flags);
  10278. }
  10279. return $all;
  10280. }
  10281. public function getSourceOfValue(string $key): string
  10282. {
  10283. $this->get($key);
  10284. return $this->sourceOfConfigValue[$key] ?? self::SOURCE_UNKNOWN;
  10285. }
  10286. private function setSourceOfConfigValue($configValue, string $path, string $source): void
  10287. {
  10288. $this->sourceOfConfigValue[$path] = $source;
  10289. if (is_array($configValue)) {
  10290. foreach ($configValue as $key => $value) {
  10291. $this->setSourceOfConfigValue($value, $path . '.' . $key, $source);
  10292. }
  10293. }
  10294. }
  10295. public function raw(): array
  10296. {
  10297. return [
  10298. 'repositories' => $this->getRepositories(),
  10299. 'config' => $this->config,
  10300. ];
  10301. }
  10302. public function has(string $key): bool
  10303. {
  10304. return array_key_exists($key, $this->config);
  10305. }
  10306. private function process($value, int $flags)
  10307. {
  10308. if (!is_string($value)) {
  10309. return $value;
  10310. }
  10311. return Preg::replaceCallback('#\{\$(.+)\}#', function ($match) use ($flags) {
  10312. assert(is_string($match[1]));
  10313. return $this->get($match[1], $flags);
  10314. }, $value);
  10315. }
  10316. private function realpath(string $path): string
  10317. {
  10318. if (Preg::isMatch('{^(?:/|[a-z]:|[a-z0-9.]+://|\\\\\\\\)}i', $path)) {
  10319. return $path;
  10320. }
  10321. return $this->baseDir ? $this->baseDir . '/' . $path : $path;
  10322. }
  10323. private function getComposerEnv(string $var)
  10324. {
  10325. if ($this->useEnvironment) {
  10326. return Platform::getEnv($var);
  10327. }
  10328. return false;
  10329. }
  10330. private function disableRepoByName(string $name): void
  10331. {
  10332. if (isset($this->repositories[$name])) {
  10333. unset($this->repositories[$name]);
  10334. } elseif ($name === 'packagist') {
  10335. unset($this->repositories['packagist.org']);
  10336. }
  10337. }
  10338. public function prohibitUrlByConfig(string $url, ?IOInterface $io = null, array $repoOptions = []): void
  10339. {
  10340. if (false === filter_var($url, FILTER_VALIDATE_URL)) {
  10341. return;
  10342. }
  10343. $scheme = parse_url($url, PHP_URL_SCHEME);
  10344. $hostname = parse_url($url, PHP_URL_HOST);
  10345. if (in_array($scheme, ['http', 'git', 'ftp', 'svn'])) {
  10346. if ($this->get('secure-http')) {
  10347. if ($scheme === 'svn') {
  10348. if (in_array($hostname, $this->get('secure-svn-domains'), true)) {
  10349. return;
  10350. }
  10351. throw new TransportException("Your configuration does not allow connections to $url. See https://getcomposer.org/doc/06-config.md#secure-svn-domains for details.");
  10352. }
  10353. throw new TransportException("Your configuration does not allow connections to $url. See https://getcomposer.org/doc/06-config.md#secure-http for details.");
  10354. }
  10355. if ($io !== null) {
  10356. if (is_string($hostname)) {
  10357. if (!isset($this->warnedHosts[$hostname])) {
  10358. $io->writeError("<warning>Warning: Accessing $hostname over $scheme which is an insecure protocol.</warning>");
  10359. }
  10360. $this->warnedHosts[$hostname] = true;
  10361. }
  10362. }
  10363. }
  10364. if ($io !== null && is_string($hostname) && !isset($this->sslVerifyWarnedHosts[$hostname])) {
  10365. $warning = null;
  10366. if (isset($repoOptions['ssl']['verify_peer']) && !(bool) $repoOptions['ssl']['verify_peer']) {
  10367. $warning = 'verify_peer';
  10368. }
  10369. if (isset($repoOptions['ssl']['verify_peer_name']) && !(bool) $repoOptions['ssl']['verify_peer_name']) {
  10370. $warning = $warning === null ? 'verify_peer_name' : $warning . ' and verify_peer_name';
  10371. }
  10372. if ($warning !== null) {
  10373. $io->writeError("<warning>Warning: Accessing $hostname with $warning disabled.</warning>");
  10374. $this->sslVerifyWarnedHosts[$hostname] = true;
  10375. }
  10376. }
  10377. }
  10378. public static function disableProcessTimeout(): void
  10379. {
  10380. ProcessExecutor::setTimeout(0);
  10381. }
  10382. }
  10383. <?php declare(strict_types=1);
  10384. namespace Composer\Config;
  10385. interface ConfigSourceInterface
  10386. {
  10387. public function addRepository(string $name, $config, bool $append = true): void;
  10388. public function removeRepository(string $name): void;
  10389. public function addConfigSetting(string $name, $value): void;
  10390. public function removeConfigSetting(string $name): void;
  10391. public function addProperty(string $name, $value): void;
  10392. public function removeProperty(string $name): void;
  10393. public function addLink(string $type, string $name, string $value): void;
  10394. public function removeLink(string $type, string $name): void;
  10395. public function getName(): string;
  10396. }
  10397. <?php declare(strict_types=1);
  10398. namespace Composer\Config;
  10399. use Composer\Json\JsonFile;
  10400. use Composer\Json\JsonManipulator;
  10401. use Composer\Json\JsonValidationException;
  10402. use Composer\Pcre\Preg;
  10403. use Composer\Util\Filesystem;
  10404. use Composer\Util\Silencer;
  10405. class JsonConfigSource implements ConfigSourceInterface
  10406. {
  10407. private $file;
  10408. private $authConfig;
  10409. public function __construct(JsonFile $file, bool $authConfig = false)
  10410. {
  10411. $this->file = $file;
  10412. $this->authConfig = $authConfig;
  10413. }
  10414. public function getName(): string
  10415. {
  10416. return $this->file->getPath();
  10417. }
  10418. public function addRepository(string $name, $config, bool $append = true): void
  10419. {
  10420. $this->manipulateJson('addRepository', static function (&$config, $repo, $repoConfig) use ($append): void {
  10421. if (isset($config['repositories'])) {
  10422. foreach ($config['repositories'] as $index => $val) {
  10423. if ($index === $repo) {
  10424. continue;
  10425. }
  10426. if (is_numeric($index) && ($val === ['packagist' => false] || $val === ['packagist.org' => false])) {
  10427. unset($config['repositories'][$index]);
  10428. $config['repositories']['packagist.org'] = false;
  10429. break;
  10430. }
  10431. }
  10432. }
  10433. if ($append) {
  10434. $config['repositories'][$repo] = $repoConfig;
  10435. } else {
  10436. $config['repositories'] = [$repo => $repoConfig] + $config['repositories'];
  10437. }
  10438. }, $name, $config, $append);
  10439. }
  10440. public function removeRepository(string $name): void
  10441. {
  10442. $this->manipulateJson('removeRepository', static function (&$config, $repo): void {
  10443. unset($config['repositories'][$repo]);
  10444. }, $name);
  10445. }
  10446. public function addConfigSetting(string $name, $value): void
  10447. {
  10448. $authConfig = $this->authConfig;
  10449. $this->manipulateJson('addConfigSetting', static function (&$config, $key, $val) use ($authConfig): void {
  10450. if (Preg::isMatch('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|bearer|http-basic|platform)\.}', $key)) {
  10451. [$key, $host] = explode('.', $key, 2);
  10452. if ($authConfig) {
  10453. $config[$key][$host] = $val;
  10454. } else {
  10455. $config['config'][$key][$host] = $val;
  10456. }
  10457. } else {
  10458. $config['config'][$key] = $val;
  10459. }
  10460. }, $name, $value);
  10461. }
  10462. public function removeConfigSetting(string $name): void
  10463. {
  10464. $authConfig = $this->authConfig;
  10465. $this->manipulateJson('removeConfigSetting', static function (&$config, $key) use ($authConfig): void {
  10466. if (Preg::isMatch('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|bearer|http-basic|platform)\.}', $key)) {
  10467. [$key, $host] = explode('.', $key, 2);
  10468. if ($authConfig) {
  10469. unset($config[$key][$host]);
  10470. } else {
  10471. unset($config['config'][$key][$host]);
  10472. }
  10473. } else {
  10474. unset($config['config'][$key]);
  10475. }
  10476. }, $name);
  10477. }
  10478. public function addProperty(string $name, $value): void
  10479. {
  10480. $this->manipulateJson('addProperty', static function (&$config, $key, $val): void {
  10481. if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {
  10482. $bits = explode('.', $key);
  10483. $last = array_pop($bits);
  10484. $arr = &$config[reset($bits)];
  10485. foreach ($bits as $bit) {
  10486. if (!isset($arr[$bit])) {
  10487. $arr[$bit] = [];
  10488. }
  10489. $arr = &$arr[$bit];
  10490. }
  10491. $arr[$last] = $val;
  10492. } else {
  10493. $config[$key] = $val;
  10494. }
  10495. }, $name, $value);
  10496. }
  10497. public function removeProperty(string $name): void
  10498. {
  10499. $this->manipulateJson('removeProperty', static function (&$config, $key): void {
  10500. if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {
  10501. $bits = explode('.', $key);
  10502. $last = array_pop($bits);
  10503. $arr = &$config[reset($bits)];
  10504. foreach ($bits as $bit) {
  10505. if (!isset($arr[$bit])) {
  10506. return;
  10507. }
  10508. $arr = &$arr[$bit];
  10509. }
  10510. unset($arr[$last]);
  10511. } else {
  10512. unset($config[$key]);
  10513. }
  10514. }, $name);
  10515. }
  10516. public function addLink(string $type, string $name, string $value): void
  10517. {
  10518. $this->manipulateJson('addLink', static function (&$config, $type, $name, $value): void {
  10519. $config[$type][$name] = $value;
  10520. }, $type, $name, $value);
  10521. }
  10522. public function removeLink(string $type, string $name): void
  10523. {
  10524. $this->manipulateJson('removeSubNode', static function (&$config, $type, $name): void {
  10525. unset($config[$type][$name]);
  10526. }, $type, $name);
  10527. $this->manipulateJson('removeMainKeyIfEmpty', static function (&$config, $type): void {
  10528. if (0 === count($config[$type])) {
  10529. unset($config[$type]);
  10530. }
  10531. }, $type);
  10532. }
  10533. private function manipulateJson(string $method, callable $fallback, ...$args): void
  10534. {
  10535. if ($this->file->exists()) {
  10536. if (!is_writable($this->file->getPath())) {
  10537. throw new \RuntimeException(sprintf('The file "%s" is not writable.', $this->file->getPath()));
  10538. }
  10539. if (!Filesystem::isReadable($this->file->getPath())) {
  10540. throw new \RuntimeException(sprintf('The file "%s" is not readable.', $this->file->getPath()));
  10541. }
  10542. $contents = file_get_contents($this->file->getPath());
  10543. } elseif ($this->authConfig) {
  10544. $contents = "{\n}\n";
  10545. } else {
  10546. $contents = "{\n \"config\": {\n }\n}\n";
  10547. }
  10548. $manipulator = new JsonManipulator($contents);
  10549. $newFile = !$this->file->exists();
  10550. if ($this->authConfig && $method === 'addConfigSetting') {
  10551. $method = 'addSubNode';
  10552. [$mainNode, $name] = explode('.', $args[0], 2);
  10553. $args = [$mainNode, $name, $args[1]];
  10554. } elseif ($this->authConfig && $method === 'removeConfigSetting') {
  10555. $method = 'removeSubNode';
  10556. [$mainNode, $name] = explode('.', $args[0], 2);
  10557. $args = [$mainNode, $name];
  10558. }
  10559. if (call_user_func_array([$manipulator, $method], $args)) {
  10560. file_put_contents($this->file->getPath(), $manipulator->getContents());
  10561. } else {
  10562. $config = $this->file->read();
  10563. $this->arrayUnshiftRef($args, $config);
  10564. $fallback(...$args);
  10565. foreach (['require', 'require-dev', 'conflict', 'provide', 'replace', 'suggest', 'config', 'autoload', 'autoload-dev', 'scripts', 'scripts-descriptions', 'support'] as $prop) {
  10566. if (isset($config[$prop]) && $config[$prop] === []) {
  10567. $config[$prop] = new \stdClass;
  10568. }
  10569. }
  10570. foreach (['psr-0', 'psr-4'] as $prop) {
  10571. if (isset($config['autoload'][$prop]) && $config['autoload'][$prop] === []) {
  10572. $config['autoload'][$prop] = new \stdClass;
  10573. }
  10574. if (isset($config['autoload-dev'][$prop]) && $config['autoload-dev'][$prop] === []) {
  10575. $config['autoload-dev'][$prop] = new \stdClass;
  10576. }
  10577. }
  10578. foreach (['platform', 'http-basic', 'bearer', 'gitlab-token', 'gitlab-oauth', 'github-oauth', 'preferred-install'] as $prop) {
  10579. if (isset($config['config'][$prop]) && $config['config'][$prop] === []) {
  10580. $config['config'][$prop] = new \stdClass;
  10581. }
  10582. }
  10583. $this->file->write($config);
  10584. }
  10585. try {
  10586. $this->file->validateSchema(JsonFile::LAX_SCHEMA);
  10587. } catch (JsonValidationException $e) {
  10588. file_put_contents($this->file->getPath(), $contents);
  10589. 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);
  10590. }
  10591. if ($newFile) {
  10592. Silencer::call('chmod', $this->file->getPath(), 0600);
  10593. }
  10594. }
  10595. private function arrayUnshiftRef(array &$array, &$value): int
  10596. {
  10597. $return = array_unshift($array, '');
  10598. $array[0] = &$value;
  10599. return $return;
  10600. }
  10601. }
  10602. <?php declare(strict_types=1);
  10603. namespace Composer\Console;
  10604. use Composer\IO\NullIO;
  10605. use Composer\Util\Filesystem;
  10606. use Composer\Util\Platform;
  10607. use Composer\Util\Silencer;
  10608. use LogicException;
  10609. use RuntimeException;
  10610. use Seld\Signal\SignalHandler;
  10611. use Symfony\Component\Console\Application as BaseApplication;
  10612. use Symfony\Component\Console\Exception\CommandNotFoundException;
  10613. use Symfony\Component\Console\Helper\HelperSet;
  10614. use Symfony\Component\Console\Helper\QuestionHelper;
  10615. use Symfony\Component\Console\Input\InputDefinition;
  10616. use Symfony\Component\Console\Input\InputInterface;
  10617. use Symfony\Component\Console\Input\InputOption;
  10618. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  10619. use Symfony\Component\Console\Output\OutputInterface;
  10620. use Seld\JsonLint\ParsingException;
  10621. use Composer\Command;
  10622. use Composer\Composer;
  10623. use Composer\Factory;
  10624. use Composer\IO\IOInterface;
  10625. use Composer\IO\ConsoleIO;
  10626. use Composer\Json\JsonValidationException;
  10627. use Composer\Util\ErrorHandler;
  10628. use Composer\Util\HttpDownloader;
  10629. use Composer\EventDispatcher\ScriptExecutionException;
  10630. use Composer\Exception\NoSslException;
  10631. use Composer\XdebugHandler\XdebugHandler;
  10632. use Symfony\Component\Process\Exception\ProcessTimedOutException;
  10633. class Application extends BaseApplication
  10634. {
  10635. protected $composer;
  10636. protected $io;
  10637. private static $logo = ' ______
  10638. / ____/___ ____ ___ ____ ____ ________ _____
  10639. / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
  10640. / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
  10641. \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
  10642. /_/
  10643. ';
  10644. private $hasPluginCommands = false;
  10645. private $disablePluginsByDefault = false;
  10646. private $disableScriptsByDefault = false;
  10647. private $initialWorkingDirectory;
  10648. private $signalHandler;
  10649. public function __construct(string $name = 'Composer', string $version = '')
  10650. {
  10651. if (method_exists($this, 'setCatchErrors')) {
  10652. $this->setCatchErrors(true);
  10653. }
  10654. static $shutdownRegistered = false;
  10655. if ($version === '') {
  10656. $version = Composer::getVersion();
  10657. }
  10658. if (function_exists('ini_set') && extension_loaded('xdebug')) {
  10659. ini_set('xdebug.show_exception_trace', '0');
  10660. ini_set('xdebug.scream', '0');
  10661. }
  10662. if (function_exists('date_default_timezone_set') && function_exists('date_default_timezone_get')) {
  10663. date_default_timezone_set(Silencer::call('date_default_timezone_get'));
  10664. }
  10665. $this->io = new NullIO();
  10666. $this->signalHandler = SignalHandler::create([SignalHandler::SIGINT, SignalHandler::SIGTERM, SignalHandler::SIGHUP], function (string $signal, SignalHandler $handler) {
  10667. $this->io->writeError('Received '.$signal.', aborting', true, IOInterface::DEBUG);
  10668. $handler->exitWithLastSignal();
  10669. });
  10670. if (!$shutdownRegistered) {
  10671. $shutdownRegistered = true;
  10672. register_shutdown_function(static function (): void {
  10673. $lastError = error_get_last();
  10674. if ($lastError && $lastError['message'] &&
  10675. (strpos($lastError['message'], 'Allowed memory') !== false ||
  10676. strpos($lastError['message'], 'exceeded memory') !== false )) {
  10677. echo "\n". 'Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.';
  10678. }
  10679. });
  10680. }
  10681. $this->initialWorkingDirectory = getcwd();
  10682. parent::__construct($name, $version);
  10683. }
  10684. public function __destruct()
  10685. {
  10686. $this->signalHandler->unregister();
  10687. }
  10688. public function run(?InputInterface $input = null, ?OutputInterface $output = null): int
  10689. {
  10690. if (null === $output) {
  10691. $output = Factory::createOutput();
  10692. }
  10693. return parent::run($input, $output);
  10694. }
  10695. public function doRun(InputInterface $input, OutputInterface $output): int
  10696. {
  10697. $this->disablePluginsByDefault = $input->hasParameterOption('--no-plugins');
  10698. $this->disableScriptsByDefault = $input->hasParameterOption('--no-scripts');
  10699. $stdin = defined('STDIN') ? STDIN : fopen('php://stdin', 'r');
  10700. if (Platform::getEnv('COMPOSER_TESTS_ARE_RUNNING') !== '1' && (Platform::getEnv('COMPOSER_NO_INTERACTION') || $stdin === false || !Platform::isTty($stdin))) {
  10701. $input->setInteractive(false);
  10702. }
  10703. $io = $this->io = new ConsoleIO($input, $output, new HelperSet([
  10704. new QuestionHelper(),
  10705. ]));
  10706. ErrorHandler::register($io);
  10707. if ($input->hasParameterOption('--no-cache')) {
  10708. $io->writeError('Disabling cache usage', true, IOInterface::DEBUG);
  10709. Platform::putEnv('COMPOSER_CACHE_DIR', Platform::isWindows() ? 'nul' : '/dev/null');
  10710. }
  10711. $newWorkDir = $this->getNewWorkingDir($input);
  10712. if (null !== $newWorkDir) {
  10713. $oldWorkingDir = Platform::getCwd(true);
  10714. chdir($newWorkDir);
  10715. $this->initialWorkingDirectory = $newWorkDir;
  10716. $cwd = Platform::getCwd(true);
  10717. $io->writeError('Changed CWD to ' . ($cwd !== '' ? $cwd : $newWorkDir), true, IOInterface::DEBUG);
  10718. }
  10719. $commandName = '';
  10720. if ($name = $this->getCommandName($input)) {
  10721. try {
  10722. $commandName = $this->find($name)->getName();
  10723. } catch (CommandNotFoundException $e) {
  10724. $commandName = false;
  10725. } catch (\InvalidArgumentException $e) {
  10726. }
  10727. }
  10728. if ($io->isInteractive() && null === $newWorkDir && !in_array($commandName, ['', 'list', 'init', 'about', 'help', 'diagnose', 'self-update', 'global', 'create-project', 'outdated'], true) && !file_exists(Factory::getComposerFile()) && ($useParentDirIfNoJsonAvailable = $this->getUseParentDirConfigValue()) !== false) {
  10729. $dir = dirname(Platform::getCwd(true));
  10730. $home = realpath(Platform::getEnv('HOME') ?: Platform::getEnv('USERPROFILE') ?: '/');
  10731. while (dirname($dir) !== $dir && $dir !== $home) {
  10732. if (file_exists($dir.'/'.Factory::getComposerFile())) {
  10733. 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>]? ')) {
  10734. if ($useParentDirIfNoJsonAvailable === true) {
  10735. $io->writeError('<info>No composer.json in current directory, changing working directory to '.$dir.'</info>');
  10736. } else {
  10737. $io->writeError('<info>Always want to use the parent dir? Use "composer config --global use-parent-dir true" to change the default.</info>');
  10738. }
  10739. $oldWorkingDir = Platform::getCwd(true);
  10740. chdir($dir);
  10741. }
  10742. break;
  10743. }
  10744. $dir = dirname($dir);
  10745. }
  10746. }
  10747. $needsSudoCheck = !Platform::isWindows()
  10748. && function_exists('exec')
  10749. && !Platform::getEnv('COMPOSER_ALLOW_SUPERUSER')
  10750. && (ini_get('open_basedir') || !file_exists('/.dockerenv'));
  10751. $isNonAllowedRoot = false;
  10752. if ($needsSudoCheck) {
  10753. $isNonAllowedRoot = function_exists('posix_getuid') && posix_getuid() === 0;
  10754. if ($isNonAllowedRoot) {
  10755. if ($uid = (int) Platform::getEnv('SUDO_UID')) {
  10756. Silencer::call('exec', "sudo -u \\#{$uid} sudo -K > /dev/null 2>&1");
  10757. }
  10758. }
  10759. Silencer::call('exec', 'sudo -K > /dev/null 2>&1');
  10760. }
  10761. $mayNeedPluginCommand = false === $input->hasParameterOption(['--version', '-V'])
  10762. && (
  10763. false === $commandName
  10764. || in_array($commandName, ['', 'list', 'help'], true)
  10765. || ($commandName === '_complete' && !$isNonAllowedRoot)
  10766. );
  10767. if ($mayNeedPluginCommand && !$this->disablePluginsByDefault && !$this->hasPluginCommands) {
  10768. if ($isNonAllowedRoot) {
  10769. $io->writeError('<warning>Do not run Composer as root/super user! See https://getcomposer.org/root for details</warning>');
  10770. if ($io->isInteractive() && $io->askConfirmation('<info>Continue as root/super user</info> [<comment>yes</comment>]? ')) {
  10771. $isNonAllowedRoot = false;
  10772. } else {
  10773. $io->writeError('<warning>Aborting as no plugin should be loaded if running as super user is not explicitly allowed</warning>');
  10774. return 1;
  10775. }
  10776. }
  10777. try {
  10778. foreach ($this->getPluginCommands() as $command) {
  10779. if ($this->has($command->getName())) {
  10780. $io->writeError('<warning>Plugin command '.$command->getName().' ('.get_class($command).') would override a Composer command and has been skipped</warning>');
  10781. } else {
  10782. $this->add($command);
  10783. }
  10784. }
  10785. } catch (NoSslException $e) {
  10786. } catch (ParsingException $e) {
  10787. $details = $e->getDetails();
  10788. $file = realpath(Factory::getComposerFile());
  10789. $line = null;
  10790. if ($details && isset($details['line'])) {
  10791. $line = $details['line'];
  10792. }
  10793. $ghe = new GithubActionError($this->io);
  10794. $ghe->emit($e->getMessage(), $file, $line);
  10795. throw $e;
  10796. }
  10797. $this->hasPluginCommands = true;
  10798. }
  10799. if ($isNonAllowedRoot && !$io->isInteractive()) {
  10800. $io->writeError('<error>Composer plugins have been disabled for safety in this non-interactive session. Set COMPOSER_ALLOW_SUPERUSER=1 if you want to allow plugins to run as root/super user.</error>');
  10801. $this->disablePluginsByDefault = true;
  10802. }
  10803. $isProxyCommand = false;
  10804. if ($name = $this->getCommandName($input)) {
  10805. try {
  10806. $command = $this->find($name);
  10807. $commandName = $command->getName();
  10808. $isProxyCommand = ($command instanceof Command\BaseCommand && $command->isProxyCommand());
  10809. } catch (\InvalidArgumentException $e) {
  10810. }
  10811. }
  10812. if (!$isProxyCommand) {
  10813. $io->writeError(sprintf(
  10814. 'Running %s (%s) with %s on %s',
  10815. Composer::getVersion(),
  10816. Composer::RELEASE_DATE,
  10817. defined('HHVM_VERSION') ? 'HHVM '.HHVM_VERSION : 'PHP '.PHP_VERSION,
  10818. function_exists('php_uname') ? php_uname('s') . ' / ' . php_uname('r') : 'Unknown OS'
  10819. ), true, IOInterface::DEBUG);
  10820. if (PHP_VERSION_ID < 70205) {
  10821. $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>');
  10822. }
  10823. if (XdebugHandler::isXdebugActive() && !Platform::getEnv('COMPOSER_DISABLE_XDEBUG_WARN')) {
  10824. $io->writeError('<warning>Composer is operating slower than normal because you have Xdebug enabled. See https://getcomposer.org/xdebug</warning>');
  10825. }
  10826. if (defined('COMPOSER_DEV_WARNING_TIME') && $commandName !== 'self-update' && $commandName !== 'selfupdate' && time() > COMPOSER_DEV_WARNING_TIME) {
  10827. $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']));
  10828. }
  10829. if ($isNonAllowedRoot) {
  10830. if ($commandName !== 'self-update' && $commandName !== 'selfupdate' && $commandName !== '_complete') {
  10831. $io->writeError('<warning>Do not run Composer as root/super user! See https://getcomposer.org/root for details</warning>');
  10832. if ($io->isInteractive()) {
  10833. if (!$io->askConfirmation('<info>Continue as root/super user</info> [<comment>yes</comment>]? ')) {
  10834. return 1;
  10835. }
  10836. }
  10837. }
  10838. }
  10839. Silencer::call(static function () use ($io): void {
  10840. $pid = function_exists('getmypid') ? getmypid() . '-' : '';
  10841. $tempfile = sys_get_temp_dir() . '/temp-' . $pid . md5(microtime());
  10842. if (!(file_put_contents($tempfile, __FILE__) && (file_get_contents($tempfile) === __FILE__) && unlink($tempfile) && !file_exists($tempfile))) {
  10843. $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()));
  10844. }
  10845. });
  10846. $file = Factory::getComposerFile();
  10847. if (is_file($file) && Filesystem::isReadable($file) && is_array($composer = json_decode(file_get_contents($file), true))) {
  10848. if (isset($composer['scripts']) && is_array($composer['scripts'])) {
  10849. foreach ($composer['scripts'] as $script => $dummy) {
  10850. if (!defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
  10851. if ($this->has($script)) {
  10852. $io->writeError('<warning>A script named '.$script.' would override a Composer command and has been skipped</warning>');
  10853. } else {
  10854. $description = null;
  10855. if (isset($composer['scripts-descriptions'][$script])) {
  10856. $description = $composer['scripts-descriptions'][$script];
  10857. }
  10858. $this->add(new Command\ScriptAliasCommand($script, $description));
  10859. }
  10860. }
  10861. }
  10862. }
  10863. }
  10864. }
  10865. try {
  10866. if ($input->hasParameterOption('--profile')) {
  10867. $startTime = microtime(true);
  10868. $this->io->enableDebugging($startTime);
  10869. }
  10870. $result = parent::doRun($input, $output);
  10871. if (isset($oldWorkingDir) && '' !== $oldWorkingDir) {
  10872. Silencer::call('chdir', $oldWorkingDir);
  10873. }
  10874. if (isset($startTime)) {
  10875. $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');
  10876. }
  10877. return $result;
  10878. } catch (ScriptExecutionException $e) {
  10879. return $e->getCode();
  10880. } catch (\Throwable $e) {
  10881. $ghe = new GithubActionError($this->io);
  10882. $ghe->emit($e->getMessage());
  10883. $this->hintCommonErrors($e, $output);
  10884. if (!method_exists($this, 'setCatchErrors') && !$e instanceof \Exception) {
  10885. if ($output instanceof ConsoleOutputInterface) {
  10886. $this->renderThrowable($e, $output->getErrorOutput());
  10887. } else {
  10888. $this->renderThrowable($e, $output);
  10889. }
  10890. return max(1, $e->getCode());
  10891. }
  10892. throw $e;
  10893. } finally {
  10894. restore_error_handler();
  10895. }
  10896. }
  10897. private function getNewWorkingDir(InputInterface $input): ?string
  10898. {
  10899. $workingDir = $input->getParameterOption(['--working-dir', '-d'], null, true);
  10900. if (null !== $workingDir && !is_dir($workingDir)) {
  10901. throw new \RuntimeException('Invalid working directory specified, '.$workingDir.' does not exist.');
  10902. }
  10903. return $workingDir;
  10904. }
  10905. private function hintCommonErrors(\Throwable $exception, OutputInterface $output): void
  10906. {
  10907. $io = $this->getIO();
  10908. if ((get_class($exception) === LogicException::class || $exception instanceof \Error) && $output->getVerbosity() < OutputInterface::VERBOSITY_VERBOSE) {
  10909. $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
  10910. }
  10911. Silencer::suppress();
  10912. try {
  10913. $composer = $this->getComposer(false, true);
  10914. if (null !== $composer && function_exists('disk_free_space')) {
  10915. $config = $composer->getConfig();
  10916. $minSpaceFree = 100 * 1024 * 1024;
  10917. if ((($df = disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree)
  10918. || (($df = disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree)
  10919. || (($df = disk_free_space($dir = sys_get_temp_dir())) !== false && $df < $minSpaceFree)
  10920. ) {
  10921. $io->writeError('<error>The disk hosting '.$dir.' has less than 100MiB of free space, this may be the cause of the following exception</error>', true, IOInterface::QUIET);
  10922. }
  10923. }
  10924. } catch (\Exception $e) {
  10925. }
  10926. Silencer::restore();
  10927. if (Platform::isWindows() && false !== strpos($exception->getMessage(), 'The system cannot find the path specified')) {
  10928. $io->writeError('<error>The following exception may be caused by a stale entry in your cmd.exe AutoRun</error>', true, IOInterface::QUIET);
  10929. $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);
  10930. }
  10931. if (false !== strpos($exception->getMessage(), 'fork failed - Cannot allocate memory')) {
  10932. $io->writeError('<error>The following exception is caused by a lack of memory or swap, or not having swap configured</error>', true, IOInterface::QUIET);
  10933. $io->writeError('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details</error>', true, IOInterface::QUIET);
  10934. }
  10935. if ($exception instanceof ProcessTimedOutException) {
  10936. $io->writeError('<error>The following exception is caused by a process timeout</error>', true, IOInterface::QUIET);
  10937. $io->writeError('<error>Check https://getcomposer.org/doc/06-config.md#process-timeout for details</error>', true, IOInterface::QUIET);
  10938. }
  10939. $hints = HttpDownloader::getExceptionHints($exception);
  10940. if (null !== $hints && count($hints) > 0) {
  10941. foreach ($hints as $hint) {
  10942. $io->writeError($hint, true, IOInterface::QUIET);
  10943. }
  10944. }
  10945. }
  10946. public function getComposer(bool $required = true, ?bool $disablePlugins = null, ?bool $disableScripts = null): ?Composer
  10947. {
  10948. if (null === $disablePlugins) {
  10949. $disablePlugins = $this->disablePluginsByDefault;
  10950. }
  10951. if (null === $disableScripts) {
  10952. $disableScripts = $this->disableScriptsByDefault;
  10953. }
  10954. if (null === $this->composer) {
  10955. try {
  10956. $this->composer = Factory::create(Platform::isInputCompletionProcess() ? new NullIO() : $this->io, null, $disablePlugins, $disableScripts);
  10957. } catch (\InvalidArgumentException $e) {
  10958. if ($required) {
  10959. $this->io->writeError($e->getMessage());
  10960. if ($this->areExceptionsCaught()) {
  10961. exit(1);
  10962. }
  10963. throw $e;
  10964. }
  10965. } catch (JsonValidationException $e) {
  10966. if ($required) {
  10967. throw $e;
  10968. }
  10969. } catch (RuntimeException $e) {
  10970. if ($required) {
  10971. throw $e;
  10972. }
  10973. }
  10974. }
  10975. return $this->composer;
  10976. }
  10977. public function resetComposer(): void
  10978. {
  10979. $this->composer = null;
  10980. if (method_exists($this->getIO(), 'resetAuthentications')) {
  10981. $this->getIO()->resetAuthentications();
  10982. }
  10983. }
  10984. public function getIO(): IOInterface
  10985. {
  10986. return $this->io;
  10987. }
  10988. public function getHelp(): string
  10989. {
  10990. return self::$logo . parent::getHelp();
  10991. }
  10992. protected function getDefaultCommands(): array
  10993. {
  10994. $commands = array_merge(parent::getDefaultCommands(), [
  10995. new Command\AboutCommand(),
  10996. new Command\ConfigCommand(),
  10997. new Command\DependsCommand(),
  10998. new Command\ProhibitsCommand(),
  10999. new Command\InitCommand(),
  11000. new Command\InstallCommand(),
  11001. new Command\CreateProjectCommand(),
  11002. new Command\UpdateCommand(),
  11003. new Command\SearchCommand(),
  11004. new Command\ValidateCommand(),
  11005. new Command\AuditCommand(),
  11006. new Command\ShowCommand(),
  11007. new Command\SuggestsCommand(),
  11008. new Command\RequireCommand(),
  11009. new Command\DumpAutoloadCommand(),
  11010. new Command\StatusCommand(),
  11011. new Command\ArchiveCommand(),
  11012. new Command\DiagnoseCommand(),
  11013. new Command\RunScriptCommand(),
  11014. new Command\LicensesCommand(),
  11015. new Command\GlobalCommand(),
  11016. new Command\ClearCacheCommand(),
  11017. new Command\RemoveCommand(),
  11018. new Command\HomeCommand(),
  11019. new Command\ExecCommand(),
  11020. new Command\OutdatedCommand(),
  11021. new Command\CheckPlatformReqsCommand(),
  11022. new Command\FundCommand(),
  11023. new Command\ReinstallCommand(),
  11024. new Command\BumpCommand(),
  11025. ]);
  11026. if (strpos(__FILE__, 'phar:') === 0 || '1' === Platform::getEnv('COMPOSER_TESTS_ARE_RUNNING')) {
  11027. $commands[] = new Command\SelfUpdateCommand();
  11028. }
  11029. return $commands;
  11030. }
  11031. public function getLongVersion(): string
  11032. {
  11033. $branchAliasString = '';
  11034. if (Composer::BRANCH_ALIAS_VERSION && Composer::BRANCH_ALIAS_VERSION !== '@package_branch_alias_version'.'@') {
  11035. $branchAliasString = sprintf(' (%s)', Composer::BRANCH_ALIAS_VERSION);
  11036. }
  11037. return sprintf(
  11038. '<info>%s</info> version <comment>%s%s</comment> %s',
  11039. $this->getName(),
  11040. $this->getVersion(),
  11041. $branchAliasString,
  11042. Composer::RELEASE_DATE
  11043. );
  11044. }
  11045. protected function getDefaultInputDefinition(): InputDefinition
  11046. {
  11047. $definition = parent::getDefaultInputDefinition();
  11048. $definition->addOption(new InputOption('--profile', null, InputOption::VALUE_NONE, 'Display timing and memory usage information'));
  11049. $definition->addOption(new InputOption('--no-plugins', null, InputOption::VALUE_NONE, 'Whether to disable plugins.'));
  11050. $definition->addOption(new InputOption('--no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'));
  11051. $definition->addOption(new InputOption('--working-dir', '-d', InputOption::VALUE_REQUIRED, 'If specified, use the given directory as working directory.'));
  11052. $definition->addOption(new InputOption('--no-cache', null, InputOption::VALUE_NONE, 'Prevent use of the cache'));
  11053. return $definition;
  11054. }
  11055. private function getPluginCommands(): array
  11056. {
  11057. $commands = [];
  11058. $composer = $this->getComposer(false, false);
  11059. if (null === $composer) {
  11060. $composer = Factory::createGlobal($this->io, $this->disablePluginsByDefault, $this->disableScriptsByDefault);
  11061. }
  11062. if (null !== $composer) {
  11063. $pm = $composer->getPluginManager();
  11064. foreach ($pm->getPluginCapabilities('Composer\Plugin\Capability\CommandProvider', ['composer' => $composer, 'io' => $this->io]) as $capability) {
  11065. $newCommands = $capability->getCommands();
  11066. if (!is_array($newCommands)) {
  11067. throw new \UnexpectedValueException('Plugin capability '.get_class($capability).' failed to return an array from getCommands');
  11068. }
  11069. foreach ($newCommands as $command) {
  11070. if (!$command instanceof Command\BaseCommand) {
  11071. throw new \UnexpectedValueException('Plugin capability '.get_class($capability).' returned an invalid value, we expected an array of Composer\Command\BaseCommand objects');
  11072. }
  11073. }
  11074. $commands = array_merge($commands, $newCommands);
  11075. }
  11076. }
  11077. return $commands;
  11078. }
  11079. public function getInitialWorkingDirectory()
  11080. {
  11081. return $this->initialWorkingDirectory;
  11082. }
  11083. private function getUseParentDirConfigValue()
  11084. {
  11085. $config = Factory::createConfig($this->io);
  11086. return $config->get('use-parent-dir');
  11087. }
  11088. }
  11089. <?php declare(strict_types=1);
  11090. namespace Composer\Console;
  11091. use Composer\IO\IOInterface;
  11092. use Composer\Util\Platform;
  11093. final class GithubActionError
  11094. {
  11095. protected $io;
  11096. public function __construct(IOInterface $io)
  11097. {
  11098. $this->io = $io;
  11099. }
  11100. public function emit(string $message, ?string $file = null, ?int $line = null): void
  11101. {
  11102. if (Platform::getEnv('GITHUB_ACTIONS') && !Platform::getEnv('COMPOSER_TESTS_ARE_RUNNING')) {
  11103. $message = $this->escapeData($message);
  11104. if ($file && $line) {
  11105. $file = $this->escapeProperty($file);
  11106. $this->io->write("::error file=". $file .",line=". $line ."::". $message);
  11107. } elseif ($file) {
  11108. $file = $this->escapeProperty($file);
  11109. $this->io->write("::error file=". $file ."::". $message);
  11110. } else {
  11111. $this->io->write("::error ::". $message);
  11112. }
  11113. }
  11114. }
  11115. private function escapeData(string $data): string
  11116. {
  11117. $data = str_replace("%", '%25', $data);
  11118. $data = str_replace("\r", '%0D', $data);
  11119. $data = str_replace("\n", '%0A', $data);
  11120. return $data;
  11121. }
  11122. private function escapeProperty(string $property): string
  11123. {
  11124. $property = str_replace("%", '%25', $property);
  11125. $property = str_replace("\r", '%0D', $property);
  11126. $property = str_replace("\n", '%0A', $property);
  11127. $property = str_replace(":", '%3A', $property);
  11128. $property = str_replace(",", '%2C', $property);
  11129. return $property;
  11130. }
  11131. }
  11132. <?php declare(strict_types=1);
  11133. namespace Composer\Console;
  11134. use Closure;
  11135. use Composer\Pcre\Preg;
  11136. use Symfony\Component\Console\Formatter\OutputFormatter;
  11137. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  11138. class HtmlOutputFormatter extends OutputFormatter
  11139. {
  11140. private static $availableForegroundColors = [
  11141. 30 => 'black',
  11142. 31 => 'red',
  11143. 32 => 'green',
  11144. 33 => 'yellow',
  11145. 34 => 'blue',
  11146. 35 => 'magenta',
  11147. 36 => 'cyan',
  11148. 37 => 'white',
  11149. ];
  11150. private static $availableBackgroundColors = [
  11151. 40 => 'black',
  11152. 41 => 'red',
  11153. 42 => 'green',
  11154. 43 => 'yellow',
  11155. 44 => 'blue',
  11156. 45 => 'magenta',
  11157. 46 => 'cyan',
  11158. 47 => 'white',
  11159. ];
  11160. private static $availableOptions = [
  11161. 1 => 'bold',
  11162. 4 => 'underscore',
  11163. ];
  11164. public function __construct(array $styles = [])
  11165. {
  11166. parent::__construct(true, $styles);
  11167. }
  11168. public function format(?string $message): ?string
  11169. {
  11170. $formatted = parent::format($message);
  11171. if ($formatted === null) {
  11172. return null;
  11173. }
  11174. $clearEscapeCodes = '(?:39|49|0|22|24|25|27|28)';
  11175. return Preg::replaceCallback("{\033\[([0-9;]+)m(.*?)\033\[(?:".$clearEscapeCodes.";)*?".$clearEscapeCodes."m}s", Closure::fromCallable([$this, 'formatHtml']), $formatted);
  11176. }
  11177. private function formatHtml(array $matches): string
  11178. {
  11179. assert(is_string($matches[1]));
  11180. $out = '<span style="';
  11181. foreach (explode(';', $matches[1]) as $code) {
  11182. if (isset(self::$availableForegroundColors[(int) $code])) {
  11183. $out .= 'color:'.self::$availableForegroundColors[(int) $code].';';
  11184. } elseif (isset(self::$availableBackgroundColors[(int) $code])) {
  11185. $out .= 'background-color:'.self::$availableBackgroundColors[(int) $code].';';
  11186. } elseif (isset(self::$availableOptions[(int) $code])) {
  11187. switch (self::$availableOptions[(int) $code]) {
  11188. case 'bold':
  11189. $out .= 'font-weight:bold;';
  11190. break;
  11191. case 'underscore':
  11192. $out .= 'text-decoration:underline;';
  11193. break;
  11194. }
  11195. }
  11196. }
  11197. return $out.'">'.$matches[2].'</span>';
  11198. }
  11199. }
  11200. <?php declare(strict_types=1);
  11201. namespace Composer\Console\Input;
  11202. use Symfony\Component\Console\Completion\CompletionInput;
  11203. use Symfony\Component\Console\Completion\CompletionSuggestions;
  11204. use Symfony\Component\Console\Completion\Suggestion;
  11205. use Symfony\Component\Console\Exception\InvalidArgumentException;
  11206. use Symfony\Component\Console\Exception\LogicException;
  11207. use Symfony\Component\Console\Input\InputArgument as BaseInputArgument;
  11208. class InputArgument extends BaseInputArgument
  11209. {
  11210. private $suggestedValues;
  11211. public function __construct(string $name, ?int $mode = null, string $description = '', $default = null, $suggestedValues = [])
  11212. {
  11213. parent::__construct($name, $mode, $description, $default);
  11214. $this->suggestedValues = $suggestedValues;
  11215. }
  11216. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  11217. {
  11218. $values = $this->suggestedValues;
  11219. if ($values instanceof \Closure && !\is_array($values = $values($input, $suggestions))) {
  11220. throw new LogicException(sprintf('Closure for option "%s" must return an array. Got "%s".', $this->getName(), get_debug_type($values)));
  11221. }
  11222. if ([] !== $values) {
  11223. $suggestions->suggestValues($values);
  11224. }
  11225. }
  11226. }
  11227. <?php declare(strict_types=1);
  11228. namespace Composer\Console\Input;
  11229. use Symfony\Component\Console\Completion\CompletionInput;
  11230. use Symfony\Component\Console\Completion\CompletionSuggestions;
  11231. use Symfony\Component\Console\Completion\Suggestion;
  11232. use Symfony\Component\Console\Exception\InvalidArgumentException;
  11233. use Symfony\Component\Console\Exception\LogicException;
  11234. use Symfony\Component\Console\Input\InputOption as BaseInputOption;
  11235. class InputOption extends BaseInputOption
  11236. {
  11237. private $suggestedValues;
  11238. public function __construct(string $name, $shortcut = null, ?int $mode = null, string $description = '', $default = null, $suggestedValues = [])
  11239. {
  11240. parent::__construct($name, $shortcut, $mode, $description, $default);
  11241. $this->suggestedValues = $suggestedValues;
  11242. if ([] !== $suggestedValues && !$this->acceptValue()) {
  11243. throw new LogicException('Cannot set suggested values if the option does not accept a value.');
  11244. }
  11245. }
  11246. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  11247. {
  11248. $values = $this->suggestedValues;
  11249. if ($values instanceof \Closure && !\is_array($values = $values($input, $suggestions))) {
  11250. throw new LogicException(sprintf('Closure for argument "%s" must return an array. Got "%s".', $this->getName(), get_debug_type($values)));
  11251. }
  11252. if ([] !== $values) {
  11253. $suggestions->suggestValues($values);
  11254. }
  11255. }
  11256. }
  11257. <?php declare(strict_types=1);
  11258. namespace Composer\DependencyResolver;
  11259. class Decisions implements \Iterator, \Countable
  11260. {
  11261. public const DECISION_LITERAL = 0;
  11262. public const DECISION_REASON = 1;
  11263. protected $pool;
  11264. protected $decisionMap;
  11265. protected $decisionQueue = [];
  11266. public function __construct(Pool $pool)
  11267. {
  11268. $this->pool = $pool;
  11269. $this->decisionMap = [];
  11270. }
  11271. public function decide(int $literal, int $level, Rule $why): void
  11272. {
  11273. $this->addDecision($literal, $level);
  11274. $this->decisionQueue[] = [
  11275. self::DECISION_LITERAL => $literal,
  11276. self::DECISION_REASON => $why,
  11277. ];
  11278. }
  11279. public function satisfy(int $literal): bool
  11280. {
  11281. $packageId = abs($literal);
  11282. return (
  11283. $literal > 0 && isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0 ||
  11284. $literal < 0 && isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] < 0
  11285. );
  11286. }
  11287. public function conflict(int $literal): bool
  11288. {
  11289. $packageId = abs($literal);
  11290. return (
  11291. (isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0 && $literal < 0) ||
  11292. (isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] < 0 && $literal > 0)
  11293. );
  11294. }
  11295. public function decided(int $literalOrPackageId): bool
  11296. {
  11297. return !empty($this->decisionMap[abs($literalOrPackageId)]);
  11298. }
  11299. public function undecided(int $literalOrPackageId): bool
  11300. {
  11301. return empty($this->decisionMap[abs($literalOrPackageId)]);
  11302. }
  11303. public function decidedInstall(int $literalOrPackageId): bool
  11304. {
  11305. $packageId = abs($literalOrPackageId);
  11306. return isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0;
  11307. }
  11308. public function decisionLevel(int $literalOrPackageId): int
  11309. {
  11310. $packageId = abs($literalOrPackageId);
  11311. if (isset($this->decisionMap[$packageId])) {
  11312. return abs($this->decisionMap[$packageId]);
  11313. }
  11314. return 0;
  11315. }
  11316. public function decisionRule(int $literalOrPackageId): ?Rule
  11317. {
  11318. $packageId = abs($literalOrPackageId);
  11319. foreach ($this->decisionQueue as $decision) {
  11320. if ($packageId === abs($decision[self::DECISION_LITERAL])) {
  11321. return $decision[self::DECISION_REASON];
  11322. }
  11323. }
  11324. return null;
  11325. }
  11326. public function atOffset(int $queueOffset): array
  11327. {
  11328. return $this->decisionQueue[$queueOffset];
  11329. }
  11330. public function validOffset(int $queueOffset): bool
  11331. {
  11332. return $queueOffset >= 0 && $queueOffset < \count($this->decisionQueue);
  11333. }
  11334. public function lastReason(): Rule
  11335. {
  11336. return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_REASON];
  11337. }
  11338. public function lastLiteral(): int
  11339. {
  11340. return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_LITERAL];
  11341. }
  11342. public function reset(): void
  11343. {
  11344. while ($decision = array_pop($this->decisionQueue)) {
  11345. $this->decisionMap[abs($decision[self::DECISION_LITERAL])] = 0;
  11346. }
  11347. }
  11348. public function resetToOffset(int $offset): void
  11349. {
  11350. while (\count($this->decisionQueue) > $offset + 1) {
  11351. $decision = array_pop($this->decisionQueue);
  11352. $this->decisionMap[abs($decision[self::DECISION_LITERAL])] = 0;
  11353. }
  11354. }
  11355. public function revertLast(): void
  11356. {
  11357. $this->decisionMap[abs($this->lastLiteral())] = 0;
  11358. array_pop($this->decisionQueue);
  11359. }
  11360. public function count(): int
  11361. {
  11362. return \count($this->decisionQueue);
  11363. }
  11364. public function rewind(): void
  11365. {
  11366. end($this->decisionQueue);
  11367. }
  11368. #[\ReturnTypeWillChange]
  11369. public function current()
  11370. {
  11371. return current($this->decisionQueue);
  11372. }
  11373. public function key(): ?int
  11374. {
  11375. return key($this->decisionQueue);
  11376. }
  11377. public function next(): void
  11378. {
  11379. prev($this->decisionQueue);
  11380. }
  11381. public function valid(): bool
  11382. {
  11383. return false !== current($this->decisionQueue);
  11384. }
  11385. public function isEmpty(): bool
  11386. {
  11387. return \count($this->decisionQueue) === 0;
  11388. }
  11389. protected function addDecision(int $literal, int $level): void
  11390. {
  11391. $packageId = abs($literal);
  11392. $previousDecision = $this->decisionMap[$packageId] ?? 0;
  11393. if ($previousDecision !== 0) {
  11394. $literalString = $this->pool->literalToPrettyString($literal, []);
  11395. $package = $this->pool->literalToPackage($literal);
  11396. throw new SolverBugException(
  11397. "Trying to decide $literalString on level $level, even though $package was previously decided as ".$previousDecision."."
  11398. );
  11399. }
  11400. if ($literal > 0) {
  11401. $this->decisionMap[$packageId] = $level;
  11402. } else {
  11403. $this->decisionMap[$packageId] = -$level;
  11404. }
  11405. }
  11406. public function toString(?Pool $pool = null): string
  11407. {
  11408. $decisionMap = $this->decisionMap;
  11409. ksort($decisionMap);
  11410. $str = '[';
  11411. foreach ($decisionMap as $packageId => $level) {
  11412. $str .= (($pool) ? $pool->literalToPackage($packageId) : $packageId).':'.$level.',';
  11413. }
  11414. $str .= ']';
  11415. return $str;
  11416. }
  11417. public function __toString(): string
  11418. {
  11419. return $this->toString();
  11420. }
  11421. }
  11422. <?php declare(strict_types=1);
  11423. namespace Composer\DependencyResolver;
  11424. use Composer\Package\AliasPackage;
  11425. use Composer\Package\BasePackage;
  11426. use Composer\Package\PackageInterface;
  11427. use Composer\Semver\CompilingMatcher;
  11428. use Composer\Semver\Constraint\Constraint;
  11429. class DefaultPolicy implements PolicyInterface
  11430. {
  11431. private $preferStable;
  11432. private $preferLowest;
  11433. private $preferredPackageResultCachePerPool;
  11434. private $sortingCachePerPool;
  11435. public function __construct(bool $preferStable = false, bool $preferLowest = false)
  11436. {
  11437. $this->preferStable = $preferStable;
  11438. $this->preferLowest = $preferLowest;
  11439. }
  11440. public function versionCompare(PackageInterface $a, PackageInterface $b, string $operator): bool
  11441. {
  11442. if ($this->preferStable && ($stabA = $a->getStability()) !== ($stabB = $b->getStability())) {
  11443. return BasePackage::$stabilities[$stabA] < BasePackage::$stabilities[$stabB];
  11444. }
  11445. if (strpos($a->getVersion(), 'dev-') === 0 || strpos($b->getVersion(), 'dev-') === 0) {
  11446. $constraint = new Constraint($operator, $b->getVersion());
  11447. $version = new Constraint('==', $a->getVersion());
  11448. return $constraint->matchSpecific($version, true);
  11449. }
  11450. return CompilingMatcher::match(new Constraint($operator, $b->getVersion()), Constraint::OP_EQ, $a->getVersion());
  11451. }
  11452. public function selectPreferredPackages(Pool $pool, array $literals, ?string $requiredPackage = null): array
  11453. {
  11454. sort($literals);
  11455. $resultCacheKey = implode(',', $literals).$requiredPackage;
  11456. $poolId = spl_object_id($pool);
  11457. if (isset($this->preferredPackageResultCachePerPool[$poolId][$resultCacheKey])) {
  11458. return $this->preferredPackageResultCachePerPool[$poolId][$resultCacheKey];
  11459. }
  11460. $packages = $this->groupLiteralsByName($pool, $literals);
  11461. foreach ($packages as &$nameLiterals) {
  11462. usort($nameLiterals, function ($a, $b) use ($pool, $requiredPackage, $poolId): int {
  11463. $cacheKey = 'i'.$a.'.'.$b.$requiredPackage;
  11464. if (isset($this->sortingCachePerPool[$poolId][$cacheKey])) {
  11465. return $this->sortingCachePerPool[$poolId][$cacheKey];
  11466. }
  11467. return $this->sortingCachePerPool[$poolId][$cacheKey] = $this->compareByPriority($pool, $pool->literalToPackage($a), $pool->literalToPackage($b), $requiredPackage, true);
  11468. });
  11469. }
  11470. foreach ($packages as &$sortedLiterals) {
  11471. $sortedLiterals = $this->pruneToBestVersion($pool, $sortedLiterals);
  11472. $sortedLiterals = $this->pruneRemoteAliases($pool, $sortedLiterals);
  11473. }
  11474. $selected = array_merge(...array_values($packages));
  11475. usort($selected, function ($a, $b) use ($pool, $requiredPackage, $poolId): int {
  11476. $cacheKey = $a.'.'.$b.$requiredPackage;
  11477. if (isset($this->sortingCachePerPool[$poolId][$cacheKey])) {
  11478. return $this->sortingCachePerPool[$poolId][$cacheKey];
  11479. }
  11480. return $this->sortingCachePerPool[$poolId][$cacheKey] = $this->compareByPriority($pool, $pool->literalToPackage($a), $pool->literalToPackage($b), $requiredPackage);
  11481. });
  11482. return $this->preferredPackageResultCachePerPool[$poolId][$resultCacheKey] = $selected;
  11483. }
  11484. protected function groupLiteralsByName(Pool $pool, array $literals): array
  11485. {
  11486. $packages = [];
  11487. foreach ($literals as $literal) {
  11488. $packageName = $pool->literalToPackage($literal)->getName();
  11489. if (!isset($packages[$packageName])) {
  11490. $packages[$packageName] = [];
  11491. }
  11492. $packages[$packageName][] = $literal;
  11493. }
  11494. return $packages;
  11495. }
  11496. public function compareByPriority(Pool $pool, BasePackage $a, BasePackage $b, ?string $requiredPackage = null, bool $ignoreReplace = false): int
  11497. {
  11498. if ($a->getName() === $b->getName()) {
  11499. $aAliased = $a instanceof AliasPackage;
  11500. $bAliased = $b instanceof AliasPackage;
  11501. if ($aAliased && !$bAliased) {
  11502. return -1;
  11503. }
  11504. if (!$aAliased && $bAliased) {
  11505. return 1;
  11506. }
  11507. }
  11508. if (!$ignoreReplace) {
  11509. if ($this->replaces($a, $b)) {
  11510. return 1;
  11511. }
  11512. if ($this->replaces($b, $a)) {
  11513. return -1;
  11514. }
  11515. if ($requiredPackage && false !== ($pos = strpos($requiredPackage, '/'))) {
  11516. $requiredVendor = substr($requiredPackage, 0, $pos);
  11517. $aIsSameVendor = strpos($a->getName(), $requiredVendor) === 0;
  11518. $bIsSameVendor = strpos($b->getName(), $requiredVendor) === 0;
  11519. if ($bIsSameVendor !== $aIsSameVendor) {
  11520. return $aIsSameVendor ? -1 : 1;
  11521. }
  11522. }
  11523. }
  11524. if ($a->id === $b->id) {
  11525. return 0;
  11526. }
  11527. return ($a->id < $b->id) ? -1 : 1;
  11528. }
  11529. protected function replaces(BasePackage $source, BasePackage $target): bool
  11530. {
  11531. foreach ($source->getReplaces() as $link) {
  11532. if ($link->getTarget() === $target->getName()
  11533. ) {
  11534. return true;
  11535. }
  11536. }
  11537. return false;
  11538. }
  11539. protected function pruneToBestVersion(Pool $pool, array $literals): array
  11540. {
  11541. $operator = $this->preferLowest ? '<' : '>';
  11542. $bestLiterals = [$literals[0]];
  11543. $bestPackage = $pool->literalToPackage($literals[0]);
  11544. foreach ($literals as $i => $literal) {
  11545. if (0 === $i) {
  11546. continue;
  11547. }
  11548. $package = $pool->literalToPackage($literal);
  11549. if ($this->versionCompare($package, $bestPackage, $operator)) {
  11550. $bestPackage = $package;
  11551. $bestLiterals = [$literal];
  11552. } elseif ($this->versionCompare($package, $bestPackage, '==')) {
  11553. $bestLiterals[] = $literal;
  11554. }
  11555. }
  11556. return $bestLiterals;
  11557. }
  11558. protected function pruneRemoteAliases(Pool $pool, array $literals): array
  11559. {
  11560. $hasLocalAlias = false;
  11561. foreach ($literals as $literal) {
  11562. $package = $pool->literalToPackage($literal);
  11563. if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
  11564. $hasLocalAlias = true;
  11565. break;
  11566. }
  11567. }
  11568. if (!$hasLocalAlias) {
  11569. return $literals;
  11570. }
  11571. $selected = [];
  11572. foreach ($literals as $literal) {
  11573. $package = $pool->literalToPackage($literal);
  11574. if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
  11575. $selected[] = $literal;
  11576. }
  11577. }
  11578. return $selected;
  11579. }
  11580. }
  11581. <?php declare(strict_types=1);
  11582. namespace Composer\DependencyResolver;
  11583. class GenericRule extends Rule
  11584. {
  11585. protected $literals;
  11586. public function __construct(array $literals, $reason, $reasonData)
  11587. {
  11588. parent::__construct($reason, $reasonData);
  11589. sort($literals);
  11590. $this->literals = $literals;
  11591. }
  11592. public function getLiterals(): array
  11593. {
  11594. return $this->literals;
  11595. }
  11596. public function getHash()
  11597. {
  11598. $data = unpack('ihash', md5(implode(',', $this->literals), true));
  11599. return $data['hash'];
  11600. }
  11601. public function equals(Rule $rule): bool
  11602. {
  11603. return $this->literals === $rule->getLiterals();
  11604. }
  11605. public function isAssertion(): bool
  11606. {
  11607. return 1 === \count($this->literals);
  11608. }
  11609. public function __toString(): string
  11610. {
  11611. $result = $this->isDisabled() ? 'disabled(' : '(';
  11612. foreach ($this->literals as $i => $literal) {
  11613. if ($i !== 0) {
  11614. $result .= '|';
  11615. }
  11616. $result .= $literal;
  11617. }
  11618. $result .= ')';
  11619. return $result;
  11620. }
  11621. }
  11622. <?php declare(strict_types=1);
  11623. namespace Composer\DependencyResolver;
  11624. use Composer\Repository\InstalledRepositoryInterface;
  11625. use Composer\Repository\RepositoryInterface;
  11626. class LocalRepoTransaction extends Transaction
  11627. {
  11628. public function __construct(RepositoryInterface $lockedRepository, InstalledRepositoryInterface $localRepository)
  11629. {
  11630. parent::__construct(
  11631. $localRepository->getPackages(),
  11632. $lockedRepository->getPackages()
  11633. );
  11634. }
  11635. }
  11636. <?php declare(strict_types=1);
  11637. namespace Composer\DependencyResolver;
  11638. use Composer\Package\AliasPackage;
  11639. use Composer\Package\BasePackage;
  11640. use Composer\Package\Package;
  11641. class LockTransaction extends Transaction
  11642. {
  11643. protected $presentMap;
  11644. protected $unlockableMap;
  11645. protected $resultPackages;
  11646. public function __construct(Pool $pool, array $presentMap, array $unlockableMap, Decisions $decisions)
  11647. {
  11648. $this->presentMap = $presentMap;
  11649. $this->unlockableMap = $unlockableMap;
  11650. $this->setResultPackages($pool, $decisions);
  11651. parent::__construct($this->presentMap, $this->resultPackages['all']);
  11652. }
  11653. public function setResultPackages(Pool $pool, Decisions $decisions): void
  11654. {
  11655. $this->resultPackages = ['all' => [], 'non-dev' => [], 'dev' => []];
  11656. foreach ($decisions as $i => $decision) {
  11657. $literal = $decision[Decisions::DECISION_LITERAL];
  11658. if ($literal > 0) {
  11659. $package = $pool->literalToPackage($literal);
  11660. $this->resultPackages['all'][] = $package;
  11661. if (!isset($this->unlockableMap[$package->id])) {
  11662. $this->resultPackages['non-dev'][] = $package;
  11663. }
  11664. }
  11665. }
  11666. }
  11667. public function setNonDevPackages(LockTransaction $extractionResult): void
  11668. {
  11669. $packages = $extractionResult->getNewLockPackages(false);
  11670. $this->resultPackages['dev'] = $this->resultPackages['non-dev'];
  11671. $this->resultPackages['non-dev'] = [];
  11672. foreach ($packages as $package) {
  11673. foreach ($this->resultPackages['dev'] as $i => $resultPackage) {
  11674. if ($package->getName() === $resultPackage->getName()) {
  11675. $this->resultPackages['non-dev'][] = $resultPackage;
  11676. unset($this->resultPackages['dev'][$i]);
  11677. }
  11678. }
  11679. }
  11680. }
  11681. public function getNewLockPackages(bool $devMode, bool $updateMirrors = false): array
  11682. {
  11683. $packages = [];
  11684. foreach ($this->resultPackages[$devMode ? 'dev' : 'non-dev'] as $package) {
  11685. if (!$package instanceof AliasPackage) {
  11686. if ($updateMirrors && !isset($this->presentMap[spl_object_hash($package)])) {
  11687. foreach ($this->presentMap as $presentPackage) {
  11688. if ($package->getName() === $presentPackage->getName() && $package->getVersion() === $presentPackage->getVersion()) {
  11689. if ($presentPackage->getSourceReference() && $presentPackage->getSourceType() === $package->getSourceType()) {
  11690. $package->setSourceDistReferences($presentPackage->getSourceReference());
  11691. }
  11692. if ($presentPackage->getReleaseDate() !== null && $package instanceof Package) {
  11693. $package->setReleaseDate($presentPackage->getReleaseDate());
  11694. }
  11695. }
  11696. }
  11697. }
  11698. $packages[] = $package;
  11699. }
  11700. }
  11701. return $packages;
  11702. }
  11703. public function getAliases(array $aliases): array
  11704. {
  11705. $usedAliases = [];
  11706. foreach ($this->resultPackages['all'] as $package) {
  11707. if ($package instanceof AliasPackage) {
  11708. foreach ($aliases as $index => $alias) {
  11709. if ($alias['package'] === $package->getName()) {
  11710. $usedAliases[] = $alias;
  11711. unset($aliases[$index]);
  11712. }
  11713. }
  11714. }
  11715. }
  11716. usort($usedAliases, static function ($a, $b): int {
  11717. return strcmp($a['package'], $b['package']);
  11718. });
  11719. return $usedAliases;
  11720. }
  11721. }
  11722. <?php declare(strict_types=1);
  11723. namespace Composer\DependencyResolver;
  11724. class MultiConflictRule extends Rule
  11725. {
  11726. protected $literals;
  11727. public function __construct(array $literals, $reason, $reasonData)
  11728. {
  11729. parent::__construct($reason, $reasonData);
  11730. if (\count($literals) < 3) {
  11731. throw new \RuntimeException("multi conflict rule requires at least 3 literals");
  11732. }
  11733. sort($literals);
  11734. $this->literals = $literals;
  11735. }
  11736. public function getLiterals(): array
  11737. {
  11738. return $this->literals;
  11739. }
  11740. public function getHash()
  11741. {
  11742. $data = unpack('ihash', md5('c:'.implode(',', $this->literals), true));
  11743. return $data['hash'];
  11744. }
  11745. public function equals(Rule $rule): bool
  11746. {
  11747. if ($rule instanceof MultiConflictRule) {
  11748. return $this->literals === $rule->getLiterals();
  11749. }
  11750. return false;
  11751. }
  11752. public function isAssertion(): bool
  11753. {
  11754. return false;
  11755. }
  11756. public function disable(): void
  11757. {
  11758. 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.");
  11759. }
  11760. public function __toString(): string
  11761. {
  11762. $result = $this->isDisabled() ? 'disabled(multi(' : '(multi(';
  11763. foreach ($this->literals as $i => $literal) {
  11764. if ($i !== 0) {
  11765. $result .= '|';
  11766. }
  11767. $result .= $literal;
  11768. }
  11769. $result .= '))';
  11770. return $result;
  11771. }
  11772. }
  11773. <?php declare(strict_types=1);
  11774. namespace Composer\DependencyResolver\Operation;
  11775. use Composer\Package\PackageInterface;
  11776. class InstallOperation extends SolverOperation implements OperationInterface
  11777. {
  11778. protected const TYPE = 'install';
  11779. protected $package;
  11780. public function __construct(PackageInterface $package)
  11781. {
  11782. $this->package = $package;
  11783. }
  11784. public function getPackage(): PackageInterface
  11785. {
  11786. return $this->package;
  11787. }
  11788. public function show($lock): string
  11789. {
  11790. return self::format($this->package, $lock);
  11791. }
  11792. public static function format(PackageInterface $package, bool $lock = false): string
  11793. {
  11794. return ($lock ? 'Locking ' : 'Installing ').'<info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
  11795. }
  11796. }
  11797. <?php declare(strict_types=1);
  11798. namespace Composer\DependencyResolver\Operation;
  11799. use Composer\Package\AliasPackage;
  11800. class MarkAliasInstalledOperation extends SolverOperation implements OperationInterface
  11801. {
  11802. protected const TYPE = 'markAliasInstalled';
  11803. protected $package;
  11804. public function __construct(AliasPackage $package)
  11805. {
  11806. $this->package = $package;
  11807. }
  11808. public function getPackage(): AliasPackage
  11809. {
  11810. return $this->package;
  11811. }
  11812. public function show($lock): string
  11813. {
  11814. 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>)';
  11815. }
  11816. }
  11817. <?php declare(strict_types=1);
  11818. namespace Composer\DependencyResolver\Operation;
  11819. use Composer\Package\AliasPackage;
  11820. class MarkAliasUninstalledOperation extends SolverOperation implements OperationInterface
  11821. {
  11822. protected const TYPE = 'markAliasUninstalled';
  11823. protected $package;
  11824. public function __construct(AliasPackage $package)
  11825. {
  11826. $this->package = $package;
  11827. }
  11828. public function getPackage(): AliasPackage
  11829. {
  11830. return $this->package;
  11831. }
  11832. public function show($lock): string
  11833. {
  11834. 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>)';
  11835. }
  11836. }
  11837. <?php declare(strict_types=1);
  11838. namespace Composer\DependencyResolver\Operation;
  11839. interface OperationInterface
  11840. {
  11841. public function getOperationType();
  11842. public function show(bool $lock);
  11843. public function __toString();
  11844. }
  11845. <?php declare(strict_types=1);
  11846. namespace Composer\DependencyResolver\Operation;
  11847. abstract class SolverOperation implements OperationInterface
  11848. {
  11849. protected const TYPE = '';
  11850. public function getOperationType(): string
  11851. {
  11852. return static::TYPE;
  11853. }
  11854. public function __toString()
  11855. {
  11856. return $this->show(false);
  11857. }
  11858. }
  11859. <?php declare(strict_types=1);
  11860. namespace Composer\DependencyResolver\Operation;
  11861. use Composer\Package\PackageInterface;
  11862. class UninstallOperation extends SolverOperation implements OperationInterface
  11863. {
  11864. protected const TYPE = 'uninstall';
  11865. protected $package;
  11866. public function __construct(PackageInterface $package)
  11867. {
  11868. $this->package = $package;
  11869. }
  11870. public function getPackage(): PackageInterface
  11871. {
  11872. return $this->package;
  11873. }
  11874. public function show($lock): string
  11875. {
  11876. return self::format($this->package, $lock);
  11877. }
  11878. public static function format(PackageInterface $package, bool $lock = false): string
  11879. {
  11880. return 'Removing <info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
  11881. }
  11882. }
  11883. <?php declare(strict_types=1);
  11884. namespace Composer\DependencyResolver\Operation;
  11885. use Composer\Package\PackageInterface;
  11886. use Composer\Package\Version\VersionParser;
  11887. class UpdateOperation extends SolverOperation implements OperationInterface
  11888. {
  11889. protected const TYPE = 'update';
  11890. protected $initialPackage;
  11891. protected $targetPackage;
  11892. public function __construct(PackageInterface $initial, PackageInterface $target)
  11893. {
  11894. $this->initialPackage = $initial;
  11895. $this->targetPackage = $target;
  11896. }
  11897. public function getInitialPackage(): PackageInterface
  11898. {
  11899. return $this->initialPackage;
  11900. }
  11901. public function getTargetPackage(): PackageInterface
  11902. {
  11903. return $this->targetPackage;
  11904. }
  11905. public function show($lock): string
  11906. {
  11907. return self::format($this->initialPackage, $this->targetPackage, $lock);
  11908. }
  11909. public static function format(PackageInterface $initialPackage, PackageInterface $targetPackage, bool $lock = false): string
  11910. {
  11911. $fromVersion = $initialPackage->getFullPrettyVersion();
  11912. $toVersion = $targetPackage->getFullPrettyVersion();
  11913. if ($fromVersion === $toVersion && $initialPackage->getSourceReference() !== $targetPackage->getSourceReference()) {
  11914. $fromVersion = $initialPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_SOURCE_REF);
  11915. $toVersion = $targetPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_SOURCE_REF);
  11916. } elseif ($fromVersion === $toVersion && $initialPackage->getDistReference() !== $targetPackage->getDistReference()) {
  11917. $fromVersion = $initialPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_DIST_REF);
  11918. $toVersion = $targetPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_DIST_REF);
  11919. }
  11920. $actionName = VersionParser::isUpgrade($initialPackage->getVersion(), $targetPackage->getVersion()) ? 'Upgrading' : 'Downgrading';
  11921. return $actionName.' <info>'.$initialPackage->getPrettyName().'</info> (<comment>'.$fromVersion.'</comment> => <comment>'.$toVersion.'</comment>)';
  11922. }
  11923. }
  11924. <?php declare(strict_types=1);
  11925. namespace Composer\DependencyResolver;
  11926. use Composer\Package\PackageInterface;
  11927. use Composer\Semver\Constraint\Constraint;
  11928. interface PolicyInterface
  11929. {
  11930. public function versionCompare(PackageInterface $a, PackageInterface $b, string $operator): bool;
  11931. public function selectPreferredPackages(Pool $pool, array $literals, ?string $requiredPackage = null): array;
  11932. }
  11933. <?php declare(strict_types=1);
  11934. namespace Composer\DependencyResolver;
  11935. use Composer\Package\BasePackage;
  11936. use Composer\Package\Version\VersionParser;
  11937. use Composer\Semver\CompilingMatcher;
  11938. use Composer\Semver\Constraint\ConstraintInterface;
  11939. use Composer\Semver\Constraint\Constraint;
  11940. class Pool implements \Countable
  11941. {
  11942. protected $packages = [];
  11943. protected $packageByName = [];
  11944. protected $versionParser;
  11945. protected $providerCache = [];
  11946. protected $unacceptableFixedOrLockedPackages;
  11947. protected $removedVersions = [];
  11948. protected $removedVersionsByPackage = [];
  11949. public function __construct(array $packages = [], array $unacceptableFixedOrLockedPackages = [], array $removedVersions = [], array $removedVersionsByPackage = [])
  11950. {
  11951. $this->versionParser = new VersionParser;
  11952. $this->setPackages($packages);
  11953. $this->unacceptableFixedOrLockedPackages = $unacceptableFixedOrLockedPackages;
  11954. $this->removedVersions = $removedVersions;
  11955. $this->removedVersionsByPackage = $removedVersionsByPackage;
  11956. }
  11957. public function getRemovedVersions(string $name, ConstraintInterface $constraint): array
  11958. {
  11959. if (!isset($this->removedVersions[$name])) {
  11960. return [];
  11961. }
  11962. $result = [];
  11963. foreach ($this->removedVersions[$name] as $version => $prettyVersion) {
  11964. if ($constraint->matches(new Constraint('==', $version))) {
  11965. $result[$version] = $prettyVersion;
  11966. }
  11967. }
  11968. return $result;
  11969. }
  11970. public function getRemovedVersionsByPackage(string $objectHash): array
  11971. {
  11972. if (!isset($this->removedVersionsByPackage[$objectHash])) {
  11973. return [];
  11974. }
  11975. return $this->removedVersionsByPackage[$objectHash];
  11976. }
  11977. private function setPackages(array $packages): void
  11978. {
  11979. $id = 1;
  11980. foreach ($packages as $package) {
  11981. $this->packages[] = $package;
  11982. $package->id = $id++;
  11983. foreach ($package->getNames() as $provided) {
  11984. $this->packageByName[$provided][] = $package;
  11985. }
  11986. }
  11987. }
  11988. public function getPackages(): array
  11989. {
  11990. return $this->packages;
  11991. }
  11992. public function packageById(int $id): BasePackage
  11993. {
  11994. return $this->packages[$id - 1];
  11995. }
  11996. public function count(): int
  11997. {
  11998. return \count($this->packages);
  11999. }
  12000. public function whatProvides(string $name, ?ConstraintInterface $constraint = null): array
  12001. {
  12002. $key = (string) $constraint;
  12003. if (isset($this->providerCache[$name][$key])) {
  12004. return $this->providerCache[$name][$key];
  12005. }
  12006. return $this->providerCache[$name][$key] = $this->computeWhatProvides($name, $constraint);
  12007. }
  12008. private function computeWhatProvides(string $name, ?ConstraintInterface $constraint = null): array
  12009. {
  12010. if (!isset($this->packageByName[$name])) {
  12011. return [];
  12012. }
  12013. $matches = [];
  12014. foreach ($this->packageByName[$name] as $candidate) {
  12015. if ($this->match($candidate, $name, $constraint)) {
  12016. $matches[] = $candidate;
  12017. }
  12018. }
  12019. return $matches;
  12020. }
  12021. public function literalToPackage(int $literal): BasePackage
  12022. {
  12023. $packageId = abs($literal);
  12024. return $this->packageById($packageId);
  12025. }
  12026. public function literalToPrettyString(int $literal, array $installedMap): string
  12027. {
  12028. $package = $this->literalToPackage($literal);
  12029. if (isset($installedMap[$package->id])) {
  12030. $prefix = ($literal > 0 ? 'keep' : 'remove');
  12031. } else {
  12032. $prefix = ($literal > 0 ? 'install' : 'don\'t install');
  12033. }
  12034. return $prefix.' '.$package->getPrettyString();
  12035. }
  12036. public function match(BasePackage $candidate, string $name, ?ConstraintInterface $constraint = null): bool
  12037. {
  12038. $candidateName = $candidate->getName();
  12039. $candidateVersion = $candidate->getVersion();
  12040. if ($candidateName === $name) {
  12041. return $constraint === null || CompilingMatcher::match($constraint, Constraint::OP_EQ, $candidateVersion);
  12042. }
  12043. $provides = $candidate->getProvides();
  12044. $replaces = $candidate->getReplaces();
  12045. if (isset($replaces[0]) || isset($provides[0])) {
  12046. foreach ($provides as $link) {
  12047. if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
  12048. return true;
  12049. }
  12050. }
  12051. foreach ($replaces as $link) {
  12052. if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
  12053. return true;
  12054. }
  12055. }
  12056. return false;
  12057. }
  12058. if (isset($provides[$name]) && ($constraint === null || $constraint->matches($provides[$name]->getConstraint()))) {
  12059. return true;
  12060. }
  12061. if (isset($replaces[$name]) && ($constraint === null || $constraint->matches($replaces[$name]->getConstraint()))) {
  12062. return true;
  12063. }
  12064. return false;
  12065. }
  12066. public function isUnacceptableFixedOrLockedPackage(BasePackage $package): bool
  12067. {
  12068. return \in_array($package, $this->unacceptableFixedOrLockedPackages, true);
  12069. }
  12070. public function getUnacceptableFixedOrLockedPackages(): array
  12071. {
  12072. return $this->unacceptableFixedOrLockedPackages;
  12073. }
  12074. public function __toString(): string
  12075. {
  12076. $str = "Pool:\n";
  12077. foreach ($this->packages as $package) {
  12078. $str .= '- '.str_pad((string) $package->id, 6, ' ', STR_PAD_LEFT).': '.$package->getName()."\n";
  12079. }
  12080. return $str;
  12081. }
  12082. }
  12083. <?php declare(strict_types=1);
  12084. namespace Composer\DependencyResolver;
  12085. use Composer\EventDispatcher\EventDispatcher;
  12086. use Composer\IO\IOInterface;
  12087. use Composer\Package\AliasPackage;
  12088. use Composer\Package\BasePackage;
  12089. use Composer\Package\CompleteAliasPackage;
  12090. use Composer\Package\CompletePackage;
  12091. use Composer\Package\PackageInterface;
  12092. use Composer\Package\Version\StabilityFilter;
  12093. use Composer\Pcre\Preg;
  12094. use Composer\Plugin\PluginEvents;
  12095. use Composer\Plugin\PrePoolCreateEvent;
  12096. use Composer\Repository\PlatformRepository;
  12097. use Composer\Repository\RepositoryInterface;
  12098. use Composer\Repository\RootPackageRepository;
  12099. use Composer\Semver\CompilingMatcher;
  12100. use Composer\Semver\Constraint\Constraint;
  12101. use Composer\Semver\Constraint\ConstraintInterface;
  12102. use Composer\Semver\Constraint\MatchAllConstraint;
  12103. use Composer\Semver\Constraint\MultiConstraint;
  12104. use Composer\Semver\Intervals;
  12105. class PoolBuilder
  12106. {
  12107. private $acceptableStabilities;
  12108. private $stabilityFlags;
  12109. private $rootAliases;
  12110. private $rootReferences;
  12111. private $temporaryConstraints;
  12112. private $eventDispatcher;
  12113. private $poolOptimizer;
  12114. private $io;
  12115. private $aliasMap = [];
  12116. private $packagesToLoad = [];
  12117. private $loadedPackages = [];
  12118. private $loadedPerRepo = [];
  12119. private $packages = [];
  12120. private $unacceptableFixedOrLockedPackages = [];
  12121. private $updateAllowList = [];
  12122. private $skippedLoad = [];
  12123. private $restrictedPackagesList = null;
  12124. private $pathRepoUnlocked = [];
  12125. private $maxExtendedReqs = [];
  12126. private $updateAllowWarned = [];
  12127. private $indexCounter = 0;
  12128. public function __construct(array $acceptableStabilities, array $stabilityFlags, array $rootAliases, array $rootReferences, IOInterface $io, ?EventDispatcher $eventDispatcher = null, ?PoolOptimizer $poolOptimizer = null, array $temporaryConstraints = [])
  12129. {
  12130. $this->acceptableStabilities = $acceptableStabilities;
  12131. $this->stabilityFlags = $stabilityFlags;
  12132. $this->rootAliases = $rootAliases;
  12133. $this->rootReferences = $rootReferences;
  12134. $this->eventDispatcher = $eventDispatcher;
  12135. $this->poolOptimizer = $poolOptimizer;
  12136. $this->io = $io;
  12137. $this->temporaryConstraints = $temporaryConstraints;
  12138. }
  12139. public function buildPool(array $repositories, Request $request): Pool
  12140. {
  12141. $this->restrictedPackagesList = $request->getRestrictedPackages() !== null ? array_flip($request->getRestrictedPackages()) : null;
  12142. if ($request->getUpdateAllowList()) {
  12143. $this->updateAllowList = $request->getUpdateAllowList();
  12144. $this->warnAboutNonMatchingUpdateAllowList($request);
  12145. foreach ($request->getLockedRepository()->getPackages() as $lockedPackage) {
  12146. if (!$this->isUpdateAllowed($lockedPackage)) {
  12147. $this->skippedLoad[$lockedPackage->getName()][] = $lockedPackage;
  12148. foreach ($lockedPackage->getReplaces() as $link) {
  12149. $this->skippedLoad[$link->getTarget()][] = $lockedPackage;
  12150. }
  12151. if ($lockedPackage->getDistType() === 'path') {
  12152. $transportOptions = $lockedPackage->getTransportOptions();
  12153. if (!isset($transportOptions['symlink']) || $transportOptions['symlink'] !== false) {
  12154. $this->pathRepoUnlocked[$lockedPackage->getName()] = true;
  12155. continue;
  12156. }
  12157. }
  12158. $request->lockPackage($lockedPackage);
  12159. }
  12160. }
  12161. }
  12162. foreach ($request->getFixedOrLockedPackages() as $package) {
  12163. $this->loadedPackages[$package->getName()] = new MatchAllConstraint();
  12164. foreach ($package->getReplaces() as $link) {
  12165. $this->loadedPackages[$link->getTarget()] = new MatchAllConstraint();
  12166. }
  12167. if (
  12168. $package->getRepository() instanceof RootPackageRepository
  12169. || $package->getRepository() instanceof PlatformRepository
  12170. || StabilityFilter::isPackageAcceptable($this->acceptableStabilities, $this->stabilityFlags, $package->getNames(), $package->getStability())
  12171. ) {
  12172. $this->loadPackage($request, $repositories, $package, false);
  12173. } else {
  12174. $this->unacceptableFixedOrLockedPackages[] = $package;
  12175. }
  12176. }
  12177. foreach ($request->getRequires() as $packageName => $constraint) {
  12178. if (isset($this->loadedPackages[$packageName])) {
  12179. continue;
  12180. }
  12181. $this->packagesToLoad[$packageName] = $constraint;
  12182. $this->maxExtendedReqs[$packageName] = true;
  12183. }
  12184. foreach ($this->packagesToLoad as $name => $constraint) {
  12185. if (isset($this->loadedPackages[$name])) {
  12186. unset($this->packagesToLoad[$name]);
  12187. }
  12188. }
  12189. while (!empty($this->packagesToLoad)) {
  12190. $this->loadPackagesMarkedForLoading($request, $repositories);
  12191. }
  12192. if (\count($this->temporaryConstraints) > 0) {
  12193. foreach ($this->packages as $i => $package) {
  12194. if (!isset($this->temporaryConstraints[$package->getName()]) || $package instanceof AliasPackage) {
  12195. continue;
  12196. }
  12197. $constraint = $this->temporaryConstraints[$package->getName()];
  12198. $packageAndAliases = [$i => $package];
  12199. if (isset($this->aliasMap[spl_object_hash($package)])) {
  12200. $packageAndAliases += $this->aliasMap[spl_object_hash($package)];
  12201. }
  12202. $found = false;
  12203. foreach ($packageAndAliases as $packageOrAlias) {
  12204. if (CompilingMatcher::match($constraint, Constraint::OP_EQ, $packageOrAlias->getVersion())) {
  12205. $found = true;
  12206. }
  12207. }
  12208. if (!$found) {
  12209. foreach ($packageAndAliases as $index => $packageOrAlias) {
  12210. unset($this->packages[$index]);
  12211. }
  12212. }
  12213. }
  12214. }
  12215. if ($this->eventDispatcher) {
  12216. $prePoolCreateEvent = new PrePoolCreateEvent(
  12217. PluginEvents::PRE_POOL_CREATE,
  12218. $repositories,
  12219. $request,
  12220. $this->acceptableStabilities,
  12221. $this->stabilityFlags,
  12222. $this->rootAliases,
  12223. $this->rootReferences,
  12224. $this->packages,
  12225. $this->unacceptableFixedOrLockedPackages
  12226. );
  12227. $this->eventDispatcher->dispatch($prePoolCreateEvent->getName(), $prePoolCreateEvent);
  12228. $this->packages = $prePoolCreateEvent->getPackages();
  12229. $this->unacceptableFixedOrLockedPackages = $prePoolCreateEvent->getUnacceptableFixedPackages();
  12230. }
  12231. $pool = new Pool($this->packages, $this->unacceptableFixedOrLockedPackages);
  12232. $this->aliasMap = [];
  12233. $this->packagesToLoad = [];
  12234. $this->loadedPackages = [];
  12235. $this->loadedPerRepo = [];
  12236. $this->packages = [];
  12237. $this->unacceptableFixedOrLockedPackages = [];
  12238. $this->maxExtendedReqs = [];
  12239. $this->skippedLoad = [];
  12240. $this->indexCounter = 0;
  12241. $this->io->debug('Built pool.');
  12242. $pool = $this->runOptimizer($request, $pool);
  12243. Intervals::clear();
  12244. return $pool;
  12245. }
  12246. private function markPackageNameForLoading(Request $request, string $name, ConstraintInterface $constraint): void
  12247. {
  12248. if (PlatformRepository::isPlatformPackage($name)) {
  12249. return;
  12250. }
  12251. if (isset($this->maxExtendedReqs[$name])) {
  12252. return;
  12253. }
  12254. $rootRequires = $request->getRequires();
  12255. if (isset($rootRequires[$name]) && !Intervals::isSubsetOf($constraint, $rootRequires[$name])) {
  12256. $constraint = $rootRequires[$name];
  12257. }
  12258. if (!isset($this->loadedPackages[$name])) {
  12259. if (isset($this->packagesToLoad[$name])) {
  12260. if (Intervals::isSubsetOf($constraint, $this->packagesToLoad[$name])) {
  12261. return;
  12262. }
  12263. $constraint = Intervals::compactConstraint(MultiConstraint::create([$this->packagesToLoad[$name], $constraint], false));
  12264. }
  12265. $this->packagesToLoad[$name] = $constraint;
  12266. return;
  12267. }
  12268. if (Intervals::isSubsetOf($constraint, $this->loadedPackages[$name])) {
  12269. return;
  12270. }
  12271. $this->packagesToLoad[$name] = Intervals::compactConstraint(MultiConstraint::create([$this->loadedPackages[$name], $constraint], false));
  12272. unset($this->loadedPackages[$name]);
  12273. }
  12274. private function loadPackagesMarkedForLoading(Request $request, array $repositories): void
  12275. {
  12276. foreach ($this->packagesToLoad as $name => $constraint) {
  12277. if ($this->restrictedPackagesList !== null && !isset($this->restrictedPackagesList[$name])) {
  12278. unset($this->packagesToLoad[$name]);
  12279. continue;
  12280. }
  12281. $this->loadedPackages[$name] = $constraint;
  12282. }
  12283. $packageBatch = $this->packagesToLoad;
  12284. $this->packagesToLoad = [];
  12285. foreach ($repositories as $repoIndex => $repository) {
  12286. if (empty($packageBatch)) {
  12287. break;
  12288. }
  12289. if ($repository instanceof PlatformRepository || $repository === $request->getLockedRepository()) {
  12290. continue;
  12291. }
  12292. $result = $repository->loadPackages($packageBatch, $this->acceptableStabilities, $this->stabilityFlags, $this->loadedPerRepo[$repoIndex] ?? []);
  12293. foreach ($result['namesFound'] as $name) {
  12294. unset($packageBatch[$name]);
  12295. }
  12296. foreach ($result['packages'] as $package) {
  12297. $this->loadedPerRepo[$repoIndex][$package->getName()][$package->getVersion()] = $package;
  12298. $this->loadPackage($request, $repositories, $package, !isset($this->pathRepoUnlocked[$package->getName()]));
  12299. }
  12300. }
  12301. }
  12302. private function loadPackage(Request $request, array $repositories, BasePackage $package, bool $propagateUpdate): void
  12303. {
  12304. $index = $this->indexCounter++;
  12305. $this->packages[$index] = $package;
  12306. if ($package instanceof AliasPackage) {
  12307. $this->aliasMap[spl_object_hash($package->getAliasOf())][$index] = $package;
  12308. }
  12309. $name = $package->getName();
  12310. if (isset($this->rootReferences[$name])) {
  12311. if (!$request->isLockedPackage($package) && !$request->isFixedPackage($package)) {
  12312. $package->setSourceDistReferences($this->rootReferences[$name]);
  12313. }
  12314. }
  12315. if (($propagateUpdate || isset($this->pathRepoUnlocked[$package->getName()])) && isset($this->rootAliases[$name][$package->getVersion()])) {
  12316. $alias = $this->rootAliases[$name][$package->getVersion()];
  12317. if ($package instanceof AliasPackage) {
  12318. $basePackage = $package->getAliasOf();
  12319. } else {
  12320. $basePackage = $package;
  12321. }
  12322. if ($basePackage instanceof CompletePackage) {
  12323. $aliasPackage = new CompleteAliasPackage($basePackage, $alias['alias_normalized'], $alias['alias']);
  12324. } else {
  12325. $aliasPackage = new AliasPackage($basePackage, $alias['alias_normalized'], $alias['alias']);
  12326. }
  12327. $aliasPackage->setRootPackageAlias(true);
  12328. $newIndex = $this->indexCounter++;
  12329. $this->packages[$newIndex] = $aliasPackage;
  12330. $this->aliasMap[spl_object_hash($aliasPackage->getAliasOf())][$newIndex] = $aliasPackage;
  12331. }
  12332. foreach ($package->getRequires() as $link) {
  12333. $require = $link->getTarget();
  12334. $linkConstraint = $link->getConstraint();
  12335. if (isset($this->skippedLoad[$require])) {
  12336. if ($propagateUpdate && $request->getUpdateAllowTransitiveDependencies()) {
  12337. $skippedRootRequires = $this->getSkippedRootRequires($request, $require);
  12338. if ($request->getUpdateAllowTransitiveRootDependencies() || !$skippedRootRequires) {
  12339. $this->unlockPackage($request, $repositories, $require);
  12340. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  12341. } else {
  12342. foreach ($skippedRootRequires as $rootRequire) {
  12343. if (!isset($this->updateAllowWarned[$rootRequire])) {
  12344. $this->updateAllowWarned[$rootRequire] = true;
  12345. $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>');
  12346. }
  12347. }
  12348. }
  12349. } elseif (isset($this->pathRepoUnlocked[$require]) && !isset($this->loadedPackages[$require])) {
  12350. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  12351. }
  12352. } else {
  12353. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  12354. }
  12355. }
  12356. if ($propagateUpdate && $request->getUpdateAllowTransitiveDependencies()) {
  12357. foreach ($package->getReplaces() as $link) {
  12358. $replace = $link->getTarget();
  12359. if (isset($this->loadedPackages[$replace], $this->skippedLoad[$replace])) {
  12360. $skippedRootRequires = $this->getSkippedRootRequires($request, $replace);
  12361. if ($request->getUpdateAllowTransitiveRootDependencies() || !$skippedRootRequires) {
  12362. $this->unlockPackage($request, $repositories, $replace);
  12363. $this->markPackageNameForLoadingIfRequired($request, $replace);
  12364. } else {
  12365. foreach ($skippedRootRequires as $rootRequire) {
  12366. if (!isset($this->updateAllowWarned[$rootRequire])) {
  12367. $this->updateAllowWarned[$rootRequire] = true;
  12368. $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>');
  12369. }
  12370. }
  12371. }
  12372. }
  12373. }
  12374. }
  12375. }
  12376. private function isRootRequire(Request $request, string $name): bool
  12377. {
  12378. $rootRequires = $request->getRequires();
  12379. return isset($rootRequires[$name]);
  12380. }
  12381. private function getSkippedRootRequires(Request $request, string $name): array
  12382. {
  12383. if (!isset($this->skippedLoad[$name])) {
  12384. return [];
  12385. }
  12386. $rootRequires = $request->getRequires();
  12387. $matches = [];
  12388. if (isset($rootRequires[$name])) {
  12389. return array_map(static function (PackageInterface $package) use ($name): string {
  12390. if ($name !== $package->getName()) {
  12391. return $package->getName() .' (via replace of '.$name.')';
  12392. }
  12393. return $package->getName();
  12394. }, $this->skippedLoad[$name]);
  12395. }
  12396. foreach ($this->skippedLoad[$name] as $packageOrReplacer) {
  12397. if (isset($rootRequires[$packageOrReplacer->getName()])) {
  12398. $matches[] = $packageOrReplacer->getName();
  12399. }
  12400. foreach ($packageOrReplacer->getReplaces() as $link) {
  12401. if (isset($rootRequires[$link->getTarget()])) {
  12402. if ($name !== $packageOrReplacer->getName()) {
  12403. $matches[] = $packageOrReplacer->getName() .' (via replace of '.$name.')';
  12404. } else {
  12405. $matches[] = $packageOrReplacer->getName();
  12406. }
  12407. break;
  12408. }
  12409. }
  12410. }
  12411. return $matches;
  12412. }
  12413. private function isUpdateAllowed(BasePackage $package): bool
  12414. {
  12415. foreach ($this->updateAllowList as $pattern) {
  12416. $patternRegexp = BasePackage::packageNameToRegexp($pattern);
  12417. if (Preg::isMatch($patternRegexp, $package->getName())) {
  12418. return true;
  12419. }
  12420. }
  12421. return false;
  12422. }
  12423. private function warnAboutNonMatchingUpdateAllowList(Request $request): void
  12424. {
  12425. foreach ($this->updateAllowList as $pattern) {
  12426. $patternRegexp = BasePackage::packageNameToRegexp($pattern);
  12427. foreach ($request->getLockedRepository()->getPackages() as $package) {
  12428. if (Preg::isMatch($patternRegexp, $package->getName())) {
  12429. continue 2;
  12430. }
  12431. }
  12432. foreach ($request->getRequires() as $packageName => $constraint) {
  12433. if (Preg::isMatch($patternRegexp, $packageName)) {
  12434. continue 2;
  12435. }
  12436. }
  12437. if (strpos($pattern, '*') !== false) {
  12438. $this->io->writeError('<warning>Pattern "' . $pattern . '" listed for update does not match any locked packages.</warning>');
  12439. } else {
  12440. $this->io->writeError('<warning>Package "' . $pattern . '" listed for update is not locked.</warning>');
  12441. }
  12442. }
  12443. }
  12444. private function unlockPackage(Request $request, array $repositories, string $name): void
  12445. {
  12446. foreach ($this->skippedLoad[$name] as $packageOrReplacer) {
  12447. if ($packageOrReplacer->getName() !== $name && isset($this->skippedLoad[$packageOrReplacer->getName()])) {
  12448. $replacerName = $packageOrReplacer->getName();
  12449. if ($request->getUpdateAllowTransitiveRootDependencies() || (!$this->isRootRequire($request, $name) && !$this->isRootRequire($request, $replacerName))) {
  12450. $this->unlockPackage($request, $repositories, $replacerName);
  12451. if ($this->isRootRequire($request, $replacerName)) {
  12452. $this->markPackageNameForLoading($request, $replacerName, new MatchAllConstraint);
  12453. } else {
  12454. foreach ($this->packages as $loadedPackage) {
  12455. $requires = $loadedPackage->getRequires();
  12456. if (isset($requires[$replacerName])) {
  12457. $this->markPackageNameForLoading($request, $replacerName, $requires[$replacerName]->getConstraint());
  12458. }
  12459. }
  12460. }
  12461. }
  12462. }
  12463. }
  12464. if (isset($this->pathRepoUnlocked[$name])) {
  12465. foreach ($this->packages as $index => $package) {
  12466. if ($package->getName() === $name) {
  12467. $this->removeLoadedPackage($request, $repositories, $package, $index);
  12468. }
  12469. }
  12470. }
  12471. unset($this->skippedLoad[$name], $this->loadedPackages[$name], $this->maxExtendedReqs[$name], $this->pathRepoUnlocked[$name]);
  12472. foreach ($request->getLockedPackages() as $lockedPackage) {
  12473. if (!($lockedPackage instanceof AliasPackage) && $lockedPackage->getName() === $name) {
  12474. if (false !== $index = array_search($lockedPackage, $this->packages, true)) {
  12475. $request->unlockPackage($lockedPackage);
  12476. $this->removeLoadedPackage($request, $repositories, $lockedPackage, $index);
  12477. foreach ($request->getFixedOrLockedPackages() as $fixedOrLockedPackage) {
  12478. if ($fixedOrLockedPackage === $lockedPackage) {
  12479. continue;
  12480. }
  12481. if (isset($this->skippedLoad[$fixedOrLockedPackage->getName()])) {
  12482. $requires = $fixedOrLockedPackage->getRequires();
  12483. if (isset($requires[$lockedPackage->getName()])) {
  12484. $this->markPackageNameForLoading($request, $lockedPackage->getName(), $requires[$lockedPackage->getName()]->getConstraint());
  12485. }
  12486. foreach ($lockedPackage->getReplaces() as $replace) {
  12487. if (isset($requires[$replace->getTarget()], $this->skippedLoad[$replace->getTarget()])) {
  12488. $this->unlockPackage($request, $repositories, $replace->getTarget());
  12489. $this->markPackageNameForLoading($request, $replace->getTarget(), $replace->getConstraint());
  12490. }
  12491. }
  12492. }
  12493. }
  12494. }
  12495. }
  12496. }
  12497. }
  12498. private function markPackageNameForLoadingIfRequired(Request $request, string $name): void
  12499. {
  12500. if ($this->isRootRequire($request, $name)) {
  12501. $this->markPackageNameForLoading($request, $name, $request->getRequires()[$name]);
  12502. }
  12503. foreach ($this->packages as $package) {
  12504. foreach ($package->getRequires() as $link) {
  12505. if ($name === $link->getTarget()) {
  12506. $this->markPackageNameForLoading($request, $link->getTarget(), $link->getConstraint());
  12507. }
  12508. }
  12509. }
  12510. }
  12511. private function removeLoadedPackage(Request $request, array $repositories, BasePackage $package, int $index): void
  12512. {
  12513. $repoIndex = array_search($package->getRepository(), $repositories, true);
  12514. unset($this->loadedPerRepo[$repoIndex][$package->getName()][$package->getVersion()]);
  12515. unset($this->packages[$index]);
  12516. if (isset($this->aliasMap[spl_object_hash($package)])) {
  12517. foreach ($this->aliasMap[spl_object_hash($package)] as $aliasIndex => $aliasPackage) {
  12518. unset($this->loadedPerRepo[$repoIndex][$aliasPackage->getName()][$aliasPackage->getVersion()]);
  12519. unset($this->packages[$aliasIndex]);
  12520. }
  12521. unset($this->aliasMap[spl_object_hash($package)]);
  12522. }
  12523. }
  12524. private function runOptimizer(Request $request, Pool $pool): Pool
  12525. {
  12526. if (null === $this->poolOptimizer) {
  12527. return $pool;
  12528. }
  12529. $this->io->debug('Running pool optimizer.');
  12530. $before = microtime(true);
  12531. $total = \count($pool->getPackages());
  12532. $pool = $this->poolOptimizer->optimize($request, $pool);
  12533. $filtered = $total - \count($pool->getPackages());
  12534. if (0 === $filtered) {
  12535. return $pool;
  12536. }
  12537. $this->io->write(sprintf('Pool optimizer completed in %.3f seconds', microtime(true) - $before), true, IOInterface::VERY_VERBOSE);
  12538. $this->io->write(sprintf(
  12539. '<info>Found %s package versions referenced in your dependency graph. %s (%d%%) were optimized away.</info>',
  12540. number_format($total),
  12541. number_format($filtered),
  12542. round(100 / $total * $filtered)
  12543. ), true, IOInterface::VERY_VERBOSE);
  12544. return $pool;
  12545. }
  12546. }
  12547. <?php declare(strict_types=1);
  12548. namespace Composer\DependencyResolver;
  12549. use Composer\Package\AliasPackage;
  12550. use Composer\Package\BasePackage;
  12551. use Composer\Package\Version\VersionParser;
  12552. use Composer\Semver\CompilingMatcher;
  12553. use Composer\Semver\Constraint\ConstraintInterface;
  12554. use Composer\Semver\Constraint\Constraint;
  12555. use Composer\Semver\Constraint\MultiConstraint;
  12556. use Composer\Semver\Intervals;
  12557. class PoolOptimizer
  12558. {
  12559. private $policy;
  12560. private $irremovablePackages = [];
  12561. private $requireConstraintsPerPackage = [];
  12562. private $conflictConstraintsPerPackage = [];
  12563. private $packagesToRemove = [];
  12564. private $aliasesPerPackage = [];
  12565. private $removedVersionsByPackage = [];
  12566. public function __construct(PolicyInterface $policy)
  12567. {
  12568. $this->policy = $policy;
  12569. }
  12570. public function optimize(Request $request, Pool $pool): Pool
  12571. {
  12572. $this->prepare($request, $pool);
  12573. $this->optimizeByIdenticalDependencies($request, $pool);
  12574. $this->optimizeImpossiblePackagesAway($request, $pool);
  12575. $optimizedPool = $this->applyRemovalsToPool($pool);
  12576. $this->irremovablePackages = [];
  12577. $this->requireConstraintsPerPackage = [];
  12578. $this->conflictConstraintsPerPackage = [];
  12579. $this->packagesToRemove = [];
  12580. $this->aliasesPerPackage = [];
  12581. $this->removedVersionsByPackage = [];
  12582. return $optimizedPool;
  12583. }
  12584. private function prepare(Request $request, Pool $pool): void
  12585. {
  12586. $irremovablePackageConstraintGroups = [];
  12587. foreach ($request->getFixedOrLockedPackages() as $package) {
  12588. $irremovablePackageConstraintGroups[$package->getName()][] = new Constraint('==', $package->getVersion());
  12589. }
  12590. foreach ($request->getRequires() as $require => $constraint) {
  12591. $this->extractRequireConstraintsPerPackage($require, $constraint);
  12592. }
  12593. foreach ($pool->getPackages() as $package) {
  12594. foreach ($package->getRequires() as $link) {
  12595. $this->extractRequireConstraintsPerPackage($link->getTarget(), $link->getConstraint());
  12596. }
  12597. foreach ($package->getConflicts() as $link) {
  12598. $this->extractConflictConstraintsPerPackage($link->getTarget(), $link->getConstraint());
  12599. }
  12600. if ($package instanceof AliasPackage) {
  12601. $this->aliasesPerPackage[$package->getAliasOf()->id][] = $package;
  12602. }
  12603. }
  12604. $irremovablePackageConstraints = [];
  12605. foreach ($irremovablePackageConstraintGroups as $packageName => $constraints) {
  12606. $irremovablePackageConstraints[$packageName] = 1 === \count($constraints) ? $constraints[0] : new MultiConstraint($constraints, false);
  12607. }
  12608. unset($irremovablePackageConstraintGroups);
  12609. foreach ($pool->getPackages() as $package) {
  12610. if (!isset($irremovablePackageConstraints[$package->getName()])) {
  12611. continue;
  12612. }
  12613. if (CompilingMatcher::match($irremovablePackageConstraints[$package->getName()], Constraint::OP_EQ, $package->getVersion())) {
  12614. $this->markPackageIrremovable($package);
  12615. }
  12616. }
  12617. }
  12618. private function markPackageIrremovable(BasePackage $package): void
  12619. {
  12620. $this->irremovablePackages[$package->id] = true;
  12621. if ($package instanceof AliasPackage) {
  12622. $this->markPackageIrremovable($package->getAliasOf());
  12623. }
  12624. if (isset($this->aliasesPerPackage[$package->id])) {
  12625. foreach ($this->aliasesPerPackage[$package->id] as $aliasPackage) {
  12626. $this->irremovablePackages[$aliasPackage->id] = true;
  12627. }
  12628. }
  12629. }
  12630. private function applyRemovalsToPool(Pool $pool): Pool
  12631. {
  12632. $packages = [];
  12633. $removedVersions = [];
  12634. foreach ($pool->getPackages() as $package) {
  12635. if (!isset($this->packagesToRemove[$package->id])) {
  12636. $packages[] = $package;
  12637. } else {
  12638. $removedVersions[$package->getName()][$package->getVersion()] = $package->getPrettyVersion();
  12639. }
  12640. }
  12641. $optimizedPool = new Pool($packages, $pool->getUnacceptableFixedOrLockedPackages(), $removedVersions, $this->removedVersionsByPackage);
  12642. return $optimizedPool;
  12643. }
  12644. private function optimizeByIdenticalDependencies(Request $request, Pool $pool): void
  12645. {
  12646. $identicalDefinitionsPerPackage = [];
  12647. $packageIdenticalDefinitionLookup = [];
  12648. foreach ($pool->getPackages() as $package) {
  12649. if (isset($this->irremovablePackages[$package->id])) {
  12650. continue;
  12651. }
  12652. $this->markPackageForRemoval($package->id);
  12653. $dependencyHash = $this->calculateDependencyHash($package);
  12654. foreach ($package->getNames(false) as $packageName) {
  12655. if (!isset($this->requireConstraintsPerPackage[$packageName])) {
  12656. continue;
  12657. }
  12658. foreach ($this->requireConstraintsPerPackage[$packageName] as $requireConstraint) {
  12659. $groupHashParts = [];
  12660. if (CompilingMatcher::match($requireConstraint, Constraint::OP_EQ, $package->getVersion())) {
  12661. $groupHashParts[] = 'require:' . (string) $requireConstraint;
  12662. }
  12663. if ($package->getReplaces()) {
  12664. foreach ($package->getReplaces() as $link) {
  12665. if (CompilingMatcher::match($link->getConstraint(), Constraint::OP_EQ, $package->getVersion())) {
  12666. $groupHashParts[] = 'require:' . (string) $link->getConstraint();
  12667. }
  12668. }
  12669. }
  12670. if (isset($this->conflictConstraintsPerPackage[$packageName])) {
  12671. foreach ($this->conflictConstraintsPerPackage[$packageName] as $conflictConstraint) {
  12672. if (CompilingMatcher::match($conflictConstraint, Constraint::OP_EQ, $package->getVersion())) {
  12673. $groupHashParts[] = 'conflict:' . (string) $conflictConstraint;
  12674. }
  12675. }
  12676. }
  12677. if (!$groupHashParts) {
  12678. continue;
  12679. }
  12680. $groupHash = implode('', $groupHashParts);
  12681. $identicalDefinitionsPerPackage[$packageName][$groupHash][$dependencyHash][] = $package;
  12682. $packageIdenticalDefinitionLookup[$package->id][$packageName] = ['groupHash' => $groupHash, 'dependencyHash' => $dependencyHash];
  12683. }
  12684. }
  12685. }
  12686. foreach ($identicalDefinitionsPerPackage as $constraintGroups) {
  12687. foreach ($constraintGroups as $constraintGroup) {
  12688. foreach ($constraintGroup as $packages) {
  12689. if (1 === \count($packages)) {
  12690. $this->keepPackage($packages[0], $identicalDefinitionsPerPackage, $packageIdenticalDefinitionLookup);
  12691. continue;
  12692. }
  12693. $literals = [];
  12694. foreach ($packages as $package) {
  12695. $literals[] = $package->id;
  12696. }
  12697. foreach ($this->policy->selectPreferredPackages($pool, $literals) as $preferredLiteral) {
  12698. $this->keepPackage($pool->literalToPackage($preferredLiteral), $identicalDefinitionsPerPackage, $packageIdenticalDefinitionLookup);
  12699. }
  12700. }
  12701. }
  12702. }
  12703. }
  12704. private function calculateDependencyHash(BasePackage $package): string
  12705. {
  12706. $hash = '';
  12707. $hashRelevantLinks = [
  12708. 'requires' => $package->getRequires(),
  12709. 'conflicts' => $package->getConflicts(),
  12710. 'replaces' => $package->getReplaces(),
  12711. 'provides' => $package->getProvides(),
  12712. ];
  12713. foreach ($hashRelevantLinks as $key => $links) {
  12714. if (0 === \count($links)) {
  12715. continue;
  12716. }
  12717. $hash .= $key . ':';
  12718. $subhash = [];
  12719. foreach ($links as $link) {
  12720. $subhash[$link->getTarget()] = (string) $link->getConstraint();
  12721. }
  12722. ksort($subhash);
  12723. foreach ($subhash as $target => $constraint) {
  12724. $hash .= $target . '@' . $constraint;
  12725. }
  12726. }
  12727. return $hash;
  12728. }
  12729. private function markPackageForRemoval(int $id): void
  12730. {
  12731. if (isset($this->irremovablePackages[$id])) {
  12732. throw new \LogicException('Attempted removing a package which was previously marked irremovable');
  12733. }
  12734. $this->packagesToRemove[$id] = true;
  12735. }
  12736. private function keepPackage(BasePackage $package, array $identicalDefinitionsPerPackage, array $packageIdenticalDefinitionLookup): void
  12737. {
  12738. if (!isset($this->packagesToRemove[$package->id])) {
  12739. return;
  12740. }
  12741. unset($this->packagesToRemove[$package->id]);
  12742. if ($package instanceof AliasPackage) {
  12743. $this->keepPackage($package->getAliasOf(), $identicalDefinitionsPerPackage, $packageIdenticalDefinitionLookup);
  12744. }
  12745. foreach ($package->getNames(false) as $name) {
  12746. if (isset($packageIdenticalDefinitionLookup[$package->id][$name])) {
  12747. $packageGroupPointers = $packageIdenticalDefinitionLookup[$package->id][$name];
  12748. $packageGroup = $identicalDefinitionsPerPackage[$name][$packageGroupPointers['groupHash']][$packageGroupPointers['dependencyHash']];
  12749. foreach ($packageGroup as $pkg) {
  12750. if ($pkg instanceof AliasPackage && $pkg->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  12751. $pkg = $pkg->getAliasOf();
  12752. }
  12753. $this->removedVersionsByPackage[spl_object_hash($package)][$pkg->getVersion()] = $pkg->getPrettyVersion();
  12754. }
  12755. }
  12756. }
  12757. if (isset($this->aliasesPerPackage[$package->id])) {
  12758. foreach ($this->aliasesPerPackage[$package->id] as $aliasPackage) {
  12759. unset($this->packagesToRemove[$aliasPackage->id]);
  12760. foreach ($aliasPackage->getNames(false) as $name) {
  12761. if (isset($packageIdenticalDefinitionLookup[$aliasPackage->id][$name])) {
  12762. $packageGroupPointers = $packageIdenticalDefinitionLookup[$aliasPackage->id][$name];
  12763. $packageGroup = $identicalDefinitionsPerPackage[$name][$packageGroupPointers['groupHash']][$packageGroupPointers['dependencyHash']];
  12764. foreach ($packageGroup as $pkg) {
  12765. if ($pkg instanceof AliasPackage && $pkg->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  12766. $pkg = $pkg->getAliasOf();
  12767. }
  12768. $this->removedVersionsByPackage[spl_object_hash($aliasPackage)][$pkg->getVersion()] = $pkg->getPrettyVersion();
  12769. }
  12770. }
  12771. }
  12772. }
  12773. }
  12774. }
  12775. private function optimizeImpossiblePackagesAway(Request $request, Pool $pool): void
  12776. {
  12777. if (count($request->getLockedPackages()) === 0) {
  12778. return;
  12779. }
  12780. $packageIndex = [];
  12781. foreach ($pool->getPackages() as $package) {
  12782. $id = $package->id;
  12783. if (isset($this->irremovablePackages[$id])) {
  12784. continue;
  12785. }
  12786. if (isset($this->aliasesPerPackage[$id]) || $package instanceof AliasPackage) {
  12787. continue;
  12788. }
  12789. if ($request->isFixedPackage($package) || $request->isLockedPackage($package)) {
  12790. continue;
  12791. }
  12792. $packageIndex[$package->getName()][$package->id] = $package;
  12793. }
  12794. foreach ($request->getLockedPackages() as $package) {
  12795. $isUnusedPackage = true;
  12796. foreach ($package->getNames(false) as $packageName) {
  12797. if (isset($this->requireConstraintsPerPackage[$packageName])) {
  12798. $isUnusedPackage = false;
  12799. break;
  12800. }
  12801. }
  12802. if ($isUnusedPackage) {
  12803. continue;
  12804. }
  12805. foreach ($package->getRequires() as $link) {
  12806. $require = $link->getTarget();
  12807. if (!isset($packageIndex[$require])) {
  12808. continue;
  12809. }
  12810. $linkConstraint = $link->getConstraint();
  12811. foreach ($packageIndex[$require] as $id => $requiredPkg) {
  12812. if (false === CompilingMatcher::match($linkConstraint, Constraint::OP_EQ, $requiredPkg->getVersion())) {
  12813. $this->markPackageForRemoval($id);
  12814. unset($packageIndex[$require][$id]);
  12815. }
  12816. }
  12817. }
  12818. }
  12819. }
  12820. private function extractRequireConstraintsPerPackage(string $package, ConstraintInterface $constraint)
  12821. {
  12822. foreach ($this->expandDisjunctiveMultiConstraints($constraint) as $expanded) {
  12823. $this->requireConstraintsPerPackage[$package][(string) $expanded] = $expanded;
  12824. }
  12825. }
  12826. private function extractConflictConstraintsPerPackage(string $package, ConstraintInterface $constraint)
  12827. {
  12828. foreach ($this->expandDisjunctiveMultiConstraints($constraint) as $expanded) {
  12829. $this->conflictConstraintsPerPackage[$package][(string) $expanded] = $expanded;
  12830. }
  12831. }
  12832. private function expandDisjunctiveMultiConstraints(ConstraintInterface $constraint)
  12833. {
  12834. $constraint = Intervals::compactConstraint($constraint);
  12835. if ($constraint instanceof MultiConstraint && $constraint->isDisjunctive()) {
  12836. return $constraint->getConstraints();
  12837. }
  12838. return [$constraint];
  12839. }
  12840. }
  12841. <?php declare(strict_types=1);
  12842. namespace Composer\DependencyResolver;
  12843. use Composer\Package\CompletePackageInterface;
  12844. use Composer\Package\AliasPackage;
  12845. use Composer\Package\BasePackage;
  12846. use Composer\Package\Link;
  12847. use Composer\Package\PackageInterface;
  12848. use Composer\Package\RootPackageInterface;
  12849. use Composer\Pcre\Preg;
  12850. use Composer\Repository\RepositorySet;
  12851. use Composer\Repository\LockArrayRepository;
  12852. use Composer\Semver\Constraint\Constraint;
  12853. use Composer\Semver\Constraint\ConstraintInterface;
  12854. use Composer\Package\Version\VersionParser;
  12855. use Composer\Repository\PlatformRepository;
  12856. class Problem
  12857. {
  12858. protected $reasonSeen;
  12859. protected $reasons = [];
  12860. protected $section = 0;
  12861. public function addRule(Rule $rule): void
  12862. {
  12863. $this->addReason(spl_object_hash($rule), $rule);
  12864. }
  12865. public function getReasons(): array
  12866. {
  12867. return $this->reasons;
  12868. }
  12869. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, bool $isVerbose, array $installedMap = [], array $learnedPool = []): string
  12870. {
  12871. $reasons = array_merge(...array_reverse($this->reasons));
  12872. if (count($reasons) === 1) {
  12873. reset($reasons);
  12874. $rule = current($reasons);
  12875. if ($rule->getReason() !== Rule::RULE_ROOT_REQUIRE) {
  12876. throw new \LogicException("Single reason problems must contain a root require rule.");
  12877. }
  12878. $reasonData = $rule->getReasonData();
  12879. $packageName = $reasonData['packageName'];
  12880. $constraint = $reasonData['constraint'];
  12881. $packages = $pool->whatProvides($packageName, $constraint);
  12882. if (count($packages) === 0) {
  12883. return "\n ".implode(self::getMissingPackageReason($repositorySet, $request, $pool, $isVerbose, $packageName, $constraint));
  12884. }
  12885. }
  12886. return self::formatDeduplicatedRules($reasons, ' ', $repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool);
  12887. }
  12888. public static function formatDeduplicatedRules(array $rules, string $indent, RepositorySet $repositorySet, Request $request, Pool $pool, bool $isVerbose, array $installedMap = [], array $learnedPool = []): string
  12889. {
  12890. $messages = [];
  12891. $templates = [];
  12892. $parser = new VersionParser;
  12893. $deduplicatableRuleTypes = [Rule::RULE_PACKAGE_REQUIRES, Rule::RULE_PACKAGE_CONFLICT];
  12894. foreach ($rules as $rule) {
  12895. $message = $rule->getPrettyString($repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool);
  12896. if (in_array($rule->getReason(), $deduplicatableRuleTypes, true) && Preg::isMatchStrictGroups('{^(?P<package>\S+) (?P<version>\S+) (?P<type>requires|conflicts)}', $message, $m)) {
  12897. $message = str_replace('%', '%%', $message);
  12898. $template = Preg::replace('{^\S+ \S+ }', '%s%s ', $message);
  12899. $messages[] = $template;
  12900. $templates[$template][$m[1]][$parser->normalize($m[2])] = $m[2];
  12901. $sourcePackage = $rule->getSourcePackage($pool);
  12902. foreach ($pool->getRemovedVersionsByPackage(spl_object_hash($sourcePackage)) as $version => $prettyVersion) {
  12903. $templates[$template][$m[1]][$version] = $prettyVersion;
  12904. }
  12905. } elseif ($message !== '') {
  12906. $messages[] = $message;
  12907. }
  12908. }
  12909. $result = [];
  12910. foreach (array_unique($messages) as $message) {
  12911. if (isset($templates[$message])) {
  12912. foreach ($templates[$message] as $package => $versions) {
  12913. uksort($versions, 'version_compare');
  12914. if (!$isVerbose) {
  12915. $versions = self::condenseVersionList($versions, 1);
  12916. }
  12917. if (count($versions) > 1) {
  12918. $message = Preg::replace('{^(%s%s (?:require|conflict))s}', '$1', $message);
  12919. $result[] = sprintf($message, $package, '['.implode(', ', $versions).']');
  12920. } else {
  12921. $result[] = sprintf($message, $package, ' '.reset($versions));
  12922. }
  12923. }
  12924. } else {
  12925. $result[] = $message;
  12926. }
  12927. }
  12928. return "\n$indent- ".implode("\n$indent- ", $result);
  12929. }
  12930. public function isCausedByLock(RepositorySet $repositorySet, Request $request, Pool $pool): bool
  12931. {
  12932. foreach ($this->reasons as $sectionRules) {
  12933. foreach ($sectionRules as $rule) {
  12934. if ($rule->isCausedByLock($repositorySet, $request, $pool)) {
  12935. return true;
  12936. }
  12937. }
  12938. }
  12939. return false;
  12940. }
  12941. protected function addReason(string $id, Rule $reason): void
  12942. {
  12943. if (!isset($this->reasonSeen[$id])) {
  12944. $this->reasonSeen[$id] = true;
  12945. $this->reasons[$this->section][] = $reason;
  12946. }
  12947. }
  12948. public function nextSection(): void
  12949. {
  12950. $this->section++;
  12951. }
  12952. public static function getMissingPackageReason(RepositorySet $repositorySet, Request $request, Pool $pool, bool $isVerbose, string $packageName, ?ConstraintInterface $constraint = null): array
  12953. {
  12954. if (PlatformRepository::isPlatformPackage($packageName)) {
  12955. if (0 === stripos($packageName, 'php') || $packageName === 'hhvm') {
  12956. $version = self::getPlatformPackageVersion($pool, $packageName, phpversion());
  12957. $msg = "- Root composer.json requires ".$packageName.self::constraintToText($constraint).' but ';
  12958. if (defined('HHVM_VERSION') || ($packageName === 'hhvm' && count($pool->whatProvides($packageName)) > 0)) {
  12959. return [$msg, 'your HHVM version does not satisfy that requirement.'];
  12960. }
  12961. if ($packageName === 'hhvm') {
  12962. return [$msg, 'HHVM was not detected on this machine, make sure it is in your PATH.'];
  12963. }
  12964. if (null === $version) {
  12965. return [$msg, 'the '.$packageName.' package is disabled by your platform config. Enable it again with "composer config platform.'.$packageName.' --unset".'];
  12966. }
  12967. return [$msg, 'your '.$packageName.' version ('. $version .') does not satisfy that requirement.'];
  12968. }
  12969. if (0 === stripos($packageName, 'ext-')) {
  12970. if (false !== strpos($packageName, ' ')) {
  12971. return ['- ', "PHP extension ".$packageName.' should be required as '.str_replace(' ', '-', $packageName).'.'];
  12972. }
  12973. $ext = substr($packageName, 4);
  12974. $msg = "- Root composer.json requires PHP extension ".$packageName.self::constraintToText($constraint).' but ';
  12975. $version = self::getPlatformPackageVersion($pool, $packageName, phpversion($ext) ?: '0');
  12976. if (null === $version) {
  12977. if (extension_loaded($ext)) {
  12978. return [
  12979. $msg,
  12980. 'the '.$packageName.' package is disabled by your platform config. Enable it again with "composer config platform.'.$packageName.' --unset".',
  12981. ];
  12982. }
  12983. return [$msg, 'it is missing from your system. Install or enable PHP\'s '.$ext.' extension.'];
  12984. }
  12985. return [$msg, 'it has the wrong version installed ('.$version.').'];
  12986. }
  12987. if (0 === stripos($packageName, 'lib-')) {
  12988. if (strtolower($packageName) === 'lib-icu') {
  12989. $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.';
  12990. return ["- Root composer.json requires linked library ".$packageName.self::constraintToText($constraint).' but ', $error];
  12991. }
  12992. return ["- 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.'];
  12993. }
  12994. }
  12995. $lockedPackage = null;
  12996. foreach ($request->getLockedPackages() as $package) {
  12997. if ($package->getName() === $packageName) {
  12998. $lockedPackage = $package;
  12999. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  13000. return ["- ", $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.'];
  13001. }
  13002. break;
  13003. }
  13004. }
  13005. if ($packages = $repositorySet->findPackages($packageName, $constraint)) {
  13006. $rootReqs = $repositorySet->getRootRequires();
  13007. if (isset($rootReqs[$packageName])) {
  13008. $filtered = array_filter($packages, static function ($p) use ($rootReqs, $packageName): bool {
  13009. return $rootReqs[$packageName]->matches(new Constraint('==', $p->getVersion()));
  13010. });
  13011. if (0 === count($filtered)) {
  13012. return ["- 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().').'];
  13013. }
  13014. }
  13015. $tempReqs = $repositorySet->getTemporaryConstraints();
  13016. if (isset($tempReqs[$packageName])) {
  13017. $filtered = array_filter($packages, static function ($p) use ($tempReqs, $packageName): bool {
  13018. return $tempReqs[$packageName]->matches(new Constraint('==', $p->getVersion()));
  13019. });
  13020. if (0 === count($filtered)) {
  13021. return ["- 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 temporary update constraint ('.$packageName.':'.$tempReqs[$packageName]->getPrettyString().').'];
  13022. }
  13023. }
  13024. if ($lockedPackage) {
  13025. $fixedConstraint = new Constraint('==', $lockedPackage->getVersion());
  13026. $filtered = array_filter($packages, static function ($p) use ($fixedConstraint): bool {
  13027. return $fixedConstraint->matches(new Constraint('==', $p->getVersion()));
  13028. });
  13029. if (0 === count($filtered)) {
  13030. return ["- 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.'];
  13031. }
  13032. }
  13033. $nonLockedPackages = array_filter($packages, static function ($p): bool {
  13034. return !$p->getRepository() instanceof LockArrayRepository;
  13035. });
  13036. if (!$nonLockedPackages) {
  13037. return ["- 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.'];
  13038. }
  13039. return ["- 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.'];
  13040. }
  13041. if ($packages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES)) {
  13042. if ($allReposPackages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  13043. return self::computeCheckForLowerPrioRepo($pool, $isVerbose, $packageName, $packages, $allReposPackages, 'minimum-stability', $constraint);
  13044. }
  13045. return ["- 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.'];
  13046. }
  13047. if ($packages = $repositorySet->findPackages($packageName, null, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES)) {
  13048. if ($allReposPackages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  13049. return self::computeCheckForLowerPrioRepo($pool, $isVerbose, $packageName, $packages, $allReposPackages, 'constraint', $constraint);
  13050. }
  13051. $suffix = '';
  13052. if ($constraint instanceof Constraint && $constraint->getVersion() === 'dev-master') {
  13053. foreach ($packages as $candidate) {
  13054. if (in_array($candidate->getVersion(), ['dev-default', 'dev-main'], true)) {
  13055. $suffix = ' Perhaps dev-master was renamed to '.$candidate->getPrettyVersion().'?';
  13056. break;
  13057. }
  13058. }
  13059. }
  13060. $allReposPackages = $packages;
  13061. $topPackage = reset($allReposPackages);
  13062. if ($topPackage instanceof RootPackageInterface) {
  13063. $suffix = ' See https://getcomposer.org/dep-on-root for details and assistance.';
  13064. }
  13065. return ["- 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];
  13066. }
  13067. if (!Preg::isMatch('{^[A-Za-z0-9_./-]+$}', $packageName)) {
  13068. $illegalChars = Preg::replace('{[A-Za-z0-9_./-]+}', '', $packageName);
  13069. return ["- Root composer.json requires $packageName, it ", 'could not be found, it looks like its name is invalid, "'.$illegalChars.'" is not allowed in package names.'];
  13070. }
  13071. if ($providers = $repositorySet->getProviders($packageName)) {
  13072. $maxProviders = 20;
  13073. $providersStr = implode(array_map(static function ($p): string {
  13074. $description = $p['description'] ? ' '.substr($p['description'], 0, 100) : '';
  13075. return ' - '.$p['name'].$description."\n";
  13076. }, count($providers) > $maxProviders + 1 ? array_slice($providers, 0, $maxProviders) : $providers));
  13077. if (count($providers) > $maxProviders + 1) {
  13078. $providersStr .= ' ... and '.(count($providers) - $maxProviders).' more.'."\n";
  13079. }
  13080. return ["- 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."];
  13081. }
  13082. return ["- Root composer.json requires $packageName, it ", "could not be found in any version, there may be a typo in the package name."];
  13083. }
  13084. public static function getPackageList(array $packages, bool $isVerbose, ?Pool $pool = null, ?ConstraintInterface $constraint = null, bool $useRemovedVersionGroup = false): string
  13085. {
  13086. $prepared = [];
  13087. $hasDefaultBranch = [];
  13088. foreach ($packages as $package) {
  13089. $prepared[$package->getName()]['name'] = $package->getPrettyName();
  13090. $prepared[$package->getName()]['versions'][$package->getVersion()] = $package->getPrettyVersion().($package instanceof AliasPackage ? ' (alias of '.$package->getAliasOf()->getPrettyVersion().')' : '');
  13091. if ($pool && $constraint) {
  13092. foreach ($pool->getRemovedVersions($package->getName(), $constraint) as $version => $prettyVersion) {
  13093. $prepared[$package->getName()]['versions'][$version] = $prettyVersion;
  13094. }
  13095. }
  13096. if ($pool && $useRemovedVersionGroup) {
  13097. foreach ($pool->getRemovedVersionsByPackage(spl_object_hash($package)) as $version => $prettyVersion) {
  13098. $prepared[$package->getName()]['versions'][$version] = $prettyVersion;
  13099. }
  13100. }
  13101. if ($package->isDefaultBranch()) {
  13102. $hasDefaultBranch[$package->getName()] = true;
  13103. }
  13104. }
  13105. $preparedStrings = [];
  13106. foreach ($prepared as $name => $package) {
  13107. if (isset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS], $hasDefaultBranch[$name])) {
  13108. unset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS]);
  13109. }
  13110. uksort($package['versions'], 'version_compare');
  13111. if (!$isVerbose) {
  13112. $package['versions'] = self::condenseVersionList($package['versions'], 4);
  13113. }
  13114. $preparedStrings[] = $package['name'].'['.implode(', ', $package['versions']).']';
  13115. }
  13116. return implode(', ', $preparedStrings);
  13117. }
  13118. private static function getPlatformPackageVersion(Pool $pool, string $packageName, string $version): ?string
  13119. {
  13120. $available = $pool->whatProvides($packageName);
  13121. if (count($available)) {
  13122. $selected = null;
  13123. foreach ($available as $pkg) {
  13124. if ($pkg->getRepository() instanceof PlatformRepository) {
  13125. $selected = $pkg;
  13126. break;
  13127. }
  13128. }
  13129. if ($selected === null) {
  13130. $selected = reset($available);
  13131. }
  13132. if ($selected->getName() !== $packageName) {
  13133. foreach (array_merge(array_values($selected->getProvides()), array_values($selected->getReplaces())) as $link) {
  13134. if ($link->getTarget() === $packageName) {
  13135. return $link->getPrettyConstraint().' '.substr($link->getDescription(), 0, -1).'d by '.$selected->getPrettyString();
  13136. }
  13137. }
  13138. }
  13139. $version = $selected->getPrettyVersion();
  13140. $extra = $selected->getExtra();
  13141. if ($selected instanceof CompletePackageInterface && isset($extra['config.platform']) && $extra['config.platform'] === true) {
  13142. $version .= '; ' . str_replace('Package ', '', $selected->getDescription());
  13143. }
  13144. } else {
  13145. return null;
  13146. }
  13147. return $version;
  13148. }
  13149. private static function condenseVersionList(array $versions, int $max, int $maxDev = 16): array
  13150. {
  13151. if (count($versions) <= $max) {
  13152. return array_values($versions);
  13153. }
  13154. $filtered = [];
  13155. $byMajor = [];
  13156. foreach ($versions as $version => $pretty) {
  13157. if (0 === stripos((string) $version, 'dev-')) {
  13158. $byMajor['dev'][] = $pretty;
  13159. } else {
  13160. $byMajor[Preg::replace('{^(\d+)\..*}', '$1', (string) $version)][] = $pretty;
  13161. }
  13162. }
  13163. foreach ($byMajor as $majorVersion => $versionsForMajor) {
  13164. $maxVersions = $majorVersion === 'dev' ? $maxDev : $max;
  13165. if (count($versionsForMajor) > $maxVersions) {
  13166. $filtered[] = $versionsForMajor[0];
  13167. $filtered[] = '...';
  13168. $filtered[] = $versionsForMajor[count($versionsForMajor) - 1];
  13169. } else {
  13170. $filtered = array_merge($filtered, $versionsForMajor);
  13171. }
  13172. }
  13173. return $filtered;
  13174. }
  13175. private static function hasMultipleNames(array $packages): bool
  13176. {
  13177. $name = null;
  13178. foreach ($packages as $package) {
  13179. if ($name === null || $name === $package->getName()) {
  13180. $name = $package->getName();
  13181. } else {
  13182. return true;
  13183. }
  13184. }
  13185. return false;
  13186. }
  13187. private static function computeCheckForLowerPrioRepo(Pool $pool, bool $isVerbose, string $packageName, array $higherRepoPackages, array $allReposPackages, string $reason, ?ConstraintInterface $constraint = null): array
  13188. {
  13189. $nextRepoPackages = [];
  13190. $nextRepo = null;
  13191. foreach ($allReposPackages as $package) {
  13192. if ($nextRepo === null || $nextRepo === $package->getRepository()) {
  13193. $nextRepoPackages[] = $package;
  13194. $nextRepo = $package->getRepository();
  13195. } else {
  13196. break;
  13197. }
  13198. }
  13199. if ($higherRepoPackages) {
  13200. $topPackage = reset($higherRepoPackages);
  13201. if ($topPackage instanceof RootPackageInterface) {
  13202. return [
  13203. "- Root composer.json requires $packageName".self::constraintToText($constraint).', it is ',
  13204. '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.',
  13205. ];
  13206. }
  13207. }
  13208. if ($nextRepo instanceof LockArrayRepository) {
  13209. $singular = count($higherRepoPackages) === 1;
  13210. $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).').';
  13211. if ($nextRepoPackages[0]->getDistType() === 'path') {
  13212. $transportOptions = $nextRepoPackages[0]->getTransportOptions();
  13213. if (!isset($transportOptions['symlink']) || $transportOptions['symlink'] !== false) {
  13214. $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.';
  13215. }
  13216. }
  13217. return ["- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ',
  13218. '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,
  13219. ];
  13220. }
  13221. return ["- 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.'];
  13222. }
  13223. protected static function constraintToText(?ConstraintInterface $constraint = null): string
  13224. {
  13225. if ($constraint instanceof Constraint && $constraint->getOperator() === Constraint::STR_OP_EQ && !str_starts_with($constraint->getVersion(), 'dev-')) {
  13226. if (!Preg::isMatch('{^\d+(?:\.\d+)*$}', $constraint->getPrettyString())) {
  13227. return ' '.$constraint->getPrettyString() .' (exact version match)';
  13228. }
  13229. $versions = [$constraint->getPrettyString()];
  13230. for ($i = 3 - substr_count($versions[0], '.'); $i > 0; $i--) {
  13231. $versions[] = end($versions) . '.0';
  13232. }
  13233. return ' ' . $constraint->getPrettyString() . ' (exact version match: ' . (count($versions) > 1 ? implode(', ', array_slice($versions, 0, -1)) . ' or ' . end($versions) : $versions[0]) . ')';
  13234. }
  13235. return $constraint ? ' '.$constraint->getPrettyString() : '';
  13236. }
  13237. }
  13238. <?php declare(strict_types=1);
  13239. namespace Composer\DependencyResolver;
  13240. use Composer\Package\BasePackage;
  13241. use Composer\Package\PackageInterface;
  13242. use Composer\Repository\LockArrayRepository;
  13243. use Composer\Semver\Constraint\ConstraintInterface;
  13244. use Composer\Semver\Constraint\MatchAllConstraint;
  13245. class Request
  13246. {
  13247. public const UPDATE_ONLY_LISTED = 0;
  13248. public const UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE = 1;
  13249. public const UPDATE_LISTED_WITH_TRANSITIVE_DEPS = 2;
  13250. protected $lockedRepository;
  13251. protected $requires = [];
  13252. protected $fixedPackages = [];
  13253. protected $lockedPackages = [];
  13254. protected $fixedLockedPackages = [];
  13255. protected $updateAllowList = [];
  13256. protected $updateAllowTransitiveDependencies = false;
  13257. private $restrictedPackages = null;
  13258. public function __construct(?LockArrayRepository $lockedRepository = null)
  13259. {
  13260. $this->lockedRepository = $lockedRepository;
  13261. }
  13262. public function requireName(string $packageName, ?ConstraintInterface $constraint = null): void
  13263. {
  13264. $packageName = strtolower($packageName);
  13265. if ($constraint === null) {
  13266. $constraint = new MatchAllConstraint();
  13267. }
  13268. if (isset($this->requires[$packageName])) {
  13269. 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');
  13270. }
  13271. $this->requires[$packageName] = $constraint;
  13272. }
  13273. public function fixPackage(BasePackage $package): void
  13274. {
  13275. $this->fixedPackages[spl_object_hash($package)] = $package;
  13276. }
  13277. public function lockPackage(BasePackage $package): void
  13278. {
  13279. $this->lockedPackages[spl_object_hash($package)] = $package;
  13280. }
  13281. public function fixLockedPackage(BasePackage $package): void
  13282. {
  13283. $this->fixedPackages[spl_object_hash($package)] = $package;
  13284. $this->fixedLockedPackages[spl_object_hash($package)] = $package;
  13285. }
  13286. public function unlockPackage(BasePackage $package): void
  13287. {
  13288. unset($this->lockedPackages[spl_object_hash($package)]);
  13289. }
  13290. public function setUpdateAllowList(array $updateAllowList, $updateAllowTransitiveDependencies): void
  13291. {
  13292. $this->updateAllowList = $updateAllowList;
  13293. $this->updateAllowTransitiveDependencies = $updateAllowTransitiveDependencies;
  13294. }
  13295. public function getUpdateAllowList(): array
  13296. {
  13297. return $this->updateAllowList;
  13298. }
  13299. public function getUpdateAllowTransitiveDependencies(): bool
  13300. {
  13301. return $this->updateAllowTransitiveDependencies !== self::UPDATE_ONLY_LISTED;
  13302. }
  13303. public function getUpdateAllowTransitiveRootDependencies(): bool
  13304. {
  13305. return $this->updateAllowTransitiveDependencies === self::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  13306. }
  13307. public function getRequires(): array
  13308. {
  13309. return $this->requires;
  13310. }
  13311. public function getFixedPackages(): array
  13312. {
  13313. return $this->fixedPackages;
  13314. }
  13315. public function isFixedPackage(BasePackage $package): bool
  13316. {
  13317. return isset($this->fixedPackages[spl_object_hash($package)]);
  13318. }
  13319. public function getLockedPackages(): array
  13320. {
  13321. return $this->lockedPackages;
  13322. }
  13323. public function isLockedPackage(PackageInterface $package): bool
  13324. {
  13325. return isset($this->lockedPackages[spl_object_hash($package)]) || isset($this->fixedLockedPackages[spl_object_hash($package)]);
  13326. }
  13327. public function getFixedOrLockedPackages(): array
  13328. {
  13329. return array_merge($this->fixedPackages, $this->lockedPackages);
  13330. }
  13331. public function getPresentMap(bool $packageIds = false): array
  13332. {
  13333. $presentMap = [];
  13334. if ($this->lockedRepository) {
  13335. foreach ($this->lockedRepository->getPackages() as $package) {
  13336. $presentMap[$packageIds ? $package->getId() : spl_object_hash($package)] = $package;
  13337. }
  13338. }
  13339. foreach ($this->fixedPackages as $package) {
  13340. $presentMap[$packageIds ? $package->getId() : spl_object_hash($package)] = $package;
  13341. }
  13342. return $presentMap;
  13343. }
  13344. public function getFixedPackagesMap(): array
  13345. {
  13346. $fixedPackagesMap = [];
  13347. foreach ($this->fixedPackages as $package) {
  13348. $fixedPackagesMap[$package->getId()] = $package;
  13349. }
  13350. return $fixedPackagesMap;
  13351. }
  13352. public function getLockedRepository(): ?LockArrayRepository
  13353. {
  13354. return $this->lockedRepository;
  13355. }
  13356. public function restrictPackages(array $names): void
  13357. {
  13358. $this->restrictedPackages = $names;
  13359. }
  13360. public function getRestrictedPackages(): ?array
  13361. {
  13362. return $this->restrictedPackages;
  13363. }
  13364. }
  13365. <?php declare(strict_types=1);
  13366. namespace Composer\DependencyResolver;
  13367. use Composer\Package\AliasPackage;
  13368. use Composer\Package\BasePackage;
  13369. use Composer\Package\Link;
  13370. use Composer\Repository\PlatformRepository;
  13371. use Composer\Repository\RepositorySet;
  13372. use Composer\Package\Version\VersionParser;
  13373. use Composer\Semver\Constraint\Constraint;
  13374. use Composer\Semver\Constraint\ConstraintInterface;
  13375. abstract class Rule
  13376. {
  13377. public const RULE_ROOT_REQUIRE = 2;
  13378. public const RULE_FIXED = 3;
  13379. public const RULE_PACKAGE_CONFLICT = 6;
  13380. public const RULE_PACKAGE_REQUIRES = 7;
  13381. public const RULE_PACKAGE_SAME_NAME = 10;
  13382. public const RULE_LEARNED = 12;
  13383. public const RULE_PACKAGE_ALIAS = 13;
  13384. public const RULE_PACKAGE_INVERSE_ALIAS = 14;
  13385. private const BITFIELD_TYPE = 0;
  13386. private const BITFIELD_REASON = 8;
  13387. private const BITFIELD_DISABLED = 16;
  13388. protected $bitfield;
  13389. protected $request;
  13390. protected $reasonData;
  13391. public function __construct($reason, $reasonData)
  13392. {
  13393. $this->reasonData = $reasonData;
  13394. $this->bitfield = (0 << self::BITFIELD_DISABLED) |
  13395. ($reason << self::BITFIELD_REASON) |
  13396. (255 << self::BITFIELD_TYPE);
  13397. }
  13398. abstract public function getLiterals(): array;
  13399. abstract public function getHash();
  13400. abstract public function __toString(): string;
  13401. abstract public function equals(Rule $rule): bool;
  13402. public function getReason(): int
  13403. {
  13404. return ($this->bitfield & (255 << self::BITFIELD_REASON)) >> self::BITFIELD_REASON;
  13405. }
  13406. public function getReasonData()
  13407. {
  13408. return $this->reasonData;
  13409. }
  13410. public function getRequiredPackage(): ?string
  13411. {
  13412. switch ($this->getReason()) {
  13413. case self::RULE_ROOT_REQUIRE:
  13414. return $this->getReasonData()['packageName'];
  13415. case self::RULE_FIXED:
  13416. return $this->getReasonData()['package']->getName();
  13417. case self::RULE_PACKAGE_REQUIRES:
  13418. return $this->getReasonData()->getTarget();
  13419. }
  13420. return null;
  13421. }
  13422. public function setType($type): void
  13423. {
  13424. $this->bitfield = ($this->bitfield & ~(255 << self::BITFIELD_TYPE)) | ((255 & $type) << self::BITFIELD_TYPE);
  13425. }
  13426. public function getType(): int
  13427. {
  13428. return ($this->bitfield & (255 << self::BITFIELD_TYPE)) >> self::BITFIELD_TYPE;
  13429. }
  13430. public function disable(): void
  13431. {
  13432. $this->bitfield = ($this->bitfield & ~(255 << self::BITFIELD_DISABLED)) | (1 << self::BITFIELD_DISABLED);
  13433. }
  13434. public function enable(): void
  13435. {
  13436. $this->bitfield &= ~(255 << self::BITFIELD_DISABLED);
  13437. }
  13438. public function isDisabled(): bool
  13439. {
  13440. return (bool) (($this->bitfield & (255 << self::BITFIELD_DISABLED)) >> self::BITFIELD_DISABLED);
  13441. }
  13442. public function isEnabled(): bool
  13443. {
  13444. return !(($this->bitfield & (255 << self::BITFIELD_DISABLED)) >> self::BITFIELD_DISABLED);
  13445. }
  13446. abstract public function isAssertion(): bool;
  13447. public function isCausedByLock(RepositorySet $repositorySet, Request $request, Pool $pool): bool
  13448. {
  13449. if ($this->getReason() === self::RULE_PACKAGE_REQUIRES) {
  13450. if (PlatformRepository::isPlatformPackage($this->getReasonData()->getTarget())) {
  13451. return false;
  13452. }
  13453. if ($request->getLockedRepository()) {
  13454. foreach ($request->getLockedRepository()->getPackages() as $package) {
  13455. if ($package->getName() === $this->getReasonData()->getTarget()) {
  13456. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  13457. return true;
  13458. }
  13459. if (!$this->getReasonData()->getConstraint()->matches(new Constraint('=', $package->getVersion()))) {
  13460. return true;
  13461. }
  13462. if (!$request->isLockedPackage($package)) {
  13463. return true;
  13464. }
  13465. break;
  13466. }
  13467. }
  13468. }
  13469. }
  13470. if ($this->getReason() === self::RULE_ROOT_REQUIRE) {
  13471. if (PlatformRepository::isPlatformPackage($this->getReasonData()['packageName'])) {
  13472. return false;
  13473. }
  13474. if ($request->getLockedRepository()) {
  13475. foreach ($request->getLockedRepository()->getPackages() as $package) {
  13476. if ($package->getName() === $this->getReasonData()['packageName']) {
  13477. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  13478. return true;
  13479. }
  13480. if (!$this->getReasonData()['constraint']->matches(new Constraint('=', $package->getVersion()))) {
  13481. return true;
  13482. }
  13483. break;
  13484. }
  13485. }
  13486. }
  13487. }
  13488. return false;
  13489. }
  13490. public function getSourcePackage(Pool $pool): BasePackage
  13491. {
  13492. $literals = $this->getLiterals();
  13493. switch ($this->getReason()) {
  13494. case self::RULE_PACKAGE_CONFLICT:
  13495. $package1 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[0]));
  13496. $package2 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
  13497. $reasonData = $this->getReasonData();
  13498. if ($reasonData->getSource() === $package1->getName()) {
  13499. [$package2, $package1] = [$package1, $package2];
  13500. }
  13501. return $package2;
  13502. case self::RULE_PACKAGE_REQUIRES:
  13503. $sourceLiteral = array_shift($literals);
  13504. $sourcePackage = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($sourceLiteral));
  13505. return $sourcePackage;
  13506. default:
  13507. throw new \LogicException('Not implemented');
  13508. }
  13509. }
  13510. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, bool $isVerbose, array $installedMap = [], array $learnedPool = []): string
  13511. {
  13512. $literals = $this->getLiterals();
  13513. switch ($this->getReason()) {
  13514. case self::RULE_ROOT_REQUIRE:
  13515. $reasonData = $this->getReasonData();
  13516. $packageName = $reasonData['packageName'];
  13517. $constraint = $reasonData['constraint'];
  13518. $packages = $pool->whatProvides($packageName, $constraint);
  13519. if (!$packages) {
  13520. return 'No package found to satisfy root composer.json require '.$packageName.' '.$constraint->getPrettyString();
  13521. }
  13522. $packagesNonAlias = array_values(array_filter($packages, static function ($p): bool {
  13523. return !($p instanceof AliasPackage);
  13524. }));
  13525. if (count($packagesNonAlias) === 1) {
  13526. $package = $packagesNonAlias[0];
  13527. if ($request->isLockedPackage($package)) {
  13528. return $package->getPrettyName().' is locked to version '.$package->getPrettyVersion()." and an update of this package was not requested.";
  13529. }
  13530. }
  13531. return 'Root composer.json requires '.$packageName.' '.$constraint->getPrettyString().' -> satisfiable by '.$this->formatPackagesUnique($pool, $packages, $isVerbose, $constraint).'.';
  13532. case self::RULE_FIXED:
  13533. $package = $this->deduplicateDefaultBranchAlias($this->getReasonData()['package']);
  13534. if ($request->isLockedPackage($package)) {
  13535. return $package->getPrettyName().' is locked to version '.$package->getPrettyVersion().' and an update of this package was not requested.';
  13536. }
  13537. return $package->getPrettyName().' is present at version '.$package->getPrettyVersion() . ' and cannot be modified by Composer';
  13538. case self::RULE_PACKAGE_CONFLICT:
  13539. $package1 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[0]));
  13540. $package2 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
  13541. $conflictTarget = $package1->getPrettyString();
  13542. $reasonData = $this->getReasonData();
  13543. if ($reasonData->getSource() === $package1->getName()) {
  13544. [$package2, $package1] = [$package1, $package2];
  13545. $conflictTarget = $package1->getPrettyName().' '.$reasonData->getPrettyConstraint();
  13546. }
  13547. if ($reasonData->getTarget() !== $package1->getName()) {
  13548. $provideType = null;
  13549. $provided = null;
  13550. foreach ($package1->getProvides() as $provide) {
  13551. if ($provide->getTarget() === $reasonData->getTarget()) {
  13552. $provideType = 'provides';
  13553. $provided = $provide->getPrettyConstraint();
  13554. break;
  13555. }
  13556. }
  13557. foreach ($package1->getReplaces() as $replace) {
  13558. if ($replace->getTarget() === $reasonData->getTarget()) {
  13559. $provideType = 'replaces';
  13560. $provided = $replace->getPrettyConstraint();
  13561. break;
  13562. }
  13563. }
  13564. if (null !== $provideType) {
  13565. $conflictTarget = $reasonData->getTarget().' '.$reasonData->getPrettyConstraint().' ('.$package1->getPrettyString().' '.$provideType.' '.$reasonData->getTarget().' '.$provided.')';
  13566. }
  13567. }
  13568. return $package2->getPrettyString().' conflicts with '.$conflictTarget.'.';
  13569. case self::RULE_PACKAGE_REQUIRES:
  13570. $sourceLiteral = array_shift($literals);
  13571. $sourcePackage = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($sourceLiteral));
  13572. $reasonData = $this->getReasonData();
  13573. $requires = [];
  13574. foreach ($literals as $literal) {
  13575. $requires[] = $pool->literalToPackage($literal);
  13576. }
  13577. $text = $reasonData->getPrettyString($sourcePackage);
  13578. if ($requires) {
  13579. $text .= ' -> satisfiable by ' . $this->formatPackagesUnique($pool, $requires, $isVerbose, $reasonData->getConstraint()) . '.';
  13580. } else {
  13581. $targetName = $reasonData->getTarget();
  13582. $reason = Problem::getMissingPackageReason($repositorySet, $request, $pool, $isVerbose, $targetName, $reasonData->getConstraint());
  13583. return $text . ' -> ' . $reason[1];
  13584. }
  13585. return $text;
  13586. case self::RULE_PACKAGE_SAME_NAME:
  13587. $packageNames = [];
  13588. foreach ($literals as $literal) {
  13589. $package = $pool->literalToPackage($literal);
  13590. $packageNames[$package->getName()] = true;
  13591. }
  13592. $replacedName = $this->getReasonData();
  13593. if (count($packageNames) > 1) {
  13594. $reason = null;
  13595. if (!isset($packageNames[$replacedName])) {
  13596. $reason = 'They '.(count($literals) === 2 ? 'both' : 'all').' replace '.$replacedName.' and thus cannot coexist.';
  13597. } else {
  13598. $replacerNames = $packageNames;
  13599. unset($replacerNames[$replacedName]);
  13600. $replacerNames = array_keys($replacerNames);
  13601. if (count($replacerNames) === 1) {
  13602. $reason = $replacerNames[0] . ' replaces ';
  13603. } else {
  13604. $reason = '['.implode(', ', $replacerNames).'] replace ';
  13605. }
  13606. $reason .= $replacedName.' and thus cannot coexist with it.';
  13607. }
  13608. $installedPackages = [];
  13609. $removablePackages = [];
  13610. foreach ($literals as $literal) {
  13611. if (isset($installedMap[abs($literal)])) {
  13612. $installedPackages[] = $pool->literalToPackage($literal);
  13613. } else {
  13614. $removablePackages[] = $pool->literalToPackage($literal);
  13615. }
  13616. }
  13617. if ($installedPackages && $removablePackages) {
  13618. return $this->formatPackagesUnique($pool, $removablePackages, $isVerbose, null, true).' cannot be installed as that would require removing '.$this->formatPackagesUnique($pool, $installedPackages, $isVerbose, null, true).'. '.$reason;
  13619. }
  13620. return 'Only one of these can be installed: '.$this->formatPackagesUnique($pool, $literals, $isVerbose, null, true).'. '.$reason;
  13621. }
  13622. 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) . '.';
  13623. case self::RULE_LEARNED:
  13624. $learnedString = ' (conflict analysis result)';
  13625. if (count($literals) === 1) {
  13626. $ruleText = $pool->literalToPrettyString($literals[0], $installedMap);
  13627. } else {
  13628. $groups = [];
  13629. foreach ($literals as $literal) {
  13630. $package = $pool->literalToPackage($literal);
  13631. if (isset($installedMap[$package->id])) {
  13632. $group = $literal > 0 ? 'keep' : 'remove';
  13633. } else {
  13634. $group = $literal > 0 ? 'install' : 'don\'t install';
  13635. }
  13636. $groups[$group][] = $this->deduplicateDefaultBranchAlias($package);
  13637. }
  13638. $ruleTexts = [];
  13639. foreach ($groups as $group => $packages) {
  13640. $ruleTexts[] = $group . (count($packages) > 1 ? ' one of' : '').' ' . $this->formatPackagesUnique($pool, $packages, $isVerbose);
  13641. }
  13642. $ruleText = implode(' | ', $ruleTexts);
  13643. }
  13644. return 'Conclusion: '.$ruleText.$learnedString;
  13645. case self::RULE_PACKAGE_ALIAS:
  13646. $aliasPackage = $pool->literalToPackage($literals[0]);
  13647. if ($aliasPackage->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  13648. return '';
  13649. }
  13650. $package = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
  13651. return $aliasPackage->getPrettyString() .' is an alias of '.$package->getPrettyString().' and thus requires it to be installed too.';
  13652. case self::RULE_PACKAGE_INVERSE_ALIAS:
  13653. $aliasPackage = $pool->literalToPackage($literals[1]);
  13654. if ($aliasPackage->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  13655. return '';
  13656. }
  13657. $package = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[0]));
  13658. return $aliasPackage->getPrettyString() .' is an alias of '.$package->getPrettyString().' and must be installed with it.';
  13659. default:
  13660. $ruleText = '';
  13661. foreach ($literals as $i => $literal) {
  13662. if ($i !== 0) {
  13663. $ruleText .= '|';
  13664. }
  13665. $ruleText .= $pool->literalToPrettyString($literal, $installedMap);
  13666. }
  13667. return '('.$ruleText.')';
  13668. }
  13669. }
  13670. protected function formatPackagesUnique(Pool $pool, array $packages, bool $isVerbose, ?ConstraintInterface $constraint = null, bool $useRemovedVersionGroup = false): string
  13671. {
  13672. foreach ($packages as $index => $package) {
  13673. if (!\is_object($package)) {
  13674. $packages[$index] = $pool->literalToPackage($package);
  13675. }
  13676. }
  13677. return Problem::getPackageList($packages, $isVerbose, $pool, $constraint, $useRemovedVersionGroup);
  13678. }
  13679. private function deduplicateDefaultBranchAlias(BasePackage $package): BasePackage
  13680. {
  13681. if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  13682. $package = $package->getAliasOf();
  13683. }
  13684. return $package;
  13685. }
  13686. }
  13687. <?php declare(strict_types=1);
  13688. namespace Composer\DependencyResolver;
  13689. class Rule2Literals extends Rule
  13690. {
  13691. protected $literal1;
  13692. protected $literal2;
  13693. public function __construct(int $literal1, int $literal2, $reason, $reasonData)
  13694. {
  13695. parent::__construct($reason, $reasonData);
  13696. if ($literal1 < $literal2) {
  13697. $this->literal1 = $literal1;
  13698. $this->literal2 = $literal2;
  13699. } else {
  13700. $this->literal1 = $literal2;
  13701. $this->literal2 = $literal1;
  13702. }
  13703. }
  13704. public function getLiterals(): array
  13705. {
  13706. return [$this->literal1, $this->literal2];
  13707. }
  13708. public function getHash()
  13709. {
  13710. return $this->literal1.','.$this->literal2;
  13711. }
  13712. public function equals(Rule $rule): bool
  13713. {
  13714. if ($rule instanceof self) {
  13715. if ($this->literal1 !== $rule->literal1) {
  13716. return false;
  13717. }
  13718. if ($this->literal2 !== $rule->literal2) {
  13719. return false;
  13720. }
  13721. return true;
  13722. }
  13723. $literals = $rule->getLiterals();
  13724. if (2 !== \count($literals)) {
  13725. return false;
  13726. }
  13727. if ($this->literal1 !== $literals[0]) {
  13728. return false;
  13729. }
  13730. if ($this->literal2 !== $literals[1]) {
  13731. return false;
  13732. }
  13733. return true;
  13734. }
  13735. public function isAssertion(): bool
  13736. {
  13737. return false;
  13738. }
  13739. public function __toString(): string
  13740. {
  13741. $result = $this->isDisabled() ? 'disabled(' : '(';
  13742. $result .= $this->literal1 . '|' . $this->literal2 . ')';
  13743. return $result;
  13744. }
  13745. }
  13746. <?php declare(strict_types=1);
  13747. namespace Composer\DependencyResolver;
  13748. use Composer\Repository\RepositorySet;
  13749. class RuleSet implements \IteratorAggregate, \Countable
  13750. {
  13751. public const TYPE_PACKAGE = 0;
  13752. public const TYPE_REQUEST = 1;
  13753. public const TYPE_LEARNED = 4;
  13754. public $ruleById = [];
  13755. const TYPES = [
  13756. self::TYPE_PACKAGE => 'PACKAGE',
  13757. self::TYPE_REQUEST => 'REQUEST',
  13758. self::TYPE_LEARNED => 'LEARNED',
  13759. ];
  13760. protected $rules;
  13761. protected $nextRuleId = 0;
  13762. protected $rulesByHash = [];
  13763. public function __construct()
  13764. {
  13765. foreach ($this->getTypes() as $type) {
  13766. $this->rules[$type] = [];
  13767. }
  13768. }
  13769. public function add(Rule $rule, $type): void
  13770. {
  13771. if (!isset(self::TYPES[$type])) {
  13772. throw new \OutOfBoundsException('Unknown rule type: ' . $type);
  13773. }
  13774. $hash = $rule->getHash();
  13775. if (isset($this->rulesByHash[$hash])) {
  13776. $potentialDuplicates = $this->rulesByHash[$hash];
  13777. if (\is_array($potentialDuplicates)) {
  13778. foreach ($potentialDuplicates as $potentialDuplicate) {
  13779. if ($rule->equals($potentialDuplicate)) {
  13780. return;
  13781. }
  13782. }
  13783. } else {
  13784. if ($rule->equals($potentialDuplicates)) {
  13785. return;
  13786. }
  13787. }
  13788. }
  13789. if (!isset($this->rules[$type])) {
  13790. $this->rules[$type] = [];
  13791. }
  13792. $this->rules[$type][] = $rule;
  13793. $this->ruleById[$this->nextRuleId] = $rule;
  13794. $rule->setType($type);
  13795. $this->nextRuleId++;
  13796. if (!isset($this->rulesByHash[$hash])) {
  13797. $this->rulesByHash[$hash] = $rule;
  13798. } elseif (\is_array($this->rulesByHash[$hash])) {
  13799. $this->rulesByHash[$hash][] = $rule;
  13800. } else {
  13801. $originalRule = $this->rulesByHash[$hash];
  13802. $this->rulesByHash[$hash] = [$originalRule, $rule];
  13803. }
  13804. }
  13805. public function count(): int
  13806. {
  13807. return $this->nextRuleId;
  13808. }
  13809. public function ruleById(int $id): Rule
  13810. {
  13811. return $this->ruleById[$id];
  13812. }
  13813. public function getRules(): array
  13814. {
  13815. return $this->rules;
  13816. }
  13817. public function getIterator(): RuleSetIterator
  13818. {
  13819. return new RuleSetIterator($this->getRules());
  13820. }
  13821. public function getIteratorFor($types): RuleSetIterator
  13822. {
  13823. if (!\is_array($types)) {
  13824. $types = [$types];
  13825. }
  13826. $allRules = $this->getRules();
  13827. $rules = [];
  13828. foreach ($types as $type) {
  13829. $rules[$type] = $allRules[$type];
  13830. }
  13831. return new RuleSetIterator($rules);
  13832. }
  13833. public function getIteratorWithout($types): RuleSetIterator
  13834. {
  13835. if (!\is_array($types)) {
  13836. $types = [$types];
  13837. }
  13838. $rules = $this->getRules();
  13839. foreach ($types as $type) {
  13840. unset($rules[$type]);
  13841. }
  13842. return new RuleSetIterator($rules);
  13843. }
  13844. public function getTypes(): array
  13845. {
  13846. $types = self::TYPES;
  13847. return array_keys($types);
  13848. }
  13849. public function getPrettyString(?RepositorySet $repositorySet = null, ?Request $request = null, ?Pool $pool = null, bool $isVerbose = false): string
  13850. {
  13851. $string = "\n";
  13852. foreach ($this->rules as $type => $rules) {
  13853. $string .= str_pad(self::TYPES[$type], 8, ' ') . ": ";
  13854. foreach ($rules as $rule) {
  13855. $string .= ($repositorySet && $request && $pool ? $rule->getPrettyString($repositorySet, $request, $pool, $isVerbose) : $rule)."\n";
  13856. }
  13857. $string .= "\n\n";
  13858. }
  13859. return $string;
  13860. }
  13861. public function __toString(): string
  13862. {
  13863. return $this->getPrettyString();
  13864. }
  13865. }
  13866. <?php declare(strict_types=1);
  13867. namespace Composer\DependencyResolver;
  13868. use Composer\Filter\PlatformRequirementFilter\IgnoreListPlatformRequirementFilter;
  13869. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  13870. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  13871. use Composer\Package\BasePackage;
  13872. use Composer\Package\AliasPackage;
  13873. class RuleSetGenerator
  13874. {
  13875. protected $policy;
  13876. protected $pool;
  13877. protected $rules;
  13878. protected $addedMap = [];
  13879. protected $addedPackagesByNames = [];
  13880. public function __construct(PolicyInterface $policy, Pool $pool)
  13881. {
  13882. $this->policy = $policy;
  13883. $this->pool = $pool;
  13884. $this->rules = new RuleSet;
  13885. }
  13886. protected function createRequireRule(BasePackage $package, array $providers, $reason, $reasonData = null): ?Rule
  13887. {
  13888. $literals = [-$package->id];
  13889. foreach ($providers as $provider) {
  13890. if ($provider === $package) {
  13891. return null;
  13892. }
  13893. $literals[] = $provider->id;
  13894. }
  13895. return new GenericRule($literals, $reason, $reasonData);
  13896. }
  13897. protected function createInstallOneOfRule(array $packages, $reason, $reasonData): Rule
  13898. {
  13899. $literals = [];
  13900. foreach ($packages as $package) {
  13901. $literals[] = $package->id;
  13902. }
  13903. return new GenericRule($literals, $reason, $reasonData);
  13904. }
  13905. protected function createRule2Literals(BasePackage $issuer, BasePackage $provider, $reason, $reasonData = null): ?Rule
  13906. {
  13907. if ($issuer === $provider) {
  13908. return null;
  13909. }
  13910. return new Rule2Literals(-$issuer->id, -$provider->id, $reason, $reasonData);
  13911. }
  13912. protected function createMultiConflictRule(array $packages, $reason, $reasonData): Rule
  13913. {
  13914. $literals = [];
  13915. foreach ($packages as $package) {
  13916. $literals[] = -$package->id;
  13917. }
  13918. if (\count($literals) === 2) {
  13919. return new Rule2Literals($literals[0], $literals[1], $reason, $reasonData);
  13920. }
  13921. return new MultiConflictRule($literals, $reason, $reasonData);
  13922. }
  13923. private function addRule($type, ?Rule $newRule = null): void
  13924. {
  13925. if (!$newRule) {
  13926. return;
  13927. }
  13928. $this->rules->add($newRule, $type);
  13929. }
  13930. protected function addRulesForPackage(BasePackage $package, PlatformRequirementFilterInterface $platformRequirementFilter): void
  13931. {
  13932. $workQueue = new \SplQueue;
  13933. $workQueue->enqueue($package);
  13934. while (!$workQueue->isEmpty()) {
  13935. $package = $workQueue->dequeue();
  13936. if (isset($this->addedMap[$package->id])) {
  13937. continue;
  13938. }
  13939. $this->addedMap[$package->id] = $package;
  13940. if (!$package instanceof AliasPackage) {
  13941. foreach ($package->getNames(false) as $name) {
  13942. $this->addedPackagesByNames[$name][] = $package;
  13943. }
  13944. } else {
  13945. $workQueue->enqueue($package->getAliasOf());
  13946. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, [$package->getAliasOf()], Rule::RULE_PACKAGE_ALIAS, $package));
  13947. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package->getAliasOf(), [$package], Rule::RULE_PACKAGE_INVERSE_ALIAS, $package->getAliasOf()));
  13948. if (!$package->hasSelfVersionRequires()) {
  13949. continue;
  13950. }
  13951. }
  13952. foreach ($package->getRequires() as $link) {
  13953. $constraint = $link->getConstraint();
  13954. if ($platformRequirementFilter->isIgnored($link->getTarget())) {
  13955. continue;
  13956. } elseif ($platformRequirementFilter instanceof IgnoreListPlatformRequirementFilter) {
  13957. $constraint = $platformRequirementFilter->filterConstraint($link->getTarget(), $constraint);
  13958. }
  13959. $possibleRequires = $this->pool->whatProvides($link->getTarget(), $constraint);
  13960. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, $possibleRequires, Rule::RULE_PACKAGE_REQUIRES, $link));
  13961. foreach ($possibleRequires as $require) {
  13962. $workQueue->enqueue($require);
  13963. }
  13964. }
  13965. }
  13966. }
  13967. protected function addConflictRules(PlatformRequirementFilterInterface $platformRequirementFilter): void
  13968. {
  13969. foreach ($this->addedMap as $package) {
  13970. foreach ($package->getConflicts() as $link) {
  13971. if (!isset($this->addedPackagesByNames[$link->getTarget()])) {
  13972. continue;
  13973. }
  13974. $constraint = $link->getConstraint();
  13975. if ($platformRequirementFilter->isIgnored($link->getTarget())) {
  13976. continue;
  13977. } elseif ($platformRequirementFilter instanceof IgnoreListPlatformRequirementFilter) {
  13978. $constraint = $platformRequirementFilter->filterConstraint($link->getTarget(), $constraint, false);
  13979. }
  13980. $conflicts = $this->pool->whatProvides($link->getTarget(), $constraint);
  13981. foreach ($conflicts as $conflict) {
  13982. if (!$conflict instanceof AliasPackage || $conflict->getName() === $link->getTarget()) {
  13983. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRule2Literals($package, $conflict, Rule::RULE_PACKAGE_CONFLICT, $link));
  13984. }
  13985. }
  13986. }
  13987. }
  13988. foreach ($this->addedPackagesByNames as $name => $packages) {
  13989. if (\count($packages) > 1) {
  13990. $reason = Rule::RULE_PACKAGE_SAME_NAME;
  13991. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createMultiConflictRule($packages, $reason, $name));
  13992. }
  13993. }
  13994. }
  13995. protected function addRulesForRequest(Request $request, PlatformRequirementFilterInterface $platformRequirementFilter): void
  13996. {
  13997. foreach ($request->getFixedPackages() as $package) {
  13998. if ($package->id === -1) {
  13999. if ($this->pool->isUnacceptableFixedOrLockedPackage($package)) {
  14000. continue;
  14001. }
  14002. throw new \LogicException("Fixed package ".$package->getPrettyString()." was not added to solver pool.");
  14003. }
  14004. $this->addRulesForPackage($package, $platformRequirementFilter);
  14005. $rule = $this->createInstallOneOfRule([$package], Rule::RULE_FIXED, [
  14006. 'package' => $package,
  14007. ]);
  14008. $this->addRule(RuleSet::TYPE_REQUEST, $rule);
  14009. }
  14010. foreach ($request->getRequires() as $packageName => $constraint) {
  14011. if ($platformRequirementFilter->isIgnored($packageName)) {
  14012. continue;
  14013. } elseif ($platformRequirementFilter instanceof IgnoreListPlatformRequirementFilter) {
  14014. $constraint = $platformRequirementFilter->filterConstraint($packageName, $constraint);
  14015. }
  14016. $packages = $this->pool->whatProvides($packageName, $constraint);
  14017. if ($packages) {
  14018. foreach ($packages as $package) {
  14019. $this->addRulesForPackage($package, $platformRequirementFilter);
  14020. }
  14021. $rule = $this->createInstallOneOfRule($packages, Rule::RULE_ROOT_REQUIRE, [
  14022. 'packageName' => $packageName,
  14023. 'constraint' => $constraint,
  14024. ]);
  14025. $this->addRule(RuleSet::TYPE_REQUEST, $rule);
  14026. }
  14027. }
  14028. }
  14029. protected function addRulesForRootAliases(PlatformRequirementFilterInterface $platformRequirementFilter): void
  14030. {
  14031. foreach ($this->pool->getPackages() as $package) {
  14032. if (!isset($this->addedMap[$package->id]) &&
  14033. $package instanceof AliasPackage &&
  14034. ($package->isRootPackageAlias() || isset($this->addedMap[$package->getAliasOf()->id]))
  14035. ) {
  14036. $this->addRulesForPackage($package, $platformRequirementFilter);
  14037. }
  14038. }
  14039. }
  14040. public function getRulesFor(Request $request, ?PlatformRequirementFilterInterface $platformRequirementFilter = null): RuleSet
  14041. {
  14042. $platformRequirementFilter = $platformRequirementFilter ?: PlatformRequirementFilterFactory::ignoreNothing();
  14043. $this->addRulesForRequest($request, $platformRequirementFilter);
  14044. $this->addRulesForRootAliases($platformRequirementFilter);
  14045. $this->addConflictRules($platformRequirementFilter);
  14046. $this->addedMap = $this->addedPackagesByNames = [];
  14047. $rules = $this->rules;
  14048. $this->rules = new RuleSet;
  14049. return $rules;
  14050. }
  14051. }
  14052. <?php declare(strict_types=1);
  14053. namespace Composer\DependencyResolver;
  14054. class RuleSetIterator implements \Iterator
  14055. {
  14056. protected $rules;
  14057. protected $types;
  14058. protected $currentOffset;
  14059. protected $currentType;
  14060. protected $currentTypeOffset;
  14061. public function __construct(array $rules)
  14062. {
  14063. $this->rules = $rules;
  14064. $this->types = array_keys($rules);
  14065. sort($this->types);
  14066. $this->rewind();
  14067. }
  14068. public function current(): Rule
  14069. {
  14070. return $this->rules[$this->currentType][$this->currentOffset];
  14071. }
  14072. public function key(): int
  14073. {
  14074. return $this->currentType;
  14075. }
  14076. public function next(): void
  14077. {
  14078. $this->currentOffset++;
  14079. if (!isset($this->rules[$this->currentType])) {
  14080. return;
  14081. }
  14082. if ($this->currentOffset >= \count($this->rules[$this->currentType])) {
  14083. $this->currentOffset = 0;
  14084. do {
  14085. $this->currentTypeOffset++;
  14086. if (!isset($this->types[$this->currentTypeOffset])) {
  14087. $this->currentType = -1;
  14088. break;
  14089. }
  14090. $this->currentType = $this->types[$this->currentTypeOffset];
  14091. } while (0 === \count($this->rules[$this->currentType]));
  14092. }
  14093. }
  14094. public function rewind(): void
  14095. {
  14096. $this->currentOffset = 0;
  14097. $this->currentTypeOffset = -1;
  14098. $this->currentType = -1;
  14099. do {
  14100. $this->currentTypeOffset++;
  14101. if (!isset($this->types[$this->currentTypeOffset])) {
  14102. $this->currentType = -1;
  14103. break;
  14104. }
  14105. $this->currentType = $this->types[$this->currentTypeOffset];
  14106. } while (0 === \count($this->rules[$this->currentType]));
  14107. }
  14108. public function valid(): bool
  14109. {
  14110. return isset($this->rules[$this->currentType], $this->rules[$this->currentType][$this->currentOffset]);
  14111. }
  14112. }
  14113. <?php declare(strict_types=1);
  14114. namespace Composer\DependencyResolver;
  14115. class RuleWatchChain extends \SplDoublyLinkedList
  14116. {
  14117. public function seek(int $offset): void
  14118. {
  14119. $this->rewind();
  14120. for ($i = 0; $i < $offset; $i++, $this->next());
  14121. }
  14122. public function remove(): void
  14123. {
  14124. $offset = $this->key();
  14125. $this->offsetUnset($offset);
  14126. $this->seek($offset);
  14127. }
  14128. }
  14129. <?php declare(strict_types=1);
  14130. namespace Composer\DependencyResolver;
  14131. class RuleWatchGraph
  14132. {
  14133. protected $watchChains = [];
  14134. public function insert(RuleWatchNode $node): void
  14135. {
  14136. if ($node->getRule()->isAssertion()) {
  14137. return;
  14138. }
  14139. if (!$node->getRule() instanceof MultiConflictRule) {
  14140. foreach ([$node->watch1, $node->watch2] as $literal) {
  14141. if (!isset($this->watchChains[$literal])) {
  14142. $this->watchChains[$literal] = new RuleWatchChain;
  14143. }
  14144. $this->watchChains[$literal]->unshift($node);
  14145. }
  14146. } else {
  14147. foreach ($node->getRule()->getLiterals() as $literal) {
  14148. if (!isset($this->watchChains[$literal])) {
  14149. $this->watchChains[$literal] = new RuleWatchChain;
  14150. }
  14151. $this->watchChains[$literal]->unshift($node);
  14152. }
  14153. }
  14154. }
  14155. public function propagateLiteral(int $decidedLiteral, int $level, Decisions $decisions): ?Rule
  14156. {
  14157. $literal = -$decidedLiteral;
  14158. if (!isset($this->watchChains[$literal])) {
  14159. return null;
  14160. }
  14161. $chain = $this->watchChains[$literal];
  14162. $chain->rewind();
  14163. while ($chain->valid()) {
  14164. $node = $chain->current();
  14165. if (!$node->getRule() instanceof MultiConflictRule) {
  14166. $otherWatch = $node->getOtherWatch($literal);
  14167. if (!$node->getRule()->isDisabled() && !$decisions->satisfy($otherWatch)) {
  14168. $ruleLiterals = $node->getRule()->getLiterals();
  14169. $alternativeLiterals = array_filter($ruleLiterals, static function ($ruleLiteral) use ($literal, $otherWatch, $decisions): bool {
  14170. return $literal !== $ruleLiteral &&
  14171. $otherWatch !== $ruleLiteral &&
  14172. !$decisions->conflict($ruleLiteral);
  14173. });
  14174. if (\count($alternativeLiterals) > 0) {
  14175. reset($alternativeLiterals);
  14176. $this->moveWatch($literal, current($alternativeLiterals), $node);
  14177. continue;
  14178. }
  14179. if ($decisions->conflict($otherWatch)) {
  14180. return $node->getRule();
  14181. }
  14182. $decisions->decide($otherWatch, $level, $node->getRule());
  14183. }
  14184. } else {
  14185. foreach ($node->getRule()->getLiterals() as $otherLiteral) {
  14186. if ($literal !== $otherLiteral && !$decisions->satisfy($otherLiteral)) {
  14187. if ($decisions->conflict($otherLiteral)) {
  14188. return $node->getRule();
  14189. }
  14190. $decisions->decide($otherLiteral, $level, $node->getRule());
  14191. }
  14192. }
  14193. }
  14194. $chain->next();
  14195. }
  14196. return null;
  14197. }
  14198. protected function moveWatch(int $fromLiteral, int $toLiteral, RuleWatchNode $node): void
  14199. {
  14200. if (!isset($this->watchChains[$toLiteral])) {
  14201. $this->watchChains[$toLiteral] = new RuleWatchChain;
  14202. }
  14203. $node->moveWatch($fromLiteral, $toLiteral);
  14204. $this->watchChains[$fromLiteral]->remove();
  14205. $this->watchChains[$toLiteral]->unshift($node);
  14206. }
  14207. }
  14208. <?php declare(strict_types=1);
  14209. namespace Composer\DependencyResolver;
  14210. class RuleWatchNode
  14211. {
  14212. public $watch1;
  14213. public $watch2;
  14214. protected $rule;
  14215. public function __construct(Rule $rule)
  14216. {
  14217. $this->rule = $rule;
  14218. $literals = $rule->getLiterals();
  14219. $literalCount = \count($literals);
  14220. $this->watch1 = $literalCount > 0 ? $literals[0] : 0;
  14221. $this->watch2 = $literalCount > 1 ? $literals[1] : 0;
  14222. }
  14223. public function watch2OnHighest(Decisions $decisions): void
  14224. {
  14225. $literals = $this->rule->getLiterals();
  14226. if (\count($literals) < 3 || $this->rule instanceof MultiConflictRule) {
  14227. return;
  14228. }
  14229. $watchLevel = 0;
  14230. foreach ($literals as $literal) {
  14231. $level = $decisions->decisionLevel($literal);
  14232. if ($level > $watchLevel) {
  14233. $this->watch2 = $literal;
  14234. $watchLevel = $level;
  14235. }
  14236. }
  14237. }
  14238. public function getRule(): Rule
  14239. {
  14240. return $this->rule;
  14241. }
  14242. public function getOtherWatch(int $literal): int
  14243. {
  14244. if ($this->watch1 === $literal) {
  14245. return $this->watch2;
  14246. }
  14247. return $this->watch1;
  14248. }
  14249. public function moveWatch(int $from, int $to): void
  14250. {
  14251. if ($this->watch1 === $from) {
  14252. $this->watch1 = $to;
  14253. } else {
  14254. $this->watch2 = $to;
  14255. }
  14256. }
  14257. }
  14258. <?php declare(strict_types=1);
  14259. namespace Composer\DependencyResolver;
  14260. use Composer\Filter\PlatformRequirementFilter\IgnoreListPlatformRequirementFilter;
  14261. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  14262. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  14263. use Composer\IO\IOInterface;
  14264. use Composer\Package\BasePackage;
  14265. class Solver
  14266. {
  14267. private const BRANCH_LITERALS = 0;
  14268. private const BRANCH_LEVEL = 1;
  14269. protected $policy;
  14270. protected $pool;
  14271. protected $rules;
  14272. protected $watchGraph;
  14273. protected $decisions;
  14274. protected $fixedMap;
  14275. protected $propagateIndex;
  14276. protected $branches = [];
  14277. protected $problems = [];
  14278. protected $learnedPool = [];
  14279. protected $learnedWhy = [];
  14280. public $testFlagLearnedPositiveLiteral = false;
  14281. protected $io;
  14282. public function __construct(PolicyInterface $policy, Pool $pool, IOInterface $io)
  14283. {
  14284. $this->io = $io;
  14285. $this->policy = $policy;
  14286. $this->pool = $pool;
  14287. }
  14288. public function getRuleSetSize(): int
  14289. {
  14290. return \count($this->rules);
  14291. }
  14292. public function getPool(): Pool
  14293. {
  14294. return $this->pool;
  14295. }
  14296. private function makeAssertionRuleDecisions(): void
  14297. {
  14298. $decisionStart = \count($this->decisions) - 1;
  14299. $rulesCount = \count($this->rules);
  14300. for ($ruleIndex = 0; $ruleIndex < $rulesCount; $ruleIndex++) {
  14301. $rule = $this->rules->ruleById[$ruleIndex];
  14302. if (!$rule->isAssertion() || $rule->isDisabled()) {
  14303. continue;
  14304. }
  14305. $literals = $rule->getLiterals();
  14306. $literal = $literals[0];
  14307. if (!$this->decisions->decided($literal)) {
  14308. $this->decisions->decide($literal, 1, $rule);
  14309. continue;
  14310. }
  14311. if ($this->decisions->satisfy($literal)) {
  14312. continue;
  14313. }
  14314. if (RuleSet::TYPE_LEARNED === $rule->getType()) {
  14315. $rule->disable();
  14316. continue;
  14317. }
  14318. $conflict = $this->decisions->decisionRule($literal);
  14319. if ($conflict && RuleSet::TYPE_PACKAGE === $conflict->getType()) {
  14320. $problem = new Problem();
  14321. $problem->addRule($rule);
  14322. $problem->addRule($conflict);
  14323. $rule->disable();
  14324. $this->problems[] = $problem;
  14325. continue;
  14326. }
  14327. $problem = new Problem();
  14328. $problem->addRule($rule);
  14329. $problem->addRule($conflict);
  14330. foreach ($this->rules->getIteratorFor(RuleSet::TYPE_REQUEST) as $assertRule) {
  14331. if ($assertRule->isDisabled() || !$assertRule->isAssertion()) {
  14332. continue;
  14333. }
  14334. $assertRuleLiterals = $assertRule->getLiterals();
  14335. $assertRuleLiteral = $assertRuleLiterals[0];
  14336. if (abs($literal) !== abs($assertRuleLiteral)) {
  14337. continue;
  14338. }
  14339. $problem->addRule($assertRule);
  14340. $assertRule->disable();
  14341. }
  14342. $this->problems[] = $problem;
  14343. $this->decisions->resetToOffset($decisionStart);
  14344. $ruleIndex = -1;
  14345. }
  14346. }
  14347. protected function setupFixedMap(Request $request): void
  14348. {
  14349. $this->fixedMap = [];
  14350. foreach ($request->getFixedPackages() as $package) {
  14351. $this->fixedMap[$package->id] = $package;
  14352. }
  14353. }
  14354. protected function checkForRootRequireProblems(Request $request, PlatformRequirementFilterInterface $platformRequirementFilter): void
  14355. {
  14356. foreach ($request->getRequires() as $packageName => $constraint) {
  14357. if ($platformRequirementFilter->isIgnored($packageName)) {
  14358. continue;
  14359. } elseif ($platformRequirementFilter instanceof IgnoreListPlatformRequirementFilter) {
  14360. $constraint = $platformRequirementFilter->filterConstraint($packageName, $constraint);
  14361. }
  14362. if (!$this->pool->whatProvides($packageName, $constraint)) {
  14363. $problem = new Problem();
  14364. $problem->addRule(new GenericRule([], Rule::RULE_ROOT_REQUIRE, ['packageName' => $packageName, 'constraint' => $constraint]));
  14365. $this->problems[] = $problem;
  14366. }
  14367. }
  14368. }
  14369. public function solve(Request $request, ?PlatformRequirementFilterInterface $platformRequirementFilter = null): LockTransaction
  14370. {
  14371. $platformRequirementFilter = $platformRequirementFilter ?: PlatformRequirementFilterFactory::ignoreNothing();
  14372. $this->setupFixedMap($request);
  14373. $this->io->writeError('Generating rules', true, IOInterface::DEBUG);
  14374. $ruleSetGenerator = new RuleSetGenerator($this->policy, $this->pool);
  14375. $this->rules = $ruleSetGenerator->getRulesFor($request, $platformRequirementFilter);
  14376. unset($ruleSetGenerator);
  14377. $this->checkForRootRequireProblems($request, $platformRequirementFilter);
  14378. $this->decisions = new Decisions($this->pool);
  14379. $this->watchGraph = new RuleWatchGraph;
  14380. foreach ($this->rules as $rule) {
  14381. $this->watchGraph->insert(new RuleWatchNode($rule));
  14382. }
  14383. $this->makeAssertionRuleDecisions();
  14384. $this->io->writeError('Resolving dependencies through SAT', true, IOInterface::DEBUG);
  14385. $before = microtime(true);
  14386. $this->runSat();
  14387. $this->io->writeError('', true, IOInterface::DEBUG);
  14388. $this->io->writeError(sprintf('Dependency resolution completed in %.3f seconds', microtime(true) - $before), true, IOInterface::VERBOSE);
  14389. if ($this->problems) {
  14390. throw new SolverProblemsException($this->problems, $this->learnedPool);
  14391. }
  14392. return new LockTransaction($this->pool, $request->getPresentMap(), $request->getFixedPackagesMap(), $this->decisions);
  14393. }
  14394. protected function propagate(int $level): ?Rule
  14395. {
  14396. while ($this->decisions->validOffset($this->propagateIndex)) {
  14397. $decision = $this->decisions->atOffset($this->propagateIndex);
  14398. $conflict = $this->watchGraph->propagateLiteral(
  14399. $decision[Decisions::DECISION_LITERAL],
  14400. $level,
  14401. $this->decisions
  14402. );
  14403. $this->propagateIndex++;
  14404. if ($conflict) {
  14405. return $conflict;
  14406. }
  14407. }
  14408. return null;
  14409. }
  14410. private function revert(int $level): void
  14411. {
  14412. while (!$this->decisions->isEmpty()) {
  14413. $literal = $this->decisions->lastLiteral();
  14414. if ($this->decisions->undecided($literal)) {
  14415. break;
  14416. }
  14417. $decisionLevel = $this->decisions->decisionLevel($literal);
  14418. if ($decisionLevel <= $level) {
  14419. break;
  14420. }
  14421. $this->decisions->revertLast();
  14422. $this->propagateIndex = \count($this->decisions);
  14423. }
  14424. while (!empty($this->branches) && $this->branches[\count($this->branches) - 1][self::BRANCH_LEVEL] >= $level) {
  14425. array_pop($this->branches);
  14426. }
  14427. }
  14428. private function setPropagateLearn(int $level, $literal, Rule $rule): int
  14429. {
  14430. $level++;
  14431. $this->decisions->decide($literal, $level, $rule);
  14432. while (true) {
  14433. $rule = $this->propagate($level);
  14434. if (null === $rule) {
  14435. break;
  14436. }
  14437. if ($level === 1) {
  14438. return $this->analyzeUnsolvable($rule);
  14439. }
  14440. [$learnLiteral, $newLevel, $newRule, $why] = $this->analyze($level, $rule);
  14441. if ($newLevel <= 0 || $newLevel >= $level) {
  14442. throw new SolverBugException(
  14443. "Trying to revert to invalid level ".$newLevel." from level ".$level."."
  14444. );
  14445. }
  14446. $level = $newLevel;
  14447. $this->revert($level);
  14448. $this->rules->add($newRule, RuleSet::TYPE_LEARNED);
  14449. $this->learnedWhy[spl_object_hash($newRule)] = $why;
  14450. $ruleNode = new RuleWatchNode($newRule);
  14451. $ruleNode->watch2OnHighest($this->decisions);
  14452. $this->watchGraph->insert($ruleNode);
  14453. $this->decisions->decide($learnLiteral, $level, $newRule);
  14454. }
  14455. return $level;
  14456. }
  14457. private function selectAndInstall(int $level, array $decisionQueue, Rule $rule): int
  14458. {
  14459. $literals = $this->policy->selectPreferredPackages($this->pool, $decisionQueue, $rule->getRequiredPackage());
  14460. $selectedLiteral = array_shift($literals);
  14461. if (\count($literals)) {
  14462. $this->branches[] = [$literals, $level];
  14463. }
  14464. return $this->setPropagateLearn($level, $selectedLiteral, $rule);
  14465. }
  14466. protected function analyze(int $level, Rule $rule): array
  14467. {
  14468. $analyzedRule = $rule;
  14469. $ruleLevel = 1;
  14470. $num = 0;
  14471. $l1num = 0;
  14472. $seen = [];
  14473. $learnedLiterals = [null];
  14474. $decisionId = \count($this->decisions);
  14475. $this->learnedPool[] = [];
  14476. while (true) {
  14477. $this->learnedPool[\count($this->learnedPool) - 1][] = $rule;
  14478. foreach ($rule->getLiterals() as $literal) {
  14479. if ($rule instanceof MultiConflictRule && !$this->decisions->decided($literal)) {
  14480. continue;
  14481. }
  14482. if ($this->decisions->satisfy($literal)) {
  14483. continue;
  14484. }
  14485. if (isset($seen[abs($literal)])) {
  14486. continue;
  14487. }
  14488. $seen[abs($literal)] = true;
  14489. $l = $this->decisions->decisionLevel($literal);
  14490. if (1 === $l) {
  14491. $l1num++;
  14492. } elseif ($level === $l) {
  14493. $num++;
  14494. } else {
  14495. $learnedLiterals[] = $literal;
  14496. if ($l > $ruleLevel) {
  14497. $ruleLevel = $l;
  14498. }
  14499. }
  14500. }
  14501. unset($literal);
  14502. $l1retry = true;
  14503. while ($l1retry) {
  14504. $l1retry = false;
  14505. if (0 === $num && 0 === --$l1num) {
  14506. break 2;
  14507. }
  14508. while (true) {
  14509. if ($decisionId <= 0) {
  14510. throw new SolverBugException(
  14511. "Reached invalid decision id $decisionId while looking through $rule for a literal present in the analyzed rule $analyzedRule."
  14512. );
  14513. }
  14514. $decisionId--;
  14515. $decision = $this->decisions->atOffset($decisionId);
  14516. $literal = $decision[Decisions::DECISION_LITERAL];
  14517. if (isset($seen[abs($literal)])) {
  14518. break;
  14519. }
  14520. }
  14521. unset($seen[abs($literal)]);
  14522. if (0 !== $num && 0 === --$num) {
  14523. if ($literal < 0) {
  14524. $this->testFlagLearnedPositiveLiteral = true;
  14525. }
  14526. $learnedLiterals[0] = -$literal;
  14527. if (!$l1num) {
  14528. break 2;
  14529. }
  14530. foreach ($learnedLiterals as $i => $learnedLiteral) {
  14531. if ($i !== 0) {
  14532. unset($seen[abs($learnedLiteral)]);
  14533. }
  14534. }
  14535. $l1num++;
  14536. $l1retry = true;
  14537. } else {
  14538. $decision = $this->decisions->atOffset($decisionId);
  14539. $rule = $decision[Decisions::DECISION_REASON];
  14540. if ($rule instanceof MultiConflictRule) {
  14541. foreach ($rule->getLiterals() as $literal) {
  14542. if (!isset($seen[abs($literal)]) && $this->decisions->satisfy(-$literal)) {
  14543. $this->learnedPool[\count($this->learnedPool) - 1][] = $rule;
  14544. $l = $this->decisions->decisionLevel($literal);
  14545. if (1 === $l) {
  14546. $l1num++;
  14547. } elseif ($level === $l) {
  14548. $num++;
  14549. } else {
  14550. $learnedLiterals[] = $literal;
  14551. if ($l > $ruleLevel) {
  14552. $ruleLevel = $l;
  14553. }
  14554. }
  14555. $seen[abs($literal)] = true;
  14556. break;
  14557. }
  14558. }
  14559. $l1retry = true;
  14560. }
  14561. }
  14562. }
  14563. $decision = $this->decisions->atOffset($decisionId);
  14564. $rule = $decision[Decisions::DECISION_REASON];
  14565. }
  14566. $why = \count($this->learnedPool) - 1;
  14567. if (null === $learnedLiterals[0]) {
  14568. throw new SolverBugException(
  14569. "Did not find a learnable literal in analyzed rule $analyzedRule."
  14570. );
  14571. }
  14572. $newRule = new GenericRule($learnedLiterals, Rule::RULE_LEARNED, $why);
  14573. return [$learnedLiterals[0], $ruleLevel, $newRule, $why];
  14574. }
  14575. private function analyzeUnsolvableRule(Problem $problem, Rule $conflictRule, array &$ruleSeen): void
  14576. {
  14577. $why = spl_object_hash($conflictRule);
  14578. $ruleSeen[$why] = true;
  14579. if ($conflictRule->getType() === RuleSet::TYPE_LEARNED) {
  14580. $learnedWhy = $this->learnedWhy[$why];
  14581. $problemRules = $this->learnedPool[$learnedWhy];
  14582. foreach ($problemRules as $problemRule) {
  14583. if (!isset($ruleSeen[spl_object_hash($problemRule)])) {
  14584. $this->analyzeUnsolvableRule($problem, $problemRule, $ruleSeen);
  14585. }
  14586. }
  14587. return;
  14588. }
  14589. if ($conflictRule->getType() === RuleSet::TYPE_PACKAGE) {
  14590. return;
  14591. }
  14592. $problem->nextSection();
  14593. $problem->addRule($conflictRule);
  14594. }
  14595. private function analyzeUnsolvable(Rule $conflictRule): int
  14596. {
  14597. $problem = new Problem();
  14598. $problem->addRule($conflictRule);
  14599. $ruleSeen = [];
  14600. $this->analyzeUnsolvableRule($problem, $conflictRule, $ruleSeen);
  14601. $this->problems[] = $problem;
  14602. $seen = [];
  14603. $literals = $conflictRule->getLiterals();
  14604. foreach ($literals as $literal) {
  14605. if ($this->decisions->satisfy($literal)) {
  14606. continue;
  14607. }
  14608. $seen[abs($literal)] = true;
  14609. }
  14610. foreach ($this->decisions as $decision) {
  14611. $literal = $decision[Decisions::DECISION_LITERAL];
  14612. if (!isset($seen[abs($literal)])) {
  14613. continue;
  14614. }
  14615. $why = $decision[Decisions::DECISION_REASON];
  14616. $problem->addRule($why);
  14617. $this->analyzeUnsolvableRule($problem, $why, $ruleSeen);
  14618. $literals = $why->getLiterals();
  14619. foreach ($literals as $literal) {
  14620. if ($this->decisions->satisfy($literal)) {
  14621. continue;
  14622. }
  14623. $seen[abs($literal)] = true;
  14624. }
  14625. }
  14626. return 0;
  14627. }
  14628. private function runSat(): void
  14629. {
  14630. $this->propagateIndex = 0;
  14631. $level = 1;
  14632. $systemLevel = $level + 1;
  14633. while (true) {
  14634. if (1 === $level) {
  14635. $conflictRule = $this->propagate($level);
  14636. if (null !== $conflictRule) {
  14637. if ($this->analyzeUnsolvable($conflictRule)) {
  14638. continue;
  14639. }
  14640. return;
  14641. }
  14642. }
  14643. if ($level < $systemLevel) {
  14644. $iterator = $this->rules->getIteratorFor(RuleSet::TYPE_REQUEST);
  14645. foreach ($iterator as $rule) {
  14646. if ($rule->isEnabled()) {
  14647. $decisionQueue = [];
  14648. $noneSatisfied = true;
  14649. foreach ($rule->getLiterals() as $literal) {
  14650. if ($this->decisions->satisfy($literal)) {
  14651. $noneSatisfied = false;
  14652. break;
  14653. }
  14654. if ($literal > 0 && $this->decisions->undecided($literal)) {
  14655. $decisionQueue[] = $literal;
  14656. }
  14657. }
  14658. if ($noneSatisfied && \count($decisionQueue)) {
  14659. $prunedQueue = [];
  14660. foreach ($decisionQueue as $literal) {
  14661. if (isset($this->fixedMap[abs($literal)])) {
  14662. $prunedQueue[] = $literal;
  14663. }
  14664. }
  14665. if (!empty($prunedQueue)) {
  14666. $decisionQueue = $prunedQueue;
  14667. }
  14668. }
  14669. if ($noneSatisfied && \count($decisionQueue)) {
  14670. $oLevel = $level;
  14671. $level = $this->selectAndInstall($level, $decisionQueue, $rule);
  14672. if (0 === $level) {
  14673. return;
  14674. }
  14675. if ($level <= $oLevel) {
  14676. break;
  14677. }
  14678. }
  14679. }
  14680. }
  14681. $systemLevel = $level + 1;
  14682. $iterator->next();
  14683. if ($iterator->valid()) {
  14684. continue;
  14685. }
  14686. }
  14687. if ($level < $systemLevel) {
  14688. $systemLevel = $level;
  14689. }
  14690. $rulesCount = \count($this->rules);
  14691. $pass = 1;
  14692. $this->io->writeError('Looking at all rules.', true, IOInterface::DEBUG);
  14693. for ($i = 0, $n = 0; $n < $rulesCount; $i++, $n++) {
  14694. if ($i === $rulesCount) {
  14695. if (1 === $pass) {
  14696. $this->io->writeError("Something's changed, looking at all rules again (pass #$pass)", false, IOInterface::DEBUG);
  14697. } else {
  14698. $this->io->overwriteError("Something's changed, looking at all rules again (pass #$pass)", false, null, IOInterface::DEBUG);
  14699. }
  14700. $i = 0;
  14701. $pass++;
  14702. }
  14703. $rule = $this->rules->ruleById[$i];
  14704. $literals = $rule->getLiterals();
  14705. if ($rule->isDisabled()) {
  14706. continue;
  14707. }
  14708. $decisionQueue = [];
  14709. foreach ($literals as $literal) {
  14710. if ($literal <= 0) {
  14711. if (!$this->decisions->decidedInstall($literal)) {
  14712. continue 2;
  14713. }
  14714. } else {
  14715. if ($this->decisions->decidedInstall($literal)) {
  14716. continue 2;
  14717. }
  14718. if ($this->decisions->undecided($literal)) {
  14719. $decisionQueue[] = $literal;
  14720. }
  14721. }
  14722. }
  14723. if (\count($decisionQueue) < 2) {
  14724. continue;
  14725. }
  14726. $level = $this->selectAndInstall($level, $decisionQueue, $rule);
  14727. if (0 === $level) {
  14728. return;
  14729. }
  14730. $rulesCount = \count($this->rules);
  14731. $n = -1;
  14732. }
  14733. if ($level < $systemLevel) {
  14734. continue;
  14735. }
  14736. if (\count($this->branches)) {
  14737. $lastLiteral = null;
  14738. $lastLevel = null;
  14739. $lastBranchIndex = 0;
  14740. $lastBranchOffset = 0;
  14741. for ($i = \count($this->branches) - 1; $i >= 0; $i--) {
  14742. [$literals, $l] = $this->branches[$i];
  14743. foreach ($literals as $offset => $literal) {
  14744. if ($literal && $literal > 0 && $this->decisions->decisionLevel($literal) > $l + 1) {
  14745. $lastLiteral = $literal;
  14746. $lastBranchIndex = $i;
  14747. $lastBranchOffset = $offset;
  14748. $lastLevel = $l;
  14749. }
  14750. }
  14751. }
  14752. if ($lastLiteral) {
  14753. unset($this->branches[$lastBranchIndex][self::BRANCH_LITERALS][$lastBranchOffset]);
  14754. $level = $lastLevel;
  14755. $this->revert($level);
  14756. $why = $this->decisions->lastReason();
  14757. $level = $this->setPropagateLearn($level, $lastLiteral, $why);
  14758. if ($level === 0) {
  14759. return;
  14760. }
  14761. continue;
  14762. }
  14763. }
  14764. break;
  14765. }
  14766. }
  14767. }
  14768. <?php declare(strict_types=1);
  14769. namespace Composer\DependencyResolver;
  14770. class SolverBugException extends \RuntimeException
  14771. {
  14772. public function __construct(string $message)
  14773. {
  14774. parent::__construct(
  14775. $message."\nThis exception was most likely caused by a bug in Composer.\n".
  14776. "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"
  14777. );
  14778. }
  14779. }
  14780. <?php declare(strict_types=1);
  14781. namespace Composer\DependencyResolver;
  14782. use Composer\Util\IniHelper;
  14783. use Composer\Repository\RepositorySet;
  14784. class SolverProblemsException extends \RuntimeException
  14785. {
  14786. public const ERROR_DEPENDENCY_RESOLUTION_FAILED = 2;
  14787. protected $problems;
  14788. protected $learnedPool;
  14789. public function __construct(array $problems, array $learnedPool)
  14790. {
  14791. $this->problems = $problems;
  14792. $this->learnedPool = $learnedPool;
  14793. parent::__construct('Failed resolving dependencies with '.count($problems).' problems, call getPrettyString to get formatted details', self::ERROR_DEPENDENCY_RESOLUTION_FAILED);
  14794. }
  14795. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, bool $isVerbose, bool $isDevExtraction = false): string
  14796. {
  14797. $installedMap = $request->getPresentMap(true);
  14798. $missingExtensions = [];
  14799. $isCausedByLock = false;
  14800. $problems = [];
  14801. foreach ($this->problems as $problem) {
  14802. $problems[] = $problem->getPrettyString($repositorySet, $request, $pool, $isVerbose, $installedMap, $this->learnedPool)."\n";
  14803. $missingExtensions = array_merge($missingExtensions, $this->getExtensionProblems($problem->getReasons()));
  14804. $isCausedByLock = $isCausedByLock || $problem->isCausedByLock($repositorySet, $request, $pool);
  14805. }
  14806. $i = 1;
  14807. $text = "\n";
  14808. foreach (array_unique($problems) as $problem) {
  14809. $text .= " Problem ".($i++).$problem;
  14810. }
  14811. $hints = [];
  14812. if (!$isDevExtraction && (strpos($text, 'could not be found') || strpos($text, 'no matching package found'))) {
  14813. $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.";
  14814. }
  14815. if (!empty($missingExtensions)) {
  14816. $hints[] = $this->createExtensionHint($missingExtensions);
  14817. }
  14818. if ($isCausedByLock && !$isDevExtraction && !$request->getUpdateAllowTransitiveRootDependencies()) {
  14819. $hints[] = "Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.";
  14820. }
  14821. if (strpos($text, 'found composer-plugin-api[2.0.0] but it does not match') && strpos($text, '- ocramius/package-versions')) {
  14822. $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+.";
  14823. }
  14824. if (!class_exists('PHPUnit\Framework\TestCase', false)) {
  14825. if (strpos($text, 'found composer-plugin-api[2.0.0] but it does not match')) {
  14826. $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.";
  14827. }
  14828. }
  14829. if ($hints) {
  14830. $text .= "\n" . implode("\n\n", $hints);
  14831. }
  14832. return $text;
  14833. }
  14834. public function getProblems(): array
  14835. {
  14836. return $this->problems;
  14837. }
  14838. private function createExtensionHint(array $missingExtensions): string
  14839. {
  14840. $paths = IniHelper::getAll();
  14841. if ('' === $paths[0]) {
  14842. if (count($paths) === 1) {
  14843. return '';
  14844. }
  14845. array_shift($paths);
  14846. }
  14847. $ignoreExtensionsArguments = implode(" ", array_map(static function ($extension) {
  14848. return "--ignore-platform-req=$extension";
  14849. }, array_unique($missingExtensions)));
  14850. $text = "To enable extensions, verify that they are enabled in your .ini files:\n - ";
  14851. $text .= implode("\n - ", $paths);
  14852. $text .= "\nYou can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.";
  14853. $text .= "\nAlternatively, you can run Composer with `$ignoreExtensionsArguments` to temporarily ignore these required extensions.";
  14854. return $text;
  14855. }
  14856. private function getExtensionProblems(array $reasonSets): array
  14857. {
  14858. $missingExtensions = [];
  14859. foreach ($reasonSets as $reasonSet) {
  14860. foreach ($reasonSet as $rule) {
  14861. $required = $rule->getRequiredPackage();
  14862. if (null !== $required && 0 === strpos($required, 'ext-')) {
  14863. $missingExtensions[$required] = 1;
  14864. }
  14865. }
  14866. }
  14867. return array_keys($missingExtensions);
  14868. }
  14869. }
  14870. <?php declare(strict_types=1);
  14871. namespace Composer\DependencyResolver;
  14872. use Composer\Package\AliasPackage;
  14873. use Composer\Package\Link;
  14874. use Composer\Package\PackageInterface;
  14875. use Composer\Repository\PlatformRepository;
  14876. use Composer\DependencyResolver\Operation\OperationInterface;
  14877. class Transaction
  14878. {
  14879. protected $operations;
  14880. protected $presentPackages;
  14881. protected $resultPackageMap;
  14882. protected $resultPackagesByName = [];
  14883. public function __construct(array $presentPackages, array $resultPackages)
  14884. {
  14885. $this->presentPackages = $presentPackages;
  14886. $this->setResultPackageMaps($resultPackages);
  14887. $this->operations = $this->calculateOperations();
  14888. }
  14889. public function getOperations(): array
  14890. {
  14891. return $this->operations;
  14892. }
  14893. private function setResultPackageMaps(array $resultPackages): void
  14894. {
  14895. $packageSort = static function (PackageInterface $a, PackageInterface $b): int {
  14896. if ($a->getName() === $b->getName()) {
  14897. if ($a instanceof AliasPackage !== $b instanceof AliasPackage) {
  14898. return $a instanceof AliasPackage ? -1 : 1;
  14899. }
  14900. return strcmp($b->getVersion(), $a->getVersion());
  14901. }
  14902. return strcmp($b->getName(), $a->getName());
  14903. };
  14904. $this->resultPackageMap = [];
  14905. foreach ($resultPackages as $package) {
  14906. $this->resultPackageMap[spl_object_hash($package)] = $package;
  14907. foreach ($package->getNames() as $name) {
  14908. $this->resultPackagesByName[$name][] = $package;
  14909. }
  14910. }
  14911. uasort($this->resultPackageMap, $packageSort);
  14912. foreach ($this->resultPackagesByName as $name => $packages) {
  14913. uasort($this->resultPackagesByName[$name], $packageSort);
  14914. }
  14915. }
  14916. protected function calculateOperations(): array
  14917. {
  14918. $operations = [];
  14919. $presentPackageMap = [];
  14920. $removeMap = [];
  14921. $presentAliasMap = [];
  14922. $removeAliasMap = [];
  14923. foreach ($this->presentPackages as $package) {
  14924. if ($package instanceof AliasPackage) {
  14925. $presentAliasMap[$package->getName().'::'.$package->getVersion()] = $package;
  14926. $removeAliasMap[$package->getName().'::'.$package->getVersion()] = $package;
  14927. } else {
  14928. $presentPackageMap[$package->getName()] = $package;
  14929. $removeMap[$package->getName()] = $package;
  14930. }
  14931. }
  14932. $stack = $this->getRootPackages();
  14933. $visited = [];
  14934. $processed = [];
  14935. while (!empty($stack)) {
  14936. $package = array_pop($stack);
  14937. if (isset($processed[spl_object_hash($package)])) {
  14938. continue;
  14939. }
  14940. if (!isset($visited[spl_object_hash($package)])) {
  14941. $visited[spl_object_hash($package)] = true;
  14942. $stack[] = $package;
  14943. if ($package instanceof AliasPackage) {
  14944. $stack[] = $package->getAliasOf();
  14945. } else {
  14946. foreach ($package->getRequires() as $link) {
  14947. $possibleRequires = $this->getProvidersInResult($link);
  14948. foreach ($possibleRequires as $require) {
  14949. $stack[] = $require;
  14950. }
  14951. }
  14952. }
  14953. } elseif (!isset($processed[spl_object_hash($package)])) {
  14954. $processed[spl_object_hash($package)] = true;
  14955. if ($package instanceof AliasPackage) {
  14956. $aliasKey = $package->getName().'::'.$package->getVersion();
  14957. if (isset($presentAliasMap[$aliasKey])) {
  14958. unset($removeAliasMap[$aliasKey]);
  14959. } else {
  14960. $operations[] = new Operation\MarkAliasInstalledOperation($package);
  14961. }
  14962. } else {
  14963. if (isset($presentPackageMap[$package->getName()])) {
  14964. $source = $presentPackageMap[$package->getName()];
  14965. if ($package->getVersion() !== $presentPackageMap[$package->getName()]->getVersion() ||
  14966. $package->getDistReference() !== $presentPackageMap[$package->getName()]->getDistReference() ||
  14967. $package->getSourceReference() !== $presentPackageMap[$package->getName()]->getSourceReference()
  14968. ) {
  14969. $operations[] = new Operation\UpdateOperation($source, $package);
  14970. }
  14971. unset($removeMap[$package->getName()]);
  14972. } else {
  14973. $operations[] = new Operation\InstallOperation($package);
  14974. unset($removeMap[$package->getName()]);
  14975. }
  14976. }
  14977. }
  14978. }
  14979. foreach ($removeMap as $name => $package) {
  14980. array_unshift($operations, new Operation\UninstallOperation($package));
  14981. }
  14982. foreach ($removeAliasMap as $nameVersion => $package) {
  14983. $operations[] = new Operation\MarkAliasUninstalledOperation($package);
  14984. }
  14985. $operations = $this->movePluginsToFront($operations);
  14986. $operations = $this->moveUninstallsToFront($operations);
  14987. return $this->operations = $operations;
  14988. }
  14989. protected function getRootPackages(): array
  14990. {
  14991. $roots = $this->resultPackageMap;
  14992. foreach ($this->resultPackageMap as $packageHash => $package) {
  14993. if (!isset($roots[$packageHash])) {
  14994. continue;
  14995. }
  14996. foreach ($package->getRequires() as $link) {
  14997. $possibleRequires = $this->getProvidersInResult($link);
  14998. foreach ($possibleRequires as $require) {
  14999. if ($require !== $package) {
  15000. unset($roots[spl_object_hash($require)]);
  15001. }
  15002. }
  15003. }
  15004. }
  15005. return $roots;
  15006. }
  15007. protected function getProvidersInResult(Link $link): array
  15008. {
  15009. if (!isset($this->resultPackagesByName[$link->getTarget()])) {
  15010. return [];
  15011. }
  15012. return $this->resultPackagesByName[$link->getTarget()];
  15013. }
  15014. private function movePluginsToFront(array $operations): array
  15015. {
  15016. $dlModifyingPluginsNoDeps = [];
  15017. $dlModifyingPluginsWithDeps = [];
  15018. $dlModifyingPluginRequires = [];
  15019. $pluginsNoDeps = [];
  15020. $pluginsWithDeps = [];
  15021. $pluginRequires = [];
  15022. foreach (array_reverse($operations, true) as $idx => $op) {
  15023. if ($op instanceof Operation\InstallOperation) {
  15024. $package = $op->getPackage();
  15025. } elseif ($op instanceof Operation\UpdateOperation) {
  15026. $package = $op->getTargetPackage();
  15027. } else {
  15028. continue;
  15029. }
  15030. $isDownloadsModifyingPlugin = $package->getType() === 'composer-plugin' && ($extra = $package->getExtra()) && isset($extra['plugin-modifies-downloads']) && $extra['plugin-modifies-downloads'] === true;
  15031. if ($isDownloadsModifyingPlugin || count(array_intersect($package->getNames(), $dlModifyingPluginRequires))) {
  15032. $requires = array_filter(array_keys($package->getRequires()), static function ($req): bool {
  15033. return !PlatformRepository::isPlatformPackage($req);
  15034. });
  15035. if ($isDownloadsModifyingPlugin && !count($requires)) {
  15036. array_unshift($dlModifyingPluginsNoDeps, $op);
  15037. } else {
  15038. $dlModifyingPluginRequires = array_merge($dlModifyingPluginRequires, $requires);
  15039. array_unshift($dlModifyingPluginsWithDeps, $op);
  15040. }
  15041. unset($operations[$idx]);
  15042. continue;
  15043. }
  15044. $isPlugin = $package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer';
  15045. if ($isPlugin || count(array_intersect($package->getNames(), $pluginRequires))) {
  15046. $requires = array_filter(array_keys($package->getRequires()), static function ($req): bool {
  15047. return !PlatformRepository::isPlatformPackage($req);
  15048. });
  15049. if ($isPlugin && !count($requires)) {
  15050. array_unshift($pluginsNoDeps, $op);
  15051. } else {
  15052. $pluginRequires = array_merge($pluginRequires, $requires);
  15053. array_unshift($pluginsWithDeps, $op);
  15054. }
  15055. unset($operations[$idx]);
  15056. }
  15057. }
  15058. return array_merge($dlModifyingPluginsNoDeps, $dlModifyingPluginsWithDeps, $pluginsNoDeps, $pluginsWithDeps, $operations);
  15059. }
  15060. private function moveUninstallsToFront(array $operations): array
  15061. {
  15062. $uninstOps = [];
  15063. foreach ($operations as $idx => $op) {
  15064. if ($op instanceof Operation\UninstallOperation || $op instanceof Operation\MarkAliasUninstalledOperation) {
  15065. $uninstOps[] = $op;
  15066. unset($operations[$idx]);
  15067. }
  15068. }
  15069. return array_merge($uninstOps, $operations);
  15070. }
  15071. }
  15072. <?php declare(strict_types=1);
  15073. namespace Composer\Downloader;
  15074. use Composer\Package\PackageInterface;
  15075. use Composer\Util\Platform;
  15076. use Symfony\Component\Finder\Finder;
  15077. use React\Promise\PromiseInterface;
  15078. use Composer\DependencyResolver\Operation\InstallOperation;
  15079. abstract class ArchiveDownloader extends FileDownloader
  15080. {
  15081. protected $cleanupExecuted = [];
  15082. public function prepare(string $type, PackageInterface $package, string $path, ?PackageInterface $prevPackage = null): PromiseInterface
  15083. {
  15084. unset($this->cleanupExecuted[$package->getName()]);
  15085. return parent::prepare($type, $package, $path, $prevPackage);
  15086. }
  15087. public function cleanup(string $type, PackageInterface $package, string $path, ?PackageInterface $prevPackage = null): PromiseInterface
  15088. {
  15089. $this->cleanupExecuted[$package->getName()] = true;
  15090. return parent::cleanup($type, $package, $path, $prevPackage);
  15091. }
  15092. public function install(PackageInterface $package, string $path, bool $output = true): PromiseInterface
  15093. {
  15094. if ($output) {
  15095. $this->io->writeError(" - " . InstallOperation::format($package) . $this->getInstallOperationAppendix($package, $path));
  15096. }
  15097. $vendorDir = $this->config->get('vendor-dir');
  15098. if (false === strpos($this->filesystem->normalizePath($vendorDir), $this->filesystem->normalizePath($path.DIRECTORY_SEPARATOR))) {
  15099. $this->filesystem->emptyDirectory($path);
  15100. }
  15101. do {
  15102. $temporaryDir = $vendorDir.'/composer/'.substr(md5(uniqid('', true)), 0, 8);
  15103. } while (is_dir($temporaryDir));
  15104. $this->addCleanupPath($package, $temporaryDir);
  15105. if (!is_dir($path) || realpath($path) !== Platform::getCwd()) {
  15106. $this->addCleanupPath($package, $path);
  15107. }
  15108. $this->filesystem->ensureDirectoryExists($temporaryDir);
  15109. $fileName = $this->getFileName($package, $path);
  15110. $filesystem = $this->filesystem;
  15111. $cleanup = function () use ($path, $filesystem, $temporaryDir, $package) {
  15112. $this->clearLastCacheWrite($package);
  15113. $filesystem->removeDirectory($temporaryDir);
  15114. if (is_dir($path) && realpath($path) !== Platform::getCwd()) {
  15115. $filesystem->removeDirectory($path);
  15116. }
  15117. $this->removeCleanupPath($package, $temporaryDir);
  15118. $realpath = realpath($path);
  15119. if ($realpath !== false) {
  15120. $this->removeCleanupPath($package, $realpath);
  15121. }
  15122. };
  15123. try {
  15124. $promise = $this->extract($package, $fileName, $temporaryDir);
  15125. } catch (\Exception $e) {
  15126. $cleanup();
  15127. throw $e;
  15128. }
  15129. return $promise->then(function () use ($package, $filesystem, $fileName, $temporaryDir, $path): \React\Promise\PromiseInterface {
  15130. if (file_exists($fileName)) {
  15131. $filesystem->unlink($fileName);
  15132. }
  15133. $getFolderContent = static function ($dir): array {
  15134. $finder = Finder::create()
  15135. ->ignoreVCS(false)
  15136. ->ignoreDotFiles(false)
  15137. ->notName('.DS_Store')
  15138. ->depth(0)
  15139. ->in($dir);
  15140. return iterator_to_array($finder);
  15141. };
  15142. $renameRecursively = null;
  15143. $renameRecursively = static function ($from, $to) use ($filesystem, $getFolderContent, $package, &$renameRecursively) {
  15144. $contentDir = $getFolderContent($from);
  15145. foreach ($contentDir as $file) {
  15146. $file = (string) $file;
  15147. if (is_dir($to . '/' . basename($file))) {
  15148. if (!is_dir($file)) {
  15149. throw new \RuntimeException('Installing '.$package.' would lead to overwriting the '.$to.'/'.basename($file).' directory with a file from the package, invalid operation.');
  15150. }
  15151. $renameRecursively($file, $to . '/' . basename($file));
  15152. } else {
  15153. $filesystem->rename($file, $to . '/' . basename($file));
  15154. }
  15155. }
  15156. };
  15157. $renameAsOne = false;
  15158. if (!file_exists($path)) {
  15159. $renameAsOne = true;
  15160. } elseif ($filesystem->isDirEmpty($path)) {
  15161. try {
  15162. if ($filesystem->removeDirectoryPhp($path)) {
  15163. $renameAsOne = true;
  15164. }
  15165. } catch (\RuntimeException $e) {
  15166. }
  15167. }
  15168. $contentDir = $getFolderContent($temporaryDir);
  15169. $singleDirAtTopLevel = 1 === count($contentDir) && is_dir((string) reset($contentDir));
  15170. if ($renameAsOne) {
  15171. if ($singleDirAtTopLevel) {
  15172. $extractedDir = (string) reset($contentDir);
  15173. } else {
  15174. $extractedDir = $temporaryDir;
  15175. }
  15176. $filesystem->rename($extractedDir, $path);
  15177. } else {
  15178. $from = $temporaryDir;
  15179. if ($singleDirAtTopLevel) {
  15180. $from = (string) reset($contentDir);
  15181. }
  15182. $renameRecursively($from, $path);
  15183. }
  15184. $promise = $filesystem->removeDirectoryAsync($temporaryDir);
  15185. return $promise->then(function () use ($package, $path, $temporaryDir) {
  15186. $this->removeCleanupPath($package, $temporaryDir);
  15187. $this->removeCleanupPath($package, $path);
  15188. });
  15189. }, static function ($e) use ($cleanup) {
  15190. $cleanup();
  15191. throw $e;
  15192. });
  15193. }
  15194. protected function getInstallOperationAppendix(PackageInterface $package, string $path): string
  15195. {
  15196. return ': Extracting archive';
  15197. }
  15198. abstract protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface;
  15199. }
  15200. <?php declare(strict_types=1);
  15201. namespace Composer\Downloader;
  15202. use Composer\Package\PackageInterface;
  15203. interface ChangeReportInterface
  15204. {
  15205. public function getLocalChanges(PackageInterface $package, string $path): ?string;
  15206. }
  15207. <?php declare(strict_types=1);
  15208. namespace Composer\Downloader;
  15209. use Composer\Package\PackageInterface;
  15210. use Composer\IO\IOInterface;
  15211. use Composer\Pcre\Preg;
  15212. use Composer\Util\Filesystem;
  15213. use Composer\Exception\IrrecoverableDownloadException;
  15214. use React\Promise\PromiseInterface;
  15215. class DownloadManager
  15216. {
  15217. private $io;
  15218. private $preferDist = false;
  15219. private $preferSource;
  15220. private $packagePreferences = [];
  15221. private $filesystem;
  15222. private $downloaders = [];
  15223. public function __construct(IOInterface $io, bool $preferSource = false, ?Filesystem $filesystem = null)
  15224. {
  15225. $this->io = $io;
  15226. $this->preferSource = $preferSource;
  15227. $this->filesystem = $filesystem ?: new Filesystem();
  15228. }
  15229. public function setPreferSource(bool $preferSource): self
  15230. {
  15231. $this->preferSource = $preferSource;
  15232. return $this;
  15233. }
  15234. public function setPreferDist(bool $preferDist): self
  15235. {
  15236. $this->preferDist = $preferDist;
  15237. return $this;
  15238. }
  15239. public function setPreferences(array $preferences): self
  15240. {
  15241. $this->packagePreferences = $preferences;
  15242. return $this;
  15243. }
  15244. public function setDownloader(string $type, DownloaderInterface $downloader): self
  15245. {
  15246. $type = strtolower($type);
  15247. $this->downloaders[$type] = $downloader;
  15248. return $this;
  15249. }
  15250. public function getDownloader(string $type): DownloaderInterface
  15251. {
  15252. $type = strtolower($type);
  15253. if (!isset($this->downloaders[$type])) {
  15254. throw new \InvalidArgumentException(sprintf('Unknown downloader type: %s. Available types: %s.', $type, implode(', ', array_keys($this->downloaders))));
  15255. }
  15256. return $this->downloaders[$type];
  15257. }
  15258. public function getDownloaderForPackage(PackageInterface $package): ?DownloaderInterface
  15259. {
  15260. $installationSource = $package->getInstallationSource();
  15261. if ('metapackage' === $package->getType()) {
  15262. return null;
  15263. }
  15264. if ('dist' === $installationSource) {
  15265. $downloader = $this->getDownloader($package->getDistType());
  15266. } elseif ('source' === $installationSource) {
  15267. $downloader = $this->getDownloader($package->getSourceType());
  15268. } else {
  15269. throw new \InvalidArgumentException(
  15270. 'Package '.$package.' does not have an installation source set'
  15271. );
  15272. }
  15273. if ($installationSource !== $downloader->getInstallationSource()) {
  15274. throw new \LogicException(sprintf(
  15275. 'Downloader "%s" is a %s type downloader and can not be used to download %s for package %s',
  15276. get_class($downloader),
  15277. $downloader->getInstallationSource(),
  15278. $installationSource,
  15279. $package
  15280. ));
  15281. }
  15282. return $downloader;
  15283. }
  15284. public function getDownloaderType(DownloaderInterface $downloader): string
  15285. {
  15286. return array_search($downloader, $this->downloaders);
  15287. }
  15288. public function download(PackageInterface $package, string $targetDir, ?PackageInterface $prevPackage = null): PromiseInterface
  15289. {
  15290. $targetDir = $this->normalizeTargetDir($targetDir);
  15291. $this->filesystem->ensureDirectoryExists(dirname($targetDir));
  15292. $sources = $this->getAvailableSources($package, $prevPackage);
  15293. $io = $this->io;
  15294. $download = function ($retry = false) use (&$sources, $io, $package, $targetDir, &$download, $prevPackage) {
  15295. $source = array_shift($sources);
  15296. if ($retry) {
  15297. $io->writeError(' <warning>Now trying to download from ' . $source . '</warning>');
  15298. }
  15299. $package->setInstallationSource($source);
  15300. $downloader = $this->getDownloaderForPackage($package);
  15301. if (!$downloader) {
  15302. return \React\Promise\resolve(null);
  15303. }
  15304. $handleError = static function ($e) use ($sources, $source, $package, $io, $download) {
  15305. if ($e instanceof \RuntimeException && !$e instanceof IrrecoverableDownloadException) {
  15306. if (!$sources) {
  15307. throw $e;
  15308. }
  15309. $io->writeError(
  15310. ' <warning>Failed to download '.
  15311. $package->getPrettyName().
  15312. ' from ' . $source . ': '.
  15313. $e->getMessage().'</warning>'
  15314. );
  15315. return $download(true);
  15316. }
  15317. throw $e;
  15318. };
  15319. try {
  15320. $result = $downloader->download($package, $targetDir, $prevPackage);
  15321. } catch (\Exception $e) {
  15322. return $handleError($e);
  15323. }
  15324. $res = $result->then(static function ($res) {
  15325. return $res;
  15326. }, $handleError);
  15327. return $res;
  15328. };
  15329. return $download();
  15330. }
  15331. public function prepare(string $type, PackageInterface $package, string $targetDir, ?PackageInterface $prevPackage = null): PromiseInterface
  15332. {
  15333. $targetDir = $this->normalizeTargetDir($targetDir);
  15334. $downloader = $this->getDownloaderForPackage($package);
  15335. if ($downloader) {
  15336. return $downloader->prepare($type, $package, $targetDir, $prevPackage);
  15337. }
  15338. return \React\Promise\resolve(null);
  15339. }
  15340. public function install(PackageInterface $package, string $targetDir): PromiseInterface
  15341. {
  15342. $targetDir = $this->normalizeTargetDir($targetDir);
  15343. $downloader = $this->getDownloaderForPackage($package);
  15344. if ($downloader) {
  15345. return $downloader->install($package, $targetDir);
  15346. }
  15347. return \React\Promise\resolve(null);
  15348. }
  15349. public function update(PackageInterface $initial, PackageInterface $target, string $targetDir): PromiseInterface
  15350. {
  15351. $targetDir = $this->normalizeTargetDir($targetDir);
  15352. $downloader = $this->getDownloaderForPackage($target);
  15353. $initialDownloader = $this->getDownloaderForPackage($initial);
  15354. if (!$initialDownloader && !$downloader) {
  15355. return \React\Promise\resolve(null);
  15356. }
  15357. if (!$downloader) {
  15358. return $initialDownloader->remove($initial, $targetDir);
  15359. }
  15360. $initialType = $this->getDownloaderType($initialDownloader);
  15361. $targetType = $this->getDownloaderType($downloader);
  15362. if ($initialType === $targetType) {
  15363. try {
  15364. return $downloader->update($initial, $target, $targetDir);
  15365. } catch (\RuntimeException $e) {
  15366. if (!$this->io->isInteractive()) {
  15367. throw $e;
  15368. }
  15369. $this->io->writeError('<error> Update failed ('.$e->getMessage().')</error>');
  15370. if (!$this->io->askConfirmation(' Would you like to try reinstalling the package instead [<comment>yes</comment>]? ')) {
  15371. throw $e;
  15372. }
  15373. }
  15374. }
  15375. $promise = $initialDownloader->remove($initial, $targetDir);
  15376. return $promise->then(function ($res) use ($target, $targetDir): PromiseInterface {
  15377. return $this->install($target, $targetDir);
  15378. });
  15379. }
  15380. public function remove(PackageInterface $package, string $targetDir): PromiseInterface
  15381. {
  15382. $targetDir = $this->normalizeTargetDir($targetDir);
  15383. $downloader = $this->getDownloaderForPackage($package);
  15384. if ($downloader) {
  15385. return $downloader->remove($package, $targetDir);
  15386. }
  15387. return \React\Promise\resolve(null);
  15388. }
  15389. public function cleanup(string $type, PackageInterface $package, string $targetDir, ?PackageInterface $prevPackage = null): PromiseInterface
  15390. {
  15391. $targetDir = $this->normalizeTargetDir($targetDir);
  15392. $downloader = $this->getDownloaderForPackage($package);
  15393. if ($downloader) {
  15394. return $downloader->cleanup($type, $package, $targetDir, $prevPackage);
  15395. }
  15396. return \React\Promise\resolve(null);
  15397. }
  15398. protected function resolvePackageInstallPreference(PackageInterface $package): string
  15399. {
  15400. foreach ($this->packagePreferences as $pattern => $preference) {
  15401. $pattern = '{^'.str_replace('\\*', '.*', preg_quote($pattern)).'$}i';
  15402. if (Preg::isMatch($pattern, $package->getName())) {
  15403. if ('dist' === $preference || (!$package->isDev() && 'auto' === $preference)) {
  15404. return 'dist';
  15405. }
  15406. return 'source';
  15407. }
  15408. }
  15409. return $package->isDev() ? 'source' : 'dist';
  15410. }
  15411. private function getAvailableSources(PackageInterface $package, ?PackageInterface $prevPackage = null): array
  15412. {
  15413. $sourceType = $package->getSourceType();
  15414. $distType = $package->getDistType();
  15415. $sources = [];
  15416. if ($sourceType) {
  15417. $sources[] = 'source';
  15418. }
  15419. if ($distType) {
  15420. $sources[] = 'dist';
  15421. }
  15422. if (empty($sources)) {
  15423. throw new \InvalidArgumentException('Package '.$package.' must have a source or dist specified');
  15424. }
  15425. if (
  15426. $prevPackage
  15427. && in_array($prevPackage->getInstallationSource(), $sources, true)
  15428. && !(!$prevPackage->isDev() && $prevPackage->getInstallationSource() === 'dist' && $package->isDev())
  15429. ) {
  15430. $prevSource = $prevPackage->getInstallationSource();
  15431. usort($sources, static function ($a, $b) use ($prevSource): int {
  15432. return $a === $prevSource ? -1 : 1;
  15433. });
  15434. return $sources;
  15435. }
  15436. if (!$this->preferSource && ($this->preferDist || 'dist' === $this->resolvePackageInstallPreference($package))) {
  15437. $sources = array_reverse($sources);
  15438. }
  15439. return $sources;
  15440. }
  15441. private function normalizeTargetDir(string $dir): string
  15442. {
  15443. if ($dir === '\\' || $dir === '/') {
  15444. return $dir;
  15445. }
  15446. return rtrim($dir, '\\/');
  15447. }
  15448. }
  15449. <?php declare(strict_types=1);
  15450. namespace Composer\Downloader;
  15451. use Composer\Package\PackageInterface;
  15452. use React\Promise\PromiseInterface;
  15453. interface DownloaderInterface
  15454. {
  15455. public function getInstallationSource(): string;
  15456. public function download(PackageInterface $package, string $path, ?PackageInterface $prevPackage = null): PromiseInterface;
  15457. public function prepare(string $type, PackageInterface $package, string $path, ?PackageInterface $prevPackage = null): PromiseInterface;
  15458. public function install(PackageInterface $package, string $path): PromiseInterface;
  15459. public function update(PackageInterface $initial, PackageInterface $target, string $path): PromiseInterface;
  15460. public function remove(PackageInterface $package, string $path): PromiseInterface;
  15461. public function cleanup(string $type, PackageInterface $package, string $path, ?PackageInterface $prevPackage = null): PromiseInterface;
  15462. }
  15463. <?php declare(strict_types=1);
  15464. namespace Composer\Downloader;
  15465. use Composer\Package\PackageInterface;
  15466. interface DvcsDownloaderInterface
  15467. {
  15468. public function getUnpushedChanges(PackageInterface $package, string $path): ?string;
  15469. }
  15470. <?php declare(strict_types=1);
  15471. namespace Composer\Downloader;
  15472. use Composer\Config;
  15473. use Composer\Cache;
  15474. use Composer\IO\IOInterface;
  15475. use Composer\IO\NullIO;
  15476. use Composer\Exception\IrrecoverableDownloadException;
  15477. use Composer\Package\Comparer\Comparer;
  15478. use Composer\DependencyResolver\Operation\UpdateOperation;
  15479. use Composer\DependencyResolver\Operation\InstallOperation;
  15480. use Composer\DependencyResolver\Operation\UninstallOperation;
  15481. use Composer\Package\PackageInterface;
  15482. use Composer\Plugin\PluginEvents;
  15483. use Composer\Plugin\PostFileDownloadEvent;
  15484. use Composer\Plugin\PreFileDownloadEvent;
  15485. use Composer\EventDispatcher\EventDispatcher;
  15486. use Composer\Util\Filesystem;
  15487. use Composer\Util\Platform;
  15488. use Composer\Util\Silencer;
  15489. use Composer\Util\HttpDownloader;
  15490. use Composer\Util\Url as UrlUtil;
  15491. use Composer\Util\ProcessExecutor;
  15492. use React\Promise\PromiseInterface;
  15493. class FileDownloader implements DownloaderInterface, ChangeReportInterface
  15494. {
  15495. protected $io;
  15496. protected $config;
  15497. protected $httpDownloader;
  15498. protected $filesystem;
  15499. protected $cache;
  15500. protected $eventDispatcher;
  15501. protected $process;
  15502. public static $downloadMetadata = [];
  15503. public static $responseHeaders = [];
  15504. private $lastCacheWrites = [];
  15505. private $additionalCleanupPaths = [];
  15506. public function __construct(IOInterface $io, Config $config, HttpDownloader $httpDownloader, ?EventDispatcher $eventDispatcher = null, ?Cache $cache = null, ?Filesystem $filesystem = null, ?ProcessExecutor $process = null)
  15507. {
  15508. $this->io = $io;
  15509. $this->config = $config;
  15510. $this->eventDispatcher = $eventDispatcher;
  15511. $this->httpDownloader = $httpDownloader;
  15512. $this->cache = $cache;
  15513. $this->process = $process ?? new ProcessExecutor($io);
  15514. $this->filesystem = $filesystem ?: new Filesystem($this->process);
  15515. if ($this->cache && $this->cache->gcIsNecessary()) {
  15516. $this->io->writeError('Running cache garbage collection', true, IOInterface::VERY_VERBOSE);
  15517. $this->cache->gc($config->get('cache-files-ttl'), $config->get('cache-files-maxsize'));
  15518. }
  15519. }
  15520. public function getInstallationSource(): string
  15521. {
  15522. return 'dist';
  15523. }
  15524. public function download(PackageInterface $package, string $path, ?PackageInterface $prevPackage = null, bool $output = true): PromiseInterface
  15525. {
  15526. if (!$package->getDistUrl()) {
  15527. throw new \InvalidArgumentException('The given package is missing url information');
  15528. }
  15529. $cacheKeyGenerator = static function (PackageInterface $package, $key): string {
  15530. $cacheKey = sha1($key);
  15531. return $package->getName().'/'.$cacheKey.'.'.$package->getDistType();
  15532. };
  15533. $retries = 3;
  15534. $distUrls = $package->getDistUrls();
  15535. $urls = [];
  15536. foreach ($distUrls as $index => $url) {
  15537. $processedUrl = $this->processUrl($package, $url);
  15538. $urls[$index] = [
  15539. 'base' => $url,
  15540. 'processed' => $processedUrl,
  15541. 'cacheKey' => $cacheKeyGenerator($package, $processedUrl),
  15542. ];
  15543. }
  15544. assert(count($urls) > 0);
  15545. $fileName = $this->getFileName($package, $path);
  15546. $this->filesystem->ensureDirectoryExists($path);
  15547. $this->filesystem->ensureDirectoryExists(dirname($fileName));
  15548. $io = $this->io;
  15549. $cache = $this->cache;
  15550. $httpDownloader = $this->httpDownloader;
  15551. $eventDispatcher = $this->eventDispatcher;
  15552. $filesystem = $this->filesystem;
  15553. $accept = null;
  15554. $reject = null;
  15555. $download = function () use ($io, $output, $httpDownloader, $cache, $cacheKeyGenerator, $eventDispatcher, $package, $fileName, &$urls, &$accept, &$reject) {
  15556. $url = reset($urls);
  15557. $index = key($urls);
  15558. if ($eventDispatcher) {
  15559. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $httpDownloader, $url['processed'], 'package', $package);
  15560. $eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  15561. if ($preFileDownloadEvent->getCustomCacheKey() !== null) {
  15562. $url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getCustomCacheKey());
  15563. } elseif ($preFileDownloadEvent->getProcessedUrl() !== $url['processed']) {
  15564. $url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getProcessedUrl());
  15565. }
  15566. $url['processed'] = $preFileDownloadEvent->getProcessedUrl();
  15567. }
  15568. $urls[$index] = $url;
  15569. $checksum = $package->getDistSha1Checksum();
  15570. $cacheKey = $url['cacheKey'];
  15571. if ($cache && (!$checksum || $checksum === $cache->sha1($cacheKey)) && $cache->copyTo($cacheKey, $fileName)) {
  15572. if ($output) {
  15573. $io->writeError(" - Loading <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>) from cache", true, IOInterface::VERY_VERBOSE);
  15574. }
  15575. if (!$cache->isReadOnly()) {
  15576. $this->lastCacheWrites[$package->getName()] = $cacheKey;
  15577. }
  15578. $result = \React\Promise\resolve($fileName);
  15579. } else {
  15580. if ($output) {
  15581. $io->writeError(" - Downloading <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
  15582. }
  15583. $result = $httpDownloader->addCopy($url['processed'], $fileName, $package->getTransportOptions())
  15584. ->then($accept, $reject);
  15585. }
  15586. return $result->then(static function ($result) use ($fileName, $checksum, $url, $package, $eventDispatcher): string {
  15587. if (null === $result) {
  15588. return $fileName;
  15589. }
  15590. if (!file_exists($fileName)) {
  15591. throw new \UnexpectedValueException($url['base'].' could not be saved to '.$fileName.', make sure the'
  15592. .' directory is writable and you have internet connectivity');
  15593. }
  15594. if ($checksum && hash_file('sha1', $fileName) !== $checksum) {
  15595. throw new \UnexpectedValueException('The checksum verification of the file failed (downloaded from '.$url['base'].')');
  15596. }
  15597. if ($eventDispatcher) {
  15598. $postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, $fileName, $checksum, $url['processed'], 'package', $package);
  15599. $eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
  15600. }
  15601. return $fileName;
  15602. });
  15603. };
  15604. $accept = function ($response) use ($cache, $package, $fileName, &$urls): string {
  15605. $url = reset($urls);
  15606. $cacheKey = $url['cacheKey'];
  15607. FileDownloader::$downloadMetadata[$package->getName()] = @filesize($fileName) ?: $response->getHeader('Content-Length') ?: '?';
  15608. if (Platform::getEnv('GITHUB_ACTIONS') !== false && Platform::getEnv('COMPOSER_TESTS_ARE_RUNNING') === false) {
  15609. FileDownloader::$responseHeaders[$package->getName()] = $response->getHeaders();
  15610. }
  15611. if ($cache && !$cache->isReadOnly()) {
  15612. $this->lastCacheWrites[$package->getName()] = $cacheKey;
  15613. $cache->copyFrom($cacheKey, $fileName);
  15614. }
  15615. $response->collect();
  15616. return $fileName;
  15617. };
  15618. $reject = function ($e) use ($io, &$urls, $download, $fileName, $package, &$retries, $filesystem) {
  15619. if (file_exists($fileName)) {
  15620. $filesystem->unlink($fileName);
  15621. }
  15622. $this->clearLastCacheWrite($package);
  15623. if ($e instanceof IrrecoverableDownloadException) {
  15624. throw $e;
  15625. }
  15626. if ($e instanceof MaxFileSizeExceededException) {
  15627. throw $e;
  15628. }
  15629. if ($e instanceof TransportException) {
  15630. if ((0 !== $e->getCode() && !in_array($e->getCode(), [500, 502, 503, 504])) || !$retries) {
  15631. $retries = 0;
  15632. }
  15633. }
  15634. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  15635. $retries = 0;
  15636. $urls = [];
  15637. }
  15638. if ($retries) {
  15639. usleep(500000);
  15640. $retries--;
  15641. return $download();
  15642. }
  15643. array_shift($urls);
  15644. if ($urls) {
  15645. if ($io->isDebug()) {
  15646. $io->writeError(' Failed downloading '.$package->getName().': ['.get_class($e).'] '.$e->getCode().': '.$e->getMessage());
  15647. $io->writeError(' Trying the next URL for '.$package->getName());
  15648. } else {
  15649. $io->writeError(' Failed downloading '.$package->getName().', trying the next URL ('.$e->getCode().': '.$e->getMessage().')');
  15650. }
  15651. $retries = 3;
  15652. usleep(100000);
  15653. return $download();
  15654. }
  15655. throw $e;
  15656. };
  15657. return $download();
  15658. }
  15659. public function prepare(string $type, PackageInterface $package, string $path, ?PackageInterface $prevPackage = null): PromiseInterface
  15660. {
  15661. return \React\Promise\resolve(null);
  15662. }
  15663. public function cleanup(string $type, PackageInterface $package, string $path, ?PackageInterface $prevPackage = null): PromiseInterface
  15664. {
  15665. $fileName = $this->getFileName($package, $path);
  15666. if (file_exists($fileName)) {
  15667. $this->filesystem->unlink($fileName);
  15668. }
  15669. $dirsToCleanUp = [
  15670. $path,
  15671. $this->config->get('vendor-dir').'/'.explode('/', $package->getPrettyName())[0],
  15672. $this->config->get('vendor-dir').'/composer/',
  15673. $this->config->get('vendor-dir'),
  15674. ];
  15675. if (isset($this->additionalCleanupPaths[$package->getName()])) {
  15676. foreach ($this->additionalCleanupPaths[$package->getName()] as $path) {
  15677. $this->filesystem->remove($path);
  15678. }
  15679. }
  15680. foreach ($dirsToCleanUp as $dir) {
  15681. if (is_dir($dir) && $this->filesystem->isDirEmpty($dir) && realpath($dir) !== Platform::getCwd()) {
  15682. $this->filesystem->removeDirectoryPhp($dir);
  15683. }
  15684. }
  15685. return \React\Promise\resolve(null);
  15686. }
  15687. public function install(PackageInterface $package, string $path, bool $output = true): PromiseInterface
  15688. {
  15689. if ($output) {
  15690. $this->io->writeError(" - " . InstallOperation::format($package));
  15691. }
  15692. $this->filesystem->emptyDirectory($path);
  15693. $this->filesystem->ensureDirectoryExists($path);
  15694. $this->filesystem->rename($this->getFileName($package, $path), $path . '/' . $this->getDistPath($package, PATHINFO_BASENAME));
  15695. if ($package->getBinaries()) {
  15696. foreach ($package->getBinaries() as $bin) {
  15697. if (file_exists($path . '/' . $bin) && !is_executable($path . '/' . $bin)) {
  15698. Silencer::call('chmod', $path . '/' . $bin, 0777 & ~umask());
  15699. }
  15700. }
  15701. }
  15702. return \React\Promise\resolve(null);
  15703. }
  15704. protected function getDistPath(PackageInterface $package, int $component): string
  15705. {
  15706. return pathinfo((string) parse_url(strtr((string) $package->getDistUrl(), '\\', '/'), PHP_URL_PATH), $component);
  15707. }
  15708. protected function clearLastCacheWrite(PackageInterface $package): void
  15709. {
  15710. if ($this->cache && isset($this->lastCacheWrites[$package->getName()])) {
  15711. $this->cache->remove($this->lastCacheWrites[$package->getName()]);
  15712. unset($this->lastCacheWrites[$package->getName()]);
  15713. }
  15714. }
  15715. protected function addCleanupPath(PackageInterface $package, string $path): void
  15716. {
  15717. $this->additionalCleanupPaths[$package->getName()][] = $path;
  15718. }
  15719. protected function removeCleanupPath(PackageInterface $package, string $path): void
  15720. {
  15721. if (isset($this->additionalCleanupPaths[$package->getName()])) {
  15722. $idx = array_search($path, $this->additionalCleanupPaths[$package->getName()]);
  15723. if (false !== $idx) {
  15724. unset($this->additionalCleanupPaths[$package->getName()][$idx]);
  15725. }
  15726. }
  15727. }
  15728. public function update(PackageInterface $initial, PackageInterface $target, string $path): PromiseInterface
  15729. {
  15730. $this->io->writeError(" - " . UpdateOperation::format($initial, $target) . $this->getInstallOperationAppendix($target, $path));
  15731. $promise = $this->remove($initial, $path, false);
  15732. return $promise->then(function () use ($target, $path): PromiseInterface {
  15733. return $this->install($target, $path, false);
  15734. });
  15735. }
  15736. public function remove(PackageInterface $package, string $path, bool $output = true): PromiseInterface
  15737. {
  15738. if ($output) {
  15739. $this->io->writeError(" - " . UninstallOperation::format($package));
  15740. }
  15741. $promise = $this->filesystem->removeDirectoryAsync($path);
  15742. return $promise->then(static function ($result) use ($path): void {
  15743. if (!$result) {
  15744. throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
  15745. }
  15746. });
  15747. }
  15748. protected function getFileName(PackageInterface $package, string $path): string
  15749. {
  15750. $extension = $this->getDistPath($package, PATHINFO_EXTENSION);
  15751. if ($extension === '') {
  15752. $extension = $package->getDistType();
  15753. }
  15754. return rtrim($this->config->get('vendor-dir') . '/composer/tmp-' . md5($package . spl_object_hash($package)) . '.' . $extension, '.');
  15755. }
  15756. protected function getInstallOperationAppendix(PackageInterface $package, string $path): string
  15757. {
  15758. return '';
  15759. }
  15760. protected function processUrl(PackageInterface $package, string $url): string
  15761. {
  15762. if (!extension_loaded('openssl') && 0 === strpos($url, 'https:')) {
  15763. throw new \RuntimeException('You must enable the openssl extension to download files via https');
  15764. }
  15765. if ($package->getDistReference()) {
  15766. $url = UrlUtil::updateDistReference($this->config, $url, $package->getDistReference());
  15767. }
  15768. return $url;
  15769. }
  15770. public function getLocalChanges(PackageInterface $package, string $path): ?string
  15771. {
  15772. $prevIO = $this->io;
  15773. $this->io = new NullIO;
  15774. $this->io->loadConfiguration($this->config);
  15775. $e = null;
  15776. $output = '';
  15777. $targetDir = Filesystem::trimTrailingSlash($path);
  15778. try {
  15779. if (is_dir($targetDir.'_compare')) {
  15780. $this->filesystem->removeDirectory($targetDir.'_compare');
  15781. }
  15782. $this->download($package, $targetDir.'_compare', null, false);
  15783. $this->httpDownloader->wait();
  15784. $this->install($package, $targetDir.'_compare', false);
  15785. $this->process->wait();
  15786. $comparer = new Comparer();
  15787. $comparer->setSource($targetDir.'_compare');
  15788. $comparer->setUpdate($targetDir);
  15789. $comparer->doCompare();
  15790. $output = $comparer->getChangedAsString(true);
  15791. $this->filesystem->removeDirectory($targetDir.'_compare');
  15792. } catch (\Exception $e) {
  15793. }
  15794. $this->io = $prevIO;
  15795. if ($e) {
  15796. throw $e;
  15797. }
  15798. $output = trim($output);
  15799. return strlen($output) > 0 ? $output : null;
  15800. }
  15801. }
  15802. <?php declare(strict_types=1);
  15803. namespace Composer\Downloader;
  15804. class FilesystemException extends \Exception
  15805. {
  15806. public function __construct(string $message = '', int $code = 0, ?\Exception $previous = null)
  15807. {
  15808. parent::__construct("Filesystem exception: \n".$message, $code, $previous);
  15809. }
  15810. }
  15811. <?php declare(strict_types=1);
  15812. namespace Composer\Downloader;
  15813. use React\Promise\PromiseInterface;
  15814. use Composer\Package\PackageInterface;
  15815. use Composer\Pcre\Preg;
  15816. use Composer\Util\ProcessExecutor;
  15817. class FossilDownloader extends VcsDownloader
  15818. {
  15819. protected function doDownload(PackageInterface $package, string $path, string $url, ?PackageInterface $prevPackage = null): PromiseInterface
  15820. {
  15821. return \React\Promise\resolve(null);
  15822. }
  15823. protected function doInstall(PackageInterface $package, string $path, string $url): PromiseInterface
  15824. {
  15825. $this->config->prohibitUrlByConfig($url, $this->io);
  15826. $url = ProcessExecutor::escape($url);
  15827. $ref = ProcessExecutor::escape($package->getSourceReference());
  15828. $repoFile = $path . '.fossil';
  15829. $this->io->writeError("Cloning ".$package->getSourceReference());
  15830. $command = sprintf('fossil clone -- %s %s', $url, ProcessExecutor::escape($repoFile));
  15831. if (0 !== $this->process->execute($command, $ignoredOutput)) {
  15832. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  15833. }
  15834. $command = sprintf('fossil open --nested -- %s', ProcessExecutor::escape($repoFile));
  15835. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  15836. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  15837. }
  15838. $command = sprintf('fossil update -- %s', $ref);
  15839. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  15840. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  15841. }
  15842. return \React\Promise\resolve(null);
  15843. }
  15844. protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): PromiseInterface
  15845. {
  15846. $this->config->prohibitUrlByConfig($url, $this->io);
  15847. $ref = ProcessExecutor::escape($target->getSourceReference());
  15848. $this->io->writeError(" Updating to ".$target->getSourceReference());
  15849. if (!$this->hasMetadataRepository($path)) {
  15850. throw new \RuntimeException('The .fslckout file is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  15851. }
  15852. $command = sprintf('fossil pull && fossil up %s', $ref);
  15853. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  15854. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  15855. }
  15856. return \React\Promise\resolve(null);
  15857. }
  15858. public function getLocalChanges(PackageInterface $package, string $path): ?string
  15859. {
  15860. if (!$this->hasMetadataRepository($path)) {
  15861. return null;
  15862. }
  15863. $this->process->execute('fossil changes', $output, realpath($path));
  15864. $output = trim($output);
  15865. return strlen($output) > 0 ? $output : null;
  15866. }
  15867. protected function getCommitLogs(string $fromReference, string $toReference, string $path): string
  15868. {
  15869. $command = sprintf('fossil timeline -t ci -W 0 -n 0 before %s', ProcessExecutor::escape($toReference));
  15870. if (0 !== $this->process->execute($command, $output, realpath($path))) {
  15871. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  15872. }
  15873. $log = '';
  15874. $match = '/\d\d:\d\d:\d\d\s+\[' . $toReference . '\]/';
  15875. foreach ($this->process->splitLines($output) as $line) {
  15876. if (Preg::isMatch($match, $line)) {
  15877. break;
  15878. }
  15879. $log .= $line;
  15880. }
  15881. return $log;
  15882. }
  15883. protected function hasMetadataRepository(string $path): bool
  15884. {
  15885. return is_file($path . '/.fslckout') || is_file($path . '/_FOSSIL_');
  15886. }
  15887. }
  15888. <?php declare(strict_types=1);
  15889. namespace Composer\Downloader;
  15890. use Composer\Config;
  15891. use Composer\IO\IOInterface;
  15892. use Composer\Package\PackageInterface;
  15893. use Composer\Pcre\Preg;
  15894. use Composer\Util\Filesystem;
  15895. use Composer\Util\Git as GitUtil;
  15896. use Composer\Util\Url;
  15897. use Composer\Util\Platform;
  15898. use Composer\Util\ProcessExecutor;
  15899. use Composer\Cache;
  15900. use React\Promise\PromiseInterface;
  15901. class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
  15902. {
  15903. private $hasStashedChanges = [];
  15904. private $hasDiscardedChanges = [];
  15905. private $gitUtil;
  15906. private $cachedPackages = [];
  15907. public function __construct(IOInterface $io, Config $config, ?ProcessExecutor $process = null, ?Filesystem $fs = null)
  15908. {
  15909. parent::__construct($io, $config, $process, $fs);
  15910. $this->gitUtil = new GitUtil($this->io, $this->config, $this->process, $this->filesystem);
  15911. }
  15912. protected function doDownload(PackageInterface $package, string $path, string $url, ?PackageInterface $prevPackage = null): PromiseInterface
  15913. {
  15914. if (Filesystem::isLocalPath($url)) {
  15915. return \React\Promise\resolve(null);
  15916. }
  15917. GitUtil::cleanEnv();
  15918. $cachePath = $this->config->get('cache-vcs-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', $url).'/';
  15919. $gitVersion = GitUtil::getVersion($this->process);
  15920. if ($gitVersion && version_compare($gitVersion, '2.3.0-rc0', '>=') && Cache::isUsable($cachePath)) {
  15921. $this->io->writeError(" - Syncing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>) into cache");
  15922. $this->io->writeError(sprintf(' Cloning to cache at %s', ProcessExecutor::escape($cachePath)), true, IOInterface::DEBUG);
  15923. $ref = $package->getSourceReference();
  15924. if ($this->gitUtil->fetchRefOrSyncMirror($url, $cachePath, $ref, $package->getPrettyVersion()) && is_dir($cachePath)) {
  15925. $this->cachedPackages[$package->getId()][$ref] = true;
  15926. }
  15927. } elseif (null === $gitVersion) {
  15928. throw new \RuntimeException('git was not found in your PATH, skipping source download');
  15929. }
  15930. return \React\Promise\resolve(null);
  15931. }
  15932. protected function doInstall(PackageInterface $package, string $path, string $url): PromiseInterface
  15933. {
  15934. GitUtil::cleanEnv();
  15935. $path = $this->normalizePath($path);
  15936. $cachePath = $this->config->get('cache-vcs-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', $url).'/';
  15937. $ref = $package->getSourceReference();
  15938. $flag = Platform::isWindows() ? '/D ' : '';
  15939. if (!empty($this->cachedPackages[$package->getId()][$ref])) {
  15940. $msg = "Cloning ".$this->getShortHash($ref).' from cache';
  15941. $cloneFlags = '--dissociate --reference %cachePath% ';
  15942. $transportOptions = $package->getTransportOptions();
  15943. if (isset($transportOptions['git']['single_use_clone']) && $transportOptions['git']['single_use_clone']) {
  15944. $cloneFlags = '';
  15945. }
  15946. $command =
  15947. 'git clone --no-checkout %cachePath% %path% ' . $cloneFlags
  15948. . '&& cd '.$flag.'%path% '
  15949. . '&& git remote set-url origin -- %sanitizedUrl% && git remote add composer -- %sanitizedUrl%';
  15950. } else {
  15951. $msg = "Cloning ".$this->getShortHash($ref);
  15952. $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%';
  15953. if (Platform::getEnv('COMPOSER_DISABLE_NETWORK')) {
  15954. throw new \RuntimeException('The required git reference for '.$package->getName().' is not in cache and network is disabled, aborting');
  15955. }
  15956. }
  15957. $this->io->writeError($msg);
  15958. $commandCallable = static function (string $url) use ($path, $command, $cachePath): string {
  15959. return str_replace(
  15960. ['%url%', '%path%', '%cachePath%', '%sanitizedUrl%'],
  15961. [
  15962. ProcessExecutor::escape($url),
  15963. ProcessExecutor::escape($path),
  15964. ProcessExecutor::escape($cachePath),
  15965. ProcessExecutor::escape(Preg::replace('{://([^@]+?):(.+?)@}', '://', $url)),
  15966. ],
  15967. $command
  15968. );
  15969. };
  15970. $this->gitUtil->runCommand($commandCallable, $url, $path, true);
  15971. $sourceUrl = $package->getSourceUrl();
  15972. if ($url !== $sourceUrl && $sourceUrl !== null) {
  15973. $this->updateOriginUrl($path, $sourceUrl);
  15974. } else {
  15975. $this->setPushUrl($path, $url);
  15976. }
  15977. if ($newRef = $this->updateToCommit($package, $path, (string) $ref, $package->getPrettyVersion())) {
  15978. if ($package->getDistReference() === $package->getSourceReference()) {
  15979. $package->setDistReference($newRef);
  15980. }
  15981. $package->setSourceReference($newRef);
  15982. }
  15983. return \React\Promise\resolve(null);
  15984. }
  15985. protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): PromiseInterface
  15986. {
  15987. GitUtil::cleanEnv();
  15988. $path = $this->normalizePath($path);
  15989. if (!$this->hasMetadataRepository($path)) {
  15990. throw new \RuntimeException('The .git directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  15991. }
  15992. $cachePath = $this->config->get('cache-vcs-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', $url).'/';
  15993. $ref = $target->getSourceReference();
  15994. if (!empty($this->cachedPackages[$target->getId()][$ref])) {
  15995. $msg = "Checking out ".$this->getShortHash($ref).' from cache';
  15996. $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%';
  15997. } else {
  15998. $msg = "Checking out ".$this->getShortHash($ref);
  15999. $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%';
  16000. if (Platform::getEnv('COMPOSER_DISABLE_NETWORK')) {
  16001. throw new \RuntimeException('The required git reference for '.$target->getName().' is not in cache and network is disabled, aborting');
  16002. }
  16003. }
  16004. $this->io->writeError($msg);
  16005. $commandCallable = static function ($url) use ($ref, $command, $cachePath): string {
  16006. return str_replace(
  16007. ['%url%', '%ref%', '%cachePath%', '%sanitizedUrl%'],
  16008. [
  16009. ProcessExecutor::escape($url),
  16010. ProcessExecutor::escape($ref.'^{commit}'),
  16011. ProcessExecutor::escape($cachePath),
  16012. ProcessExecutor::escape(Preg::replace('{://([^@]+?):(.+?)@}', '://', $url)),
  16013. ],
  16014. $command
  16015. );
  16016. };
  16017. $this->gitUtil->runCommand($commandCallable, $url, $path);
  16018. if ($newRef = $this->updateToCommit($target, $path, (string) $ref, $target->getPrettyVersion())) {
  16019. if ($target->getDistReference() === $target->getSourceReference()) {
  16020. $target->setDistReference($newRef);
  16021. }
  16022. $target->setSourceReference($newRef);
  16023. }
  16024. $updateOriginUrl = false;
  16025. if (
  16026. 0 === $this->process->execute('git remote -v', $output, $path)
  16027. && Preg::isMatch('{^origin\s+(?P<url>\S+)}m', $output, $originMatch)
  16028. && Preg::isMatch('{^composer\s+(?P<url>\S+)}m', $output, $composerMatch)
  16029. ) {
  16030. if ($originMatch['url'] === $composerMatch['url'] && $composerMatch['url'] !== $target->getSourceUrl()) {
  16031. $updateOriginUrl = true;
  16032. }
  16033. }
  16034. if ($updateOriginUrl && $target->getSourceUrl() !== null) {
  16035. $this->updateOriginUrl($path, $target->getSourceUrl());
  16036. }
  16037. return \React\Promise\resolve(null);
  16038. }
  16039. public function getLocalChanges(PackageInterface $package, string $path): ?string
  16040. {
  16041. GitUtil::cleanEnv();
  16042. if (!$this->hasMetadataRepository($path)) {
  16043. return null;
  16044. }
  16045. $command = 'git status --porcelain --untracked-files=no';
  16046. if (0 !== $this->process->execute($command, $output, $path)) {
  16047. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  16048. }
  16049. $output = trim($output);
  16050. return strlen($output) > 0 ? $output : null;
  16051. }
  16052. public function getUnpushedChanges(PackageInterface $package, string $path): ?string
  16053. {
  16054. GitUtil::cleanEnv();
  16055. $path = $this->normalizePath($path);
  16056. if (!$this->hasMetadataRepository($path)) {
  16057. return null;
  16058. }
  16059. $command = 'git show-ref --head -d';
  16060. if (0 !== $this->process->execute($command, $output, $path)) {
  16061. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  16062. }
  16063. $refs = trim($output);
  16064. if (!Preg::isMatchStrictGroups('{^([a-f0-9]+) HEAD$}mi', $refs, $match)) {
  16065. return null;
  16066. }
  16067. $headRef = $match[1];
  16068. if (!Preg::isMatchAllStrictGroups('{^'.$headRef.' refs/heads/(.+)$}mi', $refs, $matches)) {
  16069. return null;
  16070. }
  16071. $candidateBranches = $matches[1];
  16072. $branch = $candidateBranches[0];
  16073. $unpushedChanges = null;
  16074. $branchNotFoundError = false;
  16075. for ($i = 0; $i <= 1; $i++) {
  16076. $remoteBranches = [];
  16077. foreach ($candidateBranches as $candidate) {
  16078. if (Preg::isMatchAllStrictGroups('{^[a-f0-9]+ refs/remotes/((?:[^/]+)/'.preg_quote($candidate).')$}mi', $refs, $matches)) {
  16079. foreach ($matches[1] as $match) {
  16080. $branch = $candidate;
  16081. $remoteBranches[] = $match;
  16082. }
  16083. break;
  16084. }
  16085. }
  16086. if (count($remoteBranches) === 0) {
  16087. $unpushedChanges = 'Branch ' . $branch . ' could not be found on any remote and appears to be unpushed';
  16088. $branchNotFoundError = true;
  16089. } else {
  16090. if ($branchNotFoundError) {
  16091. $unpushedChanges = null;
  16092. }
  16093. foreach ($remoteBranches as $remoteBranch) {
  16094. $command = sprintf('git diff --name-status %s...%s --', $remoteBranch, $branch);
  16095. if (0 !== $this->process->execute($command, $output, $path)) {
  16096. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  16097. }
  16098. $output = trim($output);
  16099. if ($unpushedChanges === null || strlen($output) < strlen($unpushedChanges)) {
  16100. $unpushedChanges = $output;
  16101. }
  16102. }
  16103. }
  16104. if ($unpushedChanges && $i === 0) {
  16105. $this->process->execute('git fetch --all', $output, $path);
  16106. $command = 'git show-ref --head -d';
  16107. if (0 !== $this->process->execute($command, $output, $path)) {
  16108. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  16109. }
  16110. $refs = trim($output);
  16111. }
  16112. if (!$unpushedChanges) {
  16113. break;
  16114. }
  16115. }
  16116. return $unpushedChanges;
  16117. }
  16118. protected function cleanChanges(PackageInterface $package, string $path, bool $update): PromiseInterface
  16119. {
  16120. GitUtil::cleanEnv();
  16121. $path = $this->normalizePath($path);
  16122. $unpushed = $this->getUnpushedChanges($package, $path);
  16123. if ($unpushed && ($this->io->isInteractive() || $this->config->get('discard-changes') !== true)) {
  16124. throw new \RuntimeException('Source directory ' . $path . ' has unpushed changes on the current branch: '."\n".$unpushed);
  16125. }
  16126. if (null === ($changes = $this->getLocalChanges($package, $path))) {
  16127. return \React\Promise\resolve(null);
  16128. }
  16129. if (!$this->io->isInteractive()) {
  16130. $discardChanges = $this->config->get('discard-changes');
  16131. if (true === $discardChanges) {
  16132. return $this->discardChanges($path);
  16133. }
  16134. if ('stash' === $discardChanges) {
  16135. if (!$update) {
  16136. return parent::cleanChanges($package, $path, $update);
  16137. }
  16138. return $this->stashChanges($path);
  16139. }
  16140. return parent::cleanChanges($package, $path, $update);
  16141. }
  16142. $changes = array_map(static function ($elem): string {
  16143. return ' '.$elem;
  16144. }, Preg::split('{\s*\r?\n\s*}', $changes));
  16145. $this->io->writeError(' <error>'.$package->getPrettyName().' has modified files:</error>');
  16146. $this->io->writeError(array_slice($changes, 0, 10));
  16147. if (count($changes) > 10) {
  16148. $this->io->writeError(' <info>' . (count($changes) - 10) . ' more files modified, choose "v" to view the full list</info>');
  16149. }
  16150. while (true) {
  16151. switch ($this->io->ask(' <info>Discard changes [y,n,v,d,'.($update ? 's,' : '').'?]?</info> ', '?')) {
  16152. case 'y':
  16153. $this->discardChanges($path);
  16154. break 2;
  16155. case 's':
  16156. if (!$update) {
  16157. goto help;
  16158. }
  16159. $this->stashChanges($path);
  16160. break 2;
  16161. case 'n':
  16162. throw new \RuntimeException('Update aborted');
  16163. case 'v':
  16164. $this->io->writeError($changes);
  16165. break;
  16166. case 'd':
  16167. $this->viewDiff($path);
  16168. break;
  16169. case '?':
  16170. default:
  16171. help :
  16172. $this->io->writeError([
  16173. ' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
  16174. ' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
  16175. ' v - view modified files',
  16176. ' d - view local modifications (diff)',
  16177. ]);
  16178. if ($update) {
  16179. $this->io->writeError(' s - stash changes and try to reapply them after the update');
  16180. }
  16181. $this->io->writeError(' ? - print help');
  16182. break;
  16183. }
  16184. }
  16185. return \React\Promise\resolve(null);
  16186. }
  16187. protected function reapplyChanges(string $path): void
  16188. {
  16189. $path = $this->normalizePath($path);
  16190. if (!empty($this->hasStashedChanges[$path])) {
  16191. unset($this->hasStashedChanges[$path]);
  16192. $this->io->writeError(' <info>Re-applying stashed changes</info>');
  16193. if (0 !== $this->process->execute('git stash pop', $output, $path)) {
  16194. throw new \RuntimeException("Failed to apply stashed changes:\n\n".$this->process->getErrorOutput());
  16195. }
  16196. }
  16197. unset($this->hasDiscardedChanges[$path]);
  16198. }
  16199. protected function updateToCommit(PackageInterface $package, string $path, string $reference, string $prettyVersion): ?string
  16200. {
  16201. $force = !empty($this->hasDiscardedChanges[$path]) || !empty($this->hasStashedChanges[$path]) ? '-f ' : '';
  16202. $template = 'git checkout '.$force.'%s -- && git reset --hard %1$s --';
  16203. $branch = Preg::replace('{(?:^dev-|(?:\.x)?-dev$)}i', '', $prettyVersion);
  16204. $branches = null;
  16205. if (0 === $this->process->execute('git branch -r', $output, $path)) {
  16206. $branches = $output;
  16207. }
  16208. $gitRef = $reference;
  16209. if (!Preg::isMatch('{^[a-f0-9]{40}$}', $reference)
  16210. && null !== $branches
  16211. && Preg::isMatch('{^\s+composer/'.preg_quote($reference).'$}m', $branches)
  16212. ) {
  16213. $command = sprintf('git checkout '.$force.'-B %s %s -- && git reset --hard %2$s --', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$reference));
  16214. if (0 === $this->process->execute($command, $output, $path)) {
  16215. return null;
  16216. }
  16217. }
  16218. if (Preg::isMatch('{^[a-f0-9]{40}$}', $reference)) {
  16219. if (null !== $branches && !Preg::isMatch('{^\s+composer/'.preg_quote($branch).'$}m', $branches) && Preg::isMatch('{^\s+composer/v'.preg_quote($branch).'$}m', $branches)) {
  16220. $branch = 'v' . $branch;
  16221. }
  16222. $command = sprintf('git checkout %s --', ProcessExecutor::escape($branch));
  16223. $fallbackCommand = sprintf('git checkout '.$force.'-B %s %s --', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$branch));
  16224. $resetCommand = sprintf('git reset --hard %s --', ProcessExecutor::escape($reference));
  16225. if (0 === $this->process->execute("($command || $fallbackCommand) && $resetCommand", $output, $path)) {
  16226. return null;
  16227. }
  16228. }
  16229. $command = sprintf($template, ProcessExecutor::escape($gitRef));
  16230. if (0 === $this->process->execute($command, $output, $path)) {
  16231. return null;
  16232. }
  16233. $exceptionExtra = '';
  16234. if (false !== strpos($this->process->getErrorOutput(), $reference)) {
  16235. $this->io->writeError(' <warning>'.$reference.' is gone (history was rewritten?)</warning>');
  16236. $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.';
  16237. }
  16238. throw new \RuntimeException(Url::sanitize('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput() . $exceptionExtra));
  16239. }
  16240. protected function updateOriginUrl(string $path, string $url): void
  16241. {
  16242. $this->process->execute(sprintf('git remote set-url origin -- %s', ProcessExecutor::escape($url)), $output, $path);
  16243. $this->setPushUrl($path, $url);
  16244. }
  16245. protected function setPushUrl(string $path, string $url): void
  16246. {
  16247. if (Preg::isMatch('{^(?:https?|git)://'.GitUtil::getGitHubDomainsRegex($this->config).'/([^/]+)/([^/]+?)(?:\.git)?$}', $url, $match)) {
  16248. $protocols = $this->config->get('github-protocols');
  16249. $pushUrl = 'git@'.$match[1].':'.$match[2].'/'.$match[3].'.git';
  16250. if (!in_array('ssh', $protocols, true)) {
  16251. $pushUrl = 'https://' . $match[1] . '/'.$match[2].'/'.$match[3].'.git';
  16252. }
  16253. $cmd = sprintf('git remote set-url --push origin -- %s', ProcessExecutor::escape($pushUrl));
  16254. $this->process->execute($cmd, $ignoredOutput, $path);
  16255. }
  16256. }
  16257. protected function getCommitLogs(string $fromReference, string $toReference, string $path): string
  16258. {
  16259. $path = $this->normalizePath($path);
  16260. $command = sprintf('git log %s..%s --pretty=format:"%%h - %%an: %%s"'.GitUtil::getNoShowSignatureFlag($this->process), ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
  16261. if (0 !== $this->process->execute($command, $output, $path)) {
  16262. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  16263. }
  16264. return $output;
  16265. }
  16266. protected function discardChanges(string $path): PromiseInterface
  16267. {
  16268. $path = $this->normalizePath($path);
  16269. if (0 !== $this->process->execute('git clean -df && git reset --hard', $output, $path)) {
  16270. throw new \RuntimeException("Could not reset changes\n\n:".$output);
  16271. }
  16272. $this->hasDiscardedChanges[$path] = true;
  16273. return \React\Promise\resolve(null);
  16274. }
  16275. protected function stashChanges(string $path): PromiseInterface
  16276. {
  16277. $path = $this->normalizePath($path);
  16278. if (0 !== $this->process->execute('git stash --include-untracked', $output, $path)) {
  16279. throw new \RuntimeException("Could not stash changes\n\n:".$output);
  16280. }
  16281. $this->hasStashedChanges[$path] = true;
  16282. return \React\Promise\resolve(null);
  16283. }
  16284. protected function viewDiff(string $path): void
  16285. {
  16286. $path = $this->normalizePath($path);
  16287. if (0 !== $this->process->execute('git diff HEAD', $output, $path)) {
  16288. throw new \RuntimeException("Could not view diff\n\n:".$output);
  16289. }
  16290. $this->io->writeError($output);
  16291. }
  16292. protected function normalizePath(string $path): string
  16293. {
  16294. if (Platform::isWindows() && strlen($path) > 0) {
  16295. $basePath = $path;
  16296. $removed = [];
  16297. while (!is_dir($basePath) && $basePath !== '\\') {
  16298. array_unshift($removed, basename($basePath));
  16299. $basePath = dirname($basePath);
  16300. }
  16301. if ($basePath === '\\') {
  16302. return $path;
  16303. }
  16304. $path = rtrim(realpath($basePath) . '/' . implode('/', $removed), '/');
  16305. }
  16306. return $path;
  16307. }
  16308. protected function hasMetadataRepository(string $path): bool
  16309. {
  16310. $path = $this->normalizePath($path);
  16311. return is_dir($path.'/.git');
  16312. }
  16313. protected function getShortHash(string $reference): string
  16314. {
  16315. if (!$this->io->isVerbose() && Preg::isMatch('{^[0-9a-f]{40}$}', $reference)) {
  16316. return substr($reference, 0, 10);
  16317. }
  16318. return $reference;
  16319. }
  16320. }
  16321. <?php declare(strict_types=1);
  16322. namespace Composer\Downloader;
  16323. use React\Promise\PromiseInterface;
  16324. use Composer\Package\PackageInterface;
  16325. use Composer\Util\Platform;
  16326. use Composer\Util\ProcessExecutor;
  16327. class GzipDownloader extends ArchiveDownloader
  16328. {
  16329. protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface
  16330. {
  16331. $filename = pathinfo(parse_url(strtr((string) $package->getDistUrl(), '\\', '/'), PHP_URL_PATH), PATHINFO_FILENAME);
  16332. $targetFilepath = $path . DIRECTORY_SEPARATOR . $filename;
  16333. if (!Platform::isWindows()) {
  16334. $command = 'gzip -cd -- ' . ProcessExecutor::escape($file) . ' > ' . ProcessExecutor::escape($targetFilepath);
  16335. if (0 === $this->process->execute($command, $ignoredOutput)) {
  16336. return \React\Promise\resolve(null);
  16337. }
  16338. if (extension_loaded('zlib')) {
  16339. $this->extractUsingExt($file, $targetFilepath);
  16340. return \React\Promise\resolve(null);
  16341. }
  16342. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  16343. throw new \RuntimeException($processError);
  16344. }
  16345. $this->extractUsingExt($file, $targetFilepath);
  16346. return \React\Promise\resolve(null);
  16347. }
  16348. private function extractUsingExt(string $file, string $targetFilepath): void
  16349. {
  16350. $archiveFile = gzopen($file, 'rb');
  16351. $targetFile = fopen($targetFilepath, 'wb');
  16352. while ($string = gzread($archiveFile, 4096)) {
  16353. fwrite($targetFile, $string, Platform::strlen($string));
  16354. }
  16355. gzclose($archiveFile);
  16356. fclose($targetFile);
  16357. }
  16358. }
  16359. <?php declare(strict_types=1);
  16360. namespace Composer\Downloader;
  16361. use React\Promise\PromiseInterface;
  16362. use Composer\Package\PackageInterface;
  16363. use Composer\Util\ProcessExecutor;
  16364. use Composer\Util\Hg as HgUtils;
  16365. class HgDownloader extends VcsDownloader
  16366. {
  16367. protected function doDownload(PackageInterface $package, string $path, string $url, ?PackageInterface $prevPackage = null): PromiseInterface
  16368. {
  16369. if (null === HgUtils::getVersion($this->process)) {
  16370. throw new \RuntimeException('hg was not found in your PATH, skipping source download');
  16371. }
  16372. return \React\Promise\resolve(null);
  16373. }
  16374. protected function doInstall(PackageInterface $package, string $path, string $url): PromiseInterface
  16375. {
  16376. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  16377. $cloneCommand = static function (string $url) use ($path): string {
  16378. return sprintf('hg clone -- %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($path));
  16379. };
  16380. $hgUtils->runCommand($cloneCommand, $url, $path);
  16381. $ref = ProcessExecutor::escape($package->getSourceReference());
  16382. $command = sprintf('hg up -- %s', $ref);
  16383. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  16384. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  16385. }
  16386. return \React\Promise\resolve(null);
  16387. }
  16388. protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): PromiseInterface
  16389. {
  16390. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  16391. $ref = $target->getSourceReference();
  16392. $this->io->writeError(" Updating to ".$target->getSourceReference());
  16393. if (!$this->hasMetadataRepository($path)) {
  16394. throw new \RuntimeException('The .hg directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  16395. }
  16396. $command = static function ($url) use ($ref): string {
  16397. return sprintf('hg pull -- %s && hg up -- %s', ProcessExecutor::escape($url), ProcessExecutor::escape($ref));
  16398. };
  16399. $hgUtils->runCommand($command, $url, $path);
  16400. return \React\Promise\resolve(null);
  16401. }
  16402. public function getLocalChanges(PackageInterface $package, string $path): ?string
  16403. {
  16404. if (!is_dir($path.'/.hg')) {
  16405. return null;
  16406. }
  16407. $this->process->execute('hg st', $output, realpath($path));
  16408. $output = trim($output);
  16409. return strlen($output) > 0 ? $output : null;
  16410. }
  16411. protected function getCommitLogs(string $fromReference, string $toReference, string $path): string
  16412. {
  16413. $command = sprintf('hg log -r %s:%s --style compact', ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
  16414. if (0 !== $this->process->execute($command, $output, realpath($path))) {
  16415. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  16416. }
  16417. return $output;
  16418. }
  16419. protected function hasMetadataRepository(string $path): bool
  16420. {
  16421. return is_dir($path . '/.hg');
  16422. }
  16423. }
  16424. <?php declare(strict_types=1);
  16425. namespace Composer\Downloader;
  16426. class MaxFileSizeExceededException extends TransportException
  16427. {
  16428. }
  16429. <?php declare(strict_types=1);
  16430. namespace Composer\Downloader;
  16431. use React\Promise\PromiseInterface;
  16432. use Composer\Package\Archiver\ArchivableFilesFinder;
  16433. use Composer\Package\Dumper\ArrayDumper;
  16434. use Composer\Package\PackageInterface;
  16435. use Composer\Package\Version\VersionGuesser;
  16436. use Composer\Package\Version\VersionParser;
  16437. use Composer\Util\Platform;
  16438. use Composer\Util\Filesystem;
  16439. use Symfony\Component\Filesystem\Exception\IOException;
  16440. use Symfony\Component\Filesystem\Filesystem as SymfonyFilesystem;
  16441. use Composer\DependencyResolver\Operation\InstallOperation;
  16442. use Composer\DependencyResolver\Operation\UninstallOperation;
  16443. class PathDownloader extends FileDownloader implements VcsCapableDownloaderInterface
  16444. {
  16445. private const STRATEGY_SYMLINK = 10;
  16446. private const STRATEGY_MIRROR = 20;
  16447. public function download(PackageInterface $package, string $path, ?PackageInterface $prevPackage = null, bool $output = true): PromiseInterface
  16448. {
  16449. $path = Filesystem::trimTrailingSlash($path);
  16450. $url = $package->getDistUrl();
  16451. $realUrl = realpath($url);
  16452. if (false === $realUrl || !file_exists($realUrl) || !is_dir($realUrl)) {
  16453. throw new \RuntimeException(sprintf(
  16454. 'Source path "%s" is not found for package %s',
  16455. $url,
  16456. $package->getName()
  16457. ));
  16458. }
  16459. if (realpath($path) === $realUrl) {
  16460. return \React\Promise\resolve(null);
  16461. }
  16462. if (strpos(realpath($path) . DIRECTORY_SEPARATOR, $realUrl . DIRECTORY_SEPARATOR) === 0) {
  16463. throw new \RuntimeException(sprintf(
  16464. 'Package %s cannot install to "%s" inside its source at "%s"',
  16465. $package->getName(),
  16466. realpath($path),
  16467. $realUrl
  16468. ));
  16469. }
  16470. return \React\Promise\resolve(null);
  16471. }
  16472. public function install(PackageInterface $package, string $path, bool $output = true): PromiseInterface
  16473. {
  16474. $path = Filesystem::trimTrailingSlash($path);
  16475. $url = $package->getDistUrl();
  16476. $realUrl = realpath($url);
  16477. if (realpath($path) === $realUrl) {
  16478. if ($output) {
  16479. $this->io->writeError(" - " . InstallOperation::format($package) . $this->getInstallOperationAppendix($package, $path));
  16480. }
  16481. return \React\Promise\resolve(null);
  16482. }
  16483. $transportOptions = $package->getTransportOptions() + ['relative' => true];
  16484. [$currentStrategy, $allowedStrategies] = $this->computeAllowedStrategies($transportOptions);
  16485. $symfonyFilesystem = new SymfonyFilesystem();
  16486. $this->filesystem->removeDirectory($path);
  16487. if ($output) {
  16488. $this->io->writeError(" - " . InstallOperation::format($package).': ', false);
  16489. }
  16490. $isFallback = false;
  16491. if (self::STRATEGY_SYMLINK === $currentStrategy) {
  16492. try {
  16493. if (Platform::isWindows()) {
  16494. if ($output) {
  16495. $this->io->writeError(sprintf('Junctioning from %s', $url), false);
  16496. }
  16497. $this->filesystem->junction($realUrl, $path);
  16498. } else {
  16499. $absolutePath = $path;
  16500. if (!$this->filesystem->isAbsolutePath($absolutePath)) {
  16501. $absolutePath = Platform::getCwd() . DIRECTORY_SEPARATOR . $path;
  16502. }
  16503. $shortestPath = $this->filesystem->findShortestPath($absolutePath, $realUrl);
  16504. $path = rtrim($path, "/");
  16505. if ($output) {
  16506. $this->io->writeError(sprintf('Symlinking from %s', $url), false);
  16507. }
  16508. if ($transportOptions['relative']) {
  16509. $symfonyFilesystem->symlink($shortestPath.'/', $path);
  16510. } else {
  16511. $symfonyFilesystem->symlink($realUrl.'/', $path);
  16512. }
  16513. }
  16514. } catch (IOException $e) {
  16515. if (in_array(self::STRATEGY_MIRROR, $allowedStrategies, true)) {
  16516. if ($output) {
  16517. $this->io->writeError('');
  16518. $this->io->writeError(' <error>Symlink failed, fallback to use mirroring!</error>');
  16519. }
  16520. $currentStrategy = self::STRATEGY_MIRROR;
  16521. $isFallback = true;
  16522. } else {
  16523. throw new \RuntimeException(sprintf('Symlink from "%s" to "%s" failed!', $realUrl, $path));
  16524. }
  16525. }
  16526. }
  16527. if (self::STRATEGY_MIRROR === $currentStrategy) {
  16528. $realUrl = $this->filesystem->normalizePath($realUrl);
  16529. if ($output) {
  16530. $this->io->writeError(sprintf('%sMirroring from %s', $isFallback ? ' ' : '', $url), false);
  16531. }
  16532. $iterator = new ArchivableFilesFinder($realUrl, []);
  16533. $symfonyFilesystem->mirror($realUrl, $path, $iterator);
  16534. }
  16535. if ($output) {
  16536. $this->io->writeError('');
  16537. }
  16538. return \React\Promise\resolve(null);
  16539. }
  16540. public function remove(PackageInterface $package, string $path, bool $output = true): PromiseInterface
  16541. {
  16542. $path = Filesystem::trimTrailingSlash($path);
  16543. if (Platform::isWindows() && $this->filesystem->isJunction($path)) {
  16544. if ($output) {
  16545. $this->io->writeError(" - " . UninstallOperation::format($package).", source is still present in $path");
  16546. }
  16547. if (!$this->filesystem->removeJunction($path)) {
  16548. $this->io->writeError(" <warning>Could not remove junction at " . $path . " - is another process locking it?</warning>");
  16549. throw new \RuntimeException('Could not reliably remove junction for package ' . $package->getName());
  16550. }
  16551. return \React\Promise\resolve(null);
  16552. }
  16553. $fs = new Filesystem;
  16554. $absPath = $fs->isAbsolutePath($path) ? $path : Platform::getCwd() . '/' . $path;
  16555. $absDistUrl = $fs->isAbsolutePath($package->getDistUrl()) ? $package->getDistUrl() : Platform::getCwd() . '/' . $package->getDistUrl();
  16556. if ($fs->normalizePath($absPath) === $fs->normalizePath($absDistUrl)) {
  16557. if ($output) {
  16558. $this->io->writeError(" - " . UninstallOperation::format($package).", source is still present in $path");
  16559. }
  16560. return \React\Promise\resolve(null);
  16561. }
  16562. return parent::remove($package, $path, $output);
  16563. }
  16564. public function getVcsReference(PackageInterface $package, string $path): ?string
  16565. {
  16566. $path = Filesystem::trimTrailingSlash($path);
  16567. $parser = new VersionParser;
  16568. $guesser = new VersionGuesser($this->config, $this->process, $parser);
  16569. $dumper = new ArrayDumper;
  16570. $packageConfig = $dumper->dump($package);
  16571. if ($packageVersion = $guesser->guessVersion($packageConfig, $path)) {
  16572. return $packageVersion['commit'];
  16573. }
  16574. return null;
  16575. }
  16576. protected function getInstallOperationAppendix(PackageInterface $package, string $path): string
  16577. {
  16578. $realUrl = realpath($package->getDistUrl());
  16579. if (realpath($path) === $realUrl) {
  16580. return ': Source already present';
  16581. }
  16582. [$currentStrategy] = $this->computeAllowedStrategies($package->getTransportOptions());
  16583. if ($currentStrategy === self::STRATEGY_SYMLINK) {
  16584. if (Platform::isWindows()) {
  16585. return ': Junctioning from '.$package->getDistUrl();
  16586. }
  16587. return ': Symlinking from '.$package->getDistUrl();
  16588. }
  16589. return ': Mirroring from '.$package->getDistUrl();
  16590. }
  16591. private function computeAllowedStrategies(array $transportOptions): array
  16592. {
  16593. $currentStrategy = self::STRATEGY_SYMLINK;
  16594. $allowedStrategies = [self::STRATEGY_SYMLINK, self::STRATEGY_MIRROR];
  16595. $mirrorPathRepos = Platform::getEnv('COMPOSER_MIRROR_PATH_REPOS');
  16596. if ($mirrorPathRepos) {
  16597. $currentStrategy = self::STRATEGY_MIRROR;
  16598. }
  16599. $symlinkOption = $transportOptions['symlink'] ?? null;
  16600. if (true === $symlinkOption) {
  16601. $currentStrategy = self::STRATEGY_SYMLINK;
  16602. $allowedStrategies = [self::STRATEGY_SYMLINK];
  16603. } elseif (false === $symlinkOption) {
  16604. $currentStrategy = self::STRATEGY_MIRROR;
  16605. $allowedStrategies = [self::STRATEGY_MIRROR];
  16606. }
  16607. if (Platform::isWindows() && self::STRATEGY_SYMLINK === $currentStrategy && !$this->safeJunctions()) {
  16608. if (!in_array(self::STRATEGY_MIRROR, $allowedStrategies, true)) {
  16609. 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');
  16610. }
  16611. $currentStrategy = self::STRATEGY_MIRROR;
  16612. $allowedStrategies = [self::STRATEGY_MIRROR];
  16613. }
  16614. if (!Platform::isWindows() && self::STRATEGY_SYMLINK === $currentStrategy && !function_exists('symlink')) {
  16615. if (!in_array(self::STRATEGY_MIRROR, $allowedStrategies, true)) {
  16616. throw new \RuntimeException('Your PHP has the symlink() function disabled which does not allow Composer to use symlinks and this path repository has symlink:true in its options so copying is not allowed');
  16617. }
  16618. $currentStrategy = self::STRATEGY_MIRROR;
  16619. $allowedStrategies = [self::STRATEGY_MIRROR];
  16620. }
  16621. return [$currentStrategy, $allowedStrategies];
  16622. }
  16623. private function safeJunctions(): bool
  16624. {
  16625. return function_exists('proc_open') &&
  16626. (PHP_WINDOWS_VERSION_MAJOR > 6 ||
  16627. (PHP_WINDOWS_VERSION_MAJOR === 6 && PHP_WINDOWS_VERSION_MINOR >= 1));
  16628. }
  16629. }
  16630. <?php declare(strict_types=1);
  16631. namespace Composer\Downloader;
  16632. use React\Promise\PromiseInterface;
  16633. use Composer\Package\PackageInterface;
  16634. use Composer\Repository\VcsRepository;
  16635. use Composer\Util\Perforce;
  16636. class PerforceDownloader extends VcsDownloader
  16637. {
  16638. protected $perforce;
  16639. protected function doDownload(PackageInterface $package, string $path, string $url, ?PackageInterface $prevPackage = null): PromiseInterface
  16640. {
  16641. return \React\Promise\resolve(null);
  16642. }
  16643. public function doInstall(PackageInterface $package, string $path, string $url): PromiseInterface
  16644. {
  16645. $ref = $package->getSourceReference();
  16646. $label = $this->getLabelFromSourceReference((string) $ref);
  16647. $this->io->writeError('Cloning ' . $ref);
  16648. $this->initPerforce($package, $path, $url);
  16649. $this->perforce->setStream($ref);
  16650. $this->perforce->p4Login();
  16651. $this->perforce->writeP4ClientSpec();
  16652. $this->perforce->connectClient();
  16653. $this->perforce->syncCodeBase($label);
  16654. $this->perforce->cleanupClientSpec();
  16655. return \React\Promise\resolve(null);
  16656. }
  16657. private function getLabelFromSourceReference(string $ref): ?string
  16658. {
  16659. $pos = strpos($ref, '@');
  16660. if (false !== $pos) {
  16661. return substr($ref, $pos + 1);
  16662. }
  16663. return null;
  16664. }
  16665. public function initPerforce(PackageInterface $package, string $path, string $url): void
  16666. {
  16667. if (!empty($this->perforce)) {
  16668. $this->perforce->initializePath($path);
  16669. return;
  16670. }
  16671. $repository = $package->getRepository();
  16672. $repoConfig = null;
  16673. if ($repository instanceof VcsRepository) {
  16674. $repoConfig = $this->getRepoConfig($repository);
  16675. }
  16676. $this->perforce = Perforce::create($repoConfig, $url, $path, $this->process, $this->io);
  16677. }
  16678. private function getRepoConfig(VcsRepository $repository): array
  16679. {
  16680. return $repository->getRepoConfig();
  16681. }
  16682. protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): PromiseInterface
  16683. {
  16684. return $this->doInstall($target, $path, $url);
  16685. }
  16686. public function getLocalChanges(PackageInterface $package, string $path): ?string
  16687. {
  16688. $this->io->writeError('Perforce driver does not check for local changes before overriding');
  16689. return null;
  16690. }
  16691. protected function getCommitLogs(string $fromReference, string $toReference, string $path): string
  16692. {
  16693. return $this->perforce->getCommitLogs($fromReference, $toReference);
  16694. }
  16695. public function setPerforce(Perforce $perforce): void
  16696. {
  16697. $this->perforce = $perforce;
  16698. }
  16699. protected function hasMetadataRepository(string $path): bool
  16700. {
  16701. return true;
  16702. }
  16703. }
  16704. <?php declare(strict_types=1);
  16705. namespace Composer\Downloader;
  16706. use React\Promise\PromiseInterface;
  16707. use Composer\Package\PackageInterface;
  16708. class PharDownloader extends ArchiveDownloader
  16709. {
  16710. protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface
  16711. {
  16712. $archive = new \Phar($file);
  16713. $archive->extractTo($path, null, true);
  16714. return \React\Promise\resolve(null);
  16715. }
  16716. }
  16717. <?php declare(strict_types=1);
  16718. namespace Composer\Downloader;
  16719. use React\Promise\PromiseInterface;
  16720. use Composer\Util\IniHelper;
  16721. use Composer\Util\Platform;
  16722. use Composer\Util\ProcessExecutor;
  16723. use Composer\Package\PackageInterface;
  16724. use RarArchive;
  16725. class RarDownloader extends ArchiveDownloader
  16726. {
  16727. protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface
  16728. {
  16729. $processError = null;
  16730. if (!Platform::isWindows()) {
  16731. $command = 'unrar x -- ' . ProcessExecutor::escape($file) . ' ' . ProcessExecutor::escape($path) . ' >/dev/null && chmod -R u+w ' . ProcessExecutor::escape($path);
  16732. if (0 === $this->process->execute($command, $ignoredOutput)) {
  16733. return \React\Promise\resolve(null);
  16734. }
  16735. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  16736. }
  16737. if (!class_exists('RarArchive')) {
  16738. $iniMessage = IniHelper::getMessage();
  16739. $error = "Could not decompress the archive, enable the PHP rar extension or install unrar.\n"
  16740. . $iniMessage . "\n" . $processError;
  16741. if (!Platform::isWindows()) {
  16742. $error = "Could not decompress the archive, enable the PHP rar extension.\n" . $iniMessage;
  16743. }
  16744. throw new \RuntimeException($error);
  16745. }
  16746. $rarArchive = RarArchive::open($file);
  16747. if (false === $rarArchive) {
  16748. throw new \UnexpectedValueException('Could not open RAR archive: ' . $file);
  16749. }
  16750. $entries = $rarArchive->getEntries();
  16751. if (false === $entries) {
  16752. throw new \RuntimeException('Could not retrieve RAR archive entries');
  16753. }
  16754. foreach ($entries as $entry) {
  16755. if (false === $entry->extract($path)) {
  16756. throw new \RuntimeException('Could not extract entry');
  16757. }
  16758. }
  16759. $rarArchive->close();
  16760. return \React\Promise\resolve(null);
  16761. }
  16762. }
  16763. <?php declare(strict_types=1);
  16764. namespace Composer\Downloader;
  16765. use Composer\Package\PackageInterface;
  16766. use Composer\Pcre\Preg;
  16767. use Composer\Util\Svn as SvnUtil;
  16768. use Composer\Repository\VcsRepository;
  16769. use Composer\Util\ProcessExecutor;
  16770. use React\Promise\PromiseInterface;
  16771. class SvnDownloader extends VcsDownloader
  16772. {
  16773. protected $cacheCredentials = true;
  16774. protected function doDownload(PackageInterface $package, string $path, string $url, ?PackageInterface $prevPackage = null): PromiseInterface
  16775. {
  16776. SvnUtil::cleanEnv();
  16777. $util = new SvnUtil($url, $this->io, $this->config, $this->process);
  16778. if (null === $util->binaryVersion()) {
  16779. throw new \RuntimeException('svn was not found in your PATH, skipping source download');
  16780. }
  16781. return \React\Promise\resolve(null);
  16782. }
  16783. protected function doInstall(PackageInterface $package, string $path, string $url): PromiseInterface
  16784. {
  16785. SvnUtil::cleanEnv();
  16786. $ref = $package->getSourceReference();
  16787. $repo = $package->getRepository();
  16788. if ($repo instanceof VcsRepository) {
  16789. $repoConfig = $repo->getRepoConfig();
  16790. if (array_key_exists('svn-cache-credentials', $repoConfig)) {
  16791. $this->cacheCredentials = (bool) $repoConfig['svn-cache-credentials'];
  16792. }
  16793. }
  16794. $this->io->writeError(" Checking out ".$package->getSourceReference());
  16795. $this->execute($package, $url, "svn co", sprintf("%s/%s", $url, $ref), null, $path);
  16796. return \React\Promise\resolve(null);
  16797. }
  16798. protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): PromiseInterface
  16799. {
  16800. SvnUtil::cleanEnv();
  16801. $ref = $target->getSourceReference();
  16802. if (!$this->hasMetadataRepository($path)) {
  16803. throw new \RuntimeException('The .svn directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  16804. }
  16805. $util = new SvnUtil($url, $this->io, $this->config, $this->process);
  16806. $flags = "";
  16807. if (version_compare($util->binaryVersion(), '1.7.0', '>=')) {
  16808. $flags .= ' --ignore-ancestry';
  16809. }
  16810. $this->io->writeError(" Checking out " . $ref);
  16811. $this->execute($target, $url, "svn switch" . $flags, sprintf("%s/%s", $url, $ref), $path);
  16812. return \React\Promise\resolve(null);
  16813. }
  16814. public function getLocalChanges(PackageInterface $package, string $path): ?string
  16815. {
  16816. if (!$this->hasMetadataRepository($path)) {
  16817. return null;
  16818. }
  16819. $this->process->execute('svn status --ignore-externals', $output, $path);
  16820. return Preg::isMatch('{^ *[^X ] +}m', $output) ? $output : null;
  16821. }
  16822. protected function execute(PackageInterface $package, string $baseUrl, string $command, string $url, ?string $cwd = null, ?string $path = null): string
  16823. {
  16824. $util = new SvnUtil($baseUrl, $this->io, $this->config, $this->process);
  16825. $util->setCacheCredentials($this->cacheCredentials);
  16826. try {
  16827. return $util->execute($command, $url, $cwd, $path, $this->io->isVerbose());
  16828. } catch (\RuntimeException $e) {
  16829. throw new \RuntimeException(
  16830. $package->getPrettyName().' could not be downloaded, '.$e->getMessage()
  16831. );
  16832. }
  16833. }
  16834. protected function cleanChanges(PackageInterface $package, string $path, bool $update): PromiseInterface
  16835. {
  16836. if (null === ($changes = $this->getLocalChanges($package, $path))) {
  16837. return \React\Promise\resolve(null);
  16838. }
  16839. if (!$this->io->isInteractive()) {
  16840. if (true === $this->config->get('discard-changes')) {
  16841. return $this->discardChanges($path);
  16842. }
  16843. return parent::cleanChanges($package, $path, $update);
  16844. }
  16845. $changes = array_map(static function ($elem): string {
  16846. return ' '.$elem;
  16847. }, Preg::split('{\s*\r?\n\s*}', $changes));
  16848. $countChanges = count($changes);
  16849. $this->io->writeError(sprintf(' <error>'.$package->getPrettyName().' has modified file%s:</error>', $countChanges === 1 ? '' : 's'));
  16850. $this->io->writeError(array_slice($changes, 0, 10));
  16851. if ($countChanges > 10) {
  16852. $remainingChanges = $countChanges - 10;
  16853. $this->io->writeError(
  16854. sprintf(
  16855. ' <info>'.$remainingChanges.' more file%s modified, choose "v" to view the full list</info>',
  16856. $remainingChanges === 1 ? '' : 's'
  16857. )
  16858. );
  16859. }
  16860. while (true) {
  16861. switch ($this->io->ask(' <info>Discard changes [y,n,v,?]?</info> ', '?')) {
  16862. case 'y':
  16863. $this->discardChanges($path);
  16864. break 2;
  16865. case 'n':
  16866. throw new \RuntimeException('Update aborted');
  16867. case 'v':
  16868. $this->io->writeError($changes);
  16869. break;
  16870. case '?':
  16871. default:
  16872. $this->io->writeError([
  16873. ' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
  16874. ' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
  16875. ' v - view modified files',
  16876. ' ? - print help',
  16877. ]);
  16878. break;
  16879. }
  16880. }
  16881. return \React\Promise\resolve(null);
  16882. }
  16883. protected function getCommitLogs(string $fromReference, string $toReference, string $path): string
  16884. {
  16885. if (Preg::isMatch('{@(\d+)$}', $fromReference) && Preg::isMatch('{@(\d+)$}', $toReference)) {
  16886. $command = sprintf('svn info --non-interactive --xml -- %s', ProcessExecutor::escape($path));
  16887. if (0 !== $this->process->execute($command, $output, $path)) {
  16888. throw new \RuntimeException(
  16889. 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()
  16890. );
  16891. }
  16892. $urlPattern = '#<url>(.*)</url>#';
  16893. if (Preg::isMatchStrictGroups($urlPattern, $output, $matches)) {
  16894. $baseUrl = $matches[1];
  16895. } else {
  16896. throw new \RuntimeException(
  16897. 'Unable to determine svn url for path '. $path
  16898. );
  16899. }
  16900. $fromRevision = Preg::replace('{.*@(\d+)$}', '$1', $fromReference);
  16901. $toRevision = Preg::replace('{.*@(\d+)$}', '$1', $toReference);
  16902. $command = sprintf('svn log -r%s:%s --incremental', ProcessExecutor::escape($fromRevision), ProcessExecutor::escape($toRevision));
  16903. $util = new SvnUtil($baseUrl, $this->io, $this->config, $this->process);
  16904. $util->setCacheCredentials($this->cacheCredentials);
  16905. try {
  16906. return $util->executeLocal($command, $path, null, $this->io->isVerbose());
  16907. } catch (\RuntimeException $e) {
  16908. throw new \RuntimeException(
  16909. 'Failed to execute ' . $command . "\n\n".$e->getMessage()
  16910. );
  16911. }
  16912. }
  16913. return "Could not retrieve changes between $fromReference and $toReference due to missing revision information";
  16914. }
  16915. protected function discardChanges(string $path): PromiseInterface
  16916. {
  16917. if (0 !== $this->process->execute('svn revert -R .', $output, $path)) {
  16918. throw new \RuntimeException("Could not reset changes\n\n:".$this->process->getErrorOutput());
  16919. }
  16920. return \React\Promise\resolve(null);
  16921. }
  16922. protected function hasMetadataRepository(string $path): bool
  16923. {
  16924. return is_dir($path.'/.svn');
  16925. }
  16926. }
  16927. <?php declare(strict_types=1);
  16928. namespace Composer\Downloader;
  16929. use Composer\Package\PackageInterface;
  16930. use React\Promise\PromiseInterface;
  16931. class TarDownloader extends ArchiveDownloader
  16932. {
  16933. protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface
  16934. {
  16935. $archive = new \PharData($file);
  16936. $archive->extractTo($path, null, true);
  16937. return \React\Promise\resolve(null);
  16938. }
  16939. }
  16940. <?php declare(strict_types=1);
  16941. namespace Composer\Downloader;
  16942. class TransportException extends \RuntimeException
  16943. {
  16944. protected $headers;
  16945. protected $response;
  16946. protected $statusCode;
  16947. protected $responseInfo = [];
  16948. public function setHeaders(array $headers): void
  16949. {
  16950. $this->headers = $headers;
  16951. }
  16952. public function getHeaders(): ?array
  16953. {
  16954. return $this->headers;
  16955. }
  16956. public function setResponse(?string $response): void
  16957. {
  16958. $this->response = $response;
  16959. }
  16960. public function getResponse(): ?string
  16961. {
  16962. return $this->response;
  16963. }
  16964. public function setStatusCode($statusCode): void
  16965. {
  16966. $this->statusCode = $statusCode;
  16967. }
  16968. public function getStatusCode(): ?int
  16969. {
  16970. return $this->statusCode;
  16971. }
  16972. public function getResponseInfo(): array
  16973. {
  16974. return $this->responseInfo;
  16975. }
  16976. public function setResponseInfo(array $responseInfo): void
  16977. {
  16978. $this->responseInfo = $responseInfo;
  16979. }
  16980. }
  16981. <?php declare(strict_types=1);
  16982. namespace Composer\Downloader;
  16983. use Composer\Package\PackageInterface;
  16984. interface VcsCapableDownloaderInterface
  16985. {
  16986. public function getVcsReference(PackageInterface $package, string $path): ?string;
  16987. }
  16988. <?php declare(strict_types=1);
  16989. namespace Composer\Downloader;
  16990. use Composer\Config;
  16991. use Composer\Package\Dumper\ArrayDumper;
  16992. use Composer\Package\PackageInterface;
  16993. use Composer\Package\Version\VersionGuesser;
  16994. use Composer\Package\Version\VersionParser;
  16995. use Composer\Util\ProcessExecutor;
  16996. use Composer\IO\IOInterface;
  16997. use Composer\Util\Filesystem;
  16998. use React\Promise\PromiseInterface;
  16999. use Composer\DependencyResolver\Operation\UpdateOperation;
  17000. use Composer\DependencyResolver\Operation\InstallOperation;
  17001. use Composer\DependencyResolver\Operation\UninstallOperation;
  17002. abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterface, VcsCapableDownloaderInterface
  17003. {
  17004. protected $io;
  17005. protected $config;
  17006. protected $process;
  17007. protected $filesystem;
  17008. protected $hasCleanedChanges = [];
  17009. public function __construct(IOInterface $io, Config $config, ?ProcessExecutor $process = null, ?Filesystem $fs = null)
  17010. {
  17011. $this->io = $io;
  17012. $this->config = $config;
  17013. $this->process = $process ?? new ProcessExecutor($io);
  17014. $this->filesystem = $fs ?? new Filesystem($this->process);
  17015. }
  17016. public function getInstallationSource(): string
  17017. {
  17018. return 'source';
  17019. }
  17020. public function download(PackageInterface $package, string $path, ?PackageInterface $prevPackage = null): PromiseInterface
  17021. {
  17022. if (!$package->getSourceReference()) {
  17023. throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
  17024. }
  17025. $urls = $this->prepareUrls($package->getSourceUrls());
  17026. while ($url = array_shift($urls)) {
  17027. try {
  17028. return $this->doDownload($package, $path, $url, $prevPackage);
  17029. } catch (\Exception $e) {
  17030. if ($e instanceof \PHPUnit\Framework\Exception) {
  17031. throw $e;
  17032. }
  17033. if ($this->io->isDebug()) {
  17034. $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
  17035. } elseif (count($urls)) {
  17036. $this->io->writeError(' Failed, trying the next URL');
  17037. }
  17038. if (!count($urls)) {
  17039. throw $e;
  17040. }
  17041. }
  17042. }
  17043. return \React\Promise\resolve(null);
  17044. }
  17045. public function prepare(string $type, PackageInterface $package, string $path, ?PackageInterface $prevPackage = null): PromiseInterface
  17046. {
  17047. if ($type === 'update') {
  17048. $this->cleanChanges($prevPackage, $path, true);
  17049. $this->hasCleanedChanges[$prevPackage->getUniqueName()] = true;
  17050. } elseif ($type === 'install') {
  17051. $this->filesystem->emptyDirectory($path);
  17052. } elseif ($type === 'uninstall') {
  17053. $this->cleanChanges($package, $path, false);
  17054. }
  17055. return \React\Promise\resolve(null);
  17056. }
  17057. public function cleanup(string $type, PackageInterface $package, string $path, ?PackageInterface $prevPackage = null): PromiseInterface
  17058. {
  17059. if ($type === 'update' && isset($this->hasCleanedChanges[$prevPackage->getUniqueName()])) {
  17060. $this->reapplyChanges($path);
  17061. unset($this->hasCleanedChanges[$prevPackage->getUniqueName()]);
  17062. }
  17063. return \React\Promise\resolve(null);
  17064. }
  17065. public function install(PackageInterface $package, string $path): PromiseInterface
  17066. {
  17067. if (!$package->getSourceReference()) {
  17068. throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
  17069. }
  17070. $this->io->writeError(" - " . InstallOperation::format($package).': ', false);
  17071. $urls = $this->prepareUrls($package->getSourceUrls());
  17072. while ($url = array_shift($urls)) {
  17073. try {
  17074. $this->doInstall($package, $path, $url);
  17075. break;
  17076. } catch (\Exception $e) {
  17077. if ($e instanceof \PHPUnit\Framework\Exception) {
  17078. throw $e;
  17079. }
  17080. if ($this->io->isDebug()) {
  17081. $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
  17082. } elseif (count($urls)) {
  17083. $this->io->writeError(' Failed, trying the next URL');
  17084. }
  17085. if (!count($urls)) {
  17086. throw $e;
  17087. }
  17088. }
  17089. }
  17090. return \React\Promise\resolve(null);
  17091. }
  17092. public function update(PackageInterface $initial, PackageInterface $target, string $path): PromiseInterface
  17093. {
  17094. if (!$target->getSourceReference()) {
  17095. throw new \InvalidArgumentException('Package '.$target->getPrettyName().' is missing reference information');
  17096. }
  17097. $this->io->writeError(" - " . UpdateOperation::format($initial, $target).': ', false);
  17098. $urls = $this->prepareUrls($target->getSourceUrls());
  17099. $exception = null;
  17100. while ($url = array_shift($urls)) {
  17101. try {
  17102. $this->doUpdate($initial, $target, $path, $url);
  17103. $exception = null;
  17104. break;
  17105. } catch (\Exception $exception) {
  17106. if ($exception instanceof \PHPUnit\Framework\Exception) {
  17107. throw $exception;
  17108. }
  17109. if ($this->io->isDebug()) {
  17110. $this->io->writeError('Failed: ['.get_class($exception).'] '.$exception->getMessage());
  17111. } elseif (count($urls)) {
  17112. $this->io->writeError(' Failed, trying the next URL');
  17113. }
  17114. }
  17115. }
  17116. if (!$exception && $this->io->isVerbose() && $this->hasMetadataRepository($path)) {
  17117. $message = 'Pulling in changes:';
  17118. $logs = $this->getCommitLogs($initial->getSourceReference(), $target->getSourceReference(), $path);
  17119. if ('' === trim($logs)) {
  17120. $message = 'Rolling back changes:';
  17121. $logs = $this->getCommitLogs($target->getSourceReference(), $initial->getSourceReference(), $path);
  17122. }
  17123. if ('' !== trim($logs)) {
  17124. $logs = implode("\n", array_map(static function ($line): string {
  17125. return ' ' . $line;
  17126. }, explode("\n", $logs)));
  17127. $logs = str_replace('<', '\<', $logs);
  17128. $this->io->writeError(' '.$message);
  17129. $this->io->writeError($logs);
  17130. }
  17131. }
  17132. if (!$urls && $exception) {
  17133. throw $exception;
  17134. }
  17135. return \React\Promise\resolve(null);
  17136. }
  17137. public function remove(PackageInterface $package, string $path): PromiseInterface
  17138. {
  17139. $this->io->writeError(" - " . UninstallOperation::format($package));
  17140. $promise = $this->filesystem->removeDirectoryAsync($path);
  17141. return $promise->then(static function (bool $result) use ($path) {
  17142. if (!$result) {
  17143. throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
  17144. }
  17145. });
  17146. }
  17147. public function getVcsReference(PackageInterface $package, string $path): ?string
  17148. {
  17149. $parser = new VersionParser;
  17150. $guesser = new VersionGuesser($this->config, $this->process, $parser);
  17151. $dumper = new ArrayDumper;
  17152. $packageConfig = $dumper->dump($package);
  17153. if ($packageVersion = $guesser->guessVersion($packageConfig, $path)) {
  17154. return $packageVersion['commit'];
  17155. }
  17156. return null;
  17157. }
  17158. protected function cleanChanges(PackageInterface $package, string $path, bool $update): PromiseInterface
  17159. {
  17160. if (null !== $this->getLocalChanges($package, $path)) {
  17161. throw new \RuntimeException('Source directory ' . $path . ' has uncommitted changes.');
  17162. }
  17163. return \React\Promise\resolve(null);
  17164. }
  17165. protected function reapplyChanges(string $path): void
  17166. {
  17167. }
  17168. abstract protected function doDownload(PackageInterface $package, string $path, string $url, ?PackageInterface $prevPackage = null): PromiseInterface;
  17169. abstract protected function doInstall(PackageInterface $package, string $path, string $url): PromiseInterface;
  17170. abstract protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): PromiseInterface;
  17171. abstract protected function getCommitLogs(string $fromReference, string $toReference, string $path): string;
  17172. abstract protected function hasMetadataRepository(string $path): bool;
  17173. private function prepareUrls(array $urls): array
  17174. {
  17175. foreach ($urls as $index => $url) {
  17176. if (Filesystem::isLocalPath($url)) {
  17177. $fileProtocol = 'file://';
  17178. $isFileProtocol = false;
  17179. if (0 === strpos($url, $fileProtocol)) {
  17180. $url = substr($url, strlen($fileProtocol));
  17181. $isFileProtocol = true;
  17182. }
  17183. if (false !== strpos($url, '%')) {
  17184. $url = rawurldecode($url);
  17185. }
  17186. $urls[$index] = realpath($url);
  17187. if ($isFileProtocol) {
  17188. $urls[$index] = $fileProtocol . $urls[$index];
  17189. }
  17190. }
  17191. }
  17192. return $urls;
  17193. }
  17194. }
  17195. <?php declare(strict_types=1);
  17196. namespace Composer\Downloader;
  17197. use React\Promise\PromiseInterface;
  17198. use Composer\Package\PackageInterface;
  17199. use Composer\Util\ProcessExecutor;
  17200. class XzDownloader extends ArchiveDownloader
  17201. {
  17202. protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface
  17203. {
  17204. $command = 'tar -xJf ' . ProcessExecutor::escape($file) . ' -C ' . ProcessExecutor::escape($path);
  17205. if (0 === $this->process->execute($command, $ignoredOutput)) {
  17206. return \React\Promise\resolve(null);
  17207. }
  17208. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  17209. throw new \RuntimeException($processError);
  17210. }
  17211. }
  17212. <?php declare(strict_types=1);
  17213. namespace Composer\Downloader;
  17214. use Composer\Package\PackageInterface;
  17215. use Composer\Pcre\Preg;
  17216. use Composer\Util\IniHelper;
  17217. use Composer\Util\Platform;
  17218. use Composer\Util\ProcessExecutor;
  17219. use Symfony\Component\Process\ExecutableFinder;
  17220. use Symfony\Component\Process\Process;
  17221. use React\Promise\PromiseInterface;
  17222. use ZipArchive;
  17223. class ZipDownloader extends ArchiveDownloader
  17224. {
  17225. private static $unzipCommands;
  17226. private static $hasZipArchive;
  17227. private static $isWindows;
  17228. private $zipArchiveObject;
  17229. public function download(PackageInterface $package, string $path, ?PackageInterface $prevPackage = null, bool $output = true): PromiseInterface
  17230. {
  17231. if (null === self::$unzipCommands) {
  17232. self::$unzipCommands = [];
  17233. $finder = new ExecutableFinder;
  17234. if (Platform::isWindows() && ($cmd = $finder->find('7z', null, ['C:\Program Files\7-Zip']))) {
  17235. self::$unzipCommands[] = ['7z', ProcessExecutor::escape($cmd).' x -bb0 -y %s -o%s'];
  17236. }
  17237. if ($cmd = $finder->find('unzip')) {
  17238. self::$unzipCommands[] = ['unzip', ProcessExecutor::escape($cmd).' -qq %s -d %s'];
  17239. }
  17240. if (!Platform::isWindows() && ($cmd = $finder->find('7z'))) {
  17241. self::$unzipCommands[] = ['7z', ProcessExecutor::escape($cmd).' x -bb0 -y %s -o%s'];
  17242. }
  17243. if (!Platform::isWindows() && ($cmd = $finder->find('7zz'))) {
  17244. self::$unzipCommands[] = ['7zz', ProcessExecutor::escape($cmd).' x -bb0 -y %s -o%s'];
  17245. }
  17246. }
  17247. $procOpenMissing = false;
  17248. if (!function_exists('proc_open')) {
  17249. self::$unzipCommands = [];
  17250. $procOpenMissing = true;
  17251. }
  17252. if (null === self::$hasZipArchive) {
  17253. self::$hasZipArchive = class_exists('ZipArchive');
  17254. }
  17255. if (!self::$hasZipArchive && !self::$unzipCommands) {
  17256. $iniMessage = IniHelper::getMessage();
  17257. if ($procOpenMissing) {
  17258. $error = "The zip extension is missing and unzip/7z commands cannot be called as proc_open is disabled, skipping.\n" . $iniMessage;
  17259. } else {
  17260. $error = "The zip extension and unzip/7z commands are both missing, skipping.\n" . $iniMessage;
  17261. }
  17262. throw new \RuntimeException($error);
  17263. }
  17264. if (null === self::$isWindows) {
  17265. self::$isWindows = Platform::isWindows();
  17266. if (!self::$isWindows && !self::$unzipCommands) {
  17267. if ($procOpenMissing) {
  17268. $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>");
  17269. $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>");
  17270. $this->io->writeError("<warning>Enabling proc_open and installing 'unzip' or '7z' (21.01+) may remediate them.</warning>");
  17271. } else {
  17272. $this->io->writeError("<warning>As there is no 'unzip' nor '7z' command installed zip files are being unpacked using the PHP zip extension.</warning>");
  17273. $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>");
  17274. $this->io->writeError("<warning>Installing 'unzip' or '7z' (21.01+) may remediate them.</warning>");
  17275. }
  17276. }
  17277. }
  17278. return parent::download($package, $path, $prevPackage, $output);
  17279. }
  17280. private function extractWithSystemUnzip(PackageInterface $package, string $file, string $path): PromiseInterface
  17281. {
  17282. static $warned7ZipLinux = false;
  17283. $isLastChance = !self::$hasZipArchive;
  17284. if (!self::$unzipCommands) {
  17285. return $this->extractWithZipArchive($package, $file, $path);
  17286. }
  17287. $commandSpec = reset(self::$unzipCommands);
  17288. $command = sprintf($commandSpec[1], ProcessExecutor::escape($file), ProcessExecutor::escape($path));
  17289. if (Platform::isWindows()) {
  17290. $command = sprintf($commandSpec[1], ProcessExecutor::escape(strtr($file, '/', '\\')), ProcessExecutor::escape(strtr($path, '/', '\\')));
  17291. }
  17292. $executable = $commandSpec[0];
  17293. if (!$warned7ZipLinux && !Platform::isWindows() && in_array($executable, ['7z', '7zz'], true)) {
  17294. $warned7ZipLinux = true;
  17295. if (0 === $this->process->execute($executable, $output)) {
  17296. if (Preg::isMatchStrictGroups('{^\s*7-Zip(?: \[64\])? ([0-9.]+)}', $output, $match) && version_compare($match[1], '21.01', '<')) {
  17297. $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>');
  17298. }
  17299. }
  17300. }
  17301. $io = $this->io;
  17302. $tryFallback = function (\Throwable $processError) use ($isLastChance, $io, $file, $path, $package, $executable): \React\Promise\PromiseInterface {
  17303. if ($isLastChance) {
  17304. throw $processError;
  17305. }
  17306. if (!is_file($file)) {
  17307. $io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  17308. $io->writeError(' <warning>This most likely is due to a custom installer plugin not handling the returned Promise from the downloader</warning>');
  17309. $io->writeError(' <warning>See https://github.com/composer/installers/commit/5006d0c28730ade233a8f42ec31ac68fb1c5c9bb for an example fix</warning>');
  17310. } else {
  17311. $io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  17312. $io->writeError(' The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems)');
  17313. $io->writeError(' Unzip with '.$executable.' command failed, falling back to ZipArchive class');
  17314. if (Platform::getEnv('GITHUB_ACTIONS') !== false && Platform::getEnv('COMPOSER_TESTS_ARE_RUNNING') === false) {
  17315. $io->writeError(' <warning>Additional debug info, please report to https://github.com/composer/composer/issues/11148 if you see this:</warning>');
  17316. $io->writeError('File size: '.@filesize($file));
  17317. $io->writeError('File SHA1: '.hash_file('sha1', $file));
  17318. $io->writeError('First 100 bytes (hex): '.bin2hex(substr((string) file_get_contents($file), 0, 100)));
  17319. $io->writeError('Last 100 bytes (hex): '.bin2hex(substr((string) file_get_contents($file), -100)));
  17320. if (strlen((string) $package->getDistUrl()) > 0) {
  17321. $io->writeError('Origin URL: '.$this->processUrl($package, (string) $package->getDistUrl()));
  17322. $io->writeError('Response Headers: '.json_encode(FileDownloader::$responseHeaders[$package->getName()] ?? []));
  17323. }
  17324. }
  17325. }
  17326. return $this->extractWithZipArchive($package, $file, $path);
  17327. };
  17328. try {
  17329. $promise = $this->process->executeAsync($command);
  17330. return $promise->then(function (Process $process) use ($tryFallback, $command, $package, $file) {
  17331. if (!$process->isSuccessful()) {
  17332. if (isset($this->cleanupExecuted[$package->getName()])) {
  17333. throw new \RuntimeException('Failed to extract '.$package->getName().' as the installation was aborted by another package operation.');
  17334. }
  17335. $output = $process->getErrorOutput();
  17336. $output = str_replace(', '.$file.'.zip or '.$file.'.ZIP', '', $output);
  17337. return $tryFallback(new \RuntimeException('Failed to extract '.$package->getName().': ('.$process->getExitCode().') '.$command."\n\n".$output));
  17338. }
  17339. });
  17340. } catch (\Throwable $e) {
  17341. return $tryFallback($e);
  17342. }
  17343. }
  17344. private function extractWithZipArchive(PackageInterface $package, string $file, string $path): PromiseInterface
  17345. {
  17346. $processError = null;
  17347. $zipArchive = $this->zipArchiveObject ?: new ZipArchive();
  17348. try {
  17349. if (!file_exists($file) || ($filesize = filesize($file)) === false || $filesize === 0) {
  17350. $retval = -1;
  17351. } else {
  17352. $retval = $zipArchive->open($file);
  17353. }
  17354. if (true === $retval) {
  17355. $extractResult = $zipArchive->extractTo($path);
  17356. if (true === $extractResult) {
  17357. $zipArchive->close();
  17358. return \React\Promise\resolve(null);
  17359. }
  17360. $processError = new \RuntimeException(rtrim("There was an error extracting the ZIP file, it is either corrupted or using an invalid format.\n"));
  17361. } else {
  17362. $processError = new \UnexpectedValueException(rtrim($this->getErrorMessage($retval, $file)."\n"), $retval);
  17363. }
  17364. } catch (\ErrorException $e) {
  17365. $processError = new \RuntimeException('The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems): '.$e->getMessage(), 0, $e);
  17366. } catch (\Throwable $e) {
  17367. $processError = $e;
  17368. }
  17369. throw $processError;
  17370. }
  17371. protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface
  17372. {
  17373. return $this->extractWithSystemUnzip($package, $file, $path);
  17374. }
  17375. protected function getErrorMessage(int $retval, string $file): string
  17376. {
  17377. switch ($retval) {
  17378. case ZipArchive::ER_EXISTS:
  17379. return sprintf("File '%s' already exists.", $file);
  17380. case ZipArchive::ER_INCONS:
  17381. return sprintf("Zip archive '%s' is inconsistent.", $file);
  17382. case ZipArchive::ER_INVAL:
  17383. return sprintf("Invalid argument (%s)", $file);
  17384. case ZipArchive::ER_MEMORY:
  17385. return sprintf("Malloc failure (%s)", $file);
  17386. case ZipArchive::ER_NOENT:
  17387. return sprintf("No such zip file: '%s'", $file);
  17388. case ZipArchive::ER_NOZIP:
  17389. return sprintf("'%s' is not a zip archive.", $file);
  17390. case ZipArchive::ER_OPEN:
  17391. return sprintf("Can't open zip file: %s", $file);
  17392. case ZipArchive::ER_READ:
  17393. return sprintf("Zip read error (%s)", $file);
  17394. case ZipArchive::ER_SEEK:
  17395. return sprintf("Zip seek error (%s)", $file);
  17396. case -1:
  17397. return sprintf("'%s' is a corrupted zip archive (0 bytes), try again.", $file);
  17398. default:
  17399. return sprintf("'%s' is not a valid zip archive, got error code: %s", $file, $retval);
  17400. }
  17401. }
  17402. }
  17403. <?php declare(strict_types=1);
  17404. namespace Composer\EventDispatcher;
  17405. class Event
  17406. {
  17407. protected $name;
  17408. protected $args;
  17409. protected $flags;
  17410. private $propagationStopped = false;
  17411. public function __construct(string $name, array $args = [], array $flags = [])
  17412. {
  17413. $this->name = $name;
  17414. $this->args = $args;
  17415. $this->flags = $flags;
  17416. }
  17417. public function getName(): string
  17418. {
  17419. return $this->name;
  17420. }
  17421. public function getArguments(): array
  17422. {
  17423. return $this->args;
  17424. }
  17425. public function getFlags(): array
  17426. {
  17427. return $this->flags;
  17428. }
  17429. public function isPropagationStopped(): bool
  17430. {
  17431. return $this->propagationStopped;
  17432. }
  17433. public function stopPropagation(): void
  17434. {
  17435. $this->propagationStopped = true;
  17436. }
  17437. }
  17438. <?php declare(strict_types=1);
  17439. namespace Composer\EventDispatcher;
  17440. use Composer\DependencyResolver\Transaction;
  17441. use Composer\Installer\InstallerEvent;
  17442. use Composer\IO\BufferIO;
  17443. use Composer\IO\ConsoleIO;
  17444. use Composer\IO\IOInterface;
  17445. use Composer\Composer;
  17446. use Composer\PartialComposer;
  17447. use Composer\Pcre\Preg;
  17448. use Composer\Util\Platform;
  17449. use Composer\DependencyResolver\Operation\OperationInterface;
  17450. use Composer\Repository\RepositoryInterface;
  17451. use Composer\Script;
  17452. use Composer\Installer\PackageEvent;
  17453. use Composer\Installer\BinaryInstaller;
  17454. use Composer\Util\ProcessExecutor;
  17455. use Composer\Script\Event as ScriptEvent;
  17456. use Composer\Autoload\ClassLoader;
  17457. use Symfony\Component\Console\Application;
  17458. use Symfony\Component\Console\Command\Command;
  17459. use Symfony\Component\Console\Input\StringInput;
  17460. use Symfony\Component\Console\Output\ConsoleOutput;
  17461. use Symfony\Component\Process\PhpExecutableFinder;
  17462. use Symfony\Component\Process\ExecutableFinder;
  17463. class EventDispatcher
  17464. {
  17465. protected $composer;
  17466. protected $io;
  17467. protected $loader;
  17468. protected $process;
  17469. protected $listeners = [];
  17470. protected $runScripts = true;
  17471. private $eventStack;
  17472. public function __construct(PartialComposer $composer, IOInterface $io, ?ProcessExecutor $process = null)
  17473. {
  17474. $this->composer = $composer;
  17475. $this->io = $io;
  17476. $this->process = $process ?? new ProcessExecutor($io);
  17477. $this->eventStack = [];
  17478. }
  17479. public function setRunScripts(bool $runScripts = true): self
  17480. {
  17481. $this->runScripts = (bool) $runScripts;
  17482. return $this;
  17483. }
  17484. public function dispatch(?string $eventName, ?Event $event = null): int
  17485. {
  17486. if (null === $event) {
  17487. if (null === $eventName) {
  17488. throw new \InvalidArgumentException('If no $event is passed in to '.__METHOD__.' you have to pass in an $eventName, got null.');
  17489. }
  17490. $event = new Event($eventName);
  17491. }
  17492. return $this->doDispatch($event);
  17493. }
  17494. public function dispatchScript(string $eventName, bool $devMode = false, array $additionalArgs = [], array $flags = []): int
  17495. {
  17496. assert($this->composer instanceof Composer, new \LogicException('This should only be reached with a fully loaded Composer'));
  17497. return $this->doDispatch(new Script\Event($eventName, $this->composer, $this->io, $devMode, $additionalArgs, $flags));
  17498. }
  17499. public function dispatchPackageEvent(string $eventName, bool $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation): int
  17500. {
  17501. assert($this->composer instanceof Composer, new \LogicException('This should only be reached with a fully loaded Composer'));
  17502. return $this->doDispatch(new PackageEvent($eventName, $this->composer, $this->io, $devMode, $localRepo, $operations, $operation));
  17503. }
  17504. public function dispatchInstallerEvent(string $eventName, bool $devMode, bool $executeOperations, Transaction $transaction): int
  17505. {
  17506. assert($this->composer instanceof Composer, new \LogicException('This should only be reached with a fully loaded Composer'));
  17507. return $this->doDispatch(new InstallerEvent($eventName, $this->composer, $this->io, $devMode, $executeOperations, $transaction));
  17508. }
  17509. protected function doDispatch(Event $event)
  17510. {
  17511. if (Platform::getEnv('COMPOSER_DEBUG_EVENTS')) {
  17512. $details = null;
  17513. if ($event instanceof PackageEvent) {
  17514. $details = (string) $event->getOperation();
  17515. }
  17516. $this->io->writeError('Dispatching <info>'.$event->getName().'</info>'.($details ? ' ('.$details.')' : '').' event');
  17517. }
  17518. $listeners = $this->getListeners($event);
  17519. $this->pushEvent($event);
  17520. try {
  17521. $returnMax = 0;
  17522. foreach ($listeners as $callable) {
  17523. $return = 0;
  17524. $this->ensureBinDirIsInPath();
  17525. if (!is_string($callable)) {
  17526. if (!is_callable($callable)) {
  17527. $className = is_object($callable[0]) ? get_class($callable[0]) : $callable[0];
  17528. throw new \RuntimeException('Subscriber '.$className.'::'.$callable[1].' for event '.$event->getName().' is not callable, make sure the function is defined and public');
  17529. }
  17530. if (is_array($callable) && (is_string($callable[0]) || is_object($callable[0])) && is_string($callable[1])) {
  17531. $this->io->writeError(sprintf('> %s: %s', $event->getName(), (is_object($callable[0]) ? get_class($callable[0]) : $callable[0]).'->'.$callable[1]), true, IOInterface::VERBOSE);
  17532. }
  17533. $return = false === $callable($event) ? 1 : 0;
  17534. } elseif ($this->isComposerScript($callable)) {
  17535. $this->io->writeError(sprintf('> %s: %s', $event->getName(), $callable), true, IOInterface::VERBOSE);
  17536. $script = explode(' ', substr($callable, 1));
  17537. $scriptName = $script[0];
  17538. unset($script[0]);
  17539. $args = array_merge($script, $event->getArguments());
  17540. $flags = $event->getFlags();
  17541. if (isset($flags['script-alias-input'])) {
  17542. $argsString = implode(' ', array_map(static function ($arg) { return ProcessExecutor::escape($arg); }, $script));
  17543. $flags['script-alias-input'] = $argsString . ' ' . $flags['script-alias-input'];
  17544. unset($argsString);
  17545. }
  17546. if (strpos($callable, '@composer ') === 0) {
  17547. $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(Platform::getEnv('COMPOSER_BINARY')) . ' ' . implode(' ', $args);
  17548. if (0 !== ($exitCode = $this->executeTty($exec))) {
  17549. $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  17550. throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
  17551. }
  17552. } else {
  17553. if (!$this->getListeners(new Event($scriptName))) {
  17554. $this->io->writeError(sprintf('<warning>You made a reference to a non-existent script %s</warning>', $callable), true, IOInterface::QUIET);
  17555. }
  17556. try {
  17557. $scriptEvent = new Script\Event($scriptName, $event->getComposer(), $event->getIO(), $event->isDevMode(), $args, $flags);
  17558. $scriptEvent->setOriginatingEvent($event);
  17559. $return = $this->dispatch($scriptName, $scriptEvent);
  17560. } catch (ScriptExecutionException $e) {
  17561. $this->io->writeError(sprintf('<error>Script %s was called via %s</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  17562. throw $e;
  17563. }
  17564. }
  17565. } elseif ($this->isPhpScript($callable)) {
  17566. $className = substr($callable, 0, strpos($callable, '::'));
  17567. $methodName = substr($callable, strpos($callable, '::') + 2);
  17568. if (!class_exists($className)) {
  17569. $this->io->writeError('<warning>Class '.$className.' is not autoloadable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  17570. continue;
  17571. }
  17572. if (!is_callable($callable)) {
  17573. $this->io->writeError('<warning>Method '.$callable.' is not callable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  17574. continue;
  17575. }
  17576. try {
  17577. $return = false === $this->executeEventPhpScript($className, $methodName, $event) ? 1 : 0;
  17578. } catch (\Exception $e) {
  17579. $message = "Script %s handling the %s event terminated with an exception";
  17580. $this->io->writeError('<error>'.sprintf($message, $callable, $event->getName()).'</error>', true, IOInterface::QUIET);
  17581. throw $e;
  17582. }
  17583. } elseif ($this->isCommandClass($callable)) {
  17584. $className = $callable;
  17585. if (!class_exists($className)) {
  17586. $this->io->writeError('<warning>Class '.$className.' is not autoloadable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  17587. continue;
  17588. }
  17589. if (!is_a($className, Command::class, true)) {
  17590. $this->io->writeError('<warning>Class '.$className.' does not extend '.Command::class.', can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  17591. continue;
  17592. }
  17593. if (defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($event->getName())))) {
  17594. $this->io->writeError('<warning>You cannot bind '.$event->getName().' to a Command class, use a non-reserved name</warning>', true, IOInterface::QUIET);
  17595. continue;
  17596. }
  17597. $app = new Application();
  17598. $app->setCatchExceptions(false);
  17599. if (method_exists($app, 'setCatchErrors')) {
  17600. $app->setCatchErrors(false);
  17601. }
  17602. $app->setAutoExit(false);
  17603. $cmd = new $className($event->getName());
  17604. $app->add($cmd);
  17605. $app->setDefaultCommand((string) $cmd->getName(), true);
  17606. try {
  17607. $args = implode(' ', array_map(static function ($arg) { return ProcessExecutor::escape($arg); }, $event->getArguments()));
  17608. if ($this->io instanceof ConsoleIO) {
  17609. $reflProp = new \ReflectionProperty($this->io, 'output');
  17610. if (PHP_VERSION_ID < 80100) {
  17611. $reflProp->setAccessible(true);
  17612. }
  17613. $output = $reflProp->getValue($this->io);
  17614. } else {
  17615. $output = new ConsoleOutput();
  17616. }
  17617. $return = $app->run(new StringInput($event->getFlags()['script-alias-input'] ?? $args), $output);
  17618. } catch (\Exception $e) {
  17619. $message = "Script %s handling the %s event terminated with an exception";
  17620. $this->io->writeError('<error>'.sprintf($message, $callable, $event->getName()).'</error>', true, IOInterface::QUIET);
  17621. throw $e;
  17622. }
  17623. } else {
  17624. $args = implode(' ', array_map(['Composer\Util\ProcessExecutor', 'escape'], $event->getArguments()));
  17625. if (strpos($callable, '@putenv ') === 0) {
  17626. $exec = $callable;
  17627. } else {
  17628. $exec = $callable . ($args === '' ? '' : ' '.$args);
  17629. }
  17630. if ($this->io->isVerbose()) {
  17631. $this->io->writeError(sprintf('> %s: %s', $event->getName(), $exec));
  17632. } elseif ($event->getName() !== '__exec_command') {
  17633. $this->io->writeError(sprintf('> %s', $exec));
  17634. }
  17635. $possibleLocalBinaries = $this->composer->getPackage()->getBinaries();
  17636. if ($possibleLocalBinaries) {
  17637. foreach ($possibleLocalBinaries as $localExec) {
  17638. if (Preg::isMatch('{\b'.preg_quote($callable).'$}', $localExec)) {
  17639. $caller = BinaryInstaller::determineBinaryCaller($localExec);
  17640. $exec = Preg::replace('{^'.preg_quote($callable).'}', $caller . ' ' . $localExec, $exec);
  17641. break;
  17642. }
  17643. }
  17644. }
  17645. if (strpos($exec, '@putenv ') === 0) {
  17646. if (false === strpos($exec, '=')) {
  17647. Platform::clearEnv(substr($exec, 8));
  17648. } else {
  17649. [$var, $value] = explode('=', substr($exec, 8), 2);
  17650. Platform::putEnv($var, $value);
  17651. }
  17652. continue;
  17653. }
  17654. if (strpos($exec, '@php ') === 0) {
  17655. $pathAndArgs = substr($exec, 5);
  17656. if (Platform::isWindows()) {
  17657. $pathAndArgs = Preg::replaceCallback('{^\S+}', static function ($path) {
  17658. return str_replace('/', '\\', (string) $path[0]);
  17659. }, $pathAndArgs);
  17660. }
  17661. $matched = Preg::isMatchStrictGroups('{^[^\'"\s/\\\\]+}', $pathAndArgs, $match);
  17662. if ($matched && !file_exists($match[0])) {
  17663. $finder = new ExecutableFinder;
  17664. if ($pathToExec = $finder->find($match[0])) {
  17665. if (Platform::isWindows()) {
  17666. $execWithoutExt = Preg::replace('{\.(exe|bat|cmd|com)$}i', '', $pathToExec);
  17667. if (file_exists($execWithoutExt)) {
  17668. $pathToExec = $execWithoutExt;
  17669. }
  17670. unset($execWithoutExt);
  17671. }
  17672. $pathAndArgs = $pathToExec . substr($pathAndArgs, strlen($match[0]));
  17673. }
  17674. }
  17675. $exec = $this->getPhpExecCommand() . ' ' . $pathAndArgs;
  17676. } else {
  17677. $finder = new PhpExecutableFinder();
  17678. $phpPath = $finder->find(false);
  17679. if ($phpPath) {
  17680. Platform::putEnv('PHP_BINARY', $phpPath);
  17681. }
  17682. if (Platform::isWindows()) {
  17683. $exec = Preg::replaceCallback('{^\S+}', static function ($path) {
  17684. assert(is_string($path[0]));
  17685. return str_replace('/', '\\', $path[0]);
  17686. }, $exec);
  17687. }
  17688. }
  17689. if (strpos($exec, 'composer ') === 0) {
  17690. $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(Platform::getEnv('COMPOSER_BINARY')) . substr($exec, 8);
  17691. }
  17692. if (0 !== ($exitCode = $this->executeTty($exec))) {
  17693. $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  17694. throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
  17695. }
  17696. }
  17697. $returnMax = max($returnMax, $return);
  17698. if ($event->isPropagationStopped()) {
  17699. break;
  17700. }
  17701. }
  17702. } finally {
  17703. $this->popEvent();
  17704. }
  17705. return $returnMax;
  17706. }
  17707. protected function executeTty(string $exec): int
  17708. {
  17709. if ($this->io->isInteractive()) {
  17710. return $this->process->executeTty($exec);
  17711. }
  17712. return $this->process->execute($exec);
  17713. }
  17714. protected function getPhpExecCommand(): string
  17715. {
  17716. $finder = new PhpExecutableFinder();
  17717. $phpPath = $finder->find(false);
  17718. if (!$phpPath) {
  17719. throw new \RuntimeException('Failed to locate PHP binary to execute '.$phpPath);
  17720. }
  17721. $phpArgs = $finder->findArguments();
  17722. $phpArgs = $phpArgs ? ' ' . implode(' ', $phpArgs) : '';
  17723. $allowUrlFOpenFlag = ' -d allow_url_fopen=' . ProcessExecutor::escape(ini_get('allow_url_fopen'));
  17724. $disableFunctionsFlag = ' -d disable_functions=' . ProcessExecutor::escape(ini_get('disable_functions'));
  17725. $memoryLimitFlag = ' -d memory_limit=' . ProcessExecutor::escape(ini_get('memory_limit'));
  17726. return ProcessExecutor::escape($phpPath) . $phpArgs . $allowUrlFOpenFlag . $disableFunctionsFlag . $memoryLimitFlag;
  17727. }
  17728. protected function executeEventPhpScript(string $className, string $methodName, Event $event)
  17729. {
  17730. if ($this->io->isVerbose()) {
  17731. $this->io->writeError(sprintf('> %s: %s::%s', $event->getName(), $className, $methodName));
  17732. } else {
  17733. $this->io->writeError(sprintf('> %s::%s', $className, $methodName));
  17734. }
  17735. return $className::$methodName($event);
  17736. }
  17737. public function addListener(string $eventName, $listener, int $priority = 0): void
  17738. {
  17739. $this->listeners[$eventName][$priority][] = $listener;
  17740. }
  17741. public function removeListener($listener): void
  17742. {
  17743. foreach ($this->listeners as $eventName => $priorities) {
  17744. foreach ($priorities as $priority => $listeners) {
  17745. foreach ($listeners as $index => $candidate) {
  17746. if ($listener === $candidate || (is_array($candidate) && is_object($listener) && $candidate[0] === $listener)) {
  17747. unset($this->listeners[$eventName][$priority][$index]);
  17748. }
  17749. }
  17750. }
  17751. }
  17752. }
  17753. public function addSubscriber(EventSubscriberInterface $subscriber): void
  17754. {
  17755. foreach ($subscriber->getSubscribedEvents() as $eventName => $params) {
  17756. if (is_string($params)) {
  17757. $this->addListener($eventName, [$subscriber, $params]);
  17758. } elseif (is_string($params[0])) {
  17759. $this->addListener($eventName, [$subscriber, $params[0]], $params[1] ?? 0);
  17760. } else {
  17761. foreach ($params as $listener) {
  17762. $this->addListener($eventName, [$subscriber, $listener[0]], $listener[1] ?? 0);
  17763. }
  17764. }
  17765. }
  17766. }
  17767. protected function getListeners(Event $event): array
  17768. {
  17769. $scriptListeners = $this->runScripts ? $this->getScriptListeners($event) : [];
  17770. if (!isset($this->listeners[$event->getName()][0])) {
  17771. $this->listeners[$event->getName()][0] = [];
  17772. }
  17773. krsort($this->listeners[$event->getName()]);
  17774. $listeners = $this->listeners;
  17775. $listeners[$event->getName()][0] = array_merge($listeners[$event->getName()][0], $scriptListeners);
  17776. return array_merge(...$listeners[$event->getName()]);
  17777. }
  17778. public function hasEventListeners(Event $event): bool
  17779. {
  17780. $listeners = $this->getListeners($event);
  17781. return count($listeners) > 0;
  17782. }
  17783. protected function getScriptListeners(Event $event): array
  17784. {
  17785. $package = $this->composer->getPackage();
  17786. $scripts = $package->getScripts();
  17787. if (empty($scripts[$event->getName()])) {
  17788. return [];
  17789. }
  17790. assert($this->composer instanceof Composer, new \LogicException('This should only be reached with a fully loaded Composer'));
  17791. if ($this->loader) {
  17792. $this->loader->unregister();
  17793. }
  17794. $generator = $this->composer->getAutoloadGenerator();
  17795. if ($event instanceof ScriptEvent) {
  17796. $generator->setDevMode($event->isDevMode());
  17797. }
  17798. $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
  17799. $packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $package, $packages);
  17800. $map = $generator->parseAutoloads($packageMap, $package);
  17801. $this->loader = $generator->createLoader($map, $this->composer->getConfig()->get('vendor-dir'));
  17802. $this->loader->register(false);
  17803. return $scripts[$event->getName()];
  17804. }
  17805. protected function isPhpScript(string $callable): bool
  17806. {
  17807. return false === strpos($callable, ' ') && false !== strpos($callable, '::');
  17808. }
  17809. protected function isCommandClass(string $callable): bool
  17810. {
  17811. return str_contains($callable, '\\') && !str_contains($callable, ' ') && str_ends_with($callable, 'Command');
  17812. }
  17813. protected function isComposerScript(string $callable): bool
  17814. {
  17815. return strpos($callable, '@') === 0 && strpos($callable, '@php ') !== 0 && strpos($callable, '@putenv ') !== 0;
  17816. }
  17817. protected function pushEvent(Event $event): int
  17818. {
  17819. $eventName = $event->getName();
  17820. if (in_array($eventName, $this->eventStack)) {
  17821. throw new \RuntimeException(sprintf("Circular call to script handler '%s' detected", $eventName));
  17822. }
  17823. return array_push($this->eventStack, $eventName);
  17824. }
  17825. protected function popEvent(): ?string
  17826. {
  17827. return array_pop($this->eventStack);
  17828. }
  17829. private function ensureBinDirIsInPath(): void
  17830. {
  17831. $pathEnv = 'PATH';
  17832. if (!isset($_SERVER[$pathEnv]) && isset($_SERVER['Path'])) {
  17833. $pathEnv = 'Path';
  17834. }
  17835. $binDir = $this->composer->getConfig()->get('bin-dir');
  17836. if (is_dir($binDir)) {
  17837. $binDir = realpath($binDir);
  17838. $pathValue = (string) Platform::getEnv($pathEnv);
  17839. if (!Preg::isMatch('{(^|'.PATH_SEPARATOR.')'.preg_quote($binDir).'($|'.PATH_SEPARATOR.')}', $pathValue)) {
  17840. Platform::putEnv($pathEnv, $binDir.PATH_SEPARATOR.$pathValue);
  17841. }
  17842. }
  17843. }
  17844. }
  17845. <?php declare(strict_types=1);
  17846. namespace Composer\EventDispatcher;
  17847. interface EventSubscriberInterface
  17848. {
  17849. public static function getSubscribedEvents();
  17850. }
  17851. <?php declare(strict_types=1);
  17852. namespace Composer\EventDispatcher;
  17853. class ScriptExecutionException extends \RuntimeException
  17854. {
  17855. }
  17856. <?php declare(strict_types=1);
  17857. namespace Composer\Exception;
  17858. class IrrecoverableDownloadException extends \RuntimeException
  17859. {
  17860. }
  17861. <?php declare(strict_types=1);
  17862. namespace Composer\Exception;
  17863. class NoSslException extends \RuntimeException
  17864. {
  17865. }
  17866. <?php declare(strict_types=1);
  17867. namespace Composer;
  17868. use Composer\Config\JsonConfigSource;
  17869. use Composer\Json\JsonFile;
  17870. use Composer\IO\IOInterface;
  17871. use Composer\Package\Archiver;
  17872. use Composer\Package\Version\VersionGuesser;
  17873. use Composer\Package\RootPackageInterface;
  17874. use Composer\Repository\RepositoryManager;
  17875. use Composer\Repository\RepositoryFactory;
  17876. use Composer\Util\Filesystem;
  17877. use Composer\Util\Platform;
  17878. use Composer\Util\ProcessExecutor;
  17879. use Composer\Util\HttpDownloader;
  17880. use Composer\Util\Loop;
  17881. use Composer\Util\Silencer;
  17882. use Composer\Plugin\PluginEvents;
  17883. use Composer\EventDispatcher\Event;
  17884. use Phar;
  17885. use Symfony\Component\Console\Formatter\OutputFormatter;
  17886. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  17887. use Symfony\Component\Console\Output\ConsoleOutput;
  17888. use Composer\EventDispatcher\EventDispatcher;
  17889. use Composer\Autoload\AutoloadGenerator;
  17890. use Composer\Package\Version\VersionParser;
  17891. use Composer\Downloader\TransportException;
  17892. use Composer\Json\JsonValidationException;
  17893. use Composer\Repository\InstalledRepositoryInterface;
  17894. use UnexpectedValueException;
  17895. use ZipArchive;
  17896. class Factory
  17897. {
  17898. protected static function getHomeDir(): string
  17899. {
  17900. $home = Platform::getEnv('COMPOSER_HOME');
  17901. if ($home) {
  17902. return $home;
  17903. }
  17904. if (Platform::isWindows()) {
  17905. if (!Platform::getEnv('APPDATA')) {
  17906. throw new \RuntimeException('The APPDATA or COMPOSER_HOME environment variable must be set for composer to run correctly');
  17907. }
  17908. return rtrim(strtr(Platform::getEnv('APPDATA'), '\\', '/'), '/') . '/Composer';
  17909. }
  17910. $userDir = self::getUserDir();
  17911. $dirs = [];
  17912. if (self::useXdg()) {
  17913. $xdgConfig = Platform::getEnv('XDG_CONFIG_HOME');
  17914. if (!$xdgConfig) {
  17915. $xdgConfig = $userDir . '/.config';
  17916. }
  17917. $dirs[] = $xdgConfig . '/composer';
  17918. }
  17919. $dirs[] = $userDir . '/.composer';
  17920. foreach ($dirs as $dir) {
  17921. if (Silencer::call('is_dir', $dir)) {
  17922. return $dir;
  17923. }
  17924. }
  17925. return $dirs[0];
  17926. }
  17927. protected static function getCacheDir(string $home): string
  17928. {
  17929. $cacheDir = Platform::getEnv('COMPOSER_CACHE_DIR');
  17930. if ($cacheDir) {
  17931. return $cacheDir;
  17932. }
  17933. $homeEnv = Platform::getEnv('COMPOSER_HOME');
  17934. if ($homeEnv) {
  17935. return $homeEnv . '/cache';
  17936. }
  17937. if (Platform::isWindows()) {
  17938. if ($cacheDir = Platform::getEnv('LOCALAPPDATA')) {
  17939. $cacheDir .= '/Composer';
  17940. } else {
  17941. $cacheDir = $home . '/cache';
  17942. }
  17943. return rtrim(strtr($cacheDir, '\\', '/'), '/');
  17944. }
  17945. $userDir = self::getUserDir();
  17946. if (PHP_OS === 'Darwin') {
  17947. if (is_dir($home . '/cache') && !is_dir($userDir . '/Library/Caches/composer')) {
  17948. Silencer::call('rename', $home . '/cache', $userDir . '/Library/Caches/composer');
  17949. }
  17950. return $userDir . '/Library/Caches/composer';
  17951. }
  17952. if ($home === $userDir . '/.composer' && is_dir($home . '/cache')) {
  17953. return $home . '/cache';
  17954. }
  17955. if (self::useXdg()) {
  17956. $xdgCache = Platform::getEnv('XDG_CACHE_HOME') ?: $userDir . '/.cache';
  17957. return $xdgCache . '/composer';
  17958. }
  17959. return $home . '/cache';
  17960. }
  17961. protected static function getDataDir(string $home): string
  17962. {
  17963. $homeEnv = Platform::getEnv('COMPOSER_HOME');
  17964. if ($homeEnv) {
  17965. return $homeEnv;
  17966. }
  17967. if (Platform::isWindows()) {
  17968. return strtr($home, '\\', '/');
  17969. }
  17970. $userDir = self::getUserDir();
  17971. if ($home !== $userDir . '/.composer' && self::useXdg()) {
  17972. $xdgData = Platform::getEnv('XDG_DATA_HOME') ?: $userDir . '/.local/share';
  17973. return $xdgData . '/composer';
  17974. }
  17975. return $home;
  17976. }
  17977. public static function createConfig(?IOInterface $io = null, ?string $cwd = null): Config
  17978. {
  17979. $cwd = $cwd ?? Platform::getCwd(true);
  17980. $config = new Config(true, $cwd);
  17981. $home = self::getHomeDir();
  17982. $config->merge([
  17983. 'config' => [
  17984. 'home' => $home,
  17985. 'cache-dir' => self::getCacheDir($home),
  17986. 'data-dir' => self::getDataDir($home),
  17987. ],
  17988. ], Config::SOURCE_DEFAULT);
  17989. $file = new JsonFile($config->get('home').'/config.json');
  17990. if ($file->exists()) {
  17991. if ($io instanceof IOInterface) {
  17992. $io->writeError('Loading config file ' . $file->getPath(), true, IOInterface::DEBUG);
  17993. }
  17994. self::validateJsonSchema($io, $file);
  17995. $config->merge($file->read(), $file->getPath());
  17996. }
  17997. $config->setConfigSource(new JsonConfigSource($file));
  17998. $htaccessProtect = $config->get('htaccess-protect');
  17999. if ($htaccessProtect) {
  18000. $dirs = [$config->get('home'), $config->get('cache-dir'), $config->get('data-dir')];
  18001. foreach ($dirs as $dir) {
  18002. if (!file_exists($dir . '/.htaccess')) {
  18003. if (!is_dir($dir)) {
  18004. Silencer::call('mkdir', $dir, 0777, true);
  18005. }
  18006. Silencer::call('file_put_contents', $dir . '/.htaccess', 'Deny from all');
  18007. }
  18008. }
  18009. }
  18010. $file = new JsonFile($config->get('home').'/auth.json');
  18011. if ($file->exists()) {
  18012. if ($io instanceof IOInterface) {
  18013. $io->writeError('Loading config file ' . $file->getPath(), true, IOInterface::DEBUG);
  18014. }
  18015. self::validateJsonSchema($io, $file, JsonFile::AUTH_SCHEMA);
  18016. $config->merge(['config' => $file->read()], $file->getPath());
  18017. }
  18018. $config->setAuthConfigSource(new JsonConfigSource($file, true));
  18019. if ($composerAuthEnv = Platform::getEnv('COMPOSER_AUTH')) {
  18020. $authData = json_decode($composerAuthEnv);
  18021. if (null === $authData) {
  18022. throw new \UnexpectedValueException('COMPOSER_AUTH environment variable is malformed, should be a valid JSON object');
  18023. } else {
  18024. if ($io instanceof IOInterface) {
  18025. $io->writeError('Loading auth config from COMPOSER_AUTH', true, IOInterface::DEBUG);
  18026. }
  18027. self::validateJsonSchema($io, $authData, JsonFile::AUTH_SCHEMA, 'COMPOSER_AUTH');
  18028. $authData = json_decode($composerAuthEnv, true);
  18029. if (null !== $authData) {
  18030. $config->merge(['config' => $authData], 'COMPOSER_AUTH');
  18031. }
  18032. }
  18033. }
  18034. return $config;
  18035. }
  18036. public static function getComposerFile(): string
  18037. {
  18038. return trim((string) Platform::getEnv('COMPOSER')) ?: './composer.json';
  18039. }
  18040. public static function getLockFile(string $composerFile): string
  18041. {
  18042. return "json" === pathinfo($composerFile, PATHINFO_EXTENSION)
  18043. ? substr($composerFile, 0, -4).'lock'
  18044. : $composerFile . '.lock';
  18045. }
  18046. public static function createAdditionalStyles(): array
  18047. {
  18048. return [
  18049. 'highlight' => new OutputFormatterStyle('red'),
  18050. 'warning' => new OutputFormatterStyle('black', 'yellow'),
  18051. ];
  18052. }
  18053. public static function createOutput(): ConsoleOutput
  18054. {
  18055. $styles = self::createAdditionalStyles();
  18056. $formatter = new OutputFormatter(false, $styles);
  18057. return new ConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL, null, $formatter);
  18058. }
  18059. public function createComposer(IOInterface $io, $localConfig = null, $disablePlugins = false, ?string $cwd = null, bool $fullLoad = true, bool $disableScripts = false)
  18060. {
  18061. if (is_string($localConfig) && is_file($localConfig) && null === $cwd) {
  18062. $cwd = dirname($localConfig);
  18063. }
  18064. $cwd = $cwd ?? Platform::getCwd(true);
  18065. if (null === $localConfig) {
  18066. $localConfig = static::getComposerFile();
  18067. }
  18068. $localConfigSource = Config::SOURCE_UNKNOWN;
  18069. if (is_string($localConfig)) {
  18070. $composerFile = $localConfig;
  18071. $file = new JsonFile($localConfig, null, $io);
  18072. if (!$file->exists()) {
  18073. if ($localConfig === './composer.json' || $localConfig === 'composer.json') {
  18074. $message = 'Composer could not find a composer.json file in '.$cwd;
  18075. } else {
  18076. $message = 'Composer could not find the config file: '.$localConfig;
  18077. }
  18078. $instructions = $fullLoad ? 'To initialize a project, please create a composer.json file. See https://getcomposer.org/basic-usage' : '';
  18079. throw new \InvalidArgumentException($message.PHP_EOL.$instructions);
  18080. }
  18081. if (!Platform::isInputCompletionProcess()) {
  18082. try {
  18083. $file->validateSchema(JsonFile::LAX_SCHEMA);
  18084. } catch (JsonValidationException $e) {
  18085. $errors = ' - ' . implode(PHP_EOL . ' - ', $e->getErrors());
  18086. $message = $e->getMessage() . ':' . PHP_EOL . $errors;
  18087. throw new JsonValidationException($message);
  18088. }
  18089. }
  18090. $localConfig = $file->read();
  18091. $localConfigSource = $file->getPath();
  18092. }
  18093. $config = static::createConfig($io, $cwd);
  18094. $config->merge($localConfig, $localConfigSource);
  18095. if (isset($composerFile)) {
  18096. $io->writeError('Loading config file ' . $composerFile .' ('.realpath($composerFile).')', true, IOInterface::DEBUG);
  18097. $config->setConfigSource(new JsonConfigSource(new JsonFile(realpath($composerFile), null, $io)));
  18098. $localAuthFile = new JsonFile(dirname(realpath($composerFile)) . '/auth.json', null, $io);
  18099. if ($localAuthFile->exists()) {
  18100. $io->writeError('Loading config file ' . $localAuthFile->getPath(), true, IOInterface::DEBUG);
  18101. self::validateJsonSchema($io, $localAuthFile, JsonFile::AUTH_SCHEMA);
  18102. $config->merge(['config' => $localAuthFile->read()], $localAuthFile->getPath());
  18103. $config->setLocalAuthConfigSource(new JsonConfigSource($localAuthFile, true));
  18104. }
  18105. }
  18106. $vendorDir = $config->get('vendor-dir');
  18107. $composer = $fullLoad ? new Composer() : new PartialComposer();
  18108. $composer->setConfig($config);
  18109. if ($fullLoad) {
  18110. $io->loadConfiguration($config);
  18111. if (!class_exists('Composer\InstalledVersions', false) && file_exists($installedVersionsPath = $config->get('vendor-dir').'/composer/InstalledVersions.php')) {
  18112. include $installedVersionsPath;
  18113. }
  18114. }
  18115. $httpDownloader = self::createHttpDownloader($io, $config);
  18116. $process = new ProcessExecutor($io);
  18117. $loop = new Loop($httpDownloader, $process);
  18118. $composer->setLoop($loop);
  18119. $dispatcher = new EventDispatcher($composer, $io, $process);
  18120. $dispatcher->setRunScripts(!$disableScripts);
  18121. $composer->setEventDispatcher($dispatcher);
  18122. $rm = RepositoryFactory::manager($io, $config, $httpDownloader, $dispatcher, $process);
  18123. $composer->setRepositoryManager($rm);
  18124. if (!$fullLoad && !isset($localConfig['version'])) {
  18125. $localConfig['version'] = '1.0.0';
  18126. }
  18127. $parser = new VersionParser;
  18128. $guesser = new VersionGuesser($config, $process, $parser);
  18129. $loader = $this->loadRootPackage($rm, $config, $parser, $guesser, $io);
  18130. $package = $loader->load($localConfig, 'Composer\Package\RootPackage', $cwd);
  18131. $composer->setPackage($package);
  18132. $this->addLocalRepository($io, $rm, $vendorDir, $package, $process);
  18133. $im = $this->createInstallationManager($loop, $io, $dispatcher);
  18134. $composer->setInstallationManager($im);
  18135. if ($composer instanceof Composer) {
  18136. $dm = $this->createDownloadManager($io, $config, $httpDownloader, $process, $dispatcher);
  18137. $composer->setDownloadManager($dm);
  18138. $generator = new AutoloadGenerator($dispatcher, $io);
  18139. $composer->setAutoloadGenerator($generator);
  18140. $am = $this->createArchiveManager($config, $dm, $loop);
  18141. $composer->setArchiveManager($am);
  18142. }
  18143. $this->createDefaultInstallers($im, $composer, $io, $process);
  18144. if ($composer instanceof Composer && isset($composerFile)) {
  18145. $lockFile = self::getLockFile($composerFile);
  18146. if (!$config->get('lock') && file_exists($lockFile)) {
  18147. $io->writeError('<warning>'.$lockFile.' is present but ignored as the "lock" config option is disabled.</warning>');
  18148. }
  18149. $locker = new Package\Locker($io, new JsonFile($config->get('lock') ? $lockFile : Platform::getDevNull(), null, $io), $im, file_get_contents($composerFile), $process);
  18150. $composer->setLocker($locker);
  18151. } elseif ($composer instanceof Composer) {
  18152. $locker = new Package\Locker($io, new JsonFile(Platform::getDevNull(), null, $io), $im, JsonFile::encode($localConfig), $process);
  18153. $composer->setLocker($locker);
  18154. }
  18155. if ($composer instanceof Composer) {
  18156. $globalComposer = null;
  18157. if (realpath($config->get('home')) !== $cwd) {
  18158. $globalComposer = $this->createGlobalComposer($io, $config, $disablePlugins, $disableScripts);
  18159. }
  18160. $pm = $this->createPluginManager($io, $composer, $globalComposer, $disablePlugins);
  18161. $composer->setPluginManager($pm);
  18162. if (realpath($config->get('home')) === $cwd) {
  18163. $pm->setRunningInGlobalDir(true);
  18164. }
  18165. $pm->loadInstalledPlugins();
  18166. }
  18167. if ($fullLoad) {
  18168. $initEvent = new Event(PluginEvents::INIT);
  18169. $composer->getEventDispatcher()->dispatch($initEvent->getName(), $initEvent);
  18170. $this->purgePackages($rm->getLocalRepository(), $im);
  18171. }
  18172. return $composer;
  18173. }
  18174. public static function createGlobal(IOInterface $io, bool $disablePlugins = false, bool $disableScripts = false): ?Composer
  18175. {
  18176. $factory = new static();
  18177. return $factory->createGlobalComposer($io, static::createConfig($io), $disablePlugins, $disableScripts, true);
  18178. }
  18179. protected function addLocalRepository(IOInterface $io, RepositoryManager $rm, string $vendorDir, RootPackageInterface $rootPackage, ?ProcessExecutor $process = null): void
  18180. {
  18181. $fs = null;
  18182. if ($process) {
  18183. $fs = new Filesystem($process);
  18184. }
  18185. $rm->setLocalRepository(new Repository\InstalledFilesystemRepository(new JsonFile($vendorDir.'/composer/installed.json', null, $io), true, $rootPackage, $fs));
  18186. }
  18187. protected function createGlobalComposer(IOInterface $io, Config $config, $disablePlugins, bool $disableScripts, bool $fullLoad = false): ?PartialComposer
  18188. {
  18189. $disablePlugins = $disablePlugins === 'global' || $disablePlugins === true;
  18190. $composer = null;
  18191. try {
  18192. $composer = $this->createComposer($io, $config->get('home') . '/composer.json', $disablePlugins, $config->get('home'), $fullLoad, $disableScripts);
  18193. } catch (\Exception $e) {
  18194. $io->writeError('Failed to initialize global composer: '.$e->getMessage(), true, IOInterface::DEBUG);
  18195. }
  18196. return $composer;
  18197. }
  18198. public function createDownloadManager(IOInterface $io, Config $config, HttpDownloader $httpDownloader, ProcessExecutor $process, ?EventDispatcher $eventDispatcher = null): Downloader\DownloadManager
  18199. {
  18200. $cache = null;
  18201. if ($config->get('cache-files-ttl') > 0) {
  18202. $cache = new Cache($io, $config->get('cache-files-dir'), 'a-z0-9_./');
  18203. $cache->setReadOnly($config->get('cache-read-only'));
  18204. }
  18205. $fs = new Filesystem($process);
  18206. $dm = new Downloader\DownloadManager($io, false, $fs);
  18207. switch ($preferred = $config->get('preferred-install')) {
  18208. case 'dist':
  18209. $dm->setPreferDist(true);
  18210. break;
  18211. case 'source':
  18212. $dm->setPreferSource(true);
  18213. break;
  18214. case 'auto':
  18215. default:
  18216. break;
  18217. }
  18218. if (is_array($preferred)) {
  18219. $dm->setPreferences($preferred);
  18220. }
  18221. $dm->setDownloader('git', new Downloader\GitDownloader($io, $config, $process, $fs));
  18222. $dm->setDownloader('svn', new Downloader\SvnDownloader($io, $config, $process, $fs));
  18223. $dm->setDownloader('fossil', new Downloader\FossilDownloader($io, $config, $process, $fs));
  18224. $dm->setDownloader('hg', new Downloader\HgDownloader($io, $config, $process, $fs));
  18225. $dm->setDownloader('perforce', new Downloader\PerforceDownloader($io, $config, $process, $fs));
  18226. $dm->setDownloader('zip', new Downloader\ZipDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  18227. $dm->setDownloader('rar', new Downloader\RarDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  18228. $dm->setDownloader('tar', new Downloader\TarDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  18229. $dm->setDownloader('gzip', new Downloader\GzipDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  18230. $dm->setDownloader('xz', new Downloader\XzDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  18231. $dm->setDownloader('phar', new Downloader\PharDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  18232. $dm->setDownloader('file', new Downloader\FileDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  18233. $dm->setDownloader('path', new Downloader\PathDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  18234. return $dm;
  18235. }
  18236. public function createArchiveManager(Config $config, Downloader\DownloadManager $dm, Loop $loop)
  18237. {
  18238. $am = new Archiver\ArchiveManager($dm, $loop);
  18239. if (class_exists(ZipArchive::class)) {
  18240. $am->addArchiver(new Archiver\ZipArchiver);
  18241. }
  18242. if (class_exists(Phar::class)) {
  18243. $am->addArchiver(new Archiver\PharArchiver);
  18244. }
  18245. return $am;
  18246. }
  18247. protected function createPluginManager(IOInterface $io, Composer $composer, ?PartialComposer $globalComposer = null, $disablePlugins = false): Plugin\PluginManager
  18248. {
  18249. return new Plugin\PluginManager($io, $composer, $globalComposer, $disablePlugins);
  18250. }
  18251. public function createInstallationManager(Loop $loop, IOInterface $io, ?EventDispatcher $eventDispatcher = null): Installer\InstallationManager
  18252. {
  18253. return new Installer\InstallationManager($loop, $io, $eventDispatcher);
  18254. }
  18255. protected function createDefaultInstallers(Installer\InstallationManager $im, PartialComposer $composer, IOInterface $io, ?ProcessExecutor $process = null): void
  18256. {
  18257. $fs = new Filesystem($process);
  18258. $binaryInstaller = new Installer\BinaryInstaller($io, rtrim($composer->getConfig()->get('bin-dir'), '/'), $composer->getConfig()->get('bin-compat'), $fs, rtrim($composer->getConfig()->get('vendor-dir'), '/'));
  18259. $im->addInstaller(new Installer\LibraryInstaller($io, $composer, null, $fs, $binaryInstaller));
  18260. $im->addInstaller(new Installer\PluginInstaller($io, $composer, $fs, $binaryInstaller));
  18261. $im->addInstaller(new Installer\MetapackageInstaller($io));
  18262. }
  18263. protected function purgePackages(InstalledRepositoryInterface $repo, Installer\InstallationManager $im): void
  18264. {
  18265. foreach ($repo->getPackages() as $package) {
  18266. if (!$im->isPackageInstalled($repo, $package)) {
  18267. $repo->removePackage($package);
  18268. }
  18269. }
  18270. }
  18271. protected function loadRootPackage(RepositoryManager $rm, Config $config, VersionParser $parser, VersionGuesser $guesser, IOInterface $io): Package\Loader\RootPackageLoader
  18272. {
  18273. return new Package\Loader\RootPackageLoader($rm, $config, $parser, $guesser, $io);
  18274. }
  18275. public static function create(IOInterface $io, $config = null, $disablePlugins = false, bool $disableScripts = false): Composer
  18276. {
  18277. $factory = new static();
  18278. if ($config !== null && $config !== self::getComposerFile() && $disablePlugins === false) {
  18279. $disablePlugins = 'local';
  18280. }
  18281. return $factory->createComposer($io, $config, $disablePlugins, null, true, $disableScripts);
  18282. }
  18283. public static function createHttpDownloader(IOInterface $io, Config $config, array $options = []): HttpDownloader
  18284. {
  18285. static $warned = false;
  18286. $disableTls = false;
  18287. if (isset($_SERVER['argv']) && in_array('disable-tls', $_SERVER['argv']) && (in_array('conf', $_SERVER['argv']) || in_array('config', $_SERVER['argv']))) {
  18288. $warned = true;
  18289. $disableTls = !extension_loaded('openssl');
  18290. } elseif ($config->get('disable-tls') === true) {
  18291. if (!$warned) {
  18292. $io->writeError('<warning>You are running Composer with SSL/TLS protection disabled.</warning>');
  18293. }
  18294. $warned = true;
  18295. $disableTls = true;
  18296. } elseif (!extension_loaded('openssl')) {
  18297. throw new Exception\NoSslException('The openssl extension is required for SSL/TLS protection but is not available. '
  18298. . '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.');
  18299. }
  18300. $httpDownloaderOptions = [];
  18301. if ($disableTls === false) {
  18302. if ('' !== $config->get('cafile')) {
  18303. $httpDownloaderOptions['ssl']['cafile'] = $config->get('cafile');
  18304. }
  18305. if ('' !== $config->get('capath')) {
  18306. $httpDownloaderOptions['ssl']['capath'] = $config->get('capath');
  18307. }
  18308. $httpDownloaderOptions = array_replace_recursive($httpDownloaderOptions, $options);
  18309. }
  18310. try {
  18311. $httpDownloader = new HttpDownloader($io, $config, $httpDownloaderOptions, $disableTls);
  18312. } catch (TransportException $e) {
  18313. if (false !== strpos($e->getMessage(), 'cafile')) {
  18314. $io->write('<error>Unable to locate a valid CA certificate file. You must set a valid \'cafile\' option.</error>');
  18315. $io->write('<error>A valid CA certificate file is required for SSL/TLS protection.</error>');
  18316. $io->write('<error>You can disable this error, at your own risk, by setting the \'disable-tls\' option to true.</error>');
  18317. }
  18318. throw $e;
  18319. }
  18320. return $httpDownloader;
  18321. }
  18322. private static function useXdg(): bool
  18323. {
  18324. foreach (array_keys($_SERVER) as $key) {
  18325. if (strpos($key, 'XDG_') === 0) {
  18326. return true;
  18327. }
  18328. }
  18329. if (Silencer::call('is_dir', '/etc/xdg')) {
  18330. return true;
  18331. }
  18332. return false;
  18333. }
  18334. private static function getUserDir(): string
  18335. {
  18336. $home = Platform::getEnv('HOME');
  18337. if (!$home) {
  18338. throw new \RuntimeException('The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly');
  18339. }
  18340. return rtrim(strtr($home, '\\', '/'), '/');
  18341. }
  18342. private static function validateJsonSchema(?IOInterface $io, $fileOrData, int $schema = JsonFile::LAX_SCHEMA, ?string $source = null): void
  18343. {
  18344. if (Platform::isInputCompletionProcess()) {
  18345. return;
  18346. }
  18347. try {
  18348. if ($fileOrData instanceof JsonFile) {
  18349. $fileOrData->validateSchema($schema);
  18350. } else {
  18351. if (null === $source) {
  18352. throw new \InvalidArgumentException('$source is required to be provided if $fileOrData is arbitrary data');
  18353. }
  18354. JsonFile::validateJsonSchema($source, $fileOrData, $schema);
  18355. }
  18356. } catch (JsonValidationException $e) {
  18357. $msg = $e->getMessage().', this may result in errors and should be resolved:'.PHP_EOL.' - '.implode(PHP_EOL.' - ', $e->getErrors());
  18358. if ($io instanceof IOInterface) {
  18359. $io->writeError('<warning>'.$msg.'</>');
  18360. } else {
  18361. throw new UnexpectedValueException($msg);
  18362. }
  18363. }
  18364. }
  18365. }
  18366. <?php declare(strict_types=1);
  18367. namespace Composer\Filter\PlatformRequirementFilter;
  18368. use Composer\Repository\PlatformRepository;
  18369. final class IgnoreAllPlatformRequirementFilter implements PlatformRequirementFilterInterface
  18370. {
  18371. public function isIgnored(string $req): bool
  18372. {
  18373. return PlatformRepository::isPlatformPackage($req);
  18374. }
  18375. }
  18376. <?php declare(strict_types=1);
  18377. namespace Composer\Filter\PlatformRequirementFilter;
  18378. use Composer\Package\BasePackage;
  18379. use Composer\Pcre\Preg;
  18380. use Composer\Repository\PlatformRepository;
  18381. use Composer\Semver\Constraint\Constraint;
  18382. use Composer\Semver\Constraint\ConstraintInterface;
  18383. use Composer\Semver\Constraint\MatchAllConstraint;
  18384. use Composer\Semver\Constraint\MultiConstraint;
  18385. use Composer\Semver\Interval;
  18386. use Composer\Semver\Intervals;
  18387. final class IgnoreListPlatformRequirementFilter implements PlatformRequirementFilterInterface
  18388. {
  18389. private $ignoreRegex;
  18390. private $ignoreUpperBoundRegex;
  18391. public function __construct(array $reqList)
  18392. {
  18393. $ignoreAll = $ignoreUpperBound = [];
  18394. foreach ($reqList as $req) {
  18395. if (substr($req, -1) === '+') {
  18396. $ignoreUpperBound[] = substr($req, 0, -1);
  18397. } else {
  18398. $ignoreAll[] = $req;
  18399. }
  18400. }
  18401. $this->ignoreRegex = BasePackage::packageNamesToRegexp($ignoreAll);
  18402. $this->ignoreUpperBoundRegex = BasePackage::packageNamesToRegexp($ignoreUpperBound);
  18403. }
  18404. public function isIgnored(string $req): bool
  18405. {
  18406. if (!PlatformRepository::isPlatformPackage($req)) {
  18407. return false;
  18408. }
  18409. return Preg::isMatch($this->ignoreRegex, $req);
  18410. }
  18411. public function filterConstraint(string $req, ConstraintInterface $constraint, bool $allowUpperBoundOverride = true): ConstraintInterface
  18412. {
  18413. if (!PlatformRepository::isPlatformPackage($req)) {
  18414. return $constraint;
  18415. }
  18416. if (!$allowUpperBoundOverride || !Preg::isMatch($this->ignoreUpperBoundRegex, $req)) {
  18417. return $constraint;
  18418. }
  18419. if (Preg::isMatch($this->ignoreRegex, $req)) {
  18420. return new MatchAllConstraint;
  18421. }
  18422. $intervals = Intervals::get($constraint);
  18423. $last = end($intervals['numeric']);
  18424. if ($last !== false && (string) $last->getEnd() !== (string) Interval::untilPositiveInfinity()) {
  18425. $constraint = new MultiConstraint([$constraint, new Constraint('>=', $last->getEnd()->getVersion())], false);
  18426. }
  18427. return $constraint;
  18428. }
  18429. }
  18430. <?php declare(strict_types=1);
  18431. namespace Composer\Filter\PlatformRequirementFilter;
  18432. final class IgnoreNothingPlatformRequirementFilter implements PlatformRequirementFilterInterface
  18433. {
  18434. public function isIgnored(string $req): bool
  18435. {
  18436. return false;
  18437. }
  18438. }
  18439. <?php declare(strict_types=1);
  18440. namespace Composer\Filter\PlatformRequirementFilter;
  18441. final class PlatformRequirementFilterFactory
  18442. {
  18443. public static function fromBoolOrList($boolOrList): PlatformRequirementFilterInterface
  18444. {
  18445. if (is_bool($boolOrList)) {
  18446. return $boolOrList ? self::ignoreAll() : self::ignoreNothing();
  18447. }
  18448. if (is_array($boolOrList)) {
  18449. return new IgnoreListPlatformRequirementFilter($boolOrList);
  18450. }
  18451. throw new \InvalidArgumentException(
  18452. sprintf(
  18453. 'PlatformRequirementFilter: Unknown $boolOrList parameter %s. Please report at https://github.com/composer/composer/issues/new.',
  18454. gettype($boolOrList)
  18455. )
  18456. );
  18457. }
  18458. public static function ignoreAll(): PlatformRequirementFilterInterface
  18459. {
  18460. return new IgnoreAllPlatformRequirementFilter();
  18461. }
  18462. public static function ignoreNothing(): PlatformRequirementFilterInterface
  18463. {
  18464. return new IgnoreNothingPlatformRequirementFilter();
  18465. }
  18466. }
  18467. <?php declare(strict_types=1);
  18468. namespace Composer\Filter\PlatformRequirementFilter;
  18469. interface PlatformRequirementFilterInterface
  18470. {
  18471. public function isIgnored(string $req): bool;
  18472. }
  18473. <?php declare(strict_types=1);
  18474. namespace Composer\IO;
  18475. use Composer\Config;
  18476. use Composer\Pcre\Preg;
  18477. use Composer\Util\ProcessExecutor;
  18478. use Psr\Log\LogLevel;
  18479. abstract class BaseIO implements IOInterface
  18480. {
  18481. protected $authentications = [];
  18482. public function getAuthentications()
  18483. {
  18484. return $this->authentications;
  18485. }
  18486. public function resetAuthentications()
  18487. {
  18488. $this->authentications = [];
  18489. }
  18490. public function hasAuthentication($repositoryName)
  18491. {
  18492. return isset($this->authentications[$repositoryName]);
  18493. }
  18494. public function getAuthentication($repositoryName)
  18495. {
  18496. if (isset($this->authentications[$repositoryName])) {
  18497. return $this->authentications[$repositoryName];
  18498. }
  18499. return ['username' => null, 'password' => null];
  18500. }
  18501. public function setAuthentication($repositoryName, $username, $password = null)
  18502. {
  18503. $this->authentications[$repositoryName] = ['username' => $username, 'password' => $password];
  18504. }
  18505. public function writeRaw($messages, bool $newline = true, int $verbosity = self::NORMAL)
  18506. {
  18507. $this->write($messages, $newline, $verbosity);
  18508. }
  18509. public function writeErrorRaw($messages, bool $newline = true, int $verbosity = self::NORMAL)
  18510. {
  18511. $this->writeError($messages, $newline, $verbosity);
  18512. }
  18513. protected function checkAndSetAuthentication(string $repositoryName, string $username, ?string $password = null)
  18514. {
  18515. if ($this->hasAuthentication($repositoryName)) {
  18516. $auth = $this->getAuthentication($repositoryName);
  18517. if ($auth['username'] === $username && $auth['password'] === $password) {
  18518. return;
  18519. }
  18520. $this->writeError(
  18521. sprintf(
  18522. "<warning>Warning: You should avoid overwriting already defined auth settings for %s.</warning>",
  18523. $repositoryName
  18524. )
  18525. );
  18526. }
  18527. $this->setAuthentication($repositoryName, $username, $password);
  18528. }
  18529. public function loadConfiguration(Config $config)
  18530. {
  18531. $bitbucketOauth = $config->get('bitbucket-oauth');
  18532. $githubOauth = $config->get('github-oauth');
  18533. $gitlabOauth = $config->get('gitlab-oauth');
  18534. $gitlabToken = $config->get('gitlab-token');
  18535. $httpBasic = $config->get('http-basic');
  18536. $bearerToken = $config->get('bearer');
  18537. foreach ($bitbucketOauth as $domain => $cred) {
  18538. $this->checkAndSetAuthentication($domain, $cred['consumer-key'], $cred['consumer-secret']);
  18539. }
  18540. foreach ($githubOauth as $domain => $token) {
  18541. if ($domain !== 'github.com' && !in_array($domain, $config->get('github-domains'), true)) {
  18542. $this->debug($domain.' is not in the configured github-domains, adding it implicitly as authentication is configured for this domain');
  18543. $config->merge(['config' => ['github-domains' => array_merge($config->get('github-domains'), [$domain])]], 'implicit-due-to-auth');
  18544. }
  18545. if (!Preg::isMatch('{^[.A-Za-z0-9_]+$}', $token)) {
  18546. throw new \UnexpectedValueException('Your github oauth token for '.$domain.' contains invalid characters: "'.$token.'"');
  18547. }
  18548. $this->checkAndSetAuthentication($domain, $token, 'x-oauth-basic');
  18549. }
  18550. foreach ($gitlabOauth as $domain => $token) {
  18551. if ($domain !== 'gitlab.com' && !in_array($domain, $config->get('gitlab-domains'), true)) {
  18552. $this->debug($domain.' is not in the configured gitlab-domains, adding it implicitly as authentication is configured for this domain');
  18553. $config->merge(['config' => ['gitlab-domains' => array_merge($config->get('gitlab-domains'), [$domain])]], 'implicit-due-to-auth');
  18554. }
  18555. $token = is_array($token) ? $token["token"] : $token;
  18556. $this->checkAndSetAuthentication($domain, $token, 'oauth2');
  18557. }
  18558. foreach ($gitlabToken as $domain => $token) {
  18559. if ($domain !== 'gitlab.com' && !in_array($domain, $config->get('gitlab-domains'), true)) {
  18560. $this->debug($domain.' is not in the configured gitlab-domains, adding it implicitly as authentication is configured for this domain');
  18561. $config->merge(['config' => ['gitlab-domains' => array_merge($config->get('gitlab-domains'), [$domain])]], 'implicit-due-to-auth');
  18562. }
  18563. $username = is_array($token) ? $token["username"] : $token;
  18564. $password = is_array($token) ? $token["token"] : 'private-token';
  18565. $this->checkAndSetAuthentication($domain, $username, $password);
  18566. }
  18567. foreach ($httpBasic as $domain => $cred) {
  18568. $this->checkAndSetAuthentication($domain, $cred['username'], $cred['password']);
  18569. }
  18570. foreach ($bearerToken as $domain => $token) {
  18571. $this->checkAndSetAuthentication($domain, $token, 'bearer');
  18572. }
  18573. ProcessExecutor::setTimeout($config->get('process-timeout'));
  18574. }
  18575. public function emergency($message, array $context = []): void
  18576. {
  18577. $this->log(LogLevel::EMERGENCY, $message, $context);
  18578. }
  18579. public function alert($message, array $context = []): void
  18580. {
  18581. $this->log(LogLevel::ALERT, $message, $context);
  18582. }
  18583. public function critical($message, array $context = []): void
  18584. {
  18585. $this->log(LogLevel::CRITICAL, $message, $context);
  18586. }
  18587. public function error($message, array $context = []): void
  18588. {
  18589. $this->log(LogLevel::ERROR, $message, $context);
  18590. }
  18591. public function warning($message, array $context = []): void
  18592. {
  18593. $this->log(LogLevel::WARNING, $message, $context);
  18594. }
  18595. public function notice($message, array $context = []): void
  18596. {
  18597. $this->log(LogLevel::NOTICE, $message, $context);
  18598. }
  18599. public function info($message, array $context = []): void
  18600. {
  18601. $this->log(LogLevel::INFO, $message, $context);
  18602. }
  18603. public function debug($message, array $context = []): void
  18604. {
  18605. $this->log(LogLevel::DEBUG, $message, $context);
  18606. }
  18607. public function log($level, $message, array $context = []): void
  18608. {
  18609. $message = (string) $message;
  18610. if (in_array($level, [LogLevel::EMERGENCY, LogLevel::ALERT, LogLevel::CRITICAL, LogLevel::ERROR])) {
  18611. $this->writeError('<error>'.$message.'</error>');
  18612. } elseif ($level === LogLevel::WARNING) {
  18613. $this->writeError('<warning>'.$message.'</warning>');
  18614. } elseif ($level === LogLevel::NOTICE) {
  18615. $this->writeError('<info>'.$message.'</info>', true, self::VERBOSE);
  18616. } elseif ($level === LogLevel::INFO) {
  18617. $this->writeError('<info>'.$message.'</info>', true, self::VERY_VERBOSE);
  18618. } else {
  18619. $this->writeError($message, true, self::DEBUG);
  18620. }
  18621. }
  18622. }
  18623. <?php declare(strict_types=1);
  18624. namespace Composer\IO;
  18625. use Composer\Pcre\Preg;
  18626. use Symfony\Component\Console\Helper\QuestionHelper;
  18627. use Symfony\Component\Console\Output\StreamOutput;
  18628. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  18629. use Symfony\Component\Console\Input\StreamableInputInterface;
  18630. use Symfony\Component\Console\Input\StringInput;
  18631. use Symfony\Component\Console\Helper\HelperSet;
  18632. class BufferIO extends ConsoleIO
  18633. {
  18634. protected $input;
  18635. protected $output;
  18636. public function __construct(string $input = '', int $verbosity = StreamOutput::VERBOSITY_NORMAL, ?OutputFormatterInterface $formatter = null)
  18637. {
  18638. $input = new StringInput($input);
  18639. $input->setInteractive(false);
  18640. $output = new StreamOutput(fopen('php://memory', 'rw'), $verbosity, $formatter ? $formatter->isDecorated() : false, $formatter);
  18641. parent::__construct($input, $output, new HelperSet([
  18642. new QuestionHelper(),
  18643. ]));
  18644. }
  18645. public function getOutput(): string
  18646. {
  18647. fseek($this->output->getStream(), 0);
  18648. $output = stream_get_contents($this->output->getStream());
  18649. $output = Preg::replaceCallback("{(?<=^|\n|\x08)(.+?)(\x08+)}", static function ($matches): string {
  18650. assert(is_string($matches[1]));
  18651. assert(is_string($matches[2]));
  18652. $pre = strip_tags($matches[1]);
  18653. if (strlen($pre) === strlen($matches[2])) {
  18654. return '';
  18655. }
  18656. return rtrim($matches[1])."\n";
  18657. }, $output);
  18658. return $output;
  18659. }
  18660. public function setUserInputs(array $inputs): void
  18661. {
  18662. if (!$this->input instanceof StreamableInputInterface) {
  18663. throw new \RuntimeException('Setting the user inputs requires at least the version 3.2 of the symfony/console component.');
  18664. }
  18665. $this->input->setStream($this->createStream($inputs));
  18666. $this->input->setInteractive(true);
  18667. }
  18668. private function createStream(array $inputs)
  18669. {
  18670. $stream = fopen('php://memory', 'r+');
  18671. foreach ($inputs as $input) {
  18672. fwrite($stream, $input.PHP_EOL);
  18673. }
  18674. rewind($stream);
  18675. return $stream;
  18676. }
  18677. }
  18678. <?php declare(strict_types=1);
  18679. namespace Composer\IO;
  18680. use Composer\Question\StrictConfirmationQuestion;
  18681. use Symfony\Component\Console\Helper\HelperSet;
  18682. use Symfony\Component\Console\Helper\ProgressBar;
  18683. use Symfony\Component\Console\Helper\Table;
  18684. use Symfony\Component\Console\Input\InputInterface;
  18685. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  18686. use Symfony\Component\Console\Output\OutputInterface;
  18687. use Symfony\Component\Console\Question\ChoiceQuestion;
  18688. use Symfony\Component\Console\Question\Question;
  18689. class ConsoleIO extends BaseIO
  18690. {
  18691. protected $input;
  18692. protected $output;
  18693. protected $helperSet;
  18694. protected $lastMessage = '';
  18695. protected $lastMessageErr = '';
  18696. private $startTime;
  18697. private $verbosityMap;
  18698. public function __construct(InputInterface $input, OutputInterface $output, HelperSet $helperSet)
  18699. {
  18700. $this->input = $input;
  18701. $this->output = $output;
  18702. $this->helperSet = $helperSet;
  18703. $this->verbosityMap = [
  18704. self::QUIET => OutputInterface::VERBOSITY_QUIET,
  18705. self::NORMAL => OutputInterface::VERBOSITY_NORMAL,
  18706. self::VERBOSE => OutputInterface::VERBOSITY_VERBOSE,
  18707. self::VERY_VERBOSE => OutputInterface::VERBOSITY_VERY_VERBOSE,
  18708. self::DEBUG => OutputInterface::VERBOSITY_DEBUG,
  18709. ];
  18710. }
  18711. public function enableDebugging(float $startTime)
  18712. {
  18713. $this->startTime = $startTime;
  18714. }
  18715. public function isInteractive()
  18716. {
  18717. return $this->input->isInteractive();
  18718. }
  18719. public function isDecorated()
  18720. {
  18721. return $this->output->isDecorated();
  18722. }
  18723. public function isVerbose()
  18724. {
  18725. return $this->output->isVerbose();
  18726. }
  18727. public function isVeryVerbose()
  18728. {
  18729. return $this->output->isVeryVerbose();
  18730. }
  18731. public function isDebug()
  18732. {
  18733. return $this->output->isDebug();
  18734. }
  18735. public function write($messages, bool $newline = true, int $verbosity = self::NORMAL)
  18736. {
  18737. $this->doWrite($messages, $newline, false, $verbosity);
  18738. }
  18739. public function writeError($messages, bool $newline = true, int $verbosity = self::NORMAL)
  18740. {
  18741. $this->doWrite($messages, $newline, true, $verbosity);
  18742. }
  18743. public function writeRaw($messages, bool $newline = true, int $verbosity = self::NORMAL)
  18744. {
  18745. $this->doWrite($messages, $newline, false, $verbosity, true);
  18746. }
  18747. public function writeErrorRaw($messages, bool $newline = true, int $verbosity = self::NORMAL)
  18748. {
  18749. $this->doWrite($messages, $newline, true, $verbosity, true);
  18750. }
  18751. private function doWrite($messages, bool $newline, bool $stderr, int $verbosity, bool $raw = false): void
  18752. {
  18753. $sfVerbosity = $this->verbosityMap[$verbosity];
  18754. if ($sfVerbosity > $this->output->getVerbosity()) {
  18755. return;
  18756. }
  18757. if ($raw) {
  18758. $sfVerbosity |= OutputInterface::OUTPUT_RAW;
  18759. }
  18760. if (null !== $this->startTime) {
  18761. $memoryUsage = memory_get_usage() / 1024 / 1024;
  18762. $timeSpent = microtime(true) - $this->startTime;
  18763. $messages = array_map(static function ($message) use ($memoryUsage, $timeSpent): string {
  18764. return sprintf('[%.1fMiB/%.2fs] %s', $memoryUsage, $timeSpent, $message);
  18765. }, (array) $messages);
  18766. }
  18767. if (true === $stderr && $this->output instanceof ConsoleOutputInterface) {
  18768. $this->output->getErrorOutput()->write($messages, $newline, $sfVerbosity);
  18769. $this->lastMessageErr = implode($newline ? "\n" : '', (array) $messages);
  18770. return;
  18771. }
  18772. $this->output->write($messages, $newline, $sfVerbosity);
  18773. $this->lastMessage = implode($newline ? "\n" : '', (array) $messages);
  18774. }
  18775. public function overwrite($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL)
  18776. {
  18777. $this->doOverwrite($messages, $newline, $size, false, $verbosity);
  18778. }
  18779. public function overwriteError($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL)
  18780. {
  18781. $this->doOverwrite($messages, $newline, $size, true, $verbosity);
  18782. }
  18783. private function doOverwrite($messages, bool $newline, ?int $size, bool $stderr, int $verbosity): void
  18784. {
  18785. $messages = implode($newline ? "\n" : '', (array) $messages);
  18786. if (!isset($size)) {
  18787. $size = strlen(strip_tags($stderr ? $this->lastMessageErr : $this->lastMessage));
  18788. }
  18789. $this->doWrite(str_repeat("\x08", $size), false, $stderr, $verbosity);
  18790. $this->doWrite($messages, false, $stderr, $verbosity);
  18791. $fill = $size - strlen(strip_tags($messages));
  18792. if ($fill > 0) {
  18793. $this->doWrite(str_repeat(' ', $fill), false, $stderr, $verbosity);
  18794. $this->doWrite(str_repeat("\x08", $fill), false, $stderr, $verbosity);
  18795. }
  18796. if ($newline) {
  18797. $this->doWrite('', true, $stderr, $verbosity);
  18798. }
  18799. if ($stderr) {
  18800. $this->lastMessageErr = $messages;
  18801. } else {
  18802. $this->lastMessage = $messages;
  18803. }
  18804. }
  18805. public function getProgressBar(int $max = 0)
  18806. {
  18807. return new ProgressBar($this->getErrorOutput(), $max);
  18808. }
  18809. public function ask($question, $default = null)
  18810. {
  18811. $helper = $this->helperSet->get('question');
  18812. $question = new Question($question, $default);
  18813. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  18814. }
  18815. public function askConfirmation($question, $default = true)
  18816. {
  18817. $helper = $this->helperSet->get('question');
  18818. $question = new StrictConfirmationQuestion($question, $default);
  18819. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  18820. }
  18821. public function askAndValidate($question, $validator, $attempts = null, $default = null)
  18822. {
  18823. $helper = $this->helperSet->get('question');
  18824. $question = new Question($question, $default);
  18825. $question->setValidator($validator);
  18826. $question->setMaxAttempts($attempts);
  18827. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  18828. }
  18829. public function askAndHideAnswer($question)
  18830. {
  18831. $helper = $this->helperSet->get('question');
  18832. $question = new Question($question);
  18833. $question->setHidden(true);
  18834. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  18835. }
  18836. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  18837. {
  18838. $helper = $this->helperSet->get('question');
  18839. $question = new ChoiceQuestion($question, $choices, $default);
  18840. $question->setMaxAttempts($attempts ?: null);
  18841. $question->setErrorMessage($errorMessage);
  18842. $question->setMultiselect($multiselect);
  18843. $result = $helper->ask($this->input, $this->getErrorOutput(), $question);
  18844. $isAssoc = (bool) \count(array_filter(array_keys($choices), 'is_string'));
  18845. if ($isAssoc) {
  18846. return $result;
  18847. }
  18848. if (!is_array($result)) {
  18849. return (string) array_search($result, $choices, true);
  18850. }
  18851. $results = [];
  18852. foreach ($choices as $index => $choice) {
  18853. if (in_array($choice, $result, true)) {
  18854. $results[] = (string) $index;
  18855. }
  18856. }
  18857. return $results;
  18858. }
  18859. public function getTable(): Table
  18860. {
  18861. return new Table($this->output);
  18862. }
  18863. private function getErrorOutput(): OutputInterface
  18864. {
  18865. if ($this->output instanceof ConsoleOutputInterface) {
  18866. return $this->output->getErrorOutput();
  18867. }
  18868. return $this->output;
  18869. }
  18870. }
  18871. <?php declare(strict_types=1);
  18872. namespace Composer\IO;
  18873. use Composer\Config;
  18874. use Psr\Log\LoggerInterface;
  18875. interface IOInterface extends LoggerInterface
  18876. {
  18877. public const QUIET = 1;
  18878. public const NORMAL = 2;
  18879. public const VERBOSE = 4;
  18880. public const VERY_VERBOSE = 8;
  18881. public const DEBUG = 16;
  18882. public function isInteractive();
  18883. public function isVerbose();
  18884. public function isVeryVerbose();
  18885. public function isDebug();
  18886. public function isDecorated();
  18887. public function write($messages, bool $newline = true, int $verbosity = self::NORMAL);
  18888. public function writeError($messages, bool $newline = true, int $verbosity = self::NORMAL);
  18889. public function writeRaw($messages, bool $newline = true, int $verbosity = self::NORMAL);
  18890. public function writeErrorRaw($messages, bool $newline = true, int $verbosity = self::NORMAL);
  18891. public function overwrite($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL);
  18892. public function overwriteError($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL);
  18893. public function ask(string $question, $default = null);
  18894. public function askConfirmation(string $question, bool $default = true);
  18895. public function askAndValidate(string $question, callable $validator, ?int $attempts = null, $default = null);
  18896. public function askAndHideAnswer(string $question);
  18897. public function select(string $question, array $choices, $default, $attempts = false, string $errorMessage = 'Value "%s" is invalid', bool $multiselect = false);
  18898. public function getAuthentications();
  18899. public function hasAuthentication(string $repositoryName);
  18900. public function getAuthentication(string $repositoryName);
  18901. public function setAuthentication(string $repositoryName, string $username, ?string $password = null);
  18902. public function loadConfiguration(Config $config);
  18903. }
  18904. <?php declare(strict_types=1);
  18905. namespace Composer\IO;
  18906. class NullIO extends BaseIO
  18907. {
  18908. public function isInteractive(): bool
  18909. {
  18910. return false;
  18911. }
  18912. public function isVerbose(): bool
  18913. {
  18914. return false;
  18915. }
  18916. public function isVeryVerbose(): bool
  18917. {
  18918. return false;
  18919. }
  18920. public function isDebug(): bool
  18921. {
  18922. return false;
  18923. }
  18924. public function isDecorated(): bool
  18925. {
  18926. return false;
  18927. }
  18928. public function write($messages, bool $newline = true, int $verbosity = self::NORMAL): void
  18929. {
  18930. }
  18931. public function writeError($messages, bool $newline = true, int $verbosity = self::NORMAL): void
  18932. {
  18933. }
  18934. public function overwrite($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL): void
  18935. {
  18936. }
  18937. public function overwriteError($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL): void
  18938. {
  18939. }
  18940. public function ask($question, $default = null)
  18941. {
  18942. return $default;
  18943. }
  18944. public function askConfirmation($question, $default = true): bool
  18945. {
  18946. return $default;
  18947. }
  18948. public function askAndValidate($question, $validator, $attempts = null, $default = null)
  18949. {
  18950. return $default;
  18951. }
  18952. public function askAndHideAnswer($question): ?string
  18953. {
  18954. return null;
  18955. }
  18956. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  18957. {
  18958. return $default;
  18959. }
  18960. }
  18961. <?php declare(strict_types=1);
  18962. namespace Composer;
  18963. use Composer\Autoload\AutoloadGenerator;
  18964. use Composer\Console\GithubActionError;
  18965. use Composer\DependencyResolver\DefaultPolicy;
  18966. use Composer\DependencyResolver\LocalRepoTransaction;
  18967. use Composer\DependencyResolver\LockTransaction;
  18968. use Composer\DependencyResolver\Operation\UpdateOperation;
  18969. use Composer\DependencyResolver\Operation\InstallOperation;
  18970. use Composer\DependencyResolver\Operation\UninstallOperation;
  18971. use Composer\DependencyResolver\PoolOptimizer;
  18972. use Composer\DependencyResolver\Pool;
  18973. use Composer\DependencyResolver\Request;
  18974. use Composer\DependencyResolver\Solver;
  18975. use Composer\DependencyResolver\SolverProblemsException;
  18976. use Composer\DependencyResolver\PolicyInterface;
  18977. use Composer\Downloader\DownloadManager;
  18978. use Composer\Downloader\TransportException;
  18979. use Composer\EventDispatcher\EventDispatcher;
  18980. use Composer\Filter\PlatformRequirementFilter\IgnoreListPlatformRequirementFilter;
  18981. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  18982. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  18983. use Composer\Installer\InstallationManager;
  18984. use Composer\Installer\InstallerEvents;
  18985. use Composer\Installer\SuggestedPackagesReporter;
  18986. use Composer\IO\IOInterface;
  18987. use Composer\Package\AliasPackage;
  18988. use Composer\Package\RootAliasPackage;
  18989. use Composer\Package\BasePackage;
  18990. use Composer\Package\CompletePackage;
  18991. use Composer\Package\CompletePackageInterface;
  18992. use Composer\Package\Link;
  18993. use Composer\Package\Loader\ArrayLoader;
  18994. use Composer\Package\Dumper\ArrayDumper;
  18995. use Composer\Package\Version\VersionParser;
  18996. use Composer\Package\Package;
  18997. use Composer\Repository\ArrayRepository;
  18998. use Composer\Repository\RepositorySet;
  18999. use Composer\Repository\CompositeRepository;
  19000. use Composer\Semver\Constraint\Constraint;
  19001. use Composer\Package\Locker;
  19002. use Composer\Package\RootPackageInterface;
  19003. use Composer\Repository\InstalledArrayRepository;
  19004. use Composer\Repository\InstalledRepositoryInterface;
  19005. use Composer\Repository\InstalledRepository;
  19006. use Composer\Repository\RootPackageRepository;
  19007. use Composer\Repository\PlatformRepository;
  19008. use Composer\Repository\RepositoryInterface;
  19009. use Composer\Repository\RepositoryManager;
  19010. use Composer\Repository\LockArrayRepository;
  19011. use Composer\Script\ScriptEvents;
  19012. use Composer\Semver\Constraint\ConstraintInterface;
  19013. use Composer\Advisory\Auditor;
  19014. use Composer\Util\Platform;
  19015. class Installer
  19016. {
  19017. public const ERROR_NONE = 0;
  19018. public const ERROR_GENERIC_FAILURE = 1;
  19019. public const ERROR_NO_LOCK_FILE_FOR_PARTIAL_UPDATE = 3;
  19020. public const ERROR_LOCK_FILE_INVALID = 4;
  19021. public const ERROR_DEPENDENCY_RESOLUTION_FAILED = 2;
  19022. public const ERROR_AUDIT_FAILED = 5;
  19023. protected $io;
  19024. protected $config;
  19025. protected $package;
  19026. protected $fixedRootPackage;
  19027. protected $downloadManager;
  19028. protected $repositoryManager;
  19029. protected $locker;
  19030. protected $installationManager;
  19031. protected $eventDispatcher;
  19032. protected $autoloadGenerator;
  19033. protected $preferSource = false;
  19034. protected $preferDist = false;
  19035. protected $optimizeAutoloader = false;
  19036. protected $classMapAuthoritative = false;
  19037. protected $apcuAutoloader = false;
  19038. protected $apcuAutoloaderPrefix = null;
  19039. protected $devMode = false;
  19040. protected $dryRun = false;
  19041. protected $downloadOnly = false;
  19042. protected $verbose = false;
  19043. protected $update = false;
  19044. protected $install = true;
  19045. protected $dumpAutoloader = true;
  19046. protected $runScripts = true;
  19047. protected $preferStable = false;
  19048. protected $preferLowest = false;
  19049. protected $writeLock;
  19050. protected $executeOperations = true;
  19051. protected $audit = true;
  19052. protected $errorOnAudit = false;
  19053. protected $auditFormat = Auditor::FORMAT_SUMMARY;
  19054. protected $updateMirrors = false;
  19055. protected $updateAllowList = null;
  19056. protected $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  19057. protected $suggestedPackagesReporter;
  19058. protected $platformRequirementFilter;
  19059. protected $additionalFixedRepository;
  19060. protected $temporaryConstraints = [];
  19061. public function __construct(IOInterface $io, Config $config, RootPackageInterface $package, DownloadManager $downloadManager, RepositoryManager $repositoryManager, Locker $locker, InstallationManager $installationManager, EventDispatcher $eventDispatcher, AutoloadGenerator $autoloadGenerator)
  19062. {
  19063. $this->io = $io;
  19064. $this->config = $config;
  19065. $this->package = $package;
  19066. $this->downloadManager = $downloadManager;
  19067. $this->repositoryManager = $repositoryManager;
  19068. $this->locker = $locker;
  19069. $this->installationManager = $installationManager;
  19070. $this->eventDispatcher = $eventDispatcher;
  19071. $this->autoloadGenerator = $autoloadGenerator;
  19072. $this->suggestedPackagesReporter = new SuggestedPackagesReporter($this->io);
  19073. $this->platformRequirementFilter = PlatformRequirementFilterFactory::ignoreNothing();
  19074. $this->writeLock = $config->get('lock');
  19075. }
  19076. public function run(): int
  19077. {
  19078. gc_collect_cycles();
  19079. gc_disable();
  19080. if ($this->updateAllowList !== null && $this->updateMirrors) {
  19081. throw new \RuntimeException("The installer options updateMirrors and updateAllowList are mutually exclusive.");
  19082. }
  19083. $isFreshInstall = $this->repositoryManager->getLocalRepository()->isFresh();
  19084. if (!$this->update && !$this->locker->isLocked()) {
  19085. $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>');
  19086. $this->update = true;
  19087. }
  19088. if ($this->dryRun) {
  19089. $this->verbose = true;
  19090. $this->runScripts = false;
  19091. $this->executeOperations = false;
  19092. $this->writeLock = false;
  19093. $this->dumpAutoloader = false;
  19094. $this->mockLocalRepositories($this->repositoryManager);
  19095. }
  19096. if ($this->downloadOnly) {
  19097. $this->dumpAutoloader = false;
  19098. }
  19099. if ($this->update && !$this->install) {
  19100. $this->dumpAutoloader = false;
  19101. }
  19102. if ($this->runScripts) {
  19103. Platform::putEnv('COMPOSER_DEV_MODE', $this->devMode ? '1' : '0');
  19104. $eventName = $this->update ? ScriptEvents::PRE_UPDATE_CMD : ScriptEvents::PRE_INSTALL_CMD;
  19105. $this->eventDispatcher->dispatchScript($eventName, $this->devMode);
  19106. }
  19107. $this->downloadManager->setPreferSource($this->preferSource);
  19108. $this->downloadManager->setPreferDist($this->preferDist);
  19109. $localRepo = $this->repositoryManager->getLocalRepository();
  19110. try {
  19111. if ($this->update) {
  19112. $res = $this->doUpdate($localRepo, $this->install);
  19113. } else {
  19114. $res = $this->doInstall($localRepo);
  19115. }
  19116. if ($res !== 0) {
  19117. return $res;
  19118. }
  19119. } catch (\Exception $e) {
  19120. if ($this->executeOperations && $this->install && $this->config->get('notify-on-install')) {
  19121. $this->installationManager->notifyInstalls($this->io);
  19122. }
  19123. throw $e;
  19124. }
  19125. if ($this->executeOperations && $this->install && $this->config->get('notify-on-install')) {
  19126. $this->installationManager->notifyInstalls($this->io);
  19127. }
  19128. if ($this->update) {
  19129. $installedRepo = new InstalledRepository([
  19130. $this->locker->getLockedRepository($this->devMode),
  19131. $this->createPlatformRepo(false),
  19132. new RootPackageRepository(clone $this->package),
  19133. ]);
  19134. if ($isFreshInstall) {
  19135. $this->suggestedPackagesReporter->addSuggestionsFromPackage($this->package);
  19136. }
  19137. $this->suggestedPackagesReporter->outputMinimalistic($installedRepo);
  19138. }
  19139. $lockedRepository = $this->locker->getLockedRepository(true);
  19140. foreach ($lockedRepository->getPackages() as $package) {
  19141. if (!$package instanceof CompletePackage || !$package->isAbandoned()) {
  19142. continue;
  19143. }
  19144. $replacement = is_string($package->getReplacementPackage())
  19145. ? 'Use ' . $package->getReplacementPackage() . ' instead'
  19146. : 'No replacement was suggested';
  19147. $this->io->writeError(
  19148. sprintf(
  19149. "<warning>Package %s is abandoned, you should avoid using it. %s.</warning>",
  19150. $package->getPrettyName(),
  19151. $replacement
  19152. )
  19153. );
  19154. }
  19155. if ($this->dumpAutoloader) {
  19156. if ($this->optimizeAutoloader) {
  19157. $this->io->writeError('<info>Generating optimized autoload files</info>');
  19158. } else {
  19159. $this->io->writeError('<info>Generating autoload files</info>');
  19160. }
  19161. $this->autoloadGenerator->setClassMapAuthoritative($this->classMapAuthoritative);
  19162. $this->autoloadGenerator->setApcu($this->apcuAutoloader, $this->apcuAutoloaderPrefix);
  19163. $this->autoloadGenerator->setRunScripts($this->runScripts);
  19164. $this->autoloadGenerator->setPlatformRequirementFilter($this->platformRequirementFilter);
  19165. $this
  19166. ->autoloadGenerator
  19167. ->dump(
  19168. $this->config,
  19169. $localRepo,
  19170. $this->package,
  19171. $this->installationManager,
  19172. 'composer',
  19173. $this->optimizeAutoloader,
  19174. null,
  19175. $this->locker
  19176. );
  19177. }
  19178. if ($this->install && $this->executeOperations) {
  19179. foreach ($localRepo->getPackages() as $package) {
  19180. $this->installationManager->ensureBinariesPresence($package);
  19181. }
  19182. }
  19183. $fundingCount = 0;
  19184. foreach ($localRepo->getPackages() as $package) {
  19185. if ($package instanceof CompletePackageInterface && !$package instanceof AliasPackage && $package->getFunding()) {
  19186. $fundingCount++;
  19187. }
  19188. }
  19189. if ($fundingCount > 0) {
  19190. $this->io->writeError([
  19191. sprintf(
  19192. "<info>%d package%s you are using %s looking for funding.</info>",
  19193. $fundingCount,
  19194. 1 === $fundingCount ? '' : 's',
  19195. 1 === $fundingCount ? 'is' : 'are'
  19196. ),
  19197. '<info>Use the `composer fund` command to find out more!</info>',
  19198. ]);
  19199. }
  19200. if ($this->runScripts) {
  19201. $eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD;
  19202. $this->eventDispatcher->dispatchScript($eventName, $this->devMode);
  19203. }
  19204. if (!defined('HHVM_VERSION')) {
  19205. gc_enable();
  19206. }
  19207. if ($this->audit) {
  19208. if ($this->update && !$this->install) {
  19209. $packages = $lockedRepository->getCanonicalPackages();
  19210. $target = 'locked';
  19211. } else {
  19212. $packages = $localRepo->getCanonicalPackages();
  19213. $target = 'installed';
  19214. }
  19215. if (count($packages) > 0) {
  19216. try {
  19217. $auditor = new Auditor();
  19218. $repoSet = new RepositorySet();
  19219. foreach ($this->repositoryManager->getRepositories() as $repo) {
  19220. $repoSet->addRepository($repo);
  19221. }
  19222. $auditConfig = $this->config->get('audit');
  19223. return $auditor->audit($this->io, $repoSet, $packages, $this->auditFormat, true, $auditConfig['ignore'] ?? [], $auditConfig['abandoned'] ?? Auditor::ABANDONED_REPORT) > 0 && $this->errorOnAudit ? self::ERROR_AUDIT_FAILED : 0;
  19224. } catch (TransportException $e) {
  19225. $this->io->error('Failed to audit '.$target.' packages.');
  19226. if ($this->io->isVerbose()) {
  19227. $this->io->error('['.get_class($e).'] '.$e->getMessage());
  19228. }
  19229. }
  19230. } else {
  19231. $this->io->writeError('No '.$target.' packages - skipping audit.');
  19232. }
  19233. }
  19234. return 0;
  19235. }
  19236. protected function doUpdate(InstalledRepositoryInterface $localRepo, bool $doInstall): int
  19237. {
  19238. $platformRepo = $this->createPlatformRepo(true);
  19239. $aliases = $this->getRootAliases(true);
  19240. $lockedRepository = null;
  19241. try {
  19242. if ($this->locker->isLocked()) {
  19243. $lockedRepository = $this->locker->getLockedRepository(true);
  19244. }
  19245. } catch (\Seld\JsonLint\ParsingException $e) {
  19246. if ($this->updateAllowList !== null || $this->updateMirrors) {
  19247. throw $e;
  19248. }
  19249. }
  19250. if (($this->updateAllowList !== null || $this->updateMirrors) && !$lockedRepository) {
  19251. $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);
  19252. return self::ERROR_NO_LOCK_FILE_FOR_PARTIAL_UPDATE;
  19253. }
  19254. $this->io->writeError('<info>Loading composer repositories with package information</info>');
  19255. $policy = $this->createPolicy(true);
  19256. $repositorySet = $this->createRepositorySet(true, $platformRepo, $aliases);
  19257. $repositories = $this->repositoryManager->getRepositories();
  19258. foreach ($repositories as $repository) {
  19259. $repositorySet->addRepository($repository);
  19260. }
  19261. if ($lockedRepository) {
  19262. $repositorySet->addRepository($lockedRepository);
  19263. }
  19264. $request = $this->createRequest($this->fixedRootPackage, $platformRepo, $lockedRepository);
  19265. $this->requirePackagesForUpdate($request, $lockedRepository, true);
  19266. if ($this->updateAllowList !== null) {
  19267. $request->setUpdateAllowList($this->updateAllowList, $this->updateAllowTransitiveDependencies);
  19268. }
  19269. $pool = $repositorySet->createPool($request, $this->io, $this->eventDispatcher, $this->createPoolOptimizer($policy));
  19270. $this->io->writeError('<info>Updating dependencies</info>');
  19271. $solver = new Solver($policy, $pool, $this->io);
  19272. try {
  19273. $lockTransaction = $solver->solve($request, $this->platformRequirementFilter);
  19274. $ruleSetSize = $solver->getRuleSetSize();
  19275. $solver = null;
  19276. } catch (SolverProblemsException $e) {
  19277. $err = 'Your requirements could not be resolved to an installable set of packages.';
  19278. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose());
  19279. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  19280. $this->io->writeError($prettyProblem);
  19281. if (!$this->devMode) {
  19282. $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);
  19283. }
  19284. $ghe = new GithubActionError($this->io);
  19285. $ghe->emit($err."\n".$prettyProblem);
  19286. return max(self::ERROR_GENERIC_FAILURE, $e->getCode());
  19287. }
  19288. $this->io->writeError("Analyzed ".count($pool)." packages to resolve dependencies", true, IOInterface::VERBOSE);
  19289. $this->io->writeError("Analyzed ".$ruleSetSize." rules to resolve dependencies", true, IOInterface::VERBOSE);
  19290. $pool = null;
  19291. if (!$lockTransaction->getOperations()) {
  19292. $this->io->writeError('Nothing to modify in lock file');
  19293. }
  19294. $exitCode = $this->extractDevPackages($lockTransaction, $platformRepo, $aliases, $policy, $lockedRepository);
  19295. if ($exitCode !== 0) {
  19296. return $exitCode;
  19297. }
  19298. if (method_exists('Composer\Semver\CompilingMatcher', 'clear')) {
  19299. \Composer\Semver\CompilingMatcher::clear();
  19300. }
  19301. $platformReqs = $this->extractPlatformRequirements($this->package->getRequires());
  19302. $platformDevReqs = $this->extractPlatformRequirements($this->package->getDevRequires());
  19303. $installsUpdates = $uninstalls = [];
  19304. if ($lockTransaction->getOperations()) {
  19305. $installNames = $updateNames = $uninstallNames = [];
  19306. foreach ($lockTransaction->getOperations() as $operation) {
  19307. if ($operation instanceof InstallOperation) {
  19308. $installsUpdates[] = $operation;
  19309. $installNames[] = $operation->getPackage()->getPrettyName().':'.$operation->getPackage()->getFullPrettyVersion();
  19310. } elseif ($operation instanceof UpdateOperation) {
  19311. if ($this->updateMirrors
  19312. && $operation->getInitialPackage()->getName() === $operation->getTargetPackage()->getName()
  19313. && $operation->getInitialPackage()->getVersion() === $operation->getTargetPackage()->getVersion()
  19314. ) {
  19315. continue;
  19316. }
  19317. $installsUpdates[] = $operation;
  19318. $updateNames[] = $operation->getTargetPackage()->getPrettyName().':'.$operation->getTargetPackage()->getFullPrettyVersion();
  19319. } elseif ($operation instanceof UninstallOperation) {
  19320. $uninstalls[] = $operation;
  19321. $uninstallNames[] = $operation->getPackage()->getPrettyName();
  19322. }
  19323. }
  19324. if ($this->config->get('lock')) {
  19325. $this->io->writeError(sprintf(
  19326. "<info>Lock file operations: %d install%s, %d update%s, %d removal%s</info>",
  19327. count($installNames),
  19328. 1 === count($installNames) ? '' : 's',
  19329. count($updateNames),
  19330. 1 === count($updateNames) ? '' : 's',
  19331. count($uninstalls),
  19332. 1 === count($uninstalls) ? '' : 's'
  19333. ));
  19334. if ($installNames) {
  19335. $this->io->writeError("Installs: ".implode(', ', $installNames), true, IOInterface::VERBOSE);
  19336. }
  19337. if ($updateNames) {
  19338. $this->io->writeError("Updates: ".implode(', ', $updateNames), true, IOInterface::VERBOSE);
  19339. }
  19340. if ($uninstalls) {
  19341. $this->io->writeError("Removals: ".implode(', ', $uninstallNames), true, IOInterface::VERBOSE);
  19342. }
  19343. }
  19344. }
  19345. $sortByName = static function ($a, $b): int {
  19346. if ($a instanceof UpdateOperation) {
  19347. $a = $a->getTargetPackage()->getName();
  19348. } else {
  19349. $a = $a->getPackage()->getName();
  19350. }
  19351. if ($b instanceof UpdateOperation) {
  19352. $b = $b->getTargetPackage()->getName();
  19353. } else {
  19354. $b = $b->getPackage()->getName();
  19355. }
  19356. return strcmp($a, $b);
  19357. };
  19358. usort($uninstalls, $sortByName);
  19359. usort($installsUpdates, $sortByName);
  19360. foreach (array_merge($uninstalls, $installsUpdates) as $operation) {
  19361. if ($operation instanceof InstallOperation) {
  19362. $this->suggestedPackagesReporter->addSuggestionsFromPackage($operation->getPackage());
  19363. }
  19364. if ($this->config->get('lock') && (false === strpos($operation->getOperationType(), 'Alias') || $this->io->isDebug())) {
  19365. $this->io->writeError(' - ' . $operation->show(true));
  19366. }
  19367. }
  19368. $updatedLock = $this->locker->setLockData(
  19369. $lockTransaction->getNewLockPackages(false, $this->updateMirrors),
  19370. $lockTransaction->getNewLockPackages(true, $this->updateMirrors),
  19371. $platformReqs,
  19372. $platformDevReqs,
  19373. $lockTransaction->getAliases($aliases),
  19374. $this->package->getMinimumStability(),
  19375. $this->package->getStabilityFlags(),
  19376. $this->preferStable || $this->package->getPreferStable(),
  19377. $this->preferLowest,
  19378. $this->config->get('platform') ?: [],
  19379. $this->writeLock && $this->executeOperations
  19380. );
  19381. if ($updatedLock && $this->writeLock && $this->executeOperations) {
  19382. $this->io->writeError('<info>Writing lock file</info>');
  19383. }
  19384. if ($doInstall) {
  19385. return $this->doInstall($localRepo, true);
  19386. }
  19387. return 0;
  19388. }
  19389. protected function extractDevPackages(LockTransaction $lockTransaction, PlatformRepository $platformRepo, array $aliases, PolicyInterface $policy, ?LockArrayRepository $lockedRepository = null): int
  19390. {
  19391. if (!$this->package->getDevRequires()) {
  19392. return 0;
  19393. }
  19394. $resultRepo = new ArrayRepository([]);
  19395. $loader = new ArrayLoader(null, true);
  19396. $dumper = new ArrayDumper();
  19397. foreach ($lockTransaction->getNewLockPackages(false) as $pkg) {
  19398. $resultRepo->addPackage($loader->load($dumper->dump($pkg)));
  19399. }
  19400. $repositorySet = $this->createRepositorySet(true, $platformRepo, $aliases);
  19401. $repositorySet->addRepository($resultRepo);
  19402. $request = $this->createRequest($this->fixedRootPackage, $platformRepo);
  19403. $this->requirePackagesForUpdate($request, $lockedRepository, false);
  19404. $pool = $repositorySet->createPoolWithAllPackages();
  19405. $solver = new Solver($policy, $pool, $this->io);
  19406. try {
  19407. $nonDevLockTransaction = $solver->solve($request, $this->platformRequirementFilter);
  19408. $solver = null;
  19409. } catch (SolverProblemsException $e) {
  19410. $err = 'Unable to find a compatible set of packages based on your non-dev requirements alone.';
  19411. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose(), true);
  19412. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  19413. $this->io->writeError('Your requirements can be resolved successfully when require-dev packages are present.');
  19414. $this->io->writeError('You may need to move packages from require-dev or some of their dependencies to require.');
  19415. $this->io->writeError($prettyProblem);
  19416. $ghe = new GithubActionError($this->io);
  19417. $ghe->emit($err."\n".$prettyProblem);
  19418. return $e->getCode();
  19419. }
  19420. $lockTransaction->setNonDevPackages($nonDevLockTransaction);
  19421. return 0;
  19422. }
  19423. protected function doInstall(InstalledRepositoryInterface $localRepo, bool $alreadySolved = false): int
  19424. {
  19425. if ($this->config->get('lock')) {
  19426. $this->io->writeError('<info>Installing dependencies from lock file'.($this->devMode ? ' (including require-dev)' : '').'</info>');
  19427. }
  19428. $lockedRepository = $this->locker->getLockedRepository($this->devMode);
  19429. if (!$alreadySolved) {
  19430. $this->io->writeError('<info>Verifying lock file contents can be installed on current platform.</info>');
  19431. $platformRepo = $this->createPlatformRepo(false);
  19432. $policy = $this->createPolicy(false);
  19433. $repositorySet = $this->createRepositorySet(false, $platformRepo, [], $lockedRepository);
  19434. $repositorySet->addRepository($lockedRepository);
  19435. $request = $this->createRequest($this->fixedRootPackage, $platformRepo, $lockedRepository);
  19436. if (!$this->locker->isFresh()) {
  19437. $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);
  19438. }
  19439. $missingRequirementInfo = $this->locker->getMissingRequirementInfo($this->package, $this->devMode);
  19440. if ($missingRequirementInfo !== []) {
  19441. $this->io->writeError($missingRequirementInfo);
  19442. return self::ERROR_LOCK_FILE_INVALID;
  19443. }
  19444. foreach ($lockedRepository->getPackages() as $package) {
  19445. $request->fixLockedPackage($package);
  19446. }
  19447. foreach ($this->locker->getPlatformRequirements($this->devMode) as $link) {
  19448. $request->requireName($link->getTarget(), $link->getConstraint());
  19449. }
  19450. $pool = $repositorySet->createPool($request, $this->io, $this->eventDispatcher);
  19451. $solver = new Solver($policy, $pool, $this->io);
  19452. try {
  19453. $lockTransaction = $solver->solve($request, $this->platformRequirementFilter);
  19454. $solver = null;
  19455. if (0 !== count($lockTransaction->getOperations())) {
  19456. $this->io->writeError('<error>Your lock file cannot be installed on this system without changes. Please run composer update.</error>', true, IOInterface::QUIET);
  19457. return self::ERROR_LOCK_FILE_INVALID;
  19458. }
  19459. } catch (SolverProblemsException $e) {
  19460. $err = 'Your lock file does not contain a compatible set of packages. Please run composer update.';
  19461. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose());
  19462. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  19463. $this->io->writeError($prettyProblem);
  19464. $ghe = new GithubActionError($this->io);
  19465. $ghe->emit($err."\n".$prettyProblem);
  19466. return max(self::ERROR_GENERIC_FAILURE, $e->getCode());
  19467. }
  19468. }
  19469. $localRepoTransaction = new LocalRepoTransaction($lockedRepository, $localRepo);
  19470. $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_OPERATIONS_EXEC, $this->devMode, $this->executeOperations, $localRepoTransaction);
  19471. $installs = $updates = $uninstalls = [];
  19472. foreach ($localRepoTransaction->getOperations() as $operation) {
  19473. if ($operation instanceof InstallOperation) {
  19474. $installs[] = $operation->getPackage()->getPrettyName().':'.$operation->getPackage()->getFullPrettyVersion();
  19475. } elseif ($operation instanceof UpdateOperation) {
  19476. $updates[] = $operation->getTargetPackage()->getPrettyName().':'.$operation->getTargetPackage()->getFullPrettyVersion();
  19477. } elseif ($operation instanceof UninstallOperation) {
  19478. $uninstalls[] = $operation->getPackage()->getPrettyName();
  19479. }
  19480. }
  19481. if ($installs === [] && $updates === [] && $uninstalls === []) {
  19482. $this->io->writeError('Nothing to install, update or remove');
  19483. } else {
  19484. $this->io->writeError(sprintf(
  19485. "<info>Package operations: %d install%s, %d update%s, %d removal%s</info>",
  19486. count($installs),
  19487. 1 === count($installs) ? '' : 's',
  19488. count($updates),
  19489. 1 === count($updates) ? '' : 's',
  19490. count($uninstalls),
  19491. 1 === count($uninstalls) ? '' : 's'
  19492. ));
  19493. if ($installs) {
  19494. $this->io->writeError("Installs: ".implode(', ', $installs), true, IOInterface::VERBOSE);
  19495. }
  19496. if ($updates) {
  19497. $this->io->writeError("Updates: ".implode(', ', $updates), true, IOInterface::VERBOSE);
  19498. }
  19499. if ($uninstalls) {
  19500. $this->io->writeError("Removals: ".implode(', ', $uninstalls), true, IOInterface::VERBOSE);
  19501. }
  19502. }
  19503. if ($this->executeOperations) {
  19504. $localRepo->setDevPackageNames($this->locker->getDevPackageNames());
  19505. $this->installationManager->execute($localRepo, $localRepoTransaction->getOperations(), $this->devMode, $this->runScripts, $this->downloadOnly);
  19506. if (count($localRepoTransaction->getOperations()) > 0) {
  19507. $vendorDir = $this->config->get('vendor-dir');
  19508. if (is_dir($vendorDir)) {
  19509. @touch($vendorDir);
  19510. }
  19511. }
  19512. } else {
  19513. foreach ($localRepoTransaction->getOperations() as $operation) {
  19514. if (false === strpos($operation->getOperationType(), 'Alias') || $this->io->isDebug()) {
  19515. $this->io->writeError(' - ' . $operation->show(false));
  19516. }
  19517. }
  19518. }
  19519. return 0;
  19520. }
  19521. protected function createPlatformRepo(bool $forUpdate): PlatformRepository
  19522. {
  19523. if ($forUpdate) {
  19524. $platformOverrides = $this->config->get('platform') ?: [];
  19525. } else {
  19526. $platformOverrides = $this->locker->getPlatformOverrides();
  19527. }
  19528. return new PlatformRepository([], $platformOverrides);
  19529. }
  19530. private function createRepositorySet(bool $forUpdate, PlatformRepository $platformRepo, array $rootAliases = [], ?RepositoryInterface $lockedRepository = null): RepositorySet
  19531. {
  19532. if ($forUpdate) {
  19533. $minimumStability = $this->package->getMinimumStability();
  19534. $stabilityFlags = $this->package->getStabilityFlags();
  19535. $requires = array_merge($this->package->getRequires(), $this->package->getDevRequires());
  19536. } else {
  19537. $minimumStability = $this->locker->getMinimumStability();
  19538. $stabilityFlags = $this->locker->getStabilityFlags();
  19539. $requires = [];
  19540. foreach ($lockedRepository->getPackages() as $package) {
  19541. $constraint = new Constraint('=', $package->getVersion());
  19542. $constraint->setPrettyString($package->getPrettyVersion());
  19543. $requires[$package->getName()] = $constraint;
  19544. }
  19545. }
  19546. $rootRequires = [];
  19547. foreach ($requires as $req => $constraint) {
  19548. if ($constraint instanceof Link) {
  19549. $constraint = $constraint->getConstraint();
  19550. }
  19551. if ($this->platformRequirementFilter->isIgnored($req)) {
  19552. continue;
  19553. } elseif ($this->platformRequirementFilter instanceof IgnoreListPlatformRequirementFilter) {
  19554. $constraint = $this->platformRequirementFilter->filterConstraint($req, $constraint);
  19555. }
  19556. $rootRequires[$req] = $constraint;
  19557. }
  19558. $this->fixedRootPackage = clone $this->package;
  19559. $this->fixedRootPackage->setRequires([]);
  19560. $this->fixedRootPackage->setDevRequires([]);
  19561. $stabilityFlags[$this->package->getName()] = BasePackage::$stabilities[VersionParser::parseStability($this->package->getVersion())];
  19562. $repositorySet = new RepositorySet($minimumStability, $stabilityFlags, $rootAliases, $this->package->getReferences(), $rootRequires, $this->temporaryConstraints);
  19563. $repositorySet->addRepository(new RootPackageRepository($this->fixedRootPackage));
  19564. $repositorySet->addRepository($platformRepo);
  19565. if ($this->additionalFixedRepository) {
  19566. $additionalFixedRepositories = $this->additionalFixedRepository;
  19567. if ($additionalFixedRepositories instanceof CompositeRepository) {
  19568. $additionalFixedRepositories = $additionalFixedRepositories->getRepositories();
  19569. } else {
  19570. $additionalFixedRepositories = [$additionalFixedRepositories];
  19571. }
  19572. foreach ($additionalFixedRepositories as $additionalFixedRepository) {
  19573. if ($additionalFixedRepository instanceof InstalledRepository || $additionalFixedRepository instanceof InstalledRepositoryInterface) {
  19574. $repositorySet->allowInstalledRepositories();
  19575. break;
  19576. }
  19577. }
  19578. $repositorySet->addRepository($this->additionalFixedRepository);
  19579. }
  19580. return $repositorySet;
  19581. }
  19582. private function createPolicy(bool $forUpdate): DefaultPolicy
  19583. {
  19584. $preferStable = null;
  19585. $preferLowest = null;
  19586. if (!$forUpdate) {
  19587. $preferStable = $this->locker->getPreferStable();
  19588. $preferLowest = $this->locker->getPreferLowest();
  19589. }
  19590. if (null === $preferStable) {
  19591. $preferStable = $this->preferStable || $this->package->getPreferStable();
  19592. }
  19593. if (null === $preferLowest) {
  19594. $preferLowest = $this->preferLowest;
  19595. }
  19596. return new DefaultPolicy($preferStable, $preferLowest);
  19597. }
  19598. private function createRequest(RootPackageInterface $rootPackage, PlatformRepository $platformRepo, ?LockArrayRepository $lockedRepository = null): Request
  19599. {
  19600. $request = new Request($lockedRepository);
  19601. $request->fixPackage($rootPackage);
  19602. if ($rootPackage instanceof RootAliasPackage) {
  19603. $request->fixPackage($rootPackage->getAliasOf());
  19604. }
  19605. $fixedPackages = $platformRepo->getPackages();
  19606. if ($this->additionalFixedRepository) {
  19607. $fixedPackages = array_merge($fixedPackages, $this->additionalFixedRepository->getPackages());
  19608. }
  19609. $provided = $rootPackage->getProvides();
  19610. foreach ($fixedPackages as $package) {
  19611. if ($package->getRepository() !== $platformRepo
  19612. || !isset($provided[$package->getName()])
  19613. || !$provided[$package->getName()]->getConstraint()->matches(new Constraint('=', $package->getVersion()))
  19614. ) {
  19615. $request->fixPackage($package);
  19616. }
  19617. }
  19618. return $request;
  19619. }
  19620. private function requirePackagesForUpdate(Request $request, ?LockArrayRepository $lockedRepository = null, bool $includeDevRequires = true): void
  19621. {
  19622. if ($this->updateMirrors) {
  19623. $excludedPackages = [];
  19624. if (!$includeDevRequires) {
  19625. $excludedPackages = array_flip($this->locker->getDevPackageNames());
  19626. }
  19627. foreach ($lockedRepository->getPackages() as $lockedPackage) {
  19628. if (!$lockedPackage instanceof AliasPackage && !isset($excludedPackages[$lockedPackage->getName()])) {
  19629. $request->requireName($lockedPackage->getName(), new Constraint('==', $lockedPackage->getVersion()));
  19630. }
  19631. }
  19632. } else {
  19633. $links = $this->package->getRequires();
  19634. if ($includeDevRequires) {
  19635. $links = array_merge($links, $this->package->getDevRequires());
  19636. }
  19637. foreach ($links as $link) {
  19638. $request->requireName($link->getTarget(), $link->getConstraint());
  19639. }
  19640. }
  19641. }
  19642. private function getRootAliases(bool $forUpdate): array
  19643. {
  19644. if ($forUpdate) {
  19645. $aliases = $this->package->getAliases();
  19646. } else {
  19647. $aliases = $this->locker->getAliases();
  19648. }
  19649. return $aliases;
  19650. }
  19651. private function extractPlatformRequirements(array $links): array
  19652. {
  19653. $platformReqs = [];
  19654. foreach ($links as $link) {
  19655. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  19656. $platformReqs[$link->getTarget()] = $link->getPrettyConstraint();
  19657. }
  19658. }
  19659. return $platformReqs;
  19660. }
  19661. private function mockLocalRepositories(RepositoryManager $rm): void
  19662. {
  19663. $packages = [];
  19664. foreach ($rm->getLocalRepository()->getPackages() as $package) {
  19665. $packages[(string) $package] = clone $package;
  19666. }
  19667. foreach ($packages as $key => $package) {
  19668. if ($package instanceof AliasPackage) {
  19669. $alias = (string) $package->getAliasOf();
  19670. $className = get_class($package);
  19671. $packages[$key] = new $className($packages[$alias], $package->getVersion(), $package->getPrettyVersion());
  19672. }
  19673. }
  19674. $rm->setLocalRepository(
  19675. new InstalledArrayRepository($packages)
  19676. );
  19677. }
  19678. private function createPoolOptimizer(PolicyInterface $policy): ?PoolOptimizer
  19679. {
  19680. if ('0' === Platform::getEnv('COMPOSER_POOL_OPTIMIZER')) {
  19681. $this->io->write('Pool Optimizer was disabled for debugging purposes.', true, IOInterface::DEBUG);
  19682. return null;
  19683. }
  19684. return new PoolOptimizer($policy);
  19685. }
  19686. public static function create(IOInterface $io, Composer $composer): self
  19687. {
  19688. return new static(
  19689. $io,
  19690. $composer->getConfig(),
  19691. $composer->getPackage(),
  19692. $composer->getDownloadManager(),
  19693. $composer->getRepositoryManager(),
  19694. $composer->getLocker(),
  19695. $composer->getInstallationManager(),
  19696. $composer->getEventDispatcher(),
  19697. $composer->getAutoloadGenerator()
  19698. );
  19699. }
  19700. public function setAdditionalFixedRepository(RepositoryInterface $additionalFixedRepository): self
  19701. {
  19702. $this->additionalFixedRepository = $additionalFixedRepository;
  19703. return $this;
  19704. }
  19705. public function setTemporaryConstraints(array $constraints): self
  19706. {
  19707. $this->temporaryConstraints = $constraints;
  19708. return $this;
  19709. }
  19710. public function setDryRun(bool $dryRun = true): self
  19711. {
  19712. $this->dryRun = (bool) $dryRun;
  19713. return $this;
  19714. }
  19715. public function isDryRun(): bool
  19716. {
  19717. return $this->dryRun;
  19718. }
  19719. public function setDownloadOnly(bool $downloadOnly = true): self
  19720. {
  19721. $this->downloadOnly = $downloadOnly;
  19722. return $this;
  19723. }
  19724. public function setPreferSource(bool $preferSource = true): self
  19725. {
  19726. $this->preferSource = (bool) $preferSource;
  19727. return $this;
  19728. }
  19729. public function setPreferDist(bool $preferDist = true): self
  19730. {
  19731. $this->preferDist = (bool) $preferDist;
  19732. return $this;
  19733. }
  19734. public function setOptimizeAutoloader(bool $optimizeAutoloader): self
  19735. {
  19736. $this->optimizeAutoloader = (bool) $optimizeAutoloader;
  19737. if (!$this->optimizeAutoloader) {
  19738. $this->setClassMapAuthoritative(false);
  19739. }
  19740. return $this;
  19741. }
  19742. public function setClassMapAuthoritative(bool $classMapAuthoritative): self
  19743. {
  19744. $this->classMapAuthoritative = (bool) $classMapAuthoritative;
  19745. if ($this->classMapAuthoritative) {
  19746. $this->setOptimizeAutoloader(true);
  19747. }
  19748. return $this;
  19749. }
  19750. public function setApcuAutoloader(bool $apcuAutoloader, ?string $apcuAutoloaderPrefix = null): self
  19751. {
  19752. $this->apcuAutoloader = $apcuAutoloader;
  19753. $this->apcuAutoloaderPrefix = $apcuAutoloaderPrefix;
  19754. return $this;
  19755. }
  19756. public function setUpdate(bool $update): self
  19757. {
  19758. $this->update = (bool) $update;
  19759. return $this;
  19760. }
  19761. public function setInstall(bool $install): self
  19762. {
  19763. $this->install = (bool) $install;
  19764. return $this;
  19765. }
  19766. public function setDevMode(bool $devMode = true): self
  19767. {
  19768. $this->devMode = (bool) $devMode;
  19769. return $this;
  19770. }
  19771. public function setDumpAutoloader(bool $dumpAutoloader = true): self
  19772. {
  19773. $this->dumpAutoloader = (bool) $dumpAutoloader;
  19774. return $this;
  19775. }
  19776. public function setRunScripts(bool $runScripts = true): self
  19777. {
  19778. $this->runScripts = (bool) $runScripts;
  19779. return $this;
  19780. }
  19781. public function setConfig(Config $config): self
  19782. {
  19783. $this->config = $config;
  19784. return $this;
  19785. }
  19786. public function setVerbose(bool $verbose = true): self
  19787. {
  19788. $this->verbose = (bool) $verbose;
  19789. return $this;
  19790. }
  19791. public function isVerbose(): bool
  19792. {
  19793. return $this->verbose;
  19794. }
  19795. public function setIgnorePlatformRequirements($ignorePlatformReqs): self
  19796. {
  19797. trigger_error('Installer::setIgnorePlatformRequirements is deprecated since Composer 2.2, use setPlatformRequirementFilter instead.', E_USER_DEPRECATED);
  19798. return $this->setPlatformRequirementFilter(PlatformRequirementFilterFactory::fromBoolOrList($ignorePlatformReqs));
  19799. }
  19800. public function setPlatformRequirementFilter(PlatformRequirementFilterInterface $platformRequirementFilter): self
  19801. {
  19802. $this->platformRequirementFilter = $platformRequirementFilter;
  19803. return $this;
  19804. }
  19805. public function setUpdateMirrors(bool $updateMirrors): self
  19806. {
  19807. $this->updateMirrors = $updateMirrors;
  19808. return $this;
  19809. }
  19810. public function setUpdateAllowList(array $packages): self
  19811. {
  19812. if (count($packages) === 0) {
  19813. $this->updateAllowList = null;
  19814. } else {
  19815. $this->updateAllowList = array_values(array_unique(array_map('strtolower', $packages)));
  19816. }
  19817. return $this;
  19818. }
  19819. public function setUpdateAllowTransitiveDependencies(int $updateAllowTransitiveDependencies): self
  19820. {
  19821. if (!in_array($updateAllowTransitiveDependencies, [Request::UPDATE_ONLY_LISTED, Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE, Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS], true)) {
  19822. throw new \RuntimeException("Invalid value for updateAllowTransitiveDependencies supplied");
  19823. }
  19824. $this->updateAllowTransitiveDependencies = $updateAllowTransitiveDependencies;
  19825. return $this;
  19826. }
  19827. public function setPreferStable(bool $preferStable = true): self
  19828. {
  19829. $this->preferStable = (bool) $preferStable;
  19830. return $this;
  19831. }
  19832. public function setPreferLowest(bool $preferLowest = true): self
  19833. {
  19834. $this->preferLowest = (bool) $preferLowest;
  19835. return $this;
  19836. }
  19837. public function setWriteLock(bool $writeLock = true): self
  19838. {
  19839. $this->writeLock = (bool) $writeLock;
  19840. return $this;
  19841. }
  19842. public function setExecuteOperations(bool $executeOperations = true): self
  19843. {
  19844. $this->executeOperations = (bool) $executeOperations;
  19845. return $this;
  19846. }
  19847. public function setAudit(bool $audit): self
  19848. {
  19849. $this->audit = $audit;
  19850. return $this;
  19851. }
  19852. public function setErrorOnAudit(bool $errorOnAudit): self
  19853. {
  19854. $this->errorOnAudit = $errorOnAudit;
  19855. return $this;
  19856. }
  19857. public function setAuditFormat(string $auditFormat): self
  19858. {
  19859. $this->auditFormat = $auditFormat;
  19860. return $this;
  19861. }
  19862. public function disablePlugins(): self
  19863. {
  19864. $this->installationManager->disablePlugins();
  19865. return $this;
  19866. }
  19867. public function setSuggestedPackagesReporter(SuggestedPackagesReporter $suggestedPackagesReporter): self
  19868. {
  19869. $this->suggestedPackagesReporter = $suggestedPackagesReporter;
  19870. return $this;
  19871. }
  19872. }
  19873. <?php declare(strict_types=1);
  19874. namespace Composer\Installer;
  19875. use Composer\IO\IOInterface;
  19876. use Composer\Package\PackageInterface;
  19877. use Composer\Pcre\Preg;
  19878. use Composer\Util\Filesystem;
  19879. use Composer\Util\Platform;
  19880. use Composer\Util\ProcessExecutor;
  19881. use Composer\Util\Silencer;
  19882. class BinaryInstaller
  19883. {
  19884. protected $binDir;
  19885. protected $binCompat;
  19886. protected $io;
  19887. protected $filesystem;
  19888. private $vendorDir;
  19889. public function __construct(IOInterface $io, string $binDir, string $binCompat, ?Filesystem $filesystem = null, ?string $vendorDir = null)
  19890. {
  19891. $this->binDir = $binDir;
  19892. $this->binCompat = $binCompat;
  19893. $this->io = $io;
  19894. $this->filesystem = $filesystem ?: new Filesystem();
  19895. $this->vendorDir = $vendorDir;
  19896. }
  19897. public function installBinaries(PackageInterface $package, string $installPath, bool $warnOnOverwrite = true): void
  19898. {
  19899. $binaries = $this->getBinaries($package);
  19900. if (!$binaries) {
  19901. return;
  19902. }
  19903. Platform::workaroundFilesystemIssues();
  19904. foreach ($binaries as $bin) {
  19905. $binPath = $installPath.'/'.$bin;
  19906. if (!file_exists($binPath)) {
  19907. $this->io->writeError(' <warning>Skipped installation of bin '.$bin.' for package '.$package->getName().': file not found in package</warning>');
  19908. continue;
  19909. }
  19910. if (is_dir($binPath)) {
  19911. $this->io->writeError(' <warning>Skipped installation of bin '.$bin.' for package '.$package->getName().': found a directory at that path</warning>');
  19912. continue;
  19913. }
  19914. if (!$this->filesystem->isAbsolutePath($binPath)) {
  19915. $binPath = realpath($binPath);
  19916. }
  19917. $this->initializeBinDir();
  19918. $link = $this->binDir.'/'.basename($bin);
  19919. if (file_exists($link)) {
  19920. if (!is_link($link)) {
  19921. if ($warnOnOverwrite) {
  19922. $this->io->writeError(' Skipped installation of bin '.$bin.' for package '.$package->getName().': name conflicts with an existing file');
  19923. }
  19924. continue;
  19925. }
  19926. if (realpath($link) === realpath($binPath)) {
  19927. $this->filesystem->unlink($link);
  19928. }
  19929. }
  19930. $binCompat = $this->binCompat;
  19931. if ($binCompat === "auto" && (Platform::isWindows() || Platform::isWindowsSubsystemForLinux())) {
  19932. $binCompat = 'full';
  19933. }
  19934. if ($binCompat === "full") {
  19935. $this->installFullBinaries($binPath, $link, $bin, $package);
  19936. } else {
  19937. $this->installUnixyProxyBinaries($binPath, $link);
  19938. }
  19939. Silencer::call('chmod', $binPath, 0777 & ~umask());
  19940. }
  19941. }
  19942. public function removeBinaries(PackageInterface $package): void
  19943. {
  19944. $this->initializeBinDir();
  19945. $binaries = $this->getBinaries($package);
  19946. if (!$binaries) {
  19947. return;
  19948. }
  19949. foreach ($binaries as $bin) {
  19950. $link = $this->binDir.'/'.basename($bin);
  19951. if (is_link($link) || file_exists($link)) {
  19952. $this->filesystem->unlink($link);
  19953. }
  19954. if (is_file($link.'.bat')) {
  19955. $this->filesystem->unlink($link.'.bat');
  19956. }
  19957. }
  19958. if (is_dir($this->binDir) && $this->filesystem->isDirEmpty($this->binDir)) {
  19959. Silencer::call('rmdir', $this->binDir);
  19960. }
  19961. }
  19962. public static function determineBinaryCaller(string $bin): string
  19963. {
  19964. if ('.bat' === substr($bin, -4) || '.exe' === substr($bin, -4)) {
  19965. return 'call';
  19966. }
  19967. $handle = fopen($bin, 'r');
  19968. $line = fgets($handle);
  19969. fclose($handle);
  19970. if (Preg::isMatchStrictGroups('{^#!/(?:usr/bin/env )?(?:[^/]+/)*(.+)$}m', (string) $line, $match)) {
  19971. return trim($match[1]);
  19972. }
  19973. return 'php';
  19974. }
  19975. protected function getBinaries(PackageInterface $package): array
  19976. {
  19977. return $package->getBinaries();
  19978. }
  19979. protected function installFullBinaries(string $binPath, string $link, string $bin, PackageInterface $package): void
  19980. {
  19981. if ('.bat' !== substr($binPath, -4)) {
  19982. $this->installUnixyProxyBinaries($binPath, $link);
  19983. $link .= '.bat';
  19984. if (file_exists($link)) {
  19985. $this->io->writeError(' Skipped installation of bin '.$bin.'.bat proxy for package '.$package->getName().': a .bat proxy was already installed');
  19986. }
  19987. }
  19988. if (!file_exists($link)) {
  19989. file_put_contents($link, $this->generateWindowsProxyCode($binPath, $link));
  19990. Silencer::call('chmod', $link, 0777 & ~umask());
  19991. }
  19992. }
  19993. protected function installUnixyProxyBinaries(string $binPath, string $link): void
  19994. {
  19995. file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
  19996. Silencer::call('chmod', $link, 0777 & ~umask());
  19997. }
  19998. protected function initializeBinDir(): void
  19999. {
  20000. $this->filesystem->ensureDirectoryExists($this->binDir);
  20001. $this->binDir = realpath($this->binDir);
  20002. }
  20003. protected function generateWindowsProxyCode(string $bin, string $link): string
  20004. {
  20005. $binPath = $this->filesystem->findShortestPath($link, $bin);
  20006. $caller = self::determineBinaryCaller($bin);
  20007. if ($caller === 'php') {
  20008. return "@ECHO OFF\r\n".
  20009. "setlocal DISABLEDELAYEDEXPANSION\r\n".
  20010. "SET BIN_TARGET=%~dp0/".trim(ProcessExecutor::escape(basename($link, '.bat')), '"\'')."\r\n".
  20011. "SET COMPOSER_RUNTIME_BIN_DIR=%~dp0\r\n".
  20012. "{$caller} \"%BIN_TARGET%\" %*\r\n";
  20013. }
  20014. return "@ECHO OFF\r\n".
  20015. "setlocal DISABLEDELAYEDEXPANSION\r\n".
  20016. "SET BIN_TARGET=%~dp0/".trim(ProcessExecutor::escape($binPath), '"\'')."\r\n".
  20017. "SET COMPOSER_RUNTIME_BIN_DIR=%~dp0\r\n".
  20018. "{$caller} \"%BIN_TARGET%\" %*\r\n";
  20019. }
  20020. protected function generateUnixyProxyCode(string $bin, string $link): string
  20021. {
  20022. $binPath = $this->filesystem->findShortestPath($link, $bin);
  20023. $binDir = ProcessExecutor::escape(dirname($binPath));
  20024. $binFile = basename($binPath);
  20025. $binContents = file_get_contents($bin);
  20026. if (Preg::isMatch('{^(#!.*\r?\n)?[\r\n\t ]*<\?php}', $binContents, $match)) {
  20027. $proxyCode = $match[1] === null ? '#!/usr/bin/env php' : trim($match[1]);
  20028. $binPathExported = $this->filesystem->findShortestPathCode($link, $bin, false, true);
  20029. $streamProxyCode = $streamHint = '';
  20030. $globalsCode = '$GLOBALS[\'_composer_bin_dir\'] = __DIR__;'."\n";
  20031. $phpunitHack1 = $phpunitHack2 = '';
  20032. if ($this->vendorDir) {
  20033. $globalsCode .= '$GLOBALS[\'_composer_autoload_path\'] = ' . $this->filesystem->findShortestPathCode($link, $this->vendorDir . '/autoload.php', false, true).";\n";
  20034. }
  20035. if ($this->filesystem->normalizePath($bin) === $this->filesystem->normalizePath($this->vendorDir.'/phpunit/phpunit/phpunit')) {
  20036. $globalsCode .= '$GLOBALS[\'__PHPUNIT_ISOLATION_EXCLUDE_LIST\'] = $GLOBALS[\'__PHPUNIT_ISOLATION_BLACKLIST\'] = array(realpath('.$binPathExported.'));'."\n";
  20037. $phpunitHack1 = "'phpvfscomposer://'.";
  20038. $phpunitHack2 = '
  20039. $data = str_replace(\'__DIR__\', var_export(dirname($this->realpath), true), $data);
  20040. $data = str_replace(\'__FILE__\', var_export($this->realpath, true), $data);';
  20041. }
  20042. if (trim((string) $match[0]) !== '<?php') {
  20043. $streamHint = ' using a stream wrapper to prevent the shebang from being output on PHP<8'."\n *";
  20044. $streamProxyCode = <<<STREAMPROXY
  20045. if (PHP_VERSION_ID < 80000) {
  20046. if (!class_exists('Composer\BinProxyWrapper')) {
  20047. /**
  20048. * @internal
  20049. */
  20050. final class BinProxyWrapper
  20051. {
  20052. private \$handle;
  20053. private \$position;
  20054. private \$realpath;
  20055. public function stream_open(\$path, \$mode, \$options, &\$opened_path)
  20056. {
  20057. // get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution
  20058. \$opened_path = substr(\$path, 17);
  20059. \$this->realpath = realpath(\$opened_path) ?: \$opened_path;
  20060. \$opened_path = $phpunitHack1\$this->realpath;
  20061. \$this->handle = fopen(\$this->realpath, \$mode);
  20062. \$this->position = 0;
  20063. return (bool) \$this->handle;
  20064. }
  20065. public function stream_read(\$count)
  20066. {
  20067. \$data = fread(\$this->handle, \$count);
  20068. if (\$this->position === 0) {
  20069. \$data = preg_replace('{^#!.*\\r?\\n}', '', \$data);
  20070. }$phpunitHack2
  20071. \$this->position += strlen(\$data);
  20072. return \$data;
  20073. }
  20074. public function stream_cast(\$castAs)
  20075. {
  20076. return \$this->handle;
  20077. }
  20078. public function stream_close()
  20079. {
  20080. fclose(\$this->handle);
  20081. }
  20082. public function stream_lock(\$operation)
  20083. {
  20084. return \$operation ? flock(\$this->handle, \$operation) : true;
  20085. }
  20086. public function stream_seek(\$offset, \$whence)
  20087. {
  20088. if (0 === fseek(\$this->handle, \$offset, \$whence)) {
  20089. \$this->position = ftell(\$this->handle);
  20090. return true;
  20091. }
  20092. return false;
  20093. }
  20094. public function stream_tell()
  20095. {
  20096. return \$this->position;
  20097. }
  20098. public function stream_eof()
  20099. {
  20100. return feof(\$this->handle);
  20101. }
  20102. public function stream_stat()
  20103. {
  20104. return array();
  20105. }
  20106. public function stream_set_option(\$option, \$arg1, \$arg2)
  20107. {
  20108. return true;
  20109. }
  20110. public function url_stat(\$path, \$flags)
  20111. {
  20112. \$path = substr(\$path, 17);
  20113. if (file_exists(\$path)) {
  20114. return stat(\$path);
  20115. }
  20116. return false;
  20117. }
  20118. }
  20119. }
  20120. if (
  20121. (function_exists('stream_get_wrappers') && in_array('phpvfscomposer', stream_get_wrappers(), true))
  20122. || (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper'))
  20123. ) {
  20124. return include("phpvfscomposer://" . $binPathExported);
  20125. }
  20126. }
  20127. STREAMPROXY;
  20128. }
  20129. return $proxyCode . "\n" . <<<PROXY
  20130. <?php
  20131. /**
  20132. * Proxy PHP file generated by Composer
  20133. *
  20134. * This file includes the referenced bin path ($binPath)
  20135. *$streamHint
  20136. * @generated
  20137. */
  20138. namespace Composer;
  20139. $globalsCode
  20140. $streamProxyCode
  20141. return include $binPathExported;
  20142. PROXY;
  20143. }
  20144. return <<<PROXY
  20145. #!/usr/bin/env sh
  20146. # Support bash to support `source` with fallback on $0 if this does not run with bash
  20147. # https://stackoverflow.com/a/35006505/6512
  20148. selfArg="\$BASH_SOURCE"
  20149. if [ -z "\$selfArg" ]; then
  20150. selfArg="\$0"
  20151. fi
  20152. self=\$(realpath \$selfArg 2> /dev/null)
  20153. if [ -z "\$self" ]; then
  20154. self="\$selfArg"
  20155. fi
  20156. dir=\$(cd "\${self%[/\\\\]*}" > /dev/null; cd $binDir && pwd)
  20157. if [ -d /proc/cygdrive ]; then
  20158. case \$(which php) in
  20159. \$(readlink -n /proc/cygdrive)/*)
  20160. # We are in Cygwin using Windows php, so the path must be translated
  20161. dir=\$(cygpath -m "\$dir");
  20162. ;;
  20163. esac
  20164. fi
  20165. export COMPOSER_RUNTIME_BIN_DIR="\$(cd "\${self%[/\\\\]*}" > /dev/null; pwd)"
  20166. # If bash is sourcing this file, we have to source the target as well
  20167. bashSource="\$BASH_SOURCE"
  20168. if [ -n "\$bashSource" ]; then
  20169. if [ "\$bashSource" != "\$0" ]; then
  20170. source "\${dir}/$binFile" "\$@"
  20171. return
  20172. fi
  20173. fi
  20174. "\${dir}/$binFile" "\$@"
  20175. PROXY;
  20176. }
  20177. }
  20178. <?php declare(strict_types=1);
  20179. namespace Composer\Installer;
  20180. use Composer\Package\PackageInterface;
  20181. interface BinaryPresenceInterface
  20182. {
  20183. public function ensureBinariesPresence(PackageInterface $package);
  20184. }
  20185. <?php declare(strict_types=1);
  20186. namespace Composer\Installer;
  20187. use Composer\IO\IOInterface;
  20188. use Composer\IO\ConsoleIO;
  20189. use Composer\Package\PackageInterface;
  20190. use Composer\Package\AliasPackage;
  20191. use Composer\Repository\InstalledRepositoryInterface;
  20192. use Composer\DependencyResolver\Operation\OperationInterface;
  20193. use Composer\DependencyResolver\Operation\InstallOperation;
  20194. use Composer\DependencyResolver\Operation\UpdateOperation;
  20195. use Composer\DependencyResolver\Operation\UninstallOperation;
  20196. use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation;
  20197. use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
  20198. use Composer\Downloader\FileDownloader;
  20199. use Composer\EventDispatcher\EventDispatcher;
  20200. use Composer\Util\Loop;
  20201. use Composer\Util\Platform;
  20202. use React\Promise\PromiseInterface;
  20203. use Seld\Signal\SignalHandler;
  20204. class InstallationManager
  20205. {
  20206. private $installers = [];
  20207. private $cache = [];
  20208. private $notifiablePackages = [];
  20209. private $loop;
  20210. private $io;
  20211. private $eventDispatcher;
  20212. private $outputProgress;
  20213. public function __construct(Loop $loop, IOInterface $io, ?EventDispatcher $eventDispatcher = null)
  20214. {
  20215. $this->loop = $loop;
  20216. $this->io = $io;
  20217. $this->eventDispatcher = $eventDispatcher;
  20218. }
  20219. public function reset(): void
  20220. {
  20221. $this->notifiablePackages = [];
  20222. FileDownloader::$downloadMetadata = [];
  20223. }
  20224. public function addInstaller(InstallerInterface $installer): void
  20225. {
  20226. array_unshift($this->installers, $installer);
  20227. $this->cache = [];
  20228. }
  20229. public function removeInstaller(InstallerInterface $installer): void
  20230. {
  20231. if (false !== ($key = array_search($installer, $this->installers, true))) {
  20232. array_splice($this->installers, $key, 1);
  20233. $this->cache = [];
  20234. }
  20235. }
  20236. public function disablePlugins(): void
  20237. {
  20238. foreach ($this->installers as $i => $installer) {
  20239. if (!$installer instanceof PluginInstaller) {
  20240. continue;
  20241. }
  20242. unset($this->installers[$i]);
  20243. }
  20244. }
  20245. public function getInstaller(string $type): InstallerInterface
  20246. {
  20247. $type = strtolower($type);
  20248. if (isset($this->cache[$type])) {
  20249. return $this->cache[$type];
  20250. }
  20251. foreach ($this->installers as $installer) {
  20252. if ($installer->supports($type)) {
  20253. return $this->cache[$type] = $installer;
  20254. }
  20255. }
  20256. throw new \InvalidArgumentException('Unknown installer type: '.$type);
  20257. }
  20258. public function isPackageInstalled(InstalledRepositoryInterface $repo, PackageInterface $package): bool
  20259. {
  20260. if ($package instanceof AliasPackage) {
  20261. return $repo->hasPackage($package) && $this->isPackageInstalled($repo, $package->getAliasOf());
  20262. }
  20263. return $this->getInstaller($package->getType())->isInstalled($repo, $package);
  20264. }
  20265. public function ensureBinariesPresence(PackageInterface $package): void
  20266. {
  20267. try {
  20268. $installer = $this->getInstaller($package->getType());
  20269. } catch (\InvalidArgumentException $e) {
  20270. return;
  20271. }
  20272. if ($installer instanceof BinaryPresenceInterface) {
  20273. $installer->ensureBinariesPresence($package);
  20274. }
  20275. }
  20276. public function execute(InstalledRepositoryInterface $repo, array $operations, bool $devMode = true, bool $runScripts = true, bool $downloadOnly = false): void
  20277. {
  20278. $cleanupPromises = [];
  20279. $signalHandler = SignalHandler::create([SignalHandler::SIGINT, SignalHandler::SIGTERM, SignalHandler::SIGHUP], function (string $signal, SignalHandler $handler) use (&$cleanupPromises) {
  20280. $this->io->writeError('Received '.$signal.', aborting', true, IOInterface::DEBUG);
  20281. $this->runCleanup($cleanupPromises);
  20282. $handler->exitWithLastSignal();
  20283. });
  20284. try {
  20285. $batches = [];
  20286. $batch = [];
  20287. foreach ($operations as $index => $operation) {
  20288. if ($operation instanceof UpdateOperation || $operation instanceof InstallOperation) {
  20289. $package = $operation instanceof UpdateOperation ? $operation->getTargetPackage() : $operation->getPackage();
  20290. if ($package->getType() === 'composer-plugin' && ($extra = $package->getExtra()) && isset($extra['plugin-modifies-downloads']) && $extra['plugin-modifies-downloads'] === true) {
  20291. if ($batch) {
  20292. $batches[] = $batch;
  20293. }
  20294. $batches[] = [$index => $operation];
  20295. $batch = [];
  20296. continue;
  20297. }
  20298. }
  20299. $batch[$index] = $operation;
  20300. }
  20301. if ($batch) {
  20302. $batches[] = $batch;
  20303. }
  20304. foreach ($batches as $batch) {
  20305. $this->downloadAndExecuteBatch($repo, $batch, $cleanupPromises, $devMode, $runScripts, $downloadOnly, $operations);
  20306. }
  20307. } catch (\Exception $e) {
  20308. $this->runCleanup($cleanupPromises);
  20309. throw $e;
  20310. } finally {
  20311. $signalHandler->unregister();
  20312. }
  20313. if ($downloadOnly) {
  20314. return;
  20315. }
  20316. $repo->write($devMode, $this);
  20317. }
  20318. private function downloadAndExecuteBatch(InstalledRepositoryInterface $repo, array $operations, array &$cleanupPromises, bool $devMode, bool $runScripts, bool $downloadOnly, array $allOperations): void
  20319. {
  20320. $promises = [];
  20321. foreach ($operations as $index => $operation) {
  20322. $opType = $operation->getOperationType();
  20323. if (!in_array($opType, ['update', 'install', 'uninstall'])) {
  20324. continue;
  20325. }
  20326. if ($opType === 'update') {
  20327. $package = $operation->getTargetPackage();
  20328. $initialPackage = $operation->getInitialPackage();
  20329. } else {
  20330. $package = $operation->getPackage();
  20331. $initialPackage = null;
  20332. }
  20333. $installer = $this->getInstaller($package->getType());
  20334. $cleanupPromises[$index] = static function () use ($opType, $installer, $package, $initialPackage): ?PromiseInterface {
  20335. if (!$package->getInstallationSource()) {
  20336. return \React\Promise\resolve(null);
  20337. }
  20338. return $installer->cleanup($opType, $package, $initialPackage);
  20339. };
  20340. if ($opType !== 'uninstall') {
  20341. $promise = $installer->download($package, $initialPackage);
  20342. if (null !== $promise) {
  20343. $promises[] = $promise;
  20344. }
  20345. }
  20346. }
  20347. if (count($promises)) {
  20348. $this->waitOnPromises($promises);
  20349. }
  20350. if ($downloadOnly) {
  20351. $this->runCleanup($cleanupPromises);
  20352. return;
  20353. }
  20354. $batches = [];
  20355. $batch = [];
  20356. foreach ($operations as $index => $operation) {
  20357. if ($operation instanceof InstallOperation || $operation instanceof UpdateOperation) {
  20358. $package = $operation instanceof UpdateOperation ? $operation->getTargetPackage() : $operation->getPackage();
  20359. if ($package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer') {
  20360. if ($batch) {
  20361. $batches[] = $batch;
  20362. }
  20363. $batches[] = [$index => $operation];
  20364. $batch = [];
  20365. continue;
  20366. }
  20367. }
  20368. $batch[$index] = $operation;
  20369. }
  20370. if ($batch) {
  20371. $batches[] = $batch;
  20372. }
  20373. foreach ($batches as $batch) {
  20374. $this->executeBatch($repo, $batch, $cleanupPromises, $devMode, $runScripts, $allOperations);
  20375. }
  20376. }
  20377. private function executeBatch(InstalledRepositoryInterface $repo, array $operations, array $cleanupPromises, bool $devMode, bool $runScripts, array $allOperations): void
  20378. {
  20379. $promises = [];
  20380. $postExecCallbacks = [];
  20381. foreach ($operations as $index => $operation) {
  20382. $opType = $operation->getOperationType();
  20383. if (!in_array($opType, ['update', 'install', 'uninstall'])) {
  20384. if ($this->io->isDebug()) {
  20385. $this->io->writeError(' - ' . $operation->show(false));
  20386. }
  20387. $this->{$opType}($repo, $operation);
  20388. continue;
  20389. }
  20390. if ($opType === 'update') {
  20391. $package = $operation->getTargetPackage();
  20392. $initialPackage = $operation->getInitialPackage();
  20393. } else {
  20394. $package = $operation->getPackage();
  20395. $initialPackage = null;
  20396. }
  20397. $installer = $this->getInstaller($package->getType());
  20398. $eventName = [
  20399. 'install' => PackageEvents::PRE_PACKAGE_INSTALL,
  20400. 'update' => PackageEvents::PRE_PACKAGE_UPDATE,
  20401. 'uninstall' => PackageEvents::PRE_PACKAGE_UNINSTALL,
  20402. ][$opType] ?? null;
  20403. if (null !== $eventName && $runScripts && $this->eventDispatcher) {
  20404. $this->eventDispatcher->dispatchPackageEvent($eventName, $devMode, $repo, $allOperations, $operation);
  20405. }
  20406. $dispatcher = $this->eventDispatcher;
  20407. $io = $this->io;
  20408. $promise = $installer->prepare($opType, $package, $initialPackage);
  20409. if (!$promise instanceof PromiseInterface) {
  20410. $promise = \React\Promise\resolve(null);
  20411. }
  20412. $promise = $promise->then(function () use ($opType, $repo, $operation) {
  20413. return $this->{$opType}($repo, $operation);
  20414. })->then($cleanupPromises[$index])
  20415. ->then(function () use ($devMode, $repo): void {
  20416. $repo->write($devMode, $this);
  20417. }, static function ($e) use ($opType, $package, $io): void {
  20418. $io->writeError(' <error>' . ucfirst($opType) .' of '.$package->getPrettyName().' failed</error>');
  20419. throw $e;
  20420. });
  20421. $eventName = [
  20422. 'install' => PackageEvents::POST_PACKAGE_INSTALL,
  20423. 'update' => PackageEvents::POST_PACKAGE_UPDATE,
  20424. 'uninstall' => PackageEvents::POST_PACKAGE_UNINSTALL,
  20425. ][$opType] ?? null;
  20426. if (null !== $eventName && $runScripts && $dispatcher) {
  20427. $postExecCallbacks[] = static function () use ($dispatcher, $eventName, $devMode, $repo, $allOperations, $operation): void {
  20428. $dispatcher->dispatchPackageEvent($eventName, $devMode, $repo, $allOperations, $operation);
  20429. };
  20430. }
  20431. $promises[] = $promise;
  20432. }
  20433. if (count($promises)) {
  20434. $this->waitOnPromises($promises);
  20435. }
  20436. Platform::workaroundFilesystemIssues();
  20437. foreach ($postExecCallbacks as $cb) {
  20438. $cb();
  20439. }
  20440. }
  20441. private function waitOnPromises(array $promises): void
  20442. {
  20443. $progress = null;
  20444. if (
  20445. $this->outputProgress
  20446. && $this->io instanceof ConsoleIO
  20447. && !Platform::getEnv('CI')
  20448. && !$this->io->isDebug()
  20449. && count($promises) > 1
  20450. ) {
  20451. $progress = $this->io->getProgressBar();
  20452. }
  20453. $this->loop->wait($promises, $progress);
  20454. if ($progress) {
  20455. $progress->clear();
  20456. if (!$this->io->isDecorated()) {
  20457. $this->io->writeError('');
  20458. }
  20459. }
  20460. }
  20461. public function download(PackageInterface $package): ?PromiseInterface
  20462. {
  20463. $installer = $this->getInstaller($package->getType());
  20464. $promise = $installer->cleanup("install", $package);
  20465. return $promise;
  20466. }
  20467. public function install(InstalledRepositoryInterface $repo, InstallOperation $operation): ?PromiseInterface
  20468. {
  20469. $package = $operation->getPackage();
  20470. $installer = $this->getInstaller($package->getType());
  20471. $promise = $installer->install($repo, $package);
  20472. $this->markForNotification($package);
  20473. return $promise;
  20474. }
  20475. public function update(InstalledRepositoryInterface $repo, UpdateOperation $operation): ?PromiseInterface
  20476. {
  20477. $initial = $operation->getInitialPackage();
  20478. $target = $operation->getTargetPackage();
  20479. $initialType = $initial->getType();
  20480. $targetType = $target->getType();
  20481. if ($initialType === $targetType) {
  20482. $installer = $this->getInstaller($initialType);
  20483. $promise = $installer->update($repo, $initial, $target);
  20484. $this->markForNotification($target);
  20485. } else {
  20486. $promise = $this->getInstaller($initialType)->uninstall($repo, $initial);
  20487. if (!$promise instanceof PromiseInterface) {
  20488. $promise = \React\Promise\resolve(null);
  20489. }
  20490. $installer = $this->getInstaller($targetType);
  20491. $promise = $promise->then(static function () use ($installer, $repo, $target): PromiseInterface {
  20492. $promise = $installer->install($repo, $target);
  20493. if ($promise instanceof PromiseInterface) {
  20494. return $promise;
  20495. }
  20496. return \React\Promise\resolve(null);
  20497. });
  20498. }
  20499. return $promise;
  20500. }
  20501. public function uninstall(InstalledRepositoryInterface $repo, UninstallOperation $operation): ?PromiseInterface
  20502. {
  20503. $package = $operation->getPackage();
  20504. $installer = $this->getInstaller($package->getType());
  20505. return $installer->uninstall($repo, $package);
  20506. }
  20507. public function markAliasInstalled(InstalledRepositoryInterface $repo, MarkAliasInstalledOperation $operation): void
  20508. {
  20509. $package = $operation->getPackage();
  20510. if (!$repo->hasPackage($package)) {
  20511. $repo->addPackage(clone $package);
  20512. }
  20513. }
  20514. public function markAliasUninstalled(InstalledRepositoryInterface $repo, MarkAliasUninstalledOperation $operation): void
  20515. {
  20516. $package = $operation->getPackage();
  20517. $repo->removePackage($package);
  20518. }
  20519. public function getInstallPath(PackageInterface $package): ?string
  20520. {
  20521. $installer = $this->getInstaller($package->getType());
  20522. return $installer->getInstallPath($package);
  20523. }
  20524. public function setOutputProgress(bool $outputProgress): void
  20525. {
  20526. $this->outputProgress = $outputProgress;
  20527. }
  20528. public function notifyInstalls(IOInterface $io): void
  20529. {
  20530. $promises = [];
  20531. try {
  20532. foreach ($this->notifiablePackages as $repoUrl => $packages) {
  20533. if (strpos($repoUrl, '%package%')) {
  20534. foreach ($packages as $package) {
  20535. $url = str_replace('%package%', $package->getPrettyName(), $repoUrl);
  20536. $params = [
  20537. 'version' => $package->getPrettyVersion(),
  20538. 'version_normalized' => $package->getVersion(),
  20539. ];
  20540. $opts = [
  20541. 'retry-auth-failure' => false,
  20542. 'http' => [
  20543. 'method' => 'POST',
  20544. 'header' => ['Content-type: application/x-www-form-urlencoded'],
  20545. 'content' => http_build_query($params, '', '&'),
  20546. 'timeout' => 3,
  20547. ],
  20548. ];
  20549. $promises[] = $this->loop->getHttpDownloader()->add($url, $opts);
  20550. }
  20551. continue;
  20552. }
  20553. $postData = ['downloads' => []];
  20554. foreach ($packages as $package) {
  20555. $packageNotification = [
  20556. 'name' => $package->getPrettyName(),
  20557. 'version' => $package->getVersion(),
  20558. ];
  20559. if (strpos($repoUrl, 'packagist.org/') !== false) {
  20560. if (isset(FileDownloader::$downloadMetadata[$package->getName()])) {
  20561. $packageNotification['downloaded'] = FileDownloader::$downloadMetadata[$package->getName()];
  20562. } else {
  20563. $packageNotification['downloaded'] = false;
  20564. }
  20565. }
  20566. $postData['downloads'][] = $packageNotification;
  20567. }
  20568. $opts = [
  20569. 'retry-auth-failure' => false,
  20570. 'http' => [
  20571. 'method' => 'POST',
  20572. 'header' => ['Content-Type: application/json'],
  20573. 'content' => json_encode($postData),
  20574. 'timeout' => 6,
  20575. ],
  20576. ];
  20577. $promises[] = $this->loop->getHttpDownloader()->add($repoUrl, $opts);
  20578. }
  20579. $this->loop->wait($promises);
  20580. } catch (\Exception $e) {
  20581. }
  20582. $this->reset();
  20583. }
  20584. private function markForNotification(PackageInterface $package): void
  20585. {
  20586. if ($package->getNotificationUrl()) {
  20587. $this->notifiablePackages[$package->getNotificationUrl()][$package->getName()] = $package;
  20588. }
  20589. }
  20590. private function runCleanup(array $cleanupPromises): void
  20591. {
  20592. $promises = [];
  20593. $this->loop->abortJobs();
  20594. foreach ($cleanupPromises as $cleanup) {
  20595. $promises[] = new \React\Promise\Promise(static function ($resolve) use ($cleanup): void {
  20596. $promise = $cleanup();
  20597. if (!$promise instanceof PromiseInterface) {
  20598. $resolve(null);
  20599. } else {
  20600. $promise->then(static function () use ($resolve): void {
  20601. $resolve(null);
  20602. });
  20603. }
  20604. });
  20605. }
  20606. if (!empty($promises)) {
  20607. $this->loop->wait($promises);
  20608. }
  20609. }
  20610. }
  20611. <?php declare(strict_types=1);
  20612. namespace Composer\Installer;
  20613. use Composer\Composer;
  20614. use Composer\DependencyResolver\Transaction;
  20615. use Composer\EventDispatcher\Event;
  20616. use Composer\IO\IOInterface;
  20617. class InstallerEvent extends Event
  20618. {
  20619. private $composer;
  20620. private $io;
  20621. private $devMode;
  20622. private $executeOperations;
  20623. private $transaction;
  20624. public function __construct(string $eventName, Composer $composer, IOInterface $io, bool $devMode, bool $executeOperations, Transaction $transaction)
  20625. {
  20626. parent::__construct($eventName);
  20627. $this->composer = $composer;
  20628. $this->io = $io;
  20629. $this->devMode = $devMode;
  20630. $this->executeOperations = $executeOperations;
  20631. $this->transaction = $transaction;
  20632. }
  20633. public function getComposer(): Composer
  20634. {
  20635. return $this->composer;
  20636. }
  20637. public function getIO(): IOInterface
  20638. {
  20639. return $this->io;
  20640. }
  20641. public function isDevMode(): bool
  20642. {
  20643. return $this->devMode;
  20644. }
  20645. public function isExecutingOperations(): bool
  20646. {
  20647. return $this->executeOperations;
  20648. }
  20649. public function getTransaction(): ?Transaction
  20650. {
  20651. return $this->transaction;
  20652. }
  20653. }
  20654. <?php declare(strict_types=1);
  20655. namespace Composer\Installer;
  20656. class InstallerEvents
  20657. {
  20658. public const PRE_OPERATIONS_EXEC = 'pre-operations-exec';
  20659. }
  20660. <?php declare(strict_types=1);
  20661. namespace Composer\Installer;
  20662. use Composer\Package\PackageInterface;
  20663. use Composer\Repository\InstalledRepositoryInterface;
  20664. use InvalidArgumentException;
  20665. use React\Promise\PromiseInterface;
  20666. interface InstallerInterface
  20667. {
  20668. public function supports(string $packageType);
  20669. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package);
  20670. public function download(PackageInterface $package, ?PackageInterface $prevPackage = null);
  20671. public function prepare(string $type, PackageInterface $package, ?PackageInterface $prevPackage = null);
  20672. public function install(InstalledRepositoryInterface $repo, PackageInterface $package);
  20673. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target);
  20674. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package);
  20675. public function cleanup(string $type, PackageInterface $package, ?PackageInterface $prevPackage = null);
  20676. public function getInstallPath(PackageInterface $package);
  20677. }
  20678. <?php declare(strict_types=1);
  20679. namespace Composer\Installer;
  20680. use Composer\Composer;
  20681. use Composer\IO\IOInterface;
  20682. use Composer\PartialComposer;
  20683. use Composer\Pcre\Preg;
  20684. use Composer\Repository\InstalledRepositoryInterface;
  20685. use Composer\Package\PackageInterface;
  20686. use Composer\Util\Filesystem;
  20687. use Composer\Util\Silencer;
  20688. use Composer\Util\Platform;
  20689. use React\Promise\PromiseInterface;
  20690. use Composer\Downloader\DownloadManager;
  20691. class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
  20692. {
  20693. protected $composer;
  20694. protected $vendorDir;
  20695. protected $downloadManager;
  20696. protected $io;
  20697. protected $type;
  20698. protected $filesystem;
  20699. protected $binaryInstaller;
  20700. public function __construct(IOInterface $io, PartialComposer $composer, ?string $type = 'library', ?Filesystem $filesystem = null, ?BinaryInstaller $binaryInstaller = null)
  20701. {
  20702. $this->composer = $composer;
  20703. $this->downloadManager = $composer instanceof Composer ? $composer->getDownloadManager() : null;
  20704. $this->io = $io;
  20705. $this->type = $type;
  20706. $this->filesystem = $filesystem ?: new Filesystem();
  20707. $this->vendorDir = rtrim($composer->getConfig()->get('vendor-dir'), '/');
  20708. $this->binaryInstaller = $binaryInstaller ?: new BinaryInstaller($this->io, rtrim($composer->getConfig()->get('bin-dir'), '/'), $composer->getConfig()->get('bin-compat'), $this->filesystem, $this->vendorDir);
  20709. }
  20710. public function supports(string $packageType)
  20711. {
  20712. return $packageType === $this->type || null === $this->type;
  20713. }
  20714. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  20715. {
  20716. if (!$repo->hasPackage($package)) {
  20717. return false;
  20718. }
  20719. $installPath = $this->getInstallPath($package);
  20720. if (Filesystem::isReadable($installPath)) {
  20721. return true;
  20722. }
  20723. if (Platform::isWindows() && $this->filesystem->isJunction($installPath)) {
  20724. return true;
  20725. }
  20726. if (is_link($installPath)) {
  20727. if (realpath($installPath) === false) {
  20728. return false;
  20729. }
  20730. return true;
  20731. }
  20732. return false;
  20733. }
  20734. public function download(PackageInterface $package, ?PackageInterface $prevPackage = null)
  20735. {
  20736. $this->initializeVendorDir();
  20737. $downloadPath = $this->getInstallPath($package);
  20738. return $this->getDownloadManager()->download($package, $downloadPath, $prevPackage);
  20739. }
  20740. public function prepare($type, PackageInterface $package, ?PackageInterface $prevPackage = null)
  20741. {
  20742. $this->initializeVendorDir();
  20743. $downloadPath = $this->getInstallPath($package);
  20744. return $this->getDownloadManager()->prepare($type, $package, $downloadPath, $prevPackage);
  20745. }
  20746. public function cleanup($type, PackageInterface $package, ?PackageInterface $prevPackage = null)
  20747. {
  20748. $this->initializeVendorDir();
  20749. $downloadPath = $this->getInstallPath($package);
  20750. return $this->getDownloadManager()->cleanup($type, $package, $downloadPath, $prevPackage);
  20751. }
  20752. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  20753. {
  20754. $this->initializeVendorDir();
  20755. $downloadPath = $this->getInstallPath($package);
  20756. if (!Filesystem::isReadable($downloadPath) && $repo->hasPackage($package)) {
  20757. $this->binaryInstaller->removeBinaries($package);
  20758. }
  20759. $promise = $this->installCode($package);
  20760. if (!$promise instanceof PromiseInterface) {
  20761. $promise = \React\Promise\resolve(null);
  20762. }
  20763. $binaryInstaller = $this->binaryInstaller;
  20764. $installPath = $this->getInstallPath($package);
  20765. return $promise->then(static function () use ($binaryInstaller, $installPath, $package, $repo): void {
  20766. $binaryInstaller->installBinaries($package, $installPath);
  20767. if (!$repo->hasPackage($package)) {
  20768. $repo->addPackage(clone $package);
  20769. }
  20770. });
  20771. }
  20772. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  20773. {
  20774. if (!$repo->hasPackage($initial)) {
  20775. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  20776. }
  20777. $this->initializeVendorDir();
  20778. $this->binaryInstaller->removeBinaries($initial);
  20779. $promise = $this->updateCode($initial, $target);
  20780. if (!$promise instanceof PromiseInterface) {
  20781. $promise = \React\Promise\resolve(null);
  20782. }
  20783. $binaryInstaller = $this->binaryInstaller;
  20784. $installPath = $this->getInstallPath($target);
  20785. return $promise->then(static function () use ($binaryInstaller, $installPath, $target, $initial, $repo): void {
  20786. $binaryInstaller->installBinaries($target, $installPath);
  20787. $repo->removePackage($initial);
  20788. if (!$repo->hasPackage($target)) {
  20789. $repo->addPackage(clone $target);
  20790. }
  20791. });
  20792. }
  20793. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  20794. {
  20795. if (!$repo->hasPackage($package)) {
  20796. throw new \InvalidArgumentException('Package is not installed: '.$package);
  20797. }
  20798. $promise = $this->removeCode($package);
  20799. if (!$promise instanceof PromiseInterface) {
  20800. $promise = \React\Promise\resolve(null);
  20801. }
  20802. $binaryInstaller = $this->binaryInstaller;
  20803. $downloadPath = $this->getPackageBasePath($package);
  20804. $filesystem = $this->filesystem;
  20805. return $promise->then(static function () use ($binaryInstaller, $filesystem, $downloadPath, $package, $repo): void {
  20806. $binaryInstaller->removeBinaries($package);
  20807. $repo->removePackage($package);
  20808. if (strpos($package->getName(), '/')) {
  20809. $packageVendorDir = dirname($downloadPath);
  20810. if (is_dir($packageVendorDir) && $filesystem->isDirEmpty($packageVendorDir)) {
  20811. Silencer::call('rmdir', $packageVendorDir);
  20812. }
  20813. }
  20814. });
  20815. }
  20816. public function getInstallPath(PackageInterface $package)
  20817. {
  20818. $this->initializeVendorDir();
  20819. $basePath = ($this->vendorDir ? $this->vendorDir.'/' : '') . $package->getPrettyName();
  20820. $targetDir = $package->getTargetDir();
  20821. return $basePath . ($targetDir ? '/'.$targetDir : '');
  20822. }
  20823. public function ensureBinariesPresence(PackageInterface $package)
  20824. {
  20825. $this->binaryInstaller->installBinaries($package, $this->getInstallPath($package), false);
  20826. }
  20827. protected function getPackageBasePath(PackageInterface $package)
  20828. {
  20829. $installPath = $this->getInstallPath($package);
  20830. $targetDir = $package->getTargetDir();
  20831. if ($targetDir) {
  20832. return Preg::replace('{/*'.str_replace('/', '/+', preg_quote($targetDir)).'/?$}', '', $installPath);
  20833. }
  20834. return $installPath;
  20835. }
  20836. protected function installCode(PackageInterface $package)
  20837. {
  20838. $downloadPath = $this->getInstallPath($package);
  20839. return $this->getDownloadManager()->install($package, $downloadPath);
  20840. }
  20841. protected function updateCode(PackageInterface $initial, PackageInterface $target)
  20842. {
  20843. $initialDownloadPath = $this->getInstallPath($initial);
  20844. $targetDownloadPath = $this->getInstallPath($target);
  20845. if ($targetDownloadPath !== $initialDownloadPath) {
  20846. if (strpos($initialDownloadPath, $targetDownloadPath) === 0
  20847. || strpos($targetDownloadPath, $initialDownloadPath) === 0
  20848. ) {
  20849. $promise = $this->removeCode($initial);
  20850. if (!$promise instanceof PromiseInterface) {
  20851. $promise = \React\Promise\resolve(null);
  20852. }
  20853. return $promise->then(function () use ($target): PromiseInterface {
  20854. $promise = $this->installCode($target);
  20855. if ($promise instanceof PromiseInterface) {
  20856. return $promise;
  20857. }
  20858. return \React\Promise\resolve(null);
  20859. });
  20860. }
  20861. $this->filesystem->rename($initialDownloadPath, $targetDownloadPath);
  20862. }
  20863. return $this->getDownloadManager()->update($initial, $target, $targetDownloadPath);
  20864. }
  20865. protected function removeCode(PackageInterface $package)
  20866. {
  20867. $downloadPath = $this->getPackageBasePath($package);
  20868. return $this->getDownloadManager()->remove($package, $downloadPath);
  20869. }
  20870. protected function initializeVendorDir()
  20871. {
  20872. $this->filesystem->ensureDirectoryExists($this->vendorDir);
  20873. $this->vendorDir = realpath($this->vendorDir);
  20874. }
  20875. protected function getDownloadManager(): DownloadManager
  20876. {
  20877. assert($this->downloadManager instanceof DownloadManager, new \LogicException(self::class.' should be initialized with a fully loaded Composer instance to be able to install/... packages'));
  20878. return $this->downloadManager;
  20879. }
  20880. }
  20881. <?php declare(strict_types=1);
  20882. namespace Composer\Installer;
  20883. use Composer\Repository\InstalledRepositoryInterface;
  20884. use Composer\Package\PackageInterface;
  20885. use Composer\IO\IOInterface;
  20886. use Composer\DependencyResolver\Operation\UpdateOperation;
  20887. use Composer\DependencyResolver\Operation\InstallOperation;
  20888. use Composer\DependencyResolver\Operation\UninstallOperation;
  20889. class MetapackageInstaller implements InstallerInterface
  20890. {
  20891. private $io;
  20892. public function __construct(IOInterface $io)
  20893. {
  20894. $this->io = $io;
  20895. }
  20896. public function supports(string $packageType)
  20897. {
  20898. return $packageType === 'metapackage';
  20899. }
  20900. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  20901. {
  20902. return $repo->hasPackage($package);
  20903. }
  20904. public function download(PackageInterface $package, ?PackageInterface $prevPackage = null)
  20905. {
  20906. return \React\Promise\resolve(null);
  20907. }
  20908. public function prepare($type, PackageInterface $package, ?PackageInterface $prevPackage = null)
  20909. {
  20910. return \React\Promise\resolve(null);
  20911. }
  20912. public function cleanup($type, PackageInterface $package, ?PackageInterface $prevPackage = null)
  20913. {
  20914. return \React\Promise\resolve(null);
  20915. }
  20916. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  20917. {
  20918. $this->io->writeError(" - " . InstallOperation::format($package));
  20919. $repo->addPackage(clone $package);
  20920. return \React\Promise\resolve(null);
  20921. }
  20922. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  20923. {
  20924. if (!$repo->hasPackage($initial)) {
  20925. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  20926. }
  20927. $this->io->writeError(" - " . UpdateOperation::format($initial, $target));
  20928. $repo->removePackage($initial);
  20929. $repo->addPackage(clone $target);
  20930. return \React\Promise\resolve(null);
  20931. }
  20932. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  20933. {
  20934. if (!$repo->hasPackage($package)) {
  20935. throw new \InvalidArgumentException('Package is not installed: '.$package);
  20936. }
  20937. $this->io->writeError(" - " . UninstallOperation::format($package));
  20938. $repo->removePackage($package);
  20939. return \React\Promise\resolve(null);
  20940. }
  20941. public function getInstallPath(PackageInterface $package)
  20942. {
  20943. return null;
  20944. }
  20945. }
  20946. <?php declare(strict_types=1);
  20947. namespace Composer\Installer;
  20948. use Composer\Repository\InstalledRepositoryInterface;
  20949. use Composer\Package\PackageInterface;
  20950. class NoopInstaller implements InstallerInterface
  20951. {
  20952. public function supports(string $packageType)
  20953. {
  20954. return true;
  20955. }
  20956. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  20957. {
  20958. return $repo->hasPackage($package);
  20959. }
  20960. public function download(PackageInterface $package, ?PackageInterface $prevPackage = null)
  20961. {
  20962. return \React\Promise\resolve(null);
  20963. }
  20964. public function prepare($type, PackageInterface $package, ?PackageInterface $prevPackage = null)
  20965. {
  20966. return \React\Promise\resolve(null);
  20967. }
  20968. public function cleanup($type, PackageInterface $package, ?PackageInterface $prevPackage = null)
  20969. {
  20970. return \React\Promise\resolve(null);
  20971. }
  20972. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  20973. {
  20974. if (!$repo->hasPackage($package)) {
  20975. $repo->addPackage(clone $package);
  20976. }
  20977. return \React\Promise\resolve(null);
  20978. }
  20979. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  20980. {
  20981. if (!$repo->hasPackage($initial)) {
  20982. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  20983. }
  20984. $repo->removePackage($initial);
  20985. if (!$repo->hasPackage($target)) {
  20986. $repo->addPackage(clone $target);
  20987. }
  20988. return \React\Promise\resolve(null);
  20989. }
  20990. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  20991. {
  20992. if (!$repo->hasPackage($package)) {
  20993. throw new \InvalidArgumentException('Package is not installed: '.$package);
  20994. }
  20995. $repo->removePackage($package);
  20996. return \React\Promise\resolve(null);
  20997. }
  20998. public function getInstallPath(PackageInterface $package)
  20999. {
  21000. $targetDir = $package->getTargetDir();
  21001. return $package->getPrettyName() . ($targetDir ? '/'.$targetDir : '');
  21002. }
  21003. }
  21004. <?php declare(strict_types=1);
  21005. namespace Composer\Installer;
  21006. use Composer\Composer;
  21007. use Composer\IO\IOInterface;
  21008. use Composer\DependencyResolver\Operation\OperationInterface;
  21009. use Composer\Repository\RepositoryInterface;
  21010. use Composer\EventDispatcher\Event;
  21011. class PackageEvent extends Event
  21012. {
  21013. private $composer;
  21014. private $io;
  21015. private $devMode;
  21016. private $localRepo;
  21017. private $operations;
  21018. private $operation;
  21019. public function __construct(string $eventName, Composer $composer, IOInterface $io, bool $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation)
  21020. {
  21021. parent::__construct($eventName);
  21022. $this->composer = $composer;
  21023. $this->io = $io;
  21024. $this->devMode = $devMode;
  21025. $this->localRepo = $localRepo;
  21026. $this->operations = $operations;
  21027. $this->operation = $operation;
  21028. }
  21029. public function getComposer(): Composer
  21030. {
  21031. return $this->composer;
  21032. }
  21033. public function getIO(): IOInterface
  21034. {
  21035. return $this->io;
  21036. }
  21037. public function isDevMode(): bool
  21038. {
  21039. return $this->devMode;
  21040. }
  21041. public function getLocalRepo(): RepositoryInterface
  21042. {
  21043. return $this->localRepo;
  21044. }
  21045. public function getOperations(): array
  21046. {
  21047. return $this->operations;
  21048. }
  21049. public function getOperation(): OperationInterface
  21050. {
  21051. return $this->operation;
  21052. }
  21053. }
  21054. <?php declare(strict_types=1);
  21055. namespace Composer\Installer;
  21056. class PackageEvents
  21057. {
  21058. public const PRE_PACKAGE_INSTALL = 'pre-package-install';
  21059. public const POST_PACKAGE_INSTALL = 'post-package-install';
  21060. public const PRE_PACKAGE_UPDATE = 'pre-package-update';
  21061. public const POST_PACKAGE_UPDATE = 'post-package-update';
  21062. public const PRE_PACKAGE_UNINSTALL = 'pre-package-uninstall';
  21063. public const POST_PACKAGE_UNINSTALL = 'post-package-uninstall';
  21064. }
  21065. <?php declare(strict_types=1);
  21066. namespace Composer\Installer;
  21067. use Composer\Composer;
  21068. use Composer\IO\IOInterface;
  21069. use Composer\PartialComposer;
  21070. use Composer\Repository\InstalledRepositoryInterface;
  21071. use Composer\Package\PackageInterface;
  21072. use Composer\Plugin\PluginManager;
  21073. use Composer\Util\Filesystem;
  21074. use Composer\Util\Platform;
  21075. use React\Promise\PromiseInterface;
  21076. class PluginInstaller extends LibraryInstaller
  21077. {
  21078. public function __construct(IOInterface $io, PartialComposer $composer, ?Filesystem $fs = null, ?BinaryInstaller $binaryInstaller = null)
  21079. {
  21080. parent::__construct($io, $composer, 'composer-plugin', $fs, $binaryInstaller);
  21081. }
  21082. public function supports(string $packageType)
  21083. {
  21084. return $packageType === 'composer-plugin' || $packageType === 'composer-installer';
  21085. }
  21086. public function prepare($type, PackageInterface $package, ?PackageInterface $prevPackage = null)
  21087. {
  21088. if (($type === 'install' || $type === 'update') && !$this->getPluginManager()->arePluginsDisabled('local')) {
  21089. $this->getPluginManager()->isPluginAllowed($package->getName(), false, true === ($package->getExtra()['plugin-optional'] ?? false));
  21090. }
  21091. return parent::prepare($type, $package, $prevPackage);
  21092. }
  21093. public function download(PackageInterface $package, ?PackageInterface $prevPackage = null)
  21094. {
  21095. $extra = $package->getExtra();
  21096. if (empty($extra['class'])) {
  21097. throw new \UnexpectedValueException('Error while installing '.$package->getPrettyName().', composer-plugin packages should have a class defined in their extra key to be usable.');
  21098. }
  21099. return parent::download($package, $prevPackage);
  21100. }
  21101. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  21102. {
  21103. $promise = parent::install($repo, $package);
  21104. if (!$promise instanceof PromiseInterface) {
  21105. $promise = \React\Promise\resolve(null);
  21106. }
  21107. return $promise->then(function () use ($package, $repo): void {
  21108. try {
  21109. Platform::workaroundFilesystemIssues();
  21110. $this->getPluginManager()->registerPackage($package, true);
  21111. } catch (\Exception $e) {
  21112. $this->rollbackInstall($e, $repo, $package);
  21113. }
  21114. });
  21115. }
  21116. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  21117. {
  21118. $promise = parent::update($repo, $initial, $target);
  21119. if (!$promise instanceof PromiseInterface) {
  21120. $promise = \React\Promise\resolve(null);
  21121. }
  21122. return $promise->then(function () use ($initial, $target, $repo): void {
  21123. try {
  21124. Platform::workaroundFilesystemIssues();
  21125. $this->getPluginManager()->deactivatePackage($initial);
  21126. $this->getPluginManager()->registerPackage($target, true);
  21127. } catch (\Exception $e) {
  21128. $this->rollbackInstall($e, $repo, $target);
  21129. }
  21130. });
  21131. }
  21132. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  21133. {
  21134. $this->getPluginManager()->uninstallPackage($package);
  21135. return parent::uninstall($repo, $package);
  21136. }
  21137. private function rollbackInstall(\Exception $e, InstalledRepositoryInterface $repo, PackageInterface $package): void
  21138. {
  21139. $this->io->writeError('Plugin initialization failed ('.$e->getMessage().'), uninstalling plugin');
  21140. parent::uninstall($repo, $package);
  21141. throw $e;
  21142. }
  21143. protected function getPluginManager(): PluginManager
  21144. {
  21145. assert($this->composer instanceof Composer, new \LogicException(self::class.' should be initialized with a fully loaded Composer instance.'));
  21146. $pluginManager = $this->composer->getPluginManager();
  21147. return $pluginManager;
  21148. }
  21149. }
  21150. <?php declare(strict_types=1);
  21151. namespace Composer\Installer;
  21152. use React\Promise\PromiseInterface;
  21153. use Composer\Package\PackageInterface;
  21154. use Composer\Downloader\DownloadManager;
  21155. use Composer\Repository\InstalledRepositoryInterface;
  21156. use Composer\Util\Filesystem;
  21157. class ProjectInstaller implements InstallerInterface
  21158. {
  21159. private $installPath;
  21160. private $downloadManager;
  21161. private $filesystem;
  21162. public function __construct(string $installPath, DownloadManager $dm, Filesystem $fs)
  21163. {
  21164. $this->installPath = rtrim(strtr($installPath, '\\', '/'), '/').'/';
  21165. $this->downloadManager = $dm;
  21166. $this->filesystem = $fs;
  21167. }
  21168. public function supports(string $packageType): bool
  21169. {
  21170. return true;
  21171. }
  21172. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package): bool
  21173. {
  21174. return false;
  21175. }
  21176. public function download(PackageInterface $package, ?PackageInterface $prevPackage = null): ?PromiseInterface
  21177. {
  21178. $installPath = $this->installPath;
  21179. if (file_exists($installPath) && !$this->filesystem->isDirEmpty($installPath)) {
  21180. throw new \InvalidArgumentException("Project directory $installPath is not empty.");
  21181. }
  21182. if (!is_dir($installPath)) {
  21183. mkdir($installPath, 0777, true);
  21184. }
  21185. return $this->downloadManager->download($package, $installPath, $prevPackage);
  21186. }
  21187. public function prepare($type, PackageInterface $package, ?PackageInterface $prevPackage = null): ?PromiseInterface
  21188. {
  21189. return $this->downloadManager->prepare($type, $package, $this->installPath, $prevPackage);
  21190. }
  21191. public function cleanup($type, PackageInterface $package, ?PackageInterface $prevPackage = null): ?PromiseInterface
  21192. {
  21193. return $this->downloadManager->cleanup($type, $package, $this->installPath, $prevPackage);
  21194. }
  21195. public function install(InstalledRepositoryInterface $repo, PackageInterface $package): ?PromiseInterface
  21196. {
  21197. return $this->downloadManager->install($package, $this->installPath);
  21198. }
  21199. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target): ?PromiseInterface
  21200. {
  21201. throw new \InvalidArgumentException("not supported");
  21202. }
  21203. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package): ?PromiseInterface
  21204. {
  21205. throw new \InvalidArgumentException("not supported");
  21206. }
  21207. public function getInstallPath(PackageInterface $package): string
  21208. {
  21209. return $this->installPath;
  21210. }
  21211. }
  21212. <?php declare(strict_types=1);
  21213. namespace Composer\Installer;
  21214. use Composer\IO\IOInterface;
  21215. use Composer\Package\PackageInterface;
  21216. use Composer\Pcre\Preg;
  21217. use Composer\Repository\InstalledRepository;
  21218. use Symfony\Component\Console\Formatter\OutputFormatter;
  21219. class SuggestedPackagesReporter
  21220. {
  21221. public const MODE_LIST = 1;
  21222. public const MODE_BY_PACKAGE = 2;
  21223. public const MODE_BY_SUGGESTION = 4;
  21224. protected $suggestedPackages = [];
  21225. private $io;
  21226. public function __construct(IOInterface $io)
  21227. {
  21228. $this->io = $io;
  21229. }
  21230. public function getPackages(): array
  21231. {
  21232. return $this->suggestedPackages;
  21233. }
  21234. public function addPackage(string $source, string $target, string $reason): SuggestedPackagesReporter
  21235. {
  21236. $this->suggestedPackages[] = [
  21237. 'source' => $source,
  21238. 'target' => $target,
  21239. 'reason' => $reason,
  21240. ];
  21241. return $this;
  21242. }
  21243. public function addSuggestionsFromPackage(PackageInterface $package): SuggestedPackagesReporter
  21244. {
  21245. $source = $package->getPrettyName();
  21246. foreach ($package->getSuggests() as $target => $reason) {
  21247. $this->addPackage(
  21248. $source,
  21249. $target,
  21250. $reason
  21251. );
  21252. }
  21253. return $this;
  21254. }
  21255. public function output(int $mode, ?InstalledRepository $installedRepo = null, ?PackageInterface $onlyDependentsOf = null): void
  21256. {
  21257. $suggestedPackages = $this->getFilteredSuggestions($installedRepo, $onlyDependentsOf);
  21258. $suggesters = [];
  21259. $suggested = [];
  21260. foreach ($suggestedPackages as $suggestion) {
  21261. $suggesters[$suggestion['source']][$suggestion['target']] = $suggestion['reason'];
  21262. $suggested[$suggestion['target']][$suggestion['source']] = $suggestion['reason'];
  21263. }
  21264. ksort($suggesters);
  21265. ksort($suggested);
  21266. if ($mode & self::MODE_LIST) {
  21267. foreach (array_keys($suggested) as $name) {
  21268. $this->io->write(sprintf('<info>%s</info>', $name));
  21269. }
  21270. return;
  21271. }
  21272. if ($mode & self::MODE_BY_PACKAGE) {
  21273. foreach ($suggesters as $suggester => $suggestions) {
  21274. $this->io->write(sprintf('<comment>%s</comment> suggests:', $suggester));
  21275. foreach ($suggestions as $suggestion => $reason) {
  21276. $this->io->write(sprintf(' - <info>%s</info>' . ($reason ? ': %s' : ''), $suggestion, $this->escapeOutput($reason)));
  21277. }
  21278. $this->io->write('');
  21279. }
  21280. }
  21281. if ($mode & self::MODE_BY_SUGGESTION) {
  21282. if ($mode & self::MODE_BY_PACKAGE) {
  21283. $this->io->write(str_repeat('-', 78));
  21284. }
  21285. foreach ($suggested as $suggestion => $suggesters) {
  21286. $this->io->write(sprintf('<comment>%s</comment> is suggested by:', $suggestion));
  21287. foreach ($suggesters as $suggester => $reason) {
  21288. $this->io->write(sprintf(' - <info>%s</info>' . ($reason ? ': %s' : ''), $suggester, $this->escapeOutput($reason)));
  21289. }
  21290. $this->io->write('');
  21291. }
  21292. }
  21293. if ($onlyDependentsOf) {
  21294. $allSuggestedPackages = $this->getFilteredSuggestions($installedRepo);
  21295. $diff = count($allSuggestedPackages) - count($suggestedPackages);
  21296. if ($diff) {
  21297. $this->io->write('<info>'.$diff.' additional suggestions</info> by transitive dependencies can be shown with <info>--all</info>');
  21298. }
  21299. }
  21300. }
  21301. public function outputMinimalistic(?InstalledRepository $installedRepo = null, ?PackageInterface $onlyDependentsOf = null): void
  21302. {
  21303. $suggestedPackages = $this->getFilteredSuggestions($installedRepo, $onlyDependentsOf);
  21304. if ($suggestedPackages) {
  21305. $this->io->writeError('<info>'.count($suggestedPackages).' package suggestions were added by new dependencies, use `composer suggest` to see details.</info>');
  21306. }
  21307. }
  21308. private function getFilteredSuggestions(?InstalledRepository $installedRepo = null, ?PackageInterface $onlyDependentsOf = null): array
  21309. {
  21310. $suggestedPackages = $this->getPackages();
  21311. $installedNames = [];
  21312. if (null !== $installedRepo && !empty($suggestedPackages)) {
  21313. foreach ($installedRepo->getPackages() as $package) {
  21314. $installedNames = array_merge(
  21315. $installedNames,
  21316. $package->getNames()
  21317. );
  21318. }
  21319. }
  21320. $sourceFilter = [];
  21321. if ($onlyDependentsOf) {
  21322. $sourceFilter = array_map(static function ($link): string {
  21323. return $link->getTarget();
  21324. }, array_merge($onlyDependentsOf->getRequires(), $onlyDependentsOf->getDevRequires()));
  21325. $sourceFilter[] = $onlyDependentsOf->getName();
  21326. }
  21327. $suggestions = [];
  21328. foreach ($suggestedPackages as $suggestion) {
  21329. if (in_array($suggestion['target'], $installedNames) || ($sourceFilter && !in_array($suggestion['source'], $sourceFilter))) {
  21330. continue;
  21331. }
  21332. $suggestions[] = $suggestion;
  21333. }
  21334. return $suggestions;
  21335. }
  21336. private function escapeOutput(string $string): string
  21337. {
  21338. return OutputFormatter::escape(
  21339. $this->removeControlCharacters($string)
  21340. );
  21341. }
  21342. private function removeControlCharacters(string $string): string
  21343. {
  21344. return Preg::replace(
  21345. '/[[:cntrl:]]/',
  21346. '',
  21347. str_replace("\n", ' ', $string)
  21348. );
  21349. }
  21350. }
  21351. <?php declare(strict_types=1);
  21352. namespace Composer\Json;
  21353. use Composer\Pcre\Preg;
  21354. use Composer\Util\Filesystem;
  21355. use JsonSchema\Validator;
  21356. use Seld\JsonLint\JsonParser;
  21357. use Seld\JsonLint\ParsingException;
  21358. use Composer\Util\HttpDownloader;
  21359. use Composer\IO\IOInterface;
  21360. use Composer\Downloader\TransportException;
  21361. class JsonFile
  21362. {
  21363. public const LAX_SCHEMA = 1;
  21364. public const STRICT_SCHEMA = 2;
  21365. public const AUTH_SCHEMA = 3;
  21366. public const JSON_UNESCAPED_SLASHES = 64;
  21367. public const JSON_PRETTY_PRINT = 128;
  21368. public const JSON_UNESCAPED_UNICODE = 256;
  21369. public const COMPOSER_SCHEMA_PATH = __DIR__ . '/../../../res/composer-schema.json';
  21370. public const INDENT_DEFAULT = ' ';
  21371. private $path;
  21372. private $httpDownloader;
  21373. private $io;
  21374. private $indent = self::INDENT_DEFAULT;
  21375. public function __construct(string $path, ?HttpDownloader $httpDownloader = null, ?IOInterface $io = null)
  21376. {
  21377. $this->path = $path;
  21378. if (null === $httpDownloader && Preg::isMatch('{^https?://}i', $path)) {
  21379. throw new \InvalidArgumentException('http urls require a HttpDownloader instance to be passed');
  21380. }
  21381. $this->httpDownloader = $httpDownloader;
  21382. $this->io = $io;
  21383. }
  21384. public function getPath(): string
  21385. {
  21386. return $this->path;
  21387. }
  21388. public function exists(): bool
  21389. {
  21390. return is_file($this->path);
  21391. }
  21392. public function read()
  21393. {
  21394. try {
  21395. if ($this->httpDownloader) {
  21396. $json = $this->httpDownloader->get($this->path)->getBody();
  21397. } else {
  21398. if (!Filesystem::isReadable($this->path)) {
  21399. throw new \RuntimeException('The file "'.$this->path.'" is not readable.');
  21400. }
  21401. if ($this->io && $this->io->isDebug()) {
  21402. $realpathInfo = '';
  21403. $realpath = realpath($this->path);
  21404. if (false !== $realpath && $realpath !== $this->path) {
  21405. $realpathInfo = ' (' . $realpath . ')';
  21406. }
  21407. $this->io->writeError('Reading ' . $this->path . $realpathInfo);
  21408. }
  21409. $json = file_get_contents($this->path);
  21410. }
  21411. } catch (TransportException $e) {
  21412. throw new \RuntimeException($e->getMessage(), 0, $e);
  21413. } catch (\Exception $e) {
  21414. throw new \RuntimeException('Could not read '.$this->path."\n\n".$e->getMessage());
  21415. }
  21416. if ($json === false) {
  21417. throw new \RuntimeException('Could not read '.$this->path);
  21418. }
  21419. $this->indent = self::detectIndenting($json);
  21420. return static::parseJson($json, $this->path);
  21421. }
  21422. public function write(array $hash, int $options = JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)
  21423. {
  21424. if ($this->path === 'php://memory') {
  21425. file_put_contents($this->path, static::encode($hash, $options, $this->indent));
  21426. return;
  21427. }
  21428. $dir = dirname($this->path);
  21429. if (!is_dir($dir)) {
  21430. if (file_exists($dir)) {
  21431. throw new \UnexpectedValueException(
  21432. realpath($dir).' exists and is not a directory.'
  21433. );
  21434. }
  21435. if (!@mkdir($dir, 0777, true)) {
  21436. throw new \UnexpectedValueException(
  21437. $dir.' does not exist and could not be created.'
  21438. );
  21439. }
  21440. }
  21441. $retries = 3;
  21442. while ($retries--) {
  21443. try {
  21444. $this->filePutContentsIfModified($this->path, static::encode($hash, $options, $this->indent). ($options & JSON_PRETTY_PRINT ? "\n" : ''));
  21445. break;
  21446. } catch (\Exception $e) {
  21447. if ($retries > 0) {
  21448. usleep(500000);
  21449. continue;
  21450. }
  21451. throw $e;
  21452. }
  21453. }
  21454. }
  21455. private function filePutContentsIfModified(string $path, string $content)
  21456. {
  21457. $currentContent = @file_get_contents($path);
  21458. if (false === $currentContent || $currentContent !== $content) {
  21459. return file_put_contents($path, $content);
  21460. }
  21461. return 0;
  21462. }
  21463. public function validateSchema(int $schema = self::STRICT_SCHEMA, ?string $schemaFile = null): bool
  21464. {
  21465. if (!Filesystem::isReadable($this->path)) {
  21466. throw new \RuntimeException('The file "'.$this->path.'" is not readable.');
  21467. }
  21468. $content = file_get_contents($this->path);
  21469. $data = json_decode($content);
  21470. if (null === $data && 'null' !== $content) {
  21471. self::validateSyntax($content, $this->path);
  21472. }
  21473. return self::validateJsonSchema($this->path, $data, $schema, $schemaFile);
  21474. }
  21475. public static function validateJsonSchema(string $source, $data, int $schema, ?string $schemaFile = null): bool
  21476. {
  21477. $isComposerSchemaFile = false;
  21478. if (null === $schemaFile) {
  21479. $isComposerSchemaFile = true;
  21480. $schemaFile = self::COMPOSER_SCHEMA_PATH;
  21481. }
  21482. if (false === strpos($schemaFile, '://')) {
  21483. $schemaFile = 'file://' . $schemaFile;
  21484. }
  21485. $schemaData = (object) ['$ref' => $schemaFile];
  21486. if ($schema === self::LAX_SCHEMA) {
  21487. $schemaData->additionalProperties = true;
  21488. $schemaData->required = [];
  21489. } elseif ($schema === self::STRICT_SCHEMA && $isComposerSchemaFile) {
  21490. $schemaData->additionalProperties = false;
  21491. $schemaData->required = ['name', 'description'];
  21492. } elseif ($schema === self::AUTH_SCHEMA && $isComposerSchemaFile) {
  21493. $schemaData = (object) ['$ref' => $schemaFile.'#/properties/config', '$schema' => "https://json-schema.org/draft-04/schema#"];
  21494. }
  21495. $validator = new Validator();
  21496. $validator->check($data, $schemaData);
  21497. if (!$validator->isValid()) {
  21498. $errors = [];
  21499. foreach ((array) $validator->getErrors() as $error) {
  21500. $errors[] = ($error['property'] ? $error['property'].' : ' : '').$error['message'];
  21501. }
  21502. throw new JsonValidationException('"'.$source.'" does not match the expected JSON schema', $errors);
  21503. }
  21504. return true;
  21505. }
  21506. public static function encode($data, int $options = 448, string $indent = self::INDENT_DEFAULT): string
  21507. {
  21508. $json = json_encode($data, $options);
  21509. if (false === $json) {
  21510. self::throwEncodeError(json_last_error());
  21511. }
  21512. if (($options & JSON_PRETTY_PRINT) > 0 && $indent !== self::INDENT_DEFAULT ) {
  21513. return Preg::replaceCallback(
  21514. '#^ {4,}#m',
  21515. static function ($match) use ($indent): string {
  21516. return str_repeat($indent, (int)(strlen($match[0] ?? '') / 4));
  21517. },
  21518. $json
  21519. );
  21520. }
  21521. return $json;
  21522. }
  21523. private static function throwEncodeError(int $code): void
  21524. {
  21525. switch ($code) {
  21526. case JSON_ERROR_DEPTH:
  21527. $msg = 'Maximum stack depth exceeded';
  21528. break;
  21529. case JSON_ERROR_STATE_MISMATCH:
  21530. $msg = 'Underflow or the modes mismatch';
  21531. break;
  21532. case JSON_ERROR_CTRL_CHAR:
  21533. $msg = 'Unexpected control character found';
  21534. break;
  21535. case JSON_ERROR_UTF8:
  21536. $msg = 'Malformed UTF-8 characters, possibly incorrectly encoded';
  21537. break;
  21538. default:
  21539. $msg = 'Unknown error';
  21540. }
  21541. throw new \RuntimeException('JSON encoding failed: '.$msg);
  21542. }
  21543. public static function parseJson(?string $json, ?string $file = null)
  21544. {
  21545. if (null === $json) {
  21546. return null;
  21547. }
  21548. $data = json_decode($json, true);
  21549. if (null === $data && JSON_ERROR_NONE !== json_last_error()) {
  21550. self::validateSyntax($json, $file);
  21551. }
  21552. return $data;
  21553. }
  21554. protected static function validateSyntax(string $json, ?string $file = null): bool
  21555. {
  21556. $parser = new JsonParser();
  21557. $result = $parser->lint($json);
  21558. if (null === $result) {
  21559. if (defined('JSON_ERROR_UTF8') && JSON_ERROR_UTF8 === json_last_error()) {
  21560. if ($file === null) {
  21561. throw new \UnexpectedValueException('The input is not UTF-8, could not parse as JSON');
  21562. } else {
  21563. throw new \UnexpectedValueException('"' . $file . '" is not UTF-8, could not parse as JSON');
  21564. }
  21565. }
  21566. return true;
  21567. }
  21568. if ($file === null) {
  21569. throw new ParsingException('The input does not contain valid JSON' . "\n" . $result->getMessage(),
  21570. $result->getDetails());
  21571. } else {
  21572. throw new ParsingException('"' . $file . '" does not contain valid JSON' . "\n" . $result->getMessage(),
  21573. $result->getDetails());
  21574. }
  21575. }
  21576. public static function detectIndenting(?string $json): string
  21577. {
  21578. if (Preg::isMatchStrictGroups('#^([ \t]+)"#m', $json ?? '', $match)) {
  21579. return $match[1];
  21580. }
  21581. return self::INDENT_DEFAULT;
  21582. }
  21583. }
  21584. <?php declare(strict_types=1);
  21585. namespace Composer\Json;
  21586. use Composer\Pcre\Preg;
  21587. class JsonFormatter
  21588. {
  21589. public static function format(string $json, bool $unescapeUnicode, bool $unescapeSlashes): string
  21590. {
  21591. $result = '';
  21592. $pos = 0;
  21593. $strLen = strlen($json);
  21594. $indentStr = ' ';
  21595. $newLine = "\n";
  21596. $outOfQuotes = true;
  21597. $buffer = '';
  21598. $noescape = true;
  21599. for ($i = 0; $i < $strLen; $i++) {
  21600. $char = substr($json, $i, 1);
  21601. if ('"' === $char && $noescape) {
  21602. $outOfQuotes = !$outOfQuotes;
  21603. }
  21604. if (!$outOfQuotes) {
  21605. $buffer .= $char;
  21606. $noescape = '\\' === $char ? !$noescape : true;
  21607. continue;
  21608. }
  21609. if ('' !== $buffer) {
  21610. if ($unescapeSlashes) {
  21611. $buffer = str_replace('\\/', '/', $buffer);
  21612. }
  21613. if ($unescapeUnicode && function_exists('mb_convert_encoding')) {
  21614. $buffer = Preg::replaceCallback('/(\\\\+)u([0-9a-f]{4})/i', static function ($match) {
  21615. assert(is_string($match[1]));
  21616. assert(is_string($match[2]));
  21617. $l = strlen($match[1]);
  21618. if ($l % 2) {
  21619. $code = hexdec($match[2]);
  21620. if (0xD800 <= $code && 0xDFFF >= $code) {
  21621. return $match[0];
  21622. }
  21623. return str_repeat('\\', $l - 1) . mb_convert_encoding(
  21624. pack('H*', $match[2]),
  21625. 'UTF-8',
  21626. 'UCS-2BE'
  21627. );
  21628. }
  21629. return $match[0];
  21630. }, $buffer);
  21631. }
  21632. $result .= $buffer.$char;
  21633. $buffer = '';
  21634. continue;
  21635. }
  21636. if (':' === $char) {
  21637. $char .= ' ';
  21638. } elseif ('}' === $char || ']' === $char) {
  21639. $pos--;
  21640. $prevChar = substr($json, $i - 1, 1);
  21641. if ('{' !== $prevChar && '[' !== $prevChar) {
  21642. $result .= $newLine;
  21643. $result .= str_repeat($indentStr, $pos);
  21644. } else {
  21645. $result = rtrim($result);
  21646. }
  21647. }
  21648. $result .= $char;
  21649. if (',' === $char || '{' === $char || '[' === $char) {
  21650. $result .= $newLine;
  21651. if ('{' === $char || '[' === $char) {
  21652. $pos++;
  21653. }
  21654. $result .= str_repeat($indentStr, $pos);
  21655. }
  21656. }
  21657. return $result;
  21658. }
  21659. }
  21660. <?php declare(strict_types=1);
  21661. namespace Composer\Json;
  21662. use Composer\Pcre\Preg;
  21663. use Composer\Repository\PlatformRepository;
  21664. class JsonManipulator
  21665. {
  21666. private const DEFINES = '(?(DEFINE)
  21667. (?<number> -? (?= [1-9]|0(?!\d) ) \d++ (?:\.\d++)? (?:[eE] [+-]?+ \d++)? )
  21668. (?<boolean> true | false | null )
  21669. (?<string> " (?:[^"\\\\]*+ | \\\\ ["\\\\bfnrt\/] | \\\\ u [0-9A-Fa-f]{4} )* " )
  21670. (?<array> \[ (?: (?&json) \s*+ (?: , (?&json) \s*+ )*+ )?+ \s*+ \] )
  21671. (?<pair> \s*+ (?&string) \s*+ : (?&json) \s*+ )
  21672. (?<object> \{ (?: (?&pair) (?: , (?&pair) )*+ )?+ \s*+ \} )
  21673. (?<json> \s*+ (?: (?&number) | (?&boolean) | (?&string) | (?&array) | (?&object) ) )
  21674. )';
  21675. private $contents;
  21676. private $newline;
  21677. private $indent;
  21678. public function __construct(string $contents)
  21679. {
  21680. $contents = trim($contents);
  21681. if ($contents === '') {
  21682. $contents = '{}';
  21683. }
  21684. if (!Preg::isMatch('#^\{(.*)\}$#s', $contents)) {
  21685. throw new \InvalidArgumentException('The json file must be an object ({})');
  21686. }
  21687. $this->newline = false !== strpos($contents, "\r\n") ? "\r\n" : "\n";
  21688. $this->contents = $contents === '{}' ? '{' . $this->newline . '}' : $contents;
  21689. $this->detectIndenting();
  21690. }
  21691. public function getContents(): string
  21692. {
  21693. return $this->contents . $this->newline;
  21694. }
  21695. public function addLink(string $type, string $package, string $constraint, bool $sortPackages = false): bool
  21696. {
  21697. $decoded = JsonFile::parseJson($this->contents);
  21698. if (!isset($decoded[$type])) {
  21699. return $this->addMainKey($type, [$package => $constraint]);
  21700. }
  21701. $regex = '{'.self::DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  21702. '(?P<property>'.preg_quote(JsonFile::encode($type)).'\s*:\s*)(?P<value>(?&json))(?P<end>.*)}sx';
  21703. if (!Preg::isMatch($regex, $this->contents, $matches)) {
  21704. return false;
  21705. }
  21706. assert(is_string($matches['start']));
  21707. assert(is_string($matches['value']));
  21708. assert(is_string($matches['end']));
  21709. $links = $matches['value'];
  21710. $packageRegex = str_replace('/', '\\\\?/', preg_quote($package));
  21711. $regex = '{'.self::DEFINES.'"(?P<package>'.$packageRegex.')"(\s*:\s*)(?&string)}ix';
  21712. if (Preg::isMatch($regex, $links, $packageMatches)) {
  21713. assert(is_string($packageMatches['package']));
  21714. $existingPackage = $packageMatches['package'];
  21715. $packageRegex = str_replace('/', '\\\\?/', preg_quote($existingPackage));
  21716. $links = Preg::replaceCallback('{'.self::DEFINES.'"'.$packageRegex.'"(?P<separator>\s*:\s*)(?&string)}ix', static function ($m) use ($existingPackage, $constraint): string {
  21717. return JsonFile::encode(str_replace('\\/', '/', $existingPackage)) . $m['separator'] . '"' . $constraint . '"';
  21718. }, $links);
  21719. } else {
  21720. if (Preg::isMatchStrictGroups('#^\s*\{\s*\S+.*?(\s*\}\s*)$#s', $links, $match)) {
  21721. $links = Preg::replace(
  21722. '{'.preg_quote($match[1]).'$}',
  21723. addcslashes(',' . $this->newline . $this->indent . $this->indent . JsonFile::encode($package).': '.JsonFile::encode($constraint) . $match[1], '\\$'),
  21724. $links
  21725. );
  21726. } else {
  21727. $links = '{' . $this->newline .
  21728. $this->indent . $this->indent . JsonFile::encode($package).': '.JsonFile::encode($constraint) . $this->newline .
  21729. $this->indent . '}';
  21730. }
  21731. }
  21732. if (true === $sortPackages) {
  21733. $requirements = json_decode($links, true);
  21734. $this->sortPackages($requirements);
  21735. $links = $this->format($requirements);
  21736. }
  21737. $this->contents = $matches['start'] . $matches['property'] . $links . $matches['end'];
  21738. return true;
  21739. }
  21740. private function sortPackages(array &$packages = []): void
  21741. {
  21742. $prefix = static function ($requirement): string {
  21743. if (PlatformRepository::isPlatformPackage($requirement)) {
  21744. return Preg::replace(
  21745. [
  21746. '/^php/',
  21747. '/^hhvm/',
  21748. '/^ext/',
  21749. '/^lib/',
  21750. '/^\D/',
  21751. ],
  21752. [
  21753. '0-$0',
  21754. '1-$0',
  21755. '2-$0',
  21756. '3-$0',
  21757. '4-$0',
  21758. ],
  21759. $requirement
  21760. );
  21761. }
  21762. return '5-'.$requirement;
  21763. };
  21764. uksort($packages, static function ($a, $b) use ($prefix): int {
  21765. return strnatcmp($prefix($a), $prefix($b));
  21766. });
  21767. }
  21768. public function addRepository(string $name, $config, bool $append = true): bool
  21769. {
  21770. return $this->addSubNode('repositories', $name, $config, $append);
  21771. }
  21772. public function removeRepository(string $name): bool
  21773. {
  21774. return $this->removeSubNode('repositories', $name);
  21775. }
  21776. public function addConfigSetting(string $name, $value): bool
  21777. {
  21778. return $this->addSubNode('config', $name, $value);
  21779. }
  21780. public function removeConfigSetting(string $name): bool
  21781. {
  21782. return $this->removeSubNode('config', $name);
  21783. }
  21784. public function addProperty(string $name, $value): bool
  21785. {
  21786. if (strpos($name, 'suggest.') === 0) {
  21787. return $this->addSubNode('suggest', substr($name, 8), $value);
  21788. }
  21789. if (strpos($name, 'extra.') === 0) {
  21790. return $this->addSubNode('extra', substr($name, 6), $value);
  21791. }
  21792. if (strpos($name, 'scripts.') === 0) {
  21793. return $this->addSubNode('scripts', substr($name, 8), $value);
  21794. }
  21795. return $this->addMainKey($name, $value);
  21796. }
  21797. public function removeProperty(string $name): bool
  21798. {
  21799. if (strpos($name, 'suggest.') === 0) {
  21800. return $this->removeSubNode('suggest', substr($name, 8));
  21801. }
  21802. if (strpos($name, 'extra.') === 0) {
  21803. return $this->removeSubNode('extra', substr($name, 6));
  21804. }
  21805. if (strpos($name, 'scripts.') === 0) {
  21806. return $this->removeSubNode('scripts', substr($name, 8));
  21807. }
  21808. return $this->removeMainKey($name);
  21809. }
  21810. public function addSubNode(string $mainNode, string $name, $value, bool $append = true): bool
  21811. {
  21812. $decoded = JsonFile::parseJson($this->contents);
  21813. $subName = null;
  21814. if (in_array($mainNode, ['config', 'extra', 'scripts']) && false !== strpos($name, '.')) {
  21815. [$name, $subName] = explode('.', $name, 2);
  21816. }
  21817. if (!isset($decoded[$mainNode])) {
  21818. if ($subName !== null) {
  21819. $this->addMainKey($mainNode, [$name => [$subName => $value]]);
  21820. } else {
  21821. $this->addMainKey($mainNode, [$name => $value]);
  21822. }
  21823. return true;
  21824. }
  21825. $nodeRegex = '{'.self::DEFINES.'^(?P<start> \s* \{ \s* (?: (?&string) \s* : (?&json) \s* , \s* )*?'.
  21826. preg_quote(JsonFile::encode($mainNode)).'\s*:\s*)(?P<content>(?&object))(?P<end>.*)}sx';
  21827. try {
  21828. if (!Preg::isMatch($nodeRegex, $this->contents, $match)) {
  21829. return false;
  21830. }
  21831. } catch (\RuntimeException $e) {
  21832. if ($e->getCode() === PREG_BACKTRACK_LIMIT_ERROR) {
  21833. return false;
  21834. }
  21835. throw $e;
  21836. }
  21837. assert(is_string($match['start']));
  21838. assert(is_string($match['content']));
  21839. assert(is_string($match['end']));
  21840. $children = $match['content'];
  21841. if (!@json_decode($children)) {
  21842. return false;
  21843. }
  21844. $childRegex = '{'.self::DEFINES.'(?P<start>"'.preg_quote($name).'"\s*:\s*)(?P<content>(?&json))(?P<end>,?)}x';
  21845. if (Preg::isMatch($childRegex, $children, $matches)) {
  21846. $children = Preg::replaceCallback($childRegex, function ($matches) use ($subName, $value): string {
  21847. if ($subName !== null && is_string($matches['content'])) {
  21848. $curVal = json_decode($matches['content'], true);
  21849. if (!is_array($curVal)) {
  21850. $curVal = [];
  21851. }
  21852. $curVal[$subName] = $value;
  21853. $value = $curVal;
  21854. }
  21855. return $matches['start'] . $this->format($value, 1) . $matches['end'];
  21856. }, $children);
  21857. } else {
  21858. Preg::match('#^{ (?P<leadingspace>\s*?) (?P<content>\S+.*?)? (?P<trailingspace>\s*) }$#sx', $children, $match);
  21859. $whitespace = '';
  21860. if (!empty($match['trailingspace'])) {
  21861. $whitespace = $match['trailingspace'];
  21862. }
  21863. if (!empty($match['content'])) {
  21864. if ($subName !== null) {
  21865. $value = [$subName => $value];
  21866. }
  21867. if ($append) {
  21868. $children = Preg::replace(
  21869. '#'.$whitespace.'}$#',
  21870. addcslashes(',' . $this->newline . $this->indent . $this->indent . JsonFile::encode($name).': '.$this->format($value, 1) . $whitespace . '}', '\\$'),
  21871. $children
  21872. );
  21873. } else {
  21874. $whitespace = '';
  21875. if (!empty($match['leadingspace'])) {
  21876. $whitespace = $match['leadingspace'];
  21877. }
  21878. $children = Preg::replace(
  21879. '#^{'.$whitespace.'#',
  21880. addcslashes('{' . $whitespace . JsonFile::encode($name).': '.$this->format($value, 1) . ',' . $this->newline . $this->indent . $this->indent, '\\$'),
  21881. $children
  21882. );
  21883. }
  21884. } else {
  21885. if ($subName !== null) {
  21886. $value = [$subName => $value];
  21887. }
  21888. $children = '{' . $this->newline . $this->indent . $this->indent . JsonFile::encode($name).': '.$this->format($value, 1) . $whitespace . '}';
  21889. }
  21890. }
  21891. $this->contents = Preg::replaceCallback($nodeRegex, static function ($m) use ($children): string {
  21892. return $m['start'] . $children . $m['end'];
  21893. }, $this->contents);
  21894. return true;
  21895. }
  21896. public function removeSubNode(string $mainNode, string $name): bool
  21897. {
  21898. $decoded = JsonFile::parseJson($this->contents);
  21899. if (empty($decoded[$mainNode])) {
  21900. return true;
  21901. }
  21902. $nodeRegex = '{'.self::DEFINES.'^(?P<start> \s* \{ \s* (?: (?&string) \s* : (?&json) \s* , \s* )*?'.
  21903. preg_quote(JsonFile::encode($mainNode)).'\s*:\s*)(?P<content>(?&object))(?P<end>.*)}sx';
  21904. try {
  21905. if (!Preg::isMatch($nodeRegex, $this->contents, $match)) {
  21906. return false;
  21907. }
  21908. } catch (\RuntimeException $e) {
  21909. if ($e->getCode() === PREG_BACKTRACK_LIMIT_ERROR) {
  21910. return false;
  21911. }
  21912. throw $e;
  21913. }
  21914. assert(is_string($match['start']));
  21915. assert(is_string($match['content']));
  21916. assert(is_string($match['end']));
  21917. $children = $match['content'];
  21918. if (!@json_decode($children, true)) {
  21919. return false;
  21920. }
  21921. $subName = null;
  21922. if (in_array($mainNode, ['config', 'extra', 'scripts']) && false !== strpos($name, '.')) {
  21923. [$name, $subName] = explode('.', $name, 2);
  21924. }
  21925. if (!isset($decoded[$mainNode][$name]) || ($subName && !isset($decoded[$mainNode][$name][$subName]))) {
  21926. return true;
  21927. }
  21928. $keyRegex = str_replace('/', '\\\\?/', preg_quote($name));
  21929. if (Preg::isMatch('{"'.$keyRegex.'"\s*:}i', $children)) {
  21930. if (Preg::isMatchAll('{'.self::DEFINES.'"'.$keyRegex.'"\s*:\s*(?:(?&json))}x', $children, $matches)) {
  21931. $bestMatch = '';
  21932. foreach ($matches[0] as $match) {
  21933. assert(is_string($match));
  21934. if (strlen($bestMatch) < strlen($match)) {
  21935. $bestMatch = $match;
  21936. }
  21937. }
  21938. $childrenClean = Preg::replace('{,\s*'.preg_quote($bestMatch).'}i', '', $children, -1, $count);
  21939. if (1 !== $count) {
  21940. $childrenClean = Preg::replace('{'.preg_quote($bestMatch).'\s*,?\s*}i', '', $childrenClean, -1, $count);
  21941. if (1 !== $count) {
  21942. return false;
  21943. }
  21944. }
  21945. }
  21946. } else {
  21947. $childrenClean = $children;
  21948. }
  21949. if (!isset($childrenClean)) {
  21950. throw new \InvalidArgumentException("JsonManipulator: \$childrenClean is not defined. Please report at https://github.com/composer/composer/issues/new.");
  21951. }
  21952. unset($match);
  21953. Preg::match('#^{ \s*? (?P<content>\S+.*?)? (?P<trailingspace>\s*) }$#sx', $childrenClean, $match);
  21954. if (empty($match['content'])) {
  21955. $newline = $this->newline;
  21956. $indent = $this->indent;
  21957. $this->contents = Preg::replaceCallback($nodeRegex, static function ($matches) use ($indent, $newline): string {
  21958. return $matches['start'] . '{' . $newline . $indent . '}' . $matches['end'];
  21959. }, $this->contents);
  21960. if ($subName !== null) {
  21961. $curVal = json_decode($children, true);
  21962. unset($curVal[$name][$subName]);
  21963. $this->addSubNode($mainNode, $name, $curVal[$name]);
  21964. }
  21965. return true;
  21966. }
  21967. $this->contents = Preg::replaceCallback($nodeRegex, function ($matches) use ($name, $subName, $childrenClean): string {
  21968. assert(is_string($matches['content']));
  21969. if ($subName !== null) {
  21970. $curVal = json_decode($matches['content'], true);
  21971. unset($curVal[$name][$subName]);
  21972. $childrenClean = $this->format($curVal);
  21973. }
  21974. return $matches['start'] . $childrenClean . $matches['end'];
  21975. }, $this->contents);
  21976. return true;
  21977. }
  21978. public function addMainKey(string $key, $content): bool
  21979. {
  21980. $decoded = JsonFile::parseJson($this->contents);
  21981. $content = $this->format($content);
  21982. $regex = '{'.self::DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  21983. '(?P<key>'.preg_quote(JsonFile::encode($key)).'\s*:\s*(?&json))(?P<end>.*)}sx';
  21984. if (isset($decoded[$key]) && Preg::isMatch($regex, $this->contents, $matches)) {
  21985. if (!@json_decode('{'.$matches['key'].'}')) {
  21986. return false;
  21987. }
  21988. $this->contents = $matches['start'] . JsonFile::encode($key).': '.$content . $matches['end'];
  21989. return true;
  21990. }
  21991. if (Preg::isMatch('#[^{\s](\s*)\}$#', $this->contents, $match)) {
  21992. $this->contents = Preg::replace(
  21993. '#'.$match[1].'\}$#',
  21994. addcslashes(',' . $this->newline . $this->indent . JsonFile::encode($key). ': '. $content . $this->newline . '}', '\\$'),
  21995. $this->contents
  21996. );
  21997. return true;
  21998. }
  21999. $this->contents = Preg::replace(
  22000. '#\}$#',
  22001. addcslashes($this->indent . JsonFile::encode($key). ': '.$content . $this->newline . '}', '\\$'),
  22002. $this->contents
  22003. );
  22004. return true;
  22005. }
  22006. public function removeMainKey(string $key): bool
  22007. {
  22008. $decoded = JsonFile::parseJson($this->contents);
  22009. if (!array_key_exists($key, $decoded)) {
  22010. return true;
  22011. }
  22012. $regex = '{'.self::DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  22013. '(?P<removal>'.preg_quote(JsonFile::encode($key)).'\s*:\s*(?&json))\s*,?\s*(?P<end>.*)}sx';
  22014. if (Preg::isMatch($regex, $this->contents, $matches)) {
  22015. assert(is_string($matches['start']));
  22016. assert(is_string($matches['removal']));
  22017. assert(is_string($matches['end']));
  22018. if (!@json_decode('{'.$matches['removal'].'}')) {
  22019. return false;
  22020. }
  22021. if (Preg::isMatchStrictGroups('#,\s*$#', $matches['start']) && Preg::isMatch('#^\}$#', $matches['end'])) {
  22022. $matches['start'] = rtrim(Preg::replace('#,(\s*)$#', '$1', $matches['start']), $this->indent);
  22023. }
  22024. $this->contents = $matches['start'] . $matches['end'];
  22025. if (Preg::isMatch('#^\{\s*\}\s*$#', $this->contents)) {
  22026. $this->contents = "{\n}";
  22027. }
  22028. return true;
  22029. }
  22030. return false;
  22031. }
  22032. public function removeMainKeyIfEmpty(string $key): bool
  22033. {
  22034. $decoded = JsonFile::parseJson($this->contents);
  22035. if (!array_key_exists($key, $decoded)) {
  22036. return true;
  22037. }
  22038. if (is_array($decoded[$key]) && count($decoded[$key]) === 0) {
  22039. return $this->removeMainKey($key);
  22040. }
  22041. return true;
  22042. }
  22043. public function format($data, int $depth = 0): string
  22044. {
  22045. if (is_array($data)) {
  22046. reset($data);
  22047. if (is_numeric(key($data))) {
  22048. foreach ($data as $key => $val) {
  22049. $data[$key] = $this->format($val, $depth + 1);
  22050. }
  22051. return '['.implode(', ', $data).']';
  22052. }
  22053. $out = '{' . $this->newline;
  22054. $elems = [];
  22055. foreach ($data as $key => $val) {
  22056. $elems[] = str_repeat($this->indent, $depth + 2) . JsonFile::encode($key). ': '.$this->format($val, $depth + 1);
  22057. }
  22058. return $out . implode(','.$this->newline, $elems) . $this->newline . str_repeat($this->indent, $depth + 1) . '}';
  22059. }
  22060. return JsonFile::encode($data);
  22061. }
  22062. protected function detectIndenting(): void
  22063. {
  22064. $this->indent = JsonFile::detectIndenting($this->contents);
  22065. }
  22066. }
  22067. <?php declare(strict_types=1);
  22068. namespace Composer\Json;
  22069. use Exception;
  22070. class JsonValidationException extends Exception
  22071. {
  22072. protected $errors;
  22073. public function __construct(string $message, array $errors = [], ?Exception $previous = null)
  22074. {
  22075. $this->errors = $errors;
  22076. parent::__construct((string) $message, 0, $previous);
  22077. }
  22078. public function getErrors(): array
  22079. {
  22080. return $this->errors;
  22081. }
  22082. }
  22083. <?php declare(strict_types=1);
  22084. namespace Composer\PHPStan;
  22085. use Composer\Config;
  22086. use Composer\Json\JsonFile;
  22087. use PhpParser\Node\Expr\MethodCall;
  22088. use PHPStan\Analyser\Scope;
  22089. use PHPStan\Reflection\MethodReflection;
  22090. use PHPStan\Reflection\ParametersAcceptorSelector;
  22091. use PHPStan\Type\ArrayType;
  22092. use PHPStan\Type\BooleanType;
  22093. use PHPStan\Type\Constant\ConstantArrayType;
  22094. use PHPStan\Type\Constant\ConstantBooleanType;
  22095. use PHPStan\Type\Constant\ConstantStringType;
  22096. use PHPStan\Type\DynamicMethodReturnTypeExtension;
  22097. use PHPStan\Type\IntegerRangeType;
  22098. use PHPStan\Type\IntegerType;
  22099. use PHPStan\Type\MixedType;
  22100. use PHPStan\Type\StringType;
  22101. use PHPStan\Type\Type;
  22102. use PHPStan\Type\TypeCombinator;
  22103. use PHPStan\Type\TypeUtils;
  22104. use PHPStan\Type\UnionType;
  22105. final class ConfigReturnTypeExtension implements DynamicMethodReturnTypeExtension
  22106. {
  22107. private $properties = [];
  22108. public function __construct()
  22109. {
  22110. $schema = JsonFile::parseJson((string) file_get_contents(JsonFile::COMPOSER_SCHEMA_PATH));
  22111. foreach ($schema['properties']['config']['properties'] as $prop => $conf) {
  22112. $type = $this->parseType($conf, $prop);
  22113. $this->properties[$prop] = $type;
  22114. }
  22115. }
  22116. public function getClass(): string
  22117. {
  22118. return Config::class;
  22119. }
  22120. public function isMethodSupported(MethodReflection $methodReflection): bool
  22121. {
  22122. return strtolower($methodReflection->getName()) === 'get';
  22123. }
  22124. public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
  22125. {
  22126. $args = $methodCall->getArgs();
  22127. $defaultReturn = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
  22128. if (count($args) < 1) {
  22129. return $defaultReturn;
  22130. }
  22131. $keyType = $scope->getType($args[0]->value);
  22132. if (method_exists($keyType, 'getConstantStrings')) {
  22133. $strings = $keyType->getConstantStrings();
  22134. } else {
  22135. $strings = TypeUtils::getConstantStrings($keyType);
  22136. }
  22137. if ($strings !== []) {
  22138. $types = [];
  22139. foreach($strings as $string) {
  22140. if (!isset($this->properties[$string->getValue()])) {
  22141. return $defaultReturn;
  22142. }
  22143. $types[] = $this->properties[$string->getValue()];
  22144. }
  22145. return TypeCombinator::union(...$types);
  22146. }
  22147. return $defaultReturn;
  22148. }
  22149. private function parseType(array $def, string $path): Type
  22150. {
  22151. if (isset($def['type'])) {
  22152. $types = [];
  22153. foreach ((array) $def['type'] as $type) {
  22154. switch ($type) {
  22155. case 'integer':
  22156. if (in_array($path, ['process-timeout', 'cache-ttl', 'cache-files-ttl', 'cache-files-maxsize'], true)) {
  22157. $types[] = IntegerRangeType::createAllGreaterThanOrEqualTo(0);
  22158. } else {
  22159. $types[] = new IntegerType();
  22160. }
  22161. break;
  22162. case 'string':
  22163. if ($path === 'cache-files-maxsize') {
  22164. } elseif ($path === 'discard-changes') {
  22165. $types[] = new ConstantStringType('stash');
  22166. } elseif ($path === 'use-parent-dir') {
  22167. $types[] = new ConstantStringType('prompt');
  22168. } elseif ($path === 'store-auths') {
  22169. $types[] = new ConstantStringType('prompt');
  22170. } elseif ($path === 'platform-check') {
  22171. $types[] = new ConstantStringType('php-only');
  22172. } elseif ($path === 'github-protocols') {
  22173. $types[] = new UnionType([new ConstantStringType('git'), new ConstantStringType('https'), new ConstantStringType('ssh'), new ConstantStringType('http')]);
  22174. } elseif (str_starts_with($path, 'preferred-install')) {
  22175. $types[] = new UnionType([new ConstantStringType('source'), new ConstantStringType('dist'), new ConstantStringType('auto')]);
  22176. } else {
  22177. $types[] = new StringType();
  22178. }
  22179. break;
  22180. case 'boolean':
  22181. if ($path === 'platform.additionalProperties') {
  22182. $types[] = new ConstantBooleanType(false);
  22183. } else {
  22184. $types[] = new BooleanType();
  22185. }
  22186. break;
  22187. case 'object':
  22188. $addlPropType = null;
  22189. if (isset($def['additionalProperties'])) {
  22190. $addlPropType = $this->parseType($def['additionalProperties'], $path.'.additionalProperties');
  22191. }
  22192. if (isset($def['properties'])) {
  22193. $keyNames = [];
  22194. $valTypes = [];
  22195. $optionalKeys = [];
  22196. $propIndex = 0;
  22197. foreach ($def['properties'] as $propName => $propdef) {
  22198. $keyNames[] = new ConstantStringType($propName);
  22199. $valType = $this->parseType($propdef, $path.'.'.$propName);
  22200. if (!isset($def['required']) || !in_array($propName, $def['required'], true)) {
  22201. $valType = TypeCombinator::addNull($valType);
  22202. $optionalKeys[] = $propIndex;
  22203. }
  22204. $valTypes[] = $valType;
  22205. $propIndex++;
  22206. }
  22207. if ($addlPropType !== null) {
  22208. $types[] = new ArrayType(TypeCombinator::union(new StringType(), ...$keyNames), TypeCombinator::union($addlPropType, ...$valTypes));
  22209. } else {
  22210. $types[] = new ConstantArrayType($keyNames, $valTypes, [0], $optionalKeys);
  22211. }
  22212. } else {
  22213. $types[] = new ArrayType(new StringType(), $addlPropType ?? new MixedType());
  22214. }
  22215. break;
  22216. case 'array':
  22217. if (isset($def['items'])) {
  22218. $valType = $this->parseType($def['items'], $path.'.items');
  22219. } else {
  22220. $valType = new MixedType();
  22221. }
  22222. $types[] = new ArrayType(new IntegerType(), $valType);
  22223. break;
  22224. default:
  22225. $types[] = new MixedType();
  22226. }
  22227. }
  22228. $type = TypeCombinator::union(...$types);
  22229. } elseif (isset($def['enum'])) {
  22230. $type = TypeCombinator::union(...array_map(static function (string $value): ConstantStringType {
  22231. return new ConstantStringType($value);
  22232. }, $def['enum']));
  22233. } else {
  22234. $type = new MixedType();
  22235. }
  22236. if ($path === 'allow-plugins' && time() < strtotime('2022-07-01')) {
  22237. $type = TypeCombinator::addNull($type);
  22238. }
  22239. if (in_array($path, ['autoloader-suffix', 'gitlab-protocol'], true)) {
  22240. $type = TypeCombinator::addNull($type);
  22241. }
  22242. return $type;
  22243. }
  22244. }
  22245. <?php declare(strict_types=1);
  22246. namespace Composer\PHPStan;
  22247. use Composer\DependencyResolver\Rule;
  22248. use Composer\Package\BasePackage;
  22249. use Composer\Package\Link;
  22250. use Composer\Semver\Constraint\ConstraintInterface;
  22251. use PhpParser\Node\Expr\MethodCall;
  22252. use PHPStan\Analyser\Scope;
  22253. use PHPStan\Reflection\MethodReflection;
  22254. use PHPStan\Type\Accessory\AccessoryNonEmptyStringType;
  22255. use PHPStan\Type\Constant\ConstantArrayType;
  22256. use PHPStan\Type\Constant\ConstantStringType;
  22257. use PHPStan\Type\Constant\ConstantIntegerType;
  22258. use PHPStan\Type\DynamicMethodReturnTypeExtension;
  22259. use PHPStan\Type\IntegerType;
  22260. use PHPStan\Type\StringType;
  22261. use PHPStan\Type\Type;
  22262. use PHPStan\Type\ObjectType;
  22263. use PHPStan\Type\TypeCombinator;
  22264. use PhpParser\Node\Identifier;
  22265. final class RuleReasonDataReturnTypeExtension implements DynamicMethodReturnTypeExtension
  22266. {
  22267. public function getClass(): string
  22268. {
  22269. return Rule::class;
  22270. }
  22271. public function isMethodSupported(MethodReflection $methodReflection): bool
  22272. {
  22273. return strtolower($methodReflection->getName()) === 'getreasondata';
  22274. }
  22275. public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
  22276. {
  22277. $reasonType = $scope->getType(new MethodCall($methodCall->var, new Identifier('getReason')));
  22278. $types = [
  22279. Rule::RULE_ROOT_REQUIRE => new ConstantArrayType([new ConstantStringType('packageName'), new ConstantStringType('constraint')], [new StringType, new ObjectType(ConstraintInterface::class)]),
  22280. Rule::RULE_FIXED => new ConstantArrayType([new ConstantStringType('package')], [new ObjectType(BasePackage::class)]),
  22281. Rule::RULE_PACKAGE_CONFLICT => new ObjectType(Link::class),
  22282. Rule::RULE_PACKAGE_REQUIRES => new ObjectType(Link::class),
  22283. Rule::RULE_PACKAGE_SAME_NAME => TypeCombinator::intersect(new StringType, new AccessoryNonEmptyStringType()),
  22284. Rule::RULE_LEARNED => new IntegerType(),
  22285. Rule::RULE_PACKAGE_ALIAS => new ObjectType(BasePackage::class),
  22286. Rule::RULE_PACKAGE_INVERSE_ALIAS => new ObjectType(BasePackage::class),
  22287. ];
  22288. foreach ($types as $const => $type) {
  22289. if ((new ConstantIntegerType($const))->isSuperTypeOf($reasonType)->yes()) {
  22290. return $type;
  22291. }
  22292. }
  22293. return TypeCombinator::union(...$types);
  22294. }
  22295. }
  22296. <?php declare(strict_types=1);
  22297. namespace Composer\Package;
  22298. use Composer\Semver\Constraint\Constraint;
  22299. use Composer\Package\Version\VersionParser;
  22300. class AliasPackage extends BasePackage
  22301. {
  22302. protected $version;
  22303. protected $prettyVersion;
  22304. protected $dev;
  22305. protected $rootPackageAlias = false;
  22306. protected $stability;
  22307. protected $hasSelfVersionRequires = false;
  22308. protected $aliasOf;
  22309. protected $requires;
  22310. protected $devRequires;
  22311. protected $conflicts;
  22312. protected $provides;
  22313. protected $replaces;
  22314. public function __construct(BasePackage $aliasOf, string $version, string $prettyVersion)
  22315. {
  22316. parent::__construct($aliasOf->getName());
  22317. $this->version = $version;
  22318. $this->prettyVersion = $prettyVersion;
  22319. $this->aliasOf = $aliasOf;
  22320. $this->stability = VersionParser::parseStability($version);
  22321. $this->dev = $this->stability === 'dev';
  22322. foreach (Link::$TYPES as $type) {
  22323. $links = $aliasOf->{'get' . ucfirst($type)}();
  22324. $this->{$type} = $this->replaceSelfVersionDependencies($links, $type);
  22325. }
  22326. }
  22327. public function getAliasOf()
  22328. {
  22329. return $this->aliasOf;
  22330. }
  22331. public function getVersion(): string
  22332. {
  22333. return $this->version;
  22334. }
  22335. public function getStability(): string
  22336. {
  22337. return $this->stability;
  22338. }
  22339. public function getPrettyVersion(): string
  22340. {
  22341. return $this->prettyVersion;
  22342. }
  22343. public function isDev(): bool
  22344. {
  22345. return $this->dev;
  22346. }
  22347. public function getRequires(): array
  22348. {
  22349. return $this->requires;
  22350. }
  22351. public function getConflicts(): array
  22352. {
  22353. return $this->conflicts;
  22354. }
  22355. public function getProvides(): array
  22356. {
  22357. return $this->provides;
  22358. }
  22359. public function getReplaces(): array
  22360. {
  22361. return $this->replaces;
  22362. }
  22363. public function getDevRequires(): array
  22364. {
  22365. return $this->devRequires;
  22366. }
  22367. public function setRootPackageAlias(bool $value): void
  22368. {
  22369. $this->rootPackageAlias = $value;
  22370. }
  22371. public function isRootPackageAlias(): bool
  22372. {
  22373. return $this->rootPackageAlias;
  22374. }
  22375. protected function replaceSelfVersionDependencies(array $links, $linkType): array
  22376. {
  22377. $prettyVersion = $this->prettyVersion;
  22378. if ($prettyVersion === VersionParser::DEFAULT_BRANCH_ALIAS) {
  22379. $prettyVersion = $this->aliasOf->getPrettyVersion();
  22380. }
  22381. if (\in_array($linkType, [Link::TYPE_CONFLICT, Link::TYPE_PROVIDE, Link::TYPE_REPLACE], true)) {
  22382. $newLinks = [];
  22383. foreach ($links as $link) {
  22384. if ('self.version' === $link->getPrettyConstraint()) {
  22385. $newLinks[] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);
  22386. $constraint->setPrettyString($prettyVersion);
  22387. }
  22388. }
  22389. $links = array_merge($links, $newLinks);
  22390. } else {
  22391. foreach ($links as $index => $link) {
  22392. if ('self.version' === $link->getPrettyConstraint()) {
  22393. if ($linkType === Link::TYPE_REQUIRE) {
  22394. $this->hasSelfVersionRequires = true;
  22395. }
  22396. $links[$index] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);
  22397. $constraint->setPrettyString($prettyVersion);
  22398. }
  22399. }
  22400. }
  22401. return $links;
  22402. }
  22403. public function hasSelfVersionRequires(): bool
  22404. {
  22405. return $this->hasSelfVersionRequires;
  22406. }
  22407. public function __toString(): string
  22408. {
  22409. return parent::__toString().' ('.($this->rootPackageAlias ? 'root ' : ''). 'alias of '.$this->aliasOf->getVersion().')';
  22410. }
  22411. public function getType(): string
  22412. {
  22413. return $this->aliasOf->getType();
  22414. }
  22415. public function getTargetDir(): ?string
  22416. {
  22417. return $this->aliasOf->getTargetDir();
  22418. }
  22419. public function getExtra(): array
  22420. {
  22421. return $this->aliasOf->getExtra();
  22422. }
  22423. public function setInstallationSource(?string $type): void
  22424. {
  22425. $this->aliasOf->setInstallationSource($type);
  22426. }
  22427. public function getInstallationSource(): ?string
  22428. {
  22429. return $this->aliasOf->getInstallationSource();
  22430. }
  22431. public function getSourceType(): ?string
  22432. {
  22433. return $this->aliasOf->getSourceType();
  22434. }
  22435. public function getSourceUrl(): ?string
  22436. {
  22437. return $this->aliasOf->getSourceUrl();
  22438. }
  22439. public function getSourceUrls(): array
  22440. {
  22441. return $this->aliasOf->getSourceUrls();
  22442. }
  22443. public function getSourceReference(): ?string
  22444. {
  22445. return $this->aliasOf->getSourceReference();
  22446. }
  22447. public function setSourceReference(?string $reference): void
  22448. {
  22449. $this->aliasOf->setSourceReference($reference);
  22450. }
  22451. public function setSourceMirrors(?array $mirrors): void
  22452. {
  22453. $this->aliasOf->setSourceMirrors($mirrors);
  22454. }
  22455. public function getSourceMirrors(): ?array
  22456. {
  22457. return $this->aliasOf->getSourceMirrors();
  22458. }
  22459. public function getDistType(): ?string
  22460. {
  22461. return $this->aliasOf->getDistType();
  22462. }
  22463. public function getDistUrl(): ?string
  22464. {
  22465. return $this->aliasOf->getDistUrl();
  22466. }
  22467. public function getDistUrls(): array
  22468. {
  22469. return $this->aliasOf->getDistUrls();
  22470. }
  22471. public function getDistReference(): ?string
  22472. {
  22473. return $this->aliasOf->getDistReference();
  22474. }
  22475. public function setDistReference(?string $reference): void
  22476. {
  22477. $this->aliasOf->setDistReference($reference);
  22478. }
  22479. public function getDistSha1Checksum(): ?string
  22480. {
  22481. return $this->aliasOf->getDistSha1Checksum();
  22482. }
  22483. public function setTransportOptions(array $options): void
  22484. {
  22485. $this->aliasOf->setTransportOptions($options);
  22486. }
  22487. public function getTransportOptions(): array
  22488. {
  22489. return $this->aliasOf->getTransportOptions();
  22490. }
  22491. public function setDistMirrors(?array $mirrors): void
  22492. {
  22493. $this->aliasOf->setDistMirrors($mirrors);
  22494. }
  22495. public function getDistMirrors(): ?array
  22496. {
  22497. return $this->aliasOf->getDistMirrors();
  22498. }
  22499. public function getAutoload(): array
  22500. {
  22501. return $this->aliasOf->getAutoload();
  22502. }
  22503. public function getDevAutoload(): array
  22504. {
  22505. return $this->aliasOf->getDevAutoload();
  22506. }
  22507. public function getIncludePaths(): array
  22508. {
  22509. return $this->aliasOf->getIncludePaths();
  22510. }
  22511. public function getReleaseDate(): ?\DateTimeInterface
  22512. {
  22513. return $this->aliasOf->getReleaseDate();
  22514. }
  22515. public function getBinaries(): array
  22516. {
  22517. return $this->aliasOf->getBinaries();
  22518. }
  22519. public function getSuggests(): array
  22520. {
  22521. return $this->aliasOf->getSuggests();
  22522. }
  22523. public function getNotificationUrl(): ?string
  22524. {
  22525. return $this->aliasOf->getNotificationUrl();
  22526. }
  22527. public function isDefaultBranch(): bool
  22528. {
  22529. return $this->aliasOf->isDefaultBranch();
  22530. }
  22531. public function setDistUrl(?string $url): void
  22532. {
  22533. $this->aliasOf->setDistUrl($url);
  22534. }
  22535. public function setDistType(?string $type): void
  22536. {
  22537. $this->aliasOf->setDistType($type);
  22538. }
  22539. public function setSourceDistReferences(string $reference): void
  22540. {
  22541. $this->aliasOf->setSourceDistReferences($reference);
  22542. }
  22543. }
  22544. <?php declare(strict_types=1);
  22545. namespace Composer\Package\Archiver;
  22546. use FilterIterator;
  22547. use Iterator;
  22548. use PharData;
  22549. use SplFileInfo;
  22550. class ArchivableFilesFilter extends FilterIterator
  22551. {
  22552. private $dirs = [];
  22553. public function accept(): bool
  22554. {
  22555. $file = $this->getInnerIterator()->current();
  22556. if ($file->isDir()) {
  22557. $this->dirs[] = (string) $file;
  22558. return false;
  22559. }
  22560. return true;
  22561. }
  22562. public function addEmptyDir(PharData $phar, string $sources): void
  22563. {
  22564. foreach ($this->dirs as $filepath) {
  22565. $localname = str_replace($sources . "/", '', $filepath);
  22566. $phar->addEmptyDir($localname);
  22567. }
  22568. }
  22569. }
  22570. <?php declare(strict_types=1);
  22571. namespace Composer\Package\Archiver;
  22572. use Composer\Pcre\Preg;
  22573. use Composer\Util\Filesystem;
  22574. use FilesystemIterator;
  22575. use FilterIterator;
  22576. use Iterator;
  22577. use Symfony\Component\Finder\Finder;
  22578. use Symfony\Component\Finder\SplFileInfo;
  22579. class ArchivableFilesFinder extends FilterIterator
  22580. {
  22581. protected $finder;
  22582. public function __construct(string $sources, array $excludes, bool $ignoreFilters = false)
  22583. {
  22584. $fs = new Filesystem();
  22585. $sources = $fs->normalizePath(realpath($sources));
  22586. if ($ignoreFilters) {
  22587. $filters = [];
  22588. } else {
  22589. $filters = [
  22590. new GitExcludeFilter($sources),
  22591. new ComposerExcludeFilter($sources, $excludes),
  22592. ];
  22593. }
  22594. $this->finder = new Finder();
  22595. $filter = static function (\SplFileInfo $file) use ($sources, $filters, $fs): bool {
  22596. if ($file->isLink() && ($file->getRealPath() === false || strpos($file->getRealPath(), $sources) !== 0)) {
  22597. return false;
  22598. }
  22599. $relativePath = Preg::replace(
  22600. '#^'.preg_quote($sources, '#').'#',
  22601. '',
  22602. $fs->normalizePath($file->getRealPath())
  22603. );
  22604. $exclude = false;
  22605. foreach ($filters as $filter) {
  22606. $exclude = $filter->filter($relativePath, $exclude);
  22607. }
  22608. return !$exclude;
  22609. };
  22610. if (method_exists($filter, 'bindTo')) {
  22611. $filter = $filter->bindTo(null);
  22612. }
  22613. $this->finder
  22614. ->in($sources)
  22615. ->filter($filter)
  22616. ->ignoreVCS(true)
  22617. ->ignoreDotFiles(false)
  22618. ->sortByName();
  22619. parent::__construct($this->finder->getIterator());
  22620. }
  22621. public function accept(): bool
  22622. {
  22623. $current = $this->getInnerIterator()->current();
  22624. if (!$current->isDir()) {
  22625. return true;
  22626. }
  22627. $iterator = new FilesystemIterator((string) $current, FilesystemIterator::SKIP_DOTS);
  22628. return !$iterator->valid();
  22629. }
  22630. }
  22631. <?php declare(strict_types=1);
  22632. namespace Composer\Package\Archiver;
  22633. use Composer\Downloader\DownloadManager;
  22634. use Composer\Package\RootPackageInterface;
  22635. use Composer\Pcre\Preg;
  22636. use Composer\Util\Filesystem;
  22637. use Composer\Util\Loop;
  22638. use Composer\Util\SyncHelper;
  22639. use Composer\Json\JsonFile;
  22640. use Composer\Package\CompletePackageInterface;
  22641. class ArchiveManager
  22642. {
  22643. protected $downloadManager;
  22644. protected $loop;
  22645. protected $archivers = [];
  22646. protected $overwriteFiles = true;
  22647. public function __construct(DownloadManager $downloadManager, Loop $loop)
  22648. {
  22649. $this->downloadManager = $downloadManager;
  22650. $this->loop = $loop;
  22651. }
  22652. public function addArchiver(ArchiverInterface $archiver): void
  22653. {
  22654. $this->archivers[] = $archiver;
  22655. }
  22656. public function setOverwriteFiles(bool $overwriteFiles): self
  22657. {
  22658. $this->overwriteFiles = $overwriteFiles;
  22659. return $this;
  22660. }
  22661. public function getPackageFilenameParts(CompletePackageInterface $package): array
  22662. {
  22663. $baseName = $package->getArchiveName();
  22664. if (null === $baseName) {
  22665. $baseName = Preg::replace('#[^a-z0-9-_]#i', '-', $package->getName());
  22666. }
  22667. $parts = [
  22668. 'base' => $baseName,
  22669. ];
  22670. $distReference = $package->getDistReference();
  22671. if (null !== $distReference && Preg::isMatch('{^[a-f0-9]{40}$}', $distReference)) {
  22672. $parts['dist_reference'] = $distReference;
  22673. $parts['dist_type'] = $package->getDistType();
  22674. } else {
  22675. $parts['version'] = $package->getPrettyVersion();
  22676. $parts['dist_reference'] = $distReference;
  22677. }
  22678. $sourceReference = $package->getSourceReference();
  22679. if (null !== $sourceReference) {
  22680. $parts['source_reference'] = substr(sha1($sourceReference), 0, 6);
  22681. }
  22682. $parts = array_filter($parts);
  22683. foreach ($parts as $key => $part) {
  22684. $parts[$key] = str_replace('/', '-', $part);
  22685. }
  22686. return $parts;
  22687. }
  22688. public function getPackageFilenameFromParts(array $parts): string
  22689. {
  22690. return implode('-', $parts);
  22691. }
  22692. public function getPackageFilename(CompletePackageInterface $package): string
  22693. {
  22694. return $this->getPackageFilenameFromParts($this->getPackageFilenameParts($package));
  22695. }
  22696. public function archive(CompletePackageInterface $package, string $format, string $targetDir, ?string $fileName = null, bool $ignoreFilters = false): string
  22697. {
  22698. if (empty($format)) {
  22699. throw new \InvalidArgumentException('Format must be specified');
  22700. }
  22701. $usableArchiver = null;
  22702. foreach ($this->archivers as $archiver) {
  22703. if ($archiver->supports($format, $package->getSourceType())) {
  22704. $usableArchiver = $archiver;
  22705. break;
  22706. }
  22707. }
  22708. if (null === $usableArchiver) {
  22709. throw new \RuntimeException(sprintf('No archiver found to support %s format', $format));
  22710. }
  22711. $filesystem = new Filesystem();
  22712. if ($package instanceof RootPackageInterface) {
  22713. $sourcePath = realpath('.');
  22714. } else {
  22715. $sourcePath = sys_get_temp_dir().'/composer_archive'.uniqid();
  22716. $filesystem->ensureDirectoryExists($sourcePath);
  22717. try {
  22718. $promise = $this->downloadManager->download($package, $sourcePath);
  22719. SyncHelper::await($this->loop, $promise);
  22720. $promise = $this->downloadManager->install($package, $sourcePath);
  22721. SyncHelper::await($this->loop, $promise);
  22722. } catch (\Exception $e) {
  22723. $filesystem->removeDirectory($sourcePath);
  22724. throw $e;
  22725. }
  22726. if (file_exists($composerJsonPath = $sourcePath.'/composer.json')) {
  22727. $jsonFile = new JsonFile($composerJsonPath);
  22728. $jsonData = $jsonFile->read();
  22729. if (!empty($jsonData['archive']['name'])) {
  22730. $package->setArchiveName($jsonData['archive']['name']);
  22731. }
  22732. if (!empty($jsonData['archive']['exclude'])) {
  22733. $package->setArchiveExcludes($jsonData['archive']['exclude']);
  22734. }
  22735. }
  22736. }
  22737. $supportedFormats = $this->getSupportedFormats();
  22738. $packageNameParts = null === $fileName ?
  22739. $this->getPackageFilenameParts($package)
  22740. : ['base' => $fileName];
  22741. $packageName = $this->getPackageFilenameFromParts($packageNameParts);
  22742. $excludePatterns = $this->buildExcludePatterns($packageNameParts, $supportedFormats);
  22743. $filesystem->ensureDirectoryExists($targetDir);
  22744. $target = realpath($targetDir).'/'.$packageName.'.'.$format;
  22745. $filesystem->ensureDirectoryExists(dirname($target));
  22746. if (!$this->overwriteFiles && file_exists($target)) {
  22747. return $target;
  22748. }
  22749. $tempTarget = sys_get_temp_dir().'/composer_archive'.uniqid().'.'.$format;
  22750. $filesystem->ensureDirectoryExists(dirname($tempTarget));
  22751. $archivePath = $usableArchiver->archive(
  22752. $sourcePath,
  22753. $tempTarget,
  22754. $format,
  22755. array_merge($excludePatterns, $package->getArchiveExcludes()),
  22756. $ignoreFilters
  22757. );
  22758. $filesystem->rename($archivePath, $target);
  22759. if (!$package instanceof RootPackageInterface) {
  22760. $filesystem->removeDirectory($sourcePath);
  22761. }
  22762. $filesystem->remove($tempTarget);
  22763. return $target;
  22764. }
  22765. private function buildExcludePatterns(array $parts, array $formats): array
  22766. {
  22767. $base = $parts['base'];
  22768. if (count($parts) > 1) {
  22769. $base .= '-*';
  22770. }
  22771. $patterns = [];
  22772. foreach ($formats as $format) {
  22773. $patterns[] = "$base.$format";
  22774. }
  22775. return $patterns;
  22776. }
  22777. private function getSupportedFormats(): array
  22778. {
  22779. $formats = [];
  22780. foreach ($this->archivers as $archiver) {
  22781. $items = [];
  22782. switch (get_class($archiver)) {
  22783. case ZipArchiver::class:
  22784. $items = ['zip'];
  22785. break;
  22786. case PharArchiver::class:
  22787. $items = ['zip', 'tar', 'tar.gz', 'tar.bz2'];
  22788. break;
  22789. }
  22790. $formats = array_merge($formats, $items);
  22791. }
  22792. return array_unique($formats);
  22793. }
  22794. }
  22795. <?php declare(strict_types=1);
  22796. namespace Composer\Package\Archiver;
  22797. interface ArchiverInterface
  22798. {
  22799. public function archive(string $sources, string $target, string $format, array $excludes = [], bool $ignoreFilters = false): string;
  22800. public function supports(string $format, ?string $sourceType): bool;
  22801. }
  22802. <?php declare(strict_types=1);
  22803. namespace Composer\Package\Archiver;
  22804. use Composer\Pcre\Preg;
  22805. use Symfony\Component\Finder;
  22806. abstract class BaseExcludeFilter
  22807. {
  22808. protected $sourcePath;
  22809. protected $excludePatterns;
  22810. public function __construct(string $sourcePath)
  22811. {
  22812. $this->sourcePath = $sourcePath;
  22813. $this->excludePatterns = [];
  22814. }
  22815. public function filter(string $relativePath, bool $exclude): bool
  22816. {
  22817. foreach ($this->excludePatterns as $patternData) {
  22818. [$pattern, $negate, $stripLeadingSlash] = $patternData;
  22819. if ($stripLeadingSlash) {
  22820. $path = substr($relativePath, 1);
  22821. } else {
  22822. $path = $relativePath;
  22823. }
  22824. try {
  22825. if (Preg::isMatch($pattern, $path)) {
  22826. $exclude = !$negate;
  22827. }
  22828. } catch (\RuntimeException $e) {
  22829. }
  22830. }
  22831. return $exclude;
  22832. }
  22833. protected function parseLines(array $lines, callable $lineParser): array
  22834. {
  22835. return array_filter(
  22836. array_map(
  22837. static function ($line) use ($lineParser) {
  22838. $line = trim($line);
  22839. if (!$line || 0 === strpos($line, '#')) {
  22840. return null;
  22841. }
  22842. return $lineParser($line);
  22843. },
  22844. $lines
  22845. ),
  22846. static function ($pattern): bool {
  22847. return $pattern !== null;
  22848. }
  22849. );
  22850. }
  22851. protected function generatePatterns(array $rules): array
  22852. {
  22853. $patterns = [];
  22854. foreach ($rules as $rule) {
  22855. $patterns[] = $this->generatePattern($rule);
  22856. }
  22857. return $patterns;
  22858. }
  22859. protected function generatePattern(string $rule): array
  22860. {
  22861. $negate = false;
  22862. $pattern = '';
  22863. if ($rule !== '' && $rule[0] === '!') {
  22864. $negate = true;
  22865. $rule = ltrim($rule, '!');
  22866. }
  22867. $firstSlashPosition = strpos($rule, '/');
  22868. if (0 === $firstSlashPosition) {
  22869. $pattern = '^/';
  22870. } elseif (false === $firstSlashPosition || strlen($rule) - 1 === $firstSlashPosition) {
  22871. $pattern = '/';
  22872. }
  22873. $rule = trim($rule, '/');
  22874. $rule = substr(Finder\Glob::toRegex($rule), 2, -2);
  22875. return ['{'.$pattern.$rule.'(?=$|/)}', $negate, false];
  22876. }
  22877. }
  22878. <?php declare(strict_types=1);
  22879. namespace Composer\Package\Archiver;
  22880. class ComposerExcludeFilter extends BaseExcludeFilter
  22881. {
  22882. public function __construct(string $sourcePath, array $excludeRules)
  22883. {
  22884. parent::__construct($sourcePath);
  22885. $this->excludePatterns = $this->generatePatterns($excludeRules);
  22886. }
  22887. }
  22888. <?php declare(strict_types=1);
  22889. namespace Composer\Package\Archiver;
  22890. use Composer\Pcre\Preg;
  22891. class GitExcludeFilter extends BaseExcludeFilter
  22892. {
  22893. public function __construct(string $sourcePath)
  22894. {
  22895. parent::__construct($sourcePath);
  22896. if (file_exists($sourcePath.'/.gitattributes')) {
  22897. $this->excludePatterns = array_merge(
  22898. $this->excludePatterns,
  22899. $this->parseLines(
  22900. file($sourcePath.'/.gitattributes'),
  22901. [$this, 'parseGitAttributesLine']
  22902. )
  22903. );
  22904. }
  22905. }
  22906. public function parseGitAttributesLine(string $line): ?array
  22907. {
  22908. $parts = Preg::split('#\s+#', $line);
  22909. if (count($parts) === 2 && $parts[1] === 'export-ignore') {
  22910. return $this->generatePattern($parts[0]);
  22911. }
  22912. if (count($parts) === 2 && $parts[1] === '-export-ignore') {
  22913. return $this->generatePattern('!'.$parts[0]);
  22914. }
  22915. return null;
  22916. }
  22917. }
  22918. <?php declare(strict_types=1);
  22919. namespace Composer\Package\Archiver;
  22920. class PharArchiver implements ArchiverInterface
  22921. {
  22922. protected static $formats = [
  22923. 'zip' => \Phar::ZIP,
  22924. 'tar' => \Phar::TAR,
  22925. 'tar.gz' => \Phar::TAR,
  22926. 'tar.bz2' => \Phar::TAR,
  22927. ];
  22928. protected static $compressFormats = [
  22929. 'tar.gz' => \Phar::GZ,
  22930. 'tar.bz2' => \Phar::BZ2,
  22931. ];
  22932. public function archive(string $sources, string $target, string $format, array $excludes = [], bool $ignoreFilters = false): string
  22933. {
  22934. $sources = realpath($sources);
  22935. if (file_exists($target)) {
  22936. unlink($target);
  22937. }
  22938. try {
  22939. $filename = substr($target, 0, strrpos($target, $format) - 1);
  22940. if (isset(static::$compressFormats[$format])) {
  22941. $target = $filename . '.tar';
  22942. }
  22943. $phar = new \PharData(
  22944. $target,
  22945. \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO,
  22946. '',
  22947. static::$formats[$format]
  22948. );
  22949. $files = new ArchivableFilesFinder($sources, $excludes, $ignoreFilters);
  22950. $filesOnly = new ArchivableFilesFilter($files);
  22951. $phar->buildFromIterator($filesOnly, $sources);
  22952. $filesOnly->addEmptyDir($phar, $sources);
  22953. if (isset(static::$compressFormats[$format])) {
  22954. if (!$phar->canCompress(static::$compressFormats[$format])) {
  22955. throw new \RuntimeException(sprintf('Can not compress to %s format', $format));
  22956. }
  22957. unlink($target);
  22958. $phar->compress(static::$compressFormats[$format]);
  22959. $target = $filename . '.' . $format;
  22960. }
  22961. return $target;
  22962. } catch (\UnexpectedValueException $e) {
  22963. $message = sprintf(
  22964. "Could not create archive '%s' from '%s': %s",
  22965. $target,
  22966. $sources,
  22967. $e->getMessage()
  22968. );
  22969. throw new \RuntimeException($message, $e->getCode(), $e);
  22970. }
  22971. }
  22972. public function supports(string $format, ?string $sourceType): bool
  22973. {
  22974. return isset(static::$formats[$format]);
  22975. }
  22976. }
  22977. <?php declare(strict_types=1);
  22978. namespace Composer\Package\Archiver;
  22979. use ZipArchive;
  22980. use Composer\Util\Filesystem;
  22981. class ZipArchiver implements ArchiverInterface
  22982. {
  22983. protected static $formats = [
  22984. 'zip' => true,
  22985. ];
  22986. public function archive(string $sources, string $target, string $format, array $excludes = [], bool $ignoreFilters = false): string
  22987. {
  22988. $fs = new Filesystem();
  22989. $sourcesRealpath = realpath($sources);
  22990. if (false !== $sourcesRealpath) {
  22991. $sources = $sourcesRealpath;
  22992. }
  22993. unset($sourcesRealpath);
  22994. $sources = $fs->normalizePath($sources);
  22995. $zip = new ZipArchive();
  22996. $res = $zip->open($target, ZipArchive::CREATE);
  22997. if ($res === true) {
  22998. $files = new ArchivableFilesFinder($sources, $excludes, $ignoreFilters);
  22999. foreach ($files as $file) {
  23000. $filepath = strtr($file->getPath()."/".$file->getFilename(), '\\', '/');
  23001. $localname = $filepath;
  23002. if (strpos($localname, $sources . '/') === 0) {
  23003. $localname = substr($localname, strlen($sources . '/'));
  23004. }
  23005. if ($file->isDir()) {
  23006. $zip->addEmptyDir($localname);
  23007. } else {
  23008. $zip->addFile($filepath, $localname);
  23009. }
  23010. if (method_exists($zip, 'setExternalAttributesName')) {
  23011. $perms = fileperms($filepath);
  23012. $zip->setExternalAttributesName($localname, ZipArchive::OPSYS_UNIX, $perms << 16);
  23013. }
  23014. }
  23015. if ($zip->close()) {
  23016. return $target;
  23017. }
  23018. }
  23019. $message = sprintf(
  23020. "Could not create archive '%s' from '%s': %s",
  23021. $target,
  23022. $sources,
  23023. $zip->getStatusString()
  23024. );
  23025. throw new \RuntimeException($message);
  23026. }
  23027. public function supports(string $format, ?string $sourceType): bool
  23028. {
  23029. return isset(static::$formats[$format]) && $this->compressionAvailable();
  23030. }
  23031. private function compressionAvailable(): bool
  23032. {
  23033. return class_exists('ZipArchive');
  23034. }
  23035. }
  23036. <?php declare(strict_types=1);
  23037. namespace Composer\Package;
  23038. use Composer\Repository\RepositoryInterface;
  23039. use Composer\Repository\PlatformRepository;
  23040. abstract class BasePackage implements PackageInterface
  23041. {
  23042. public static $supportedLinkTypes = [
  23043. 'require' => ['description' => 'requires', 'method' => Link::TYPE_REQUIRE],
  23044. 'conflict' => ['description' => 'conflicts', 'method' => Link::TYPE_CONFLICT],
  23045. 'provide' => ['description' => 'provides', 'method' => Link::TYPE_PROVIDE],
  23046. 'replace' => ['description' => 'replaces', 'method' => Link::TYPE_REPLACE],
  23047. 'require-dev' => ['description' => 'requires (for development)', 'method' => Link::TYPE_DEV_REQUIRE],
  23048. ];
  23049. public const STABILITY_STABLE = 0;
  23050. public const STABILITY_RC = 5;
  23051. public const STABILITY_BETA = 10;
  23052. public const STABILITY_ALPHA = 15;
  23053. public const STABILITY_DEV = 20;
  23054. public static $stabilities = [
  23055. 'stable' => self::STABILITY_STABLE,
  23056. 'RC' => self::STABILITY_RC,
  23057. 'beta' => self::STABILITY_BETA,
  23058. 'alpha' => self::STABILITY_ALPHA,
  23059. 'dev' => self::STABILITY_DEV,
  23060. ];
  23061. public $id;
  23062. protected $name;
  23063. protected $prettyName;
  23064. protected $repository = null;
  23065. public function __construct(string $name)
  23066. {
  23067. $this->prettyName = $name;
  23068. $this->name = strtolower($name);
  23069. $this->id = -1;
  23070. }
  23071. public function getName(): string
  23072. {
  23073. return $this->name;
  23074. }
  23075. public function getPrettyName(): string
  23076. {
  23077. return $this->prettyName;
  23078. }
  23079. public function getNames($provides = true): array
  23080. {
  23081. $names = [
  23082. $this->getName() => true,
  23083. ];
  23084. if ($provides) {
  23085. foreach ($this->getProvides() as $link) {
  23086. $names[$link->getTarget()] = true;
  23087. }
  23088. }
  23089. foreach ($this->getReplaces() as $link) {
  23090. $names[$link->getTarget()] = true;
  23091. }
  23092. return array_keys($names);
  23093. }
  23094. public function setId(int $id): void
  23095. {
  23096. $this->id = $id;
  23097. }
  23098. public function getId(): int
  23099. {
  23100. return $this->id;
  23101. }
  23102. public function setRepository(RepositoryInterface $repository): void
  23103. {
  23104. if ($this->repository && $repository !== $this->repository) {
  23105. throw new \LogicException(sprintf(
  23106. 'Package "%s" cannot be added to repository "%s" as it is already in repository "%s".',
  23107. $this->getPrettyName(),
  23108. $repository->getRepoName(),
  23109. $this->repository->getRepoName()
  23110. ));
  23111. }
  23112. $this->repository = $repository;
  23113. }
  23114. public function getRepository(): ?RepositoryInterface
  23115. {
  23116. return $this->repository;
  23117. }
  23118. public function isPlatform(): bool
  23119. {
  23120. return $this->getRepository() instanceof PlatformRepository;
  23121. }
  23122. public function getUniqueName(): string
  23123. {
  23124. return $this->getName().'-'.$this->getVersion();
  23125. }
  23126. public function equals(PackageInterface $package): bool
  23127. {
  23128. $self = $this;
  23129. if ($this instanceof AliasPackage) {
  23130. $self = $this->getAliasOf();
  23131. }
  23132. if ($package instanceof AliasPackage) {
  23133. $package = $package->getAliasOf();
  23134. }
  23135. return $package === $self;
  23136. }
  23137. public function __toString(): string
  23138. {
  23139. return $this->getUniqueName();
  23140. }
  23141. public function getPrettyString(): string
  23142. {
  23143. return $this->getPrettyName().' '.$this->getPrettyVersion();
  23144. }
  23145. public function getFullPrettyVersion(bool $truncate = true, int $displayMode = PackageInterface::DISPLAY_SOURCE_REF_IF_DEV): string
  23146. {
  23147. if ($displayMode === PackageInterface::DISPLAY_SOURCE_REF_IF_DEV &&
  23148. (!$this->isDev() || !\in_array($this->getSourceType(), ['hg', 'git']))
  23149. ) {
  23150. return $this->getPrettyVersion();
  23151. }
  23152. switch ($displayMode) {
  23153. case PackageInterface::DISPLAY_SOURCE_REF_IF_DEV:
  23154. case PackageInterface::DISPLAY_SOURCE_REF:
  23155. $reference = $this->getSourceReference();
  23156. break;
  23157. case PackageInterface::DISPLAY_DIST_REF:
  23158. $reference = $this->getDistReference();
  23159. break;
  23160. default:
  23161. throw new \UnexpectedValueException('Display mode '.$displayMode.' is not supported');
  23162. }
  23163. if (null === $reference) {
  23164. return $this->getPrettyVersion();
  23165. }
  23166. if ($truncate && \strlen($reference) === 40 && $this->getSourceType() !== 'svn') {
  23167. return $this->getPrettyVersion() . ' ' . substr($reference, 0, 7);
  23168. }
  23169. return $this->getPrettyVersion() . ' ' . $reference;
  23170. }
  23171. public function getStabilityPriority(): int
  23172. {
  23173. return self::$stabilities[$this->getStability()];
  23174. }
  23175. public function __clone()
  23176. {
  23177. $this->repository = null;
  23178. $this->id = -1;
  23179. }
  23180. public static function packageNameToRegexp(string $allowPattern, string $wrap = '{^%s$}i'): string
  23181. {
  23182. $cleanedAllowPattern = str_replace('\\*', '.*', preg_quote($allowPattern));
  23183. return sprintf($wrap, $cleanedAllowPattern);
  23184. }
  23185. public static function packageNamesToRegexp(array $packageNames, string $wrap = '{^(?:%s)$}iD'): string
  23186. {
  23187. $packageNames = array_map(
  23188. static function ($packageName): string {
  23189. return BasePackage::packageNameToRegexp($packageName, '%s');
  23190. },
  23191. $packageNames
  23192. );
  23193. return sprintf($wrap, implode('|', $packageNames));
  23194. }
  23195. }
  23196. <?php declare(strict_types=1);
  23197. namespace Composer\Package\Comparer;
  23198. use Composer\Util\Platform;
  23199. class Comparer
  23200. {
  23201. private $source;
  23202. private $update;
  23203. private $changed;
  23204. public function setSource(string $source): void
  23205. {
  23206. $this->source = $source;
  23207. }
  23208. public function setUpdate(string $update): void
  23209. {
  23210. $this->update = $update;
  23211. }
  23212. public function getChanged(bool $explicated = false)
  23213. {
  23214. $changed = $this->changed;
  23215. if (!count($changed)) {
  23216. return false;
  23217. }
  23218. if ($explicated) {
  23219. foreach ($changed as $sectionKey => $itemSection) {
  23220. foreach ($itemSection as $itemKey => $item) {
  23221. $changed[$sectionKey][$itemKey] = $item.' ('.$sectionKey.')';
  23222. }
  23223. }
  23224. }
  23225. return $changed;
  23226. }
  23227. public function getChangedAsString(bool $toString = false, bool $explicated = false): string
  23228. {
  23229. $changed = $this->getChanged($explicated);
  23230. if (false === $changed) {
  23231. return '';
  23232. }
  23233. $strings = [];
  23234. foreach ($changed as $sectionKey => $itemSection) {
  23235. foreach ($itemSection as $itemKey => $item) {
  23236. $strings[] = $item."\r\n";
  23237. }
  23238. }
  23239. return trim(implode("\r\n", $strings));
  23240. }
  23241. public function doCompare(): void
  23242. {
  23243. $source = [];
  23244. $destination = [];
  23245. $this->changed = [];
  23246. $currentDirectory = Platform::getCwd();
  23247. chdir($this->source);
  23248. $source = $this->doTree('.', $source);
  23249. if (!is_array($source)) {
  23250. return;
  23251. }
  23252. chdir($currentDirectory);
  23253. chdir($this->update);
  23254. $destination = $this->doTree('.', $destination);
  23255. if (!is_array($destination)) {
  23256. exit;
  23257. }
  23258. chdir($currentDirectory);
  23259. foreach ($source as $dir => $value) {
  23260. foreach ($value as $file => $hash) {
  23261. if (isset($destination[$dir][$file])) {
  23262. if ($hash !== $destination[$dir][$file]) {
  23263. $this->changed['changed'][] = $dir.'/'.$file;
  23264. }
  23265. } else {
  23266. $this->changed['removed'][] = $dir.'/'.$file;
  23267. }
  23268. }
  23269. }
  23270. foreach ($destination as $dir => $value) {
  23271. foreach ($value as $file => $hash) {
  23272. if (!isset($source[$dir][$file])) {
  23273. $this->changed['added'][] = $dir.'/'.$file;
  23274. }
  23275. }
  23276. }
  23277. }
  23278. private function doTree(string $dir, array &$array)
  23279. {
  23280. if ($dh = opendir($dir)) {
  23281. while ($file = readdir($dh)) {
  23282. if ($file !== '.' && $file !== '..') {
  23283. if (is_link($dir.'/'.$file)) {
  23284. $array[$dir][$file] = readlink($dir.'/'.$file);
  23285. } elseif (is_dir($dir.'/'.$file)) {
  23286. if (!count($array)) {
  23287. $array[0] = 'Temp';
  23288. }
  23289. if (!$this->doTree($dir.'/'.$file, $array)) {
  23290. return false;
  23291. }
  23292. } elseif (is_file($dir.'/'.$file) && filesize($dir.'/'.$file)) {
  23293. $array[$dir][$file] = md5_file($dir.'/'.$file);
  23294. }
  23295. }
  23296. }
  23297. if (count($array) > 1 && isset($array['0'])) {
  23298. unset($array['0']);
  23299. }
  23300. return $array;
  23301. }
  23302. return false;
  23303. }
  23304. }
  23305. <?php declare(strict_types=1);
  23306. namespace Composer\Package;
  23307. class CompleteAliasPackage extends AliasPackage implements CompletePackageInterface
  23308. {
  23309. protected $aliasOf;
  23310. public function __construct(CompletePackage $aliasOf, string $version, string $prettyVersion)
  23311. {
  23312. parent::__construct($aliasOf, $version, $prettyVersion);
  23313. }
  23314. public function getAliasOf()
  23315. {
  23316. return $this->aliasOf;
  23317. }
  23318. public function getScripts(): array
  23319. {
  23320. return $this->aliasOf->getScripts();
  23321. }
  23322. public function setScripts(array $scripts): void
  23323. {
  23324. $this->aliasOf->setScripts($scripts);
  23325. }
  23326. public function getRepositories(): array
  23327. {
  23328. return $this->aliasOf->getRepositories();
  23329. }
  23330. public function setRepositories(array $repositories): void
  23331. {
  23332. $this->aliasOf->setRepositories($repositories);
  23333. }
  23334. public function getLicense(): array
  23335. {
  23336. return $this->aliasOf->getLicense();
  23337. }
  23338. public function setLicense(array $license): void
  23339. {
  23340. $this->aliasOf->setLicense($license);
  23341. }
  23342. public function getKeywords(): array
  23343. {
  23344. return $this->aliasOf->getKeywords();
  23345. }
  23346. public function setKeywords(array $keywords): void
  23347. {
  23348. $this->aliasOf->setKeywords($keywords);
  23349. }
  23350. public function getDescription(): ?string
  23351. {
  23352. return $this->aliasOf->getDescription();
  23353. }
  23354. public function setDescription(?string $description): void
  23355. {
  23356. $this->aliasOf->setDescription($description);
  23357. }
  23358. public function getHomepage(): ?string
  23359. {
  23360. return $this->aliasOf->getHomepage();
  23361. }
  23362. public function setHomepage(?string $homepage): void
  23363. {
  23364. $this->aliasOf->setHomepage($homepage);
  23365. }
  23366. public function getAuthors(): array
  23367. {
  23368. return $this->aliasOf->getAuthors();
  23369. }
  23370. public function setAuthors(array $authors): void
  23371. {
  23372. $this->aliasOf->setAuthors($authors);
  23373. }
  23374. public function getSupport(): array
  23375. {
  23376. return $this->aliasOf->getSupport();
  23377. }
  23378. public function setSupport(array $support): void
  23379. {
  23380. $this->aliasOf->setSupport($support);
  23381. }
  23382. public function getFunding(): array
  23383. {
  23384. return $this->aliasOf->getFunding();
  23385. }
  23386. public function setFunding(array $funding): void
  23387. {
  23388. $this->aliasOf->setFunding($funding);
  23389. }
  23390. public function isAbandoned(): bool
  23391. {
  23392. return $this->aliasOf->isAbandoned();
  23393. }
  23394. public function getReplacementPackage(): ?string
  23395. {
  23396. return $this->aliasOf->getReplacementPackage();
  23397. }
  23398. public function setAbandoned($abandoned): void
  23399. {
  23400. $this->aliasOf->setAbandoned($abandoned);
  23401. }
  23402. public function getArchiveName(): ?string
  23403. {
  23404. return $this->aliasOf->getArchiveName();
  23405. }
  23406. public function setArchiveName(?string $name): void
  23407. {
  23408. $this->aliasOf->setArchiveName($name);
  23409. }
  23410. public function getArchiveExcludes(): array
  23411. {
  23412. return $this->aliasOf->getArchiveExcludes();
  23413. }
  23414. public function setArchiveExcludes(array $excludes): void
  23415. {
  23416. $this->aliasOf->setArchiveExcludes($excludes);
  23417. }
  23418. }
  23419. <?php declare(strict_types=1);
  23420. namespace Composer\Package;
  23421. class CompletePackage extends Package implements CompletePackageInterface
  23422. {
  23423. protected $repositories = [];
  23424. protected $license = [];
  23425. protected $keywords = [];
  23426. protected $authors = [];
  23427. protected $description = null;
  23428. protected $homepage = null;
  23429. protected $scripts = [];
  23430. protected $support = [];
  23431. protected $funding = [];
  23432. protected $abandoned = false;
  23433. protected $archiveName = null;
  23434. protected $archiveExcludes = [];
  23435. public function setScripts(array $scripts): void
  23436. {
  23437. $this->scripts = $scripts;
  23438. }
  23439. public function getScripts(): array
  23440. {
  23441. return $this->scripts;
  23442. }
  23443. public function setRepositories(array $repositories): void
  23444. {
  23445. $this->repositories = $repositories;
  23446. }
  23447. public function getRepositories(): array
  23448. {
  23449. return $this->repositories;
  23450. }
  23451. public function setLicense(array $license): void
  23452. {
  23453. $this->license = $license;
  23454. }
  23455. public function getLicense(): array
  23456. {
  23457. return $this->license;
  23458. }
  23459. public function setKeywords(array $keywords): void
  23460. {
  23461. $this->keywords = $keywords;
  23462. }
  23463. public function getKeywords(): array
  23464. {
  23465. return $this->keywords;
  23466. }
  23467. public function setAuthors(array $authors): void
  23468. {
  23469. $this->authors = $authors;
  23470. }
  23471. public function getAuthors(): array
  23472. {
  23473. return $this->authors;
  23474. }
  23475. public function setDescription(?string $description): void
  23476. {
  23477. $this->description = $description;
  23478. }
  23479. public function getDescription(): ?string
  23480. {
  23481. return $this->description;
  23482. }
  23483. public function setHomepage(?string $homepage): void
  23484. {
  23485. $this->homepage = $homepage;
  23486. }
  23487. public function getHomepage(): ?string
  23488. {
  23489. return $this->homepage;
  23490. }
  23491. public function setSupport(array $support): void
  23492. {
  23493. $this->support = $support;
  23494. }
  23495. public function getSupport(): array
  23496. {
  23497. return $this->support;
  23498. }
  23499. public function setFunding(array $funding): void
  23500. {
  23501. $this->funding = $funding;
  23502. }
  23503. public function getFunding(): array
  23504. {
  23505. return $this->funding;
  23506. }
  23507. public function isAbandoned(): bool
  23508. {
  23509. return (bool) $this->abandoned;
  23510. }
  23511. public function setAbandoned($abandoned): void
  23512. {
  23513. $this->abandoned = $abandoned;
  23514. }
  23515. public function getReplacementPackage(): ?string
  23516. {
  23517. return \is_string($this->abandoned) ? $this->abandoned : null;
  23518. }
  23519. public function setArchiveName(?string $name): void
  23520. {
  23521. $this->archiveName = $name;
  23522. }
  23523. public function getArchiveName(): ?string
  23524. {
  23525. return $this->archiveName;
  23526. }
  23527. public function setArchiveExcludes(array $excludes): void
  23528. {
  23529. $this->archiveExcludes = $excludes;
  23530. }
  23531. public function getArchiveExcludes(): array
  23532. {
  23533. return $this->archiveExcludes;
  23534. }
  23535. }
  23536. <?php declare(strict_types=1);
  23537. namespace Composer\Package;
  23538. interface CompletePackageInterface extends PackageInterface
  23539. {
  23540. public function getScripts(): array;
  23541. public function setScripts(array $scripts): void;
  23542. public function getRepositories(): array;
  23543. public function setRepositories(array $repositories): void;
  23544. public function getLicense(): array;
  23545. public function setLicense(array $license): void;
  23546. public function getKeywords(): array;
  23547. public function setKeywords(array $keywords): void;
  23548. public function getDescription(): ?string;
  23549. public function setDescription(string $description): void;
  23550. public function getHomepage(): ?string;
  23551. public function setHomepage(string $homepage): void;
  23552. public function getAuthors(): array;
  23553. public function setAuthors(array $authors): void;
  23554. public function getSupport(): array;
  23555. public function setSupport(array $support): void;
  23556. public function getFunding(): array;
  23557. public function setFunding(array $funding): void;
  23558. public function isAbandoned(): bool;
  23559. public function getReplacementPackage(): ?string;
  23560. public function setAbandoned($abandoned): void;
  23561. public function getArchiveName(): ?string;
  23562. public function setArchiveName(string $name): void;
  23563. public function getArchiveExcludes(): array;
  23564. public function setArchiveExcludes(array $excludes): void;
  23565. }
  23566. <?php declare(strict_types=1);
  23567. namespace Composer\Package\Dumper;
  23568. use Composer\Package\BasePackage;
  23569. use Composer\Package\PackageInterface;
  23570. use Composer\Package\CompletePackageInterface;
  23571. use Composer\Package\RootPackageInterface;
  23572. class ArrayDumper
  23573. {
  23574. public function dump(PackageInterface $package): array
  23575. {
  23576. $keys = [
  23577. 'binaries' => 'bin',
  23578. 'type',
  23579. 'extra',
  23580. 'installationSource' => 'installation-source',
  23581. 'autoload',
  23582. 'devAutoload' => 'autoload-dev',
  23583. 'notificationUrl' => 'notification-url',
  23584. 'includePaths' => 'include-path',
  23585. ];
  23586. $data = [];
  23587. $data['name'] = $package->getPrettyName();
  23588. $data['version'] = $package->getPrettyVersion();
  23589. $data['version_normalized'] = $package->getVersion();
  23590. if ($package->getTargetDir()) {
  23591. $data['target-dir'] = $package->getTargetDir();
  23592. }
  23593. if ($package->getSourceType()) {
  23594. $data['source']['type'] = $package->getSourceType();
  23595. $data['source']['url'] = $package->getSourceUrl();
  23596. if (null !== ($value = $package->getSourceReference())) {
  23597. $data['source']['reference'] = $value;
  23598. }
  23599. if ($mirrors = $package->getSourceMirrors()) {
  23600. $data['source']['mirrors'] = $mirrors;
  23601. }
  23602. }
  23603. if ($package->getDistType()) {
  23604. $data['dist']['type'] = $package->getDistType();
  23605. $data['dist']['url'] = $package->getDistUrl();
  23606. if (null !== ($value = $package->getDistReference())) {
  23607. $data['dist']['reference'] = $value;
  23608. }
  23609. if (null !== ($value = $package->getDistSha1Checksum())) {
  23610. $data['dist']['shasum'] = $value;
  23611. }
  23612. if ($mirrors = $package->getDistMirrors()) {
  23613. $data['dist']['mirrors'] = $mirrors;
  23614. }
  23615. }
  23616. foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
  23617. if ($links = $package->{'get'.ucfirst($opts['method'])}()) {
  23618. foreach ($links as $link) {
  23619. $data[$type][$link->getTarget()] = $link->getPrettyConstraint();
  23620. }
  23621. ksort($data[$type]);
  23622. }
  23623. }
  23624. if ($packages = $package->getSuggests()) {
  23625. ksort($packages);
  23626. $data['suggest'] = $packages;
  23627. }
  23628. if ($package->getReleaseDate() instanceof \DateTimeInterface) {
  23629. $data['time'] = $package->getReleaseDate()->format(DATE_RFC3339);
  23630. }
  23631. if ($package->isDefaultBranch()) {
  23632. $data['default-branch'] = true;
  23633. }
  23634. $data = $this->dumpValues($package, $keys, $data);
  23635. if ($package instanceof CompletePackageInterface) {
  23636. if ($package->getArchiveName()) {
  23637. $data['archive']['name'] = $package->getArchiveName();
  23638. }
  23639. if ($package->getArchiveExcludes()) {
  23640. $data['archive']['exclude'] = $package->getArchiveExcludes();
  23641. }
  23642. $keys = [
  23643. 'scripts',
  23644. 'license',
  23645. 'authors',
  23646. 'description',
  23647. 'homepage',
  23648. 'keywords',
  23649. 'repositories',
  23650. 'support',
  23651. 'funding',
  23652. ];
  23653. $data = $this->dumpValues($package, $keys, $data);
  23654. if (isset($data['keywords']) && \is_array($data['keywords'])) {
  23655. sort($data['keywords']);
  23656. }
  23657. if ($package->isAbandoned()) {
  23658. $data['abandoned'] = $package->getReplacementPackage() ?: true;
  23659. }
  23660. }
  23661. if ($package instanceof RootPackageInterface) {
  23662. $minimumStability = $package->getMinimumStability();
  23663. if ($minimumStability) {
  23664. $data['minimum-stability'] = $minimumStability;
  23665. }
  23666. }
  23667. if (\count($package->getTransportOptions()) > 0) {
  23668. $data['transport-options'] = $package->getTransportOptions();
  23669. }
  23670. return $data;
  23671. }
  23672. private function dumpValues(PackageInterface $package, array $keys, array $data): array
  23673. {
  23674. foreach ($keys as $method => $key) {
  23675. if (is_numeric($method)) {
  23676. $method = $key;
  23677. }
  23678. $getter = 'get'.ucfirst($method);
  23679. $value = $package->{$getter}();
  23680. if (null !== $value && !(\is_array($value) && 0 === \count($value))) {
  23681. $data[$key] = $value;
  23682. }
  23683. }
  23684. return $data;
  23685. }
  23686. }
  23687. <?php declare(strict_types=1);
  23688. namespace Composer\Package;
  23689. use Composer\Semver\Constraint\ConstraintInterface;
  23690. class Link
  23691. {
  23692. public const TYPE_REQUIRE = 'requires';
  23693. public const TYPE_DEV_REQUIRE = 'devRequires';
  23694. public const TYPE_PROVIDE = 'provides';
  23695. public const TYPE_CONFLICT = 'conflicts';
  23696. public const TYPE_REPLACE = 'replaces';
  23697. public const TYPE_DOES_NOT_REQUIRE = 'does not require';
  23698. private const TYPE_UNKNOWN = 'relates to';
  23699. public static $TYPES = [
  23700. self::TYPE_REQUIRE,
  23701. self::TYPE_DEV_REQUIRE,
  23702. self::TYPE_PROVIDE,
  23703. self::TYPE_CONFLICT,
  23704. self::TYPE_REPLACE,
  23705. ];
  23706. protected $source;
  23707. protected $target;
  23708. protected $constraint;
  23709. protected $description;
  23710. protected $prettyConstraint;
  23711. public function __construct(
  23712. string $source,
  23713. string $target,
  23714. ConstraintInterface $constraint,
  23715. $description = self::TYPE_UNKNOWN,
  23716. ?string $prettyConstraint = null
  23717. ) {
  23718. $this->source = strtolower($source);
  23719. $this->target = strtolower($target);
  23720. $this->constraint = $constraint;
  23721. $this->description = self::TYPE_DEV_REQUIRE === $description ? 'requires (for development)' : $description;
  23722. $this->prettyConstraint = $prettyConstraint;
  23723. }
  23724. public function getDescription(): string
  23725. {
  23726. return $this->description;
  23727. }
  23728. public function getSource(): string
  23729. {
  23730. return $this->source;
  23731. }
  23732. public function getTarget(): string
  23733. {
  23734. return $this->target;
  23735. }
  23736. public function getConstraint(): ConstraintInterface
  23737. {
  23738. return $this->constraint;
  23739. }
  23740. public function getPrettyConstraint(): string
  23741. {
  23742. if (null === $this->prettyConstraint) {
  23743. throw new \UnexpectedValueException(sprintf('Link %s has been misconfigured and had no prettyConstraint given.', $this));
  23744. }
  23745. return $this->prettyConstraint;
  23746. }
  23747. public function __toString(): string
  23748. {
  23749. return $this->source.' '.$this->description.' '.$this->target.' ('.$this->constraint.')';
  23750. }
  23751. public function getPrettyString(PackageInterface $sourcePackage): string
  23752. {
  23753. return $sourcePackage->getPrettyString().' '.$this->description.' '.$this->target.' '.$this->constraint->getPrettyString();
  23754. }
  23755. }
  23756. <?php declare(strict_types=1);
  23757. namespace Composer\Package\Loader;
  23758. use Composer\Package\BasePackage;
  23759. use Composer\Package\CompleteAliasPackage;
  23760. use Composer\Package\CompletePackage;
  23761. use Composer\Package\RootPackage;
  23762. use Composer\Package\PackageInterface;
  23763. use Composer\Package\CompletePackageInterface;
  23764. use Composer\Package\Link;
  23765. use Composer\Package\RootAliasPackage;
  23766. use Composer\Package\Version\VersionParser;
  23767. use Composer\Pcre\Preg;
  23768. class ArrayLoader implements LoaderInterface
  23769. {
  23770. protected $versionParser;
  23771. protected $loadOptions;
  23772. public function __construct(?VersionParser $parser = null, bool $loadOptions = false)
  23773. {
  23774. if (!$parser) {
  23775. $parser = new VersionParser;
  23776. }
  23777. $this->versionParser = $parser;
  23778. $this->loadOptions = $loadOptions;
  23779. }
  23780. public function load(array $config, string $class = 'Composer\Package\CompletePackage'): BasePackage
  23781. {
  23782. if ($class !== 'Composer\Package\CompletePackage' && $class !== 'Composer\Package\RootPackage') {
  23783. trigger_error('The $class arg is deprecated, please reach out to Composer maintainers ASAP if you still need this.', E_USER_DEPRECATED);
  23784. }
  23785. $package = $this->createObject($config, $class);
  23786. foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
  23787. if (!isset($config[$type]) || !is_array($config[$type])) {
  23788. continue;
  23789. }
  23790. $method = 'set'.ucfirst($opts['method']);
  23791. $package->{$method}(
  23792. $this->parseLinks(
  23793. $package->getName(),
  23794. $package->getPrettyVersion(),
  23795. $opts['method'],
  23796. $config[$type]
  23797. )
  23798. );
  23799. }
  23800. $package = $this->configureObject($package, $config);
  23801. return $package;
  23802. }
  23803. public function loadPackages(array $versions): array
  23804. {
  23805. $packages = [];
  23806. $linkCache = [];
  23807. foreach ($versions as $version) {
  23808. $package = $this->createObject($version, 'Composer\Package\CompletePackage');
  23809. $this->configureCachedLinks($linkCache, $package, $version);
  23810. $package = $this->configureObject($package, $version);
  23811. $packages[] = $package;
  23812. }
  23813. return $packages;
  23814. }
  23815. private function createObject(array $config, string $class): CompletePackage
  23816. {
  23817. if (!isset($config['name'])) {
  23818. throw new \UnexpectedValueException('Unknown package has no name defined ('.json_encode($config).').');
  23819. }
  23820. if (!isset($config['version']) || !is_scalar($config['version'])) {
  23821. throw new \UnexpectedValueException('Package '.$config['name'].' has no version defined.');
  23822. }
  23823. if (!is_string($config['version'])) {
  23824. $config['version'] = (string) $config['version'];
  23825. }
  23826. if (isset($config['version_normalized']) && is_string($config['version_normalized'])) {
  23827. $version = $config['version_normalized'];
  23828. if ($version === VersionParser::DEFAULT_BRANCH_ALIAS) {
  23829. $version = $this->versionParser->normalize($config['version']);
  23830. }
  23831. } else {
  23832. $version = $this->versionParser->normalize($config['version']);
  23833. }
  23834. return new $class($config['name'], $version, $config['version']);
  23835. }
  23836. private function configureObject(PackageInterface $package, array $config): BasePackage
  23837. {
  23838. if (!$package instanceof CompletePackage) {
  23839. throw new \LogicException('ArrayLoader expects instances of the Composer\Package\CompletePackage class to function correctly');
  23840. }
  23841. $package->setType(isset($config['type']) ? strtolower($config['type']) : 'library');
  23842. if (isset($config['target-dir'])) {
  23843. $package->setTargetDir($config['target-dir']);
  23844. }
  23845. if (isset($config['extra']) && \is_array($config['extra'])) {
  23846. $package->setExtra($config['extra']);
  23847. }
  23848. if (isset($config['bin'])) {
  23849. if (!\is_array($config['bin'])) {
  23850. $config['bin'] = [$config['bin']];
  23851. }
  23852. foreach ($config['bin'] as $key => $bin) {
  23853. $config['bin'][$key] = ltrim($bin, '/');
  23854. }
  23855. $package->setBinaries($config['bin']);
  23856. }
  23857. if (isset($config['installation-source'])) {
  23858. $package->setInstallationSource($config['installation-source']);
  23859. }
  23860. if (isset($config['default-branch']) && $config['default-branch'] === true) {
  23861. $package->setIsDefaultBranch(true);
  23862. }
  23863. if (isset($config['source'])) {
  23864. if (!isset($config['source']['type'], $config['source']['url'], $config['source']['reference'])) {
  23865. throw new \UnexpectedValueException(sprintf(
  23866. "Package %s's source key should be specified as {\"type\": ..., \"url\": ..., \"reference\": ...},\n%s given.",
  23867. $config['name'],
  23868. json_encode($config['source'])
  23869. ));
  23870. }
  23871. $package->setSourceType($config['source']['type']);
  23872. $package->setSourceUrl($config['source']['url']);
  23873. $package->setSourceReference(isset($config['source']['reference']) ? (string) $config['source']['reference'] : null);
  23874. if (isset($config['source']['mirrors'])) {
  23875. $package->setSourceMirrors($config['source']['mirrors']);
  23876. }
  23877. }
  23878. if (isset($config['dist'])) {
  23879. if (!isset($config['dist']['type'], $config['dist']['url'])) {
  23880. throw new \UnexpectedValueException(sprintf(
  23881. "Package %s's dist key should be specified as ".
  23882. "{\"type\": ..., \"url\": ..., \"reference\": ..., \"shasum\": ...},\n%s given.",
  23883. $config['name'],
  23884. json_encode($config['dist'])
  23885. ));
  23886. }
  23887. $package->setDistType($config['dist']['type']);
  23888. $package->setDistUrl($config['dist']['url']);
  23889. $package->setDistReference(isset($config['dist']['reference']) ? (string) $config['dist']['reference'] : null);
  23890. $package->setDistSha1Checksum($config['dist']['shasum'] ?? null);
  23891. if (isset($config['dist']['mirrors'])) {
  23892. $package->setDistMirrors($config['dist']['mirrors']);
  23893. }
  23894. }
  23895. if (isset($config['suggest']) && \is_array($config['suggest'])) {
  23896. foreach ($config['suggest'] as $target => $reason) {
  23897. if ('self.version' === trim($reason)) {
  23898. $config['suggest'][$target] = $package->getPrettyVersion();
  23899. }
  23900. }
  23901. $package->setSuggests($config['suggest']);
  23902. }
  23903. if (isset($config['autoload'])) {
  23904. $package->setAutoload($config['autoload']);
  23905. }
  23906. if (isset($config['autoload-dev'])) {
  23907. $package->setDevAutoload($config['autoload-dev']);
  23908. }
  23909. if (isset($config['include-path'])) {
  23910. $package->setIncludePaths($config['include-path']);
  23911. }
  23912. if (!empty($config['time'])) {
  23913. $time = Preg::isMatch('/^\d++$/D', $config['time']) ? '@'.$config['time'] : $config['time'];
  23914. try {
  23915. $date = new \DateTime($time, new \DateTimeZone('UTC'));
  23916. $package->setReleaseDate($date);
  23917. } catch (\Exception $e) {
  23918. }
  23919. }
  23920. if (!empty($config['notification-url'])) {
  23921. $package->setNotificationUrl($config['notification-url']);
  23922. }
  23923. if ($package instanceof CompletePackageInterface) {
  23924. if (!empty($config['archive']['name'])) {
  23925. $package->setArchiveName($config['archive']['name']);
  23926. }
  23927. if (!empty($config['archive']['exclude'])) {
  23928. $package->setArchiveExcludes($config['archive']['exclude']);
  23929. }
  23930. if (isset($config['scripts']) && \is_array($config['scripts'])) {
  23931. foreach ($config['scripts'] as $event => $listeners) {
  23932. $config['scripts'][$event] = (array) $listeners;
  23933. }
  23934. foreach (['composer', 'php', 'putenv'] as $reserved) {
  23935. if (isset($config['scripts'][$reserved])) {
  23936. trigger_error('The `'.$reserved.'` script name is reserved for internal use, please avoid defining it', E_USER_DEPRECATED);
  23937. }
  23938. }
  23939. $package->setScripts($config['scripts']);
  23940. }
  23941. if (!empty($config['description']) && \is_string($config['description'])) {
  23942. $package->setDescription($config['description']);
  23943. }
  23944. if (!empty($config['homepage']) && \is_string($config['homepage'])) {
  23945. $package->setHomepage($config['homepage']);
  23946. }
  23947. if (!empty($config['keywords']) && \is_array($config['keywords'])) {
  23948. $package->setKeywords(array_map('strval', $config['keywords']));
  23949. }
  23950. if (!empty($config['license'])) {
  23951. $package->setLicense(\is_array($config['license']) ? $config['license'] : [$config['license']]);
  23952. }
  23953. if (!empty($config['authors']) && \is_array($config['authors'])) {
  23954. $package->setAuthors($config['authors']);
  23955. }
  23956. if (isset($config['support']) && \is_array($config['support'])) {
  23957. $package->setSupport($config['support']);
  23958. }
  23959. if (!empty($config['funding']) && \is_array($config['funding'])) {
  23960. $package->setFunding($config['funding']);
  23961. }
  23962. if (isset($config['abandoned'])) {
  23963. $package->setAbandoned($config['abandoned']);
  23964. }
  23965. }
  23966. if ($this->loadOptions && isset($config['transport-options'])) {
  23967. $package->setTransportOptions($config['transport-options']);
  23968. }
  23969. if ($aliasNormalized = $this->getBranchAlias($config)) {
  23970. $prettyAlias = Preg::replace('{(\.9{7})+}', '.x', $aliasNormalized);
  23971. if ($package instanceof RootPackage) {
  23972. return new RootAliasPackage($package, $aliasNormalized, $prettyAlias);
  23973. }
  23974. return new CompleteAliasPackage($package, $aliasNormalized, $prettyAlias);
  23975. }
  23976. return $package;
  23977. }
  23978. private function configureCachedLinks(array &$linkCache, PackageInterface $package, array $config): void
  23979. {
  23980. $name = $package->getName();
  23981. $prettyVersion = $package->getPrettyVersion();
  23982. foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
  23983. if (isset($config[$type])) {
  23984. $method = 'set'.ucfirst($opts['method']);
  23985. $links = [];
  23986. foreach ($config[$type] as $prettyTarget => $constraint) {
  23987. $target = strtolower($prettyTarget);
  23988. if ($target === $name) {
  23989. continue;
  23990. }
  23991. if ($constraint === 'self.version') {
  23992. $links[$target] = $this->createLink($name, $prettyVersion, $opts['method'], $target, $constraint);
  23993. } else {
  23994. if (!isset($linkCache[$name][$type][$target][$constraint])) {
  23995. $linkCache[$name][$type][$target][$constraint] = [$target, $this->createLink($name, $prettyVersion, $opts['method'], $target, $constraint)];
  23996. }
  23997. [$target, $link] = $linkCache[$name][$type][$target][$constraint];
  23998. $links[$target] = $link;
  23999. }
  24000. }
  24001. $package->{$method}($links);
  24002. }
  24003. }
  24004. }
  24005. public function parseLinks(string $source, string $sourceVersion, string $description, array $links): array
  24006. {
  24007. $res = [];
  24008. foreach ($links as $target => $constraint) {
  24009. if (!is_string($constraint)) {
  24010. continue;
  24011. }
  24012. $target = strtolower((string) $target);
  24013. $res[$target] = $this->createLink($source, $sourceVersion, $description, $target, $constraint);
  24014. }
  24015. return $res;
  24016. }
  24017. private function createLink(string $source, string $sourceVersion, string $description, string $target, string $prettyConstraint): Link
  24018. {
  24019. if (!\is_string($prettyConstraint)) {
  24020. throw new \UnexpectedValueException('Link constraint in '.$source.' '.$description.' > '.$target.' should be a string, got '.\gettype($prettyConstraint) . ' (' . var_export($prettyConstraint, true) . ')');
  24021. }
  24022. if ('self.version' === $prettyConstraint) {
  24023. $parsedConstraint = $this->versionParser->parseConstraints($sourceVersion);
  24024. } else {
  24025. $parsedConstraint = $this->versionParser->parseConstraints($prettyConstraint);
  24026. }
  24027. return new Link($source, $target, $parsedConstraint, $description, $prettyConstraint);
  24028. }
  24029. public function getBranchAlias(array $config): ?string
  24030. {
  24031. if (!isset($config['version']) || !is_scalar($config['version'])) {
  24032. throw new \UnexpectedValueException('no/invalid version defined');
  24033. }
  24034. if (!is_string($config['version'])) {
  24035. $config['version'] = (string) $config['version'];
  24036. }
  24037. if (strpos($config['version'], 'dev-') !== 0 && '-dev' !== substr($config['version'], -4)) {
  24038. return null;
  24039. }
  24040. if (isset($config['extra']['branch-alias']) && \is_array($config['extra']['branch-alias'])) {
  24041. foreach ($config['extra']['branch-alias'] as $sourceBranch => $targetBranch) {
  24042. $sourceBranch = (string) $sourceBranch;
  24043. if ('-dev' !== substr($targetBranch, -4)) {
  24044. continue;
  24045. }
  24046. if ($targetBranch === VersionParser::DEFAULT_BRANCH_ALIAS) {
  24047. $validatedTargetBranch = VersionParser::DEFAULT_BRANCH_ALIAS;
  24048. } else {
  24049. $validatedTargetBranch = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4));
  24050. }
  24051. if ('-dev' !== substr($validatedTargetBranch, -4)) {
  24052. continue;
  24053. }
  24054. if (strtolower($config['version']) !== strtolower($sourceBranch)) {
  24055. continue;
  24056. }
  24057. if (($sourcePrefix = $this->versionParser->parseNumericAliasPrefix($sourceBranch))
  24058. && ($targetPrefix = $this->versionParser->parseNumericAliasPrefix($targetBranch))
  24059. && (stripos($targetPrefix, $sourcePrefix) !== 0)
  24060. ) {
  24061. continue;
  24062. }
  24063. return $validatedTargetBranch;
  24064. }
  24065. }
  24066. if (
  24067. isset($config['default-branch'])
  24068. && $config['default-branch'] === true
  24069. && false === $this->versionParser->parseNumericAliasPrefix(Preg::replace('{^v}', '', $config['version']))
  24070. ) {
  24071. return VersionParser::DEFAULT_BRANCH_ALIAS;
  24072. }
  24073. return null;
  24074. }
  24075. }
  24076. <?php declare(strict_types=1);
  24077. namespace Composer\Package\Loader;
  24078. class InvalidPackageException extends \Exception
  24079. {
  24080. private $errors;
  24081. private $warnings;
  24082. private $data;
  24083. public function __construct(array $errors, array $warnings, array $data)
  24084. {
  24085. $this->errors = $errors;
  24086. $this->warnings = $warnings;
  24087. $this->data = $data;
  24088. parent::__construct("Invalid package information: \n".implode("\n", array_merge($errors, $warnings)));
  24089. }
  24090. public function getData(): array
  24091. {
  24092. return $this->data;
  24093. }
  24094. public function getErrors(): array
  24095. {
  24096. return $this->errors;
  24097. }
  24098. public function getWarnings(): array
  24099. {
  24100. return $this->warnings;
  24101. }
  24102. }
  24103. <?php declare(strict_types=1);
  24104. namespace Composer\Package\Loader;
  24105. use Composer\Json\JsonFile;
  24106. use Composer\Package\BasePackage;
  24107. use Composer\Package\CompletePackage;
  24108. use Composer\Package\CompleteAliasPackage;
  24109. use Composer\Package\RootPackage;
  24110. use Composer\Package\RootAliasPackage;
  24111. class JsonLoader
  24112. {
  24113. private $loader;
  24114. public function __construct(LoaderInterface $loader)
  24115. {
  24116. $this->loader = $loader;
  24117. }
  24118. public function load($json): BasePackage
  24119. {
  24120. if ($json instanceof JsonFile) {
  24121. $config = $json->read();
  24122. } elseif (file_exists($json)) {
  24123. $config = JsonFile::parseJson(file_get_contents($json), $json);
  24124. } elseif (is_string($json)) {
  24125. $config = JsonFile::parseJson($json);
  24126. } else {
  24127. throw new \InvalidArgumentException(sprintf(
  24128. "JsonLoader: Unknown \$json parameter %s. Please report at https://github.com/composer/composer/issues/new.",
  24129. gettype($json)
  24130. ));
  24131. }
  24132. return $this->loader->load($config);
  24133. }
  24134. }
  24135. <?php declare(strict_types=1);
  24136. namespace Composer\Package\Loader;
  24137. use Composer\Package\CompletePackage;
  24138. use Composer\Package\CompleteAliasPackage;
  24139. use Composer\Package\RootAliasPackage;
  24140. use Composer\Package\RootPackage;
  24141. use Composer\Package\BasePackage;
  24142. interface LoaderInterface
  24143. {
  24144. public function load(array $config, string $class = 'Composer\Package\CompletePackage'): BasePackage;
  24145. }
  24146. <?php declare(strict_types=1);
  24147. namespace Composer\Package\Loader;
  24148. use Composer\Package\BasePackage;
  24149. use Composer\Config;
  24150. use Composer\IO\IOInterface;
  24151. use Composer\Package\RootAliasPackage;
  24152. use Composer\Pcre\Preg;
  24153. use Composer\Repository\RepositoryFactory;
  24154. use Composer\Package\Version\VersionGuesser;
  24155. use Composer\Package\Version\VersionParser;
  24156. use Composer\Package\RootPackage;
  24157. use Composer\Repository\RepositoryManager;
  24158. use Composer\Util\Platform;
  24159. use Composer\Util\ProcessExecutor;
  24160. class RootPackageLoader extends ArrayLoader
  24161. {
  24162. private $manager;
  24163. private $config;
  24164. private $versionGuesser;
  24165. public function __construct(RepositoryManager $manager, Config $config, ?VersionParser $parser = null, ?VersionGuesser $versionGuesser = null, ?IOInterface $io = null)
  24166. {
  24167. parent::__construct($parser);
  24168. $this->manager = $manager;
  24169. $this->config = $config;
  24170. $this->versionGuesser = $versionGuesser ?: new VersionGuesser($config, new ProcessExecutor($io), $this->versionParser);
  24171. }
  24172. public function load(array $config, string $class = 'Composer\Package\RootPackage', ?string $cwd = null): BasePackage
  24173. {
  24174. if ($class !== 'Composer\Package\RootPackage') {
  24175. trigger_error('The $class arg is deprecated, please reach out to Composer maintainers ASAP if you still need this.', E_USER_DEPRECATED);
  24176. }
  24177. if (!isset($config['name'])) {
  24178. $config['name'] = '__root__';
  24179. } elseif ($err = ValidatingArrayLoader::hasPackageNamingError($config['name'])) {
  24180. throw new \RuntimeException('Your package name '.$err);
  24181. }
  24182. $autoVersioned = false;
  24183. if (!isset($config['version'])) {
  24184. $commit = null;
  24185. if (Platform::getEnv('COMPOSER_ROOT_VERSION')) {
  24186. $config['version'] = Platform::getEnv('COMPOSER_ROOT_VERSION');
  24187. } else {
  24188. $versionData = $this->versionGuesser->guessVersion($config, $cwd ?? Platform::getCwd(true));
  24189. if ($versionData) {
  24190. $config['version'] = $versionData['pretty_version'];
  24191. $config['version_normalized'] = $versionData['version'];
  24192. $commit = $versionData['commit'];
  24193. }
  24194. }
  24195. if (!isset($config['version'])) {
  24196. $config['version'] = '1.0.0';
  24197. $autoVersioned = true;
  24198. }
  24199. if ($commit) {
  24200. $config['source'] = [
  24201. 'type' => '',
  24202. 'url' => '',
  24203. 'reference' => $commit,
  24204. ];
  24205. $config['dist'] = [
  24206. 'type' => '',
  24207. 'url' => '',
  24208. 'reference' => $commit,
  24209. ];
  24210. }
  24211. }
  24212. $package = parent::load($config, $class);
  24213. if ($package instanceof RootAliasPackage) {
  24214. $realPackage = $package->getAliasOf();
  24215. } else {
  24216. $realPackage = $package;
  24217. }
  24218. if (!$realPackage instanceof RootPackage) {
  24219. throw new \LogicException('Expecting a Composer\Package\RootPackage at this point');
  24220. }
  24221. if ($autoVersioned) {
  24222. $realPackage->replaceVersion($realPackage->getVersion(), RootPackage::DEFAULT_PRETTY_VERSION);
  24223. }
  24224. if (isset($config['minimum-stability'])) {
  24225. $realPackage->setMinimumStability(VersionParser::normalizeStability($config['minimum-stability']));
  24226. }
  24227. $aliases = [];
  24228. $stabilityFlags = [];
  24229. $references = [];
  24230. foreach (['require', 'require-dev'] as $linkType) {
  24231. if (isset($config[$linkType])) {
  24232. $linkInfo = BasePackage::$supportedLinkTypes[$linkType];
  24233. $method = 'get'.ucfirst($linkInfo['method']);
  24234. $links = [];
  24235. foreach ($realPackage->{$method}() as $link) {
  24236. $links[$link->getTarget()] = $link->getConstraint()->getPrettyString();
  24237. }
  24238. $aliases = $this->extractAliases($links, $aliases);
  24239. $stabilityFlags = self::extractStabilityFlags($links, $realPackage->getMinimumStability(), $stabilityFlags);
  24240. $references = self::extractReferences($links, $references);
  24241. if (isset($links[$config['name']])) {
  24242. throw new \RuntimeException(sprintf('Root package \'%s\' cannot require itself in its composer.json' . PHP_EOL .
  24243. 'Did you accidentally name your root package after an external package?', $config['name']));
  24244. }
  24245. }
  24246. }
  24247. foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
  24248. if (isset($config[$linkType])) {
  24249. foreach ($config[$linkType] as $linkName => $constraint) {
  24250. if ($err = ValidatingArrayLoader::hasPackageNamingError($linkName, true)) {
  24251. throw new \RuntimeException($linkType.'.'.$err);
  24252. }
  24253. }
  24254. }
  24255. }
  24256. $realPackage->setAliases($aliases);
  24257. $realPackage->setStabilityFlags($stabilityFlags);
  24258. $realPackage->setReferences($references);
  24259. if (isset($config['prefer-stable'])) {
  24260. $realPackage->setPreferStable((bool) $config['prefer-stable']);
  24261. }
  24262. if (isset($config['config'])) {
  24263. $realPackage->setConfig($config['config']);
  24264. }
  24265. $repos = RepositoryFactory::defaultRepos(null, $this->config, $this->manager);
  24266. foreach ($repos as $repo) {
  24267. $this->manager->addRepository($repo);
  24268. }
  24269. $realPackage->setRepositories($this->config->getRepositories());
  24270. return $package;
  24271. }
  24272. private function extractAliases(array $requires, array $aliases): array
  24273. {
  24274. foreach ($requires as $reqName => $reqVersion) {
  24275. if (Preg::isMatchStrictGroups('{(?:^|\| *|, *)([^,\s#|]+)(?:#[^ ]+)? +as +([^,\s|]+)(?:$| *\|| *,)}', $reqVersion, $match)) {
  24276. $aliases[] = [
  24277. 'package' => strtolower($reqName),
  24278. 'version' => $this->versionParser->normalize($match[1], $reqVersion),
  24279. 'alias' => $match[2],
  24280. 'alias_normalized' => $this->versionParser->normalize($match[2], $reqVersion),
  24281. ];
  24282. } elseif (strpos($reqVersion, ' as ') !== false) {
  24283. throw new \UnexpectedValueException('Invalid alias definition in "'.$reqName.'": "'.$reqVersion.'". Aliases should be in the form "exact-version as other-exact-version".');
  24284. }
  24285. }
  24286. return $aliases;
  24287. }
  24288. public static function extractStabilityFlags(array $requires, string $minimumStability, array $stabilityFlags): array
  24289. {
  24290. $stabilities = BasePackage::$stabilities;
  24291. $minimumStability = $stabilities[$minimumStability];
  24292. foreach ($requires as $reqName => $reqVersion) {
  24293. $constraints = [];
  24294. $orSplit = Preg::split('{\s*\|\|?\s*}', trim($reqVersion));
  24295. foreach ($orSplit as $orConstraint) {
  24296. $andSplit = Preg::split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $orConstraint);
  24297. foreach ($andSplit as $andConstraint) {
  24298. $constraints[] = $andConstraint;
  24299. }
  24300. }
  24301. $matched = false;
  24302. foreach ($constraints as $constraint) {
  24303. if (Preg::isMatchStrictGroups('{^[^@]*?@('.implode('|', array_keys($stabilities)).')$}i', $constraint, $match)) {
  24304. $name = strtolower($reqName);
  24305. $stability = $stabilities[VersionParser::normalizeStability($match[1])];
  24306. if (isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) {
  24307. continue;
  24308. }
  24309. $stabilityFlags[$name] = $stability;
  24310. $matched = true;
  24311. }
  24312. }
  24313. if ($matched) {
  24314. continue;
  24315. }
  24316. foreach ($constraints as $constraint) {
  24317. $reqVersion = Preg::replace('{^([^,\s@]+) as .+$}', '$1', $constraint);
  24318. if (Preg::isMatch('{^[^,\s@]+$}', $reqVersion) && 'stable' !== ($stabilityName = VersionParser::parseStability($reqVersion))) {
  24319. $name = strtolower($reqName);
  24320. $stability = $stabilities[$stabilityName];
  24321. if ((isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) || ($minimumStability > $stability)) {
  24322. continue;
  24323. }
  24324. $stabilityFlags[$name] = $stability;
  24325. }
  24326. }
  24327. }
  24328. return $stabilityFlags;
  24329. }
  24330. public static function extractReferences(array $requires, array $references): array
  24331. {
  24332. foreach ($requires as $reqName => $reqVersion) {
  24333. $reqVersion = Preg::replace('{^([^,\s@]+) as .+$}', '$1', $reqVersion);
  24334. if (Preg::isMatchStrictGroups('{^[^,\s@]+?#([a-f0-9]+)$}', $reqVersion, $match) && 'dev' === VersionParser::parseStability($reqVersion)) {
  24335. $name = strtolower($reqName);
  24336. $references[$name] = $match[1];
  24337. }
  24338. }
  24339. return $references;
  24340. }
  24341. }
  24342. <?php declare(strict_types=1);
  24343. namespace Composer\Package\Loader;
  24344. use Composer\Package\BasePackage;
  24345. use Composer\Pcre\Preg;
  24346. use Composer\Semver\Constraint\Constraint;
  24347. use Composer\Package\Version\VersionParser;
  24348. use Composer\Repository\PlatformRepository;
  24349. use Composer\Spdx\SpdxLicenses;
  24350. class ValidatingArrayLoader implements LoaderInterface
  24351. {
  24352. public const CHECK_ALL = 3;
  24353. public const CHECK_UNBOUND_CONSTRAINTS = 1;
  24354. public const CHECK_STRICT_CONSTRAINTS = 2;
  24355. private $loader;
  24356. private $versionParser;
  24357. private $errors;
  24358. private $warnings;
  24359. private $config;
  24360. private $flags;
  24361. public function __construct(LoaderInterface $loader, bool $strictName = true, ?VersionParser $parser = null, int $flags = 0)
  24362. {
  24363. $this->loader = $loader;
  24364. $this->versionParser = $parser ?? new VersionParser();
  24365. $this->flags = $flags;
  24366. if ($strictName !== true) {
  24367. 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);
  24368. }
  24369. }
  24370. public function load(array $config, string $class = 'Composer\Package\CompletePackage'): BasePackage
  24371. {
  24372. $this->errors = [];
  24373. $this->warnings = [];
  24374. $this->config = $config;
  24375. $this->validateString('name', true);
  24376. if (isset($config['name']) && null !== ($err = self::hasPackageNamingError($config['name']))) {
  24377. $this->errors[] = 'name : '.$err;
  24378. }
  24379. if (isset($this->config['version'])) {
  24380. if (!is_scalar($this->config['version'])) {
  24381. $this->validateString('version');
  24382. } else {
  24383. if (!is_string($this->config['version'])) {
  24384. $this->config['version'] = (string) $this->config['version'];
  24385. }
  24386. try {
  24387. $this->versionParser->normalize($this->config['version']);
  24388. } catch (\Exception $e) {
  24389. $this->errors[] = 'version : invalid value ('.$this->config['version'].'): '.$e->getMessage();
  24390. unset($this->config['version']);
  24391. }
  24392. }
  24393. }
  24394. if (isset($this->config['config']['platform'])) {
  24395. foreach ((array) $this->config['config']['platform'] as $key => $platform) {
  24396. if (false === $platform) {
  24397. continue;
  24398. }
  24399. if (!is_string($platform)) {
  24400. $this->errors[] = 'config.platform.' . $key . ' : invalid value ('.gettype($platform).' '.var_export($platform, true).'): expected string or false';
  24401. continue;
  24402. }
  24403. try {
  24404. $this->versionParser->normalize($platform);
  24405. } catch (\Exception $e) {
  24406. $this->errors[] = 'config.platform.' . $key . ' : invalid value ('.$platform.'): '.$e->getMessage();
  24407. }
  24408. }
  24409. }
  24410. $this->validateRegex('type', '[A-Za-z0-9-]+');
  24411. $this->validateString('target-dir');
  24412. $this->validateArray('extra');
  24413. if (isset($this->config['bin'])) {
  24414. if (is_string($this->config['bin'])) {
  24415. $this->validateString('bin');
  24416. } else {
  24417. $this->validateFlatArray('bin');
  24418. }
  24419. }
  24420. $this->validateArray('scripts');
  24421. $this->validateString('description');
  24422. $this->validateUrl('homepage');
  24423. $this->validateFlatArray('keywords', '[\p{N}\p{L} ._-]+');
  24424. $releaseDate = null;
  24425. $this->validateString('time');
  24426. if (isset($this->config['time'])) {
  24427. try {
  24428. $releaseDate = new \DateTime($this->config['time'], new \DateTimeZone('UTC'));
  24429. } catch (\Exception $e) {
  24430. $this->errors[] = 'time : invalid value ('.$this->config['time'].'): '.$e->getMessage();
  24431. unset($this->config['time']);
  24432. }
  24433. }
  24434. if (isset($this->config['license']) && (null === $releaseDate || $releaseDate->getTimestamp() >= strtotime('-8days'))) {
  24435. if (is_array($this->config['license']) || is_string($this->config['license'])) {
  24436. $licenses = (array) $this->config['license'];
  24437. $licenseValidator = new SpdxLicenses();
  24438. foreach ($licenses as $license) {
  24439. if ('proprietary' === $license) {
  24440. continue;
  24441. }
  24442. $licenseToValidate = str_replace('proprietary', 'MIT', $license);
  24443. if (!$licenseValidator->validate($licenseToValidate)) {
  24444. if ($licenseValidator->validate(trim($licenseToValidate))) {
  24445. $this->warnings[] = sprintf(
  24446. 'License %s must not contain extra spaces, make sure to trim it.',
  24447. json_encode($license)
  24448. );
  24449. } else {
  24450. $this->warnings[] = sprintf(
  24451. 'License %s is not a valid SPDX license identifier, see https://spdx.org/licenses/ if you use an open license.' . PHP_EOL .
  24452. 'If the software is closed-source, you may use "proprietary" as license.',
  24453. json_encode($license)
  24454. );
  24455. }
  24456. }
  24457. }
  24458. }
  24459. }
  24460. if ($this->validateArray('authors')) {
  24461. foreach ($this->config['authors'] as $key => $author) {
  24462. if (!is_array($author)) {
  24463. $this->errors[] = 'authors.'.$key.' : should be an array, '.gettype($author).' given';
  24464. unset($this->config['authors'][$key]);
  24465. continue;
  24466. }
  24467. foreach (['homepage', 'email', 'name', 'role'] as $authorData) {
  24468. if (isset($author[$authorData]) && !is_string($author[$authorData])) {
  24469. $this->errors[] = 'authors.'.$key.'.'.$authorData.' : invalid value, must be a string';
  24470. unset($this->config['authors'][$key][$authorData]);
  24471. }
  24472. }
  24473. if (isset($author['homepage']) && !$this->filterUrl($author['homepage'])) {
  24474. $this->warnings[] = 'authors.'.$key.'.homepage : invalid value ('.$author['homepage'].'), must be an http/https URL';
  24475. unset($this->config['authors'][$key]['homepage']);
  24476. }
  24477. if (isset($author['email']) && false === filter_var($author['email'], FILTER_VALIDATE_EMAIL)) {
  24478. $this->warnings[] = 'authors.'.$key.'.email : invalid value ('.$author['email'].'), must be a valid email address';
  24479. unset($this->config['authors'][$key]['email']);
  24480. }
  24481. if (\count($this->config['authors'][$key]) === 0) {
  24482. unset($this->config['authors'][$key]);
  24483. }
  24484. }
  24485. if (\count($this->config['authors']) === 0) {
  24486. unset($this->config['authors']);
  24487. }
  24488. }
  24489. if ($this->validateArray('support') && !empty($this->config['support'])) {
  24490. foreach (['issues', 'forum', 'wiki', 'source', 'email', 'irc', 'docs', 'rss', 'chat', 'security'] as $key) {
  24491. if (isset($this->config['support'][$key]) && !is_string($this->config['support'][$key])) {
  24492. $this->errors[] = 'support.'.$key.' : invalid value, must be a string';
  24493. unset($this->config['support'][$key]);
  24494. }
  24495. }
  24496. if (isset($this->config['support']['email']) && !filter_var($this->config['support']['email'], FILTER_VALIDATE_EMAIL)) {
  24497. $this->warnings[] = 'support.email : invalid value ('.$this->config['support']['email'].'), must be a valid email address';
  24498. unset($this->config['support']['email']);
  24499. }
  24500. if (isset($this->config['support']['irc']) && !$this->filterUrl($this->config['support']['irc'], ['irc', 'ircs'])) {
  24501. $this->warnings[] = 'support.irc : invalid value ('.$this->config['support']['irc'].'), must be a irc://<server>/<channel> or ircs:// URL';
  24502. unset($this->config['support']['irc']);
  24503. }
  24504. foreach (['issues', 'forum', 'wiki', 'source', 'docs', 'chat', 'security'] as $key) {
  24505. if (isset($this->config['support'][$key]) && !$this->filterUrl($this->config['support'][$key])) {
  24506. $this->warnings[] = 'support.'.$key.' : invalid value ('.$this->config['support'][$key].'), must be an http/https URL';
  24507. unset($this->config['support'][$key]);
  24508. }
  24509. }
  24510. if (empty($this->config['support'])) {
  24511. unset($this->config['support']);
  24512. }
  24513. }
  24514. if ($this->validateArray('funding') && !empty($this->config['funding'])) {
  24515. foreach ($this->config['funding'] as $key => $fundingOption) {
  24516. if (!is_array($fundingOption)) {
  24517. $this->errors[] = 'funding.'.$key.' : should be an array, '.gettype($fundingOption).' given';
  24518. unset($this->config['funding'][$key]);
  24519. continue;
  24520. }
  24521. foreach (['type', 'url'] as $fundingData) {
  24522. if (isset($fundingOption[$fundingData]) && !is_string($fundingOption[$fundingData])) {
  24523. $this->errors[] = 'funding.'.$key.'.'.$fundingData.' : invalid value, must be a string';
  24524. unset($this->config['funding'][$key][$fundingData]);
  24525. }
  24526. }
  24527. if (isset($fundingOption['url']) && !$this->filterUrl($fundingOption['url'])) {
  24528. $this->warnings[] = 'funding.'.$key.'.url : invalid value ('.$fundingOption['url'].'), must be an http/https URL';
  24529. unset($this->config['funding'][$key]['url']);
  24530. }
  24531. if (empty($this->config['funding'][$key])) {
  24532. unset($this->config['funding'][$key]);
  24533. }
  24534. }
  24535. if (empty($this->config['funding'])) {
  24536. unset($this->config['funding']);
  24537. }
  24538. }
  24539. $unboundConstraint = new Constraint('=', '10000000-dev');
  24540. foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
  24541. if ($this->validateArray($linkType) && isset($this->config[$linkType])) {
  24542. foreach ($this->config[$linkType] as $package => $constraint) {
  24543. $package = (string) $package;
  24544. if (0 === strcasecmp($package, $this->config['name'])) {
  24545. $this->errors[] = $linkType.'.'.$package.' : a package cannot set a '.$linkType.' on itself';
  24546. unset($this->config[$linkType][$package]);
  24547. continue;
  24548. }
  24549. if ($err = self::hasPackageNamingError($package, true)) {
  24550. $this->warnings[] = $linkType.'.'.$err;
  24551. } elseif (!Preg::isMatch('{^[A-Za-z0-9_./-]+$}', $package)) {
  24552. $this->errors[] = $linkType.'.'.$package.' : invalid key, package names must be strings containing only [A-Za-z0-9_./-]';
  24553. }
  24554. if (!is_string($constraint)) {
  24555. $this->errors[] = $linkType.'.'.$package.' : invalid value, must be a string containing a version constraint';
  24556. unset($this->config[$linkType][$package]);
  24557. } elseif ('self.version' !== $constraint) {
  24558. try {
  24559. $linkConstraint = $this->versionParser->parseConstraints($constraint);
  24560. } catch (\Exception $e) {
  24561. $this->errors[] = $linkType.'.'.$package.' : invalid version constraint ('.$e->getMessage().')';
  24562. unset($this->config[$linkType][$package]);
  24563. continue;
  24564. }
  24565. if (
  24566. ($this->flags & self::CHECK_UNBOUND_CONSTRAINTS)
  24567. && 'require' === $linkType
  24568. && $linkConstraint->matches($unboundConstraint)
  24569. && !PlatformRepository::isPlatformPackage($package)
  24570. ) {
  24571. $this->warnings[] = $linkType.'.'.$package.' : unbound version constraints ('.$constraint.') should be avoided';
  24572. } elseif (
  24573. ($this->flags & self::CHECK_STRICT_CONSTRAINTS)
  24574. && 'require' === $linkType
  24575. && $linkConstraint instanceof Constraint && in_array($linkConstraint->getOperator(), ['==', '='], true)
  24576. && (new Constraint('>=', '1.0.0.0-dev'))->matches($linkConstraint)
  24577. ) {
  24578. $this->warnings[] = $linkType.'.'.$package.' : exact version constraints ('.$constraint.') should be avoided if the package follows semantic versioning';
  24579. }
  24580. }
  24581. if ($linkType === 'conflict' && isset($this->config['replace']) && $keys = array_intersect_key($this->config['replace'], $this->config['conflict'])) {
  24582. $this->errors[] = $linkType.'.'.$package.' : you cannot conflict with a package that is also replaced, as replace already creates an implicit conflict rule';
  24583. unset($this->config[$linkType][$package]);
  24584. }
  24585. }
  24586. }
  24587. }
  24588. if ($this->validateArray('suggest') && isset($this->config['suggest'])) {
  24589. foreach ($this->config['suggest'] as $package => $description) {
  24590. if (!is_string($description)) {
  24591. $this->errors[] = 'suggest.'.$package.' : invalid value, must be a string describing why the package is suggested';
  24592. unset($this->config['suggest'][$package]);
  24593. }
  24594. }
  24595. }
  24596. if ($this->validateString('minimum-stability') && isset($this->config['minimum-stability'])) {
  24597. if (!isset(BasePackage::$stabilities[strtolower($this->config['minimum-stability'])]) && $this->config['minimum-stability'] !== 'RC') {
  24598. $this->errors[] = 'minimum-stability : invalid value ('.$this->config['minimum-stability'].'), must be one of '.implode(', ', array_keys(BasePackage::$stabilities));
  24599. unset($this->config['minimum-stability']);
  24600. }
  24601. }
  24602. if ($this->validateArray('autoload') && isset($this->config['autoload'])) {
  24603. $types = ['psr-0', 'psr-4', 'classmap', 'files', 'exclude-from-classmap'];
  24604. foreach ($this->config['autoload'] as $type => $typeConfig) {
  24605. if (!in_array($type, $types)) {
  24606. $this->errors[] = 'autoload : invalid value ('.$type.'), must be one of '.implode(', ', $types);
  24607. unset($this->config['autoload'][$type]);
  24608. }
  24609. if ($type === 'psr-4') {
  24610. foreach ($typeConfig as $namespace => $dirs) {
  24611. if ($namespace !== '' && '\\' !== substr((string) $namespace, -1)) {
  24612. $this->errors[] = 'autoload.psr-4 : invalid value ('.$namespace.'), namespaces must end with a namespace separator, should be '.$namespace.'\\\\';
  24613. }
  24614. }
  24615. }
  24616. }
  24617. }
  24618. if (isset($this->config['autoload']['psr-4']) && isset($this->config['target-dir'])) {
  24619. $this->errors[] = 'target-dir : this can not be used together with the autoload.psr-4 setting, remove target-dir to upgrade to psr-4';
  24620. unset($this->config['autoload']['psr-4']);
  24621. }
  24622. foreach (['source', 'dist'] as $srcType) {
  24623. if ($this->validateArray($srcType) && !empty($this->config[$srcType])) {
  24624. if (!isset($this->config[$srcType]['type'])) {
  24625. $this->errors[] = $srcType . '.type : must be present';
  24626. }
  24627. if (!isset($this->config[$srcType]['url'])) {
  24628. $this->errors[] = $srcType . '.url : must be present';
  24629. }
  24630. if ($srcType === 'source' && !isset($this->config[$srcType]['reference'])) {
  24631. $this->errors[] = $srcType . '.reference : must be present';
  24632. }
  24633. if (isset($this->config[$srcType]['type']) && !is_string($this->config[$srcType]['type'])) {
  24634. $this->errors[] = $srcType . '.type : should be a string, '.gettype($this->config[$srcType]['type']).' given';
  24635. }
  24636. if (isset($this->config[$srcType]['url']) && !is_string($this->config[$srcType]['url'])) {
  24637. $this->errors[] = $srcType . '.url : should be a string, '.gettype($this->config[$srcType]['url']).' given';
  24638. }
  24639. if (isset($this->config[$srcType]['reference']) && !is_string($this->config[$srcType]['reference']) && !is_int($this->config[$srcType]['reference'])) {
  24640. $this->errors[] = $srcType . '.reference : should be a string or int, '.gettype($this->config[$srcType]['reference']).' given';
  24641. }
  24642. if (isset($this->config[$srcType]['reference']) && Preg::isMatch('{^\s*-}', (string) $this->config[$srcType]['reference'])) {
  24643. $this->errors[] = $srcType . '.reference : must not start with a "-", "'.$this->config[$srcType]['reference'].'" given';
  24644. }
  24645. if (isset($this->config[$srcType]['url']) && Preg::isMatch('{^\s*-}', (string) $this->config[$srcType]['url'])) {
  24646. $this->errors[] = $srcType . '.url : must not start with a "-", "'.$this->config[$srcType]['url'].'" given';
  24647. }
  24648. }
  24649. }
  24650. $this->validateFlatArray('include-path');
  24651. $this->validateArray('transport-options');
  24652. if (isset($this->config['extra']['branch-alias'])) {
  24653. if (!is_array($this->config['extra']['branch-alias'])) {
  24654. $this->errors[] = 'extra.branch-alias : must be an array of versions => aliases';
  24655. } else {
  24656. foreach ($this->config['extra']['branch-alias'] as $sourceBranch => $targetBranch) {
  24657. if (!is_string($targetBranch)) {
  24658. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.json_encode($targetBranch).') must be a string, "'.gettype($targetBranch).'" received.';
  24659. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  24660. continue;
  24661. }
  24662. if ('-dev' !== substr($targetBranch, -4)) {
  24663. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') must end in -dev';
  24664. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  24665. continue;
  24666. }
  24667. $validatedTargetBranch = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4));
  24668. if ('-dev' !== substr($validatedTargetBranch, -4)) {
  24669. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') must be a parseable number like 2.0-dev';
  24670. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  24671. continue;
  24672. }
  24673. if (($sourcePrefix = $this->versionParser->parseNumericAliasPrefix($sourceBranch))
  24674. && ($targetPrefix = $this->versionParser->parseNumericAliasPrefix($targetBranch))
  24675. && (stripos($targetPrefix, $sourcePrefix) !== 0)
  24676. ) {
  24677. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') is not a valid numeric alias for this version';
  24678. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  24679. }
  24680. }
  24681. }
  24682. }
  24683. if ($this->errors) {
  24684. throw new InvalidPackageException($this->errors, $this->warnings, $config);
  24685. }
  24686. $package = $this->loader->load($this->config, $class);
  24687. $this->config = [];
  24688. return $package;
  24689. }
  24690. public function getWarnings(): array
  24691. {
  24692. return $this->warnings;
  24693. }
  24694. public function getErrors(): array
  24695. {
  24696. return $this->errors;
  24697. }
  24698. public static function hasPackageNamingError(string $name, bool $isLink = false): ?string
  24699. {
  24700. if (PlatformRepository::isPlatformPackage($name)) {
  24701. return null;
  24702. }
  24703. if (!Preg::isMatch('{^[a-z0-9](?:[_.-]?[a-z0-9]++)*+/[a-z0-9](?:(?:[_.]|-{1,2})?[a-z0-9]++)*+$}iD', $name)) {
  24704. 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]+)*$".';
  24705. }
  24706. $reservedNames = ['nul', 'con', 'prn', 'aux', 'com1', 'com2', 'com3', 'com4', 'com5', 'com6', 'com7', 'com8', 'com9', 'lpt1', 'lpt2', 'lpt3', 'lpt4', 'lpt5', 'lpt6', 'lpt7', 'lpt8', 'lpt9'];
  24707. $bits = explode('/', strtolower($name));
  24708. if (in_array($bits[0], $reservedNames, true) || in_array($bits[1], $reservedNames, true)) {
  24709. return $name.' is reserved, package and vendor names can not match any of: '.implode(', ', $reservedNames).'.';
  24710. }
  24711. if (Preg::isMatch('{\.json$}', $name)) {
  24712. return $name.' is invalid, package names can not end in .json, consider renaming it or perhaps using a -json suffix instead.';
  24713. }
  24714. if (Preg::isMatch('{[A-Z]}', $name)) {
  24715. if ($isLink) {
  24716. return $name.' is invalid, it should not contain uppercase characters. Please use '.strtolower($name).' instead.';
  24717. }
  24718. $suggestName = Preg::replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name);
  24719. $suggestName = strtolower($suggestName);
  24720. return $name.' is invalid, it should not contain uppercase characters. We suggest using '.$suggestName.' instead.';
  24721. }
  24722. return null;
  24723. }
  24724. private function validateRegex(string $property, string $regex, bool $mandatory = false): bool
  24725. {
  24726. if (!$this->validateString($property, $mandatory)) {
  24727. return false;
  24728. }
  24729. if (!Preg::isMatch('{^'.$regex.'$}u', $this->config[$property])) {
  24730. $message = $property.' : invalid value ('.$this->config[$property].'), must match '.$regex;
  24731. if ($mandatory) {
  24732. $this->errors[] = $message;
  24733. } else {
  24734. $this->warnings[] = $message;
  24735. }
  24736. unset($this->config[$property]);
  24737. return false;
  24738. }
  24739. return true;
  24740. }
  24741. private function validateString(string $property, bool $mandatory = false): bool
  24742. {
  24743. if (isset($this->config[$property]) && !is_string($this->config[$property])) {
  24744. $this->errors[] = $property.' : should be a string, '.gettype($this->config[$property]).' given';
  24745. unset($this->config[$property]);
  24746. return false;
  24747. }
  24748. if (!isset($this->config[$property]) || trim($this->config[$property]) === '') {
  24749. if ($mandatory) {
  24750. $this->errors[] = $property.' : must be present';
  24751. }
  24752. unset($this->config[$property]);
  24753. return false;
  24754. }
  24755. return true;
  24756. }
  24757. private function validateArray(string $property, bool $mandatory = false): bool
  24758. {
  24759. if (isset($this->config[$property]) && !is_array($this->config[$property])) {
  24760. $this->errors[] = $property.' : should be an array, '.gettype($this->config[$property]).' given';
  24761. unset($this->config[$property]);
  24762. return false;
  24763. }
  24764. if (!isset($this->config[$property]) || !count($this->config[$property])) {
  24765. if ($mandatory) {
  24766. $this->errors[] = $property.' : must be present and contain at least one element';
  24767. }
  24768. unset($this->config[$property]);
  24769. return false;
  24770. }
  24771. return true;
  24772. }
  24773. private function validateFlatArray(string $property, ?string $regex = null, bool $mandatory = false): bool
  24774. {
  24775. if (!$this->validateArray($property, $mandatory)) {
  24776. return false;
  24777. }
  24778. $pass = true;
  24779. foreach ($this->config[$property] as $key => $value) {
  24780. if (!is_string($value) && !is_numeric($value)) {
  24781. $this->errors[] = $property.'.'.$key.' : must be a string or int, '.gettype($value).' given';
  24782. unset($this->config[$property][$key]);
  24783. $pass = false;
  24784. continue;
  24785. }
  24786. if ($regex && !Preg::isMatch('{^'.$regex.'$}u', (string) $value)) {
  24787. $this->warnings[] = $property.'.'.$key.' : invalid value ('.$value.'), must match '.$regex;
  24788. unset($this->config[$property][$key]);
  24789. $pass = false;
  24790. }
  24791. }
  24792. return $pass;
  24793. }
  24794. private function validateUrl(string $property, bool $mandatory = false): bool
  24795. {
  24796. if (!$this->validateString($property, $mandatory)) {
  24797. return false;
  24798. }
  24799. if (!$this->filterUrl($this->config[$property])) {
  24800. $this->warnings[] = $property.' : invalid value ('.$this->config[$property].'), must be an http/https URL';
  24801. unset($this->config[$property]);
  24802. return false;
  24803. }
  24804. return true;
  24805. }
  24806. private function filterUrl($value, array $schemes = ['http', 'https']): bool
  24807. {
  24808. if ($value === '') {
  24809. return true;
  24810. }
  24811. $bits = parse_url($value);
  24812. if (empty($bits['scheme']) || empty($bits['host'])) {
  24813. return false;
  24814. }
  24815. if (!in_array($bits['scheme'], $schemes, true)) {
  24816. return false;
  24817. }
  24818. return true;
  24819. }
  24820. }
  24821. <?php declare(strict_types=1);
  24822. namespace Composer\Package;
  24823. use Composer\Json\JsonFile;
  24824. use Composer\Installer\InstallationManager;
  24825. use Composer\Pcre\Preg;
  24826. use Composer\Repository\InstalledRepository;
  24827. use Composer\Repository\LockArrayRepository;
  24828. use Composer\Repository\PlatformRepository;
  24829. use Composer\Repository\RootPackageRepository;
  24830. use Composer\Util\ProcessExecutor;
  24831. use Composer\Package\Dumper\ArrayDumper;
  24832. use Composer\Package\Loader\ArrayLoader;
  24833. use Composer\Package\Version\VersionParser;
  24834. use Composer\Plugin\PluginInterface;
  24835. use Composer\Util\Git as GitUtil;
  24836. use Composer\IO\IOInterface;
  24837. use Seld\JsonLint\ParsingException;
  24838. class Locker
  24839. {
  24840. private $lockFile;
  24841. private $installationManager;
  24842. private $hash;
  24843. private $contentHash;
  24844. private $loader;
  24845. private $dumper;
  24846. private $process;
  24847. private $lockDataCache = null;
  24848. private $virtualFileWritten = false;
  24849. public function __construct(IOInterface $io, JsonFile $lockFile, InstallationManager $installationManager, string $composerFileContents, ?ProcessExecutor $process = null)
  24850. {
  24851. $this->lockFile = $lockFile;
  24852. $this->installationManager = $installationManager;
  24853. $this->hash = md5($composerFileContents);
  24854. $this->contentHash = self::getContentHash($composerFileContents);
  24855. $this->loader = new ArrayLoader(null, true);
  24856. $this->dumper = new ArrayDumper();
  24857. $this->process = $process ?? new ProcessExecutor($io);
  24858. }
  24859. public static function getContentHash(string $composerFileContents): string
  24860. {
  24861. $content = JsonFile::parseJson($composerFileContents, 'composer.json');
  24862. $relevantKeys = [
  24863. 'name',
  24864. 'version',
  24865. 'require',
  24866. 'require-dev',
  24867. 'conflict',
  24868. 'replace',
  24869. 'provide',
  24870. 'minimum-stability',
  24871. 'prefer-stable',
  24872. 'repositories',
  24873. 'extra',
  24874. ];
  24875. $relevantContent = [];
  24876. foreach (array_intersect($relevantKeys, array_keys($content)) as $key) {
  24877. $relevantContent[$key] = $content[$key];
  24878. }
  24879. if (isset($content['config']['platform'])) {
  24880. $relevantContent['config']['platform'] = $content['config']['platform'];
  24881. }
  24882. ksort($relevantContent);
  24883. return md5(JsonFile::encode($relevantContent, 0));
  24884. }
  24885. public function isLocked(): bool
  24886. {
  24887. if (!$this->virtualFileWritten && !$this->lockFile->exists()) {
  24888. return false;
  24889. }
  24890. $data = $this->getLockData();
  24891. return isset($data['packages']);
  24892. }
  24893. public function isFresh(): bool
  24894. {
  24895. $lock = $this->lockFile->read();
  24896. if (!empty($lock['content-hash'])) {
  24897. return $this->contentHash === $lock['content-hash'];
  24898. }
  24899. if (!empty($lock['hash'])) {
  24900. return $this->hash === $lock['hash'];
  24901. }
  24902. return false;
  24903. }
  24904. public function getLockedRepository(bool $withDevReqs = false): LockArrayRepository
  24905. {
  24906. $lockData = $this->getLockData();
  24907. $packages = new LockArrayRepository();
  24908. $lockedPackages = $lockData['packages'];
  24909. if ($withDevReqs) {
  24910. if (isset($lockData['packages-dev'])) {
  24911. $lockedPackages = array_merge($lockedPackages, $lockData['packages-dev']);
  24912. } else {
  24913. 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.');
  24914. }
  24915. }
  24916. if (empty($lockedPackages)) {
  24917. return $packages;
  24918. }
  24919. if (isset($lockedPackages[0]['name'])) {
  24920. $packageByName = [];
  24921. foreach ($lockedPackages as $info) {
  24922. $package = $this->loader->load($info);
  24923. $packages->addPackage($package);
  24924. $packageByName[$package->getName()] = $package;
  24925. if ($package instanceof AliasPackage) {
  24926. $packageByName[$package->getAliasOf()->getName()] = $package->getAliasOf();
  24927. }
  24928. }
  24929. if (isset($lockData['aliases'])) {
  24930. foreach ($lockData['aliases'] as $alias) {
  24931. if (isset($packageByName[$alias['package']])) {
  24932. $aliasPkg = new CompleteAliasPackage($packageByName[$alias['package']], $alias['alias_normalized'], $alias['alias']);
  24933. $aliasPkg->setRootPackageAlias(true);
  24934. $packages->addPackage($aliasPkg);
  24935. }
  24936. }
  24937. }
  24938. return $packages;
  24939. }
  24940. throw new \RuntimeException('Your composer.lock is invalid. Run "composer update" to generate a new one.');
  24941. }
  24942. public function getDevPackageNames(): array
  24943. {
  24944. $names = [];
  24945. $lockData = $this->getLockData();
  24946. if (isset($lockData['packages-dev'])) {
  24947. foreach ($lockData['packages-dev'] as $package) {
  24948. $names[] = strtolower($package['name']);
  24949. }
  24950. }
  24951. return $names;
  24952. }
  24953. public function getPlatformRequirements(bool $withDevReqs = false): array
  24954. {
  24955. $lockData = $this->getLockData();
  24956. $requirements = [];
  24957. if (!empty($lockData['platform'])) {
  24958. $requirements = $this->loader->parseLinks(
  24959. '__root__',
  24960. '1.0.0',
  24961. Link::TYPE_REQUIRE,
  24962. $lockData['platform'] ?? []
  24963. );
  24964. }
  24965. if ($withDevReqs && !empty($lockData['platform-dev'])) {
  24966. $devRequirements = $this->loader->parseLinks(
  24967. '__root__',
  24968. '1.0.0',
  24969. Link::TYPE_REQUIRE,
  24970. $lockData['platform-dev'] ?? []
  24971. );
  24972. $requirements = array_merge($requirements, $devRequirements);
  24973. }
  24974. return $requirements;
  24975. }
  24976. public function getMinimumStability(): string
  24977. {
  24978. $lockData = $this->getLockData();
  24979. return $lockData['minimum-stability'] ?? 'stable';
  24980. }
  24981. public function getStabilityFlags(): array
  24982. {
  24983. $lockData = $this->getLockData();
  24984. return $lockData['stability-flags'] ?? [];
  24985. }
  24986. public function getPreferStable(): ?bool
  24987. {
  24988. $lockData = $this->getLockData();
  24989. return $lockData['prefer-stable'] ?? null;
  24990. }
  24991. public function getPreferLowest(): ?bool
  24992. {
  24993. $lockData = $this->getLockData();
  24994. return $lockData['prefer-lowest'] ?? null;
  24995. }
  24996. public function getPlatformOverrides(): array
  24997. {
  24998. $lockData = $this->getLockData();
  24999. return $lockData['platform-overrides'] ?? [];
  25000. }
  25001. public function getAliases(): array
  25002. {
  25003. $lockData = $this->getLockData();
  25004. return $lockData['aliases'] ?? [];
  25005. }
  25006. public function getPluginApi()
  25007. {
  25008. $lockData = $this->getLockData();
  25009. return $lockData['plugin-api-version'] ?? '1.1.0';
  25010. }
  25011. public function getLockData(): array
  25012. {
  25013. if (null !== $this->lockDataCache) {
  25014. return $this->lockDataCache;
  25015. }
  25016. if (!$this->lockFile->exists()) {
  25017. throw new \LogicException('No lockfile found. Unable to read locked packages');
  25018. }
  25019. return $this->lockDataCache = $this->lockFile->read();
  25020. }
  25021. 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
  25022. {
  25023. $aliases = array_map(static function ($alias): array {
  25024. if (in_array($alias['version'], ['dev-master', 'dev-trunk', 'dev-default'], true)) {
  25025. $alias['version'] = VersionParser::DEFAULT_BRANCH_ALIAS;
  25026. }
  25027. return $alias;
  25028. }, $aliases);
  25029. $lock = [
  25030. '_readme' => ['This file locks the dependencies of your project to a known state',
  25031. 'Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies',
  25032. 'This file is @gener'.'ated automatically', ],
  25033. 'content-hash' => $this->contentHash,
  25034. 'packages' => null,
  25035. 'packages-dev' => null,
  25036. 'aliases' => $aliases,
  25037. 'minimum-stability' => $minimumStability,
  25038. 'stability-flags' => $stabilityFlags,
  25039. 'prefer-stable' => $preferStable,
  25040. 'prefer-lowest' => $preferLowest,
  25041. ];
  25042. $lock['packages'] = $this->lockPackages($packages);
  25043. if (null !== $devPackages) {
  25044. $lock['packages-dev'] = $this->lockPackages($devPackages);
  25045. }
  25046. $lock['platform'] = $platformReqs;
  25047. $lock['platform-dev'] = $platformDevReqs;
  25048. if (\count($platformOverrides) > 0) {
  25049. $lock['platform-overrides'] = $platformOverrides;
  25050. }
  25051. $lock['plugin-api-version'] = PluginInterface::PLUGIN_API_VERSION;
  25052. try {
  25053. $isLocked = $this->isLocked();
  25054. } catch (ParsingException $e) {
  25055. $isLocked = false;
  25056. }
  25057. if (!$isLocked || $lock !== $this->getLockData()) {
  25058. if ($write) {
  25059. $this->lockFile->write($lock);
  25060. $this->lockDataCache = null;
  25061. $this->virtualFileWritten = false;
  25062. } else {
  25063. $this->virtualFileWritten = true;
  25064. $this->lockDataCache = JsonFile::parseJson(JsonFile::encode($lock));
  25065. }
  25066. return true;
  25067. }
  25068. return false;
  25069. }
  25070. private function lockPackages(array $packages): array
  25071. {
  25072. $locked = [];
  25073. foreach ($packages as $package) {
  25074. if ($package instanceof AliasPackage) {
  25075. continue;
  25076. }
  25077. $name = $package->getPrettyName();
  25078. $version = $package->getPrettyVersion();
  25079. if (!$name || !$version) {
  25080. throw new \LogicException(sprintf(
  25081. 'Package "%s" has no version or name and can not be locked',
  25082. $package
  25083. ));
  25084. }
  25085. $spec = $this->dumper->dump($package);
  25086. unset($spec['version_normalized']);
  25087. $time = $spec['time'] ?? null;
  25088. unset($spec['time']);
  25089. if ($package->isDev() && $package->getInstallationSource() === 'source') {
  25090. $time = $this->getPackageTime($package) ?: $time;
  25091. }
  25092. if (null !== $time) {
  25093. $spec['time'] = $time;
  25094. }
  25095. unset($spec['installation-source']);
  25096. $locked[] = $spec;
  25097. }
  25098. usort($locked, static function ($a, $b) {
  25099. $comparison = strcmp($a['name'], $b['name']);
  25100. if (0 !== $comparison) {
  25101. return $comparison;
  25102. }
  25103. return strcmp($a['version'], $b['version']);
  25104. });
  25105. return $locked;
  25106. }
  25107. private function getPackageTime(PackageInterface $package): ?string
  25108. {
  25109. if (!function_exists('proc_open')) {
  25110. return null;
  25111. }
  25112. $path = $this->installationManager->getInstallPath($package);
  25113. if ($path === null) {
  25114. return null;
  25115. }
  25116. $path = realpath($path);
  25117. $sourceType = $package->getSourceType();
  25118. $datetime = null;
  25119. if ($path && in_array($sourceType, ['git', 'hg'])) {
  25120. $sourceRef = $package->getSourceReference() ?: $package->getDistReference();
  25121. switch ($sourceType) {
  25122. case 'git':
  25123. GitUtil::cleanEnv();
  25124. 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)) {
  25125. $datetime = new \DateTime('@'.trim($output), new \DateTimeZone('UTC'));
  25126. }
  25127. break;
  25128. case 'hg':
  25129. if (0 === $this->process->execute('hg log --template "{date|hgdate}" -r '.ProcessExecutor::escape($sourceRef), $output, $path) && Preg::isMatch('{^\s*(\d+)\s*}', $output, $match)) {
  25130. $datetime = new \DateTime('@'.$match[1], new \DateTimeZone('UTC'));
  25131. }
  25132. break;
  25133. }
  25134. }
  25135. return $datetime ? $datetime->format(DATE_RFC3339) : null;
  25136. }
  25137. public function getMissingRequirementInfo(RootPackageInterface $package, bool $includeDev): array
  25138. {
  25139. $missingRequirementInfo = [];
  25140. $missingRequirements = false;
  25141. $sets = [['repo' => $this->getLockedRepository(false), 'method' => 'getRequires', 'description' => 'Required']];
  25142. if ($includeDev === true) {
  25143. $sets[] = ['repo' => $this->getLockedRepository(true), 'method' => 'getDevRequires', 'description' => 'Required (in require-dev)'];
  25144. }
  25145. $rootRepo = new RootPackageRepository(clone $package);
  25146. foreach ($sets as $set) {
  25147. $installedRepo = new InstalledRepository([$set['repo'], $rootRepo]);
  25148. foreach (call_user_func([$package, $set['method']]) as $link) {
  25149. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  25150. continue;
  25151. }
  25152. if ($link->getPrettyConstraint() === 'self.version') {
  25153. continue;
  25154. }
  25155. if ($installedRepo->findPackagesWithReplacersAndProviders($link->getTarget(), $link->getConstraint()) === []) {
  25156. $results = $installedRepo->findPackagesWithReplacersAndProviders($link->getTarget());
  25157. if ($results !== []) {
  25158. $provider = reset($results);
  25159. $description = $provider->getPrettyVersion();
  25160. if ($provider->getName() !== $link->getTarget()) {
  25161. foreach (['getReplaces' => 'replaced as %s by %s', 'getProvides' => 'provided as %s by %s'] as $method => $text) {
  25162. foreach (call_user_func([$provider, $method]) as $providerLink) {
  25163. if ($providerLink->getTarget() === $link->getTarget()) {
  25164. $description = sprintf($text, $providerLink->getPrettyConstraint(), $provider->getPrettyName().' '.$provider->getPrettyVersion());
  25165. break 2;
  25166. }
  25167. }
  25168. }
  25169. }
  25170. $missingRequirementInfo[] = '- ' . $set['description'].' package "' . $link->getTarget() . '" is in the lock file as "'.$description.'" but that does not satisfy your constraint "'.$link->getPrettyConstraint().'".';
  25171. } else {
  25172. $missingRequirementInfo[] = '- ' . $set['description'].' package "' . $link->getTarget() . '" is not present in the lock file.';
  25173. }
  25174. $missingRequirements = true;
  25175. }
  25176. }
  25177. }
  25178. if ($missingRequirements) {
  25179. $missingRequirementInfo[] = 'This usually happens when composer files are incorrectly merged or the composer.json file is manually edited.';
  25180. $missingRequirementInfo[] = 'Read more about correctly resolving merge conflicts https://getcomposer.org/doc/articles/resolving-merge-conflicts.md';
  25181. $missingRequirementInfo[] = 'and prefer using the "require" command over editing the composer.json file directly https://getcomposer.org/doc/03-cli.md#require-r';
  25182. }
  25183. return $missingRequirementInfo;
  25184. }
  25185. }
  25186. <?php declare(strict_types=1);
  25187. namespace Composer\Package;
  25188. use Composer\Package\Version\VersionParser;
  25189. use Composer\Pcre\Preg;
  25190. use Composer\Util\ComposerMirror;
  25191. class Package extends BasePackage
  25192. {
  25193. protected $type;
  25194. protected $targetDir;
  25195. protected $installationSource;
  25196. protected $sourceType;
  25197. protected $sourceUrl;
  25198. protected $sourceReference;
  25199. protected $sourceMirrors;
  25200. protected $distType;
  25201. protected $distUrl;
  25202. protected $distReference;
  25203. protected $distSha1Checksum;
  25204. protected $distMirrors;
  25205. protected $version;
  25206. protected $prettyVersion;
  25207. protected $releaseDate;
  25208. protected $extra = [];
  25209. protected $binaries = [];
  25210. protected $dev;
  25211. protected $stability;
  25212. protected $notificationUrl;
  25213. protected $requires = [];
  25214. protected $conflicts = [];
  25215. protected $provides = [];
  25216. protected $replaces = [];
  25217. protected $devRequires = [];
  25218. protected $suggests = [];
  25219. protected $autoload = [];
  25220. protected $devAutoload = [];
  25221. protected $includePaths = [];
  25222. protected $isDefaultBranch = false;
  25223. protected $transportOptions = [];
  25224. public function __construct(string $name, string $version, string $prettyVersion)
  25225. {
  25226. parent::__construct($name);
  25227. $this->version = $version;
  25228. $this->prettyVersion = $prettyVersion;
  25229. $this->stability = VersionParser::parseStability($version);
  25230. $this->dev = $this->stability === 'dev';
  25231. }
  25232. public function isDev(): bool
  25233. {
  25234. return $this->dev;
  25235. }
  25236. public function setType(string $type): void
  25237. {
  25238. $this->type = $type;
  25239. }
  25240. public function getType(): string
  25241. {
  25242. return $this->type ?: 'library';
  25243. }
  25244. public function getStability(): string
  25245. {
  25246. return $this->stability;
  25247. }
  25248. public function setTargetDir(?string $targetDir): void
  25249. {
  25250. $this->targetDir = $targetDir;
  25251. }
  25252. public function getTargetDir(): ?string
  25253. {
  25254. if (null === $this->targetDir) {
  25255. return null;
  25256. }
  25257. return ltrim(Preg::replace('{ (?:^|[\\\\/]+) \.\.? (?:[\\\\/]+|$) (?:\.\.? (?:[\\\\/]+|$) )*}x', '/', $this->targetDir), '/');
  25258. }
  25259. public function setExtra(array $extra): void
  25260. {
  25261. $this->extra = $extra;
  25262. }
  25263. public function getExtra(): array
  25264. {
  25265. return $this->extra;
  25266. }
  25267. public function setBinaries(array $binaries): void
  25268. {
  25269. $this->binaries = $binaries;
  25270. }
  25271. public function getBinaries(): array
  25272. {
  25273. return $this->binaries;
  25274. }
  25275. public function setInstallationSource(?string $type): void
  25276. {
  25277. $this->installationSource = $type;
  25278. }
  25279. public function getInstallationSource(): ?string
  25280. {
  25281. return $this->installationSource;
  25282. }
  25283. public function setSourceType(?string $type): void
  25284. {
  25285. $this->sourceType = $type;
  25286. }
  25287. public function getSourceType(): ?string
  25288. {
  25289. return $this->sourceType;
  25290. }
  25291. public function setSourceUrl(?string $url): void
  25292. {
  25293. $this->sourceUrl = $url;
  25294. }
  25295. public function getSourceUrl(): ?string
  25296. {
  25297. return $this->sourceUrl;
  25298. }
  25299. public function setSourceReference(?string $reference): void
  25300. {
  25301. $this->sourceReference = $reference;
  25302. }
  25303. public function getSourceReference(): ?string
  25304. {
  25305. return $this->sourceReference;
  25306. }
  25307. public function setSourceMirrors(?array $mirrors): void
  25308. {
  25309. $this->sourceMirrors = $mirrors;
  25310. }
  25311. public function getSourceMirrors(): ?array
  25312. {
  25313. return $this->sourceMirrors;
  25314. }
  25315. public function getSourceUrls(): array
  25316. {
  25317. return $this->getUrls($this->sourceUrl, $this->sourceMirrors, $this->sourceReference, $this->sourceType, 'source');
  25318. }
  25319. public function setDistType(?string $type): void
  25320. {
  25321. $this->distType = $type === '' ? null : $type;
  25322. }
  25323. public function getDistType(): ?string
  25324. {
  25325. return $this->distType;
  25326. }
  25327. public function setDistUrl(?string $url): void
  25328. {
  25329. $this->distUrl = $url === '' ? null : $url;
  25330. }
  25331. public function getDistUrl(): ?string
  25332. {
  25333. return $this->distUrl;
  25334. }
  25335. public function setDistReference(?string $reference): void
  25336. {
  25337. $this->distReference = $reference;
  25338. }
  25339. public function getDistReference(): ?string
  25340. {
  25341. return $this->distReference;
  25342. }
  25343. public function setDistSha1Checksum(?string $sha1checksum): void
  25344. {
  25345. $this->distSha1Checksum = $sha1checksum;
  25346. }
  25347. public function getDistSha1Checksum(): ?string
  25348. {
  25349. return $this->distSha1Checksum;
  25350. }
  25351. public function setDistMirrors(?array $mirrors): void
  25352. {
  25353. $this->distMirrors = $mirrors;
  25354. }
  25355. public function getDistMirrors(): ?array
  25356. {
  25357. return $this->distMirrors;
  25358. }
  25359. public function getDistUrls(): array
  25360. {
  25361. return $this->getUrls($this->distUrl, $this->distMirrors, $this->distReference, $this->distType, 'dist');
  25362. }
  25363. public function getTransportOptions(): array
  25364. {
  25365. return $this->transportOptions;
  25366. }
  25367. public function setTransportOptions(array $options): void
  25368. {
  25369. $this->transportOptions = $options;
  25370. }
  25371. public function getVersion(): string
  25372. {
  25373. return $this->version;
  25374. }
  25375. public function getPrettyVersion(): string
  25376. {
  25377. return $this->prettyVersion;
  25378. }
  25379. public function setReleaseDate(?\DateTimeInterface $releaseDate): void
  25380. {
  25381. $this->releaseDate = $releaseDate;
  25382. }
  25383. public function getReleaseDate(): ?\DateTimeInterface
  25384. {
  25385. return $this->releaseDate;
  25386. }
  25387. public function setRequires(array $requires): void
  25388. {
  25389. if (isset($requires[0])) {
  25390. $requires = $this->convertLinksToMap($requires, 'setRequires');
  25391. }
  25392. $this->requires = $requires;
  25393. }
  25394. public function getRequires(): array
  25395. {
  25396. return $this->requires;
  25397. }
  25398. public function setConflicts(array $conflicts): void
  25399. {
  25400. if (isset($conflicts[0])) {
  25401. $conflicts = $this->convertLinksToMap($conflicts, 'setConflicts');
  25402. }
  25403. $this->conflicts = $conflicts;
  25404. }
  25405. public function getConflicts(): array
  25406. {
  25407. return $this->conflicts;
  25408. }
  25409. public function setProvides(array $provides): void
  25410. {
  25411. if (isset($provides[0])) {
  25412. $provides = $this->convertLinksToMap($provides, 'setProvides');
  25413. }
  25414. $this->provides = $provides;
  25415. }
  25416. public function getProvides(): array
  25417. {
  25418. return $this->provides;
  25419. }
  25420. public function setReplaces(array $replaces): void
  25421. {
  25422. if (isset($replaces[0])) {
  25423. $replaces = $this->convertLinksToMap($replaces, 'setReplaces');
  25424. }
  25425. $this->replaces = $replaces;
  25426. }
  25427. public function getReplaces(): array
  25428. {
  25429. return $this->replaces;
  25430. }
  25431. public function setDevRequires(array $devRequires): void
  25432. {
  25433. if (isset($devRequires[0])) {
  25434. $devRequires = $this->convertLinksToMap($devRequires, 'setDevRequires');
  25435. }
  25436. $this->devRequires = $devRequires;
  25437. }
  25438. public function getDevRequires(): array
  25439. {
  25440. return $this->devRequires;
  25441. }
  25442. public function setSuggests(array $suggests): void
  25443. {
  25444. $this->suggests = $suggests;
  25445. }
  25446. public function getSuggests(): array
  25447. {
  25448. return $this->suggests;
  25449. }
  25450. public function setAutoload(array $autoload): void
  25451. {
  25452. $this->autoload = $autoload;
  25453. }
  25454. public function getAutoload(): array
  25455. {
  25456. return $this->autoload;
  25457. }
  25458. public function setDevAutoload(array $devAutoload): void
  25459. {
  25460. $this->devAutoload = $devAutoload;
  25461. }
  25462. public function getDevAutoload(): array
  25463. {
  25464. return $this->devAutoload;
  25465. }
  25466. public function setIncludePaths(array $includePaths): void
  25467. {
  25468. $this->includePaths = $includePaths;
  25469. }
  25470. public function getIncludePaths(): array
  25471. {
  25472. return $this->includePaths;
  25473. }
  25474. public function setNotificationUrl(string $notificationUrl): void
  25475. {
  25476. $this->notificationUrl = $notificationUrl;
  25477. }
  25478. public function getNotificationUrl(): ?string
  25479. {
  25480. return $this->notificationUrl;
  25481. }
  25482. public function setIsDefaultBranch(bool $defaultBranch): void
  25483. {
  25484. $this->isDefaultBranch = $defaultBranch;
  25485. }
  25486. public function isDefaultBranch(): bool
  25487. {
  25488. return $this->isDefaultBranch;
  25489. }
  25490. public function setSourceDistReferences(string $reference): void
  25491. {
  25492. $this->setSourceReference($reference);
  25493. if (
  25494. $this->getDistUrl() !== null
  25495. && Preg::isMatch('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com|(?:www\.)?gitlab\.com)/}i', $this->getDistUrl())
  25496. ) {
  25497. $this->setDistReference($reference);
  25498. $this->setDistUrl(Preg::replace('{(?<=/|sha=)[a-f0-9]{40}(?=/|$)}i', $reference, $this->getDistUrl()));
  25499. } elseif ($this->getDistReference()) {
  25500. $this->setDistReference($reference);
  25501. }
  25502. }
  25503. public function replaceVersion(string $version, string $prettyVersion): void
  25504. {
  25505. $this->version = $version;
  25506. $this->prettyVersion = $prettyVersion;
  25507. $this->stability = VersionParser::parseStability($version);
  25508. $this->dev = $this->stability === 'dev';
  25509. }
  25510. protected function getUrls(?string $url, ?array $mirrors, ?string $ref, ?string $type, string $urlType): array
  25511. {
  25512. if (!$url) {
  25513. return [];
  25514. }
  25515. if ($urlType === 'dist' && false !== strpos($url, '%')) {
  25516. $url = ComposerMirror::processUrl($url, $this->name, $this->version, $ref, $type, $this->prettyVersion);
  25517. }
  25518. $urls = [$url];
  25519. if ($mirrors) {
  25520. foreach ($mirrors as $mirror) {
  25521. if ($urlType === 'dist') {
  25522. $mirrorUrl = ComposerMirror::processUrl($mirror['url'], $this->name, $this->version, $ref, $type, $this->prettyVersion);
  25523. } elseif ($urlType === 'source' && $type === 'git') {
  25524. $mirrorUrl = ComposerMirror::processGitUrl($mirror['url'], $this->name, $url, $type);
  25525. } elseif ($urlType === 'source' && $type === 'hg') {
  25526. $mirrorUrl = ComposerMirror::processHgUrl($mirror['url'], $this->name, $url, $type);
  25527. } else {
  25528. continue;
  25529. }
  25530. if (!\in_array($mirrorUrl, $urls)) {
  25531. $func = $mirror['preferred'] ? 'array_unshift' : 'array_push';
  25532. $func($urls, $mirrorUrl);
  25533. }
  25534. }
  25535. }
  25536. return $urls;
  25537. }
  25538. private function convertLinksToMap(array $links, string $source): array
  25539. {
  25540. 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.');
  25541. $newLinks = [];
  25542. foreach ($links as $link) {
  25543. $newLinks[$link->getTarget()] = $link;
  25544. }
  25545. return $newLinks;
  25546. }
  25547. }
  25548. <?php declare(strict_types=1);
  25549. namespace Composer\Package;
  25550. use Composer\Repository\RepositoryInterface;
  25551. interface PackageInterface
  25552. {
  25553. public const DISPLAY_SOURCE_REF_IF_DEV = 0;
  25554. public const DISPLAY_SOURCE_REF = 1;
  25555. public const DISPLAY_DIST_REF = 2;
  25556. public function getName(): string;
  25557. public function getPrettyName(): string;
  25558. public function getNames(bool $provides = true): array;
  25559. public function setId(int $id): void;
  25560. public function getId(): int;
  25561. public function isDev(): bool;
  25562. public function getType(): string;
  25563. public function getTargetDir(): ?string;
  25564. public function getExtra(): array;
  25565. public function setInstallationSource(?string $type): void;
  25566. public function getInstallationSource(): ?string;
  25567. public function getSourceType(): ?string;
  25568. public function getSourceUrl(): ?string;
  25569. public function getSourceUrls(): array;
  25570. public function getSourceReference(): ?string;
  25571. public function getSourceMirrors(): ?array;
  25572. public function setSourceMirrors(?array $mirrors): void;
  25573. public function getDistType(): ?string;
  25574. public function getDistUrl(): ?string;
  25575. public function getDistUrls(): array;
  25576. public function getDistReference(): ?string;
  25577. public function getDistSha1Checksum(): ?string;
  25578. public function getDistMirrors(): ?array;
  25579. public function setDistMirrors(?array $mirrors): void;
  25580. public function getVersion(): string;
  25581. public function getPrettyVersion(): string;
  25582. public function getFullPrettyVersion(bool $truncate = true, int $displayMode = self::DISPLAY_SOURCE_REF_IF_DEV): string;
  25583. public function getReleaseDate(): ?\DateTimeInterface;
  25584. public function getStability(): string;
  25585. public function getRequires(): array;
  25586. public function getConflicts(): array;
  25587. public function getProvides(): array;
  25588. public function getReplaces(): array;
  25589. public function getDevRequires(): array;
  25590. public function getSuggests(): array;
  25591. public function getAutoload(): array;
  25592. public function getDevAutoload(): array;
  25593. public function getIncludePaths(): array;
  25594. public function setRepository(RepositoryInterface $repository): void;
  25595. public function getRepository(): ?RepositoryInterface;
  25596. public function getBinaries(): array;
  25597. public function getUniqueName(): string;
  25598. public function getNotificationUrl(): ?string;
  25599. public function __toString(): string;
  25600. public function getPrettyString(): string;
  25601. public function isDefaultBranch(): bool;
  25602. public function getTransportOptions(): array;
  25603. public function setTransportOptions(array $options): void;
  25604. public function setSourceReference(?string $reference): void;
  25605. public function setDistUrl(?string $url): void;
  25606. public function setDistType(?string $type): void;
  25607. public function setDistReference(?string $reference): void;
  25608. public function setSourceDistReferences(string $reference): void;
  25609. }
  25610. <?php declare(strict_types=1);
  25611. namespace Composer\Package;
  25612. class RootAliasPackage extends CompleteAliasPackage implements RootPackageInterface
  25613. {
  25614. protected $aliasOf;
  25615. public function __construct(RootPackage $aliasOf, string $version, string $prettyVersion)
  25616. {
  25617. parent::__construct($aliasOf, $version, $prettyVersion);
  25618. }
  25619. public function getAliasOf()
  25620. {
  25621. return $this->aliasOf;
  25622. }
  25623. public function getAliases(): array
  25624. {
  25625. return $this->aliasOf->getAliases();
  25626. }
  25627. public function getMinimumStability(): string
  25628. {
  25629. return $this->aliasOf->getMinimumStability();
  25630. }
  25631. public function getStabilityFlags(): array
  25632. {
  25633. return $this->aliasOf->getStabilityFlags();
  25634. }
  25635. public function getReferences(): array
  25636. {
  25637. return $this->aliasOf->getReferences();
  25638. }
  25639. public function getPreferStable(): bool
  25640. {
  25641. return $this->aliasOf->getPreferStable();
  25642. }
  25643. public function getConfig(): array
  25644. {
  25645. return $this->aliasOf->getConfig();
  25646. }
  25647. public function setRequires(array $requires): void
  25648. {
  25649. $this->requires = $this->replaceSelfVersionDependencies($requires, Link::TYPE_REQUIRE);
  25650. $this->aliasOf->setRequires($requires);
  25651. }
  25652. public function setDevRequires(array $devRequires): void
  25653. {
  25654. $this->devRequires = $this->replaceSelfVersionDependencies($devRequires, Link::TYPE_DEV_REQUIRE);
  25655. $this->aliasOf->setDevRequires($devRequires);
  25656. }
  25657. public function setConflicts(array $conflicts): void
  25658. {
  25659. $this->conflicts = $this->replaceSelfVersionDependencies($conflicts, Link::TYPE_CONFLICT);
  25660. $this->aliasOf->setConflicts($conflicts);
  25661. }
  25662. public function setProvides(array $provides): void
  25663. {
  25664. $this->provides = $this->replaceSelfVersionDependencies($provides, Link::TYPE_PROVIDE);
  25665. $this->aliasOf->setProvides($provides);
  25666. }
  25667. public function setReplaces(array $replaces): void
  25668. {
  25669. $this->replaces = $this->replaceSelfVersionDependencies($replaces, Link::TYPE_REPLACE);
  25670. $this->aliasOf->setReplaces($replaces);
  25671. }
  25672. public function setAutoload(array $autoload): void
  25673. {
  25674. $this->aliasOf->setAutoload($autoload);
  25675. }
  25676. public function setDevAutoload(array $devAutoload): void
  25677. {
  25678. $this->aliasOf->setDevAutoload($devAutoload);
  25679. }
  25680. public function setStabilityFlags(array $stabilityFlags): void
  25681. {
  25682. $this->aliasOf->setStabilityFlags($stabilityFlags);
  25683. }
  25684. public function setMinimumStability(string $minimumStability): void
  25685. {
  25686. $this->aliasOf->setMinimumStability($minimumStability);
  25687. }
  25688. public function setPreferStable(bool $preferStable): void
  25689. {
  25690. $this->aliasOf->setPreferStable($preferStable);
  25691. }
  25692. public function setConfig(array $config): void
  25693. {
  25694. $this->aliasOf->setConfig($config);
  25695. }
  25696. public function setReferences(array $references): void
  25697. {
  25698. $this->aliasOf->setReferences($references);
  25699. }
  25700. public function setAliases(array $aliases): void
  25701. {
  25702. $this->aliasOf->setAliases($aliases);
  25703. }
  25704. public function setSuggests(array $suggests): void
  25705. {
  25706. $this->aliasOf->setSuggests($suggests);
  25707. }
  25708. public function setExtra(array $extra): void
  25709. {
  25710. $this->aliasOf->setExtra($extra);
  25711. }
  25712. public function __clone()
  25713. {
  25714. parent::__clone();
  25715. $this->aliasOf = clone $this->aliasOf;
  25716. }
  25717. }
  25718. <?php declare(strict_types=1);
  25719. namespace Composer\Package;
  25720. class RootPackage extends CompletePackage implements RootPackageInterface
  25721. {
  25722. public const DEFAULT_PRETTY_VERSION = '1.0.0+no-version-set';
  25723. protected $minimumStability = 'stable';
  25724. protected $preferStable = false;
  25725. protected $stabilityFlags = [];
  25726. protected $config = [];
  25727. protected $references = [];
  25728. protected $aliases = [];
  25729. public function setMinimumStability(string $minimumStability): void
  25730. {
  25731. $this->minimumStability = $minimumStability;
  25732. }
  25733. public function getMinimumStability(): string
  25734. {
  25735. return $this->minimumStability;
  25736. }
  25737. public function setStabilityFlags(array $stabilityFlags): void
  25738. {
  25739. $this->stabilityFlags = $stabilityFlags;
  25740. }
  25741. public function getStabilityFlags(): array
  25742. {
  25743. return $this->stabilityFlags;
  25744. }
  25745. public function setPreferStable(bool $preferStable): void
  25746. {
  25747. $this->preferStable = $preferStable;
  25748. }
  25749. public function getPreferStable(): bool
  25750. {
  25751. return $this->preferStable;
  25752. }
  25753. public function setConfig(array $config): void
  25754. {
  25755. $this->config = $config;
  25756. }
  25757. public function getConfig(): array
  25758. {
  25759. return $this->config;
  25760. }
  25761. public function setReferences(array $references): void
  25762. {
  25763. $this->references = $references;
  25764. }
  25765. public function getReferences(): array
  25766. {
  25767. return $this->references;
  25768. }
  25769. public function setAliases(array $aliases): void
  25770. {
  25771. $this->aliases = $aliases;
  25772. }
  25773. public function getAliases(): array
  25774. {
  25775. return $this->aliases;
  25776. }
  25777. }
  25778. <?php declare(strict_types=1);
  25779. namespace Composer\Package;
  25780. interface RootPackageInterface extends CompletePackageInterface
  25781. {
  25782. public function getAliases(): array;
  25783. public function getMinimumStability(): string;
  25784. public function getStabilityFlags(): array;
  25785. public function getReferences(): array;
  25786. public function getPreferStable(): bool;
  25787. public function getConfig(): array;
  25788. public function setRequires(array $requires): void;
  25789. public function setDevRequires(array $devRequires): void;
  25790. public function setConflicts(array $conflicts): void;
  25791. public function setProvides(array $provides): void;
  25792. public function setReplaces(array $replaces): void;
  25793. public function setAutoload(array $autoload): void;
  25794. public function setDevAutoload(array $devAutoload): void;
  25795. public function setStabilityFlags(array $stabilityFlags): void;
  25796. public function setMinimumStability(string $minimumStability): void;
  25797. public function setPreferStable(bool $preferStable): void;
  25798. public function setConfig(array $config): void;
  25799. public function setReferences(array $references): void;
  25800. public function setAliases(array $aliases): void;
  25801. public function setSuggests(array $suggests): void;
  25802. public function setExtra(array $extra): void;
  25803. }
  25804. <?php declare(strict_types=1);
  25805. namespace Composer\Package\Version;
  25806. use Composer\Package\BasePackage;
  25807. class StabilityFilter
  25808. {
  25809. public static function isPackageAcceptable(array $acceptableStabilities, array $stabilityFlags, array $names, string $stability): bool
  25810. {
  25811. foreach ($names as $name) {
  25812. if (isset($stabilityFlags[$name])) {
  25813. if (BasePackage::$stabilities[$stability] <= $stabilityFlags[$name]) {
  25814. return true;
  25815. }
  25816. } elseif (isset($acceptableStabilities[$stability])) {
  25817. return true;
  25818. }
  25819. }
  25820. return false;
  25821. }
  25822. }
  25823. <?php declare(strict_types=1);
  25824. namespace Composer\Package\Version;
  25825. use Composer\Package\PackageInterface;
  25826. use Composer\Package\Loader\ArrayLoader;
  25827. use Composer\Package\Dumper\ArrayDumper;
  25828. use Composer\Pcre\Preg;
  25829. use Composer\Semver\Constraint\Constraint;
  25830. use Composer\Semver\Constraint\ConstraintInterface;
  25831. use Composer\Semver\Intervals;
  25832. use Composer\Util\Platform;
  25833. class VersionBumper
  25834. {
  25835. public function bumpRequirement(ConstraintInterface $constraint, PackageInterface $package): string
  25836. {
  25837. $parser = new VersionParser();
  25838. $prettyConstraint = $constraint->getPrettyString();
  25839. if (str_starts_with($constraint->getPrettyString(), 'dev-')) {
  25840. return $prettyConstraint;
  25841. }
  25842. $version = $package->getVersion();
  25843. if (str_starts_with($package->getVersion(), 'dev-')) {
  25844. $loader = new ArrayLoader($parser);
  25845. $dumper = new ArrayDumper();
  25846. $extra = $loader->getBranchAlias($dumper->dump($package));
  25847. if (null === $extra || $extra === VersionParser::DEFAULT_BRANCH_ALIAS) {
  25848. return $prettyConstraint;
  25849. }
  25850. $version = $extra;
  25851. }
  25852. $intervals = Intervals::get($constraint);
  25853. if (\count($intervals['branches']['names']) > 0) {
  25854. return $prettyConstraint;
  25855. }
  25856. $major = Preg::replace('{^(\d+).*}', '$1', $version);
  25857. $versionWithoutSuffix = Preg::replace('{(?:\.(?:0|9999999))+(-dev)?$}', '', $version);
  25858. $newPrettyConstraint = '^'.$versionWithoutSuffix;
  25859. if (!Preg::isMatch('{^\^\d+(\.\d+)*$}', $newPrettyConstraint)) {
  25860. return $prettyConstraint;
  25861. }
  25862. $pattern = '{
  25863. (?<=,|\ |\||^) # leading separator
  25864. (?P<constraint>
  25865. \^'.$major.'(?:\.\d+)* # e.g. ^2.anything
  25866. | ~'.$major.'(?:\.\d+){0,2} # e.g. ~2 or ~2.2 or ~2.2.2 but no more
  25867. | '.$major.'(?:\.[*x])+ # e.g. 2.* or 2.*.* or 2.x.x.x etc
  25868. | >=\d(?:\.\d+)* # e.g. >=2 or >=1.2 etc
  25869. )
  25870. (?=,|$|\ |\||@) # trailing separator
  25871. }x';
  25872. if (Preg::isMatchAllWithOffsets($pattern, $prettyConstraint, $matches)) {
  25873. $modified = $prettyConstraint;
  25874. foreach (array_reverse($matches['constraint']) as $match) {
  25875. assert(is_string($match[0]));
  25876. $suffix = '';
  25877. if (substr_count($match[0], '.') === 2 && substr_count($versionWithoutSuffix, '.') === 1) {
  25878. $suffix = '.0';
  25879. }
  25880. if (str_starts_with($match[0], '~') && substr_count($match[0], '.') === 2) {
  25881. $replacement = '~'.$versionWithoutSuffix.$suffix;
  25882. } elseif (str_starts_with($match[0], '>=')) {
  25883. $replacement = '>='.$versionWithoutSuffix.$suffix;
  25884. } else {
  25885. $replacement = $newPrettyConstraint.$suffix;
  25886. }
  25887. $modified = substr_replace($modified, $replacement, $match[1], Platform::strlen($match[0]));
  25888. }
  25889. $newConstraint = $parser->parseConstraints($modified);
  25890. if (Intervals::isSubsetOf($newConstraint, $constraint) && Intervals::isSubsetOf($constraint, $newConstraint)) {
  25891. return $prettyConstraint;
  25892. }
  25893. return $modified;
  25894. }
  25895. return $prettyConstraint;
  25896. }
  25897. }
  25898. <?php declare(strict_types=1);
  25899. namespace Composer\Package\Version;
  25900. use Composer\Config;
  25901. use Composer\Pcre\Preg;
  25902. use Composer\Repository\Vcs\HgDriver;
  25903. use Composer\IO\NullIO;
  25904. use Composer\Semver\VersionParser as SemverVersionParser;
  25905. use Composer\Util\Git as GitUtil;
  25906. use Composer\Util\HttpDownloader;
  25907. use Composer\Util\Platform;
  25908. use Composer\Util\ProcessExecutor;
  25909. use Composer\Util\Svn as SvnUtil;
  25910. use React\Promise\CancellablePromiseInterface;
  25911. use Symfony\Component\Process\Process;
  25912. class VersionGuesser
  25913. {
  25914. private $config;
  25915. private $process;
  25916. private $versionParser;
  25917. public function __construct(Config $config, ProcessExecutor $process, SemverVersionParser $versionParser)
  25918. {
  25919. $this->config = $config;
  25920. $this->process = $process;
  25921. $this->versionParser = $versionParser;
  25922. }
  25923. public function guessVersion(array $packageConfig, string $path): ?array
  25924. {
  25925. if (!function_exists('proc_open')) {
  25926. return null;
  25927. }
  25928. if (Platform::isInputCompletionProcess()) {
  25929. return null;
  25930. }
  25931. $versionData = $this->guessGitVersion($packageConfig, $path);
  25932. if (null !== $versionData['version']) {
  25933. return $this->postprocess($versionData);
  25934. }
  25935. $versionData = $this->guessHgVersion($packageConfig, $path);
  25936. if (null !== $versionData && null !== $versionData['version']) {
  25937. return $this->postprocess($versionData);
  25938. }
  25939. $versionData = $this->guessFossilVersion($path);
  25940. if (null !== $versionData['version']) {
  25941. return $this->postprocess($versionData);
  25942. }
  25943. $versionData = $this->guessSvnVersion($packageConfig, $path);
  25944. if (null !== $versionData && null !== $versionData['version']) {
  25945. return $this->postprocess($versionData);
  25946. }
  25947. return null;
  25948. }
  25949. private function postprocess(array $versionData): array
  25950. {
  25951. if (!empty($versionData['feature_version']) && $versionData['feature_version'] === $versionData['version'] && $versionData['feature_pretty_version'] === $versionData['pretty_version']) {
  25952. unset($versionData['feature_version'], $versionData['feature_pretty_version']);
  25953. }
  25954. if ('-dev' === substr($versionData['version'], -4) && Preg::isMatch('{\.9{7}}', $versionData['version'])) {
  25955. $versionData['pretty_version'] = Preg::replace('{(\.9{7})+}', '.x', $versionData['version']);
  25956. }
  25957. if (!empty($versionData['feature_version']) && '-dev' === substr($versionData['feature_version'], -4) && Preg::isMatch('{\.9{7}}', $versionData['feature_version'])) {
  25958. $versionData['feature_pretty_version'] = Preg::replace('{(\.9{7})+}', '.x', $versionData['feature_version']);
  25959. }
  25960. return $versionData;
  25961. }
  25962. private function guessGitVersion(array $packageConfig, string $path): array
  25963. {
  25964. GitUtil::cleanEnv();
  25965. $commit = null;
  25966. $version = null;
  25967. $prettyVersion = null;
  25968. $featureVersion = null;
  25969. $featurePrettyVersion = null;
  25970. $isDetached = false;
  25971. if (0 === $this->process->execute(['git', 'branch', '-a', '--no-color', '--no-abbrev', '-v'], $output, $path)) {
  25972. $branches = [];
  25973. $isFeatureBranch = false;
  25974. foreach ($this->process->splitLines($output) as $branch) {
  25975. if ($branch && Preg::isMatchStrictGroups('{^(?:\* ) *(\(no branch\)|\(detached from \S+\)|\(HEAD detached at \S+\)|\S+) *([a-f0-9]+) .*$}', $branch, $match)) {
  25976. if (
  25977. $match[1] === '(no branch)'
  25978. || strpos($match[1], '(detached ') === 0
  25979. || strpos($match[1], '(HEAD detached at') === 0
  25980. ) {
  25981. $version = 'dev-' . $match[2];
  25982. $prettyVersion = $version;
  25983. $isFeatureBranch = true;
  25984. $isDetached = true;
  25985. } else {
  25986. $version = $this->versionParser->normalizeBranch($match[1]);
  25987. $prettyVersion = 'dev-' . $match[1];
  25988. $isFeatureBranch = $this->isFeatureBranch($packageConfig, $match[1]);
  25989. }
  25990. $commit = $match[2];
  25991. }
  25992. if ($branch && !Preg::isMatchStrictGroups('{^ *.+/HEAD }', $branch)) {
  25993. if (Preg::isMatchStrictGroups('{^(?:\* )? *((?:remotes/(?:origin|upstream)/)?[^\s/]+) *([a-f0-9]+) .*$}', $branch, $match)) {
  25994. $branches[] = $match[1];
  25995. }
  25996. }
  25997. }
  25998. if ($isFeatureBranch) {
  25999. $featureVersion = $version;
  26000. $featurePrettyVersion = $prettyVersion;
  26001. $result = $this->guessFeatureVersion($packageConfig, $version, $branches, 'git rev-list %candidate%..%branch%', $path);
  26002. $version = $result['version'];
  26003. $prettyVersion = $result['pretty_version'];
  26004. }
  26005. }
  26006. if (!$version || $isDetached) {
  26007. $result = $this->versionFromGitTags($path);
  26008. if ($result) {
  26009. $version = $result['version'];
  26010. $prettyVersion = $result['pretty_version'];
  26011. $featureVersion = null;
  26012. $featurePrettyVersion = null;
  26013. }
  26014. }
  26015. if (null === $commit) {
  26016. $command = 'git log --pretty="%H" -n1 HEAD'.GitUtil::getNoShowSignatureFlag($this->process);
  26017. if (0 === $this->process->execute($command, $output, $path)) {
  26018. $commit = trim($output) ?: null;
  26019. }
  26020. }
  26021. if ($featureVersion) {
  26022. return ['version' => $version, 'commit' => $commit, 'pretty_version' => $prettyVersion, 'feature_version' => $featureVersion, 'feature_pretty_version' => $featurePrettyVersion];
  26023. }
  26024. return ['version' => $version, 'commit' => $commit, 'pretty_version' => $prettyVersion];
  26025. }
  26026. private function versionFromGitTags(string $path): ?array
  26027. {
  26028. if (0 === $this->process->execute('git describe --exact-match --tags', $output, $path)) {
  26029. try {
  26030. $version = $this->versionParser->normalize(trim($output));
  26031. return ['version' => $version, 'pretty_version' => trim($output)];
  26032. } catch (\Exception $e) {
  26033. }
  26034. }
  26035. return null;
  26036. }
  26037. private function guessHgVersion(array $packageConfig, string $path): ?array
  26038. {
  26039. if (0 === $this->process->execute('hg branch', $output, $path)) {
  26040. $branch = trim($output);
  26041. $version = $this->versionParser->normalizeBranch($branch);
  26042. $isFeatureBranch = 0 === strpos($version, 'dev-');
  26043. if (VersionParser::DEFAULT_BRANCH_ALIAS === $version) {
  26044. return ['version' => $version, 'commit' => null, 'pretty_version' => 'dev-'.$branch];
  26045. }
  26046. if (!$isFeatureBranch) {
  26047. return ['version' => $version, 'commit' => null, 'pretty_version' => $version];
  26048. }
  26049. $io = new NullIO();
  26050. $driver = new HgDriver(['url' => $path], $io, $this->config, new HttpDownloader($io, $this->config), $this->process);
  26051. $branches = array_map('strval', array_keys($driver->getBranches()));
  26052. $result = $this->guessFeatureVersion($packageConfig, $version, $branches, 'hg log -r "not ancestors(\'%candidate%\') and ancestors(\'%branch%\')" --template "{node}\\n"', $path);
  26053. $result['commit'] = '';
  26054. $result['feature_version'] = $version;
  26055. $result['feature_pretty_version'] = $version;
  26056. return $result;
  26057. }
  26058. return null;
  26059. }
  26060. private function guessFeatureVersion(array $packageConfig, ?string $version, array $branches, string $scmCmdline, string $path): array
  26061. {
  26062. $prettyVersion = $version;
  26063. if (!isset($packageConfig['extra']['branch-alias'][$version])
  26064. || strpos(json_encode($packageConfig), '"self.version"')
  26065. ) {
  26066. $branch = Preg::replace('{^dev-}', '', $version);
  26067. $length = PHP_INT_MAX;
  26068. if (!$this->isFeatureBranch($packageConfig, $branch)) {
  26069. return ['version' => $version, 'pretty_version' => $prettyVersion];
  26070. }
  26071. usort($branches, static function ($a, $b): int {
  26072. $aRemote = 0 === strpos($a, 'remotes/');
  26073. $bRemote = 0 === strpos($b, 'remotes/');
  26074. if ($aRemote !== $bRemote) {
  26075. return $aRemote ? 1 : -1;
  26076. }
  26077. return strnatcasecmp($b, $a);
  26078. });
  26079. $promises = [];
  26080. $this->process->setMaxJobs(30);
  26081. try {
  26082. foreach ($branches as $candidate) {
  26083. $candidateVersion = Preg::replace('{^remotes/\S+/}', '', $candidate);
  26084. if ($candidate === $branch || $this->isFeatureBranch($packageConfig, $candidateVersion)) {
  26085. continue;
  26086. }
  26087. $cmdLine = str_replace(['%candidate%', '%branch%'], [$candidate, $branch], $scmCmdline);
  26088. $promises[] = $this->process->executeAsync($cmdLine, $path)->then(function (Process $process) use (&$length, &$version, &$prettyVersion, $candidateVersion, &$promises): void {
  26089. if (!$process->isSuccessful()) {
  26090. return;
  26091. }
  26092. $output = $process->getOutput();
  26093. if (strlen($output) < $length) {
  26094. $length = strlen($output);
  26095. $version = $this->versionParser->normalizeBranch($candidateVersion);
  26096. $prettyVersion = 'dev-' . $candidateVersion;
  26097. if ($length === 0) {
  26098. foreach ($promises as $promise) {
  26099. \React\Promise\resolve($promise)->cancel();
  26100. }
  26101. }
  26102. }
  26103. });
  26104. }
  26105. $this->process->wait();
  26106. } finally {
  26107. $this->process->resetMaxJobs();
  26108. }
  26109. }
  26110. return ['version' => $version, 'pretty_version' => $prettyVersion];
  26111. }
  26112. private function isFeatureBranch(array $packageConfig, ?string $branchName): bool
  26113. {
  26114. $nonFeatureBranches = '';
  26115. if (!empty($packageConfig['non-feature-branches'])) {
  26116. $nonFeatureBranches = implode('|', $packageConfig['non-feature-branches']);
  26117. }
  26118. return !Preg::isMatch('{^(' . $nonFeatureBranches . '|master|main|latest|next|current|support|tip|trunk|default|develop|\d+\..+)$}', $branchName, $match);
  26119. }
  26120. private function guessFossilVersion(string $path): array
  26121. {
  26122. $version = null;
  26123. $prettyVersion = null;
  26124. if (0 === $this->process->execute('fossil branch list', $output, $path)) {
  26125. $branch = trim($output);
  26126. $version = $this->versionParser->normalizeBranch($branch);
  26127. $prettyVersion = 'dev-' . $branch;
  26128. }
  26129. if (0 === $this->process->execute('fossil tag list', $output, $path)) {
  26130. try {
  26131. $version = $this->versionParser->normalize(trim($output));
  26132. $prettyVersion = trim($output);
  26133. } catch (\Exception $e) {
  26134. }
  26135. }
  26136. return ['version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion];
  26137. }
  26138. private function guessSvnVersion(array $packageConfig, string $path): ?array
  26139. {
  26140. SvnUtil::cleanEnv();
  26141. if (0 === $this->process->execute('svn info --xml', $output, $path)) {
  26142. $trunkPath = isset($packageConfig['trunk-path']) ? preg_quote($packageConfig['trunk-path'], '#') : 'trunk';
  26143. $branchesPath = isset($packageConfig['branches-path']) ? preg_quote($packageConfig['branches-path'], '#') : 'branches';
  26144. $tagsPath = isset($packageConfig['tags-path']) ? preg_quote($packageConfig['tags-path'], '#') : 'tags';
  26145. $urlPattern = '#<url>.*/(' . $trunkPath . '|(' . $branchesPath . '|' . $tagsPath . ')/(.*))</url>#';
  26146. if (Preg::isMatch($urlPattern, $output, $matches)) {
  26147. if (isset($matches[2], $matches[3]) && ($branchesPath === $matches[2] || $tagsPath === $matches[2])) {
  26148. $version = $this->versionParser->normalizeBranch($matches[3]);
  26149. $prettyVersion = 'dev-' . $matches[3];
  26150. return ['version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion];
  26151. }
  26152. assert(is_string($matches[1]));
  26153. $prettyVersion = trim($matches[1]);
  26154. if ($prettyVersion === 'trunk') {
  26155. $version = 'dev-trunk';
  26156. } else {
  26157. $version = $this->versionParser->normalize($prettyVersion);
  26158. }
  26159. return ['version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion];
  26160. }
  26161. }
  26162. return null;
  26163. }
  26164. }
  26165. <?php declare(strict_types=1);
  26166. namespace Composer\Package\Version;
  26167. use Composer\Pcre\Preg;
  26168. use Composer\Repository\PlatformRepository;
  26169. use Composer\Semver\VersionParser as SemverVersionParser;
  26170. use Composer\Semver\Semver;
  26171. use Composer\Semver\Constraint\ConstraintInterface;
  26172. class VersionParser extends SemverVersionParser
  26173. {
  26174. public const DEFAULT_BRANCH_ALIAS = '9999999-dev';
  26175. private static $constraints = [];
  26176. public function parseConstraints($constraints): ConstraintInterface
  26177. {
  26178. if (!isset(self::$constraints[$constraints])) {
  26179. self::$constraints[$constraints] = parent::parseConstraints($constraints);
  26180. }
  26181. return self::$constraints[$constraints];
  26182. }
  26183. public function parseNameVersionPairs(array $pairs): array
  26184. {
  26185. $pairs = array_values($pairs);
  26186. $result = [];
  26187. for ($i = 0, $count = count($pairs); $i < $count; $i++) {
  26188. $pair = Preg::replace('{^([^=: ]+)[=: ](.*)$}', '$1 $2', trim($pairs[$i]));
  26189. 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])) {
  26190. $pair .= ' '.$pairs[$i + 1];
  26191. $i++;
  26192. }
  26193. if (strpos($pair, ' ')) {
  26194. [$name, $version] = explode(' ', $pair, 2);
  26195. $result[] = ['name' => $name, 'version' => $version];
  26196. } else {
  26197. $result[] = ['name' => $pair];
  26198. }
  26199. }
  26200. return $result;
  26201. }
  26202. public static function isUpgrade(string $normalizedFrom, string $normalizedTo): bool
  26203. {
  26204. if ($normalizedFrom === $normalizedTo) {
  26205. return true;
  26206. }
  26207. if (in_array($normalizedFrom, ['dev-master', 'dev-trunk', 'dev-default'], true)) {
  26208. $normalizedFrom = VersionParser::DEFAULT_BRANCH_ALIAS;
  26209. }
  26210. if (in_array($normalizedTo, ['dev-master', 'dev-trunk', 'dev-default'], true)) {
  26211. $normalizedTo = VersionParser::DEFAULT_BRANCH_ALIAS;
  26212. }
  26213. if (strpos($normalizedFrom, 'dev-') === 0 || strpos($normalizedTo, 'dev-') === 0) {
  26214. return true;
  26215. }
  26216. $sorted = Semver::sort([$normalizedTo, $normalizedFrom]);
  26217. return $sorted[0] === $normalizedFrom;
  26218. }
  26219. }
  26220. <?php declare(strict_types=1);
  26221. namespace Composer\Package\Version;
  26222. use Composer\Filter\PlatformRequirementFilter\IgnoreAllPlatformRequirementFilter;
  26223. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  26224. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  26225. use Composer\IO\IOInterface;
  26226. use Composer\Package\BasePackage;
  26227. use Composer\Package\AliasPackage;
  26228. use Composer\Package\PackageInterface;
  26229. use Composer\Composer;
  26230. use Composer\Package\Loader\ArrayLoader;
  26231. use Composer\Package\Dumper\ArrayDumper;
  26232. use Composer\Pcre\Preg;
  26233. use Composer\Repository\RepositorySet;
  26234. use Composer\Repository\PlatformRepository;
  26235. use Composer\Semver\Constraint\Constraint;
  26236. use Composer\Semver\Constraint\ConstraintInterface;
  26237. class VersionSelector
  26238. {
  26239. private $repositorySet;
  26240. private $platformConstraints = [];
  26241. private $parser;
  26242. public function __construct(RepositorySet $repositorySet, ?PlatformRepository $platformRepo = null)
  26243. {
  26244. $this->repositorySet = $repositorySet;
  26245. if ($platformRepo) {
  26246. foreach ($platformRepo->getPackages() as $package) {
  26247. $this->platformConstraints[$package->getName()][] = new Constraint('==', $package->getVersion());
  26248. }
  26249. }
  26250. }
  26251. public function findBestCandidate(string $packageName, ?string $targetPackageVersion = null, string $preferredStability = 'stable', $platformRequirementFilter = null, int $repoSetFlags = 0, ?IOInterface $io = null, $showWarnings = true)
  26252. {
  26253. if (!isset(BasePackage::$stabilities[$preferredStability])) {
  26254. throw new \UnexpectedValueException('Expected a valid stability name as 3rd argument, got '.$preferredStability);
  26255. }
  26256. if (null === $platformRequirementFilter) {
  26257. $platformRequirementFilter = PlatformRequirementFilterFactory::ignoreNothing();
  26258. } elseif (!($platformRequirementFilter instanceof PlatformRequirementFilterInterface)) {
  26259. 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);
  26260. $platformRequirementFilter = PlatformRequirementFilterFactory::fromBoolOrList($platformRequirementFilter);
  26261. }
  26262. $constraint = $targetPackageVersion ? $this->getParser()->parseConstraints($targetPackageVersion) : null;
  26263. $candidates = $this->repositorySet->findPackages(strtolower($packageName), $constraint, $repoSetFlags);
  26264. $minPriority = BasePackage::$stabilities[$preferredStability];
  26265. usort($candidates, static function (PackageInterface $a, PackageInterface $b) use ($minPriority) {
  26266. $aPriority = $a->getStabilityPriority();
  26267. $bPriority = $b->getStabilityPriority();
  26268. if ($minPriority < $aPriority && $bPriority < $aPriority) {
  26269. return 1;
  26270. }
  26271. if ($minPriority < $aPriority && $aPriority < $bPriority) {
  26272. return -1;
  26273. }
  26274. if ($minPriority >= $aPriority && $minPriority < $bPriority) {
  26275. return -1;
  26276. }
  26277. return version_compare($b->getVersion(), $a->getVersion());
  26278. });
  26279. if (count($this->platformConstraints) > 0 && !($platformRequirementFilter instanceof IgnoreAllPlatformRequirementFilter)) {
  26280. $alreadyWarnedNames = [];
  26281. $alreadySeenNames = [];
  26282. foreach ($candidates as $pkg) {
  26283. $reqs = $pkg->getRequires();
  26284. foreach ($reqs as $name => $link) {
  26285. if (!PlatformRepository::isPlatformPackage($name) || $platformRequirementFilter->isIgnored($name)) {
  26286. continue;
  26287. }
  26288. if (isset($this->platformConstraints[$name])) {
  26289. foreach ($this->platformConstraints[$name] as $providedConstraint) {
  26290. if ($link->getConstraint()->matches($providedConstraint)) {
  26291. continue 2;
  26292. }
  26293. }
  26294. $reason = 'is not satisfied by your platform';
  26295. } else {
  26296. $reason = 'is missing from your platform';
  26297. }
  26298. $isLatestVersion = !isset($alreadySeenNames[$pkg->getName()]);
  26299. $alreadySeenNames[$pkg->getName()] = true;
  26300. if ($io !== null && ($showWarnings === true || (is_callable($showWarnings) && $showWarnings($pkg)))) {
  26301. $isFirstWarning = !isset($alreadyWarnedNames[$pkg->getName()]);
  26302. $alreadyWarnedNames[$pkg->getName()] = true;
  26303. $latest = $isLatestVersion ? "'s latest version" : '';
  26304. $io->writeError(
  26305. '<warning>Cannot use '.$pkg->getPrettyName().$latest.' '.$pkg->getPrettyVersion().' as it '.$link->getDescription().' '.$link->getTarget().' '.$link->getPrettyConstraint().' which '.$reason.'.</>',
  26306. true,
  26307. $isFirstWarning ? IOInterface::NORMAL : IOInterface::VERBOSE
  26308. );
  26309. }
  26310. continue 2;
  26311. }
  26312. $package = $pkg;
  26313. break;
  26314. }
  26315. } else {
  26316. $package = count($candidates) > 0 ? $candidates[0] : null;
  26317. }
  26318. if (!isset($package)) {
  26319. return false;
  26320. }
  26321. if ($package instanceof AliasPackage && $package->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  26322. $package = $package->getAliasOf();
  26323. }
  26324. return $package;
  26325. }
  26326. public function findRecommendedRequireVersion(PackageInterface $package): string
  26327. {
  26328. if (0 === strpos($package->getName(), 'ext-')) {
  26329. $phpVersion = PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
  26330. $extVersion = implode('.', array_slice(explode('.', $package->getVersion()), 0, 3));
  26331. if ($phpVersion === $extVersion) {
  26332. return '*';
  26333. }
  26334. }
  26335. $version = $package->getVersion();
  26336. if (!$package->isDev()) {
  26337. return $this->transformVersion($version, $package->getPrettyVersion(), $package->getStability());
  26338. }
  26339. $loader = new ArrayLoader($this->getParser());
  26340. $dumper = new ArrayDumper();
  26341. $extra = $loader->getBranchAlias($dumper->dump($package));
  26342. if ($extra && $extra !== VersionParser::DEFAULT_BRANCH_ALIAS) {
  26343. $extra = Preg::replace('{^(\d+\.\d+\.\d+)(\.9999999)-dev$}', '$1.0', $extra, -1, $count);
  26344. if ($count > 0) {
  26345. $extra = str_replace('.9999999', '.0', $extra);
  26346. return $this->transformVersion($extra, $extra, 'dev');
  26347. }
  26348. }
  26349. return $package->getPrettyVersion();
  26350. }
  26351. private function transformVersion(string $version, string $prettyVersion, string $stability): string
  26352. {
  26353. $semanticVersionParts = explode('.', $version);
  26354. if (count($semanticVersionParts) === 4 && Preg::isMatch('{^0\D?}', $semanticVersionParts[3])) {
  26355. if ($semanticVersionParts[0] === '0') {
  26356. unset($semanticVersionParts[3]);
  26357. } else {
  26358. unset($semanticVersionParts[2], $semanticVersionParts[3]);
  26359. }
  26360. $version = implode('.', $semanticVersionParts);
  26361. } else {
  26362. return $prettyVersion;
  26363. }
  26364. if ($stability !== 'stable') {
  26365. $version .= '@'.$stability;
  26366. }
  26367. return '^' . $version;
  26368. }
  26369. private function getParser(): VersionParser
  26370. {
  26371. if ($this->parser === null) {
  26372. $this->parser = new VersionParser();
  26373. }
  26374. return $this->parser;
  26375. }
  26376. }
  26377. <?php declare(strict_types=1);
  26378. namespace Composer;
  26379. use Composer\Package\RootPackageInterface;
  26380. use Composer\Util\Loop;
  26381. use Composer\Repository\RepositoryManager;
  26382. use Composer\Installer\InstallationManager;
  26383. use Composer\EventDispatcher\EventDispatcher;
  26384. class PartialComposer
  26385. {
  26386. private $package;
  26387. private $loop;
  26388. private $repositoryManager;
  26389. private $installationManager;
  26390. private $config;
  26391. private $eventDispatcher;
  26392. public function setPackage(RootPackageInterface $package): void
  26393. {
  26394. $this->package = $package;
  26395. }
  26396. public function getPackage(): RootPackageInterface
  26397. {
  26398. return $this->package;
  26399. }
  26400. public function setConfig(Config $config): void
  26401. {
  26402. $this->config = $config;
  26403. }
  26404. public function getConfig(): Config
  26405. {
  26406. return $this->config;
  26407. }
  26408. public function setLoop(Loop $loop): void
  26409. {
  26410. $this->loop = $loop;
  26411. }
  26412. public function getLoop(): Loop
  26413. {
  26414. return $this->loop;
  26415. }
  26416. public function setRepositoryManager(RepositoryManager $manager): void
  26417. {
  26418. $this->repositoryManager = $manager;
  26419. }
  26420. public function getRepositoryManager(): RepositoryManager
  26421. {
  26422. return $this->repositoryManager;
  26423. }
  26424. public function setInstallationManager(InstallationManager $manager): void
  26425. {
  26426. $this->installationManager = $manager;
  26427. }
  26428. public function getInstallationManager(): InstallationManager
  26429. {
  26430. return $this->installationManager;
  26431. }
  26432. public function setEventDispatcher(EventDispatcher $eventDispatcher): void
  26433. {
  26434. $this->eventDispatcher = $eventDispatcher;
  26435. }
  26436. public function getEventDispatcher(): EventDispatcher
  26437. {
  26438. return $this->eventDispatcher;
  26439. }
  26440. }
  26441. <?php declare(strict_types=1);
  26442. namespace Composer\Platform;
  26443. use Composer\Util\Platform;
  26444. use Composer\Util\ProcessExecutor;
  26445. use Symfony\Component\Process\ExecutableFinder;
  26446. class HhvmDetector
  26447. {
  26448. private static $hhvmVersion = null;
  26449. private $executableFinder;
  26450. private $processExecutor;
  26451. public function __construct(?ExecutableFinder $executableFinder = null, ?ProcessExecutor $processExecutor = null)
  26452. {
  26453. $this->executableFinder = $executableFinder;
  26454. $this->processExecutor = $processExecutor;
  26455. }
  26456. public function reset(): void
  26457. {
  26458. self::$hhvmVersion = null;
  26459. }
  26460. public function getVersion(): ?string
  26461. {
  26462. if (null !== self::$hhvmVersion) {
  26463. return self::$hhvmVersion ?: null;
  26464. }
  26465. self::$hhvmVersion = defined('HHVM_VERSION') ? HHVM_VERSION : null;
  26466. if (self::$hhvmVersion === null && !Platform::isWindows()) {
  26467. self::$hhvmVersion = false;
  26468. $this->executableFinder = $this->executableFinder ?: new ExecutableFinder();
  26469. $hhvmPath = $this->executableFinder->find('hhvm');
  26470. if ($hhvmPath !== null) {
  26471. $this->processExecutor = $this->processExecutor ?? new ProcessExecutor();
  26472. $exitCode = $this->processExecutor->execute(
  26473. ProcessExecutor::escape($hhvmPath).
  26474. ' --php -d hhvm.jit=0 -r "echo HHVM_VERSION;" 2>/dev/null',
  26475. self::$hhvmVersion
  26476. );
  26477. if ($exitCode !== 0) {
  26478. self::$hhvmVersion = false;
  26479. }
  26480. }
  26481. }
  26482. return self::$hhvmVersion ?: null;
  26483. }
  26484. }
  26485. <?php declare(strict_types=1);
  26486. namespace Composer\Platform;
  26487. class Runtime
  26488. {
  26489. public function hasConstant(string $constant, ?string $class = null): bool
  26490. {
  26491. return defined(ltrim($class.'::'.$constant, ':'));
  26492. }
  26493. public function getConstant(string $constant, ?string $class = null)
  26494. {
  26495. return constant(ltrim($class.'::'.$constant, ':'));
  26496. }
  26497. public function hasFunction(string $fn): bool
  26498. {
  26499. return function_exists($fn);
  26500. }
  26501. public function invoke(callable $callable, array $arguments = [])
  26502. {
  26503. return $callable(...$arguments);
  26504. }
  26505. public function hasClass(string $class): bool
  26506. {
  26507. return class_exists($class, false);
  26508. }
  26509. public function construct(string $class, array $arguments = []): object
  26510. {
  26511. if (empty($arguments)) {
  26512. return new $class;
  26513. }
  26514. $refl = new \ReflectionClass($class);
  26515. return $refl->newInstanceArgs($arguments);
  26516. }
  26517. public function getExtensions(): array
  26518. {
  26519. return get_loaded_extensions();
  26520. }
  26521. public function getExtensionVersion(string $extension): string
  26522. {
  26523. $version = phpversion($extension);
  26524. if ($version === false) {
  26525. $version = '0';
  26526. }
  26527. return $version;
  26528. }
  26529. public function getExtensionInfo(string $extension): string
  26530. {
  26531. $reflector = new \ReflectionExtension($extension);
  26532. ob_start();
  26533. $reflector->info();
  26534. return ob_get_clean();
  26535. }
  26536. }
  26537. <?php declare(strict_types=1);
  26538. namespace Composer\Platform;
  26539. use Composer\Pcre\Preg;
  26540. class Version
  26541. {
  26542. public static function parseOpenssl(string $opensslVersion, ?bool &$isFips): ?string
  26543. {
  26544. $isFips = false;
  26545. if (!Preg::isMatchStrictGroups('/^(?<version>[0-9.]+)(?<patch>[a-z]{0,2})(?<suffix>(?:-?(?:dev|pre|alpha|beta|rc|fips)[\d]*)*)(?:-\w+)?(?: \(.+?\))?$/', $opensslVersion, $matches)) {
  26546. return null;
  26547. }
  26548. $patch = '';
  26549. if (version_compare($matches['version'], '3.0.0', '<')) {
  26550. $patch = '.'.self::convertAlphaVersionToIntVersion($matches['patch']);
  26551. }
  26552. $isFips = strpos($matches['suffix'], 'fips') !== false;
  26553. $suffix = strtr('-'.ltrim($matches['suffix'], '-'), ['-fips' => '', '-pre' => '-alpha']);
  26554. return rtrim($matches['version'].$patch.$suffix, '-');
  26555. }
  26556. public static function parseLibjpeg(string $libjpegVersion): ?string
  26557. {
  26558. if (!Preg::isMatchStrictGroups('/^(?<major>\d+)(?<minor>[a-z]*)$/', $libjpegVersion, $matches)) {
  26559. return null;
  26560. }
  26561. return $matches['major'].'.'.self::convertAlphaVersionToIntVersion($matches['minor']);
  26562. }
  26563. public static function parseZoneinfoVersion(string $zoneinfoVersion): ?string
  26564. {
  26565. if (!Preg::isMatchStrictGroups('/^(?<year>\d{4})(?<revision>[a-z]*)$/', $zoneinfoVersion, $matches)) {
  26566. return null;
  26567. }
  26568. return $matches['year'].'.'.self::convertAlphaVersionToIntVersion($matches['revision']);
  26569. }
  26570. private static function convertAlphaVersionToIntVersion(string $alpha): int
  26571. {
  26572. return strlen($alpha) * (-ord('a') + 1) + array_sum(array_map('ord', str_split($alpha)));
  26573. }
  26574. public static function convertLibxpmVersionId(int $versionId): string
  26575. {
  26576. return self::convertVersionId($versionId, 100);
  26577. }
  26578. public static function convertOpenldapVersionId(int $versionId): string
  26579. {
  26580. return self::convertVersionId($versionId, 100);
  26581. }
  26582. private static function convertVersionId(int $versionId, int $base): string
  26583. {
  26584. return sprintf(
  26585. '%d.%d.%d',
  26586. $versionId / ($base * $base),
  26587. (int) ($versionId / $base) % $base,
  26588. $versionId % $base
  26589. );
  26590. }
  26591. }
  26592. <?php declare(strict_types=1);
  26593. namespace Composer\Plugin\Capability;
  26594. interface Capability
  26595. {
  26596. }
  26597. <?php declare(strict_types=1);
  26598. namespace Composer\Plugin\Capability;
  26599. interface CommandProvider extends Capability
  26600. {
  26601. public function getCommands();
  26602. }
  26603. <?php declare(strict_types=1);
  26604. namespace Composer\Plugin;
  26605. interface Capable
  26606. {
  26607. public function getCapabilities();
  26608. }
  26609. <?php declare(strict_types=1);
  26610. namespace Composer\Plugin;
  26611. use Composer\EventDispatcher\Event;
  26612. use Symfony\Component\Console\Input\InputInterface;
  26613. use Symfony\Component\Console\Output\OutputInterface;
  26614. class CommandEvent extends Event
  26615. {
  26616. private $commandName;
  26617. private $input;
  26618. private $output;
  26619. public function __construct(string $name, string $commandName, InputInterface $input, OutputInterface $output, array $args = [], array $flags = [])
  26620. {
  26621. parent::__construct($name, $args, $flags);
  26622. $this->commandName = $commandName;
  26623. $this->input = $input;
  26624. $this->output = $output;
  26625. }
  26626. public function getInput(): InputInterface
  26627. {
  26628. return $this->input;
  26629. }
  26630. public function getOutput(): OutputInterface
  26631. {
  26632. return $this->output;
  26633. }
  26634. public function getCommandName(): string
  26635. {
  26636. return $this->commandName;
  26637. }
  26638. }
  26639. <?php declare(strict_types=1);
  26640. namespace Composer\Plugin;
  26641. use UnexpectedValueException;
  26642. class PluginBlockedException extends UnexpectedValueException
  26643. {
  26644. }
  26645. <?php declare(strict_types=1);
  26646. namespace Composer\Plugin;
  26647. class PluginEvents
  26648. {
  26649. public const INIT = 'init';
  26650. public const COMMAND = 'command';
  26651. public const PRE_FILE_DOWNLOAD = 'pre-file-download';
  26652. public const POST_FILE_DOWNLOAD = 'post-file-download';
  26653. public const PRE_COMMAND_RUN = 'pre-command-run';
  26654. public const PRE_POOL_CREATE = 'pre-pool-create';
  26655. }
  26656. <?php declare(strict_types=1);
  26657. namespace Composer\Plugin;
  26658. use Composer\Composer;
  26659. use Composer\IO\IOInterface;
  26660. interface PluginInterface
  26661. {
  26662. public const PLUGIN_API_VERSION = '2.6.0';
  26663. public function activate(Composer $composer, IOInterface $io);
  26664. public function deactivate(Composer $composer, IOInterface $io);
  26665. public function uninstall(Composer $composer, IOInterface $io);
  26666. }
  26667. <?php declare(strict_types=1);
  26668. namespace Composer\Plugin;
  26669. use Composer\Composer;
  26670. use Composer\EventDispatcher\EventSubscriberInterface;
  26671. use Composer\Installer\InstallerInterface;
  26672. use Composer\IO\IOInterface;
  26673. use Composer\Package\BasePackage;
  26674. use Composer\Package\CompletePackage;
  26675. use Composer\Package\Locker;
  26676. use Composer\Package\Package;
  26677. use Composer\Package\Version\VersionParser;
  26678. use Composer\PartialComposer;
  26679. use Composer\Pcre\Preg;
  26680. use Composer\Repository\RepositoryInterface;
  26681. use Composer\Repository\InstalledRepository;
  26682. use Composer\Repository\RootPackageRepository;
  26683. use Composer\Package\PackageInterface;
  26684. use Composer\Package\Link;
  26685. use Composer\Semver\Constraint\Constraint;
  26686. use Composer\Plugin\Capability\Capability;
  26687. use Composer\Util\PackageSorter;
  26688. class PluginManager
  26689. {
  26690. protected $composer;
  26691. protected $io;
  26692. protected $globalComposer;
  26693. protected $versionParser;
  26694. protected $disablePlugins = false;
  26695. protected $plugins = [];
  26696. protected $registeredPlugins = [];
  26697. private $allowPluginRules;
  26698. private $allowGlobalPluginRules;
  26699. private $runningInGlobalDir = false;
  26700. private static $classCounter = 0;
  26701. public function __construct(IOInterface $io, Composer $composer, ?PartialComposer $globalComposer = null, $disablePlugins = false)
  26702. {
  26703. $this->io = $io;
  26704. $this->composer = $composer;
  26705. $this->globalComposer = $globalComposer;
  26706. $this->versionParser = new VersionParser();
  26707. $this->disablePlugins = $disablePlugins;
  26708. $this->allowPluginRules = $this->parseAllowedPlugins($composer->getConfig()->get('allow-plugins'), $composer->getLocker());
  26709. $this->allowGlobalPluginRules = $this->parseAllowedPlugins($globalComposer !== null ? $globalComposer->getConfig()->get('allow-plugins') : false);
  26710. }
  26711. public function setRunningInGlobalDir(bool $runningInGlobalDir): void
  26712. {
  26713. $this->runningInGlobalDir = $runningInGlobalDir;
  26714. }
  26715. public function loadInstalledPlugins(): void
  26716. {
  26717. if (!$this->arePluginsDisabled('local')) {
  26718. $repo = $this->composer->getRepositoryManager()->getLocalRepository();
  26719. $this->loadRepository($repo, false);
  26720. }
  26721. if ($this->globalComposer !== null && !$this->arePluginsDisabled('global')) {
  26722. $this->loadRepository($this->globalComposer->getRepositoryManager()->getLocalRepository(), true);
  26723. }
  26724. }
  26725. public function deactivateInstalledPlugins(): void
  26726. {
  26727. if (!$this->arePluginsDisabled('local')) {
  26728. $repo = $this->composer->getRepositoryManager()->getLocalRepository();
  26729. $this->deactivateRepository($repo, false);
  26730. }
  26731. if ($this->globalComposer !== null && !$this->arePluginsDisabled('global')) {
  26732. $this->deactivateRepository($this->globalComposer->getRepositoryManager()->getLocalRepository(), true);
  26733. }
  26734. }
  26735. public function getPlugins(): array
  26736. {
  26737. return $this->plugins;
  26738. }
  26739. public function getGlobalComposer(): ?PartialComposer
  26740. {
  26741. return $this->globalComposer;
  26742. }
  26743. public function registerPackage(PackageInterface $package, bool $failOnMissingClasses = false, bool $isGlobalPlugin = false): void
  26744. {
  26745. if ($this->arePluginsDisabled($isGlobalPlugin ? 'global' : 'local')) {
  26746. return;
  26747. }
  26748. if ($package->getType() === 'composer-plugin') {
  26749. $requiresComposer = null;
  26750. foreach ($package->getRequires() as $link) {
  26751. if ('composer-plugin-api' === $link->getTarget()) {
  26752. $requiresComposer = $link->getConstraint();
  26753. break;
  26754. }
  26755. }
  26756. if (!$requiresComposer) {
  26757. throw new \RuntimeException("Plugin ".$package->getName()." is missing a require statement for a version of the composer-plugin-api package.");
  26758. }
  26759. $currentPluginApiVersion = $this->getPluginApiVersion();
  26760. $currentPluginApiConstraint = new Constraint('==', $this->versionParser->normalize($currentPluginApiVersion));
  26761. if ($requiresComposer->getPrettyString() === $this->getPluginApiVersion()) {
  26762. $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>');
  26763. } elseif (!$requiresComposer->matches($currentPluginApiConstraint)) {
  26764. $this->io->writeError('<warning>The "' . $package->getName() . '" plugin '.($isGlobalPlugin || $this->runningInGlobalDir ? '(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>');
  26765. return;
  26766. }
  26767. if ($package->getName() === 'symfony/flex' && Preg::isMatch('{^[0-9.]+$}', $package->getVersion()) && version_compare($package->getVersion(), '1.9.8', '<')) {
  26768. $this->io->writeError('<warning>The "' . $package->getName() . '" plugin '.($isGlobalPlugin || $this->runningInGlobalDir ? '(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>');
  26769. return;
  26770. }
  26771. }
  26772. if (!$this->isPluginAllowed($package->getName(), $isGlobalPlugin, true === ($package->getExtra()['plugin-optional'] ?? false))) {
  26773. $this->io->writeError('Skipped loading "'.$package->getName() . '" '.($isGlobalPlugin || $this->runningInGlobalDir ? '(installed globally) ' : '').'as it is not in config.allow-plugins', true, IOInterface::DEBUG);
  26774. return;
  26775. }
  26776. $oldInstallerPlugin = ($package->getType() === 'composer-installer');
  26777. if (isset($this->registeredPlugins[$package->getName()])) {
  26778. return;
  26779. }
  26780. $extra = $package->getExtra();
  26781. if (empty($extra['class'])) {
  26782. throw new \UnexpectedValueException('Error while installing '.$package->getPrettyName().', composer-plugin packages should have a class defined in their extra key to be usable.');
  26783. }
  26784. $classes = is_array($extra['class']) ? $extra['class'] : [$extra['class']];
  26785. $localRepo = $this->composer->getRepositoryManager()->getLocalRepository();
  26786. $globalRepo = $this->globalComposer !== null ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null;
  26787. $rootPackage = clone $this->composer->getPackage();
  26788. $rootPackageAutoloads = $rootPackage->getAutoload();
  26789. $rootPackageAutoloads['files'] = [];
  26790. $rootPackage->setAutoload($rootPackageAutoloads);
  26791. $rootPackageAutoloads = $rootPackage->getDevAutoload();
  26792. $rootPackageAutoloads['files'] = [];
  26793. $rootPackage->setDevAutoload($rootPackageAutoloads);
  26794. unset($rootPackageAutoloads);
  26795. $rootPackageRepo = new RootPackageRepository($rootPackage);
  26796. $installedRepo = new InstalledRepository([$localRepo, $rootPackageRepo]);
  26797. if ($globalRepo) {
  26798. $installedRepo->addRepository($globalRepo);
  26799. }
  26800. $autoloadPackages = [$package->getName() => $package];
  26801. $autoloadPackages = $this->collectDependencies($installedRepo, $autoloadPackages, $package);
  26802. $generator = $this->composer->getAutoloadGenerator();
  26803. $autoloads = [[$rootPackage, '']];
  26804. foreach ($autoloadPackages as $autoloadPackage) {
  26805. if ($autoloadPackage === $rootPackage) {
  26806. continue;
  26807. }
  26808. $installPath = $this->getInstallPath($autoloadPackage, $globalRepo && $globalRepo->hasPackage($autoloadPackage));
  26809. if ($installPath === null) {
  26810. continue;
  26811. }
  26812. $autoloads[] = [$autoloadPackage, $installPath];
  26813. }
  26814. $map = $generator->parseAutoloads($autoloads, $rootPackage);
  26815. $classLoader = $generator->createLoader($map, $this->composer->getConfig()->get('vendor-dir'));
  26816. $classLoader->register(false);
  26817. foreach ($map['files'] as $fileIdentifier => $file) {
  26818. if ($fileIdentifier === '7e9bd612cc444b3eed788ebbe46263a0') {
  26819. continue;
  26820. }
  26821. \Composer\Autoload\composerRequire($fileIdentifier, $file);
  26822. }
  26823. foreach ($classes as $class) {
  26824. if (class_exists($class, false)) {
  26825. $class = trim($class, '\\');
  26826. $path = $classLoader->findFile($class);
  26827. $code = file_get_contents($path);
  26828. $separatorPos = strrpos($class, '\\');
  26829. $className = $class;
  26830. if ($separatorPos) {
  26831. $className = substr($class, $separatorPos + 1);
  26832. }
  26833. $code = Preg::replace('{^((?:(?:final|readonly)\s+)*(?:\s*))class\s+('.preg_quote($className).')}mi', '$1class $2_composer_tmp'.self::$classCounter, $code, 1);
  26834. $code = strtr($code, [
  26835. '__FILE__' => var_export($path, true),
  26836. '__DIR__' => var_export(dirname($path), true),
  26837. '__CLASS__' => var_export($class, true),
  26838. ]);
  26839. $code = Preg::replace('/^\s*<\?(php)?/i', '', $code, 1);
  26840. eval($code);
  26841. $class .= '_composer_tmp'.self::$classCounter;
  26842. self::$classCounter++;
  26843. }
  26844. if ($oldInstallerPlugin) {
  26845. if (!is_a($class, 'Composer\Installer\InstallerInterface', true)) {
  26846. throw new \RuntimeException('Could not activate plugin "'.$package->getName().'" as "'.$class.'" does not implement Composer\Installer\InstallerInterface');
  26847. }
  26848. $this->io->writeError('<warning>Loading "'.$package->getName() . '" '.($isGlobalPlugin || $this->runningInGlobalDir ? '(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>');
  26849. $installer = new $class($this->io, $this->composer);
  26850. $this->composer->getInstallationManager()->addInstaller($installer);
  26851. $this->registeredPlugins[$package->getName()] = $installer;
  26852. } elseif (class_exists($class)) {
  26853. if (!is_a($class, 'Composer\Plugin\PluginInterface', true)) {
  26854. throw new \RuntimeException('Could not activate plugin "'.$package->getName().'" as "'.$class.'" does not implement Composer\Plugin\PluginInterface');
  26855. }
  26856. $plugin = new $class();
  26857. $this->addPlugin($plugin, $isGlobalPlugin, $package);
  26858. $this->registeredPlugins[$package->getName()] = $plugin;
  26859. } elseif ($failOnMissingClasses) {
  26860. throw new \UnexpectedValueException('Plugin '.$package->getName().' could not be initialized, class not found: '.$class);
  26861. }
  26862. }
  26863. }
  26864. public function deactivatePackage(PackageInterface $package): void
  26865. {
  26866. if (!isset($this->registeredPlugins[$package->getName()])) {
  26867. return;
  26868. }
  26869. $plugin = $this->registeredPlugins[$package->getName()];
  26870. unset($this->registeredPlugins[$package->getName()]);
  26871. if ($plugin instanceof InstallerInterface) {
  26872. $this->composer->getInstallationManager()->removeInstaller($plugin);
  26873. } else {
  26874. $this->removePlugin($plugin);
  26875. }
  26876. }
  26877. public function uninstallPackage(PackageInterface $package): void
  26878. {
  26879. if (!isset($this->registeredPlugins[$package->getName()])) {
  26880. return;
  26881. }
  26882. $plugin = $this->registeredPlugins[$package->getName()];
  26883. if ($plugin instanceof InstallerInterface) {
  26884. $this->deactivatePackage($package);
  26885. } else {
  26886. unset($this->registeredPlugins[$package->getName()]);
  26887. $this->removePlugin($plugin);
  26888. $this->uninstallPlugin($plugin);
  26889. }
  26890. }
  26891. protected function getPluginApiVersion(): string
  26892. {
  26893. return PluginInterface::PLUGIN_API_VERSION;
  26894. }
  26895. public function addPlugin(PluginInterface $plugin, bool $isGlobalPlugin = false, ?PackageInterface $sourcePackage = null): void
  26896. {
  26897. if ($this->arePluginsDisabled($isGlobalPlugin ? 'global' : 'local')) {
  26898. return;
  26899. }
  26900. if ($sourcePackage === null) {
  26901. 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);
  26902. } elseif (!$this->isPluginAllowed($sourcePackage->getName(), $isGlobalPlugin, true === ($sourcePackage->getExtra()['plugin-optional'] ?? false))) {
  26903. $this->io->writeError('Skipped loading "'.get_class($plugin).' from '.$sourcePackage->getName() . '" '.($isGlobalPlugin || $this->runningInGlobalDir ? '(installed globally) ' : '').' as it is not in config.allow-plugins', true, IOInterface::DEBUG);
  26904. return;
  26905. }
  26906. $details = [];
  26907. if ($sourcePackage) {
  26908. $details[] = 'from '.$sourcePackage->getName();
  26909. }
  26910. if ($isGlobalPlugin || $this->runningInGlobalDir) {
  26911. $details[] = 'installed globally';
  26912. }
  26913. $this->io->writeError('Loading plugin '.get_class($plugin).($details ? ' ('.implode(', ', $details).')' : ''), true, IOInterface::DEBUG);
  26914. $this->plugins[] = $plugin;
  26915. $plugin->activate($this->composer, $this->io);
  26916. if ($plugin instanceof EventSubscriberInterface) {
  26917. $this->composer->getEventDispatcher()->addSubscriber($plugin);
  26918. }
  26919. }
  26920. public function removePlugin(PluginInterface $plugin): void
  26921. {
  26922. $index = array_search($plugin, $this->plugins, true);
  26923. if ($index === false) {
  26924. return;
  26925. }
  26926. $this->io->writeError('Unloading plugin '.get_class($plugin), true, IOInterface::DEBUG);
  26927. unset($this->plugins[$index]);
  26928. $plugin->deactivate($this->composer, $this->io);
  26929. $this->composer->getEventDispatcher()->removeListener($plugin);
  26930. }
  26931. public function uninstallPlugin(PluginInterface $plugin): void
  26932. {
  26933. $this->io->writeError('Uninstalling plugin '.get_class($plugin), true, IOInterface::DEBUG);
  26934. $plugin->uninstall($this->composer, $this->io);
  26935. }
  26936. private function loadRepository(RepositoryInterface $repo, bool $isGlobalRepo): void
  26937. {
  26938. $packages = $repo->getPackages();
  26939. $weights = [];
  26940. foreach ($packages as $package) {
  26941. if ($package->getType() === 'composer-plugin') {
  26942. $extra = $package->getExtra();
  26943. if ($package->getName() === 'composer/installers' || true === ($extra['plugin-modifies-install-path'] ?? false)) {
  26944. $weights[$package->getName()] = -10000;
  26945. }
  26946. }
  26947. }
  26948. $sortedPackages = PackageSorter::sortPackages($packages, $weights);
  26949. foreach ($sortedPackages as $package) {
  26950. if (!($package instanceof CompletePackage)) {
  26951. continue;
  26952. }
  26953. if ('composer-plugin' === $package->getType()) {
  26954. $this->registerPackage($package, false, $isGlobalRepo);
  26955. } elseif ('composer-installer' === $package->getType()) {
  26956. $this->registerPackage($package, false, $isGlobalRepo);
  26957. }
  26958. }
  26959. }
  26960. private function deactivateRepository(RepositoryInterface $repo, bool $isGlobalRepo): void
  26961. {
  26962. $packages = $repo->getPackages();
  26963. $sortedPackages = array_reverse(PackageSorter::sortPackages($packages));
  26964. foreach ($sortedPackages as $package) {
  26965. if (!($package instanceof CompletePackage)) {
  26966. continue;
  26967. }
  26968. if ('composer-plugin' === $package->getType()) {
  26969. $this->deactivatePackage($package);
  26970. } elseif ('composer-installer' === $package->getType()) {
  26971. $this->deactivatePackage($package);
  26972. }
  26973. }
  26974. }
  26975. private function collectDependencies(InstalledRepository $installedRepo, array $collected, PackageInterface $package): array
  26976. {
  26977. foreach ($package->getRequires() as $requireLink) {
  26978. foreach ($installedRepo->findPackagesWithReplacersAndProviders($requireLink->getTarget()) as $requiredPackage) {
  26979. if (!isset($collected[$requiredPackage->getName()])) {
  26980. $collected[$requiredPackage->getName()] = $requiredPackage;
  26981. $collected = $this->collectDependencies($installedRepo, $collected, $requiredPackage);
  26982. }
  26983. }
  26984. }
  26985. return $collected;
  26986. }
  26987. private function getInstallPath(PackageInterface $package, bool $global = false): ?string
  26988. {
  26989. if (!$global) {
  26990. return $this->composer->getInstallationManager()->getInstallPath($package);
  26991. }
  26992. assert(null !== $this->globalComposer);
  26993. return $this->globalComposer->getInstallationManager()->getInstallPath($package);
  26994. }
  26995. protected function getCapabilityImplementationClassName(PluginInterface $plugin, string $capability): ?string
  26996. {
  26997. if (!($plugin instanceof Capable)) {
  26998. return null;
  26999. }
  27000. $capabilities = (array) $plugin->getCapabilities();
  27001. if (!empty($capabilities[$capability]) && is_string($capabilities[$capability]) && trim($capabilities[$capability])) {
  27002. return trim($capabilities[$capability]);
  27003. }
  27004. if (
  27005. array_key_exists($capability, $capabilities)
  27006. && (empty($capabilities[$capability]) || !is_string($capabilities[$capability]) || !trim($capabilities[$capability]))
  27007. ) {
  27008. throw new \UnexpectedValueException('Plugin '.get_class($plugin).' provided invalid capability class name(s), got '.var_export($capabilities[$capability], true));
  27009. }
  27010. return null;
  27011. }
  27012. public function getPluginCapability(PluginInterface $plugin, $capabilityClassName, array $ctorArgs = []): ?Capability
  27013. {
  27014. if ($capabilityClass = $this->getCapabilityImplementationClassName($plugin, $capabilityClassName)) {
  27015. if (!class_exists($capabilityClass)) {
  27016. throw new \RuntimeException("Cannot instantiate Capability, as class $capabilityClass from plugin ".get_class($plugin)." does not exist.");
  27017. }
  27018. $ctorArgs['plugin'] = $plugin;
  27019. $capabilityObj = new $capabilityClass($ctorArgs);
  27020. if (!$capabilityObj instanceof Capability || !$capabilityObj instanceof $capabilityClassName) {
  27021. throw new \RuntimeException(
  27022. 'Class ' . $capabilityClass . ' must implement both Composer\Plugin\Capability\Capability and '. $capabilityClassName . '.'
  27023. );
  27024. }
  27025. return $capabilityObj;
  27026. }
  27027. return null;
  27028. }
  27029. public function getPluginCapabilities($capabilityClassName, array $ctorArgs = []): array
  27030. {
  27031. $capabilities = [];
  27032. foreach ($this->getPlugins() as $plugin) {
  27033. $capability = $this->getPluginCapability($plugin, $capabilityClassName, $ctorArgs);
  27034. if (null !== $capability) {
  27035. $capabilities[] = $capability;
  27036. }
  27037. }
  27038. return $capabilities;
  27039. }
  27040. private function parseAllowedPlugins($allowPluginsConfig, ?Locker $locker = null): ?array
  27041. {
  27042. if ([] === $allowPluginsConfig && $locker !== null && $locker->isLocked() && version_compare($locker->getPluginApi(), '2.2.0', '<')) {
  27043. return null;
  27044. }
  27045. if (true === $allowPluginsConfig) {
  27046. return ['{}' => true];
  27047. }
  27048. if (false === $allowPluginsConfig) {
  27049. return ['{}' => false];
  27050. }
  27051. $rules = [];
  27052. foreach ($allowPluginsConfig as $pattern => $allow) {
  27053. $rules[BasePackage::packageNameToRegexp($pattern)] = $allow;
  27054. }
  27055. return $rules;
  27056. }
  27057. public function arePluginsDisabled($type)
  27058. {
  27059. return $this->disablePlugins === true || $this->disablePlugins === $type;
  27060. }
  27061. public function isPluginAllowed(string $package, bool $isGlobalPlugin, bool $optional = false): bool
  27062. {
  27063. if ($isGlobalPlugin) {
  27064. $rules = &$this->allowGlobalPluginRules;
  27065. } else {
  27066. $rules = &$this->allowPluginRules;
  27067. }
  27068. if ($rules === null) {
  27069. if (!$this->io->isInteractive()) {
  27070. $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>');
  27071. $this->io->writeError('<warning>This warning will become an exception once you run composer update!</warning>');
  27072. $rules = ['{}' => true];
  27073. return true;
  27074. }
  27075. $rules = [];
  27076. }
  27077. foreach ($rules as $pattern => $allow) {
  27078. if (Preg::isMatch($pattern, $package)) {
  27079. return $allow === true;
  27080. }
  27081. }
  27082. if ($package === 'composer/package-versions-deprecated') {
  27083. return false;
  27084. }
  27085. if ($this->io->isInteractive()) {
  27086. $composer = $isGlobalPlugin && $this->globalComposer !== null ? $this->globalComposer : $this->composer;
  27087. $this->io->writeError('<warning>'.$package.($isGlobalPlugin || $this->runningInGlobalDir ? ' (installed globally)' : '').' contains a Composer plugin which is currently not in your allow-plugins config. See https://getcomposer.org/allow-plugins</warning>');
  27088. $attempts = 0;
  27089. while (true) {
  27090. $default = '?';
  27091. if ($attempts > 5) {
  27092. $this->io->writeError('Too many failed prompts, aborting.');
  27093. break;
  27094. }
  27095. 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)) {
  27096. case 'y':
  27097. case 'n':
  27098. case 'd':
  27099. $allow = $answer === 'y';
  27100. $rules[BasePackage::packageNameToRegexp($package)] = $allow;
  27101. if ($answer === 'y' || $answer === 'n') {
  27102. $composer->getConfig()->getConfigSource()->addConfigSetting('allow-plugins.'.$package, $allow);
  27103. }
  27104. return $allow;
  27105. case '?':
  27106. default:
  27107. $attempts++;
  27108. $this->io->writeError([
  27109. 'y - add package to allow-plugins in composer.json and let it run immediately',
  27110. 'n - add package (as disallowed) to allow-plugins in composer.json to suppress further prompts',
  27111. 'd - discard this, do not change composer.json and do not allow the plugin to run',
  27112. '? - print help',
  27113. ]);
  27114. break;
  27115. }
  27116. }
  27117. } elseif ($optional) {
  27118. return false;
  27119. }
  27120. throw new PluginBlockedException(
  27121. $package.($isGlobalPlugin || $this->runningInGlobalDir ? ' (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.'.PHP_EOL.
  27122. 'You can run "composer '.($isGlobalPlugin || $this->runningInGlobalDir ? 'global ' : '').'config --no-plugins allow-plugins.'.$package.' [true|false]" to enable it (true) or disable it explicitly and suppress this exception (false)'.PHP_EOL.
  27123. 'See https://getcomposer.org/allow-plugins'
  27124. );
  27125. }
  27126. }
  27127. <?php declare(strict_types=1);
  27128. namespace Composer\Plugin;
  27129. use Composer\EventDispatcher\Event;
  27130. use Composer\Package\PackageInterface;
  27131. class PostFileDownloadEvent extends Event
  27132. {
  27133. private $fileName;
  27134. private $checksum;
  27135. private $url;
  27136. private $context;
  27137. private $type;
  27138. public function __construct(string $name, ?string $fileName, ?string $checksum, string $url, string $type, $context = null)
  27139. {
  27140. if ($context === null && $type instanceof PackageInterface) {
  27141. $context = $type;
  27142. $type = 'package';
  27143. trigger_error('PostFileDownloadEvent::__construct should receive a $type=package and the package object in $context since Composer 2.1.', E_USER_DEPRECATED);
  27144. }
  27145. parent::__construct($name);
  27146. $this->fileName = $fileName;
  27147. $this->checksum = $checksum;
  27148. $this->url = $url;
  27149. $this->context = $context;
  27150. $this->type = $type;
  27151. }
  27152. public function getFileName(): ?string
  27153. {
  27154. return $this->fileName;
  27155. }
  27156. public function getChecksum(): ?string
  27157. {
  27158. return $this->checksum;
  27159. }
  27160. public function getUrl(): string
  27161. {
  27162. return $this->url;
  27163. }
  27164. public function getContext()
  27165. {
  27166. return $this->context;
  27167. }
  27168. public function getPackage(): ?PackageInterface
  27169. {
  27170. trigger_error('PostFileDownloadEvent::getPackage is deprecated since Composer 2.1, use getContext instead.', E_USER_DEPRECATED);
  27171. $context = $this->getContext();
  27172. return $context instanceof PackageInterface ? $context : null;
  27173. }
  27174. public function getType(): string
  27175. {
  27176. return $this->type;
  27177. }
  27178. }
  27179. <?php declare(strict_types=1);
  27180. namespace Composer\Plugin;
  27181. use Composer\EventDispatcher\Event;
  27182. use Symfony\Component\Console\Input\InputInterface;
  27183. class PreCommandRunEvent extends Event
  27184. {
  27185. private $input;
  27186. private $command;
  27187. public function __construct(string $name, InputInterface $input, string $command)
  27188. {
  27189. parent::__construct($name);
  27190. $this->input = $input;
  27191. $this->command = $command;
  27192. }
  27193. public function getInput(): InputInterface
  27194. {
  27195. return $this->input;
  27196. }
  27197. public function getCommand(): string
  27198. {
  27199. return $this->command;
  27200. }
  27201. }
  27202. <?php declare(strict_types=1);
  27203. namespace Composer\Plugin;
  27204. use Composer\EventDispatcher\Event;
  27205. use Composer\Util\HttpDownloader;
  27206. class PreFileDownloadEvent extends Event
  27207. {
  27208. private $httpDownloader;
  27209. private $processedUrl;
  27210. private $customCacheKey;
  27211. private $type;
  27212. private $context;
  27213. private $transportOptions = [];
  27214. public function __construct(string $name, HttpDownloader $httpDownloader, string $processedUrl, string $type, $context = null)
  27215. {
  27216. parent::__construct($name);
  27217. $this->httpDownloader = $httpDownloader;
  27218. $this->processedUrl = $processedUrl;
  27219. $this->type = $type;
  27220. $this->context = $context;
  27221. }
  27222. public function getHttpDownloader(): HttpDownloader
  27223. {
  27224. return $this->httpDownloader;
  27225. }
  27226. public function getProcessedUrl(): string
  27227. {
  27228. return $this->processedUrl;
  27229. }
  27230. public function setProcessedUrl(string $processedUrl): void
  27231. {
  27232. $this->processedUrl = $processedUrl;
  27233. }
  27234. public function getCustomCacheKey(): ?string
  27235. {
  27236. return $this->customCacheKey;
  27237. }
  27238. public function setCustomCacheKey(?string $customCacheKey): void
  27239. {
  27240. $this->customCacheKey = $customCacheKey;
  27241. }
  27242. public function getType(): string
  27243. {
  27244. return $this->type;
  27245. }
  27246. public function getContext()
  27247. {
  27248. return $this->context;
  27249. }
  27250. public function getTransportOptions(): array
  27251. {
  27252. return $this->transportOptions;
  27253. }
  27254. public function setTransportOptions(array $options): void
  27255. {
  27256. $this->transportOptions = $options;
  27257. }
  27258. }
  27259. <?php declare(strict_types=1);
  27260. namespace Composer\Plugin;
  27261. use Composer\EventDispatcher\Event;
  27262. use Composer\Repository\RepositoryInterface;
  27263. use Composer\DependencyResolver\Request;
  27264. use Composer\Package\BasePackage;
  27265. class PrePoolCreateEvent extends Event
  27266. {
  27267. private $repositories;
  27268. private $request;
  27269. private $acceptableStabilities;
  27270. private $stabilityFlags;
  27271. private $rootAliases;
  27272. private $rootReferences;
  27273. private $packages;
  27274. private $unacceptableFixedPackages;
  27275. public function __construct(string $name, array $repositories, Request $request, array $acceptableStabilities, array $stabilityFlags, array $rootAliases, array $rootReferences, array $packages, array $unacceptableFixedPackages)
  27276. {
  27277. parent::__construct($name);
  27278. $this->repositories = $repositories;
  27279. $this->request = $request;
  27280. $this->acceptableStabilities = $acceptableStabilities;
  27281. $this->stabilityFlags = $stabilityFlags;
  27282. $this->rootAliases = $rootAliases;
  27283. $this->rootReferences = $rootReferences;
  27284. $this->packages = $packages;
  27285. $this->unacceptableFixedPackages = $unacceptableFixedPackages;
  27286. }
  27287. public function getRepositories(): array
  27288. {
  27289. return $this->repositories;
  27290. }
  27291. public function getRequest(): Request
  27292. {
  27293. return $this->request;
  27294. }
  27295. public function getAcceptableStabilities(): array
  27296. {
  27297. return $this->acceptableStabilities;
  27298. }
  27299. public function getStabilityFlags(): array
  27300. {
  27301. return $this->stabilityFlags;
  27302. }
  27303. public function getRootAliases(): array
  27304. {
  27305. return $this->rootAliases;
  27306. }
  27307. public function getRootReferences(): array
  27308. {
  27309. return $this->rootReferences;
  27310. }
  27311. public function getPackages(): array
  27312. {
  27313. return $this->packages;
  27314. }
  27315. public function getUnacceptableFixedPackages(): array
  27316. {
  27317. return $this->unacceptableFixedPackages;
  27318. }
  27319. public function setPackages(array $packages): void
  27320. {
  27321. $this->packages = $packages;
  27322. }
  27323. public function setUnacceptableFixedPackages(array $packages): void
  27324. {
  27325. $this->unacceptableFixedPackages = $packages;
  27326. }
  27327. }
  27328. <?php declare(strict_types=1);
  27329. namespace Composer\Question;
  27330. use Composer\Pcre\Preg;
  27331. use Symfony\Component\Console\Exception\InvalidArgumentException;
  27332. use Symfony\Component\Console\Question\Question;
  27333. class StrictConfirmationQuestion extends Question
  27334. {
  27335. private $trueAnswerRegex;
  27336. private $falseAnswerRegex;
  27337. public function __construct(string $question, bool $default = true, string $trueAnswerRegex = '/^y(?:es)?$/i', string $falseAnswerRegex = '/^no?$/i')
  27338. {
  27339. parent::__construct($question, (bool) $default);
  27340. $this->trueAnswerRegex = $trueAnswerRegex;
  27341. $this->falseAnswerRegex = $falseAnswerRegex;
  27342. $this->setNormalizer($this->getDefaultNormalizer());
  27343. $this->setValidator($this->getDefaultValidator());
  27344. }
  27345. private function getDefaultNormalizer(): callable
  27346. {
  27347. $default = $this->getDefault();
  27348. $trueRegex = $this->trueAnswerRegex;
  27349. $falseRegex = $this->falseAnswerRegex;
  27350. return static function ($answer) use ($default, $trueRegex, $falseRegex) {
  27351. if (is_bool($answer)) {
  27352. return $answer;
  27353. }
  27354. if (empty($answer) && !empty($default)) {
  27355. return $default;
  27356. }
  27357. if (Preg::isMatch($trueRegex, $answer)) {
  27358. return true;
  27359. }
  27360. if (Preg::isMatch($falseRegex, $answer)) {
  27361. return false;
  27362. }
  27363. return null;
  27364. };
  27365. }
  27366. private function getDefaultValidator(): callable
  27367. {
  27368. return static function ($answer): bool {
  27369. if (!is_bool($answer)) {
  27370. throw new InvalidArgumentException('Please answer yes, y, no, or n.');
  27371. }
  27372. return $answer;
  27373. };
  27374. }
  27375. }
  27376. <?php declare(strict_types=1);
  27377. namespace Composer\Repository;
  27378. use Composer\Semver\Constraint\ConstraintInterface;
  27379. use Composer\Advisory\PartialSecurityAdvisory;
  27380. use Composer\Advisory\SecurityAdvisory;
  27381. interface AdvisoryProviderInterface
  27382. {
  27383. public function hasSecurityAdvisories(): bool;
  27384. public function getSecurityAdvisories(array $packageConstraintMap, bool $allowPartialAdvisories = false): array;
  27385. }
  27386. <?php declare(strict_types=1);
  27387. namespace Composer\Repository;
  27388. use Composer\Package\AliasPackage;
  27389. use Composer\Package\BasePackage;
  27390. use Composer\Package\CompleteAliasPackage;
  27391. use Composer\Package\CompletePackage;
  27392. use Composer\Package\PackageInterface;
  27393. use Composer\Package\CompletePackageInterface;
  27394. use Composer\Package\Version\VersionParser;
  27395. use Composer\Package\Version\StabilityFilter;
  27396. use Composer\Pcre\Preg;
  27397. use Composer\Semver\Constraint\ConstraintInterface;
  27398. use Composer\Semver\Constraint\Constraint;
  27399. class ArrayRepository implements RepositoryInterface
  27400. {
  27401. protected $packages = null;
  27402. protected $packageMap = null;
  27403. public function __construct(array $packages = [])
  27404. {
  27405. foreach ($packages as $package) {
  27406. $this->addPackage($package);
  27407. }
  27408. }
  27409. public function getRepoName()
  27410. {
  27411. return 'array repo (defining '.$this->count().' package'.($this->count() > 1 ? 's' : '').')';
  27412. }
  27413. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = [])
  27414. {
  27415. $packages = $this->getPackages();
  27416. $result = [];
  27417. $namesFound = [];
  27418. foreach ($packages as $package) {
  27419. if (array_key_exists($package->getName(), $packageNameMap)) {
  27420. if (
  27421. (!$packageNameMap[$package->getName()] || $packageNameMap[$package->getName()]->matches(new Constraint('==', $package->getVersion())))
  27422. && StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, $package->getNames(), $package->getStability())
  27423. && !isset($alreadyLoaded[$package->getName()][$package->getVersion()])
  27424. ) {
  27425. $result[spl_object_hash($package)] = $package;
  27426. if ($package instanceof AliasPackage && !isset($result[spl_object_hash($package->getAliasOf())])) {
  27427. $result[spl_object_hash($package->getAliasOf())] = $package->getAliasOf();
  27428. }
  27429. }
  27430. $namesFound[$package->getName()] = true;
  27431. }
  27432. }
  27433. foreach ($packages as $package) {
  27434. if ($package instanceof AliasPackage) {
  27435. if (isset($result[spl_object_hash($package->getAliasOf())])) {
  27436. $result[spl_object_hash($package)] = $package;
  27437. }
  27438. }
  27439. }
  27440. return ['namesFound' => array_keys($namesFound), 'packages' => $result];
  27441. }
  27442. public function findPackage(string $name, $constraint)
  27443. {
  27444. $name = strtolower($name);
  27445. if (!$constraint instanceof ConstraintInterface) {
  27446. $versionParser = new VersionParser();
  27447. $constraint = $versionParser->parseConstraints($constraint);
  27448. }
  27449. foreach ($this->getPackages() as $package) {
  27450. if ($name === $package->getName()) {
  27451. $pkgConstraint = new Constraint('==', $package->getVersion());
  27452. if ($constraint->matches($pkgConstraint)) {
  27453. return $package;
  27454. }
  27455. }
  27456. }
  27457. return null;
  27458. }
  27459. public function findPackages(string $name, $constraint = null)
  27460. {
  27461. $name = strtolower($name);
  27462. $packages = [];
  27463. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  27464. $versionParser = new VersionParser();
  27465. $constraint = $versionParser->parseConstraints($constraint);
  27466. }
  27467. foreach ($this->getPackages() as $package) {
  27468. if ($name === $package->getName()) {
  27469. if (null === $constraint || $constraint->matches(new Constraint('==', $package->getVersion()))) {
  27470. $packages[] = $package;
  27471. }
  27472. }
  27473. }
  27474. return $packages;
  27475. }
  27476. public function search(string $query, int $mode = 0, ?string $type = null)
  27477. {
  27478. if ($mode === self::SEARCH_FULLTEXT) {
  27479. $regex = '{(?:'.implode('|', Preg::split('{\s+}', preg_quote($query))).')}i';
  27480. } else {
  27481. $regex = '{(?:'.implode('|', Preg::split('{\s+}', $query)).')}i';
  27482. }
  27483. $matches = [];
  27484. foreach ($this->getPackages() as $package) {
  27485. $name = $package->getName();
  27486. if ($mode === self::SEARCH_VENDOR) {
  27487. [$name] = explode('/', $name);
  27488. }
  27489. if (isset($matches[$name])) {
  27490. continue;
  27491. }
  27492. if (null !== $type && $package->getType() !== $type) {
  27493. continue;
  27494. }
  27495. if (Preg::isMatch($regex, $name)
  27496. || ($mode === self::SEARCH_FULLTEXT && $package instanceof CompletePackageInterface && Preg::isMatch($regex, implode(' ', (array) $package->getKeywords()) . ' ' . $package->getDescription()))
  27497. ) {
  27498. if ($mode === self::SEARCH_VENDOR) {
  27499. $matches[$name] = [
  27500. 'name' => $name,
  27501. 'description' => null,
  27502. ];
  27503. } else {
  27504. $matches[$name] = [
  27505. 'name' => $package->getPrettyName(),
  27506. 'description' => $package instanceof CompletePackageInterface ? $package->getDescription() : null,
  27507. ];
  27508. if ($package instanceof CompletePackageInterface && $package->isAbandoned()) {
  27509. $matches[$name]['abandoned'] = $package->getReplacementPackage() ?: true;
  27510. }
  27511. }
  27512. }
  27513. }
  27514. return array_values($matches);
  27515. }
  27516. public function hasPackage(PackageInterface $package)
  27517. {
  27518. if ($this->packageMap === null) {
  27519. $this->packageMap = [];
  27520. foreach ($this->getPackages() as $repoPackage) {
  27521. $this->packageMap[$repoPackage->getUniqueName()] = $repoPackage;
  27522. }
  27523. }
  27524. return isset($this->packageMap[$package->getUniqueName()]);
  27525. }
  27526. public function addPackage(PackageInterface $package)
  27527. {
  27528. if (!$package instanceof BasePackage) {
  27529. throw new \InvalidArgumentException('Only subclasses of BasePackage are supported');
  27530. }
  27531. if (null === $this->packages) {
  27532. $this->initialize();
  27533. }
  27534. $package->setRepository($this);
  27535. $this->packages[] = $package;
  27536. if ($package instanceof AliasPackage) {
  27537. $aliasedPackage = $package->getAliasOf();
  27538. if (null === $aliasedPackage->getRepository()) {
  27539. $this->addPackage($aliasedPackage);
  27540. }
  27541. }
  27542. $this->packageMap = null;
  27543. }
  27544. public function getProviders(string $packageName)
  27545. {
  27546. $result = [];
  27547. foreach ($this->getPackages() as $candidate) {
  27548. if (isset($result[$candidate->getName()])) {
  27549. continue;
  27550. }
  27551. foreach ($candidate->getProvides() as $link) {
  27552. if ($packageName === $link->getTarget()) {
  27553. $result[$candidate->getName()] = [
  27554. 'name' => $candidate->getName(),
  27555. 'description' => $candidate instanceof CompletePackageInterface ? $candidate->getDescription() : null,
  27556. 'type' => $candidate->getType(),
  27557. ];
  27558. continue 2;
  27559. }
  27560. }
  27561. }
  27562. return $result;
  27563. }
  27564. protected function createAliasPackage(BasePackage $package, string $alias, string $prettyAlias)
  27565. {
  27566. while ($package instanceof AliasPackage) {
  27567. $package = $package->getAliasOf();
  27568. }
  27569. if ($package instanceof CompletePackage) {
  27570. return new CompleteAliasPackage($package, $alias, $prettyAlias);
  27571. }
  27572. return new AliasPackage($package, $alias, $prettyAlias);
  27573. }
  27574. public function removePackage(PackageInterface $package)
  27575. {
  27576. $packageId = $package->getUniqueName();
  27577. foreach ($this->getPackages() as $key => $repoPackage) {
  27578. if ($packageId === $repoPackage->getUniqueName()) {
  27579. array_splice($this->packages, $key, 1);
  27580. $this->packageMap = null;
  27581. return;
  27582. }
  27583. }
  27584. }
  27585. public function getPackages()
  27586. {
  27587. if (null === $this->packages) {
  27588. $this->initialize();
  27589. }
  27590. if (null === $this->packages) {
  27591. throw new \LogicException('initialize failed to initialize the packages array');
  27592. }
  27593. return $this->packages;
  27594. }
  27595. public function count(): int
  27596. {
  27597. if (null === $this->packages) {
  27598. $this->initialize();
  27599. }
  27600. return count($this->packages);
  27601. }
  27602. protected function initialize()
  27603. {
  27604. $this->packages = [];
  27605. }
  27606. }
  27607. <?php declare(strict_types=1);
  27608. namespace Composer\Repository;
  27609. use Composer\IO\IOInterface;
  27610. use Composer\Json\JsonFile;
  27611. use Composer\Package\BasePackage;
  27612. use Composer\Package\Loader\ArrayLoader;
  27613. use Composer\Package\Loader\LoaderInterface;
  27614. use Composer\Util\Platform;
  27615. use Composer\Util\Tar;
  27616. use Composer\Util\Zip;
  27617. class ArtifactRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  27618. {
  27619. protected $loader;
  27620. protected $lookup;
  27621. protected $repoConfig;
  27622. private $io;
  27623. public function __construct(array $repoConfig, IOInterface $io)
  27624. {
  27625. parent::__construct();
  27626. if (!extension_loaded('zip')) {
  27627. throw new \RuntimeException('The artifact repository requires PHP\'s zip extension');
  27628. }
  27629. $this->loader = new ArrayLoader();
  27630. $this->lookup = Platform::expandPath($repoConfig['url']);
  27631. $this->io = $io;
  27632. $this->repoConfig = $repoConfig;
  27633. }
  27634. public function getRepoName()
  27635. {
  27636. return 'artifact repo ('.$this->lookup.')';
  27637. }
  27638. public function getRepoConfig()
  27639. {
  27640. return $this->repoConfig;
  27641. }
  27642. protected function initialize()
  27643. {
  27644. parent::initialize();
  27645. $this->scanDirectory($this->lookup);
  27646. }
  27647. private function scanDirectory(string $path): void
  27648. {
  27649. $io = $this->io;
  27650. $directory = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS);
  27651. $iterator = new \RecursiveIteratorIterator($directory);
  27652. $regex = new \RegexIterator($iterator, '/^.+\.(zip|tar|gz|tgz)$/i');
  27653. foreach ($regex as $file) {
  27654. if (!$file->isFile()) {
  27655. continue;
  27656. }
  27657. $package = $this->getComposerInformation($file);
  27658. if (!$package) {
  27659. $io->writeError("File <comment>{$file->getBasename()}</comment> doesn't seem to hold a package", true, IOInterface::VERBOSE);
  27660. continue;
  27661. }
  27662. $template = 'Found package <info>%s</info> (<comment>%s</comment>) in file <info>%s</info>';
  27663. $io->writeError(sprintf($template, $package->getName(), $package->getPrettyVersion(), $file->getBasename()), true, IOInterface::VERBOSE);
  27664. $this->addPackage($package);
  27665. }
  27666. }
  27667. private function getComposerInformation(\SplFileInfo $file): ?BasePackage
  27668. {
  27669. $json = null;
  27670. $fileType = null;
  27671. $fileExtension = pathinfo($file->getPathname(), PATHINFO_EXTENSION);
  27672. if (in_array($fileExtension, ['gz', 'tar', 'tgz'], true)) {
  27673. $fileType = 'tar';
  27674. } elseif ($fileExtension === 'zip') {
  27675. $fileType = 'zip';
  27676. } else {
  27677. throw new \RuntimeException('Files with "'.$fileExtension.'" extensions aren\'t supported. Only ZIP and TAR/TAR.GZ/TGZ archives are supported.');
  27678. }
  27679. try {
  27680. if ($fileType === 'tar') {
  27681. $json = Tar::getComposerJson($file->getPathname());
  27682. } else {
  27683. $json = Zip::getComposerJson($file->getPathname());
  27684. }
  27685. } catch (\Exception $exception) {
  27686. $this->io->write('Failed loading package '.$file->getPathname().': '.$exception->getMessage(), false, IOInterface::VERBOSE);
  27687. }
  27688. if (null === $json) {
  27689. return null;
  27690. }
  27691. $package = JsonFile::parseJson($json, $file->getPathname().'#composer.json');
  27692. $package['dist'] = [
  27693. 'type' => $fileType,
  27694. 'url' => strtr($file->getPathname(), '\\', '/'),
  27695. 'shasum' => sha1_file($file->getRealPath()),
  27696. ];
  27697. try {
  27698. $package = $this->loader->load($package);
  27699. } catch (\UnexpectedValueException $e) {
  27700. throw new \UnexpectedValueException('Failed loading package in '.$file.': '.$e->getMessage(), 0, $e);
  27701. }
  27702. return $package;
  27703. }
  27704. }
  27705. <?php declare(strict_types=1);
  27706. namespace Composer\Repository;
  27707. use Composer\Package\AliasPackage;
  27708. use Composer\Package\PackageInterface;
  27709. trait CanonicalPackagesTrait
  27710. {
  27711. public function getCanonicalPackages()
  27712. {
  27713. $packages = $this->getPackages();
  27714. $packagesByName = [];
  27715. foreach ($packages as $package) {
  27716. if (!isset($packagesByName[$package->getName()]) || $packagesByName[$package->getName()] instanceof AliasPackage) {
  27717. $packagesByName[$package->getName()] = $package;
  27718. }
  27719. }
  27720. $canonicalPackages = [];
  27721. foreach ($packagesByName as $package) {
  27722. while ($package instanceof AliasPackage) {
  27723. $package = $package->getAliasOf();
  27724. }
  27725. $canonicalPackages[] = $package;
  27726. }
  27727. return $canonicalPackages;
  27728. }
  27729. }
  27730. <?php declare(strict_types=1);
  27731. namespace Composer\Repository;
  27732. use Composer\Advisory\PartialSecurityAdvisory;
  27733. use Composer\Advisory\SecurityAdvisory;
  27734. use Composer\Package\BasePackage;
  27735. use Composer\Package\Loader\ArrayLoader;
  27736. use Composer\Package\PackageInterface;
  27737. use Composer\Package\AliasPackage;
  27738. use Composer\Package\CompletePackage;
  27739. use Composer\Package\CompleteAliasPackage;
  27740. use Composer\Package\Version\VersionParser;
  27741. use Composer\Package\Version\StabilityFilter;
  27742. use Composer\Json\JsonFile;
  27743. use Composer\Cache;
  27744. use Composer\Config;
  27745. use Composer\IO\IOInterface;
  27746. use Composer\Pcre\Preg;
  27747. use Composer\Plugin\PostFileDownloadEvent;
  27748. use Composer\Semver\CompilingMatcher;
  27749. use Composer\Util\HttpDownloader;
  27750. use Composer\Util\Loop;
  27751. use Composer\Plugin\PluginEvents;
  27752. use Composer\Plugin\PreFileDownloadEvent;
  27753. use Composer\EventDispatcher\EventDispatcher;
  27754. use Composer\Downloader\TransportException;
  27755. use Composer\Semver\Constraint\ConstraintInterface;
  27756. use Composer\Semver\Constraint\Constraint;
  27757. use Composer\Semver\Constraint\MatchAllConstraint;
  27758. use Composer\Util\Http\Response;
  27759. use Composer\MetadataMinifier\MetadataMinifier;
  27760. use Composer\Util\Url;
  27761. use React\Promise\PromiseInterface;
  27762. class ComposerRepository extends ArrayRepository implements ConfigurableRepositoryInterface, AdvisoryProviderInterface
  27763. {
  27764. private $repoConfig;
  27765. private $options;
  27766. private $url;
  27767. private $baseUrl;
  27768. private $io;
  27769. private $httpDownloader;
  27770. private $loop;
  27771. protected $cache;
  27772. protected $notifyUrl = null;
  27773. protected $searchUrl = null;
  27774. protected $providersApiUrl = null;
  27775. protected $hasProviders = false;
  27776. protected $providersUrl = null;
  27777. protected $listUrl = null;
  27778. protected $hasAvailablePackageList = false;
  27779. protected $availablePackages = null;
  27780. protected $availablePackagePatterns = null;
  27781. protected $lazyProvidersUrl = null;
  27782. protected $providerListing;
  27783. protected $loader;
  27784. private $allowSslDowngrade = false;
  27785. private $eventDispatcher;
  27786. private $sourceMirrors;
  27787. private $distMirrors;
  27788. private $degradedMode = false;
  27789. private $rootData;
  27790. private $hasPartialPackages = false;
  27791. private $partialPackagesByName = null;
  27792. private $displayedWarningAboutNonMatchingPackageIndex = false;
  27793. private $securityAdvisoryConfig = null;
  27794. private $freshMetadataUrls = [];
  27795. private $packagesNotFoundCache = [];
  27796. private $versionParser;
  27797. public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, ?EventDispatcher $eventDispatcher = null)
  27798. {
  27799. parent::__construct();
  27800. if (!Preg::isMatch('{^[\w.]+\??://}', $repoConfig['url'])) {
  27801. if (($localFilePath = realpath($repoConfig['url'])) !== false) {
  27802. $repoConfig['url'] = 'file://'.$localFilePath;
  27803. } else {
  27804. $repoConfig['url'] = 'http://'.$repoConfig['url'];
  27805. }
  27806. }
  27807. $repoConfig['url'] = rtrim($repoConfig['url'], '/');
  27808. if ($repoConfig['url'] === '') {
  27809. throw new \InvalidArgumentException('The repository url must not be an empty string');
  27810. }
  27811. if (str_starts_with($repoConfig['url'], 'https?')) {
  27812. $repoConfig['url'] = (extension_loaded('openssl') ? 'https' : 'http') . substr($repoConfig['url'], 6);
  27813. }
  27814. $urlBits = parse_url(strtr($repoConfig['url'], '\\', '/'));
  27815. if ($urlBits === false || empty($urlBits['scheme'])) {
  27816. throw new \UnexpectedValueException('Invalid url given for Composer repository: '.$repoConfig['url']);
  27817. }
  27818. if (!isset($repoConfig['options'])) {
  27819. $repoConfig['options'] = [];
  27820. }
  27821. if (isset($repoConfig['allow_ssl_downgrade']) && true === $repoConfig['allow_ssl_downgrade']) {
  27822. $this->allowSslDowngrade = true;
  27823. }
  27824. $this->options = $repoConfig['options'];
  27825. $this->url = $repoConfig['url'];
  27826. if (Preg::isMatch('{^(?P<proto>https?)://packagist\.org/?$}i', $this->url, $match)) {
  27827. $this->url = $match['proto'].'://repo.packagist.org';
  27828. }
  27829. $baseUrl = rtrim(Preg::replace('{(?:/[^/\\\\]+\.json)?(?:[?#].*)?$}', '', $this->url), '/');
  27830. assert($baseUrl !== '');
  27831. $this->baseUrl = $baseUrl;
  27832. $this->io = $io;
  27833. $this->cache = new Cache($io, $config->get('cache-repo-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', Url::sanitize($this->url)), 'a-z0-9.$~_');
  27834. $this->cache->setReadOnly($config->get('cache-read-only'));
  27835. $this->versionParser = new VersionParser();
  27836. $this->loader = new ArrayLoader($this->versionParser);
  27837. $this->httpDownloader = $httpDownloader;
  27838. $this->eventDispatcher = $eventDispatcher;
  27839. $this->repoConfig = $repoConfig;
  27840. $this->loop = new Loop($this->httpDownloader);
  27841. }
  27842. public function getRepoName()
  27843. {
  27844. return 'composer repo ('.Url::sanitize($this->url).')';
  27845. }
  27846. public function getRepoConfig()
  27847. {
  27848. return $this->repoConfig;
  27849. }
  27850. public function findPackage(string $name, $constraint)
  27851. {
  27852. $hasProviders = $this->hasProviders();
  27853. $name = strtolower($name);
  27854. if (!$constraint instanceof ConstraintInterface) {
  27855. $constraint = $this->versionParser->parseConstraints($constraint);
  27856. }
  27857. if ($this->lazyProvidersUrl) {
  27858. if ($this->hasPartialPackages() && isset($this->partialPackagesByName[$name])) {
  27859. return $this->filterPackages($this->whatProvides($name), $constraint, true);
  27860. }
  27861. if ($this->hasAvailablePackageList && !$this->lazyProvidersRepoContains($name)) {
  27862. return null;
  27863. }
  27864. $packages = $this->loadAsyncPackages([$name => $constraint]);
  27865. if (count($packages['packages']) > 0) {
  27866. return reset($packages['packages']);
  27867. }
  27868. return null;
  27869. }
  27870. if ($hasProviders) {
  27871. foreach ($this->getProviderNames() as $providerName) {
  27872. if ($name === $providerName) {
  27873. return $this->filterPackages($this->whatProvides($providerName), $constraint, true);
  27874. }
  27875. }
  27876. return null;
  27877. }
  27878. return parent::findPackage($name, $constraint);
  27879. }
  27880. public function findPackages(string $name, $constraint = null)
  27881. {
  27882. $hasProviders = $this->hasProviders();
  27883. $name = strtolower($name);
  27884. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  27885. $constraint = $this->versionParser->parseConstraints($constraint);
  27886. }
  27887. if ($this->lazyProvidersUrl) {
  27888. if ($this->hasPartialPackages() && isset($this->partialPackagesByName[$name])) {
  27889. return $this->filterPackages($this->whatProvides($name), $constraint);
  27890. }
  27891. if ($this->hasAvailablePackageList && !$this->lazyProvidersRepoContains($name)) {
  27892. return [];
  27893. }
  27894. $result = $this->loadAsyncPackages([$name => $constraint]);
  27895. return $result['packages'];
  27896. }
  27897. if ($hasProviders) {
  27898. foreach ($this->getProviderNames() as $providerName) {
  27899. if ($name === $providerName) {
  27900. return $this->filterPackages($this->whatProvides($providerName), $constraint);
  27901. }
  27902. }
  27903. return [];
  27904. }
  27905. return parent::findPackages($name, $constraint);
  27906. }
  27907. private function filterPackages(array $packages, ?ConstraintInterface $constraint = null, bool $returnFirstMatch = false)
  27908. {
  27909. if (null === $constraint) {
  27910. if ($returnFirstMatch) {
  27911. return reset($packages);
  27912. }
  27913. return $packages;
  27914. }
  27915. $filteredPackages = [];
  27916. foreach ($packages as $package) {
  27917. $pkgConstraint = new Constraint('==', $package->getVersion());
  27918. if ($constraint->matches($pkgConstraint)) {
  27919. if ($returnFirstMatch) {
  27920. return $package;
  27921. }
  27922. $filteredPackages[] = $package;
  27923. }
  27924. }
  27925. if ($returnFirstMatch) {
  27926. return null;
  27927. }
  27928. return $filteredPackages;
  27929. }
  27930. public function getPackages()
  27931. {
  27932. $hasProviders = $this->hasProviders();
  27933. if ($this->lazyProvidersUrl) {
  27934. if (is_array($this->availablePackages) && !$this->availablePackagePatterns) {
  27935. $packageMap = [];
  27936. foreach ($this->availablePackages as $name) {
  27937. $packageMap[$name] = new MatchAllConstraint();
  27938. }
  27939. $result = $this->loadAsyncPackages($packageMap);
  27940. return array_values($result['packages']);
  27941. }
  27942. if ($this->hasPartialPackages()) {
  27943. if (!is_array($this->partialPackagesByName)) {
  27944. throw new \LogicException('hasPartialPackages failed to initialize $this->partialPackagesByName');
  27945. }
  27946. return $this->createPackages($this->partialPackagesByName, 'packages.json inline packages');
  27947. }
  27948. 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.');
  27949. }
  27950. if ($hasProviders) {
  27951. throw new \LogicException('Composer repositories that have providers can not load the complete list of packages, use getPackageNames instead.');
  27952. }
  27953. return parent::getPackages();
  27954. }
  27955. public function getPackageNames(?string $packageFilter = null)
  27956. {
  27957. $hasProviders = $this->hasProviders();
  27958. $filterResults =
  27959. static function (array $results): array {
  27960. return $results;
  27961. }
  27962. ;
  27963. if (null !== $packageFilter && '' !== $packageFilter) {
  27964. $packageFilterRegex = BasePackage::packageNameToRegexp($packageFilter);
  27965. $filterResults =
  27966. static function (array $results) use ($packageFilterRegex): array {
  27967. return Preg::grep($packageFilterRegex, $results);
  27968. }
  27969. ;
  27970. }
  27971. if ($this->lazyProvidersUrl) {
  27972. if (is_array($this->availablePackages)) {
  27973. return $filterResults(array_keys($this->availablePackages));
  27974. }
  27975. if ($this->listUrl) {
  27976. return $this->loadPackageList($packageFilter);
  27977. }
  27978. if ($this->hasPartialPackages() && $this->partialPackagesByName !== null) {
  27979. return $filterResults(array_keys($this->partialPackagesByName));
  27980. }
  27981. return [];
  27982. }
  27983. if ($hasProviders) {
  27984. return $filterResults($this->getProviderNames());
  27985. }
  27986. $names = [];
  27987. foreach ($this->getPackages() as $package) {
  27988. $names[] = $package->getPrettyName();
  27989. }
  27990. return $filterResults($names);
  27991. }
  27992. private function getVendorNames(): array
  27993. {
  27994. $cacheKey = 'vendor-list.txt';
  27995. $cacheAge = $this->cache->getAge($cacheKey);
  27996. if (false !== $cacheAge && $cacheAge < 600 && ($cachedData = $this->cache->read($cacheKey)) !== false) {
  27997. $cachedData = explode("\n", $cachedData);
  27998. return $cachedData;
  27999. }
  28000. $names = $this->getPackageNames();
  28001. $uniques = [];
  28002. foreach ($names as $name) {
  28003. $uniques[substr($name, 0, strpos($name, '/'))] = true;
  28004. }
  28005. $vendors = array_keys($uniques);
  28006. if (!$this->cache->isReadOnly()) {
  28007. $this->cache->write($cacheKey, implode("\n", $vendors));
  28008. }
  28009. return $vendors;
  28010. }
  28011. private function loadPackageList(?string $packageFilter = null): array
  28012. {
  28013. if (null === $this->listUrl) {
  28014. throw new \LogicException('Make sure to call loadRootServerFile before loadPackageList');
  28015. }
  28016. $url = $this->listUrl;
  28017. if (is_string($packageFilter) && $packageFilter !== '') {
  28018. $url .= '?filter='.urlencode($packageFilter);
  28019. $result = $this->httpDownloader->get($url, $this->options)->decodeJson();
  28020. return $result['packageNames'];
  28021. }
  28022. $cacheKey = 'package-list.txt';
  28023. $cacheAge = $this->cache->getAge($cacheKey);
  28024. if (false !== $cacheAge && $cacheAge < 600 && ($cachedData = $this->cache->read($cacheKey)) !== false) {
  28025. $cachedData = explode("\n", $cachedData);
  28026. return $cachedData;
  28027. }
  28028. $result = $this->httpDownloader->get($url, $this->options)->decodeJson();
  28029. if (!$this->cache->isReadOnly()) {
  28030. $this->cache->write($cacheKey, implode("\n", $result['packageNames']));
  28031. }
  28032. return $result['packageNames'];
  28033. }
  28034. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = [])
  28035. {
  28036. $hasProviders = $this->hasProviders();
  28037. if (!$hasProviders && !$this->hasPartialPackages() && null === $this->lazyProvidersUrl) {
  28038. return parent::loadPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  28039. }
  28040. $packages = [];
  28041. $namesFound = [];
  28042. if ($hasProviders || $this->hasPartialPackages()) {
  28043. foreach ($packageNameMap as $name => $constraint) {
  28044. $matches = [];
  28045. if (!$hasProviders && !isset($this->partialPackagesByName[$name])) {
  28046. continue;
  28047. }
  28048. $candidates = $this->whatProvides($name, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  28049. foreach ($candidates as $candidate) {
  28050. if ($candidate->getName() !== $name) {
  28051. throw new \LogicException('whatProvides should never return a package with a different name than the requested one');
  28052. }
  28053. $namesFound[$name] = true;
  28054. if (!$constraint || $constraint->matches(new Constraint('==', $candidate->getVersion()))) {
  28055. $matches[spl_object_hash($candidate)] = $candidate;
  28056. if ($candidate instanceof AliasPackage && !isset($matches[spl_object_hash($candidate->getAliasOf())])) {
  28057. $matches[spl_object_hash($candidate->getAliasOf())] = $candidate->getAliasOf();
  28058. }
  28059. }
  28060. }
  28061. foreach ($candidates as $candidate) {
  28062. if ($candidate instanceof AliasPackage) {
  28063. if (isset($matches[spl_object_hash($candidate->getAliasOf())])) {
  28064. $matches[spl_object_hash($candidate)] = $candidate;
  28065. }
  28066. }
  28067. }
  28068. $packages = array_merge($packages, $matches);
  28069. unset($packageNameMap[$name]);
  28070. }
  28071. }
  28072. if ($this->lazyProvidersUrl && count($packageNameMap)) {
  28073. if ($this->hasAvailablePackageList) {
  28074. foreach ($packageNameMap as $name => $constraint) {
  28075. if (!$this->lazyProvidersRepoContains(strtolower($name))) {
  28076. unset($packageNameMap[$name]);
  28077. }
  28078. }
  28079. }
  28080. $result = $this->loadAsyncPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  28081. $packages = array_merge($packages, $result['packages']);
  28082. $namesFound = array_merge($namesFound, $result['namesFound']);
  28083. }
  28084. return ['namesFound' => array_keys($namesFound), 'packages' => $packages];
  28085. }
  28086. public function search(string $query, int $mode = 0, ?string $type = null)
  28087. {
  28088. $this->loadRootServerFile(600);
  28089. if ($this->searchUrl && $mode === self::SEARCH_FULLTEXT) {
  28090. $url = str_replace(['%query%', '%type%'], [urlencode($query), $type], $this->searchUrl);
  28091. $search = $this->httpDownloader->get($url, $this->options)->decodeJson();
  28092. if (empty($search['results'])) {
  28093. return [];
  28094. }
  28095. $results = [];
  28096. foreach ($search['results'] as $result) {
  28097. if (!empty($result['virtual'])) {
  28098. continue;
  28099. }
  28100. $results[] = $result;
  28101. }
  28102. return $results;
  28103. }
  28104. if ($mode === self::SEARCH_VENDOR) {
  28105. $results = [];
  28106. $regex = '{(?:'.implode('|', Preg::split('{\s+}', $query)).')}i';
  28107. $vendorNames = $this->getVendorNames();
  28108. foreach (Preg::grep($regex, $vendorNames) as $name) {
  28109. $results[] = ['name' => $name, 'description' => ''];
  28110. }
  28111. return $results;
  28112. }
  28113. if ($this->hasProviders() || $this->lazyProvidersUrl) {
  28114. if (Preg::isMatchStrictGroups('{^\^(?P<query>(?P<vendor>[a-z0-9_.-]+)/[a-z0-9_.-]*)\*?$}i', $query, $match) && $this->listUrl !== null) {
  28115. $url = $this->listUrl . '?vendor='.urlencode($match['vendor']).'&filter='.urlencode($match['query'].'*');
  28116. $result = $this->httpDownloader->get($url, $this->options)->decodeJson();
  28117. $results = [];
  28118. foreach ($result['packageNames'] as $name) {
  28119. $results[] = ['name' => $name, 'description' => ''];
  28120. }
  28121. return $results;
  28122. }
  28123. $results = [];
  28124. $regex = '{(?:'.implode('|', Preg::split('{\s+}', $query)).')}i';
  28125. $packageNames = $this->getPackageNames();
  28126. foreach (Preg::grep($regex, $packageNames) as $name) {
  28127. $results[] = ['name' => $name, 'description' => ''];
  28128. }
  28129. return $results;
  28130. }
  28131. return parent::search($query, $mode);
  28132. }
  28133. public function hasSecurityAdvisories(): bool
  28134. {
  28135. $this->loadRootServerFile(600);
  28136. return $this->securityAdvisoryConfig !== null && ($this->securityAdvisoryConfig['metadata'] || $this->securityAdvisoryConfig['api-url'] !== null);
  28137. }
  28138. public function getSecurityAdvisories(array $packageConstraintMap, bool $allowPartialAdvisories = false): array
  28139. {
  28140. $this->loadRootServerFile(600);
  28141. if (null === $this->securityAdvisoryConfig) {
  28142. return ['namesFound' => [], 'advisories' => []];
  28143. }
  28144. $advisories = [];
  28145. $namesFound = [];
  28146. $apiUrl = $this->securityAdvisoryConfig['api-url'];
  28147. $parser = new VersionParser();
  28148. $create = function (array $data, string $name) use ($parser, $allowPartialAdvisories, &$packageConstraintMap): ?PartialSecurityAdvisory {
  28149. $advisory = PartialSecurityAdvisory::create($name, $data, $parser);
  28150. if (!$allowPartialAdvisories && !$advisory instanceof SecurityAdvisory) {
  28151. throw new \RuntimeException('Advisory for '.$name.' could not be loaded as a full advisory from '.$this->getRepoName() . PHP_EOL . var_export($data, true));
  28152. }
  28153. if (!$advisory->affectedVersions->matches($packageConstraintMap[$name])) {
  28154. return null;
  28155. }
  28156. return $advisory;
  28157. };
  28158. if ($this->securityAdvisoryConfig['metadata'] && ($allowPartialAdvisories || $apiUrl === null)) {
  28159. $promises = [];
  28160. foreach ($packageConstraintMap as $name => $constraint) {
  28161. $name = strtolower($name);
  28162. if (PlatformRepository::isPlatformPackage($name) || '__root__' === $name) {
  28163. continue;
  28164. }
  28165. $promises[] = $this->startCachedAsyncDownload($name, $name)
  28166. ->then(static function (array $spec) use (&$advisories, &$namesFound, &$packageConstraintMap, $name, $create): void {
  28167. [$response, ] = $spec;
  28168. if (!isset($response['security-advisories']) || !is_array($response['security-advisories'])) {
  28169. return;
  28170. }
  28171. $namesFound[$name] = true;
  28172. if (count($response['security-advisories']) > 0) {
  28173. $advisories[$name] = array_filter(array_map(
  28174. static function ($data) use ($name, $create) {
  28175. return $create($data, $name);
  28176. },
  28177. $response['security-advisories']
  28178. ));
  28179. }
  28180. unset($packageConstraintMap[$name]);
  28181. });
  28182. }
  28183. $this->loop->wait($promises);
  28184. }
  28185. if ($apiUrl !== null && count($packageConstraintMap) > 0) {
  28186. $options = $this->options;
  28187. $options['http']['method'] = 'POST';
  28188. if (isset($options['http']['header'])) {
  28189. $options['http']['header'] = (array) $options['http']['header'];
  28190. }
  28191. $options['http']['header'][] = 'Content-type: application/x-www-form-urlencoded';
  28192. $options['http']['timeout'] = 10;
  28193. $options['http']['content'] = http_build_query(['packages' => array_keys($packageConstraintMap)]);
  28194. $response = $this->httpDownloader->get($apiUrl, $options);
  28195. foreach ($response->decodeJson()['advisories'] as $name => $list) {
  28196. if (count($list) > 0) {
  28197. $advisories[$name] = array_filter(array_map(
  28198. static function ($data) use ($name, $create) {
  28199. return $create($data, $name);
  28200. },
  28201. $list
  28202. ));
  28203. }
  28204. $namesFound[$name] = true;
  28205. }
  28206. }
  28207. return ['namesFound' => array_keys($namesFound), 'advisories' => array_filter($advisories)];
  28208. }
  28209. public function getProviders(string $packageName)
  28210. {
  28211. $this->loadRootServerFile();
  28212. $result = [];
  28213. if ($this->providersApiUrl) {
  28214. try {
  28215. $apiResult = $this->httpDownloader->get(str_replace('%package%', $packageName, $this->providersApiUrl), $this->options)->decodeJson();
  28216. } catch (TransportException $e) {
  28217. if ($e->getStatusCode() === 404) {
  28218. return $result;
  28219. }
  28220. throw $e;
  28221. }
  28222. foreach ($apiResult['providers'] as $provider) {
  28223. $result[$provider['name']] = $provider;
  28224. }
  28225. return $result;
  28226. }
  28227. if ($this->hasPartialPackages()) {
  28228. if (!is_array($this->partialPackagesByName)) {
  28229. throw new \LogicException('hasPartialPackages failed to initialize $this->partialPackagesByName');
  28230. }
  28231. foreach ($this->partialPackagesByName as $versions) {
  28232. foreach ($versions as $candidate) {
  28233. if (isset($result[$candidate['name']]) || !isset($candidate['provide'][$packageName])) {
  28234. continue;
  28235. }
  28236. $result[$candidate['name']] = [
  28237. 'name' => $candidate['name'],
  28238. 'description' => $candidate['description'] ?? '',
  28239. 'type' => $candidate['type'] ?? '',
  28240. ];
  28241. }
  28242. }
  28243. }
  28244. if ($this->packages) {
  28245. $result = array_merge($result, parent::getProviders($packageName));
  28246. }
  28247. return $result;
  28248. }
  28249. private function getProviderNames(): array
  28250. {
  28251. $this->loadRootServerFile();
  28252. if (null === $this->providerListing) {
  28253. $data = $this->loadRootServerFile();
  28254. if (is_array($data)) {
  28255. $this->loadProviderListings($data);
  28256. }
  28257. }
  28258. if ($this->lazyProvidersUrl) {
  28259. return [];
  28260. }
  28261. if (null !== $this->providersUrl && null !== $this->providerListing) {
  28262. return array_keys($this->providerListing);
  28263. }
  28264. return [];
  28265. }
  28266. protected function configurePackageTransportOptions(PackageInterface $package): void
  28267. {
  28268. foreach ($package->getDistUrls() as $url) {
  28269. if (strpos($url, $this->baseUrl) === 0) {
  28270. $package->setTransportOptions($this->options);
  28271. return;
  28272. }
  28273. }
  28274. }
  28275. private function hasProviders(): bool
  28276. {
  28277. $this->loadRootServerFile();
  28278. return $this->hasProviders;
  28279. }
  28280. private function whatProvides(string $name, ?array $acceptableStabilities = null, ?array $stabilityFlags = null, array $alreadyLoaded = []): array
  28281. {
  28282. $packagesSource = null;
  28283. if (!$this->hasPartialPackages() || !isset($this->partialPackagesByName[$name])) {
  28284. if (PlatformRepository::isPlatformPackage($name) || '__root__' === $name) {
  28285. return [];
  28286. }
  28287. if (null === $this->providerListing) {
  28288. $data = $this->loadRootServerFile();
  28289. if (is_array($data)) {
  28290. $this->loadProviderListings($data);
  28291. }
  28292. }
  28293. $useLastModifiedCheck = false;
  28294. if ($this->lazyProvidersUrl && !isset($this->providerListing[$name])) {
  28295. $hash = null;
  28296. $url = str_replace('%package%', $name, $this->lazyProvidersUrl);
  28297. $cacheKey = 'provider-'.strtr($name, '/', '$').'.json';
  28298. $useLastModifiedCheck = true;
  28299. } elseif ($this->providersUrl) {
  28300. if (!isset($this->providerListing[$name])) {
  28301. return [];
  28302. }
  28303. $hash = $this->providerListing[$name]['sha256'];
  28304. $url = str_replace(['%package%', '%hash%'], [$name, $hash], $this->providersUrl);
  28305. $cacheKey = 'provider-'.strtr($name, '/', '$').'.json';
  28306. } else {
  28307. return [];
  28308. }
  28309. $packages = null;
  28310. if (!$useLastModifiedCheck && $hash && $this->cache->sha256($cacheKey) === $hash) {
  28311. $packages = json_decode($this->cache->read($cacheKey), true);
  28312. $packagesSource = 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')';
  28313. } elseif ($useLastModifiedCheck) {
  28314. if ($contents = $this->cache->read($cacheKey)) {
  28315. $contents = json_decode($contents, true);
  28316. if (isset($alreadyLoaded[$name])) {
  28317. $packages = $contents;
  28318. $packagesSource = 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')';
  28319. } elseif (isset($contents['last-modified'])) {
  28320. $response = $this->fetchFileIfLastModified($url, $cacheKey, $contents['last-modified']);
  28321. $packages = true === $response ? $contents : $response;
  28322. $packagesSource = true === $response ? 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')' : 'downloaded file ('.Url::sanitize($url).')';
  28323. }
  28324. }
  28325. }
  28326. if (!$packages) {
  28327. try {
  28328. $packages = $this->fetchFile($url, $cacheKey, $hash, $useLastModifiedCheck);
  28329. $packagesSource = 'downloaded file ('.Url::sanitize($url).')';
  28330. } catch (TransportException $e) {
  28331. if ($this->lazyProvidersUrl && in_array($e->getStatusCode(), [404, 499], true)) {
  28332. $packages = ['packages' => []];
  28333. $packagesSource = 'not-found file ('.Url::sanitize($url).')';
  28334. if ($e->getStatusCode() === 499) {
  28335. $this->io->error('<warning>' . $e->getMessage() . '</warning>');
  28336. }
  28337. } else {
  28338. throw $e;
  28339. }
  28340. }
  28341. }
  28342. $loadingPartialPackage = false;
  28343. } else {
  28344. $packages = ['packages' => ['versions' => $this->partialPackagesByName[$name]]];
  28345. $packagesSource = 'root file ('.Url::sanitize($this->getPackagesJsonUrl()).')';
  28346. $loadingPartialPackage = true;
  28347. }
  28348. $result = [];
  28349. $versionsToLoad = [];
  28350. foreach ($packages['packages'] as $versions) {
  28351. foreach ($versions as $version) {
  28352. $normalizedName = strtolower($version['name']);
  28353. if ($normalizedName !== $name) {
  28354. continue;
  28355. }
  28356. if (!$loadingPartialPackage && $this->hasPartialPackages() && isset($this->partialPackagesByName[$normalizedName])) {
  28357. continue;
  28358. }
  28359. if (!isset($versionsToLoad[$version['uid']])) {
  28360. if (!isset($version['version_normalized'])) {
  28361. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  28362. } elseif ($version['version_normalized'] === VersionParser::DEFAULT_BRANCH_ALIAS) {
  28363. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  28364. }
  28365. if (isset($alreadyLoaded[$name][$version['version_normalized']])) {
  28366. continue;
  28367. }
  28368. if ($this->isVersionAcceptable(null, $normalizedName, $version, $acceptableStabilities, $stabilityFlags)) {
  28369. $versionsToLoad[$version['uid']] = $version;
  28370. }
  28371. }
  28372. }
  28373. }
  28374. $loadedPackages = $this->createPackages($versionsToLoad, $packagesSource);
  28375. $uids = array_keys($versionsToLoad);
  28376. foreach ($loadedPackages as $index => $package) {
  28377. $package->setRepository($this);
  28378. $uid = $uids[$index];
  28379. if ($package instanceof AliasPackage) {
  28380. $aliased = $package->getAliasOf();
  28381. $aliased->setRepository($this);
  28382. $result[$uid] = $aliased;
  28383. $result[$uid.'-alias'] = $package;
  28384. } else {
  28385. $result[$uid] = $package;
  28386. }
  28387. }
  28388. return $result;
  28389. }
  28390. protected function initialize()
  28391. {
  28392. parent::initialize();
  28393. $repoData = $this->loadDataFromServer();
  28394. foreach ($this->createPackages($repoData, 'root file ('.Url::sanitize($this->getPackagesJsonUrl()).')') as $package) {
  28395. $this->addPackage($package);
  28396. }
  28397. }
  28398. public function addPackage(PackageInterface $package)
  28399. {
  28400. parent::addPackage($package);
  28401. $this->configurePackageTransportOptions($package);
  28402. }
  28403. private function loadAsyncPackages(array $packageNames, ?array $acceptableStabilities = null, ?array $stabilityFlags = null, array $alreadyLoaded = []): array
  28404. {
  28405. $this->loadRootServerFile();
  28406. $packages = [];
  28407. $namesFound = [];
  28408. $promises = [];
  28409. if (null === $this->lazyProvidersUrl) {
  28410. throw new \LogicException('loadAsyncPackages only supports v2 protocol composer repos with a metadata-url');
  28411. }
  28412. foreach ($packageNames as $name => $constraint) {
  28413. if ($acceptableStabilities === null || $stabilityFlags === null || StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, [$name], 'dev')) {
  28414. $packageNames[$name.'~dev'] = $constraint;
  28415. }
  28416. if (isset($acceptableStabilities['dev']) && count($acceptableStabilities) === 1 && count($stabilityFlags) === 0) {
  28417. unset($packageNames[$name]);
  28418. }
  28419. }
  28420. foreach ($packageNames as $name => $constraint) {
  28421. $name = strtolower($name);
  28422. $realName = Preg::replace('{~dev$}', '', $name);
  28423. if (PlatformRepository::isPlatformPackage($realName) || '__root__' === $realName) {
  28424. continue;
  28425. }
  28426. $promises[] = $this->startCachedAsyncDownload($name, $realName)
  28427. ->then(function (array $spec) use (&$packages, &$namesFound, $realName, $constraint, $acceptableStabilities, $stabilityFlags, $alreadyLoaded): void {
  28428. [$response, $packagesSource] = $spec;
  28429. if (null === $response || !isset($response['packages'][$realName])) {
  28430. return;
  28431. }
  28432. $versions = $response['packages'][$realName];
  28433. if (isset($response['minified']) && $response['minified'] === 'composer/2.0') {
  28434. $versions = MetadataMinifier::expand($versions);
  28435. }
  28436. $namesFound[$realName] = true;
  28437. $versionsToLoad = [];
  28438. foreach ($versions as $version) {
  28439. if (!isset($version['version_normalized'])) {
  28440. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  28441. } elseif ($version['version_normalized'] === VersionParser::DEFAULT_BRANCH_ALIAS) {
  28442. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  28443. }
  28444. if (isset($alreadyLoaded[$realName][$version['version_normalized']])) {
  28445. continue;
  28446. }
  28447. if ($this->isVersionAcceptable($constraint, $realName, $version, $acceptableStabilities, $stabilityFlags)) {
  28448. $versionsToLoad[] = $version;
  28449. }
  28450. }
  28451. $loadedPackages = $this->createPackages($versionsToLoad, $packagesSource);
  28452. foreach ($loadedPackages as $package) {
  28453. $package->setRepository($this);
  28454. $packages[spl_object_hash($package)] = $package;
  28455. if ($package instanceof AliasPackage && !isset($packages[spl_object_hash($package->getAliasOf())])) {
  28456. $package->getAliasOf()->setRepository($this);
  28457. $packages[spl_object_hash($package->getAliasOf())] = $package->getAliasOf();
  28458. }
  28459. }
  28460. });
  28461. }
  28462. $this->loop->wait($promises);
  28463. return ['namesFound' => $namesFound, 'packages' => $packages];
  28464. }
  28465. private function startCachedAsyncDownload(string $fileName, ?string $packageName = null): PromiseInterface
  28466. {
  28467. if (null === $this->lazyProvidersUrl) {
  28468. throw new \LogicException('startCachedAsyncDownload only supports v2 protocol composer repos with a metadata-url');
  28469. }
  28470. $name = strtolower($fileName);
  28471. $packageName = $packageName ?? $name;
  28472. $url = str_replace('%package%', $name, $this->lazyProvidersUrl);
  28473. $cacheKey = 'provider-'.strtr($name, '/', '~').'.json';
  28474. $lastModified = null;
  28475. if ($contents = $this->cache->read($cacheKey)) {
  28476. $contents = json_decode($contents, true);
  28477. $lastModified = $contents['last-modified'] ?? null;
  28478. }
  28479. return $this->asyncFetchFile($url, $cacheKey, $lastModified)
  28480. ->then(static function ($response) use ($url, $cacheKey, $contents, $packageName): array {
  28481. $packagesSource = 'downloaded file ('.Url::sanitize($url).')';
  28482. if (true === $response) {
  28483. $packagesSource = 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')';
  28484. $response = $contents;
  28485. }
  28486. if (!isset($response['packages'][$packageName]) && !isset($response['security-advisories'])) {
  28487. return [null, $packagesSource];
  28488. }
  28489. return [$response, $packagesSource];
  28490. });
  28491. }
  28492. private function isVersionAcceptable(?ConstraintInterface $constraint, string $name, array $versionData, ?array $acceptableStabilities = null, ?array $stabilityFlags = null): bool
  28493. {
  28494. $versions = [$versionData['version_normalized']];
  28495. if ($alias = $this->loader->getBranchAlias($versionData)) {
  28496. $versions[] = $alias;
  28497. }
  28498. foreach ($versions as $version) {
  28499. if (null !== $acceptableStabilities && null !== $stabilityFlags && !StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, [$name], VersionParser::parseStability($version))) {
  28500. continue;
  28501. }
  28502. if ($constraint && !CompilingMatcher::match($constraint, Constraint::OP_EQ, $version)) {
  28503. continue;
  28504. }
  28505. return true;
  28506. }
  28507. return false;
  28508. }
  28509. private function getPackagesJsonUrl(): string
  28510. {
  28511. $jsonUrlParts = parse_url(strtr($this->url, '\\', '/'));
  28512. if (isset($jsonUrlParts['path']) && false !== strpos($jsonUrlParts['path'], '.json')) {
  28513. return $this->url;
  28514. }
  28515. return $this->url . '/packages.json';
  28516. }
  28517. protected function loadRootServerFile(?int $rootMaxAge = null)
  28518. {
  28519. if (null !== $this->rootData) {
  28520. return $this->rootData;
  28521. }
  28522. if (!extension_loaded('openssl') && strpos($this->url, 'https') === 0) {
  28523. throw new \RuntimeException('You must enable the openssl extension in your php.ini to load information from '.$this->url);
  28524. }
  28525. if ($cachedData = $this->cache->read('packages.json')) {
  28526. $cachedData = json_decode($cachedData, true);
  28527. if ($rootMaxAge !== null && ($age = $this->cache->getAge('packages.json')) !== false && $age <= $rootMaxAge) {
  28528. $data = $cachedData;
  28529. } elseif (isset($cachedData['last-modified'])) {
  28530. $response = $this->fetchFileIfLastModified($this->getPackagesJsonUrl(), 'packages.json', $cachedData['last-modified']);
  28531. $data = true === $response ? $cachedData : $response;
  28532. }
  28533. }
  28534. if (!isset($data)) {
  28535. $data = $this->fetchFile($this->getPackagesJsonUrl(), 'packages.json', null, true);
  28536. }
  28537. if (!empty($data['notify-batch'])) {
  28538. $this->notifyUrl = $this->canonicalizeUrl($data['notify-batch']);
  28539. } elseif (!empty($data['notify'])) {
  28540. $this->notifyUrl = $this->canonicalizeUrl($data['notify']);
  28541. }
  28542. if (!empty($data['search'])) {
  28543. $this->searchUrl = $this->canonicalizeUrl($data['search']);
  28544. }
  28545. if (!empty($data['mirrors'])) {
  28546. foreach ($data['mirrors'] as $mirror) {
  28547. if (!empty($mirror['git-url'])) {
  28548. $this->sourceMirrors['git'][] = ['url' => $mirror['git-url'], 'preferred' => !empty($mirror['preferred'])];
  28549. }
  28550. if (!empty($mirror['hg-url'])) {
  28551. $this->sourceMirrors['hg'][] = ['url' => $mirror['hg-url'], 'preferred' => !empty($mirror['preferred'])];
  28552. }
  28553. if (!empty($mirror['dist-url'])) {
  28554. $this->distMirrors[] = [
  28555. 'url' => $this->canonicalizeUrl($mirror['dist-url']),
  28556. 'preferred' => !empty($mirror['preferred']),
  28557. ];
  28558. }
  28559. }
  28560. }
  28561. if (!empty($data['providers-lazy-url'])) {
  28562. $this->lazyProvidersUrl = $this->canonicalizeUrl($data['providers-lazy-url']);
  28563. $this->hasProviders = true;
  28564. $this->hasPartialPackages = !empty($data['packages']) && is_array($data['packages']);
  28565. }
  28566. if (!empty($data['metadata-url'])) {
  28567. $this->lazyProvidersUrl = $this->canonicalizeUrl($data['metadata-url']);
  28568. $this->providersUrl = null;
  28569. $this->hasProviders = false;
  28570. $this->hasPartialPackages = !empty($data['packages']) && is_array($data['packages']);
  28571. $this->allowSslDowngrade = false;
  28572. if (!empty($data['available-packages'])) {
  28573. $availPackages = array_map('strtolower', $data['available-packages']);
  28574. $this->availablePackages = array_combine($availPackages, $availPackages);
  28575. $this->hasAvailablePackageList = true;
  28576. }
  28577. if (!empty($data['available-package-patterns'])) {
  28578. $this->availablePackagePatterns = array_map(static function ($pattern): string {
  28579. return BasePackage::packageNameToRegexp($pattern);
  28580. }, $data['available-package-patterns']);
  28581. $this->hasAvailablePackageList = true;
  28582. }
  28583. unset($data['providers-url'], $data['providers'], $data['providers-includes']);
  28584. if (isset($data['security-advisories']) && is_array($data['security-advisories'])) {
  28585. $this->securityAdvisoryConfig = [
  28586. 'metadata' => $data['security-advisories']['metadata'] ?? false,
  28587. 'api-url' => $data['security-advisories']['api-url'] ?? null,
  28588. 'query-all' => $data['security-advisories']['query-all'] ?? false,
  28589. ];
  28590. }
  28591. }
  28592. if ($this->allowSslDowngrade) {
  28593. $this->url = str_replace('https://', 'http://', $this->url);
  28594. $this->baseUrl = str_replace('https://', 'http://', $this->baseUrl);
  28595. }
  28596. if (!empty($data['providers-url'])) {
  28597. $this->providersUrl = $this->canonicalizeUrl($data['providers-url']);
  28598. $this->hasProviders = true;
  28599. }
  28600. if (!empty($data['list'])) {
  28601. $this->listUrl = $this->canonicalizeUrl($data['list']);
  28602. }
  28603. if (!empty($data['providers']) || !empty($data['providers-includes'])) {
  28604. $this->hasProviders = true;
  28605. }
  28606. if (!empty($data['providers-api'])) {
  28607. $this->providersApiUrl = $this->canonicalizeUrl($data['providers-api']);
  28608. }
  28609. return $this->rootData = $data;
  28610. }
  28611. private function canonicalizeUrl(string $url): string
  28612. {
  28613. if ('/' === $url[0]) {
  28614. if (Preg::isMatch('{^[^:]++://[^/]*+}', $this->url, $matches)) {
  28615. return $matches[0] . $url;
  28616. }
  28617. return $this->url;
  28618. }
  28619. return $url;
  28620. }
  28621. private function loadDataFromServer(): array
  28622. {
  28623. $data = $this->loadRootServerFile();
  28624. if (true === $data) {
  28625. throw new \LogicException('loadRootServerFile should not return true during initialization');
  28626. }
  28627. return $this->loadIncludes($data);
  28628. }
  28629. private function hasPartialPackages(): bool
  28630. {
  28631. if ($this->hasPartialPackages && null === $this->partialPackagesByName) {
  28632. $this->initializePartialPackages();
  28633. }
  28634. return $this->hasPartialPackages;
  28635. }
  28636. private function loadProviderListings($data): void
  28637. {
  28638. if (isset($data['providers'])) {
  28639. if (!is_array($this->providerListing)) {
  28640. $this->providerListing = [];
  28641. }
  28642. $this->providerListing = array_merge($this->providerListing, $data['providers']);
  28643. }
  28644. if ($this->providersUrl && isset($data['provider-includes'])) {
  28645. $includes = $data['provider-includes'];
  28646. foreach ($includes as $include => $metadata) {
  28647. $url = $this->baseUrl . '/' . str_replace('%hash%', $metadata['sha256'], $include);
  28648. $cacheKey = str_replace(['%hash%','$'], '', $include);
  28649. if ($this->cache->sha256($cacheKey) === $metadata['sha256']) {
  28650. $includedData = json_decode($this->cache->read($cacheKey), true);
  28651. } else {
  28652. $includedData = $this->fetchFile($url, $cacheKey, $metadata['sha256']);
  28653. }
  28654. $this->loadProviderListings($includedData);
  28655. }
  28656. }
  28657. }
  28658. private function loadIncludes(array $data): array
  28659. {
  28660. $packages = [];
  28661. if (!isset($data['packages']) && !isset($data['includes'])) {
  28662. foreach ($data as $pkg) {
  28663. if (isset($pkg['versions']) && is_array($pkg['versions'])) {
  28664. foreach ($pkg['versions'] as $metadata) {
  28665. $packages[] = $metadata;
  28666. }
  28667. }
  28668. }
  28669. return $packages;
  28670. }
  28671. if (isset($data['packages'])) {
  28672. foreach ($data['packages'] as $package => $versions) {
  28673. $packageName = strtolower((string) $package);
  28674. foreach ($versions as $version => $metadata) {
  28675. $packages[] = $metadata;
  28676. if (!$this->displayedWarningAboutNonMatchingPackageIndex && $packageName !== strtolower((string) ($metadata['name'] ?? ''))) {
  28677. $this->displayedWarningAboutNonMatchingPackageIndex = true;
  28678. $this->io->writeError(sprintf("<warning>Warning: the packages key '%s' doesn't match the name defined in the package metadata '%s' in repository %s</warning>", $package, $metadata['name'] ?? '', $this->baseUrl));
  28679. }
  28680. }
  28681. }
  28682. }
  28683. if (isset($data['includes'])) {
  28684. foreach ($data['includes'] as $include => $metadata) {
  28685. if (isset($metadata['sha1']) && $this->cache->sha1((string) $include) === $metadata['sha1']) {
  28686. $includedData = json_decode($this->cache->read((string) $include), true);
  28687. } else {
  28688. $includedData = $this->fetchFile($include);
  28689. }
  28690. $packages = array_merge($packages, $this->loadIncludes($includedData));
  28691. }
  28692. }
  28693. return $packages;
  28694. }
  28695. private function createPackages(array $packages, ?string $source = null): array
  28696. {
  28697. if (!$packages) {
  28698. return [];
  28699. }
  28700. try {
  28701. foreach ($packages as &$data) {
  28702. if (!isset($data['notification-url'])) {
  28703. $data['notification-url'] = $this->notifyUrl;
  28704. }
  28705. }
  28706. $packageInstances = $this->loader->loadPackages($packages);
  28707. foreach ($packageInstances as $package) {
  28708. if (isset($this->sourceMirrors[$package->getSourceType()])) {
  28709. $package->setSourceMirrors($this->sourceMirrors[$package->getSourceType()]);
  28710. }
  28711. $package->setDistMirrors($this->distMirrors);
  28712. $this->configurePackageTransportOptions($package);
  28713. }
  28714. return $packageInstances;
  28715. } catch (\Exception $e) {
  28716. 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);
  28717. }
  28718. }
  28719. protected function fetchFile(string $filename, ?string $cacheKey = null, ?string $sha256 = null, bool $storeLastModifiedTime = false)
  28720. {
  28721. if ('' === $filename) {
  28722. throw new \InvalidArgumentException('$filename should not be an empty string');
  28723. }
  28724. if (null === $cacheKey) {
  28725. $cacheKey = $filename;
  28726. $filename = $this->baseUrl.'/'.$filename;
  28727. }
  28728. if (($pos = strpos($filename, '$')) && Preg::isMatch('{^https?://}i', $filename)) {
  28729. $filename = substr($filename, 0, $pos) . '%24' . substr($filename, $pos + 1);
  28730. }
  28731. $retries = 3;
  28732. while ($retries--) {
  28733. try {
  28734. $options = $this->options;
  28735. if ($this->eventDispatcher) {
  28736. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata', ['repository' => $this]);
  28737. $preFileDownloadEvent->setTransportOptions($this->options);
  28738. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  28739. $filename = $preFileDownloadEvent->getProcessedUrl();
  28740. $options = $preFileDownloadEvent->getTransportOptions();
  28741. }
  28742. $response = $this->httpDownloader->get($filename, $options);
  28743. $json = (string) $response->getBody();
  28744. if ($sha256 && $sha256 !== hash('sha256', $json)) {
  28745. if ($this->allowSslDowngrade) {
  28746. $this->url = str_replace('http://', 'https://', $this->url);
  28747. $this->baseUrl = str_replace('http://', 'https://', $this->baseUrl);
  28748. $filename = str_replace('http://', 'https://', $filename);
  28749. }
  28750. if ($retries > 0) {
  28751. usleep(100000);
  28752. continue;
  28753. }
  28754. 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.');
  28755. }
  28756. if ($this->eventDispatcher) {
  28757. $postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, null, $sha256, $filename, 'metadata', ['response' => $response, 'repository' => $this]);
  28758. $this->eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
  28759. }
  28760. $data = $response->decodeJson();
  28761. HttpDownloader::outputWarnings($this->io, $this->url, $data);
  28762. if ($cacheKey && !$this->cache->isReadOnly()) {
  28763. if ($storeLastModifiedTime) {
  28764. $lastModifiedDate = $response->getHeader('last-modified');
  28765. if ($lastModifiedDate) {
  28766. $data['last-modified'] = $lastModifiedDate;
  28767. $json = JsonFile::encode($data, 0);
  28768. }
  28769. }
  28770. $this->cache->write($cacheKey, $json);
  28771. }
  28772. $response->collect();
  28773. break;
  28774. } catch (\Exception $e) {
  28775. if ($e instanceof \LogicException) {
  28776. throw $e;
  28777. }
  28778. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  28779. throw $e;
  28780. }
  28781. if ($e instanceof RepositorySecurityException) {
  28782. throw $e;
  28783. }
  28784. if ($cacheKey && ($contents = $this->cache->read($cacheKey))) {
  28785. if (!$this->degradedMode) {
  28786. $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>');
  28787. }
  28788. $this->degradedMode = true;
  28789. $data = JsonFile::parseJson($contents, $this->cache->getRoot().$cacheKey);
  28790. break;
  28791. }
  28792. throw $e;
  28793. }
  28794. }
  28795. if (!isset($data)) {
  28796. throw new \LogicException("ComposerRepository: Undefined \$data. Please report at https://github.com/composer/composer/issues/new.");
  28797. }
  28798. return $data;
  28799. }
  28800. private function fetchFileIfLastModified(string $filename, string $cacheKey, string $lastModifiedTime)
  28801. {
  28802. if ('' === $filename) {
  28803. throw new \InvalidArgumentException('$filename should not be an empty string');
  28804. }
  28805. try {
  28806. $options = $this->options;
  28807. if ($this->eventDispatcher) {
  28808. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata', ['repository' => $this]);
  28809. $preFileDownloadEvent->setTransportOptions($this->options);
  28810. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  28811. $filename = $preFileDownloadEvent->getProcessedUrl();
  28812. $options = $preFileDownloadEvent->getTransportOptions();
  28813. }
  28814. if (isset($options['http']['header'])) {
  28815. $options['http']['header'] = (array) $options['http']['header'];
  28816. }
  28817. $options['http']['header'][] = 'If-Modified-Since: '.$lastModifiedTime;
  28818. $response = $this->httpDownloader->get($filename, $options);
  28819. $json = (string) $response->getBody();
  28820. if ($json === '' && $response->getStatusCode() === 304) {
  28821. return true;
  28822. }
  28823. if ($this->eventDispatcher) {
  28824. $postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, null, null, $filename, 'metadata', ['response' => $response, 'repository' => $this]);
  28825. $this->eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
  28826. }
  28827. $data = $response->decodeJson();
  28828. HttpDownloader::outputWarnings($this->io, $this->url, $data);
  28829. $lastModifiedDate = $response->getHeader('last-modified');
  28830. $response->collect();
  28831. if ($lastModifiedDate) {
  28832. $data['last-modified'] = $lastModifiedDate;
  28833. $json = JsonFile::encode($data, 0);
  28834. }
  28835. if (!$this->cache->isReadOnly()) {
  28836. $this->cache->write($cacheKey, $json);
  28837. }
  28838. return $data;
  28839. } catch (\Exception $e) {
  28840. if ($e instanceof \LogicException) {
  28841. throw $e;
  28842. }
  28843. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  28844. throw $e;
  28845. }
  28846. if (!$this->degradedMode) {
  28847. $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>');
  28848. }
  28849. $this->degradedMode = true;
  28850. return true;
  28851. }
  28852. }
  28853. private function asyncFetchFile(string $filename, string $cacheKey, ?string $lastModifiedTime = null): PromiseInterface
  28854. {
  28855. if ('' === $filename) {
  28856. throw new \InvalidArgumentException('$filename should not be an empty string');
  28857. }
  28858. if (isset($this->packagesNotFoundCache[$filename])) {
  28859. return \React\Promise\resolve(['packages' => []]);
  28860. }
  28861. if (isset($this->freshMetadataUrls[$filename]) && $lastModifiedTime) {
  28862. $promise = \React\Promise\resolve(true);
  28863. return $promise;
  28864. }
  28865. $httpDownloader = $this->httpDownloader;
  28866. $options = $this->options;
  28867. if ($this->eventDispatcher) {
  28868. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata', ['repository' => $this]);
  28869. $preFileDownloadEvent->setTransportOptions($this->options);
  28870. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  28871. $filename = $preFileDownloadEvent->getProcessedUrl();
  28872. $options = $preFileDownloadEvent->getTransportOptions();
  28873. }
  28874. if ($lastModifiedTime) {
  28875. if (isset($options['http']['header'])) {
  28876. $options['http']['header'] = (array) $options['http']['header'];
  28877. }
  28878. $options['http']['header'][] = 'If-Modified-Since: '.$lastModifiedTime;
  28879. }
  28880. $io = $this->io;
  28881. $url = $this->url;
  28882. $cache = $this->cache;
  28883. $degradedMode = &$this->degradedMode;
  28884. $eventDispatcher = $this->eventDispatcher;
  28885. $accept = function ($response) use ($io, $url, $filename, $cache, $cacheKey, $eventDispatcher) {
  28886. if ($response->getStatusCode() === 404) {
  28887. $this->packagesNotFoundCache[$filename] = true;
  28888. return ['packages' => []];
  28889. }
  28890. $json = (string) $response->getBody();
  28891. if ($json === '' && $response->getStatusCode() === 304) {
  28892. $this->freshMetadataUrls[$filename] = true;
  28893. return true;
  28894. }
  28895. if ($eventDispatcher) {
  28896. $postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, null, null, $filename, 'metadata', ['response' => $response, 'repository' => $this]);
  28897. $eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
  28898. }
  28899. $data = $response->decodeJson();
  28900. HttpDownloader::outputWarnings($io, $url, $data);
  28901. $lastModifiedDate = $response->getHeader('last-modified');
  28902. $response->collect();
  28903. if ($lastModifiedDate) {
  28904. $data['last-modified'] = $lastModifiedDate;
  28905. $json = JsonFile::encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
  28906. }
  28907. if (!$cache->isReadOnly()) {
  28908. $cache->write($cacheKey, $json);
  28909. }
  28910. $this->freshMetadataUrls[$filename] = true;
  28911. return $data;
  28912. };
  28913. $reject = function ($e) use ($filename, $accept, $io, $url, &$degradedMode, $lastModifiedTime) {
  28914. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  28915. $this->packagesNotFoundCache[$filename] = true;
  28916. return false;
  28917. }
  28918. if (!$degradedMode) {
  28919. $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>');
  28920. }
  28921. $degradedMode = true;
  28922. if ($lastModifiedTime) {
  28923. return $accept(new Response(['url' => $url], 304, [], ''));
  28924. }
  28925. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  28926. return $accept(new Response(['url' => $url], 404, [], ''));
  28927. }
  28928. throw $e;
  28929. };
  28930. return $httpDownloader->add($filename, $options)->then($accept, $reject);
  28931. }
  28932. private function initializePartialPackages(): void
  28933. {
  28934. $rootData = $this->loadRootServerFile();
  28935. if ($rootData === true) {
  28936. return;
  28937. }
  28938. $this->partialPackagesByName = [];
  28939. foreach ($rootData['packages'] as $package => $versions) {
  28940. foreach ($versions as $version) {
  28941. $versionPackageName = strtolower((string) ($version['name'] ?? ''));
  28942. $this->partialPackagesByName[$versionPackageName][] = $version;
  28943. if (!$this->displayedWarningAboutNonMatchingPackageIndex && $versionPackageName !== strtolower($package)) {
  28944. $this->io->writeError(sprintf("<warning>Warning: the packages key '%s' doesn't match the name defined in the package metadata '%s' in repository %s</warning>", $package, $version['name'] ?? '', $this->baseUrl));
  28945. $this->displayedWarningAboutNonMatchingPackageIndex = true;
  28946. }
  28947. }
  28948. }
  28949. $this->rootData = true;
  28950. }
  28951. protected function lazyProvidersRepoContains(string $name)
  28952. {
  28953. if (!$this->hasAvailablePackageList) {
  28954. throw new \LogicException('lazyProvidersRepoContains should not be called unless hasAvailablePackageList is true');
  28955. }
  28956. if (is_array($this->availablePackages) && isset($this->availablePackages[$name])) {
  28957. return true;
  28958. }
  28959. if (is_array($this->availablePackagePatterns)) {
  28960. foreach ($this->availablePackagePatterns as $providerRegex) {
  28961. if (Preg::isMatch($providerRegex, $name)) {
  28962. return true;
  28963. }
  28964. }
  28965. }
  28966. return false;
  28967. }
  28968. }
  28969. <?php declare(strict_types=1);
  28970. namespace Composer\Repository;
  28971. use Composer\Package\BasePackage;
  28972. use Composer\Package\PackageInterface;
  28973. class CompositeRepository implements RepositoryInterface
  28974. {
  28975. private $repositories;
  28976. public function __construct(array $repositories)
  28977. {
  28978. $this->repositories = [];
  28979. foreach ($repositories as $repo) {
  28980. $this->addRepository($repo);
  28981. }
  28982. }
  28983. public function getRepoName(): string
  28984. {
  28985. return 'composite repo ('.implode(', ', array_map(static function ($repo): string {
  28986. return $repo->getRepoName();
  28987. }, $this->repositories)).')';
  28988. }
  28989. public function getRepositories(): array
  28990. {
  28991. return $this->repositories;
  28992. }
  28993. public function hasPackage(PackageInterface $package): bool
  28994. {
  28995. foreach ($this->repositories as $repository) {
  28996. if ($repository->hasPackage($package)) {
  28997. return true;
  28998. }
  28999. }
  29000. return false;
  29001. }
  29002. public function findPackage($name, $constraint): ?BasePackage
  29003. {
  29004. foreach ($this->repositories as $repository) {
  29005. $package = $repository->findPackage($name, $constraint);
  29006. if (null !== $package) {
  29007. return $package;
  29008. }
  29009. }
  29010. return null;
  29011. }
  29012. public function findPackages($name, $constraint = null): array
  29013. {
  29014. $packages = [];
  29015. foreach ($this->repositories as $repository) {
  29016. $packages[] = $repository->findPackages($name, $constraint);
  29017. }
  29018. return $packages ? array_merge(...$packages) : [];
  29019. }
  29020. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = []): array
  29021. {
  29022. $packages = [];
  29023. $namesFound = [];
  29024. foreach ($this->repositories as $repository) {
  29025. $result = $repository->loadPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  29026. $packages[] = $result['packages'];
  29027. $namesFound[] = $result['namesFound'];
  29028. }
  29029. return [
  29030. 'packages' => $packages ? array_merge(...$packages) : [],
  29031. 'namesFound' => $namesFound ? array_unique(array_merge(...$namesFound)) : [],
  29032. ];
  29033. }
  29034. public function search(string $query, int $mode = 0, ?string $type = null): array
  29035. {
  29036. $matches = [];
  29037. foreach ($this->repositories as $repository) {
  29038. $matches[] = $repository->search($query, $mode, $type);
  29039. }
  29040. return \count($matches) > 0 ? array_merge(...$matches) : [];
  29041. }
  29042. public function getPackages(): array
  29043. {
  29044. $packages = [];
  29045. foreach ($this->repositories as $repository) {
  29046. $packages[] = $repository->getPackages();
  29047. }
  29048. return $packages ? array_merge(...$packages) : [];
  29049. }
  29050. public function getProviders($packageName): array
  29051. {
  29052. $results = [];
  29053. foreach ($this->repositories as $repository) {
  29054. $results[] = $repository->getProviders($packageName);
  29055. }
  29056. return $results ? array_merge(...$results) : [];
  29057. }
  29058. public function removePackage(PackageInterface $package): void
  29059. {
  29060. foreach ($this->repositories as $repository) {
  29061. if ($repository instanceof WritableRepositoryInterface) {
  29062. $repository->removePackage($package);
  29063. }
  29064. }
  29065. }
  29066. public function count(): int
  29067. {
  29068. $total = 0;
  29069. foreach ($this->repositories as $repository) {
  29070. $total += $repository->count();
  29071. }
  29072. return $total;
  29073. }
  29074. public function addRepository(RepositoryInterface $repository): void
  29075. {
  29076. if ($repository instanceof self) {
  29077. foreach ($repository->getRepositories() as $repo) {
  29078. $this->addRepository($repo);
  29079. }
  29080. } else {
  29081. $this->repositories[] = $repository;
  29082. }
  29083. }
  29084. }
  29085. <?php declare(strict_types=1);
  29086. namespace Composer\Repository;
  29087. interface ConfigurableRepositoryInterface
  29088. {
  29089. public function getRepoConfig();
  29090. }
  29091. <?php declare(strict_types=1);
  29092. namespace Composer\Repository;
  29093. use Composer\Json\JsonFile;
  29094. use Composer\Package\Loader\ArrayLoader;
  29095. use Composer\Package\PackageInterface;
  29096. use Composer\Package\RootAliasPackage;
  29097. use Composer\Package\RootPackageInterface;
  29098. use Composer\Package\AliasPackage;
  29099. use Composer\Package\Dumper\ArrayDumper;
  29100. use Composer\Installer\InstallationManager;
  29101. use Composer\Util\Filesystem;
  29102. use Composer\Util\Platform;
  29103. class FilesystemRepository extends WritableArrayRepository
  29104. {
  29105. protected $file;
  29106. private $dumpVersions;
  29107. private $rootPackage;
  29108. private $filesystem;
  29109. private $devMode = null;
  29110. public function __construct(JsonFile $repositoryFile, bool $dumpVersions = false, ?RootPackageInterface $rootPackage = null, ?Filesystem $filesystem = null)
  29111. {
  29112. parent::__construct();
  29113. $this->file = $repositoryFile;
  29114. $this->dumpVersions = $dumpVersions;
  29115. $this->rootPackage = $rootPackage;
  29116. $this->filesystem = $filesystem ?: new Filesystem;
  29117. if ($dumpVersions && !$rootPackage) {
  29118. throw new \InvalidArgumentException('Expected a root package instance if $dumpVersions is true');
  29119. }
  29120. }
  29121. public function getDevMode()
  29122. {
  29123. return $this->devMode;
  29124. }
  29125. protected function initialize()
  29126. {
  29127. parent::initialize();
  29128. if (!$this->file->exists()) {
  29129. return;
  29130. }
  29131. try {
  29132. $data = $this->file->read();
  29133. if (isset($data['packages'])) {
  29134. $packages = $data['packages'];
  29135. } else {
  29136. $packages = $data;
  29137. }
  29138. if (isset($data['dev-package-names'])) {
  29139. $this->setDevPackageNames($data['dev-package-names']);
  29140. }
  29141. if (isset($data['dev'])) {
  29142. $this->devMode = $data['dev'];
  29143. }
  29144. if (!is_array($packages)) {
  29145. throw new \UnexpectedValueException('Could not parse package list from the repository');
  29146. }
  29147. } catch (\Exception $e) {
  29148. throw new InvalidRepositoryException('Invalid repository data in '.$this->file->getPath().', packages could not be loaded: ['.get_class($e).'] '.$e->getMessage());
  29149. }
  29150. $loader = new ArrayLoader(null, true);
  29151. foreach ($packages as $packageData) {
  29152. $package = $loader->load($packageData);
  29153. $this->addPackage($package);
  29154. }
  29155. }
  29156. public function reload()
  29157. {
  29158. $this->packages = null;
  29159. $this->initialize();
  29160. }
  29161. public function write(bool $devMode, InstallationManager $installationManager)
  29162. {
  29163. $data = ['packages' => [], 'dev' => $devMode, 'dev-package-names' => []];
  29164. $dumper = new ArrayDumper();
  29165. $repoDir = dirname($this->file->getPath());
  29166. $this->filesystem->ensureDirectoryExists($repoDir);
  29167. $repoDir = $this->filesystem->normalizePath(realpath($repoDir));
  29168. $installPaths = [];
  29169. foreach ($this->getCanonicalPackages() as $package) {
  29170. $pkgArray = $dumper->dump($package);
  29171. $path = $installationManager->getInstallPath($package);
  29172. $installPath = null;
  29173. if ('' !== $path && null !== $path) {
  29174. $normalizedPath = $this->filesystem->normalizePath($this->filesystem->isAbsolutePath($path) ? $path : Platform::getCwd() . '/' . $path);
  29175. $installPath = $this->filesystem->findShortestPath($repoDir, $normalizedPath, true);
  29176. }
  29177. $installPaths[$package->getName()] = $installPath;
  29178. $pkgArray['install-path'] = $installPath;
  29179. $data['packages'][] = $pkgArray;
  29180. if (in_array($package->getName(), $this->devPackageNames, true)) {
  29181. $data['dev-package-names'][] = $package->getName();
  29182. }
  29183. }
  29184. sort($data['dev-package-names']);
  29185. usort($data['packages'], static function ($a, $b): int {
  29186. return strcmp($a['name'], $b['name']);
  29187. });
  29188. $this->file->write($data);
  29189. if ($this->dumpVersions) {
  29190. $versions = $this->generateInstalledVersions($installationManager, $installPaths, $devMode, $repoDir);
  29191. $this->filesystem->filePutContentsIfModified($repoDir.'/installed.php', '<?php return ' . $this->dumpToPhpCode($versions) . ';'."\n");
  29192. $installedVersionsClass = file_get_contents(__DIR__.'/../InstalledVersions.php');
  29193. if ($installedVersionsClass !== false) {
  29194. $this->filesystem->filePutContentsIfModified($repoDir.'/InstalledVersions.php', $installedVersionsClass);
  29195. \Composer\InstalledVersions::reload($versions);
  29196. }
  29197. }
  29198. }
  29199. private function dumpToPhpCode(array $array = [], int $level = 0): string
  29200. {
  29201. $lines = "array(\n";
  29202. $level++;
  29203. foreach ($array as $key => $value) {
  29204. $lines .= str_repeat(' ', $level);
  29205. $lines .= is_int($key) ? $key . ' => ' : '\'' . $key . '\' => ';
  29206. if (is_array($value)) {
  29207. if (!empty($value)) {
  29208. $lines .= $this->dumpToPhpCode($value, $level);
  29209. } else {
  29210. $lines .= "array(),\n";
  29211. }
  29212. } elseif ($key === 'install_path' && is_string($value)) {
  29213. if ($this->filesystem->isAbsolutePath($value)) {
  29214. $lines .= var_export($value, true) . ",\n";
  29215. } else {
  29216. $lines .= "__DIR__ . " . var_export('/' . $value, true) . ",\n";
  29217. }
  29218. } else {
  29219. $lines .= var_export($value, true) . ",\n";
  29220. }
  29221. }
  29222. $lines .= str_repeat(' ', $level - 1) . ')' . ($level - 1 === 0 ? '' : ",\n");
  29223. return $lines;
  29224. }
  29225. private function generateInstalledVersions(InstallationManager $installationManager, array $installPaths, bool $devMode, string $repoDir): array
  29226. {
  29227. $devPackages = array_flip($this->devPackageNames);
  29228. $packages = $this->getPackages();
  29229. if (null === $this->rootPackage) {
  29230. throw new \LogicException('It should not be possible to dump packages if no root package is given');
  29231. }
  29232. $packages[] = $rootPackage = $this->rootPackage;
  29233. while ($rootPackage instanceof RootAliasPackage) {
  29234. $rootPackage = $rootPackage->getAliasOf();
  29235. $packages[] = $rootPackage;
  29236. }
  29237. $versions = [
  29238. 'root' => $this->dumpRootPackage($rootPackage, $installPaths, $devMode, $repoDir, $devPackages),
  29239. 'versions' => [],
  29240. ];
  29241. foreach ($packages as $package) {
  29242. if ($package instanceof AliasPackage) {
  29243. continue;
  29244. }
  29245. $versions['versions'][$package->getName()] = $this->dumpInstalledPackage($package, $installPaths, $repoDir, $devPackages);
  29246. }
  29247. foreach ($packages as $package) {
  29248. $isDevPackage = isset($devPackages[$package->getName()]);
  29249. foreach ($package->getReplaces() as $replace) {
  29250. if (PlatformRepository::isPlatformPackage($replace->getTarget())) {
  29251. continue;
  29252. }
  29253. if (!isset($versions['versions'][$replace->getTarget()]['dev_requirement'])) {
  29254. $versions['versions'][$replace->getTarget()]['dev_requirement'] = $isDevPackage;
  29255. } elseif (!$isDevPackage) {
  29256. $versions['versions'][$replace->getTarget()]['dev_requirement'] = false;
  29257. }
  29258. $replaced = $replace->getPrettyConstraint();
  29259. if ($replaced === 'self.version') {
  29260. $replaced = $package->getPrettyVersion();
  29261. }
  29262. if (!isset($versions['versions'][$replace->getTarget()]['replaced']) || !in_array($replaced, $versions['versions'][$replace->getTarget()]['replaced'], true)) {
  29263. $versions['versions'][$replace->getTarget()]['replaced'][] = $replaced;
  29264. }
  29265. }
  29266. foreach ($package->getProvides() as $provide) {
  29267. if (PlatformRepository::isPlatformPackage($provide->getTarget())) {
  29268. continue;
  29269. }
  29270. if (!isset($versions['versions'][$provide->getTarget()]['dev_requirement'])) {
  29271. $versions['versions'][$provide->getTarget()]['dev_requirement'] = $isDevPackage;
  29272. } elseif (!$isDevPackage) {
  29273. $versions['versions'][$provide->getTarget()]['dev_requirement'] = false;
  29274. }
  29275. $provided = $provide->getPrettyConstraint();
  29276. if ($provided === 'self.version') {
  29277. $provided = $package->getPrettyVersion();
  29278. }
  29279. if (!isset($versions['versions'][$provide->getTarget()]['provided']) || !in_array($provided, $versions['versions'][$provide->getTarget()]['provided'], true)) {
  29280. $versions['versions'][$provide->getTarget()]['provided'][] = $provided;
  29281. }
  29282. }
  29283. }
  29284. foreach ($packages as $package) {
  29285. if (!$package instanceof AliasPackage) {
  29286. continue;
  29287. }
  29288. $versions['versions'][$package->getName()]['aliases'][] = $package->getPrettyVersion();
  29289. if ($package instanceof RootPackageInterface) {
  29290. $versions['root']['aliases'][] = $package->getPrettyVersion();
  29291. }
  29292. }
  29293. ksort($versions['versions']);
  29294. ksort($versions);
  29295. return $versions;
  29296. }
  29297. private function dumpInstalledPackage(PackageInterface $package, array $installPaths, string $repoDir, array $devPackages): array
  29298. {
  29299. $reference = null;
  29300. if ($package->getInstallationSource()) {
  29301. $reference = $package->getInstallationSource() === 'source' ? $package->getSourceReference() : $package->getDistReference();
  29302. }
  29303. if (null === $reference) {
  29304. $reference = ($package->getSourceReference() ?: $package->getDistReference()) ?: null;
  29305. }
  29306. if ($package instanceof RootPackageInterface) {
  29307. $to = $this->filesystem->normalizePath(realpath(Platform::getCwd()));
  29308. $installPath = $this->filesystem->findShortestPath($repoDir, $to, true);
  29309. } else {
  29310. $installPath = $installPaths[$package->getName()];
  29311. }
  29312. $data = [
  29313. 'pretty_version' => $package->getPrettyVersion(),
  29314. 'version' => $package->getVersion(),
  29315. 'reference' => $reference,
  29316. 'type' => $package->getType(),
  29317. 'install_path' => $installPath,
  29318. 'aliases' => [],
  29319. 'dev_requirement' => isset($devPackages[$package->getName()]),
  29320. ];
  29321. return $data;
  29322. }
  29323. private function dumpRootPackage(RootPackageInterface $package, array $installPaths, bool $devMode, string $repoDir, array $devPackages)
  29324. {
  29325. $data = $this->dumpInstalledPackage($package, $installPaths, $repoDir, $devPackages);
  29326. return [
  29327. 'name' => $package->getName(),
  29328. 'pretty_version' => $data['pretty_version'],
  29329. 'version' => $data['version'],
  29330. 'reference' => $data['reference'],
  29331. 'type' => $data['type'],
  29332. 'install_path' => $data['install_path'],
  29333. 'aliases' => $data['aliases'],
  29334. 'dev' => $devMode,
  29335. ];
  29336. }
  29337. }
  29338. <?php declare(strict_types=1);
  29339. namespace Composer\Repository;
  29340. use Composer\Package\PackageInterface;
  29341. use Composer\Package\BasePackage;
  29342. use Composer\Pcre\Preg;
  29343. class FilterRepository implements RepositoryInterface, AdvisoryProviderInterface
  29344. {
  29345. private $only = null;
  29346. private $exclude = null;
  29347. private $canonical = true;
  29348. private $repo;
  29349. public function __construct(RepositoryInterface $repo, array $options)
  29350. {
  29351. if (isset($options['only'])) {
  29352. if (!is_array($options['only'])) {
  29353. throw new \InvalidArgumentException('"only" key for repository '.$repo->getRepoName().' should be an array');
  29354. }
  29355. $this->only = BasePackage::packageNamesToRegexp($options['only']);
  29356. }
  29357. if (isset($options['exclude'])) {
  29358. if (!is_array($options['exclude'])) {
  29359. throw new \InvalidArgumentException('"exclude" key for repository '.$repo->getRepoName().' should be an array');
  29360. }
  29361. $this->exclude = BasePackage::packageNamesToRegexp($options['exclude']);
  29362. }
  29363. if ($this->exclude && $this->only) {
  29364. throw new \InvalidArgumentException('Only one of "only" and "exclude" can be specified for repository '.$repo->getRepoName());
  29365. }
  29366. if (isset($options['canonical'])) {
  29367. if (!is_bool($options['canonical'])) {
  29368. throw new \InvalidArgumentException('"canonical" key for repository '.$repo->getRepoName().' should be a boolean');
  29369. }
  29370. $this->canonical = $options['canonical'];
  29371. }
  29372. $this->repo = $repo;
  29373. }
  29374. public function getRepoName(): string
  29375. {
  29376. return $this->repo->getRepoName();
  29377. }
  29378. public function getRepository(): RepositoryInterface
  29379. {
  29380. return $this->repo;
  29381. }
  29382. public function hasPackage(PackageInterface $package): bool
  29383. {
  29384. return $this->repo->hasPackage($package);
  29385. }
  29386. public function findPackage($name, $constraint): ?BasePackage
  29387. {
  29388. if (!$this->isAllowed($name)) {
  29389. return null;
  29390. }
  29391. return $this->repo->findPackage($name, $constraint);
  29392. }
  29393. public function findPackages($name, $constraint = null): array
  29394. {
  29395. if (!$this->isAllowed($name)) {
  29396. return [];
  29397. }
  29398. return $this->repo->findPackages($name, $constraint);
  29399. }
  29400. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = []): array
  29401. {
  29402. foreach ($packageNameMap as $name => $constraint) {
  29403. if (!$this->isAllowed($name)) {
  29404. unset($packageNameMap[$name]);
  29405. }
  29406. }
  29407. if (!$packageNameMap) {
  29408. return ['namesFound' => [], 'packages' => []];
  29409. }
  29410. $result = $this->repo->loadPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  29411. if (!$this->canonical) {
  29412. $result['namesFound'] = [];
  29413. }
  29414. return $result;
  29415. }
  29416. public function search(string $query, int $mode = 0, ?string $type = null): array
  29417. {
  29418. $result = [];
  29419. foreach ($this->repo->search($query, $mode, $type) as $package) {
  29420. if ($this->isAllowed($package['name'])) {
  29421. $result[] = $package;
  29422. }
  29423. }
  29424. return $result;
  29425. }
  29426. public function getPackages(): array
  29427. {
  29428. $result = [];
  29429. foreach ($this->repo->getPackages() as $package) {
  29430. if ($this->isAllowed($package->getName())) {
  29431. $result[] = $package;
  29432. }
  29433. }
  29434. return $result;
  29435. }
  29436. public function getProviders($packageName): array
  29437. {
  29438. $result = [];
  29439. foreach ($this->repo->getProviders($packageName) as $name => $provider) {
  29440. if ($this->isAllowed($provider['name'])) {
  29441. $result[$name] = $provider;
  29442. }
  29443. }
  29444. return $result;
  29445. }
  29446. public function count(): int
  29447. {
  29448. if ($this->repo->count() > 0) {
  29449. return count($this->getPackages());
  29450. }
  29451. return 0;
  29452. }
  29453. public function hasSecurityAdvisories(): bool
  29454. {
  29455. if (!$this->repo instanceof AdvisoryProviderInterface) {
  29456. return false;
  29457. }
  29458. return $this->repo->hasSecurityAdvisories();
  29459. }
  29460. public function getSecurityAdvisories(array $packageConstraintMap, bool $allowPartialAdvisories = false): array
  29461. {
  29462. if (!$this->repo instanceof AdvisoryProviderInterface) {
  29463. return ['namesFound' => [], 'advisories' => []];
  29464. }
  29465. foreach ($packageConstraintMap as $name => $constraint) {
  29466. if (!$this->isAllowed($name)) {
  29467. unset($packageConstraintMap[$name]);
  29468. }
  29469. }
  29470. return $this->repo->getSecurityAdvisories($packageConstraintMap, $allowPartialAdvisories);
  29471. }
  29472. private function isAllowed(string $name): bool
  29473. {
  29474. if (!$this->only && !$this->exclude) {
  29475. return true;
  29476. }
  29477. if ($this->only) {
  29478. return Preg::isMatch($this->only, $name);
  29479. }
  29480. if ($this->exclude === null) {
  29481. return true;
  29482. }
  29483. return !Preg::isMatch($this->exclude, $name);
  29484. }
  29485. }
  29486. <?php declare(strict_types=1);
  29487. namespace Composer\Repository;
  29488. class InstalledArrayRepository extends WritableArrayRepository implements InstalledRepositoryInterface
  29489. {
  29490. public function getRepoName(): string
  29491. {
  29492. return 'installed '.parent::getRepoName();
  29493. }
  29494. public function isFresh(): bool
  29495. {
  29496. return $this->count() === 0;
  29497. }
  29498. }
  29499. <?php declare(strict_types=1);
  29500. namespace Composer\Repository;
  29501. class InstalledFilesystemRepository extends FilesystemRepository implements InstalledRepositoryInterface
  29502. {
  29503. public function getRepoName()
  29504. {
  29505. return 'installed '.parent::getRepoName();
  29506. }
  29507. public function isFresh()
  29508. {
  29509. return !$this->file->exists();
  29510. }
  29511. }
  29512. <?php declare(strict_types=1);
  29513. namespace Composer\Repository;
  29514. use Composer\Package\BasePackage;
  29515. use Composer\Package\PackageInterface;
  29516. use Composer\Package\Version\VersionParser;
  29517. use Composer\Semver\Constraint\ConstraintInterface;
  29518. use Composer\Semver\Constraint\Constraint;
  29519. use Composer\Semver\Constraint\MatchAllConstraint;
  29520. use Composer\Package\RootPackageInterface;
  29521. use Composer\Package\Link;
  29522. class InstalledRepository extends CompositeRepository
  29523. {
  29524. public function findPackagesWithReplacersAndProviders(string $name, $constraint = null): array
  29525. {
  29526. $name = strtolower($name);
  29527. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  29528. $versionParser = new VersionParser();
  29529. $constraint = $versionParser->parseConstraints($constraint);
  29530. }
  29531. $matches = [];
  29532. foreach ($this->getRepositories() as $repo) {
  29533. foreach ($repo->getPackages() as $candidate) {
  29534. if ($name === $candidate->getName()) {
  29535. if (null === $constraint || $constraint->matches(new Constraint('==', $candidate->getVersion()))) {
  29536. $matches[] = $candidate;
  29537. }
  29538. continue;
  29539. }
  29540. foreach (array_merge($candidate->getProvides(), $candidate->getReplaces()) as $link) {
  29541. if (
  29542. $name === $link->getTarget()
  29543. && ($constraint === null || $constraint->matches($link->getConstraint()))
  29544. ) {
  29545. $matches[] = $candidate;
  29546. continue 2;
  29547. }
  29548. }
  29549. }
  29550. }
  29551. return $matches;
  29552. }
  29553. public function getDependents($needle, ?ConstraintInterface $constraint = null, bool $invert = false, bool $recurse = true, ?array $packagesFound = null): array
  29554. {
  29555. $needles = array_map('strtolower', (array) $needle);
  29556. $results = [];
  29557. if (null === $packagesFound) {
  29558. $packagesFound = $needles;
  29559. }
  29560. $rootPackage = null;
  29561. foreach ($this->getPackages() as $package) {
  29562. if ($package instanceof RootPackageInterface) {
  29563. $rootPackage = $package;
  29564. break;
  29565. }
  29566. }
  29567. foreach ($this->getPackages() as $package) {
  29568. $links = $package->getRequires();
  29569. $packagesInTree = $packagesFound;
  29570. if (!$invert) {
  29571. $links += $package->getReplaces();
  29572. foreach ($package->getReplaces() as $link) {
  29573. foreach ($needles as $needle) {
  29574. if ($link->getSource() === $needle) {
  29575. if ($constraint === null || ($link->getConstraint()->matches($constraint) === true)) {
  29576. if (in_array($link->getTarget(), $packagesInTree)) {
  29577. $results[] = [$package, $link, false];
  29578. continue;
  29579. }
  29580. $packagesInTree[] = $link->getTarget();
  29581. $dependents = $recurse ? $this->getDependents($link->getTarget(), null, false, true, $packagesInTree) : [];
  29582. $results[] = [$package, $link, $dependents];
  29583. $needles[] = $link->getTarget();
  29584. }
  29585. }
  29586. }
  29587. }
  29588. }
  29589. if ($package instanceof RootPackageInterface) {
  29590. $links += $package->getDevRequires();
  29591. }
  29592. foreach ($links as $link) {
  29593. foreach ($needles as $needle) {
  29594. if ($link->getTarget() === $needle) {
  29595. if ($constraint === null || ($link->getConstraint()->matches($constraint) === !$invert)) {
  29596. if (in_array($link->getSource(), $packagesInTree)) {
  29597. $results[] = [$package, $link, false];
  29598. continue;
  29599. }
  29600. $packagesInTree[] = $link->getSource();
  29601. $dependents = $recurse ? $this->getDependents($link->getSource(), null, false, true, $packagesInTree) : [];
  29602. $results[] = [$package, $link, $dependents];
  29603. }
  29604. }
  29605. }
  29606. }
  29607. if ($invert && in_array($package->getName(), $needles)) {
  29608. foreach ($package->getConflicts() as $link) {
  29609. foreach ($this->findPackages($link->getTarget()) as $pkg) {
  29610. $version = new Constraint('=', $pkg->getVersion());
  29611. if ($link->getConstraint()->matches($version) === $invert) {
  29612. $results[] = [$package, $link, false];
  29613. }
  29614. }
  29615. }
  29616. }
  29617. foreach ($package->getConflicts() as $link) {
  29618. if (in_array($link->getTarget(), $needles)) {
  29619. foreach ($this->findPackages($link->getTarget()) as $pkg) {
  29620. $version = new Constraint('=', $pkg->getVersion());
  29621. if ($link->getConstraint()->matches($version) === $invert) {
  29622. $results[] = [$package, $link, false];
  29623. }
  29624. }
  29625. }
  29626. }
  29627. if ($invert && $constraint && in_array($package->getName(), $needles) && $constraint->matches(new Constraint('=', $package->getVersion()))) {
  29628. foreach ($package->getRequires() as $link) {
  29629. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  29630. if ($this->findPackage($link->getTarget(), $link->getConstraint())) {
  29631. continue;
  29632. }
  29633. $platformPkg = $this->findPackage($link->getTarget(), '*');
  29634. $description = $platformPkg ? 'but '.$platformPkg->getPrettyVersion().' is installed' : 'but it is missing';
  29635. $results[] = [$package, new Link($package->getName(), $link->getTarget(), new MatchAllConstraint, Link::TYPE_REQUIRE, $link->getPrettyConstraint().' '.$description), false];
  29636. continue;
  29637. }
  29638. foreach ($this->getPackages() as $pkg) {
  29639. if (!in_array($link->getTarget(), $pkg->getNames())) {
  29640. continue;
  29641. }
  29642. $version = new Constraint('=', $pkg->getVersion());
  29643. if ($link->getTarget() !== $pkg->getName()) {
  29644. foreach (array_merge($pkg->getReplaces(), $pkg->getProvides()) as $prov) {
  29645. if ($link->getTarget() === $prov->getTarget()) {
  29646. $version = $prov->getConstraint();
  29647. break;
  29648. }
  29649. }
  29650. }
  29651. if (!$link->getConstraint()->matches($version)) {
  29652. if ($rootPackage) {
  29653. foreach (array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires()) as $rootReq) {
  29654. if (in_array($rootReq->getTarget(), $pkg->getNames()) && !$rootReq->getConstraint()->matches($link->getConstraint())) {
  29655. $results[] = [$package, $link, false];
  29656. $results[] = [$rootPackage, $rootReq, false];
  29657. continue 3;
  29658. }
  29659. }
  29660. $results[] = [$package, $link, false];
  29661. $results[] = [$rootPackage, new Link($rootPackage->getName(), $link->getTarget(), new MatchAllConstraint, Link::TYPE_DOES_NOT_REQUIRE, 'but ' . $pkg->getPrettyVersion() . ' is installed'), false];
  29662. } else {
  29663. $results[] = [$package, $link, false];
  29664. }
  29665. }
  29666. continue 2;
  29667. }
  29668. }
  29669. }
  29670. }
  29671. ksort($results);
  29672. return $results;
  29673. }
  29674. public function getRepoName(): string
  29675. {
  29676. return 'installed repo ('.implode(', ', array_map(static function ($repo): string {
  29677. return $repo->getRepoName();
  29678. }, $this->getRepositories())).')';
  29679. }
  29680. public function addRepository(RepositoryInterface $repository): void
  29681. {
  29682. if (
  29683. $repository instanceof LockArrayRepository
  29684. || $repository instanceof InstalledRepositoryInterface
  29685. || $repository instanceof RootPackageRepository
  29686. || $repository instanceof PlatformRepository
  29687. ) {
  29688. parent::addRepository($repository);
  29689. return;
  29690. }
  29691. throw new \LogicException('An InstalledRepository can not contain a repository of type '.get_class($repository).' ('.$repository->getRepoName().')');
  29692. }
  29693. }
  29694. <?php declare(strict_types=1);
  29695. namespace Composer\Repository;
  29696. interface InstalledRepositoryInterface extends WritableRepositoryInterface
  29697. {
  29698. public function getDevMode();
  29699. public function isFresh();
  29700. }
  29701. <?php declare(strict_types=1);
  29702. namespace Composer\Repository;
  29703. class InvalidRepositoryException extends \Exception
  29704. {
  29705. }
  29706. <?php declare(strict_types=1);
  29707. namespace Composer\Repository;
  29708. class LockArrayRepository extends ArrayRepository
  29709. {
  29710. use CanonicalPackagesTrait;
  29711. public function getRepoName(): string
  29712. {
  29713. return 'lock repo';
  29714. }
  29715. }
  29716. <?php declare(strict_types=1);
  29717. namespace Composer\Repository;
  29718. use Composer\Package\Loader\ArrayLoader;
  29719. use Composer\Package\Loader\ValidatingArrayLoader;
  29720. use Composer\Pcre\Preg;
  29721. class PackageRepository extends ArrayRepository
  29722. {
  29723. private $config;
  29724. public function __construct(array $config)
  29725. {
  29726. parent::__construct();
  29727. $this->config = $config['package'];
  29728. if (!is_numeric(key($this->config))) {
  29729. $this->config = [$this->config];
  29730. }
  29731. }
  29732. protected function initialize(): void
  29733. {
  29734. parent::initialize();
  29735. $loader = new ValidatingArrayLoader(new ArrayLoader(null, true), true);
  29736. foreach ($this->config as $package) {
  29737. try {
  29738. $package = $loader->load($package);
  29739. } catch (\Exception $e) {
  29740. throw new InvalidRepositoryException('A repository of type "package" contains an invalid package definition: '.$e->getMessage()."\n\nInvalid package definition:\n".json_encode($package));
  29741. }
  29742. $this->addPackage($package);
  29743. }
  29744. }
  29745. public function getRepoName(): string
  29746. {
  29747. return Preg::replace('{^array }', 'package ', parent::getRepoName());
  29748. }
  29749. }
  29750. <?php declare(strict_types=1);
  29751. namespace Composer\Repository;
  29752. use Composer\Config;
  29753. use Composer\EventDispatcher\EventDispatcher;
  29754. use Composer\IO\IOInterface;
  29755. use Composer\Json\JsonFile;
  29756. use Composer\Package\Loader\ArrayLoader;
  29757. use Composer\Package\Version\VersionGuesser;
  29758. use Composer\Package\Version\VersionParser;
  29759. use Composer\Pcre\Preg;
  29760. use Composer\Util\HttpDownloader;
  29761. use Composer\Util\Platform;
  29762. use Composer\Util\ProcessExecutor;
  29763. use Composer\Util\Filesystem;
  29764. use Composer\Util\Url;
  29765. use Composer\Util\Git as GitUtil;
  29766. class PathRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  29767. {
  29768. private $loader;
  29769. private $versionGuesser;
  29770. private $url;
  29771. private $repoConfig;
  29772. private $process;
  29773. private $options;
  29774. public function __construct(array $repoConfig, IOInterface $io, Config $config, ?HttpDownloader $httpDownloader = null, ?EventDispatcher $dispatcher = null, ?ProcessExecutor $process = null)
  29775. {
  29776. if (!isset($repoConfig['url'])) {
  29777. throw new \RuntimeException('You must specify the `url` configuration for the path repository');
  29778. }
  29779. $this->loader = new ArrayLoader(null, true);
  29780. $this->url = Platform::expandPath($repoConfig['url']);
  29781. $this->process = $process ?? new ProcessExecutor($io);
  29782. $this->versionGuesser = new VersionGuesser($config, $this->process, new VersionParser());
  29783. $this->repoConfig = $repoConfig;
  29784. $this->options = $repoConfig['options'] ?? [];
  29785. if (!isset($this->options['relative'])) {
  29786. $filesystem = new Filesystem();
  29787. $this->options['relative'] = !$filesystem->isAbsolutePath($this->url);
  29788. }
  29789. parent::__construct();
  29790. }
  29791. public function getRepoName(): string
  29792. {
  29793. return 'path repo ('.Url::sanitize($this->repoConfig['url']).')';
  29794. }
  29795. public function getRepoConfig(): array
  29796. {
  29797. return $this->repoConfig;
  29798. }
  29799. protected function initialize(): void
  29800. {
  29801. parent::initialize();
  29802. $urlMatches = $this->getUrlMatches();
  29803. if (empty($urlMatches)) {
  29804. if (Preg::isMatch('{[*{}]}', $this->url)) {
  29805. $url = $this->url;
  29806. while (Preg::isMatch('{[*{}]}', $url)) {
  29807. $url = dirname($url);
  29808. }
  29809. if (is_dir($url)) {
  29810. return;
  29811. }
  29812. }
  29813. throw new \RuntimeException('The `url` supplied for the path (' . $this->url . ') repository does not exist');
  29814. }
  29815. foreach ($urlMatches as $url) {
  29816. $path = realpath($url) . DIRECTORY_SEPARATOR;
  29817. $composerFilePath = $path.'composer.json';
  29818. if (!file_exists($composerFilePath)) {
  29819. continue;
  29820. }
  29821. $json = file_get_contents($composerFilePath);
  29822. $package = JsonFile::parseJson($json, $composerFilePath);
  29823. $package['dist'] = [
  29824. 'type' => 'path',
  29825. 'url' => $url,
  29826. ];
  29827. $reference = $this->options['reference'] ?? 'auto';
  29828. if ('none' === $reference) {
  29829. $package['dist']['reference'] = null;
  29830. } elseif ('config' === $reference || 'auto' === $reference) {
  29831. $package['dist']['reference'] = sha1($json . serialize($this->options));
  29832. }
  29833. $package['transport-options'] = array_intersect_key($this->options, ['symlink' => true, 'relative' => true]);
  29834. if (isset($package['name'], $this->options['versions'][$package['name']])) {
  29835. $package['version'] = $this->options['versions'][$package['name']];
  29836. }
  29837. if (!isset($package['version']) && ($rootVersion = Platform::getEnv('COMPOSER_ROOT_VERSION'))) {
  29838. if (
  29839. 0 === $this->process->execute('git rev-parse HEAD', $ref1, $path)
  29840. && 0 === $this->process->execute('git rev-parse HEAD', $ref2)
  29841. && $ref1 === $ref2
  29842. ) {
  29843. $package['version'] = $rootVersion;
  29844. }
  29845. }
  29846. $output = '';
  29847. if ('auto' === $reference && is_dir($path . DIRECTORY_SEPARATOR . '.git') && 0 === $this->process->execute('git log -n1 --pretty=%H'.GitUtil::getNoShowSignatureFlag($this->process), $output, $path)) {
  29848. $package['dist']['reference'] = trim($output);
  29849. }
  29850. if (!isset($package['version'])) {
  29851. $versionData = $this->versionGuesser->guessVersion($package, $path);
  29852. if (is_array($versionData) && $versionData['pretty_version']) {
  29853. if (!empty($versionData['feature_pretty_version'])) {
  29854. $package['version'] = $versionData['feature_pretty_version'];
  29855. $this->addPackage($this->loader->load($package));
  29856. }
  29857. $package['version'] = $versionData['pretty_version'];
  29858. } else {
  29859. $package['version'] = 'dev-main';
  29860. }
  29861. }
  29862. try {
  29863. $this->addPackage($this->loader->load($package));
  29864. } catch (\Exception $e) {
  29865. throw new \RuntimeException('Failed loading the package in '.$composerFilePath, 0, $e);
  29866. }
  29867. }
  29868. }
  29869. private function getUrlMatches(): array
  29870. {
  29871. $flags = GLOB_MARK | GLOB_ONLYDIR;
  29872. if (defined('GLOB_BRACE')) {
  29873. $flags |= GLOB_BRACE;
  29874. } elseif (strpos($this->url, '{') !== false || strpos($this->url, '}') !== false) {
  29875. throw new \RuntimeException('The operating system does not support GLOB_BRACE which is required for the url '. $this->url);
  29876. }
  29877. return array_map(static function ($val): string {
  29878. return rtrim(str_replace(DIRECTORY_SEPARATOR, '/', $val), '/');
  29879. }, glob($this->url, $flags));
  29880. }
  29881. }
  29882. <?php declare(strict_types=1);
  29883. namespace Composer\Repository;
  29884. class PearRepository extends ArrayRepository
  29885. {
  29886. public function __construct()
  29887. {
  29888. throw new \InvalidArgumentException('The PEAR repository has been removed from Composer 2.x');
  29889. }
  29890. }
  29891. <?php declare(strict_types=1);
  29892. namespace Composer\Repository;
  29893. use Composer\Composer;
  29894. use Composer\Package\CompletePackage;
  29895. use Composer\Package\CompletePackageInterface;
  29896. use Composer\Package\Link;
  29897. use Composer\Package\PackageInterface;
  29898. use Composer\Package\Version\VersionParser;
  29899. use Composer\Pcre\Preg;
  29900. use Composer\Platform\HhvmDetector;
  29901. use Composer\Platform\Runtime;
  29902. use Composer\Platform\Version;
  29903. use Composer\Plugin\PluginInterface;
  29904. use Composer\Semver\Constraint\Constraint;
  29905. use Composer\Util\Silencer;
  29906. use Composer\XdebugHandler\XdebugHandler;
  29907. class PlatformRepository extends ArrayRepository
  29908. {
  29909. public const PLATFORM_PACKAGE_REGEX = '{^(?:php(?:-64bit|-ipv6|-zts|-debug)?|hhvm|(?:ext|lib)-[a-z0-9](?:[_.-]?[a-z0-9]+)*|composer(?:-(?:plugin|runtime)-api)?)$}iD';
  29910. private static $lastSeenPlatformPhp = null;
  29911. private $versionParser;
  29912. private $overrides = [];
  29913. private $disabledPackages = [];
  29914. private $runtime;
  29915. private $hhvmDetector;
  29916. public function __construct(array $packages = [], array $overrides = [], ?Runtime $runtime = null, ?HhvmDetector $hhvmDetector = null)
  29917. {
  29918. $this->runtime = $runtime ?: new Runtime();
  29919. $this->hhvmDetector = $hhvmDetector ?: new HhvmDetector();
  29920. foreach ($overrides as $name => $version) {
  29921. if (!is_string($version) && false !== $version) {
  29922. throw new \UnexpectedValueException('config.platform.'.$name.' should be a string or false, but got '.gettype($version).' '.var_export($version, true));
  29923. }
  29924. if ($name === 'php' && $version === false) {
  29925. throw new \UnexpectedValueException('config.platform.'.$name.' cannot be set to false as you cannot disable php entirely.');
  29926. }
  29927. $this->overrides[strtolower($name)] = ['name' => $name, 'version' => $version];
  29928. }
  29929. parent::__construct($packages);
  29930. }
  29931. public function getRepoName(): string
  29932. {
  29933. return 'platform repo';
  29934. }
  29935. public function isPlatformPackageDisabled(string $name): bool
  29936. {
  29937. return isset($this->disabledPackages[$name]);
  29938. }
  29939. public function getDisabledPackages(): array
  29940. {
  29941. return $this->disabledPackages;
  29942. }
  29943. protected function initialize(): void
  29944. {
  29945. parent::initialize();
  29946. $this->versionParser = new VersionParser();
  29947. foreach ($this->overrides as $override) {
  29948. if (!self::isPlatformPackage($override['name'])) {
  29949. throw new \InvalidArgumentException('Invalid platform package name in config.platform: '.$override['name']);
  29950. }
  29951. if ($override['version'] !== false) {
  29952. $this->addOverriddenPackage($override);
  29953. }
  29954. }
  29955. $prettyVersion = Composer::getVersion();
  29956. $version = $this->versionParser->normalize($prettyVersion);
  29957. $composer = new CompletePackage('composer', $version, $prettyVersion);
  29958. $composer->setDescription('Composer package');
  29959. $this->addPackage($composer);
  29960. $prettyVersion = PluginInterface::PLUGIN_API_VERSION;
  29961. $version = $this->versionParser->normalize($prettyVersion);
  29962. $composerPluginApi = new CompletePackage('composer-plugin-api', $version, $prettyVersion);
  29963. $composerPluginApi->setDescription('The Composer Plugin API');
  29964. $this->addPackage($composerPluginApi);
  29965. $prettyVersion = Composer::RUNTIME_API_VERSION;
  29966. $version = $this->versionParser->normalize($prettyVersion);
  29967. $composerRuntimeApi = new CompletePackage('composer-runtime-api', $version, $prettyVersion);
  29968. $composerRuntimeApi->setDescription('The Composer Runtime API');
  29969. $this->addPackage($composerRuntimeApi);
  29970. try {
  29971. $prettyVersion = $this->runtime->getConstant('PHP_VERSION');
  29972. $version = $this->versionParser->normalize($prettyVersion);
  29973. } catch (\UnexpectedValueException $e) {
  29974. $prettyVersion = Preg::replace('#^([^~+-]+).*$#', '$1', $this->runtime->getConstant('PHP_VERSION'));
  29975. $version = $this->versionParser->normalize($prettyVersion);
  29976. }
  29977. $php = new CompletePackage('php', $version, $prettyVersion);
  29978. $php->setDescription('The PHP interpreter');
  29979. $this->addPackage($php);
  29980. if ($this->runtime->getConstant('PHP_DEBUG')) {
  29981. $phpdebug = new CompletePackage('php-debug', $version, $prettyVersion);
  29982. $phpdebug->setDescription('The PHP interpreter, with debugging symbols');
  29983. $this->addPackage($phpdebug);
  29984. }
  29985. if ($this->runtime->hasConstant('PHP_ZTS') && $this->runtime->getConstant('PHP_ZTS')) {
  29986. $phpzts = new CompletePackage('php-zts', $version, $prettyVersion);
  29987. $phpzts->setDescription('The PHP interpreter, with Zend Thread Safety');
  29988. $this->addPackage($phpzts);
  29989. }
  29990. if ($this->runtime->getConstant('PHP_INT_SIZE') === 8) {
  29991. $php64 = new CompletePackage('php-64bit', $version, $prettyVersion);
  29992. $php64->setDescription('The PHP interpreter, 64bit');
  29993. $this->addPackage($php64);
  29994. }
  29995. if ($this->runtime->hasConstant('AF_INET6') || Silencer::call([$this->runtime, 'invoke'], 'inet_pton', ['::']) !== false) {
  29996. $phpIpv6 = new CompletePackage('php-ipv6', $version, $prettyVersion);
  29997. $phpIpv6->setDescription('The PHP interpreter, with IPv6 support');
  29998. $this->addPackage($phpIpv6);
  29999. }
  30000. $loadedExtensions = $this->runtime->getExtensions();
  30001. foreach ($loadedExtensions as $name) {
  30002. if (in_array($name, ['standard', 'Core'])) {
  30003. continue;
  30004. }
  30005. $this->addExtension($name, $this->runtime->getExtensionVersion($name));
  30006. }
  30007. if (!in_array('xdebug', $loadedExtensions, true) && ($prettyVersion = XdebugHandler::getSkippedVersion())) {
  30008. $this->addExtension('xdebug', $prettyVersion);
  30009. }
  30010. foreach ($loadedExtensions as $name) {
  30011. switch ($name) {
  30012. case 'amqp':
  30013. $info = $this->runtime->getExtensionInfo($name);
  30014. if (Preg::isMatch('/^librabbitmq version => (?<version>.+)$/im', $info, $librabbitmqMatches)) {
  30015. $this->addLibrary($name.'-librabbitmq', $librabbitmqMatches['version'], 'AMQP librabbitmq version');
  30016. }
  30017. if (Preg::isMatchStrictGroups('/^AMQP protocol version => (?<version>.+)$/im', $info, $protocolMatches)) {
  30018. $this->addLibrary($name.'-protocol', str_replace('-', '.', $protocolMatches['version']), 'AMQP protocol version');
  30019. }
  30020. break;
  30021. case 'bz2':
  30022. $info = $this->runtime->getExtensionInfo($name);
  30023. if (Preg::isMatch('/^BZip2 Version => (?<version>.*),/im', $info, $matches)) {
  30024. $this->addLibrary($name, $matches['version']);
  30025. }
  30026. break;
  30027. case 'curl':
  30028. $curlVersion = $this->runtime->invoke('curl_version');
  30029. $this->addLibrary($name, $curlVersion['version']);
  30030. $info = $this->runtime->getExtensionInfo($name);
  30031. if (Preg::isMatchStrictGroups('{^SSL Version => (?<library>[^/]+)/(?<version>.+)$}im', $info, $sslMatches)) {
  30032. $library = strtolower($sslMatches['library']);
  30033. if ($library === 'openssl') {
  30034. $parsedVersion = Version::parseOpenssl($sslMatches['version'], $isFips);
  30035. $this->addLibrary($name.'-openssl'.($isFips ? '-fips' : ''), $parsedVersion, 'curl OpenSSL version ('.$parsedVersion.')', [], $isFips ? ['curl-openssl'] : []);
  30036. } else {
  30037. if ($library === '(securetransport) openssl') {
  30038. $shortlib = 'securetransport';
  30039. } else {
  30040. $shortlib = $library;
  30041. }
  30042. $this->addLibrary($name.'-'.$shortlib, $sslMatches['version'], 'curl '.$library.' version ('.$sslMatches['version'].')', ['curl-openssl']);
  30043. }
  30044. }
  30045. if (Preg::isMatchStrictGroups('{^libSSH Version => (?<library>[^/]+)/(?<version>.+?)(?:/.*)?$}im', $info, $sshMatches)) {
  30046. $this->addLibrary($name.'-'.strtolower($sshMatches['library']), $sshMatches['version'], 'curl '.$sshMatches['library'].' version');
  30047. }
  30048. if (Preg::isMatchStrictGroups('{^ZLib Version => (?<version>.+)$}im', $info, $zlibMatches)) {
  30049. $this->addLibrary($name.'-zlib', $zlibMatches['version'], 'curl zlib version');
  30050. }
  30051. break;
  30052. case 'date':
  30053. $info = $this->runtime->getExtensionInfo($name);
  30054. if (Preg::isMatchStrictGroups('/^timelib version => (?<version>.+)$/im', $info, $timelibMatches)) {
  30055. $this->addLibrary($name.'-timelib', $timelibMatches['version'], 'date timelib version');
  30056. }
  30057. if (Preg::isMatchStrictGroups('/^Timezone Database => (?<source>internal|external)$/im', $info, $zoneinfoSourceMatches)) {
  30058. $external = $zoneinfoSourceMatches['source'] === 'external';
  30059. if (Preg::isMatchStrictGroups('/^"Olson" Timezone Database Version => (?<version>.+?)(?:\.system)?$/im', $info, $zoneinfoMatches)) {
  30060. if ($external && in_array('timezonedb', $loadedExtensions, true)) {
  30061. $this->addLibrary('timezonedb-zoneinfo', $zoneinfoMatches['version'], 'zoneinfo ("Olson") database for date (replaced by timezonedb)', [$name.'-zoneinfo']);
  30062. } else {
  30063. $this->addLibrary($name.'-zoneinfo', $zoneinfoMatches['version'], 'zoneinfo ("Olson") database for date');
  30064. }
  30065. }
  30066. }
  30067. break;
  30068. case 'fileinfo':
  30069. $info = $this->runtime->getExtensionInfo($name);
  30070. if (Preg::isMatch('/^libmagic => (?<version>.+)$/im', $info, $magicMatches)) {
  30071. $this->addLibrary($name.'-libmagic', $magicMatches['version'], 'fileinfo libmagic version');
  30072. }
  30073. break;
  30074. case 'gd':
  30075. $this->addLibrary($name, $this->runtime->getConstant('GD_VERSION'));
  30076. $info = $this->runtime->getExtensionInfo($name);
  30077. if (Preg::isMatchStrictGroups('/^libJPEG Version => (?<version>.+?)(?: compatible)?$/im', $info, $libjpegMatches)) {
  30078. $this->addLibrary($name.'-libjpeg', Version::parseLibjpeg($libjpegMatches['version']), 'libjpeg version for gd');
  30079. }
  30080. if (Preg::isMatchStrictGroups('/^libPNG Version => (?<version>.+)$/im', $info, $libpngMatches)) {
  30081. $this->addLibrary($name.'-libpng', $libpngMatches['version'], 'libpng version for gd');
  30082. }
  30083. if (Preg::isMatchStrictGroups('/^FreeType Version => (?<version>.+)$/im', $info, $freetypeMatches)) {
  30084. $this->addLibrary($name.'-freetype', $freetypeMatches['version'], 'freetype version for gd');
  30085. }
  30086. if (Preg::isMatchStrictGroups('/^libXpm Version => (?<versionId>\d+)$/im', $info, $libxpmMatches)) {
  30087. $this->addLibrary($name.'-libxpm', Version::convertLibxpmVersionId((int) $libxpmMatches['versionId']), 'libxpm version for gd');
  30088. }
  30089. break;
  30090. case 'gmp':
  30091. $this->addLibrary($name, $this->runtime->getConstant('GMP_VERSION'));
  30092. break;
  30093. case 'iconv':
  30094. $this->addLibrary($name, $this->runtime->getConstant('ICONV_VERSION'));
  30095. break;
  30096. case 'intl':
  30097. $info = $this->runtime->getExtensionInfo($name);
  30098. $description = 'The ICU unicode and globalization support library';
  30099. if ($this->runtime->hasConstant('INTL_ICU_VERSION')) {
  30100. $this->addLibrary('icu', $this->runtime->getConstant('INTL_ICU_VERSION'), $description);
  30101. } elseif (Preg::isMatch('/^ICU version => (?<version>.+)$/im', $info, $matches)) {
  30102. $this->addLibrary('icu', $matches['version'], $description);
  30103. }
  30104. if (Preg::isMatchStrictGroups('/^ICU TZData version => (?<version>.*)$/im', $info, $zoneinfoMatches) && null !== ($version = Version::parseZoneinfoVersion($zoneinfoMatches['version']))) {
  30105. $this->addLibrary('icu-zoneinfo', $version, 'zoneinfo ("Olson") database for icu');
  30106. }
  30107. if ($this->runtime->hasClass('ResourceBundle')) {
  30108. $resourceBundle = $this->runtime->invoke(['ResourceBundle', 'create'], ['root', 'ICUDATA', false]);
  30109. if ($resourceBundle !== null) {
  30110. $this->addLibrary('icu-cldr', $resourceBundle->get('Version'), 'ICU CLDR project version');
  30111. }
  30112. }
  30113. if ($this->runtime->hasClass('IntlChar')) {
  30114. $this->addLibrary('icu-unicode', implode('.', array_slice($this->runtime->invoke(['IntlChar', 'getUnicodeVersion']), 0, 3)), 'ICU unicode version');
  30115. }
  30116. break;
  30117. case 'imagick':
  30118. $imageMagickVersion = $this->runtime->construct('Imagick')->getVersion();
  30119. Preg::match('/^ImageMagick (?<version>[\d.]+)(?:-(?<patch>\d+))?/', $imageMagickVersion['versionString'], $matches);
  30120. $version = $matches['version'];
  30121. if (isset($matches['patch'])) {
  30122. $version .= '.'.$matches['patch'];
  30123. }
  30124. $this->addLibrary($name.'-imagemagick', $version, null, ['imagick']);
  30125. break;
  30126. case 'ldap':
  30127. $info = $this->runtime->getExtensionInfo($name);
  30128. if (Preg::isMatchStrictGroups('/^Vendor Version => (?<versionId>\d+)$/im', $info, $matches) && Preg::isMatchStrictGroups('/^Vendor Name => (?<vendor>.+)$/im', $info, $vendorMatches)) {
  30129. $this->addLibrary($name.'-'.strtolower($vendorMatches['vendor']), Version::convertOpenldapVersionId((int) $matches['versionId']), $vendorMatches['vendor'].' version of ldap');
  30130. }
  30131. break;
  30132. case 'libxml':
  30133. $libxmlProvides = array_map(static function ($extension): string {
  30134. return $extension . '-libxml';
  30135. }, array_intersect($loadedExtensions, ['dom', 'simplexml', 'xml', 'xmlreader', 'xmlwriter']));
  30136. $this->addLibrary($name, $this->runtime->getConstant('LIBXML_DOTTED_VERSION'), 'libxml library version', [], $libxmlProvides);
  30137. break;
  30138. case 'mbstring':
  30139. $info = $this->runtime->getExtensionInfo($name);
  30140. if (Preg::isMatch('/^libmbfl version => (?<version>.+)$/im', $info, $libmbflMatches)) {
  30141. $this->addLibrary($name.'-libmbfl', $libmbflMatches['version'], 'mbstring libmbfl version');
  30142. }
  30143. if ($this->runtime->hasConstant('MB_ONIGURUMA_VERSION')) {
  30144. $this->addLibrary($name.'-oniguruma', $this->runtime->getConstant('MB_ONIGURUMA_VERSION'), 'mbstring oniguruma version');
  30145. } elseif (Preg::isMatch('/^(?:oniguruma|Multibyte regex \(oniguruma\)) version => (?<version>.+)$/im', $info, $onigurumaMatches)) {
  30146. $this->addLibrary($name.'-oniguruma', $onigurumaMatches['version'], 'mbstring oniguruma version');
  30147. }
  30148. break;
  30149. case 'memcached':
  30150. $info = $this->runtime->getExtensionInfo($name);
  30151. if (Preg::isMatch('/^libmemcached version => (?<version>.+)$/im', $info, $matches)) {
  30152. $this->addLibrary($name.'-libmemcached', $matches['version'], 'libmemcached version');
  30153. }
  30154. break;
  30155. case 'openssl':
  30156. if (Preg::isMatchStrictGroups('{^(?:OpenSSL|LibreSSL)?\s*(?<version>\S+)}i', $this->runtime->getConstant('OPENSSL_VERSION_TEXT'), $matches)) {
  30157. $parsedVersion = Version::parseOpenssl($matches['version'], $isFips);
  30158. $this->addLibrary($name.($isFips ? '-fips' : ''), $parsedVersion, $this->runtime->getConstant('OPENSSL_VERSION_TEXT'), [], $isFips ? [$name] : []);
  30159. }
  30160. break;
  30161. case 'pcre':
  30162. $this->addLibrary($name, Preg::replace('{^(\S+).*}', '$1', $this->runtime->getConstant('PCRE_VERSION')));
  30163. $info = $this->runtime->getExtensionInfo($name);
  30164. if (Preg::isMatchStrictGroups('/^PCRE Unicode Version => (?<version>.+)$/im', $info, $pcreUnicodeMatches)) {
  30165. $this->addLibrary($name.'-unicode', $pcreUnicodeMatches['version'], 'PCRE Unicode version support');
  30166. }
  30167. break;
  30168. case 'mysqlnd':
  30169. case 'pdo_mysql':
  30170. $info = $this->runtime->getExtensionInfo($name);
  30171. if (Preg::isMatchStrictGroups('/^(?:Client API version|Version) => mysqlnd (?<version>.+?) /mi', $info, $matches)) {
  30172. $this->addLibrary($name.'-mysqlnd', $matches['version'], 'mysqlnd library version for '.$name);
  30173. }
  30174. break;
  30175. case 'mongodb':
  30176. $info = $this->runtime->getExtensionInfo($name);
  30177. if (Preg::isMatchStrictGroups('/^libmongoc bundled version => (?<version>.+)$/im', $info, $libmongocMatches)) {
  30178. $this->addLibrary($name.'-libmongoc', $libmongocMatches['version'], 'libmongoc version of mongodb');
  30179. }
  30180. if (Preg::isMatchStrictGroups('/^libbson bundled version => (?<version>.+)$/im', $info, $libbsonMatches)) {
  30181. $this->addLibrary($name.'-libbson', $libbsonMatches['version'], 'libbson version of mongodb');
  30182. }
  30183. break;
  30184. case 'pgsql':
  30185. if ($this->runtime->hasConstant('PGSQL_LIBPQ_VERSION')) {
  30186. $this->addLibrary('pgsql-libpq', $this->runtime->getConstant('PGSQL_LIBPQ_VERSION'), 'libpq for pgsql');
  30187. break;
  30188. }
  30189. case 'pdo_pgsql':
  30190. $info = $this->runtime->getExtensionInfo($name);
  30191. if (Preg::isMatch('/^PostgreSQL\(libpq\) Version => (?<version>.*)$/im', $info, $matches)) {
  30192. $this->addLibrary($name.'-libpq', $matches['version'], 'libpq for '.$name);
  30193. }
  30194. break;
  30195. case 'pq':
  30196. $info = $this->runtime->getExtensionInfo($name);
  30197. if (Preg::isMatch('/^libpq => (?<compiled>.+) => (?<linked>.+)$/im', $info, $matches)) {
  30198. $this->addLibrary($name.'-libpq', $matches['linked'], 'libpq for '.$name);
  30199. }
  30200. break;
  30201. case 'rdkafka':
  30202. if ($this->runtime->hasConstant('RD_KAFKA_VERSION')) {
  30203. $libRdKafkaVersionInt = $this->runtime->getConstant('RD_KAFKA_VERSION');
  30204. $this->addLibrary($name.'-librdkafka', sprintf('%d.%d.%d', ($libRdKafkaVersionInt & 0xFF000000) >> 24, ($libRdKafkaVersionInt & 0x00FF0000) >> 16, ($libRdKafkaVersionInt & 0x0000FF00) >> 8), 'librdkafka for '.$name);
  30205. }
  30206. break;
  30207. case 'libsodium':
  30208. case 'sodium':
  30209. if ($this->runtime->hasConstant('SODIUM_LIBRARY_VERSION')) {
  30210. $this->addLibrary('libsodium', $this->runtime->getConstant('SODIUM_LIBRARY_VERSION'));
  30211. }
  30212. break;
  30213. case 'sqlite3':
  30214. case 'pdo_sqlite':
  30215. $info = $this->runtime->getExtensionInfo($name);
  30216. if (Preg::isMatch('/^SQLite Library => (?<version>.+)$/im', $info, $matches)) {
  30217. $this->addLibrary($name.'-sqlite', $matches['version']);
  30218. }
  30219. break;
  30220. case 'ssh2':
  30221. $info = $this->runtime->getExtensionInfo($name);
  30222. if (Preg::isMatch('/^libssh2 version => (?<version>.+)$/im', $info, $matches)) {
  30223. $this->addLibrary($name.'-libssh2', $matches['version']);
  30224. }
  30225. break;
  30226. case 'xsl':
  30227. $this->addLibrary('libxslt', $this->runtime->getConstant('LIBXSLT_DOTTED_VERSION'), null, ['xsl']);
  30228. $info = $this->runtime->getExtensionInfo('xsl');
  30229. if (Preg::isMatch('/^libxslt compiled against libxml Version => (?<version>.+)$/im', $info, $matches)) {
  30230. $this->addLibrary('libxslt-libxml', $matches['version'], 'libxml version libxslt is compiled against');
  30231. }
  30232. break;
  30233. case 'yaml':
  30234. $info = $this->runtime->getExtensionInfo('yaml');
  30235. if (Preg::isMatch('/^LibYAML Version => (?<version>.+)$/im', $info, $matches)) {
  30236. $this->addLibrary($name.'-libyaml', $matches['version'], 'libyaml version of yaml');
  30237. }
  30238. break;
  30239. case 'zip':
  30240. if ($this->runtime->hasConstant('LIBZIP_VERSION', 'ZipArchive')) {
  30241. $this->addLibrary($name.'-libzip', $this->runtime->getConstant('LIBZIP_VERSION', 'ZipArchive'), null, ['zip']);
  30242. }
  30243. break;
  30244. case 'zlib':
  30245. if ($this->runtime->hasConstant('ZLIB_VERSION')) {
  30246. $this->addLibrary($name, $this->runtime->getConstant('ZLIB_VERSION'));
  30247. } elseif (Preg::isMatch('/^Linked Version => (?<version>.+)$/im', $this->runtime->getExtensionInfo($name), $matches)) {
  30248. $this->addLibrary($name, $matches['version']);
  30249. }
  30250. break;
  30251. default:
  30252. break;
  30253. }
  30254. }
  30255. $hhvmVersion = $this->hhvmDetector->getVersion();
  30256. if ($hhvmVersion) {
  30257. try {
  30258. $prettyVersion = $hhvmVersion;
  30259. $version = $this->versionParser->normalize($prettyVersion);
  30260. } catch (\UnexpectedValueException $e) {
  30261. $prettyVersion = Preg::replace('#^([^~+-]+).*$#', '$1', $hhvmVersion);
  30262. $version = $this->versionParser->normalize($prettyVersion);
  30263. }
  30264. $hhvm = new CompletePackage('hhvm', $version, $prettyVersion);
  30265. $hhvm->setDescription('The HHVM Runtime (64bit)');
  30266. $this->addPackage($hhvm);
  30267. }
  30268. }
  30269. public function addPackage(PackageInterface $package): void
  30270. {
  30271. if (!$package instanceof CompletePackage) {
  30272. throw new \UnexpectedValueException('Expected CompletePackage but got '.get_class($package));
  30273. }
  30274. if (isset($this->overrides[$package->getName()])) {
  30275. if ($this->overrides[$package->getName()]['version'] === false) {
  30276. $this->addDisabledPackage($package);
  30277. return;
  30278. }
  30279. $overrider = $this->findPackage($package->getName(), '*');
  30280. if ($package->getVersion() === $overrider->getVersion()) {
  30281. $actualText = 'same as actual';
  30282. } else {
  30283. $actualText = 'actual: '.$package->getPrettyVersion();
  30284. }
  30285. if ($overrider instanceof CompletePackageInterface) {
  30286. $overrider->setDescription($overrider->getDescription().', '.$actualText);
  30287. }
  30288. return;
  30289. }
  30290. if (isset($this->overrides['php']) && 0 === strpos($package->getName(), 'php-')) {
  30291. $overrider = $this->addOverriddenPackage($this->overrides['php'], $package->getPrettyName());
  30292. if ($package->getVersion() === $overrider->getVersion()) {
  30293. $actualText = 'same as actual';
  30294. } else {
  30295. $actualText = 'actual: '.$package->getPrettyVersion();
  30296. }
  30297. $overrider->setDescription($overrider->getDescription().', '.$actualText);
  30298. return;
  30299. }
  30300. parent::addPackage($package);
  30301. }
  30302. private function addOverriddenPackage(array $override, ?string $name = null): CompletePackage
  30303. {
  30304. $version = $this->versionParser->normalize($override['version']);
  30305. $package = new CompletePackage($name ?: $override['name'], $version, $override['version']);
  30306. $package->setDescription('Package overridden via config.platform');
  30307. $package->setExtra(['config.platform' => true]);
  30308. parent::addPackage($package);
  30309. if ($package->getName() === 'php') {
  30310. self::$lastSeenPlatformPhp = implode('.', array_slice(explode('.', $package->getVersion()), 0, 3));
  30311. }
  30312. return $package;
  30313. }
  30314. private function addDisabledPackage(CompletePackage $package): void
  30315. {
  30316. $package->setDescription($package->getDescription().'. <warning>Package disabled via config.platform</warning>');
  30317. $package->setExtra(['config.platform' => true]);
  30318. $this->disabledPackages[$package->getName()] = $package;
  30319. }
  30320. private function addExtension(string $name, string $prettyVersion): void
  30321. {
  30322. $extraDescription = null;
  30323. try {
  30324. $version = $this->versionParser->normalize($prettyVersion);
  30325. } catch (\UnexpectedValueException $e) {
  30326. $extraDescription = ' (actual version: '.$prettyVersion.')';
  30327. if (Preg::isMatchStrictGroups('{^(\d+\.\d+\.\d+(?:\.\d+)?)}', $prettyVersion, $match)) {
  30328. $prettyVersion = $match[1];
  30329. } else {
  30330. $prettyVersion = '0';
  30331. }
  30332. $version = $this->versionParser->normalize($prettyVersion);
  30333. }
  30334. $packageName = $this->buildPackageName($name);
  30335. $ext = new CompletePackage($packageName, $version, $prettyVersion);
  30336. $ext->setDescription('The '.$name.' PHP extension'.$extraDescription);
  30337. if ($name === 'uuid') {
  30338. $ext->setReplaces([
  30339. 'lib-uuid' => new Link('ext-uuid', 'lib-uuid', new Constraint('=', $version), Link::TYPE_REPLACE, $ext->getPrettyVersion()),
  30340. ]);
  30341. }
  30342. $this->addPackage($ext);
  30343. }
  30344. private function buildPackageName(string $name): string
  30345. {
  30346. return 'ext-' . str_replace(' ', '-', strtolower($name));
  30347. }
  30348. private function addLibrary(string $name, ?string $prettyVersion, ?string $description = null, array $replaces = [], array $provides = []): void
  30349. {
  30350. if (null === $prettyVersion) {
  30351. return;
  30352. }
  30353. try {
  30354. $version = $this->versionParser->normalize($prettyVersion);
  30355. } catch (\UnexpectedValueException $e) {
  30356. return;
  30357. }
  30358. if ($description === null) {
  30359. $description = 'The '.$name.' library';
  30360. }
  30361. $lib = new CompletePackage('lib-'.$name, $version, $prettyVersion);
  30362. $lib->setDescription($description);
  30363. $replaceLinks = [];
  30364. foreach ($replaces as $replace) {
  30365. $replace = strtolower($replace);
  30366. $replaceLinks[$replace] = new Link('lib-'.$name, 'lib-'.$replace, new Constraint('=', $version), Link::TYPE_REPLACE, $lib->getPrettyVersion());
  30367. }
  30368. $provideLinks = [];
  30369. foreach ($provides as $provide) {
  30370. $provide = strtolower($provide);
  30371. $provideLinks[$provide] = new Link('lib-'.$name, 'lib-'.$provide, new Constraint('=', $version), Link::TYPE_PROVIDE, $lib->getPrettyVersion());
  30372. }
  30373. $lib->setReplaces($replaceLinks);
  30374. $lib->setProvides($provideLinks);
  30375. $this->addPackage($lib);
  30376. }
  30377. public static function isPlatformPackage(string $name): bool
  30378. {
  30379. static $cache = [];
  30380. if (isset($cache[$name])) {
  30381. return $cache[$name];
  30382. }
  30383. return $cache[$name] = Preg::isMatch(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name);
  30384. }
  30385. public static function getPlatformPhpVersion(): ?string
  30386. {
  30387. return self::$lastSeenPlatformPhp;
  30388. }
  30389. public function search(string $query, int $mode = 0, ?string $type = null): array
  30390. {
  30391. if ($mode === self::SEARCH_VENDOR) {
  30392. return [];
  30393. }
  30394. return parent::search($query, $mode, $type);
  30395. }
  30396. }
  30397. <?php declare(strict_types=1);
  30398. namespace Composer\Repository;
  30399. use Composer\Factory;
  30400. use Composer\IO\IOInterface;
  30401. use Composer\Config;
  30402. use Composer\EventDispatcher\EventDispatcher;
  30403. use Composer\Pcre\Preg;
  30404. use Composer\Util\HttpDownloader;
  30405. use Composer\Util\ProcessExecutor;
  30406. use Composer\Json\JsonFile;
  30407. class RepositoryFactory
  30408. {
  30409. public static function configFromString(IOInterface $io, Config $config, string $repository, bool $allowFilesystem = false)
  30410. {
  30411. if (0 === strpos($repository, 'http')) {
  30412. $repoConfig = ['type' => 'composer', 'url' => $repository];
  30413. } elseif ("json" === pathinfo($repository, PATHINFO_EXTENSION)) {
  30414. $json = new JsonFile($repository, Factory::createHttpDownloader($io, $config));
  30415. $data = $json->read();
  30416. if (!empty($data['packages']) || !empty($data['includes']) || !empty($data['provider-includes'])) {
  30417. $repoConfig = ['type' => 'composer', 'url' => 'file://' . strtr(realpath($repository), '\\', '/')];
  30418. } elseif ($allowFilesystem) {
  30419. $repoConfig = ['type' => 'filesystem', 'json' => $json];
  30420. } else {
  30421. throw new \InvalidArgumentException("Invalid repository URL ($repository) given. This file does not contain a valid composer repository.");
  30422. }
  30423. } elseif (strpos($repository, '{') === 0) {
  30424. $repoConfig = JsonFile::parseJson($repository);
  30425. } else {
  30426. throw new \InvalidArgumentException("Invalid repository url ($repository) given. Has to be a .json file, an http url or a JSON object.");
  30427. }
  30428. return $repoConfig;
  30429. }
  30430. public static function fromString(IOInterface $io, Config $config, string $repository, bool $allowFilesystem = false, ?RepositoryManager $rm = null): RepositoryInterface
  30431. {
  30432. $repoConfig = static::configFromString($io, $config, $repository, $allowFilesystem);
  30433. return static::createRepo($io, $config, $repoConfig, $rm);
  30434. }
  30435. public static function createRepo(IOInterface $io, Config $config, array $repoConfig, ?RepositoryManager $rm = null): RepositoryInterface
  30436. {
  30437. if (!$rm) {
  30438. @trigger_error('Not passing a repository manager when calling createRepo is deprecated since Composer 2.3.6', E_USER_DEPRECATED);
  30439. $rm = static::manager($io, $config);
  30440. }
  30441. $repos = self::createRepos($rm, [$repoConfig]);
  30442. return reset($repos);
  30443. }
  30444. public static function defaultRepos(?IOInterface $io = null, ?Config $config = null, ?RepositoryManager $rm = null): array
  30445. {
  30446. if (null === $rm) {
  30447. @trigger_error('Not passing a repository manager when calling defaultRepos is deprecated since Composer 2.3.6, use defaultReposWithDefaultManager() instead if you cannot get a manager.', E_USER_DEPRECATED);
  30448. }
  30449. if (null === $config) {
  30450. $config = Factory::createConfig($io);
  30451. }
  30452. if (null !== $io) {
  30453. $io->loadConfiguration($config);
  30454. }
  30455. if (null === $rm) {
  30456. if (null === $io) {
  30457. throw new \InvalidArgumentException('This function requires either an IOInterface or a RepositoryManager');
  30458. }
  30459. $rm = static::manager($io, $config, Factory::createHttpDownloader($io, $config));
  30460. }
  30461. return self::createRepos($rm, $config->getRepositories());
  30462. }
  30463. public static function manager(IOInterface $io, Config $config, ?HttpDownloader $httpDownloader = null, ?EventDispatcher $eventDispatcher = null, ?ProcessExecutor $process = null): RepositoryManager
  30464. {
  30465. if ($httpDownloader === null) {
  30466. $httpDownloader = Factory::createHttpDownloader($io, $config);
  30467. }
  30468. if ($process === null) {
  30469. $process = new ProcessExecutor($io);
  30470. $process->enableAsync();
  30471. }
  30472. $rm = new RepositoryManager($io, $config, $httpDownloader, $eventDispatcher, $process);
  30473. $rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
  30474. $rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository');
  30475. $rm->setRepositoryClass('package', 'Composer\Repository\PackageRepository');
  30476. $rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
  30477. $rm->setRepositoryClass('git', 'Composer\Repository\VcsRepository');
  30478. $rm->setRepositoryClass('bitbucket', 'Composer\Repository\VcsRepository');
  30479. $rm->setRepositoryClass('git-bitbucket', 'Composer\Repository\VcsRepository');
  30480. $rm->setRepositoryClass('github', 'Composer\Repository\VcsRepository');
  30481. $rm->setRepositoryClass('gitlab', 'Composer\Repository\VcsRepository');
  30482. $rm->setRepositoryClass('svn', 'Composer\Repository\VcsRepository');
  30483. $rm->setRepositoryClass('fossil', 'Composer\Repository\VcsRepository');
  30484. $rm->setRepositoryClass('perforce', 'Composer\Repository\VcsRepository');
  30485. $rm->setRepositoryClass('hg', 'Composer\Repository\VcsRepository');
  30486. $rm->setRepositoryClass('artifact', 'Composer\Repository\ArtifactRepository');
  30487. $rm->setRepositoryClass('path', 'Composer\Repository\PathRepository');
  30488. return $rm;
  30489. }
  30490. public static function defaultReposWithDefaultManager(IOInterface $io): array
  30491. {
  30492. $manager = RepositoryFactory::manager($io, $config = Factory::createConfig($io));
  30493. $io->loadConfiguration($config);
  30494. return RepositoryFactory::defaultRepos($io, $config, $manager);
  30495. }
  30496. private static function createRepos(RepositoryManager $rm, array $repoConfigs): array
  30497. {
  30498. $repos = [];
  30499. foreach ($repoConfigs as $index => $repo) {
  30500. if (is_string($repo)) {
  30501. throw new \UnexpectedValueException('"repositories" should be an array of repository definitions, only a single repository was given');
  30502. }
  30503. if (!is_array($repo)) {
  30504. throw new \UnexpectedValueException('Repository "'.$index.'" ('.json_encode($repo).') should be an array, '.gettype($repo).' given');
  30505. }
  30506. if (!isset($repo['type'])) {
  30507. throw new \UnexpectedValueException('Repository "'.$index.'" ('.json_encode($repo).') must have a type defined');
  30508. }
  30509. $name = self::generateRepositoryName($index, $repo, $repos);
  30510. if ($repo['type'] === 'filesystem') {
  30511. $repos[$name] = new FilesystemRepository($repo['json']);
  30512. } else {
  30513. $repos[$name] = $rm->createRepository($repo['type'], $repo, (string) $index);
  30514. }
  30515. }
  30516. return $repos;
  30517. }
  30518. public static function generateRepositoryName($index, array $repo, array $existingRepos): string
  30519. {
  30520. $name = is_int($index) && isset($repo['url']) ? Preg::replace('{^https?://}i', '', $repo['url']) : (string) $index;
  30521. while (isset($existingRepos[$name])) {
  30522. $name .= '2';
  30523. }
  30524. return $name;
  30525. }
  30526. }
  30527. <?php declare(strict_types=1);
  30528. namespace Composer\Repository;
  30529. use Composer\Package\PackageInterface;
  30530. use Composer\Package\BasePackage;
  30531. use Composer\Semver\Constraint\ConstraintInterface;
  30532. interface RepositoryInterface extends \Countable
  30533. {
  30534. public const SEARCH_FULLTEXT = 0;
  30535. public const SEARCH_NAME = 1;
  30536. public const SEARCH_VENDOR = 2;
  30537. public function hasPackage(PackageInterface $package);
  30538. public function findPackage(string $name, $constraint);
  30539. public function findPackages(string $name, $constraint = null);
  30540. public function getPackages();
  30541. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = []);
  30542. public function search(string $query, int $mode = 0, ?string $type = null);
  30543. public function getProviders(string $packageName);
  30544. public function getRepoName();
  30545. }
  30546. <?php declare(strict_types=1);
  30547. namespace Composer\Repository;
  30548. use Composer\IO\IOInterface;
  30549. use Composer\Config;
  30550. use Composer\EventDispatcher\EventDispatcher;
  30551. use Composer\Package\PackageInterface;
  30552. use Composer\Util\HttpDownloader;
  30553. use Composer\Util\ProcessExecutor;
  30554. class RepositoryManager
  30555. {
  30556. private $localRepository;
  30557. private $repositories = [];
  30558. private $repositoryClasses = [];
  30559. private $io;
  30560. private $config;
  30561. private $httpDownloader;
  30562. private $eventDispatcher;
  30563. private $process;
  30564. public function __construct(IOInterface $io, Config $config, HttpDownloader $httpDownloader, ?EventDispatcher $eventDispatcher = null, ?ProcessExecutor $process = null)
  30565. {
  30566. $this->io = $io;
  30567. $this->config = $config;
  30568. $this->httpDownloader = $httpDownloader;
  30569. $this->eventDispatcher = $eventDispatcher;
  30570. $this->process = $process ?? new ProcessExecutor($io);
  30571. }
  30572. public function findPackage(string $name, $constraint): ?PackageInterface
  30573. {
  30574. foreach ($this->repositories as $repository) {
  30575. if ($package = $repository->findPackage($name, $constraint)) {
  30576. return $package;
  30577. }
  30578. }
  30579. return null;
  30580. }
  30581. public function findPackages(string $name, $constraint): array
  30582. {
  30583. $packages = [];
  30584. foreach ($this->getRepositories() as $repository) {
  30585. $packages = array_merge($packages, $repository->findPackages($name, $constraint));
  30586. }
  30587. return $packages;
  30588. }
  30589. public function addRepository(RepositoryInterface $repository): void
  30590. {
  30591. $this->repositories[] = $repository;
  30592. }
  30593. public function prependRepository(RepositoryInterface $repository): void
  30594. {
  30595. array_unshift($this->repositories, $repository);
  30596. }
  30597. public function createRepository(string $type, array $config, ?string $name = null): RepositoryInterface
  30598. {
  30599. if (!isset($this->repositoryClasses[$type])) {
  30600. throw new \InvalidArgumentException('Repository type is not registered: '.$type);
  30601. }
  30602. if (isset($config['packagist']) && false === $config['packagist']) {
  30603. $this->io->writeError('<warning>Repository "'.$name.'" ('.json_encode($config).') has a packagist key which should be in its own repository definition</warning>');
  30604. }
  30605. $class = $this->repositoryClasses[$type];
  30606. if (isset($config['only']) || isset($config['exclude']) || isset($config['canonical'])) {
  30607. $filterConfig = $config;
  30608. unset($config['only'], $config['exclude'], $config['canonical']);
  30609. }
  30610. $repository = new $class($config, $this->io, $this->config, $this->httpDownloader, $this->eventDispatcher, $this->process);
  30611. if (isset($filterConfig)) {
  30612. $repository = new FilterRepository($repository, $filterConfig);
  30613. }
  30614. return $repository;
  30615. }
  30616. public function setRepositoryClass(string $type, $class): void
  30617. {
  30618. $this->repositoryClasses[$type] = $class;
  30619. }
  30620. public function getRepositories(): array
  30621. {
  30622. return $this->repositories;
  30623. }
  30624. public function setLocalRepository(InstalledRepositoryInterface $repository): void
  30625. {
  30626. $this->localRepository = $repository;
  30627. }
  30628. public function getLocalRepository(): InstalledRepositoryInterface
  30629. {
  30630. return $this->localRepository;
  30631. }
  30632. }
  30633. <?php declare(strict_types=1);
  30634. namespace Composer\Repository;
  30635. class RepositorySecurityException extends \Exception
  30636. {
  30637. }
  30638. <?php declare(strict_types=1);
  30639. namespace Composer\Repository;
  30640. use Composer\DependencyResolver\PoolOptimizer;
  30641. use Composer\DependencyResolver\Pool;
  30642. use Composer\DependencyResolver\PoolBuilder;
  30643. use Composer\DependencyResolver\Request;
  30644. use Composer\EventDispatcher\EventDispatcher;
  30645. use Composer\Advisory\SecurityAdvisory;
  30646. use Composer\Advisory\PartialSecurityAdvisory;
  30647. use Composer\IO\IOInterface;
  30648. use Composer\IO\NullIO;
  30649. use Composer\Package\BasePackage;
  30650. use Composer\Package\AliasPackage;
  30651. use Composer\Package\CompleteAliasPackage;
  30652. use Composer\Package\CompletePackage;
  30653. use Composer\Package\PackageInterface;
  30654. use Composer\Semver\Constraint\Constraint;
  30655. use Composer\Semver\Constraint\ConstraintInterface;
  30656. use Composer\Package\Version\StabilityFilter;
  30657. use Composer\Semver\Constraint\MatchAllConstraint;
  30658. class RepositorySet
  30659. {
  30660. public const ALLOW_UNACCEPTABLE_STABILITIES = 1;
  30661. public const ALLOW_SHADOWED_REPOSITORIES = 2;
  30662. private $rootAliases;
  30663. private $rootReferences;
  30664. private $repositories = [];
  30665. private $acceptableStabilities;
  30666. private $stabilityFlags;
  30667. private $rootRequires;
  30668. private $temporaryConstraints;
  30669. private $locked = false;
  30670. private $allowInstalledRepositories = false;
  30671. public function __construct(string $minimumStability = 'stable', array $stabilityFlags = [], array $rootAliases = [], array $rootReferences = [], array $rootRequires = [], array $temporaryConstraints = [])
  30672. {
  30673. $this->rootAliases = self::getRootAliasesPerPackage($rootAliases);
  30674. $this->rootReferences = $rootReferences;
  30675. $this->acceptableStabilities = [];
  30676. foreach (BasePackage::$stabilities as $stability => $value) {
  30677. if ($value <= BasePackage::$stabilities[$minimumStability]) {
  30678. $this->acceptableStabilities[$stability] = $value;
  30679. }
  30680. }
  30681. $this->stabilityFlags = $stabilityFlags;
  30682. $this->rootRequires = $rootRequires;
  30683. foreach ($rootRequires as $name => $constraint) {
  30684. if (PlatformRepository::isPlatformPackage($name)) {
  30685. unset($this->rootRequires[$name]);
  30686. }
  30687. }
  30688. $this->temporaryConstraints = $temporaryConstraints;
  30689. }
  30690. public function allowInstalledRepositories(bool $allow = true): void
  30691. {
  30692. $this->allowInstalledRepositories = $allow;
  30693. }
  30694. public function getRootRequires(): array
  30695. {
  30696. return $this->rootRequires;
  30697. }
  30698. public function getTemporaryConstraints(): array
  30699. {
  30700. return $this->temporaryConstraints;
  30701. }
  30702. public function addRepository(RepositoryInterface $repo): void
  30703. {
  30704. if ($this->locked) {
  30705. throw new \RuntimeException("Pool has already been created from this repository set, it cannot be modified anymore.");
  30706. }
  30707. if ($repo instanceof CompositeRepository) {
  30708. $repos = $repo->getRepositories();
  30709. } else {
  30710. $repos = [$repo];
  30711. }
  30712. foreach ($repos as $repo) {
  30713. $this->repositories[] = $repo;
  30714. }
  30715. }
  30716. public function findPackages(string $name, ?ConstraintInterface $constraint = null, int $flags = 0): array
  30717. {
  30718. $ignoreStability = ($flags & self::ALLOW_UNACCEPTABLE_STABILITIES) !== 0;
  30719. $loadFromAllRepos = ($flags & self::ALLOW_SHADOWED_REPOSITORIES) !== 0;
  30720. $packages = [];
  30721. if ($loadFromAllRepos) {
  30722. foreach ($this->repositories as $repository) {
  30723. $packages[] = $repository->findPackages($name, $constraint) ?: [];
  30724. }
  30725. } else {
  30726. foreach ($this->repositories as $repository) {
  30727. $result = $repository->loadPackages([$name => $constraint], $ignoreStability ? BasePackage::$stabilities : $this->acceptableStabilities, $ignoreStability ? [] : $this->stabilityFlags);
  30728. $packages[] = $result['packages'];
  30729. foreach ($result['namesFound'] as $nameFound) {
  30730. if ($name === $nameFound) {
  30731. break 2;
  30732. }
  30733. }
  30734. }
  30735. }
  30736. $candidates = $packages ? array_merge(...$packages) : [];
  30737. if ($ignoreStability || !$loadFromAllRepos) {
  30738. return $candidates;
  30739. }
  30740. $result = [];
  30741. foreach ($candidates as $candidate) {
  30742. if ($this->isPackageAcceptable($candidate->getNames(), $candidate->getStability())) {
  30743. $result[] = $candidate;
  30744. }
  30745. }
  30746. return $result;
  30747. }
  30748. public function getSecurityAdvisories(array $packageNames, bool $allowPartialAdvisories = false): array
  30749. {
  30750. $map = [];
  30751. foreach ($packageNames as $name) {
  30752. $map[$name] = new MatchAllConstraint();
  30753. }
  30754. return $this->getSecurityAdvisoriesForConstraints($map, $allowPartialAdvisories);
  30755. }
  30756. public function getMatchingSecurityAdvisories(array $packages, bool $allowPartialAdvisories = false): array
  30757. {
  30758. $map = [];
  30759. foreach ($packages as $package) {
  30760. $map[$package->getName()] = new Constraint('=', $package->getVersion());
  30761. }
  30762. return $this->getSecurityAdvisoriesForConstraints($map, $allowPartialAdvisories);
  30763. }
  30764. private function getSecurityAdvisoriesForConstraints(array $packageConstraintMap, bool $allowPartialAdvisories): array
  30765. {
  30766. $repoAdvisories = [];
  30767. foreach ($this->repositories as $repository) {
  30768. if (!$repository instanceof AdvisoryProviderInterface || !$repository->hasSecurityAdvisories()) {
  30769. continue;
  30770. }
  30771. $repoAdvisories[] = $repository->getSecurityAdvisories($packageConstraintMap, $allowPartialAdvisories)['advisories'];
  30772. }
  30773. $advisories = array_merge_recursive([], ...$repoAdvisories);
  30774. ksort($advisories);
  30775. return $advisories;
  30776. }
  30777. public function getProviders(string $packageName): array
  30778. {
  30779. $providers = [];
  30780. foreach ($this->repositories as $repository) {
  30781. if ($repoProviders = $repository->getProviders($packageName)) {
  30782. $providers = array_merge($providers, $repoProviders);
  30783. }
  30784. }
  30785. return $providers;
  30786. }
  30787. public function isPackageAcceptable(array $names, string $stability): bool
  30788. {
  30789. return StabilityFilter::isPackageAcceptable($this->acceptableStabilities, $this->stabilityFlags, $names, $stability);
  30790. }
  30791. public function createPool(Request $request, IOInterface $io, ?EventDispatcher $eventDispatcher = null, ?PoolOptimizer $poolOptimizer = null): Pool
  30792. {
  30793. $poolBuilder = new PoolBuilder($this->acceptableStabilities, $this->stabilityFlags, $this->rootAliases, $this->rootReferences, $io, $eventDispatcher, $poolOptimizer, $this->temporaryConstraints);
  30794. foreach ($this->repositories as $repo) {
  30795. if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) {
  30796. throw new \LogicException('The pool can not accept packages from an installed repository');
  30797. }
  30798. }
  30799. $this->locked = true;
  30800. return $poolBuilder->buildPool($this->repositories, $request);
  30801. }
  30802. public function createPoolWithAllPackages(): Pool
  30803. {
  30804. foreach ($this->repositories as $repo) {
  30805. if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) {
  30806. throw new \LogicException('The pool can not accept packages from an installed repository');
  30807. }
  30808. }
  30809. $this->locked = true;
  30810. $packages = [];
  30811. foreach ($this->repositories as $repository) {
  30812. foreach ($repository->getPackages() as $package) {
  30813. $packages[] = $package;
  30814. if (isset($this->rootAliases[$package->getName()][$package->getVersion()])) {
  30815. $alias = $this->rootAliases[$package->getName()][$package->getVersion()];
  30816. while ($package instanceof AliasPackage) {
  30817. $package = $package->getAliasOf();
  30818. }
  30819. if ($package instanceof CompletePackage) {
  30820. $aliasPackage = new CompleteAliasPackage($package, $alias['alias_normalized'], $alias['alias']);
  30821. } else {
  30822. $aliasPackage = new AliasPackage($package, $alias['alias_normalized'], $alias['alias']);
  30823. }
  30824. $aliasPackage->setRootPackageAlias(true);
  30825. $packages[] = $aliasPackage;
  30826. }
  30827. }
  30828. }
  30829. return new Pool($packages);
  30830. }
  30831. public function createPoolForPackage(string $packageName, ?LockArrayRepository $lockedRepo = null): Pool
  30832. {
  30833. return $this->createPoolForPackages([$packageName], $lockedRepo);
  30834. }
  30835. public function createPoolForPackages(array $packageNames, ?LockArrayRepository $lockedRepo = null): Pool
  30836. {
  30837. $request = new Request($lockedRepo);
  30838. $allowedPackages = [];
  30839. foreach ($packageNames as $packageName) {
  30840. if (PlatformRepository::isPlatformPackage($packageName)) {
  30841. 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.');
  30842. }
  30843. $request->requireName($packageName);
  30844. $allowedPackages[] = strtolower($packageName);
  30845. }
  30846. if (count($allowedPackages) > 0) {
  30847. $request->restrictPackages($allowedPackages);
  30848. }
  30849. return $this->createPool($request, new NullIO());
  30850. }
  30851. private static function getRootAliasesPerPackage(array $aliases): array
  30852. {
  30853. $normalizedAliases = [];
  30854. foreach ($aliases as $alias) {
  30855. $normalizedAliases[$alias['package']][$alias['version']] = [
  30856. 'alias' => $alias['alias'],
  30857. 'alias_normalized' => $alias['alias_normalized'],
  30858. ];
  30859. }
  30860. return $normalizedAliases;
  30861. }
  30862. }
  30863. <?php declare(strict_types=1);
  30864. namespace Composer\Repository;
  30865. use Composer\Package\PackageInterface;
  30866. class RepositoryUtils
  30867. {
  30868. public static function filterRequiredPackages(array $packages, PackageInterface $requirer, array $bucket = []): array
  30869. {
  30870. $requires = $requirer->getRequires();
  30871. foreach ($packages as $candidate) {
  30872. foreach ($candidate->getNames() as $name) {
  30873. if (isset($requires[$name])) {
  30874. if (!in_array($candidate, $bucket, true)) {
  30875. $bucket[] = $candidate;
  30876. $bucket = self::filterRequiredPackages($packages, $candidate, $bucket);
  30877. }
  30878. break;
  30879. }
  30880. }
  30881. }
  30882. return $bucket;
  30883. }
  30884. public static function flattenRepositories(RepositoryInterface $repo, bool $unwrapFilterRepos = true): array
  30885. {
  30886. if ($unwrapFilterRepos && $repo instanceof FilterRepository) {
  30887. $repo = $repo->getRepository();
  30888. }
  30889. if (!$repo instanceof CompositeRepository) {
  30890. return [$repo];
  30891. }
  30892. $repos = [];
  30893. foreach ($repo->getRepositories() as $r) {
  30894. foreach (self::flattenRepositories($r, $unwrapFilterRepos) as $r2) {
  30895. $repos[] = $r2;
  30896. }
  30897. }
  30898. return $repos;
  30899. }
  30900. }
  30901. <?php declare(strict_types=1);
  30902. namespace Composer\Repository;
  30903. use Composer\Package\RootPackageInterface;
  30904. class RootPackageRepository extends ArrayRepository
  30905. {
  30906. public function __construct(RootPackageInterface $package)
  30907. {
  30908. parent::__construct([$package]);
  30909. }
  30910. public function getRepoName(): string
  30911. {
  30912. return 'root package repo';
  30913. }
  30914. }
  30915. <?php declare(strict_types=1);
  30916. namespace Composer\Repository\Vcs;
  30917. use Composer\Cache;
  30918. use Composer\Config;
  30919. use Composer\Pcre\Preg;
  30920. use Composer\Util\ProcessExecutor;
  30921. use Composer\Util\Filesystem;
  30922. use Composer\IO\IOInterface;
  30923. class FossilDriver extends VcsDriver
  30924. {
  30925. protected $tags;
  30926. protected $branches;
  30927. protected $rootIdentifier = null;
  30928. protected $repoFile = null;
  30929. protected $checkoutDir;
  30930. public function initialize(): void
  30931. {
  30932. $this->checkFossil();
  30933. $this->config->prohibitUrlByConfig($this->url, $this->io);
  30934. if (Filesystem::isLocalPath($this->url) && is_dir($this->url)) {
  30935. $this->checkoutDir = $this->url;
  30936. } else {
  30937. if (!Cache::isUsable($this->config->get('cache-repo-dir')) || !Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  30938. throw new \RuntimeException('FossilDriver requires a usable cache directory, and it looks like you set it to be disabled');
  30939. }
  30940. $localName = Preg::replace('{[^a-z0-9]}i', '-', $this->url);
  30941. $this->repoFile = $this->config->get('cache-repo-dir') . '/' . $localName . '.fossil';
  30942. $this->checkoutDir = $this->config->get('cache-vcs-dir') . '/' . $localName . '/';
  30943. $this->updateLocalRepo();
  30944. }
  30945. $this->getTags();
  30946. $this->getBranches();
  30947. }
  30948. protected function checkFossil(): void
  30949. {
  30950. if (0 !== $this->process->execute('fossil version', $ignoredOutput)) {
  30951. throw new \RuntimeException("fossil was not found, check that it is installed and in your PATH env.\n\n" . $this->process->getErrorOutput());
  30952. }
  30953. }
  30954. protected function updateLocalRepo(): void
  30955. {
  30956. $fs = new Filesystem();
  30957. $fs->ensureDirectoryExists($this->checkoutDir);
  30958. if (!is_writable(dirname($this->checkoutDir))) {
  30959. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.$this->checkoutDir.'" directory is not writable by the current user.');
  30960. }
  30961. if (is_file($this->repoFile) && is_dir($this->checkoutDir) && 0 === $this->process->execute('fossil info', $output, $this->checkoutDir)) {
  30962. if (0 !== $this->process->execute('fossil pull', $output, $this->checkoutDir)) {
  30963. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')</error>');
  30964. }
  30965. } else {
  30966. $fs->removeDirectory($this->checkoutDir);
  30967. $fs->remove($this->repoFile);
  30968. $fs->ensureDirectoryExists($this->checkoutDir);
  30969. if (0 !== $this->process->execute(sprintf('fossil clone -- %s %s', ProcessExecutor::escape($this->url), ProcessExecutor::escape($this->repoFile)), $output)) {
  30970. $output = $this->process->getErrorOutput();
  30971. throw new \RuntimeException('Failed to clone '.$this->url.' to repository ' . $this->repoFile . "\n\n" .$output);
  30972. }
  30973. if (0 !== $this->process->execute(sprintf('fossil open --nested -- %s', ProcessExecutor::escape($this->repoFile)), $output, $this->checkoutDir)) {
  30974. $output = $this->process->getErrorOutput();
  30975. throw new \RuntimeException('Failed to open repository '.$this->repoFile.' in ' . $this->checkoutDir . "\n\n" .$output);
  30976. }
  30977. }
  30978. }
  30979. public function getRootIdentifier(): string
  30980. {
  30981. if (null === $this->rootIdentifier) {
  30982. $this->rootIdentifier = 'trunk';
  30983. }
  30984. return $this->rootIdentifier;
  30985. }
  30986. public function getUrl(): string
  30987. {
  30988. return $this->url;
  30989. }
  30990. public function getSource(string $identifier): array
  30991. {
  30992. return ['type' => 'fossil', 'url' => $this->getUrl(), 'reference' => $identifier];
  30993. }
  30994. public function getDist(string $identifier): ?array
  30995. {
  30996. return null;
  30997. }
  30998. public function getFileContent(string $file, string $identifier): ?string
  30999. {
  31000. $command = sprintf('fossil cat -r %s -- %s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  31001. $this->process->execute($command, $content, $this->checkoutDir);
  31002. if (!trim($content)) {
  31003. return null;
  31004. }
  31005. return $content;
  31006. }
  31007. public function getChangeDate(string $identifier): ?\DateTimeImmutable
  31008. {
  31009. $this->process->execute('fossil finfo -b -n 1 composer.json', $output, $this->checkoutDir);
  31010. [, $date] = explode(' ', trim($output), 3);
  31011. return new \DateTimeImmutable($date, new \DateTimeZone('UTC'));
  31012. }
  31013. public function getTags(): array
  31014. {
  31015. if (null === $this->tags) {
  31016. $tags = [];
  31017. $this->process->execute('fossil tag list', $output, $this->checkoutDir);
  31018. foreach ($this->process->splitLines($output) as $tag) {
  31019. $tags[$tag] = $tag;
  31020. }
  31021. $this->tags = $tags;
  31022. }
  31023. return $this->tags;
  31024. }
  31025. public function getBranches(): array
  31026. {
  31027. if (null === $this->branches) {
  31028. $branches = [];
  31029. $this->process->execute('fossil branch list', $output, $this->checkoutDir);
  31030. foreach ($this->process->splitLines($output) as $branch) {
  31031. $branch = trim(Preg::replace('/^\*/', '', trim($branch)));
  31032. $branches[$branch] = $branch;
  31033. }
  31034. $this->branches = $branches;
  31035. }
  31036. return $this->branches;
  31037. }
  31038. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
  31039. {
  31040. if (Preg::isMatch('#(^(?:https?|ssh)://(?:[^@]@)?(?:chiselapp\.com|fossil\.))#i', $url)) {
  31041. return true;
  31042. }
  31043. if (Preg::isMatch('!/fossil/|\.fossil!', $url)) {
  31044. return true;
  31045. }
  31046. if (Filesystem::isLocalPath($url)) {
  31047. $url = Filesystem::getPlatformPath($url);
  31048. if (!is_dir($url)) {
  31049. return false;
  31050. }
  31051. $process = new ProcessExecutor($io);
  31052. if ($process->execute('fossil info', $output, $url) === 0) {
  31053. return true;
  31054. }
  31055. }
  31056. return false;
  31057. }
  31058. }
  31059. <?php declare(strict_types=1);
  31060. namespace Composer\Repository\Vcs;
  31061. use Composer\Config;
  31062. use Composer\IO\IOInterface;
  31063. use Composer\Cache;
  31064. use Composer\Downloader\TransportException;
  31065. use Composer\Json\JsonFile;
  31066. use Composer\Pcre\Preg;
  31067. use Composer\Util\Bitbucket;
  31068. use Composer\Util\Http\Response;
  31069. class GitBitbucketDriver extends VcsDriver
  31070. {
  31071. protected $owner;
  31072. protected $repository;
  31073. private $hasIssues = false;
  31074. private $rootIdentifier;
  31075. private $tags;
  31076. private $branches;
  31077. private $branchesUrl = '';
  31078. private $tagsUrl = '';
  31079. private $homeUrl = '';
  31080. private $website = '';
  31081. private $cloneHttpsUrl = '';
  31082. private $repoData;
  31083. protected $fallbackDriver = null;
  31084. private $vcsType;
  31085. public function initialize(): void
  31086. {
  31087. if (!Preg::isMatchStrictGroups('#^https?://bitbucket\.org/([^/]+)/([^/]+?)(?:\.git|/?)?$#i', $this->url, $match)) {
  31088. throw new \InvalidArgumentException(sprintf('The Bitbucket repository URL %s is invalid. It must be the HTTPS URL of a Bitbucket repository.', $this->url));
  31089. }
  31090. $this->owner = $match[1];
  31091. $this->repository = $match[2];
  31092. $this->originUrl = 'bitbucket.org';
  31093. $this->cache = new Cache(
  31094. $this->io,
  31095. implode('/', [
  31096. $this->config->get('cache-repo-dir'),
  31097. $this->originUrl,
  31098. $this->owner,
  31099. $this->repository,
  31100. ])
  31101. );
  31102. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  31103. }
  31104. public function getUrl(): string
  31105. {
  31106. if ($this->fallbackDriver) {
  31107. return $this->fallbackDriver->getUrl();
  31108. }
  31109. return $this->cloneHttpsUrl;
  31110. }
  31111. protected function getRepoData(): bool
  31112. {
  31113. $resource = sprintf(
  31114. 'https://api.bitbucket.org/2.0/repositories/%s/%s?%s',
  31115. $this->owner,
  31116. $this->repository,
  31117. http_build_query(
  31118. ['fields' => '-project,-owner'],
  31119. '',
  31120. '&'
  31121. )
  31122. );
  31123. $repoData = $this->fetchWithOAuthCredentials($resource, true)->decodeJson();
  31124. if ($this->fallbackDriver) {
  31125. return false;
  31126. }
  31127. $this->parseCloneUrls($repoData['links']['clone']);
  31128. $this->hasIssues = !empty($repoData['has_issues']);
  31129. $this->branchesUrl = $repoData['links']['branches']['href'];
  31130. $this->tagsUrl = $repoData['links']['tags']['href'];
  31131. $this->homeUrl = $repoData['links']['html']['href'];
  31132. $this->website = $repoData['website'];
  31133. $this->vcsType = $repoData['scm'];
  31134. $this->repoData = $repoData;
  31135. return true;
  31136. }
  31137. public function getComposerInformation(string $identifier): ?array
  31138. {
  31139. if ($this->fallbackDriver) {
  31140. return $this->fallbackDriver->getComposerInformation($identifier);
  31141. }
  31142. if (!isset($this->infoCache[$identifier])) {
  31143. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  31144. $composer = JsonFile::parseJson($res);
  31145. } else {
  31146. $composer = $this->getBaseComposerInformation($identifier);
  31147. if ($this->shouldCache($identifier)) {
  31148. $this->cache->write($identifier, json_encode($composer));
  31149. }
  31150. }
  31151. if ($composer !== null) {
  31152. if (isset($composer['support']) && !is_array($composer['support'])) {
  31153. $composer['support'] = [];
  31154. }
  31155. if (!isset($composer['support']['source'])) {
  31156. $label = array_search(
  31157. $identifier,
  31158. $this->getTags()
  31159. ) ?: array_search(
  31160. $identifier,
  31161. $this->getBranches()
  31162. ) ?: $identifier;
  31163. if (array_key_exists($label, $tags = $this->getTags())) {
  31164. $hash = $tags[$label];
  31165. } elseif (array_key_exists($label, $branches = $this->getBranches())) {
  31166. $hash = $branches[$label];
  31167. }
  31168. if (!isset($hash)) {
  31169. $composer['support']['source'] = sprintf(
  31170. 'https://%s/%s/%s/src',
  31171. $this->originUrl,
  31172. $this->owner,
  31173. $this->repository
  31174. );
  31175. } else {
  31176. $composer['support']['source'] = sprintf(
  31177. 'https://%s/%s/%s/src/%s/?at=%s',
  31178. $this->originUrl,
  31179. $this->owner,
  31180. $this->repository,
  31181. $hash,
  31182. $label
  31183. );
  31184. }
  31185. }
  31186. if (!isset($composer['support']['issues']) && $this->hasIssues) {
  31187. $composer['support']['issues'] = sprintf(
  31188. 'https://%s/%s/%s/issues',
  31189. $this->originUrl,
  31190. $this->owner,
  31191. $this->repository
  31192. );
  31193. }
  31194. if (!isset($composer['homepage'])) {
  31195. $composer['homepage'] = empty($this->website) ? $this->homeUrl : $this->website;
  31196. }
  31197. }
  31198. $this->infoCache[$identifier] = $composer;
  31199. }
  31200. return $this->infoCache[$identifier];
  31201. }
  31202. public function getFileContent(string $file, string $identifier): ?string
  31203. {
  31204. if ($this->fallbackDriver) {
  31205. return $this->fallbackDriver->getFileContent($file, $identifier);
  31206. }
  31207. if (strpos($identifier, '/') !== false) {
  31208. $branches = $this->getBranches();
  31209. if (isset($branches[$identifier])) {
  31210. $identifier = $branches[$identifier];
  31211. }
  31212. }
  31213. $resource = sprintf(
  31214. 'https://api.bitbucket.org/2.0/repositories/%s/%s/src/%s/%s',
  31215. $this->owner,
  31216. $this->repository,
  31217. $identifier,
  31218. $file
  31219. );
  31220. return $this->fetchWithOAuthCredentials($resource)->getBody();
  31221. }
  31222. public function getChangeDate(string $identifier): ?\DateTimeImmutable
  31223. {
  31224. if ($this->fallbackDriver) {
  31225. return $this->fallbackDriver->getChangeDate($identifier);
  31226. }
  31227. if (strpos($identifier, '/') !== false) {
  31228. $branches = $this->getBranches();
  31229. if (isset($branches[$identifier])) {
  31230. $identifier = $branches[$identifier];
  31231. }
  31232. }
  31233. $resource = sprintf(
  31234. 'https://api.bitbucket.org/2.0/repositories/%s/%s/commit/%s?fields=date',
  31235. $this->owner,
  31236. $this->repository,
  31237. $identifier
  31238. );
  31239. $commit = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  31240. return new \DateTimeImmutable($commit['date']);
  31241. }
  31242. public function getSource(string $identifier): array
  31243. {
  31244. if ($this->fallbackDriver) {
  31245. return $this->fallbackDriver->getSource($identifier);
  31246. }
  31247. return ['type' => $this->vcsType, 'url' => $this->getUrl(), 'reference' => $identifier];
  31248. }
  31249. public function getDist(string $identifier): ?array
  31250. {
  31251. if ($this->fallbackDriver) {
  31252. return $this->fallbackDriver->getDist($identifier);
  31253. }
  31254. $url = sprintf(
  31255. 'https://bitbucket.org/%s/%s/get/%s.zip',
  31256. $this->owner,
  31257. $this->repository,
  31258. $identifier
  31259. );
  31260. return ['type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => ''];
  31261. }
  31262. public function getTags(): array
  31263. {
  31264. if ($this->fallbackDriver) {
  31265. return $this->fallbackDriver->getTags();
  31266. }
  31267. if (null === $this->tags) {
  31268. $tags = [];
  31269. $resource = sprintf(
  31270. '%s?%s',
  31271. $this->tagsUrl,
  31272. http_build_query(
  31273. [
  31274. 'pagelen' => 100,
  31275. 'fields' => 'values.name,values.target.hash,next',
  31276. 'sort' => '-target.date',
  31277. ],
  31278. '',
  31279. '&'
  31280. )
  31281. );
  31282. $hasNext = true;
  31283. while ($hasNext) {
  31284. $tagsData = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  31285. foreach ($tagsData['values'] as $data) {
  31286. $tags[$data['name']] = $data['target']['hash'];
  31287. }
  31288. if (empty($tagsData['next'])) {
  31289. $hasNext = false;
  31290. } else {
  31291. $resource = $tagsData['next'];
  31292. }
  31293. }
  31294. $this->tags = $tags;
  31295. }
  31296. return $this->tags;
  31297. }
  31298. public function getBranches(): array
  31299. {
  31300. if ($this->fallbackDriver) {
  31301. return $this->fallbackDriver->getBranches();
  31302. }
  31303. if (null === $this->branches) {
  31304. $branches = [];
  31305. $resource = sprintf(
  31306. '%s?%s',
  31307. $this->branchesUrl,
  31308. http_build_query(
  31309. [
  31310. 'pagelen' => 100,
  31311. 'fields' => 'values.name,values.target.hash,values.heads,next',
  31312. 'sort' => '-target.date',
  31313. ],
  31314. '',
  31315. '&'
  31316. )
  31317. );
  31318. $hasNext = true;
  31319. while ($hasNext) {
  31320. $branchData = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  31321. foreach ($branchData['values'] as $data) {
  31322. $branches[$data['name']] = $data['target']['hash'];
  31323. }
  31324. if (empty($branchData['next'])) {
  31325. $hasNext = false;
  31326. } else {
  31327. $resource = $branchData['next'];
  31328. }
  31329. }
  31330. $this->branches = $branches;
  31331. }
  31332. return $this->branches;
  31333. }
  31334. protected function fetchWithOAuthCredentials(string $url, bool $fetchingRepoData = false): Response
  31335. {
  31336. try {
  31337. return parent::getContents($url);
  31338. } catch (TransportException $e) {
  31339. $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process, $this->httpDownloader);
  31340. if (in_array($e->getCode(), [403, 404], true) || (401 === $e->getCode() && strpos($e->getMessage(), 'Could not authenticate against') === 0)) {
  31341. if (!$this->io->hasAuthentication($this->originUrl)
  31342. && $bitbucketUtil->authorizeOAuth($this->originUrl)
  31343. ) {
  31344. return parent::getContents($url);
  31345. }
  31346. if (!$this->io->isInteractive() && $fetchingRepoData) {
  31347. $this->attemptCloneFallback();
  31348. return new Response(['url' => 'dummy'], 200, [], 'null');
  31349. }
  31350. }
  31351. throw $e;
  31352. }
  31353. }
  31354. protected function generateSshUrl(): string
  31355. {
  31356. return 'git@' . $this->originUrl . ':' . $this->owner.'/'.$this->repository.'.git';
  31357. }
  31358. protected function attemptCloneFallback(): bool
  31359. {
  31360. try {
  31361. $this->setupFallbackDriver($this->generateSshUrl());
  31362. return true;
  31363. } catch (\RuntimeException $e) {
  31364. $this->fallbackDriver = null;
  31365. $this->io->writeError(
  31366. '<error>Failed to clone the ' . $this->generateSshUrl() . ' repository, try running in interactive mode'
  31367. . ' so that you can enter your Bitbucket OAuth consumer credentials</error>'
  31368. );
  31369. throw $e;
  31370. }
  31371. }
  31372. protected function setupFallbackDriver(string $url): void
  31373. {
  31374. $this->fallbackDriver = new GitDriver(
  31375. ['url' => $url],
  31376. $this->io,
  31377. $this->config,
  31378. $this->httpDownloader,
  31379. $this->process
  31380. );
  31381. $this->fallbackDriver->initialize();
  31382. }
  31383. protected function parseCloneUrls(array $cloneLinks): void
  31384. {
  31385. foreach ($cloneLinks as $cloneLink) {
  31386. if ($cloneLink['name'] === 'https') {
  31387. $this->cloneHttpsUrl = Preg::replace('/https:\/\/([^@]+@)?/', 'https://', $cloneLink['href']);
  31388. }
  31389. }
  31390. }
  31391. public function getRootIdentifier(): string
  31392. {
  31393. if ($this->fallbackDriver) {
  31394. return $this->fallbackDriver->getRootIdentifier();
  31395. }
  31396. if (null === $this->rootIdentifier) {
  31397. if (!$this->getRepoData()) {
  31398. if (!$this->fallbackDriver) {
  31399. throw new \LogicException('A fallback driver should be setup if getRepoData returns false');
  31400. }
  31401. return $this->fallbackDriver->getRootIdentifier();
  31402. }
  31403. if ($this->vcsType !== 'git') {
  31404. throw new \RuntimeException(
  31405. $this->url.' does not appear to be a git repository, use '.
  31406. $this->cloneHttpsUrl.' but remember that Bitbucket no longer supports the mercurial repositories. '.
  31407. 'https://bitbucket.org/blog/sunsetting-mercurial-support-in-bitbucket'
  31408. );
  31409. }
  31410. $this->rootIdentifier = $this->repoData['mainbranch']['name'] ?? 'master';
  31411. }
  31412. return $this->rootIdentifier;
  31413. }
  31414. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
  31415. {
  31416. if (!Preg::isMatch('#^https?://bitbucket\.org/([^/]+)/([^/]+?)(\.git|/?)?$#i', $url)) {
  31417. return false;
  31418. }
  31419. if (!extension_loaded('openssl')) {
  31420. $io->writeError('Skipping Bitbucket git driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  31421. return false;
  31422. }
  31423. return true;
  31424. }
  31425. }
  31426. <?php declare(strict_types=1);
  31427. namespace Composer\Repository\Vcs;
  31428. use Composer\Pcre\Preg;
  31429. use Composer\Util\ProcessExecutor;
  31430. use Composer\Util\Filesystem;
  31431. use Composer\Util\Url;
  31432. use Composer\Util\Git as GitUtil;
  31433. use Composer\IO\IOInterface;
  31434. use Composer\Cache;
  31435. use Composer\Config;
  31436. class GitDriver extends VcsDriver
  31437. {
  31438. protected $tags;
  31439. protected $branches;
  31440. protected $rootIdentifier;
  31441. protected $repoDir;
  31442. public function initialize(): void
  31443. {
  31444. if (Filesystem::isLocalPath($this->url)) {
  31445. $this->url = Preg::replace('{[\\/]\.git/?$}', '', $this->url);
  31446. if (!is_dir($this->url)) {
  31447. throw new \RuntimeException('Failed to read package information from '.$this->url.' as the path does not exist');
  31448. }
  31449. $this->repoDir = $this->url;
  31450. $cacheUrl = realpath($this->url);
  31451. } else {
  31452. if (!Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  31453. throw new \RuntimeException('GitDriver requires a usable cache directory, and it looks like you set it to be disabled');
  31454. }
  31455. $this->repoDir = $this->config->get('cache-vcs-dir') . '/' . Preg::replace('{[^a-z0-9.]}i', '-', $this->url) . '/';
  31456. GitUtil::cleanEnv();
  31457. $fs = new Filesystem();
  31458. $fs->ensureDirectoryExists(dirname($this->repoDir));
  31459. if (!is_writable(dirname($this->repoDir))) {
  31460. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.dirname($this->repoDir).'" directory is not writable by the current user.');
  31461. }
  31462. if (Preg::isMatch('{^ssh://[^@]+@[^:]+:[^0-9]+}', $this->url)) {
  31463. 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.');
  31464. }
  31465. $gitUtil = new GitUtil($this->io, $this->config, $this->process, $fs);
  31466. if (!$gitUtil->syncMirror($this->url, $this->repoDir)) {
  31467. if (!is_dir($this->repoDir)) {
  31468. throw new \RuntimeException('Failed to clone '.$this->url.' to read package information from it');
  31469. }
  31470. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated</error>');
  31471. }
  31472. $cacheUrl = $this->url;
  31473. }
  31474. $this->getTags();
  31475. $this->getBranches();
  31476. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', Url::sanitize($cacheUrl)));
  31477. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  31478. }
  31479. public function getRootIdentifier(): string
  31480. {
  31481. if (null === $this->rootIdentifier) {
  31482. $this->rootIdentifier = 'master';
  31483. $gitUtil = new GitUtil($this->io, $this->config, $this->process, new Filesystem());
  31484. if (!Filesystem::isLocalPath($this->url)) {
  31485. $defaultBranch = $gitUtil->getMirrorDefaultBranch($this->url, $this->repoDir, false);
  31486. if ($defaultBranch !== null) {
  31487. return $this->rootIdentifier = $defaultBranch;
  31488. }
  31489. }
  31490. $this->process->execute('git branch --no-color', $output, $this->repoDir);
  31491. $branches = $this->process->splitLines($output);
  31492. if (!in_array('* master', $branches)) {
  31493. foreach ($branches as $branch) {
  31494. if ($branch && Preg::isMatchStrictGroups('{^\* +(\S+)}', $branch, $match)) {
  31495. $this->rootIdentifier = $match[1];
  31496. break;
  31497. }
  31498. }
  31499. }
  31500. }
  31501. return $this->rootIdentifier;
  31502. }
  31503. public function getUrl(): string
  31504. {
  31505. return $this->url;
  31506. }
  31507. public function getSource(string $identifier): array
  31508. {
  31509. return ['type' => 'git', 'url' => $this->getUrl(), 'reference' => $identifier];
  31510. }
  31511. public function getDist(string $identifier): ?array
  31512. {
  31513. return null;
  31514. }
  31515. public function getFileContent(string $file, string $identifier): ?string
  31516. {
  31517. if (isset($identifier[0]) && $identifier[0] === '-') {
  31518. throw new \RuntimeException('Invalid git identifier detected. Identifier must not start with a -, given: ' . $identifier);
  31519. }
  31520. $resource = sprintf('%s:%s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  31521. $this->process->execute(sprintf('git show %s', $resource), $content, $this->repoDir);
  31522. if (!trim($content)) {
  31523. return null;
  31524. }
  31525. return $content;
  31526. }
  31527. public function getChangeDate(string $identifier): ?\DateTimeImmutable
  31528. {
  31529. $this->process->execute(sprintf(
  31530. 'git -c log.showSignature=false log -1 --format=%%at %s',
  31531. ProcessExecutor::escape($identifier)
  31532. ), $output, $this->repoDir);
  31533. return new \DateTimeImmutable('@'.trim($output), new \DateTimeZone('UTC'));
  31534. }
  31535. public function getTags(): array
  31536. {
  31537. if (null === $this->tags) {
  31538. $this->tags = [];
  31539. $this->process->execute('git show-ref --tags --dereference', $output, $this->repoDir);
  31540. foreach ($output = $this->process->splitLines($output) as $tag) {
  31541. if ($tag && Preg::isMatch('{^([a-f0-9]{40}) refs/tags/(\S+?)(\^\{\})?$}', $tag, $match)) {
  31542. $this->tags[$match[2]] = (string) $match[1];
  31543. }
  31544. }
  31545. }
  31546. return $this->tags;
  31547. }
  31548. public function getBranches(): array
  31549. {
  31550. if (null === $this->branches) {
  31551. $branches = [];
  31552. $this->process->execute('git branch --no-color --no-abbrev -v', $output, $this->repoDir);
  31553. foreach ($this->process->splitLines($output) as $branch) {
  31554. if ($branch && !Preg::isMatch('{^ *[^/]+/HEAD }', $branch)) {
  31555. if (Preg::isMatchStrictGroups('{^(?:\* )? *(\S+) *([a-f0-9]+)(?: .*)?$}', $branch, $match) && $match[1][0] !== '-') {
  31556. $branches[$match[1]] = $match[2];
  31557. }
  31558. }
  31559. }
  31560. $this->branches = $branches;
  31561. }
  31562. return $this->branches;
  31563. }
  31564. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
  31565. {
  31566. if (Preg::isMatch('#(^git://|\.git/?$|git(?:olite)?@|//git\.|//github.com/)#i', $url)) {
  31567. return true;
  31568. }
  31569. if (Filesystem::isLocalPath($url)) {
  31570. $url = Filesystem::getPlatformPath($url);
  31571. if (!is_dir($url)) {
  31572. return false;
  31573. }
  31574. $process = new ProcessExecutor($io);
  31575. if ($process->execute('git tag', $output, $url) === 0) {
  31576. return true;
  31577. }
  31578. }
  31579. if (!$deep) {
  31580. return false;
  31581. }
  31582. $gitUtil = new GitUtil($io, $config, new ProcessExecutor($io), new Filesystem());
  31583. GitUtil::cleanEnv();
  31584. try {
  31585. $gitUtil->runCommand(static function ($url): string {
  31586. return 'git ls-remote --heads -- ' . ProcessExecutor::escape($url);
  31587. }, $url, sys_get_temp_dir());
  31588. } catch (\RuntimeException $e) {
  31589. return false;
  31590. }
  31591. return true;
  31592. }
  31593. }
  31594. <?php declare(strict_types=1);
  31595. namespace Composer\Repository\Vcs;
  31596. use Composer\Config;
  31597. use Composer\Downloader\TransportException;
  31598. use Composer\Json\JsonFile;
  31599. use Composer\Cache;
  31600. use Composer\IO\IOInterface;
  31601. use Composer\Pcre\Preg;
  31602. use Composer\Util\GitHub;
  31603. use Composer\Util\Http\Response;
  31604. class GitHubDriver extends VcsDriver
  31605. {
  31606. protected $owner;
  31607. protected $repository;
  31608. protected $tags;
  31609. protected $branches;
  31610. protected $rootIdentifier;
  31611. protected $repoData;
  31612. protected $hasIssues = false;
  31613. protected $isPrivate = false;
  31614. private $isArchived = false;
  31615. private $fundingInfo;
  31616. protected $gitDriver = null;
  31617. public function initialize(): void
  31618. {
  31619. if (!Preg::isMatch('#^(?:(?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/([^/]+?)(?:\.git|/)?$#', $this->url, $match)) {
  31620. throw new \InvalidArgumentException(sprintf('The GitHub repository URL %s is invalid.', $this->url));
  31621. }
  31622. assert(is_string($match[3]));
  31623. assert(is_string($match[4]));
  31624. $this->owner = $match[3];
  31625. $this->repository = $match[4];
  31626. $this->originUrl = strtolower($match[1] ?? (string) $match[2]);
  31627. if ($this->originUrl === 'www.github.com') {
  31628. $this->originUrl = 'github.com';
  31629. }
  31630. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->owner.'/'.$this->repository);
  31631. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  31632. if ($this->config->get('use-github-api') === false || (isset($this->repoConfig['no-api']) && $this->repoConfig['no-api'])) {
  31633. $this->setupGitDriver($this->url);
  31634. return;
  31635. }
  31636. $this->fetchRootIdentifier();
  31637. }
  31638. public function getRepositoryUrl(): string
  31639. {
  31640. return 'https://'.$this->originUrl.'/'.$this->owner.'/'.$this->repository;
  31641. }
  31642. public function getRootIdentifier(): string
  31643. {
  31644. if ($this->gitDriver) {
  31645. return $this->gitDriver->getRootIdentifier();
  31646. }
  31647. return $this->rootIdentifier;
  31648. }
  31649. public function getUrl(): string
  31650. {
  31651. if ($this->gitDriver) {
  31652. return $this->gitDriver->getUrl();
  31653. }
  31654. return 'https://' . $this->originUrl . '/'.$this->owner.'/'.$this->repository.'.git';
  31655. }
  31656. protected function getApiUrl(): string
  31657. {
  31658. if ('github.com' === $this->originUrl) {
  31659. $apiUrl = 'api.github.com';
  31660. } else {
  31661. $apiUrl = $this->originUrl . '/api/v3';
  31662. }
  31663. return 'https://' . $apiUrl;
  31664. }
  31665. public function getSource(string $identifier): array
  31666. {
  31667. if ($this->gitDriver) {
  31668. return $this->gitDriver->getSource($identifier);
  31669. }
  31670. if ($this->isPrivate) {
  31671. $url = $this->generateSshUrl();
  31672. } else {
  31673. $url = $this->getUrl();
  31674. }
  31675. return ['type' => 'git', 'url' => $url, 'reference' => $identifier];
  31676. }
  31677. public function getDist(string $identifier): ?array
  31678. {
  31679. $url = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/zipball/'.$identifier;
  31680. return ['type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => ''];
  31681. }
  31682. public function getComposerInformation(string $identifier): ?array
  31683. {
  31684. if ($this->gitDriver) {
  31685. return $this->gitDriver->getComposerInformation($identifier);
  31686. }
  31687. if (!isset($this->infoCache[$identifier])) {
  31688. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  31689. $composer = JsonFile::parseJson($res);
  31690. } else {
  31691. $composer = $this->getBaseComposerInformation($identifier);
  31692. if ($this->shouldCache($identifier)) {
  31693. $this->cache->write($identifier, json_encode($composer));
  31694. }
  31695. }
  31696. if ($composer !== null) {
  31697. if (isset($composer['support']) && !is_array($composer['support'])) {
  31698. $composer['support'] = [];
  31699. }
  31700. if (!isset($composer['support']['source'])) {
  31701. $label = array_search($identifier, $this->getTags()) ?: array_search($identifier, $this->getBranches()) ?: $identifier;
  31702. $composer['support']['source'] = sprintf('https://%s/%s/%s/tree/%s', $this->originUrl, $this->owner, $this->repository, $label);
  31703. }
  31704. if (!isset($composer['support']['issues']) && $this->hasIssues) {
  31705. $composer['support']['issues'] = sprintf('https://%s/%s/%s/issues', $this->originUrl, $this->owner, $this->repository);
  31706. }
  31707. if (!isset($composer['abandoned']) && $this->isArchived) {
  31708. $composer['abandoned'] = true;
  31709. }
  31710. if (!isset($composer['funding']) && $funding = $this->getFundingInfo()) {
  31711. $composer['funding'] = $funding;
  31712. }
  31713. }
  31714. $this->infoCache[$identifier] = $composer;
  31715. }
  31716. return $this->infoCache[$identifier];
  31717. }
  31718. private function getFundingInfo()
  31719. {
  31720. if (null !== $this->fundingInfo) {
  31721. return $this->fundingInfo;
  31722. }
  31723. if ($this->originUrl !== 'github.com') {
  31724. return $this->fundingInfo = false;
  31725. }
  31726. foreach ([$this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/.github/FUNDING.yml', $this->getApiUrl() . '/repos/'.$this->owner.'/.github/contents/FUNDING.yml'] as $file) {
  31727. try {
  31728. $response = $this->httpDownloader->get($file, [
  31729. 'retry-auth-failure' => false,
  31730. ])->decodeJson();
  31731. } catch (TransportException $e) {
  31732. continue;
  31733. }
  31734. if (empty($response['content']) || $response['encoding'] !== 'base64' || !($funding = base64_decode($response['content']))) {
  31735. continue;
  31736. }
  31737. break;
  31738. }
  31739. if (empty($funding)) {
  31740. return $this->fundingInfo = false;
  31741. }
  31742. $result = [];
  31743. $key = null;
  31744. foreach (Preg::split('{\r?\n}', $funding) as $line) {
  31745. $line = trim($line);
  31746. if (Preg::isMatchStrictGroups('{^(\w+)\s*:\s*(.+)$}', $line, $match)) {
  31747. if ($match[2] === '[') {
  31748. $key = $match[1];
  31749. continue;
  31750. }
  31751. if (Preg::isMatchStrictGroups('{^\[(.*)\](?:\s*#.*)?$}', $match[2], $match2)) {
  31752. foreach (array_map('trim', Preg::split('{[\'"]?\s*,\s*[\'"]?}', $match2[1])) as $item) {
  31753. $result[] = ['type' => $match[1], 'url' => trim($item, '"\' ')];
  31754. }
  31755. } elseif (Preg::isMatchStrictGroups('{^([^#].*?)(?:\s+#.*)?$}', $match[2], $match2)) {
  31756. $result[] = ['type' => $match[1], 'url' => trim($match2[1], '"\' ')];
  31757. }
  31758. $key = null;
  31759. } elseif (Preg::isMatchStrictGroups('{^(\w+)\s*:\s*#\s*$}', $line, $match)) {
  31760. $key = $match[1];
  31761. } elseif ($key !== null && (
  31762. Preg::isMatchStrictGroups('{^-\s*(.+)(?:\s+#.*)?$}', $line, $match)
  31763. || Preg::isMatchStrictGroups('{^(.+),(?:\s*#.*)?$}', $line, $match)
  31764. )) {
  31765. $result[] = ['type' => $key, 'url' => trim($match[1], '"\' ')];
  31766. } elseif ($key !== null && $line === ']') {
  31767. $key = null;
  31768. }
  31769. }
  31770. foreach ($result as $key => $item) {
  31771. switch ($item['type']) {
  31772. case 'tidelift':
  31773. $result[$key]['url'] = 'https://tidelift.com/funding/github/' . $item['url'];
  31774. break;
  31775. case 'github':
  31776. $result[$key]['url'] = 'https://github.com/' . basename($item['url']);
  31777. break;
  31778. case 'patreon':
  31779. $result[$key]['url'] = 'https://www.patreon.com/' . basename($item['url']);
  31780. break;
  31781. case 'otechie':
  31782. $result[$key]['url'] = 'https://otechie.com/' . basename($item['url']);
  31783. break;
  31784. case 'open_collective':
  31785. $result[$key]['url'] = 'https://opencollective.com/' . basename($item['url']);
  31786. break;
  31787. case 'liberapay':
  31788. $result[$key]['url'] = 'https://liberapay.com/' . basename($item['url']);
  31789. break;
  31790. case 'ko_fi':
  31791. $result[$key]['url'] = 'https://ko-fi.com/' . basename($item['url']);
  31792. break;
  31793. case 'issuehunt':
  31794. $result[$key]['url'] = 'https://issuehunt.io/r/' . $item['url'];
  31795. break;
  31796. case 'community_bridge':
  31797. $result[$key]['url'] = 'https://funding.communitybridge.org/projects/' . basename($item['url']);
  31798. break;
  31799. }
  31800. }
  31801. return $this->fundingInfo = $result;
  31802. }
  31803. public function getFileContent(string $file, string $identifier): ?string
  31804. {
  31805. if ($this->gitDriver) {
  31806. return $this->gitDriver->getFileContent($file, $identifier);
  31807. }
  31808. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/' . $file . '?ref='.urlencode($identifier);
  31809. $resource = $this->getContents($resource)->decodeJson();
  31810. if ((!isset($resource['content']) || $resource['content'] === '') && $resource['encoding'] === 'none' && isset($resource['git_url'])) {
  31811. $resource = $this->getContents($resource['git_url'])->decodeJson();
  31812. }
  31813. if (!isset($resource['content']) || $resource['encoding'] !== 'base64' || false === ($content = base64_decode($resource['content']))) {
  31814. throw new \RuntimeException('Could not retrieve ' . $file . ' for '.$identifier);
  31815. }
  31816. return $content;
  31817. }
  31818. public function getChangeDate(string $identifier): ?\DateTimeImmutable
  31819. {
  31820. if ($this->gitDriver) {
  31821. return $this->gitDriver->getChangeDate($identifier);
  31822. }
  31823. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/commits/'.urlencode($identifier);
  31824. $commit = $this->getContents($resource)->decodeJson();
  31825. return new \DateTimeImmutable($commit['commit']['committer']['date']);
  31826. }
  31827. public function getTags(): array
  31828. {
  31829. if ($this->gitDriver) {
  31830. return $this->gitDriver->getTags();
  31831. }
  31832. if (null === $this->tags) {
  31833. $tags = [];
  31834. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/tags?per_page=100';
  31835. do {
  31836. $response = $this->getContents($resource);
  31837. $tagsData = $response->decodeJson();
  31838. foreach ($tagsData as $tag) {
  31839. $tags[$tag['name']] = $tag['commit']['sha'];
  31840. }
  31841. $resource = $this->getNextPage($response);
  31842. } while ($resource);
  31843. $this->tags = $tags;
  31844. }
  31845. return $this->tags;
  31846. }
  31847. public function getBranches(): array
  31848. {
  31849. if ($this->gitDriver) {
  31850. return $this->gitDriver->getBranches();
  31851. }
  31852. if (null === $this->branches) {
  31853. $branches = [];
  31854. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/git/refs/heads?per_page=100';
  31855. do {
  31856. $response = $this->getContents($resource);
  31857. $branchData = $response->decodeJson();
  31858. foreach ($branchData as $branch) {
  31859. $name = substr($branch['ref'], 11);
  31860. if ($name !== 'gh-pages') {
  31861. $branches[$name] = $branch['object']['sha'];
  31862. }
  31863. }
  31864. $resource = $this->getNextPage($response);
  31865. } while ($resource);
  31866. $this->branches = $branches;
  31867. }
  31868. return $this->branches;
  31869. }
  31870. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
  31871. {
  31872. if (!Preg::isMatch('#^((?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/([^/]+?)(?:\.git|/)?$#', $url, $matches)) {
  31873. return false;
  31874. }
  31875. $originUrl = $matches[2] ?? (string) $matches[3];
  31876. if (!in_array(strtolower(Preg::replace('{^www\.}i', '', $originUrl)), $config->get('github-domains'))) {
  31877. return false;
  31878. }
  31879. if (!extension_loaded('openssl')) {
  31880. $io->writeError('Skipping GitHub driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  31881. return false;
  31882. }
  31883. return true;
  31884. }
  31885. public function getRepoData(): ?array
  31886. {
  31887. $this->fetchRootIdentifier();
  31888. return $this->repoData;
  31889. }
  31890. protected function generateSshUrl(): string
  31891. {
  31892. if (false !== strpos($this->originUrl, ':')) {
  31893. return 'ssh://git@' . $this->originUrl . '/'.$this->owner.'/'.$this->repository.'.git';
  31894. }
  31895. return 'git@' . $this->originUrl . ':'.$this->owner.'/'.$this->repository.'.git';
  31896. }
  31897. protected function getContents(string $url, bool $fetchingRepoData = false): Response
  31898. {
  31899. try {
  31900. return parent::getContents($url);
  31901. } catch (TransportException $e) {
  31902. $gitHubUtil = new GitHub($this->io, $this->config, $this->process, $this->httpDownloader);
  31903. switch ($e->getCode()) {
  31904. case 401:
  31905. case 404:
  31906. if (!$fetchingRepoData) {
  31907. throw $e;
  31908. }
  31909. if ($gitHubUtil->authorizeOAuth($this->originUrl)) {
  31910. return parent::getContents($url);
  31911. }
  31912. if (!$this->io->isInteractive()) {
  31913. $this->attemptCloneFallback();
  31914. return new Response(['url' => 'dummy'], 200, [], 'null');
  31915. }
  31916. $scopesIssued = [];
  31917. $scopesNeeded = [];
  31918. if ($headers = $e->getHeaders()) {
  31919. if ($scopes = Response::findHeaderValue($headers, 'X-OAuth-Scopes')) {
  31920. $scopesIssued = explode(' ', $scopes);
  31921. }
  31922. if ($scopes = Response::findHeaderValue($headers, 'X-Accepted-OAuth-Scopes')) {
  31923. $scopesNeeded = explode(' ', $scopes);
  31924. }
  31925. }
  31926. $scopesFailed = array_diff($scopesNeeded, $scopesIssued);
  31927. if (!$headers || !count($scopesNeeded) || count($scopesFailed)) {
  31928. $gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'Your GitHub credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
  31929. }
  31930. return parent::getContents($url);
  31931. case 403:
  31932. if (!$this->io->hasAuthentication($this->originUrl) && $gitHubUtil->authorizeOAuth($this->originUrl)) {
  31933. return parent::getContents($url);
  31934. }
  31935. if (!$this->io->isInteractive() && $fetchingRepoData) {
  31936. $this->attemptCloneFallback();
  31937. return new Response(['url' => 'dummy'], 200, [], 'null');
  31938. }
  31939. $rateLimited = $gitHubUtil->isRateLimited((array) $e->getHeaders());
  31940. if (!$this->io->hasAuthentication($this->originUrl)) {
  31941. if (!$this->io->isInteractive()) {
  31942. $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>');
  31943. throw $e;
  31944. }
  31945. $gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'API limit exhausted. Enter your GitHub credentials to get a larger API limit (<info>'.$this->url.'</info>)');
  31946. return parent::getContents($url);
  31947. }
  31948. if ($rateLimited) {
  31949. $rateLimit = $gitHubUtil->getRateLimit($e->getHeaders());
  31950. $this->io->writeError(sprintf(
  31951. '<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>',
  31952. $rateLimit['limit'],
  31953. $rateLimit['reset']
  31954. ));
  31955. }
  31956. throw $e;
  31957. default:
  31958. throw $e;
  31959. }
  31960. }
  31961. }
  31962. protected function fetchRootIdentifier(): void
  31963. {
  31964. if ($this->repoData) {
  31965. return;
  31966. }
  31967. $repoDataUrl = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository;
  31968. try {
  31969. $this->repoData = $this->getContents($repoDataUrl, true)->decodeJson();
  31970. } catch (TransportException $e) {
  31971. if ($e->getCode() === 499) {
  31972. $this->attemptCloneFallback();
  31973. } else {
  31974. throw $e;
  31975. }
  31976. }
  31977. if (null === $this->repoData && null !== $this->gitDriver) {
  31978. return;
  31979. }
  31980. $this->owner = $this->repoData['owner']['login'];
  31981. $this->repository = $this->repoData['name'];
  31982. $this->isPrivate = !empty($this->repoData['private']);
  31983. if (isset($this->repoData['default_branch'])) {
  31984. $this->rootIdentifier = $this->repoData['default_branch'];
  31985. } elseif (isset($this->repoData['master_branch'])) {
  31986. $this->rootIdentifier = $this->repoData['master_branch'];
  31987. } else {
  31988. $this->rootIdentifier = 'master';
  31989. }
  31990. $this->hasIssues = !empty($this->repoData['has_issues']);
  31991. $this->isArchived = !empty($this->repoData['archived']);
  31992. }
  31993. protected function attemptCloneFallback(): bool
  31994. {
  31995. $this->isPrivate = true;
  31996. try {
  31997. $this->setupGitDriver($this->generateSshUrl());
  31998. return true;
  31999. } catch (\RuntimeException $e) {
  32000. $this->gitDriver = null;
  32001. $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>');
  32002. throw $e;
  32003. }
  32004. }
  32005. protected function setupGitDriver(string $url): void
  32006. {
  32007. $this->gitDriver = new GitDriver(
  32008. ['url' => $url],
  32009. $this->io,
  32010. $this->config,
  32011. $this->httpDownloader,
  32012. $this->process
  32013. );
  32014. $this->gitDriver->initialize();
  32015. }
  32016. protected function getNextPage(Response $response): ?string
  32017. {
  32018. $header = $response->getHeader('link');
  32019. if (!$header) {
  32020. return null;
  32021. }
  32022. $links = explode(',', $header);
  32023. foreach ($links as $link) {
  32024. if (Preg::isMatch('{<(.+?)>; *rel="next"}', $link, $match)) {
  32025. return $match[1];
  32026. }
  32027. }
  32028. return null;
  32029. }
  32030. }
  32031. <?php declare(strict_types=1);
  32032. namespace Composer\Repository\Vcs;
  32033. use Composer\Config;
  32034. use Composer\Cache;
  32035. use Composer\IO\IOInterface;
  32036. use Composer\Json\JsonFile;
  32037. use Composer\Downloader\TransportException;
  32038. use Composer\Pcre\Preg;
  32039. use Composer\Util\HttpDownloader;
  32040. use Composer\Util\GitLab;
  32041. use Composer\Util\Http\Response;
  32042. class GitLabDriver extends VcsDriver
  32043. {
  32044. private $scheme;
  32045. private $namespace;
  32046. private $repository;
  32047. private $project;
  32048. private $commits = [];
  32049. private $tags;
  32050. private $branches;
  32051. protected $gitDriver = null;
  32052. protected $protocol;
  32053. private $isPrivate = true;
  32054. private $hasNonstandardOrigin = false;
  32055. public const URL_REGEX = '#^(?:(?P<scheme>https?)://(?P<domain>.+?)(?::(?P<port>[0-9]+))?/|git@(?P<domain2>[^:]+):)(?P<parts>.+)/(?P<repo>[^/]+?)(?:\.git|/)?$#';
  32056. public function initialize(): void
  32057. {
  32058. if (!Preg::isMatch(self::URL_REGEX, $this->url, $match)) {
  32059. throw new \InvalidArgumentException(sprintf('The GitLab repository URL %s is invalid. It must be the HTTP URL of a GitLab project.', $this->url));
  32060. }
  32061. assert(is_string($match['parts']));
  32062. assert(is_string($match['repo']));
  32063. $guessedDomain = $match['domain'] ?? (string) $match['domain2'];
  32064. $configuredDomains = $this->config->get('gitlab-domains');
  32065. $urlParts = explode('/', $match['parts']);
  32066. $this->scheme = in_array($match['scheme'], ['https', 'http'], true)
  32067. ? $match['scheme']
  32068. : (isset($this->repoConfig['secure-http']) && $this->repoConfig['secure-http'] === false ? 'http' : 'https')
  32069. ;
  32070. $origin = self::determineOrigin($configuredDomains, $guessedDomain, $urlParts, $match['port']);
  32071. if (false === $origin) {
  32072. throw new \LogicException('It should not be possible to create a gitlab driver with an unparseable origin URL ('.$this->url.')');
  32073. }
  32074. $this->originUrl = $origin;
  32075. if (is_string($protocol = $this->config->get('gitlab-protocol'))) {
  32076. if (!in_array($protocol, ['git', 'http', 'https'])) {
  32077. throw new \RuntimeException('gitlab-protocol must be one of git, http.');
  32078. }
  32079. $this->protocol = $protocol === 'git' ? 'ssh' : 'http';
  32080. }
  32081. if (false !== strpos($this->originUrl, ':') || false !== strpos($this->originUrl, '/')) {
  32082. $this->hasNonstandardOrigin = true;
  32083. }
  32084. $this->namespace = implode('/', $urlParts);
  32085. $this->repository = Preg::replace('#(\.git)$#', '', $match['repo']);
  32086. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->namespace.'/'.$this->repository);
  32087. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  32088. $this->fetchProject();
  32089. }
  32090. public function setHttpDownloader(HttpDownloader $httpDownloader): void
  32091. {
  32092. $this->httpDownloader = $httpDownloader;
  32093. }
  32094. public function getComposerInformation(string $identifier): ?array
  32095. {
  32096. if ($this->gitDriver) {
  32097. return $this->gitDriver->getComposerInformation($identifier);
  32098. }
  32099. if (!isset($this->infoCache[$identifier])) {
  32100. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  32101. $composer = JsonFile::parseJson($res);
  32102. } else {
  32103. $composer = $this->getBaseComposerInformation($identifier);
  32104. if ($this->shouldCache($identifier)) {
  32105. $this->cache->write($identifier, json_encode($composer));
  32106. }
  32107. }
  32108. if (null !== $composer) {
  32109. if (isset($composer['support']) && !is_array($composer['support'])) {
  32110. $composer['support'] = [];
  32111. }
  32112. if (!isset($composer['support']['source']) && isset($this->project['web_url'])) {
  32113. $label = array_search($identifier, $this->getTags(), true) ?: array_search($identifier, $this->getBranches(), true) ?: $identifier;
  32114. $composer['support']['source'] = sprintf('%s/-/tree/%s', $this->project['web_url'], $label);
  32115. }
  32116. if (!isset($composer['support']['issues']) && !empty($this->project['issues_enabled']) && isset($this->project['web_url'])) {
  32117. $composer['support']['issues'] = sprintf('%s/-/issues', $this->project['web_url']);
  32118. }
  32119. if (!isset($composer['abandoned']) && !empty($this->project['archived'])) {
  32120. $composer['abandoned'] = true;
  32121. }
  32122. }
  32123. $this->infoCache[$identifier] = $composer;
  32124. }
  32125. return $this->infoCache[$identifier];
  32126. }
  32127. public function getFileContent(string $file, string $identifier): ?string
  32128. {
  32129. if ($this->gitDriver) {
  32130. return $this->gitDriver->getFileContent($file, $identifier);
  32131. }
  32132. if (!Preg::isMatch('{[a-f0-9]{40}}i', $identifier)) {
  32133. $branches = $this->getBranches();
  32134. if (isset($branches[$identifier])) {
  32135. $identifier = $branches[$identifier];
  32136. }
  32137. }
  32138. $resource = $this->getApiUrl().'/repository/files/'.$this->urlEncodeAll($file).'/raw?ref='.$identifier;
  32139. try {
  32140. $content = $this->getContents($resource)->getBody();
  32141. } catch (TransportException $e) {
  32142. if ($e->getCode() !== 404) {
  32143. throw $e;
  32144. }
  32145. return null;
  32146. }
  32147. return $content;
  32148. }
  32149. public function getChangeDate(string $identifier): ?\DateTimeImmutable
  32150. {
  32151. if ($this->gitDriver) {
  32152. return $this->gitDriver->getChangeDate($identifier);
  32153. }
  32154. if (isset($this->commits[$identifier])) {
  32155. return new \DateTimeImmutable($this->commits[$identifier]['committed_date']);
  32156. }
  32157. return null;
  32158. }
  32159. public function getRepositoryUrl(): string
  32160. {
  32161. if ($this->protocol) {
  32162. return $this->project["{$this->protocol}_url_to_repo"];
  32163. }
  32164. return $this->isPrivate ? $this->project['ssh_url_to_repo'] : $this->project['http_url_to_repo'];
  32165. }
  32166. public function getUrl(): string
  32167. {
  32168. if ($this->gitDriver) {
  32169. return $this->gitDriver->getUrl();
  32170. }
  32171. return $this->project['web_url'];
  32172. }
  32173. public function getDist(string $identifier): ?array
  32174. {
  32175. $url = $this->getApiUrl().'/repository/archive.zip?sha='.$identifier;
  32176. return ['type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => ''];
  32177. }
  32178. public function getSource(string $identifier): array
  32179. {
  32180. if ($this->gitDriver) {
  32181. return $this->gitDriver->getSource($identifier);
  32182. }
  32183. return ['type' => 'git', 'url' => $this->getRepositoryUrl(), 'reference' => $identifier];
  32184. }
  32185. public function getRootIdentifier(): string
  32186. {
  32187. if ($this->gitDriver) {
  32188. return $this->gitDriver->getRootIdentifier();
  32189. }
  32190. return $this->project['default_branch'];
  32191. }
  32192. public function getBranches(): array
  32193. {
  32194. if ($this->gitDriver) {
  32195. return $this->gitDriver->getBranches();
  32196. }
  32197. if (null === $this->branches) {
  32198. $this->branches = $this->getReferences('branches');
  32199. }
  32200. return $this->branches;
  32201. }
  32202. public function getTags(): array
  32203. {
  32204. if ($this->gitDriver) {
  32205. return $this->gitDriver->getTags();
  32206. }
  32207. if (null === $this->tags) {
  32208. $this->tags = $this->getReferences('tags');
  32209. }
  32210. return $this->tags;
  32211. }
  32212. public function getApiUrl(): string
  32213. {
  32214. return $this->scheme.'://'.$this->originUrl.'/api/v4/projects/'.$this->urlEncodeAll($this->namespace).'%2F'.$this->urlEncodeAll($this->repository);
  32215. }
  32216. private function urlEncodeAll(string $string): string
  32217. {
  32218. $encoded = '';
  32219. for ($i = 0; isset($string[$i]); $i++) {
  32220. $character = $string[$i];
  32221. if (!ctype_alnum($character) && !in_array($character, ['-', '_'], true)) {
  32222. $character = '%' . sprintf('%02X', ord($character));
  32223. }
  32224. $encoded .= $character;
  32225. }
  32226. return $encoded;
  32227. }
  32228. protected function getReferences(string $type): array
  32229. {
  32230. $perPage = 100;
  32231. $resource = $this->getApiUrl().'/repository/'.$type.'?per_page='.$perPage;
  32232. $references = [];
  32233. do {
  32234. $response = $this->getContents($resource);
  32235. $data = $response->decodeJson();
  32236. foreach ($data as $datum) {
  32237. $references[$datum['name']] = $datum['commit']['id'];
  32238. $this->commits[$datum['commit']['id']] = $datum['commit'];
  32239. }
  32240. if (count($data) >= $perPage) {
  32241. $resource = $this->getNextPage($response);
  32242. } else {
  32243. $resource = false;
  32244. }
  32245. } while ($resource);
  32246. return $references;
  32247. }
  32248. protected function fetchProject(): void
  32249. {
  32250. $resource = $this->getApiUrl();
  32251. $this->project = $this->getContents($resource, true)->decodeJson();
  32252. if (isset($this->project['visibility'])) {
  32253. $this->isPrivate = $this->project['visibility'] !== 'public';
  32254. } else {
  32255. $this->isPrivate = false;
  32256. }
  32257. }
  32258. protected function attemptCloneFallback(): bool
  32259. {
  32260. if ($this->isPrivate === false) {
  32261. $url = $this->generatePublicUrl();
  32262. } else {
  32263. $url = $this->generateSshUrl();
  32264. }
  32265. try {
  32266. $this->setupGitDriver($url);
  32267. return true;
  32268. } catch (\RuntimeException $e) {
  32269. $this->gitDriver = null;
  32270. $this->io->writeError('<error>Failed to clone the '.$url.' repository, try running in interactive mode so that you can enter your credentials</error>');
  32271. throw $e;
  32272. }
  32273. }
  32274. protected function generateSshUrl(): string
  32275. {
  32276. if ($this->hasNonstandardOrigin) {
  32277. return 'ssh://git@'.$this->originUrl.'/'.$this->namespace.'/'.$this->repository.'.git';
  32278. }
  32279. return 'git@' . $this->originUrl . ':'.$this->namespace.'/'.$this->repository.'.git';
  32280. }
  32281. protected function generatePublicUrl(): string
  32282. {
  32283. return $this->scheme . '://' . $this->originUrl . '/'.$this->namespace.'/'.$this->repository.'.git';
  32284. }
  32285. protected function setupGitDriver(string $url): void
  32286. {
  32287. $this->gitDriver = new GitDriver(
  32288. ['url' => $url],
  32289. $this->io,
  32290. $this->config,
  32291. $this->httpDownloader,
  32292. $this->process
  32293. );
  32294. $this->gitDriver->initialize();
  32295. }
  32296. protected function getContents(string $url, bool $fetchingRepoData = false): Response
  32297. {
  32298. try {
  32299. $response = parent::getContents($url);
  32300. if ($fetchingRepoData) {
  32301. $json = $response->decodeJson();
  32302. if (!isset($json['default_branch']) && isset($json['permissions'])) {
  32303. $this->isPrivate = $json['visibility'] !== 'public';
  32304. $moreThanGuestAccess = false;
  32305. foreach ($json['permissions'] as $permission) {
  32306. if ($permission && $permission['access_level'] > 10) {
  32307. $moreThanGuestAccess = true;
  32308. }
  32309. }
  32310. if (!$moreThanGuestAccess) {
  32311. $this->io->writeError('<warning>GitLab token with Guest only access detected</warning>');
  32312. $this->attemptCloneFallback();
  32313. return new Response(['url' => 'dummy'], 200, [], 'null');
  32314. }
  32315. }
  32316. if (!isset($json['default_branch'])) {
  32317. if (isset($json['repository_access_level']) && $json['repository_access_level'] === 'disabled') {
  32318. throw new TransportException('The GitLab repository is disabled in the project', 400);
  32319. }
  32320. if (!empty($json['id'])) {
  32321. $this->isPrivate = false;
  32322. }
  32323. throw new TransportException('GitLab API seems to not be authenticated as it did not return a default_branch', 401);
  32324. }
  32325. }
  32326. return $response;
  32327. } catch (TransportException $e) {
  32328. $gitLabUtil = new GitLab($this->io, $this->config, $this->process, $this->httpDownloader);
  32329. switch ($e->getCode()) {
  32330. case 401:
  32331. case 404:
  32332. if (!$fetchingRepoData) {
  32333. throw $e;
  32334. }
  32335. if ($gitLabUtil->authorizeOAuth($this->originUrl)) {
  32336. return parent::getContents($url);
  32337. }
  32338. if ($gitLabUtil->isOAuthExpired($this->originUrl) && $gitLabUtil->authorizeOAuthRefresh($this->scheme, $this->originUrl)) {
  32339. return parent::getContents($url);
  32340. }
  32341. if (!$this->io->isInteractive()) {
  32342. $this->attemptCloneFallback();
  32343. return new Response(['url' => 'dummy'], 200, [], 'null');
  32344. }
  32345. $this->io->writeError('<warning>Failed to download ' . $this->namespace . '/' . $this->repository . ':' . $e->getMessage() . '</warning>');
  32346. $gitLabUtil->authorizeOAuthInteractively($this->scheme, $this->originUrl, 'Your credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
  32347. return parent::getContents($url);
  32348. case 403:
  32349. if (!$this->io->hasAuthentication($this->originUrl) && $gitLabUtil->authorizeOAuth($this->originUrl)) {
  32350. return parent::getContents($url);
  32351. }
  32352. if (!$this->io->isInteractive() && $fetchingRepoData) {
  32353. $this->attemptCloneFallback();
  32354. return new Response(['url' => 'dummy'], 200, [], 'null');
  32355. }
  32356. throw $e;
  32357. default:
  32358. throw $e;
  32359. }
  32360. }
  32361. }
  32362. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
  32363. {
  32364. if (!Preg::isMatch(self::URL_REGEX, $url, $match)) {
  32365. return false;
  32366. }
  32367. assert(is_string($match['parts']));
  32368. assert(is_string($match['repo']));
  32369. $scheme = $match['scheme'];
  32370. $guessedDomain = $match['domain'] ?? (string) $match['domain2'];
  32371. $urlParts = explode('/', $match['parts']);
  32372. if (false === self::determineOrigin($config->get('gitlab-domains'), $guessedDomain, $urlParts, $match['port'])) {
  32373. return false;
  32374. }
  32375. if ('https' === $scheme && !extension_loaded('openssl')) {
  32376. $io->writeError('Skipping GitLab driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  32377. return false;
  32378. }
  32379. return true;
  32380. }
  32381. protected function getNextPage(Response $response): ?string
  32382. {
  32383. $header = $response->getHeader('link');
  32384. $links = explode(',', $header);
  32385. foreach ($links as $link) {
  32386. if (Preg::isMatchStrictGroups('{<(.+?)>; *rel="next"}', $link, $match)) {
  32387. return $match[1];
  32388. }
  32389. }
  32390. return null;
  32391. }
  32392. private static function determineOrigin(array $configuredDomains, string $guessedDomain, array &$urlParts, ?string $portNumber)
  32393. {
  32394. $guessedDomain = strtolower($guessedDomain);
  32395. if (in_array($guessedDomain, $configuredDomains) || (null !== $portNumber && in_array($guessedDomain.':'.$portNumber, $configuredDomains))) {
  32396. if (null !== $portNumber) {
  32397. return $guessedDomain.':'.$portNumber;
  32398. }
  32399. return $guessedDomain;
  32400. }
  32401. if (null !== $portNumber) {
  32402. $guessedDomain .= ':'.$portNumber;
  32403. }
  32404. while (null !== ($part = array_shift($urlParts))) {
  32405. $guessedDomain .= '/' . $part;
  32406. if (in_array($guessedDomain, $configuredDomains) || (null !== $portNumber && in_array(Preg::replace('{:\d+}', '', $guessedDomain), $configuredDomains))) {
  32407. return $guessedDomain;
  32408. }
  32409. }
  32410. return false;
  32411. }
  32412. }
  32413. <?php declare(strict_types=1);
  32414. namespace Composer\Repository\Vcs;
  32415. use Composer\Config;
  32416. use Composer\Cache;
  32417. use Composer\Pcre\Preg;
  32418. use Composer\Util\Hg as HgUtils;
  32419. use Composer\Util\ProcessExecutor;
  32420. use Composer\Util\Filesystem;
  32421. use Composer\IO\IOInterface;
  32422. class HgDriver extends VcsDriver
  32423. {
  32424. protected $tags;
  32425. protected $branches;
  32426. protected $rootIdentifier;
  32427. protected $repoDir;
  32428. public function initialize(): void
  32429. {
  32430. if (Filesystem::isLocalPath($this->url)) {
  32431. $this->repoDir = $this->url;
  32432. } else {
  32433. if (!Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  32434. throw new \RuntimeException('HgDriver requires a usable cache directory, and it looks like you set it to be disabled');
  32435. }
  32436. $cacheDir = $this->config->get('cache-vcs-dir');
  32437. $this->repoDir = $cacheDir . '/' . Preg::replace('{[^a-z0-9]}i', '-', $this->url) . '/';
  32438. $fs = new Filesystem();
  32439. $fs->ensureDirectoryExists($cacheDir);
  32440. if (!is_writable(dirname($this->repoDir))) {
  32441. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.$cacheDir.'" directory is not writable by the current user.');
  32442. }
  32443. $this->config->prohibitUrlByConfig($this->url, $this->io);
  32444. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  32445. if (is_dir($this->repoDir) && 0 === $this->process->execute('hg summary', $output, $this->repoDir)) {
  32446. if (0 !== $this->process->execute('hg pull', $output, $this->repoDir)) {
  32447. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')</error>');
  32448. }
  32449. } else {
  32450. $fs->removeDirectory($this->repoDir);
  32451. $repoDir = $this->repoDir;
  32452. $command = static function ($url) use ($repoDir): string {
  32453. return sprintf('hg clone --noupdate -- %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($repoDir));
  32454. };
  32455. $hgUtils->runCommand($command, $this->url, null);
  32456. }
  32457. }
  32458. $this->getTags();
  32459. $this->getBranches();
  32460. }
  32461. public function getRootIdentifier(): string
  32462. {
  32463. if (null === $this->rootIdentifier) {
  32464. $this->process->execute('hg tip --template "{node}"', $output, $this->repoDir);
  32465. $output = $this->process->splitLines($output);
  32466. $this->rootIdentifier = $output[0];
  32467. }
  32468. return $this->rootIdentifier;
  32469. }
  32470. public function getUrl(): string
  32471. {
  32472. return $this->url;
  32473. }
  32474. public function getSource(string $identifier): array
  32475. {
  32476. return ['type' => 'hg', 'url' => $this->getUrl(), 'reference' => $identifier];
  32477. }
  32478. public function getDist(string $identifier): ?array
  32479. {
  32480. return null;
  32481. }
  32482. public function getFileContent(string $file, string $identifier): ?string
  32483. {
  32484. if (isset($identifier[0]) && $identifier[0] === '-') {
  32485. throw new \RuntimeException('Invalid hg identifier detected. Identifier must not start with a -, given: ' . $identifier);
  32486. }
  32487. $resource = sprintf('hg cat -r %s -- %s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  32488. $this->process->execute($resource, $content, $this->repoDir);
  32489. if (!trim($content)) {
  32490. return null;
  32491. }
  32492. return $content;
  32493. }
  32494. public function getChangeDate(string $identifier): ?\DateTimeImmutable
  32495. {
  32496. $this->process->execute(
  32497. sprintf(
  32498. 'hg log --template "{date|rfc3339date}" -r %s',
  32499. ProcessExecutor::escape($identifier)
  32500. ),
  32501. $output,
  32502. $this->repoDir
  32503. );
  32504. return new \DateTimeImmutable(trim($output), new \DateTimeZone('UTC'));
  32505. }
  32506. public function getTags(): array
  32507. {
  32508. if (null === $this->tags) {
  32509. $tags = [];
  32510. $this->process->execute('hg tags', $output, $this->repoDir);
  32511. foreach ($this->process->splitLines($output) as $tag) {
  32512. if ($tag && Preg::isMatchStrictGroups('(^([^\s]+)\s+\d+:(.*)$)', $tag, $match)) {
  32513. $tags[$match[1]] = $match[2];
  32514. }
  32515. }
  32516. unset($tags['tip']);
  32517. $this->tags = $tags;
  32518. }
  32519. return $this->tags;
  32520. }
  32521. public function getBranches(): array
  32522. {
  32523. if (null === $this->branches) {
  32524. $branches = [];
  32525. $bookmarks = [];
  32526. $this->process->execute('hg branches', $output, $this->repoDir);
  32527. foreach ($this->process->splitLines($output) as $branch) {
  32528. if ($branch && Preg::isMatchStrictGroups('(^([^\s]+)\s+\d+:([a-f0-9]+))', $branch, $match) && $match[1][0] !== '-') {
  32529. $branches[$match[1]] = $match[2];
  32530. }
  32531. }
  32532. $this->process->execute('hg bookmarks', $output, $this->repoDir);
  32533. foreach ($this->process->splitLines($output) as $branch) {
  32534. if ($branch && Preg::isMatchStrictGroups('(^(?:[\s*]*)([^\s]+)\s+\d+:(.*)$)', $branch, $match) && $match[1][0] !== '-') {
  32535. $bookmarks[$match[1]] = $match[2];
  32536. }
  32537. }
  32538. $this->branches = array_merge($bookmarks, $branches);
  32539. }
  32540. return $this->branches;
  32541. }
  32542. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
  32543. {
  32544. if (Preg::isMatch('#(^(?:https?|ssh)://(?:[^@]+@)?bitbucket.org|https://(?:.*?)\.kilnhg.com)#i', $url)) {
  32545. return true;
  32546. }
  32547. if (Filesystem::isLocalPath($url)) {
  32548. $url = Filesystem::getPlatformPath($url);
  32549. if (!is_dir($url)) {
  32550. return false;
  32551. }
  32552. $process = new ProcessExecutor($io);
  32553. if ($process->execute('hg summary', $output, $url) === 0) {
  32554. return true;
  32555. }
  32556. }
  32557. if (!$deep) {
  32558. return false;
  32559. }
  32560. $process = new ProcessExecutor($io);
  32561. $exit = $process->execute(sprintf('hg identify -- %s', ProcessExecutor::escape($url)), $ignored);
  32562. return $exit === 0;
  32563. }
  32564. }
  32565. <?php declare(strict_types=1);
  32566. namespace Composer\Repository\Vcs;
  32567. use Composer\Config;
  32568. use Composer\Cache;
  32569. use Composer\IO\IOInterface;
  32570. use Composer\Pcre\Preg;
  32571. use Composer\Util\ProcessExecutor;
  32572. use Composer\Util\Perforce;
  32573. use Composer\Util\Http\Response;
  32574. class PerforceDriver extends VcsDriver
  32575. {
  32576. protected $depot;
  32577. protected $branch;
  32578. protected $perforce = null;
  32579. public function initialize(): void
  32580. {
  32581. $this->depot = $this->repoConfig['depot'];
  32582. $this->branch = '';
  32583. if (!empty($this->repoConfig['branch'])) {
  32584. $this->branch = $this->repoConfig['branch'];
  32585. }
  32586. $this->initPerforce($this->repoConfig);
  32587. $this->perforce->p4Login();
  32588. $this->perforce->checkStream();
  32589. $this->perforce->writeP4ClientSpec();
  32590. $this->perforce->connectClient();
  32591. }
  32592. private function initPerforce(array $repoConfig): void
  32593. {
  32594. if (!empty($this->perforce)) {
  32595. return;
  32596. }
  32597. if (!Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  32598. throw new \RuntimeException('PerforceDriver requires a usable cache directory, and it looks like you set it to be disabled');
  32599. }
  32600. $repoDir = $this->config->get('cache-vcs-dir') . '/' . $this->depot;
  32601. $this->perforce = Perforce::create($repoConfig, $this->getUrl(), $repoDir, $this->process, $this->io);
  32602. }
  32603. public function getFileContent(string $file, string $identifier): ?string
  32604. {
  32605. return $this->perforce->getFileContent($file, $identifier);
  32606. }
  32607. public function getChangeDate(string $identifier): ?\DateTimeImmutable
  32608. {
  32609. return null;
  32610. }
  32611. public function getRootIdentifier(): string
  32612. {
  32613. return $this->branch;
  32614. }
  32615. public function getBranches(): array
  32616. {
  32617. return $this->perforce->getBranches();
  32618. }
  32619. public function getTags(): array
  32620. {
  32621. return $this->perforce->getTags();
  32622. }
  32623. public function getDist(string $identifier): ?array
  32624. {
  32625. return null;
  32626. }
  32627. public function getSource(string $identifier): array
  32628. {
  32629. return [
  32630. 'type' => 'perforce',
  32631. 'url' => $this->repoConfig['url'],
  32632. 'reference' => $identifier,
  32633. 'p4user' => $this->perforce->getUser(),
  32634. ];
  32635. }
  32636. public function getUrl(): string
  32637. {
  32638. return $this->url;
  32639. }
  32640. public function hasComposerFile(string $identifier): bool
  32641. {
  32642. $composerInfo = $this->perforce->getComposerInformation('//' . $this->depot . '/' . $identifier);
  32643. return !empty($composerInfo);
  32644. }
  32645. public function getContents(string $url): Response
  32646. {
  32647. throw new \BadMethodCallException('Not implemented/used in PerforceDriver');
  32648. }
  32649. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
  32650. {
  32651. if ($deep || Preg::isMatch('#\b(perforce|p4)\b#i', $url)) {
  32652. return Perforce::checkServerExists($url, new ProcessExecutor($io));
  32653. }
  32654. return false;
  32655. }
  32656. public function cleanup(): void
  32657. {
  32658. $this->perforce->cleanupClientSpec();
  32659. $this->perforce = null;
  32660. }
  32661. public function getDepot(): string
  32662. {
  32663. return $this->depot;
  32664. }
  32665. public function getBranch(): string
  32666. {
  32667. return $this->branch;
  32668. }
  32669. }
  32670. <?php declare(strict_types=1);
  32671. namespace Composer\Repository\Vcs;
  32672. use Composer\Cache;
  32673. use Composer\Config;
  32674. use Composer\Json\JsonFile;
  32675. use Composer\Pcre\Preg;
  32676. use Composer\Util\ProcessExecutor;
  32677. use Composer\Util\Filesystem;
  32678. use Composer\Util\Url;
  32679. use Composer\Util\Svn as SvnUtil;
  32680. use Composer\IO\IOInterface;
  32681. use Composer\Downloader\TransportException;
  32682. class SvnDriver extends VcsDriver
  32683. {
  32684. protected $baseUrl;
  32685. protected $tags;
  32686. protected $branches;
  32687. protected $rootIdentifier;
  32688. protected $trunkPath = 'trunk';
  32689. protected $branchesPath = 'branches';
  32690. protected $tagsPath = 'tags';
  32691. protected $packagePath = '';
  32692. protected $cacheCredentials = true;
  32693. private $util;
  32694. public function initialize(): void
  32695. {
  32696. $this->url = $this->baseUrl = rtrim(self::normalizeUrl($this->url), '/');
  32697. SvnUtil::cleanEnv();
  32698. if (isset($this->repoConfig['trunk-path'])) {
  32699. $this->trunkPath = $this->repoConfig['trunk-path'];
  32700. }
  32701. if (isset($this->repoConfig['branches-path'])) {
  32702. $this->branchesPath = $this->repoConfig['branches-path'];
  32703. }
  32704. if (isset($this->repoConfig['tags-path'])) {
  32705. $this->tagsPath = $this->repoConfig['tags-path'];
  32706. }
  32707. if (array_key_exists('svn-cache-credentials', $this->repoConfig)) {
  32708. $this->cacheCredentials = (bool) $this->repoConfig['svn-cache-credentials'];
  32709. }
  32710. if (isset($this->repoConfig['package-path'])) {
  32711. $this->packagePath = '/' . trim($this->repoConfig['package-path'], '/');
  32712. }
  32713. if (false !== ($pos = strrpos($this->url, '/' . $this->trunkPath))) {
  32714. $this->baseUrl = substr($this->url, 0, $pos);
  32715. }
  32716. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', Url::sanitize($this->baseUrl)));
  32717. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  32718. $this->getBranches();
  32719. $this->getTags();
  32720. }
  32721. public function getRootIdentifier(): string
  32722. {
  32723. return $this->rootIdentifier ?: $this->trunkPath;
  32724. }
  32725. public function getUrl(): string
  32726. {
  32727. return $this->url;
  32728. }
  32729. public function getSource(string $identifier): array
  32730. {
  32731. return ['type' => 'svn', 'url' => $this->baseUrl, 'reference' => $identifier];
  32732. }
  32733. public function getDist(string $identifier): ?array
  32734. {
  32735. return null;
  32736. }
  32737. protected function shouldCache(string $identifier): bool
  32738. {
  32739. return $this->cache && Preg::isMatch('{@\d+$}', $identifier);
  32740. }
  32741. public function getComposerInformation(string $identifier): ?array
  32742. {
  32743. if (!isset($this->infoCache[$identifier])) {
  32744. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier.'.json')) {
  32745. if ($res === '""') {
  32746. $res = 'null';
  32747. $this->cache->write($identifier.'.json', json_encode(null));
  32748. }
  32749. return $this->infoCache[$identifier] = JsonFile::parseJson($res);
  32750. }
  32751. try {
  32752. $composer = $this->getBaseComposerInformation($identifier);
  32753. } catch (TransportException $e) {
  32754. $message = $e->getMessage();
  32755. if (stripos($message, 'path not found') === false && stripos($message, 'svn: warning: W160013') === false) {
  32756. throw $e;
  32757. }
  32758. $composer = null;
  32759. }
  32760. if ($this->shouldCache($identifier)) {
  32761. $this->cache->write($identifier.'.json', json_encode($composer));
  32762. }
  32763. $this->infoCache[$identifier] = $composer;
  32764. }
  32765. if (!is_array($this->infoCache[$identifier])) {
  32766. return null;
  32767. }
  32768. return $this->infoCache[$identifier];
  32769. }
  32770. public function getFileContent(string $file, string $identifier): ?string
  32771. {
  32772. $identifier = '/' . trim($identifier, '/') . '/';
  32773. Preg::match('{^(.+?)(@\d+)?/$}', $identifier, $match);
  32774. if (!empty($match[2])) {
  32775. $path = $match[1];
  32776. $rev = $match[2];
  32777. } else {
  32778. $path = $identifier;
  32779. $rev = '';
  32780. }
  32781. try {
  32782. $resource = $path.$file;
  32783. $output = $this->execute('svn cat', $this->baseUrl . $resource . $rev);
  32784. if (!trim($output)) {
  32785. return null;
  32786. }
  32787. } catch (\RuntimeException $e) {
  32788. throw new TransportException($e->getMessage());
  32789. }
  32790. return $output;
  32791. }
  32792. public function getChangeDate(string $identifier): ?\DateTimeImmutable
  32793. {
  32794. $identifier = '/' . trim($identifier, '/') . '/';
  32795. Preg::match('{^(.+?)(@\d+)?/$}', $identifier, $match);
  32796. if (null !== $match[2] && null !== $match[1]) {
  32797. $path = $match[1];
  32798. $rev = $match[2];
  32799. } else {
  32800. $path = $identifier;
  32801. $rev = '';
  32802. }
  32803. $output = $this->execute('svn info', $this->baseUrl . $path . $rev);
  32804. foreach ($this->process->splitLines($output) as $line) {
  32805. if ($line && Preg::isMatchStrictGroups('{^Last Changed Date: ([^(]+)}', $line, $match)) {
  32806. return new \DateTimeImmutable($match[1], new \DateTimeZone('UTC'));
  32807. }
  32808. }
  32809. return null;
  32810. }
  32811. public function getTags(): array
  32812. {
  32813. if (null === $this->tags) {
  32814. $tags = [];
  32815. if ($this->tagsPath !== false) {
  32816. $output = $this->execute('svn ls --verbose', $this->baseUrl . '/' . $this->tagsPath);
  32817. if ($output) {
  32818. $lastRev = 0;
  32819. foreach ($this->process->splitLines($output) as $line) {
  32820. $line = trim($line);
  32821. if ($line && Preg::isMatch('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  32822. if (isset($match[1], $match[2])) {
  32823. if ($match[2] === './') {
  32824. $lastRev = (int) $match[1];
  32825. } else {
  32826. $tags[rtrim($match[2], '/')] = $this->buildIdentifier(
  32827. '/' . $this->tagsPath . '/' . $match[2],
  32828. max($lastRev, (int) $match[1])
  32829. );
  32830. }
  32831. }
  32832. }
  32833. }
  32834. }
  32835. }
  32836. $this->tags = $tags;
  32837. }
  32838. return $this->tags;
  32839. }
  32840. public function getBranches(): array
  32841. {
  32842. if (null === $this->branches) {
  32843. $branches = [];
  32844. if (false === $this->trunkPath) {
  32845. $trunkParent = $this->baseUrl . '/';
  32846. } else {
  32847. $trunkParent = $this->baseUrl . '/' . $this->trunkPath;
  32848. }
  32849. $output = $this->execute('svn ls --verbose', $trunkParent);
  32850. if ($output) {
  32851. foreach ($this->process->splitLines($output) as $line) {
  32852. $line = trim($line);
  32853. if ($line && Preg::isMatch('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  32854. if (isset($match[1], $match[2]) && $match[2] === './') {
  32855. $branches['trunk'] = $this->buildIdentifier(
  32856. '/' . $this->trunkPath,
  32857. (int) $match[1]
  32858. );
  32859. $this->rootIdentifier = $branches['trunk'];
  32860. break;
  32861. }
  32862. }
  32863. }
  32864. }
  32865. unset($output);
  32866. if ($this->branchesPath !== false) {
  32867. $output = $this->execute('svn ls --verbose', $this->baseUrl . '/' . $this->branchesPath);
  32868. if ($output) {
  32869. $lastRev = 0;
  32870. foreach ($this->process->splitLines(trim($output)) as $line) {
  32871. $line = trim($line);
  32872. if ($line && Preg::isMatch('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  32873. if (isset($match[1], $match[2])) {
  32874. if ($match[2] === './') {
  32875. $lastRev = (int) $match[1];
  32876. } else {
  32877. $branches[rtrim($match[2], '/')] = $this->buildIdentifier(
  32878. '/' . $this->branchesPath . '/' . $match[2],
  32879. max($lastRev, (int) $match[1])
  32880. );
  32881. }
  32882. }
  32883. }
  32884. }
  32885. }
  32886. }
  32887. $this->branches = $branches;
  32888. }
  32889. return $this->branches;
  32890. }
  32891. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
  32892. {
  32893. $url = self::normalizeUrl($url);
  32894. if (Preg::isMatch('#(^svn://|^svn\+ssh://|svn\.)#i', $url)) {
  32895. return true;
  32896. }
  32897. if (!$deep && !Filesystem::isLocalPath($url)) {
  32898. return false;
  32899. }
  32900. $process = new ProcessExecutor($io);
  32901. $exit = $process->execute(
  32902. "svn info --non-interactive -- ".ProcessExecutor::escape($url),
  32903. $ignoredOutput
  32904. );
  32905. if ($exit === 0) {
  32906. return true;
  32907. }
  32908. if (false !== stripos($process->getErrorOutput(), 'authorization failed:')) {
  32909. return true;
  32910. }
  32911. if (false !== stripos($process->getErrorOutput(), 'Authentication failed')) {
  32912. return true;
  32913. }
  32914. return false;
  32915. }
  32916. protected static function normalizeUrl(string $url): string
  32917. {
  32918. $fs = new Filesystem();
  32919. if ($fs->isAbsolutePath($url)) {
  32920. return 'file://' . strtr($url, '\\', '/');
  32921. }
  32922. return $url;
  32923. }
  32924. protected function execute(string $command, string $url): string
  32925. {
  32926. if (null === $this->util) {
  32927. $this->util = new SvnUtil($this->baseUrl, $this->io, $this->config, $this->process);
  32928. $this->util->setCacheCredentials($this->cacheCredentials);
  32929. }
  32930. try {
  32931. return $this->util->execute($command, $url);
  32932. } catch (\RuntimeException $e) {
  32933. if (null === $this->util->binaryVersion()) {
  32934. 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());
  32935. }
  32936. throw new \RuntimeException(
  32937. 'Repository '.$this->url.' could not be processed, '.$e->getMessage()
  32938. );
  32939. }
  32940. }
  32941. protected function buildIdentifier(string $baseDir, int $revision): string
  32942. {
  32943. return rtrim($baseDir, '/') . $this->packagePath . '/@' . $revision;
  32944. }
  32945. }
  32946. <?php declare(strict_types=1);
  32947. namespace Composer\Repository\Vcs;
  32948. use Composer\Cache;
  32949. use Composer\Downloader\TransportException;
  32950. use Composer\Config;
  32951. use Composer\IO\IOInterface;
  32952. use Composer\Json\JsonFile;
  32953. use Composer\Pcre\Preg;
  32954. use Composer\Util\ProcessExecutor;
  32955. use Composer\Util\HttpDownloader;
  32956. use Composer\Util\Filesystem;
  32957. use Composer\Util\Http\Response;
  32958. abstract class VcsDriver implements VcsDriverInterface
  32959. {
  32960. protected $url;
  32961. protected $originUrl;
  32962. protected $repoConfig;
  32963. protected $io;
  32964. protected $config;
  32965. protected $process;
  32966. protected $httpDownloader;
  32967. protected $infoCache = [];
  32968. protected $cache;
  32969. final public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, ProcessExecutor $process)
  32970. {
  32971. if (Filesystem::isLocalPath($repoConfig['url'])) {
  32972. $repoConfig['url'] = Filesystem::getPlatformPath($repoConfig['url']);
  32973. }
  32974. $this->url = $repoConfig['url'];
  32975. $this->originUrl = $repoConfig['url'];
  32976. $this->repoConfig = $repoConfig;
  32977. $this->io = $io;
  32978. $this->config = $config;
  32979. $this->httpDownloader = $httpDownloader;
  32980. $this->process = $process;
  32981. }
  32982. protected function shouldCache(string $identifier): bool
  32983. {
  32984. return $this->cache && Preg::isMatch('{^[a-f0-9]{40}$}iD', $identifier);
  32985. }
  32986. public function getComposerInformation(string $identifier): ?array
  32987. {
  32988. if (!isset($this->infoCache[$identifier])) {
  32989. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  32990. return $this->infoCache[$identifier] = JsonFile::parseJson($res);
  32991. }
  32992. $composer = $this->getBaseComposerInformation($identifier);
  32993. if ($this->shouldCache($identifier)) {
  32994. $this->cache->write($identifier, JsonFile::encode($composer, 0));
  32995. }
  32996. $this->infoCache[$identifier] = $composer;
  32997. }
  32998. return $this->infoCache[$identifier];
  32999. }
  33000. protected function getBaseComposerInformation(string $identifier): ?array
  33001. {
  33002. $composerFileContent = $this->getFileContent('composer.json', $identifier);
  33003. if (!$composerFileContent) {
  33004. return null;
  33005. }
  33006. $composer = JsonFile::parseJson($composerFileContent, $identifier . ':composer.json');
  33007. if ([] === $composer || !is_array($composer)) {
  33008. return null;
  33009. }
  33010. if (empty($composer['time']) && null !== ($changeDate = $this->getChangeDate($identifier))) {
  33011. $composer['time'] = $changeDate->format(DATE_RFC3339);
  33012. }
  33013. return $composer;
  33014. }
  33015. public function hasComposerFile(string $identifier): bool
  33016. {
  33017. try {
  33018. return null !== $this->getComposerInformation($identifier);
  33019. } catch (TransportException $e) {
  33020. }
  33021. return false;
  33022. }
  33023. protected function getScheme(): string
  33024. {
  33025. if (extension_loaded('openssl')) {
  33026. return 'https';
  33027. }
  33028. return 'http';
  33029. }
  33030. protected function getContents(string $url): Response
  33031. {
  33032. $options = $this->repoConfig['options'] ?? [];
  33033. return $this->httpDownloader->get($url, $options);
  33034. }
  33035. public function cleanup(): void
  33036. {
  33037. }
  33038. }
  33039. <?php declare(strict_types=1);
  33040. namespace Composer\Repository\Vcs;
  33041. use Composer\Config;
  33042. use Composer\IO\IOInterface;
  33043. interface VcsDriverInterface
  33044. {
  33045. public function initialize(): void;
  33046. public function getComposerInformation(string $identifier): ?array;
  33047. public function getFileContent(string $file, string $identifier): ?string;
  33048. public function getChangeDate(string $identifier): ?\DateTimeImmutable;
  33049. public function getRootIdentifier(): string;
  33050. public function getBranches(): array;
  33051. public function getTags(): array;
  33052. public function getDist(string $identifier): ?array;
  33053. public function getSource(string $identifier): array;
  33054. public function getUrl(): string;
  33055. public function hasComposerFile(string $identifier): bool;
  33056. public function cleanup(): void;
  33057. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool;
  33058. }
  33059. <?php declare(strict_types=1);
  33060. namespace Composer\Repository;
  33061. use Composer\Downloader\TransportException;
  33062. use Composer\Pcre\Preg;
  33063. use Composer\Repository\Vcs\VcsDriverInterface;
  33064. use Composer\Package\Version\VersionParser;
  33065. use Composer\Package\Loader\ArrayLoader;
  33066. use Composer\Package\Loader\ValidatingArrayLoader;
  33067. use Composer\Package\Loader\InvalidPackageException;
  33068. use Composer\Package\Loader\LoaderInterface;
  33069. use Composer\EventDispatcher\EventDispatcher;
  33070. use Composer\Util\Platform;
  33071. use Composer\Util\ProcessExecutor;
  33072. use Composer\Util\HttpDownloader;
  33073. use Composer\Util\Url;
  33074. use Composer\Semver\Constraint\Constraint;
  33075. use Composer\IO\IOInterface;
  33076. use Composer\Config;
  33077. class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  33078. {
  33079. protected $url;
  33080. protected $packageName;
  33081. protected $isVerbose;
  33082. protected $isVeryVerbose;
  33083. protected $io;
  33084. protected $config;
  33085. protected $versionParser;
  33086. protected $type;
  33087. protected $loader;
  33088. protected $repoConfig;
  33089. protected $httpDownloader;
  33090. protected $processExecutor;
  33091. protected $branchErrorOccurred = false;
  33092. private $drivers;
  33093. private $driver;
  33094. private $versionCache;
  33095. private $emptyReferences = [];
  33096. private $versionTransportExceptions = [];
  33097. public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, ?EventDispatcher $dispatcher = null, ?ProcessExecutor $process = null, ?array $drivers = null, ?VersionCacheInterface $versionCache = null)
  33098. {
  33099. parent::__construct();
  33100. $this->drivers = $drivers ?: [
  33101. 'github' => 'Composer\Repository\Vcs\GitHubDriver',
  33102. 'gitlab' => 'Composer\Repository\Vcs\GitLabDriver',
  33103. 'bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver',
  33104. 'git-bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver',
  33105. 'git' => 'Composer\Repository\Vcs\GitDriver',
  33106. 'hg' => 'Composer\Repository\Vcs\HgDriver',
  33107. 'perforce' => 'Composer\Repository\Vcs\PerforceDriver',
  33108. 'fossil' => 'Composer\Repository\Vcs\FossilDriver',
  33109. 'svn' => 'Composer\Repository\Vcs\SvnDriver',
  33110. ];
  33111. $this->url = $repoConfig['url'] = Platform::expandPath($repoConfig['url']);
  33112. $this->io = $io;
  33113. $this->type = $repoConfig['type'] ?? 'vcs';
  33114. $this->isVerbose = $io->isVerbose();
  33115. $this->isVeryVerbose = $io->isVeryVerbose();
  33116. $this->config = $config;
  33117. $this->repoConfig = $repoConfig;
  33118. $this->versionCache = $versionCache;
  33119. $this->httpDownloader = $httpDownloader;
  33120. $this->processExecutor = $process ?? new ProcessExecutor($io);
  33121. }
  33122. public function getRepoName()
  33123. {
  33124. $driverClass = get_class($this->getDriver());
  33125. $driverType = array_search($driverClass, $this->drivers);
  33126. if (!$driverType) {
  33127. $driverType = $driverClass;
  33128. }
  33129. return 'vcs repo ('.$driverType.' '.Url::sanitize($this->url).')';
  33130. }
  33131. public function getRepoConfig()
  33132. {
  33133. return $this->repoConfig;
  33134. }
  33135. public function setLoader(LoaderInterface $loader): void
  33136. {
  33137. $this->loader = $loader;
  33138. }
  33139. public function getDriver(): ?VcsDriverInterface
  33140. {
  33141. if ($this->driver) {
  33142. return $this->driver;
  33143. }
  33144. if (isset($this->drivers[$this->type])) {
  33145. $class = $this->drivers[$this->type];
  33146. $this->driver = new $class($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  33147. $this->driver->initialize();
  33148. return $this->driver;
  33149. }
  33150. foreach ($this->drivers as $driver) {
  33151. if ($driver::supports($this->io, $this->config, $this->url)) {
  33152. $this->driver = new $driver($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  33153. $this->driver->initialize();
  33154. return $this->driver;
  33155. }
  33156. }
  33157. foreach ($this->drivers as $driver) {
  33158. if ($driver::supports($this->io, $this->config, $this->url, true)) {
  33159. $this->driver = new $driver($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  33160. $this->driver->initialize();
  33161. return $this->driver;
  33162. }
  33163. }
  33164. return null;
  33165. }
  33166. public function hadInvalidBranches(): bool
  33167. {
  33168. return $this->branchErrorOccurred;
  33169. }
  33170. public function getEmptyReferences(): array
  33171. {
  33172. return $this->emptyReferences;
  33173. }
  33174. public function getVersionTransportExceptions(): array
  33175. {
  33176. return $this->versionTransportExceptions;
  33177. }
  33178. protected function initialize()
  33179. {
  33180. parent::initialize();
  33181. $isVerbose = $this->isVerbose;
  33182. $isVeryVerbose = $this->isVeryVerbose;
  33183. $driver = $this->getDriver();
  33184. if (!$driver) {
  33185. throw new \InvalidArgumentException('No driver found to handle VCS repository '.$this->url);
  33186. }
  33187. $this->versionParser = new VersionParser;
  33188. if (!$this->loader) {
  33189. $this->loader = new ArrayLoader($this->versionParser);
  33190. }
  33191. $hasRootIdentifierComposerJson = false;
  33192. try {
  33193. $hasRootIdentifierComposerJson = $driver->hasComposerFile($driver->getRootIdentifier());
  33194. if ($hasRootIdentifierComposerJson) {
  33195. $data = $driver->getComposerInformation($driver->getRootIdentifier());
  33196. $this->packageName = !empty($data['name']) ? $data['name'] : null;
  33197. }
  33198. } catch (\Exception $e) {
  33199. if ($e instanceof TransportException && $this->shouldRethrowTransportException($e)) {
  33200. throw $e;
  33201. }
  33202. if ($isVeryVerbose) {
  33203. $this->io->writeError('<error>Skipped parsing '.$driver->getRootIdentifier().', '.$e->getMessage().'</error>');
  33204. }
  33205. }
  33206. foreach ($driver->getTags() as $tag => $identifier) {
  33207. $tag = (string) $tag;
  33208. $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $tag . '</comment>)';
  33209. if ($isVeryVerbose) {
  33210. $this->io->writeError($msg);
  33211. } elseif ($isVerbose) {
  33212. $this->io->overwriteError($msg, false);
  33213. }
  33214. $tag = str_replace('release-', '', $tag);
  33215. $cachedPackage = $this->getCachedPackageVersion($tag, $identifier, $isVerbose, $isVeryVerbose);
  33216. if ($cachedPackage) {
  33217. $this->addPackage($cachedPackage);
  33218. continue;
  33219. }
  33220. if ($cachedPackage === false) {
  33221. $this->emptyReferences[] = $identifier;
  33222. continue;
  33223. }
  33224. if (!$parsedTag = $this->validateTag($tag)) {
  33225. if ($isVeryVerbose) {
  33226. $this->io->writeError('<warning>Skipped tag '.$tag.', invalid tag name</warning>');
  33227. }
  33228. continue;
  33229. }
  33230. try {
  33231. $data = $driver->getComposerInformation($identifier);
  33232. if (null === $data) {
  33233. if ($isVeryVerbose) {
  33234. $this->io->writeError('<warning>Skipped tag '.$tag.', no composer file</warning>');
  33235. }
  33236. $this->emptyReferences[] = $identifier;
  33237. continue;
  33238. }
  33239. if (isset($data['version'])) {
  33240. $data['version_normalized'] = $this->versionParser->normalize($data['version']);
  33241. } else {
  33242. $data['version'] = $tag;
  33243. $data['version_normalized'] = $parsedTag;
  33244. }
  33245. $data['version'] = Preg::replace('{[.-]?dev$}i', '', $data['version']);
  33246. $data['version_normalized'] = Preg::replace('{(^dev-|[.-]?dev$)}i', '', $data['version_normalized']);
  33247. unset($data['default-branch']);
  33248. if ($data['version_normalized'] !== $parsedTag) {
  33249. if ($isVeryVerbose) {
  33250. if (Preg::isMatch('{(^dev-|[.-]?dev$)}i', $parsedTag)) {
  33251. $this->io->writeError('<warning>Skipped tag '.$tag.', invalid tag name, tags can not use dev prefixes or suffixes</warning>');
  33252. } else {
  33253. $this->io->writeError('<warning>Skipped tag '.$tag.', tag ('.$parsedTag.') does not match version ('.$data['version_normalized'].') in composer.json</warning>');
  33254. }
  33255. }
  33256. continue;
  33257. }
  33258. $tagPackageName = $this->packageName ?: ($data['name'] ?? '');
  33259. if ($existingPackage = $this->findPackage($tagPackageName, $data['version_normalized'])) {
  33260. if ($isVeryVerbose) {
  33261. $this->io->writeError('<warning>Skipped tag '.$tag.', it conflicts with an another tag ('.$existingPackage->getPrettyVersion().') as both resolve to '.$data['version_normalized'].' internally</warning>');
  33262. }
  33263. continue;
  33264. }
  33265. if ($isVeryVerbose) {
  33266. $this->io->writeError('Importing tag '.$tag.' ('.$data['version_normalized'].')');
  33267. }
  33268. $this->addPackage($this->loader->load($this->preProcess($driver, $data, $identifier)));
  33269. } catch (\Exception $e) {
  33270. if ($e instanceof TransportException) {
  33271. $this->versionTransportExceptions['tags'][$tag] = $e;
  33272. if ($e->getCode() === 404) {
  33273. $this->emptyReferences[] = $identifier;
  33274. }
  33275. if ($this->shouldRethrowTransportException($e)) {
  33276. throw $e;
  33277. }
  33278. }
  33279. if ($isVeryVerbose) {
  33280. $this->io->writeError('<warning>Skipped tag '.$tag.', '.($e instanceof TransportException ? 'no composer file was found (' . $e->getCode() . ' HTTP status code)' : $e->getMessage()).'</warning>');
  33281. }
  33282. continue;
  33283. }
  33284. }
  33285. if (!$isVeryVerbose) {
  33286. $this->io->overwriteError('', false);
  33287. }
  33288. $branches = $driver->getBranches();
  33289. if ($hasRootIdentifierComposerJson && isset($branches[$driver->getRootIdentifier()])) {
  33290. $branches = [$driver->getRootIdentifier() => $branches[$driver->getRootIdentifier()]] + $branches;
  33291. }
  33292. foreach ($branches as $branch => $identifier) {
  33293. $branch = (string) $branch;
  33294. $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $branch . '</comment>)';
  33295. if ($isVeryVerbose) {
  33296. $this->io->writeError($msg);
  33297. } elseif ($isVerbose) {
  33298. $this->io->overwriteError($msg, false);
  33299. }
  33300. if (!$parsedBranch = $this->validateBranch($branch)) {
  33301. if ($isVeryVerbose) {
  33302. $this->io->writeError('<warning>Skipped branch '.$branch.', invalid name</warning>');
  33303. }
  33304. continue;
  33305. }
  33306. if (strpos($parsedBranch, 'dev-') === 0 || VersionParser::DEFAULT_BRANCH_ALIAS === $parsedBranch) {
  33307. $version = 'dev-' . $branch;
  33308. } else {
  33309. $prefix = strpos($branch, 'v') === 0 ? 'v' : '';
  33310. $version = $prefix . Preg::replace('{(\.9{7})+}', '.x', $parsedBranch);
  33311. }
  33312. $cachedPackage = $this->getCachedPackageVersion($version, $identifier, $isVerbose, $isVeryVerbose, $driver->getRootIdentifier() === $branch);
  33313. if ($cachedPackage) {
  33314. $this->addPackage($cachedPackage);
  33315. continue;
  33316. }
  33317. if ($cachedPackage === false) {
  33318. $this->emptyReferences[] = $identifier;
  33319. continue;
  33320. }
  33321. try {
  33322. $data = $driver->getComposerInformation($identifier);
  33323. if (null === $data) {
  33324. if ($isVeryVerbose) {
  33325. $this->io->writeError('<warning>Skipped branch '.$branch.', no composer file</warning>');
  33326. }
  33327. $this->emptyReferences[] = $identifier;
  33328. continue;
  33329. }
  33330. $data['version'] = $version;
  33331. $data['version_normalized'] = $parsedBranch;
  33332. unset($data['default-branch']);
  33333. if ($driver->getRootIdentifier() === $branch) {
  33334. $data['default-branch'] = true;
  33335. }
  33336. if ($isVeryVerbose) {
  33337. $this->io->writeError('Importing branch '.$branch.' ('.$data['version'].')');
  33338. }
  33339. $packageData = $this->preProcess($driver, $data, $identifier);
  33340. $package = $this->loader->load($packageData);
  33341. if ($this->loader instanceof ValidatingArrayLoader && \count($this->loader->getWarnings()) > 0) {
  33342. throw new InvalidPackageException($this->loader->getErrors(), $this->loader->getWarnings(), $packageData);
  33343. }
  33344. $this->addPackage($package);
  33345. } catch (TransportException $e) {
  33346. $this->versionTransportExceptions['branches'][$branch] = $e;
  33347. if ($e->getCode() === 404) {
  33348. $this->emptyReferences[] = $identifier;
  33349. }
  33350. if ($this->shouldRethrowTransportException($e)) {
  33351. throw $e;
  33352. }
  33353. if ($isVeryVerbose) {
  33354. $this->io->writeError('<warning>Skipped branch '.$branch.', no composer file was found (' . $e->getCode() . ' HTTP status code)</warning>');
  33355. }
  33356. continue;
  33357. } catch (\Exception $e) {
  33358. if (!$isVeryVerbose) {
  33359. $this->io->writeError('');
  33360. }
  33361. $this->branchErrorOccurred = true;
  33362. $this->io->writeError('<error>Skipped branch '.$branch.', '.$e->getMessage().'</error>');
  33363. $this->io->writeError('');
  33364. continue;
  33365. }
  33366. }
  33367. $driver->cleanup();
  33368. if (!$isVeryVerbose) {
  33369. $this->io->overwriteError('', false);
  33370. }
  33371. if (!$this->getPackages()) {
  33372. throw new InvalidRepositoryException('No valid composer.json was found in any branch or tag of '.$this->url.', could not load a package from it.');
  33373. }
  33374. }
  33375. protected function preProcess(VcsDriverInterface $driver, array $data, string $identifier): array
  33376. {
  33377. $dataPackageName = $data['name'] ?? null;
  33378. $data['name'] = $this->packageName ?: $dataPackageName;
  33379. if (!isset($data['dist'])) {
  33380. $data['dist'] = $driver->getDist($identifier);
  33381. }
  33382. if (!isset($data['source'])) {
  33383. $data['source'] = $driver->getSource($identifier);
  33384. }
  33385. return $data;
  33386. }
  33387. private function validateBranch(string $branch)
  33388. {
  33389. try {
  33390. $normalizedBranch = $this->versionParser->normalizeBranch($branch);
  33391. $this->versionParser->parseConstraints($normalizedBranch);
  33392. return $normalizedBranch;
  33393. } catch (\Exception $e) {
  33394. }
  33395. return false;
  33396. }
  33397. private function validateTag(string $version)
  33398. {
  33399. try {
  33400. return $this->versionParser->normalize($version);
  33401. } catch (\Exception $e) {
  33402. }
  33403. return false;
  33404. }
  33405. private function getCachedPackageVersion(string $version, string $identifier, bool $isVerbose, bool $isVeryVerbose, bool $isDefaultBranch = false)
  33406. {
  33407. if (!$this->versionCache) {
  33408. return null;
  33409. }
  33410. $cachedPackage = $this->versionCache->getVersionPackage($version, $identifier);
  33411. if ($cachedPackage === false) {
  33412. if ($isVeryVerbose) {
  33413. $this->io->writeError('<warning>Skipped '.$version.', no composer file (cached from ref '.$identifier.')</warning>');
  33414. }
  33415. return false;
  33416. }
  33417. if ($cachedPackage) {
  33418. $msg = 'Found cached composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $version . '</comment>)';
  33419. if ($isVeryVerbose) {
  33420. $this->io->writeError($msg);
  33421. } elseif ($isVerbose) {
  33422. $this->io->overwriteError($msg, false);
  33423. }
  33424. unset($cachedPackage['default-branch']);
  33425. if ($isDefaultBranch) {
  33426. $cachedPackage['default-branch'] = true;
  33427. }
  33428. if ($existingPackage = $this->findPackage($cachedPackage['name'], new Constraint('=', $cachedPackage['version_normalized']))) {
  33429. if ($isVeryVerbose) {
  33430. $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>');
  33431. }
  33432. $cachedPackage = null;
  33433. }
  33434. }
  33435. if ($cachedPackage) {
  33436. return $this->loader->load($cachedPackage);
  33437. }
  33438. return null;
  33439. }
  33440. private function shouldRethrowTransportException(TransportException $e): bool
  33441. {
  33442. return in_array($e->getCode(), [401, 403, 429], true) || $e->getCode() >= 500;
  33443. }
  33444. }
  33445. <?php declare(strict_types=1);
  33446. namespace Composer\Repository;
  33447. interface VersionCacheInterface
  33448. {
  33449. public function getVersionPackage(string $version, string $identifier);
  33450. }
  33451. <?php declare(strict_types=1);
  33452. namespace Composer\Repository;
  33453. use Composer\Installer\InstallationManager;
  33454. class WritableArrayRepository extends ArrayRepository implements WritableRepositoryInterface
  33455. {
  33456. use CanonicalPackagesTrait;
  33457. protected $devPackageNames = [];
  33458. private $devMode = null;
  33459. public function getDevMode()
  33460. {
  33461. return $this->devMode;
  33462. }
  33463. public function setDevPackageNames(array $devPackageNames)
  33464. {
  33465. $this->devPackageNames = $devPackageNames;
  33466. }
  33467. public function getDevPackageNames()
  33468. {
  33469. return $this->devPackageNames;
  33470. }
  33471. public function write(bool $devMode, InstallationManager $installationManager)
  33472. {
  33473. $this->devMode = $devMode;
  33474. }
  33475. public function reload()
  33476. {
  33477. $this->devMode = null;
  33478. }
  33479. }
  33480. <?php declare(strict_types=1);
  33481. namespace Composer\Repository;
  33482. use Composer\Package\PackageInterface;
  33483. use Composer\Installer\InstallationManager;
  33484. interface WritableRepositoryInterface extends RepositoryInterface
  33485. {
  33486. public function write(bool $devMode, InstallationManager $installationManager);
  33487. public function addPackage(PackageInterface $package);
  33488. public function removePackage(PackageInterface $package);
  33489. public function getCanonicalPackages();
  33490. public function reload();
  33491. public function setDevPackageNames(array $devPackageNames);
  33492. public function getDevPackageNames();
  33493. }
  33494. <?php declare(strict_types=1);
  33495. namespace Composer\Script;
  33496. use Composer\Composer;
  33497. use Composer\IO\IOInterface;
  33498. use Composer\EventDispatcher\Event as BaseEvent;
  33499. class Event extends BaseEvent
  33500. {
  33501. private $composer;
  33502. private $io;
  33503. private $devMode;
  33504. private $originatingEvent;
  33505. public function __construct(string $name, Composer $composer, IOInterface $io, bool $devMode = false, array $args = [], array $flags = [])
  33506. {
  33507. parent::__construct($name, $args, $flags);
  33508. $this->composer = $composer;
  33509. $this->io = $io;
  33510. $this->devMode = $devMode;
  33511. }
  33512. public function getComposer(): Composer
  33513. {
  33514. return $this->composer;
  33515. }
  33516. public function getIO(): IOInterface
  33517. {
  33518. return $this->io;
  33519. }
  33520. public function isDevMode(): bool
  33521. {
  33522. return $this->devMode;
  33523. }
  33524. public function getOriginatingEvent(): ?BaseEvent
  33525. {
  33526. return $this->originatingEvent;
  33527. }
  33528. public function setOriginatingEvent(BaseEvent $event): self
  33529. {
  33530. $this->originatingEvent = $this->calculateOriginatingEvent($event);
  33531. return $this;
  33532. }
  33533. private function calculateOriginatingEvent(BaseEvent $event): BaseEvent
  33534. {
  33535. if ($event instanceof Event && $event->getOriginatingEvent()) {
  33536. return $this->calculateOriginatingEvent($event->getOriginatingEvent());
  33537. }
  33538. return $event;
  33539. }
  33540. }
  33541. <?php declare(strict_types=1);
  33542. namespace Composer\Script;
  33543. class ScriptEvents
  33544. {
  33545. public const PRE_INSTALL_CMD = 'pre-install-cmd';
  33546. public const POST_INSTALL_CMD = 'post-install-cmd';
  33547. public const PRE_UPDATE_CMD = 'pre-update-cmd';
  33548. public const POST_UPDATE_CMD = 'post-update-cmd';
  33549. public const PRE_STATUS_CMD = 'pre-status-cmd';
  33550. public const POST_STATUS_CMD = 'post-status-cmd';
  33551. public const PRE_AUTOLOAD_DUMP = 'pre-autoload-dump';
  33552. public const POST_AUTOLOAD_DUMP = 'post-autoload-dump';
  33553. public const POST_ROOT_PACKAGE_INSTALL = 'post-root-package-install';
  33554. public const POST_CREATE_PROJECT_CMD = 'post-create-project-cmd';
  33555. public const PRE_ARCHIVE_CMD = 'pre-archive-cmd';
  33556. public const POST_ARCHIVE_CMD = 'post-archive-cmd';
  33557. }
  33558. <?php declare(strict_types=1);
  33559. namespace Composer\SelfUpdate;
  33560. use Composer\Pcre\Preg;
  33561. class Keys
  33562. {
  33563. public static function fingerprint(string $path): string
  33564. {
  33565. $hash = strtoupper(hash('sha256', Preg::replace('{\s}', '', file_get_contents($path))));
  33566. return implode(' ', [
  33567. substr($hash, 0, 8),
  33568. substr($hash, 8, 8),
  33569. substr($hash, 16, 8),
  33570. substr($hash, 24, 8),
  33571. '',
  33572. substr($hash, 32, 8),
  33573. substr($hash, 40, 8),
  33574. substr($hash, 48, 8),
  33575. substr($hash, 56, 8),
  33576. ]);
  33577. }
  33578. }
  33579. <?php declare(strict_types=1);
  33580. namespace Composer\SelfUpdate;
  33581. use Composer\IO\IOInterface;
  33582. use Composer\Pcre\Preg;
  33583. use Composer\Util\HttpDownloader;
  33584. use Composer\Config;
  33585. class Versions
  33586. {
  33587. public static $channels = self::CHANNELS;
  33588. public const CHANNELS = ['stable', 'preview', 'snapshot', '1', '2', '2.2'];
  33589. private $httpDownloader;
  33590. private $config;
  33591. private $channel;
  33592. private $versionsData = null;
  33593. public function __construct(Config $config, HttpDownloader $httpDownloader)
  33594. {
  33595. $this->httpDownloader = $httpDownloader;
  33596. $this->config = $config;
  33597. }
  33598. public function getChannel(): string
  33599. {
  33600. if ($this->channel) {
  33601. return $this->channel;
  33602. }
  33603. $channelFile = $this->config->get('home').'/update-channel';
  33604. if (file_exists($channelFile)) {
  33605. $channel = trim(file_get_contents($channelFile));
  33606. if (in_array($channel, ['stable', 'preview', 'snapshot', '2.2'], true)) {
  33607. return $this->channel = $channel;
  33608. }
  33609. }
  33610. return $this->channel = 'stable';
  33611. }
  33612. public function setChannel(string $channel, ?IOInterface $io = null): void
  33613. {
  33614. if (!in_array($channel, self::CHANNELS, true)) {
  33615. throw new \InvalidArgumentException('Invalid channel '.$channel.', must be one of: ' . implode(', ', self::CHANNELS));
  33616. }
  33617. $channelFile = $this->config->get('home').'/update-channel';
  33618. $this->channel = $channel;
  33619. $storedChannel = Preg::isMatch('{^\d+$}D', $channel) ? 'stable' : $channel;
  33620. $previouslyStored = file_exists($channelFile) ? trim((string) file_get_contents($channelFile)) : null;
  33621. file_put_contents($channelFile, $storedChannel.PHP_EOL);
  33622. if ($io !== null && $previouslyStored !== $storedChannel) {
  33623. $io->writeError('Storing "<info>'.$storedChannel.'</info>" as default update channel for the next self-update run.');
  33624. }
  33625. }
  33626. public function getLatest(?string $channel = null): array
  33627. {
  33628. $versions = $this->getVersionsData();
  33629. foreach ($versions[$channel ?: $this->getChannel()] as $version) {
  33630. if ($version['min-php'] <= PHP_VERSION_ID) {
  33631. return $version;
  33632. }
  33633. }
  33634. throw new \UnexpectedValueException('There is no version of Composer available for your PHP version ('.PHP_VERSION.')');
  33635. }
  33636. private function getVersionsData(): array
  33637. {
  33638. if (null === $this->versionsData) {
  33639. if ($this->config->get('disable-tls') === true) {
  33640. $protocol = 'http';
  33641. } else {
  33642. $protocol = 'https';
  33643. }
  33644. $this->versionsData = $this->httpDownloader->get($protocol . '://getcomposer.org/versions')->decodeJson();
  33645. }
  33646. return $this->versionsData;
  33647. }
  33648. }
  33649. <?php declare(strict_types=1);
  33650. namespace Composer\Util;
  33651. use Composer\Config;
  33652. use Composer\IO\IOInterface;
  33653. use Composer\Downloader\TransportException;
  33654. use Composer\Pcre\Preg;
  33655. class AuthHelper
  33656. {
  33657. protected $io;
  33658. protected $config;
  33659. private $displayedOriginAuthentications = [];
  33660. private $bitbucketRetry = [];
  33661. public function __construct(IOInterface $io, Config $config)
  33662. {
  33663. $this->io = $io;
  33664. $this->config = $config;
  33665. }
  33666. public function storeAuth(string $origin, $storeAuth): void
  33667. {
  33668. $store = false;
  33669. $configSource = $this->config->getAuthConfigSource();
  33670. if ($storeAuth === true) {
  33671. $store = $configSource;
  33672. } elseif ($storeAuth === 'prompt') {
  33673. $answer = $this->io->askAndValidate(
  33674. 'Do you want to store credentials for '.$origin.' in '.$configSource->getName().' ? [Yn] ',
  33675. static function ($value): string {
  33676. $input = strtolower(substr(trim($value), 0, 1));
  33677. if (in_array($input, ['y','n'])) {
  33678. return $input;
  33679. }
  33680. throw new \RuntimeException('Please answer (y)es or (n)o');
  33681. },
  33682. null,
  33683. 'y'
  33684. );
  33685. if ($answer === 'y') {
  33686. $store = $configSource;
  33687. }
  33688. }
  33689. if ($store) {
  33690. $store->addConfigSetting(
  33691. 'http-basic.'.$origin,
  33692. $this->io->getAuthentication($origin)
  33693. );
  33694. }
  33695. }
  33696. public function promptAuthIfNeeded(string $url, string $origin, int $statusCode, ?string $reason = null, array $headers = [], int $retryCount = 0): array
  33697. {
  33698. $storeAuth = false;
  33699. if (in_array($origin, $this->config->get('github-domains'), true)) {
  33700. $gitHubUtil = new GitHub($this->io, $this->config, null);
  33701. $message = "\n";
  33702. $rateLimited = $gitHubUtil->isRateLimited($headers);
  33703. $requiresSso = $gitHubUtil->requiresSso($headers);
  33704. if ($requiresSso) {
  33705. $ssoUrl = $gitHubUtil->getSsoUrl($headers);
  33706. $message = 'GitHub API token requires SSO authorization. Authorize this token at ' . $ssoUrl . "\n";
  33707. $this->io->writeError($message);
  33708. if (!$this->io->isInteractive()) {
  33709. throw new TransportException('Could not authenticate against ' . $origin, 403);
  33710. }
  33711. $this->io->ask('After authorizing your token, confirm that you would like to retry the request');
  33712. return ['retry' => true, 'storeAuth' => $storeAuth];
  33713. }
  33714. if ($rateLimited) {
  33715. $rateLimit = $gitHubUtil->getRateLimit($headers);
  33716. if ($this->io->hasAuthentication($origin)) {
  33717. $message = 'Review your configured GitHub OAuth token or enter a new one to go over the API rate limit.';
  33718. } else {
  33719. $message = 'Create a GitHub OAuth token to go over the API rate limit.';
  33720. }
  33721. $message = sprintf(
  33722. '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.',
  33723. $rateLimit['limit'],
  33724. $rateLimit['reset']
  33725. )."\n";
  33726. } else {
  33727. $message .= 'Could not fetch '.$url.', please ';
  33728. if ($this->io->hasAuthentication($origin)) {
  33729. $message .= 'review your configured GitHub OAuth token or enter a new one to access private repos';
  33730. } else {
  33731. $message .= 'create a GitHub OAuth token to access private repos';
  33732. }
  33733. }
  33734. if (!$gitHubUtil->authorizeOAuth($origin)
  33735. && (!$this->io->isInteractive() || !$gitHubUtil->authorizeOAuthInteractively($origin, $message))
  33736. ) {
  33737. throw new TransportException('Could not authenticate against '.$origin, 401);
  33738. }
  33739. } elseif (in_array($origin, $this->config->get('gitlab-domains'), true)) {
  33740. $message = "\n".'Could not fetch '.$url.', enter your ' . $origin . ' credentials ' .($statusCode === 401 ? 'to access private repos' : 'to go over the API rate limit');
  33741. $gitLabUtil = new GitLab($this->io, $this->config, null);
  33742. $auth = null;
  33743. if ($this->io->hasAuthentication($origin)) {
  33744. $auth = $this->io->getAuthentication($origin);
  33745. if (in_array($auth['password'], ['gitlab-ci-token', 'private-token', 'oauth2'], true)) {
  33746. throw new TransportException("Invalid credentials for '" . $url . "', aborting.", $statusCode);
  33747. }
  33748. }
  33749. if (!$gitLabUtil->authorizeOAuth($origin)
  33750. && (!$this->io->isInteractive() || !$gitLabUtil->authorizeOAuthInteractively(parse_url($url, PHP_URL_SCHEME), $origin, $message))
  33751. ) {
  33752. throw new TransportException('Could not authenticate against '.$origin, 401);
  33753. }
  33754. if ($auth !== null && $this->io->hasAuthentication($origin)) {
  33755. if ($auth === $this->io->getAuthentication($origin)) {
  33756. throw new TransportException("Invalid credentials for '" . $url . "', aborting.", $statusCode);
  33757. }
  33758. }
  33759. } elseif ($origin === 'bitbucket.org' || $origin === 'api.bitbucket.org') {
  33760. $askForOAuthToken = true;
  33761. $origin = 'bitbucket.org';
  33762. if ($this->io->hasAuthentication($origin)) {
  33763. $auth = $this->io->getAuthentication($origin);
  33764. if ($auth['username'] !== 'x-token-auth') {
  33765. $bitbucketUtil = new Bitbucket($this->io, $this->config);
  33766. $accessToken = $bitbucketUtil->requestToken($origin, $auth['username'], $auth['password']);
  33767. if (!empty($accessToken)) {
  33768. $this->io->setAuthentication($origin, 'x-token-auth', $accessToken);
  33769. $askForOAuthToken = false;
  33770. }
  33771. } elseif (!isset($this->bitbucketRetry[$url])) {
  33772. $askForOAuthToken = false;
  33773. $this->bitbucketRetry[$url] = true;
  33774. } else {
  33775. throw new TransportException('Could not authenticate against ' . $origin, 401);
  33776. }
  33777. }
  33778. if ($askForOAuthToken) {
  33779. $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');
  33780. $bitBucketUtil = new Bitbucket($this->io, $this->config);
  33781. if (!$bitBucketUtil->authorizeOAuth($origin)
  33782. && (!$this->io->isInteractive() || !$bitBucketUtil->authorizeOAuthInteractively($origin, $message))
  33783. ) {
  33784. throw new TransportException('Could not authenticate against ' . $origin, 401);
  33785. }
  33786. }
  33787. } else {
  33788. if ($statusCode === 404) {
  33789. return ['retry' => false, 'storeAuth' => false];
  33790. }
  33791. if (!$this->io->isInteractive()) {
  33792. if ($statusCode === 401) {
  33793. $message = "The '" . $url . "' URL required authentication (HTTP 401).\nYou must be using the interactive console to authenticate";
  33794. } elseif ($statusCode === 403) {
  33795. $message = "The '" . $url . "' URL could not be accessed (HTTP 403): " . $reason;
  33796. } else {
  33797. $message = "Unknown error code '" . $statusCode . "', reason: " . $reason;
  33798. }
  33799. throw new TransportException($message, $statusCode);
  33800. }
  33801. if ($this->io->hasAuthentication($origin)) {
  33802. if ($retryCount === 0) {
  33803. return ['retry' => true, 'storeAuth' => false];
  33804. }
  33805. throw new TransportException("Invalid credentials (HTTP $statusCode) for '$url', aborting.", $statusCode);
  33806. }
  33807. $this->io->writeError(' Authentication required (<info>'.$origin.'</info>):');
  33808. $username = $this->io->ask(' Username: ');
  33809. $password = $this->io->askAndHideAnswer(' Password: ');
  33810. $this->io->setAuthentication($origin, $username, $password);
  33811. $storeAuth = $this->config->get('store-auths');
  33812. }
  33813. return ['retry' => true, 'storeAuth' => $storeAuth];
  33814. }
  33815. public function addAuthenticationHeader(array $headers, string $origin, string $url): array
  33816. {
  33817. if ($this->io->hasAuthentication($origin)) {
  33818. $authenticationDisplayMessage = null;
  33819. $auth = $this->io->getAuthentication($origin);
  33820. if ($auth['password'] === 'bearer') {
  33821. $headers[] = 'Authorization: Bearer '.$auth['username'];
  33822. } elseif ('github.com' === $origin && 'x-oauth-basic' === $auth['password']) {
  33823. if (Preg::isMatch('{^https?://api\.github\.com/}', $url)) {
  33824. $headers[] = 'Authorization: token '.$auth['username'];
  33825. $authenticationDisplayMessage = 'Using GitHub token authentication';
  33826. }
  33827. } elseif (
  33828. in_array($origin, $this->config->get('gitlab-domains'), true)
  33829. && in_array($auth['password'], ['oauth2', 'private-token', 'gitlab-ci-token'], true)
  33830. ) {
  33831. if ($auth['password'] === 'oauth2') {
  33832. $headers[] = 'Authorization: Bearer '.$auth['username'];
  33833. $authenticationDisplayMessage = 'Using GitLab OAuth token authentication';
  33834. } else {
  33835. $headers[] = 'PRIVATE-TOKEN: '.$auth['username'];
  33836. $authenticationDisplayMessage = 'Using GitLab private token authentication';
  33837. }
  33838. } elseif (
  33839. 'bitbucket.org' === $origin
  33840. && $url !== Bitbucket::OAUTH2_ACCESS_TOKEN_URL
  33841. && 'x-token-auth' === $auth['username']
  33842. ) {
  33843. if (!$this->isPublicBitBucketDownload($url)) {
  33844. $headers[] = 'Authorization: Bearer ' . $auth['password'];
  33845. $authenticationDisplayMessage = 'Using Bitbucket OAuth token authentication';
  33846. }
  33847. } else {
  33848. $authStr = base64_encode($auth['username'] . ':' . $auth['password']);
  33849. $headers[] = 'Authorization: Basic '.$authStr;
  33850. $authenticationDisplayMessage = 'Using HTTP basic authentication with username "' . $auth['username'] . '"';
  33851. }
  33852. if ($authenticationDisplayMessage && (!isset($this->displayedOriginAuthentications[$origin]) || $this->displayedOriginAuthentications[$origin] !== $authenticationDisplayMessage)) {
  33853. $this->io->writeError($authenticationDisplayMessage, true, IOInterface::DEBUG);
  33854. $this->displayedOriginAuthentications[$origin] = $authenticationDisplayMessage;
  33855. }
  33856. } elseif (in_array($origin, ['api.bitbucket.org', 'api.github.com'], true)) {
  33857. return $this->addAuthenticationHeader($headers, str_replace('api.', '', $origin), $url);
  33858. }
  33859. return $headers;
  33860. }
  33861. public function isPublicBitBucketDownload(string $urlToBitBucketFile): bool
  33862. {
  33863. $domain = parse_url($urlToBitBucketFile, PHP_URL_HOST);
  33864. if (strpos($domain, 'bitbucket.org') === false) {
  33865. return true;
  33866. }
  33867. $path = parse_url($urlToBitBucketFile, PHP_URL_PATH);
  33868. $pathParts = explode('/', $path);
  33869. return count($pathParts) >= 4 && $pathParts[3] === 'downloads';
  33870. }
  33871. }
  33872. <?php declare(strict_types=1);
  33873. namespace Composer\Util;
  33874. use Composer\Factory;
  33875. use Composer\IO\IOInterface;
  33876. use Composer\Config;
  33877. use Composer\Downloader\TransportException;
  33878. class Bitbucket
  33879. {
  33880. private $io;
  33881. private $config;
  33882. private $process;
  33883. private $httpDownloader;
  33884. private $token = null;
  33885. private $time;
  33886. public const OAUTH2_ACCESS_TOKEN_URL = 'https://bitbucket.org/site/oauth2/access_token';
  33887. public function __construct(IOInterface $io, Config $config, ?ProcessExecutor $process = null, ?HttpDownloader $httpDownloader = null, ?int $time = null)
  33888. {
  33889. $this->io = $io;
  33890. $this->config = $config;
  33891. $this->process = $process ?: new ProcessExecutor($io);
  33892. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  33893. $this->time = $time;
  33894. }
  33895. public function getToken(): string
  33896. {
  33897. if (!isset($this->token['access_token'])) {
  33898. return '';
  33899. }
  33900. return $this->token['access_token'];
  33901. }
  33902. public function authorizeOAuth(string $originUrl): bool
  33903. {
  33904. if ($originUrl !== 'bitbucket.org') {
  33905. return false;
  33906. }
  33907. if (0 === $this->process->execute('git config bitbucket.accesstoken', $output)) {
  33908. $this->io->setAuthentication($originUrl, 'x-token-auth', trim($output));
  33909. return true;
  33910. }
  33911. return false;
  33912. }
  33913. private function requestAccessToken(): bool
  33914. {
  33915. try {
  33916. $response = $this->httpDownloader->get(self::OAUTH2_ACCESS_TOKEN_URL, [
  33917. 'retry-auth-failure' => false,
  33918. 'http' => [
  33919. 'method' => 'POST',
  33920. 'content' => 'grant_type=client_credentials',
  33921. ],
  33922. ]);
  33923. $token = $response->decodeJson();
  33924. if (!isset($token['expires_in']) || !isset($token['access_token'])) {
  33925. throw new \LogicException('Expected a token configured with expires_in and access_token present, got '.json_encode($token));
  33926. }
  33927. $this->token = $token;
  33928. } catch (TransportException $e) {
  33929. if ($e->getCode() === 400) {
  33930. $this->io->writeError('<error>Invalid OAuth consumer provided.</error>');
  33931. $this->io->writeError('This can have three reasons:');
  33932. $this->io->writeError('1. You are authenticating with a bitbucket username/password combination');
  33933. $this->io->writeError('2. You are using an OAuth consumer, but didn\'t configure a (dummy) callback url');
  33934. $this->io->writeError('3. You are using an OAuth consumer, but didn\'t configure it as private consumer');
  33935. return false;
  33936. }
  33937. if (in_array($e->getCode(), [403, 401])) {
  33938. $this->io->writeError('<error>Invalid OAuth consumer provided.</error>');
  33939. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  33940. return false;
  33941. }
  33942. throw $e;
  33943. }
  33944. return true;
  33945. }
  33946. public function authorizeOAuthInteractively(string $originUrl, ?string $message = null): bool
  33947. {
  33948. if ($message) {
  33949. $this->io->writeError($message);
  33950. }
  33951. $localAuthConfig = $this->config->getLocalAuthConfigSource();
  33952. $url = 'https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/';
  33953. $this->io->writeError(sprintf('Follow the instructions on %s', $url));
  33954. $this->io->writeError(sprintf('to create a consumer. It will be stored in "%s" for future use by Composer.', ($localAuthConfig !== null ? $localAuthConfig->getName() . ' OR ' : '') . $this->config->getAuthConfigSource()->getName()));
  33955. $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)');
  33956. $storeInLocalAuthConfig = false;
  33957. if ($localAuthConfig !== null) {
  33958. $storeInLocalAuthConfig = $this->io->askConfirmation('A local auth config source was found, do you want to store the token there?', true);
  33959. }
  33960. $consumerKey = trim((string) $this->io->askAndHideAnswer('Consumer Key (hidden): '));
  33961. if (!$consumerKey) {
  33962. $this->io->writeError('<warning>No consumer key given, aborting.</warning>');
  33963. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  33964. return false;
  33965. }
  33966. $consumerSecret = trim((string) $this->io->askAndHideAnswer('Consumer Secret (hidden): '));
  33967. if (!$consumerSecret) {
  33968. $this->io->writeError('<warning>No consumer secret given, aborting.</warning>');
  33969. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  33970. return false;
  33971. }
  33972. $this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret);
  33973. if (!$this->requestAccessToken()) {
  33974. return false;
  33975. }
  33976. $authConfigSource = $storeInLocalAuthConfig && $localAuthConfig !== null ? $localAuthConfig : $this->config->getAuthConfigSource();
  33977. $this->storeInAuthConfig($authConfigSource, $originUrl, $consumerKey, $consumerSecret);
  33978. $this->config->getAuthConfigSource()->removeConfigSetting('http-basic.' . $originUrl);
  33979. $this->io->writeError('<info>Consumer stored successfully.</info>');
  33980. return true;
  33981. }
  33982. public function requestToken(string $originUrl, string $consumerKey, string $consumerSecret): string
  33983. {
  33984. if ($this->token !== null || $this->getTokenFromConfig($originUrl)) {
  33985. return $this->token['access_token'];
  33986. }
  33987. $this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret);
  33988. if (!$this->requestAccessToken()) {
  33989. return '';
  33990. }
  33991. $this->storeInAuthConfig($this->config->getLocalAuthConfigSource() ?? $this->config->getAuthConfigSource(), $originUrl, $consumerKey, $consumerSecret);
  33992. if (!isset($this->token['access_token'])) {
  33993. throw new \LogicException('Failed to initialize token above');
  33994. }
  33995. return $this->token['access_token'];
  33996. }
  33997. private function storeInAuthConfig(Config\ConfigSourceInterface $authConfigSource, string $originUrl, string $consumerKey, string $consumerSecret): void
  33998. {
  33999. $this->config->getConfigSource()->removeConfigSetting('bitbucket-oauth.'.$originUrl);
  34000. if (null === $this->token || !isset($this->token['expires_in'])) {
  34001. throw new \LogicException('Expected a token configured with expires_in present, got '.json_encode($this->token));
  34002. }
  34003. $time = null === $this->time ? time() : $this->time;
  34004. $consumer = [
  34005. "consumer-key" => $consumerKey,
  34006. "consumer-secret" => $consumerSecret,
  34007. "access-token" => $this->token['access_token'],
  34008. "access-token-expiration" => $time + $this->token['expires_in'],
  34009. ];
  34010. $this->config->getAuthConfigSource()->addConfigSetting('bitbucket-oauth.'.$originUrl, $consumer);
  34011. }
  34012. private function getTokenFromConfig(string $originUrl): bool
  34013. {
  34014. $authConfig = $this->config->get('bitbucket-oauth');
  34015. if (
  34016. !isset($authConfig[$originUrl]['access-token'], $authConfig[$originUrl]['access-token-expiration'])
  34017. || time() > $authConfig[$originUrl]['access-token-expiration']
  34018. ) {
  34019. return false;
  34020. }
  34021. $this->token = [
  34022. 'access_token' => $authConfig[$originUrl]['access-token'],
  34023. ];
  34024. return true;
  34025. }
  34026. }
  34027. <?php declare(strict_types=1);
  34028. namespace Composer\Util;
  34029. use Composer\Pcre\Preg;
  34030. class ComposerMirror
  34031. {
  34032. public static function processUrl(string $mirrorUrl, string $packageName, string $version, ?string $reference, ?string $type, ?string $prettyVersion = null): string
  34033. {
  34034. if ($reference) {
  34035. $reference = Preg::isMatch('{^([a-f0-9]*|%reference%)$}', $reference) ? $reference : md5($reference);
  34036. }
  34037. $version = strpos($version, '/') === false ? $version : md5($version);
  34038. $from = ['%package%', '%version%', '%reference%', '%type%'];
  34039. $to = [$packageName, $version, $reference, $type];
  34040. if (null !== $prettyVersion) {
  34041. $from[] = '%prettyVersion%';
  34042. $to[] = $prettyVersion;
  34043. }
  34044. $url = str_replace($from, $to, $mirrorUrl);
  34045. assert($url !== '');
  34046. return $url;
  34047. }
  34048. public static function processGitUrl(string $mirrorUrl, string $packageName, string $url, ?string $type): string
  34049. {
  34050. if (Preg::isMatch('#^(?:(?:https?|git)://github\.com/|git@github\.com:)([^/]+)/(.+?)(?:\.git)?$#', $url, $match)) {
  34051. $url = 'gh-'.$match[1].'/'.$match[2];
  34052. } elseif (Preg::isMatch('#^https://bitbucket\.org/([^/]+)/(.+?)(?:\.git)?/?$#', $url, $match)) {
  34053. $url = 'bb-'.$match[1].'/'.$match[2];
  34054. } else {
  34055. $url = Preg::replace('{[^a-z0-9_.-]}i', '-', trim($url, '/'));
  34056. }
  34057. return str_replace(
  34058. ['%package%', '%normalizedUrl%', '%type%'],
  34059. [$packageName, $url, $type],
  34060. $mirrorUrl
  34061. );
  34062. }
  34063. public static function processHgUrl(string $mirrorUrl, string $packageName, string $url, string $type): string
  34064. {
  34065. return self::processGitUrl($mirrorUrl, $packageName, $url, $type);
  34066. }
  34067. }
  34068. <?php declare(strict_types=1);
  34069. namespace Composer\Util;
  34070. use Composer\Package\Loader\ArrayLoader;
  34071. use Composer\Package\Loader\ValidatingArrayLoader;
  34072. use Composer\Package\Loader\InvalidPackageException;
  34073. use Composer\Json\JsonValidationException;
  34074. use Composer\IO\IOInterface;
  34075. use Composer\Json\JsonFile;
  34076. use Composer\Pcre\Preg;
  34077. use Composer\Spdx\SpdxLicenses;
  34078. use Seld\JsonLint\DuplicateKeyException;
  34079. use Seld\JsonLint\JsonParser;
  34080. class ConfigValidator
  34081. {
  34082. public const CHECK_VERSION = 1;
  34083. private $io;
  34084. public function __construct(IOInterface $io)
  34085. {
  34086. $this->io = $io;
  34087. }
  34088. public function validate(string $file, int $arrayLoaderValidationFlags = ValidatingArrayLoader::CHECK_ALL, int $flags = self::CHECK_VERSION): array
  34089. {
  34090. $errors = [];
  34091. $publishErrors = [];
  34092. $warnings = [];
  34093. $laxValid = false;
  34094. $manifest = null;
  34095. try {
  34096. $json = new JsonFile($file, null, $this->io);
  34097. $manifest = $json->read();
  34098. $json->validateSchema(JsonFile::LAX_SCHEMA);
  34099. $laxValid = true;
  34100. $json->validateSchema();
  34101. } catch (JsonValidationException $e) {
  34102. foreach ($e->getErrors() as $message) {
  34103. if ($laxValid) {
  34104. $publishErrors[] = $message;
  34105. } else {
  34106. $errors[] = $message;
  34107. }
  34108. }
  34109. } catch (\Exception $e) {
  34110. $errors[] = $e->getMessage();
  34111. return [$errors, $publishErrors, $warnings];
  34112. }
  34113. if (is_array($manifest)) {
  34114. $jsonParser = new JsonParser();
  34115. try {
  34116. $jsonParser->parse((string) file_get_contents($file), JsonParser::DETECT_KEY_CONFLICTS);
  34117. } catch (DuplicateKeyException $e) {
  34118. $details = $e->getDetails();
  34119. $warnings[] = 'Key '.$details['key'].' is a duplicate in '.$file.' at line '.$details['line'];
  34120. }
  34121. }
  34122. if (empty($manifest['license'])) {
  34123. $warnings[] = 'No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.';
  34124. } else {
  34125. $licenses = (array) $manifest['license'];
  34126. foreach ($licenses as $key => $license) {
  34127. if ('proprietary' === $license) {
  34128. unset($licenses[$key]);
  34129. }
  34130. }
  34131. $licenseValidator = new SpdxLicenses();
  34132. foreach ($licenses as $license) {
  34133. $spdxLicense = $licenseValidator->getLicenseByIdentifier($license);
  34134. if ($spdxLicense && $spdxLicense[3]) {
  34135. if (Preg::isMatch('{^[AL]?GPL-[123](\.[01])?\+$}i', $license)) {
  34136. $warnings[] = sprintf(
  34137. 'License "%s" is a deprecated SPDX license identifier, use "'.str_replace('+', '', $license).'-or-later" instead',
  34138. $license
  34139. );
  34140. } elseif (Preg::isMatch('{^[AL]?GPL-[123](\.[01])?$}i', $license)) {
  34141. $warnings[] = sprintf(
  34142. 'License "%s" is a deprecated SPDX license identifier, use "'.$license.'-only" or "'.$license.'-or-later" instead',
  34143. $license
  34144. );
  34145. } else {
  34146. $warnings[] = sprintf(
  34147. 'License "%s" is a deprecated SPDX license identifier, see https://spdx.org/licenses/',
  34148. $license
  34149. );
  34150. }
  34151. }
  34152. }
  34153. }
  34154. if (($flags & self::CHECK_VERSION) && isset($manifest['version'])) {
  34155. $warnings[] = 'The version field is present, it is recommended to leave it out if the package is published on Packagist.';
  34156. }
  34157. if (!empty($manifest['name']) && Preg::isMatch('{[A-Z]}', $manifest['name'])) {
  34158. $suggestName = Preg::replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $manifest['name']);
  34159. $suggestName = strtolower($suggestName);
  34160. $publishErrors[] = sprintf(
  34161. '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.',
  34162. $manifest['name'],
  34163. $suggestName
  34164. );
  34165. }
  34166. if (!empty($manifest['type']) && $manifest['type'] === 'composer-installer') {
  34167. $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.";
  34168. }
  34169. if (isset($manifest['require'], $manifest['require-dev'])) {
  34170. $requireOverrides = array_intersect_key($manifest['require'], $manifest['require-dev']);
  34171. if (!empty($requireOverrides)) {
  34172. $plural = (count($requireOverrides) > 1) ? 'are' : 'is';
  34173. $warnings[] = implode(', ', array_keys($requireOverrides)). " {$plural} required both in require and require-dev, this can lead to unexpected behavior";
  34174. }
  34175. }
  34176. foreach (['provide', 'replace'] as $linkType) {
  34177. if (isset($manifest[$linkType])) {
  34178. foreach (['require', 'require-dev'] as $requireType) {
  34179. if (isset($manifest[$requireType])) {
  34180. foreach ($manifest[$linkType] as $provide => $constraint) {
  34181. if (isset($manifest[$requireType][$provide])) {
  34182. $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.';
  34183. }
  34184. }
  34185. }
  34186. }
  34187. }
  34188. }
  34189. $require = $manifest['require'] ?? [];
  34190. $requireDev = $manifest['require-dev'] ?? [];
  34191. $packages = array_merge($require, $requireDev);
  34192. foreach ($packages as $package => $version) {
  34193. if (Preg::isMatch('/#/', $version)) {
  34194. $warnings[] = sprintf(
  34195. 'The package "%s" is pointing to a commit-ref, this is bad practice and can cause unforeseen issues.',
  34196. $package
  34197. );
  34198. }
  34199. }
  34200. $scriptsDescriptions = $manifest['scripts-descriptions'] ?? [];
  34201. $scripts = $manifest['scripts'] ?? [];
  34202. foreach ($scriptsDescriptions as $scriptName => $scriptDescription) {
  34203. if (!array_key_exists($scriptName, $scripts)) {
  34204. $warnings[] = sprintf(
  34205. 'Description for non-existent script "%s" found in "scripts-descriptions"',
  34206. $scriptName
  34207. );
  34208. }
  34209. }
  34210. if (isset($manifest['autoload']['psr-0'][''])) {
  34211. $warnings[] = "Defining autoload.psr-0 with an empty namespace prefix is a bad idea for performance";
  34212. }
  34213. if (isset($manifest['autoload']['psr-4'][''])) {
  34214. $warnings[] = "Defining autoload.psr-4 with an empty namespace prefix is a bad idea for performance";
  34215. }
  34216. $loader = new ValidatingArrayLoader(new ArrayLoader(), true, null, $arrayLoaderValidationFlags);
  34217. try {
  34218. if (!isset($manifest['version'])) {
  34219. $manifest['version'] = '1.0.0';
  34220. }
  34221. if (!isset($manifest['name'])) {
  34222. $manifest['name'] = 'dummy/dummy';
  34223. }
  34224. $loader->load($manifest);
  34225. } catch (InvalidPackageException $e) {
  34226. $errors = array_merge($errors, $e->getErrors());
  34227. }
  34228. $warnings = array_merge($warnings, $loader->getWarnings());
  34229. return [$errors, $publishErrors, $warnings];
  34230. }
  34231. }
  34232. <?php declare(strict_types=1);
  34233. namespace Composer\Util;
  34234. use Composer\IO\IOInterface;
  34235. class ErrorHandler
  34236. {
  34237. private static $io;
  34238. public static function handle(int $level, string $message, string $file, int $line): bool
  34239. {
  34240. $isDeprecationNotice = $level === E_DEPRECATED || $level === E_USER_DEPRECATED;
  34241. if (!$isDeprecationNotice && !(error_reporting() & $level)) {
  34242. return true;
  34243. }
  34244. if (filter_var(ini_get('xdebug.scream'), FILTER_VALIDATE_BOOLEAN)) {
  34245. $message .= "\n\nWarning: You have xdebug.scream enabled, the warning above may be".
  34246. "\na legitimately suppressed error that you were not supposed to see.";
  34247. }
  34248. if (!$isDeprecationNotice) {
  34249. throw new \ErrorException($message, 0, $level, $file, $line);
  34250. }
  34251. if (self::$io) {
  34252. self::$io->writeError('<warning>Deprecation Notice: '.$message.' in '.$file.':'.$line.'</warning>');
  34253. if (self::$io->isVerbose()) {
  34254. self::$io->writeError('<warning>Stack trace:</warning>');
  34255. self::$io->writeError(array_filter(array_map(static function ($a): ?string {
  34256. if (isset($a['line'], $a['file'])) {
  34257. return '<warning> '.$a['file'].':'.$a['line'].'</warning>';
  34258. }
  34259. return null;
  34260. }, array_slice(debug_backtrace(), 2))));
  34261. }
  34262. }
  34263. return true;
  34264. }
  34265. public static function register(?IOInterface $io = null): void
  34266. {
  34267. set_error_handler([__CLASS__, 'handle']);
  34268. error_reporting(E_ALL | E_STRICT);
  34269. self::$io = $io;
  34270. }
  34271. }
  34272. <?php declare(strict_types=1);
  34273. namespace Composer\Util;
  34274. use Composer\Pcre\Preg;
  34275. use React\Promise\PromiseInterface;
  34276. use RecursiveDirectoryIterator;
  34277. use RecursiveIteratorIterator;
  34278. use Symfony\Component\Filesystem\Exception\IOException;
  34279. use Symfony\Component\Finder\Finder;
  34280. class Filesystem
  34281. {
  34282. private $processExecutor;
  34283. public function __construct(?ProcessExecutor $executor = null)
  34284. {
  34285. $this->processExecutor = $executor;
  34286. }
  34287. public function remove(string $file)
  34288. {
  34289. if (is_dir($file)) {
  34290. return $this->removeDirectory($file);
  34291. }
  34292. if (file_exists($file)) {
  34293. return $this->unlink($file);
  34294. }
  34295. return false;
  34296. }
  34297. public function isDirEmpty(string $dir)
  34298. {
  34299. $finder = Finder::create()
  34300. ->ignoreVCS(false)
  34301. ->ignoreDotFiles(false)
  34302. ->depth(0)
  34303. ->in($dir);
  34304. return \count($finder) === 0;
  34305. }
  34306. public function emptyDirectory(string $dir, bool $ensureDirectoryExists = true)
  34307. {
  34308. if (is_link($dir) && file_exists($dir)) {
  34309. $this->unlink($dir);
  34310. }
  34311. if ($ensureDirectoryExists) {
  34312. $this->ensureDirectoryExists($dir);
  34313. }
  34314. if (is_dir($dir)) {
  34315. $finder = Finder::create()
  34316. ->ignoreVCS(false)
  34317. ->ignoreDotFiles(false)
  34318. ->depth(0)
  34319. ->in($dir);
  34320. foreach ($finder as $path) {
  34321. $this->remove((string) $path);
  34322. }
  34323. }
  34324. }
  34325. public function removeDirectory(string $directory)
  34326. {
  34327. $edgeCaseResult = $this->removeEdgeCases($directory);
  34328. if ($edgeCaseResult !== null) {
  34329. return $edgeCaseResult;
  34330. }
  34331. if (Platform::isWindows()) {
  34332. $cmd = sprintf('rmdir /S /Q %s', ProcessExecutor::escape(realpath($directory)));
  34333. } else {
  34334. $cmd = sprintf('rm -rf %s', ProcessExecutor::escape($directory));
  34335. }
  34336. $result = $this->getProcess()->execute($cmd, $output) === 0;
  34337. clearstatcache();
  34338. if ($result && !is_dir($directory)) {
  34339. return true;
  34340. }
  34341. return $this->removeDirectoryPhp($directory);
  34342. }
  34343. public function removeDirectoryAsync(string $directory)
  34344. {
  34345. $edgeCaseResult = $this->removeEdgeCases($directory);
  34346. if ($edgeCaseResult !== null) {
  34347. return \React\Promise\resolve($edgeCaseResult);
  34348. }
  34349. if (Platform::isWindows()) {
  34350. $cmd = sprintf('rmdir /S /Q %s', ProcessExecutor::escape(realpath($directory)));
  34351. } else {
  34352. $cmd = sprintf('rm -rf %s', ProcessExecutor::escape($directory));
  34353. }
  34354. $promise = $this->getProcess()->executeAsync($cmd);
  34355. return $promise->then(function ($process) use ($directory) {
  34356. clearstatcache();
  34357. if ($process->isSuccessful()) {
  34358. if (!is_dir($directory)) {
  34359. return \React\Promise\resolve(true);
  34360. }
  34361. }
  34362. return \React\Promise\resolve($this->removeDirectoryPhp($directory));
  34363. });
  34364. }
  34365. private function removeEdgeCases(string $directory, bool $fallbackToPhp = true): ?bool
  34366. {
  34367. if ($this->isSymlinkedDirectory($directory)) {
  34368. return $this->unlinkSymlinkedDirectory($directory);
  34369. }
  34370. if ($this->isJunction($directory)) {
  34371. return $this->removeJunction($directory);
  34372. }
  34373. if (is_link($directory)) {
  34374. return unlink($directory);
  34375. }
  34376. if (!is_dir($directory) || !file_exists($directory)) {
  34377. return true;
  34378. }
  34379. if (Preg::isMatch('{^(?:[a-z]:)?[/\\\\]+$}i', $directory)) {
  34380. throw new \RuntimeException('Aborting an attempted deletion of '.$directory.', this was probably not intended, if it is a real use case please report it.');
  34381. }
  34382. if (!\function_exists('proc_open') && $fallbackToPhp) {
  34383. return $this->removeDirectoryPhp($directory);
  34384. }
  34385. return null;
  34386. }
  34387. public function removeDirectoryPhp(string $directory)
  34388. {
  34389. $edgeCaseResult = $this->removeEdgeCases($directory, false);
  34390. if ($edgeCaseResult !== null) {
  34391. return $edgeCaseResult;
  34392. }
  34393. try {
  34394. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  34395. } catch (\UnexpectedValueException $e) {
  34396. clearstatcache();
  34397. usleep(100000);
  34398. if (!is_dir($directory)) {
  34399. return true;
  34400. }
  34401. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  34402. }
  34403. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
  34404. foreach ($ri as $file) {
  34405. if ($file->isDir()) {
  34406. $this->rmdir($file->getPathname());
  34407. } else {
  34408. $this->unlink($file->getPathname());
  34409. }
  34410. }
  34411. unset($ri, $it, $file);
  34412. return $this->rmdir($directory);
  34413. }
  34414. public function ensureDirectoryExists(string $directory)
  34415. {
  34416. if (!is_dir($directory)) {
  34417. if (file_exists($directory)) {
  34418. throw new \RuntimeException(
  34419. $directory.' exists and is not a directory.'
  34420. );
  34421. }
  34422. if (is_link($directory) && !@$this->unlinkImplementation($directory)) {
  34423. throw new \RuntimeException('Could not delete symbolic link '.$directory.': '.(error_get_last()['message'] ?? ''));
  34424. }
  34425. if (!@mkdir($directory, 0777, true)) {
  34426. throw new \RuntimeException($directory.' does not exist and could not be created: '.(error_get_last()['message'] ?? ''));
  34427. }
  34428. }
  34429. }
  34430. public function unlink(string $path)
  34431. {
  34432. $unlinked = @$this->unlinkImplementation($path);
  34433. if (!$unlinked) {
  34434. if (Platform::isWindows()) {
  34435. usleep(350000);
  34436. $unlinked = @$this->unlinkImplementation($path);
  34437. }
  34438. if (!$unlinked) {
  34439. $error = error_get_last();
  34440. $message = 'Could not delete '.$path.': ' . ($error['message'] ?? '');
  34441. if (Platform::isWindows()) {
  34442. $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed";
  34443. }
  34444. throw new \RuntimeException($message);
  34445. }
  34446. }
  34447. return true;
  34448. }
  34449. public function rmdir(string $path)
  34450. {
  34451. $deleted = @rmdir($path);
  34452. if (!$deleted) {
  34453. if (Platform::isWindows()) {
  34454. usleep(350000);
  34455. $deleted = @rmdir($path);
  34456. }
  34457. if (!$deleted) {
  34458. $error = error_get_last();
  34459. $message = 'Could not delete '.$path.': ' . ($error['message'] ?? '');
  34460. if (Platform::isWindows()) {
  34461. $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed";
  34462. }
  34463. throw new \RuntimeException($message);
  34464. }
  34465. }
  34466. return true;
  34467. }
  34468. public function copyThenRemove(string $source, string $target)
  34469. {
  34470. $this->copy($source, $target);
  34471. if (!is_dir($source)) {
  34472. $this->unlink($source);
  34473. return;
  34474. }
  34475. $this->removeDirectoryPhp($source);
  34476. }
  34477. public function copy(string $source, string $target)
  34478. {
  34479. if (!is_dir($source)) {
  34480. return copy($source, $target);
  34481. }
  34482. $it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
  34483. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);
  34484. $this->ensureDirectoryExists($target);
  34485. $result = true;
  34486. foreach ($ri as $file) {
  34487. $targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathname();
  34488. if ($file->isDir()) {
  34489. $this->ensureDirectoryExists($targetPath);
  34490. } else {
  34491. $result = $result && copy($file->getPathname(), $targetPath);
  34492. }
  34493. }
  34494. return $result;
  34495. }
  34496. public function rename(string $source, string $target)
  34497. {
  34498. if (true === @rename($source, $target)) {
  34499. return;
  34500. }
  34501. if (!\function_exists('proc_open')) {
  34502. $this->copyThenRemove($source, $target);
  34503. return;
  34504. }
  34505. if (Platform::isWindows()) {
  34506. $command = sprintf('xcopy %s %s /E /I /Q /Y', ProcessExecutor::escape($source), ProcessExecutor::escape($target));
  34507. $result = $this->getProcess()->execute($command, $output);
  34508. clearstatcache();
  34509. if (0 === $result) {
  34510. $this->remove($source);
  34511. return;
  34512. }
  34513. } else {
  34514. $command = sprintf('mv %s %s', ProcessExecutor::escape($source), ProcessExecutor::escape($target));
  34515. $result = $this->getProcess()->execute($command, $output);
  34516. clearstatcache();
  34517. if (0 === $result) {
  34518. return;
  34519. }
  34520. }
  34521. $this->copyThenRemove($source, $target);
  34522. }
  34523. public function findShortestPath(string $from, string $to, bool $directories = false)
  34524. {
  34525. if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
  34526. throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
  34527. }
  34528. $from = $this->normalizePath($from);
  34529. $to = $this->normalizePath($to);
  34530. if ($directories) {
  34531. $from = rtrim($from, '/') . '/dummy_file';
  34532. }
  34533. if (\dirname($from) === \dirname($to)) {
  34534. return './'.basename($to);
  34535. }
  34536. $commonPath = $to;
  34537. while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !Preg::isMatch('{^[A-Z]:/?$}i', $commonPath)) {
  34538. $commonPath = strtr(\dirname($commonPath), '\\', '/');
  34539. }
  34540. if (0 !== strpos($from, $commonPath)) {
  34541. return $to;
  34542. }
  34543. $commonPath = rtrim($commonPath, '/') . '/';
  34544. $sourcePathDepth = substr_count((string) substr($from, \strlen($commonPath)), '/');
  34545. $commonPathCode = str_repeat('../', $sourcePathDepth);
  34546. if ('/' === $commonPath && $sourcePathDepth > 1) {
  34547. return $to;
  34548. }
  34549. $result = $commonPathCode . substr($to, \strlen($commonPath));
  34550. if (\strlen($result) === 0) {
  34551. return './';
  34552. }
  34553. return $result;
  34554. }
  34555. public function findShortestPathCode(string $from, string $to, bool $directories = false, bool $staticCode = false)
  34556. {
  34557. if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
  34558. throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
  34559. }
  34560. $from = $this->normalizePath($from);
  34561. $to = $this->normalizePath($to);
  34562. if ($from === $to) {
  34563. return $directories ? '__DIR__' : '__FILE__';
  34564. }
  34565. $commonPath = $to;
  34566. while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !Preg::isMatch('{^[A-Z]:/?$}i', $commonPath) && '.' !== $commonPath) {
  34567. $commonPath = strtr(\dirname($commonPath), '\\', '/');
  34568. }
  34569. if (0 !== strpos($from, $commonPath) || '.' === $commonPath) {
  34570. return var_export($to, true);
  34571. }
  34572. $commonPath = rtrim($commonPath, '/') . '/';
  34573. if (str_starts_with($to, $from.'/')) {
  34574. return '__DIR__ . '.var_export((string) substr($to, \strlen($from)), true);
  34575. }
  34576. $sourcePathDepth = substr_count((string) substr($from, \strlen($commonPath)), '/') + (int) $directories;
  34577. if ('/' === $commonPath && $sourcePathDepth > 1) {
  34578. return var_export($to, true);
  34579. }
  34580. if ($staticCode) {
  34581. $commonPathCode = "__DIR__ . '".str_repeat('/..', $sourcePathDepth)."'";
  34582. } else {
  34583. $commonPathCode = str_repeat('dirname(', $sourcePathDepth).'__DIR__'.str_repeat(')', $sourcePathDepth);
  34584. }
  34585. $relTarget = (string) substr($to, \strlen($commonPath));
  34586. return $commonPathCode . (\strlen($relTarget) > 0 ? '.' . var_export('/' . $relTarget, true) : '');
  34587. }
  34588. public function isAbsolutePath(string $path)
  34589. {
  34590. return strpos($path, '/') === 0 || substr($path, 1, 1) === ':' || strpos($path, '\\\\') === 0;
  34591. }
  34592. public function size(string $path)
  34593. {
  34594. if (!file_exists($path)) {
  34595. throw new \RuntimeException("$path does not exist.");
  34596. }
  34597. if (is_dir($path)) {
  34598. return $this->directorySize($path);
  34599. }
  34600. return (int) filesize($path);
  34601. }
  34602. public function normalizePath(string $path)
  34603. {
  34604. $parts = [];
  34605. $path = strtr($path, '\\', '/');
  34606. $prefix = '';
  34607. $absolute = '';
  34608. if (strpos($path, '//') === 0 && \strlen($path) > 2) {
  34609. $absolute = '//';
  34610. $path = substr($path, 2);
  34611. }
  34612. if (Preg::isMatchStrictGroups('{^( [0-9a-z]{2,}+: (?: // (?: [a-z]: )? )? | [a-z]: )}ix', $path, $match)) {
  34613. $prefix = $match[1];
  34614. $path = substr($path, \strlen($prefix));
  34615. }
  34616. if (strpos($path, '/') === 0) {
  34617. $absolute = '/';
  34618. $path = substr($path, 1);
  34619. }
  34620. $up = false;
  34621. foreach (explode('/', $path) as $chunk) {
  34622. if ('..' === $chunk && (\strlen($absolute) > 0 || $up)) {
  34623. array_pop($parts);
  34624. $up = !(\count($parts) === 0 || '..' === end($parts));
  34625. } elseif ('.' !== $chunk && '' !== $chunk) {
  34626. $parts[] = $chunk;
  34627. $up = '..' !== $chunk;
  34628. }
  34629. }
  34630. $prefix = Preg::replaceCallback('{(^|://)[a-z]:$}i', static function (array $m) {
  34631. assert(is_string($m[0]));
  34632. return strtoupper($m[0]);
  34633. }, $prefix);
  34634. return $prefix.$absolute.implode('/', $parts);
  34635. }
  34636. public static function trimTrailingSlash(string $path)
  34637. {
  34638. if (!Preg::isMatch('{^[/\\\\]+$}', $path)) {
  34639. $path = rtrim($path, '/\\');
  34640. }
  34641. return $path;
  34642. }
  34643. public static function isLocalPath(string $path)
  34644. {
  34645. return Preg::isMatch('{^(file://(?!//)|/(?!/)|/?[a-z]:[\\\\/]|\.\.[\\\\/]|[a-z0-9_.-]+[\\\\/])}i', $path);
  34646. }
  34647. public static function getPlatformPath(string $path)
  34648. {
  34649. if (Platform::isWindows()) {
  34650. $path = Preg::replace('{^(?:file:///([a-z]):?/)}i', 'file://$1:/', $path);
  34651. }
  34652. return Preg::replace('{^file://}i', '', $path);
  34653. }
  34654. public static function isReadable(string $path)
  34655. {
  34656. if (is_readable($path)) {
  34657. return true;
  34658. }
  34659. if (is_file($path)) {
  34660. return false !== Silencer::call('file_get_contents', $path, false, null, 0, 1);
  34661. }
  34662. if (is_dir($path)) {
  34663. return false !== Silencer::call('opendir', $path);
  34664. }
  34665. return false;
  34666. }
  34667. protected function directorySize(string $directory)
  34668. {
  34669. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  34670. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
  34671. $size = 0;
  34672. foreach ($ri as $file) {
  34673. if ($file->isFile()) {
  34674. $size += $file->getSize();
  34675. }
  34676. }
  34677. return $size;
  34678. }
  34679. protected function getProcess()
  34680. {
  34681. if (null === $this->processExecutor) {
  34682. $this->processExecutor = new ProcessExecutor();
  34683. }
  34684. return $this->processExecutor;
  34685. }
  34686. private function unlinkImplementation(string $path): bool
  34687. {
  34688. if (Platform::isWindows() && is_dir($path) && is_link($path)) {
  34689. return rmdir($path);
  34690. }
  34691. return unlink($path);
  34692. }
  34693. public function relativeSymlink(string $target, string $link)
  34694. {
  34695. if (!function_exists('symlink')) {
  34696. return false;
  34697. }
  34698. $cwd = Platform::getCwd();
  34699. $relativePath = $this->findShortestPath($link, $target);
  34700. chdir(\dirname($link));
  34701. $result = @symlink($relativePath, $link);
  34702. chdir($cwd);
  34703. return $result;
  34704. }
  34705. public function isSymlinkedDirectory(string $directory)
  34706. {
  34707. if (!is_dir($directory)) {
  34708. return false;
  34709. }
  34710. $resolved = $this->resolveSymlinkedDirectorySymlink($directory);
  34711. return is_link($resolved);
  34712. }
  34713. private function unlinkSymlinkedDirectory(string $directory): bool
  34714. {
  34715. $resolved = $this->resolveSymlinkedDirectorySymlink($directory);
  34716. return $this->unlink($resolved);
  34717. }
  34718. private function resolveSymlinkedDirectorySymlink(string $pathname): string
  34719. {
  34720. if (!is_dir($pathname)) {
  34721. return $pathname;
  34722. }
  34723. $resolved = rtrim($pathname, '/');
  34724. if (0 === \strlen($resolved)) {
  34725. return $pathname;
  34726. }
  34727. return $resolved;
  34728. }
  34729. public function junction(string $target, string $junction)
  34730. {
  34731. if (!Platform::isWindows()) {
  34732. throw new \LogicException(sprintf('Function %s is not available on non-Windows platform', __CLASS__));
  34733. }
  34734. if (!is_dir($target)) {
  34735. throw new IOException(sprintf('Cannot junction to "%s" as it is not a directory.', $target), 0, null, $target);
  34736. }
  34737. if (!is_dir($junction) || $this->isJunction($junction)) {
  34738. @rmdir($junction);
  34739. }
  34740. $cmd = sprintf(
  34741. 'mklink /J %s %s',
  34742. ProcessExecutor::escape(str_replace('/', DIRECTORY_SEPARATOR, $junction)),
  34743. ProcessExecutor::escape(realpath($target))
  34744. );
  34745. if ($this->getProcess()->execute($cmd, $output) !== 0) {
  34746. throw new IOException(sprintf('Failed to create junction to "%s" at "%s".', $target, $junction), 0, null, $target);
  34747. }
  34748. clearstatcache(true, $junction);
  34749. }
  34750. public function isJunction(string $junction)
  34751. {
  34752. if (!Platform::isWindows()) {
  34753. return false;
  34754. }
  34755. clearstatcache(true, $junction);
  34756. if (!is_dir($junction) || is_link($junction)) {
  34757. return false;
  34758. }
  34759. $stat = lstat($junction);
  34760. return is_array($stat) ? 0x4000 !== ($stat['mode'] & 0xF000) : false;
  34761. }
  34762. public function removeJunction(string $junction)
  34763. {
  34764. if (!Platform::isWindows()) {
  34765. return false;
  34766. }
  34767. $junction = rtrim(str_replace('/', DIRECTORY_SEPARATOR, $junction), DIRECTORY_SEPARATOR);
  34768. if (!$this->isJunction($junction)) {
  34769. throw new IOException(sprintf('%s is not a junction and thus cannot be removed as one', $junction));
  34770. }
  34771. return $this->rmdir($junction);
  34772. }
  34773. public function filePutContentsIfModified(string $path, string $content)
  34774. {
  34775. $currentContent = Silencer::call('file_get_contents', $path);
  34776. if (false === $currentContent || $currentContent !== $content) {
  34777. return file_put_contents($path, $content);
  34778. }
  34779. return 0;
  34780. }
  34781. public function safeCopy(string $source, string $target): void
  34782. {
  34783. if (!file_exists($target) || !file_exists($source) || !$this->filesAreEqual($source, $target)) {
  34784. $sourceHandle = fopen($source, 'r');
  34785. assert($sourceHandle !== false, 'Could not open "'.$source.'" for reading.');
  34786. $targetHandle = fopen($target, 'w+');
  34787. assert($targetHandle !== false, 'Could not open "'.$target.'" for writing.');
  34788. stream_copy_to_stream($sourceHandle, $targetHandle);
  34789. fclose($sourceHandle);
  34790. fclose($targetHandle);
  34791. touch($target, (int) filemtime($source), (int) fileatime($source));
  34792. }
  34793. }
  34794. private function filesAreEqual(string $a, string $b): bool
  34795. {
  34796. if (filesize($a) !== filesize($b)) {
  34797. return false;
  34798. }
  34799. $aHandle = fopen($a, 'rb');
  34800. assert($aHandle !== false, 'Could not open "'.$a.'" for reading.');
  34801. $bHandle = fopen($b, 'rb');
  34802. assert($bHandle !== false, 'Could not open "'.$b.'" for reading.');
  34803. $result = true;
  34804. while (!feof($aHandle)) {
  34805. if (fread($aHandle, 8192) !== fread($bHandle, 8192)) {
  34806. $result = false;
  34807. break;
  34808. }
  34809. }
  34810. fclose($aHandle);
  34811. fclose($bHandle);
  34812. return $result;
  34813. }
  34814. }
  34815. <?php declare(strict_types=1);
  34816. namespace Composer\Util;
  34817. use Composer\Config;
  34818. use Composer\IO\IOInterface;
  34819. use Composer\Pcre\Preg;
  34820. class Git
  34821. {
  34822. private static $version = false;
  34823. protected $io;
  34824. protected $config;
  34825. protected $process;
  34826. protected $filesystem;
  34827. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process, Filesystem $fs)
  34828. {
  34829. $this->io = $io;
  34830. $this->config = $config;
  34831. $this->process = $process;
  34832. $this->filesystem = $fs;
  34833. }
  34834. public function runCommand(callable $commandCallable, string $url, ?string $cwd, bool $initialClone = false, &$commandOutput = null): void
  34835. {
  34836. $this->config->prohibitUrlByConfig($url, $this->io);
  34837. if ($initialClone) {
  34838. $origCwd = $cwd;
  34839. $cwd = null;
  34840. }
  34841. if (Preg::isMatch('{^ssh://[^@]+@[^:]+:[^0-9]+}', $url)) {
  34842. 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.');
  34843. }
  34844. if (!$initialClone) {
  34845. $this->process->execute('git remote -v', $output, $cwd);
  34846. if (Preg::isMatchStrictGroups('{^(?:composer|origin)\s+https?://(.+):(.+)@([^/]+)}im', $output, $match) && !$this->io->hasAuthentication($match[3])) {
  34847. $this->io->setAuthentication($match[3], rawurldecode($match[1]), rawurldecode($match[2]));
  34848. }
  34849. }
  34850. $protocols = $this->config->get('github-protocols');
  34851. if (Preg::isMatchStrictGroups('{^(?:https?|git)://' . self::getGitHubDomainsRegex($this->config) . '/(.*)}', $url, $match)) {
  34852. $messages = [];
  34853. foreach ($protocols as $protocol) {
  34854. if ('ssh' === $protocol) {
  34855. $protoUrl = "git@" . $match[1] . ":" . $match[2];
  34856. } else {
  34857. $protoUrl = $protocol . "://" . $match[1] . "/" . $match[2];
  34858. }
  34859. if (0 === $this->process->execute($commandCallable($protoUrl), $commandOutput, $cwd)) {
  34860. return;
  34861. }
  34862. $messages[] = '- ' . $protoUrl . "\n" . Preg::replace('#^#m', ' ', $this->process->getErrorOutput());
  34863. if ($initialClone && isset($origCwd)) {
  34864. $this->filesystem->removeDirectory($origCwd);
  34865. }
  34866. }
  34867. if (!$this->io->hasAuthentication($match[1]) && !$this->io->isInteractive()) {
  34868. $this->throwException('Failed to clone ' . $url . ' via ' . implode(', ', $protocols) . ' protocols, aborting.' . "\n\n" . implode("\n", $messages), $url);
  34869. }
  34870. }
  34871. $bypassSshForGitHub = Preg::isMatch('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\.git$}i', $url) && !in_array('ssh', $protocols, true);
  34872. $command = $commandCallable($url);
  34873. $auth = null;
  34874. $credentials = [];
  34875. if ($bypassSshForGitHub || 0 !== $this->process->execute($command, $commandOutput, $cwd)) {
  34876. $errorMsg = $this->process->getErrorOutput();
  34877. if (Preg::isMatchStrictGroups('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\.git$}i', $url, $match)
  34878. || Preg::isMatchStrictGroups('{^https?://' . self::getGitHubDomainsRegex($this->config) . '/(.*?)(?:\.git)?$}i', $url, $match)
  34879. ) {
  34880. if (!$this->io->hasAuthentication($match[1])) {
  34881. $gitHubUtil = new GitHub($this->io, $this->config, $this->process);
  34882. $message = 'Cloning failed using an ssh key for authentication, enter your GitHub credentials to access private repos';
  34883. if (!$gitHubUtil->authorizeOAuth($match[1]) && $this->io->isInteractive()) {
  34884. $gitHubUtil->authorizeOAuthInteractively($match[1], $message);
  34885. }
  34886. }
  34887. if ($this->io->hasAuthentication($match[1])) {
  34888. $auth = $this->io->getAuthentication($match[1]);
  34889. $authUrl = 'https://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[1] . '/' . $match[2] . '.git';
  34890. $command = $commandCallable($authUrl);
  34891. if (0 === $this->process->execute($command, $commandOutput, $cwd)) {
  34892. return;
  34893. }
  34894. $credentials = [rawurlencode($auth['username']), rawurlencode($auth['password'])];
  34895. $errorMsg = $this->process->getErrorOutput();
  34896. }
  34897. } elseif (Preg::isMatchStrictGroups('{^https://(bitbucket\.org)/(.*?)(?:\.git)?$}i', $url, $match)) {
  34898. $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process);
  34899. if (!$this->io->hasAuthentication($match[1])) {
  34900. $message = 'Enter your Bitbucket credentials to access private repos';
  34901. if (!$bitbucketUtil->authorizeOAuth($match[1]) && $this->io->isInteractive()) {
  34902. $bitbucketUtil->authorizeOAuthInteractively($match[1], $message);
  34903. $accessToken = $bitbucketUtil->getToken();
  34904. $this->io->setAuthentication($match[1], 'x-token-auth', $accessToken);
  34905. }
  34906. } else {
  34907. $auth = $this->io->getAuthentication($match[1]);
  34908. if ($auth['username'] !== 'x-token-auth') {
  34909. $accessToken = $bitbucketUtil->requestToken($match[1], $auth['username'], $auth['password']);
  34910. if (!empty($accessToken)) {
  34911. $this->io->setAuthentication($match[1], 'x-token-auth', $accessToken);
  34912. }
  34913. }
  34914. }
  34915. if ($this->io->hasAuthentication($match[1])) {
  34916. $auth = $this->io->getAuthentication($match[1]);
  34917. $authUrl = 'https://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[1] . '/' . $match[2] . '.git';
  34918. $command = $commandCallable($authUrl);
  34919. if (0 === $this->process->execute($command, $commandOutput, $cwd)) {
  34920. return;
  34921. }
  34922. $credentials = [rawurlencode($auth['username']), rawurlencode($auth['password'])];
  34923. $errorMsg = $this->process->getErrorOutput();
  34924. } else {
  34925. $sshUrl = 'git@bitbucket.org:' . $match[2] . '.git';
  34926. $this->io->writeError(' No bitbucket authentication configured. Falling back to ssh.');
  34927. $command = $commandCallable($sshUrl);
  34928. if (0 === $this->process->execute($command, $commandOutput, $cwd)) {
  34929. return;
  34930. }
  34931. $errorMsg = $this->process->getErrorOutput();
  34932. }
  34933. } elseif (
  34934. Preg::isMatchStrictGroups('{^(git)@' . self::getGitLabDomainsRegex($this->config) . ':(.+?\.git)$}i', $url, $match)
  34935. || Preg::isMatchStrictGroups('{^(https?)://' . self::getGitLabDomainsRegex($this->config) . '/(.*)}i', $url, $match)
  34936. ) {
  34937. if ($match[1] === 'git') {
  34938. $match[1] = 'https';
  34939. }
  34940. if (!$this->io->hasAuthentication($match[2])) {
  34941. $gitLabUtil = new GitLab($this->io, $this->config, $this->process);
  34942. $message = 'Cloning failed, enter your GitLab credentials to access private repos';
  34943. if (!$gitLabUtil->authorizeOAuth($match[2]) && $this->io->isInteractive()) {
  34944. $gitLabUtil->authorizeOAuthInteractively($match[1], $match[2], $message);
  34945. }
  34946. }
  34947. if ($this->io->hasAuthentication($match[2])) {
  34948. $auth = $this->io->getAuthentication($match[2]);
  34949. if ($auth['password'] === 'private-token' || $auth['password'] === 'oauth2' || $auth['password'] === 'gitlab-ci-token') {
  34950. $authUrl = $match[1] . '://' . rawurlencode($auth['password']) . ':' . rawurlencode($auth['username']) . '@' . $match[2] . '/' . $match[3];
  34951. } else {
  34952. $authUrl = $match[1] . '://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[2] . '/' . $match[3];
  34953. }
  34954. $command = $commandCallable($authUrl);
  34955. if (0 === $this->process->execute($command, $commandOutput, $cwd)) {
  34956. return;
  34957. }
  34958. $credentials = [rawurlencode($auth['username']), rawurlencode($auth['password'])];
  34959. $errorMsg = $this->process->getErrorOutput();
  34960. }
  34961. } elseif ($this->isAuthenticationFailure($url, $match)) {
  34962. if (strpos($match[2], '@')) {
  34963. [$authParts, $match[2]] = explode('@', $match[2], 2);
  34964. }
  34965. $storeAuth = false;
  34966. if ($this->io->hasAuthentication($match[2])) {
  34967. $auth = $this->io->getAuthentication($match[2]);
  34968. } elseif ($this->io->isInteractive()) {
  34969. $defaultUsername = null;
  34970. if (isset($authParts) && $authParts) {
  34971. if (false !== strpos($authParts, ':')) {
  34972. [$defaultUsername, ] = explode(':', $authParts, 2);
  34973. } else {
  34974. $defaultUsername = $authParts;
  34975. }
  34976. }
  34977. $this->io->writeError(' Authentication required (<info>' . $match[2] . '</info>):');
  34978. $this->io->writeError('<warning>' . trim($errorMsg) . '</warning>', true, IOInterface::VERBOSE);
  34979. $auth = [
  34980. 'username' => $this->io->ask(' Username: ', $defaultUsername),
  34981. 'password' => $this->io->askAndHideAnswer(' Password: '),
  34982. ];
  34983. $storeAuth = $this->config->get('store-auths');
  34984. }
  34985. if (null !== $auth) {
  34986. $authUrl = $match[1] . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[2] . $match[3];
  34987. $command = $commandCallable($authUrl);
  34988. if (0 === $this->process->execute($command, $commandOutput, $cwd)) {
  34989. $this->io->setAuthentication($match[2], $auth['username'], $auth['password']);
  34990. $authHelper = new AuthHelper($this->io, $this->config);
  34991. $authHelper->storeAuth($match[2], $storeAuth);
  34992. return;
  34993. }
  34994. $credentials = [rawurlencode($auth['username']), rawurlencode($auth['password'])];
  34995. $errorMsg = $this->process->getErrorOutput();
  34996. }
  34997. }
  34998. if ($initialClone && isset($origCwd)) {
  34999. $this->filesystem->removeDirectory($origCwd);
  35000. }
  35001. if (count($credentials) > 0) {
  35002. $command = $this->maskCredentials($command, $credentials);
  35003. $errorMsg = $this->maskCredentials($errorMsg, $credentials);
  35004. }
  35005. $this->throwException('Failed to execute ' . $command . "\n\n" . $errorMsg, $url);
  35006. }
  35007. }
  35008. public function syncMirror(string $url, string $dir): bool
  35009. {
  35010. if (Platform::getEnv('COMPOSER_DISABLE_NETWORK') && Platform::getEnv('COMPOSER_DISABLE_NETWORK') !== 'prime') {
  35011. $this->io->writeError('<warning>Aborting git mirror sync of '.$url.' as network is disabled</warning>');
  35012. return false;
  35013. }
  35014. if (is_dir($dir) && 0 === $this->process->execute('git rev-parse --git-dir', $output, $dir) && trim($output) === '.') {
  35015. try {
  35016. $commandCallable = static function ($url): string {
  35017. $sanitizedUrl = Preg::replace('{://([^@]+?):(.+?)@}', '://', $url);
  35018. 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));
  35019. };
  35020. $this->runCommand($commandCallable, $url, $dir);
  35021. } catch (\Exception $e) {
  35022. $this->io->writeError('<error>Sync mirror failed: ' . $e->getMessage() . '</error>', true, IOInterface::DEBUG);
  35023. return false;
  35024. }
  35025. return true;
  35026. }
  35027. $this->filesystem->removeDirectory($dir);
  35028. $commandCallable = static function ($url) use ($dir): string {
  35029. return sprintf('git clone --mirror -- %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($dir));
  35030. };
  35031. $this->runCommand($commandCallable, $url, $dir, true);
  35032. return true;
  35033. }
  35034. public function fetchRefOrSyncMirror(string $url, string $dir, string $ref, string $prettyVersion = null): bool
  35035. {
  35036. if ($this->checkRefIsInMirror($dir, $ref)) {
  35037. if (Preg::isMatch('{^[a-f0-9]{40}$}', $ref) && $prettyVersion !== null) {
  35038. $branch = Preg::replace('{(?:^dev-|(?:\.x)?-dev$)}i', '', $prettyVersion);
  35039. $branches = null;
  35040. $tags = null;
  35041. if (0 === $this->process->execute('git branch', $output, $dir)) {
  35042. $branches = $output;
  35043. }
  35044. if (0 === $this->process->execute('git tag', $output, $dir)) {
  35045. $tags = $output;
  35046. }
  35047. if (null !== $branches && !Preg::isMatch('{^[\s*]*v?'.preg_quote($branch).'$}m', $branches)
  35048. && null !== $tags && !Preg::isMatch('{^[\s*]*'.preg_quote($branch).'$}m', $tags)
  35049. ) {
  35050. $this->syncMirror($url, $dir);
  35051. }
  35052. }
  35053. return true;
  35054. }
  35055. if ($this->syncMirror($url, $dir)) {
  35056. return $this->checkRefIsInMirror($dir, $ref);
  35057. }
  35058. return false;
  35059. }
  35060. public static function getNoShowSignatureFlag(ProcessExecutor $process): string
  35061. {
  35062. $gitVersion = self::getVersion($process);
  35063. if ($gitVersion && version_compare($gitVersion, '2.10.0-rc0', '>=')) {
  35064. return ' --no-show-signature';
  35065. }
  35066. return '';
  35067. }
  35068. private function checkRefIsInMirror(string $dir, string $ref): bool
  35069. {
  35070. if (is_dir($dir) && 0 === $this->process->execute('git rev-parse --git-dir', $output, $dir) && trim($output) === '.') {
  35071. $escapedRef = ProcessExecutor::escape($ref.'^{commit}');
  35072. $exitCode = $this->process->execute(sprintf('git rev-parse --quiet --verify %s', $escapedRef), $ignoredOutput, $dir);
  35073. if ($exitCode === 0) {
  35074. return true;
  35075. }
  35076. }
  35077. return false;
  35078. }
  35079. private function isAuthenticationFailure(string $url, array &$match): bool
  35080. {
  35081. if (!Preg::isMatch('{^(https?://)([^/]+)(.*)$}i', $url, $match)) {
  35082. return false;
  35083. }
  35084. $authFailures = [
  35085. 'fatal: Authentication failed',
  35086. 'remote error: Invalid username or password.',
  35087. 'error: 401 Unauthorized',
  35088. 'fatal: unable to access',
  35089. 'fatal: could not read Username',
  35090. ];
  35091. $errorOutput = $this->process->getErrorOutput();
  35092. foreach ($authFailures as $authFailure) {
  35093. if (strpos($errorOutput, $authFailure) !== false) {
  35094. return true;
  35095. }
  35096. }
  35097. return false;
  35098. }
  35099. public function getMirrorDefaultBranch(string $url, string $dir, bool $isLocalPathRepository): ?string
  35100. {
  35101. if ((bool) Platform::getEnv('COMPOSER_DISABLE_NETWORK')) {
  35102. return null;
  35103. }
  35104. try {
  35105. if ($isLocalPathRepository) {
  35106. $this->process->execute('git remote show origin', $output, $dir);
  35107. } else {
  35108. $commandCallable = static function ($url): string {
  35109. $sanitizedUrl = Preg::replace('{://([^@]+?):(.+?)@}', '://', $url);
  35110. return sprintf('git remote set-url origin -- %s && git remote show origin && git remote set-url origin -- %s', ProcessExecutor::escape($url), ProcessExecutor::escape($sanitizedUrl));
  35111. };
  35112. $this->runCommand($commandCallable, $url, $dir, false, $output);
  35113. }
  35114. $lines = $this->process->splitLines($output);
  35115. foreach ($lines as $line) {
  35116. if (Preg::match('{^\s*HEAD branch:\s(.+)\s*$}m', $line, $matches) > 0) {
  35117. return $matches[1];
  35118. }
  35119. }
  35120. } catch (\Exception $e) {
  35121. $this->io->writeError('<error>Failed to fetch root identifier from remote: ' . $e->getMessage() . '</error>', true, IOInterface::DEBUG);
  35122. }
  35123. return null;
  35124. }
  35125. public static function cleanEnv(): void
  35126. {
  35127. if (Platform::getEnv('GIT_ASKPASS') !== 'echo') {
  35128. Platform::putEnv('GIT_ASKPASS', 'echo');
  35129. }
  35130. if (Platform::getEnv('GIT_DIR')) {
  35131. Platform::clearEnv('GIT_DIR');
  35132. }
  35133. if (Platform::getEnv('GIT_WORK_TREE')) {
  35134. Platform::clearEnv('GIT_WORK_TREE');
  35135. }
  35136. if (Platform::getEnv('LANGUAGE') !== 'C') {
  35137. Platform::putEnv('LANGUAGE', 'C');
  35138. }
  35139. Platform::clearEnv('DYLD_LIBRARY_PATH');
  35140. }
  35141. public static function getGitHubDomainsRegex(Config $config): string
  35142. {
  35143. return '(' . implode('|', array_map('preg_quote', $config->get('github-domains'))) . ')';
  35144. }
  35145. public static function getGitLabDomainsRegex(Config $config): string
  35146. {
  35147. return '(' . implode('|', array_map('preg_quote', $config->get('gitlab-domains'))) . ')';
  35148. }
  35149. private function throwException($message, string $url): void
  35150. {
  35151. clearstatcache();
  35152. if (0 !== $this->process->execute('git --version', $ignoredOutput)) {
  35153. 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()));
  35154. }
  35155. throw new \RuntimeException(Url::sanitize($message));
  35156. }
  35157. public static function getVersion(ProcessExecutor $process): ?string
  35158. {
  35159. if (false === self::$version) {
  35160. self::$version = null;
  35161. if (0 === $process->execute('git --version', $output) && Preg::isMatch('/^git version (\d+(?:\.\d+)+)/m', $output, $matches)) {
  35162. self::$version = $matches[1];
  35163. }
  35164. }
  35165. return self::$version;
  35166. }
  35167. private function maskCredentials(string $error, array $credentials): string
  35168. {
  35169. $maskedCredentials = [];
  35170. foreach ($credentials as $credential) {
  35171. if (in_array($credential, ['private-token', 'x-token-auth', 'oauth2', 'gitlab-ci-token', 'x-oauth-basic'])) {
  35172. $maskedCredentials[] = $credential;
  35173. } elseif (strlen($credential) > 6) {
  35174. $maskedCredentials[] = substr($credential, 0, 3) . '...' . substr($credential, -3);
  35175. } elseif (strlen($credential) > 3) {
  35176. $maskedCredentials[] = substr($credential, 0, 3) . '...';
  35177. } else {
  35178. $maskedCredentials[] = 'XXX';
  35179. }
  35180. }
  35181. return str_replace($credentials, $maskedCredentials, $error);
  35182. }
  35183. }
  35184. <?php declare(strict_types=1);
  35185. namespace Composer\Util;
  35186. use Composer\Factory;
  35187. use Composer\IO\IOInterface;
  35188. use Composer\Config;
  35189. use Composer\Downloader\TransportException;
  35190. use Composer\Pcre\Preg;
  35191. class GitHub
  35192. {
  35193. protected $io;
  35194. protected $config;
  35195. protected $process;
  35196. protected $httpDownloader;
  35197. public function __construct(IOInterface $io, Config $config, ?ProcessExecutor $process = null, ?HttpDownloader $httpDownloader = null)
  35198. {
  35199. $this->io = $io;
  35200. $this->config = $config;
  35201. $this->process = $process ?: new ProcessExecutor($io);
  35202. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  35203. }
  35204. public function authorizeOAuth(string $originUrl): bool
  35205. {
  35206. if (!in_array($originUrl, $this->config->get('github-domains'))) {
  35207. return false;
  35208. }
  35209. if (0 === $this->process->execute('git config github.accesstoken', $output)) {
  35210. $this->io->setAuthentication($originUrl, trim($output), 'x-oauth-basic');
  35211. return true;
  35212. }
  35213. return false;
  35214. }
  35215. public function authorizeOAuthInteractively(string $originUrl, ?string $message = null): bool
  35216. {
  35217. if ($message) {
  35218. $this->io->writeError($message);
  35219. }
  35220. $note = 'Composer';
  35221. if ($this->config->get('github-expose-hostname') === true && 0 === $this->process->execute('hostname', $output)) {
  35222. $note .= ' on ' . trim($output);
  35223. }
  35224. $note .= ' ' . date('Y-m-d Hi');
  35225. $url = 'https://'.$originUrl.'/settings/tokens/new?scopes=&description=' . str_replace('%20', '+', rawurlencode($note));
  35226. $this->io->writeError(sprintf('When working with _public_ GitHub repositories only, head to %s to retrieve a token.', $url));
  35227. $this->io->writeError('This token will have read-only permission for public information only.');
  35228. $localAuthConfig = $this->config->getLocalAuthConfigSource();
  35229. $url = 'https://'.$originUrl.'/settings/tokens/new?scopes=repo&description=' . str_replace('%20', '+', rawurlencode($note));
  35230. $this->io->writeError(sprintf('When you need to access _private_ GitHub repositories as well, go to %s', $url));
  35231. $this->io->writeError('Note that such tokens have broad read/write permissions on your behalf, even if not needed by Composer.');
  35232. $this->io->writeError(sprintf('Tokens will be stored in plain text in "%s" for future use by Composer.', ($localAuthConfig !== null ? $localAuthConfig->getName() . ' OR ' : '') . $this->config->getAuthConfigSource()->getName()));
  35233. $this->io->writeError('For additional information, check https://getcomposer.org/doc/articles/authentication-for-private-packages.md#github-oauth');
  35234. $storeInLocalAuthConfig = false;
  35235. if ($localAuthConfig !== null) {
  35236. $storeInLocalAuthConfig = $this->io->askConfirmation('A local auth config source was found, do you want to store the token there?', true);
  35237. }
  35238. $token = trim((string) $this->io->askAndHideAnswer('Token (hidden): '));
  35239. if ($token === '') {
  35240. $this->io->writeError('<warning>No token given, aborting.</warning>');
  35241. $this->io->writeError('You can also add it manually later by using "composer config --global --auth github-oauth.github.com <token>"');
  35242. return false;
  35243. }
  35244. $this->io->setAuthentication($originUrl, $token, 'x-oauth-basic');
  35245. try {
  35246. $apiUrl = ('github.com' === $originUrl) ? 'api.github.com/' : $originUrl . '/api/v3/';
  35247. $this->httpDownloader->get('https://'. $apiUrl, [
  35248. 'retry-auth-failure' => false,
  35249. ]);
  35250. } catch (TransportException $e) {
  35251. if (in_array($e->getCode(), [403, 401])) {
  35252. $this->io->writeError('<error>Invalid token provided.</error>');
  35253. $this->io->writeError('You can also add it manually later by using "composer config --global --auth github-oauth.github.com <token>"');
  35254. return false;
  35255. }
  35256. throw $e;
  35257. }
  35258. $authConfigSource = $storeInLocalAuthConfig && $localAuthConfig !== null ? $localAuthConfig : $this->config->getAuthConfigSource();
  35259. $this->config->getConfigSource()->removeConfigSetting('github-oauth.'.$originUrl);
  35260. $authConfigSource->addConfigSetting('github-oauth.'.$originUrl, $token);
  35261. $this->io->writeError('<info>Token stored successfully.</info>');
  35262. return true;
  35263. }
  35264. public function getRateLimit(array $headers): array
  35265. {
  35266. $rateLimit = [
  35267. 'limit' => '?',
  35268. 'reset' => '?',
  35269. ];
  35270. foreach ($headers as $header) {
  35271. $header = trim($header);
  35272. if (false === stripos($header, 'x-ratelimit-')) {
  35273. continue;
  35274. }
  35275. [$type, $value] = explode(':', $header, 2);
  35276. switch (strtolower($type)) {
  35277. case 'x-ratelimit-limit':
  35278. $rateLimit['limit'] = (int) trim($value);
  35279. break;
  35280. case 'x-ratelimit-reset':
  35281. $rateLimit['reset'] = date('Y-m-d H:i:s', (int) trim($value));
  35282. break;
  35283. }
  35284. }
  35285. return $rateLimit;
  35286. }
  35287. public function getSsoUrl(array $headers): ?string
  35288. {
  35289. foreach ($headers as $header) {
  35290. $header = trim($header);
  35291. if (false === stripos($header, 'x-github-sso: required')) {
  35292. continue;
  35293. }
  35294. if (Preg::isMatch('{\burl=(?P<url>[^\s;]+)}', $header, $match)) {
  35295. return $match['url'];
  35296. }
  35297. }
  35298. return null;
  35299. }
  35300. public function isRateLimited(array $headers): bool
  35301. {
  35302. foreach ($headers as $header) {
  35303. if (Preg::isMatch('{^x-ratelimit-remaining: *0$}i', trim($header))) {
  35304. return true;
  35305. }
  35306. }
  35307. return false;
  35308. }
  35309. public function requiresSso(array $headers): bool
  35310. {
  35311. foreach ($headers as $header) {
  35312. if (Preg::isMatch('{^x-github-sso: required}i', trim($header))) {
  35313. return true;
  35314. }
  35315. }
  35316. return false;
  35317. }
  35318. }
  35319. <?php declare(strict_types=1);
  35320. namespace Composer\Util;
  35321. use Composer\IO\IOInterface;
  35322. use Composer\Config;
  35323. use Composer\Factory;
  35324. use Composer\Downloader\TransportException;
  35325. use Composer\Pcre\Preg;
  35326. class GitLab
  35327. {
  35328. protected $io;
  35329. protected $config;
  35330. protected $process;
  35331. protected $httpDownloader;
  35332. public function __construct(IOInterface $io, Config $config, ?ProcessExecutor $process = null, ?HttpDownloader $httpDownloader = null)
  35333. {
  35334. $this->io = $io;
  35335. $this->config = $config;
  35336. $this->process = $process ?: new ProcessExecutor($io);
  35337. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  35338. }
  35339. public function authorizeOAuth(string $originUrl): bool
  35340. {
  35341. $bcOriginUrl = Preg::replace('{:\d+}', '', $originUrl);
  35342. if (!in_array($originUrl, $this->config->get('gitlab-domains'), true) && !in_array($bcOriginUrl, $this->config->get('gitlab-domains'), true)) {
  35343. return false;
  35344. }
  35345. if (0 === $this->process->execute('git config gitlab.accesstoken', $output)) {
  35346. $this->io->setAuthentication($originUrl, trim($output), 'oauth2');
  35347. return true;
  35348. }
  35349. if (0 === $this->process->execute('git config gitlab.deploytoken.user', $tokenUser) && 0 === $this->process->execute('git config gitlab.deploytoken.token', $tokenPassword)) {
  35350. $this->io->setAuthentication($originUrl, trim($tokenUser), trim($tokenPassword));
  35351. return true;
  35352. }
  35353. $authTokens = $this->config->get('gitlab-token');
  35354. if (isset($authTokens[$originUrl])) {
  35355. $token = $authTokens[$originUrl];
  35356. }
  35357. if (isset($authTokens[$bcOriginUrl])) {
  35358. $token = $authTokens[$bcOriginUrl];
  35359. }
  35360. if (isset($token)) {
  35361. $username = is_array($token) ? $token["username"] : $token;
  35362. $password = is_array($token) ? $token["token"] : 'private-token';
  35363. if (in_array($username, ['private-token', 'gitlab-ci-token', 'oauth2'], true)) {
  35364. $this->io->setAuthentication($originUrl, $password, $username);
  35365. } else {
  35366. $this->io->setAuthentication($originUrl, $username, $password);
  35367. }
  35368. return true;
  35369. }
  35370. return false;
  35371. }
  35372. public function authorizeOAuthInteractively(string $scheme, string $originUrl, ?string $message = null): bool
  35373. {
  35374. if ($message) {
  35375. $this->io->writeError($message);
  35376. }
  35377. $localAuthConfig = $this->config->getLocalAuthConfigSource();
  35378. $this->io->writeError(sprintf('A token will be created and stored in "%s", your password will never be stored', ($localAuthConfig !== null ? $localAuthConfig->getName() . ' OR ' : '') . $this->config->getAuthConfigSource()->getName()));
  35379. $this->io->writeError('To revoke access to this token you can visit '.$scheme.'://'.$originUrl.'/-/profile/applications');
  35380. $this->io->writeError('Alternatively you can setup an personal access token on '.$scheme.'://'.$originUrl.'/-/profile/personal_access_tokens and store it under "gitlab-token" see https://getcomposer.org/doc/articles/authentication-for-private-packages.md#gitlab-token for more details.');
  35381. $storeInLocalAuthConfig = false;
  35382. if ($localAuthConfig !== null) {
  35383. $storeInLocalAuthConfig = $this->io->askConfirmation('A local auth config source was found, do you want to store the token there?', true);
  35384. }
  35385. $attemptCounter = 0;
  35386. while ($attemptCounter++ < 5) {
  35387. try {
  35388. $response = $this->createToken($scheme, $originUrl);
  35389. } catch (TransportException $e) {
  35390. if (in_array($e->getCode(), [403, 401])) {
  35391. if (401 === $e->getCode()) {
  35392. $response = json_decode($e->getResponse(), true);
  35393. if (isset($response['error']) && $response['error'] === 'invalid_grant') {
  35394. $this->io->writeError('Bad credentials. If you have two factor authentication enabled you will have to manually create a personal access token');
  35395. } else {
  35396. $this->io->writeError('Bad credentials.');
  35397. }
  35398. } else {
  35399. $this->io->writeError('Maximum number of login attempts exceeded. Please try again later.');
  35400. }
  35401. $this->io->writeError('You can also manually create a personal access token enabling the "read_api" scope at '.$scheme.'://'.$originUrl.'/profile/personal_access_tokens');
  35402. $this->io->writeError('Add it using "composer config --global --auth gitlab-token.'.$originUrl.' <token>"');
  35403. continue;
  35404. }
  35405. throw $e;
  35406. }
  35407. $this->io->setAuthentication($originUrl, $response['access_token'], 'oauth2');
  35408. $authConfigSource = $storeInLocalAuthConfig && $localAuthConfig !== null ? $localAuthConfig : $this->config->getAuthConfigSource();
  35409. if (isset($response['expires_in'])) {
  35410. $authConfigSource->addConfigSetting(
  35411. 'gitlab-oauth.'.$originUrl,
  35412. [
  35413. 'expires-at' => intval($response['created_at']) + intval($response['expires_in']),
  35414. 'refresh-token' => $response['refresh_token'],
  35415. 'token' => $response['access_token'],
  35416. ]
  35417. );
  35418. } else {
  35419. $authConfigSource->addConfigSetting('gitlab-oauth.'.$originUrl, $response['access_token']);
  35420. }
  35421. return true;
  35422. }
  35423. throw new \RuntimeException('Invalid GitLab credentials 5 times in a row, aborting.');
  35424. }
  35425. public function authorizeOAuthRefresh(string $scheme, string $originUrl): bool
  35426. {
  35427. try {
  35428. $response = $this->refreshToken($scheme, $originUrl);
  35429. } catch (TransportException $e) {
  35430. $this->io->writeError("Couldn't refresh access token: ".$e->getMessage());
  35431. return false;
  35432. }
  35433. $this->io->setAuthentication($originUrl, $response['access_token'], 'oauth2');
  35434. $this->config->getAuthConfigSource()->addConfigSetting(
  35435. 'gitlab-oauth.'.$originUrl,
  35436. [
  35437. 'expires-at' => intval($response['created_at']) + intval($response['expires_in']),
  35438. 'refresh-token' => $response['refresh_token'],
  35439. 'token' => $response['access_token'],
  35440. ]
  35441. );
  35442. return true;
  35443. }
  35444. private function createToken(string $scheme, string $originUrl): array
  35445. {
  35446. $username = $this->io->ask('Username: ');
  35447. $password = $this->io->askAndHideAnswer('Password: ');
  35448. $headers = ['Content-Type: application/x-www-form-urlencoded'];
  35449. $apiUrl = $originUrl;
  35450. $data = http_build_query([
  35451. 'username' => $username,
  35452. 'password' => $password,
  35453. 'grant_type' => 'password',
  35454. ], '', '&');
  35455. $options = [
  35456. 'retry-auth-failure' => false,
  35457. 'http' => [
  35458. 'method' => 'POST',
  35459. 'header' => $headers,
  35460. 'content' => $data,
  35461. ],
  35462. ];
  35463. $token = $this->httpDownloader->get($scheme.'://'.$apiUrl.'/oauth/token', $options)->decodeJson();
  35464. $this->io->writeError('Token successfully created');
  35465. return $token;
  35466. }
  35467. public function isOAuthExpired(string $originUrl): bool
  35468. {
  35469. $authTokens = $this->config->get('gitlab-oauth');
  35470. if (isset($authTokens[$originUrl]['expires-at'])) {
  35471. if ($authTokens[$originUrl]['expires-at'] < time()) {
  35472. return true;
  35473. }
  35474. }
  35475. return false;
  35476. }
  35477. private function refreshToken(string $scheme, string $originUrl): array
  35478. {
  35479. $authTokens = $this->config->get('gitlab-oauth');
  35480. if (!isset($authTokens[$originUrl]['refresh-token'])) {
  35481. throw new \RuntimeException('No GitLab refresh token present for '.$originUrl.'.');
  35482. }
  35483. $refreshToken = $authTokens[$originUrl]['refresh-token'];
  35484. $headers = ['Content-Type: application/x-www-form-urlencoded'];
  35485. $data = http_build_query([
  35486. 'refresh_token' => $refreshToken,
  35487. 'grant_type' => 'refresh_token',
  35488. ], '', '&');
  35489. $options = [
  35490. 'retry-auth-failure' => false,
  35491. 'http' => [
  35492. 'method' => 'POST',
  35493. 'header' => $headers,
  35494. 'content' => $data,
  35495. ],
  35496. ];
  35497. $token = $this->httpDownloader->get($scheme.'://'.$originUrl.'/oauth/token', $options)->decodeJson();
  35498. $this->io->writeError('GitLab token successfully refreshed', true, IOInterface::VERY_VERBOSE);
  35499. $this->io->writeError('To revoke access to this token you can visit '.$scheme.'://'.$originUrl.'/-/profile/applications', true, IOInterface::VERY_VERBOSE);
  35500. return $token;
  35501. }
  35502. }
  35503. <?php declare(strict_types=1);
  35504. namespace Composer\Util;
  35505. use Composer\Config;
  35506. use Composer\IO\IOInterface;
  35507. use Composer\Pcre\Preg;
  35508. class Hg
  35509. {
  35510. private static $version = false;
  35511. private $io;
  35512. private $config;
  35513. private $process;
  35514. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process)
  35515. {
  35516. $this->io = $io;
  35517. $this->config = $config;
  35518. $this->process = $process;
  35519. }
  35520. public function runCommand(callable $commandCallable, string $url, ?string $cwd): void
  35521. {
  35522. $this->config->prohibitUrlByConfig($url, $this->io);
  35523. $command = $commandCallable($url);
  35524. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  35525. return;
  35526. }
  35527. if (Preg::isMatch('{^(https?)://((.+)(?:\:(.+))?@)?([^/]+)(/.*)?}mi', $url, $match) && $this->io->hasAuthentication((string) $match[5])) {
  35528. $auth = $this->io->getAuthentication((string) $match[5]);
  35529. $authenticatedUrl = $match[1] . '://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[5] . $match[6];
  35530. $command = $commandCallable($authenticatedUrl);
  35531. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  35532. return;
  35533. }
  35534. $error = $this->process->getErrorOutput();
  35535. } else {
  35536. $error = 'The given URL (' . $url . ') does not match the required format (http(s)://(username:password@)example.com/path-to-repository)';
  35537. }
  35538. $this->throwException('Failed to clone ' . $url . ', ' . "\n\n" . $error, $url);
  35539. }
  35540. private function throwException($message, string $url): void
  35541. {
  35542. if (null === self::getVersion($this->process)) {
  35543. 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()));
  35544. }
  35545. throw new \RuntimeException(Url::sanitize($message));
  35546. }
  35547. public static function getVersion(ProcessExecutor $process): ?string
  35548. {
  35549. if (false === self::$version) {
  35550. self::$version = null;
  35551. if (0 === $process->execute('hg --version', $output) && Preg::isMatch('/^.+? (\d+(?:\.\d+)+)(?:\+.*?)?\)?\r?\n/', $output, $matches)) {
  35552. self::$version = $matches[1];
  35553. }
  35554. }
  35555. return self::$version;
  35556. }
  35557. }
  35558. <?php declare(strict_types=1);
  35559. namespace Composer\Util\Http;
  35560. use Composer\Config;
  35561. use Composer\Downloader\MaxFileSizeExceededException;
  35562. use Composer\IO\IOInterface;
  35563. use Composer\Downloader\TransportException;
  35564. use Composer\Pcre\Preg;
  35565. use Composer\Util\Platform;
  35566. use Composer\Util\StreamContextFactory;
  35567. use Composer\Util\AuthHelper;
  35568. use Composer\Util\Url;
  35569. use Composer\Util\HttpDownloader;
  35570. use React\Promise\Promise;
  35571. class CurlDownloader
  35572. {
  35573. private $multiHandle;
  35574. private $shareHandle;
  35575. private $jobs = [];
  35576. private $io;
  35577. private $config;
  35578. private $authHelper;
  35579. private $selectTimeout = 5.0;
  35580. private $maxRedirects = 20;
  35581. private $maxRetries = 3;
  35582. private $proxyManager;
  35583. private $supportsSecureProxy;
  35584. protected $multiErrors = [
  35585. CURLM_BAD_HANDLE => ['CURLM_BAD_HANDLE', 'The passed-in handle is not a valid CURLM handle.'],
  35586. CURLM_BAD_EASY_HANDLE => ['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."],
  35587. CURLM_OUT_OF_MEMORY => ['CURLM_OUT_OF_MEMORY', 'You are doomed.'],
  35588. CURLM_INTERNAL_ERROR => ['CURLM_INTERNAL_ERROR', 'This can only be returned if libcurl bugs. Please report it to us!'],
  35589. ];
  35590. private static $options = [
  35591. 'http' => [
  35592. 'method' => CURLOPT_CUSTOMREQUEST,
  35593. 'content' => CURLOPT_POSTFIELDS,
  35594. 'header' => CURLOPT_HTTPHEADER,
  35595. 'timeout' => CURLOPT_TIMEOUT,
  35596. ],
  35597. 'ssl' => [
  35598. 'cafile' => CURLOPT_CAINFO,
  35599. 'capath' => CURLOPT_CAPATH,
  35600. 'verify_peer' => CURLOPT_SSL_VERIFYPEER,
  35601. 'verify_peer_name' => CURLOPT_SSL_VERIFYHOST,
  35602. 'local_cert' => CURLOPT_SSLCERT,
  35603. 'local_pk' => CURLOPT_SSLKEY,
  35604. 'passphrase' => CURLOPT_SSLKEYPASSWD,
  35605. ],
  35606. ];
  35607. private static $timeInfo = [
  35608. 'total_time' => true,
  35609. 'namelookup_time' => true,
  35610. 'connect_time' => true,
  35611. 'pretransfer_time' => true,
  35612. 'starttransfer_time' => true,
  35613. 'redirect_time' => true,
  35614. ];
  35615. public function __construct(IOInterface $io, Config $config, array $options = [], bool $disableTls = false)
  35616. {
  35617. $this->io = $io;
  35618. $this->config = $config;
  35619. $this->multiHandle = $mh = curl_multi_init();
  35620. if (function_exists('curl_multi_setopt')) {
  35621. curl_multi_setopt($mh, CURLMOPT_PIPELINING, PHP_VERSION_ID >= 70400 ? 2 : 3);
  35622. if (defined('CURLMOPT_MAX_HOST_CONNECTIONS') && !defined('HHVM_VERSION')) {
  35623. curl_multi_setopt($mh, CURLMOPT_MAX_HOST_CONNECTIONS, 8);
  35624. }
  35625. }
  35626. if (function_exists('curl_share_init')) {
  35627. $this->shareHandle = $sh = curl_share_init();
  35628. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
  35629. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
  35630. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
  35631. }
  35632. $this->authHelper = new AuthHelper($io, $config);
  35633. $this->proxyManager = ProxyManager::getInstance();
  35634. $version = curl_version();
  35635. $features = $version['features'];
  35636. $this->supportsSecureProxy = defined('CURL_VERSION_HTTPS_PROXY') && ($features & CURL_VERSION_HTTPS_PROXY);
  35637. }
  35638. public function download(callable $resolve, callable $reject, string $origin, string $url, array $options, ?string $copyTo = null): int
  35639. {
  35640. $attributes = [];
  35641. if (isset($options['retry-auth-failure'])) {
  35642. $attributes['retryAuthFailure'] = $options['retry-auth-failure'];
  35643. unset($options['retry-auth-failure']);
  35644. }
  35645. return $this->initDownload($resolve, $reject, $origin, $url, $options, $copyTo, $attributes);
  35646. }
  35647. private function initDownload(callable $resolve, callable $reject, string $origin, string $url, array $options, ?string $copyTo = null, array $attributes = []): int
  35648. {
  35649. $attributes = array_merge([
  35650. 'retryAuthFailure' => true,
  35651. 'redirects' => 0,
  35652. 'retries' => 0,
  35653. 'storeAuth' => false,
  35654. ], $attributes);
  35655. $originalOptions = $options;
  35656. if (!Preg::isMatch('{^http://(repo\.)?packagist\.org/p/}', $url) || (false === strpos($url, '$') && false === strpos($url, '%24'))) {
  35657. $this->config->prohibitUrlByConfig($url, $this->io, $options);
  35658. }
  35659. $curlHandle = curl_init();
  35660. $headerHandle = fopen('php://temp/maxmemory:32768', 'w+b');
  35661. if (false === $headerHandle) {
  35662. throw new \RuntimeException('Failed to open a temp stream to store curl headers');
  35663. }
  35664. if ($copyTo !== null) {
  35665. $bodyTarget = $copyTo.'~';
  35666. } else {
  35667. $bodyTarget = 'php://temp/maxmemory:524288';
  35668. }
  35669. $errorMessage = '';
  35670. set_error_handler(static function ($code, $msg) use (&$errorMessage): void {
  35671. if ($errorMessage) {
  35672. $errorMessage .= "\n";
  35673. }
  35674. $errorMessage .= Preg::replace('{^fopen\(.*?\): }', '', $msg);
  35675. });
  35676. $bodyHandle = fopen($bodyTarget, 'w+b');
  35677. restore_error_handler();
  35678. if (false === $bodyHandle) {
  35679. throw new TransportException('The "'.$url.'" file could not be written to '.($copyTo ?? 'a temporary file').': '.$errorMessage);
  35680. }
  35681. curl_setopt($curlHandle, CURLOPT_URL, $url);
  35682. curl_setopt($curlHandle, CURLOPT_FOLLOWLOCATION, false);
  35683. curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 10);
  35684. curl_setopt($curlHandle, CURLOPT_TIMEOUT, max((int) ini_get("default_socket_timeout"), 300));
  35685. curl_setopt($curlHandle, CURLOPT_WRITEHEADER, $headerHandle);
  35686. curl_setopt($curlHandle, CURLOPT_FILE, $bodyHandle);
  35687. curl_setopt($curlHandle, CURLOPT_ENCODING, "");
  35688. curl_setopt($curlHandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
  35689. if (function_exists('curl_share_init')) {
  35690. curl_setopt($curlHandle, CURLOPT_SHARE, $this->shareHandle);
  35691. }
  35692. if (!isset($options['http']['header'])) {
  35693. $options['http']['header'] = [];
  35694. }
  35695. $options['http']['header'] = array_diff($options['http']['header'], ['Connection: close']);
  35696. $options['http']['header'][] = 'Connection: keep-alive';
  35697. $version = curl_version();
  35698. $features = $version['features'];
  35699. if (0 === strpos($url, 'https://') && \defined('CURL_VERSION_HTTP2') && \defined('CURL_HTTP_VERSION_2_0') && (CURL_VERSION_HTTP2 & $features)) {
  35700. curl_setopt($curlHandle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
  35701. }
  35702. $options['http']['header'] = $this->authHelper->addAuthenticationHeader($options['http']['header'], $origin, $url);
  35703. $options = StreamContextFactory::initOptions($url, $options, true);
  35704. foreach (self::$options as $type => $curlOptions) {
  35705. foreach ($curlOptions as $name => $curlOption) {
  35706. if (isset($options[$type][$name])) {
  35707. if ($type === 'ssl' && $name === 'verify_peer_name') {
  35708. curl_setopt($curlHandle, $curlOption, $options[$type][$name] === true ? 2 : $options[$type][$name]);
  35709. } else {
  35710. curl_setopt($curlHandle, $curlOption, $options[$type][$name]);
  35711. }
  35712. }
  35713. }
  35714. }
  35715. $proxy = $this->proxyManager->getProxyForRequest($url);
  35716. if ($proxy->getUrl() !== '') {
  35717. curl_setopt($curlHandle, CURLOPT_PROXY, $proxy->getUrl());
  35718. }
  35719. if ($proxy->isSecure()) {
  35720. if (!$this->supportsSecureProxy) {
  35721. throw new TransportException('Connecting to a secure proxy using curl is not supported on PHP versions below 7.3.0.');
  35722. }
  35723. if (!empty($options['ssl']['cafile'])) {
  35724. curl_setopt($curlHandle, CURLOPT_PROXY_CAINFO, $options['ssl']['cafile']);
  35725. }
  35726. if (!empty($options['ssl']['capath'])) {
  35727. curl_setopt($curlHandle, CURLOPT_PROXY_CAPATH, $options['ssl']['capath']);
  35728. }
  35729. }
  35730. $progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo);
  35731. $this->jobs[(int) $curlHandle] = [
  35732. 'url' => $url,
  35733. 'origin' => $origin,
  35734. 'attributes' => $attributes,
  35735. 'options' => $originalOptions,
  35736. 'progress' => $progress,
  35737. 'curlHandle' => $curlHandle,
  35738. 'filename' => $copyTo,
  35739. 'headerHandle' => $headerHandle,
  35740. 'bodyHandle' => $bodyHandle,
  35741. 'resolve' => $resolve,
  35742. 'reject' => $reject,
  35743. ];
  35744. $usingProxy = $proxy->getFormattedUrl(' using proxy (%s)');
  35745. $ifModified = false !== stripos(implode(',', $options['http']['header']), 'if-modified-since:') ? ' if modified' : '';
  35746. if ($attributes['redirects'] === 0 && $attributes['retries'] === 0) {
  35747. $this->io->writeError('Downloading ' . Url::sanitize($url) . $usingProxy . $ifModified, true, IOInterface::DEBUG);
  35748. }
  35749. $this->checkCurlResult(curl_multi_add_handle($this->multiHandle, $curlHandle));
  35750. return (int) $curlHandle;
  35751. }
  35752. public function abortRequest(int $id): void
  35753. {
  35754. if (isset($this->jobs[$id], $this->jobs[$id]['curlHandle'])) {
  35755. $job = $this->jobs[$id];
  35756. curl_multi_remove_handle($this->multiHandle, $job['curlHandle']);
  35757. curl_close($job['curlHandle']);
  35758. if (is_resource($job['headerHandle'])) {
  35759. fclose($job['headerHandle']);
  35760. }
  35761. if (is_resource($job['bodyHandle'])) {
  35762. fclose($job['bodyHandle']);
  35763. }
  35764. if (null !== $job['filename']) {
  35765. @unlink($job['filename'].'~');
  35766. }
  35767. unset($this->jobs[$id]);
  35768. }
  35769. }
  35770. public function tick(): void
  35771. {
  35772. static $timeoutWarning = false;
  35773. if (count($this->jobs) === 0) {
  35774. return;
  35775. }
  35776. $active = true;
  35777. $this->checkCurlResult(curl_multi_exec($this->multiHandle, $active));
  35778. if (-1 === curl_multi_select($this->multiHandle, $this->selectTimeout)) {
  35779. usleep(150);
  35780. }
  35781. while ($progress = curl_multi_info_read($this->multiHandle)) {
  35782. $curlHandle = $progress['handle'];
  35783. $result = $progress['result'];
  35784. $i = (int) $curlHandle;
  35785. if (!isset($this->jobs[$i])) {
  35786. continue;
  35787. }
  35788. $progress = curl_getinfo($curlHandle);
  35789. if (false === $progress) {
  35790. throw new \RuntimeException('Failed getting info from curl handle '.$i.' ('.$this->jobs[$i]['url'].')');
  35791. }
  35792. $job = $this->jobs[$i];
  35793. unset($this->jobs[$i]);
  35794. $error = curl_error($curlHandle);
  35795. $errno = curl_errno($curlHandle);
  35796. curl_multi_remove_handle($this->multiHandle, $curlHandle);
  35797. curl_close($curlHandle);
  35798. $headers = null;
  35799. $statusCode = null;
  35800. $response = null;
  35801. try {
  35802. if (CURLE_OK !== $errno || $error || $result !== CURLE_OK) {
  35803. $errno = $errno ?: $result;
  35804. if (!$error && function_exists('curl_strerror')) {
  35805. $error = curl_strerror($errno);
  35806. }
  35807. $progress['error_code'] = $errno;
  35808. if (
  35809. (!isset($job['options']['http']['method']) || $job['options']['http']['method'] === 'GET')
  35810. && (
  35811. in_array($errno, [7 , 16 , 92 , 6 ], true)
  35812. || (in_array($errno, [56 , 35 ], true) && str_contains((string) $error, 'Connection reset by peer'))
  35813. ) && $job['attributes']['retries'] < $this->maxRetries
  35814. ) {
  35815. $this->io->writeError('Retrying ('.($job['attributes']['retries'] + 1).') ' . Url::sanitize($job['url']) . ' due to curl error '. $errno, true, IOInterface::DEBUG);
  35816. $this->restartJobWithDelay($job, $job['url'], ['retries' => $job['attributes']['retries'] + 1]);
  35817. continue;
  35818. }
  35819. if ($errno === 55 ) {
  35820. $this->io->writeError('Retrying ('.($job['attributes']['retries'] + 1).') ' . Url::sanitize($job['url']) . ' due to curl error '. $errno, true, IOInterface::DEBUG);
  35821. $this->restartJobWithDelay($job, $job['url'], ['retries' => $job['attributes']['retries'] + 1]);
  35822. continue;
  35823. }
  35824. if ($errno === 28 && PHP_VERSION_ID >= 70300 && $progress['namelookup_time'] === 0.0 && !$timeoutWarning) {
  35825. $timeoutWarning = true;
  35826. $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>');
  35827. }
  35828. throw new TransportException('curl error '.$errno.' while downloading '.Url::sanitize($progress['url']).': '.$error);
  35829. }
  35830. $statusCode = $progress['http_code'];
  35831. rewind($job['headerHandle']);
  35832. $headers = explode("\r\n", rtrim(stream_get_contents($job['headerHandle'])));
  35833. fclose($job['headerHandle']);
  35834. if ($statusCode === 0) {
  35835. 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));
  35836. }
  35837. if (null !== $job['filename']) {
  35838. $contents = $job['filename'].'~';
  35839. if ($statusCode >= 300) {
  35840. rewind($job['bodyHandle']);
  35841. $contents = stream_get_contents($job['bodyHandle']);
  35842. }
  35843. $response = new CurlResponse(['url' => $job['url']], $statusCode, $headers, $contents, $progress);
  35844. $this->io->writeError('['.$statusCode.'] '.Url::sanitize($job['url']), true, IOInterface::DEBUG);
  35845. } else {
  35846. $maxFileSize = $job['options']['max_file_size'] ?? null;
  35847. rewind($job['bodyHandle']);
  35848. if ($maxFileSize !== null) {
  35849. $contents = stream_get_contents($job['bodyHandle'], $maxFileSize);
  35850. if ($contents !== false && Platform::strlen($contents) >= $maxFileSize) {
  35851. throw new MaxFileSizeExceededException('Maximum allowed download size reached. Downloaded ' . Platform::strlen($contents) . ' of allowed ' . $maxFileSize . ' bytes');
  35852. }
  35853. } else {
  35854. $contents = stream_get_contents($job['bodyHandle']);
  35855. }
  35856. $response = new CurlResponse(['url' => $job['url']], $statusCode, $headers, $contents, $progress);
  35857. $this->io->writeError('['.$statusCode.'] '.Url::sanitize($job['url']), true, IOInterface::DEBUG);
  35858. }
  35859. fclose($job['bodyHandle']);
  35860. if ($response->getStatusCode() >= 400 && $response->getHeader('content-type') === 'application/json') {
  35861. HttpDownloader::outputWarnings($this->io, $job['origin'], json_decode($response->getBody(), true));
  35862. }
  35863. $result = $this->isAuthenticatedRetryNeeded($job, $response);
  35864. if ($result['retry']) {
  35865. $this->restartJob($job, $job['url'], ['storeAuth' => $result['storeAuth'], 'retries' => $job['attributes']['retries'] + 1]);
  35866. continue;
  35867. }
  35868. if ($statusCode >= 300 && $statusCode <= 399 && $statusCode !== 304 && $job['attributes']['redirects'] < $this->maxRedirects) {
  35869. $location = $this->handleRedirect($job, $response);
  35870. if ($location) {
  35871. $this->restartJob($job, $location, ['redirects' => $job['attributes']['redirects'] + 1]);
  35872. continue;
  35873. }
  35874. }
  35875. if ($statusCode >= 400 && $statusCode <= 599) {
  35876. if (
  35877. (!isset($job['options']['http']['method']) || $job['options']['http']['method'] === 'GET')
  35878. && in_array($statusCode, [423, 425, 500, 502, 503, 504, 507, 510], true)
  35879. && $job['attributes']['retries'] < $this->maxRetries
  35880. ) {
  35881. $this->io->writeError('Retrying ('.($job['attributes']['retries'] + 1).') ' . Url::sanitize($job['url']) . ' due to status code '. $statusCode, true, IOInterface::DEBUG);
  35882. $this->restartJobWithDelay($job, $job['url'], ['retries' => $job['attributes']['retries'] + 1]);
  35883. continue;
  35884. }
  35885. throw $this->failResponse($job, $response, $response->getStatusMessage());
  35886. }
  35887. if ($job['attributes']['storeAuth'] !== false) {
  35888. $this->authHelper->storeAuth($job['origin'], $job['attributes']['storeAuth']);
  35889. }
  35890. if (null !== $job['filename']) {
  35891. rename($job['filename'].'~', $job['filename']);
  35892. $job['resolve']($response);
  35893. } else {
  35894. $job['resolve']($response);
  35895. }
  35896. } catch (\Exception $e) {
  35897. if ($e instanceof TransportException) {
  35898. if (null !== $headers) {
  35899. $e->setHeaders($headers);
  35900. $e->setStatusCode($statusCode);
  35901. }
  35902. if (null !== $response) {
  35903. $e->setResponse($response->getBody());
  35904. }
  35905. $e->setResponseInfo($progress);
  35906. }
  35907. $this->rejectJob($job, $e);
  35908. }
  35909. }
  35910. foreach ($this->jobs as $i => $curlHandle) {
  35911. $curlHandle = $this->jobs[$i]['curlHandle'];
  35912. $progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo);
  35913. if ($this->jobs[$i]['progress'] !== $progress) {
  35914. $this->jobs[$i]['progress'] = $progress;
  35915. if (isset($this->jobs[$i]['options']['max_file_size'])) {
  35916. if ($this->jobs[$i]['options']['max_file_size'] < $progress['download_content_length']) {
  35917. $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'));
  35918. }
  35919. if ($this->jobs[$i]['options']['max_file_size'] < $progress['size_download']) {
  35920. $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'));
  35921. }
  35922. }
  35923. }
  35924. }
  35925. }
  35926. private function handleRedirect(array $job, Response $response): string
  35927. {
  35928. if ($locationHeader = $response->getHeader('location')) {
  35929. if (parse_url($locationHeader, PHP_URL_SCHEME)) {
  35930. $targetUrl = $locationHeader;
  35931. } elseif (parse_url($locationHeader, PHP_URL_HOST)) {
  35932. $targetUrl = parse_url($job['url'], PHP_URL_SCHEME).':'.$locationHeader;
  35933. } elseif ('/' === $locationHeader[0]) {
  35934. $urlHost = parse_url($job['url'], PHP_URL_HOST);
  35935. $targetUrl = Preg::replace('{^(.+(?://|@)'.preg_quote($urlHost).'(?::\d+)?)(?:[/\?].*)?$}', '\1'.$locationHeader, $job['url']);
  35936. } else {
  35937. $targetUrl = Preg::replace('{^(.+/)[^/?]*(?:\?.*)?$}', '\1'.$locationHeader, $job['url']);
  35938. }
  35939. }
  35940. if (!empty($targetUrl)) {
  35941. $this->io->writeError(sprintf('Following redirect (%u) %s', $job['attributes']['redirects'] + 1, Url::sanitize($targetUrl)), true, IOInterface::DEBUG);
  35942. return $targetUrl;
  35943. }
  35944. throw new TransportException('The "'.$job['url'].'" file could not be downloaded, got redirect without Location ('.$response->getStatusMessage().')');
  35945. }
  35946. private function isAuthenticatedRetryNeeded(array $job, Response $response): array
  35947. {
  35948. if (in_array($response->getStatusCode(), [401, 403]) && $job['attributes']['retryAuthFailure']) {
  35949. $result = $this->authHelper->promptAuthIfNeeded($job['url'], $job['origin'], $response->getStatusCode(), $response->getStatusMessage(), $response->getHeaders(), $job['attributes']['retries']);
  35950. if ($result['retry']) {
  35951. return $result;
  35952. }
  35953. }
  35954. $locationHeader = $response->getHeader('location');
  35955. $needsAuthRetry = false;
  35956. if (
  35957. $job['origin'] === 'bitbucket.org'
  35958. && !$this->authHelper->isPublicBitBucketDownload($job['url'])
  35959. && substr($job['url'], -4) === '.zip'
  35960. && (!$locationHeader || substr($locationHeader, -4) !== '.zip')
  35961. && Preg::isMatch('{^text/html\b}i', $response->getHeader('content-type'))
  35962. ) {
  35963. $needsAuthRetry = 'Bitbucket requires authentication and it was not provided';
  35964. }
  35965. if (
  35966. $response->getStatusCode() === 404
  35967. && in_array($job['origin'], $this->config->get('gitlab-domains'), true)
  35968. && false !== strpos($job['url'], 'archive.zip')
  35969. ) {
  35970. $needsAuthRetry = 'GitLab requires authentication and it was not provided';
  35971. }
  35972. if ($needsAuthRetry) {
  35973. if ($job['attributes']['retryAuthFailure']) {
  35974. $result = $this->authHelper->promptAuthIfNeeded($job['url'], $job['origin'], 401, null, [], $job['attributes']['retries']);
  35975. if ($result['retry']) {
  35976. return $result;
  35977. }
  35978. }
  35979. throw $this->failResponse($job, $response, $needsAuthRetry);
  35980. }
  35981. return ['retry' => false, 'storeAuth' => false];
  35982. }
  35983. private function restartJob(array $job, string $url, array $attributes = []): void
  35984. {
  35985. if (null !== $job['filename']) {
  35986. @unlink($job['filename'].'~');
  35987. }
  35988. $attributes = array_merge($job['attributes'], $attributes);
  35989. $origin = Url::getOrigin($this->config, $url);
  35990. $this->initDownload($job['resolve'], $job['reject'], $origin, $url, $job['options'], $job['filename'], $attributes);
  35991. }
  35992. private function restartJobWithDelay(array $job, string $url, array $attributes): void
  35993. {
  35994. if ($attributes['retries'] >= 3) {
  35995. usleep(500000);
  35996. } elseif ($attributes['retries'] >= 2) {
  35997. usleep(100000);
  35998. }
  35999. $this->restartJob($job, $url, $attributes);
  36000. }
  36001. private function failResponse(array $job, Response $response, string $errorMessage): TransportException
  36002. {
  36003. if (null !== $job['filename']) {
  36004. @unlink($job['filename'].'~');
  36005. }
  36006. $details = '';
  36007. if (in_array(strtolower((string) $response->getHeader('content-type')), ['application/json', 'application/json; charset=utf-8'], true)) {
  36008. $details = ':'.PHP_EOL.substr($response->getBody(), 0, 200).(strlen($response->getBody()) > 200 ? '...' : '');
  36009. }
  36010. return new TransportException('The "'.$job['url'].'" file could not be downloaded ('.$errorMessage.')' . $details, $response->getStatusCode());
  36011. }
  36012. private function rejectJob(array $job, \Exception $e): void
  36013. {
  36014. if (is_resource($job['headerHandle'])) {
  36015. fclose($job['headerHandle']);
  36016. }
  36017. if (is_resource($job['bodyHandle'])) {
  36018. fclose($job['bodyHandle']);
  36019. }
  36020. if (null !== $job['filename']) {
  36021. @unlink($job['filename'].'~');
  36022. }
  36023. $job['reject']($e);
  36024. }
  36025. private function checkCurlResult(int $code): void
  36026. {
  36027. if ($code !== CURLM_OK && $code !== CURLM_CALL_MULTI_PERFORM) {
  36028. throw new \RuntimeException(
  36029. isset($this->multiErrors[$code])
  36030. ? "cURL error: {$code} ({$this->multiErrors[$code][0]}): cURL message: {$this->multiErrors[$code][1]}"
  36031. : 'Unexpected cURL error: ' . $code
  36032. );
  36033. }
  36034. }
  36035. }
  36036. <?php declare(strict_types=1);
  36037. namespace Composer\Util\Http;
  36038. class CurlResponse extends Response
  36039. {
  36040. private $curlInfo;
  36041. public function __construct(array $request, ?int $code, array $headers, ?string $body, array $curlInfo)
  36042. {
  36043. parent::__construct($request, $code, $headers, $body);
  36044. $this->curlInfo = $curlInfo;
  36045. }
  36046. public function getCurlInfo(): array
  36047. {
  36048. return $this->curlInfo;
  36049. }
  36050. }
  36051. <?php declare(strict_types=1);
  36052. namespace Composer\Util\Http;
  36053. class ProxyHelper
  36054. {
  36055. public static function getProxyData(): array
  36056. {
  36057. $httpProxy = null;
  36058. $httpsProxy = null;
  36059. if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
  36060. if ($env = self::getProxyEnv(['http_proxy', 'HTTP_PROXY'], $name)) {
  36061. $httpProxy = self::checkProxy($env, $name);
  36062. }
  36063. }
  36064. if ($env = self::getProxyEnv(['CGI_HTTP_PROXY'], $name)) {
  36065. $httpProxy = self::checkProxy($env, $name);
  36066. }
  36067. if ($env = self::getProxyEnv(['https_proxy', 'HTTPS_PROXY'], $name)) {
  36068. $httpsProxy = self::checkProxy($env, $name);
  36069. } else {
  36070. $httpsProxy = $httpProxy;
  36071. }
  36072. $noProxy = self::getProxyEnv(['no_proxy', 'NO_PROXY'], $name);
  36073. return [$httpProxy, $httpsProxy, $noProxy];
  36074. }
  36075. public static function getContextOptions(string $proxyUrl): array
  36076. {
  36077. $proxy = parse_url($proxyUrl);
  36078. $proxyUrl = self::formatParsedUrl($proxy, false);
  36079. $proxyUrl = str_replace(['http://', 'https://'], ['tcp://', 'ssl://'], $proxyUrl);
  36080. $options['http']['proxy'] = $proxyUrl;
  36081. if (isset($proxy['user'])) {
  36082. $auth = rawurldecode($proxy['user']);
  36083. if (isset($proxy['pass'])) {
  36084. $auth .= ':' . rawurldecode($proxy['pass']);
  36085. }
  36086. $auth = base64_encode($auth);
  36087. $options['http']['header'] = "Proxy-Authorization: Basic {$auth}";
  36088. }
  36089. return $options;
  36090. }
  36091. public static function setRequestFullUri(string $requestUrl, array &$options): void
  36092. {
  36093. if ('http' === parse_url($requestUrl, PHP_URL_SCHEME)) {
  36094. $options['http']['request_fulluri'] = true;
  36095. } else {
  36096. unset($options['http']['request_fulluri']);
  36097. }
  36098. }
  36099. private static function getProxyEnv(array $names, ?string &$name): ?string
  36100. {
  36101. foreach ($names as $name) {
  36102. if (!empty($_SERVER[$name])) {
  36103. return $_SERVER[$name];
  36104. }
  36105. }
  36106. return null;
  36107. }
  36108. private static function checkProxy(string $proxyUrl, string $envName): string
  36109. {
  36110. $error = sprintf('malformed %s url', $envName);
  36111. $proxy = parse_url($proxyUrl);
  36112. if (!isset($proxy['host'])) {
  36113. throw new \RuntimeException($error);
  36114. }
  36115. $proxyUrl = self::formatParsedUrl($proxy, true);
  36116. if (!parse_url($proxyUrl, PHP_URL_PORT)) {
  36117. throw new \RuntimeException($error);
  36118. }
  36119. return $proxyUrl;
  36120. }
  36121. private static function formatParsedUrl(array $proxy, bool $includeAuth): string
  36122. {
  36123. $proxyUrl = isset($proxy['scheme']) ? strtolower($proxy['scheme']) . '://' : '';
  36124. if ($includeAuth && isset($proxy['user'])) {
  36125. $proxyUrl .= $proxy['user'];
  36126. if (isset($proxy['pass'])) {
  36127. $proxyUrl .= ':' . $proxy['pass'];
  36128. }
  36129. $proxyUrl .= '@';
  36130. }
  36131. $proxyUrl .= $proxy['host'];
  36132. if (isset($proxy['port'])) {
  36133. $proxyUrl .= ':' . $proxy['port'];
  36134. } elseif (strpos($proxyUrl, 'http://') === 0) {
  36135. $proxyUrl .= ':80';
  36136. } elseif (strpos($proxyUrl, 'https://') === 0) {
  36137. $proxyUrl .= ':443';
  36138. }
  36139. return $proxyUrl;
  36140. }
  36141. }
  36142. <?php declare(strict_types=1);
  36143. namespace Composer\Util\Http;
  36144. use Composer\Downloader\TransportException;
  36145. use Composer\Util\NoProxyPattern;
  36146. use Composer\Util\Url;
  36147. class ProxyManager
  36148. {
  36149. private $error = null;
  36150. private $fullProxy;
  36151. private $safeProxy;
  36152. private $streams;
  36153. private $hasProxy;
  36154. private $info = null;
  36155. private $noProxyHandler = null;
  36156. private static $instance = null;
  36157. private function __construct()
  36158. {
  36159. $this->fullProxy = $this->safeProxy = [
  36160. 'http' => null,
  36161. 'https' => null,
  36162. ];
  36163. $this->streams['http'] = $this->streams['https'] = [
  36164. 'options' => null,
  36165. ];
  36166. $this->hasProxy = false;
  36167. $this->initProxyData();
  36168. }
  36169. public static function getInstance(): ProxyManager
  36170. {
  36171. if (!self::$instance) {
  36172. self::$instance = new self();
  36173. }
  36174. return self::$instance;
  36175. }
  36176. public static function reset(): void
  36177. {
  36178. self::$instance = null;
  36179. }
  36180. public function getProxyForRequest(string $requestUrl): RequestProxy
  36181. {
  36182. if ($this->error) {
  36183. throw new TransportException('Unable to use a proxy: '.$this->error);
  36184. }
  36185. $scheme = parse_url($requestUrl, PHP_URL_SCHEME) ?: 'http';
  36186. $proxyUrl = '';
  36187. $options = [];
  36188. $formattedProxyUrl = '';
  36189. if ($this->hasProxy && in_array($scheme, ['http', 'https'], true) && $this->fullProxy[$scheme]) {
  36190. if ($this->noProxy($requestUrl)) {
  36191. $formattedProxyUrl = 'excluded by no_proxy';
  36192. } else {
  36193. $proxyUrl = $this->fullProxy[$scheme];
  36194. $options = $this->streams[$scheme]['options'];
  36195. ProxyHelper::setRequestFullUri($requestUrl, $options);
  36196. $formattedProxyUrl = $this->safeProxy[$scheme];
  36197. }
  36198. }
  36199. return new RequestProxy($proxyUrl, $options, $formattedProxyUrl);
  36200. }
  36201. public function isProxying(): bool
  36202. {
  36203. return $this->hasProxy;
  36204. }
  36205. public function getFormattedProxy(): ?string
  36206. {
  36207. return $this->hasProxy ? $this->info : $this->error;
  36208. }
  36209. private function initProxyData(): void
  36210. {
  36211. try {
  36212. [$httpProxy, $httpsProxy, $noProxy] = ProxyHelper::getProxyData();
  36213. } catch (\RuntimeException $e) {
  36214. $this->error = $e->getMessage();
  36215. return;
  36216. }
  36217. $info = [];
  36218. if ($httpProxy) {
  36219. $info[] = $this->setData($httpProxy, 'http');
  36220. }
  36221. if ($httpsProxy) {
  36222. $info[] = $this->setData($httpsProxy, 'https');
  36223. }
  36224. if ($this->hasProxy) {
  36225. $this->info = implode(', ', $info);
  36226. if ($noProxy) {
  36227. $this->noProxyHandler = new NoProxyPattern($noProxy);
  36228. }
  36229. }
  36230. }
  36231. private function setData($url, $scheme): string
  36232. {
  36233. $safeProxy = Url::sanitize($url);
  36234. $this->fullProxy[$scheme] = $url;
  36235. $this->safeProxy[$scheme] = $safeProxy;
  36236. $this->streams[$scheme]['options'] = ProxyHelper::getContextOptions($url);
  36237. $this->hasProxy = true;
  36238. return sprintf('%s=%s', $scheme, $safeProxy);
  36239. }
  36240. private function noProxy(string $requestUrl): bool
  36241. {
  36242. return $this->noProxyHandler && $this->noProxyHandler->test($requestUrl);
  36243. }
  36244. }
  36245. <?php declare(strict_types=1);
  36246. namespace Composer\Util\Http;
  36247. use Composer\Util\Url;
  36248. class RequestProxy
  36249. {
  36250. private $contextOptions;
  36251. private $isSecure;
  36252. private $formattedUrl;
  36253. private $url;
  36254. public function __construct(string $url, array $contextOptions, string $formattedUrl)
  36255. {
  36256. $this->url = $url;
  36257. $this->contextOptions = $contextOptions;
  36258. $this->formattedUrl = $formattedUrl;
  36259. $this->isSecure = 0 === strpos($url, 'https://');
  36260. }
  36261. public function getContextOptions(): array
  36262. {
  36263. return $this->contextOptions;
  36264. }
  36265. public function getFormattedUrl(?string $format = ''): string
  36266. {
  36267. $result = '';
  36268. if ($this->formattedUrl) {
  36269. $format = $format ?: '%s';
  36270. $result = sprintf($format, $this->formattedUrl);
  36271. }
  36272. return $result;
  36273. }
  36274. public function getUrl(): string
  36275. {
  36276. return $this->url;
  36277. }
  36278. public function isSecure(): bool
  36279. {
  36280. return $this->isSecure;
  36281. }
  36282. }
  36283. <?php declare(strict_types=1);
  36284. namespace Composer\Util\Http;
  36285. use Composer\Json\JsonFile;
  36286. use Composer\Pcre\Preg;
  36287. use Composer\Util\HttpDownloader;
  36288. class Response
  36289. {
  36290. private $request;
  36291. private $code;
  36292. private $headers;
  36293. private $body;
  36294. public function __construct(array $request, ?int $code, array $headers, ?string $body)
  36295. {
  36296. if (!isset($request['url'])) {
  36297. throw new \LogicException('url key missing from request array');
  36298. }
  36299. $this->request = $request;
  36300. $this->code = (int) $code;
  36301. $this->headers = $headers;
  36302. $this->body = $body;
  36303. }
  36304. public function getStatusCode(): int
  36305. {
  36306. return $this->code;
  36307. }
  36308. public function getStatusMessage(): ?string
  36309. {
  36310. $value = null;
  36311. foreach ($this->headers as $header) {
  36312. if (Preg::isMatch('{^HTTP/\S+ \d+}i', $header)) {
  36313. $value = $header;
  36314. }
  36315. }
  36316. return $value;
  36317. }
  36318. public function getHeaders(): array
  36319. {
  36320. return $this->headers;
  36321. }
  36322. public function getHeader(string $name): ?string
  36323. {
  36324. return self::findHeaderValue($this->headers, $name);
  36325. }
  36326. public function getBody(): ?string
  36327. {
  36328. return $this->body;
  36329. }
  36330. public function decodeJson()
  36331. {
  36332. return JsonFile::parseJson($this->body, $this->request['url']);
  36333. }
  36334. public function collect(): void
  36335. {
  36336. $this->request = $this->code = $this->headers = $this->body = null;
  36337. }
  36338. public static function findHeaderValue(array $headers, string $name): ?string
  36339. {
  36340. $value = null;
  36341. foreach ($headers as $header) {
  36342. if (Preg::isMatch('{^'.preg_quote($name).':\s*(.+?)\s*$}i', $header, $match)) {
  36343. $value = $match[1];
  36344. }
  36345. }
  36346. return $value;
  36347. }
  36348. }
  36349. <?php declare(strict_types=1);
  36350. namespace Composer\Util;
  36351. use Composer\Config;
  36352. use Composer\IO\IOInterface;
  36353. use Composer\Downloader\TransportException;
  36354. use Composer\Pcre\Preg;
  36355. use Composer\Util\Http\Response;
  36356. use Composer\Util\Http\CurlDownloader;
  36357. use Composer\Composer;
  36358. use Composer\Package\Version\VersionParser;
  36359. use Composer\Semver\Constraint\Constraint;
  36360. use Composer\Exception\IrrecoverableDownloadException;
  36361. use React\Promise\Promise;
  36362. use React\Promise\PromiseInterface;
  36363. class HttpDownloader
  36364. {
  36365. private const STATUS_QUEUED = 1;
  36366. private const STATUS_STARTED = 2;
  36367. private const STATUS_COMPLETED = 3;
  36368. private const STATUS_FAILED = 4;
  36369. private const STATUS_ABORTED = 5;
  36370. private $io;
  36371. private $config;
  36372. private $jobs = [];
  36373. private $options = [];
  36374. private $runningJobs = 0;
  36375. private $maxJobs = 12;
  36376. private $curl;
  36377. private $rfs;
  36378. private $idGen = 0;
  36379. private $disabled;
  36380. private $allowAsync = false;
  36381. public function __construct(IOInterface $io, Config $config, array $options = [], bool $disableTls = false)
  36382. {
  36383. $this->io = $io;
  36384. $this->disabled = (bool) Platform::getEnv('COMPOSER_DISABLE_NETWORK');
  36385. if ($disableTls === false) {
  36386. $this->options = StreamContextFactory::getTlsDefaults($options, $io);
  36387. }
  36388. $this->options = array_replace_recursive($this->options, $options);
  36389. $this->config = $config;
  36390. if (self::isCurlEnabled()) {
  36391. $this->curl = new CurlDownloader($io, $config, $options, $disableTls);
  36392. }
  36393. $this->rfs = new RemoteFilesystem($io, $config, $options, $disableTls);
  36394. if (is_numeric($maxJobs = Platform::getEnv('COMPOSER_MAX_PARALLEL_HTTP'))) {
  36395. $this->maxJobs = max(1, min(50, (int) $maxJobs));
  36396. }
  36397. }
  36398. public function get(string $url, array $options = [])
  36399. {
  36400. if ('' === $url) {
  36401. throw new \InvalidArgumentException('$url must not be an empty string');
  36402. }
  36403. [$job, $promise] = $this->addJob(['url' => $url, 'options' => $options, 'copyTo' => null], true);
  36404. $promise->then(null, function (\Throwable $e) {
  36405. });
  36406. $this->wait($job['id']);
  36407. $response = $this->getResponse($job['id']);
  36408. return $response;
  36409. }
  36410. public function add(string $url, array $options = [])
  36411. {
  36412. if ('' === $url) {
  36413. throw new \InvalidArgumentException('$url must not be an empty string');
  36414. }
  36415. [, $promise] = $this->addJob(['url' => $url, 'options' => $options, 'copyTo' => null]);
  36416. return $promise;
  36417. }
  36418. public function copy(string $url, string $to, array $options = [])
  36419. {
  36420. if ('' === $url) {
  36421. throw new \InvalidArgumentException('$url must not be an empty string');
  36422. }
  36423. [$job] = $this->addJob(['url' => $url, 'options' => $options, 'copyTo' => $to], true);
  36424. $this->wait($job['id']);
  36425. return $this->getResponse($job['id']);
  36426. }
  36427. public function addCopy(string $url, string $to, array $options = [])
  36428. {
  36429. if ('' === $url) {
  36430. throw new \InvalidArgumentException('$url must not be an empty string');
  36431. }
  36432. [, $promise] = $this->addJob(['url' => $url, 'options' => $options, 'copyTo' => $to]);
  36433. return $promise;
  36434. }
  36435. public function getOptions()
  36436. {
  36437. return $this->options;
  36438. }
  36439. public function setOptions(array $options)
  36440. {
  36441. $this->options = array_replace_recursive($this->options, $options);
  36442. }
  36443. private function addJob(array $request, bool $sync = false): array
  36444. {
  36445. $request['options'] = array_replace_recursive($this->options, $request['options']);
  36446. $job = [
  36447. 'id' => $this->idGen++,
  36448. 'status' => self::STATUS_QUEUED,
  36449. 'request' => $request,
  36450. 'sync' => $sync,
  36451. 'origin' => Url::getOrigin($this->config, $request['url']),
  36452. ];
  36453. if (!$sync && !$this->allowAsync) {
  36454. 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');
  36455. }
  36456. if (Preg::isMatchStrictGroups('{^https?://([^:/]+):([^@/]+)@([^/]+)}i', $request['url'], $match)) {
  36457. $this->io->setAuthentication($job['origin'], rawurldecode($match[1]), rawurldecode($match[2]));
  36458. }
  36459. $rfs = $this->rfs;
  36460. if ($this->canUseCurl($job)) {
  36461. $resolver = static function ($resolve, $reject) use (&$job): void {
  36462. $job['status'] = HttpDownloader::STATUS_QUEUED;
  36463. $job['resolve'] = $resolve;
  36464. $job['reject'] = $reject;
  36465. };
  36466. } else {
  36467. $resolver = static function ($resolve, $reject) use (&$job, $rfs): void {
  36468. $url = $job['request']['url'];
  36469. $options = $job['request']['options'];
  36470. $job['status'] = HttpDownloader::STATUS_STARTED;
  36471. if ($job['request']['copyTo']) {
  36472. $rfs->copy($job['origin'], $url, $job['request']['copyTo'], false , $options);
  36473. $headers = $rfs->getLastHeaders();
  36474. $response = new Http\Response($job['request'], $rfs->findStatusCode($headers), $headers, $job['request']['copyTo'].'~');
  36475. $resolve($response);
  36476. } else {
  36477. $body = $rfs->getContents($job['origin'], $url, false , $options);
  36478. $headers = $rfs->getLastHeaders();
  36479. $response = new Http\Response($job['request'], $rfs->findStatusCode($headers), $headers, $body);
  36480. $resolve($response);
  36481. }
  36482. };
  36483. }
  36484. $curl = $this->curl;
  36485. $canceler = static function () use (&$job, $curl): void {
  36486. if ($job['status'] === HttpDownloader::STATUS_QUEUED) {
  36487. $job['status'] = HttpDownloader::STATUS_ABORTED;
  36488. }
  36489. if ($job['status'] !== HttpDownloader::STATUS_STARTED) {
  36490. return;
  36491. }
  36492. $job['status'] = HttpDownloader::STATUS_ABORTED;
  36493. if (isset($job['curl_id'])) {
  36494. $curl->abortRequest($job['curl_id']);
  36495. }
  36496. throw new IrrecoverableDownloadException('Download of ' . Url::sanitize($job['request']['url']) . ' canceled');
  36497. };
  36498. $promise = new Promise($resolver, $canceler);
  36499. $promise = $promise->then(function ($response) use (&$job) {
  36500. $job['status'] = HttpDownloader::STATUS_COMPLETED;
  36501. $job['response'] = $response;
  36502. $this->markJobDone();
  36503. return $response;
  36504. }, function ($e) use (&$job): void {
  36505. $job['status'] = HttpDownloader::STATUS_FAILED;
  36506. $job['exception'] = $e;
  36507. $this->markJobDone();
  36508. throw $e;
  36509. });
  36510. $this->jobs[$job['id']] = &$job;
  36511. if ($this->runningJobs < $this->maxJobs) {
  36512. $this->startJob($job['id']);
  36513. }
  36514. return [$job, $promise];
  36515. }
  36516. private function startJob(int $id): void
  36517. {
  36518. $job = &$this->jobs[$id];
  36519. if ($job['status'] !== self::STATUS_QUEUED) {
  36520. return;
  36521. }
  36522. $job['status'] = self::STATUS_STARTED;
  36523. $this->runningJobs++;
  36524. assert(isset($job['resolve']));
  36525. assert(isset($job['reject']));
  36526. $resolve = $job['resolve'];
  36527. $reject = $job['reject'];
  36528. $url = $job['request']['url'];
  36529. $options = $job['request']['options'];
  36530. $origin = $job['origin'];
  36531. if ($this->disabled) {
  36532. if (isset($job['request']['options']['http']['header']) && false !== stripos(implode('', $job['request']['options']['http']['header']), 'if-modified-since')) {
  36533. $resolve(new Response(['url' => $url], 304, [], ''));
  36534. } else {
  36535. $e = new TransportException('Network disabled, request canceled: '.Url::sanitize($url), 499);
  36536. $e->setStatusCode(499);
  36537. $reject($e);
  36538. }
  36539. return;
  36540. }
  36541. try {
  36542. if ($job['request']['copyTo']) {
  36543. $job['curl_id'] = $this->curl->download($resolve, $reject, $origin, $url, $options, $job['request']['copyTo']);
  36544. } else {
  36545. $job['curl_id'] = $this->curl->download($resolve, $reject, $origin, $url, $options);
  36546. }
  36547. } catch (\Exception $exception) {
  36548. $reject($exception);
  36549. }
  36550. }
  36551. private function markJobDone(): void
  36552. {
  36553. $this->runningJobs--;
  36554. }
  36555. public function wait(?int $index = null)
  36556. {
  36557. do {
  36558. $jobCount = $this->countActiveJobs($index);
  36559. } while ($jobCount);
  36560. }
  36561. public function enableAsync(): void
  36562. {
  36563. $this->allowAsync = true;
  36564. }
  36565. public function countActiveJobs(?int $index = null): int
  36566. {
  36567. if ($this->runningJobs < $this->maxJobs) {
  36568. foreach ($this->jobs as $job) {
  36569. if ($job['status'] === self::STATUS_QUEUED && $this->runningJobs < $this->maxJobs) {
  36570. $this->startJob($job['id']);
  36571. }
  36572. }
  36573. }
  36574. if ($this->curl) {
  36575. $this->curl->tick();
  36576. }
  36577. if (null !== $index) {
  36578. return $this->jobs[$index]['status'] < self::STATUS_COMPLETED ? 1 : 0;
  36579. }
  36580. $active = 0;
  36581. foreach ($this->jobs as $job) {
  36582. if ($job['status'] < self::STATUS_COMPLETED) {
  36583. $active++;
  36584. } elseif (!$job['sync']) {
  36585. unset($this->jobs[$job['id']]);
  36586. }
  36587. }
  36588. return $active;
  36589. }
  36590. private function getResponse(int $index): Response
  36591. {
  36592. if (!isset($this->jobs[$index])) {
  36593. throw new \LogicException('Invalid request id');
  36594. }
  36595. if ($this->jobs[$index]['status'] === self::STATUS_FAILED) {
  36596. assert(isset($this->jobs[$index]['exception']));
  36597. throw $this->jobs[$index]['exception'];
  36598. }
  36599. if (!isset($this->jobs[$index]['response'])) {
  36600. throw new \LogicException('Response not available yet, call wait() first');
  36601. }
  36602. $resp = $this->jobs[$index]['response'];
  36603. unset($this->jobs[$index]);
  36604. return $resp;
  36605. }
  36606. public static function outputWarnings(IOInterface $io, string $url, $data): void
  36607. {
  36608. $cleanMessage = static function ($msg) use ($io) {
  36609. if (!$io->isDecorated()) {
  36610. $msg = Preg::replace('{'.chr(27).'\\[[;\d]*m}u', '', $msg);
  36611. }
  36612. return $msg;
  36613. };
  36614. foreach (['warning', 'info'] as $type) {
  36615. if (empty($data[$type])) {
  36616. continue;
  36617. }
  36618. if (!empty($data[$type . '-versions'])) {
  36619. $versionParser = new VersionParser();
  36620. $constraint = $versionParser->parseConstraints($data[$type . '-versions']);
  36621. $composer = new Constraint('==', $versionParser->normalize(Composer::getVersion()));
  36622. if (!$constraint->matches($composer)) {
  36623. continue;
  36624. }
  36625. }
  36626. $io->writeError('<'.$type.'>'.ucfirst($type).' from '.Url::sanitize($url).': '.$cleanMessage($data[$type]).'</'.$type.'>');
  36627. }
  36628. foreach (['warnings', 'infos'] as $key) {
  36629. if (empty($data[$key])) {
  36630. continue;
  36631. }
  36632. $versionParser = new VersionParser();
  36633. foreach ($data[$key] as $spec) {
  36634. $type = substr($key, 0, -1);
  36635. $constraint = $versionParser->parseConstraints($spec['versions']);
  36636. $composer = new Constraint('==', $versionParser->normalize(Composer::getVersion()));
  36637. if (!$constraint->matches($composer)) {
  36638. continue;
  36639. }
  36640. $io->writeError('<'.$type.'>'.ucfirst($type).' from '.Url::sanitize($url).': '.$cleanMessage($spec['message']).'</'.$type.'>');
  36641. }
  36642. }
  36643. }
  36644. public static function getExceptionHints(\Throwable $e): ?array
  36645. {
  36646. if (!$e instanceof TransportException) {
  36647. return null;
  36648. }
  36649. if (
  36650. false !== strpos($e->getMessage(), 'Resolving timed out')
  36651. || false !== strpos($e->getMessage(), 'Could not resolve host')
  36652. ) {
  36653. Silencer::suppress();
  36654. $testConnectivity = file_get_contents('https://8.8.8.8', false, stream_context_create([
  36655. 'ssl' => ['verify_peer' => false],
  36656. 'http' => ['follow_location' => false, 'ignore_errors' => true],
  36657. ]));
  36658. Silencer::restore();
  36659. if (false !== $testConnectivity) {
  36660. return [
  36661. '<error>The following exception probably indicates you have misconfigured DNS resolver(s)</error>',
  36662. ];
  36663. }
  36664. return [
  36665. '<error>The following exception probably indicates you are offline or have misconfigured DNS resolver(s)</error>',
  36666. ];
  36667. }
  36668. return null;
  36669. }
  36670. private function canUseCurl(array $job): bool
  36671. {
  36672. if (!$this->curl) {
  36673. return false;
  36674. }
  36675. if (!Preg::isMatch('{^https?://}i', $job['request']['url'])) {
  36676. return false;
  36677. }
  36678. if (!empty($job['request']['options']['ssl']['allow_self_signed'])) {
  36679. return false;
  36680. }
  36681. return true;
  36682. }
  36683. public static function isCurlEnabled(): bool
  36684. {
  36685. return \extension_loaded('curl') && \function_exists('curl_multi_exec') && \function_exists('curl_multi_init');
  36686. }
  36687. }
  36688. <?php declare(strict_types=1);
  36689. namespace Composer\Util;
  36690. use Composer\XdebugHandler\XdebugHandler;
  36691. class IniHelper
  36692. {
  36693. public static function getAll(): array
  36694. {
  36695. return XdebugHandler::getAllIniFiles();
  36696. }
  36697. public static function getMessage(): string
  36698. {
  36699. $paths = self::getAll();
  36700. if (empty($paths[0])) {
  36701. array_shift($paths);
  36702. }
  36703. $ini = array_shift($paths);
  36704. if (empty($ini)) {
  36705. return 'A php.ini file does not exist. You will have to create one.';
  36706. }
  36707. if (!empty($paths)) {
  36708. return 'Your command-line PHP is using multiple ini files. Run `php --ini` to show them.';
  36709. }
  36710. return 'The php.ini used by your command-line PHP is: '.$ini;
  36711. }
  36712. }
  36713. <?php declare(strict_types=1);
  36714. namespace Composer\Util;
  36715. use React\Promise\CancellablePromiseInterface;
  36716. use Symfony\Component\Console\Helper\ProgressBar;
  36717. use React\Promise\PromiseInterface;
  36718. class Loop
  36719. {
  36720. private $httpDownloader;
  36721. private $processExecutor;
  36722. private $currentPromises = [];
  36723. private $waitIndex = 0;
  36724. public function __construct(HttpDownloader $httpDownloader, ?ProcessExecutor $processExecutor = null)
  36725. {
  36726. $this->httpDownloader = $httpDownloader;
  36727. $this->httpDownloader->enableAsync();
  36728. $this->processExecutor = $processExecutor;
  36729. if ($this->processExecutor) {
  36730. $this->processExecutor->enableAsync();
  36731. }
  36732. }
  36733. public function getHttpDownloader(): HttpDownloader
  36734. {
  36735. return $this->httpDownloader;
  36736. }
  36737. public function getProcessExecutor(): ?ProcessExecutor
  36738. {
  36739. return $this->processExecutor;
  36740. }
  36741. public function wait(array $promises, ?ProgressBar $progress = null): void
  36742. {
  36743. $uncaught = null;
  36744. \React\Promise\all($promises)->then(
  36745. static function (): void {
  36746. },
  36747. static function (\Throwable $e) use (&$uncaught): void {
  36748. $uncaught = $e;
  36749. }
  36750. );
  36751. $waitIndex = $this->waitIndex++;
  36752. $this->currentPromises[$waitIndex] = $promises;
  36753. if ($progress) {
  36754. $totalJobs = 0;
  36755. $totalJobs += $this->httpDownloader->countActiveJobs();
  36756. if ($this->processExecutor) {
  36757. $totalJobs += $this->processExecutor->countActiveJobs();
  36758. }
  36759. $progress->start($totalJobs);
  36760. }
  36761. $lastUpdate = 0;
  36762. while (true) {
  36763. $activeJobs = 0;
  36764. $activeJobs += $this->httpDownloader->countActiveJobs();
  36765. if ($this->processExecutor) {
  36766. $activeJobs += $this->processExecutor->countActiveJobs();
  36767. }
  36768. if ($progress && microtime(true) - $lastUpdate > 0.1) {
  36769. $lastUpdate = microtime(true);
  36770. $progress->setProgress($progress->getMaxSteps() - $activeJobs);
  36771. }
  36772. if (!$activeJobs) {
  36773. break;
  36774. }
  36775. }
  36776. if ($progress) {
  36777. $progress->finish();
  36778. }
  36779. unset($this->currentPromises[$waitIndex]);
  36780. if (null !== $uncaught) {
  36781. throw $uncaught;
  36782. }
  36783. }
  36784. public function abortJobs(): void
  36785. {
  36786. foreach ($this->currentPromises as $promiseGroup) {
  36787. foreach ($promiseGroup as $promise) {
  36788. \React\Promise\resolve($promise)->cancel();
  36789. }
  36790. }
  36791. }
  36792. }
  36793. <?php declare(strict_types=1);
  36794. namespace Composer\Util;
  36795. @trigger_error('Composer\Util\MetadataMinifier is deprecated, use Composer\MetadataMinifier\MetadataMinifier from composer/metadata-minifier instead.', E_USER_DEPRECATED);
  36796. class MetadataMinifier extends \Composer\MetadataMinifier\MetadataMinifier
  36797. {
  36798. }
  36799. <?php declare(strict_types=1);
  36800. namespace Composer\Util;
  36801. use Composer\Pcre\Preg;
  36802. use stdClass;
  36803. class NoProxyPattern
  36804. {
  36805. protected $hostNames = [];
  36806. protected $rules = [];
  36807. protected $noproxy;
  36808. public function __construct(string $pattern)
  36809. {
  36810. $this->hostNames = Preg::split('{[\s,]+}', $pattern, -1, PREG_SPLIT_NO_EMPTY);
  36811. $this->noproxy = empty($this->hostNames) || '*' === $this->hostNames[0];
  36812. }
  36813. public function test(string $url): bool
  36814. {
  36815. if ($this->noproxy) {
  36816. return true;
  36817. }
  36818. if (!$urlData = $this->getUrlData($url)) {
  36819. return false;
  36820. }
  36821. foreach ($this->hostNames as $index => $hostName) {
  36822. if ($this->match($index, $hostName, $urlData)) {
  36823. return true;
  36824. }
  36825. }
  36826. return false;
  36827. }
  36828. protected function getUrlData(string $url)
  36829. {
  36830. if (!$host = parse_url($url, PHP_URL_HOST)) {
  36831. return false;
  36832. }
  36833. $port = parse_url($url, PHP_URL_PORT);
  36834. if (empty($port)) {
  36835. switch (parse_url($url, PHP_URL_SCHEME)) {
  36836. case 'http':
  36837. $port = 80;
  36838. break;
  36839. case 'https':
  36840. $port = 443;
  36841. break;
  36842. }
  36843. }
  36844. $hostName = $host . ($port ? ':' . $port : '');
  36845. [$host, $port, $err] = $this->splitHostPort($hostName);
  36846. if ($err || !$this->ipCheckData($host, $ipdata)) {
  36847. return false;
  36848. }
  36849. return $this->makeData($host, $port, $ipdata);
  36850. }
  36851. protected function match(int $index, string $hostName, stdClass $url): bool
  36852. {
  36853. if (!$rule = $this->getRule($index, $hostName)) {
  36854. return false;
  36855. }
  36856. if ($rule->ipdata) {
  36857. if (!$url->ipdata) {
  36858. return false;
  36859. }
  36860. if ($rule->ipdata->netmask) {
  36861. return $this->matchRange($rule->ipdata, $url->ipdata);
  36862. }
  36863. $match = $rule->ipdata->ip === $url->ipdata->ip;
  36864. } else {
  36865. $haystack = substr($url->name, -strlen($rule->name));
  36866. $match = stripos($haystack, $rule->name) === 0;
  36867. }
  36868. if ($match && $rule->port) {
  36869. $match = $rule->port === $url->port;
  36870. }
  36871. return $match;
  36872. }
  36873. protected function matchRange(stdClass $network, stdClass $target): bool
  36874. {
  36875. $net = unpack('C*', $network->ip);
  36876. $mask = unpack('C*', $network->netmask);
  36877. $ip = unpack('C*', $target->ip);
  36878. if (false === $net) {
  36879. throw new \RuntimeException('Could not parse network IP '.$network->ip);
  36880. }
  36881. if (false === $mask) {
  36882. throw new \RuntimeException('Could not parse netmask '.$network->netmask);
  36883. }
  36884. if (false === $ip) {
  36885. throw new \RuntimeException('Could not parse target IP '.$target->ip);
  36886. }
  36887. for ($i = 1; $i < 17; ++$i) {
  36888. if (($net[$i] & $mask[$i]) !== ($ip[$i] & $mask[$i])) {
  36889. return false;
  36890. }
  36891. }
  36892. return true;
  36893. }
  36894. private function getRule(int $index, string $hostName): ?stdClass
  36895. {
  36896. if (array_key_exists($index, $this->rules)) {
  36897. return $this->rules[$index];
  36898. }
  36899. $this->rules[$index] = null;
  36900. [$host, $port, $err] = $this->splitHostPort($hostName);
  36901. if ($err || !$this->ipCheckData($host, $ipdata, true)) {
  36902. return null;
  36903. }
  36904. $this->rules[$index] = $this->makeData($host, $port, $ipdata);
  36905. return $this->rules[$index];
  36906. }
  36907. private function ipCheckData(string $host, ?stdClass &$ipdata, bool $allowPrefix = false): bool
  36908. {
  36909. $ipdata = null;
  36910. $netmask = null;
  36911. $prefix = null;
  36912. $modified = false;
  36913. if (strpos($host, '/') !== false) {
  36914. [$host, $prefix] = explode('/', $host);
  36915. if (!$allowPrefix || !$this->validateInt($prefix, 0, 128)) {
  36916. return false;
  36917. }
  36918. $prefix = (int) $prefix;
  36919. $modified = true;
  36920. }
  36921. if (!filter_var($host, FILTER_VALIDATE_IP)) {
  36922. return !$modified;
  36923. }
  36924. [$ip, $size] = $this->ipGetAddr($host);
  36925. if ($prefix !== null) {
  36926. if ($prefix > $size * 8) {
  36927. return false;
  36928. }
  36929. [$ip, $netmask] = $this->ipGetNetwork($ip, $size, $prefix);
  36930. }
  36931. $ipdata = $this->makeIpData($ip, $size, $netmask);
  36932. return true;
  36933. }
  36934. private function ipGetAddr(string $host): array
  36935. {
  36936. $ip = inet_pton($host);
  36937. $size = strlen($ip);
  36938. $mapped = $this->ipMapTo6($ip, $size);
  36939. return [$mapped, $size];
  36940. }
  36941. private function ipGetMask(int $prefix, int $size): string
  36942. {
  36943. $mask = '';
  36944. if ($ones = floor($prefix / 8)) {
  36945. $mask = str_repeat(chr(255), (int) $ones);
  36946. }
  36947. if ($remainder = $prefix % 8) {
  36948. $mask .= chr(0xff ^ (0xff >> $remainder));
  36949. }
  36950. $mask = str_pad($mask, $size, chr(0));
  36951. return $this->ipMapTo6($mask, $size);
  36952. }
  36953. private function ipGetNetwork(string $rangeIp, int $size, int $prefix): array
  36954. {
  36955. $netmask = $this->ipGetMask($prefix, $size);
  36956. $mask = unpack('C*', $netmask);
  36957. $ip = unpack('C*', $rangeIp);
  36958. $net = '';
  36959. if (false === $mask) {
  36960. throw new \RuntimeException('Could not parse netmask '.$netmask);
  36961. }
  36962. if (false === $ip) {
  36963. throw new \RuntimeException('Could not parse range IP '.$rangeIp);
  36964. }
  36965. for ($i = 1; $i < 17; ++$i) {
  36966. $net .= chr($ip[$i] & $mask[$i]);
  36967. }
  36968. return [$net, $netmask];
  36969. }
  36970. private function ipMapTo6(string $binary, int $size): string
  36971. {
  36972. if ($size === 4) {
  36973. $prefix = str_repeat(chr(0), 10) . str_repeat(chr(255), 2);
  36974. $binary = $prefix . $binary;
  36975. }
  36976. return $binary;
  36977. }
  36978. private function makeData(string $host, int $port, ?stdClass $ipdata): stdClass
  36979. {
  36980. return (object) [
  36981. 'host' => $host,
  36982. 'name' => '.' . ltrim($host, '.'),
  36983. 'port' => $port,
  36984. 'ipdata' => $ipdata,
  36985. ];
  36986. }
  36987. private function makeIpData(string $ip, int $size, ?string $netmask): stdClass
  36988. {
  36989. return (object) [
  36990. 'ip' => $ip,
  36991. 'size' => $size,
  36992. 'netmask' => $netmask,
  36993. ];
  36994. }
  36995. private function splitHostPort(string $hostName): array
  36996. {
  36997. $error = ['', '', true];
  36998. $port = 0;
  36999. $ip6 = '';
  37000. if ($hostName[0] === '[') {
  37001. $index = strpos($hostName, ']');
  37002. if (false === $index || $index < 3) {
  37003. return $error;
  37004. }
  37005. $ip6 = substr($hostName, 1, $index - 1);
  37006. $hostName = substr($hostName, $index + 1);
  37007. if (strpbrk($hostName, '[]') !== false || substr_count($hostName, ':') > 1) {
  37008. return $error;
  37009. }
  37010. }
  37011. if (substr_count($hostName, ':') === 1) {
  37012. $index = strpos($hostName, ':');
  37013. $port = substr($hostName, $index + 1);
  37014. $hostName = substr($hostName, 0, $index);
  37015. if (!$this->validateInt($port, 1, 65535)) {
  37016. return $error;
  37017. }
  37018. $port = (int) $port;
  37019. }
  37020. $host = $ip6 . $hostName;
  37021. return [$host, $port, false];
  37022. }
  37023. private function validateInt(string $int, int $min, int $max): bool
  37024. {
  37025. $options = [
  37026. 'options' => [
  37027. 'min_range' => $min,
  37028. 'max_range' => $max,
  37029. ],
  37030. ];
  37031. return false !== filter_var($int, FILTER_VALIDATE_INT, $options);
  37032. }
  37033. }
  37034. <?php declare(strict_types=1);
  37035. namespace Composer\Util;
  37036. use Composer\Package\CompletePackageInterface;
  37037. use Composer\Package\PackageInterface;
  37038. class PackageInfo
  37039. {
  37040. public static function getViewSourceUrl(PackageInterface $package): ?string
  37041. {
  37042. if ($package instanceof CompletePackageInterface && isset($package->getSupport()['source']) && '' !== $package->getSupport()['source']) {
  37043. return $package->getSupport()['source'];
  37044. }
  37045. return $package->getSourceUrl();
  37046. }
  37047. public static function getViewSourceOrHomepageUrl(PackageInterface $package): ?string
  37048. {
  37049. $url = self::getViewSourceUrl($package) ?? ($package instanceof CompletePackageInterface ? $package->getHomepage() : null);
  37050. if ($url === '') {
  37051. return null;
  37052. }
  37053. return $url;
  37054. }
  37055. }
  37056. <?php declare(strict_types=1);
  37057. namespace Composer\Util;
  37058. use Composer\Package\PackageInterface;
  37059. use Composer\Package\RootPackageInterface;
  37060. class PackageSorter
  37061. {
  37062. public static function getMostCurrentVersion(array $packages): ?PackageInterface
  37063. {
  37064. if (count($packages) === 0) {
  37065. return null;
  37066. }
  37067. $highest = reset($packages);
  37068. foreach ($packages as $candidate) {
  37069. if ($candidate->isDefaultBranch()) {
  37070. return $candidate;
  37071. }
  37072. if (version_compare($highest->getVersion(), $candidate->getVersion(), '<')) {
  37073. $highest = $candidate;
  37074. }
  37075. }
  37076. return $highest;
  37077. }
  37078. public static function sortPackagesAlphabetically(array $packages): array
  37079. {
  37080. usort($packages, static function (PackageInterface $a, PackageInterface $b) {
  37081. return $a->getName() <=> $b->getName();
  37082. });
  37083. return $packages;
  37084. }
  37085. public static function sortPackages(array $packages, array $weights = []): array
  37086. {
  37087. $usageList = [];
  37088. foreach ($packages as $package) {
  37089. $links = $package->getRequires();
  37090. if ($package instanceof RootPackageInterface) {
  37091. $links = array_merge($links, $package->getDevRequires());
  37092. }
  37093. foreach ($links as $link) {
  37094. $target = $link->getTarget();
  37095. $usageList[$target][] = $package->getName();
  37096. }
  37097. }
  37098. $computing = [];
  37099. $computed = [];
  37100. $computeImportance = static function ($name) use (&$computeImportance, &$computing, &$computed, $usageList, $weights) {
  37101. if (isset($computed[$name])) {
  37102. return $computed[$name];
  37103. }
  37104. if (isset($computing[$name])) {
  37105. return 0;
  37106. }
  37107. $computing[$name] = true;
  37108. $weight = $weights[$name] ?? 0;
  37109. if (isset($usageList[$name])) {
  37110. foreach ($usageList[$name] as $user) {
  37111. $weight -= 1 - $computeImportance($user);
  37112. }
  37113. }
  37114. unset($computing[$name]);
  37115. $computed[$name] = $weight;
  37116. return $weight;
  37117. };
  37118. $weightedPackages = [];
  37119. foreach ($packages as $index => $package) {
  37120. $name = $package->getName();
  37121. $weight = $computeImportance($name);
  37122. $weightedPackages[] = ['name' => $name, 'weight' => $weight, 'index' => $index];
  37123. }
  37124. usort($weightedPackages, static function (array $a, array $b): int {
  37125. if ($a['weight'] !== $b['weight']) {
  37126. return $a['weight'] - $b['weight'];
  37127. }
  37128. return strnatcasecmp($a['name'], $b['name']);
  37129. });
  37130. $sortedPackages = [];
  37131. foreach ($weightedPackages as $pkg) {
  37132. $sortedPackages[] = $packages[$pkg['index']];
  37133. }
  37134. return $sortedPackages;
  37135. }
  37136. }
  37137. <?php declare(strict_types=1);
  37138. namespace Composer\Util;
  37139. use Composer\IO\IOInterface;
  37140. use Composer\Pcre\Preg;
  37141. use Symfony\Component\Process\Process;
  37142. class Perforce
  37143. {
  37144. protected $path;
  37145. protected $p4Depot;
  37146. protected $p4Client;
  37147. protected $p4User;
  37148. protected $p4Password;
  37149. protected $p4Port;
  37150. protected $p4Stream;
  37151. protected $p4ClientSpec;
  37152. protected $p4DepotType;
  37153. protected $p4Branch;
  37154. protected $process;
  37155. protected $uniquePerforceClientName;
  37156. protected $windowsFlag;
  37157. protected $commandResult;
  37158. protected $io;
  37159. protected $filesystem;
  37160. public function __construct($repoConfig, string $port, string $path, ProcessExecutor $process, bool $isWindows, IOInterface $io)
  37161. {
  37162. $this->windowsFlag = $isWindows;
  37163. $this->p4Port = $port;
  37164. $this->initializePath($path);
  37165. $this->process = $process;
  37166. $this->initialize($repoConfig);
  37167. $this->io = $io;
  37168. }
  37169. public static function create($repoConfig, string $port, string $path, ProcessExecutor $process, IOInterface $io): self
  37170. {
  37171. return new Perforce($repoConfig, $port, $path, $process, Platform::isWindows(), $io);
  37172. }
  37173. public static function checkServerExists(string $url, ProcessExecutor $processExecutor): bool
  37174. {
  37175. return 0 === $processExecutor->execute('p4 -p ' . ProcessExecutor::escape($url) . ' info -s', $ignoredOutput);
  37176. }
  37177. public function initialize($repoConfig): void
  37178. {
  37179. $this->uniquePerforceClientName = $this->generateUniquePerforceClientName();
  37180. if (!$repoConfig) {
  37181. return;
  37182. }
  37183. if (isset($repoConfig['unique_perforce_client_name'])) {
  37184. $this->uniquePerforceClientName = $repoConfig['unique_perforce_client_name'];
  37185. }
  37186. if (isset($repoConfig['depot'])) {
  37187. $this->p4Depot = $repoConfig['depot'];
  37188. }
  37189. if (isset($repoConfig['branch'])) {
  37190. $this->p4Branch = $repoConfig['branch'];
  37191. }
  37192. if (isset($repoConfig['p4user'])) {
  37193. $this->p4User = $repoConfig['p4user'];
  37194. } else {
  37195. $this->p4User = $this->getP4variable('P4USER');
  37196. }
  37197. if (isset($repoConfig['p4password'])) {
  37198. $this->p4Password = $repoConfig['p4password'];
  37199. }
  37200. }
  37201. public function initializeDepotAndBranch(?string $depot, ?string $branch): void
  37202. {
  37203. if (isset($depot)) {
  37204. $this->p4Depot = $depot;
  37205. }
  37206. if (isset($branch)) {
  37207. $this->p4Branch = $branch;
  37208. }
  37209. }
  37210. public function generateUniquePerforceClientName(): string
  37211. {
  37212. return gethostname() . "_" . time();
  37213. }
  37214. public function cleanupClientSpec(): void
  37215. {
  37216. $client = $this->getClient();
  37217. $task = 'client -d ' . ProcessExecutor::escape($client);
  37218. $useP4Client = false;
  37219. $command = $this->generateP4Command($task, $useP4Client);
  37220. $this->executeCommand($command);
  37221. $clientSpec = $this->getP4ClientSpec();
  37222. $fileSystem = $this->getFilesystem();
  37223. $fileSystem->remove($clientSpec);
  37224. }
  37225. protected function executeCommand($command): int
  37226. {
  37227. $this->commandResult = '';
  37228. return $this->process->execute($command, $this->commandResult);
  37229. }
  37230. public function getClient(): string
  37231. {
  37232. if (!isset($this->p4Client)) {
  37233. $cleanStreamName = str_replace(['//', '/', '@'], ['', '_', ''], $this->getStream());
  37234. $this->p4Client = 'composer_perforce_' . $this->uniquePerforceClientName . '_' . $cleanStreamName;
  37235. }
  37236. return $this->p4Client;
  37237. }
  37238. protected function getPath(): string
  37239. {
  37240. return $this->path;
  37241. }
  37242. public function initializePath(string $path): void
  37243. {
  37244. $this->path = $path;
  37245. $fs = $this->getFilesystem();
  37246. $fs->ensureDirectoryExists($path);
  37247. }
  37248. protected function getPort(): string
  37249. {
  37250. return $this->p4Port;
  37251. }
  37252. public function setStream(string $stream): void
  37253. {
  37254. $this->p4Stream = $stream;
  37255. $index = strrpos($stream, '/');
  37256. if ($index > 2) {
  37257. $this->p4DepotType = 'stream';
  37258. }
  37259. }
  37260. public function isStream(): bool
  37261. {
  37262. return is_string($this->p4DepotType) && (strcmp($this->p4DepotType, 'stream') === 0);
  37263. }
  37264. public function getStream(): string
  37265. {
  37266. if (!isset($this->p4Stream)) {
  37267. if ($this->isStream()) {
  37268. $this->p4Stream = '//' . $this->p4Depot . '/' . $this->p4Branch;
  37269. } else {
  37270. $this->p4Stream = '//' . $this->p4Depot;
  37271. }
  37272. }
  37273. return $this->p4Stream;
  37274. }
  37275. public function getStreamWithoutLabel(string $stream): string
  37276. {
  37277. $index = strpos($stream, '@');
  37278. if ($index === false) {
  37279. return $stream;
  37280. }
  37281. return substr($stream, 0, $index);
  37282. }
  37283. public function getP4ClientSpec(): string
  37284. {
  37285. return $this->path . '/' . $this->getClient() . '.p4.spec';
  37286. }
  37287. public function getUser(): ?string
  37288. {
  37289. return $this->p4User;
  37290. }
  37291. public function setUser(?string $user): void
  37292. {
  37293. $this->p4User = $user;
  37294. }
  37295. public function queryP4User(): void
  37296. {
  37297. $this->getUser();
  37298. if (strlen((string) $this->p4User) > 0) {
  37299. return;
  37300. }
  37301. $this->p4User = $this->getP4variable('P4USER');
  37302. if (strlen((string) $this->p4User) > 0) {
  37303. return;
  37304. }
  37305. $this->p4User = $this->io->ask('Enter P4 User:');
  37306. if ($this->windowsFlag) {
  37307. $command = 'p4 set P4USER=' . $this->p4User;
  37308. } else {
  37309. $command = 'export P4USER=' . $this->p4User;
  37310. }
  37311. $this->executeCommand($command);
  37312. }
  37313. protected function getP4variable(string $name): ?string
  37314. {
  37315. if ($this->windowsFlag) {
  37316. $command = 'p4 set';
  37317. $this->executeCommand($command);
  37318. $result = trim($this->commandResult);
  37319. $resArray = explode(PHP_EOL, $result);
  37320. foreach ($resArray as $line) {
  37321. $fields = explode('=', $line);
  37322. if (strcmp($name, $fields[0]) === 0) {
  37323. $index = strpos($fields[1], ' ');
  37324. if ($index === false) {
  37325. $value = $fields[1];
  37326. } else {
  37327. $value = substr($fields[1], 0, $index);
  37328. }
  37329. $value = trim($value);
  37330. return $value;
  37331. }
  37332. }
  37333. return null;
  37334. }
  37335. $command = 'echo $' . $name;
  37336. $this->executeCommand($command);
  37337. $result = trim($this->commandResult);
  37338. return $result;
  37339. }
  37340. public function queryP4Password(): ?string
  37341. {
  37342. if (isset($this->p4Password)) {
  37343. return $this->p4Password;
  37344. }
  37345. $password = $this->getP4variable('P4PASSWD');
  37346. if (strlen((string) $password) <= 0) {
  37347. $password = $this->io->askAndHideAnswer('Enter password for Perforce user ' . $this->getUser() . ': ');
  37348. }
  37349. $this->p4Password = $password;
  37350. return $password;
  37351. }
  37352. public function generateP4Command(string $command, bool $useClient = true): string
  37353. {
  37354. $p4Command = 'p4 ';
  37355. $p4Command .= '-u ' . $this->getUser() . ' ';
  37356. if ($useClient) {
  37357. $p4Command .= '-c ' . $this->getClient() . ' ';
  37358. }
  37359. $p4Command .= '-p ' . $this->getPort() . ' ' . $command;
  37360. return $p4Command;
  37361. }
  37362. public function isLoggedIn(): bool
  37363. {
  37364. $command = $this->generateP4Command('login -s', false);
  37365. $exitCode = $this->executeCommand($command);
  37366. if ($exitCode) {
  37367. $errorOutput = $this->process->getErrorOutput();
  37368. $index = strpos($errorOutput, $this->getUser());
  37369. if ($index === false) {
  37370. $index = strpos($errorOutput, 'p4');
  37371. if ($index === false) {
  37372. return false;
  37373. }
  37374. throw new \Exception('p4 command not found in path: ' . $errorOutput);
  37375. }
  37376. throw new \Exception('Invalid user name: ' . $this->getUser());
  37377. }
  37378. return true;
  37379. }
  37380. public function connectClient(): void
  37381. {
  37382. $p4CreateClientCommand = $this->generateP4Command(
  37383. 'client -i < ' . str_replace(" ", "\\ ", $this->getP4ClientSpec())
  37384. );
  37385. $this->executeCommand($p4CreateClientCommand);
  37386. }
  37387. public function syncCodeBase(?string $sourceReference): void
  37388. {
  37389. $prevDir = Platform::getCwd();
  37390. chdir($this->path);
  37391. $p4SyncCommand = $this->generateP4Command('sync -f ');
  37392. if (null !== $sourceReference) {
  37393. $p4SyncCommand .= '@' . $sourceReference;
  37394. }
  37395. $this->executeCommand($p4SyncCommand);
  37396. chdir($prevDir);
  37397. }
  37398. public function writeClientSpecToFile($spec): void
  37399. {
  37400. fwrite($spec, 'Client: ' . $this->getClient() . PHP_EOL . PHP_EOL);
  37401. fwrite($spec, 'Update: ' . date('Y/m/d H:i:s') . PHP_EOL . PHP_EOL);
  37402. fwrite($spec, 'Access: ' . date('Y/m/d H:i:s') . PHP_EOL);
  37403. fwrite($spec, 'Owner: ' . $this->getUser() . PHP_EOL . PHP_EOL);
  37404. fwrite($spec, 'Description:' . PHP_EOL);
  37405. fwrite($spec, ' Created by ' . $this->getUser() . ' from composer.' . PHP_EOL . PHP_EOL);
  37406. fwrite($spec, 'Root: ' . $this->getPath() . PHP_EOL . PHP_EOL);
  37407. fwrite($spec, 'Options: noallwrite noclobber nocompress unlocked modtime rmdir' . PHP_EOL . PHP_EOL);
  37408. fwrite($spec, 'SubmitOptions: revertunchanged' . PHP_EOL . PHP_EOL);
  37409. fwrite($spec, 'LineEnd: local' . PHP_EOL . PHP_EOL);
  37410. if ($this->isStream()) {
  37411. fwrite($spec, 'Stream:' . PHP_EOL);
  37412. fwrite($spec, ' ' . $this->getStreamWithoutLabel($this->p4Stream) . PHP_EOL);
  37413. } else {
  37414. fwrite(
  37415. $spec,
  37416. 'View: ' . $this->getStream() . '/... //' . $this->getClient() . '/... ' . PHP_EOL
  37417. );
  37418. }
  37419. }
  37420. public function writeP4ClientSpec(): void
  37421. {
  37422. $clientSpec = $this->getP4ClientSpec();
  37423. $spec = fopen($clientSpec, 'w');
  37424. try {
  37425. $this->writeClientSpecToFile($spec);
  37426. } catch (\Exception $e) {
  37427. fclose($spec);
  37428. throw $e;
  37429. }
  37430. fclose($spec);
  37431. }
  37432. protected function read($pipe, $name): void
  37433. {
  37434. if (feof($pipe)) {
  37435. return;
  37436. }
  37437. $line = fgets($pipe);
  37438. while ($line !== false) {
  37439. $line = fgets($pipe);
  37440. }
  37441. }
  37442. public function windowsLogin(?string $password): int
  37443. {
  37444. $command = $this->generateP4Command(' login -a');
  37445. $process = Process::fromShellCommandline($command, null, null, $password);
  37446. return $process->run();
  37447. }
  37448. public function p4Login(): void
  37449. {
  37450. $this->queryP4User();
  37451. if (!$this->isLoggedIn()) {
  37452. $password = $this->queryP4Password();
  37453. if ($this->windowsFlag) {
  37454. $this->windowsLogin($password);
  37455. } else {
  37456. $command = 'echo ' . ProcessExecutor::escape($password) . ' | ' . $this->generateP4Command(' login -a', false);
  37457. $exitCode = $this->executeCommand($command);
  37458. if ($exitCode) {
  37459. throw new \Exception("Error logging in:" . $this->process->getErrorOutput());
  37460. }
  37461. }
  37462. }
  37463. }
  37464. public function getComposerInformation(string $identifier): ?array
  37465. {
  37466. $composerFileContent = $this->getFileContent('composer.json', $identifier);
  37467. if (!$composerFileContent) {
  37468. return null;
  37469. }
  37470. return json_decode($composerFileContent, true);
  37471. }
  37472. public function getFileContent(string $file, string $identifier): ?string
  37473. {
  37474. $path = $this->getFilePath($file, $identifier);
  37475. $command = $this->generateP4Command(' print ' . ProcessExecutor::escape($path));
  37476. $this->executeCommand($command);
  37477. $result = $this->commandResult;
  37478. if (!trim($result)) {
  37479. return null;
  37480. }
  37481. return $result;
  37482. }
  37483. public function getFilePath(string $file, string $identifier): ?string
  37484. {
  37485. $index = strpos($identifier, '@');
  37486. if ($index === false) {
  37487. return $identifier. '/' . $file;
  37488. }
  37489. $path = substr($identifier, 0, $index) . '/' . $file . substr($identifier, $index);
  37490. $command = $this->generateP4Command(' files ' . ProcessExecutor::escape($path), false);
  37491. $this->executeCommand($command);
  37492. $result = $this->commandResult;
  37493. $index2 = strpos($result, 'no such file(s).');
  37494. if ($index2 === false) {
  37495. $index3 = strpos($result, 'change');
  37496. if ($index3 !== false) {
  37497. $phrase = trim(substr($result, $index3));
  37498. $fields = explode(' ', $phrase);
  37499. return substr($identifier, 0, $index) . '/' . $file . '@' . $fields[1];
  37500. }
  37501. }
  37502. return null;
  37503. }
  37504. public function getBranches(): array
  37505. {
  37506. $possibleBranches = [];
  37507. if (!$this->isStream()) {
  37508. $possibleBranches[$this->p4Branch] = $this->getStream();
  37509. } else {
  37510. $command = $this->generateP4Command('streams '.ProcessExecutor::escape('//' . $this->p4Depot . '/...'));
  37511. $this->executeCommand($command);
  37512. $result = $this->commandResult;
  37513. $resArray = explode(PHP_EOL, $result);
  37514. foreach ($resArray as $line) {
  37515. $resBits = explode(' ', $line);
  37516. if (count($resBits) > 4) {
  37517. $branch = Preg::replace('/[^A-Za-z0-9 ]/', '', $resBits[4]);
  37518. $possibleBranches[$branch] = $resBits[1];
  37519. }
  37520. }
  37521. }
  37522. $command = $this->generateP4Command('changes '. ProcessExecutor::escape($this->getStream() . '/...'), false);
  37523. $this->executeCommand($command);
  37524. $result = $this->commandResult;
  37525. $resArray = explode(PHP_EOL, $result);
  37526. $lastCommit = $resArray[0];
  37527. $lastCommitArr = explode(' ', $lastCommit);
  37528. $lastCommitNum = $lastCommitArr[1];
  37529. return ['master' => $possibleBranches[$this->p4Branch] . '@'. $lastCommitNum];
  37530. }
  37531. public function getTags(): array
  37532. {
  37533. $command = $this->generateP4Command('labels');
  37534. $this->executeCommand($command);
  37535. $result = $this->commandResult;
  37536. $resArray = explode(PHP_EOL, $result);
  37537. $tags = [];
  37538. foreach ($resArray as $line) {
  37539. if (strpos($line, 'Label') !== false) {
  37540. $fields = explode(' ', $line);
  37541. $tags[$fields[1]] = $this->getStream() . '@' . $fields[1];
  37542. }
  37543. }
  37544. return $tags;
  37545. }
  37546. public function checkStream(): bool
  37547. {
  37548. $command = $this->generateP4Command('depots', false);
  37549. $this->executeCommand($command);
  37550. $result = $this->commandResult;
  37551. $resArray = explode(PHP_EOL, $result);
  37552. foreach ($resArray as $line) {
  37553. if (strpos($line, 'Depot') !== false) {
  37554. $fields = explode(' ', $line);
  37555. if (strcmp($this->p4Depot, $fields[1]) === 0) {
  37556. $this->p4DepotType = $fields[3];
  37557. return $this->isStream();
  37558. }
  37559. }
  37560. }
  37561. return false;
  37562. }
  37563. protected function getChangeList(string $reference): mixed
  37564. {
  37565. $index = strpos($reference, '@');
  37566. if ($index === false) {
  37567. return null;
  37568. }
  37569. $label = substr($reference, $index);
  37570. $command = $this->generateP4Command(' changes -m1 ' . ProcessExecutor::escape($label));
  37571. $this->executeCommand($command);
  37572. $changes = $this->commandResult;
  37573. if (strpos($changes, 'Change') !== 0) {
  37574. return null;
  37575. }
  37576. $fields = explode(' ', $changes);
  37577. return $fields[1];
  37578. }
  37579. public function getCommitLogs(string $fromReference, string $toReference): mixed
  37580. {
  37581. $fromChangeList = $this->getChangeList($fromReference);
  37582. if ($fromChangeList === null) {
  37583. return null;
  37584. }
  37585. $toChangeList = $this->getChangeList($toReference);
  37586. if ($toChangeList === null) {
  37587. return null;
  37588. }
  37589. $index = strpos($fromReference, '@');
  37590. $main = substr($fromReference, 0, $index) . '/...';
  37591. $command = $this->generateP4Command('filelog ' . ProcessExecutor::escape($main . '@' . $fromChangeList. ',' . $toChangeList));
  37592. $this->executeCommand($command);
  37593. return $this->commandResult;
  37594. }
  37595. public function getFilesystem(): Filesystem
  37596. {
  37597. if (null === $this->filesystem) {
  37598. $this->filesystem = new Filesystem($this->process);
  37599. }
  37600. return $this->filesystem;
  37601. }
  37602. public function setFilesystem(Filesystem $fs): void
  37603. {
  37604. $this->filesystem = $fs;
  37605. }
  37606. }
  37607. <?php declare(strict_types=1);
  37608. namespace Composer\Util;
  37609. use Composer\Pcre\Preg;
  37610. class Platform
  37611. {
  37612. private static $isVirtualBoxGuest = null;
  37613. private static $isWindowsSubsystemForLinux = null;
  37614. public static function getCwd(bool $allowEmpty = false): string
  37615. {
  37616. $cwd = getcwd();
  37617. if (false === $cwd) {
  37618. $cwd = realpath('');
  37619. }
  37620. if (false === $cwd) {
  37621. if ($allowEmpty) {
  37622. return '';
  37623. }
  37624. throw new \RuntimeException('Could not determine the current working directory');
  37625. }
  37626. return $cwd;
  37627. }
  37628. public static function getEnv(string $name)
  37629. {
  37630. if (array_key_exists($name, $_SERVER)) {
  37631. return (string) $_SERVER[$name];
  37632. }
  37633. if (array_key_exists($name, $_ENV)) {
  37634. return (string) $_ENV[$name];
  37635. }
  37636. return getenv($name);
  37637. }
  37638. public static function putEnv(string $name, string $value): void
  37639. {
  37640. $value = (string) $value;
  37641. putenv($name . '=' . $value);
  37642. $_SERVER[$name] = $_ENV[$name] = $value;
  37643. }
  37644. public static function clearEnv(string $name): void
  37645. {
  37646. putenv($name);
  37647. unset($_SERVER[$name], $_ENV[$name]);
  37648. }
  37649. public static function expandPath(string $path): string
  37650. {
  37651. if (Preg::isMatch('#^~[\\/]#', $path)) {
  37652. return self::getUserDirectory() . substr($path, 1);
  37653. }
  37654. return Preg::replaceCallback('#^(\$|(?P<percent>%))(?P<var>\w++)(?(percent)%)(?P<path>.*)#', static function ($matches): string {
  37655. assert(is_string($matches['var']));
  37656. if (Platform::isWindows() && $matches['var'] === 'HOME') {
  37657. return (Platform::getEnv('HOME') ?: Platform::getEnv('USERPROFILE')) . $matches['path'];
  37658. }
  37659. return Platform::getEnv($matches['var']) . $matches['path'];
  37660. }, $path);
  37661. }
  37662. public static function getUserDirectory(): string
  37663. {
  37664. if (false !== ($home = self::getEnv('HOME'))) {
  37665. return $home;
  37666. }
  37667. if (self::isWindows() && false !== ($home = self::getEnv('USERPROFILE'))) {
  37668. return $home;
  37669. }
  37670. if (\function_exists('posix_getuid') && \function_exists('posix_getpwuid')) {
  37671. $info = posix_getpwuid(posix_getuid());
  37672. return $info['dir'];
  37673. }
  37674. throw new \RuntimeException('Could not determine user directory');
  37675. }
  37676. public static function isWindowsSubsystemForLinux(): bool
  37677. {
  37678. if (null === self::$isWindowsSubsystemForLinux) {
  37679. self::$isWindowsSubsystemForLinux = false;
  37680. if (self::isWindows()) {
  37681. return self::$isWindowsSubsystemForLinux = false;
  37682. }
  37683. if (
  37684. !ini_get('open_basedir')
  37685. && is_readable('/proc/version')
  37686. && false !== stripos((string)Silencer::call('file_get_contents', '/proc/version'), 'microsoft')
  37687. && !file_exists('/.dockerenv')
  37688. ) {
  37689. return self::$isWindowsSubsystemForLinux = true;
  37690. }
  37691. }
  37692. return self::$isWindowsSubsystemForLinux;
  37693. }
  37694. public static function isWindows(): bool
  37695. {
  37696. return \defined('PHP_WINDOWS_VERSION_BUILD');
  37697. }
  37698. public static function strlen(string $str): int
  37699. {
  37700. static $useMbString = null;
  37701. if (null === $useMbString) {
  37702. $useMbString = \function_exists('mb_strlen') && ini_get('mbstring.func_overload');
  37703. }
  37704. if ($useMbString) {
  37705. return mb_strlen($str, '8bit');
  37706. }
  37707. return \strlen($str);
  37708. }
  37709. public static function isTty($fd = null): bool
  37710. {
  37711. if ($fd === null) {
  37712. $fd = defined('STDOUT') ? STDOUT : fopen('php://stdout', 'w');
  37713. if ($fd === false) {
  37714. return false;
  37715. }
  37716. }
  37717. if (in_array(strtoupper(self::getEnv('MSYSTEM') ?: ''), ['MINGW32', 'MINGW64'], true)) {
  37718. return true;
  37719. }
  37720. if (function_exists('stream_isatty')) {
  37721. return stream_isatty($fd);
  37722. }
  37723. if (function_exists('posix_isatty') && posix_isatty($fd)) {
  37724. return true;
  37725. }
  37726. $stat = @fstat($fd);
  37727. return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
  37728. }
  37729. public static function isInputCompletionProcess(): bool
  37730. {
  37731. return '_complete' === ($_SERVER['argv'][1] ?? null);
  37732. }
  37733. public static function workaroundFilesystemIssues(): void
  37734. {
  37735. if (self::isVirtualBoxGuest()) {
  37736. usleep(200000);
  37737. }
  37738. }
  37739. private static function isVirtualBoxGuest(): bool
  37740. {
  37741. if (null === self::$isVirtualBoxGuest) {
  37742. self::$isVirtualBoxGuest = false;
  37743. if (self::isWindows()) {
  37744. return self::$isVirtualBoxGuest;
  37745. }
  37746. if (function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
  37747. $processUser = posix_getpwuid(posix_geteuid());
  37748. if ($processUser && $processUser['name'] === 'vagrant') {
  37749. return self::$isVirtualBoxGuest = true;
  37750. }
  37751. }
  37752. if (self::getEnv('COMPOSER_RUNTIME_ENV') === 'virtualbox') {
  37753. return self::$isVirtualBoxGuest = true;
  37754. }
  37755. if (defined('PHP_OS_FAMILY') && PHP_OS_FAMILY === 'Linux') {
  37756. $process = new ProcessExecutor();
  37757. try {
  37758. if (0 === $process->execute('lsmod | grep vboxguest', $ignoredOutput)) {
  37759. return self::$isVirtualBoxGuest = true;
  37760. }
  37761. } catch (\Exception $e) {
  37762. }
  37763. }
  37764. }
  37765. return self::$isVirtualBoxGuest;
  37766. }
  37767. public static function getDevNull(): string
  37768. {
  37769. if (self::isWindows()) {
  37770. return 'NUL';
  37771. }
  37772. return '/dev/null';
  37773. }
  37774. }
  37775. <?php declare(strict_types=1);
  37776. namespace Composer\Util;
  37777. use Composer\IO\IOInterface;
  37778. use Composer\Pcre\Preg;
  37779. use Seld\Signal\SignalHandler;
  37780. use Symfony\Component\Process\Exception\ProcessSignaledException;
  37781. use Symfony\Component\Process\Process;
  37782. use Symfony\Component\Process\Exception\RuntimeException;
  37783. use React\Promise\Promise;
  37784. use React\Promise\PromiseInterface;
  37785. class ProcessExecutor
  37786. {
  37787. private const STATUS_QUEUED = 1;
  37788. private const STATUS_STARTED = 2;
  37789. private const STATUS_COMPLETED = 3;
  37790. private const STATUS_FAILED = 4;
  37791. private const STATUS_ABORTED = 5;
  37792. protected static $timeout = 300;
  37793. protected $captureOutput = false;
  37794. protected $errorOutput = '';
  37795. protected $io;
  37796. private $jobs = [];
  37797. private $runningJobs = 0;
  37798. private $maxJobs = 10;
  37799. private $idGen = 0;
  37800. private $allowAsync = false;
  37801. public function __construct(?IOInterface $io = null)
  37802. {
  37803. $this->io = $io;
  37804. }
  37805. public function execute($command, &$output = null, ?string $cwd = null): int
  37806. {
  37807. if (func_num_args() > 1) {
  37808. return $this->doExecute($command, $cwd, false, $output);
  37809. }
  37810. return $this->doExecute($command, $cwd, false);
  37811. }
  37812. public function executeTty($command, ?string $cwd = null): int
  37813. {
  37814. if (Platform::isTty()) {
  37815. return $this->doExecute($command, $cwd, true);
  37816. }
  37817. return $this->doExecute($command, $cwd, false);
  37818. }
  37819. private function doExecute($command, ?string $cwd, bool $tty, &$output = null): int
  37820. {
  37821. $this->outputCommandRun($command, $cwd, false);
  37822. $this->captureOutput = func_num_args() > 3;
  37823. $this->errorOutput = '';
  37824. if (is_string($command)) {
  37825. $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout());
  37826. } else {
  37827. $process = new Process($command, $cwd, null, null, static::getTimeout());
  37828. }
  37829. if (!Platform::isWindows() && $tty) {
  37830. try {
  37831. $process->setTty(true);
  37832. } catch (RuntimeException $e) {
  37833. }
  37834. }
  37835. $callback = is_callable($output) ? $output : function (string $type, string $buffer): void {
  37836. $this->outputHandler($type, $buffer);
  37837. };
  37838. $signalHandler = SignalHandler::create([SignalHandler::SIGINT, SignalHandler::SIGTERM, SignalHandler::SIGHUP], function (string $signal) {
  37839. if ($this->io !== null) {
  37840. $this->io->writeError('Received '.$signal.', aborting when child process is done', true, IOInterface::DEBUG);
  37841. }
  37842. });
  37843. try {
  37844. $process->run($callback);
  37845. if ($this->captureOutput && !is_callable($output)) {
  37846. $output = $process->getOutput();
  37847. }
  37848. $this->errorOutput = $process->getErrorOutput();
  37849. } catch (ProcessSignaledException $e) {
  37850. if ($signalHandler->isTriggered()) {
  37851. $signalHandler->exitWithLastSignal();
  37852. }
  37853. } finally {
  37854. $signalHandler->unregister();
  37855. }
  37856. return $process->getExitCode();
  37857. }
  37858. public function executeAsync($command, ?string $cwd = null): PromiseInterface
  37859. {
  37860. if (!$this->allowAsync) {
  37861. throw new \LogicException('You must use the ProcessExecutor instance which is part of a Composer\Loop instance to be able to run async processes');
  37862. }
  37863. $job = [
  37864. 'id' => $this->idGen++,
  37865. 'status' => self::STATUS_QUEUED,
  37866. 'command' => $command,
  37867. 'cwd' => $cwd,
  37868. ];
  37869. $resolver = static function ($resolve, $reject) use (&$job): void {
  37870. $job['status'] = ProcessExecutor::STATUS_QUEUED;
  37871. $job['resolve'] = $resolve;
  37872. $job['reject'] = $reject;
  37873. };
  37874. $canceler = static function () use (&$job): void {
  37875. if ($job['status'] === ProcessExecutor::STATUS_QUEUED) {
  37876. $job['status'] = ProcessExecutor::STATUS_ABORTED;
  37877. }
  37878. if ($job['status'] !== ProcessExecutor::STATUS_STARTED) {
  37879. return;
  37880. }
  37881. $job['status'] = ProcessExecutor::STATUS_ABORTED;
  37882. try {
  37883. if (defined('SIGINT')) {
  37884. $job['process']->signal(SIGINT);
  37885. }
  37886. } catch (\Exception $e) {
  37887. }
  37888. $job['process']->stop(1);
  37889. throw new \RuntimeException('Aborted process');
  37890. };
  37891. $promise = new Promise($resolver, $canceler);
  37892. $promise = $promise->then(function () use (&$job) {
  37893. if ($job['process']->isSuccessful()) {
  37894. $job['status'] = ProcessExecutor::STATUS_COMPLETED;
  37895. } else {
  37896. $job['status'] = ProcessExecutor::STATUS_FAILED;
  37897. }
  37898. $this->markJobDone();
  37899. return $job['process'];
  37900. }, function ($e) use (&$job): void {
  37901. $job['status'] = ProcessExecutor::STATUS_FAILED;
  37902. $this->markJobDone();
  37903. throw $e;
  37904. });
  37905. $this->jobs[$job['id']] = &$job;
  37906. if ($this->runningJobs < $this->maxJobs) {
  37907. $this->startJob($job['id']);
  37908. }
  37909. return $promise;
  37910. }
  37911. protected function outputHandler(string $type, string $buffer): void
  37912. {
  37913. if ($this->captureOutput) {
  37914. return;
  37915. }
  37916. if (null === $this->io) {
  37917. echo $buffer;
  37918. return;
  37919. }
  37920. if (Process::ERR === $type) {
  37921. $this->io->writeErrorRaw($buffer, false);
  37922. } else {
  37923. $this->io->writeRaw($buffer, false);
  37924. }
  37925. }
  37926. private function startJob(int $id): void
  37927. {
  37928. $job = &$this->jobs[$id];
  37929. if ($job['status'] !== self::STATUS_QUEUED) {
  37930. return;
  37931. }
  37932. $job['status'] = self::STATUS_STARTED;
  37933. $this->runningJobs++;
  37934. $command = $job['command'];
  37935. $cwd = $job['cwd'];
  37936. $this->outputCommandRun($command, $cwd, true);
  37937. try {
  37938. if (is_string($command)) {
  37939. $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout());
  37940. } else {
  37941. $process = new Process($command, $cwd, null, null, static::getTimeout());
  37942. }
  37943. } catch (\Throwable $e) {
  37944. $job['reject']($e);
  37945. return;
  37946. }
  37947. $job['process'] = $process;
  37948. try {
  37949. $process->start();
  37950. } catch (\Throwable $e) {
  37951. $job['reject']($e);
  37952. return;
  37953. }
  37954. }
  37955. public function setMaxJobs(int $maxJobs): void
  37956. {
  37957. $this->maxJobs = $maxJobs;
  37958. }
  37959. public function resetMaxJobs(): void
  37960. {
  37961. $this->maxJobs = 10;
  37962. }
  37963. public function wait($index = null): void
  37964. {
  37965. while (true) {
  37966. if (0 === $this->countActiveJobs($index)) {
  37967. return;
  37968. }
  37969. usleep(1000);
  37970. }
  37971. }
  37972. public function enableAsync(): void
  37973. {
  37974. $this->allowAsync = true;
  37975. }
  37976. public function countActiveJobs($index = null): int
  37977. {
  37978. foreach ($this->jobs as $job) {
  37979. if ($job['status'] === self::STATUS_STARTED) {
  37980. if (!$job['process']->isRunning()) {
  37981. call_user_func($job['resolve'], $job['process']);
  37982. }
  37983. $job['process']->checkTimeout();
  37984. }
  37985. if ($this->runningJobs < $this->maxJobs) {
  37986. if ($job['status'] === self::STATUS_QUEUED) {
  37987. $this->startJob($job['id']);
  37988. }
  37989. }
  37990. }
  37991. if (null !== $index) {
  37992. return $this->jobs[$index]['status'] < self::STATUS_COMPLETED ? 1 : 0;
  37993. }
  37994. $active = 0;
  37995. foreach ($this->jobs as $job) {
  37996. if ($job['status'] < self::STATUS_COMPLETED) {
  37997. $active++;
  37998. } else {
  37999. unset($this->jobs[$job['id']]);
  38000. }
  38001. }
  38002. return $active;
  38003. }
  38004. private function markJobDone(): void
  38005. {
  38006. $this->runningJobs--;
  38007. }
  38008. public function splitLines(?string $output): array
  38009. {
  38010. $output = trim((string) $output);
  38011. return $output === '' ? [] : Preg::split('{\r?\n}', $output);
  38012. }
  38013. public function getErrorOutput(): string
  38014. {
  38015. return $this->errorOutput;
  38016. }
  38017. public static function getTimeout(): int
  38018. {
  38019. return static::$timeout;
  38020. }
  38021. public static function setTimeout(int $timeout): void
  38022. {
  38023. static::$timeout = $timeout;
  38024. }
  38025. public static function escape($argument): string
  38026. {
  38027. return self::escapeArgument($argument);
  38028. }
  38029. private function outputCommandRun($command, ?string $cwd, bool $async): void
  38030. {
  38031. if (null === $this->io || !$this->io->isDebug()) {
  38032. return;
  38033. }
  38034. $commandString = is_string($command) ? $command : implode(' ', array_map(self::class.'::escape', $command));
  38035. $safeCommand = Preg::replaceCallback('{://(?P<user>[^:/\s]+):(?P<password>[^@\s/]+)@}i', static function ($m): string {
  38036. assert(is_string($m['user']));
  38037. if (Preg::isMatch('{^([a-f0-9]{12,}|gh[a-z]_[a-zA-Z0-9_]+)$}', $m['user'])) {
  38038. return '://***:***@';
  38039. }
  38040. if (Preg::isMatch('{^[a-f0-9]{12,}$}', $m['user'])) {
  38041. return '://***:***@';
  38042. }
  38043. return '://'.$m['user'].':***@';
  38044. }, $commandString);
  38045. $safeCommand = Preg::replace("{--password (.*[^\\\\]\') }", '--password \'***\' ', $safeCommand);
  38046. $this->io->writeError('Executing'.($async ? ' async' : '').' command ('.($cwd ?: 'CWD').'): '.$safeCommand);
  38047. }
  38048. private static function escapeArgument($argument): string
  38049. {
  38050. if ('' === ($argument = (string) $argument)) {
  38051. return escapeshellarg($argument);
  38052. }
  38053. if (!Platform::isWindows()) {
  38054. return "'".str_replace("'", "'\\''", $argument)."'";
  38055. }
  38056. $argument = strtr($argument, "\n", ' ');
  38057. $quote = strpbrk($argument, " \t,") !== false;
  38058. $argument = Preg::replace('/(\\\\*)"/', '$1$1\\"', $argument, -1, $dquotes);
  38059. $meta = $dquotes > 0 || Preg::isMatch('/%[^%]+%|![^!]+!/', $argument);
  38060. if (!$meta && !$quote) {
  38061. $quote = strpbrk($argument, '^&|<>()') !== false;
  38062. }
  38063. if ($quote) {
  38064. $argument = '"'.Preg::replace('/(\\\\*)$/', '$1$1', $argument).'"';
  38065. }
  38066. if ($meta) {
  38067. $argument = Preg::replace('/(["^&|<>()%])/', '^$1', $argument);
  38068. $argument = Preg::replace('/(!)/', '^^$1', $argument);
  38069. }
  38070. return $argument;
  38071. }
  38072. }
  38073. <?php declare(strict_types=1);
  38074. namespace Composer\Util;
  38075. use Composer\Config;
  38076. use Composer\Downloader\MaxFileSizeExceededException;
  38077. use Composer\IO\IOInterface;
  38078. use Composer\Downloader\TransportException;
  38079. use Composer\Pcre\Preg;
  38080. use Composer\Util\Http\Response;
  38081. use Composer\Util\Http\ProxyManager;
  38082. class RemoteFilesystem
  38083. {
  38084. private $io;
  38085. private $config;
  38086. private $scheme;
  38087. private $bytesMax;
  38088. private $originUrl;
  38089. private $fileUrl;
  38090. private $fileName;
  38091. private $retry = false;
  38092. private $progress;
  38093. private $lastProgress;
  38094. private $options = [];
  38095. private $disableTls = false;
  38096. private $lastHeaders;
  38097. private $storeAuth = false;
  38098. private $authHelper;
  38099. private $degradedMode = false;
  38100. private $redirects;
  38101. private $maxRedirects = 20;
  38102. private $proxyManager;
  38103. public function __construct(IOInterface $io, Config $config, array $options = [], bool $disableTls = false, ?AuthHelper $authHelper = null)
  38104. {
  38105. $this->io = $io;
  38106. if ($disableTls === false) {
  38107. $this->options = StreamContextFactory::getTlsDefaults($options, $io);
  38108. } else {
  38109. $this->disableTls = true;
  38110. }
  38111. $this->options = array_replace_recursive($this->options, $options);
  38112. $this->config = $config;
  38113. $this->authHelper = $authHelper ?? new AuthHelper($io, $config);
  38114. $this->proxyManager = ProxyManager::getInstance();
  38115. }
  38116. public function copy(string $originUrl, string $fileUrl, string $fileName, bool $progress = true, array $options = [])
  38117. {
  38118. return $this->get($originUrl, $fileUrl, $options, $fileName, $progress);
  38119. }
  38120. public function getContents(string $originUrl, string $fileUrl, bool $progress = true, array $options = [])
  38121. {
  38122. return $this->get($originUrl, $fileUrl, $options, null, $progress);
  38123. }
  38124. public function getOptions()
  38125. {
  38126. return $this->options;
  38127. }
  38128. public function setOptions(array $options)
  38129. {
  38130. $this->options = array_replace_recursive($this->options, $options);
  38131. }
  38132. public function isTlsDisabled()
  38133. {
  38134. return $this->disableTls === true;
  38135. }
  38136. public function getLastHeaders()
  38137. {
  38138. return $this->lastHeaders;
  38139. }
  38140. public static function findStatusCode(array $headers)
  38141. {
  38142. $value = null;
  38143. foreach ($headers as $header) {
  38144. if (Preg::isMatch('{^HTTP/\S+ (\d+)}i', $header, $match)) {
  38145. $value = (int) $match[1];
  38146. }
  38147. }
  38148. return $value;
  38149. }
  38150. public function findStatusMessage(array $headers)
  38151. {
  38152. $value = null;
  38153. foreach ($headers as $header) {
  38154. if (Preg::isMatch('{^HTTP/\S+ \d+}i', $header)) {
  38155. $value = $header;
  38156. }
  38157. }
  38158. return $value;
  38159. }
  38160. protected function get(string $originUrl, string $fileUrl, array $additionalOptions = [], ?string $fileName = null, bool $progress = true)
  38161. {
  38162. $this->scheme = parse_url(strtr($fileUrl, '\\', '/'), PHP_URL_SCHEME);
  38163. $this->bytesMax = 0;
  38164. $this->originUrl = $originUrl;
  38165. $this->fileUrl = $fileUrl;
  38166. $this->fileName = $fileName;
  38167. $this->progress = $progress;
  38168. $this->lastProgress = null;
  38169. $retryAuthFailure = true;
  38170. $this->lastHeaders = [];
  38171. $this->redirects = 1;
  38172. $tempAdditionalOptions = $additionalOptions;
  38173. if (isset($tempAdditionalOptions['retry-auth-failure'])) {
  38174. $retryAuthFailure = (bool) $tempAdditionalOptions['retry-auth-failure'];
  38175. unset($tempAdditionalOptions['retry-auth-failure']);
  38176. }
  38177. $isRedirect = false;
  38178. if (isset($tempAdditionalOptions['redirects'])) {
  38179. $this->redirects = $tempAdditionalOptions['redirects'];
  38180. $isRedirect = true;
  38181. unset($tempAdditionalOptions['redirects']);
  38182. }
  38183. $options = $this->getOptionsForUrl($originUrl, $tempAdditionalOptions);
  38184. unset($tempAdditionalOptions);
  38185. $origFileUrl = $fileUrl;
  38186. if (isset($options['gitlab-token'])) {
  38187. $fileUrl .= (false === strpos($fileUrl, '?') ? '?' : '&') . 'access_token='.$options['gitlab-token'];
  38188. unset($options['gitlab-token']);
  38189. }
  38190. if (isset($options['http'])) {
  38191. $options['http']['ignore_errors'] = true;
  38192. }
  38193. if ($this->degradedMode && strpos($fileUrl, 'http://repo.packagist.org/') === 0) {
  38194. $fileUrl = 'http://' . gethostbyname('repo.packagist.org') . substr($fileUrl, 20);
  38195. $degradedPackagist = true;
  38196. }
  38197. $maxFileSize = null;
  38198. if (isset($options['max_file_size'])) {
  38199. $maxFileSize = $options['max_file_size'];
  38200. unset($options['max_file_size']);
  38201. }
  38202. $ctx = StreamContextFactory::getContext($fileUrl, $options, ['notification' => [$this, 'callbackGet']]);
  38203. $proxy = $this->proxyManager->getProxyForRequest($fileUrl);
  38204. $usingProxy = $proxy->getFormattedUrl(' using proxy (%s)');
  38205. $this->io->writeError((strpos($origFileUrl, 'http') === 0 ? 'Downloading ' : 'Reading ') . Url::sanitize($origFileUrl) . $usingProxy, true, IOInterface::DEBUG);
  38206. unset($origFileUrl, $proxy, $usingProxy);
  38207. if ((!Preg::isMatch('{^http://(repo\.)?packagist\.org/p/}', $fileUrl) || (false === strpos($fileUrl, '$') && false === strpos($fileUrl, '%24'))) && empty($degradedPackagist)) {
  38208. $this->config->prohibitUrlByConfig($fileUrl, $this->io);
  38209. }
  38210. if ($this->progress && !$isRedirect) {
  38211. $this->io->writeError("Downloading (<comment>connecting...</comment>)", false);
  38212. }
  38213. $errorMessage = '';
  38214. $errorCode = 0;
  38215. $result = false;
  38216. set_error_handler(static function ($code, $msg) use (&$errorMessage): bool {
  38217. if ($errorMessage) {
  38218. $errorMessage .= "\n";
  38219. }
  38220. $errorMessage .= Preg::replace('{^file_get_contents\(.*?\): }', '', $msg);
  38221. return true;
  38222. });
  38223. $http_response_header = [];
  38224. try {
  38225. $result = $this->getRemoteContents($originUrl, $fileUrl, $ctx, $http_response_header, $maxFileSize);
  38226. if (!empty($http_response_header[0])) {
  38227. $statusCode = self::findStatusCode($http_response_header);
  38228. if ($statusCode >= 400 && Response::findHeaderValue($http_response_header, 'content-type') === 'application/json') {
  38229. HttpDownloader::outputWarnings($this->io, $originUrl, json_decode($result, true));
  38230. }
  38231. if (in_array($statusCode, [401, 403]) && $retryAuthFailure) {
  38232. $this->promptAuthAndRetry($statusCode, $this->findStatusMessage($http_response_header), $http_response_header);
  38233. }
  38234. }
  38235. $contentLength = !empty($http_response_header[0]) ? Response::findHeaderValue($http_response_header, 'content-length') : null;
  38236. if ($contentLength && Platform::strlen($result) < $contentLength) {
  38237. $e = new TransportException('Content-Length mismatch, received '.Platform::strlen($result).' bytes out of the expected '.$contentLength);
  38238. $e->setHeaders($http_response_header);
  38239. $e->setStatusCode(self::findStatusCode($http_response_header));
  38240. try {
  38241. $e->setResponse($this->decodeResult($result, $http_response_header));
  38242. } catch (\Exception $discarded) {
  38243. $e->setResponse($this->normalizeResult($result));
  38244. }
  38245. $this->io->writeError('Content-Length mismatch, received '.Platform::strlen($result).' out of '.$contentLength.' bytes: (' . base64_encode($result).')', true, IOInterface::DEBUG);
  38246. throw $e;
  38247. }
  38248. } catch (\Exception $e) {
  38249. if ($e instanceof TransportException && !empty($http_response_header[0])) {
  38250. $e->setHeaders($http_response_header);
  38251. $e->setStatusCode(self::findStatusCode($http_response_header));
  38252. }
  38253. if ($e instanceof TransportException && $result !== false) {
  38254. $e->setResponse($this->decodeResult($result, $http_response_header));
  38255. }
  38256. $result = false;
  38257. }
  38258. if ($errorMessage && !filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN)) {
  38259. $errorMessage = 'allow_url_fopen must be enabled in php.ini ('.$errorMessage.')';
  38260. }
  38261. restore_error_handler();
  38262. if (isset($e) && !$this->retry) {
  38263. if (!$this->degradedMode && false !== strpos($e->getMessage(), 'Operation timed out')) {
  38264. $this->degradedMode = true;
  38265. $this->io->writeError('');
  38266. $this->io->writeError([
  38267. '<error>'.$e->getMessage().'</error>',
  38268. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  38269. ]);
  38270. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  38271. }
  38272. throw $e;
  38273. }
  38274. $statusCode = null;
  38275. $contentType = null;
  38276. $locationHeader = null;
  38277. if (!empty($http_response_header[0])) {
  38278. $statusCode = self::findStatusCode($http_response_header);
  38279. $contentType = Response::findHeaderValue($http_response_header, 'content-type');
  38280. $locationHeader = Response::findHeaderValue($http_response_header, 'location');
  38281. }
  38282. if ($originUrl === 'bitbucket.org'
  38283. && !$this->authHelper->isPublicBitBucketDownload($fileUrl)
  38284. && substr($fileUrl, -4) === '.zip'
  38285. && (!$locationHeader || substr(parse_url($locationHeader, PHP_URL_PATH), -4) !== '.zip')
  38286. && $contentType && Preg::isMatch('{^text/html\b}i', $contentType)
  38287. ) {
  38288. $result = false;
  38289. if ($retryAuthFailure) {
  38290. $this->promptAuthAndRetry(401);
  38291. }
  38292. }
  38293. if ($statusCode === 404
  38294. && in_array($originUrl, $this->config->get('gitlab-domains'), true)
  38295. && false !== strpos($fileUrl, 'archive.zip')
  38296. ) {
  38297. $result = false;
  38298. if ($retryAuthFailure) {
  38299. $this->promptAuthAndRetry(401);
  38300. }
  38301. }
  38302. $hasFollowedRedirect = false;
  38303. if ($statusCode >= 300 && $statusCode <= 399 && $statusCode !== 304 && $this->redirects < $this->maxRedirects) {
  38304. $hasFollowedRedirect = true;
  38305. $result = $this->handleRedirect($http_response_header, $additionalOptions, $result);
  38306. }
  38307. if ($statusCode && $statusCode >= 400 && $statusCode <= 599) {
  38308. if (!$this->retry) {
  38309. if ($this->progress && !$isRedirect) {
  38310. $this->io->overwriteError("Downloading (<error>failed</error>)", false);
  38311. }
  38312. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded ('.$http_response_header[0].')', $statusCode);
  38313. $e->setHeaders($http_response_header);
  38314. $e->setResponse($this->decodeResult($result, $http_response_header));
  38315. $e->setStatusCode($statusCode);
  38316. throw $e;
  38317. }
  38318. $result = false;
  38319. }
  38320. if ($this->progress && !$this->retry && !$isRedirect) {
  38321. $this->io->overwriteError("Downloading (".($result === false ? '<error>failed</error>' : '<comment>100%</comment>').")", false);
  38322. }
  38323. if ($result && extension_loaded('zlib') && strpos($fileUrl, 'http') === 0 && !$hasFollowedRedirect) {
  38324. try {
  38325. $result = $this->decodeResult($result, $http_response_header);
  38326. } catch (\Exception $e) {
  38327. if ($this->degradedMode) {
  38328. throw $e;
  38329. }
  38330. $this->degradedMode = true;
  38331. $this->io->writeError([
  38332. '',
  38333. '<error>Failed to decode response: '.$e->getMessage().'</error>',
  38334. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  38335. ]);
  38336. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  38337. }
  38338. }
  38339. if (false !== $result && null !== $fileName && !$isRedirect) {
  38340. if ('' === $result) {
  38341. throw new TransportException('"'.$this->fileUrl.'" appears broken, and returned an empty 200 response');
  38342. }
  38343. $errorMessage = '';
  38344. set_error_handler(static function ($code, $msg) use (&$errorMessage): bool {
  38345. if ($errorMessage) {
  38346. $errorMessage .= "\n";
  38347. }
  38348. $errorMessage .= Preg::replace('{^file_put_contents\(.*?\): }', '', $msg);
  38349. return true;
  38350. });
  38351. $result = (bool) file_put_contents($fileName, $result);
  38352. restore_error_handler();
  38353. if (false === $result) {
  38354. throw new TransportException('The "'.$this->fileUrl.'" file could not be written to '.$fileName.': '.$errorMessage);
  38355. }
  38356. }
  38357. if ($this->retry) {
  38358. $this->retry = false;
  38359. $result = $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  38360. if ($this->storeAuth) {
  38361. $this->authHelper->storeAuth($this->originUrl, $this->storeAuth);
  38362. $this->storeAuth = false;
  38363. }
  38364. return $result;
  38365. }
  38366. if (false === $result) {
  38367. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded: '.$errorMessage, $errorCode);
  38368. if (!empty($http_response_header[0])) {
  38369. $e->setHeaders($http_response_header);
  38370. }
  38371. if (!$this->degradedMode && false !== strpos($e->getMessage(), 'Operation timed out')) {
  38372. $this->degradedMode = true;
  38373. $this->io->writeError('');
  38374. $this->io->writeError([
  38375. '<error>'.$e->getMessage().'</error>',
  38376. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  38377. ]);
  38378. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  38379. }
  38380. throw $e;
  38381. }
  38382. if (!empty($http_response_header[0])) {
  38383. $this->lastHeaders = $http_response_header;
  38384. }
  38385. return $result;
  38386. }
  38387. protected function getRemoteContents(string $originUrl, string $fileUrl, $context, ?array &$responseHeaders = null, ?int $maxFileSize = null)
  38388. {
  38389. $result = false;
  38390. try {
  38391. $e = null;
  38392. if ($maxFileSize !== null) {
  38393. $result = file_get_contents($fileUrl, false, $context, 0, $maxFileSize);
  38394. } else {
  38395. $result = file_get_contents($fileUrl, false, $context);
  38396. }
  38397. } catch (\Throwable $e) {
  38398. }
  38399. if ($result !== false && $maxFileSize !== null && Platform::strlen($result) >= $maxFileSize) {
  38400. throw new MaxFileSizeExceededException('Maximum allowed download size reached. Downloaded ' . Platform::strlen($result) . ' of allowed ' . $maxFileSize . ' bytes');
  38401. }
  38402. $responseHeaders = $http_response_header ?? [];
  38403. if (null !== $e) {
  38404. throw $e;
  38405. }
  38406. return $result;
  38407. }
  38408. protected function callbackGet(int $notificationCode, int $severity, ?string $message, int $messageCode, int $bytesTransferred, int $bytesMax)
  38409. {
  38410. switch ($notificationCode) {
  38411. case STREAM_NOTIFY_FAILURE:
  38412. if (400 === $messageCode) {
  38413. throw new TransportException("The '" . $this->fileUrl . "' URL could not be accessed: " . $message, $messageCode);
  38414. }
  38415. break;
  38416. case STREAM_NOTIFY_FILE_SIZE_IS:
  38417. $this->bytesMax = $bytesMax;
  38418. break;
  38419. case STREAM_NOTIFY_PROGRESS:
  38420. if ($this->bytesMax > 0 && $this->progress) {
  38421. $progression = min(100, (int) round($bytesTransferred / $this->bytesMax * 100));
  38422. if ((0 === $progression % 5) && 100 !== $progression && $progression !== $this->lastProgress) {
  38423. $this->lastProgress = $progression;
  38424. $this->io->overwriteError("Downloading (<comment>$progression%</comment>)", false);
  38425. }
  38426. }
  38427. break;
  38428. default:
  38429. break;
  38430. }
  38431. }
  38432. protected function promptAuthAndRetry($httpStatus, ?string $reason = null, array $headers = [])
  38433. {
  38434. $result = $this->authHelper->promptAuthIfNeeded($this->fileUrl, $this->originUrl, $httpStatus, $reason, $headers, 1 );
  38435. $this->storeAuth = $result['storeAuth'];
  38436. $this->retry = $result['retry'];
  38437. if ($this->retry) {
  38438. throw new TransportException('RETRY');
  38439. }
  38440. }
  38441. protected function getOptionsForUrl(string $originUrl, array $additionalOptions)
  38442. {
  38443. $tlsOptions = [];
  38444. $headers = [];
  38445. if (extension_loaded('zlib')) {
  38446. $headers[] = 'Accept-Encoding: gzip';
  38447. }
  38448. $options = array_replace_recursive($this->options, $tlsOptions, $additionalOptions);
  38449. if (!$this->degradedMode) {
  38450. $options['http']['protocol_version'] = 1.1;
  38451. $headers[] = 'Connection: close';
  38452. }
  38453. $headers = $this->authHelper->addAuthenticationHeader($headers, $originUrl, $this->fileUrl);
  38454. $options['http']['follow_location'] = 0;
  38455. if (isset($options['http']['header']) && !is_array($options['http']['header'])) {
  38456. $options['http']['header'] = explode("\r\n", trim($options['http']['header'], "\r\n"));
  38457. }
  38458. foreach ($headers as $header) {
  38459. $options['http']['header'][] = $header;
  38460. }
  38461. return $options;
  38462. }
  38463. private function handleRedirect(array $http_response_header, array $additionalOptions, $result)
  38464. {
  38465. if ($locationHeader = Response::findHeaderValue($http_response_header, 'location')) {
  38466. if (parse_url($locationHeader, PHP_URL_SCHEME)) {
  38467. $targetUrl = $locationHeader;
  38468. } elseif (parse_url($locationHeader, PHP_URL_HOST)) {
  38469. $targetUrl = $this->scheme.':'.$locationHeader;
  38470. } elseif ('/' === $locationHeader[0]) {
  38471. $urlHost = parse_url($this->fileUrl, PHP_URL_HOST);
  38472. $targetUrl = Preg::replace('{^(.+(?://|@)'.preg_quote($urlHost).'(?::\d+)?)(?:[/\?].*)?$}', '\1'.$locationHeader, $this->fileUrl);
  38473. } else {
  38474. $targetUrl = Preg::replace('{^(.+/)[^/?]*(?:\?.*)?$}', '\1'.$locationHeader, $this->fileUrl);
  38475. }
  38476. }
  38477. if (!empty($targetUrl)) {
  38478. $this->redirects++;
  38479. $this->io->writeError('', true, IOInterface::DEBUG);
  38480. $this->io->writeError(sprintf('Following redirect (%u) %s', $this->redirects, Url::sanitize($targetUrl)), true, IOInterface::DEBUG);
  38481. $additionalOptions['redirects'] = $this->redirects;
  38482. return $this->get(parse_url($targetUrl, PHP_URL_HOST), $targetUrl, $additionalOptions, $this->fileName, $this->progress);
  38483. }
  38484. if (!$this->retry) {
  38485. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded, got redirect without Location ('.$http_response_header[0].')');
  38486. $e->setHeaders($http_response_header);
  38487. $e->setResponse($this->decodeResult($result, $http_response_header));
  38488. throw $e;
  38489. }
  38490. return false;
  38491. }
  38492. private function decodeResult($result, array $http_response_header): ?string
  38493. {
  38494. if ($result && extension_loaded('zlib')) {
  38495. $contentEncoding = Response::findHeaderValue($http_response_header, 'content-encoding');
  38496. $decode = $contentEncoding && 'gzip' === strtolower($contentEncoding);
  38497. if ($decode) {
  38498. $result = zlib_decode($result);
  38499. if ($result === false) {
  38500. throw new TransportException('Failed to decode zlib stream');
  38501. }
  38502. }
  38503. }
  38504. return $this->normalizeResult($result);
  38505. }
  38506. private function normalizeResult($result): ?string
  38507. {
  38508. if ($result === false) {
  38509. return null;
  38510. }
  38511. return $result;
  38512. }
  38513. }
  38514. <?php declare(strict_types=1);
  38515. namespace Composer\Util;
  38516. class Silencer
  38517. {
  38518. private static $stack = [];
  38519. public static function suppress(?int $mask = null): int
  38520. {
  38521. if (!isset($mask)) {
  38522. $mask = E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_DEPRECATED | E_USER_DEPRECATED | E_STRICT;
  38523. }
  38524. $old = error_reporting();
  38525. self::$stack[] = $old;
  38526. error_reporting($old & ~$mask);
  38527. return $old;
  38528. }
  38529. public static function restore(): void
  38530. {
  38531. if (!empty(self::$stack)) {
  38532. error_reporting(array_pop(self::$stack));
  38533. }
  38534. }
  38535. public static function call(callable $callable, ...$parameters)
  38536. {
  38537. try {
  38538. self::suppress();
  38539. $result = $callable(...$parameters);
  38540. self::restore();
  38541. return $result;
  38542. } catch (\Exception $e) {
  38543. self::restore();
  38544. throw $e;
  38545. }
  38546. }
  38547. }
  38548. <?php declare(strict_types=1);
  38549. namespace Composer\Util;
  38550. use Composer\Composer;
  38551. use Composer\CaBundle\CaBundle;
  38552. use Composer\Downloader\TransportException;
  38553. use Composer\Repository\PlatformRepository;
  38554. use Composer\Util\Http\ProxyManager;
  38555. use Psr\Log\LoggerInterface;
  38556. final class StreamContextFactory
  38557. {
  38558. public static function getContext(string $url, array $defaultOptions = [], array $defaultParams = [])
  38559. {
  38560. $options = ['http' => [
  38561. 'follow_location' => 1,
  38562. 'max_redirects' => 20,
  38563. ]];
  38564. $options = array_replace_recursive($options, self::initOptions($url, $defaultOptions));
  38565. unset($defaultOptions['http']['header']);
  38566. $options = array_replace_recursive($options, $defaultOptions);
  38567. if (isset($options['http']['header'])) {
  38568. $options['http']['header'] = self::fixHttpHeaderField($options['http']['header']);
  38569. }
  38570. return stream_context_create($options, $defaultParams);
  38571. }
  38572. public static function initOptions(string $url, array $options, bool $forCurl = false): array
  38573. {
  38574. if (!isset($options['http']['header'])) {
  38575. $options['http']['header'] = [];
  38576. }
  38577. if (is_string($options['http']['header'])) {
  38578. $options['http']['header'] = explode("\r\n", $options['http']['header']);
  38579. }
  38580. if (!$forCurl) {
  38581. $proxy = ProxyManager::getInstance()->getProxyForRequest($url);
  38582. if ($proxyOptions = $proxy->getContextOptions()) {
  38583. $isHttpsRequest = 0 === strpos($url, 'https://');
  38584. if ($proxy->isSecure()) {
  38585. if (!extension_loaded('openssl')) {
  38586. throw new TransportException('You must enable the openssl extension to use a secure proxy.');
  38587. }
  38588. if ($isHttpsRequest) {
  38589. throw new TransportException('You must enable the curl extension to make https requests through a secure proxy.');
  38590. }
  38591. } elseif ($isHttpsRequest && !extension_loaded('openssl')) {
  38592. throw new TransportException('You must enable the openssl extension to make https requests through a proxy.');
  38593. }
  38594. if (isset($proxyOptions['http']['header'])) {
  38595. $options['http']['header'][] = $proxyOptions['http']['header'];
  38596. unset($proxyOptions['http']['header']);
  38597. }
  38598. $options = array_replace_recursive($options, $proxyOptions);
  38599. }
  38600. }
  38601. if (defined('HHVM_VERSION')) {
  38602. $phpVersion = 'HHVM ' . HHVM_VERSION;
  38603. } else {
  38604. $phpVersion = 'PHP ' . PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
  38605. }
  38606. if ($forCurl) {
  38607. $curl = curl_version();
  38608. $httpVersion = 'cURL '.$curl['version'];
  38609. } else {
  38610. $httpVersion = 'streams';
  38611. }
  38612. if (!isset($options['http']['header']) || false === stripos(implode('', $options['http']['header']), 'user-agent')) {
  38613. $platformPhpVersion = PlatformRepository::getPlatformPhpVersion();
  38614. $options['http']['header'][] = sprintf(
  38615. 'User-Agent: Composer/%s (%s; %s; %s; %s%s%s)',
  38616. Composer::getVersion(),
  38617. function_exists('php_uname') ? php_uname('s') : 'Unknown',
  38618. function_exists('php_uname') ? php_uname('r') : 'Unknown',
  38619. $phpVersion,
  38620. $httpVersion,
  38621. $platformPhpVersion ? '; Platform-PHP '.$platformPhpVersion : '',
  38622. Platform::getEnv('CI') ? '; CI' : ''
  38623. );
  38624. }
  38625. return $options;
  38626. }
  38627. public static function getTlsDefaults(array $options, ?LoggerInterface $logger = null): array
  38628. {
  38629. $ciphers = implode(':', [
  38630. 'ECDHE-RSA-AES128-GCM-SHA256',
  38631. 'ECDHE-ECDSA-AES128-GCM-SHA256',
  38632. 'ECDHE-RSA-AES256-GCM-SHA384',
  38633. 'ECDHE-ECDSA-AES256-GCM-SHA384',
  38634. 'DHE-RSA-AES128-GCM-SHA256',
  38635. 'DHE-DSS-AES128-GCM-SHA256',
  38636. 'kEDH+AESGCM',
  38637. 'ECDHE-RSA-AES128-SHA256',
  38638. 'ECDHE-ECDSA-AES128-SHA256',
  38639. 'ECDHE-RSA-AES128-SHA',
  38640. 'ECDHE-ECDSA-AES128-SHA',
  38641. 'ECDHE-RSA-AES256-SHA384',
  38642. 'ECDHE-ECDSA-AES256-SHA384',
  38643. 'ECDHE-RSA-AES256-SHA',
  38644. 'ECDHE-ECDSA-AES256-SHA',
  38645. 'DHE-RSA-AES128-SHA256',
  38646. 'DHE-RSA-AES128-SHA',
  38647. 'DHE-DSS-AES128-SHA256',
  38648. 'DHE-RSA-AES256-SHA256',
  38649. 'DHE-DSS-AES256-SHA',
  38650. 'DHE-RSA-AES256-SHA',
  38651. 'AES128-GCM-SHA256',
  38652. 'AES256-GCM-SHA384',
  38653. 'AES128-SHA256',
  38654. 'AES256-SHA256',
  38655. 'AES128-SHA',
  38656. 'AES256-SHA',
  38657. 'AES',
  38658. 'CAMELLIA',
  38659. 'DES-CBC3-SHA',
  38660. '!aNULL',
  38661. '!eNULL',
  38662. '!EXPORT',
  38663. '!DES',
  38664. '!RC4',
  38665. '!MD5',
  38666. '!PSK',
  38667. '!aECDH',
  38668. '!EDH-DSS-DES-CBC3-SHA',
  38669. '!EDH-RSA-DES-CBC3-SHA',
  38670. '!KRB5-DES-CBC3-SHA',
  38671. ]);
  38672. $defaults = [
  38673. 'ssl' => [
  38674. 'ciphers' => $ciphers,
  38675. 'verify_peer' => true,
  38676. 'verify_depth' => 7,
  38677. 'SNI_enabled' => true,
  38678. 'capture_peer_cert' => true,
  38679. ],
  38680. ];
  38681. if (isset($options['ssl'])) {
  38682. $defaults['ssl'] = array_replace_recursive($defaults['ssl'], $options['ssl']);
  38683. }
  38684. if (!isset($defaults['ssl']['cafile']) && !isset($defaults['ssl']['capath'])) {
  38685. $result = CaBundle::getSystemCaRootBundlePath($logger);
  38686. if (is_dir($result)) {
  38687. $defaults['ssl']['capath'] = $result;
  38688. } else {
  38689. $defaults['ssl']['cafile'] = $result;
  38690. }
  38691. }
  38692. if (isset($defaults['ssl']['cafile']) && (!Filesystem::isReadable($defaults['ssl']['cafile']) || !CaBundle::validateCaFile($defaults['ssl']['cafile'], $logger))) {
  38693. throw new TransportException('The configured cafile was not valid or could not be read.');
  38694. }
  38695. if (isset($defaults['ssl']['capath']) && (!is_dir($defaults['ssl']['capath']) || !Filesystem::isReadable($defaults['ssl']['capath']))) {
  38696. throw new TransportException('The configured capath was not valid or could not be read.');
  38697. }
  38698. $defaults['ssl']['disable_compression'] = true;
  38699. return $defaults;
  38700. }
  38701. private static function fixHttpHeaderField($header): array
  38702. {
  38703. if (!is_array($header)) {
  38704. $header = explode("\r\n", $header);
  38705. }
  38706. uasort($header, static function ($el): int {
  38707. return stripos($el, 'content-type') === 0 ? 1 : -1;
  38708. });
  38709. return $header;
  38710. }
  38711. }
  38712. <?php declare(strict_types=1);
  38713. namespace Composer\Util;
  38714. use Composer\Config;
  38715. use Composer\IO\IOInterface;
  38716. use Composer\Pcre\Preg;
  38717. class Svn
  38718. {
  38719. private const MAX_QTY_AUTH_TRIES = 5;
  38720. protected $credentials;
  38721. protected $hasAuth;
  38722. protected $io;
  38723. protected $url;
  38724. protected $cacheCredentials = true;
  38725. protected $process;
  38726. protected $qtyAuthTries = 0;
  38727. protected $config;
  38728. private static $version;
  38729. public function __construct(string $url, IOInterface $io, Config $config, ?ProcessExecutor $process = null)
  38730. {
  38731. $this->url = $url;
  38732. $this->io = $io;
  38733. $this->config = $config;
  38734. $this->process = $process ?: new ProcessExecutor($io);
  38735. }
  38736. public static function cleanEnv(): void
  38737. {
  38738. Platform::clearEnv('DYLD_LIBRARY_PATH');
  38739. }
  38740. public function execute(string $command, string $url, ?string $cwd = null, ?string $path = null, bool $verbose = false): string
  38741. {
  38742. $this->config->prohibitUrlByConfig($url, $this->io);
  38743. return $this->executeWithAuthRetry($command, $cwd, $url, $path, $verbose);
  38744. }
  38745. public function executeLocal(string $command, string $path, ?string $cwd = null, bool $verbose = false): string
  38746. {
  38747. return $this->executeWithAuthRetry($command, $cwd, '', $path, $verbose);
  38748. }
  38749. private function executeWithAuthRetry(string $svnCommand, ?string $cwd, string $url, ?string $path, bool $verbose): ?string
  38750. {
  38751. $command = $this->getCommand($svnCommand, $url, $path);
  38752. $output = null;
  38753. $io = $this->io;
  38754. $handler = static function ($type, $buffer) use (&$output, $io, $verbose) {
  38755. if ($type !== 'out') {
  38756. return null;
  38757. }
  38758. if (strpos($buffer, 'Redirecting to URL ') === 0) {
  38759. return null;
  38760. }
  38761. $output .= $buffer;
  38762. if ($verbose) {
  38763. $io->writeError($buffer, false);
  38764. }
  38765. };
  38766. $status = $this->process->execute($command, $handler, $cwd);
  38767. if (0 === $status) {
  38768. return $output;
  38769. }
  38770. $errorOutput = $this->process->getErrorOutput();
  38771. $fullOutput = trim(implode("\n", [$output, $errorOutput]));
  38772. if (false === stripos($fullOutput, 'Could not authenticate to server:')
  38773. && false === stripos($fullOutput, 'authorization failed')
  38774. && false === stripos($fullOutput, 'svn: E170001:')
  38775. && false === stripos($fullOutput, 'svn: E215004:')) {
  38776. throw new \RuntimeException($fullOutput);
  38777. }
  38778. if (!$this->hasAuth()) {
  38779. $this->doAuthDance();
  38780. }
  38781. if ($this->qtyAuthTries++ < self::MAX_QTY_AUTH_TRIES) {
  38782. return $this->executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose);
  38783. }
  38784. throw new \RuntimeException(
  38785. 'wrong credentials provided ('.$fullOutput.')'
  38786. );
  38787. }
  38788. public function setCacheCredentials(bool $cacheCredentials): void
  38789. {
  38790. $this->cacheCredentials = $cacheCredentials;
  38791. }
  38792. protected function doAuthDance(): Svn
  38793. {
  38794. if (!$this->io->isInteractive()) {
  38795. throw new \RuntimeException(
  38796. 'can not ask for authentication in non interactive mode'
  38797. );
  38798. }
  38799. $this->io->writeError("The Subversion server ({$this->url}) requested credentials:");
  38800. $this->hasAuth = true;
  38801. $this->credentials = [
  38802. 'username' => (string) $this->io->ask("Username: ", ''),
  38803. 'password' => (string) $this->io->askAndHideAnswer("Password: "),
  38804. ];
  38805. $this->cacheCredentials = $this->io->askConfirmation("Should Subversion cache these credentials? (yes/no) ");
  38806. return $this;
  38807. }
  38808. protected function getCommand(string $cmd, string $url, ?string $path = null): string
  38809. {
  38810. $cmd = sprintf(
  38811. '%s %s%s -- %s',
  38812. $cmd,
  38813. '--non-interactive ',
  38814. $this->getCredentialString(),
  38815. ProcessExecutor::escape($url)
  38816. );
  38817. if ($path) {
  38818. $cmd .= ' ' . ProcessExecutor::escape($path);
  38819. }
  38820. return $cmd;
  38821. }
  38822. protected function getCredentialString(): string
  38823. {
  38824. if (!$this->hasAuth()) {
  38825. return '';
  38826. }
  38827. return sprintf(
  38828. ' %s--username %s --password %s ',
  38829. $this->getAuthCache(),
  38830. ProcessExecutor::escape($this->getUsername()),
  38831. ProcessExecutor::escape($this->getPassword())
  38832. );
  38833. }
  38834. protected function getPassword(): string
  38835. {
  38836. if ($this->credentials === null) {
  38837. throw new \LogicException("No svn auth detected.");
  38838. }
  38839. return $this->credentials['password'];
  38840. }
  38841. protected function getUsername(): string
  38842. {
  38843. if ($this->credentials === null) {
  38844. throw new \LogicException("No svn auth detected.");
  38845. }
  38846. return $this->credentials['username'];
  38847. }
  38848. protected function hasAuth(): bool
  38849. {
  38850. if (null !== $this->hasAuth) {
  38851. return $this->hasAuth;
  38852. }
  38853. if (false === $this->createAuthFromConfig()) {
  38854. $this->createAuthFromUrl();
  38855. }
  38856. return (bool) $this->hasAuth;
  38857. }
  38858. protected function getAuthCache(): string
  38859. {
  38860. return $this->cacheCredentials ? '' : '--no-auth-cache ';
  38861. }
  38862. private function createAuthFromConfig(): bool
  38863. {
  38864. if (!$this->config->has('http-basic')) {
  38865. return $this->hasAuth = false;
  38866. }
  38867. $authConfig = $this->config->get('http-basic');
  38868. $host = parse_url($this->url, PHP_URL_HOST);
  38869. if (isset($authConfig[$host])) {
  38870. $this->credentials = [
  38871. 'username' => $authConfig[$host]['username'],
  38872. 'password' => $authConfig[$host]['password'],
  38873. ];
  38874. return $this->hasAuth = true;
  38875. }
  38876. return $this->hasAuth = false;
  38877. }
  38878. private function createAuthFromUrl(): bool
  38879. {
  38880. $uri = parse_url($this->url);
  38881. if (empty($uri['user'])) {
  38882. return $this->hasAuth = false;
  38883. }
  38884. $this->credentials = [
  38885. 'username' => $uri['user'],
  38886. 'password' => !empty($uri['pass']) ? $uri['pass'] : '',
  38887. ];
  38888. return $this->hasAuth = true;
  38889. }
  38890. public function binaryVersion(): ?string
  38891. {
  38892. if (!self::$version) {
  38893. if (0 === $this->process->execute('svn --version', $output)) {
  38894. if (Preg::isMatch('{(\d+(?:\.\d+)+)}', $output, $match)) {
  38895. self::$version = $match[1];
  38896. }
  38897. }
  38898. }
  38899. return self::$version;
  38900. }
  38901. }
  38902. <?php declare(strict_types=1);
  38903. namespace Composer\Util;
  38904. use Composer\Downloader\DownloaderInterface;
  38905. use Composer\Downloader\DownloadManager;
  38906. use Composer\Package\PackageInterface;
  38907. use React\Promise\PromiseInterface;
  38908. class SyncHelper
  38909. {
  38910. public static function downloadAndInstallPackageSync(Loop $loop, $downloader, string $path, PackageInterface $package, ?PackageInterface $prevPackage = null): void
  38911. {
  38912. assert($downloader instanceof DownloaderInterface || $downloader instanceof DownloadManager);
  38913. $type = $prevPackage !== null ? 'update' : 'install';
  38914. try {
  38915. self::await($loop, $downloader->download($package, $path, $prevPackage));
  38916. self::await($loop, $downloader->prepare($type, $package, $path, $prevPackage));
  38917. if ($type === 'update' && $prevPackage !== null) {
  38918. self::await($loop, $downloader->update($package, $prevPackage, $path));
  38919. } else {
  38920. self::await($loop, $downloader->install($package, $path));
  38921. }
  38922. } catch (\Exception $e) {
  38923. self::await($loop, $downloader->cleanup($type, $package, $path, $prevPackage));
  38924. throw $e;
  38925. }
  38926. self::await($loop, $downloader->cleanup($type, $package, $path, $prevPackage));
  38927. }
  38928. public static function await(Loop $loop, ?PromiseInterface $promise = null): void
  38929. {
  38930. if ($promise !== null) {
  38931. $loop->wait([$promise]);
  38932. }
  38933. }
  38934. }
  38935. <?php declare(strict_types=1);
  38936. namespace Composer\Util;
  38937. class Tar
  38938. {
  38939. public static function getComposerJson(string $pathToArchive): ?string
  38940. {
  38941. $phar = new \PharData($pathToArchive);
  38942. if (!$phar->valid()) {
  38943. return null;
  38944. }
  38945. return self::extractComposerJsonFromFolder($phar);
  38946. }
  38947. private static function extractComposerJsonFromFolder(\PharData $phar): string
  38948. {
  38949. if (isset($phar['composer.json'])) {
  38950. return $phar['composer.json']->getContent();
  38951. }
  38952. $topLevelPaths = [];
  38953. foreach ($phar as $folderFile) {
  38954. $name = $folderFile->getBasename();
  38955. if ($folderFile->isDir()) {
  38956. $topLevelPaths[$name] = true;
  38957. if (\count($topLevelPaths) > 1) {
  38958. 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)));
  38959. }
  38960. }
  38961. }
  38962. $composerJsonPath = key($topLevelPaths).'/composer.json';
  38963. if ($topLevelPaths && isset($phar[$composerJsonPath])) {
  38964. return $phar[$composerJsonPath]->getContent();
  38965. }
  38966. throw new \RuntimeException('No composer.json found either at the top level or within the topmost directory');
  38967. }
  38968. }
  38969. <?php declare(strict_types=1);
  38970. namespace Composer\Util;
  38971. use Composer\CaBundle\CaBundle;
  38972. use Composer\Pcre\Preg;
  38973. final class TlsHelper
  38974. {
  38975. public static function checkCertificateHost($certificate, string $hostname, ?string &$cn = null): bool
  38976. {
  38977. $names = self::getCertificateNames($certificate);
  38978. if (empty($names)) {
  38979. return false;
  38980. }
  38981. $combinedNames = array_merge($names['san'], [$names['cn']]);
  38982. $hostname = strtolower($hostname);
  38983. foreach ($combinedNames as $certName) {
  38984. $matcher = self::certNameMatcher($certName);
  38985. if ($matcher && $matcher($hostname)) {
  38986. $cn = $names['cn'];
  38987. return true;
  38988. }
  38989. }
  38990. return false;
  38991. }
  38992. public static function getCertificateNames($certificate): ?array
  38993. {
  38994. if (is_array($certificate)) {
  38995. $info = $certificate;
  38996. } elseif (CaBundle::isOpensslParseSafe()) {
  38997. $info = openssl_x509_parse($certificate, false);
  38998. }
  38999. if (!isset($info['subject']['commonName'])) {
  39000. return null;
  39001. }
  39002. $commonName = strtolower($info['subject']['commonName']);
  39003. $subjectAltNames = [];
  39004. if (isset($info['extensions']['subjectAltName'])) {
  39005. $subjectAltNames = Preg::split('{\s*,\s*}', $info['extensions']['subjectAltName']);
  39006. $subjectAltNames = array_filter(array_map(static function ($name): ?string {
  39007. if (0 === strpos($name, 'DNS:')) {
  39008. return strtolower(ltrim(substr($name, 4)));
  39009. }
  39010. return null;
  39011. }, $subjectAltNames));
  39012. $subjectAltNames = array_values($subjectAltNames);
  39013. }
  39014. return [
  39015. 'cn' => $commonName,
  39016. 'san' => $subjectAltNames,
  39017. ];
  39018. }
  39019. public static function getCertificateFingerprint(string $certificate): string
  39020. {
  39021. $pubkey = openssl_get_publickey($certificate);
  39022. if ($pubkey === false) {
  39023. throw new \RuntimeException('Failed to retrieve the public key from certificate');
  39024. }
  39025. $pubkeydetails = openssl_pkey_get_details($pubkey);
  39026. $pubkeypem = $pubkeydetails['key'];
  39027. $start = '-----BEGIN PUBLIC KEY-----';
  39028. $end = '-----END PUBLIC KEY-----';
  39029. $pemtrim = substr($pubkeypem, strpos($pubkeypem, $start) + strlen($start), (strlen($pubkeypem) - strpos($pubkeypem, $end)) * (-1));
  39030. $der = base64_decode($pemtrim);
  39031. return sha1($der);
  39032. }
  39033. public static function isOpensslParseSafe(): bool
  39034. {
  39035. return CaBundle::isOpensslParseSafe();
  39036. }
  39037. private static function certNameMatcher(string $certName): ?callable
  39038. {
  39039. $wildcards = substr_count($certName, '*');
  39040. if (0 === $wildcards) {
  39041. return static function ($hostname) use ($certName): bool {
  39042. return $hostname === $certName;
  39043. };
  39044. }
  39045. if (1 === $wildcards) {
  39046. $components = explode('.', $certName);
  39047. if (3 > count($components)) {
  39048. return null;
  39049. }
  39050. $firstComponent = $components[0];
  39051. if ('*' !== $firstComponent[strlen($firstComponent) - 1]) {
  39052. return null;
  39053. }
  39054. $wildcardRegex = preg_quote($certName);
  39055. $wildcardRegex = str_replace('\\*', '[a-z0-9-]+', $wildcardRegex);
  39056. $wildcardRegex = "{^{$wildcardRegex}$}";
  39057. return static function ($hostname) use ($wildcardRegex): bool {
  39058. return Preg::isMatch($wildcardRegex, $hostname);
  39059. };
  39060. }
  39061. return null;
  39062. }
  39063. }
  39064. <?php declare(strict_types=1);
  39065. namespace Composer\Util;
  39066. use Composer\Config;
  39067. use Composer\Pcre\Preg;
  39068. class Url
  39069. {
  39070. public static function updateDistReference(Config $config, string $url, string $ref): string
  39071. {
  39072. $host = parse_url($url, PHP_URL_HOST);
  39073. if ($host === 'api.github.com' || $host === 'github.com' || $host === 'www.github.com') {
  39074. if (Preg::isMatch('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/(zip|tar)ball/(.+)$}i', $url, $match)) {
  39075. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  39076. } elseif (Preg::isMatch('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/archive/.+\.(zip|tar)(?:\.gz)?$}i', $url, $match)) {
  39077. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  39078. } elseif (Preg::isMatch('{^https?://api\.github\.com/repos/([^/]+)/([^/]+)/(zip|tar)ball(?:/.+)?$}i', $url, $match)) {
  39079. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  39080. }
  39081. } elseif ($host === 'bitbucket.org' || $host === 'www.bitbucket.org') {
  39082. if (Preg::isMatch('{^https?://(?:www\.)?bitbucket\.org/([^/]+)/([^/]+)/get/(.+)\.(zip|tar\.gz|tar\.bz2)$}i', $url, $match)) {
  39083. $url = 'https://bitbucket.org/' . $match[1] . '/'. $match[2] . '/get/' . $ref . '.' . $match[4];
  39084. }
  39085. } elseif ($host === 'gitlab.com' || $host === 'www.gitlab.com') {
  39086. if (Preg::isMatch('{^https?://(?:www\.)?gitlab\.com/api/v[34]/projects/([^/]+)/repository/archive\.(zip|tar\.gz|tar\.bz2|tar)\?sha=.+$}i', $url, $match)) {
  39087. $url = 'https://gitlab.com/api/v4/projects/' . $match[1] . '/repository/archive.' . $match[2] . '?sha=' . $ref;
  39088. }
  39089. } elseif (in_array($host, $config->get('github-domains'), true)) {
  39090. $url = Preg::replace('{(/repos/[^/]+/[^/]+/(zip|tar)ball)(?:/.+)?$}i', '$1/'.$ref, $url);
  39091. } elseif (in_array($host, $config->get('gitlab-domains'), true)) {
  39092. $url = Preg::replace('{(/api/v[34]/projects/[^/]+/repository/archive\.(?:zip|tar\.gz|tar\.bz2|tar)\?sha=).+$}i', '${1}'.$ref, $url);
  39093. }
  39094. assert($url !== '');
  39095. return $url;
  39096. }
  39097. public static function getOrigin(Config $config, string $url): string
  39098. {
  39099. if (0 === strpos($url, 'file://')) {
  39100. return $url;
  39101. }
  39102. $origin = (string) parse_url($url, PHP_URL_HOST);
  39103. if ($port = parse_url($url, PHP_URL_PORT)) {
  39104. $origin .= ':'.$port;
  39105. }
  39106. if (strpos($origin, '.github.com') === (strlen($origin) - 11)) {
  39107. return 'github.com';
  39108. }
  39109. if ($origin === 'repo.packagist.org') {
  39110. return 'packagist.org';
  39111. }
  39112. if ($origin === '') {
  39113. $origin = $url;
  39114. }
  39115. if (
  39116. false === strpos($origin, '/')
  39117. && !in_array($origin, $config->get('gitlab-domains'), true)
  39118. ) {
  39119. foreach ($config->get('gitlab-domains') as $gitlabDomain) {
  39120. if ($gitlabDomain !== '' && str_starts_with($gitlabDomain, $origin)) {
  39121. return $gitlabDomain;
  39122. }
  39123. }
  39124. }
  39125. return $origin;
  39126. }
  39127. public static function sanitize(string $url): string
  39128. {
  39129. $url = Preg::replace('{([&?]access_token=)[^&]+}', '$1***', $url);
  39130. $url = Preg::replaceCallback('{^(?P<prefix>[a-z0-9]+://)?(?P<user>[^:/\s@]+):(?P<password>[^@\s/]+)@}i', static function ($m): string {
  39131. assert(is_string($m['user']));
  39132. if (Preg::isMatch('{^([a-f0-9]{12,}|gh[a-z]_[a-zA-Z0-9_]+|github_pat_[a-zA-Z0-9_]+)$}', $m['user'])) {
  39133. return $m['prefix'].'***:***@';
  39134. }
  39135. return $m['prefix'].$m['user'].':***@';
  39136. }, $url);
  39137. return $url;
  39138. }
  39139. }
  39140. <?php declare(strict_types=1);
  39141. namespace Composer\Util;
  39142. class Zip
  39143. {
  39144. public static function getComposerJson(string $pathToZip): ?string
  39145. {
  39146. if (!extension_loaded('zip')) {
  39147. throw new \RuntimeException('The Zip Util requires PHP\'s zip extension');
  39148. }
  39149. $zip = new \ZipArchive();
  39150. if ($zip->open($pathToZip) !== true) {
  39151. return null;
  39152. }
  39153. if (0 === $zip->numFiles) {
  39154. $zip->close();
  39155. return null;
  39156. }
  39157. $foundFileIndex = self::locateFile($zip, 'composer.json');
  39158. $content = null;
  39159. $configurationFileName = $zip->getNameIndex($foundFileIndex);
  39160. $stream = $zip->getStream($configurationFileName);
  39161. if (false !== $stream) {
  39162. $content = stream_get_contents($stream);
  39163. }
  39164. $zip->close();
  39165. return $content;
  39166. }
  39167. private static function locateFile(\ZipArchive $zip, string $filename): int
  39168. {
  39169. if (false !== ($index = $zip->locateName($filename)) && $zip->getFromIndex($index) !== false) {
  39170. return $index;
  39171. }
  39172. $topLevelPaths = [];
  39173. for ($i = 0; $i < $zip->numFiles; $i++) {
  39174. $name = $zip->getNameIndex($i);
  39175. $dirname = dirname($name);
  39176. if (strpos($name, '__MACOSX') !== false) {
  39177. continue;
  39178. }
  39179. if ($dirname === '.') {
  39180. $topLevelPaths[$name] = true;
  39181. if (\count($topLevelPaths) > 1) {
  39182. 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)));
  39183. }
  39184. continue;
  39185. }
  39186. if (false === strpos($dirname, '\\') && false === strpos($dirname, '/')) {
  39187. $topLevelPaths[$dirname.'/'] = true;
  39188. if (\count($topLevelPaths) > 1) {
  39189. 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)));
  39190. }
  39191. }
  39192. }
  39193. if ($topLevelPaths && false !== ($index = $zip->locateName(key($topLevelPaths).$filename)) && $zip->getFromIndex($index) !== false) {
  39194. return $index;
  39195. }
  39196. throw new \RuntimeException('No composer.json found either at the top level or within the topmost directory');
  39197. }
  39198. }
  39199. <?php declare(strict_types=1);
  39200. use Composer\Autoload\ClassLoader;
  39201. function includeIfExists(string $file): ?ClassLoader
  39202. {
  39203. return file_exists($file) ? include $file : null;
  39204. }
  39205. if ((!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../../../autoload.php'))) {
  39206. echo 'You must set up the project dependencies using `composer install`'.PHP_EOL.
  39207. 'See https://getcomposer.org/download/ for instructions on installing Composer'.PHP_EOL;
  39208. exit(1);
  39209. }
  39210. return $loader;
  39211. <?php
  39212. /*
  39213. * This file is part of Composer.
  39214. *
  39215. * (c) Nils Adermann <naderman@naderman.de>
  39216. * Jordi Boggiano <j.boggiano@seld.be>
  39217. *
  39218. * For the full copyright and license information, please view the LICENSE
  39219. * file that was distributed with this source code.
  39220. */
  39221. namespace Composer\Autoload;
  39222. /**
  39223. * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
  39224. *
  39225. * $loader = new \Composer\Autoload\ClassLoader();
  39226. *
  39227. * // register classes with namespaces
  39228. * $loader->add('Symfony\Component', __DIR__.'/component');
  39229. * $loader->add('Symfony', __DIR__.'/framework');
  39230. *
  39231. * // activate the autoloader
  39232. * $loader->register();
  39233. *
  39234. * // to enable searching the include path (eg. for PEAR packages)
  39235. * $loader->setUseIncludePath(true);
  39236. *
  39237. * In this example, if you try to use a class in the Symfony\Component
  39238. * namespace or one of its children (Symfony\Component\Console for instance),
  39239. * the autoloader will first look for the class under the component/
  39240. * directory, and it will then fallback to the framework/ directory if not
  39241. * found before giving up.
  39242. *
  39243. * This class is loosely based on the Symfony UniversalClassLoader.
  39244. *
  39245. * @author Fabien Potencier <fabien@symfony.com>
  39246. * @author Jordi Boggiano <j.boggiano@seld.be>
  39247. * @see https://www.php-fig.org/psr/psr-0/
  39248. * @see https://www.php-fig.org/psr/psr-4/
  39249. */
  39250. class ClassLoader
  39251. {
  39252. /** @var \Closure(string):void */
  39253. private static $includeFile;
  39254. /** @var string|null */
  39255. private $vendorDir;
  39256. // PSR-4
  39257. /**
  39258. * @var array<string, array<string, int>>
  39259. */
  39260. private $prefixLengthsPsr4 = array();
  39261. /**
  39262. * @var array<string, list<string>>
  39263. */
  39264. private $prefixDirsPsr4 = array();
  39265. /**
  39266. * @var list<string>
  39267. */
  39268. private $fallbackDirsPsr4 = array();
  39269. // PSR-0
  39270. /**
  39271. * List of PSR-0 prefixes
  39272. *
  39273. * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
  39274. *
  39275. * @var array<string, array<string, list<string>>>
  39276. */
  39277. private $prefixesPsr0 = array();
  39278. /**
  39279. * @var list<string>
  39280. */
  39281. private $fallbackDirsPsr0 = array();
  39282. /** @var bool */
  39283. private $useIncludePath = false;
  39284. /**
  39285. * @var array<string, string>
  39286. */
  39287. private $classMap = array();
  39288. /** @var bool */
  39289. private $classMapAuthoritative = false;
  39290. /**
  39291. * @var array<string, bool>
  39292. */
  39293. private $missingClasses = array();
  39294. /** @var string|null */
  39295. private $apcuPrefix;
  39296. /**
  39297. * @var array<string, self>
  39298. */
  39299. private static $registeredLoaders = array();
  39300. /**
  39301. * @param string|null $vendorDir
  39302. */
  39303. public function __construct($vendorDir = null)
  39304. {
  39305. $this->vendorDir = $vendorDir;
  39306. self::initializeIncludeClosure();
  39307. }
  39308. /**
  39309. * @return array<string, list<string>>
  39310. */
  39311. public function getPrefixes()
  39312. {
  39313. if (!empty($this->prefixesPsr0)) {
  39314. return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
  39315. }
  39316. return array();
  39317. }
  39318. /**
  39319. * @return array<string, list<string>>
  39320. */
  39321. public function getPrefixesPsr4()
  39322. {
  39323. return $this->prefixDirsPsr4;
  39324. }
  39325. /**
  39326. * @return list<string>
  39327. */
  39328. public function getFallbackDirs()
  39329. {
  39330. return $this->fallbackDirsPsr0;
  39331. }
  39332. /**
  39333. * @return list<string>
  39334. */
  39335. public function getFallbackDirsPsr4()
  39336. {
  39337. return $this->fallbackDirsPsr4;
  39338. }
  39339. /**
  39340. * @return array<string, string> Array of classname => path
  39341. */
  39342. public function getClassMap()
  39343. {
  39344. return $this->classMap;
  39345. }
  39346. /**
  39347. * @param array<string, string> $classMap Class to filename map
  39348. *
  39349. * @return void
  39350. */
  39351. public function addClassMap(array $classMap)
  39352. {
  39353. if ($this->classMap) {
  39354. $this->classMap = array_merge($this->classMap, $classMap);
  39355. } else {
  39356. $this->classMap = $classMap;
  39357. }
  39358. }
  39359. /**
  39360. * Registers a set of PSR-0 directories for a given prefix, either
  39361. * appending or prepending to the ones previously set for this prefix.
  39362. *
  39363. * @param string $prefix The prefix
  39364. * @param list<string>|string $paths The PSR-0 root directories
  39365. * @param bool $prepend Whether to prepend the directories
  39366. *
  39367. * @return void
  39368. */
  39369. public function add($prefix, $paths, $prepend = false)
  39370. {
  39371. $paths = (array) $paths;
  39372. if (!$prefix) {
  39373. if ($prepend) {
  39374. $this->fallbackDirsPsr0 = array_merge(
  39375. $paths,
  39376. $this->fallbackDirsPsr0
  39377. );
  39378. } else {
  39379. $this->fallbackDirsPsr0 = array_merge(
  39380. $this->fallbackDirsPsr0,
  39381. $paths
  39382. );
  39383. }
  39384. return;
  39385. }
  39386. $first = $prefix[0];
  39387. if (!isset($this->prefixesPsr0[$first][$prefix])) {
  39388. $this->prefixesPsr0[$first][$prefix] = $paths;
  39389. return;
  39390. }
  39391. if ($prepend) {
  39392. $this->prefixesPsr0[$first][$prefix] = array_merge(
  39393. $paths,
  39394. $this->prefixesPsr0[$first][$prefix]
  39395. );
  39396. } else {
  39397. $this->prefixesPsr0[$first][$prefix] = array_merge(
  39398. $this->prefixesPsr0[$first][$prefix],
  39399. $paths
  39400. );
  39401. }
  39402. }
  39403. /**
  39404. * Registers a set of PSR-4 directories for a given namespace, either
  39405. * appending or prepending to the ones previously set for this namespace.
  39406. *
  39407. * @param string $prefix The prefix/namespace, with trailing '\\'
  39408. * @param list<string>|string $paths The PSR-4 base directories
  39409. * @param bool $prepend Whether to prepend the directories
  39410. *
  39411. * @throws \InvalidArgumentException
  39412. *
  39413. * @return void
  39414. */
  39415. public function addPsr4($prefix, $paths, $prepend = false)
  39416. {
  39417. $paths = (array) $paths;
  39418. if (!$prefix) {
  39419. // Register directories for the root namespace.
  39420. if ($prepend) {
  39421. $this->fallbackDirsPsr4 = array_merge(
  39422. $paths,
  39423. $this->fallbackDirsPsr4
  39424. );
  39425. } else {
  39426. $this->fallbackDirsPsr4 = array_merge(
  39427. $this->fallbackDirsPsr4,
  39428. $paths
  39429. );
  39430. }
  39431. } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
  39432. // Register directories for a new namespace.
  39433. $length = strlen($prefix);
  39434. if ('\\' !== $prefix[$length - 1]) {
  39435. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  39436. }
  39437. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  39438. $this->prefixDirsPsr4[$prefix] = $paths;
  39439. } elseif ($prepend) {
  39440. // Prepend directories for an already registered namespace.
  39441. $this->prefixDirsPsr4[$prefix] = array_merge(
  39442. $paths,
  39443. $this->prefixDirsPsr4[$prefix]
  39444. );
  39445. } else {
  39446. // Append directories for an already registered namespace.
  39447. $this->prefixDirsPsr4[$prefix] = array_merge(
  39448. $this->prefixDirsPsr4[$prefix],
  39449. $paths
  39450. );
  39451. }
  39452. }
  39453. /**
  39454. * Registers a set of PSR-0 directories for a given prefix,
  39455. * replacing any others previously set for this prefix.
  39456. *
  39457. * @param string $prefix The prefix
  39458. * @param list<string>|string $paths The PSR-0 base directories
  39459. *
  39460. * @return void
  39461. */
  39462. public function set($prefix, $paths)
  39463. {
  39464. if (!$prefix) {
  39465. $this->fallbackDirsPsr0 = (array) $paths;
  39466. } else {
  39467. $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
  39468. }
  39469. }
  39470. /**
  39471. * Registers a set of PSR-4 directories for a given namespace,
  39472. * replacing any others previously set for this namespace.
  39473. *
  39474. * @param string $prefix The prefix/namespace, with trailing '\\'
  39475. * @param list<string>|string $paths The PSR-4 base directories
  39476. *
  39477. * @throws \InvalidArgumentException
  39478. *
  39479. * @return void
  39480. */
  39481. public function setPsr4($prefix, $paths)
  39482. {
  39483. if (!$prefix) {
  39484. $this->fallbackDirsPsr4 = (array) $paths;
  39485. } else {
  39486. $length = strlen($prefix);
  39487. if ('\\' !== $prefix[$length - 1]) {
  39488. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  39489. }
  39490. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  39491. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  39492. }
  39493. }
  39494. /**
  39495. * Turns on searching the include path for class files.
  39496. *
  39497. * @param bool $useIncludePath
  39498. *
  39499. * @return void
  39500. */
  39501. public function setUseIncludePath($useIncludePath)
  39502. {
  39503. $this->useIncludePath = $useIncludePath;
  39504. }
  39505. /**
  39506. * Can be used to check if the autoloader uses the include path to check
  39507. * for classes.
  39508. *
  39509. * @return bool
  39510. */
  39511. public function getUseIncludePath()
  39512. {
  39513. return $this->useIncludePath;
  39514. }
  39515. /**
  39516. * Turns off searching the prefix and fallback directories for classes
  39517. * that have not been registered with the class map.
  39518. *
  39519. * @param bool $classMapAuthoritative
  39520. *
  39521. * @return void
  39522. */
  39523. public function setClassMapAuthoritative($classMapAuthoritative)
  39524. {
  39525. $this->classMapAuthoritative = $classMapAuthoritative;
  39526. }
  39527. /**
  39528. * Should class lookup fail if not found in the current class map?
  39529. *
  39530. * @return bool
  39531. */
  39532. public function isClassMapAuthoritative()
  39533. {
  39534. return $this->classMapAuthoritative;
  39535. }
  39536. /**
  39537. * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
  39538. *
  39539. * @param string|null $apcuPrefix
  39540. *
  39541. * @return void
  39542. */
  39543. public function setApcuPrefix($apcuPrefix)
  39544. {
  39545. $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
  39546. }
  39547. /**
  39548. * The APCu prefix in use, or null if APCu caching is not enabled.
  39549. *
  39550. * @return string|null
  39551. */
  39552. public function getApcuPrefix()
  39553. {
  39554. return $this->apcuPrefix;
  39555. }
  39556. /**
  39557. * Registers this instance as an autoloader.
  39558. *
  39559. * @param bool $prepend Whether to prepend the autoloader or not
  39560. *
  39561. * @return void
  39562. */
  39563. public function register($prepend = false)
  39564. {
  39565. spl_autoload_register(array($this, 'loadClass'), true, $prepend);
  39566. if (null === $this->vendorDir) {
  39567. return;
  39568. }
  39569. if ($prepend) {
  39570. self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
  39571. } else {
  39572. unset(self::$registeredLoaders[$this->vendorDir]);
  39573. self::$registeredLoaders[$this->vendorDir] = $this;
  39574. }
  39575. }
  39576. /**
  39577. * Unregisters this instance as an autoloader.
  39578. *
  39579. * @return void
  39580. */
  39581. public function unregister()
  39582. {
  39583. spl_autoload_unregister(array($this, 'loadClass'));
  39584. if (null !== $this->vendorDir) {
  39585. unset(self::$registeredLoaders[$this->vendorDir]);
  39586. }
  39587. }
  39588. /**
  39589. * Loads the given class or interface.
  39590. *
  39591. * @param string $class The name of the class
  39592. * @return true|null True if loaded, null otherwise
  39593. */
  39594. public function loadClass($class)
  39595. {
  39596. if ($file = $this->findFile($class)) {
  39597. $includeFile = self::$includeFile;
  39598. $includeFile($file);
  39599. return true;
  39600. }
  39601. return null;
  39602. }
  39603. /**
  39604. * Finds the path to the file where the class is defined.
  39605. *
  39606. * @param string $class The name of the class
  39607. *
  39608. * @return string|false The path if found, false otherwise
  39609. */
  39610. public function findFile($class)
  39611. {
  39612. // class map lookup
  39613. if (isset($this->classMap[$class])) {
  39614. return $this->classMap[$class];
  39615. }
  39616. if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
  39617. return false;
  39618. }
  39619. if (null !== $this->apcuPrefix) {
  39620. $file = apcu_fetch($this->apcuPrefix.$class, $hit);
  39621. if ($hit) {
  39622. return $file;
  39623. }
  39624. }
  39625. $file = $this->findFileWithExtension($class, '.php');
  39626. // Search for Hack files if we are running on HHVM
  39627. if (false === $file && defined('HHVM_VERSION')) {
  39628. $file = $this->findFileWithExtension($class, '.hh');
  39629. }
  39630. if (null !== $this->apcuPrefix) {
  39631. apcu_add($this->apcuPrefix.$class, $file);
  39632. }
  39633. if (false === $file) {
  39634. // Remember that this class does not exist.
  39635. $this->missingClasses[$class] = true;
  39636. }
  39637. return $file;
  39638. }
  39639. /**
  39640. * Returns the currently registered loaders keyed by their corresponding vendor directories.
  39641. *
  39642. * @return array<string, self>
  39643. */
  39644. public static function getRegisteredLoaders()
  39645. {
  39646. return self::$registeredLoaders;
  39647. }
  39648. /**
  39649. * @param string $class
  39650. * @param string $ext
  39651. * @return string|false
  39652. */
  39653. private function findFileWithExtension($class, $ext)
  39654. {
  39655. // PSR-4 lookup
  39656. $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
  39657. $first = $class[0];
  39658. if (isset($this->prefixLengthsPsr4[$first])) {
  39659. $subPath = $class;
  39660. while (false !== $lastPos = strrpos($subPath, '\\')) {
  39661. $subPath = substr($subPath, 0, $lastPos);
  39662. $search = $subPath . '\\';
  39663. if (isset($this->prefixDirsPsr4[$search])) {
  39664. $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
  39665. foreach ($this->prefixDirsPsr4[$search] as $dir) {
  39666. if (file_exists($file = $dir . $pathEnd)) {
  39667. return $file;
  39668. }
  39669. }
  39670. }
  39671. }
  39672. }
  39673. // PSR-4 fallback dirs
  39674. foreach ($this->fallbackDirsPsr4 as $dir) {
  39675. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
  39676. return $file;
  39677. }
  39678. }
  39679. // PSR-0 lookup
  39680. if (false !== $pos = strrpos($class, '\\')) {
  39681. // namespaced class name
  39682. $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
  39683. . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
  39684. } else {
  39685. // PEAR-like class name
  39686. $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
  39687. }
  39688. if (isset($this->prefixesPsr0[$first])) {
  39689. foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
  39690. if (0 === strpos($class, $prefix)) {
  39691. foreach ($dirs as $dir) {
  39692. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  39693. return $file;
  39694. }
  39695. }
  39696. }
  39697. }
  39698. }
  39699. // PSR-0 fallback dirs
  39700. foreach ($this->fallbackDirsPsr0 as $dir) {
  39701. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  39702. return $file;
  39703. }
  39704. }
  39705. // PSR-0 include paths.
  39706. if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
  39707. return $file;
  39708. }
  39709. return false;
  39710. }
  39711. /**
  39712. * @return void
  39713. */
  39714. private static function initializeIncludeClosure()
  39715. {
  39716. if (self::$includeFile !== null) {
  39717. return;
  39718. }
  39719. /**
  39720. * Scope isolated include.
  39721. *
  39722. * Prevents access to $this/self from included files.
  39723. *
  39724. * @param string $file
  39725. * @return void
  39726. */
  39727. self::$includeFile = \Closure::bind(static function($file) {
  39728. include $file;
  39729. }, null, null);
  39730. }
  39731. }
  39732. <?php
  39733. /*
  39734. * This file is part of Composer.
  39735. *
  39736. * (c) Nils Adermann <naderman@naderman.de>
  39737. * Jordi Boggiano <j.boggiano@seld.be>
  39738. *
  39739. * For the full copyright and license information, please view the LICENSE
  39740. * file that was distributed with this source code.
  39741. */
  39742. namespace Composer;
  39743. use Composer\Autoload\ClassLoader;
  39744. use Composer\Semver\VersionParser;
  39745. /**
  39746. * This class is copied in every Composer installed project and available to all
  39747. *
  39748. * See also https://getcomposer.org/doc/07-runtime.md#installed-versions
  39749. *
  39750. * To require its presence, you can require `composer-runtime-api ^2.0`
  39751. *
  39752. * @final
  39753. */
  39754. class InstalledVersions
  39755. {
  39756. /**
  39757. * @var mixed[]|null
  39758. * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
  39759. */
  39760. private static $installed;
  39761. /**
  39762. * @var bool|null
  39763. */
  39764. private static $canGetVendors;
  39765. /**
  39766. * @var array[]
  39767. * @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
  39768. */
  39769. private static $installedByVendor = array();
  39770. /**
  39771. * Returns a list of all package names which are present, either by being installed, replaced or provided
  39772. *
  39773. * @return string[]
  39774. * @psalm-return list<string>
  39775. */
  39776. public static function getInstalledPackages()
  39777. {
  39778. $packages = array();
  39779. foreach (self::getInstalled() as $installed) {
  39780. $packages[] = array_keys($installed['versions']);
  39781. }
  39782. if (1 === \count($packages)) {
  39783. return $packages[0];
  39784. }
  39785. return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
  39786. }
  39787. /**
  39788. * Returns a list of all package names with a specific type e.g. 'library'
  39789. *
  39790. * @param string $type
  39791. * @return string[]
  39792. * @psalm-return list<string>
  39793. */
  39794. public static function getInstalledPackagesByType($type)
  39795. {
  39796. $packagesByType = array();
  39797. foreach (self::getInstalled() as $installed) {
  39798. foreach ($installed['versions'] as $name => $package) {
  39799. if (isset($package['type']) && $package['type'] === $type) {
  39800. $packagesByType[] = $name;
  39801. }
  39802. }
  39803. }
  39804. return $packagesByType;
  39805. }
  39806. /**
  39807. * Checks whether the given package is installed
  39808. *
  39809. * This also returns true if the package name is provided or replaced by another package
  39810. *
  39811. * @param string $packageName
  39812. * @param bool $includeDevRequirements
  39813. * @return bool
  39814. */
  39815. public static function isInstalled($packageName, $includeDevRequirements = true)
  39816. {
  39817. foreach (self::getInstalled() as $installed) {
  39818. if (isset($installed['versions'][$packageName])) {
  39819. return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
  39820. }
  39821. }
  39822. return false;
  39823. }
  39824. /**
  39825. * Checks whether the given package satisfies a version constraint
  39826. *
  39827. * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
  39828. *
  39829. * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
  39830. *
  39831. * @param VersionParser $parser Install composer/semver to have access to this class and functionality
  39832. * @param string $packageName
  39833. * @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
  39834. * @return bool
  39835. */
  39836. public static function satisfies(VersionParser $parser, $packageName, $constraint)
  39837. {
  39838. $constraint = $parser->parseConstraints((string) $constraint);
  39839. $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
  39840. return $provided->matches($constraint);
  39841. }
  39842. /**
  39843. * Returns a version constraint representing all the range(s) which are installed for a given package
  39844. *
  39845. * It is easier to use this via isInstalled() with the $constraint argument if you need to check
  39846. * whether a given version of a package is installed, and not just whether it exists
  39847. *
  39848. * @param string $packageName
  39849. * @return string Version constraint usable with composer/semver
  39850. */
  39851. public static function getVersionRanges($packageName)
  39852. {
  39853. foreach (self::getInstalled() as $installed) {
  39854. if (!isset($installed['versions'][$packageName])) {
  39855. continue;
  39856. }
  39857. $ranges = array();
  39858. if (isset($installed['versions'][$packageName]['pretty_version'])) {
  39859. $ranges[] = $installed['versions'][$packageName]['pretty_version'];
  39860. }
  39861. if (array_key_exists('aliases', $installed['versions'][$packageName])) {
  39862. $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
  39863. }
  39864. if (array_key_exists('replaced', $installed['versions'][$packageName])) {
  39865. $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
  39866. }
  39867. if (array_key_exists('provided', $installed['versions'][$packageName])) {
  39868. $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
  39869. }
  39870. return implode(' || ', $ranges);
  39871. }
  39872. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  39873. }
  39874. /**
  39875. * @param string $packageName
  39876. * @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
  39877. */
  39878. public static function getVersion($packageName)
  39879. {
  39880. foreach (self::getInstalled() as $installed) {
  39881. if (!isset($installed['versions'][$packageName])) {
  39882. continue;
  39883. }
  39884. if (!isset($installed['versions'][$packageName]['version'])) {
  39885. return null;
  39886. }
  39887. return $installed['versions'][$packageName]['version'];
  39888. }
  39889. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  39890. }
  39891. /**
  39892. * @param string $packageName
  39893. * @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
  39894. */
  39895. public static function getPrettyVersion($packageName)
  39896. {
  39897. foreach (self::getInstalled() as $installed) {
  39898. if (!isset($installed['versions'][$packageName])) {
  39899. continue;
  39900. }
  39901. if (!isset($installed['versions'][$packageName]['pretty_version'])) {
  39902. return null;
  39903. }
  39904. return $installed['versions'][$packageName]['pretty_version'];
  39905. }
  39906. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  39907. }
  39908. /**
  39909. * @param string $packageName
  39910. * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
  39911. */
  39912. public static function getReference($packageName)
  39913. {
  39914. foreach (self::getInstalled() as $installed) {
  39915. if (!isset($installed['versions'][$packageName])) {
  39916. continue;
  39917. }
  39918. if (!isset($installed['versions'][$packageName]['reference'])) {
  39919. return null;
  39920. }
  39921. return $installed['versions'][$packageName]['reference'];
  39922. }
  39923. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  39924. }
  39925. /**
  39926. * @param string $packageName
  39927. * @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.
  39928. */
  39929. public static function getInstallPath($packageName)
  39930. {
  39931. foreach (self::getInstalled() as $installed) {
  39932. if (!isset($installed['versions'][$packageName])) {
  39933. continue;
  39934. }
  39935. return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
  39936. }
  39937. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  39938. }
  39939. /**
  39940. * @return array
  39941. * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
  39942. */
  39943. public static function getRootPackage()
  39944. {
  39945. $installed = self::getInstalled();
  39946. return $installed[0]['root'];
  39947. }
  39948. /**
  39949. * Returns the raw installed.php data for custom implementations
  39950. *
  39951. * @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.
  39952. * @return array[]
  39953. * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
  39954. */
  39955. public static function getRawData()
  39956. {
  39957. @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);
  39958. if (null === self::$installed) {
  39959. // only require the installed.php file if this file is loaded from its dumped location,
  39960. // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
  39961. if (substr(__DIR__, -8, 1) !== 'C') {
  39962. self::$installed = include __DIR__ . '/installed.php';
  39963. } else {
  39964. self::$installed = array();
  39965. }
  39966. }
  39967. return self::$installed;
  39968. }
  39969. /**
  39970. * Returns the raw data of all installed.php which are currently loaded for custom implementations
  39971. *
  39972. * @return array[]
  39973. * @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
  39974. */
  39975. public static function getAllRawData()
  39976. {
  39977. return self::getInstalled();
  39978. }
  39979. /**
  39980. * Lets you reload the static array from another file
  39981. *
  39982. * This is only useful for complex integrations in which a project needs to use
  39983. * this class but then also needs to execute another project's autoloader in process,
  39984. * and wants to ensure both projects have access to their version of installed.php.
  39985. *
  39986. * A typical case would be PHPUnit, where it would need to make sure it reads all
  39987. * the data it needs from this class, then call reload() with
  39988. * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
  39989. * the project in which it runs can then also use this class safely, without
  39990. * interference between PHPUnit's dependencies and the project's dependencies.
  39991. *
  39992. * @param array[] $data A vendor/composer/installed.php data set
  39993. * @return void
  39994. *
  39995. * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
  39996. */
  39997. public static function reload($data)
  39998. {
  39999. self::$installed = $data;
  40000. self::$installedByVendor = array();
  40001. }
  40002. /**
  40003. * @return array[]
  40004. * @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
  40005. */
  40006. private static function getInstalled()
  40007. {
  40008. if (null === self::$canGetVendors) {
  40009. self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
  40010. }
  40011. $installed = array();
  40012. if (self::$canGetVendors) {
  40013. foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
  40014. if (isset(self::$installedByVendor[$vendorDir])) {
  40015. $installed[] = self::$installedByVendor[$vendorDir];
  40016. } elseif (is_file($vendorDir.'/composer/installed.php')) {
  40017. /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
  40018. $required = require $vendorDir.'/composer/installed.php';
  40019. $installed[] = self::$installedByVendor[$vendorDir] = $required;
  40020. if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
  40021. self::$installed = $installed[count($installed) - 1];
  40022. }
  40023. }
  40024. }
  40025. }
  40026. if (null === self::$installed) {
  40027. // only require the installed.php file if this file is loaded from its dumped location,
  40028. // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
  40029. if (substr(__DIR__, -8, 1) !== 'C') {
  40030. /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
  40031. $required = require __DIR__ . '/installed.php';
  40032. self::$installed = $required;
  40033. } else {
  40034. self::$installed = array();
  40035. }
  40036. }
  40037. if (self::$installed !== array()) {
  40038. $installed[] = self::$installed;
  40039. }
  40040. return $installed;
  40041. }
  40042. }
  40043. {
  40044. "$schema": "https://json-schema.org/draft-04/schema#",
  40045. "description": "A representation of packages metadata.",
  40046. "type": "object",
  40047. "oneOf": [
  40048. { "required": [ "packages" ] },
  40049. { "required": [ "providers" ] },
  40050. { "required": [ "provider-includes", "providers-url" ] }
  40051. ],
  40052. "properties": {
  40053. "packages": {
  40054. "type": ["object", "array"],
  40055. "description": "A hashmap of package names in the form of <vendor>/<name>.",
  40056. "additionalProperties": { "$ref": "#/definitions/versions" }
  40057. },
  40058. "providers-url": {
  40059. "type": "string",
  40060. "description": "Endpoint to retrieve provider data from, e.g. '/p/%package%$%hash%.json'."
  40061. },
  40062. "provider-includes": {
  40063. "type": "object",
  40064. "description": "A hashmap of provider listings.",
  40065. "additionalProperties": { "$ref": "#/definitions/provider" }
  40066. },
  40067. "providers": {
  40068. "type": "object",
  40069. "description": "A hashmap of package names in the form of <vendor>/<name>.",
  40070. "additionalProperties": { "$ref": "#/definitions/provider" }
  40071. },
  40072. "notify-batch": {
  40073. "type": "string",
  40074. "description": "Endpoint to call after multiple packages have been installed, e.g. '/downloads/'."
  40075. },
  40076. "search": {
  40077. "type": "string",
  40078. "description": "Endpoint that provides search capabilities, e.g. '/search.json?q=%query%&type=%type%'."
  40079. },
  40080. "warning": {
  40081. "type": "string",
  40082. "description": "A message that will be output by Composer as a warning when this source is consulted."
  40083. }
  40084. },
  40085. "definitions": {
  40086. "versions": {
  40087. "type": "object",
  40088. "description": "A hashmap of versions and their metadata.",
  40089. "additionalProperties": { "$ref": "#/definitions/version" }
  40090. },
  40091. "version": {
  40092. "type": "object",
  40093. "oneOf": [
  40094. { "$ref": "#/definitions/package" },
  40095. { "$ref": "#/definitions/metapackage" }
  40096. ]
  40097. },
  40098. "package-base": {
  40099. "properties": {
  40100. "name": { "type": "string" },
  40101. "type": { "type": "string" },
  40102. "version": { "type": "string" },
  40103. "version_normalized": {
  40104. "type": "string",
  40105. "description": "Normalized version, optional but can save computational time on client side."
  40106. },
  40107. "autoload": { "type": "object" },
  40108. "require": { "type": "object" },
  40109. "replace": { "type": "object" },
  40110. "conflict": { "type": "object" },
  40111. "provide": { "type": "object" },
  40112. "time": { "type": "string" }
  40113. },
  40114. "additionalProperties": true
  40115. },
  40116. "package": {
  40117. "allOf": [
  40118. { "$ref": "#/definitions/package-base" },
  40119. {
  40120. "properties": {
  40121. "dist": { "type": "object" },
  40122. "source": { "type": "object" }
  40123. }
  40124. },
  40125. { "oneOf": [
  40126. { "required": [ "name", "version", "source" ] },
  40127. { "required": [ "name", "version", "dist" ] }
  40128. ] }
  40129. ]
  40130. },
  40131. "metapackage": {
  40132. "allOf": [
  40133. { "$ref": "#/definitions/package-base" },
  40134. {
  40135. "properties": {
  40136. "type": { "type": "string", "enum": [ "metapackage" ] }
  40137. },
  40138. "required": [ "name", "version", "type" ]
  40139. }
  40140. ]
  40141. },
  40142. "provider": {
  40143. "type": "object",
  40144. "properties": {
  40145. "sha256": {
  40146. "type": "string",
  40147. "description": "Hash value that can be used to validate the resource."
  40148. }
  40149. }
  40150. }
  40151. }
  40152. }
  40153. {
  40154. "$schema": "https://json-schema.org/draft-04/schema#",
  40155. "title": "Package",
  40156. "type": "object",
  40157. "properties": {
  40158. "name": {
  40159. "type": "string",
  40160. "description": "Package name, including 'vendor-name/' prefix.",
  40161. "pattern": "^[a-z0-9]([_.-]?[a-z0-9]+)*\/[a-z0-9](([_.]|-{1,2})?[a-z0-9]+)*$"
  40162. },
  40163. "description": {
  40164. "type": "string",
  40165. "description": "Short package description."
  40166. },
  40167. "license": {
  40168. "type": ["string", "array"],
  40169. "description": "License name. Or an array of license names."
  40170. },
  40171. "type": {
  40172. "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.",
  40173. "type": "string",
  40174. "pattern": "^[a-z0-9-]+$"
  40175. },
  40176. "abandoned": {
  40177. "type": ["boolean", "string"],
  40178. "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."
  40179. },
  40180. "version": {
  40181. "type": "string",
  40182. "description": "Package version, see https://getcomposer.org/doc/04-schema.md#version for more info on valid schemes.",
  40183. "pattern": "^v?\\d+(\\.\\d+){0,3}|^dev-"
  40184. },
  40185. "default-branch": {
  40186. "type": ["boolean"],
  40187. "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."
  40188. },
  40189. "non-feature-branches": {
  40190. "type": ["array"],
  40191. "description": "A set of string or regex patterns for non-numeric branch names that will not be handled as feature branches.",
  40192. "items": {
  40193. "type": "string"
  40194. }
  40195. },
  40196. "keywords": {
  40197. "type": "array",
  40198. "items": {
  40199. "type": "string",
  40200. "description": "A tag/keyword that this package relates to."
  40201. }
  40202. },
  40203. "readme": {
  40204. "type": "string",
  40205. "description": "Relative path to the readme document."
  40206. },
  40207. "time": {
  40208. "type": "string",
  40209. "description": "Package release date, in 'YYYY-MM-DD', 'YYYY-MM-DD HH:MM:SS' or 'YYYY-MM-DDTHH:MM:SSZ' format."
  40210. },
  40211. "authors": {
  40212. "$ref": "#/definitions/authors"
  40213. },
  40214. "homepage": {
  40215. "type": "string",
  40216. "description": "Homepage URL for the project.",
  40217. "format": "uri"
  40218. },
  40219. "support": {
  40220. "type": "object",
  40221. "properties": {
  40222. "email": {
  40223. "type": "string",
  40224. "description": "Email address for support.",
  40225. "format": "email"
  40226. },
  40227. "issues": {
  40228. "type": "string",
  40229. "description": "URL to the issue tracker.",
  40230. "format": "uri"
  40231. },
  40232. "forum": {
  40233. "type": "string",
  40234. "description": "URL to the forum.",
  40235. "format": "uri"
  40236. },
  40237. "wiki": {
  40238. "type": "string",
  40239. "description": "URL to the wiki.",
  40240. "format": "uri"
  40241. },
  40242. "irc": {
  40243. "type": "string",
  40244. "description": "IRC channel for support, as irc://server/channel.",
  40245. "format": "uri"
  40246. },
  40247. "chat": {
  40248. "type": "string",
  40249. "description": "URL to the support chat.",
  40250. "format": "uri"
  40251. },
  40252. "source": {
  40253. "type": "string",
  40254. "description": "URL to browse or download the sources.",
  40255. "format": "uri"
  40256. },
  40257. "docs": {
  40258. "type": "string",
  40259. "description": "URL to the documentation.",
  40260. "format": "uri"
  40261. },
  40262. "rss": {
  40263. "type": "string",
  40264. "description": "URL to the RSS feed.",
  40265. "format": "uri"
  40266. },
  40267. "security": {
  40268. "type": "string",
  40269. "description": "URL to the vulnerability disclosure policy (VDP).",
  40270. "format": "uri"
  40271. }
  40272. }
  40273. },
  40274. "funding": {
  40275. "type": "array",
  40276. "description": "A list of options to fund the development and maintenance of the package.",
  40277. "items": {
  40278. "type": "object",
  40279. "properties": {
  40280. "type": {
  40281. "type": "string",
  40282. "description": "Type of funding or platform through which funding is possible."
  40283. },
  40284. "url": {
  40285. "type": "string",
  40286. "description": "URL to a website with details on funding and a way to fund the package.",
  40287. "format": "uri"
  40288. }
  40289. }
  40290. }
  40291. },
  40292. "source": {
  40293. "$ref": "#/definitions/source"
  40294. },
  40295. "dist": {
  40296. "$ref": "#/definitions/dist"
  40297. },
  40298. "_comment": {
  40299. "type": ["array", "string"],
  40300. "description": "A key to store comments in"
  40301. },
  40302. "require": {
  40303. "type": "object",
  40304. "description": "This is an object of package name (keys) and version constraints (values) that are required to run this package.",
  40305. "additionalProperties": {
  40306. "type": "string"
  40307. }
  40308. },
  40309. "require-dev": {
  40310. "type": "object",
  40311. "description": "This is an object of package name (keys) and version constraints (values) that this package requires for developing it (testing tools and such).",
  40312. "additionalProperties": {
  40313. "type": "string"
  40314. }
  40315. },
  40316. "replace": {
  40317. "type": "object",
  40318. "description": "This is an object of package name (keys) and version constraints (values) that can be replaced by this package.",
  40319. "additionalProperties": {
  40320. "type": "string"
  40321. }
  40322. },
  40323. "conflict": {
  40324. "type": "object",
  40325. "description": "This is an object of package name (keys) and version constraints (values) that conflict with this package.",
  40326. "additionalProperties": {
  40327. "type": "string"
  40328. }
  40329. },
  40330. "provide": {
  40331. "type": "object",
  40332. "description": "This is an object of package name (keys) and version constraints (values) that this package provides in addition to this package's name.",
  40333. "additionalProperties": {
  40334. "type": "string"
  40335. }
  40336. },
  40337. "suggest": {
  40338. "type": "object",
  40339. "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).",
  40340. "additionalProperties": {
  40341. "type": "string"
  40342. }
  40343. },
  40344. "repositories": {
  40345. "type": ["object", "array"],
  40346. "description": "A set of additional repositories where packages can be found.",
  40347. "additionalProperties": {
  40348. "anyOf": [
  40349. { "$ref": "#/definitions/repository" },
  40350. { "type": "boolean", "enum": [false] }
  40351. ]
  40352. },
  40353. "items": {
  40354. "anyOf": [
  40355. { "$ref": "#/definitions/repository" },
  40356. {
  40357. "type": "object",
  40358. "additionalProperties": { "type": "boolean", "enum": [false] },
  40359. "minProperties": 1,
  40360. "maxProperties": 1
  40361. }
  40362. ]
  40363. }
  40364. },
  40365. "minimum-stability": {
  40366. "type": ["string"],
  40367. "description": "The minimum stability the packages must have to be install-able. Possible values are: dev, alpha, beta, RC, stable.",
  40368. "enum": ["dev", "alpha", "beta", "rc", "RC", "stable"]
  40369. },
  40370. "prefer-stable": {
  40371. "type": ["boolean"],
  40372. "description": "If set to true, stable packages will be preferred to dev packages when possible, even if the minimum-stability allows unstable packages."
  40373. },
  40374. "autoload": {
  40375. "$ref": "#/definitions/autoload"
  40376. },
  40377. "autoload-dev": {
  40378. "type": "object",
  40379. "description": "Description of additional autoload rules for development purpose (eg. a test suite).",
  40380. "properties": {
  40381. "psr-0": {
  40382. "type": "object",
  40383. "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.",
  40384. "additionalProperties": {
  40385. "type": ["string", "array"],
  40386. "items": {
  40387. "type": "string"
  40388. }
  40389. }
  40390. },
  40391. "psr-4": {
  40392. "type": "object",
  40393. "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.",
  40394. "additionalProperties": {
  40395. "type": ["string", "array"],
  40396. "items": {
  40397. "type": "string"
  40398. }
  40399. }
  40400. },
  40401. "classmap": {
  40402. "type": "array",
  40403. "description": "This is an array of paths that contain classes to be included in the class-map generation process."
  40404. },
  40405. "files": {
  40406. "type": "array",
  40407. "description": "This is an array of files that are always required on every request."
  40408. }
  40409. }
  40410. },
  40411. "target-dir": {
  40412. "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.",
  40413. "type": "string"
  40414. },
  40415. "include-path": {
  40416. "type": ["array"],
  40417. "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.",
  40418. "items": {
  40419. "type": "string"
  40420. }
  40421. },
  40422. "bin": {
  40423. "type": ["string", "array"],
  40424. "description": "A set of files, or a single file, that should be treated as binaries and symlinked into bin-dir (from config).",
  40425. "items": {
  40426. "type": "string"
  40427. }
  40428. },
  40429. "archive": {
  40430. "type": ["object"],
  40431. "description": "Options for creating package archives for distribution.",
  40432. "properties": {
  40433. "name": {
  40434. "type": "string",
  40435. "description": "A base name for archive."
  40436. },
  40437. "exclude": {
  40438. "type": "array",
  40439. "description": "A list of patterns for paths to exclude or include if prefixed with an exclamation mark."
  40440. }
  40441. }
  40442. },
  40443. "config": {
  40444. "type": "object",
  40445. "description": "Composer options.",
  40446. "properties": {
  40447. "platform": {
  40448. "type": "object",
  40449. "description": "This is an object of package name (keys) and version (values) that will be used to mock the platform packages on this machine, the version can be set to false to make it appear like the package is not present.",
  40450. "additionalProperties": {
  40451. "type": ["string", "boolean"]
  40452. }
  40453. },
  40454. "allow-plugins": {
  40455. "type": ["object", "boolean"],
  40456. "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.",
  40457. "additionalProperties": {
  40458. "type": ["boolean"]
  40459. }
  40460. },
  40461. "process-timeout": {
  40462. "type": "integer",
  40463. "description": "The timeout in seconds for process executions, defaults to 300 (5mins)."
  40464. },
  40465. "use-include-path": {
  40466. "type": "boolean",
  40467. "description": "If true, the Composer autoloader will also look for classes in the PHP include path."
  40468. },
  40469. "use-parent-dir": {
  40470. "type": ["string", "boolean"],
  40471. "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."
  40472. },
  40473. "preferred-install": {
  40474. "type": ["string", "object"],
  40475. "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\"}.",
  40476. "additionalProperties": {
  40477. "type": ["string"]
  40478. }
  40479. },
  40480. "audit": {
  40481. "type": "object",
  40482. "description": "Security audit configuration options",
  40483. "properties": {
  40484. "ignore": {
  40485. "anyOf": [
  40486. {
  40487. "type": "object",
  40488. "description": "A list of advisory ids, remote ids or CVE ids (keys) and the explanations (values) for why they're being ignored. The listed items are reported but let the audit command pass.",
  40489. "additionalProperties": {
  40490. "type": ["string", "string"]
  40491. }
  40492. },
  40493. {
  40494. "type": "array",
  40495. "description": "A set of advisory ids, remote ids or CVE ids that are reported but let the audit command pass.",
  40496. "items": {
  40497. "type": "string"
  40498. }
  40499. }
  40500. ]
  40501. },
  40502. "abandoned": {
  40503. "enum": ["ignore", "report", "fail"],
  40504. "description": "Whether abandoned packages should be ignored, reported as problems or cause an audit failure."
  40505. }
  40506. }
  40507. },
  40508. "notify-on-install": {
  40509. "type": "boolean",
  40510. "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."
  40511. },
  40512. "github-protocols": {
  40513. "type": "array",
  40514. "description": "A list of protocols to use for github.com clones, in priority order, defaults to [\"https\", \"ssh\", \"git\"].",
  40515. "items": {
  40516. "type": "string"
  40517. }
  40518. },
  40519. "github-oauth": {
  40520. "type": "object",
  40521. "description": "An object of domain name => github API oauth tokens, typically {\"github.com\":\"<token>\"}.",
  40522. "additionalProperties": {
  40523. "type": "string"
  40524. }
  40525. },
  40526. "gitlab-oauth": {
  40527. "type": "object",
  40528. "description": "An object of domain name => gitlab API oauth tokens, typically {\"gitlab.com\":{\"expires-at\":\"<expiration date>\", \"refresh-token\":\"<refresh token>\", \"token\":\"<token>\"}}.",
  40529. "additionalProperties": {
  40530. "type": ["string", "object"],
  40531. "required": [ "token"],
  40532. "properties": {
  40533. "expires-at": {
  40534. "type": "integer",
  40535. "description": "The expiration date for this GitLab token"
  40536. },
  40537. "refresh-token": {
  40538. "type": "string",
  40539. "description": "The refresh token used for GitLab authentication"
  40540. },
  40541. "token": {
  40542. "type": "string",
  40543. "description": "The token used for GitLab authentication"
  40544. }
  40545. }
  40546. }
  40547. },
  40548. "gitlab-token": {
  40549. "type": "object",
  40550. "description": "An object of domain name => gitlab private tokens, typically {\"gitlab.com\":\"<token>\"}, or an object with username and token keys.",
  40551. "additionalProperties": {
  40552. "type": ["string", "object"],
  40553. "required": ["username", "token"],
  40554. "properties": {
  40555. "username": {
  40556. "type": "string",
  40557. "description": "The username used for GitLab authentication"
  40558. },
  40559. "token": {
  40560. "type": "string",
  40561. "description": "The token used for GitLab authentication"
  40562. }
  40563. }
  40564. }
  40565. },
  40566. "gitlab-protocol": {
  40567. "enum": ["git", "http", "https"],
  40568. "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."
  40569. },
  40570. "bearer": {
  40571. "type": "object",
  40572. "description": "An object of domain name => bearer authentication token, for example {\"example.com\":\"<token>\"}.",
  40573. "additionalProperties": {
  40574. "type": "string"
  40575. }
  40576. },
  40577. "disable-tls": {
  40578. "type": "boolean",
  40579. "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."
  40580. },
  40581. "secure-http": {
  40582. "type": "boolean",
  40583. "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."
  40584. },
  40585. "secure-svn-domains": {
  40586. "type": "array",
  40587. "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.",
  40588. "items": {
  40589. "type": "string"
  40590. }
  40591. },
  40592. "cafile": {
  40593. "type": "string",
  40594. "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."
  40595. },
  40596. "capath": {
  40597. "type": "string",
  40598. "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."
  40599. },
  40600. "http-basic": {
  40601. "type": "object",
  40602. "description": "An object of domain name => {\"username\": \"...\", \"password\": \"...\"}.",
  40603. "additionalProperties": {
  40604. "type": "object",
  40605. "required": ["username", "password"],
  40606. "properties": {
  40607. "username": {
  40608. "type": "string",
  40609. "description": "The username used for HTTP Basic authentication"
  40610. },
  40611. "password": {
  40612. "type": "string",
  40613. "description": "The password used for HTTP Basic authentication"
  40614. }
  40615. }
  40616. }
  40617. },
  40618. "store-auths": {
  40619. "type": ["string", "boolean"],
  40620. "description": "What to do after prompting for authentication, one of: true (store), false (do not store) or \"prompt\" (ask every time), defaults to prompt."
  40621. },
  40622. "vendor-dir": {
  40623. "type": "string",
  40624. "description": "The location where all packages are installed, defaults to \"vendor\"."
  40625. },
  40626. "bin-dir": {
  40627. "type": "string",
  40628. "description": "The location where all binaries are linked, defaults to \"vendor/bin\"."
  40629. },
  40630. "data-dir": {
  40631. "type": "string",
  40632. "description": "The location where old phar files are stored, defaults to \"$home\" except on XDG Base Directory compliant unixes."
  40633. },
  40634. "cache-dir": {
  40635. "type": "string",
  40636. "description": "The location where all caches are located, defaults to \"~/.composer/cache\" on *nix and \"%LOCALAPPDATA%\\Composer\" on windows."
  40637. },
  40638. "cache-files-dir": {
  40639. "type": "string",
  40640. "description": "The location where files (zip downloads) are cached, defaults to \"{$cache-dir}/files\"."
  40641. },
  40642. "cache-repo-dir": {
  40643. "type": "string",
  40644. "description": "The location where repo (git/hg repo clones) are cached, defaults to \"{$cache-dir}/repo\"."
  40645. },
  40646. "cache-vcs-dir": {
  40647. "type": "string",
  40648. "description": "The location where vcs infos (git clones, github api calls, etc. when reading vcs repos) are cached, defaults to \"{$cache-dir}/vcs\"."
  40649. },
  40650. "cache-ttl": {
  40651. "type": "integer",
  40652. "description": "The default cache time-to-live, defaults to 15552000 (6 months)."
  40653. },
  40654. "cache-files-ttl": {
  40655. "type": "integer",
  40656. "description": "The cache time-to-live for files, defaults to the value of cache-ttl."
  40657. },
  40658. "cache-files-maxsize": {
  40659. "type": ["string", "integer"],
  40660. "description": "The cache max size for the files cache, defaults to \"300MiB\"."
  40661. },
  40662. "cache-read-only": {
  40663. "type": ["boolean"],
  40664. "description": "Whether to use the Composer cache in read-only mode."
  40665. },
  40666. "bin-compat": {
  40667. "enum": ["auto", "full", "proxy", "symlink"],
  40668. "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)."
  40669. },
  40670. "discard-changes": {
  40671. "type": ["string", "boolean"],
  40672. "description": "The default style of handling dirty updates, defaults to false and can be any of true, false or \"stash\"."
  40673. },
  40674. "autoloader-suffix": {
  40675. "type": "string",
  40676. "description": "Optional string to be used as a suffix for the generated Composer autoloader. When null a random one will be generated."
  40677. },
  40678. "optimize-autoloader": {
  40679. "type": "boolean",
  40680. "description": "Always optimize when dumping the autoloader."
  40681. },
  40682. "prepend-autoloader": {
  40683. "type": "boolean",
  40684. "description": "If false, the composer autoloader will not be prepended to existing autoloaders, defaults to true."
  40685. },
  40686. "classmap-authoritative": {
  40687. "type": "boolean",
  40688. "description": "If true, the composer autoloader will not scan the filesystem for classes that are not found in the class map, defaults to false."
  40689. },
  40690. "apcu-autoloader": {
  40691. "type": "boolean",
  40692. "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."
  40693. },
  40694. "github-domains": {
  40695. "type": "array",
  40696. "description": "A list of domains to use in github mode. This is used for GitHub Enterprise setups, defaults to [\"github.com\"].",
  40697. "items": {
  40698. "type": "string"
  40699. }
  40700. },
  40701. "github-expose-hostname": {
  40702. "type": "boolean",
  40703. "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."
  40704. },
  40705. "gitlab-domains": {
  40706. "type": "array",
  40707. "description": "A list of domains to use in gitlab mode. This is used for custom GitLab setups, defaults to [\"gitlab.com\"].",
  40708. "items": {
  40709. "type": "string"
  40710. }
  40711. },
  40712. "bitbucket-oauth": {
  40713. "type": "object",
  40714. "description": "An object of domain name => {\"consumer-key\": \"...\", \"consumer-secret\": \"...\"}.",
  40715. "additionalProperties": {
  40716. "type": "object",
  40717. "required": ["consumer-key", "consumer-secret"],
  40718. "properties": {
  40719. "consumer-key": {
  40720. "type": "string",
  40721. "description": "The consumer-key used for OAuth authentication"
  40722. },
  40723. "consumer-secret": {
  40724. "type": "string",
  40725. "description": "The consumer-secret used for OAuth authentication"
  40726. },
  40727. "access-token": {
  40728. "type": "string",
  40729. "description": "The OAuth token retrieved from Bitbucket's API, this is written by Composer and you should not set it nor modify it."
  40730. },
  40731. "access-token-expiration": {
  40732. "type": "integer",
  40733. "description": "The generated token's expiration timestamp, this is written by Composer and you should not set it nor modify it."
  40734. }
  40735. }
  40736. }
  40737. },
  40738. "use-github-api": {
  40739. "type": "boolean",
  40740. "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."
  40741. },
  40742. "archive-format": {
  40743. "type": "string",
  40744. "description": "The default archiving format when not provided on cli, defaults to \"tar\"."
  40745. },
  40746. "archive-dir": {
  40747. "type": "string",
  40748. "description": "The default archive path when not provided on cli, defaults to \".\"."
  40749. },
  40750. "htaccess-protect": {
  40751. "type": "boolean",
  40752. "description": "Defaults to true. If set to false, Composer will not create .htaccess files in the composer home, cache, and data directories."
  40753. },
  40754. "sort-packages": {
  40755. "type": "boolean",
  40756. "description": "Defaults to false. If set to true, Composer will sort packages when adding/updating a new dependency."
  40757. },
  40758. "lock": {
  40759. "type": "boolean",
  40760. "description": "Defaults to true. If set to false, Composer will not create a composer.lock file."
  40761. },
  40762. "platform-check": {
  40763. "type": ["boolean", "string"],
  40764. "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."
  40765. }
  40766. }
  40767. },
  40768. "extra": {
  40769. "type": ["object", "array"],
  40770. "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.",
  40771. "additionalProperties": true
  40772. },
  40773. "scripts": {
  40774. "type": ["object"],
  40775. "description": "Script listeners that will be executed before/after some events.",
  40776. "properties": {
  40777. "pre-install-cmd": {
  40778. "type": ["array", "string"],
  40779. "description": "Occurs before the install command is executed, contains one or more Class::method callables or shell commands."
  40780. },
  40781. "post-install-cmd": {
  40782. "type": ["array", "string"],
  40783. "description": "Occurs after the install command is executed, contains one or more Class::method callables or shell commands."
  40784. },
  40785. "pre-update-cmd": {
  40786. "type": ["array", "string"],
  40787. "description": "Occurs before the update command is executed, contains one or more Class::method callables or shell commands."
  40788. },
  40789. "post-update-cmd": {
  40790. "type": ["array", "string"],
  40791. "description": "Occurs after the update command is executed, contains one or more Class::method callables or shell commands."
  40792. },
  40793. "pre-status-cmd": {
  40794. "type": ["array", "string"],
  40795. "description": "Occurs before the status command is executed, contains one or more Class::method callables or shell commands."
  40796. },
  40797. "post-status-cmd": {
  40798. "type": ["array", "string"],
  40799. "description": "Occurs after the status command is executed, contains one or more Class::method callables or shell commands."
  40800. },
  40801. "pre-package-install": {
  40802. "type": ["array", "string"],
  40803. "description": "Occurs before a package is installed, contains one or more Class::method callables or shell commands."
  40804. },
  40805. "post-package-install": {
  40806. "type": ["array", "string"],
  40807. "description": "Occurs after a package is installed, contains one or more Class::method callables or shell commands."
  40808. },
  40809. "pre-package-update": {
  40810. "type": ["array", "string"],
  40811. "description": "Occurs before a package is updated, contains one or more Class::method callables or shell commands."
  40812. },
  40813. "post-package-update": {
  40814. "type": ["array", "string"],
  40815. "description": "Occurs after a package is updated, contains one or more Class::method callables or shell commands."
  40816. },
  40817. "pre-package-uninstall": {
  40818. "type": ["array", "string"],
  40819. "description": "Occurs before a package has been uninstalled, contains one or more Class::method callables or shell commands."
  40820. },
  40821. "post-package-uninstall": {
  40822. "type": ["array", "string"],
  40823. "description": "Occurs after a package has been uninstalled, contains one or more Class::method callables or shell commands."
  40824. },
  40825. "pre-autoload-dump": {
  40826. "type": ["array", "string"],
  40827. "description": "Occurs before the autoloader is dumped, contains one or more Class::method callables or shell commands."
  40828. },
  40829. "post-autoload-dump": {
  40830. "type": ["array", "string"],
  40831. "description": "Occurs after the autoloader is dumped, contains one or more Class::method callables or shell commands."
  40832. },
  40833. "post-root-package-install": {
  40834. "type": ["array", "string"],
  40835. "description": "Occurs after the root-package is installed, contains one or more Class::method callables or shell commands."
  40836. },
  40837. "post-create-project-cmd": {
  40838. "type": ["array", "string"],
  40839. "description": "Occurs after the create-project command is executed, contains one or more Class::method callables or shell commands."
  40840. }
  40841. }
  40842. },
  40843. "scripts-descriptions": {
  40844. "type": ["object"],
  40845. "description": "Descriptions for custom commands, shown in console help.",
  40846. "additionalProperties": {
  40847. "type": "string"
  40848. }
  40849. }
  40850. },
  40851. "definitions": {
  40852. "authors": {
  40853. "type": "array",
  40854. "description": "List of authors that contributed to the package. This is typically the main maintainers, not the full list.",
  40855. "items": {
  40856. "type": "object",
  40857. "additionalProperties": false,
  40858. "required": [ "name"],
  40859. "properties": {
  40860. "name": {
  40861. "type": "string",
  40862. "description": "Full name of the author."
  40863. },
  40864. "email": {
  40865. "type": "string",
  40866. "description": "Email address of the author.",
  40867. "format": "email"
  40868. },
  40869. "homepage": {
  40870. "type": "string",
  40871. "description": "Homepage URL for the author.",
  40872. "format": "uri"
  40873. },
  40874. "role": {
  40875. "type": "string",
  40876. "description": "Author's role in the project."
  40877. }
  40878. }
  40879. }
  40880. },
  40881. "autoload": {
  40882. "type": "object",
  40883. "description": "Description of how the package can be autoloaded.",
  40884. "properties": {
  40885. "psr-0": {
  40886. "type": "object",
  40887. "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.",
  40888. "additionalProperties": {
  40889. "type": ["string", "array"],
  40890. "items": {
  40891. "type": "string"
  40892. }
  40893. }
  40894. },
  40895. "psr-4": {
  40896. "type": "object",
  40897. "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.",
  40898. "additionalProperties": {
  40899. "type": ["string", "array"],
  40900. "items": {
  40901. "type": "string"
  40902. }
  40903. }
  40904. },
  40905. "classmap": {
  40906. "type": "array",
  40907. "description": "This is an array of paths that contain classes to be included in the class-map generation process."
  40908. },
  40909. "files": {
  40910. "type": "array",
  40911. "description": "This is an array of files that are always required on every request."
  40912. },
  40913. "exclude-from-classmap": {
  40914. "type": "array",
  40915. "description": "This is an array of patterns to exclude from autoload classmap generation. (e.g. \"exclude-from-classmap\": [\"/test/\", \"/tests/\", \"/Tests/\"]"
  40916. }
  40917. }
  40918. },
  40919. "repository": {
  40920. "type": "object",
  40921. "anyOf": [
  40922. { "$ref": "#/definitions/composer-repository" },
  40923. { "$ref": "#/definitions/vcs-repository" },
  40924. { "$ref": "#/definitions/path-repository" },
  40925. { "$ref": "#/definitions/artifact-repository" },
  40926. { "$ref": "#/definitions/pear-repository" },
  40927. { "$ref": "#/definitions/package-repository" }
  40928. ]
  40929. },
  40930. "composer-repository": {
  40931. "type": "object",
  40932. "required": ["type", "url"],
  40933. "properties": {
  40934. "type": { "type": "string", "enum": ["composer"] },
  40935. "url": { "type": "string" },
  40936. "canonical": { "type": "boolean" },
  40937. "only": {
  40938. "type": "array",
  40939. "items": {
  40940. "type": "string"
  40941. }
  40942. },
  40943. "exclude": {
  40944. "type": "array",
  40945. "items": {
  40946. "type": "string"
  40947. }
  40948. },
  40949. "options": {
  40950. "type": "object",
  40951. "additionalProperties": true
  40952. },
  40953. "allow_ssl_downgrade": { "type": "boolean" },
  40954. "force-lazy-providers": { "type": "boolean" }
  40955. }
  40956. },
  40957. "vcs-repository": {
  40958. "type": "object",
  40959. "required": ["type", "url"],
  40960. "properties": {
  40961. "type": { "type": "string", "enum": ["vcs", "github", "git", "gitlab", "bitbucket", "git-bitbucket", "hg", "fossil", "perforce", "svn"] },
  40962. "url": { "type": "string" },
  40963. "canonical": { "type": "boolean" },
  40964. "only": {
  40965. "type": "array",
  40966. "items": {
  40967. "type": "string"
  40968. }
  40969. },
  40970. "exclude": {
  40971. "type": "array",
  40972. "items": {
  40973. "type": "string"
  40974. }
  40975. },
  40976. "no-api": { "type": "boolean" },
  40977. "secure-http": { "type": "boolean" },
  40978. "svn-cache-credentials": { "type": "boolean" },
  40979. "trunk-path": { "type": ["string", "boolean"] },
  40980. "branches-path": { "type": ["string", "boolean"] },
  40981. "tags-path": { "type": ["string", "boolean"] },
  40982. "package-path": { "type": "string" },
  40983. "depot": { "type": "string" },
  40984. "branch": { "type": "string" },
  40985. "unique_perforce_client_name": { "type": "string" },
  40986. "p4user": { "type": "string" },
  40987. "p4password": { "type": "string" }
  40988. }
  40989. },
  40990. "path-repository": {
  40991. "type": "object",
  40992. "required": ["type", "url"],
  40993. "properties": {
  40994. "type": { "type": "string", "enum": ["path"] },
  40995. "url": { "type": "string" },
  40996. "canonical": { "type": "boolean" },
  40997. "only": {
  40998. "type": "array",
  40999. "items": {
  41000. "type": "string"
  41001. }
  41002. },
  41003. "exclude": {
  41004. "type": "array",
  41005. "items": {
  41006. "type": "string"
  41007. }
  41008. },
  41009. "options": {
  41010. "type": "object",
  41011. "properties": {
  41012. "symlink": { "type": ["boolean", "null"] }
  41013. },
  41014. "additionalProperties": true
  41015. }
  41016. }
  41017. },
  41018. "artifact-repository": {
  41019. "type": "object",
  41020. "required": ["type", "url"],
  41021. "properties": {
  41022. "type": { "type": "string", "enum": ["artifact"] },
  41023. "url": { "type": "string" },
  41024. "canonical": { "type": "boolean" },
  41025. "only": {
  41026. "type": "array",
  41027. "items": {
  41028. "type": "string"
  41029. }
  41030. },
  41031. "exclude": {
  41032. "type": "array",
  41033. "items": {
  41034. "type": "string"
  41035. }
  41036. }
  41037. }
  41038. },
  41039. "pear-repository": {
  41040. "type": "object",
  41041. "required": ["type", "url"],
  41042. "properties": {
  41043. "type": { "type": "string", "enum": ["pear"] },
  41044. "url": { "type": "string" },
  41045. "canonical": { "type": "boolean" },
  41046. "only": {
  41047. "type": "array",
  41048. "items": {
  41049. "type": "string"
  41050. }
  41051. },
  41052. "exclude": {
  41053. "type": "array",
  41054. "items": {
  41055. "type": "string"
  41056. }
  41057. },
  41058. "vendor-alias": { "type": "string" }
  41059. }
  41060. },
  41061. "package-repository": {
  41062. "type": "object",
  41063. "required": ["type", "package"],
  41064. "properties": {
  41065. "type": { "type": "string", "enum": ["package"] },
  41066. "canonical": { "type": "boolean" },
  41067. "only": {
  41068. "type": "array",
  41069. "items": {
  41070. "type": "string"
  41071. }
  41072. },
  41073. "exclude": {
  41074. "type": "array",
  41075. "items": {
  41076. "type": "string"
  41077. }
  41078. },
  41079. "package": {
  41080. "oneOf": [
  41081. { "$ref": "#/definitions/inline-package" },
  41082. {
  41083. "type": "array",
  41084. "items": { "$ref": "#/definitions/inline-package" }
  41085. }
  41086. ]
  41087. }
  41088. }
  41089. },
  41090. "inline-package": {
  41091. "type": "object",
  41092. "required": ["name", "version"],
  41093. "properties": {
  41094. "name": {
  41095. "type": "string",
  41096. "description": "Package name, including 'vendor-name/' prefix."
  41097. },
  41098. "type": {
  41099. "type": "string"
  41100. },
  41101. "target-dir": {
  41102. "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.",
  41103. "type": "string"
  41104. },
  41105. "description": {
  41106. "type": "string"
  41107. },
  41108. "keywords": {
  41109. "type": "array",
  41110. "items": {
  41111. "type": "string"
  41112. }
  41113. },
  41114. "homepage": {
  41115. "type": "string",
  41116. "format": "uri"
  41117. },
  41118. "version": {
  41119. "type": "string"
  41120. },
  41121. "time": {
  41122. "type": "string"
  41123. },
  41124. "license": {
  41125. "type": [
  41126. "string",
  41127. "array"
  41128. ]
  41129. },
  41130. "authors": {
  41131. "$ref": "#/definitions/authors"
  41132. },
  41133. "require": {
  41134. "type": "object",
  41135. "additionalProperties": {
  41136. "type": "string"
  41137. }
  41138. },
  41139. "replace": {
  41140. "type": "object",
  41141. "additionalProperties": {
  41142. "type": "string"
  41143. }
  41144. },
  41145. "conflict": {
  41146. "type": "object",
  41147. "additionalProperties": {
  41148. "type": "string"
  41149. }
  41150. },
  41151. "provide": {
  41152. "type": "object",
  41153. "additionalProperties": {
  41154. "type": "string"
  41155. }
  41156. },
  41157. "require-dev": {
  41158. "type": "object",
  41159. "additionalProperties": {
  41160. "type": "string"
  41161. }
  41162. },
  41163. "suggest": {
  41164. "type": "object",
  41165. "additionalProperties": {
  41166. "type": "string"
  41167. }
  41168. },
  41169. "extra": {
  41170. "type": ["object", "array"],
  41171. "additionalProperties": true
  41172. },
  41173. "autoload": {
  41174. "$ref": "#/definitions/autoload"
  41175. },
  41176. "archive": {
  41177. "type": ["object"],
  41178. "properties": {
  41179. "exclude": {
  41180. "type": "array"
  41181. }
  41182. }
  41183. },
  41184. "bin": {
  41185. "type": ["string", "array"],
  41186. "description": "A set of files, or a single file, that should be treated as binaries and symlinked into bin-dir (from config).",
  41187. "items": {
  41188. "type": "string"
  41189. }
  41190. },
  41191. "include-path": {
  41192. "type": ["array"],
  41193. "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.",
  41194. "items": {
  41195. "type": "string"
  41196. }
  41197. },
  41198. "source": {
  41199. "$ref": "#/definitions/source"
  41200. },
  41201. "dist": {
  41202. "$ref": "#/definitions/dist"
  41203. }
  41204. },
  41205. "additionalProperties": true
  41206. },
  41207. "source": {
  41208. "type": "object",
  41209. "required": ["type", "url", "reference"],
  41210. "properties": {
  41211. "type": {
  41212. "type": "string"
  41213. },
  41214. "url": {
  41215. "type": "string"
  41216. },
  41217. "reference": {
  41218. "type": "string"
  41219. },
  41220. "mirrors": {
  41221. "type": "array"
  41222. }
  41223. }
  41224. },
  41225. "dist": {
  41226. "type": "object",
  41227. "required": ["type", "url"],
  41228. "properties": {
  41229. "type": {
  41230. "type": "string"
  41231. },
  41232. "url": {
  41233. "type": "string"
  41234. },
  41235. "reference": {
  41236. "type": "string"
  41237. },
  41238. "shasum": {
  41239. "type": "string"
  41240. },
  41241. "mirrors": {
  41242. "type": "array"
  41243. }
  41244. }
  41245. }
  41246. }
  41247. }
  41248. <?php
  41249. if (PHP_VERSION_ID < 50600) {
  41250. if (!headers_sent()) {
  41251. header('HTTP/1.1 500 Internal Server Error');
  41252. }
  41253. $err = '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;
  41254. if (!ini_get('display_errors')) {
  41255. if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
  41256. fwrite(STDERR, $err);
  41257. } elseif (!headers_sent()) {
  41258. echo $err;
  41259. }
  41260. }
  41261. trigger_error(
  41262. $err,
  41263. E_USER_ERROR
  41264. );
  41265. }
  41266. require_once __DIR__ . '/composer/autoload_real.php';
  41267. return ComposerAutoloaderInitComposerPhar1702056746::getLoader();
  41268. <?php
  41269. namespace Composer\Autoload;
  41270. class ClassLoader
  41271. {
  41272. private static $includeFile;
  41273. private $vendorDir;
  41274. private $prefixLengthsPsr4 = array();
  41275. private $prefixDirsPsr4 = array();
  41276. private $fallbackDirsPsr4 = array();
  41277. private $prefixesPsr0 = array();
  41278. private $fallbackDirsPsr0 = array();
  41279. private $useIncludePath = false;
  41280. private $classMap = array();
  41281. private $classMapAuthoritative = false;
  41282. private $missingClasses = array();
  41283. private $apcuPrefix;
  41284. private static $registeredLoaders = array();
  41285. public function __construct($vendorDir = null)
  41286. {
  41287. $this->vendorDir = $vendorDir;
  41288. self::initializeIncludeClosure();
  41289. }
  41290. public function getPrefixes()
  41291. {
  41292. if (!empty($this->prefixesPsr0)) {
  41293. return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
  41294. }
  41295. return array();
  41296. }
  41297. public function getPrefixesPsr4()
  41298. {
  41299. return $this->prefixDirsPsr4;
  41300. }
  41301. public function getFallbackDirs()
  41302. {
  41303. return $this->fallbackDirsPsr0;
  41304. }
  41305. public function getFallbackDirsPsr4()
  41306. {
  41307. return $this->fallbackDirsPsr4;
  41308. }
  41309. public function getClassMap()
  41310. {
  41311. return $this->classMap;
  41312. }
  41313. public function addClassMap(array $classMap)
  41314. {
  41315. if ($this->classMap) {
  41316. $this->classMap = array_merge($this->classMap, $classMap);
  41317. } else {
  41318. $this->classMap = $classMap;
  41319. }
  41320. }
  41321. public function add($prefix, $paths, $prepend = false)
  41322. {
  41323. $paths = (array) $paths;
  41324. if (!$prefix) {
  41325. if ($prepend) {
  41326. $this->fallbackDirsPsr0 = array_merge(
  41327. $paths,
  41328. $this->fallbackDirsPsr0
  41329. );
  41330. } else {
  41331. $this->fallbackDirsPsr0 = array_merge(
  41332. $this->fallbackDirsPsr0,
  41333. $paths
  41334. );
  41335. }
  41336. return;
  41337. }
  41338. $first = $prefix[0];
  41339. if (!isset($this->prefixesPsr0[$first][$prefix])) {
  41340. $this->prefixesPsr0[$first][$prefix] = $paths;
  41341. return;
  41342. }
  41343. if ($prepend) {
  41344. $this->prefixesPsr0[$first][$prefix] = array_merge(
  41345. $paths,
  41346. $this->prefixesPsr0[$first][$prefix]
  41347. );
  41348. } else {
  41349. $this->prefixesPsr0[$first][$prefix] = array_merge(
  41350. $this->prefixesPsr0[$first][$prefix],
  41351. $paths
  41352. );
  41353. }
  41354. }
  41355. public function addPsr4($prefix, $paths, $prepend = false)
  41356. {
  41357. $paths = (array) $paths;
  41358. if (!$prefix) {
  41359. if ($prepend) {
  41360. $this->fallbackDirsPsr4 = array_merge(
  41361. $paths,
  41362. $this->fallbackDirsPsr4
  41363. );
  41364. } else {
  41365. $this->fallbackDirsPsr4 = array_merge(
  41366. $this->fallbackDirsPsr4,
  41367. $paths
  41368. );
  41369. }
  41370. } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
  41371. $length = strlen($prefix);
  41372. if ('\\' !== $prefix[$length - 1]) {
  41373. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  41374. }
  41375. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  41376. $this->prefixDirsPsr4[$prefix] = $paths;
  41377. } elseif ($prepend) {
  41378. $this->prefixDirsPsr4[$prefix] = array_merge(
  41379. $paths,
  41380. $this->prefixDirsPsr4[$prefix]
  41381. );
  41382. } else {
  41383. $this->prefixDirsPsr4[$prefix] = array_merge(
  41384. $this->prefixDirsPsr4[$prefix],
  41385. $paths
  41386. );
  41387. }
  41388. }
  41389. public function set($prefix, $paths)
  41390. {
  41391. if (!$prefix) {
  41392. $this->fallbackDirsPsr0 = (array) $paths;
  41393. } else {
  41394. $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
  41395. }
  41396. }
  41397. public function setPsr4($prefix, $paths)
  41398. {
  41399. if (!$prefix) {
  41400. $this->fallbackDirsPsr4 = (array) $paths;
  41401. } else {
  41402. $length = strlen($prefix);
  41403. if ('\\' !== $prefix[$length - 1]) {
  41404. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  41405. }
  41406. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  41407. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  41408. }
  41409. }
  41410. public function setUseIncludePath($useIncludePath)
  41411. {
  41412. $this->useIncludePath = $useIncludePath;
  41413. }
  41414. public function getUseIncludePath()
  41415. {
  41416. return $this->useIncludePath;
  41417. }
  41418. public function setClassMapAuthoritative($classMapAuthoritative)
  41419. {
  41420. $this->classMapAuthoritative = $classMapAuthoritative;
  41421. }
  41422. public function isClassMapAuthoritative()
  41423. {
  41424. return $this->classMapAuthoritative;
  41425. }
  41426. public function setApcuPrefix($apcuPrefix)
  41427. {
  41428. $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
  41429. }
  41430. public function getApcuPrefix()
  41431. {
  41432. return $this->apcuPrefix;
  41433. }
  41434. public function register($prepend = false)
  41435. {
  41436. spl_autoload_register(array($this, 'loadClass'), true, $prepend);
  41437. if (null === $this->vendorDir) {
  41438. return;
  41439. }
  41440. if ($prepend) {
  41441. self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
  41442. } else {
  41443. unset(self::$registeredLoaders[$this->vendorDir]);
  41444. self::$registeredLoaders[$this->vendorDir] = $this;
  41445. }
  41446. }
  41447. public function unregister()
  41448. {
  41449. spl_autoload_unregister(array($this, 'loadClass'));
  41450. if (null !== $this->vendorDir) {
  41451. unset(self::$registeredLoaders[$this->vendorDir]);
  41452. }
  41453. }
  41454. public function loadClass($class)
  41455. {
  41456. if ($file = $this->findFile($class)) {
  41457. $includeFile = self::$includeFile;
  41458. $includeFile($file);
  41459. return true;
  41460. }
  41461. return null;
  41462. }
  41463. public function findFile($class)
  41464. {
  41465. if (isset($this->classMap[$class])) {
  41466. return $this->classMap[$class];
  41467. }
  41468. if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
  41469. return false;
  41470. }
  41471. if (null !== $this->apcuPrefix) {
  41472. $file = apcu_fetch($this->apcuPrefix.$class, $hit);
  41473. if ($hit) {
  41474. return $file;
  41475. }
  41476. }
  41477. $file = $this->findFileWithExtension($class, '.php');
  41478. if (false === $file && defined('HHVM_VERSION')) {
  41479. $file = $this->findFileWithExtension($class, '.hh');
  41480. }
  41481. if (null !== $this->apcuPrefix) {
  41482. apcu_add($this->apcuPrefix.$class, $file);
  41483. }
  41484. if (false === $file) {
  41485. $this->missingClasses[$class] = true;
  41486. }
  41487. return $file;
  41488. }
  41489. public static function getRegisteredLoaders()
  41490. {
  41491. return self::$registeredLoaders;
  41492. }
  41493. private function findFileWithExtension($class, $ext)
  41494. {
  41495. $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
  41496. $first = $class[0];
  41497. if (isset($this->prefixLengthsPsr4[$first])) {
  41498. $subPath = $class;
  41499. while (false !== $lastPos = strrpos($subPath, '\\')) {
  41500. $subPath = substr($subPath, 0, $lastPos);
  41501. $search = $subPath . '\\';
  41502. if (isset($this->prefixDirsPsr4[$search])) {
  41503. $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
  41504. foreach ($this->prefixDirsPsr4[$search] as $dir) {
  41505. if (file_exists($file = $dir . $pathEnd)) {
  41506. return $file;
  41507. }
  41508. }
  41509. }
  41510. }
  41511. }
  41512. foreach ($this->fallbackDirsPsr4 as $dir) {
  41513. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
  41514. return $file;
  41515. }
  41516. }
  41517. if (false !== $pos = strrpos($class, '\\')) {
  41518. $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
  41519. . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
  41520. } else {
  41521. $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
  41522. }
  41523. if (isset($this->prefixesPsr0[$first])) {
  41524. foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
  41525. if (0 === strpos($class, $prefix)) {
  41526. foreach ($dirs as $dir) {
  41527. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  41528. return $file;
  41529. }
  41530. }
  41531. }
  41532. }
  41533. }
  41534. foreach ($this->fallbackDirsPsr0 as $dir) {
  41535. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  41536. return $file;
  41537. }
  41538. }
  41539. if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
  41540. return $file;
  41541. }
  41542. return false;
  41543. }
  41544. private static function initializeIncludeClosure()
  41545. {
  41546. if (self::$includeFile !== null) {
  41547. return;
  41548. }
  41549. self::$includeFile = \Closure::bind(static function($file) {
  41550. include $file;
  41551. }, null, null);
  41552. }
  41553. }
  41554. <?php
  41555. namespace Composer;
  41556. use Composer\Autoload\ClassLoader;
  41557. use Composer\Semver\VersionParser;
  41558. class InstalledVersions
  41559. {
  41560. private static $installed;
  41561. private static $canGetVendors;
  41562. private static $installedByVendor = array();
  41563. public static function getInstalledPackages()
  41564. {
  41565. $packages = array();
  41566. foreach (self::getInstalled() as $installed) {
  41567. $packages[] = array_keys($installed['versions']);
  41568. }
  41569. if (1 === \count($packages)) {
  41570. return $packages[0];
  41571. }
  41572. return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
  41573. }
  41574. public static function getInstalledPackagesByType($type)
  41575. {
  41576. $packagesByType = array();
  41577. foreach (self::getInstalled() as $installed) {
  41578. foreach ($installed['versions'] as $name => $package) {
  41579. if (isset($package['type']) && $package['type'] === $type) {
  41580. $packagesByType[] = $name;
  41581. }
  41582. }
  41583. }
  41584. return $packagesByType;
  41585. }
  41586. public static function isInstalled($packageName, $includeDevRequirements = true)
  41587. {
  41588. foreach (self::getInstalled() as $installed) {
  41589. if (isset($installed['versions'][$packageName])) {
  41590. return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
  41591. }
  41592. }
  41593. return false;
  41594. }
  41595. public static function satisfies(VersionParser $parser, $packageName, $constraint)
  41596. {
  41597. $constraint = $parser->parseConstraints((string) $constraint);
  41598. $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
  41599. return $provided->matches($constraint);
  41600. }
  41601. public static function getVersionRanges($packageName)
  41602. {
  41603. foreach (self::getInstalled() as $installed) {
  41604. if (!isset($installed['versions'][$packageName])) {
  41605. continue;
  41606. }
  41607. $ranges = array();
  41608. if (isset($installed['versions'][$packageName]['pretty_version'])) {
  41609. $ranges[] = $installed['versions'][$packageName]['pretty_version'];
  41610. }
  41611. if (array_key_exists('aliases', $installed['versions'][$packageName])) {
  41612. $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
  41613. }
  41614. if (array_key_exists('replaced', $installed['versions'][$packageName])) {
  41615. $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
  41616. }
  41617. if (array_key_exists('provided', $installed['versions'][$packageName])) {
  41618. $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
  41619. }
  41620. return implode(' || ', $ranges);
  41621. }
  41622. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  41623. }
  41624. public static function getVersion($packageName)
  41625. {
  41626. foreach (self::getInstalled() as $installed) {
  41627. if (!isset($installed['versions'][$packageName])) {
  41628. continue;
  41629. }
  41630. if (!isset($installed['versions'][$packageName]['version'])) {
  41631. return null;
  41632. }
  41633. return $installed['versions'][$packageName]['version'];
  41634. }
  41635. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  41636. }
  41637. public static function getPrettyVersion($packageName)
  41638. {
  41639. foreach (self::getInstalled() as $installed) {
  41640. if (!isset($installed['versions'][$packageName])) {
  41641. continue;
  41642. }
  41643. if (!isset($installed['versions'][$packageName]['pretty_version'])) {
  41644. return null;
  41645. }
  41646. return $installed['versions'][$packageName]['pretty_version'];
  41647. }
  41648. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  41649. }
  41650. public static function getReference($packageName)
  41651. {
  41652. foreach (self::getInstalled() as $installed) {
  41653. if (!isset($installed['versions'][$packageName])) {
  41654. continue;
  41655. }
  41656. if (!isset($installed['versions'][$packageName]['reference'])) {
  41657. return null;
  41658. }
  41659. return $installed['versions'][$packageName]['reference'];
  41660. }
  41661. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  41662. }
  41663. public static function getInstallPath($packageName)
  41664. {
  41665. foreach (self::getInstalled() as $installed) {
  41666. if (!isset($installed['versions'][$packageName])) {
  41667. continue;
  41668. }
  41669. return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
  41670. }
  41671. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  41672. }
  41673. public static function getRootPackage()
  41674. {
  41675. $installed = self::getInstalled();
  41676. return $installed[0]['root'];
  41677. }
  41678. public static function getRawData()
  41679. {
  41680. @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);
  41681. if (null === self::$installed) {
  41682. if (substr(__DIR__, -8, 1) !== 'C') {
  41683. self::$installed = include __DIR__ . '/installed.php';
  41684. } else {
  41685. self::$installed = array();
  41686. }
  41687. }
  41688. return self::$installed;
  41689. }
  41690. public static function getAllRawData()
  41691. {
  41692. return self::getInstalled();
  41693. }
  41694. public static function reload($data)
  41695. {
  41696. self::$installed = $data;
  41697. self::$installedByVendor = array();
  41698. }
  41699. private static function getInstalled()
  41700. {
  41701. if (null === self::$canGetVendors) {
  41702. self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
  41703. }
  41704. $installed = array();
  41705. if (self::$canGetVendors) {
  41706. foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
  41707. if (isset(self::$installedByVendor[$vendorDir])) {
  41708. $installed[] = self::$installedByVendor[$vendorDir];
  41709. } elseif (is_file($vendorDir.'/composer/installed.php')) {
  41710. $required = require $vendorDir.'/composer/installed.php';
  41711. $installed[] = self::$installedByVendor[$vendorDir] = $required;
  41712. if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
  41713. self::$installed = $installed[count($installed) - 1];
  41714. }
  41715. }
  41716. }
  41717. }
  41718. if (null === self::$installed) {
  41719. if (substr(__DIR__, -8, 1) !== 'C') {
  41720. $required = require __DIR__ . '/installed.php';
  41721. self::$installed = $required;
  41722. } else {
  41723. self::$installed = array();
  41724. }
  41725. }
  41726. if (self::$installed !== array()) {
  41727. $installed[] = self::$installed;
  41728. }
  41729. return $installed;
  41730. }
  41731. }
  41732. <?php
  41733. $vendorDir = dirname(__DIR__);
  41734. $baseDir = dirname($vendorDir);
  41735. return array(
  41736. 'Attribute' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
  41737. 'CURLStringFile' => $vendorDir . '/symfony/polyfill-php81/Resources/stubs/CURLStringFile.php',
  41738. 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
  41739. 'JsonException' => $vendorDir . '/symfony/polyfill-php73/Resources/stubs/JsonException.php',
  41740. 'Normalizer' => $vendorDir . '/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php',
  41741. 'PhpToken' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php',
  41742. 'ReturnTypeWillChange' => $vendorDir . '/symfony/polyfill-php81/Resources/stubs/ReturnTypeWillChange.php',
  41743. 'Stringable' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Stringable.php',
  41744. 'UnhandledMatchError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php',
  41745. 'ValueError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/ValueError.php',
  41746. );
  41747. <?php
  41748. $vendorDir = dirname(__DIR__);
  41749. $baseDir = dirname($vendorDir);
  41750. return array(
  41751. 'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php',
  41752. '6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php',
  41753. '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
  41754. '320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
  41755. '8825ede83f2f289127722d4e842cf7e8' => $vendorDir . '/symfony/polyfill-intl-grapheme/bootstrap.php',
  41756. 'e69f7f6ee287b969198c3c9d6777bd38' => $vendorDir . '/symfony/polyfill-intl-normalizer/bootstrap.php',
  41757. '0d59ee240a4cd96ddbb4ff164fccea4d' => $vendorDir . '/symfony/polyfill-php73/bootstrap.php',
  41758. 'b6b991a57620e2fb6b2f66f03fe9ddc2' => $vendorDir . '/symfony/string/Resources/functions.php',
  41759. 'ad155f8f1cf0d418fe49e248db8c661b' => $vendorDir . '/react/promise/src/functions_include.php',
  41760. '23c18046f52bef3eea034657bafda50f' => $vendorDir . '/symfony/polyfill-php81/bootstrap.php',
  41761. );
  41762. <?php
  41763. $vendorDir = dirname(__DIR__);
  41764. $baseDir = dirname($vendorDir);
  41765. return array(
  41766. );
  41767. <?php
  41768. $vendorDir = dirname(__DIR__);
  41769. $baseDir = dirname($vendorDir);
  41770. return array(
  41771. 'Symfony\\Polyfill\\Php81\\' => array($vendorDir . '/symfony/polyfill-php81'),
  41772. 'Symfony\\Polyfill\\Php80\\' => array($vendorDir . '/symfony/polyfill-php80'),
  41773. 'Symfony\\Polyfill\\Php73\\' => array($vendorDir . '/symfony/polyfill-php73'),
  41774. 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
  41775. 'Symfony\\Polyfill\\Intl\\Normalizer\\' => array($vendorDir . '/symfony/polyfill-intl-normalizer'),
  41776. 'Symfony\\Polyfill\\Intl\\Grapheme\\' => array($vendorDir . '/symfony/polyfill-intl-grapheme'),
  41777. 'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
  41778. 'Symfony\\Contracts\\Service\\' => array($vendorDir . '/symfony/service-contracts'),
  41779. 'Symfony\\Component\\String\\' => array($vendorDir . '/symfony/string'),
  41780. 'Symfony\\Component\\Process\\' => array($vendorDir . '/symfony/process'),
  41781. 'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'),
  41782. 'Symfony\\Component\\Filesystem\\' => array($vendorDir . '/symfony/filesystem'),
  41783. 'Symfony\\Component\\Console\\' => array($vendorDir . '/symfony/console'),
  41784. 'Seld\\Signal\\' => array($vendorDir . '/seld/signal-handler/src'),
  41785. 'Seld\\PharUtils\\' => array($vendorDir . '/seld/phar-utils/src'),
  41786. 'Seld\\JsonLint\\' => array($vendorDir . '/seld/jsonlint/src/Seld/JsonLint'),
  41787. 'React\\Promise\\' => array($vendorDir . '/react/promise/src'),
  41788. 'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
  41789. 'Psr\\Container\\' => array($vendorDir . '/psr/container/src'),
  41790. 'JsonSchema\\' => array($vendorDir . '/justinrainbow/json-schema/src/JsonSchema'),
  41791. 'Composer\\XdebugHandler\\' => array($vendorDir . '/composer/xdebug-handler/src'),
  41792. 'Composer\\Spdx\\' => array($vendorDir . '/composer/spdx-licenses/src'),
  41793. 'Composer\\Semver\\' => array($vendorDir . '/composer/semver/src'),
  41794. 'Composer\\Pcre\\' => array($vendorDir . '/composer/pcre/src'),
  41795. 'Composer\\MetadataMinifier\\' => array($vendorDir . '/composer/metadata-minifier/src'),
  41796. 'Composer\\ClassMapGenerator\\' => array($vendorDir . '/composer/class-map-generator/src'),
  41797. 'Composer\\CaBundle\\' => array($vendorDir . '/composer/ca-bundle/src'),
  41798. 'Composer\\' => array($baseDir . '/src/Composer'),
  41799. );
  41800. <?php
  41801. class ComposerAutoloaderInitComposerPhar1702056746
  41802. {
  41803. private static $loader;
  41804. public static function loadClassLoader($class)
  41805. {
  41806. if ('Composer\Autoload\ClassLoader' === $class) {
  41807. require __DIR__ . '/ClassLoader.php';
  41808. }
  41809. }
  41810. public static function getLoader()
  41811. {
  41812. if (null !== self::$loader) {
  41813. return self::$loader;
  41814. }
  41815. spl_autoload_register(array('ComposerAutoloaderInitComposerPhar1702056746', 'loadClassLoader'), true, true);
  41816. self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
  41817. spl_autoload_unregister(array('ComposerAutoloaderInitComposerPhar1702056746', 'loadClassLoader'));
  41818. require __DIR__ . '/autoload_static.php';
  41819. call_user_func(\Composer\Autoload\ComposerStaticInitComposerPhar1702056746::getInitializer($loader));
  41820. $loader->register(true);
  41821. $filesToLoad = \Composer\Autoload\ComposerStaticInitComposerPhar1702056746::$files;
  41822. $requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
  41823. if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  41824. $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
  41825. require $file;
  41826. }
  41827. }, null, null);
  41828. foreach ($filesToLoad as $fileIdentifier => $file) {
  41829. $requireFile($fileIdentifier, $file);
  41830. }
  41831. return $loader;
  41832. }
  41833. }
  41834. <?php
  41835. namespace Composer\Autoload;
  41836. class ComposerStaticInitComposerPhar1702056746
  41837. {
  41838. public static $files = array (
  41839. 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
  41840. '6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php',
  41841. '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
  41842. '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
  41843. '8825ede83f2f289127722d4e842cf7e8' => __DIR__ . '/..' . '/symfony/polyfill-intl-grapheme/bootstrap.php',
  41844. 'e69f7f6ee287b969198c3c9d6777bd38' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/bootstrap.php',
  41845. '0d59ee240a4cd96ddbb4ff164fccea4d' => __DIR__ . '/..' . '/symfony/polyfill-php73/bootstrap.php',
  41846. 'b6b991a57620e2fb6b2f66f03fe9ddc2' => __DIR__ . '/..' . '/symfony/string/Resources/functions.php',
  41847. 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
  41848. '23c18046f52bef3eea034657bafda50f' => __DIR__ . '/..' . '/symfony/polyfill-php81/bootstrap.php',
  41849. );
  41850. public static $prefixLengthsPsr4 = array (
  41851. 'S' =>
  41852. array (
  41853. 'Symfony\\Polyfill\\Php81\\' => 23,
  41854. 'Symfony\\Polyfill\\Php80\\' => 23,
  41855. 'Symfony\\Polyfill\\Php73\\' => 23,
  41856. 'Symfony\\Polyfill\\Mbstring\\' => 26,
  41857. 'Symfony\\Polyfill\\Intl\\Normalizer\\' => 33,
  41858. 'Symfony\\Polyfill\\Intl\\Grapheme\\' => 31,
  41859. 'Symfony\\Polyfill\\Ctype\\' => 23,
  41860. 'Symfony\\Contracts\\Service\\' => 26,
  41861. 'Symfony\\Component\\String\\' => 25,
  41862. 'Symfony\\Component\\Process\\' => 26,
  41863. 'Symfony\\Component\\Finder\\' => 25,
  41864. 'Symfony\\Component\\Filesystem\\' => 29,
  41865. 'Symfony\\Component\\Console\\' => 26,
  41866. 'Seld\\Signal\\' => 12,
  41867. 'Seld\\PharUtils\\' => 15,
  41868. 'Seld\\JsonLint\\' => 14,
  41869. ),
  41870. 'R' =>
  41871. array (
  41872. 'React\\Promise\\' => 14,
  41873. ),
  41874. 'P' =>
  41875. array (
  41876. 'Psr\\Log\\' => 8,
  41877. 'Psr\\Container\\' => 14,
  41878. ),
  41879. 'J' =>
  41880. array (
  41881. 'JsonSchema\\' => 11,
  41882. ),
  41883. 'C' =>
  41884. array (
  41885. 'Composer\\XdebugHandler\\' => 23,
  41886. 'Composer\\Spdx\\' => 14,
  41887. 'Composer\\Semver\\' => 16,
  41888. 'Composer\\Pcre\\' => 14,
  41889. 'Composer\\MetadataMinifier\\' => 26,
  41890. 'Composer\\ClassMapGenerator\\' => 27,
  41891. 'Composer\\CaBundle\\' => 18,
  41892. 'Composer\\' => 9,
  41893. ),
  41894. );
  41895. public static $prefixDirsPsr4 = array (
  41896. 'Symfony\\Polyfill\\Php81\\' =>
  41897. array (
  41898. 0 => __DIR__ . '/..' . '/symfony/polyfill-php81',
  41899. ),
  41900. 'Symfony\\Polyfill\\Php80\\' =>
  41901. array (
  41902. 0 => __DIR__ . '/..' . '/symfony/polyfill-php80',
  41903. ),
  41904. 'Symfony\\Polyfill\\Php73\\' =>
  41905. array (
  41906. 0 => __DIR__ . '/..' . '/symfony/polyfill-php73',
  41907. ),
  41908. 'Symfony\\Polyfill\\Mbstring\\' =>
  41909. array (
  41910. 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
  41911. ),
  41912. 'Symfony\\Polyfill\\Intl\\Normalizer\\' =>
  41913. array (
  41914. 0 => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer',
  41915. ),
  41916. 'Symfony\\Polyfill\\Intl\\Grapheme\\' =>
  41917. array (
  41918. 0 => __DIR__ . '/..' . '/symfony/polyfill-intl-grapheme',
  41919. ),
  41920. 'Symfony\\Polyfill\\Ctype\\' =>
  41921. array (
  41922. 0 => __DIR__ . '/..' . '/symfony/polyfill-ctype',
  41923. ),
  41924. 'Symfony\\Contracts\\Service\\' =>
  41925. array (
  41926. 0 => __DIR__ . '/..' . '/symfony/service-contracts',
  41927. ),
  41928. 'Symfony\\Component\\String\\' =>
  41929. array (
  41930. 0 => __DIR__ . '/..' . '/symfony/string',
  41931. ),
  41932. 'Symfony\\Component\\Process\\' =>
  41933. array (
  41934. 0 => __DIR__ . '/..' . '/symfony/process',
  41935. ),
  41936. 'Symfony\\Component\\Finder\\' =>
  41937. array (
  41938. 0 => __DIR__ . '/..' . '/symfony/finder',
  41939. ),
  41940. 'Symfony\\Component\\Filesystem\\' =>
  41941. array (
  41942. 0 => __DIR__ . '/..' . '/symfony/filesystem',
  41943. ),
  41944. 'Symfony\\Component\\Console\\' =>
  41945. array (
  41946. 0 => __DIR__ . '/..' . '/symfony/console',
  41947. ),
  41948. 'Seld\\Signal\\' =>
  41949. array (
  41950. 0 => __DIR__ . '/..' . '/seld/signal-handler/src',
  41951. ),
  41952. 'Seld\\PharUtils\\' =>
  41953. array (
  41954. 0 => __DIR__ . '/..' . '/seld/phar-utils/src',
  41955. ),
  41956. 'Seld\\JsonLint\\' =>
  41957. array (
  41958. 0 => __DIR__ . '/..' . '/seld/jsonlint/src/Seld/JsonLint',
  41959. ),
  41960. 'React\\Promise\\' =>
  41961. array (
  41962. 0 => __DIR__ . '/..' . '/react/promise/src',
  41963. ),
  41964. 'Psr\\Log\\' =>
  41965. array (
  41966. 0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
  41967. ),
  41968. 'Psr\\Container\\' =>
  41969. array (
  41970. 0 => __DIR__ . '/..' . '/psr/container/src',
  41971. ),
  41972. 'JsonSchema\\' =>
  41973. array (
  41974. 0 => __DIR__ . '/..' . '/justinrainbow/json-schema/src/JsonSchema',
  41975. ),
  41976. 'Composer\\XdebugHandler\\' =>
  41977. array (
  41978. 0 => __DIR__ . '/..' . '/composer/xdebug-handler/src',
  41979. ),
  41980. 'Composer\\Spdx\\' =>
  41981. array (
  41982. 0 => __DIR__ . '/..' . '/composer/spdx-licenses/src',
  41983. ),
  41984. 'Composer\\Semver\\' =>
  41985. array (
  41986. 0 => __DIR__ . '/..' . '/composer/semver/src',
  41987. ),
  41988. 'Composer\\Pcre\\' =>
  41989. array (
  41990. 0 => __DIR__ . '/..' . '/composer/pcre/src',
  41991. ),
  41992. 'Composer\\MetadataMinifier\\' =>
  41993. array (
  41994. 0 => __DIR__ . '/..' . '/composer/metadata-minifier/src',
  41995. ),
  41996. 'Composer\\ClassMapGenerator\\' =>
  41997. array (
  41998. 0 => __DIR__ . '/..' . '/composer/class-map-generator/src',
  41999. ),
  42000. 'Composer\\CaBundle\\' =>
  42001. array (
  42002. 0 => __DIR__ . '/..' . '/composer/ca-bundle/src',
  42003. ),
  42004. 'Composer\\' =>
  42005. array (
  42006. 0 => __DIR__ . '/../..' . '/src/Composer',
  42007. ),
  42008. );
  42009. public static $classMap = array (
  42010. 'Attribute' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
  42011. 'CURLStringFile' => __DIR__ . '/..' . '/symfony/polyfill-php81/Resources/stubs/CURLStringFile.php',
  42012. 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
  42013. 'JsonException' => __DIR__ . '/..' . '/symfony/polyfill-php73/Resources/stubs/JsonException.php',
  42014. 'Normalizer' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php',
  42015. 'PhpToken' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php',
  42016. 'ReturnTypeWillChange' => __DIR__ . '/..' . '/symfony/polyfill-php81/Resources/stubs/ReturnTypeWillChange.php',
  42017. 'Stringable' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Stringable.php',
  42018. 'UnhandledMatchError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php',
  42019. 'ValueError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/ValueError.php',
  42020. );
  42021. public static function getInitializer(ClassLoader $loader)
  42022. {
  42023. return \Closure::bind(function () use ($loader) {
  42024. $loader->prefixLengthsPsr4 = ComposerStaticInitComposerPhar1702056746::$prefixLengthsPsr4;
  42025. $loader->prefixDirsPsr4 = ComposerStaticInitComposerPhar1702056746::$prefixDirsPsr4;
  42026. $loader->classMap = ComposerStaticInitComposerPhar1702056746::$classMap;
  42027. }, null, ClassLoader::class);
  42028. }
  42029. }
  42030. Copyright (C) 2016 Composer
  42031. Permission is hereby granted, free of charge, to any person obtaining a copy of
  42032. this software and associated documentation files (the "Software"), to deal in
  42033. the Software without restriction, including without limitation the rights to
  42034. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  42035. of the Software, and to permit persons to whom the Software is furnished to do
  42036. so, subject to the following conditions:
  42037. The above copyright notice and this permission notice shall be included in all
  42038. copies or substantial portions of the Software.
  42039. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  42040. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  42041. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  42042. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  42043. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  42044. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  42045. SOFTWARE.
  42046. ##
  42047. ## Bundle of CA Root Certificates
  42048. ##
  42049. ## Certificate data from Mozilla as of: Tue Aug 22 03:12:04 2023 GMT
  42050. ##
  42051. ## This is a bundle of X.509 certificates of public Certificate Authorities
  42052. ## (CA). These were automatically extracted from Mozilla's root certificates
  42053. ## file (certdata.txt). This file can be found in the mozilla source tree:
  42054. ## https://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt
  42055. ##
  42056. ## It contains the certificates in PEM format and therefore
  42057. ## can be directly used with curl / libcurl / php_curl, or with
  42058. ## an Apache+mod_ssl webserver for SSL client authentication.
  42059. ## Just configure this file as the SSLCACertificateFile.
  42060. ##
  42061. ## Conversion done with mk-ca-bundle.pl version 1.29.
  42062. ## SHA256: 0ff137babc6a5561a9cfbe9f29558972e5b528202681b7d3803d03a3e82922bd
  42063. ##
  42064. GlobalSign Root CA
  42065. ==================
  42066. -----BEGIN CERTIFICATE-----
  42067. MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkGA1UEBhMCQkUx
  42068. GTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jvb3QgQ0ExGzAZBgNVBAMTEkds
  42069. b2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAwMDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNV
  42070. BAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYD
  42071. VQQDExJHbG9iYWxTaWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDa
  42072. DuaZjc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavpxy0Sy6sc
  42073. THAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp1Wrjsok6Vjk4bwY8iGlb
  42074. Kk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdGsnUOhugZitVtbNV4FpWi6cgKOOvyJBNP
  42075. c1STE4U6G7weNLWLBYy5d4ux2x8gkasJU26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrX
  42076. gzT/LCrBbBlDSgeF59N89iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV
  42077. HRMBAf8EBTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0BAQUF
  42078. AAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOzyj1hTdNGCbM+w6Dj
  42079. Y1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE38NflNUVyRRBnMRddWQVDf9VMOyG
  42080. j/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymPAbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhH
  42081. hm4qxFYxldBniYUr+WymXUadDKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveC
  42082. X4XSQRjbgbMEHMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==
  42083. -----END CERTIFICATE-----
  42084. Entrust.net Premium 2048 Secure Server CA
  42085. =========================================
  42086. -----BEGIN CERTIFICATE-----
  42087. MIIEKjCCAxKgAwIBAgIEOGPe+DANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChMLRW50cnVzdC5u
  42088. ZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9DUFNfMjA0OCBpbmNvcnAuIGJ5IHJlZi4gKGxp
  42089. bWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAxOTk5IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNV
  42090. BAMTKkVudHJ1c3QubmV0IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ICgyMDQ4KTAeFw05OTEyMjQx
  42091. NzUwNTFaFw0yOTA3MjQxNDE1MTJaMIG0MRQwEgYDVQQKEwtFbnRydXN0Lm5ldDFAMD4GA1UECxQ3
  42092. d3d3LmVudHJ1c3QubmV0L0NQU18yMDQ4IGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTEl
  42093. MCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEGA1UEAxMqRW50cnVzdC5u
  42094. ZXQgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgKDIwNDgpMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  42095. MIIBCgKCAQEArU1LqRKGsuqjIAcVFmQqK0vRvwtKTY7tgHalZ7d4QMBzQshowNtTK91euHaYNZOL
  42096. Gp18EzoOH1u3Hs/lJBQesYGpjX24zGtLA/ECDNyrpUAkAH90lKGdCCmziAv1h3edVc3kw37XamSr
  42097. hRSGlVuXMlBvPci6Zgzj/L24ScF2iUkZ/cCovYmjZy/Gn7xxGWC4LeksyZB2ZnuU4q941mVTXTzW
  42098. nLLPKQP5L6RQstRIzgUyVYr9smRMDuSYB3Xbf9+5CFVghTAp+XtIpGmG4zU/HoZdenoVve8AjhUi
  42099. VBcAkCaTvA5JaJG/+EfTnZVCwQ5N328mz8MYIWJmQ3DW1cAH4QIDAQABo0IwQDAOBgNVHQ8BAf8E
  42100. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUVeSB0RGAvtiJuQijMfmhJAkWuXAwDQYJ
  42101. KoZIhvcNAQEFBQADggEBADubj1abMOdTmXx6eadNl9cZlZD7Bh/KM3xGY4+WZiT6QBshJ8rmcnPy
  42102. T/4xmf3IDExoU8aAghOY+rat2l098c5u9hURlIIM7j+VrxGrD9cv3h8Dj1csHsm7mhpElesYT6Yf
  42103. zX1XEC+bBAlahLVu2B064dae0Wx5XnkcFMXj0EyTO2U87d89vqbllRrDtRnDvV5bu/8j72gZyxKT
  42104. J1wDLW8w0B62GqzeWvfRqqgnpv55gcR5mTNXuhKwqeBCbJPKVt7+bYQLCIt+jerXmCHG8+c8eS9e
  42105. nNFMFY3h7CI3zJpDC5fcgJCNs2ebb0gIFVbPv/ErfF6adulZkMV8gzURZVE=
  42106. -----END CERTIFICATE-----
  42107. Baltimore CyberTrust Root
  42108. =========================
  42109. -----BEGIN CERTIFICATE-----
  42110. MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJRTESMBAGA1UE
  42111. ChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYDVQQDExlCYWx0aW1vcmUgQ3li
  42112. ZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoXDTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMC
  42113. SUUxEjAQBgNVBAoTCUJhbHRpbW9yZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFs
  42114. dGltb3JlIEN5YmVyVHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKME
  42115. uyKrmD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjrIZ3AQSsB
  42116. UnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeKmpYcqWe4PwzV9/lSEy/C
  42117. G9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSuXmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9
  42118. XbIGevOF6uvUA65ehD5f/xXtabz5OTZydc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjpr
  42119. l3RjM71oGDHweI12v/yejl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoI
  42120. VDaGezq1BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEB
  42121. BQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT929hkTI7gQCvlYpNRh
  42122. cL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3WgxjkzSswF07r51XgdIGn9w/xZchMB5
  42123. hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsa
  42124. Y71k5h+3zvDyny67G7fyUIhzksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9H
  42125. RCwBXbsdtTLSR9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp
  42126. -----END CERTIFICATE-----
  42127. Entrust Root Certification Authority
  42128. ====================================
  42129. -----BEGIN CERTIFICATE-----
  42130. MIIEkTCCA3mgAwIBAgIERWtQVDANBgkqhkiG9w0BAQUFADCBsDELMAkGA1UEBhMCVVMxFjAUBgNV
  42131. BAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0Lm5ldC9DUFMgaXMgaW5jb3Jw
  42132. b3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMWKGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsG
  42133. A1UEAxMkRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2MTEyNzIwMjM0
  42134. MloXDTI2MTEyNzIwNTM0MlowgbAxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMu
  42135. MTkwNwYDVQQLEzB3d3cuZW50cnVzdC5uZXQvQ1BTIGlzIGluY29ycG9yYXRlZCBieSByZWZlcmVu
  42136. Y2UxHzAdBgNVBAsTFihjKSAyMDA2IEVudHJ1c3QsIEluYy4xLTArBgNVBAMTJEVudHJ1c3QgUm9v
  42137. dCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  42138. ALaVtkNC+sZtKm9I35RMOVcF7sN5EUFoNu3s/poBj6E4KPz3EEZmLk0eGrEaTsbRwJWIsMn/MYsz
  42139. A9u3g3s+IIRe7bJWKKf44LlAcTfFy0cOlypowCKVYhXbR9n10Cv/gkvJrT7eTNuQgFA/CYqEAOww
  42140. Cj0Yzfv9KlmaI5UXLEWeH25DeW0MXJj+SKfFI0dcXv1u5x609mhF0YaDW6KKjbHjKYD+JXGIrb68
  42141. j6xSlkuqUY3kEzEZ6E5Nn9uss2rVvDlUccp6en+Q3X0dgNmBu1kmwhH+5pPi94DkZfs0Nw4pgHBN
  42142. rziGLp5/V6+eF67rHMsoIV+2HNjnogQi+dPa2MsCAwEAAaOBsDCBrTAOBgNVHQ8BAf8EBAMCAQYw
  42143. DwYDVR0TAQH/BAUwAwEB/zArBgNVHRAEJDAigA8yMDA2MTEyNzIwMjM0MlqBDzIwMjYxMTI3MjA1
  42144. MzQyWjAfBgNVHSMEGDAWgBRokORnpKZTgMeGZqTx90tD+4S9bTAdBgNVHQ4EFgQUaJDkZ6SmU4DH
  42145. hmak8fdLQ/uEvW0wHQYJKoZIhvZ9B0EABBAwDhsIVjcuMTo0LjADAgSQMA0GCSqGSIb3DQEBBQUA
  42146. A4IBAQCT1DCw1wMgKtD5Y+iRDAUgqV8ZyntyTtSx29CW+1RaGSwMCPeyvIWonX9tO1KzKtvn1ISM
  42147. Y/YPyyYBkVBs9F8U4pN0wBOeMDpQ47RgxRzwIkSNcUesyBrJ6ZuaAGAT/3B+XxFNSRuzFVJ7yVTa
  42148. v52Vr2ua2J7p8eRDjeIRRDq/r72DQnNSi6q7pynP9WQcCk3RvKqsnyrQ/39/2n3qse0wJcGE2jTS
  42149. W3iDVuycNsMm4hH2Z0kdkquM++v/eu6FSqdQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0
  42150. tHuu2guQOHXvgR1m0vdXcDazv/wor3ElhVsT/h5/WrQ8
  42151. -----END CERTIFICATE-----
  42152. Comodo AAA Services root
  42153. ========================
  42154. -----BEGIN CERTIFICATE-----
  42155. MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJHQjEbMBkGA1UECAwS
  42156. R3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRowGAYDVQQKDBFDb21vZG8gQ0Eg
  42157. TGltaXRlZDEhMB8GA1UEAwwYQUFBIENlcnRpZmljYXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAwMDAw
  42158. MFoXDTI4MTIzMTIzNTk1OVowezELMAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFuY2hl
  42159. c3RlcjEQMA4GA1UEBwwHU2FsZm9yZDEaMBgGA1UECgwRQ29tb2RvIENBIExpbWl0ZWQxITAfBgNV
  42160. BAMMGEFBQSBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
  42161. ggEBAL5AnfRu4ep2hxxNRUSOvkbIgwadwSr+GB+O5AL686tdUIoWMQuaBtDFcCLNSS1UY8y2bmhG
  42162. C1Pqy0wkwLxyTurxFa70VJoSCsN6sjNg4tqJVfMiWPPe3M/vg4aijJRPn2jymJBGhCfHdr/jzDUs
  42163. i14HZGWCwEiwqJH5YZ92IFCokcdmtet4YgNW8IoaE+oxox6gmf049vYnMlhvB/VruPsUK6+3qszW
  42164. Y19zjNoFmag4qMsXeDZRrOme9Hg6jc8P2ULimAyrL58OAd7vn5lJ8S3frHRNG5i1R8XlKdH5kBjH
  42165. Ypy+g8cmez6KJcfA3Z3mNWgQIJ2P2N7Sw4ScDV7oL8kCAwEAAaOBwDCBvTAdBgNVHQ4EFgQUoBEK
  42166. Iz6W8Qfs4q8p74Klf9AwpLQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wewYDVR0f
  42167. BHQwcjA4oDagNIYyaHR0cDovL2NybC5jb21vZG9jYS5jb20vQUFBQ2VydGlmaWNhdGVTZXJ2aWNl
  42168. cy5jcmwwNqA0oDKGMGh0dHA6Ly9jcmwuY29tb2RvLm5ldC9BQUFDZXJ0aWZpY2F0ZVNlcnZpY2Vz
  42169. LmNybDANBgkqhkiG9w0BAQUFAAOCAQEACFb8AvCb6P+k+tZ7xkSAzk/ExfYAWMymtrwUSWgEdujm
  42170. 7l3sAg9g1o1QGE8mTgHj5rCl7r+8dFRBv/38ErjHT1r0iWAFf2C3BUrz9vHCv8S5dIa2LX1rzNLz
  42171. Rt0vxuBqw8M0Ayx9lt1awg6nCpnBBYurDC/zXDrPbDdVCYfeU0BsWO/8tqtlbgT2G9w84FoVxp7Z
  42172. 8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsil2D4kF501KKaU73yqWjgom7C
  42173. 12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg==
  42174. -----END CERTIFICATE-----
  42175. QuoVadis Root CA 2
  42176. ==================
  42177. -----BEGIN CERTIFICATE-----
  42178. MIIFtzCCA5+gAwIBAgICBQkwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT
  42179. EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMjAeFw0wNjExMjQx
  42180. ODI3MDBaFw0zMTExMjQxODIzMzNaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM
  42181. aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  42182. DwAwggIKAoICAQCaGMpLlA0ALa8DKYrwD4HIrkwZhR0In6spRIXzL4GtMh6QRr+jhiYaHv5+HBg6
  42183. XJxgFyo6dIMzMH1hVBHL7avg5tKifvVrbxi3Cgst/ek+7wrGsxDp3MJGF/hd/aTa/55JWpzmM+Yk
  42184. lvc/ulsrHHo1wtZn/qtmUIttKGAr79dgw8eTvI02kfN/+NsRE8Scd3bBrrcCaoF6qUWD4gXmuVbB
  42185. lDePSHFjIuwXZQeVikvfj8ZaCuWw419eaxGrDPmF60Tp+ARz8un+XJiM9XOva7R+zdRcAitMOeGy
  42186. lZUtQofX1bOQQ7dsE/He3fbE+Ik/0XX1ksOR1YqI0JDs3G3eicJlcZaLDQP9nL9bFqyS2+r+eXyt
  42187. 66/3FsvbzSUr5R/7mp/iUcw6UwxI5g69ybR2BlLmEROFcmMDBOAENisgGQLodKcftslWZvB1Jdxn
  42188. wQ5hYIizPtGo/KPaHbDRsSNU30R2be1B2MGyIrZTHN81Hdyhdyox5C315eXbyOD/5YDXC2Og/zOh
  42189. D7osFRXql7PSorW+8oyWHhqPHWykYTe5hnMz15eWniN9gqRMgeKh0bpnX5UHoycR7hYQe7xFSkyy
  42190. BNKr79X9DFHOUGoIMfmR2gyPZFwDwzqLID9ujWc9Otb+fVuIyV77zGHcizN300QyNQliBJIWENie
  42191. J0f7OyHj+OsdWwIDAQABo4GwMIGtMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1Ud
  42192. DgQWBBQahGK8SEwzJQTU7tD2A8QZRtGUazBuBgNVHSMEZzBlgBQahGK8SEwzJQTU7tD2A8QZRtGU
  42193. a6FJpEcwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMT
  42194. ElF1b1ZhZGlzIFJvb3QgQ0EgMoICBQkwDQYJKoZIhvcNAQEFBQADggIBAD4KFk2fBluornFdLwUv
  42195. Z+YTRYPENvbzwCYMDbVHZF34tHLJRqUDGCdViXh9duqWNIAXINzng/iN/Ae42l9NLmeyhP3ZRPx3
  42196. UIHmfLTJDQtyU/h2BwdBR5YM++CCJpNVjP4iH2BlfF/nJrP3MpCYUNQ3cVX2kiF495V5+vgtJodm
  42197. VjB3pjd4M1IQWK4/YY7yarHvGH5KWWPKjaJW1acvvFYfzznB4vsKqBUsfU16Y8Zsl0Q80m/DShcK
  42198. +JDSV6IZUaUtl0HaB0+pUNqQjZRG4T7wlP0QADj1O+hA4bRuVhogzG9Yje0uRY/W6ZM/57Es3zrW
  42199. IozchLsib9D45MY56QSIPMO661V6bYCZJPVsAfv4l7CUW+v90m/xd2gNNWQjrLhVoQPRTUIZ3Ph1
  42200. WVaj+ahJefivDrkRoHy3au000LYmYjgahwz46P0u05B/B5EqHdZ+XIWDmbA4CD/pXvk1B+TJYm5X
  42201. f6dQlfe6yJvmjqIBxdZmv3lh8zwc4bmCXF2gw+nYSL0ZohEUGW6yhhtoPkg3Goi3XZZenMfvJ2II
  42202. 4pEZXNLxId26F0KCl3GBUzGpn/Z9Yr9y4aOTHcyKJloJONDO1w2AFrR4pTqHTI2KpdVGl/IsELm8
  42203. VCLAAVBpQ570su9t+Oza8eOx79+Rj1QqCyXBJhnEUhAFZdWCEOrCMc0u
  42204. -----END CERTIFICATE-----
  42205. QuoVadis Root CA 3
  42206. ==================
  42207. -----BEGIN CERTIFICATE-----
  42208. MIIGnTCCBIWgAwIBAgICBcYwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT
  42209. EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMzAeFw0wNjExMjQx
  42210. OTExMjNaFw0zMTExMjQxOTA2NDRaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM
  42211. aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  42212. DwAwggIKAoICAQDMV0IWVJzmmNPTTe7+7cefQzlKZbPoFog02w1ZkXTPkrgEQK0CSzGrvI2RaNgg
  42213. DhoB4hp7Thdd4oq3P5kazethq8Jlph+3t723j/z9cI8LoGe+AaJZz3HmDyl2/7FWeUUrH556VOij
  42214. KTVopAFPD6QuN+8bv+OPEKhyq1hX51SGyMnzW9os2l2ObjyjPtr7guXd8lyyBTNvijbO0BNO/79K
  42215. DDRMpsMhvVAEVeuxu537RR5kFd5VAYwCdrXLoT9CabwvvWhDFlaJKjdhkf2mrk7AyxRllDdLkgbv
  42216. BNDInIjbC3uBr7E9KsRlOni27tyAsdLTmZw67mtaa7ONt9XOnMK+pUsvFrGeaDsGb659n/je7Mwp
  42217. p5ijJUMv7/FfJuGITfhebtfZFG4ZM2mnO4SJk8RTVROhUXhA+LjJou57ulJCg54U7QVSWllWp5f8
  42218. nT8KKdjcT5EOE7zelaTfi5m+rJsziO+1ga8bxiJTyPbH7pcUsMV8eFLI8M5ud2CEpukqdiDtWAEX
  42219. MJPpGovgc2PZapKUSU60rUqFxKMiMPwJ7Wgic6aIDFUhWMXhOp8q3crhkODZc6tsgLjoC2SToJyM
  42220. Gf+z0gzskSaHirOi4XCPLArlzW1oUevaPwV/izLmE1xr/l9A4iLItLRkT9a6fUg+qGkM17uGcclz
  42221. uD87nSVL2v9A6wIDAQABo4IBlTCCAZEwDwYDVR0TAQH/BAUwAwEB/zCB4QYDVR0gBIHZMIHWMIHT
  42222. BgkrBgEEAb5YAAMwgcUwgZMGCCsGAQUFBwICMIGGGoGDQW55IHVzZSBvZiB0aGlzIENlcnRpZmlj
  42223. YXRlIGNvbnN0aXR1dGVzIGFjY2VwdGFuY2Ugb2YgdGhlIFF1b1ZhZGlzIFJvb3QgQ0EgMyBDZXJ0
  42224. aWZpY2F0ZSBQb2xpY3kgLyBDZXJ0aWZpY2F0aW9uIFByYWN0aWNlIFN0YXRlbWVudC4wLQYIKwYB
  42225. BQUHAgEWIWh0dHA6Ly93d3cucXVvdmFkaXNnbG9iYWwuY29tL2NwczALBgNVHQ8EBAMCAQYwHQYD
  42226. VR0OBBYEFPLAE+CCQz777i9nMpY1XNu4ywLQMG4GA1UdIwRnMGWAFPLAE+CCQz777i9nMpY1XNu4
  42227. ywLQoUmkRzBFMQswCQYDVQQGEwJCTTEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRlZDEbMBkGA1UE
  42228. AxMSUXVvVmFkaXMgUm9vdCBDQSAzggIFxjANBgkqhkiG9w0BAQUFAAOCAgEAT62gLEz6wPJv92ZV
  42229. qyM07ucp2sNbtrCD2dDQ4iH782CnO11gUyeim/YIIirnv6By5ZwkajGxkHon24QRiSemd1o417+s
  42230. hvzuXYO8BsbRd2sPbSQvS3pspweWyuOEn62Iix2rFo1bZhfZFvSLgNLd+LJ2w/w4E6oM3kJpK27z
  42231. POuAJ9v1pkQNn1pVWQvVDVJIxa6f8i+AxeoyUDUSly7B4f/xI4hROJ/yZlZ25w9Rl6VSDE1JUZU2
  42232. Pb+iSwwQHYaZTKrzchGT5Or2m9qoXadNt54CrnMAyNojA+j56hl0YgCUyyIgvpSnWbWCar6ZeXqp
  42233. 8kokUvd0/bpO5qgdAm6xDYBEwa7TIzdfu4V8K5Iu6H6li92Z4b8nby1dqnuH/grdS/yO9SbkbnBC
  42234. bjPsMZ57k8HkyWkaPcBrTiJt7qtYTcbQQcEr6k8Sh17rRdhs9ZgC06DYVYoGmRmioHfRMJ6szHXu
  42235. g/WwYjnPbFfiTNKRCw51KBuav/0aQ/HKd/s7j2G4aSgWQgRecCocIdiP4b0jWy10QJLZYxkNc91p
  42236. vGJHvOB0K7Lrfb5BG7XARsWhIstfTsEokt4YutUqKLsRixeTmJlglFwjz1onl14LBQaTNx47aTbr
  42237. qZ5hHY8y2o4M1nQ+ewkk2gF3R8Q7zTSMmfXK4SVhM7JZG+Ju1zdXtg2pEto=
  42238. -----END CERTIFICATE-----
  42239. Security Communication Root CA
  42240. ==============================
  42241. -----BEGIN CERTIFICATE-----
  42242. MIIDWjCCAkKgAwIBAgIBADANBgkqhkiG9w0BAQUFADBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMP
  42243. U0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEw
  42244. HhcNMDMwOTMwMDQyMDQ5WhcNMjMwOTMwMDQyMDQ5WjBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMP
  42245. U0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEw
  42246. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCzs/5/022x7xZ8V6UMbXaKL0u/ZPtM7orw
  42247. 8yl89f/uKuDp6bpbZCKamm8sOiZpUQWZJtzVHGpxxpp9Hp3dfGzGjGdnSj74cbAZJ6kJDKaVv0uM
  42248. DPpVmDvY6CKhS3E4eayXkmmziX7qIWgGmBSWh9JhNrxtJ1aeV+7AwFb9Ms+k2Y7CI9eNqPPYJayX
  42249. 5HA49LY6tJ07lyZDo6G8SVlyTCMwhwFY9k6+HGhWZq/NQV3Is00qVUarH9oe4kA92819uZKAnDfd
  42250. DJZkndwi92SL32HeFZRSFaB9UslLqCHJxrHty8OVYNEP8Ktw+N/LTX7s1vqr2b1/VPKl6Xn62dZ2
  42251. JChzAgMBAAGjPzA9MB0GA1UdDgQWBBSgc0mZaNyFW2XjmygvV5+9M7wHSDALBgNVHQ8EBAMCAQYw
  42252. DwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAaECpqLvkT115swW1F7NgE+vGkl3g
  42253. 0dNq/vu+m22/xwVtWSDEHPC32oRYAmP6SBbvT6UL90qY8j+eG61Ha2POCEfrUj94nK9NrvjVT8+a
  42254. mCoQQTlSxN3Zmw7vkwGusi7KaEIkQmywszo+zenaSMQVy+n5Bw+SUEmK3TGXX8npN6o7WWWXlDLJ
  42255. s58+OmJYxUmtYg5xpTKqL8aJdkNAExNnPaJUJRDL8Try2frbSVa7pv6nQTXD4IhhyYjH3zYQIphZ
  42256. 6rBK+1YWc26sTfcioU+tHXotRSflMMFe8toTyyVCUZVHA4xsIcx0Qu1T/zOLjw9XARYvz6buyXAi
  42257. FL39vmwLAw==
  42258. -----END CERTIFICATE-----
  42259. XRamp Global CA Root
  42260. ====================
  42261. -----BEGIN CERTIFICATE-----
  42262. MIIEMDCCAxigAwIBAgIQUJRs7Bjq1ZxN1ZfvdY+grTANBgkqhkiG9w0BAQUFADCBgjELMAkGA1UE
  42263. BhMCVVMxHjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2Vj
  42264. dXJpdHkgU2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBB
  42265. dXRob3JpdHkwHhcNMDQxMTAxMTcxNDA0WhcNMzUwMTAxMDUzNzE5WjCBgjELMAkGA1UEBhMCVVMx
  42266. HjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2VjdXJpdHkg
  42267. U2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBBdXRob3Jp
  42268. dHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCYJB69FbS638eMpSe2OAtp87ZOqCwu
  42269. IR1cRN8hXX4jdP5efrRKt6atH67gBhbim1vZZ3RrXYCPKZ2GG9mcDZhtdhAoWORlsH9KmHmf4MMx
  42270. foArtYzAQDsRhtDLooY2YKTVMIJt2W7QDxIEM5dfT2Fa8OT5kavnHTu86M/0ay00fOJIYRyO82FE
  42271. zG+gSqmUsE3a56k0enI4qEHMPJQRfevIpoy3hsvKMzvZPTeL+3o+hiznc9cKV6xkmxnr9A8ECIqs
  42272. AxcZZPRaJSKNNCyy9mgdEm3Tih4U2sSPpuIjhdV6Db1q4Ons7Be7QhtnqiXtRYMh/MHJfNViPvry
  42273. xS3T/dRlAgMBAAGjgZ8wgZwwEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud
  42274. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFMZPoj0GY4QJnM5i5ASsjVy16bYbMDYGA1UdHwQvMC0wK6Ap
  42275. oCeGJWh0dHA6Ly9jcmwueHJhbXBzZWN1cml0eS5jb20vWEdDQS5jcmwwEAYJKwYBBAGCNxUBBAMC
  42276. AQEwDQYJKoZIhvcNAQEFBQADggEBAJEVOQMBG2f7Shz5CmBbodpNl2L5JFMn14JkTpAuw0kbK5rc
  42277. /Kh4ZzXxHfARvbdI4xD2Dd8/0sm2qlWkSLoC295ZLhVbO50WfUfXN+pfTXYSNrsf16GBBEYgoyxt
  42278. qZ4Bfj8pzgCT3/3JknOJiWSe5yvkHJEs0rnOfc5vMZnT5r7SHpDwCRR5XCOrTdLaIR9NmXmd4c8n
  42279. nxCbHIgNsIpkQTG4DmyQJKSbXHGPurt+HBvbaoAPIbzp26a3QPSyi6mx5O+aGtA9aZnuqCij4Tyz
  42280. 8LIRnM98QObd50N9otg6tamN8jSZxNQQ4Qb9CYQQO+7ETPTsJ3xCwnR8gooJybQDJbw=
  42281. -----END CERTIFICATE-----
  42282. Go Daddy Class 2 CA
  42283. ===================
  42284. -----BEGIN CERTIFICATE-----
  42285. MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMY
  42286. VGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRp
  42287. ZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkG
  42288. A1UEBhMCVVMxITAfBgNVBAoTGFRoZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28g
  42289. RGFkZHkgQ2xhc3MgMiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQAD
  42290. ggENADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCAPVYYYwhv
  42291. 2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6wwdhFJ2+qN1j3hybX2C32
  42292. qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXiEqITLdiOr18SPaAIBQi2XKVlOARFmR6j
  42293. YGB0xUGlcmIbYsUfb18aQr4CUWWoriMYavx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmY
  42294. vLEHZ6IVDd2gWMZEewo+YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjgcAwgb0wHQYDVR0O
  42295. BBYEFNLEsNKR1EwRcbNhyz2h/t2oatTjMIGNBgNVHSMEgYUwgYKAFNLEsNKR1EwRcbNhyz2h/t2o
  42296. atTjoWekZTBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMu
  42297. MTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwG
  42298. A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wim
  42299. PQoZ+YeAEW5p5JYXMP80kWNyOO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKt
  42300. I3lpjbi2Tc7PTMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ
  42301. HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mERdEr/VxqHD3VI
  42302. Ls9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5CufReYNnyicsbkqWletNw+vHX/b
  42303. vZ8=
  42304. -----END CERTIFICATE-----
  42305. Starfield Class 2 CA
  42306. ====================
  42307. -----BEGIN CERTIFICATE-----
  42308. MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzElMCMGA1UEChMc
  42309. U3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZpZWxkIENsYXNzIDIg
  42310. Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQwNjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBo
  42311. MQswCQYDVQQGEwJVUzElMCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAG
  42312. A1UECxMpU3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqG
  42313. SIb3DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf8MOh2tTY
  42314. bitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN+lq2cwQlZut3f+dZxkqZ
  42315. JRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVm
  42316. epsZGD3/cVE8MC5fvj13c7JdBmzDI1aaK4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSN
  42317. F4Azbl5KXZnJHoe0nRrA1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HF
  42318. MIHCMB0GA1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fRzt0f
  42319. hvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNo
  42320. bm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBDbGFzcyAyIENlcnRpZmljYXRpb24g
  42321. QXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGs
  42322. afPzWdqbAYcaT1epoXkJKtv3L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLM
  42323. PUxA2IGvd56Deruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl
  42324. xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynpVSJYACPq4xJD
  42325. KVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEYWQPJIrSPnNVeKtelttQKbfi3
  42326. QBFGmh95DmK/D5fs4C8fF5Q=
  42327. -----END CERTIFICATE-----
  42328. DigiCert Assured ID Root CA
  42329. ===========================
  42330. -----BEGIN CERTIFICATE-----
  42331. MIIDtzCCAp+gAwIBAgIQDOfg5RfYRv6P5WD8G/AwOTANBgkqhkiG9w0BAQUFADBlMQswCQYDVQQG
  42332. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw
  42333. IgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0EwHhcNMDYxMTEwMDAwMDAwWhcNMzEx
  42334. MTEwMDAwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL
  42335. ExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0Ew
  42336. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtDhXO5EOAXLGH87dg+XESpa7cJpSIqvTO
  42337. 9SA5KFhgDPiA2qkVlTJhPLWxKISKityfCgyDF3qPkKyK53lTXDGEKvYPmDI2dsze3Tyoou9q+yHy
  42338. UmHfnyDXH+Kx2f4YZNISW1/5WBg1vEfNoTb5a3/UsDg+wRvDjDPZ2C8Y/igPs6eD1sNuRMBhNZYW
  42339. /lmci3Zt1/GiSw0r/wty2p5g0I6QNcZ4VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpy
  42340. oeb6pNnVFzF1roV9Iq4/AUaG9ih5yLHa5FcXxH4cDrC0kqZWs72yl+2qp/C3xag/lRbQ/6GW6whf
  42341. GHdPAgMBAAGjYzBhMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRF
  42342. 66Kv9JLLgjEtUYunpyGd823IDzAfBgNVHSMEGDAWgBRF66Kv9JLLgjEtUYunpyGd823IDzANBgkq
  42343. hkiG9w0BAQUFAAOCAQEAog683+Lt8ONyc3pklL/3cmbYMuRCdWKuh+vy1dneVrOfzM4UKLkNl2Bc
  42344. EkxY5NM9g0lFWJc1aRqoR+pWxnmrEthngYTffwk8lOa4JiwgvT2zKIn3X/8i4peEH+ll74fg38Fn
  42345. SbNd67IJKusm7Xi+fT8r87cmNW1fiQG2SVufAQWbqz0lwcy2f8Lxb4bG+mRo64EtlOtCt/qMHt1i
  42346. 8b5QZ7dsvfPxH2sMNgcWfzd8qVttevESRmCD1ycEvkvOl77DZypoEd+A5wwzZr8TDRRu838fYxAe
  42347. +o0bJW1sj6W3YQGx0qMmoRBxna3iw/nDmVG3KwcIzi7mULKn+gpFL6Lw8g==
  42348. -----END CERTIFICATE-----
  42349. DigiCert Global Root CA
  42350. =======================
  42351. -----BEGIN CERTIFICATE-----
  42352. MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQG
  42353. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw
  42354. HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBDQTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAw
  42355. MDAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3
  42356. dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkq
  42357. hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsBCSDMAZOn
  42358. TjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97nh6Vfe63SKMI2tavegw5
  42359. BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt43C/dxC//AH2hdmoRBBYMql1GNXRor5H
  42360. 4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7PT19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y
  42361. 7vrTC0LUq7dBMtoM1O/4gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQAB
  42362. o2MwYTAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbRTLtm
  42363. 8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUwDQYJKoZIhvcNAQEF
  42364. BQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/EsrhMAtudXH/vTBH1jLuG2cenTnmCmr
  42365. EbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIt
  42366. tep3Sp+dWOIrWcBAI+0tKIJFPnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886
  42367. UAb3LujEV0lsYSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk
  42368. CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=
  42369. -----END CERTIFICATE-----
  42370. DigiCert High Assurance EV Root CA
  42371. ==================================
  42372. -----BEGIN CERTIFICATE-----
  42373. MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBsMQswCQYDVQQG
  42374. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSsw
  42375. KQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5jZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAw
  42376. MFoXDTMxMTExMDAwMDAwMFowbDELMAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZ
  42377. MBcGA1UECxMQd3d3LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFu
  42378. Y2UgRVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm+9S75S0t
  42379. Mqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTWPNt0OKRKzE0lgvdKpVMS
  42380. OO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEMxChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3
  42381. MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFBIk5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQ
  42382. NAQTXKFx01p8VdteZOE3hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUe
  42383. h10aUAsgEsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMB
  42384. Af8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaAFLE+w2kD+L9HAdSY
  42385. JhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3NecnzyIZgYIVyHbIUf4KmeqvxgydkAQ
  42386. V8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6zeM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFp
  42387. myPInngiK3BD41VHMWEZ71jFhS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkK
  42388. mNEVX58Svnw2Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe
  42389. vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep+OkuE6N36B9K
  42390. -----END CERTIFICATE-----
  42391. SwissSign Gold CA - G2
  42392. ======================
  42393. -----BEGIN CERTIFICATE-----
  42394. MIIFujCCA6KgAwIBAgIJALtAHEP1Xk+wMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNVBAYTAkNIMRUw
  42395. EwYDVQQKEwxTd2lzc1NpZ24gQUcxHzAdBgNVBAMTFlN3aXNzU2lnbiBHb2xkIENBIC0gRzIwHhcN
  42396. MDYxMDI1MDgzMDM1WhcNMzYxMDI1MDgzMDM1WjBFMQswCQYDVQQGEwJDSDEVMBMGA1UEChMMU3dp
  42397. c3NTaWduIEFHMR8wHQYDVQQDExZTd2lzc1NpZ24gR29sZCBDQSAtIEcyMIICIjANBgkqhkiG9w0B
  42398. AQEFAAOCAg8AMIICCgKCAgEAr+TufoskDhJuqVAtFkQ7kpJcyrhdhJJCEyq8ZVeCQD5XJM1QiyUq
  42399. t2/876LQwB8CJEoTlo8jE+YoWACjR8cGp4QjK7u9lit/VcyLwVcfDmJlD909Vopz2q5+bbqBHH5C
  42400. jCA12UNNhPqE21Is8w4ndwtrvxEvcnifLtg+5hg3Wipy+dpikJKVyh+c6bM8K8vzARO/Ws/BtQpg
  42401. vd21mWRTuKCWs2/iJneRjOBiEAKfNA+k1ZIzUd6+jbqEemA8atufK+ze3gE/bk3lUIbLtK/tREDF
  42402. ylqM2tIrfKjuvqblCqoOpd8FUrdVxyJdMmqXl2MT28nbeTZ7hTpKxVKJ+STnnXepgv9VHKVxaSvR
  42403. AiTysybUa9oEVeXBCsdtMDeQKuSeFDNeFhdVxVu1yzSJkvGdJo+hB9TGsnhQ2wwMC3wLjEHXuend
  42404. jIj3o02yMszYF9rNt85mndT9Xv+9lz4pded+p2JYryU0pUHHPbwNUMoDAw8IWh+Vc3hiv69yFGkO
  42405. peUDDniOJihC8AcLYiAQZzlG+qkDzAQ4embvIIO1jEpWjpEA/I5cgt6IoMPiaG59je883WX0XaxR
  42406. 7ySArqpWl2/5rX3aYT+YdzylkbYcjCbaZaIJbcHiVOO5ykxMgI93e2CaHt+28kgeDrpOVG2Y4OGi
  42407. GqJ3UM/EY5LsRxmd6+ZrzsECAwEAAaOBrDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUw
  42408. AwEB/zAdBgNVHQ4EFgQUWyV7lqRlUX64OfPAeGZe6Drn8O4wHwYDVR0jBBgwFoAUWyV7lqRlUX64
  42409. OfPAeGZe6Drn8O4wRgYDVR0gBD8wPTA7BglghXQBWQECAQEwLjAsBggrBgEFBQcCARYgaHR0cDov
  42410. L3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBACe645R88a7A3hfm
  42411. 5djV9VSwg/S7zV4Fe0+fdWavPOhWfvxyeDgD2StiGwC5+OlgzczOUYrHUDFu4Up+GC9pWbY9ZIEr
  42412. 44OE5iKHjn3g7gKZYbge9LgriBIWhMIxkziWMaa5O1M/wySTVltpkuzFwbs4AOPsF6m43Md8AYOf
  42413. Mke6UiI0HTJ6CVanfCU2qT1L2sCCbwq7EsiHSycR+R4tx5M/nttfJmtS2S6K8RTGRI0Vqbe/vd6m
  42414. Gu6uLftIdxf+u+yvGPUqUfA5hJeVbG4bwyvEdGB5JbAKJ9/fXtI5z0V9QkvfsywexcZdylU6oJxp
  42415. mo/a77KwPJ+HbBIrZXAVUjEaJM9vMSNQH4xPjyPDdEFjHFWoFN0+4FFQz/EbMFYOkrCChdiDyyJk
  42416. vC24JdVUorgG6q2SpCSgwYa1ShNqR88uC1aVVMvOmttqtKay20EIhid392qgQmwLOM7XdVAyksLf
  42417. KzAiSNDVQTglXaTpXZ/GlHXQRf0wl0OPkKsKx4ZzYEppLd6leNcG2mqeSz53OiATIgHQv2ieY2Br
  42418. NU0LbbqhPcCT4H8js1WtciVORvnSFu+wZMEBnunKoGqYDs/YYPIvSbjkQuE4NRb0yG5P94FW6Lqj
  42419. viOvrv1vA+ACOzB2+httQc8Bsem4yWb02ybzOqR08kkkW8mw0FfB+j564ZfJ
  42420. -----END CERTIFICATE-----
  42421. SwissSign Silver CA - G2
  42422. ========================
  42423. -----BEGIN CERTIFICATE-----
  42424. MIIFvTCCA6WgAwIBAgIITxvUL1S7L0swDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCQ0gxFTAT
  42425. BgNVBAoTDFN3aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMB4X
  42426. DTA2MTAyNTA4MzI0NloXDTM2MTAyNTA4MzI0NlowRzELMAkGA1UEBhMCQ0gxFTATBgNVBAoTDFN3
  42427. aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMIICIjANBgkqhkiG
  42428. 9w0BAQEFAAOCAg8AMIICCgKCAgEAxPGHf9N4Mfc4yfjDmUO8x/e8N+dOcbpLj6VzHVxumK4DV644
  42429. N0MvFz0fyM5oEMF4rhkDKxD6LHmD9ui5aLlV8gREpzn5/ASLHvGiTSf5YXu6t+WiE7brYT7QbNHm
  42430. +/pe7R20nqA1W6GSy/BJkv6FCgU+5tkL4k+73JU3/JHpMjUi0R86TieFnbAVlDLaYQ1HTWBCrpJH
  42431. 6INaUFjpiou5XaHc3ZlKHzZnu0jkg7Y360g6rw9njxcH6ATK72oxh9TAtvmUcXtnZLi2kUpCe2Uu
  42432. MGoM9ZDulebyzYLs2aFK7PayS+VFheZteJMELpyCbTapxDFkH4aDCyr0NQp4yVXPQbBH6TCfmb5h
  42433. qAaEuSh6XzjZG6k4sIN/c8HDO0gqgg8hm7jMqDXDhBuDsz6+pJVpATqJAHgE2cn0mRmrVn5bi4Y5
  42434. FZGkECwJMoBgs5PAKrYYC51+jUnyEEp/+dVGLxmSo5mnJqy7jDzmDrxHB9xzUfFwZC8I+bRHHTBs
  42435. ROopN4WSaGa8gzj+ezku01DwH/teYLappvonQfGbGHLy9YR0SslnxFSuSGTfjNFusB3hB48IHpmc
  42436. celM2KX3RxIfdNFRnobzwqIjQAtz20um53MGjMGg6cFZrEb65i/4z3GcRm25xBWNOHkDRUjvxF3X
  42437. CO6HOSKGsg0PWEP3calILv3q1h8CAwEAAaOBrDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/
  42438. BAUwAwEB/zAdBgNVHQ4EFgQUF6DNweRBtjpbO8tFnb0cwpj6hlgwHwYDVR0jBBgwFoAUF6DNweRB
  42439. tjpbO8tFnb0cwpj6hlgwRgYDVR0gBD8wPTA7BglghXQBWQEDAQEwLjAsBggrBgEFBQcCARYgaHR0
  42440. cDovL3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBAHPGgeAn0i0P
  42441. 4JUw4ppBf1AsX19iYamGamkYDHRJ1l2E6kFSGG9YrVBWIGrGvShpWJHckRE1qTodvBqlYJ7YH39F
  42442. kWnZfrt4csEGDyrOj4VwYaygzQu4OSlWhDJOhrs9xCrZ1x9y7v5RoSJBsXECYxqCsGKrXlcSH9/L
  42443. 3XWgwF15kIwb4FDm3jH+mHtwX6WQ2K34ArZv02DdQEsixT2tOnqfGhpHkXkzuoLcMmkDlm4fS/Bx
  42444. /uNncqCxv1yL5PqZIseEuRuNI5c/7SXgz2W79WEE790eslpBIlqhn10s6FvJbakMDHiqYMZWjwFa
  42445. DGi8aRl5xB9+lwW/xekkUV7U1UtT7dkjWjYDZaPBA61BMPNGG4WQr2W11bHkFlt4dR2Xem1ZqSqP
  42446. e97Dh4kQmUlzeMg9vVE1dCrV8X5pGyq7O70luJpaPXJhkGaH7gzWTdQRdAtq/gsD/KNVV4n+Ssuu
  42447. WxcFyPKNIzFTONItaj+CuY0IavdeQXRuwxF+B6wpYJE/OMpXEA29MC/HpeZBoNquBYeaoKRlbEwJ
  42448. DIm6uNO5wJOKMPqN5ZprFQFOZ6raYlY+hAhm0sQ2fac+EPyI4NSA5QC9qvNOBqN6avlicuMJT+ub
  42449. DgEj8Z+7fNzcbBGXJbLytGMU0gYqZ4yD9c7qB9iaah7s5Aq7KkzrCWA5zspi2C5u
  42450. -----END CERTIFICATE-----
  42451. SecureTrust CA
  42452. ==============
  42453. -----BEGIN CERTIFICATE-----
  42454. MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBIMQswCQYDVQQG
  42455. EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xFzAVBgNVBAMTDlNlY3VyZVRy
  42456. dXN0IENBMB4XDTA2MTEwNzE5MzExOFoXDTI5MTIzMTE5NDA1NVowSDELMAkGA1UEBhMCVVMxIDAe
  42457. BgNVBAoTF1NlY3VyZVRydXN0IENvcnBvcmF0aW9uMRcwFQYDVQQDEw5TZWN1cmVUcnVzdCBDQTCC
  42458. ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKukgeWVzfX2FI7CT8rU4niVWJxB4Q2ZQCQX
  42459. OZEzZum+4YOvYlyJ0fwkW2Gz4BERQRwdbvC4u/jep4G6pkjGnx29vo6pQT64lO0pGtSO0gMdA+9t
  42460. DWccV9cGrcrI9f4Or2YlSASWC12juhbDCE/RRvgUXPLIXgGZbf2IzIaowW8xQmxSPmjL8xk037uH
  42461. GFaAJsTQ3MBv396gwpEWoGQRS0S8Hvbn+mPeZqx2pHGj7DaUaHp3pLHnDi+BeuK1cobvomuL8A/b
  42462. 01k/unK8RCSc43Oz969XL0Imnal0ugBS8kvNU3xHCzaFDmapCJcWNFfBZveA4+1wVMeT4C4oFVmH
  42463. ursCAwEAAaOBnTCBmjATBgkrBgEEAYI3FAIEBh4EAEMAQTALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/
  42464. BAUwAwEB/zAdBgNVHQ4EFgQUQjK2FvoE/f5dS3rD/fdMQB1aQ68wNAYDVR0fBC0wKzApoCegJYYj
  42465. aHR0cDovL2NybC5zZWN1cmV0cnVzdC5jb20vU1RDQS5jcmwwEAYJKwYBBAGCNxUBBAMCAQAwDQYJ
  42466. KoZIhvcNAQEFBQADggEBADDtT0rhWDpSclu1pqNlGKa7UTt36Z3q059c4EVlew3KW+JwULKUBRSu
  42467. SceNQQcSc5R+DCMh/bwQf2AQWnL1mA6s7Ll/3XpvXdMc9P+IBWlCqQVxyLesJugutIxq/3HcuLHf
  42468. mbx8IVQr5Fiiu1cprp6poxkmD5kuCLDv/WnPmRoJjeOnnyvJNjR7JLN4TJUXpAYmHrZkUjZfYGfZ
  42469. nMUFdAvnZyPSCPyI6a6Lf+Ew9Dd+/cYy2i2eRDAwbO4H3tI0/NL/QPZL9GZGBlSm8jIKYyYwa5vR
  42470. 3ItHuuG51WLQoqD0ZwV4KWMabwTW+MZMo5qxN7SN5ShLHZ4swrhovO0C7jE=
  42471. -----END CERTIFICATE-----
  42472. Secure Global CA
  42473. ================
  42474. -----BEGIN CERTIFICATE-----
  42475. MIIDvDCCAqSgAwIBAgIQB1YipOjUiolN9BPI8PjqpTANBgkqhkiG9w0BAQUFADBKMQswCQYDVQQG
  42476. EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBH
  42477. bG9iYWwgQ0EwHhcNMDYxMTA3MTk0MjI4WhcNMjkxMjMxMTk1MjA2WjBKMQswCQYDVQQGEwJVUzEg
  42478. MB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBHbG9iYWwg
  42479. Q0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvNS7YrGxVaQZx5RNoJLNP2MwhR/jx
  42480. YDiJiQPpvepeRlMJ3Fz1Wuj3RSoC6zFh1ykzTM7HfAo3fg+6MpjhHZevj8fcyTiW89sa/FHtaMbQ
  42481. bqR8JNGuQsiWUGMu4P51/pinX0kuleM5M2SOHqRfkNJnPLLZ/kG5VacJjnIFHovdRIWCQtBJwB1g
  42482. 8NEXLJXr9qXBkqPFwqcIYA1gBBCWeZ4WNOaptvolRTnIHmX5k/Wq8VLcmZg9pYYaDDUz+kulBAYV
  42483. HDGA76oYa8J719rO+TMg1fW9ajMtgQT7sFzUnKPiXB3jqUJ1XnvUd+85VLrJChgbEplJL4hL/VBi
  42484. 0XPnj3pDAgMBAAGjgZ0wgZowEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud
  42485. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFK9EBMJBfkiD2045AuzshHrmzsmkMDQGA1UdHwQtMCswKaAn
  42486. oCWGI2h0dHA6Ly9jcmwuc2VjdXJldHJ1c3QuY29tL1NHQ0EuY3JsMBAGCSsGAQQBgjcVAQQDAgEA
  42487. MA0GCSqGSIb3DQEBBQUAA4IBAQBjGghAfaReUw132HquHw0LURYD7xh8yOOvaliTFGCRsoTciE6+
  42488. OYo68+aCiV0BN7OrJKQVDpI1WkpEXk5X+nXOH0jOZvQ8QCaSmGwb7iRGDBezUqXbpZGRzzfTb+cn
  42489. CDpOGR86p1hcF895P4vkp9MmI50mD1hp/Ed+stCNi5O/KU9DaXR2Z0vPB4zmAve14bRDtUstFJ/5
  42490. 3CYNv6ZHdAbYiNE6KTCEztI5gGIbqMdXSbxqVVFnFUq+NQfk1XWYN3kwFNspnWzFacxHVaIw98xc
  42491. f8LDmBxrThaA63p4ZUWiABqvDA1VZDRIuJK58bRQKfJPIx/abKwfROHdI3hRW8cW
  42492. -----END CERTIFICATE-----
  42493. COMODO Certification Authority
  42494. ==============================
  42495. -----BEGIN CERTIFICATE-----
  42496. MIIEHTCCAwWgAwIBAgIQToEtioJl4AsC7j41AkblPTANBgkqhkiG9w0BAQUFADCBgTELMAkGA1UE
  42497. BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG
  42498. A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxJzAlBgNVBAMTHkNPTU9ETyBDZXJ0aWZpY2F0aW9uIEF1
  42499. dGhvcml0eTAeFw0wNjEyMDEwMDAwMDBaFw0yOTEyMzEyMzU5NTlaMIGBMQswCQYDVQQGEwJHQjEb
  42500. MBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQKExFD
  42501. T01PRE8gQ0EgTGltaXRlZDEnMCUGA1UEAxMeQ09NT0RPIENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  42502. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0ECLi3LjkRv3UcEbVASY06m/weaKXTuH
  42503. +7uIzg3jLz8GlvCiKVCZrts7oVewdFFxze1CkU1B/qnI2GqGd0S7WWaXUF601CxwRM/aN5VCaTww
  42504. xHGzUvAhTaHYujl8HJ6jJJ3ygxaYqhZ8Q5sVW7euNJH+1GImGEaaP+vB+fGQV+useg2L23IwambV
  42505. 4EajcNxo2f8ESIl33rXp+2dtQem8Ob0y2WIC8bGoPW43nOIv4tOiJovGuFVDiOEjPqXSJDlqR6sA
  42506. 1KGzqSX+DT+nHbrTUcELpNqsOO9VUCQFZUaTNE8tja3G1CEZ0o7KBWFxB3NH5YoZEr0ETc5OnKVI
  42507. rLsm9wIDAQABo4GOMIGLMB0GA1UdDgQWBBQLWOWLxkwVN6RAqTCpIb5HNlpW/zAOBgNVHQ8BAf8E
  42508. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zBJBgNVHR8EQjBAMD6gPKA6hjhodHRwOi8vY3JsLmNvbW9k
  42509. b2NhLmNvbS9DT01PRE9DZXJ0aWZpY2F0aW9uQXV0aG9yaXR5LmNybDANBgkqhkiG9w0BAQUFAAOC
  42510. AQEAPpiem/Yb6dc5t3iuHXIYSdOH5EOC6z/JqvWote9VfCFSZfnVDeFs9D6Mk3ORLgLETgdxb8CP
  42511. OGEIqB6BCsAvIC9Bi5HcSEW88cbeunZrM8gALTFGTO3nnc+IlP8zwFboJIYmuNg4ON8qa90SzMc/
  42512. RxdMosIGlgnW2/4/PEZB31jiVg88O8EckzXZOFKs7sjsLjBOlDW0JB9LeGna8gI4zJVSk/BwJVmc
  42513. IGfE7vmLV2H0knZ9P4SNVbfo5azV8fUZVqZa+5Acr5Pr5RzUZ5ddBA6+C4OmF4O5MBKgxTMVBbkN
  42514. +8cFduPYSo38NBejxiEovjBFMR7HeL5YYTisO+IBZQ==
  42515. -----END CERTIFICATE-----
  42516. COMODO ECC Certification Authority
  42517. ==================================
  42518. -----BEGIN CERTIFICATE-----
  42519. MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTELMAkGA1UEBhMC
  42520. R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE
  42521. ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBB
  42522. dXRob3JpdHkwHhcNMDgwMzA2MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0Ix
  42523. GzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR
  42524. Q09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRo
  42525. b3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSRFtSrYpn1PlILBs5BAH+X
  42526. 4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0JcfRK9ChQtP6IHG4/bC8vCVlbpVsLM5ni
  42527. wz2J+Wos77LTBumjQjBAMB0GA1UdDgQWBBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8E
  42528. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VG
  42529. FAkK+qDmfQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdvGDeA
  42530. U/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY=
  42531. -----END CERTIFICATE-----
  42532. Certigna
  42533. ========
  42534. -----BEGIN CERTIFICATE-----
  42535. MIIDqDCCApCgAwIBAgIJAP7c4wEPyUj/MA0GCSqGSIb3DQEBBQUAMDQxCzAJBgNVBAYTAkZSMRIw
  42536. EAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hMB4XDTA3MDYyOTE1MTMwNVoXDTI3
  42537. MDYyOTE1MTMwNVowNDELMAkGA1UEBhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczERMA8GA1UEAwwI
  42538. Q2VydGlnbmEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDIaPHJ1tazNHUmgh7stL7q
  42539. XOEm7RFHYeGifBZ4QCHkYJ5ayGPhxLGWkv8YbWkj4Sti993iNi+RB7lIzw7sebYs5zRLcAglozyH
  42540. GxnygQcPOJAZ0xH+hrTy0V4eHpbNgGzOOzGTtvKg0KmVEn2lmsxryIRWijOp5yIVUxbwzBfsV1/p
  42541. ogqYCd7jX5xv3EjjhQsVWqa6n6xI4wmy9/Qy3l40vhx4XUJbzg4ij02Q130yGLMLLGq/jj8UEYkg
  42542. DncUtT2UCIf3JR7VsmAA7G8qKCVuKj4YYxclPz5EIBb2JsglrgVKtOdjLPOMFlN+XPsRGgjBRmKf
  42543. Irjxwo1p3Po6WAbfAgMBAAGjgbwwgbkwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUGu3+QTmQ
  42544. tCRZvgHyUtVF9lo53BEwZAYDVR0jBF0wW4AUGu3+QTmQtCRZvgHyUtVF9lo53BGhOKQ2MDQxCzAJ
  42545. BgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hggkA/tzjAQ/J
  42546. SP8wDgYDVR0PAQH/BAQDAgEGMBEGCWCGSAGG+EIBAQQEAwIABzANBgkqhkiG9w0BAQUFAAOCAQEA
  42547. hQMeknH2Qq/ho2Ge6/PAD/Kl1NqV5ta+aDY9fm4fTIrv0Q8hbV6lUmPOEvjvKtpv6zf+EwLHyzs+
  42548. ImvaYS5/1HI93TDhHkxAGYwP15zRgzB7mFncfca5DClMoTOi62c6ZYTTluLtdkVwj7Ur3vkj1klu
  42549. PBS1xp81HlDQwY9qcEQCYsuuHWhBp6pX6FOqB9IG9tUUBguRA3UsbHK1YZWaDYu5Def131TN3ubY
  42550. 1gkIl2PlwS6wt0QmwCbAr1UwnjvVNioZBPRcHv/PLLf/0P2HQBHVESO7SMAhqaQoLf0V+LBOK/Qw
  42551. WyH8EZE0vkHve52Xdf+XlcCWWC/qu0bXu+TZLg==
  42552. -----END CERTIFICATE-----
  42553. ePKI Root Certification Authority
  42554. =================================
  42555. -----BEGIN CERTIFICATE-----
  42556. MIIFsDCCA5igAwIBAgIQFci9ZUdcr7iXAF7kBtK8nTANBgkqhkiG9w0BAQUFADBeMQswCQYDVQQG
  42557. EwJUVzEjMCEGA1UECgwaQ2h1bmdod2EgVGVsZWNvbSBDby4sIEx0ZC4xKjAoBgNVBAsMIWVQS0kg
  42558. Um9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNDEyMjAwMjMxMjdaFw0zNDEyMjAwMjMx
  42559. MjdaMF4xCzAJBgNVBAYTAlRXMSMwIQYDVQQKDBpDaHVuZ2h3YSBUZWxlY29tIENvLiwgTHRkLjEq
  42560. MCgGA1UECwwhZVBLSSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0B
  42561. AQEFAAOCAg8AMIICCgKCAgEA4SUP7o3biDN1Z82tH306Tm2d0y8U82N0ywEhajfqhFAHSyZbCUNs
  42562. IZ5qyNUD9WBpj8zwIuQf5/dqIjG3LBXy4P4AakP/h2XGtRrBp0xtInAhijHyl3SJCRImHJ7K2RKi
  42563. lTza6We/CKBk49ZCt0Xvl/T29de1ShUCWH2YWEtgvM3XDZoTM1PRYfl61dd4s5oz9wCGzh1NlDiv
  42564. qOx4UXCKXBCDUSH3ET00hl7lSM2XgYI1TBnsZfZrxQWh7kcT1rMhJ5QQCtkkO7q+RBNGMD+XPNjX
  42565. 12ruOzjjK9SXDrkb5wdJfzcq+Xd4z1TtW0ado4AOkUPB1ltfFLqfpo0kR0BZv3I4sjZsN/+Z0V0O
  42566. WQqraffAsgRFelQArr5T9rXn4fg8ozHSqf4hUmTFpmfwdQcGlBSBVcYn5AGPF8Fqcde+S/uUWH1+
  42567. ETOxQvdibBjWzwloPn9s9h6PYq2lY9sJpx8iQkEeb5mKPtf5P0B6ebClAZLSnT0IFaUQAS2zMnao
  42568. lQ2zepr7BxB4EW/hj8e6DyUadCrlHJhBmd8hh+iVBmoKs2pHdmX2Os+PYhcZewoozRrSgx4hxyy/
  42569. vv9haLdnG7t4TY3OZ+XkwY63I2binZB1NJipNiuKmpS5nezMirH4JYlcWrYvjB9teSSnUmjDhDXi
  42570. Zo1jDiVN1Rmy5nk3pyKdVDECAwEAAaNqMGgwHQYDVR0OBBYEFB4M97Zn8uGSJglFwFU5Lnc/Qkqi
  42571. MAwGA1UdEwQFMAMBAf8wOQYEZyoHAAQxMC8wLQIBADAJBgUrDgMCGgUAMAcGBWcqAwAABBRFsMLH
  42572. ClZ87lt4DJX5GFPBphzYEDANBgkqhkiG9w0BAQUFAAOCAgEACbODU1kBPpVJufGBuvl2ICO1J2B0
  42573. 1GqZNF5sAFPZn/KmsSQHRGoqxqWOeBLoR9lYGxMqXnmbnwoqZ6YlPwZpVnPDimZI+ymBV3QGypzq
  42574. KOg4ZyYr8dW1P2WT+DZdjo2NQCCHGervJ8A9tDkPJXtoUHRVnAxZfVo9QZQlUgjgRywVMRnVvwdV
  42575. xrsStZf0X4OFunHB2WyBEXYKCrC/gpf36j36+uwtqSiUO1bd0lEursC9CBWMd1I0ltabrNMdjmEP
  42576. NXubrjlpC2JgQCA2j6/7Nu4tCEoduL+bXPjqpRugc6bY+G7gMwRfaKonh+3ZwZCc7b3jajWvY9+r
  42577. GNm65ulK6lCKD2GTHuItGeIwlDWSXQ62B68ZgI9HkFFLLk3dheLSClIKF5r8GrBQAuUBo2M3IUxE
  42578. xJtRmREOc5wGj1QupyheRDmHVi03vYVElOEMSyycw5KFNGHLD7ibSkNS/jQ6fbjpKdx2qcgw+BRx
  42579. gMYeNkh0IkFch4LoGHGLQYlE535YW6i4jRPpp2zDR+2zGp1iro2C6pSe3VkQw63d4k3jMdXH7Ojy
  42580. sP6SHhYKGvzZ8/gntsm+HbRsZJB/9OTEW9c3rkIO3aQab3yIVMUWbuF6aC74Or8NpDyJO3inTmOD
  42581. BCEIZ43ygknQW/2xzQ+DhNQ+IIX3Sj0rnP0qCglN6oH4EZw=
  42582. -----END CERTIFICATE-----
  42583. certSIGN ROOT CA
  42584. ================
  42585. -----BEGIN CERTIFICATE-----
  42586. MIIDODCCAiCgAwIBAgIGIAYFFnACMA0GCSqGSIb3DQEBBQUAMDsxCzAJBgNVBAYTAlJPMREwDwYD
  42587. VQQKEwhjZXJ0U0lHTjEZMBcGA1UECxMQY2VydFNJR04gUk9PVCBDQTAeFw0wNjA3MDQxNzIwMDRa
  42588. Fw0zMTA3MDQxNzIwMDRaMDsxCzAJBgNVBAYTAlJPMREwDwYDVQQKEwhjZXJ0U0lHTjEZMBcGA1UE
  42589. CxMQY2VydFNJR04gUk9PVCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALczuX7I
  42590. JUqOtdu0KBuqV5Do0SLTZLrTk+jUrIZhQGpgV2hUhE28alQCBf/fm5oqrl0Hj0rDKH/v+yv6efHH
  42591. rfAQUySQi2bJqIirr1qjAOm+ukbuW3N7LBeCgV5iLKECZbO9xSsAfsT8AzNXDe3i+s5dRdY4zTW2
  42592. ssHQnIFKquSyAVwdj1+ZxLGt24gh65AIgoDzMKND5pCCrlUoSe1b16kQOA7+j0xbm0bqQfWwCHTD
  42593. 0IgztnzXdN/chNFDDnU5oSVAKOp4yw4sLjmdjItuFhwvJoIQ4uNllAoEwF73XVv4EOLQunpL+943
  42594. AAAaWyjj0pxzPjKHmKHJUS/X3qwzs08CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8B
  42595. Af8EBAMCAcYwHQYDVR0OBBYEFOCMm9slSbPxfIbWskKHC9BroNnkMA0GCSqGSIb3DQEBBQUAA4IB
  42596. AQA+0hyJLjX8+HXd5n9liPRyTMks1zJO890ZeUe9jjtbkw9QSSQTaxQGcu8J06Gh40CEyecYMnQ8
  42597. SG4Pn0vU9x7Tk4ZkVJdjclDVVc/6IJMCopvDI5NOFlV2oHB5bc0hH88vLbwZ44gx+FkagQnIl6Z0
  42598. x2DEW8xXjrJ1/RsCCdtZb3KTafcxQdaIOL+Hsr0Wefmq5L6IJd1hJyMctTEHBDa0GpC9oHRxUIlt
  42599. vBTjD4au8as+x6AJzKNI0eDbZOeStc+vckNwi/nDhDwTqn6Sm1dTk/pwwpEOMfmbZ13pljheX7Nz
  42600. TogVZ96edhBiIL5VaZVDADlN9u6wWk5JRFRYX0KD
  42601. -----END CERTIFICATE-----
  42602. NetLock Arany (Class Gold) Főtanúsítvány
  42603. ========================================
  42604. -----BEGIN CERTIFICATE-----
  42605. MIIEFTCCAv2gAwIBAgIGSUEs5AAQMA0GCSqGSIb3DQEBCwUAMIGnMQswCQYDVQQGEwJIVTERMA8G
  42606. A1UEBwwIQnVkYXBlc3QxFTATBgNVBAoMDE5ldExvY2sgS2Z0LjE3MDUGA1UECwwuVGFuw7pzw610
  42607. dsOhbnlraWFkw7NrIChDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzKTE1MDMGA1UEAwwsTmV0TG9jayBB
  42608. cmFueSAoQ2xhc3MgR29sZCkgRsWRdGFuw7pzw610dsOhbnkwHhcNMDgxMjExMTUwODIxWhcNMjgx
  42609. MjA2MTUwODIxWjCBpzELMAkGA1UEBhMCSFUxETAPBgNVBAcMCEJ1ZGFwZXN0MRUwEwYDVQQKDAxO
  42610. ZXRMb2NrIEtmdC4xNzA1BgNVBAsMLlRhbsO6c8OtdHbDoW55a2lhZMOzayAoQ2VydGlmaWNhdGlv
  42611. biBTZXJ2aWNlcykxNTAzBgNVBAMMLE5ldExvY2sgQXJhbnkgKENsYXNzIEdvbGQpIEbFkXRhbsO6
  42612. c8OtdHbDoW55MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxCRec75LbRTDofTjl5Bu
  42613. 0jBFHjzuZ9lk4BqKf8owyoPjIMHj9DrTlF8afFttvzBPhCf2nx9JvMaZCpDyD/V/Q4Q3Y1GLeqVw
  42614. /HpYzY6b7cNGbIRwXdrzAZAj/E4wqX7hJ2Pn7WQ8oLjJM2P+FpD/sLj916jAwJRDC7bVWaaeVtAk
  42615. H3B5r9s5VA1lddkVQZQBr17s9o3x/61k/iCa11zr/qYfCGSji3ZVrR47KGAuhyXoqq8fxmRGILdw
  42616. fzzeSNuWU7c5d+Qa4scWhHaXWy+7GRWF+GmF9ZmnqfI0p6m2pgP8b4Y9VHx2BJtr+UBdADTHLpl1
  42617. neWIA6pN+APSQnbAGwIDAKiLo0UwQzASBgNVHRMBAf8ECDAGAQH/AgEEMA4GA1UdDwEB/wQEAwIB
  42618. BjAdBgNVHQ4EFgQUzPpnk/C2uNClwB7zU/2MU9+D15YwDQYJKoZIhvcNAQELBQADggEBAKt/7hwW
  42619. qZw8UQCgwBEIBaeZ5m8BiFRhbvG5GK1Krf6BQCOUL/t1fC8oS2IkgYIL9WHxHG64YTjrgfpioTta
  42620. YtOUZcTh5m2C+C8lcLIhJsFyUR+MLMOEkMNaj7rP9KdlpeuY0fsFskZ1FSNqb4VjMIDw1Z4fKRzC
  42621. bLBQWV2QWzuoDTDPv31/zvGdg73JRm4gpvlhUbohL3u+pRVjodSVh/GeufOJ8z2FuLjbvrW5Kfna
  42622. NwUASZQDhETnv0Mxz3WLJdH0pmT1kvarBes96aULNmLazAZfNou2XjG4Kvte9nHfRCaexOYNkbQu
  42623. dZWAUWpLMKawYqGT8ZvYzsRjdT9ZR7E=
  42624. -----END CERTIFICATE-----
  42625. SecureSign RootCA11
  42626. ===================
  42627. -----BEGIN CERTIFICATE-----
  42628. MIIDbTCCAlWgAwIBAgIBATANBgkqhkiG9w0BAQUFADBYMQswCQYDVQQGEwJKUDErMCkGA1UEChMi
  42629. SmFwYW4gQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcywgSW5jLjEcMBoGA1UEAxMTU2VjdXJlU2lnbiBS
  42630. b290Q0ExMTAeFw0wOTA0MDgwNDU2NDdaFw0yOTA0MDgwNDU2NDdaMFgxCzAJBgNVBAYTAkpQMSsw
  42631. KQYDVQQKEyJKYXBhbiBDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzLCBJbmMuMRwwGgYDVQQDExNTZWN1
  42632. cmVTaWduIFJvb3RDQTExMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA/XeqpRyQBTvL
  42633. TJszi1oURaTnkBbR31fSIRCkF/3frNYfp+TbfPfs37gD2pRY/V1yfIw/XwFndBWW4wI8h9uuywGO
  42634. wvNmxoVF9ALGOrVisq/6nL+k5tSAMJjzDbaTj6nU2DbysPyKyiyhFTOVMdrAG/LuYpmGYz+/3ZMq
  42635. g6h2uRMft85OQoWPIucuGvKVCbIFtUROd6EgvanyTgp9UK31BQ1FT0Zx/Sg+U/sE2C3XZR1KG/rP
  42636. O7AxmjVuyIsG0wCR8pQIZUyxNAYAeoni8McDWc/V1uinMrPmmECGxc0nEovMe863ETxiYAcjPitA
  42637. bpSACW22s293bzUIUPsCh8U+iQIDAQABo0IwQDAdBgNVHQ4EFgQUW/hNT7KlhtQ60vFjmqC+CfZX
  42638. t94wDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAKCh
  42639. OBZmLqdWHyGcBvod7bkixTgm2E5P7KN/ed5GIaGHd48HCJqypMWvDzKYC3xmKbabfSVSSUOrTC4r
  42640. bnpwrxYO4wJs+0LmGJ1F2FXI6Dvd5+H0LgscNFxsWEr7jIhQX5Ucv+2rIrVls4W6ng+4reV6G4pQ
  42641. Oh29Dbx7VFALuUKvVaAYga1lme++5Jy/xIWrQbJUb9wlze144o4MjQlJ3WN7WmmWAiGovVJZ6X01
  42642. y8hSyn+B/tlr0/cR7SXf+Of5pPpyl4RTDaXQMhhRdlkUbA/r7F+AjHVDg8OFmP9Mni0N5HeDk061
  42643. lgeLKBObjBmNQSdJQO7e5iNEOdyhIta6A/I=
  42644. -----END CERTIFICATE-----
  42645. Microsec e-Szigno Root CA 2009
  42646. ==============================
  42647. -----BEGIN CERTIFICATE-----
  42648. MIIECjCCAvKgAwIBAgIJAMJ+QwRORz8ZMA0GCSqGSIb3DQEBCwUAMIGCMQswCQYDVQQGEwJIVTER
  42649. MA8GA1UEBwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jv
  42650. c2VjIGUtU3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5o
  42651. dTAeFw0wOTA2MTYxMTMwMThaFw0yOTEyMzAxMTMwMThaMIGCMQswCQYDVQQGEwJIVTERMA8GA1UE
  42652. BwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jvc2VjIGUt
  42653. U3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5odTCCASIw
  42654. DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOn4j/NjrdqG2KfgQvvPkd6mJviZpWNwrZuuyjNA
  42655. fW2WbqEORO7hE52UQlKavXWFdCyoDh2Tthi3jCyoz/tccbna7P7ofo/kLx2yqHWH2Leh5TvPmUpG
  42656. 0IMZfcChEhyVbUr02MelTTMuhTlAdX4UfIASmFDHQWe4oIBhVKZsTh/gnQ4H6cm6M+f+wFUoLAKA
  42657. pxn1ntxVUwOXewdI/5n7N4okxFnMUBBjjqqpGrCEGob5X7uxUG6k0QrM1XF+H6cbfPVTbiJfyyvm
  42658. 1HxdrtbCxkzlBQHZ7Vf8wSN5/PrIJIOV87VqUQHQd9bpEqH5GoP7ghu5sJf0dgYzQ0mg/wu1+rUC
  42659. AwEAAaOBgDB+MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTLD8bf
  42660. QkPMPcu1SCOhGnqmKrs0aDAfBgNVHSMEGDAWgBTLD8bfQkPMPcu1SCOhGnqmKrs0aDAbBgNVHREE
  42661. FDASgRBpbmZvQGUtc3ppZ25vLmh1MA0GCSqGSIb3DQEBCwUAA4IBAQDJ0Q5eLtXMs3w+y/w9/w0o
  42662. lZMEyL/azXm4Q5DwpL7v8u8hmLzU1F0G9u5C7DBsoKqpyvGvivo/C3NqPuouQH4frlRheesuCDfX
  42663. I/OMn74dseGkddug4lQUsbocKaQY9hK6ohQU4zE1yED/t+AFdlfBHFny+L/k7SViXITwfn4fs775
  42664. tyERzAMBVnCnEJIeGzSBHq2cGsMEPO0CYdYeBvNfOofyK/FFh+U9rNHHV4S9a67c2Pm2G2JwCz02
  42665. yULyMtd6YebS2z3PyKnJm9zbWETXbzivf3jTo60adbocwTZ8jx5tHMN1Rq41Bab2XD0h7lbwyYIi
  42666. LXpUq3DDfSJlgnCW
  42667. -----END CERTIFICATE-----
  42668. GlobalSign Root CA - R3
  42669. =======================
  42670. -----BEGIN CERTIFICATE-----
  42671. MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4GA1UECxMXR2xv
  42672. YmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh
  42673. bFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT
  42674. aWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln
  42675. bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWt
  42676. iHL8RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsTgHeMCOFJ
  42677. 0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmmKPZpO/bLyCiR5Z2KYVc3
  42678. rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zdQQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjl
  42679. OCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZXriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2
  42680. xmmFghcCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE
  42681. FI/wS3+oLkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZURUm7
  42682. lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMpjjM5RcOO5LlXbKr8
  42683. EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK6fBdRoyV3XpYKBovHd7NADdBj+1E
  42684. bddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQXmcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18
  42685. YIvDQVETI53O9zJrlAGomecsMx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7r
  42686. kpeDMdmztcpHWD9f
  42687. -----END CERTIFICATE-----
  42688. Autoridad de Certificacion Firmaprofesional CIF A62634068
  42689. =========================================================
  42690. -----BEGIN CERTIFICATE-----
  42691. MIIGFDCCA/ygAwIBAgIIU+w77vuySF8wDQYJKoZIhvcNAQEFBQAwUTELMAkGA1UEBhMCRVMxQjBA
  42692. BgNVBAMMOUF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1hcHJvZmVzaW9uYWwgQ0lGIEE2
  42693. MjYzNDA2ODAeFw0wOTA1MjAwODM4MTVaFw0zMDEyMzEwODM4MTVaMFExCzAJBgNVBAYTAkVTMUIw
  42694. QAYDVQQDDDlBdXRvcmlkYWQgZGUgQ2VydGlmaWNhY2lvbiBGaXJtYXByb2Zlc2lvbmFsIENJRiBB
  42695. NjI2MzQwNjgwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKlmuO6vj78aI14H9M2uDD
  42696. Utd9thDIAl6zQyrET2qyyhxdKJp4ERppWVevtSBC5IsP5t9bpgOSL/UR5GLXMnE42QQMcas9UX4P
  42697. B99jBVzpv5RvwSmCwLTaUbDBPLutN0pcyvFLNg4kq7/DhHf9qFD0sefGL9ItWY16Ck6WaVICqjaY
  42698. 7Pz6FIMMNx/Jkjd/14Et5cS54D40/mf0PmbR0/RAz15iNA9wBj4gGFrO93IbJWyTdBSTo3OxDqqH
  42699. ECNZXyAFGUftaI6SEspd/NYrspI8IM/hX68gvqB2f3bl7BqGYTM+53u0P6APjqK5am+5hyZvQWyI
  42700. plD9amML9ZMWGxmPsu2bm8mQ9QEM3xk9Dz44I8kvjwzRAv4bVdZO0I08r0+k8/6vKtMFnXkIoctX
  42701. MbScyJCyZ/QYFpM6/EfY0XiWMR+6KwxfXZmtY4laJCB22N/9q06mIqqdXuYnin1oKaPnirjaEbsX
  42702. LZmdEyRG98Xi2J+Of8ePdG1asuhy9azuJBCtLxTa/y2aRnFHvkLfuwHb9H/TKI8xWVvTyQKmtFLK
  42703. bpf7Q8UIJm+K9Lv9nyiqDdVF8xM6HdjAeI9BZzwelGSuewvF6NkBiDkal4ZkQdU7hwxu+g/GvUgU
  42704. vzlN1J5Bto+WHWOWk9mVBngxaJ43BjuAiUVhOSPHG0SjFeUc+JIwuwIDAQABo4HvMIHsMBIGA1Ud
  42705. EwEB/wQIMAYBAf8CAQEwDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBRlzeurNR4APn7VdMActHNH
  42706. DhpkLzCBpgYDVR0gBIGeMIGbMIGYBgRVHSAAMIGPMC8GCCsGAQUFBwIBFiNodHRwOi8vd3d3LmZp
  42707. cm1hcHJvZmVzaW9uYWwuY29tL2NwczBcBggrBgEFBQcCAjBQHk4AUABhAHMAZQBvACAAZABlACAA
  42708. bABhACAAQgBvAG4AYQBuAG8AdgBhACAANAA3ACAAQgBhAHIAYwBlAGwAbwBuAGEAIAAwADgAMAAx
  42709. ADcwDQYJKoZIhvcNAQEFBQADggIBABd9oPm03cXF661LJLWhAqvdpYhKsg9VSytXjDvlMd3+xDLx
  42710. 51tkljYyGOylMnfX40S2wBEqgLk9am58m9Ot/MPWo+ZkKXzR4Tgegiv/J2Wv+xYVxC5xhOW1//qk
  42711. R71kMrv2JYSiJ0L1ILDCExARzRAVukKQKtJE4ZYm6zFIEv0q2skGz3QeqUvVhyj5eTSSPi5E6PaP
  42712. T481PyWzOdxjKpBrIF/EUhJOlywqrJ2X3kjyo2bbwtKDlaZmp54lD+kLM5FlClrD2VQS3a/DTg4f
  42713. Jl4N3LON7NWBcN7STyQF82xO9UxJZo3R/9ILJUFI/lGExkKvgATP0H5kSeTy36LssUzAKh3ntLFl
  42714. osS88Zj0qnAHY7S42jtM+kAiMFsRpvAFDsYCA0irhpuF3dvd6qJ2gHN99ZwExEWN57kci57q13XR
  42715. crHedUTnQn3iV2t93Jm8PYMo6oCTjcVMZcFwgbg4/EMxsvYDNEeyrPsiBsse3RdHHF9mudMaotoR
  42716. saS8I8nkvof/uZS2+F0gStRf571oe2XyFR7SOqkt6dhrJKyXWERHrVkY8SFlcN7ONGCoQPHzPKTD
  42717. KCOM/iczQ0CgFzzr6juwcqajuUpLXhZI9LK8yIySxZ2frHI2vDSANGupi5LAuBft7HZT9SQBjLMi
  42718. 6Et8Vcad+qMUu2WFbm5PEn4KPJ2V
  42719. -----END CERTIFICATE-----
  42720. Izenpe.com
  42721. ==========
  42722. -----BEGIN CERTIFICATE-----
  42723. MIIF8TCCA9mgAwIBAgIQALC3WhZIX7/hy/WL1xnmfTANBgkqhkiG9w0BAQsFADA4MQswCQYDVQQG
  42724. EwJFUzEUMBIGA1UECgwLSVpFTlBFIFMuQS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wHhcNMDcxMjEz
  42725. MTMwODI4WhcNMzcxMjEzMDgyNzI1WjA4MQswCQYDVQQGEwJFUzEUMBIGA1UECgwLSVpFTlBFIFMu
  42726. QS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDJ
  42727. 03rKDx6sp4boFmVqscIbRTJxldn+EFvMr+eleQGPicPK8lVx93e+d5TzcqQsRNiekpsUOqHnJJAK
  42728. ClaOxdgmlOHZSOEtPtoKct2jmRXagaKH9HtuJneJWK3W6wyyQXpzbm3benhB6QiIEn6HLmYRY2xU
  42729. +zydcsC8Lv/Ct90NduM61/e0aL6i9eOBbsFGb12N4E3GVFWJGjMxCrFXuaOKmMPsOzTFlUFpfnXC
  42730. PCDFYbpRR6AgkJOhkEvzTnyFRVSa0QUmQbC1TR0zvsQDyCV8wXDbO/QJLVQnSKwv4cSsPsjLkkxT
  42731. OTcj7NMB+eAJRE1NZMDhDVqHIrytG6P+JrUV86f8hBnp7KGItERphIPzidF0BqnMC9bC3ieFUCbK
  42732. F7jJeodWLBoBHmy+E60QrLUk9TiRodZL2vG70t5HtfG8gfZZa88ZU+mNFctKy6lvROUbQc/hhqfK
  42733. 0GqfvEyNBjNaooXlkDWgYlwWTvDjovoDGrQscbNYLN57C9saD+veIR8GdwYDsMnvmfzAuU8Lhij+
  42734. 0rnq49qlw0dpEuDb8PYZi+17cNcC1u2HGCgsBCRMd+RIihrGO5rUD8r6ddIBQFqNeb+Lz0vPqhbB
  42735. leStTIo+F5HUsWLlguWABKQDfo2/2n+iD5dPDNMN+9fR5XJ+HMh3/1uaD7euBUbl8agW7EekFwID
  42736. AQABo4H2MIHzMIGwBgNVHREEgagwgaWBD2luZm9AaXplbnBlLmNvbaSBkTCBjjFHMEUGA1UECgw+
  42737. SVpFTlBFIFMuQS4gLSBDSUYgQTAxMzM3MjYwLVJNZXJjLlZpdG9yaWEtR2FzdGVpeiBUMTA1NSBG
  42738. NjIgUzgxQzBBBgNVBAkMOkF2ZGEgZGVsIE1lZGl0ZXJyYW5lbyBFdG9yYmlkZWEgMTQgLSAwMTAx
  42739. MCBWaXRvcmlhLUdhc3RlaXowDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O
  42740. BBYEFB0cZQ6o8iV7tJHP5LGx5r1VdGwFMA0GCSqGSIb3DQEBCwUAA4ICAQB4pgwWSp9MiDrAyw6l
  42741. Fn2fuUhfGI8NYjb2zRlrrKvV9pF9rnHzP7MOeIWblaQnIUdCSnxIOvVFfLMMjlF4rJUT3sb9fbga
  42742. kEyrkgPH7UIBzg/YsfqikuFgba56awmqxinuaElnMIAkejEWOVt+8Rwu3WwJrfIxwYJOubv5vr8q
  42743. hT/AQKM6WfxZSzwoJNu0FXWuDYi6LnPAvViH5ULy617uHjAimcs30cQhbIHsvm0m5hzkQiCeR7Cs
  42744. g1lwLDXWrzY0tM07+DKo7+N4ifuNRSzanLh+QBxh5z6ikixL8s36mLYp//Pye6kfLqCTVyvehQP5
  42745. aTfLnnhqBbTFMXiJ7HqnheG5ezzevh55hM6fcA5ZwjUukCox2eRFekGkLhObNA5me0mrZJfQRsN5
  42746. nXJQY6aYWwa9SG3YOYNw6DXwBdGqvOPbyALqfP2C2sJbUjWumDqtujWTI6cfSN01RpiyEGjkpTHC
  42747. ClguGYEQyVB1/OpaFs4R1+7vUIgtYf8/QnMFlEPVjjxOAToZpR9GTnfQXeWBIiGH/pR9hNiTrdZo
  42748. Q0iy2+tzJOeRf1SktoA+naM8THLCV8Sg1Mw4J87VBp6iSNnpn86CcDaTmjvfliHjWbcM2pE38P1Z
  42749. WrOZyGlsQyYBNWNgVYkDOnXYukrZVP/u3oDYLdE41V4tC5h9Pmzb/CaIxw==
  42750. -----END CERTIFICATE-----
  42751. Go Daddy Root Certificate Authority - G2
  42752. ========================================
  42753. -----BEGIN CERTIFICATE-----
  42754. MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  42755. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoTEUdvRGFkZHkuY29tLCBJbmMu
  42756. MTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5
  42757. MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgYMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6
  42758. b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjExMC8G
  42759. A1UEAxMoR28gRGFkZHkgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZI
  42760. hvcNAQEBBQADggEPADCCAQoCggEBAL9xYgjx+lk09xvJGKP3gElY6SKDE6bFIEMBO4Tx5oVJnyfq
  42761. 9oQbTqC023CYxzIBsQU+B07u9PpPL1kwIuerGVZr4oAH/PMWdYA5UXvl+TW2dE6pjYIT5LY/qQOD
  42762. +qK+ihVqf94Lw7YZFAXK6sOoBJQ7RnwyDfMAZiLIjWltNowRGLfTshxgtDj6AozO091GB94KPutd
  42763. fMh8+7ArU6SSYmlRJQVhGkSBjCypQ5Yj36w6gZoOKcUcqeldHraenjAKOc7xiID7S13MMuyFYkMl
  42764. NAJWJwGRtDtwKj9useiciAF9n9T521NtYJ2/LOdYq7hfRvzOxBsDPAnrSTFcaUaz4EcCAwEAAaNC
  42765. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFDqahQcQZyi27/a9
  42766. BUFuIMGU2g/eMA0GCSqGSIb3DQEBCwUAA4IBAQCZ21151fmXWWcDYfF+OwYxdS2hII5PZYe096ac
  42767. vNjpL9DbWu7PdIxztDhC2gV7+AJ1uP2lsdeu9tfeE8tTEH6KRtGX+rcuKxGrkLAngPnon1rpN5+r
  42768. 5N9ss4UXnT3ZJE95kTXWXwTrgIOrmgIttRD02JDHBHNA7XIloKmf7J6raBKZV8aPEjoJpL1E/QYV
  42769. N8Gb5DKj7Tjo2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO
  42770. LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI4uJEvlz36hz1
  42771. -----END CERTIFICATE-----
  42772. Starfield Root Certificate Authority - G2
  42773. =========================================
  42774. -----BEGIN CERTIFICATE-----
  42775. MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  42776. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s
  42777. b2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVsZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0
  42778. eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAw
  42779. DgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQg
  42780. VGVjaG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZpY2F0ZSBB
  42781. dXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL3twQP89o/8ArFv
  42782. W59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMgnLRJdzIpVv257IzdIvpy3Cdhl+72WoTs
  42783. bhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNk
  42784. N3mSwOxGXn/hbVNMYq/NHwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7Nf
  42785. ZTD4p7dNdloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0HZbU
  42786. JtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  42787. AQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0GCSqGSIb3DQEBCwUAA4IBAQARWfol
  42788. TwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjUsHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx
  42789. 4mcujJUDJi5DnUox9g61DLu34jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUw
  42790. F5okxBDgBPfg8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K
  42791. pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1mMpYjn0q7pBZ
  42792. c2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0
  42793. -----END CERTIFICATE-----
  42794. Starfield Services Root Certificate Authority - G2
  42795. ==================================================
  42796. -----BEGIN CERTIFICATE-----
  42797. MIID7zCCAtegAwIBAgIBADANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  42798. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s
  42799. b2dpZXMsIEluYy4xOzA5BgNVBAMTMlN0YXJmaWVsZCBTZXJ2aWNlcyBSb290IENlcnRpZmljYXRl
  42800. IEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgZgxCzAJBgNV
  42801. BAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxT
  42802. dGFyZmllbGQgVGVjaG5vbG9naWVzLCBJbmMuMTswOQYDVQQDEzJTdGFyZmllbGQgU2VydmljZXMg
  42803. Um9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
  42804. AQoCggEBANUMOsQq+U7i9b4Zl1+OiFOxHz/Lz58gE20pOsgPfTz3a3Y4Y9k2YKibXlwAgLIvWX/2
  42805. h/klQ4bnaRtSmpDhcePYLQ1Ob/bISdm28xpWriu2dBTrz/sm4xq6HZYuajtYlIlHVv8loJNwU4Pa
  42806. hHQUw2eeBGg6345AWh1KTs9DkTvnVtYAcMtS7nt9rjrnvDH5RfbCYM8TWQIrgMw0R9+53pBlbQLP
  42807. LJGmpufehRhJfGZOozptqbXuNC66DQO4M99H67FrjSXZm86B0UVGMpZwh94CDklDhbZsc7tk6mFB
  42808. rMnUVN+HL8cisibMn1lUaJ/8viovxFUcdUBgF4UCVTmLfwUCAwEAAaNCMEAwDwYDVR0TAQH/BAUw
  42809. AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJxfAN+qAdcwKziIorhtSpzyEZGDMA0GCSqG
  42810. SIb3DQEBCwUAA4IBAQBLNqaEd2ndOxmfZyMIbw5hyf2E3F/YNoHN2BtBLZ9g3ccaaNnRbobhiCPP
  42811. E95Dz+I0swSdHynVv/heyNXBve6SbzJ08pGCL72CQnqtKrcgfU28elUSwhXqvfdqlS5sdJ/PHLTy
  42812. xQGjhdByPq1zqwubdQxtRbeOlKyWN7Wg0I8VRw7j6IPdj/3vQQF3zCepYoUz8jcI73HPdwbeyBkd
  42813. iEDPfUYd/x7H4c7/I9vG+o1VTqkC50cRRj70/b17KSa7qWFiNyi2LSr2EIZkyXCn0q23KXB56jza
  42814. YyWf/Wi3MOxw+3WKt21gZ7IeyLnp2KhvAotnDU0mV3HaIPzBSlCNsSi6
  42815. -----END CERTIFICATE-----
  42816. AffirmTrust Commercial
  42817. ======================
  42818. -----BEGIN CERTIFICATE-----
  42819. MIIDTDCCAjSgAwIBAgIId3cGJyapsXwwDQYJKoZIhvcNAQELBQAwRDELMAkGA1UEBhMCVVMxFDAS
  42820. BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMB4XDTEw
  42821. MDEyOTE0MDYwNloXDTMwMTIzMTE0MDYwNlowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly
  42822. bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMIIBIjANBgkqhkiG9w0BAQEF
  42823. AAOCAQ8AMIIBCgKCAQEA9htPZwcroRX1BiLLHwGy43NFBkRJLLtJJRTWzsO3qyxPxkEylFf6Eqdb
  42824. DuKPHx6GGaeqtS25Xw2Kwq+FNXkyLbscYjfysVtKPcrNcV/pQr6U6Mje+SJIZMblq8Yrba0F8PrV
  42825. C8+a5fBQpIs7R6UjW3p6+DM/uO+Zl+MgwdYoic+U+7lF7eNAFxHUdPALMeIrJmqbTFeurCA+ukV6
  42826. BfO9m2kVrn1OIGPENXY6BwLJN/3HR+7o8XYdcxXyl6S1yHp52UKqK39c/s4mT6NmgTWvRLpUHhww
  42827. MmWd5jyTXlBOeuM61G7MGvv50jeuJCqrVwMiKA1JdX+3KNp1v47j3A55MQIDAQABo0IwQDAdBgNV
  42828. HQ4EFgQUnZPGU4teyq8/nx4P5ZmVvCT2lI8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  42829. AQYwDQYJKoZIhvcNAQELBQADggEBAFis9AQOzcAN/wr91LoWXym9e2iZWEnStB03TX8nfUYGXUPG
  42830. hi4+c7ImfU+TqbbEKpqrIZcUsd6M06uJFdhrJNTxFq7YpFzUf1GO7RgBsZNjvbz4YYCanrHOQnDi
  42831. qX0GJX0nof5v7LMeJNrjS1UaADs1tDvZ110w/YETifLCBivtZ8SOyUOyXGsViQK8YvxO8rUzqrJv
  42832. 0wqiUOP2O+guRMLbZjipM1ZI8W0bM40NjD9gN53Tym1+NH4Nn3J2ixufcv1SNUFFApYvHLKac0kh
  42833. sUlHRUe072o0EclNmsxZt9YCnlpOZbWUrhvfKbAW8b8Angc6F2S1BLUjIZkKlTuXfO8=
  42834. -----END CERTIFICATE-----
  42835. AffirmTrust Networking
  42836. ======================
  42837. -----BEGIN CERTIFICATE-----
  42838. MIIDTDCCAjSgAwIBAgIIfE8EORzUmS0wDQYJKoZIhvcNAQEFBQAwRDELMAkGA1UEBhMCVVMxFDAS
  42839. BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMB4XDTEw
  42840. MDEyOTE0MDgyNFoXDTMwMTIzMTE0MDgyNFowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly
  42841. bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMIIBIjANBgkqhkiG9w0BAQEF
  42842. AAOCAQ8AMIIBCgKCAQEAtITMMxcua5Rsa2FSoOujz3mUTOWUgJnLVWREZY9nZOIG41w3SfYvm4SE
  42843. Hi3yYJ0wTsyEheIszx6e/jarM3c1RNg1lho9Nuh6DtjVR6FqaYvZ/Ls6rnla1fTWcbuakCNrmreI
  42844. dIcMHl+5ni36q1Mr3Lt2PpNMCAiMHqIjHNRqrSK6mQEubWXLviRmVSRLQESxG9fhwoXA3hA/Pe24
  42845. /PHxI1Pcv2WXb9n5QHGNfb2V1M6+oF4nI979ptAmDgAp6zxG8D1gvz9Q0twmQVGeFDdCBKNwV6gb
  42846. h+0t+nvujArjqWaJGctB+d1ENmHP4ndGyH329JKBNv3bNPFyfvMMFr20FQIDAQABo0IwQDAdBgNV
  42847. HQ4EFgQUBx/S55zawm6iQLSwelAQUHTEyL0wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  42848. AQYwDQYJKoZIhvcNAQEFBQADggEBAIlXshZ6qML91tmbmzTCnLQyFE2npN/svqe++EPbkTfOtDIu
  42849. UFUaNU52Q3Eg75N3ThVwLofDwR1t3Mu1J9QsVtFSUzpE0nPIxBsFZVpikpzuQY0x2+c06lkh1QF6
  42850. 12S4ZDnNye2v7UsDSKegmQGA3GWjNq5lWUhPgkvIZfFXHeVZLgo/bNjR9eUJtGxUAArgFU2HdW23
  42851. WJZa3W3SAKD0m0i+wzekujbgfIeFlxoVot4uolu9rxj5kFDNcFn4J2dHy8egBzp90SxdbBk6ZrV9
  42852. /ZFvgrG+CJPbFEfxojfHRZ48x3evZKiT3/Zpg4Jg8klCNO1aAFSFHBY2kgxc+qatv9s=
  42853. -----END CERTIFICATE-----
  42854. AffirmTrust Premium
  42855. ===================
  42856. -----BEGIN CERTIFICATE-----
  42857. MIIFRjCCAy6gAwIBAgIIbYwURrGmCu4wDQYJKoZIhvcNAQEMBQAwQTELMAkGA1UEBhMCVVMxFDAS
  42858. BgNVBAoMC0FmZmlybVRydXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMB4XDTEwMDEy
  42859. OTE0MTAzNloXDTQwMTIzMTE0MTAzNlowQTELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRy
  42860. dXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  42861. MIICCgKCAgEAxBLfqV/+Qd3d9Z+K4/as4Tx4mrzY8H96oDMq3I0gW64tb+eT2TZwamjPjlGjhVtn
  42862. BKAQJG9dKILBl1fYSCkTtuG+kU3fhQxTGJoeJKJPj/CihQvL9Cl/0qRY7iZNyaqoe5rZ+jjeRFcV
  42863. 5fiMyNlI4g0WJx0eyIOFJbe6qlVBzAMiSy2RjYvmia9mx+n/K+k8rNrSs8PhaJyJ+HoAVt70VZVs
  42864. +7pk3WKL3wt3MutizCaam7uqYoNMtAZ6MMgpv+0GTZe5HMQxK9VfvFMSF5yZVylmd2EhMQcuJUmd
  42865. GPLu8ytxjLW6OQdJd/zvLpKQBY0tL3d770O/Nbua2Plzpyzy0FfuKE4mX4+QaAkvuPjcBukumj5R
  42866. p9EixAqnOEhss/n/fauGV+O61oV4d7pD6kh/9ti+I20ev9E2bFhc8e6kGVQa9QPSdubhjL08s9NI
  42867. S+LI+H+SqHZGnEJlPqQewQcDWkYtuJfzt9WyVSHvutxMAJf7FJUnM7/oQ0dG0giZFmA7mn7S5u04
  42868. 6uwBHjxIVkkJx0w3AJ6IDsBz4W9m6XJHMD4Q5QsDyZpCAGzFlH5hxIrff4IaC1nEWTJ3s7xgaVY5
  42869. /bQGeyzWZDbZvUjthB9+pSKPKrhC9IK31FOQeE4tGv2Bb0TXOwF0lkLgAOIua+rF7nKsu7/+6qqo
  42870. +Nz2snmKtmcCAwEAAaNCMEAwHQYDVR0OBBYEFJ3AZ6YMItkm9UWrpmVSESfYRaxjMA8GA1UdEwEB
  42871. /wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBDAUAA4ICAQCzV00QYk465KzquByv
  42872. MiPIs0laUZx2KI15qldGF9X1Uva3ROgIRL8YhNILgM3FEv0AVQVhh0HctSSePMTYyPtwni94loMg
  42873. Nt58D2kTiKV1NpgIpsbfrM7jWNa3Pt668+s0QNiigfV4Py/VpfzZotReBA4Xrf5B8OWycvpEgjNC
  42874. 6C1Y91aMYj+6QrCcDFx+LmUmXFNPALJ4fqENmS2NuB2OosSw/WDQMKSOyARiqcTtNd56l+0OOF6S
  42875. L5Nwpamcb6d9Ex1+xghIsV5n61EIJenmJWtSKZGc0jlzCFfemQa0W50QBuHCAKi4HEoCChTQwUHK
  42876. +4w1IX2COPKpVJEZNZOUbWo6xbLQu4mGk+ibyQ86p3q4ofB4Rvr8Ny/lioTz3/4E2aFooC8k4gmV
  42877. BtWVyuEklut89pMFu+1z6S3RdTnX5yTb2E5fQ4+e0BQ5v1VwSJlXMbSc7kqYA5YwH2AG7hsj/oFg
  42878. IxpHYoWlzBk0gG+zrBrjn/B7SK3VAdlntqlyk+otZrWyuOQ9PLLvTIzq6we/qzWaVYa8GKa1qF60
  42879. g2xraUDTn9zxw2lrueFtCfTxqlB2Cnp9ehehVZZCmTEJ3WARjQUwfuaORtGdFNrHF+QFlozEJLUb
  42880. zxQHskD4o55BhrwE0GuWyCqANP2/7waj3VjFhT0+j/6eKeC2uAloGRwYQw==
  42881. -----END CERTIFICATE-----
  42882. AffirmTrust Premium ECC
  42883. =======================
  42884. -----BEGIN CERTIFICATE-----
  42885. MIIB/jCCAYWgAwIBAgIIdJclisc/elQwCgYIKoZIzj0EAwMwRTELMAkGA1UEBhMCVVMxFDASBgNV
  42886. BAoMC0FmZmlybVRydXN0MSAwHgYDVQQDDBdBZmZpcm1UcnVzdCBQcmVtaXVtIEVDQzAeFw0xMDAx
  42887. MjkxNDIwMjRaFw00MDEyMzExNDIwMjRaMEUxCzAJBgNVBAYTAlVTMRQwEgYDVQQKDAtBZmZpcm1U
  42888. cnVzdDEgMB4GA1UEAwwXQWZmaXJtVHJ1c3QgUHJlbWl1bSBFQ0MwdjAQBgcqhkjOPQIBBgUrgQQA
  42889. IgNiAAQNMF4bFZ0D0KF5Nbc6PJJ6yhUczWLznCZcBz3lVPqj1swS6vQUX+iOGasvLkjmrBhDeKzQ
  42890. N8O9ss0s5kfiGuZjuD0uL3jET9v0D6RoTFVya5UdThhClXjMNzyR4ptlKymjQjBAMB0GA1UdDgQW
  42891. BBSaryl6wBE1NSZRMADDav5A1a7WPDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAK
  42892. BggqhkjOPQQDAwNnADBkAjAXCfOHiFBar8jAQr9HX/VsaobgxCd05DhT1wV/GzTjxi+zygk8N53X
  42893. 57hG8f2h4nECMEJZh0PUUd+60wkyWs6Iflc9nF9Ca/UHLbXwgpP5WW+uZPpY5Yse42O+tYHNbwKM
  42894. eQ==
  42895. -----END CERTIFICATE-----
  42896. Certum Trusted Network CA
  42897. =========================
  42898. -----BEGIN CERTIFICATE-----
  42899. MIIDuzCCAqOgAwIBAgIDBETAMA0GCSqGSIb3DQEBBQUAMH4xCzAJBgNVBAYTAlBMMSIwIAYDVQQK
  42900. ExlVbml6ZXRvIFRlY2hub2xvZ2llcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlv
  42901. biBBdXRob3JpdHkxIjAgBgNVBAMTGUNlcnR1bSBUcnVzdGVkIE5ldHdvcmsgQ0EwHhcNMDgxMDIy
  42902. MTIwNzM3WhcNMjkxMjMxMTIwNzM3WjB+MQswCQYDVQQGEwJQTDEiMCAGA1UEChMZVW5pemV0byBU
  42903. ZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  42904. MSIwIAYDVQQDExlDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENBMIIBIjANBgkqhkiG9w0BAQEFAAOC
  42905. AQ8AMIIBCgKCAQEA4/t9o3K6wvDJFIf1awFO4W5AB7ptJ11/91sts1rHUV+rpDKmYYe2bg+G0jAC
  42906. l/jXaVehGDldamR5xgFZrDwxSjh80gTSSyjoIF87B6LMTXPb865Px1bVWqeWifrzq2jUI4ZZJ88J
  42907. J7ysbnKDHDBy3+Ci6dLhdHUZvSqeexVUBBvXQzmtVSjF4hq79MDkrjhJM8x2hZ85RdKknvISjFH4
  42908. fOQtf/WsX+sWn7Et0brMkUJ3TCXJkDhv2/DM+44el1k+1WBO5gUo7Ul5E0u6SNsv+XLTOcr+H9g0
  42909. cvW0QM8xAcPs3hEtF10fuFDRXhmnad4HMyjKUJX5p1TLVIZQRan5SQIDAQABo0IwQDAPBgNVHRMB
  42910. Af8EBTADAQH/MB0GA1UdDgQWBBQIds3LB/8k9sXN7buQvOKEN0Z19zAOBgNVHQ8BAf8EBAMCAQYw
  42911. DQYJKoZIhvcNAQEFBQADggEBAKaorSLOAT2mo/9i0Eidi15ysHhE49wcrwn9I0j6vSrEuVUEtRCj
  42912. jSfeC4Jj0O7eDDd5QVsisrCaQVymcODU0HfLI9MA4GxWL+FpDQ3Zqr8hgVDZBqWo/5U30Kr+4rP1
  42913. mS1FhIrlQgnXdAIv94nYmem8J9RHjboNRhx3zxSkHLmkMcScKHQDNP8zGSal6Q10tz6XxnboJ5aj
  42914. Zt3hrvJBW8qYVoNzcOSGGtIxQbovvi0TWnZvTuhOgQ4/WwMioBK+ZlgRSssDxLQqKi2WF+A5VLxI
  42915. 03YnnZotBqbJ7DnSq9ufmgsnAjUpsUCV5/nonFWIGUbWtzT1fs45mtk48VH3Tyw=
  42916. -----END CERTIFICATE-----
  42917. TWCA Root Certification Authority
  42918. =================================
  42919. -----BEGIN CERTIFICATE-----
  42920. MIIDezCCAmOgAwIBAgIBATANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJUVzESMBAGA1UECgwJ
  42921. VEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NBIFJvb3QgQ2VydGlmaWNh
  42922. dGlvbiBBdXRob3JpdHkwHhcNMDgwODI4MDcyNDMzWhcNMzAxMjMxMTU1OTU5WjBfMQswCQYDVQQG
  42923. EwJUVzESMBAGA1UECgwJVEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NB
  42924. IFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
  42925. AoIBAQCwfnK4pAOU5qfeCTiRShFAh6d8WWQUe7UREN3+v9XAu1bihSX0NXIP+FPQQeFEAcK0HMMx
  42926. QhZHhTMidrIKbw/lJVBPhYa+v5guEGcevhEFhgWQxFnQfHgQsIBct+HHK3XLfJ+utdGdIzdjp9xC
  42927. oi2SBBtQwXu4PhvJVgSLL1KbralW6cH/ralYhzC2gfeXRfwZVzsrb+RH9JlF/h3x+JejiB03HFyP
  42928. 4HYlmlD4oFT/RJB2I9IyxsOrBr/8+7/zrX2SYgJbKdM1o5OaQ2RgXbL6Mv87BK9NQGr5x+PvI/1r
  42929. y+UPizgN7gr8/g+YnzAx3WxSZfmLgb4i4RxYA7qRG4kHAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIB
  42930. BjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqOFsmjd6LWvJPelSDGRjjCDWmujANBgkqhkiG
  42931. 9w0BAQUFAAOCAQEAPNV3PdrfibqHDAhUaiBQkr6wQT25JmSDCi/oQMCXKCeCMErJk/9q56YAf4lC
  42932. mtYR5VPOL8zy2gXE/uJQxDqGfczafhAJO5I1KlOy/usrBdlsXebQ79NqZp4VKIV66IIArB6nCWlW
  42933. QtNoURi+VJq/REG6Sb4gumlc7rh3zc5sH62Dlhh9DrUUOYTxKOkto557HnpyWoOzeW/vtPzQCqVY
  42934. T0bf+215WfKEIlKuD8z7fDvnaspHYcN6+NOSBB+4IIThNlQWx0DeO4pz3N/GCUzf7Nr/1FNCocny
  42935. Yh0igzyXxfkZYiesZSLX0zzG5Y6yU8xJzrww/nsOM5D77dIUkR8Hrw==
  42936. -----END CERTIFICATE-----
  42937. Security Communication RootCA2
  42938. ==============================
  42939. -----BEGIN CERTIFICATE-----
  42940. MIIDdzCCAl+gAwIBAgIBADANBgkqhkiG9w0BAQsFADBdMQswCQYDVQQGEwJKUDElMCMGA1UEChMc
  42941. U0VDT00gVHJ1c3QgU3lzdGVtcyBDTy4sTFRELjEnMCUGA1UECxMeU2VjdXJpdHkgQ29tbXVuaWNh
  42942. dGlvbiBSb290Q0EyMB4XDTA5MDUyOTA1MDAzOVoXDTI5MDUyOTA1MDAzOVowXTELMAkGA1UEBhMC
  42943. SlAxJTAjBgNVBAoTHFNFQ09NIFRydXN0IFN5c3RlbXMgQ08uLExURC4xJzAlBgNVBAsTHlNlY3Vy
  42944. aXR5IENvbW11bmljYXRpb24gUm9vdENBMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  42945. ANAVOVKxUrO6xVmCxF1SrjpDZYBLx/KWvNs2l9amZIyoXvDjChz335c9S672XewhtUGrzbl+dp++
  42946. +T42NKA7wfYxEUV0kz1XgMX5iZnK5atq1LXaQZAQwdbWQonCv/Q4EpVMVAX3NuRFg3sUZdbcDE3R
  42947. 3n4MqzvEFb46VqZab3ZpUql6ucjrappdUtAtCms1FgkQhNBqyjoGADdH5H5XTz+L62e4iKrFvlNV
  42948. spHEfbmwhRkGeC7bYRr6hfVKkaHnFtWOojnflLhwHyg/i/xAXmODPIMqGplrz95Zajv8bxbXH/1K
  42949. EOtOghY6rCcMU/Gt1SSwawNQwS08Ft1ENCcadfsCAwEAAaNCMEAwHQYDVR0OBBYEFAqFqXdlBZh8
  42950. QIH4D5csOPEK7DzPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEB
  42951. CwUAA4IBAQBMOqNErLlFsceTfsgLCkLfZOoc7llsCLqJX2rKSpWeeo8HxdpFcoJxDjrSzG+ntKEj
  42952. u/Ykn8sX/oymzsLS28yN/HH8AynBbF0zX2S2ZTuJbxh2ePXcokgfGT+Ok+vx+hfuzU7jBBJV1uXk
  42953. 3fs+BXziHV7Gp7yXT2g69ekuCkO2r1dcYmh8t/2jioSgrGK+KwmHNPBqAbubKVY8/gA3zyNs8U6q
  42954. tnRGEmyR7jTV7JqR50S+kDFy1UkC9gLl9B/rfNmWVan/7Ir5mUf/NVoCqgTLiluHcSmRvaS0eg29
  42955. mvVXIwAHIRc/SjnRBUkLp7Y3gaVdjKozXoEofKd9J+sAro03
  42956. -----END CERTIFICATE-----
  42957. Actalis Authentication Root CA
  42958. ==============================
  42959. -----BEGIN CERTIFICATE-----
  42960. MIIFuzCCA6OgAwIBAgIIVwoRl0LE48wwDQYJKoZIhvcNAQELBQAwazELMAkGA1UEBhMCSVQxDjAM
  42961. BgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UE
  42962. AwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290IENBMB4XDTExMDkyMjExMjIwMloXDTMwMDky
  42963. MjExMjIwMlowazELMAkGA1UEBhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlz
  42964. IFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290
  42965. IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAp8bEpSmkLO/lGMWwUKNvUTufClrJ
  42966. wkg4CsIcoBh/kbWHuUA/3R1oHwiD1S0eiKD4j1aPbZkCkpAW1V8IbInX4ay8IMKx4INRimlNAJZa
  42967. by/ARH6jDuSRzVju3PvHHkVH3Se5CAGfpiEd9UEtL0z9KK3giq0itFZljoZUj5NDKd45RnijMCO6
  42968. zfB9E1fAXdKDa0hMxKufgFpbOr3JpyI/gCczWw63igxdBzcIy2zSekciRDXFzMwujt0q7bd9Zg1f
  42969. YVEiVRvjRuPjPdA1YprbrxTIW6HMiRvhMCb8oJsfgadHHwTrozmSBp+Z07/T6k9QnBn+locePGX2
  42970. oxgkg4YQ51Q+qDp2JE+BIcXjDwL4k5RHILv+1A7TaLndxHqEguNTVHnd25zS8gebLra8Pu2Fbe8l
  42971. EfKXGkJh90qX6IuxEAf6ZYGyojnP9zz/GPvG8VqLWeICrHuS0E4UT1lF9gxeKF+w6D9Fz8+vm2/7
  42972. hNN3WpVvrJSEnu68wEqPSpP4RCHiMUVhUE4Q2OM1fEwZtN4Fv6MGn8i1zeQf1xcGDXqVdFUNaBr8
  42973. EBtiZJ1t4JWgw5QHVw0U5r0F+7if5t+L4sbnfpb2U8WANFAoWPASUHEXMLrmeGO89LKtmyuy/uE5
  42974. jF66CyCU3nuDuP/jVo23Eek7jPKxwV2dpAtMK9myGPW1n0sCAwEAAaNjMGEwHQYDVR0OBBYEFFLY
  42975. iDrIn3hm7YnzezhwlMkCAjbQMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUUtiIOsifeGbt
  42976. ifN7OHCUyQICNtAwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBCwUAA4ICAQALe3KHwGCmSUyI
  42977. WOYdiPcUZEim2FgKDk8TNd81HdTtBjHIgT5q1d07GjLukD0R0i70jsNjLiNmsGe+b7bAEzlgqqI0
  42978. JZN1Ut6nna0Oh4lScWoWPBkdg/iaKWW+9D+a2fDzWochcYBNy+A4mz+7+uAwTc+G02UQGRjRlwKx
  42979. K3JCaKygvU5a2hi/a5iB0P2avl4VSM0RFbnAKVy06Ij3Pjaut2L9HmLecHgQHEhb2rykOLpn7VU+
  42980. Xlff1ANATIGk0k9jpwlCCRT8AKnCgHNPLsBA2RF7SOp6AsDT6ygBJlh0wcBzIm2Tlf05fbsq4/aC
  42981. 4yyXX04fkZT6/iyj2HYauE2yOE+b+h1IYHkm4vP9qdCa6HCPSXrW5b0KDtst842/6+OkfcvHlXHo
  42982. 2qN8xcL4dJIEG4aspCJTQLas/kx2z/uUMsA1n3Y/buWQbqCmJqK4LL7RK4X9p2jIugErsWx0Hbhz
  42983. lefut8cl8ABMALJ+tguLHPPAUJ4lueAI3jZm/zel0btUZCzJJ7VLkn5l/9Mt4blOvH+kQSGQQXem
  42984. OR/qnuOf0GZvBeyqdn6/axag67XH/JJULysRJyU3eExRarDzzFhdFPFqSBX/wge2sY0PjlxQRrM9
  42985. vwGYT7JZVEc+NHt4bVaTLnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg==
  42986. -----END CERTIFICATE-----
  42987. Buypass Class 2 Root CA
  42988. =======================
  42989. -----BEGIN CERTIFICATE-----
  42990. MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU
  42991. QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMiBSb290IENBMB4X
  42992. DTEwMTAyNjA4MzgwM1oXDTQwMTAyNjA4MzgwM1owTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1
  42993. eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDIgUm9vdCBDQTCCAiIw
  42994. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANfHXvfBB9R3+0Mh9PT1aeTuMgHbo4Yf5FkNuud1
  42995. g1Lr6hxhFUi7HQfKjK6w3Jad6sNgkoaCKHOcVgb/S2TwDCo3SbXlzwx87vFKu3MwZfPVL4O2fuPn
  42996. 9Z6rYPnT8Z2SdIrkHJasW4DptfQxh6NR/Md+oW+OU3fUl8FVM5I+GC911K2GScuVr1QGbNgGE41b
  42997. /+EmGVnAJLqBcXmQRFBoJJRfuLMR8SlBYaNByyM21cHxMlAQTn/0hpPshNOOvEu/XAFOBz3cFIqU
  42998. CqTqc/sLUegTBxj6DvEr0VQVfTzh97QZQmdiXnfgolXsttlpF9U6r0TtSsWe5HonfOV116rLJeff
  42999. awrbD02TTqigzXsu8lkBarcNuAeBfos4GzjmCleZPe4h6KP1DBbdi+w0jpwqHAAVF41og9JwnxgI
  43000. zRFo1clrUs3ERo/ctfPYV3Me6ZQ5BL/T3jjetFPsaRyifsSP5BtwrfKi+fv3FmRmaZ9JUaLiFRhn
  43001. Bkp/1Wy1TbMz4GHrXb7pmA8y1x1LPC5aAVKRCfLf6o3YBkBjqhHk/sM3nhRSP/TizPJhk9H9Z2vX
  43002. Uq6/aKtAQ6BXNVN48FP4YUIHZMbXb5tMOA1jrGKvNouicwoN9SG9dKpN6nIDSdvHXx1iY8f93ZHs
  43003. M+71bbRuMGjeyNYmsHVee7QHIJihdjK4TWxPAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  43004. VR0OBBYEFMmAd+BikoL1RpzzuvdMw964o605MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF
  43005. AAOCAgEAU18h9bqwOlI5LJKwbADJ784g7wbylp7ppHR/ehb8t/W2+xUbP6umwHJdELFx7rxP462s
  43006. A20ucS6vxOOto70MEae0/0qyexAQH6dXQbLArvQsWdZHEIjzIVEpMMpghq9Gqx3tOluwlN5E40EI
  43007. osHsHdb9T7bWR9AUC8rmyrV7d35BH16Dx7aMOZawP5aBQW9gkOLo+fsicdl9sz1Gv7SEr5AcD48S
  43008. aq/v7h56rgJKihcrdv6sVIkkLE8/trKnToyokZf7KcZ7XC25y2a2t6hbElGFtQl+Ynhw/qlqYLYd
  43009. DnkM/crqJIByw5c/8nerQyIKx+u2DISCLIBrQYoIwOula9+ZEsuK1V6ADJHgJgg2SMX6OBE1/yWD
  43010. LfJ6v9r9jv6ly0UsH8SIU653DtmadsWOLB2jutXsMq7Aqqz30XpN69QH4kj3Io6wpJ9qzo6ysmD0
  43011. oyLQI+uUWnpp3Q+/QFesa1lQ2aOZ4W7+jQF5JyMV3pKdewlNWudLSDBaGOYKbeaP4NK75t98biGC
  43012. wWg5TbSYWGZizEqQXsP6JwSxeRV0mcy+rSDeJmAc61ZRpqPq5KM/p/9h3PFaTWwyI0PurKju7koS
  43013. CTxdccK+efrCh2gdC/1cacwG0Jp9VJkqyTkaGa9LKkPzY11aWOIv4x3kqdbQCtCev9eBCfHJxyYN
  43014. rJgWVqA=
  43015. -----END CERTIFICATE-----
  43016. Buypass Class 3 Root CA
  43017. =======================
  43018. -----BEGIN CERTIFICATE-----
  43019. MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU
  43020. QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMyBSb290IENBMB4X
  43021. DTEwMTAyNjA4Mjg1OFoXDTQwMTAyNjA4Mjg1OFowTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1
  43022. eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDMgUm9vdCBDQTCCAiIw
  43023. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKXaCpUWUOOV8l6ddjEGMnqb8RB2uACatVI2zSRH
  43024. sJ8YZLya9vrVediQYkwiL944PdbgqOkcLNt4EemOaFEVcsfzM4fkoF0LXOBXByow9c3EN3coTRiR
  43025. 5r/VUv1xLXA+58bEiuPwKAv0dpihi4dVsjoT/Lc+JzeOIuOoTyrvYLs9tznDDgFHmV0ST9tD+leh
  43026. 7fmdvhFHJlsTmKtdFoqwNxxXnUX/iJY2v7vKB3tvh2PX0DJq1l1sDPGzbjniazEuOQAnFN44wOwZ
  43027. ZoYS6J1yFhNkUsepNxz9gjDthBgd9K5c/3ATAOux9TN6S9ZV+AWNS2mw9bMoNlwUxFFzTWsL8TQH
  43028. 2xc519woe2v1n/MuwU8XKhDzzMro6/1rqy6any2CbgTUUgGTLT2G/H783+9CHaZr77kgxve9oKeV
  43029. /afmiSTYzIw0bOIjL9kSGiG5VZFvC5F5GQytQIgLcOJ60g7YaEi7ghM5EFjp2CoHxhLbWNvSO1UQ
  43030. RwUVZ2J+GGOmRj8JDlQyXr8NYnon74Do29lLBlo3WiXQCBJ31G8JUJc9yB3D34xFMFbG02SrZvPA
  43031. Xpacw8Tvw3xrizp5f7NJzz3iiZ+gMEuFuZyUJHmPfWupRWgPK9Dx2hzLabjKSWJtyNBjYt1gD1iq
  43032. j6G8BaVmos8bdrKEZLFMOVLAMLrwjEsCsLa3AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  43033. VR0OBBYEFEe4zf/lb+74suwvTg75JbCOPGvDMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF
  43034. AAOCAgEAACAjQTUEkMJAYmDv4jVM1z+s4jSQuKFvdvoWFqRINyzpkMLyPPgKn9iB5btb2iUspKdV
  43035. cSQy9sgL8rxq+JOssgfCX5/bzMiKqr5qb+FJEMwx14C7u8jYog5kV+qi9cKpMRXSIGrs/CIBKM+G
  43036. uIAeqcwRpTzyFrNHnfzSgCHEy9BHcEGhyoMZCCxt8l13nIoUE9Q2HJLw5QY33KbmkJs4j1xrG0aG
  43037. Q0JfPgEHU1RdZX33inOhmlRaHylDFCfChQ+1iHsaO5S3HWCntZznKWlXWpuTekMwGwPXYshApqr8
  43038. ZORK15FTAaggiG6cX0S5y2CBNOxv033aSF/rtJC8LakcC6wc1aJoIIAE1vyxjy+7SjENSoYc6+I2
  43039. KSb12tjE8nVhz36udmNKekBlk4f4HoCMhuWG1o8O/FMsYOgWYRqiPkN7zTlgVGr18okmAWiDSKIz
  43040. 6MkEkbIRNBE+6tBDGR8Dk5AM/1E9V/RBbuHLoL7ryWPNbczk+DaqaJ3tvV2XcEQNtg413OEMXbug
  43041. UZTLfhbrES+jkkXITHHZvMmZUldGL1DPvTVp9D0VzgalLA8+9oG6lLvDu79leNKGef9JOxqDDPDe
  43042. eOzI8k1MGt6CKfjBWtrt7uYnXuhF0J0cUahoq0Tj0Itq4/g7u9xN12TyUb7mqqta6THuBrxzvxNi
  43043. Cp/HuZc=
  43044. -----END CERTIFICATE-----
  43045. T-TeleSec GlobalRoot Class 3
  43046. ============================
  43047. -----BEGIN CERTIFICATE-----
  43048. MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM
  43049. IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU
  43050. cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwHhcNMDgx
  43051. MDAxMTAyOTU2WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz
  43052. dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD
  43053. ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwggEiMA0GCSqGSIb3
  43054. DQEBAQUAA4IBDwAwggEKAoIBAQC9dZPwYiJvJK7genasfb3ZJNW4t/zN8ELg63iIVl6bmlQdTQyK
  43055. 9tPPcPRStdiTBONGhnFBSivwKixVA9ZIw+A5OO3yXDw/RLyTPWGrTs0NvvAgJ1gORH8EGoel15YU
  43056. NpDQSXuhdfsaa3Ox+M6pCSzyU9XDFES4hqX2iys52qMzVNn6chr3IhUciJFrf2blw2qAsCTz34ZF
  43057. iP0Zf3WHHx+xGwpzJFu5ZeAsVMhg02YXP+HMVDNzkQI6pn97djmiH5a2OK61yJN0HZ65tOVgnS9W
  43058. 0eDrXltMEnAMbEQgqxHY9Bn20pxSN+f6tsIxO0rUFJmtxxr1XV/6B7h8DR/Wgx6zAgMBAAGjQjBA
  43059. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS1A/d2O2GCahKqGFPr
  43060. AyGUv/7OyjANBgkqhkiG9w0BAQsFAAOCAQEAVj3vlNW92nOyWL6ukK2YJ5f+AbGwUgC4TeQbIXQb
  43061. fsDuXmkqJa9c1h3a0nnJ85cp4IaH3gRZD/FZ1GSFS5mvJQQeyUapl96Cshtwn5z2r3Ex3XsFpSzT
  43062. ucpH9sry9uetuUg/vBa3wW306gmv7PO15wWeph6KU1HWk4HMdJP2udqmJQV0eVp+QD6CSyYRMG7h
  43063. P0HHRwA11fXT91Q+gT3aSWqas+8QPebrb9HIIkfLzM8BMZLZGOMivgkeGj5asuRrDFR6fUNOuIml
  43064. e9eiPZaGzPImNC1qkp2aGtAw4l1OBLBfiyB+d8E9lYLRRpo7PHi4b6HQDWSieB4pTpPDpFQUWw==
  43065. -----END CERTIFICATE-----
  43066. D-TRUST Root Class 3 CA 2 2009
  43067. ==============================
  43068. -----BEGIN CERTIFICATE-----
  43069. MIIEMzCCAxugAwIBAgIDCYPzMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  43070. DAxELVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTAe
  43071. Fw0wOTExMDUwODM1NThaFw0yOTExMDUwODM1NThaME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxE
  43072. LVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTCCASIw
  43073. DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANOySs96R+91myP6Oi/WUEWJNTrGa9v+2wBoqOAD
  43074. ER03UAifTUpolDWzU9GUY6cgVq/eUXjsKj3zSEhQPgrfRlWLJ23DEE0NkVJD2IfgXU42tSHKXzlA
  43075. BF9bfsyjxiupQB7ZNoTWSPOSHjRGICTBpFGOShrvUD9pXRl/RcPHAY9RySPocq60vFYJfxLLHLGv
  43076. KZAKyVXMD9O0Gu1HNVpK7ZxzBCHQqr0ME7UAyiZsxGsMlFqVlNpQmvH/pStmMaTJOKDfHR+4CS7z
  43077. p+hnUquVH+BGPtikw8paxTGA6Eian5Rp/hnd2HN8gcqW3o7tszIFZYQ05ub9VxC1X3a/L7AQDcUC
  43078. AwEAAaOCARowggEWMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFP3aFMSfMN4hvR5COfyrYyNJ
  43079. 4PGEMA4GA1UdDwEB/wQEAwIBBjCB0wYDVR0fBIHLMIHIMIGAoH6gfIZ6bGRhcDovL2RpcmVjdG9y
  43080. eS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwUm9vdCUyMENsYXNzJTIwMyUyMENBJTIwMiUyMDIw
  43081. MDksTz1ELVRydXN0JTIwR21iSCxDPURFP2NlcnRpZmljYXRlcmV2b2NhdGlvbmxpc3QwQ6BBoD+G
  43082. PWh0dHA6Ly93d3cuZC10cnVzdC5uZXQvY3JsL2QtdHJ1c3Rfcm9vdF9jbGFzc18zX2NhXzJfMjAw
  43083. OS5jcmwwDQYJKoZIhvcNAQELBQADggEBAH+X2zDI36ScfSF6gHDOFBJpiBSVYEQBrLLpME+bUMJm
  43084. 2H6NMLVwMeniacfzcNsgFYbQDfC+rAF1hM5+n02/t2A7nPPKHeJeaNijnZflQGDSNiH+0LS4F9p0
  43085. o3/U37CYAqxva2ssJSRyoWXuJVrl5jLn8t+rSfrzkGkj2wTZ51xY/GXUl77M/C4KzCUqNQT4YJEV
  43086. dT1B/yMfGchs64JTBKbkTCJNjYy6zltz7GRUUG3RnFX7acM2w4y8PIWmawomDeCTmGCufsYkl4ph
  43087. X5GOZpIJhzbNi5stPvZR1FDUWSi9g/LMKHtThm3YJohw1+qRzT65ysCQblrGXnRl11z+o+I=
  43088. -----END CERTIFICATE-----
  43089. D-TRUST Root Class 3 CA 2 EV 2009
  43090. =================================
  43091. -----BEGIN CERTIFICATE-----
  43092. MIIEQzCCAyugAwIBAgIDCYP0MA0GCSqGSIb3DQEBCwUAMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  43093. DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw
  43094. OTAeFw0wOTExMDUwODUwNDZaFw0yOTExMDUwODUwNDZaMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  43095. DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw
  43096. OTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJnxhDRwui+3MKCOvXwEz75ivJn9gpfS
  43097. egpnljgJ9hBOlSJzmY3aFS3nBfwZcyK3jpgAvDw9rKFs+9Z5JUut8Mxk2og+KbgPCdM03TP1YtHh
  43098. zRnp7hhPTFiu4h7WDFsVWtg6uMQYZB7jM7K1iXdODL/ZlGsTl28So/6ZqQTMFexgaDbtCHu39b+T
  43099. 7WYxg4zGcTSHThfqr4uRjRxWQa4iN1438h3Z0S0NL2lRp75mpoo6Kr3HGrHhFPC+Oh25z1uxav60
  43100. sUYgovseO3Dvk5h9jHOW8sXvhXCtKSb8HgQ+HKDYD8tSg2J87otTlZCpV6LqYQXY+U3EJ/pure35
  43101. 11H3a6UCAwEAAaOCASQwggEgMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFNOUikxiEyoZLsyv
  43102. cop9NteaHNxnMA4GA1UdDwEB/wQEAwIBBjCB3QYDVR0fBIHVMIHSMIGHoIGEoIGBhn9sZGFwOi8v
  43103. ZGlyZWN0b3J5LmQtdHJ1c3QubmV0L0NOPUQtVFJVU1QlMjBSb290JTIwQ2xhc3MlMjAzJTIwQ0El
  43104. MjAyJTIwRVYlMjAyMDA5LE89RC1UcnVzdCUyMEdtYkgsQz1ERT9jZXJ0aWZpY2F0ZXJldm9jYXRp
  43105. b25saXN0MEagRKBChkBodHRwOi8vd3d3LmQtdHJ1c3QubmV0L2NybC9kLXRydXN0X3Jvb3RfY2xh
  43106. c3NfM19jYV8yX2V2XzIwMDkuY3JsMA0GCSqGSIb3DQEBCwUAA4IBAQA07XtaPKSUiO8aEXUHL7P+
  43107. PPoeUSbrh/Yp3uDx1MYkCenBz1UbtDDZzhr+BlGmFaQt77JLvyAoJUnRpjZ3NOhk31KxEcdzes05
  43108. nsKtjHEh8lprr988TlWvsoRlFIm5d8sqMb7Po23Pb0iUMkZv53GMoKaEGTcH8gNFCSuGdXzfX2lX
  43109. ANtu2KZyIktQ1HWYVt+3GP9DQ1CuekR78HlR10M9p9OB0/DJT7naxpeG0ILD5EJt/rDiZE4OJudA
  43110. NCa1CInXCGNjOCd1HjPqbqjdn5lPdE2BiYBL3ZqXKVwvvoFBuYz/6n1gBp7N1z3TLqMVvKjmJuVv
  43111. w9y4AyHqnxbxLFS1
  43112. -----END CERTIFICATE-----
  43113. CA Disig Root R2
  43114. ================
  43115. -----BEGIN CERTIFICATE-----
  43116. MIIFaTCCA1GgAwIBAgIJAJK4iNuwisFjMA0GCSqGSIb3DQEBCwUAMFIxCzAJBgNVBAYTAlNLMRMw
  43117. EQYDVQQHEwpCcmF0aXNsYXZhMRMwEQYDVQQKEwpEaXNpZyBhLnMuMRkwFwYDVQQDExBDQSBEaXNp
  43118. ZyBSb290IFIyMB4XDTEyMDcxOTA5MTUzMFoXDTQyMDcxOTA5MTUzMFowUjELMAkGA1UEBhMCU0sx
  43119. EzARBgNVBAcTCkJyYXRpc2xhdmExEzARBgNVBAoTCkRpc2lnIGEucy4xGTAXBgNVBAMTEENBIERp
  43120. c2lnIFJvb3QgUjIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCio8QACdaFXS1tFPbC
  43121. w3OeNcJxVX6B+6tGUODBfEl45qt5WDza/3wcn9iXAng+a0EE6UG9vgMsRfYvZNSrXaNHPWSb6Wia
  43122. xswbP7q+sos0Ai6YVRn8jG+qX9pMzk0DIaPY0jSTVpbLTAwAFjxfGs3Ix2ymrdMxp7zo5eFm1tL7
  43123. A7RBZckQrg4FY8aAamkw/dLukO8NJ9+flXP04SXabBbeQTg06ov80egEFGEtQX6sx3dOy1FU+16S
  43124. GBsEWmjGycT6txOgmLcRK7fWV8x8nhfRyyX+hk4kLlYMeE2eARKmK6cBZW58Yh2EhN/qwGu1pSqV
  43125. g8NTEQxzHQuyRpDRQjrOQG6Vrf/GlK1ul4SOfW+eioANSW1z4nuSHsPzwfPrLgVv2RvPN3YEyLRa
  43126. 5Beny912H9AZdugsBbPWnDTYltxhh5EF5EQIM8HauQhl1K6yNg3ruji6DOWbnuuNZt2Zz9aJQfYE
  43127. koopKW1rOhzndX0CcQ7zwOe9yxndnWCywmZgtrEE7snmhrmaZkCo5xHtgUUDi/ZnWejBBhG93c+A
  43128. Ak9lQHhcR1DIm+YfgXvkRKhbhZri3lrVx/k6RGZL5DJUfORsnLMOPReisjQS1n6yqEm70XooQL6i
  43129. Fh/f5DcfEXP7kAplQ6INfPgGAVUzfbANuPT1rqVCV3w2EYx7XsQDnYx5nQIDAQABo0IwQDAPBgNV
  43130. HRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUtZn4r7CU9eMg1gqtzk5WpC5u
  43131. Qu0wDQYJKoZIhvcNAQELBQADggIBACYGXnDnZTPIgm7ZnBc6G3pmsgH2eDtpXi/q/075KMOYKmFM
  43132. tCQSin1tERT3nLXK5ryeJ45MGcipvXrA1zYObYVybqjGom32+nNjf7xueQgcnYqfGopTpti72TVV
  43133. sRHFqQOzVju5hJMiXn7B9hJSi+osZ7z+Nkz1uM/Rs0mSO9MpDpkblvdhuDvEK7Z4bLQjb/D907Je
  43134. dR+Zlais9trhxTF7+9FGs9K8Z7RiVLoJ92Owk6Ka+elSLotgEqv89WBW7xBci8QaQtyDW2QOy7W8
  43135. 1k/BfDxujRNt+3vrMNDcTa/F1balTFtxyegxvug4BkihGuLq0t4SOVga/4AOgnXmt8kHbA7v/zjx
  43136. mHHEt38OFdAlab0inSvtBfZGR6ztwPDUO+Ls7pZbkBNOHlY667DvlruWIxG68kOGdGSVyCh13x01
  43137. utI3gzhTODY7z2zp+WsO0PsE6E9312UBeIYMej4hYvF/Y3EMyZ9E26gnonW+boE+18DrG5gPcFw0
  43138. sorMwIUY6256s/daoQe/qUKS82Ail+QUoQebTnbAjn39pCXHR+3/H3OszMOl6W8KjptlwlCFtaOg
  43139. UxLMVYdh84GuEEZhvUQhuMI9dM9+JDX6HAcOmz0iyu8xL4ysEr3vQCj8KWefshNPZiTEUxnpHikV
  43140. 7+ZtsH8tZ/3zbBt1RqPlShfppNcL
  43141. -----END CERTIFICATE-----
  43142. ACCVRAIZ1
  43143. =========
  43144. -----BEGIN CERTIFICATE-----
  43145. MIIH0zCCBbugAwIBAgIIXsO3pkN/pOAwDQYJKoZIhvcNAQEFBQAwQjESMBAGA1UEAwwJQUNDVlJB
  43146. SVoxMRAwDgYDVQQLDAdQS0lBQ0NWMQ0wCwYDVQQKDARBQ0NWMQswCQYDVQQGEwJFUzAeFw0xMTA1
  43147. MDUwOTM3MzdaFw0zMDEyMzEwOTM3MzdaMEIxEjAQBgNVBAMMCUFDQ1ZSQUlaMTEQMA4GA1UECwwH
  43148. UEtJQUNDVjENMAsGA1UECgwEQUNDVjELMAkGA1UEBhMCRVMwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  43149. DwAwggIKAoICAQCbqau/YUqXry+XZpp0X9DZlv3P4uRm7x8fRzPCRKPfmt4ftVTdFXxpNRFvu8gM
  43150. jmoYHtiP2Ra8EEg2XPBjs5BaXCQ316PWywlxufEBcoSwfdtNgM3802/J+Nq2DoLSRYWoG2ioPej0
  43151. RGy9ocLLA76MPhMAhN9KSMDjIgro6TenGEyxCQ0jVn8ETdkXhBilyNpAlHPrzg5XPAOBOp0KoVdD
  43152. aaxXbXmQeOW1tDvYvEyNKKGno6e6Ak4l0Squ7a4DIrhrIA8wKFSVf+DuzgpmndFALW4ir50awQUZ
  43153. 0m/A8p/4e7MCQvtQqR0tkw8jq8bBD5L/0KIV9VMJcRz/RROE5iZe+OCIHAr8Fraocwa48GOEAqDG
  43154. WuzndN9wrqODJerWx5eHk6fGioozl2A3ED6XPm4pFdahD9GILBKfb6qkxkLrQaLjlUPTAYVtjrs7
  43155. 8yM2x/474KElB0iryYl0/wiPgL/AlmXz7uxLaL2diMMxs0Dx6M/2OLuc5NF/1OVYm3z61PMOm3WR
  43156. 5LpSLhl+0fXNWhn8ugb2+1KoS5kE3fj5tItQo05iifCHJPqDQsGH+tUtKSpacXpkatcnYGMN285J
  43157. 9Y0fkIkyF/hzQ7jSWpOGYdbhdQrqeWZ2iE9x6wQl1gpaepPluUsXQA+xtrn13k/c4LOsOxFwYIRK
  43158. Q26ZIMApcQrAZQIDAQABo4ICyzCCAscwfQYIKwYBBQUHAQEEcTBvMEwGCCsGAQUFBzAChkBodHRw
  43159. Oi8vd3d3LmFjY3YuZXMvZmlsZWFkbWluL0FyY2hpdm9zL2NlcnRpZmljYWRvcy9yYWl6YWNjdjEu
  43160. Y3J0MB8GCCsGAQUFBzABhhNodHRwOi8vb2NzcC5hY2N2LmVzMB0GA1UdDgQWBBTSh7Tj3zcnk1X2
  43161. VuqB5TbMjB4/vTAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFNKHtOPfNyeTVfZW6oHlNsyM
  43162. Hj+9MIIBcwYDVR0gBIIBajCCAWYwggFiBgRVHSAAMIIBWDCCASIGCCsGAQUFBwICMIIBFB6CARAA
  43163. QQB1AHQAbwByAGkAZABhAGQAIABkAGUAIABDAGUAcgB0AGkAZgBpAGMAYQBjAGkA8wBuACAAUgBh
  43164. AO0AegAgAGQAZQAgAGwAYQAgAEEAQwBDAFYAIAAoAEEAZwBlAG4AYwBpAGEAIABkAGUAIABUAGUA
  43165. YwBuAG8AbABvAGcA7QBhACAAeQAgAEMAZQByAHQAaQBmAGkAYwBhAGMAaQDzAG4AIABFAGwAZQBj
  43166. AHQAcgDzAG4AaQBjAGEALAAgAEMASQBGACAAUQA0ADYAMAAxADEANQA2AEUAKQAuACAAQwBQAFMA
  43167. IABlAG4AIABoAHQAdABwADoALwAvAHcAdwB3AC4AYQBjAGMAdgAuAGUAczAwBggrBgEFBQcCARYk
  43168. aHR0cDovL3d3dy5hY2N2LmVzL2xlZ2lzbGFjaW9uX2MuaHRtMFUGA1UdHwROMEwwSqBIoEaGRGh0
  43169. dHA6Ly93d3cuYWNjdi5lcy9maWxlYWRtaW4vQXJjaGl2b3MvY2VydGlmaWNhZG9zL3JhaXphY2N2
  43170. MV9kZXIuY3JsMA4GA1UdDwEB/wQEAwIBBjAXBgNVHREEEDAOgQxhY2N2QGFjY3YuZXMwDQYJKoZI
  43171. hvcNAQEFBQADggIBAJcxAp/n/UNnSEQU5CmH7UwoZtCPNdpNYbdKl02125DgBS4OxnnQ8pdpD70E
  43172. R9m+27Up2pvZrqmZ1dM8MJP1jaGo/AaNRPTKFpV8M9xii6g3+CfYCS0b78gUJyCpZET/LtZ1qmxN
  43173. YEAZSUNUY9rizLpm5U9EelvZaoErQNV/+QEnWCzI7UiRfD+mAM/EKXMRNt6GGT6d7hmKG9Ww7Y49
  43174. nCrADdg9ZuM8Db3VlFzi4qc1GwQA9j9ajepDvV+JHanBsMyZ4k0ACtrJJ1vnE5Bc5PUzolVt3OAJ
  43175. TS+xJlsndQAJxGJ3KQhfnlmstn6tn1QwIgPBHnFk/vk4CpYY3QIUrCPLBhwepH2NDd4nQeit2hW3
  43176. sCPdK6jT2iWH7ehVRE2I9DZ+hJp4rPcOVkkO1jMl1oRQQmwgEh0q1b688nCBpHBgvgW1m54ERL5h
  43177. I6zppSSMEYCUWqKiuUnSwdzRp+0xESyeGabu4VXhwOrPDYTkF7eifKXeVSUG7szAh1xA2syVP1Xg
  43178. Nce4hL60Xc16gwFy7ofmXx2utYXGJt/mwZrpHgJHnyqobalbz+xFd3+YJ5oyXSrjhO7FmGYvliAd
  43179. 3djDJ9ew+f7Zfc3Qn48LFFhRny+Lwzgt3uiP1o2HpPVWQxaZLPSkVrQ0uGE3ycJYgBugl6H8WY3p
  43180. EfbRD0tVNEYqi4Y7
  43181. -----END CERTIFICATE-----
  43182. TWCA Global Root CA
  43183. ===================
  43184. -----BEGIN CERTIFICATE-----
  43185. MIIFQTCCAymgAwIBAgICDL4wDQYJKoZIhvcNAQELBQAwUTELMAkGA1UEBhMCVFcxEjAQBgNVBAoT
  43186. CVRBSVdBTi1DQTEQMA4GA1UECxMHUm9vdCBDQTEcMBoGA1UEAxMTVFdDQSBHbG9iYWwgUm9vdCBD
  43187. QTAeFw0xMjA2MjcwNjI4MzNaFw0zMDEyMzExNTU5NTlaMFExCzAJBgNVBAYTAlRXMRIwEAYDVQQK
  43188. EwlUQUlXQU4tQ0ExEDAOBgNVBAsTB1Jvb3QgQ0ExHDAaBgNVBAMTE1RXQ0EgR2xvYmFsIFJvb3Qg
  43189. Q0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCwBdvI64zEbooh745NnHEKH1Jw7W2C
  43190. nJfF10xORUnLQEK1EjRsGcJ0pDFfhQKX7EMzClPSnIyOt7h52yvVavKOZsTuKwEHktSz0ALfUPZV
  43191. r2YOy+BHYC8rMjk1Ujoog/h7FsYYuGLWRyWRzvAZEk2tY/XTP3VfKfChMBwqoJimFb3u/Rk28OKR
  43192. Q4/6ytYQJ0lM793B8YVwm8rqqFpD/G2Gb3PpN0Wp8DbHzIh1HrtsBv+baz4X7GGqcXzGHaL3SekV
  43193. tTzWoWH1EfcFbx39Eb7QMAfCKbAJTibc46KokWofwpFFiFzlmLhxpRUZyXx1EcxwdE8tmx2RRP1W
  43194. KKD+u4ZqyPpcC1jcxkt2yKsi2XMPpfRaAok/T54igu6idFMqPVMnaR1sjjIsZAAmY2E2TqNGtz99
  43195. sy2sbZCilaLOz9qC5wc0GZbpuCGqKX6mOL6OKUohZnkfs8O1CWfe1tQHRvMq2uYiN2DLgbYPoA/p
  43196. yJV/v1WRBXrPPRXAb94JlAGD1zQbzECl8LibZ9WYkTunhHiVJqRaCPgrdLQABDzfuBSO6N+pjWxn
  43197. kjMdwLfS7JLIvgm/LCkFbwJrnu+8vyq8W8BQj0FwcYeyTbcEqYSjMq+u7msXi7Kx/mzhkIyIqJdI
  43198. zshNy/MGz19qCkKxHh53L46g5pIOBvwFItIm4TFRfTLcDwIDAQABoyMwITAOBgNVHQ8BAf8EBAMC
  43199. AQYwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEAXzSBdu+WHdXltdkCY4QWwa6g
  43200. cFGn90xHNcgL1yg9iXHZqjNB6hQbbCEAwGxCGX6faVsgQt+i0trEfJdLjbDorMjupWkEmQqSpqsn
  43201. LhpNgb+E1HAerUf+/UqdM+DyucRFCCEK2mlpc3INvjT+lIutwx4116KD7+U4x6WFH6vPNOw/KP4M
  43202. 8VeGTslV9xzU2KV9Bnpv1d8Q34FOIWWxtuEXeZVFBs5fzNxGiWNoRI2T9GRwoD2dKAXDOXC4Ynsg
  43203. /eTb6QihuJ49CcdP+yz4k3ZB3lLg4VfSnQO8d57+nile98FRYB/e2guyLXW3Q0iT5/Z5xoRdgFlg
  43204. lPx4mI88k1HtQJAH32RjJMtOcQWh15QaiDLxInQirqWm2BJpTGCjAu4r7NRjkgtevi92a6O2JryP
  43205. A9gK8kxkRr05YuWW6zRjESjMlfGt7+/cgFhI6Uu46mWs6fyAtbXIRfmswZ/ZuepiiI7E8UuDEq3m
  43206. i4TWnsLrgxifarsbJGAzcMzs9zLzXNl5fe+epP7JI8Mk7hWSsT2RTyaGvWZzJBPqpK5jwa19hAM8
  43207. EHiGG3njxPPyBJUgriOCxLM6AGK/5jYk4Ve6xx6QddVfP5VhK8E7zeWzaGHQRiapIVJpLesux+t3
  43208. zqY6tQMzT3bR51xUAV3LePTJDL/PEo4XLSNolOer/qmyKwbQBM0=
  43209. -----END CERTIFICATE-----
  43210. TeliaSonera Root CA v1
  43211. ======================
  43212. -----BEGIN CERTIFICATE-----
  43213. MIIFODCCAyCgAwIBAgIRAJW+FqD3LkbxezmCcvqLzZYwDQYJKoZIhvcNAQEFBQAwNzEUMBIGA1UE
  43214. CgwLVGVsaWFTb25lcmExHzAdBgNVBAMMFlRlbGlhU29uZXJhIFJvb3QgQ0EgdjEwHhcNMDcxMDE4
  43215. MTIwMDUwWhcNMzIxMDE4MTIwMDUwWjA3MRQwEgYDVQQKDAtUZWxpYVNvbmVyYTEfMB0GA1UEAwwW
  43216. VGVsaWFTb25lcmEgUm9vdCBDQSB2MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMK+
  43217. 6yfwIaPzaSZVfp3FVRaRXP3vIb9TgHot0pGMYzHw7CTww6XScnwQbfQ3t+XmfHnqjLWCi65ItqwA
  43218. 3GV17CpNX8GH9SBlK4GoRz6JI5UwFpB/6FcHSOcZrr9FZ7E3GwYq/t75rH2D+1665I+XZ75Ljo1k
  43219. B1c4VWk0Nj0TSO9P4tNmHqTPGrdeNjPUtAa9GAH9d4RQAEX1jF3oI7x+/jXh7VB7qTCNGdMJjmhn
  43220. Xb88lxhTuylixcpecsHHltTbLaC0H2kD7OriUPEMPPCs81Mt8Bz17Ww5OXOAFshSsCPN4D7c3TxH
  43221. oLs1iuKYaIu+5b9y7tL6pe0S7fyYGKkmdtwoSxAgHNN/Fnct7W+A90m7UwW7XWjH1Mh1Fj+JWov3
  43222. F0fUTPHSiXk+TT2YqGHeOh7S+F4D4MHJHIzTjU3TlTazN19jY5szFPAtJmtTfImMMsJu7D0hADnJ
  43223. oWjiUIMusDor8zagrC/kb2HCUQk5PotTubtn2txTuXZZNp1D5SDgPTJghSJRt8czu90VL6R4pgd7
  43224. gUY2BIbdeTXHlSw7sKMXNeVzH7RcWe/a6hBle3rQf5+ztCo3O3CLm1u5K7fsslESl1MpWtTwEhDc
  43225. TwK7EpIvYtQ/aUN8Ddb8WHUBiJ1YFkveupD/RwGJBmr2X7KQarMCpgKIv7NHfirZ1fpoeDVNAgMB
  43226. AAGjPzA9MA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1UdDgQWBBTwj1k4ALP1j5qW
  43227. DNXr+nuqF+gTEjANBgkqhkiG9w0BAQUFAAOCAgEAvuRcYk4k9AwI//DTDGjkk0kiP0Qnb7tt3oNm
  43228. zqjMDfz1mgbldxSR651Be5kqhOX//CHBXfDkH1e3damhXwIm/9fH907eT/j3HEbAek9ALCI18Bmx
  43229. 0GtnLLCo4MBANzX2hFxc469CeP6nyQ1Q6g2EdvZR74NTxnr/DlZJLo961gzmJ1TjTQpgcmLNkQfW
  43230. pb/ImWvtxBnmq0wROMVvMeJuScg/doAmAyYp4Db29iBT4xdwNBedY2gea+zDTYa4EzAvXUYNR0PV
  43231. G6pZDrlcjQZIrXSHX8f8MVRBE+LHIQ6e4B4N4cB7Q4WQxYpYxmUKeFfyxiMPAdkgS94P+5KFdSpc
  43232. c41teyWRyu5FrgZLAMzTsVlQ2jqIOylDRl6XK1TOU2+NSueW+r9xDkKLfP0ooNBIytrEgUy7onOT
  43233. JsjrDNYmiLbAJM+7vVvrdX3pCI6GMyx5dwlppYn8s3CQh3aP0yK7Qs69cwsgJirQmz1wHiRszYd2
  43234. qReWt88NkvuOGKmYSdGe/mBEciG5Ge3C9THxOUiIkCR1VBatzvT4aRRkOfujuLpwQMcnHL/EVlP6
  43235. Y2XQ8xwOFvVrhlhNGNTkDY6lnVuR3HYkUD/GKvvZt5y11ubQ2egZixVxSK236thZiNSQvxaz2ems
  43236. WWFUyBy6ysHK4bkgTI86k4mloMy/0/Z1pHWWbVY=
  43237. -----END CERTIFICATE-----
  43238. T-TeleSec GlobalRoot Class 2
  43239. ============================
  43240. -----BEGIN CERTIFICATE-----
  43241. MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM
  43242. IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU
  43243. cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwHhcNMDgx
  43244. MDAxMTA0MDE0WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz
  43245. dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD
  43246. ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwggEiMA0GCSqGSIb3
  43247. DQEBAQUAA4IBDwAwggEKAoIBAQCqX9obX+hzkeXaXPSi5kfl82hVYAUdAqSzm1nzHoqvNK38DcLZ
  43248. SBnuaY/JIPwhqgcZ7bBcrGXHX+0CfHt8LRvWurmAwhiCFoT6ZrAIxlQjgeTNuUk/9k9uN0goOA/F
  43249. vudocP05l03Sx5iRUKrERLMjfTlH6VJi1hKTXrcxlkIF+3anHqP1wvzpesVsqXFP6st4vGCvx970
  43250. 2cu+fjOlbpSD8DT6IavqjnKgP6TeMFvvhk1qlVtDRKgQFRzlAVfFmPHmBiiRqiDFt1MmUUOyCxGV
  43251. WOHAD3bZwI18gfNycJ5v/hqO2V81xrJvNHy+SE/iWjnX2J14np+GPgNeGYtEotXHAgMBAAGjQjBA
  43252. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS/WSA2AHmgoCJrjNXy
  43253. YdK4LMuCSjANBgkqhkiG9w0BAQsFAAOCAQEAMQOiYQsfdOhyNsZt+U2e+iKo4YFWz827n+qrkRk4
  43254. r6p8FU3ztqONpfSO9kSpp+ghla0+AGIWiPACuvxhI+YzmzB6azZie60EI4RYZeLbK4rnJVM3YlNf
  43255. vNoBYimipidx5joifsFvHZVwIEoHNN/q/xWA5brXethbdXwFeilHfkCoMRN3zUA7tFFHei4R40cR
  43256. 3p1m0IvVVGb6g1XqfMIpiRvpb7PO4gWEyS8+eIVibslfwXhjdFjASBgMmTnrpMwatXlajRWc2BQN
  43257. 9noHV8cigwUtPJslJj0Ys6lDfMjIq2SPDqO/nBudMNva0Bkuqjzx+zOAduTNrRlPBSeOE6Fuwg==
  43258. -----END CERTIFICATE-----
  43259. Atos TrustedRoot 2011
  43260. =====================
  43261. -----BEGIN CERTIFICATE-----
  43262. MIIDdzCCAl+gAwIBAgIIXDPLYixfszIwDQYJKoZIhvcNAQELBQAwPDEeMBwGA1UEAwwVQXRvcyBU
  43263. cnVzdGVkUm9vdCAyMDExMQ0wCwYDVQQKDARBdG9zMQswCQYDVQQGEwJERTAeFw0xMTA3MDcxNDU4
  43264. MzBaFw0zMDEyMzEyMzU5NTlaMDwxHjAcBgNVBAMMFUF0b3MgVHJ1c3RlZFJvb3QgMjAxMTENMAsG
  43265. A1UECgwEQXRvczELMAkGA1UEBhMCREUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCV
  43266. hTuXbyo7LjvPpvMpNb7PGKw+qtn4TaA+Gke5vJrf8v7MPkfoepbCJI419KkM/IL9bcFyYie96mvr
  43267. 54rMVD6QUM+A1JX76LWC1BTFtqlVJVfbsVD2sGBkWXppzwO3bw2+yj5vdHLqqjAqc2K+SZFhyBH+
  43268. DgMq92og3AIVDV4VavzjgsG1xZ1kCWyjWZgHJ8cblithdHFsQ/H3NYkQ4J7sVaE3IqKHBAUsR320
  43269. HLliKWYoyrfhk/WklAOZuXCFteZI6o1Q/NnezG8HDt0Lcp2AMBYHlT8oDv3FdU9T1nSatCQujgKR
  43270. z3bFmx5VdJx4IbHwLfELn8LVlhgf8FQieowHAgMBAAGjfTB7MB0GA1UdDgQWBBSnpQaxLKYJYO7R
  43271. l+lwrrw7GWzbITAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFKelBrEspglg7tGX6XCuvDsZ
  43272. bNshMBgGA1UdIAQRMA8wDQYLKwYBBAGwLQMEAQEwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEB
  43273. CwUAA4IBAQAmdzTblEiGKkGdLD4GkGDEjKwLVLgfuXvTBznk+j57sj1O7Z8jvZfza1zv7v1Apt+h
  43274. k6EKhqzvINB5Ab149xnYJDE0BAGmuhWawyfc2E8PzBhj/5kPDpFrdRbhIfzYJsdHt6bPWHJxfrrh
  43275. TZVHO8mvbaG0weyJ9rQPOLXiZNwlz6bb65pcmaHFCN795trV1lpFDMS3wrUU77QR/w4VtfX128a9
  43276. 61qn8FYiqTxlVMYVqL2Gns2Dlmh6cYGJ4Qvh6hEbaAjMaZ7snkGeRDImeuKHCnE96+RapNLbxc3G
  43277. 3mB/ufNPRJLvKrcYPqcZ2Qt9sTdBQrC6YB3y/gkRsPCHe6ed
  43278. -----END CERTIFICATE-----
  43279. QuoVadis Root CA 1 G3
  43280. =====================
  43281. -----BEGIN CERTIFICATE-----
  43282. MIIFYDCCA0igAwIBAgIUeFhfLq0sGUvjNwc1NBMotZbUZZMwDQYJKoZIhvcNAQELBQAwSDELMAkG
  43283. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  43284. b3QgQ0EgMSBHMzAeFw0xMjAxMTIxNzI3NDRaFw00MjAxMTIxNzI3NDRaMEgxCzAJBgNVBAYTAkJN
  43285. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDEg
  43286. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCgvlAQjunybEC0BJyFuTHK3C3kEakE
  43287. PBtVwedYMB0ktMPvhd6MLOHBPd+C5k+tR4ds7FtJwUrVu4/sh6x/gpqG7D0DmVIB0jWerNrwU8lm
  43288. PNSsAgHaJNM7qAJGr6Qc4/hzWHa39g6QDbXwz8z6+cZM5cOGMAqNF34168Xfuw6cwI2H44g4hWf6
  43289. Pser4BOcBRiYz5P1sZK0/CPTz9XEJ0ngnjybCKOLXSoh4Pw5qlPafX7PGglTvF0FBM+hSo+LdoIN
  43290. ofjSxxR3W5A2B4GbPgb6Ul5jxaYA/qXpUhtStZI5cgMJYr2wYBZupt0lwgNm3fME0UDiTouG9G/l
  43291. g6AnhF4EwfWQvTA9xO+oabw4m6SkltFi2mnAAZauy8RRNOoMqv8hjlmPSlzkYZqn0ukqeI1RPToV
  43292. 7qJZjqlc3sX5kCLliEVx3ZGZbHqfPT2YfF72vhZooF6uCyP8Wg+qInYtyaEQHeTTRCOQiJ/GKubX
  43293. 9ZqzWB4vMIkIG1SitZgj7Ah3HJVdYdHLiZxfokqRmu8hqkkWCKi9YSgxyXSthfbZxbGL0eUQMk1f
  43294. iyA6PEkfM4VZDdvLCXVDaXP7a3F98N/ETH3Goy7IlXnLc6KOTk0k+17kBL5yG6YnLUlamXrXXAkg
  43295. t3+UuU/xDRxeiEIbEbfnkduebPRq34wGmAOtzCjvpUfzUwIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  43296. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUo5fW816iEOGrRZ88F2Q87gFwnMwwDQYJKoZI
  43297. hvcNAQELBQADggIBABj6W3X8PnrHX3fHyt/PX8MSxEBd1DKquGrX1RUVRpgjpeaQWxiZTOOtQqOC
  43298. MTaIzen7xASWSIsBx40Bz1szBpZGZnQdT+3Btrm0DWHMY37XLneMlhwqI2hrhVd2cDMT/uFPpiN3
  43299. GPoajOi9ZcnPP/TJF9zrx7zABC4tRi9pZsMbj/7sPtPKlL92CiUNqXsCHKnQO18LwIE6PWThv6ct
  43300. Tr1NxNgpxiIY0MWscgKCP6o6ojoilzHdCGPDdRS5YCgtW2jgFqlmgiNR9etT2DGbe+m3nUvriBbP
  43301. +V04ikkwj+3x6xn0dxoxGE1nVGwvb2X52z3sIexe9PSLymBlVNFxZPT5pqOBMzYzcfCkeF9OrYMh
  43302. 3jRJjehZrJ3ydlo28hP0r+AJx2EqbPfgna67hkooby7utHnNkDPDs3b69fBsnQGQ+p6Q9pxyz0fa
  43303. wx/kNSBT8lTR32GDpgLiJTjehTItXnOQUl1CxM49S+H5GYQd1aJQzEH7QRTDvdbJWqNjZgKAvQU6
  43304. O0ec7AAmTPWIUb+oI38YB7AL7YsmoWTTYUrrXJ/es69nA7Mf3W1daWhpq1467HxpvMc7hU6eFbm0
  43305. FU/DlXpY18ls6Wy58yljXrQs8C097Vpl4KlbQMJImYFtnh8GKjwStIsPm6Ik8KaN1nrgS7ZklmOV
  43306. hMJKzRwuJIczYOXD
  43307. -----END CERTIFICATE-----
  43308. QuoVadis Root CA 2 G3
  43309. =====================
  43310. -----BEGIN CERTIFICATE-----
  43311. MIIFYDCCA0igAwIBAgIURFc0JFuBiZs18s64KztbpybwdSgwDQYJKoZIhvcNAQELBQAwSDELMAkG
  43312. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  43313. b3QgQ0EgMiBHMzAeFw0xMjAxMTIxODU5MzJaFw00MjAxMTIxODU5MzJaMEgxCzAJBgNVBAYTAkJN
  43314. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDIg
  43315. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQChriWyARjcV4g/Ruv5r+LrI3HimtFh
  43316. ZiFfqq8nUeVuGxbULX1QsFN3vXg6YOJkApt8hpvWGo6t/x8Vf9WVHhLL5hSEBMHfNrMWn4rjyduY
  43317. NM7YMxcoRvynyfDStNVNCXJJ+fKH46nafaF9a7I6JaltUkSs+L5u+9ymc5GQYaYDFCDy54ejiK2t
  43318. oIz/pgslUiXnFgHVy7g1gQyjO/Dh4fxaXc6AcW34Sas+O7q414AB+6XrW7PFXmAqMaCvN+ggOp+o
  43319. MiwMzAkd056OXbxMmO7FGmh77FOm6RQ1o9/NgJ8MSPsc9PG/Srj61YxxSscfrf5BmrODXfKEVu+l
  43320. V0POKa2Mq1W/xPtbAd0jIaFYAI7D0GoT7RPjEiuA3GfmlbLNHiJuKvhB1PLKFAeNilUSxmn1uIZo
  43321. L1NesNKqIcGY5jDjZ1XHm26sGahVpkUG0CM62+tlXSoREfA7T8pt9DTEceT/AFr2XK4jYIVz8eQQ
  43322. sSWu1ZK7E8EM4DnatDlXtas1qnIhO4M15zHfeiFuuDIIfR0ykRVKYnLP43ehvNURG3YBZwjgQQvD
  43323. 6xVu+KQZ2aKrr+InUlYrAoosFCT5v0ICvybIxo/gbjh9Uy3l7ZizlWNof/k19N+IxWA1ksB8aRxh
  43324. lRbQ694Lrz4EEEVlWFA4r0jyWbYW8jwNkALGcC4BrTwV1wIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  43325. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQU7edvdlq/YOxJW8ald7tyFnGbxD0wDQYJKoZI
  43326. hvcNAQELBQADggIBAJHfgD9DCX5xwvfrs4iP4VGyvD11+ShdyLyZm3tdquXK4Qr36LLTn91nMX66
  43327. AarHakE7kNQIXLJgapDwyM4DYvmL7ftuKtwGTTwpD4kWilhMSA/ohGHqPHKmd+RCroijQ1h5fq7K
  43328. pVMNqT1wvSAZYaRsOPxDMuHBR//47PERIjKWnML2W2mWeyAMQ0GaW/ZZGYjeVYg3UQt4XAoeo0L9
  43329. x52ID8DyeAIkVJOviYeIyUqAHerQbj5hLja7NQ4nlv1mNDthcnPxFlxHBlRJAHpYErAK74X9sbgz
  43330. dWqTHBLmYF5vHX/JHyPLhGGfHoJE+V+tYlUkmlKY7VHnoX6XOuYvHxHaU4AshZ6rNRDbIl9qxV6X
  43331. U/IyAgkwo1jwDQHVcsaxfGl7w/U2Rcxhbl5MlMVerugOXou/983g7aEOGzPuVBj+D77vfoRrQ+Nw
  43332. mNtddbINWQeFFSM51vHfqSYP1kjHs6Yi9TM3WpVHn3u6GBVv/9YUZINJ0gpnIdsPNWNgKCLjsZWD
  43333. zYWm3S8P52dSbrsvhXz1SnPnxT7AvSESBT/8twNJAlvIJebiVDj1eYeMHVOyToV7BjjHLPj4sHKN
  43334. JeV3UvQDHEimUF+IIDBu8oJDqz2XhOdT+yHBTw8imoa4WSr2Rz0ZiC3oheGe7IUIarFsNMkd7Egr
  43335. O3jtZsSOeWmD3n+M
  43336. -----END CERTIFICATE-----
  43337. QuoVadis Root CA 3 G3
  43338. =====================
  43339. -----BEGIN CERTIFICATE-----
  43340. MIIFYDCCA0igAwIBAgIULvWbAiin23r/1aOp7r0DoM8Sah0wDQYJKoZIhvcNAQELBQAwSDELMAkG
  43341. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  43342. b3QgQ0EgMyBHMzAeFw0xMjAxMTIyMDI2MzJaFw00MjAxMTIyMDI2MzJaMEgxCzAJBgNVBAYTAkJN
  43343. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDMg
  43344. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCzyw4QZ47qFJenMioKVjZ/aEzHs286
  43345. IxSR/xl/pcqs7rN2nXrpixurazHb+gtTTK/FpRp5PIpM/6zfJd5O2YIyC0TeytuMrKNuFoM7pmRL
  43346. Mon7FhY4futD4tN0SsJiCnMK3UmzV9KwCoWdcTzeo8vAMvMBOSBDGzXRU7Ox7sWTaYI+FrUoRqHe
  43347. 6okJ7UO4BUaKhvVZR74bbwEhELn9qdIoyhA5CcoTNs+cra1AdHkrAj80//ogaX3T7mH1urPnMNA3
  43348. I4ZyYUUpSFlob3emLoG+B01vr87ERRORFHAGjx+f+IdpsQ7vw4kZ6+ocYfx6bIrc1gMLnia6Et3U
  43349. VDmrJqMz6nWB2i3ND0/kA9HvFZcba5DFApCTZgIhsUfei5pKgLlVj7WiL8DWM2fafsSntARE60f7
  43350. 5li59wzweyuxwHApw0BiLTtIadwjPEjrewl5qW3aqDCYz4ByA4imW0aucnl8CAMhZa634RylsSqi
  43351. Md5mBPfAdOhx3v89WcyWJhKLhZVXGqtrdQtEPREoPHtht+KPZ0/l7DxMYIBpVzgeAVuNVejH38DM
  43352. dyM0SXV89pgR6y3e7UEuFAUCf+D+IOs15xGsIs5XPd7JMG0QA4XN8f+MFrXBsj6IbGB/kE+V9/Yt
  43353. rQE5BwT6dYB9v0lQ7e/JxHwc64B+27bQ3RP+ydOc17KXqQIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  43354. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUxhfQvKjqAkPyGwaZXSuQILnXnOQwDQYJKoZI
  43355. hvcNAQELBQADggIBADRh2Va1EodVTd2jNTFGu6QHcrxfYWLopfsLN7E8trP6KZ1/AvWkyaiTt3px
  43356. KGmPc+FSkNrVvjrlt3ZqVoAh313m6Tqe5T72omnHKgqwGEfcIHB9UqM+WXzBusnIFUBhynLWcKzS
  43357. t/Ac5IYp8M7vaGPQtSCKFWGafoaYtMnCdvvMujAWzKNhxnQT5WvvoxXqA/4Ti2Tk08HS6IT7SdEQ
  43358. TXlm66r99I0xHnAUrdzeZxNMgRVhvLfZkXdxGYFgu/BYpbWcC/ePIlUnwEsBbTuZDdQdm2NnL9Du
  43359. DcpmvJRPpq3t/O5jrFc/ZSXPsoaP0Aj/uHYUbt7lJ+yreLVTubY/6CD50qi+YUbKh4yE8/nxoGib
  43360. Ih6BJpsQBJFxwAYf3KDTuVan45gtf4Od34wrnDKOMpTwATwiKp9Dwi7DmDkHOHv8XgBCH/MyJnmD
  43361. hPbl8MFREsALHgQjDFSlTC9JxUrRtm5gDWv8a4uFJGS3iQ6rJUdbPM9+Sb3H6QrG2vd+DhcI00iX
  43362. 0HGS8A85PjRqHH3Y8iKuu2n0M7SmSFXRDw4m6Oy2Cy2nhTXN/VnIn9HNPlopNLk9hM6xZdRZkZFW
  43363. dSHBd575euFgndOtBBj0fOtek49TSiIp+EgrPk2GrFt/ywaZWWDYWGWVjUTR939+J399roD1B0y2
  43364. PpxxVJkES/1Y+Zj0
  43365. -----END CERTIFICATE-----
  43366. DigiCert Assured ID Root G2
  43367. ===========================
  43368. -----BEGIN CERTIFICATE-----
  43369. MIIDljCCAn6gAwIBAgIQC5McOtY5Z+pnI7/Dr5r0SzANBgkqhkiG9w0BAQsFADBlMQswCQYDVQQG
  43370. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw
  43371. IgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIwHhcNMTMwODAxMTIwMDAwWhcNMzgw
  43372. MTE1MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL
  43373. ExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIw
  43374. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDZ5ygvUj82ckmIkzTz+GoeMVSAn61UQbVH
  43375. 35ao1K+ALbkKz3X9iaV9JPrjIgwrvJUXCzO/GU1BBpAAvQxNEP4HteccbiJVMWWXvdMX0h5i89vq
  43376. bFCMP4QMls+3ywPgym2hFEwbid3tALBSfK+RbLE4E9HpEgjAALAcKxHad3A2m67OeYfcgnDmCXRw
  43377. VWmvo2ifv922ebPynXApVfSr/5Vh88lAbx3RvpO704gqu52/clpWcTs/1PPRCv4o76Pu2ZmvA9OP
  43378. YLfykqGxvYmJHzDNw6YuYjOuFgJ3RFrngQo8p0Quebg/BLxcoIfhG69Rjs3sLPr4/m3wOnyqi+Rn
  43379. lTGNAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTO
  43380. w0q5mVXyuNtgv6l+vVa1lzan1jANBgkqhkiG9w0BAQsFAAOCAQEAyqVVjOPIQW5pJ6d1Ee88hjZv
  43381. 0p3GeDgdaZaikmkuOGybfQTUiaWxMTeKySHMq2zNixya1r9I0jJmwYrA8y8678Dj1JGG0VDjA9tz
  43382. d29KOVPt3ibHtX2vK0LRdWLjSisCx1BL4GnilmwORGYQRI+tBev4eaymG+g3NJ1TyWGqolKvSnAW
  43383. hsI6yLETcDbYz+70CjTVW0z9B5yiutkBclzzTcHdDrEcDcRjvq30FPuJ7KJBDkzMyFdA0G4Dqs0M
  43384. jomZmWzwPDCvON9vvKO+KSAnq3T/EyJ43pdSVR6DtVQgA+6uwE9W3jfMw3+qBCe703e4YtsXfJwo
  43385. IhNzbM8m9Yop5w==
  43386. -----END CERTIFICATE-----
  43387. DigiCert Assured ID Root G3
  43388. ===========================
  43389. -----BEGIN CERTIFICATE-----
  43390. MIICRjCCAc2gAwIBAgIQC6Fa+h3foLVJRK/NJKBs7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV
  43391. UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQwIgYD
  43392. VQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1
  43393. MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
  43394. d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwdjAQ
  43395. BgcqhkjOPQIBBgUrgQQAIgNiAAQZ57ysRGXtzbg/WPuNsVepRC0FFfLvC/8QdJ+1YlJfZn4f5dwb
  43396. RXkLzMZTCp2NXQLZqVneAlr2lSoOjThKiknGvMYDOAdfVdp+CW7if17QRSAPWXYQ1qAk8C3eNvJs
  43397. KTmjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTL0L2p4ZgF
  43398. UaFNN6KDec6NHSrkhDAKBggqhkjOPQQDAwNnADBkAjAlpIFFAmsSS3V0T8gj43DydXLefInwz5Fy
  43399. YZ5eEJJZVrmDxxDnOOlYJjZ91eQ0hjkCMHw2U/Aw5WJjOpnitqM7mzT6HtoQknFekROn3aRukswy
  43400. 1vUhZscv6pZjamVFkpUBtA==
  43401. -----END CERTIFICATE-----
  43402. DigiCert Global Root G2
  43403. =======================
  43404. -----BEGIN CERTIFICATE-----
  43405. MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBhMQswCQYDVQQG
  43406. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw
  43407. HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMjAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUx
  43408. MjAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3
  43409. dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEcyMIIBIjANBgkq
  43410. hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuzfNNNx7a8myaJCtSnX/RrohCgiN9RlUyfuI2/Ou8jqJ
  43411. kTx65qsGGmvPrC3oXgkkRLpimn7Wo6h+4FR1IAWsULecYxpsMNzaHxmx1x7e/dfgy5SDN67sH0NO
  43412. 3Xss0r0upS/kqbitOtSZpLYl6ZtrAGCSYP9PIUkY92eQq2EGnI/yuum06ZIya7XzV+hdG82MHauV
  43413. BJVJ8zUtluNJbd134/tJS7SsVQepj5WztCO7TG1F8PapspUwtP1MVYwnSlcUfIKdzXOS0xZKBgyM
  43414. UNGPHgm+F6HmIcr9g+UQvIOlCsRnKPZzFBQ9RnbDhxSJITRNrw9FDKZJobq7nMWxM4MphQIDAQAB
  43415. o0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUTiJUIBiV5uNu
  43416. 5g/6+rkS7QYXjzkwDQYJKoZIhvcNAQELBQADggEBAGBnKJRvDkhj6zHd6mcY1Yl9PMWLSn/pvtsr
  43417. F9+wX3N3KjITOYFnQoQj8kVnNeyIv/iPsGEMNKSuIEyExtv4NeF22d+mQrvHRAiGfzZ0JFrabA0U
  43418. WTW98kndth/Jsw1HKj2ZL7tcu7XUIOGZX1NGFdtom/DzMNU+MeKNhJ7jitralj41E6Vf8PlwUHBH
  43419. QRFXGU7Aj64GxJUTFy8bJZ918rGOmaFvE7FBcf6IKshPECBV1/MUReXgRPTqh5Uykw7+U0b6LJ3/
  43420. iyK5S9kJRaTepLiaWN0bfVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTfl
  43421. MrY=
  43422. -----END CERTIFICATE-----
  43423. DigiCert Global Root G3
  43424. =======================
  43425. -----BEGIN CERTIFICATE-----
  43426. MIICPzCCAcWgAwIBAgIQBVVWvPJepDU1w6QP1atFcjAKBggqhkjOPQQDAzBhMQswCQYDVQQGEwJV
  43427. UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAwHgYD
  43428. VQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMzAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAw
  43429. MDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5k
  43430. aWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEczMHYwEAYHKoZIzj0C
  43431. AQYFK4EEACIDYgAE3afZu4q4C/sLfyHS8L6+c/MzXRq8NOrexpu80JX28MzQC7phW1FGfp4tn+6O
  43432. YwwX7Adw9c+ELkCDnOg/QW07rdOkFFk2eJ0DQ+4QE2xy3q6Ip6FrtUPOZ9wj/wMco+I+o0IwQDAP
  43433. BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUs9tIpPmhxdiuNkHMEWNp
  43434. Yim8S8YwCgYIKoZIzj0EAwMDaAAwZQIxAK288mw/EkrRLTnDCgmXc/SINoyIJ7vmiI1Qhadj+Z4y
  43435. 3maTD/HMsQmP3Wyr+mt/oAIwOWZbwmSNuJ5Q3KjVSaLtx9zRSX8XAbjIho9OjIgrqJqpisXRAL34
  43436. VOKa5Vt8sycX
  43437. -----END CERTIFICATE-----
  43438. DigiCert Trusted Root G4
  43439. ========================
  43440. -----BEGIN CERTIFICATE-----
  43441. MIIFkDCCA3igAwIBAgIQBZsbV56OITLiOQe9p3d1XDANBgkqhkiG9w0BAQwFADBiMQswCQYDVQQG
  43442. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSEw
  43443. HwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1
  43444. MTIwMDAwWjBiMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
  43445. d3cuZGlnaWNlcnQuY29tMSEwHwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwggIiMA0G
  43446. CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC/5pBzaN675F1KPDAiMGkz7MKnJS7JIT3yithZwuEp
  43447. pz1Yq3aaza57G4QNxDAf8xukOBbrVsaXbR2rsnnyyhHS5F/WBTxSD1Ifxp4VpX6+n6lXFllVcq9o
  43448. k3DCsrp1mWpzMpTREEQQLt+C8weE5nQ7bXHiLQwb7iDVySAdYyktzuxeTsiT+CFhmzTrBcZe7Fsa
  43449. vOvJz82sNEBfsXpm7nfISKhmV1efVFiODCu3T6cw2Vbuyntd463JT17lNecxy9qTXtyOj4DatpGY
  43450. QJB5w3jHtrHEtWoYOAMQjdjUN6QuBX2I9YI+EJFwq1WCQTLX2wRzKm6RAXwhTNS8rhsDdV14Ztk6
  43451. MUSaM0C/CNdaSaTC5qmgZ92kJ7yhTzm1EVgX9yRcRo9k98FpiHaYdj1ZXUJ2h4mXaXpI8OCiEhtm
  43452. mnTK3kse5w5jrubU75KSOp493ADkRSWJtppEGSt+wJS00mFt6zPZxd9LBADMfRyVw4/3IbKyEbe7
  43453. f/LVjHAsQWCqsWMYRJUadmJ+9oCw++hkpjPRiQfhvbfmQ6QYuKZ3AeEPlAwhHbJUKSWJbOUOUlFH
  43454. dL4mrLZBdd56rF+NP8m800ERElvlEFDrMcXKchYiCd98THU/Y+whX8QgUWtvsauGi0/C1kVfnSD8
  43455. oR7FwI+isX4KJpn15GkvmB0t9dmpsh3lGwIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1Ud
  43456. DwEB/wQEAwIBhjAdBgNVHQ4EFgQU7NfjgtJxXWRM3y5nP+e6mK4cD08wDQYJKoZIhvcNAQEMBQAD
  43457. ggIBALth2X2pbL4XxJEbw6GiAI3jZGgPVs93rnD5/ZpKmbnJeFwMDF/k5hQpVgs2SV1EY+CtnJYY
  43458. ZhsjDT156W1r1lT40jzBQ0CuHVD1UvyQO7uYmWlrx8GnqGikJ9yd+SeuMIW59mdNOj6PWTkiU0Tr
  43459. yF0Dyu1Qen1iIQqAyHNm0aAFYF/opbSnr6j3bTWcfFqK1qI4mfN4i/RN0iAL3gTujJtHgXINwBQy
  43460. 7zBZLq7gcfJW5GqXb5JQbZaNaHqasjYUegbyJLkJEVDXCLG4iXqEI2FCKeWjzaIgQdfRnGTZ6iah
  43461. ixTXTBmyUEFxPT9NcCOGDErcgdLMMpSEDQgJlxxPwO5rIHQw0uA5NBCFIRUBCOhVMt5xSdkoF1BN
  43462. 5r5N0XWs0Mr7QbhDparTwwVETyw2m+L64kW4I1NsBm9nVX9GtUw/bihaeSbSpKhil9Ie4u1Ki7wb
  43463. /UdKDd9nZn6yW0HQO+T0O/QEY+nvwlQAUaCKKsnOeMzV6ocEGLPOr0mIr/OSmbaz5mEP0oUA51Aa
  43464. 5BuVnRmhuZyxm7EAHu/QD09CbMkKvO5D+jpxpchNJqU1/YldvIViHTLSoCtU7ZpXwdv6EM8Zt4tK
  43465. G48BtieVU+i2iW1bvGjUI+iLUaJW+fCmgKDWHrO8Dw9TdSmq6hN35N6MgSGtBxBHEa2HPQfRdbzP
  43466. 82Z+
  43467. -----END CERTIFICATE-----
  43468. COMODO RSA Certification Authority
  43469. ==================================
  43470. -----BEGIN CERTIFICATE-----
  43471. MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCBhTELMAkGA1UE
  43472. BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG
  43473. A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlv
  43474. biBBdXRob3JpdHkwHhcNMTAwMTE5MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMC
  43475. R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE
  43476. ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBB
  43477. dXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCR6FSS0gpWsawNJN3Fz0Rn
  43478. dJkrN6N9I3AAcbxT38T6KhKPS38QVr2fcHK3YX/JSw8Xpz3jsARh7v8Rl8f0hj4K+j5c+ZPmNHrZ
  43479. FGvnnLOFoIJ6dq9xkNfs/Q36nGz637CC9BR++b7Epi9Pf5l/tfxnQ3K9DADWietrLNPtj5gcFKt+
  43480. 5eNu/Nio5JIk2kNrYrhV/erBvGy2i/MOjZrkm2xpmfh4SDBF1a3hDTxFYPwyllEnvGfDyi62a+pG
  43481. x8cgoLEfZd5ICLqkTqnyg0Y3hOvozIFIQ2dOciqbXL1MGyiKXCJ7tKuY2e7gUYPDCUZObT6Z+pUX
  43482. 2nwzV0E8jVHtC7ZcryxjGt9XyD+86V3Em69FmeKjWiS0uqlWPc9vqv9JWL7wqP/0uK3pN/u6uPQL
  43483. OvnoQ0IeidiEyxPx2bvhiWC4jChWrBQdnArncevPDt09qZahSL0896+1DSJMwBGB7FY79tOi4lu3
  43484. sgQiUpWAk2nojkxl8ZEDLXB0AuqLZxUpaVICu9ffUGpVRr+goyhhf3DQw6KqLCGqR84onAZFdr+C
  43485. GCe01a60y1Dma/RMhnEw6abfFobg2P9A3fvQQoh/ozM6LlweQRGBY84YcWsr7KaKtzFcOmpH4MN5
  43486. WdYgGq/yapiqcrxXStJLnbsQ/LBMQeXtHT1eKJ2czL+zUdqnR+WEUwIDAQABo0IwQDAdBgNVHQ4E
  43487. FgQUu69+Aj36pvE8hI6t7jiY7NkyMtQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8w
  43488. DQYJKoZIhvcNAQEMBQADggIBAArx1UaEt65Ru2yyTUEUAJNMnMvlwFTPoCWOAvn9sKIN9SCYPBMt
  43489. rFaisNZ+EZLpLrqeLppysb0ZRGxhNaKatBYSaVqM4dc+pBroLwP0rmEdEBsqpIt6xf4FpuHA1sj+
  43490. nq6PK7o9mfjYcwlYRm6mnPTXJ9OV2jeDchzTc+CiR5kDOF3VSXkAKRzH7JsgHAckaVd4sjn8OoSg
  43491. tZx8jb8uk2IntznaFxiuvTwJaP+EmzzV1gsD41eeFPfR60/IvYcjt7ZJQ3mFXLrrkguhxuhoqEwW
  43492. sRqZCuhTLJK7oQkYdQxlqHvLI7cawiiFwxv/0Cti76R7CZGYZ4wUAc1oBmpjIXUDgIiKboHGhfKp
  43493. pC3n9KUkEEeDys30jXlYsQab5xoq2Z0B15R97QNKyvDb6KkBPvVWmckejkk9u+UJueBPSZI9FoJA
  43494. zMxZxuY67RIuaTxslbH9qh17f4a+Hg4yRvv7E491f0yLS0Zj/gA0QHDBw7mh3aZw4gSzQbzpgJHq
  43495. ZJx64SIDqZxubw5lT2yHh17zbqD5daWbQOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk52
  43496. 7RH89elWsn2/x20Kk4yl0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7I
  43497. LaZRfyHBNVOFBkpdn627G190
  43498. -----END CERTIFICATE-----
  43499. USERTrust RSA Certification Authority
  43500. =====================================
  43501. -----BEGIN CERTIFICATE-----
  43502. MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCBiDELMAkGA1UE
  43503. BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK
  43504. ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh
  43505. dGlvbiBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UE
  43506. BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK
  43507. ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh
  43508. dGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCAEmUXNg7D2wiz
  43509. 0KxXDXbtzSfTTK1Qg2HiqiBNCS1kCdzOiZ/MPans9s/B3PHTsdZ7NygRK0faOca8Ohm0X6a9fZ2j
  43510. Y0K2dvKpOyuR+OJv0OwWIJAJPuLodMkYtJHUYmTbf6MG8YgYapAiPLz+E/CHFHv25B+O1ORRxhFn
  43511. RghRy4YUVD+8M/5+bJz/Fp0YvVGONaanZshyZ9shZrHUm3gDwFA66Mzw3LyeTP6vBZY1H1dat//O
  43512. +T23LLb2VN3I5xI6Ta5MirdcmrS3ID3KfyI0rn47aGYBROcBTkZTmzNg95S+UzeQc0PzMsNT79uq
  43513. /nROacdrjGCT3sTHDN/hMq7MkztReJVni+49Vv4M0GkPGw/zJSZrM233bkf6c0Plfg6lZrEpfDKE
  43514. Y1WJxA3Bk1QwGROs0303p+tdOmw1XNtB1xLaqUkL39iAigmTYo61Zs8liM2EuLE/pDkP2QKe6xJM
  43515. lXzzawWpXhaDzLhn4ugTncxbgtNMs+1b/97lc6wjOy0AvzVVdAlJ2ElYGn+SNuZRkg7zJn0cTRe8
  43516. yexDJtC/QV9AqURE9JnnV4eeUB9XVKg+/XRjL7FQZQnmWEIuQxpMtPAlR1n6BB6T1CZGSlCBst6+
  43517. eLf8ZxXhyVeEHg9j1uliutZfVS7qXMYoCAQlObgOK6nyTJccBz8NUvXt7y+CDwIDAQABo0IwQDAd
  43518. BgNVHQ4EFgQUU3m/WqorSs9UgOHYm8Cd8rIDZsswDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQF
  43519. MAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAFzUfA3P9wF9QZllDHPFUp/L+M+ZBn8b2kMVn54CVVeW
  43520. FPFSPCeHlCjtHzoBN6J2/FNQwISbxmtOuowhT6KOVWKR82kV2LyI48SqC/3vqOlLVSoGIG1VeCkZ
  43521. 7l8wXEskEVX/JJpuXior7gtNn3/3ATiUFJVDBwn7YKnuHKsSjKCaXqeYalltiz8I+8jRRa8YFWSQ
  43522. Eg9zKC7F4iRO/Fjs8PRF/iKz6y+O0tlFYQXBl2+odnKPi4w2r78NBc5xjeambx9spnFixdjQg3IM
  43523. 8WcRiQycE0xyNN+81XHfqnHd4blsjDwSXWXavVcStkNr/+XeTWYRUc+ZruwXtuhxkYzeSf7dNXGi
  43524. FSeUHM9h4ya7b6NnJSFd5t0dCy5oGzuCr+yDZ4XUmFF0sbmZgIn/f3gZXHlKYC6SQK5MNyosycdi
  43525. yA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9c
  43526. J2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRBVXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGw
  43527. sAvgnEzDHNb842m1R0aBL6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gx
  43528. Q+6IHdfGjjxDah2nGN59PRbxYvnKkKj9
  43529. -----END CERTIFICATE-----
  43530. USERTrust ECC Certification Authority
  43531. =====================================
  43532. -----BEGIN CERTIFICATE-----
  43533. MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDELMAkGA1UEBhMC
  43534. VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU
  43535. aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv
  43536. biBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMC
  43537. VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU
  43538. aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv
  43539. biBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQarFRaqfloI+d61SRvU8Za2EurxtW2
  43540. 0eZzca7dnNYMYf3boIkDuAUU7FfO7l0/4iGzzvfUinngo4N+LZfQYcTxmdwlkWOrfzCjtHDix6Ez
  43541. nPO/LlxTsV+zfTJ/ijTjeXmjQjBAMB0GA1UdDgQWBBQ64QmG1M8ZwpZ2dEl23OA1xmNjmjAOBgNV
  43542. HQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjA2Z6EWCNzklwBB
  43543. HU6+4WMBzzuqQhFkoJ2UOQIReVx7Hfpkue4WQrO/isIJxOzksU0CMQDpKmFHjFJKS04YcPbWRNZu
  43544. 9YO6bVi9JNlWSOrvxKJGgYhqOkbRqZtNyWHa0V1Xahg=
  43545. -----END CERTIFICATE-----
  43546. GlobalSign ECC Root CA - R5
  43547. ===========================
  43548. -----BEGIN CERTIFICATE-----
  43549. MIICHjCCAaSgAwIBAgIRYFlJ4CYuu1X5CneKcflK2GwwCgYIKoZIzj0EAwMwUDEkMCIGA1UECxMb
  43550. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  43551. EwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoXDTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMb
  43552. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  43553. EwpHbG9iYWxTaWduMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAER0UOlvt9Xb/pOdEh+J8LttV7HpI6
  43554. SFkc8GIxLcB6KP4ap1yztsyX50XUWPrRd21DosCHZTQKH3rd6zwzocWdTaRvQZU4f8kehOvRnkmS
  43555. h5SHDDqFSmafnVmTTZdhBoZKo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd
  43556. BgNVHQ4EFgQUPeYpSJvqB8ohREom3m7e0oPQn1kwCgYIKoZIzj0EAwMDaAAwZQIxAOVpEslu28Yx
  43557. uglB4Zf4+/2a4n0Sye18ZNPLBSWLVtmg515dTguDnFt2KaAJJiFqYgIwcdK1j1zqO+F4CYWodZI7
  43558. yFz9SO8NdCKoCOJuxUnOxwy8p2Fp8fc74SrL+SvzZpA3
  43559. -----END CERTIFICATE-----
  43560. IdenTrust Commercial Root CA 1
  43561. ==============================
  43562. -----BEGIN CERTIFICATE-----
  43563. MIIFYDCCA0igAwIBAgIQCgFCgAAAAUUjyES1AAAAAjANBgkqhkiG9w0BAQsFADBKMQswCQYDVQQG
  43564. EwJVUzESMBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBS
  43565. b290IENBIDEwHhcNMTQwMTE2MTgxMjIzWhcNMzQwMTE2MTgxMjIzWjBKMQswCQYDVQQGEwJVUzES
  43566. MBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBSb290IENB
  43567. IDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCnUBneP5k91DNG8W9RYYKyqU+PZ4ld
  43568. hNlT3Qwo2dfw/66VQ3KZ+bVdfIrBQuExUHTRgQ18zZshq0PirK1ehm7zCYofWjK9ouuU+ehcCuz/
  43569. mNKvcbO0U59Oh++SvL3sTzIwiEsXXlfEU8L2ApeN2WIrvyQfYo3fw7gpS0l4PJNgiCL8mdo2yMKi
  43570. 1CxUAGc1bnO/AljwpN3lsKImesrgNqUZFvX9t++uP0D1bVoE/c40yiTcdCMbXTMTEl3EASX2MN0C
  43571. XZ/g1Ue9tOsbobtJSdifWwLziuQkkORiT0/Br4sOdBeo0XKIanoBScy0RnnGF7HamB4HWfp1IYVl
  43572. 3ZBWzvurpWCdxJ35UrCLvYf5jysjCiN2O/cz4ckA82n5S6LgTrx+kzmEB/dEcH7+B1rlsazRGMzy
  43573. NeVJSQjKVsk9+w8YfYs7wRPCTY/JTw436R+hDmrfYi7LNQZReSzIJTj0+kuniVyc0uMNOYZKdHzV
  43574. WYfCP04MXFL0PfdSgvHqo6z9STQaKPNBiDoT7uje/5kdX7rL6B7yuVBgwDHTc+XvvqDtMwt0viAg
  43575. xGds8AgDelWAf0ZOlqf0Hj7h9tgJ4TNkK2PXMl6f+cB7D3hvl7yTmvmcEpB4eoCHFddydJxVdHix
  43576. uuFucAS6T6C6aMN7/zHwcz09lCqxC0EOoP5NiGVreTO01wIDAQABo0IwQDAOBgNVHQ8BAf8EBAMC
  43577. AQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU7UQZwNPwBovupHu+QucmVMiONnYwDQYJKoZI
  43578. hvcNAQELBQADggIBAA2ukDL2pkt8RHYZYR4nKM1eVO8lvOMIkPkp165oCOGUAFjvLi5+U1KMtlwH
  43579. 6oi6mYtQlNeCgN9hCQCTrQ0U5s7B8jeUeLBfnLOic7iPBZM4zY0+sLj7wM+x8uwtLRvM7Kqas6pg
  43580. ghstO8OEPVeKlh6cdbjTMM1gCIOQ045U8U1mwF10A0Cj7oV+wh93nAbowacYXVKV7cndJZ5t+qnt
  43581. ozo00Fl72u1Q8zW/7esUTTHHYPTa8Yec4kjixsU3+wYQ+nVZZjFHKdp2mhzpgq7vmrlR94gjmmmV
  43582. YjzlVYA211QC//G5Xc7UI2/YRYRKW2XviQzdFKcgyxilJbQN+QHwotL0AMh0jqEqSI5l2xPE4iUX
  43583. feu+h1sXIFRRk0pTAwvsXcoz7WL9RccvW9xYoIA55vrX/hMUpu09lEpCdNTDd1lzzY9GvlU47/ro
  43584. kTLql1gEIt44w8y8bckzOmoKaT+gyOpyj4xjhiO9bTyWnpXgSUyqorkqG5w2gXjtw+hG4iZZRHUe
  43585. 2XWJUc0QhJ1hYMtd+ZciTY6Y5uN/9lu7rs3KSoFrXgvzUeF0K+l+J6fZmUlO+KWA2yUPHGNiiskz
  43586. Z2s8EIPGrd6ozRaOjfAHN3Gf8qv8QfXBi+wAN10J5U6A7/qxXDgGpRtK4dw4LTzcqx+QGtVKnO7R
  43587. cGzM7vRX+Bi6hG6H
  43588. -----END CERTIFICATE-----
  43589. IdenTrust Public Sector Root CA 1
  43590. =================================
  43591. -----BEGIN CERTIFICATE-----
  43592. MIIFZjCCA06gAwIBAgIQCgFCgAAAAUUjz0Z8AAAAAjANBgkqhkiG9w0BAQsFADBNMQswCQYDVQQG
  43593. EwJVUzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3Rv
  43594. ciBSb290IENBIDEwHhcNMTQwMTE2MTc1MzMyWhcNMzQwMTE2MTc1MzMyWjBNMQswCQYDVQQGEwJV
  43595. UzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3RvciBS
  43596. b290IENBIDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2IpT8pEiv6EdrCvsnduTy
  43597. P4o7ekosMSqMjbCpwzFrqHd2hCa2rIFCDQjrVVi7evi8ZX3yoG2LqEfpYnYeEe4IFNGyRBb06tD6
  43598. Hi9e28tzQa68ALBKK0CyrOE7S8ItneShm+waOh7wCLPQ5CQ1B5+ctMlSbdsHyo+1W/CD80/HLaXI
  43599. rcuVIKQxKFdYWuSNG5qrng0M8gozOSI5Cpcu81N3uURF/YTLNiCBWS2ab21ISGHKTN9T0a9SvESf
  43600. qy9rg3LvdYDaBjMbXcjaY8ZNzaxmMc3R3j6HEDbhuaR672BQssvKplbgN6+rNBM5Jeg5ZuSYeqoS
  43601. mJxZZoY+rfGwyj4GD3vwEUs3oERte8uojHH01bWRNszwFcYr3lEXsZdMUD2xlVl8BX0tIdUAvwFn
  43602. ol57plzy9yLxkA2T26pEUWbMfXYD62qoKjgZl3YNa4ph+bz27nb9cCvdKTz4Ch5bQhyLVi9VGxyh
  43603. LrXHFub4qjySjmm2AcG1hp2JDws4lFTo6tyePSW8Uybt1as5qsVATFSrsrTZ2fjXctscvG29ZV/v
  43604. iDUqZi/u9rNl8DONfJhBaUYPQxxp+pu10GFqzcpL2UyQRqsVWaFHVCkugyhfHMKiq3IXAAaOReyL
  43605. 4jM9f9oZRORicsPfIsbyVtTdX5Vy7W1f90gDW/3FKqD2cyOEEBsB5wIDAQABo0IwQDAOBgNVHQ8B
  43606. Af8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU43HgntinQtnbcZFrlJPrw6PRFKMw
  43607. DQYJKoZIhvcNAQELBQADggIBAEf63QqwEZE4rU1d9+UOl1QZgkiHVIyqZJnYWv6IAcVYpZmxI1Qj
  43608. t2odIFflAWJBF9MJ23XLblSQdf4an4EKwt3X9wnQW3IV5B4Jaj0z8yGa5hV+rVHVDRDtfULAj+7A
  43609. mgjVQdZcDiFpboBhDhXAuM/FSRJSzL46zNQuOAXeNf0fb7iAaJg9TaDKQGXSc3z1i9kKlT/YPyNt
  43610. GtEqJBnZhbMX73huqVjRI9PHE+1yJX9dsXNw0H8GlwmEKYBhHfpe/3OsoOOJuBxxFcbeMX8S3OFt
  43611. m6/n6J91eEyrRjuazr8FGF1NFTwWmhlQBJqymm9li1JfPFgEKCXAZmExfrngdbkaqIHWchezxQMx
  43612. NRF4eKLg6TCMf4DfWN88uieW4oA0beOY02QnrEh+KHdcxiVhJfiFDGX6xDIvpZgF5PgLZxYWxoK4
  43613. Mhn5+bl53B/N66+rDt0b20XkeucC4pVd/GnwU2lhlXV5C15V5jgclKlZM57IcXR5f1GJtshquDDI
  43614. ajjDbp7hNxbqBWJMWxJH7ae0s1hWx0nzfxJoCTFx8G34Tkf71oXuxVhAGaQdp/lLQzfcaFpPz+vC
  43615. ZHTetBXZ9FRUGi8c15dxVJCO2SCdUyt/q4/i6jC8UDfv8Ue1fXwsBOxonbRJRBD0ckscZOf85muQ
  43616. 3Wl9af0AVqW3rLatt8o+Ae+c
  43617. -----END CERTIFICATE-----
  43618. Entrust Root Certification Authority - G2
  43619. =========================================
  43620. -----BEGIN CERTIFICATE-----
  43621. MIIEPjCCAyagAwIBAgIESlOMKDANBgkqhkiG9w0BAQsFADCBvjELMAkGA1UEBhMCVVMxFjAUBgNV
  43622. BAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVy
  43623. bXMxOTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ug
  43624. b25seTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIw
  43625. HhcNMDkwNzA3MTcyNTU0WhcNMzAxMjA3MTc1NTU0WjCBvjELMAkGA1UEBhMCVVMxFjAUBgNVBAoT
  43626. DUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVybXMx
  43627. OTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25s
  43628. eTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIwggEi
  43629. MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC6hLZy254Ma+KZ6TABp3bqMriVQRrJ2mFOWHLP
  43630. /vaCeb9zYQYKpSfYs1/TRU4cctZOMvJyig/3gxnQaoCAAEUesMfnmr8SVycco2gvCoe9amsOXmXz
  43631. HHfV1IWNcCG0szLni6LVhjkCsbjSR87kyUnEO6fe+1R9V77w6G7CebI6C1XiUJgWMhNcL3hWwcKU
  43632. s/Ja5CeanyTXxuzQmyWC48zCxEXFjJd6BmsqEZ+pCm5IO2/b1BEZQvePB7/1U1+cPvQXLOZprE4y
  43633. TGJ36rfo5bs0vBmLrpxR57d+tVOxMyLlbc9wPBr64ptntoP0jaWvYkxN4FisZDQSA/i2jZRjJKRx
  43634. AgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqciZ6
  43635. 0B7vfec7aVHUbI2fkBJmqzANBgkqhkiG9w0BAQsFAAOCAQEAeZ8dlsa2eT8ijYfThwMEYGprmi5Z
  43636. iXMRrEPR9RP/jTkrwPK9T3CMqS/qF8QLVJ7UG5aYMzyorWKiAHarWWluBh1+xLlEjZivEtRh2woZ
  43637. Rkfz6/djwUAFQKXSt/S1mja/qYh2iARVBCuch38aNzx+LaUa2NSJXsq9rD1s2G2v1fN2D807iDgi
  43638. nWyTmsQ9v4IbZT+mD12q/OWyFcq1rca8PdCE6OoGcrBNOTJ4vz4RnAuknZoh8/CbCzB428Hch0P+
  43639. vGOaysXCHMnHjf87ElgI5rY97HosTvuDls4MPGmHVHOkc8KT/1EQrBVUAdj8BbGJoX90g5pJ19xO
  43640. e4pIb4tF9g==
  43641. -----END CERTIFICATE-----
  43642. Entrust Root Certification Authority - EC1
  43643. ==========================================
  43644. -----BEGIN CERTIFICATE-----
  43645. MIIC+TCCAoCgAwIBAgINAKaLeSkAAAAAUNCR+TAKBggqhkjOPQQDAzCBvzELMAkGA1UEBhMCVVMx
  43646. FjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVn
  43647. YWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDEyIEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXpl
  43648. ZCB1c2Ugb25seTEzMDEGA1UEAxMqRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  43649. IC0gRUMxMB4XDTEyMTIxODE1MjUzNloXDTM3MTIxODE1NTUzNlowgb8xCzAJBgNVBAYTAlVTMRYw
  43650. FAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0L2xlZ2Fs
  43651. LXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxMiBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhvcml6ZWQg
  43652. dXNlIG9ubHkxMzAxBgNVBAMTKkVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAt
  43653. IEVDMTB2MBAGByqGSM49AgEGBSuBBAAiA2IABIQTydC6bUF74mzQ61VfZgIaJPRbiWlH47jCffHy
  43654. AsWfoPZb1YsGGYZPUxBtByQnoaD41UcZYUx9ypMn6nQM72+WCf5j7HBdNq1nd67JnXxVRDqiY1Ef
  43655. 9eNi1KlHBz7MIKNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE
  43656. FLdj5xrdjekIplWDpOBqUEFlEUJJMAoGCCqGSM49BAMDA2cAMGQCMGF52OVCR98crlOZF7ZvHH3h
  43657. vxGU0QOIdeSNiaSKd0bebWHvAvX7td/M/k7//qnmpwIwW5nXhTcGtXsI/esni0qU+eH6p44mCOh8
  43658. kmhtc9hvJqwhAriZtyZBWyVgrtBIGu4G
  43659. -----END CERTIFICATE-----
  43660. CFCA EV ROOT
  43661. ============
  43662. -----BEGIN CERTIFICATE-----
  43663. MIIFjTCCA3WgAwIBAgIEGErM1jANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJDTjEwMC4GA1UE
  43664. CgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQDDAxDRkNB
  43665. IEVWIFJPT1QwHhcNMTIwODA4MDMwNzAxWhcNMjkxMjMxMDMwNzAxWjBWMQswCQYDVQQGEwJDTjEw
  43666. MC4GA1UECgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQD
  43667. DAxDRkNBIEVWIFJPT1QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDXXWvNED8fBVnV
  43668. BU03sQ7smCuOFR36k0sXgiFxEFLXUWRwFsJVaU2OFW2fvwwbwuCjZ9YMrM8irq93VCpLTIpTUnrD
  43669. 7i7es3ElweldPe6hL6P3KjzJIx1qqx2hp/Hz7KDVRM8Vz3IvHWOX6Jn5/ZOkVIBMUtRSqy5J35DN
  43670. uF++P96hyk0g1CXohClTt7GIH//62pCfCqktQT+x8Rgp7hZZLDRJGqgG16iI0gNyejLi6mhNbiyW
  43671. ZXvKWfry4t3uMCz7zEasxGPrb382KzRzEpR/38wmnvFyXVBlWY9ps4deMm/DGIq1lY+wejfeWkU7
  43672. xzbh72fROdOXW3NiGUgthxwG+3SYIElz8AXSG7Ggo7cbcNOIabla1jj0Ytwli3i/+Oh+uFzJlU9f
  43673. py25IGvPa931DfSCt/SyZi4QKPaXWnuWFo8BGS1sbn85WAZkgwGDg8NNkt0yxoekN+kWzqotaK8K
  43674. gWU6cMGbrU1tVMoqLUuFG7OA5nBFDWteNfB/O7ic5ARwiRIlk9oKmSJgamNgTnYGmE69g60dWIol
  43675. hdLHZR4tjsbftsbhf4oEIRUpdPA+nJCdDC7xij5aqgwJHsfVPKPtl8MeNPo4+QgO48BdK4PRVmrJ
  43676. tqhUUy54Mmc9gn900PvhtgVguXDbjgv5E1hvcWAQUhC5wUEJ73IfZzF4/5YFjQIDAQABo2MwYTAf
  43677. BgNVHSMEGDAWgBTj/i39KNALtbq2osS/BqoFjJP7LzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB
  43678. /wQEAwIBBjAdBgNVHQ4EFgQU4/4t/SjQC7W6tqLEvwaqBYyT+y8wDQYJKoZIhvcNAQELBQADggIB
  43679. ACXGumvrh8vegjmWPfBEp2uEcwPenStPuiB/vHiyz5ewG5zz13ku9Ui20vsXiObTej/tUxPQ4i9q
  43680. ecsAIyjmHjdXNYmEwnZPNDatZ8POQQaIxffu2Bq41gt/UP+TqhdLjOztUmCypAbqTuv0axn96/Ua
  43681. 4CUqmtzHQTb3yHQFhDmVOdYLO6Qn+gjYXB74BGBSESgoA//vU2YApUo0FmZ8/Qmkrp5nGm9BC2sG
  43682. E5uPhnEFtC+NiWYzKXZUmhH4J/qyP5Hgzg0b8zAarb8iXRvTvyUFTeGSGn+ZnzxEk8rUQElsgIfX
  43683. BDrDMlI1Dlb4pd19xIsNER9Tyx6yF7Zod1rg1MvIB671Oi6ON7fQAUtDKXeMOZePglr4UeWJoBjn
  43684. aH9dCi77o0cOPaYjesYBx4/IXr9tgFa+iiS6M+qf4TIRnvHST4D2G0CvOJ4RUHlzEhLN5mydLIhy
  43685. PDCBBpEi6lmt2hkuIsKNuYyH4Ga8cyNfIWRjgEj1oDwYPZTISEEdQLpe/v5WOaHIz16eGWRGENoX
  43686. kbcFgKyLmZJ956LYBws2J+dIeWCKw9cTXPhyQN9Ky8+ZAAoACxGV2lZFA4gKn2fQ1XmxqI1AbQ3C
  43687. ekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su
  43688. -----END CERTIFICATE-----
  43689. OISTE WISeKey Global Root GB CA
  43690. ===============================
  43691. -----BEGIN CERTIFICATE-----
  43692. MIIDtTCCAp2gAwIBAgIQdrEgUnTwhYdGs/gjGvbCwDANBgkqhkiG9w0BAQsFADBtMQswCQYDVQQG
  43693. EwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNl
  43694. ZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQiBDQTAeFw0xNDEyMDExNTAw
  43695. MzJaFw0zOTEyMDExNTEwMzFaMG0xCzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYD
  43696. VQQLExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEds
  43697. b2JhbCBSb290IEdCIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2Be3HEokKtaX
  43698. scriHvt9OO+Y9bI5mE4nuBFde9IllIiCFSZqGzG7qFshISvYD06fWvGxWuR51jIjK+FTzJlFXHtP
  43699. rby/h0oLS5daqPZI7H17Dc0hBt+eFf1Biki3IPShehtX1F1Q/7pn2COZH8g/497/b1t3sWtuuMlk
  43700. 9+HKQUYOKXHQuSP8yYFfTvdv37+ErXNku7dCjmn21HYdfp2nuFeKUWdy19SouJVUQHMD9ur06/4o
  43701. Qnc/nSMbsrY9gBQHTC5P99UKFg29ZkM3fiNDecNAhvVMKdqOmq0NpQSHiB6F4+lT1ZvIiwNjeOvg
  43702. GUpuuy9rM2RYk61pv48b74JIxwIDAQABo1EwTzALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB
  43703. /zAdBgNVHQ4EFgQUNQ/INmNe4qPs+TtmFc5RUuORmj0wEAYJKwYBBAGCNxUBBAMCAQAwDQYJKoZI
  43704. hvcNAQELBQADggEBAEBM+4eymYGQfp3FsLAmzYh7KzKNbrghcViXfa43FK8+5/ea4n32cZiZBKpD
  43705. dHij40lhPnOMTZTg+XHEthYOU3gf1qKHLwI5gSk8rxWYITD+KJAAjNHhy/peyP34EEY7onhCkRd0
  43706. VQreUGdNZtGn//3ZwLWoo4rOZvUPQ82nK1d7Y0Zqqi5S2PTt4W2tKZB4SLrhI6qjiey1q5bAtEui
  43707. HZeeevJuQHHfaPFlTc58Bd9TZaml8LGXBHAVRgOY1NK/VLSgWH1Sb9pWJmLU2NuJMW8c8CLC02Ic
  43708. Nc1MaRVUGpCY3useX8p3x8uOPUNpnJpY0CQ73xtAln41rYHHTnG6iBM=
  43709. -----END CERTIFICATE-----
  43710. SZAFIR ROOT CA2
  43711. ===============
  43712. -----BEGIN CERTIFICATE-----
  43713. MIIDcjCCAlqgAwIBAgIUPopdB+xV0jLVt+O2XwHrLdzk1uQwDQYJKoZIhvcNAQELBQAwUTELMAkG
  43714. A1UEBhMCUEwxKDAmBgNVBAoMH0tyYWpvd2EgSXpiYSBSb3psaWN6ZW5pb3dhIFMuQS4xGDAWBgNV
  43715. BAMMD1NaQUZJUiBST09UIENBMjAeFw0xNTEwMTkwNzQzMzBaFw0zNTEwMTkwNzQzMzBaMFExCzAJ
  43716. BgNVBAYTAlBMMSgwJgYDVQQKDB9LcmFqb3dhIEl6YmEgUm96bGljemVuaW93YSBTLkEuMRgwFgYD
  43717. VQQDDA9TWkFGSVIgUk9PVCBDQTIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC3vD5Q
  43718. qEvNQLXOYeeWyrSh2gwisPq1e3YAd4wLz32ohswmUeQgPYUM1ljj5/QqGJ3a0a4m7utT3PSQ1hNK
  43719. DJA8w/Ta0o4NkjrcsbH/ON7Dui1fgLkCvUqdGw+0w8LBZwPd3BucPbOw3gAeqDRHu5rr/gsUvTaE
  43720. 2g0gv/pby6kWIK05YO4vdbbnl5z5Pv1+TW9NL++IDWr63fE9biCloBK0TXC5ztdyO4mTp4CEHCdJ
  43721. ckm1/zuVnsHMyAHs6A6KCpbns6aH5db5BSsNl0BwPLqsdVqc1U2dAgrSS5tmS0YHF2Wtn2yIANwi
  43722. ieDhZNRnvDF5YTy7ykHNXGoAyDw4jlivAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0P
  43723. AQH/BAQDAgEGMB0GA1UdDgQWBBQuFqlKGLXLzPVvUPMjX/hd56zwyDANBgkqhkiG9w0BAQsFAAOC
  43724. AQEAtXP4A9xZWx126aMqe5Aosk3AM0+qmrHUuOQn/6mWmc5G4G18TKI4pAZw8PRBEew/R40/cof5
  43725. O/2kbytTAOD/OblqBw7rHRz2onKQy4I9EYKL0rufKq8h5mOGnXkZ7/e7DDWQw4rtTw/1zBLZpD67
  43726. oPwglV9PJi8RI4NOdQcPv5vRtB3pEAT+ymCPoky4rc/hkA/NrgrHXXu3UNLUYfrVFdvXn4dRVOul
  43727. 4+vJhaAlIDf7js4MNIThPIGyd05DpYhfhmehPea0XGG2Ptv+tyjFogeutcrKjSoS75ftwjCkySp6
  43728. +/NNIxuZMzSgLvWpCz/UXeHPhJ/iGcJfitYgHuNztw==
  43729. -----END CERTIFICATE-----
  43730. Certum Trusted Network CA 2
  43731. ===========================
  43732. -----BEGIN CERTIFICATE-----
  43733. MIIF0jCCA7qgAwIBAgIQIdbQSk8lD8kyN/yqXhKN6TANBgkqhkiG9w0BAQ0FADCBgDELMAkGA1UE
  43734. BhMCUEwxIjAgBgNVBAoTGVVuaXpldG8gVGVjaG5vbG9naWVzIFMuQS4xJzAlBgNVBAsTHkNlcnR1
  43735. bSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEkMCIGA1UEAxMbQ2VydHVtIFRydXN0ZWQgTmV0d29y
  43736. ayBDQSAyMCIYDzIwMTExMDA2MDgzOTU2WhgPMjA0NjEwMDYwODM5NTZaMIGAMQswCQYDVQQGEwJQ
  43737. TDEiMCAGA1UEChMZVW5pemV0byBUZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENl
  43738. cnRpZmljYXRpb24gQXV0aG9yaXR5MSQwIgYDVQQDExtDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENB
  43739. IDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC9+Xj45tWADGSdhhuWZGc/IjoedQF9
  43740. 7/tcZ4zJzFxrqZHmuULlIEub2pt7uZld2ZuAS9eEQCsn0+i6MLs+CRqnSZXvK0AkwpfHp+6bJe+o
  43741. CgCXhVqqndwpyeI1B+twTUrWwbNWuKFBOJvR+zF/j+Bf4bE/D44WSWDXBo0Y+aomEKsq09DRZ40b
  43742. Rr5HMNUuctHFY9rnY3lEfktjJImGLjQ/KUxSiyqnwOKRKIm5wFv5HdnnJ63/mgKXwcZQkpsCLL2p
  43743. uTRZCr+ESv/f/rOf69me4Jgj7KZrdxYq28ytOxykh9xGc14ZYmhFV+SQgkK7QtbwYeDBoz1mo130
  43744. GO6IyY0XRSmZMnUCMe4pJshrAua1YkV/NxVaI2iJ1D7eTiew8EAMvE0Xy02isx7QBlrd9pPPV3WZ
  43745. 9fqGGmd4s7+W/jTcvedSVuWz5XV710GRBdxdaeOVDUO5/IOWOZV7bIBaTxNyxtd9KXpEulKkKtVB
  43746. Rgkg/iKgtlswjbyJDNXXcPiHUv3a76xRLgezTv7QCdpw75j6VuZt27VXS9zlLCUVyJ4ueE742pye
  43747. hizKV/Ma5ciSixqClnrDvFASadgOWkaLOusm+iPJtrCBvkIApPjW/jAux9JG9uWOdf3yzLnQh1vM
  43748. BhBgu4M1t15n3kfsmUjxpKEV/q2MYo45VU85FrmxY53/twIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  43749. AQH/MB0GA1UdDgQWBBS2oVQ5AsOgP46KvPrU+Bym0ToO/TAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZI
  43750. hvcNAQENBQADggIBAHGlDs7k6b8/ONWJWsQCYftMxRQXLYtPU2sQF/xlhMcQSZDe28cmk4gmb3DW
  43751. Al45oPePq5a1pRNcgRRtDoGCERuKTsZPpd1iHkTfCVn0W3cLN+mLIMb4Ck4uWBzrM9DPhmDJ2vuA
  43752. L55MYIR4PSFk1vtBHxgP58l1cb29XN40hz5BsA72udY/CROWFC/emh1auVbONTqwX3BNXuMp8SMo
  43753. clm2q8KMZiYcdywmdjWLKKdpoPk79SPdhRB0yZADVpHnr7pH1BKXESLjokmUbOe3lEu6LaTaM4tM
  43754. pkT/WjzGHWTYtTHkpjx6qFcL2+1hGsvxznN3Y6SHb0xRONbkX8eftoEq5IVIeVheO/jbAoJnwTnb
  43755. w3RLPTYe+SmTiGhbqEQZIfCn6IENLOiTNrQ3ssqwGyZ6miUfmpqAnksqP/ujmv5zMnHCnsZy4Ypo
  43756. J/HkD7TETKVhk/iXEAcqMCWpuchxuO9ozC1+9eB+D4Kob7a6bINDd82Kkhehnlt4Fj1F4jNy3eFm
  43757. ypnTycUm/Q1oBEauttmbjL4ZvrHG8hnjXALKLNhvSgfZyTXaQHXyxKcZb55CEJh15pWLYLztxRLX
  43758. is7VmFxWlgPF7ncGNf/P5O4/E2Hu29othfDNrp2yGAlFw5Khchf8R7agCyzxxN5DaAhqXzvwdmP7
  43759. zAYspsbiDrW5viSP
  43760. -----END CERTIFICATE-----
  43761. Hellenic Academic and Research Institutions RootCA 2015
  43762. =======================================================
  43763. -----BEGIN CERTIFICATE-----
  43764. MIIGCzCCA/OgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcT
  43765. BkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0
  43766. aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNVBAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNl
  43767. YXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIwMTUwHhcNMTUwNzA3MTAxMTIxWhcNNDAwNjMwMTAx
  43768. MTIxWjCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMg
  43769. QWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNV
  43770. BAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIw
  43771. MTUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDC+Kk/G4n8PDwEXT2QNrCROnk8Zlrv
  43772. bTkBSRq0t89/TSNTt5AA4xMqKKYx8ZEA4yjsriFBzh/a/X0SWwGDD7mwX5nh8hKDgE0GPt+sr+eh
  43773. iGsxr/CL0BgzuNtFajT0AoAkKAoCFZVedioNmToUW/bLy1O8E00BiDeUJRtCvCLYjqOWXjrZMts+
  43774. 6PAQZe104S+nfK8nNLspfZu2zwnI5dMK/IhlZXQK3HMcXM1AsRzUtoSMTFDPaI6oWa7CJ06CojXd
  43775. FPQf/7J31Ycvqm59JCfnxssm5uX+Zwdj2EUN3TpZZTlYepKZcj2chF6IIbjV9Cz82XBST3i4vTwr
  43776. i5WY9bPRaM8gFH5MXF/ni+X1NYEZN9cRCLdmvtNKzoNXADrDgfgXy5I2XdGj2HUb4Ysn6npIQf1F
  43777. GQatJ5lOwXBH3bWfgVMS5bGMSF0xQxfjjMZ6Y5ZLKTBOhE5iGV48zpeQpX8B653g+IuJ3SWYPZK2
  43778. fu/Z8VFRfS0myGlZYeCsargqNhEEelC9MoS+L9xy1dcdFkfkR2YgP/SWxa+OAXqlD3pk9Q0Yh9mu
  43779. iNX6hME6wGkoLfINaFGq46V3xqSQDqE3izEjR8EJCOtu93ib14L8hCCZSRm2Ekax+0VVFqmjZayc
  43780. Bw/qa9wfLgZy7IaIEuQt218FL+TwA9MmM+eAws1CoRc0CwIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  43781. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUcRVnyMjJvXVdctA4GGqd83EkVAswDQYJKoZI
  43782. hvcNAQELBQADggIBAHW7bVRLqhBYRjTyYtcWNl0IXtVsyIe9tC5G8jH4fOpCtZMWVdyhDBKg2mF+
  43783. D1hYc2Ryx+hFjtyp8iY/xnmMsVMIM4GwVhO+5lFc2JsKT0ucVlMC6U/2DWDqTUJV6HwbISHTGzrM
  43784. d/K4kPFox/la/vot9L/J9UUbzjgQKjeKeaO04wlshYaT/4mWJ3iBj2fjRnRUjtkNaeJK9E10A/+y
  43785. d+2VZ5fkscWrv2oj6NSU4kQoYsRL4vDY4ilrGnB+JGGTe08DMiUNRSQrlrRGar9KC/eaj8GsGsVn
  43786. 82800vpzY4zvFrCopEYq+OsS7HK07/grfoxSwIuEVPkvPuNVqNxmsdnhX9izjFk0WaSrT2y7Hxjb
  43787. davYy5LNlDhhDgcGH0tGEPEVvo2FXDtKK4F5D7Rpn0lQl033DlZdwJVqwjbDG2jJ9SrcR5q+ss7F
  43788. Jej6A7na+RZukYT1HCjI/CbM1xyQVqdfbzoEvM14iQuODy+jqk+iGxI9FghAD/FGTNeqewjBCvVt
  43789. J94Cj8rDtSvK6evIIVM4pcw72Hc3MKJP2W/R8kCtQXoXxdZKNYm3QdV8hn9VTYNKpXMgwDqvkPGa
  43790. JI7ZjnHKe7iG2rKPmT4dEw0SEe7Uq/DpFXYC5ODfqiAeW2GFZECpkJcNrVPSWh2HagCXZWK0vm9q
  43791. p/UsQu0yrbYhnr68
  43792. -----END CERTIFICATE-----
  43793. Hellenic Academic and Research Institutions ECC RootCA 2015
  43794. ===========================================================
  43795. -----BEGIN CERTIFICATE-----
  43796. MIICwzCCAkqgAwIBAgIBADAKBggqhkjOPQQDAjCBqjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0
  43797. aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9u
  43798. cyBDZXJ0LiBBdXRob3JpdHkxRDBCBgNVBAMTO0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJj
  43799. aCBJbnN0aXR1dGlvbnMgRUNDIFJvb3RDQSAyMDE1MB4XDTE1MDcwNzEwMzcxMloXDTQwMDYzMDEw
  43800. MzcxMlowgaoxCzAJBgNVBAYTAkdSMQ8wDQYDVQQHEwZBdGhlbnMxRDBCBgNVBAoTO0hlbGxlbmlj
  43801. IEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9yaXR5MUQwQgYD
  43802. VQQDEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25zIEVDQyBSb290
  43803. Q0EgMjAxNTB2MBAGByqGSM49AgEGBSuBBAAiA2IABJKgQehLgoRc4vgxEZmGZE4JJS+dQS8KrjVP
  43804. dJWyUWRrjWvmP3CV8AVER6ZyOFB2lQJajq4onvktTpnvLEhvTCUp6NFxW98dwXU3tNf6e3pCnGoK
  43805. Vlp8aQuqgAkkbH7BRqNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O
  43806. BBYEFLQiC4KZJAEOnLvkDv2/+5cgk5kqMAoGCCqGSM49BAMCA2cAMGQCMGfOFmI4oqxiRaeplSTA
  43807. GiecMjvAwNW6qef4BENThe5SId6d9SWDPp5YSy/XZxMOIQIwBeF1Ad5o7SofTUwJCA3sS61kFyjn
  43808. dc5FZXIhF8siQQ6ME5g4mlRtm8rifOoCWCKR
  43809. -----END CERTIFICATE-----
  43810. ISRG Root X1
  43811. ============
  43812. -----BEGIN CERTIFICATE-----
  43813. MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAwTzELMAkGA1UE
  43814. BhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2VhcmNoIEdyb3VwMRUwEwYDVQQD
  43815. EwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQG
  43816. EwJVUzEpMCcGA1UEChMgSW50ZXJuZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMT
  43817. DElTUkcgUm9vdCBYMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54r
  43818. Vygch77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+0TM8ukj1
  43819. 3Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6UA5/TR5d8mUgjU+g4rk8K
  43820. b4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sWT8KOEUt+zwvo/7V3LvSye0rgTBIlDHCN
  43821. Aymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyHB5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ
  43822. 4Q7e2RCOFvu396j3x+UCB5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf
  43823. 1b0SHzUvKBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWnOlFu
  43824. hjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTnjh8BCNAw1FtxNrQH
  43825. usEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbwqHyGO0aoSCqI3Haadr8faqU9GY/r
  43826. OPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CIrU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4G
  43827. A1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY
  43828. 9umbbjANBgkqhkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL
  43829. ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ3BebYhtF8GaV
  43830. 0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KKNFtY2PwByVS5uCbMiogziUwt
  43831. hDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJw
  43832. TdwJx4nLCgdNbOhdjsnvzqvHu7UrTkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nx
  43833. e5AW0wdeRlN8NwdCjNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZA
  43834. JzVcoyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq4RgqsahD
  43835. YVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPAmRGunUHBcnWEvgJBQl9n
  43836. JEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57demyPxgcYxn/eR44/KJ4EBs+lVDR3veyJ
  43837. m+kXQ99b21/+jh5Xos1AnX5iItreGCc=
  43838. -----END CERTIFICATE-----
  43839. AC RAIZ FNMT-RCM
  43840. ================
  43841. -----BEGIN CERTIFICATE-----
  43842. MIIFgzCCA2ugAwIBAgIPXZONMGc2yAYdGsdUhGkHMA0GCSqGSIb3DQEBCwUAMDsxCzAJBgNVBAYT
  43843. AkVTMREwDwYDVQQKDAhGTk1ULVJDTTEZMBcGA1UECwwQQUMgUkFJWiBGTk1ULVJDTTAeFw0wODEw
  43844. MjkxNTU5NTZaFw0zMDAxMDEwMDAwMDBaMDsxCzAJBgNVBAYTAkVTMREwDwYDVQQKDAhGTk1ULVJD
  43845. TTEZMBcGA1UECwwQQUMgUkFJWiBGTk1ULVJDTTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
  43846. ggIBALpxgHpMhm5/yBNtwMZ9HACXjywMI7sQmkCpGreHiPibVmr75nuOi5KOpyVdWRHbNi63URcf
  43847. qQgfBBckWKo3Shjf5TnUV/3XwSyRAZHiItQDwFj8d0fsjz50Q7qsNI1NOHZnjrDIbzAzWHFctPVr
  43848. btQBULgTfmxKo0nRIBnuvMApGGWn3v7v3QqQIecaZ5JCEJhfTzC8PhxFtBDXaEAUwED653cXeuYL
  43849. j2VbPNmaUtu1vZ5Gzz3rkQUCwJaydkxNEJY7kvqcfw+Z374jNUUeAlz+taibmSXaXvMiwzn15Cou
  43850. 08YfxGyqxRxqAQVKL9LFwag0Jl1mpdICIfkYtwb1TplvqKtMUejPUBjFd8g5CSxJkjKZqLsXF3mw
  43851. WsXmo8RZZUc1g16p6DULmbvkzSDGm0oGObVo/CK67lWMK07q87Hj/LaZmtVC+nFNCM+HHmpxffnT
  43852. tOmlcYF7wk5HlqX2doWjKI/pgG6BU6VtX7hI+cL5NqYuSf+4lsKMB7ObiFj86xsc3i1w4peSMKGJ
  43853. 47xVqCfWS+2QrYv6YyVZLag13cqXM7zlzced0ezvXg5KkAYmY6252TUtB7p2ZSysV4999AeU14EC
  43854. ll2jB0nVetBX+RvnU0Z1qrB5QstocQjpYL05ac70r8NWQMetUqIJ5G+GR4of6ygnXYMgrwTJbFaa
  43855. i0b1AgMBAAGjgYMwgYAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE
  43856. FPd9xf3E6Jobd2Sn9R2gzL+HYJptMD4GA1UdIAQ3MDUwMwYEVR0gADArMCkGCCsGAQUFBwIBFh1o
  43857. dHRwOi8vd3d3LmNlcnQuZm5tdC5lcy9kcGNzLzANBgkqhkiG9w0BAQsFAAOCAgEAB5BK3/MjTvDD
  43858. nFFlm5wioooMhfNzKWtN/gHiqQxjAb8EZ6WdmF/9ARP67Jpi6Yb+tmLSbkyU+8B1RXxlDPiyN8+s
  43859. D8+Nb/kZ94/sHvJwnvDKuO+3/3Y3dlv2bojzr2IyIpMNOmqOFGYMLVN0V2Ue1bLdI4E7pWYjJ2cJ
  43860. j+F3qkPNZVEI7VFY/uY5+ctHhKQV8Xa7pO6kO8Rf77IzlhEYt8llvhjho6Tc+hj507wTmzl6NLrT
  43861. Qfv6MooqtyuGC2mDOL7Nii4LcK2NJpLuHvUBKwrZ1pebbuCoGRw6IYsMHkCtA+fdZn71uSANA+iW
  43862. +YJF1DngoABd15jmfZ5nc8OaKveri6E6FO80vFIOiZiaBECEHX5FaZNXzuvO+FB8TxxuBEOb+dY7
  43863. Ixjp6o7RTUaN8Tvkasq6+yO3m/qZASlaWFot4/nUbQ4mrcFuNLwy+AwF+mWj2zs3gyLp1txyM/1d
  43864. 8iC9djwj2ij3+RvrWWTV3F9yfiD8zYm1kGdNYno/Tq0dwzn+evQoFt9B9kiABdcPUXmsEKvU7ANm
  43865. 5mqwujGSQkBqvjrTcuFqN1W8rB2Vt2lh8kORdOag0wokRqEIr9baRRmW1FMdW4R58MD3R++Lj8UG
  43866. rp1MYp3/RgT408m2ECVAdf4WqslKYIYvuu8wd+RU4riEmViAqhOLUTpPSPaLtrM=
  43867. -----END CERTIFICATE-----
  43868. Amazon Root CA 1
  43869. ================
  43870. -----BEGIN CERTIFICATE-----
  43871. MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsFADA5MQswCQYD
  43872. VQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAxMB4XDTE1
  43873. MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpv
  43874. bjEZMBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
  43875. ggEBALJ4gHHKeNXjca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgH
  43876. FzZM9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qwIFAGbHrQ
  43877. gLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6VOujw5H5SNz/0egwLX0t
  43878. dHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L93FcXmn/6pUCyziKrlA4b9v7LWIbxcce
  43879. VOF34GfID5yHI9Y/QCB/IIDEgEw+OyQmjgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB
  43880. /zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3
  43881. DQEBCwUAA4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDIU5PM
  43882. CCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUsN+gDS63pYaACbvXy
  43883. 8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vvo/ufQJVtMVT8QtPHRh8jrdkPSHCa
  43884. 2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2
  43885. xJNDd2ZhwLnoQdeXeGADbkpyrqXRfboQnoZsG4q5WTP468SQvvG5
  43886. -----END CERTIFICATE-----
  43887. Amazon Root CA 2
  43888. ================
  43889. -----BEGIN CERTIFICATE-----
  43890. MIIFQTCCAymgAwIBAgITBmyf0pY1hp8KD+WGePhbJruKNzANBgkqhkiG9w0BAQwFADA5MQswCQYD
  43891. VQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAyMB4XDTE1
  43892. MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpv
  43893. bjEZMBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
  43894. ggIBAK2Wny2cSkxKgXlRmeyKy2tgURO8TW0G/LAIjd0ZEGrHJgw12MBvIITplLGbhQPDW9tK6Mj4
  43895. kHbZW0/jTOgGNk3Mmqw9DJArktQGGWCsN0R5hYGCrVo34A3MnaZMUnbqQ523BNFQ9lXg1dKmSYXp
  43896. N+nKfq5clU1Imj+uIFptiJXZNLhSGkOQsL9sBbm2eLfq0OQ6PBJTYv9K8nu+NQWpEjTj82R0Yiw9
  43897. AElaKP4yRLuH3WUnAnE72kr3H9rN9yFVkE8P7K6C4Z9r2UXTu/Bfh+08LDmG2j/e7HJV63mjrdvd
  43898. fLC6HM783k81ds8P+HgfajZRRidhW+mez/CiVX18JYpvL7TFz4QuK/0NURBs+18bvBt+xa47mAEx
  43899. kv8LV/SasrlX6avvDXbR8O70zoan4G7ptGmh32n2M8ZpLpcTnqWHsFcQgTfJU7O7f/aS0ZzQGPSS
  43900. btqDT6ZjmUyl+17vIWR6IF9sZIUVyzfpYgwLKhbcAS4y2j5L9Z469hdAlO+ekQiG+r5jqFoz7Mt0
  43901. Q5X5bGlSNscpb/xVA1wf+5+9R+vnSUeVC06JIglJ4PVhHvG/LopyboBZ/1c6+XUyo05f7O0oYtlN
  43902. c/LMgRdg7c3r3NunysV+Ar3yVAhU/bQtCSwXVEqY0VThUWcI0u1ufm8/0i2BWSlmy5A5lREedCf+
  43903. 3euvAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSw
  43904. DPBMMPQFWAJI/TPlUq9LhONmUjANBgkqhkiG9w0BAQwFAAOCAgEAqqiAjw54o+Ci1M3m9Zh6O+oA
  43905. A7CXDpO8Wqj2LIxyh6mx/H9z/WNxeKWHWc8w4Q0QshNabYL1auaAn6AFC2jkR2vHat+2/XcycuUY
  43906. +gn0oJMsXdKMdYV2ZZAMA3m3MSNjrXiDCYZohMr/+c8mmpJ5581LxedhpxfL86kSk5Nrp+gvU5LE
  43907. YFiwzAJRGFuFjWJZY7attN6a+yb3ACfAXVU3dJnJUH/jWS5E4ywl7uxMMne0nxrpS10gxdr9HIcW
  43908. xkPo1LsmmkVwXqkLN1PiRnsn/eBG8om3zEK2yygmbtmlyTrIQRNg91CMFa6ybRoVGld45pIq2WWQ
  43909. gj9sAq+uEjonljYE1x2igGOpm/HlurR8FLBOybEfdF849lHqm/osohHUqS0nGkWxr7JOcQ3AWEbW
  43910. aQbLU8uz/mtBzUF+fUwPfHJ5elnNXkoOrJupmHN5fLT0zLm4BwyydFy4x2+IoZCn9Kr5v2c69BoV
  43911. Yh63n749sSmvZ6ES8lgQGVMDMBu4Gon2nL2XA46jCfMdiyHxtN/kHNGfZQIG6lzWE7OE76KlXIx3
  43912. KadowGuuQNKotOrN8I1LOJwZmhsoVLiJkO/KdYE+HvJkJMcYr07/R54H9jVlpNMKVv/1F2Rs76gi
  43913. JUmTtt8AF9pYfl3uxRuw0dFfIRDH+fO6AgonB8Xx1sfT4PsJYGw=
  43914. -----END CERTIFICATE-----
  43915. Amazon Root CA 3
  43916. ================
  43917. -----BEGIN CERTIFICATE-----
  43918. MIIBtjCCAVugAwIBAgITBmyf1XSXNmY/Owua2eiedgPySjAKBggqhkjOPQQDAjA5MQswCQYDVQQG
  43919. EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAzMB4XDTE1MDUy
  43920. NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ
  43921. MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCmXp8ZB
  43922. f8ANm+gBG1bG8lKlui2yEujSLtf6ycXYqm0fc4E7O5hrOXwzpcVOho6AF2hiRVd9RFgdszflZwjr
  43923. Zt6jQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSrttvXBp43
  43924. rDCGB5Fwx5zEGbF4wDAKBggqhkjOPQQDAgNJADBGAiEA4IWSoxe3jfkrBqWTrBqYaGFy+uGh0Psc
  43925. eGCmQ5nFuMQCIQCcAu/xlJyzlvnrxir4tiz+OpAUFteMYyRIHN8wfdVoOw==
  43926. -----END CERTIFICATE-----
  43927. Amazon Root CA 4
  43928. ================
  43929. -----BEGIN CERTIFICATE-----
  43930. MIIB8jCCAXigAwIBAgITBmyf18G7EEwpQ+Vxe3ssyBrBDjAKBggqhkjOPQQDAzA5MQswCQYDVQQG
  43931. EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSA0MB4XDTE1MDUy
  43932. NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ
  43933. MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgNDB2MBAGByqGSM49AgEGBSuBBAAiA2IABNKrijdPo1MN
  43934. /sGKe0uoe0ZLY7Bi9i0b2whxIdIA6GO9mif78DluXeo9pcmBqqNbIJhFXRbb/egQbeOc4OO9X4Ri
  43935. 83BkM6DLJC9wuoihKqB1+IGuYgbEgds5bimwHvouXKNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV
  43936. HQ8BAf8EBAMCAYYwHQYDVR0OBBYEFNPsxzplbszh2naaVvuc84ZtV+WBMAoGCCqGSM49BAMDA2gA
  43937. MGUCMDqLIfG9fhGt0O9Yli/W651+kI0rz2ZVwyzjKKlwCkcO8DdZEv8tmZQoTipPNU0zWgIxAOp1
  43938. AE47xDqUEpHJWEadIRNyp4iciuRMStuW1KyLa2tJElMzrdfkviT8tQp21KW8EA==
  43939. -----END CERTIFICATE-----
  43940. TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1
  43941. =============================================
  43942. -----BEGIN CERTIFICATE-----
  43943. MIIEYzCCA0ugAwIBAgIBATANBgkqhkiG9w0BAQsFADCB0jELMAkGA1UEBhMCVFIxGDAWBgNVBAcT
  43944. D0dlYnplIC0gS29jYWVsaTFCMEAGA1UEChM5VHVya2l5ZSBCaWxpbXNlbCB2ZSBUZWtub2xvamlr
  43945. IEFyYXN0aXJtYSBLdXJ1bXUgLSBUVUJJVEFLMS0wKwYDVQQLEyRLYW11IFNlcnRpZmlrYXN5b24g
  43946. TWVya2V6aSAtIEthbXUgU00xNjA0BgNVBAMTLVRVQklUQUsgS2FtdSBTTSBTU0wgS29rIFNlcnRp
  43947. ZmlrYXNpIC0gU3VydW0gMTAeFw0xMzExMjUwODI1NTVaFw00MzEwMjUwODI1NTVaMIHSMQswCQYD
  43948. VQQGEwJUUjEYMBYGA1UEBxMPR2ViemUgLSBLb2NhZWxpMUIwQAYDVQQKEzlUdXJraXllIEJpbGlt
  43949. c2VsIHZlIFRla25vbG9qaWsgQXJhc3Rpcm1hIEt1cnVtdSAtIFRVQklUQUsxLTArBgNVBAsTJEth
  43950. bXUgU2VydGlmaWthc3lvbiBNZXJrZXppIC0gS2FtdSBTTTE2MDQGA1UEAxMtVFVCSVRBSyBLYW11
  43951. IFNNIFNTTCBLb2sgU2VydGlmaWthc2kgLSBTdXJ1bSAxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  43952. MIIBCgKCAQEAr3UwM6q7a9OZLBI3hNmNe5eA027n/5tQlT6QlVZC1xl8JoSNkvoBHToP4mQ4t4y8
  43953. 6Ij5iySrLqP1N+RAjhgleYN1Hzv/bKjFxlb4tO2KRKOrbEz8HdDc72i9z+SqzvBV96I01INrN3wc
  43954. wv61A+xXzry0tcXtAA9TNypN9E8Mg/uGz8v+jE69h/mniyFXnHrfA2eJLJ2XYacQuFWQfw4tJzh0
  43955. 3+f92k4S400VIgLI4OD8D62K18lUUMw7D8oWgITQUVbDjlZ/iSIzL+aFCr2lqBs23tPcLG07xxO9
  43956. WSMs5uWk99gL7eqQQESolbuT1dCANLZGeA4fAJNG4e7p+exPFwIDAQABo0IwQDAdBgNVHQ4EFgQU
  43957. ZT/HiobGPN08VFw1+DrtUgxHV8gwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJ
  43958. KoZIhvcNAQELBQADggEBACo/4fEyjq7hmFxLXs9rHmoJ0iKpEsdeV31zVmSAhHqT5Am5EM2fKifh
  43959. AHe+SMg1qIGf5LgsyX8OsNJLN13qudULXjS99HMpw+0mFZx+CFOKWI3QSyjfwbPfIPP54+M638yc
  43960. lNhOT8NrF7f3cuitZjO1JVOr4PhMqZ398g26rrnZqsZr+ZO7rqu4lzwDGrpDxpa5RXI4s6ehlj2R
  43961. e37AIVNMh+3yC1SVUZPVIqUNivGTDj5UDrDYyU7c8jEyVupk+eq1nRZmQnLzf9OxMUP8pI4X8W0j
  43962. q5Rm+K37DwhuJi1/FwcJsoz7UMCflo3Ptv0AnVoUmr8CRPXBwp8iXqIPoeM=
  43963. -----END CERTIFICATE-----
  43964. GDCA TrustAUTH R5 ROOT
  43965. ======================
  43966. -----BEGIN CERTIFICATE-----
  43967. MIIFiDCCA3CgAwIBAgIIfQmX/vBH6nowDQYJKoZIhvcNAQELBQAwYjELMAkGA1UEBhMCQ04xMjAw
  43968. BgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZIENPLixMVEQuMR8wHQYDVQQD
  43969. DBZHRENBIFRydXN0QVVUSCBSNSBST09UMB4XDTE0MTEyNjA1MTMxNVoXDTQwMTIzMTE1NTk1OVow
  43970. YjELMAkGA1UEBhMCQ04xMjAwBgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZ
  43971. IENPLixMVEQuMR8wHQYDVQQDDBZHRENBIFRydXN0QVVUSCBSNSBST09UMIICIjANBgkqhkiG9w0B
  43972. AQEFAAOCAg8AMIICCgKCAgEA2aMW8Mh0dHeb7zMNOwZ+Vfy1YI92hhJCfVZmPoiC7XJjDp6L3TQs
  43973. AlFRwxn9WVSEyfFrs0yw6ehGXTjGoqcuEVe6ghWinI9tsJlKCvLriXBjTnnEt1u9ol2x8kECK62p
  43974. OqPseQrsXzrj/e+APK00mxqriCZ7VqKChh/rNYmDf1+uKU49tm7srsHwJ5uu4/Ts765/94Y9cnrr
  43975. pftZTqfrlYwiOXnhLQiPzLyRuEH3FMEjqcOtmkVEs7LXLM3GKeJQEK5cy4KOFxg2fZfmiJqwTTQJ
  43976. 9Cy5WmYqsBebnh52nUpmMUHfP/vFBu8btn4aRjb3ZGM74zkYI+dndRTVdVeSN72+ahsmUPI2JgaQ
  43977. xXABZG12ZuGR224HwGGALrIuL4xwp9E7PLOR5G62xDtw8mySlwnNR30YwPO7ng/Wi64HtloPzgsM
  43978. R6flPri9fcebNaBhlzpBdRfMK5Z3KpIhHtmVdiBnaM8Nvd/WHwlqmuLMc3GkL30SgLdTMEZeS1SZ
  43979. D2fJpcjyIMGC7J0R38IC+xo70e0gmu9lZJIQDSri3nDxGGeCjGHeuLzRL5z7D9Ar7Rt2ueQ5Vfj4
  43980. oR24qoAATILnsn8JuLwwoC8N9VKejveSswoAHQBUlwbgsQfZxw9cZX08bVlX5O2ljelAU58VS6Bx
  43981. 9hoh49pwBiFYFIeFd3mqgnkCAwEAAaNCMEAwHQYDVR0OBBYEFOLJQJ9NzuiaoXzPDj9lxSmIahlR
  43982. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQDRSVfg
  43983. p8xoWLoBDysZzY2wYUWsEe1jUGn4H3++Fo/9nesLqjJHdtJnJO29fDMylyrHBYZmDRd9FBUb1Ov9
  43984. H5r2XpdptxolpAqzkT9fNqyL7FeoPueBihhXOYV0GkLH6VsTX4/5COmSdI31R9KrO9b7eGZONn35
  43985. 6ZLpBN79SWP8bfsUcZNnL0dKt7n/HipzcEYwv1ryL3ml4Y0M2fmyYzeMN2WFcGpcWwlyua1jPLHd
  43986. +PwyvzeG5LuOmCd+uh8W4XAR8gPfJWIyJyYYMoSf/wA6E7qaTfRPuBRwIrHKK5DOKcFw9C+df/KQ
  43987. HtZa37dG/OaG+svgIHZ6uqbL9XzeYqWxi+7egmaKTjowHz+Ay60nugxe19CxVsp3cbK1daFQqUBD
  43988. F8Io2c9Si1vIY9RCPqAzekYu9wogRlR+ak8x8YF+QnQ4ZXMn7sZ8uI7XpTrXmKGcjBBV09tL7ECQ
  43989. 8s1uV9JiDnxXk7Gnbc2dg7sq5+W2O3FYrf3RRbxake5TFW/TRQl1brqQXR4EzzffHqhmsYzmIGrv
  43990. /EhOdJhCrylvLmrH+33RZjEizIYAfmaDDEL0vTSSwxrqT8p+ck0LcIymSLumoRT2+1hEmRSuqguT
  43991. aaApJUqlyyvdimYHFngVV3Eb7PVHhPOeMTd61X8kreS8/f3MboPoDKi3QWwH3b08hpcv0g==
  43992. -----END CERTIFICATE-----
  43993. SSL.com Root Certification Authority RSA
  43994. ========================================
  43995. -----BEGIN CERTIFICATE-----
  43996. MIIF3TCCA8WgAwIBAgIIeyyb0xaAMpkwDQYJKoZIhvcNAQELBQAwfDELMAkGA1UEBhMCVVMxDjAM
  43997. BgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24x
  43998. MTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBSU0EwHhcNMTYw
  43999. MjEyMTczOTM5WhcNNDEwMjEyMTczOTM5WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx
  44000. EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NM
  44001. LmNvbSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFJTQTCCAiIwDQYJKoZIhvcNAQEBBQAD
  44002. ggIPADCCAgoCggIBAPkP3aMrfcvQKv7sZ4Wm5y4bunfh4/WvpOz6Sl2RxFdHaxh3a3by/ZPkPQ/C
  44003. Fp4LZsNWlJ4Xg4XOVu/yFv0AYvUiCVToZRdOQbngT0aXqhvIuG5iXmmxX9sqAn78bMrzQdjt0Oj8
  44004. P2FI7bADFB0QDksZ4LtO7IZl/zbzXmcCC52GVWH9ejjt/uIZALdvoVBidXQ8oPrIJZK0bnoix/ge
  44005. oeOy3ZExqysdBP+lSgQ36YWkMyv94tZVNHwZpEpox7Ko07fKoZOI68GXvIz5HdkihCR0xwQ9aqkp
  44006. k8zruFvh/l8lqjRYyMEjVJ0bmBHDOJx+PYZspQ9AhnwC9FwCTyjLrnGfDzrIM/4RJTXq/LrFYD3Z
  44007. fBjVsqnTdXgDciLKOsMf7yzlLqn6niy2UUb9rwPW6mBo6oUWNmuF6R7As93EJNyAKoFBbZQ+yODJ
  44008. gUEAnl6/f8UImKIYLEJAs/lvOCdLToD0PYFH4Ih86hzOtXVcUS4cK38acijnALXRdMbX5J+tB5O2
  44009. UzU1/Dfkw/ZdFr4hc96SCvigY2q8lpJqPvi8ZVWb3vUNiSYE/CUapiVpy8JtynziWV+XrOvvLsi8
  44010. 1xtZPCvM8hnIk2snYxnP/Okm+Mpxm3+T/jRnhE6Z6/yzeAkzcLpmpnbtG3PrGqUNxCITIJRWCk4s
  44011. bE6x/c+cCbqiM+2HAgMBAAGjYzBhMB0GA1UdDgQWBBTdBAkHovV6fVJTEpKV7jiAJQ2mWTAPBgNV
  44012. HRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFN0ECQei9Xp9UlMSkpXuOIAlDaZZMA4GA1UdDwEB/wQE
  44013. AwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAIBgRlCn7Jp0cHh5wYfGVcpNxJK1ok1iOMq8bs3AD/CUr
  44014. dIWQPXhq9LmLpZc7tRiRux6n+UBbkflVma8eEdBcHadm47GUBwwyOabqG7B52B2ccETjit3E+ZUf
  44015. ijhDPwGFpUenPUayvOUiaPd7nNgsPgohyC0zrL/FgZkxdMF1ccW+sfAjRfSda/wZY52jvATGGAsl
  44016. u1OJD7OAUN5F7kR/q5R4ZJjT9ijdh9hwZXT7DrkT66cPYakylszeu+1jTBi7qUD3oFRuIIhxdRjq
  44017. erQ0cuAjJ3dctpDqhiVAq+8zD8ufgr6iIPv2tS0a5sKFsXQP+8hlAqRSAUfdSSLBv9jra6x+3uxj
  44018. MxW3IwiPxg+NQVrdjsW5j+VFP3jbutIbQLH+cU0/4IGiul607BXgk90IH37hVZkLId6Tngr75qNJ
  44019. vTYw/ud3sqB1l7UtgYgXZSD32pAAn8lSzDLKNXz1PQ/YK9f1JmzJBjSWFupwWRoyeXkLtoh/D1JI
  44020. Pb9s2KJELtFOt3JY04kTlf5Eq/jXixtunLwsoFvVagCvXzfh1foQC5ichucmj87w7G6KVwuA406y
  44021. wKBjYZC6VWg3dGq2ktufoYYitmUnDuy2n0Jg5GfCtdpBC8TTi2EbvPofkSvXRAdeuims2cXp71NI
  44022. WuuA8ShYIc2wBlX7Jz9TkHCpBB5XJ7k=
  44023. -----END CERTIFICATE-----
  44024. SSL.com Root Certification Authority ECC
  44025. ========================================
  44026. -----BEGIN CERTIFICATE-----
  44027. MIICjTCCAhSgAwIBAgIIdebfy8FoW6gwCgYIKoZIzj0EAwIwfDELMAkGA1UEBhMCVVMxDjAMBgNV
  44028. BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xMTAv
  44029. BgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEy
  44030. MTgxNDAzWhcNNDEwMjEyMTgxNDAzWjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAO
  44031. BgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNv
  44032. bSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuBBAAiA2IA
  44033. BEVuqVDEpiM2nl8ojRfLliJkP9x6jh3MCLOicSS6jkm5BBtHllirLZXI7Z4INcgn64mMU1jrYor+
  44034. 8FsPazFSY0E7ic3s7LaNGdM0B9y7xgZ/wkWV7Mt/qCPgCemB+vNH06NjMGEwHQYDVR0OBBYEFILR
  44035. hXMw5zUE044CkvvlpNHEIejNMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUgtGFczDnNQTT
  44036. jgKS++Wk0cQh6M0wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2cAMGQCMG/n61kRpGDPYbCW
  44037. e+0F+S8Tkdzt5fxQaxFGRrMcIQBiu77D5+jNB5n5DQtdcj7EqgIwH7y6C+IwJPt8bYBVCpk+gA0z
  44038. 5Wajs6O7pdWLjwkspl1+4vAHCGht0nxpbl/f5Wpl
  44039. -----END CERTIFICATE-----
  44040. SSL.com EV Root Certification Authority RSA R2
  44041. ==============================================
  44042. -----BEGIN CERTIFICATE-----
  44043. MIIF6zCCA9OgAwIBAgIIVrYpzTS8ePYwDQYJKoZIhvcNAQELBQAwgYIxCzAJBgNVBAYTAlVTMQ4w
  44044. DAYDVQQIDAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9u
  44045. MTcwNQYDVQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIy
  44046. MB4XDTE3MDUzMTE4MTQzN1oXDTQyMDUzMDE4MTQzN1owgYIxCzAJBgNVBAYTAlVTMQ4wDAYDVQQI
  44047. DAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMTcwNQYD
  44048. VQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIyMIICIjAN
  44049. BgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAjzZlQOHWTcDXtOlG2mvqM0fNTPl9fb69LT3w23jh
  44050. hqXZuglXaO1XPqDQCEGD5yhBJB/jchXQARr7XnAjssufOePPxU7Gkm0mxnu7s9onnQqG6YE3Bf7w
  44051. cXHswxzpY6IXFJ3vG2fThVUCAtZJycxa4bH3bzKfydQ7iEGonL3Lq9ttewkfokxykNorCPzPPFTO
  44052. Zw+oz12WGQvE43LrrdF9HSfvkusQv1vrO6/PgN3B0pYEW3p+pKk8OHakYo6gOV7qd89dAFmPZiw+
  44053. B6KjBSYRaZfqhbcPlgtLyEDhULouisv3D5oi53+aNxPN8k0TayHRwMwi8qFG9kRpnMphNQcAb9Zh
  44054. CBHqurj26bNg5U257J8UZslXWNvNh2n4ioYSA0e/ZhN2rHd9NCSFg83XqpyQGp8hLH94t2S42Oim
  44055. 9HizVcuE0jLEeK6jj2HdzghTreyI/BXkmg3mnxp3zkyPuBQVPWKchjgGAGYS5Fl2WlPAApiiECto
  44056. RHuOec4zSnaqW4EWG7WK2NAAe15itAnWhmMOpgWVSbooi4iTsjQc2KRVbrcc0N6ZVTsj9CLg+Slm
  44057. JuwgUHfbSguPvuUCYHBBXtSuUDkiFCbLsjtzdFVHB3mBOagwE0TlBIqulhMlQg+5U8Sb/M3kHN48
  44058. +qvWBkofZ6aYMBzdLNvcGJVXZsb/XItW9XcCAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNV
  44059. HSMEGDAWgBT5YLvU49U09rj1BoAlp3PbRmmonjAdBgNVHQ4EFgQU+WC71OPVNPa49QaAJadz20Zp
  44060. qJ4wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQBWs47LCp1Jjr+kxJG7ZhcFUZh1
  44061. ++VQLHqe8RT6q9OKPv+RKY9ji9i0qVQBDb6Thi/5Sm3HXvVX+cpVHBK+Rw82xd9qt9t1wkclf7nx
  44062. Y/hoLVUE0fKNsKTPvDxeH3jnpaAgcLAExbf3cqfeIg29MyVGjGSSJuM+LmOW2puMPfgYCdcDzH2G
  44063. guDKBAdRUNf/ktUM79qGn5nX67evaOI5JpS6aLe/g9Pqemc9YmeuJeVy6OLk7K4S9ksrPJ/psEDz
  44064. OFSz/bdoyNrGj1E8svuR3Bznm53htw1yj+KkxKl4+esUrMZDBcJlOSgYAsOCsp0FvmXtll9ldDz7
  44065. CTUue5wT/RsPXcdtgTpWD8w74a8CLyKsRspGPKAcTNZEtF4uXBVmCeEmKf7GUmG6sXP/wwyc5Wxq
  44066. lD8UykAWlYTzWamsX0xhk23RO8yilQwipmdnRC652dKKQbNmC1r7fSOl8hqw/96bg5Qu0T/fkreR
  44067. rwU7ZcegbLHNYhLDkBvjJc40vG93drEQw/cFGsDWr3RiSBd3kmmQYRzelYB0VI8YHMPzA9C/pEN1
  44068. hlMYegouCRw2n5H9gooiS9EOUCXdywMMF8mDAAhONU2Ki+3wApRmLER/y5UnlhetCTCstnEXbosX
  44069. 9hwJ1C07mKVx01QT2WDz9UtmT/rx7iASjbSsV7FFY6GsdqnC+w==
  44070. -----END CERTIFICATE-----
  44071. SSL.com EV Root Certification Authority ECC
  44072. ===========================================
  44073. -----BEGIN CERTIFICATE-----
  44074. MIIClDCCAhqgAwIBAgIILCmcWxbtBZUwCgYIKoZIzj0EAwIwfzELMAkGA1UEBhMCVVMxDjAMBgNV
  44075. BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xNDAy
  44076. BgNVBAMMK1NTTC5jb20gRVYgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYw
  44077. MjEyMTgxNTIzWhcNNDEwMjEyMTgxNTIzWjB/MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx
  44078. EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjE0MDIGA1UEAwwrU1NM
  44079. LmNvbSBFViBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuB
  44080. BAAiA2IABKoSR5CYG/vvw0AHgyBO8TCCogbR8pKGYfL2IWjKAMTH6kMAVIbc/R/fALhBYlzccBYy
  44081. 3h+Z1MzFB8gIH2EWB1E9fVwHU+M1OIzfzZ/ZLg1KthkuWnBaBu2+8KGwytAJKaNjMGEwHQYDVR0O
  44082. BBYEFFvKXuXe0oGqzagtZFG22XKbl+ZPMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUW8pe
  44083. 5d7SgarNqC1kUbbZcpuX5k8wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2gAMGUCMQCK5kCJ
  44084. N+vp1RPZytRrJPOwPYdGWBrssd9v+1a6cGvHOMzosYxPD/fxZ3YOg9AeUY8CMD32IygmTMZgh5Mm
  44085. m7I1HrrW9zzRHM76JTymGoEVW/MSD2zuZYrJh6j5B+BimoxcSg==
  44086. -----END CERTIFICATE-----
  44087. GlobalSign Root CA - R6
  44088. =======================
  44089. -----BEGIN CERTIFICATE-----
  44090. MIIFgzCCA2ugAwIBAgIORea7A4Mzw4VlSOb/RVEwDQYJKoZIhvcNAQEMBQAwTDEgMB4GA1UECxMX
  44091. R2xvYmFsU2lnbiBSb290IENBIC0gUjYxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkds
  44092. b2JhbFNpZ24wHhcNMTQxMjEwMDAwMDAwWhcNMzQxMjEwMDAwMDAwWjBMMSAwHgYDVQQLExdHbG9i
  44093. YWxTaWduIFJvb3QgQ0EgLSBSNjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFs
  44094. U2lnbjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAJUH6HPKZvnsFMp7PPcNCPG0RQss
  44095. grRIxutbPK6DuEGSMxSkb3/pKszGsIhrxbaJ0cay/xTOURQh7ErdG1rG1ofuTToVBu1kZguSgMpE
  44096. 3nOUTvOniX9PeGMIyBJQbUJmL025eShNUhqKGoC3GYEOfsSKvGRMIRxDaNc9PIrFsmbVkJq3MQbF
  44097. vuJtMgamHvm566qjuL++gmNQ0PAYid/kD3n16qIfKtJwLnvnvJO7bVPiSHyMEAc4/2ayd2F+4OqM
  44098. PKq0pPbzlUoSB239jLKJz9CgYXfIWHSw1CM69106yqLbnQneXUQtkPGBzVeS+n68UARjNN9rkxi+
  44099. azayOeSsJDa38O+2HBNXk7besvjihbdzorg1qkXy4J02oW9UivFyVm4uiMVRQkQVlO6jxTiWm05O
  44100. WgtH8wY2SXcwvHE35absIQh1/OZhFj931dmRl4QKbNQCTXTAFO39OfuD8l4UoQSwC+n+7o/hbguy
  44101. CLNhZglqsQY6ZZZZwPA1/cnaKI0aEYdwgQqomnUdnjqGBQCe24DWJfncBZ4nWUx2OVvq+aWh2IMP
  44102. 0f/fMBH5hc8zSPXKbWQULHpYT9NLCEnFlWQaYw55PfWzjMpYrZxCRXluDocZXFSxZba/jJvcE+kN
  44103. b7gu3GduyYsRtYQUigAZcIN5kZeR1BonvzceMgfYFGM8KEyvAgMBAAGjYzBhMA4GA1UdDwEB/wQE
  44104. AwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSubAWjkxPioufi1xzWx/B/yGdToDAfBgNV
  44105. HSMEGDAWgBSubAWjkxPioufi1xzWx/B/yGdToDANBgkqhkiG9w0BAQwFAAOCAgEAgyXt6NH9lVLN
  44106. nsAEoJFp5lzQhN7craJP6Ed41mWYqVuoPId8AorRbrcWc+ZfwFSY1XS+wc3iEZGtIxg93eFyRJa0
  44107. lV7Ae46ZeBZDE1ZXs6KzO7V33EByrKPrmzU+sQghoefEQzd5Mr6155wsTLxDKZmOMNOsIeDjHfrY
  44108. BzN2VAAiKrlNIC5waNrlU/yDXNOd8v9EDERm8tLjvUYAGm0CuiVdjaExUd1URhxN25mW7xocBFym
  44109. Fe944Hn+Xds+qkxV/ZoVqW/hpvvfcDDpw+5CRu3CkwWJ+n1jez/QcYF8AOiYrg54NMMl+68KnyBr
  44110. 3TsTjxKM4kEaSHpzoHdpx7Zcf4LIHv5YGygrqGytXm3ABdJ7t+uA/iU3/gKbaKxCXcPu9czc8FB1
  44111. 0jZpnOZ7BN9uBmm23goJSFmH63sUYHpkqmlD75HHTOwY3WzvUy2MmeFe8nI+z1TIvWfspA9MRf/T
  44112. uTAjB0yPEL+GltmZWrSZVxykzLsViVO6LAUP5MSeGbEYNNVMnbrt9x+vJJUEeKgDu+6B5dpffItK
  44113. oZB0JaezPkvILFa9x8jvOOJckvB595yEunQtYQEgfn7R8k8HWV+LLUNS60YMlOH1Zkd5d9VUWx+t
  44114. JDfLRVpOoERIyNiwmcUVhAn21klJwGW45hpxbqCo8YLoRT5s1gLXCmeDBVrJpBA=
  44115. -----END CERTIFICATE-----
  44116. OISTE WISeKey Global Root GC CA
  44117. ===============================
  44118. -----BEGIN CERTIFICATE-----
  44119. MIICaTCCAe+gAwIBAgIQISpWDK7aDKtARb8roi066jAKBggqhkjOPQQDAzBtMQswCQYDVQQGEwJD
  44120. SDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNlZDEo
  44121. MCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQyBDQTAeFw0xNzA1MDkwOTQ4MzRa
  44122. Fw00MjA1MDkwOTU4MzNaMG0xCzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYDVQQL
  44123. ExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEdsb2Jh
  44124. bCBSb290IEdDIENBMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAETOlQwMYPchi82PG6s4nieUqjFqdr
  44125. VCTbUf/q9Akkwwsin8tqJ4KBDdLArzHkdIJuyiXZjHWd8dvQmqJLIX4Wp2OQ0jnUsYd4XxiWD1Ab
  44126. NTcPasbc2RNNpI6QN+a9WzGRo1QwUjAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd
  44127. BgNVHQ4EFgQUSIcUrOPDnpBgOtfKie7TrYy0UGYwEAYJKwYBBAGCNxUBBAMCAQAwCgYIKoZIzj0E
  44128. AwMDaAAwZQIwJsdpW9zV57LnyAyMjMPdeYwbY9XJUpROTYJKcx6ygISpJcBMWm1JKWB4E+J+SOtk
  44129. AjEA2zQgMgj/mkkCtojeFK9dbJlxjRo/i9fgojaGHAeCOnZT/cKi7e97sIBPWA9LUzm9
  44130. -----END CERTIFICATE-----
  44131. UCA Global G2 Root
  44132. ==================
  44133. -----BEGIN CERTIFICATE-----
  44134. MIIFRjCCAy6gAwIBAgIQXd+x2lqj7V2+WmUgZQOQ7zANBgkqhkiG9w0BAQsFADA9MQswCQYDVQQG
  44135. EwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxGzAZBgNVBAMMElVDQSBHbG9iYWwgRzIgUm9vdDAeFw0x
  44136. NjAzMTEwMDAwMDBaFw00MDEyMzEwMDAwMDBaMD0xCzAJBgNVBAYTAkNOMREwDwYDVQQKDAhVbmlU
  44137. cnVzdDEbMBkGA1UEAwwSVUNBIEdsb2JhbCBHMiBSb290MIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  44138. MIICCgKCAgEAxeYrb3zvJgUno4Ek2m/LAfmZmqkywiKHYUGRO8vDaBsGxUypK8FnFyIdK+35KYmT
  44139. oni9kmugow2ifsqTs6bRjDXVdfkX9s9FxeV67HeToI8jrg4aA3++1NDtLnurRiNb/yzmVHqUwCoV
  44140. 8MmNsHo7JOHXaOIxPAYzRrZUEaalLyJUKlgNAQLx+hVRZ2zA+te2G3/RVogvGjqNO7uCEeBHANBS
  44141. h6v7hn4PJGtAnTRnvI3HLYZveT6OqTwXS3+wmeOwcWDcC/Vkw85DvG1xudLeJ1uK6NjGruFZfc8o
  44142. LTW4lVYa8bJYS7cSN8h8s+1LgOGN+jIjtm+3SJUIsUROhYw6AlQgL9+/V087OpAh18EmNVQg7Mc/
  44143. R+zvWr9LesGtOxdQXGLYD0tK3Cv6brxzks3sx1DoQZbXqX5t2Okdj4q1uViSukqSKwxW/YDrCPBe
  44144. KW4bHAyvj5OJrdu9o54hyokZ7N+1wxrrFv54NkzWbtA+FxyQF2smuvt6L78RHBgOLXMDj6DlNaBa
  44145. 4kx1HXHhOThTeEDMg5PXCp6dW4+K5OXgSORIskfNTip1KnvyIvbJvgmRlld6iIis7nCs+dwp4wwc
  44146. OxJORNanTrAmyPPZGpeRaOrvjUYG0lZFWJo8DA+DuAUlwznPO6Q0ibd5Ei9Hxeepl2n8pndntd97
  44147. 8XplFeRhVmUCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O
  44148. BBYEFIHEjMz15DD/pQwIX4wVZyF0Ad/fMA0GCSqGSIb3DQEBCwUAA4ICAQATZSL1jiutROTL/7lo
  44149. 5sOASD0Ee/ojL3rtNtqyzm325p7lX1iPyzcyochltq44PTUbPrw7tgTQvPlJ9Zv3hcU2tsu8+Mg5
  44150. 1eRfB70VVJd0ysrtT7q6ZHafgbiERUlMjW+i67HM0cOU2kTC5uLqGOiiHycFutfl1qnN3e92mI0A
  44151. Ds0b+gO3joBYDic/UvuUospeZcnWhNq5NXHzJsBPd+aBJ9J3O5oUb3n09tDh05S60FdRvScFDcH9
  44152. yBIw7m+NESsIndTUv4BFFJqIRNow6rSn4+7vW4LVPtateJLbXDzz2K36uGt/xDYotgIVilQsnLAX
  44153. c47QN6MUPJiVAAwpBVueSUmxX8fjy88nZY41F7dXyDDZQVu5FLbowg+UMaeUmMxq67XhJ/UQqAHo
  44154. jhJi6IjMtX9Gl8CbEGY4GjZGXyJoPd/JxhMnq1MGrKI8hgZlb7F+sSlEmqO6SWkoaY/X5V+tBIZk
  44155. bxqgDMUIYs6Ao9Dz7GjevjPHF1t/gMRMTLGmhIrDO7gJzRSBuhjjVFc2/tsvfEehOjPI+Vg7RE+x
  44156. ygKJBJYoaMVLuCaJu9YzL1DV/pqJuhgyklTGW+Cd+V7lDSKb9triyCGyYiGqhkCyLmTTX8jjfhFn
  44157. RR8F/uOi77Oos/N9j/gMHyIfLXC0uAE0djAA5SN4p1bXUB+K+wb1whnw0A==
  44158. -----END CERTIFICATE-----
  44159. UCA Extended Validation Root
  44160. ============================
  44161. -----BEGIN CERTIFICATE-----
  44162. MIIFWjCCA0KgAwIBAgIQT9Irj/VkyDOeTzRYZiNwYDANBgkqhkiG9w0BAQsFADBHMQswCQYDVQQG
  44163. EwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9u
  44164. IFJvb3QwHhcNMTUwMzEzMDAwMDAwWhcNMzgxMjMxMDAwMDAwWjBHMQswCQYDVQQGEwJDTjERMA8G
  44165. A1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9uIFJvb3QwggIi
  44166. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCpCQcoEwKwmeBkqh5DFnpzsZGgdT6o+uM4AHrs
  44167. iWogD4vFsJszA1qGxliG1cGFu0/GnEBNyr7uaZa4rYEwmnySBesFK5pI0Lh2PpbIILvSsPGP2KxF
  44168. Rv+qZ2C0d35qHzwaUnoEPQc8hQ2E0B92CvdqFN9y4zR8V05WAT558aopO2z6+I9tTcg1367r3CTu
  44169. eUWnhbYFiN6IXSV8l2RnCdm/WhUFhvMJHuxYMjMR83dksHYf5BA1FxvyDrFspCqjc/wJHx4yGVMR
  44170. 59mzLC52LqGj3n5qiAno8geK+LLNEOfic0CTuwjRP+H8C5SzJe98ptfRr5//lpr1kXuYC3fUfugH
  44171. 0mK1lTnj8/FtDw5lhIpjVMWAtuCeS31HJqcBCF3RiJ7XwzJE+oJKCmhUfzhTA8ykADNkUVkLo4KR
  44172. el7sFsLzKuZi2irbWWIQJUoqgQtHB0MGcIfS+pMRKXpITeuUx3BNr2fVUbGAIAEBtHoIppB/TuDv
  44173. B0GHr2qlXov7z1CymlSvw4m6WC31MJixNnI5fkkE/SmnTHnkBVfblLkWU41Gsx2VYVdWf6/wFlth
  44174. WG82UBEL2KwrlRYaDh8IzTY0ZRBiZtWAXxQgXy0MoHgKaNYs1+lvK9JKBZP8nm9rZ/+I8U6laUpS
  44175. NwXqxhaN0sSZ0YIrO7o1dfdRUVjzyAfd5LQDfwIDAQABo0IwQDAdBgNVHQ4EFgQU2XQ65DA9DfcS
  44176. 3H5aBZ8eNJr34RQwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQEL
  44177. BQADggIBADaNl8xCFWQpN5smLNb7rhVpLGsaGvdftvkHTFnq88nIua7Mui563MD1sC3AO6+fcAUR
  44178. ap8lTwEpcOPlDOHqWnzcSbvBHiqB9RZLcpHIojG5qtr8nR/zXUACE/xOHAbKsxSQVBcZEhrxH9cM
  44179. aVr2cXj0lH2RC47skFSOvG+hTKv8dGT9cZr4QQehzZHkPJrgmzI5c6sq1WnIeJEmMX3ixzDx/BR4
  44180. dxIOE/TdFpS/S2d7cFOFyrC78zhNLJA5wA3CXWvp4uXViI3WLL+rG761KIcSF3Ru/H38j9CHJrAb
  44181. +7lsq+KePRXBOy5nAliRn+/4Qh8st2j1da3Ptfb/EX3C8CSlrdP6oDyp+l3cpaDvRKS+1ujl5BOW
  44182. F3sGPjLtx7dCvHaj2GU4Kzg1USEODm8uNBNA4StnDG1KQTAYI1oyVZnJF+A83vbsea0rWBmirSwi
  44183. GpWOvpaQXUJXxPkUAzUrHC1RVwinOt4/5Mi0A3PCwSaAuwtCH60NryZy2sy+s6ODWA2CxR9GUeOc
  44184. GMyNm43sSet1UNWMKFnKdDTajAshqx7qG+XH/RU+wBeq+yNuJkbL+vmxcmtpzyKEC2IPrNkZAJSi
  44185. djzULZrtBJ4tBmIQN1IchXIbJ+XMxjHsN+xjWZsLHXbMfjKaiJUINlK73nZfdklJrX+9ZSCyycEr
  44186. dhh2n1ax
  44187. -----END CERTIFICATE-----
  44188. Certigna Root CA
  44189. ================
  44190. -----BEGIN CERTIFICATE-----
  44191. MIIGWzCCBEOgAwIBAgIRAMrpG4nxVQMNo+ZBbcTjpuEwDQYJKoZIhvcNAQELBQAwWjELMAkGA1UE
  44192. BhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczEcMBoGA1UECwwTMDAwMiA0ODE0NjMwODEwMDAzNjEZ
  44193. MBcGA1UEAwwQQ2VydGlnbmEgUm9vdCBDQTAeFw0xMzEwMDEwODMyMjdaFw0zMzEwMDEwODMyMjda
  44194. MFoxCzAJBgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxHDAaBgNVBAsMEzAwMDIgNDgxNDYz
  44195. MDgxMDAwMzYxGTAXBgNVBAMMEENlcnRpZ25hIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  44196. DwAwggIKAoICAQDNGDllGlmx6mQWDoyUJJV8g9PFOSbcDO8WV43X2KyjQn+Cyu3NW9sOty3tRQgX
  44197. stmzy9YXUnIo245Onoq2C/mehJpNdt4iKVzSs9IGPjA5qXSjklYcoW9MCiBtnyN6tMbaLOQdLNyz
  44198. KNAT8kxOAkmhVECe5uUFoC2EyP+YbNDrihqECB63aCPuI9Vwzm1RaRDuoXrC0SIxwoKF0vJVdlB8
  44199. JXrJhFwLrN1CTivngqIkicuQstDuI7pmTLtipPlTWmR7fJj6o0ieD5Wupxj0auwuA0Wv8HT4Ks16
  44200. XdG+RCYyKfHx9WzMfgIhC59vpD++nVPiz32pLHxYGpfhPTc3GGYo0kDFUYqMwy3OU4gkWGQwFsWq
  44201. 4NYKpkDfePb1BHxpE4S80dGnBs8B92jAqFe7OmGtBIyT46388NtEbVncSVmurJqZNjBBe3YzIoej
  44202. wpKGbvlw7q6Hh5UbxHq9MfPU0uWZ/75I7HX1eBYdpnDBfzwboZL7z8g81sWTCo/1VTp2lc5ZmIoJ
  44203. lXcymoO6LAQ6l73UL77XbJuiyn1tJslV1c/DeVIICZkHJC1kJWumIWmbat10TWuXekG9qxf5kBdI
  44204. jzb5LdXF2+6qhUVB+s06RbFo5jZMm5BX7CO5hwjCxAnxl4YqKE3idMDaxIzb3+KhF1nOJFl0Mdp/
  44205. /TBt2dzhauH8XwIDAQABo4IBGjCCARYwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYw
  44206. HQYDVR0OBBYEFBiHVuBud+4kNTxOc5of1uHieX4rMB8GA1UdIwQYMBaAFBiHVuBud+4kNTxOc5of
  44207. 1uHieX4rMEQGA1UdIAQ9MDswOQYEVR0gADAxMC8GCCsGAQUFBwIBFiNodHRwczovL3d3d3cuY2Vy
  44208. dGlnbmEuZnIvYXV0b3JpdGVzLzBtBgNVHR8EZjBkMC+gLaArhilodHRwOi8vY3JsLmNlcnRpZ25h
  44209. LmZyL2NlcnRpZ25hcm9vdGNhLmNybDAxoC+gLYYraHR0cDovL2NybC5kaGlteW90aXMuY29tL2Nl
  44210. cnRpZ25hcm9vdGNhLmNybDANBgkqhkiG9w0BAQsFAAOCAgEAlLieT/DjlQgi581oQfccVdV8AOIt
  44211. OoldaDgvUSILSo3L6btdPrtcPbEo/uRTVRPPoZAbAh1fZkYJMyjhDSSXcNMQH+pkV5a7XdrnxIxP
  44212. TGRGHVyH41neQtGbqH6mid2PHMkwgu07nM3A6RngatgCdTer9zQoKJHyBApPNeNgJgH60BGM+RFq
  44213. 7q89w1DTj18zeTyGqHNFkIwgtnJzFyO+B2XleJINugHA64wcZr+shncBlA2c5uk5jR+mUYyZDDl3
  44214. 4bSb+hxnV29qao6pK0xXeXpXIs/NX2NGjVxZOob4Mkdio2cNGJHc+6Zr9UhhcyNZjgKnvETq9Emd
  44215. 8VRY+WCv2hikLyhF3HqgiIZd8zvn/yk1gPxkQ5Tm4xxvvq0OKmOZK8l+hfZx6AYDlf7ej0gcWtSS
  44216. 6Cvu5zHbugRqh5jnxV/vfaci9wHYTfmJ0A6aBVmknpjZbyvKcL5kwlWj9Omvw5Ip3IgWJJk8jSaY
  44217. tlu3zM63Nwf9JtmYhST/WSMDmu2dnajkXjjO11INb9I/bbEFa0nOipFGc/T2L/Coc3cOZayhjWZS
  44218. aX5LaAzHHjcng6WMxwLkFM1JAbBzs/3GkDpv0mztO+7skb6iQ12LAEpmJURw3kAP+HwV96LOPNde
  44219. E4yBFxgX0b3xdxA61GU5wSesVywlVP+i2k+KYTlerj1KjL0=
  44220. -----END CERTIFICATE-----
  44221. emSign Root CA - G1
  44222. ===================
  44223. -----BEGIN CERTIFICATE-----
  44224. MIIDlDCCAnygAwIBAgIKMfXkYgxsWO3W2DANBgkqhkiG9w0BAQsFADBnMQswCQYDVQQGEwJJTjET
  44225. MBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRl
  44226. ZDEcMBoGA1UEAxMTZW1TaWduIFJvb3QgQ0EgLSBHMTAeFw0xODAyMTgxODMwMDBaFw00MzAyMTgx
  44227. ODMwMDBaMGcxCzAJBgNVBAYTAklOMRMwEQYDVQQLEwplbVNpZ24gUEtJMSUwIwYDVQQKExxlTXVk
  44228. aHJhIFRlY2hub2xvZ2llcyBMaW1pdGVkMRwwGgYDVQQDExNlbVNpZ24gUm9vdCBDQSAtIEcxMIIB
  44229. IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk0u76WaK7p1b1TST0Bsew+eeuGQzf2N4aLTN
  44230. LnF115sgxk0pvLZoYIr3IZpWNVrzdr3YzZr/k1ZLpVkGoZM0Kd0WNHVO8oG0x5ZOrRkVUkr+PHB1
  44231. cM2vK6sVmjM8qrOLqs1D/fXqcP/tzxE7lM5OMhbTI0Aqd7OvPAEsbO2ZLIvZTmmYsvePQbAyeGHW
  44232. DV/D+qJAkh1cF+ZwPjXnorfCYuKrpDhMtTk1b+oDafo6VGiFbdbyL0NVHpENDtjVaqSW0RM8LHhQ
  44233. 6DqS0hdW5TUaQBw+jSztOd9C4INBdN+jzcKGYEho42kLVACL5HZpIQ15TjQIXhTCzLG3rdd8cIrH
  44234. hQIDAQABo0IwQDAdBgNVHQ4EFgQU++8Nhp6w492pufEhF38+/PB3KxowDgYDVR0PAQH/BAQDAgEG
  44235. MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAFn/8oz1h31xPaOfG1vR2vjTnGs2
  44236. vZupYeveFix0PZ7mddrXuqe8QhfnPZHr5X3dPpzxz5KsbEjMwiI/aTvFthUvozXGaCocV685743Q
  44237. NcMYDHsAVhzNixl03r4PEuDQqqE/AjSxcM6dGNYIAwlG7mDgfrbESQRRfXBgvKqy/3lyeqYdPV8q
  44238. +Mri/Tm3R7nrft8EI6/6nAYH6ftjk4BAtcZsCjEozgyfz7MjNYBBjWzEN3uBL4ChQEKF6dk4jeih
  44239. U80Bv2noWgbyRQuQ+q7hv53yrlc8pa6yVvSLZUDp/TGBLPQ5Cdjua6e0ph0VpZj3AYHYhX3zUVxx
  44240. iN66zB+Afko=
  44241. -----END CERTIFICATE-----
  44242. emSign ECC Root CA - G3
  44243. =======================
  44244. -----BEGIN CERTIFICATE-----
  44245. MIICTjCCAdOgAwIBAgIKPPYHqWhwDtqLhDAKBggqhkjOPQQDAzBrMQswCQYDVQQGEwJJTjETMBEG
  44246. A1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRlZDEg
  44247. MB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0gRzMwHhcNMTgwMjE4MTgzMDAwWhcNNDMwMjE4
  44248. MTgzMDAwWjBrMQswCQYDVQQGEwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11
  44249. ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0g
  44250. RzMwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQjpQy4LRL1KPOxst3iAhKAnjlfSU2fySU0WXTsuwYc
  44251. 58Byr+iuL+FBVIcUqEqy6HyC5ltqtdyzdc6LBtCGI79G1Y4PPwT01xySfvalY8L1X44uT6EYGQIr
  44252. MgqCZH0Wk9GjQjBAMB0GA1UdDgQWBBR8XQKEE9TMipuBzhccLikenEhjQjAOBgNVHQ8BAf8EBAMC
  44253. AQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNpADBmAjEAvvNhzwIQHWSVB7gYboiFBS+D
  44254. CBeQyh+KTOgNG3qxrdWBCUfvO6wIBHxcmbHtRwfSAjEAnbpV/KlK6O3t5nYBQnvI+GDZjVGLVTv7
  44255. jHvrZQnD+JbNR6iC8hZVdyR+EhCVBCyj
  44256. -----END CERTIFICATE-----
  44257. emSign Root CA - C1
  44258. ===================
  44259. -----BEGIN CERTIFICATE-----
  44260. MIIDczCCAlugAwIBAgILAK7PALrEzzL4Q7IwDQYJKoZIhvcNAQELBQAwVjELMAkGA1UEBhMCVVMx
  44261. EzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQDExNlbVNp
  44262. Z24gUm9vdCBDQSAtIEMxMB4XDTE4MDIxODE4MzAwMFoXDTQzMDIxODE4MzAwMFowVjELMAkGA1UE
  44263. BhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQD
  44264. ExNlbVNpZ24gUm9vdCBDQSAtIEMxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz+up
  44265. ufGZBczYKCFK83M0UYRWEPWgTywS4/oTmifQz/l5GnRfHXk5/Fv4cI7gklL35CX5VIPZHdPIWoU/
  44266. Xse2B+4+wM6ar6xWQio5JXDWv7V7Nq2s9nPczdcdioOl+yuQFTdrHCZH3DspVpNqs8FqOp099cGX
  44267. OFgFixwR4+S0uF2FHYP+eF8LRWgYSKVGczQ7/g/IdrvHGPMF0Ybzhe3nudkyrVWIzqa2kbBPrH4V
  44268. I5b2P/AgNBbeCsbEBEV5f6f9vtKppa+cxSMq9zwhbL2vj07FOrLzNBL834AaSaTUqZX3noleooms
  44269. lMuoaJuvimUnzYnu3Yy1aylwQ6BpC+S5DwIDAQABo0IwQDAdBgNVHQ4EFgQU/qHgcB4qAzlSWkK+
  44270. XJGFehiqTbUwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQAD
  44271. ggEBAMJKVvoVIXsoounlHfv4LcQ5lkFMOycsxGwYFYDGrK9HWS8mC+M2sO87/kOXSTKZEhVb3xEp
  44272. /6tT+LvBeA+snFOvV71ojD1pM/CjoCNjO2RnIkSt1XHLVip4kqNPEjE2NuLe/gDEo2APJ62gsIq1
  44273. NnpSob0n9CAnYuhNlCQT5AoE6TyrLshDCUrGYQTlSTR+08TI9Q/Aqum6VF7zYytPT1DU/rl7mYw9
  44274. wC68AivTxEDkigcxHpvOJpkT+xHqmiIMERnHXhuBUDDIlhJu58tBf5E7oke3VIAb3ADMmpDqw8NQ
  44275. BmIMMMAVSKeoWXzhriKi4gp6D/piq1JM4fHfyr6DDUI=
  44276. -----END CERTIFICATE-----
  44277. emSign ECC Root CA - C3
  44278. =======================
  44279. -----BEGIN CERTIFICATE-----
  44280. MIICKzCCAbGgAwIBAgIKe3G2gla4EnycqDAKBggqhkjOPQQDAzBaMQswCQYDVQQGEwJVUzETMBEG
  44281. A1UECxMKZW1TaWduIFBLSTEUMBIGA1UEChMLZU11ZGhyYSBJbmMxIDAeBgNVBAMTF2VtU2lnbiBF
  44282. Q0MgUm9vdCBDQSAtIEMzMB4XDTE4MDIxODE4MzAwMFoXDTQzMDIxODE4MzAwMFowWjELMAkGA1UE
  44283. BhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMSAwHgYDVQQD
  44284. ExdlbVNpZ24gRUNDIFJvb3QgQ0EgLSBDMzB2MBAGByqGSM49AgEGBSuBBAAiA2IABP2lYa57JhAd
  44285. 6bciMK4G9IGzsUJxlTm801Ljr6/58pc1kjZGDoeVjbk5Wum739D+yAdBPLtVb4OjavtisIGJAnB9
  44286. SMVK4+kiVCJNk7tCDK93nCOmfddhEc5lx/h//vXyqaNCMEAwHQYDVR0OBBYEFPtaSNCAIEDyqOkA
  44287. B2kZd6fmw/TPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MAoGCCqGSM49BAMDA2gA
  44288. MGUCMQC02C8Cif22TGK6Q04ThHK1rt0c3ta13FaPWEBaLd4gTCKDypOofu4SQMfWh0/434UCMBwU
  44289. ZOR8loMRnLDRWmFLpg9J0wD8ofzkpf9/rdcw0Md3f76BB1UwUCAU9Vc4CqgxUQ==
  44290. -----END CERTIFICATE-----
  44291. Hongkong Post Root CA 3
  44292. =======================
  44293. -----BEGIN CERTIFICATE-----
  44294. MIIFzzCCA7egAwIBAgIUCBZfikyl7ADJk0DfxMauI7gcWqQwDQYJKoZIhvcNAQELBQAwbzELMAkG
  44295. A1UEBhMCSEsxEjAQBgNVBAgTCUhvbmcgS29uZzESMBAGA1UEBxMJSG9uZyBLb25nMRYwFAYDVQQK
  44296. Ew1Ib25na29uZyBQb3N0MSAwHgYDVQQDExdIb25na29uZyBQb3N0IFJvb3QgQ0EgMzAeFw0xNzA2
  44297. MDMwMjI5NDZaFw00MjA2MDMwMjI5NDZaMG8xCzAJBgNVBAYTAkhLMRIwEAYDVQQIEwlIb25nIEtv
  44298. bmcxEjAQBgNVBAcTCUhvbmcgS29uZzEWMBQGA1UEChMNSG9uZ2tvbmcgUG9zdDEgMB4GA1UEAxMX
  44299. SG9uZ2tvbmcgUG9zdCBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCz
  44300. iNfqzg8gTr7m1gNt7ln8wlffKWihgw4+aMdoWJwcYEuJQwy51BWy7sFOdem1p+/l6TWZ5Mwc50tf
  44301. jTMwIDNT2aa71T4Tjukfh0mtUC1Qyhi+AViiE3CWu4mIVoBc+L0sPOFMV4i707mV78vH9toxdCim
  44302. 5lSJ9UExyuUmGs2C4HDaOym71QP1mbpV9WTRYA6ziUm4ii8F0oRFKHyPaFASePwLtVPLwpgchKOe
  44303. sL4jpNrcyCse2m5FHomY2vkALgbpDDtw1VAliJnLzXNg99X/NWfFobxeq81KuEXryGgeDQ0URhLj
  44304. 0mRiikKYvLTGCAj4/ahMZJx2Ab0vqWwzD9g/KLg8aQFChn5pwckGyuV6RmXpwtZQQS4/t+TtbNe/
  44305. JgERohYpSms0BpDsE9K2+2p20jzt8NYt3eEV7KObLyzJPivkaTv/ciWxNoZbx39ri1UbSsUgYT2u
  44306. y1DhCDq+sI9jQVMwCFk8mB13umOResoQUGC/8Ne8lYePl8X+l2oBlKN8W4UdKjk60FSh0Tlxnf0h
  44307. +bV78OLgAo9uliQlLKAeLKjEiafv7ZkGL7YKTE/bosw3Gq9HhS2KX8Q0NEwA/RiTZxPRN+ZItIsG
  44308. xVd7GYYKecsAyVKvQv83j+GjHno9UKtjBucVtT+2RTeUN7F+8kjDf8V1/peNRY8apxpyKBpADwID
  44309. AQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAfBgNVHSMEGDAWgBQXnc0e
  44310. i9Y5K3DTXNSguB+wAPzFYTAdBgNVHQ4EFgQUF53NHovWOStw01zUoLgfsAD8xWEwDQYJKoZIhvcN
  44311. AQELBQADggIBAFbVe27mIgHSQpsY1Q7XZiNc4/6gx5LS6ZStS6LG7BJ8dNVI0lkUmcDrudHr9Egw
  44312. W62nV3OZqdPlt9EuWSRY3GguLmLYauRwCy0gUCCkMpXRAJi70/33MvJJrsZ64Ee+bs7Lo3I6LWld
  44313. y8joRTnU+kLBEUx3XZL7av9YROXrgZ6voJmtvqkBZss4HTzfQx/0TW60uhdG/H39h4F5ag0zD/ov
  44314. +BS5gLNdTaqX4fnkGMX41TiMJjz98iji7lpJiCzfeT2OnpA8vUFKOt1b9pq0zj8lMH8yfaIDlNDc
  44315. eqFS3m6TjRgm/VWsvY+b0s+v54Ysyx8Jb6NvqYTUc79NoXQbTiNg8swOqn+knEwlqLJmOzj/2ZQw
  44316. 9nKEvmhVEA/GcywWaZMH/rFF7buiVWqw2rVKAiUnhde3t4ZEFolsgCs+l6mc1X5VTMbeRRAc6uk7
  44317. nwNT7u56AQIWeNTowr5GdogTPyK7SBIdUgC0An4hGh6cJfTzPV4e0hz5sy229zdcxsshTrD3mUcY
  44318. hcErulWuBurQB7Lcq9CClnXO0lD+mefPL5/ndtFhKvshuzHQqp9HpLIiyhY6UFfEW0NnxWViA0kB
  44319. 60PZ2Pierc+xYw5F9KBaLJstxabArahH9CdMOA0uG0k7UvToiIMrVCjU8jVStDKDYmlkDJGcn5fq
  44320. dBb9HxEGmpv0
  44321. -----END CERTIFICATE-----
  44322. Entrust Root Certification Authority - G4
  44323. =========================================
  44324. -----BEGIN CERTIFICATE-----
  44325. MIIGSzCCBDOgAwIBAgIRANm1Q3+vqTkPAAAAAFVlrVgwDQYJKoZIhvcNAQELBQAwgb4xCzAJBgNV
  44326. BAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3Qu
  44327. bmV0L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxNSBFbnRydXN0LCBJbmMuIC0gZm9yIGF1
  44328. dGhvcml6ZWQgdXNlIG9ubHkxMjAwBgNVBAMTKUVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1
  44329. dGhvcml0eSAtIEc0MB4XDTE1MDUyNzExMTExNloXDTM3MTIyNzExNDExNlowgb4xCzAJBgNVBAYT
  44330. AlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0
  44331. L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxNSBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhv
  44332. cml6ZWQgdXNlIG9ubHkxMjAwBgNVBAMTKUVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhv
  44333. cml0eSAtIEc0MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAsewsQu7i0TD/pZJH4i3D
  44334. umSXbcr3DbVZwbPLqGgZ2K+EbTBwXX7zLtJTmeH+H17ZSK9dE43b/2MzTdMAArzE+NEGCJR5WIoV
  44335. 3imz/f3ET+iq4qA7ec2/a0My3dl0ELn39GjUu9CH1apLiipvKgS1sqbHoHrmSKvS0VnM1n4j5pds
  44336. 8ELl3FFLFUHtSUrJ3hCX1nbB76W1NhSXNdh4IjVS70O92yfbYVaCNNzLiGAMC1rlLAHGVK/XqsEQ
  44337. e9IFWrhAnoanw5CGAlZSCXqc0ieCU0plUmr1POeo8pyvi73TDtTUXm6Hnmo9RR3RXRv06QqsYJn7
  44338. ibT/mCzPfB3pAqoEmh643IhuJbNsZvc8kPNXwbMv9W3y+8qh+CmdRouzavbmZwe+LGcKKh9asj5X
  44339. xNMhIWNlUpEbsZmOeX7m640A2Vqq6nPopIICR5b+W45UYaPrL0swsIsjdXJ8ITzI9vF01Bx7owVV
  44340. 7rtNOzK+mndmnqxpkCIHH2E6lr7lmk/MBTwoWdPBDFSoWWG9yHJM6Nyfh3+9nEg2XpWjDrk4JFX8
  44341. dWbrAuMINClKxuMrLzOg2qOGpRKX/YAr2hRC45K9PvJdXmd0LhyIRyk0X+IyqJwlN4y6mACXi0mW
  44342. Hv0liqzc2thddG5msP9E36EYxr5ILzeUePiVSj9/E15dWf10hkNjc0kCAwEAAaNCMEAwDwYDVR0T
  44343. AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJ84xFYjwznooHFs6FRM5Og6sb9n
  44344. MA0GCSqGSIb3DQEBCwUAA4ICAQAS5UKme4sPDORGpbZgQIeMJX6tuGguW8ZAdjwD+MlZ9POrYs4Q
  44345. jbRaZIxowLByQzTSGwv2LFPSypBLhmb8qoMi9IsabyZIrHZ3CL/FmFz0Jomee8O5ZDIBf9PD3Vht
  44346. 7LGrhFV0d4QEJ1JrhkzO3bll/9bGXp+aEJlLdWr+aumXIOTkdnrG0CSqkM0gkLpHZPt/B7NTeLUK
  44347. YvJzQ85BK4FqLoUWlFPUa19yIqtRLULVAJyZv967lDtX/Zr1hstWO1uIAeV8KEsD+UmDfLJ/fOPt
  44348. jqF/YFOOVZ1QNBIPt5d7bIdKROf1beyAN/BYGW5KaHbwH5Lk6rWS02FREAutp9lfx1/cH6NcjKF+
  44349. m7ee01ZvZl4HliDtC3T7Zk6LERXpgUl+b7DUUH8i119lAg2m9IUe2K4GS0qn0jFmwvjO5QimpAKW
  44350. RGhXxNUzzxkvFMSUHHuk2fCfDrGA4tGeEWSpiBE6doLlYsKA2KSD7ZPvfC+QsDJMlhVoSFLUmQjA
  44351. JOgc47OlIQ6SwJAfzyBfyjs4x7dtOvPmRLgOMWuIjnDrnBdSqEGULoe256YSxXXfW8AKbnuk5F6G
  44352. +TaU33fD6Q3AOfF5u0aOq0NZJ7cguyPpVkAh7DE9ZapD8j3fcEThuk0mEDuYn/PIjhs4ViFqUZPT
  44353. kcpG2om3PVODLAgfi49T3f+sHw==
  44354. -----END CERTIFICATE-----
  44355. Microsoft ECC Root Certificate Authority 2017
  44356. =============================================
  44357. -----BEGIN CERTIFICATE-----
  44358. MIICWTCCAd+gAwIBAgIQZvI9r4fei7FK6gxXMQHC7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV
  44359. UzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNyb3NvZnQgRUND
  44360. IFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwHhcNMTkxMjE4MjMwNjQ1WhcNNDIwNzE4
  44361. MjMxNjA0WjBlMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYw
  44362. NAYDVQQDEy1NaWNyb3NvZnQgRUNDIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwdjAQ
  44363. BgcqhkjOPQIBBgUrgQQAIgNiAATUvD0CQnVBEyPNgASGAlEvaqiBYgtlzPbKnR5vSmZRogPZnZH6
  44364. thaxjG7efM3beaYvzrvOcS/lpaso7GMEZpn4+vKTEAXhgShC48Zo9OYbhGBKia/teQ87zvH2RPUB
  44365. eMCjVDBSMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTIy5lycFIM
  44366. +Oa+sgRXKSrPQhDtNTAQBgkrBgEEAYI3FQEEAwIBADAKBggqhkjOPQQDAwNoADBlAjBY8k3qDPlf
  44367. Xu5gKcs68tvWMoQZP3zVL8KxzJOuULsJMsbG7X7JNpQS5GiFBqIb0C8CMQCZ6Ra0DvpWSNSkMBaR
  44368. eNtUjGUBiudQZsIxtzm6uBoiB078a1QWIP8rtedMDE2mT3M=
  44369. -----END CERTIFICATE-----
  44370. Microsoft RSA Root Certificate Authority 2017
  44371. =============================================
  44372. -----BEGIN CERTIFICATE-----
  44373. MIIFqDCCA5CgAwIBAgIQHtOXCV/YtLNHcB6qvn9FszANBgkqhkiG9w0BAQwFADBlMQswCQYDVQQG
  44374. EwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNyb3NvZnQg
  44375. UlNBIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwHhcNMTkxMjE4MjI1MTIyWhcNNDIw
  44376. NzE4MjMwMDIzWjBlMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9u
  44377. MTYwNAYDVQQDEy1NaWNyb3NvZnQgUlNBIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcw
  44378. ggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKW76UM4wplZEWCpW9R2LBifOZNt9GkMml
  44379. 7Xhqb0eRaPgnZ1AzHaGm++DlQ6OEAlcBXZxIQIJTELy/xztokLaCLeX0ZdDMbRnMlfl7rEqUrQ7e
  44380. S0MdhweSE5CAg2Q1OQT85elss7YfUJQ4ZVBcF0a5toW1HLUX6NZFndiyJrDKxHBKrmCk3bPZ7Pw7
  44381. 1VdyvD/IybLeS2v4I2wDwAW9lcfNcztmgGTjGqwu+UcF8ga2m3P1eDNbx6H7JyqhtJqRjJHTOoI+
  44382. dkC0zVJhUXAoP8XFWvLJjEm7FFtNyP9nTUwSlq31/niol4fX/V4ggNyhSyL71Imtus5Hl0dVe49F
  44383. yGcohJUcaDDv70ngNXtk55iwlNpNhTs+VcQor1fznhPbRiefHqJeRIOkpcrVE7NLP8TjwuaGYaRS
  44384. MLl6IE9vDzhTyzMMEyuP1pq9KsgtsRx9S1HKR9FIJ3Jdh+vVReZIZZ2vUpC6W6IYZVcSn2i51BVr
  44385. lMRpIpj0M+Dt+VGOQVDJNE92kKz8OMHY4Xu54+OU4UZpyw4KUGsTuqwPN1q3ErWQgR5WrlcihtnJ
  44386. 0tHXUeOrO8ZV/R4O03QK0dqq6mm4lyiPSMQH+FJDOvTKVTUssKZqwJz58oHhEmrARdlns87/I6KJ
  44387. ClTUFLkqqNfs+avNJVgyeY+QW5g5xAgGwax/Dj0ApQIDAQABo1QwUjAOBgNVHQ8BAf8EBAMCAYYw
  44388. DwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUCctZf4aycI8awznjwNnpv7tNsiMwEAYJKwYBBAGC
  44389. NxUBBAMCAQAwDQYJKoZIhvcNAQEMBQADggIBAKyvPl3CEZaJjqPnktaXFbgToqZCLgLNFgVZJ8og
  44390. 6Lq46BrsTaiXVq5lQ7GPAJtSzVXNUzltYkyLDVt8LkS/gxCP81OCgMNPOsduET/m4xaRhPtthH80
  44391. dK2Jp86519efhGSSvpWhrQlTM93uCupKUY5vVau6tZRGrox/2KJQJWVggEbbMwSubLWYdFQl3JPk
  44392. +ONVFT24bcMKpBLBaYVu32TxU5nhSnUgnZUP5NbcA/FZGOhHibJXWpS2qdgXKxdJ5XbLwVaZOjex
  44393. /2kskZGT4d9Mozd2TaGf+G0eHdP67Pv0RR0Tbc/3WeUiJ3IrhvNXuzDtJE3cfVa7o7P4NHmJweDy
  44394. AmH3pvwPuxwXC65B2Xy9J6P9LjrRk5Sxcx0ki69bIImtt2dmefU6xqaWM/5TkshGsRGRxpl/j8nW
  44395. ZjEgQRCHLQzWwa80mMpkg/sTV9HB8Dx6jKXB/ZUhoHHBk2dxEuqPiAppGWSZI1b7rCoucL5mxAyE
  44396. 7+WL85MB+GqQk2dLsmijtWKP6T+MejteD+eMuMZ87zf9dOLITzNy4ZQ5bb0Sr74MTnB8G2+NszKT
  44397. c0QWbej09+CVgI+WXTik9KveCjCHk9hNAHFiRSdLOkKEW39lt2c0Ui2cFmuqqNh7o0JMcccMyj6D
  44398. 5KbvtwEwXlGjefVwaaZBRA+GsCyRxj3qrg+E
  44399. -----END CERTIFICATE-----
  44400. e-Szigno Root CA 2017
  44401. =====================
  44402. -----BEGIN CERTIFICATE-----
  44403. MIICQDCCAeWgAwIBAgIMAVRI7yH9l1kN9QQKMAoGCCqGSM49BAMCMHExCzAJBgNVBAYTAkhVMREw
  44404. DwYDVQQHDAhCdWRhcGVzdDEWMBQGA1UECgwNTWljcm9zZWMgTHRkLjEXMBUGA1UEYQwOVkFUSFUt
  44405. MjM1ODQ0OTcxHjAcBgNVBAMMFWUtU3ppZ25vIFJvb3QgQ0EgMjAxNzAeFw0xNzA4MjIxMjA3MDZa
  44406. Fw00MjA4MjIxMjA3MDZaMHExCzAJBgNVBAYTAkhVMREwDwYDVQQHDAhCdWRhcGVzdDEWMBQGA1UE
  44407. CgwNTWljcm9zZWMgTHRkLjEXMBUGA1UEYQwOVkFUSFUtMjM1ODQ0OTcxHjAcBgNVBAMMFWUtU3pp
  44408. Z25vIFJvb3QgQ0EgMjAxNzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABJbcPYrYsHtvxie+RJCx
  44409. s1YVe45DJH0ahFnuY2iyxl6H0BVIHqiQrb1TotreOpCmYF9oMrWGQd+HWyx7xf58etqjYzBhMA8G
  44410. A1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBSHERUI0arBeAyxr87GyZDv
  44411. vzAEwDAfBgNVHSMEGDAWgBSHERUI0arBeAyxr87GyZDvvzAEwDAKBggqhkjOPQQDAgNJADBGAiEA
  44412. tVfd14pVCzbhhkT61NlojbjcI4qKDdQvfepz7L9NbKgCIQDLpbQS+ue16M9+k/zzNY9vTlp8tLxO
  44413. svxyqltZ+efcMQ==
  44414. -----END CERTIFICATE-----
  44415. certSIGN Root CA G2
  44416. ===================
  44417. -----BEGIN CERTIFICATE-----
  44418. MIIFRzCCAy+gAwIBAgIJEQA0tk7GNi02MA0GCSqGSIb3DQEBCwUAMEExCzAJBgNVBAYTAlJPMRQw
  44419. EgYDVQQKEwtDRVJUU0lHTiBTQTEcMBoGA1UECxMTY2VydFNJR04gUk9PVCBDQSBHMjAeFw0xNzAy
  44420. MDYwOTI3MzVaFw00MjAyMDYwOTI3MzVaMEExCzAJBgNVBAYTAlJPMRQwEgYDVQQKEwtDRVJUU0lH
  44421. TiBTQTEcMBoGA1UECxMTY2VydFNJR04gUk9PVCBDQSBHMjCCAiIwDQYJKoZIhvcNAQEBBQADggIP
  44422. ADCCAgoCggIBAMDFdRmRfUR0dIf+DjuW3NgBFszuY5HnC2/OOwppGnzC46+CjobXXo9X69MhWf05
  44423. N0IwvlDqtg+piNguLWkh59E3GE59kdUWX2tbAMI5Qw02hVK5U2UPHULlj88F0+7cDBrZuIt4Imfk
  44424. abBoxTzkbFpG583H+u/E7Eu9aqSs/cwoUe+StCmrqzWaTOTECMYmzPhpn+Sc8CnTXPnGFiWeI8Mg
  44425. wT0PPzhAsP6CRDiqWhqKa2NYOLQV07YRaXseVO6MGiKscpc/I1mbySKEwQdPzH/iV8oScLumZfNp
  44426. dWO9lfsbl83kqK/20U6o2YpxJM02PbyWxPFsqa7lzw1uKA2wDrXKUXt4FMMgL3/7FFXhEZn91Qqh
  44427. ngLjYl/rNUssuHLoPj1PrCy7Lobio3aP5ZMqz6WryFyNSwb/EkaseMsUBzXgqd+L6a8VTxaJW732
  44428. jcZZroiFDsGJ6x9nxUWO/203Nit4ZoORUSs9/1F3dmKh7Gc+PoGD4FapUB8fepmrY7+EF3fxDTvf
  44429. 95xhszWYijqy7DwaNz9+j5LP2RIUZNoQAhVB/0/E6xyjyfqZ90bp4RjZsbgyLcsUDFDYg2WD7rlc
  44430. z8sFWkz6GZdr1l0T08JcVLwyc6B49fFtHsufpaafItzRUZ6CeWRgKRM+o/1Pcmqr4tTluCRVLERL
  44431. iohEnMqE0yo7AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1Ud
  44432. DgQWBBSCIS1mxteg4BXrzkwJd8RgnlRuAzANBgkqhkiG9w0BAQsFAAOCAgEAYN4auOfyYILVAzOB
  44433. ywaK8SJJ6ejqkX/GM15oGQOGO0MBzwdw5AgeZYWR5hEit/UCI46uuR59H35s5r0l1ZUa8gWmr4UC
  44434. b6741jH/JclKyMeKqdmfS0mbEVeZkkMR3rYzpMzXjWR91M08KCy0mpbqTfXERMQlqiCA2ClV9+BB
  44435. /AYm/7k29UMUA2Z44RGx2iBfRgB4ACGlHgAoYXhvqAEBj500mv/0OJD7uNGzcgbJceaBxXntC6Z5
  44436. 8hMLnPddDnskk7RI24Zf3lCGeOdA5jGokHZwYa+cNywRtYK3qq4kNFtyDGkNzVmf9nGvnAvRCjj5
  44437. BiKDUyUM/FHE5r7iOZULJK2v0ZXkltd0ZGtxTgI8qoXzIKNDOXZbbFD+mpwUHmUUihW9o4JFWklW
  44438. atKcsWMy5WHgUyIOpwpJ6st+H6jiYoD2EEVSmAYY3qXNL3+q1Ok+CHLsIwMCPKaq2LxndD0UF/tU
  44439. Sxfj03k9bWtJySgOLnRQvwzZRjoQhsmnP+mg7H/rpXdYaXHmgwo38oZJar55CJD2AhZkPuXaTH4M
  44440. NMn5X7azKFGnpyuqSfqNZSlO42sTp5SjLVFteAxEy9/eCG/Oo2Sr05WE1LlSVHJ7liXMvGnjSG4N
  44441. 0MedJ5qq+BOS3R7fY581qRY27Iy4g/Q9iY/NtBde17MXQRBdJ3NghVdJIgc=
  44442. -----END CERTIFICATE-----
  44443. Trustwave Global Certification Authority
  44444. ========================================
  44445. -----BEGIN CERTIFICATE-----
  44446. MIIF2jCCA8KgAwIBAgIMBfcOhtpJ80Y1LrqyMA0GCSqGSIb3DQEBCwUAMIGIMQswCQYDVQQGEwJV
  44447. UzERMA8GA1UECAwISWxsaW5vaXMxEDAOBgNVBAcMB0NoaWNhZ28xITAfBgNVBAoMGFRydXN0d2F2
  44448. ZSBIb2xkaW5ncywgSW5jLjExMC8GA1UEAwwoVHJ1c3R3YXZlIEdsb2JhbCBDZXJ0aWZpY2F0aW9u
  44449. IEF1dGhvcml0eTAeFw0xNzA4MjMxOTM0MTJaFw00MjA4MjMxOTM0MTJaMIGIMQswCQYDVQQGEwJV
  44450. UzERMA8GA1UECAwISWxsaW5vaXMxEDAOBgNVBAcMB0NoaWNhZ28xITAfBgNVBAoMGFRydXN0d2F2
  44451. ZSBIb2xkaW5ncywgSW5jLjExMC8GA1UEAwwoVHJ1c3R3YXZlIEdsb2JhbCBDZXJ0aWZpY2F0aW9u
  44452. IEF1dGhvcml0eTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBALldUShLPDeS0YLOvR29
  44453. zd24q88KPuFd5dyqCblXAj7mY2Hf8g+CY66j96xz0XznswuvCAAJWX/NKSqIk4cXGIDtiLK0thAf
  44454. LdZfVaITXdHG6wZWiYj+rDKd/VzDBcdu7oaJuogDnXIhhpCujwOl3J+IKMujkkkP7NAP4m1ET4Bq
  44455. stTnoApTAbqOl5F2brz81Ws25kCI1nsvXwXoLG0R8+eyvpJETNKXpP7ScoFDB5zpET71ixpZfR9o
  44456. WN0EACyW80OzfpgZdNmcc9kYvkHHNHnZ9GLCQ7mzJ7Aiy/k9UscwR7PJPrhq4ufogXBeQotPJqX+
  44457. OsIgbrv4Fo7NDKm0G2x2EOFYeUY+VM6AqFcJNykbmROPDMjWLBz7BegIlT1lRtzuzWniTY+HKE40
  44458. Cz7PFNm73bZQmq131BnW2hqIyE4bJ3XYsgjxroMwuREOzYfwhI0Vcnyh78zyiGG69Gm7DIwLdVcE
  44459. uE4qFC49DxweMqZiNu5m4iK4BUBjECLzMx10coos9TkpoNPnG4CELcU9402x/RpvumUHO1jsQkUm
  44460. +9jaJXLE9gCxInm943xZYkqcBW89zubWR2OZxiRvchLIrH+QtAuRcOi35hYQcRfO3gZPSEF9NUqj
  44461. ifLJS3tBEW1ntwiYTOURGa5CgNz7kAXU+FDKvuStx8KU1xad5hePrzb7AgMBAAGjQjBAMA8GA1Ud
  44462. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFJngGWcNYtt2s9o9uFvo/ULSMQ6HMA4GA1UdDwEB/wQEAwIB
  44463. BjANBgkqhkiG9w0BAQsFAAOCAgEAmHNw4rDT7TnsTGDZqRKGFx6W0OhUKDtkLSGm+J1WE2pIPU/H
  44464. PinbbViDVD2HfSMF1OQc3Og4ZYbFdada2zUFvXfeuyk3QAUHw5RSn8pk3fEbK9xGChACMf1KaA0H
  44465. ZJDmHvUqoai7PF35owgLEQzxPy0QlG/+4jSHg9bP5Rs1bdID4bANqKCqRieCNqcVtgimQlRXtpla
  44466. 4gt5kNdXElE1GYhBaCXUNxeEFfsBctyV3lImIJgm4nb1J2/6ADtKYdkNy1GTKv0WBpanI5ojSP5R
  44467. vbbEsLFUzt5sQa0WZ37b/TjNuThOssFgy50X31ieemKyJo90lZvkWx3SD92YHJtZuSPTMaCm/zjd
  44468. zyBP6VhWOmfD0faZmZ26NraAL4hHT4a/RDqA5Dccprrql5gR0IRiR2Qequ5AvzSxnI9O4fKSTx+O
  44469. 856X3vOmeWqJcU9LJxdI/uz0UA9PSX3MReO9ekDFQdxhVicGaeVyQYHTtgGJoC86cnn+OjC/QezH
  44470. Yj6RS8fZMXZC+fc8Y+wmjHMMfRod6qh8h6jCJ3zhM0EPz8/8AKAigJ5Kp28AsEFFtyLKaEjFQqKu
  44471. 3R3y4G5OBVixwJAWKqQ9EEC+j2Jjg6mcgn0tAumDMHzLJ8n9HmYAsC7TIS+OMxZsmO0QqAfWzJPP
  44472. 29FpHOTKyeC2nOnOcXHebD8WpHk=
  44473. -----END CERTIFICATE-----
  44474. Trustwave Global ECC P256 Certification Authority
  44475. =================================================
  44476. -----BEGIN CERTIFICATE-----
  44477. MIICYDCCAgegAwIBAgIMDWpfCD8oXD5Rld9dMAoGCCqGSM49BAMCMIGRMQswCQYDVQQGEwJVUzER
  44478. MA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRydXN0d2F2ZSBI
  44479. b2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDI1NiBDZXJ0aWZp
  44480. Y2F0aW9uIEF1dGhvcml0eTAeFw0xNzA4MjMxOTM1MTBaFw00MjA4MjMxOTM1MTBaMIGRMQswCQYD
  44481. VQQGEwJVUzERMA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRy
  44482. dXN0d2F2ZSBIb2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDI1
  44483. NiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABH77bOYj
  44484. 43MyCMpg5lOcunSNGLB4kFKA3TjASh3RqMyTpJcGOMoNFWLGjgEqZZ2q3zSRLoHB5DOSMcT9CTqm
  44485. P62jQzBBMA8GA1UdEwEB/wQFMAMBAf8wDwYDVR0PAQH/BAUDAwcGADAdBgNVHQ4EFgQUo0EGrJBt
  44486. 0UrrdaVKEJmzsaGLSvcwCgYIKoZIzj0EAwIDRwAwRAIgB+ZU2g6gWrKuEZ+Hxbb/ad4lvvigtwjz
  44487. RM4q3wghDDcCIC0mA6AFvWvR9lz4ZcyGbbOcNEhjhAnFjXca4syc4XR7
  44488. -----END CERTIFICATE-----
  44489. Trustwave Global ECC P384 Certification Authority
  44490. =================================================
  44491. -----BEGIN CERTIFICATE-----
  44492. MIICnTCCAiSgAwIBAgIMCL2Fl2yZJ6SAaEc7MAoGCCqGSM49BAMDMIGRMQswCQYDVQQGEwJVUzER
  44493. MA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRydXN0d2F2ZSBI
  44494. b2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDM4NCBDZXJ0aWZp
  44495. Y2F0aW9uIEF1dGhvcml0eTAeFw0xNzA4MjMxOTM2NDNaFw00MjA4MjMxOTM2NDNaMIGRMQswCQYD
  44496. VQQGEwJVUzERMA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRy
  44497. dXN0d2F2ZSBIb2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDM4
  44498. NCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTB2MBAGByqGSM49AgEGBSuBBAAiA2IABGvaDXU1CDFH
  44499. Ba5FmVXxERMuSvgQMSOjfoPTfygIOiYaOs+Xgh+AtycJj9GOMMQKmw6sWASr9zZ9lCOkmwqKi6vr
  44500. /TklZvFe/oyujUF5nQlgziip04pt89ZF1PKYhDhloKNDMEEwDwYDVR0TAQH/BAUwAwEB/zAPBgNV
  44501. HQ8BAf8EBQMDBwYAMB0GA1UdDgQWBBRVqYSJ0sEyvRjLbKYHTsjnnb6CkDAKBggqhkjOPQQDAwNn
  44502. ADBkAjA3AZKXRRJ+oPM+rRk6ct30UJMDEr5E0k9BpIycnR+j9sKS50gU/k6bpZFXrsY3crsCMGcl
  44503. CrEMXu6pY5Jv5ZAL/mYiykf9ijH3g/56vxC+GCsej/YpHpRZ744hN8tRmKVuSw==
  44504. -----END CERTIFICATE-----
  44505. NAVER Global Root Certification Authority
  44506. =========================================
  44507. -----BEGIN CERTIFICATE-----
  44508. MIIFojCCA4qgAwIBAgIUAZQwHqIL3fXFMyqxQ0Rx+NZQTQ0wDQYJKoZIhvcNAQEMBQAwaTELMAkG
  44509. A1UEBhMCS1IxJjAkBgNVBAoMHU5BVkVSIEJVU0lORVNTIFBMQVRGT1JNIENvcnAuMTIwMAYDVQQD
  44510. DClOQVZFUiBHbG9iYWwgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0xNzA4MTgwODU4
  44511. NDJaFw0zNzA4MTgyMzU5NTlaMGkxCzAJBgNVBAYTAktSMSYwJAYDVQQKDB1OQVZFUiBCVVNJTkVT
  44512. UyBQTEFURk9STSBDb3JwLjEyMDAGA1UEAwwpTkFWRVIgR2xvYmFsIFJvb3QgQ2VydGlmaWNhdGlv
  44513. biBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC21PGTXLVAiQqrDZBb
  44514. UGOukJR0F0Vy1ntlWilLp1agS7gvQnXp2XskWjFlqxcX0TM62RHcQDaH38dq6SZeWYp34+hInDEW
  44515. +j6RscrJo+KfziFTowI2MMtSAuXaMl3Dxeb57hHHi8lEHoSTGEq0n+USZGnQJoViAbbJAh2+g1G7
  44516. XNr4rRVqmfeSVPc0W+m/6imBEtRTkZazkVrd/pBzKPswRrXKCAfHcXLJZtM0l/aM9BhK4dA9WkW2
  44517. aacp+yPOiNgSnABIqKYPszuSjXEOdMWLyEz59JuOuDxp7W87UC9Y7cSw0BwbagzivESq2M0UXZR4
  44518. Yb8ObtoqvC8MC3GmsxY/nOb5zJ9TNeIDoKAYv7vxvvTWjIcNQvcGufFt7QSUqP620wbGQGHfnZ3z
  44519. VHbOUzoBppJB7ASjjw2i1QnK1sua8e9DXcCrpUHPXFNwcMmIpi3Ua2FzUCaGYQ5fG8Ir4ozVu53B
  44520. A0K6lNpfqbDKzE0K70dpAy8i+/Eozr9dUGWokG2zdLAIx6yo0es+nPxdGoMuK8u180SdOqcXYZai
  44521. cdNwlhVNt0xz7hlcxVs+Qf6sdWA7G2POAN3aCJBitOUt7kinaxeZVL6HSuOpXgRM6xBtVNbv8ejy
  44522. YhbLgGvtPe31HzClrkvJE+2KAQHJuFFYwGY6sWZLxNUxAmLpdIQM201GLQIDAQABo0IwQDAdBgNV
  44523. HQ4EFgQU0p+I36HNLL3s9TsBAZMzJ7LrYEswDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMB
  44524. Af8wDQYJKoZIhvcNAQEMBQADggIBADLKgLOdPVQG3dLSLvCkASELZ0jKbY7gyKoNqo0hV4/GPnrK
  44525. 21HUUrPUloSlWGB/5QuOH/XcChWB5Tu2tyIvCZwTFrFsDDUIbatjcu3cvuzHV+YwIHHW1xDBE1UB
  44526. jCpD5EHxzzp6U5LOogMFDTjfArsQLtk70pt6wKGm+LUx5vR1yblTmXVHIloUFcd4G7ad6Qz4G3bx
  44527. hYTeodoS76TiEJd6eN4MUZeoIUCLhr0N8F5OSza7OyAfikJW4Qsav3vQIkMsRIz75Sq0bBwcupTg
  44528. E34h5prCy8VCZLQelHsIJchxzIdFV4XTnyliIoNRlwAYl3dqmJLJfGBs32x9SuRwTMKeuB330DTH
  44529. D8z7p/8Dvq1wkNoL3chtl1+afwkyQf3NosxabUzyqkn+Zvjp2DXrDige7kgvOtB5CTh8piKCk5XQ
  44530. A76+AqAF3SAi428diDRgxuYKuQl1C/AH6GmWNcf7I4GOODm4RStDeKLRLBT/DShycpWbXgnbiUSY
  44531. qqFJu3FS8r/2/yehNq+4tneI3TqkbZs0kNwUXTC/t+sX5Ie3cdCh13cV1ELX8vMxmV2b3RZtP+oG
  44532. I/hGoiLtk/bdmuYqh7GYVPEi92tF4+KOdh2ajcQGjTa3FPOdVGm3jjzVpG2Tgbet9r1ke8LJaDmg
  44533. kpzNNIaRkPpkUZ3+/uul9XXeifdy
  44534. -----END CERTIFICATE-----
  44535. AC RAIZ FNMT-RCM SERVIDORES SEGUROS
  44536. ===================================
  44537. -----BEGIN CERTIFICATE-----
  44538. MIICbjCCAfOgAwIBAgIQYvYybOXE42hcG2LdnC6dlTAKBggqhkjOPQQDAzB4MQswCQYDVQQGEwJF
  44539. UzERMA8GA1UECgwIRk5NVC1SQ00xDjAMBgNVBAsMBUNlcmVzMRgwFgYDVQRhDA9WQVRFUy1RMjgy
  44540. NjAwNEoxLDAqBgNVBAMMI0FDIFJBSVogRk5NVC1SQ00gU0VSVklET1JFUyBTRUdVUk9TMB4XDTE4
  44541. MTIyMDA5MzczM1oXDTQzMTIyMDA5MzczM1oweDELMAkGA1UEBhMCRVMxETAPBgNVBAoMCEZOTVQt
  44542. UkNNMQ4wDAYDVQQLDAVDZXJlczEYMBYGA1UEYQwPVkFURVMtUTI4MjYwMDRKMSwwKgYDVQQDDCNB
  44543. QyBSQUlaIEZOTVQtUkNNIFNFUlZJRE9SRVMgU0VHVVJPUzB2MBAGByqGSM49AgEGBSuBBAAiA2IA
  44544. BPa6V1PIyqvfNkpSIeSX0oNnnvBlUdBeh8dHsVnyV0ebAAKTRBdp20LHsbI6GA60XYyzZl2hNPk2
  44545. LEnb80b8s0RpRBNm/dfF/a82Tc4DTQdxz69qBdKiQ1oKUm8BA06Oi6NCMEAwDwYDVR0TAQH/BAUw
  44546. AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFAG5L++/EYZg8k/QQW6rcx/n0m5JMAoGCCqG
  44547. SM49BAMDA2kAMGYCMQCuSuMrQMN0EfKVrRYj3k4MGuZdpSRea0R7/DjiT8ucRRcRTBQnJlU5dUoD
  44548. zBOQn5ICMQD6SmxgiHPz7riYYqnOK8LZiqZwMR2vsJRM60/G49HzYqc8/5MuB1xJAWdpEgJyv+c=
  44549. -----END CERTIFICATE-----
  44550. GlobalSign Root R46
  44551. ===================
  44552. -----BEGIN CERTIFICATE-----
  44553. MIIFWjCCA0KgAwIBAgISEdK7udcjGJ5AXwqdLdDfJWfRMA0GCSqGSIb3DQEBDAUAMEYxCzAJBgNV
  44554. BAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRwwGgYDVQQDExNHbG9iYWxTaWduIFJv
  44555. b3QgUjQ2MB4XDTE5MDMyMDAwMDAwMFoXDTQ2MDMyMDAwMDAwMFowRjELMAkGA1UEBhMCQkUxGTAX
  44556. BgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExHDAaBgNVBAMTE0dsb2JhbFNpZ24gUm9vdCBSNDYwggIi
  44557. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCsrHQy6LNl5brtQyYdpokNRbopiLKkHWPd08Es
  44558. CVeJOaFV6Wc0dwxu5FUdUiXSE2te4R2pt32JMl8Nnp8semNgQB+msLZ4j5lUlghYruQGvGIFAha/
  44559. r6gjA7aUD7xubMLL1aa7DOn2wQL7Id5m3RerdELv8HQvJfTqa1VbkNud316HCkD7rRlr+/fKYIje
  44560. 2sGP1q7Vf9Q8g+7XFkyDRTNrJ9CG0Bwta/OrffGFqfUo0q3v84RLHIf8E6M6cqJaESvWJ3En7YEt
  44561. bWaBkoe0G1h6zD8K+kZPTXhc+CtI4wSEy132tGqzZfxCnlEmIyDLPRT5ge1lFgBPGmSXZgjPjHvj
  44562. K8Cd+RTyG/FWaha/LIWFzXg4mutCagI0GIMXTpRW+LaCtfOW3T3zvn8gdz57GSNrLNRyc0NXfeD4
  44563. 12lPFzYE+cCQYDdF3uYM2HSNrpyibXRdQr4G9dlkbgIQrImwTDsHTUB+JMWKmIJ5jqSngiCNI/on
  44564. ccnfxkF0oE32kRbcRoxfKWMxWXEM2G/CtjJ9++ZdU6Z+Ffy7dXxd7Pj2Fxzsx2sZy/N78CsHpdls
  44565. eVR2bJ0cpm4O6XkMqCNqo98bMDGfsVR7/mrLZqrcZdCinkqaByFrgY/bxFn63iLABJzjqls2k+g9
  44566. vXqhnQt2sQvHnf3PmKgGwvgqo6GDoLclcqUC4wIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAYYwDwYD
  44567. VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA1yrc4GHqMywptWU4jaWSf8FmSwwDQYJKoZIhvcNAQEM
  44568. BQADggIBAHx47PYCLLtbfpIrXTncvtgdokIzTfnvpCo7RGkerNlFo048p9gkUbJUHJNOxO97k4Vg
  44569. JuoJSOD1u8fpaNK7ajFxzHmuEajwmf3lH7wvqMxX63bEIaZHU1VNaL8FpO7XJqti2kM3S+LGteWy
  44570. gxk6x9PbTZ4IevPuzz5i+6zoYMzRx6Fcg0XERczzF2sUyQQCPtIkpnnpHs6i58FZFZ8d4kuaPp92
  44571. CC1r2LpXFNqD6v6MVenQTqnMdzGxRBF6XLE+0xRFFRhiJBPSy03OXIPBNvIQtQ6IbbjhVp+J3pZm
  44572. OUdkLG5NrmJ7v2B0GbhWrJKsFjLtrWhV/pi60zTe9Mlhww6G9kuEYO4Ne7UyWHmRVSyBQ7N0H3qq
  44573. JZ4d16GLuc1CLgSkZoNNiTW2bKg2SnkheCLQQrzRQDGQob4Ez8pn7fXwgNNgyYMqIgXQBztSvwye
  44574. qiv5u+YfjyW6hY0XHgL+XVAEV8/+LbzvXMAaq7afJMbfc2hIkCwU9D9SGuTSyxTDYWnP4vkYxboz
  44575. nxSjBF25cfe1lNj2M8FawTSLfJvdkzrnE6JwYZ+vj+vYxXX4M2bUdGc6N3ec592kD3ZDZopD8p/7
  44576. DEJ4Y9HiD2971KE9dJeFt0g5QdYg/NA6s/rob8SKunE3vouXsXgxT7PntgMTzlSdriVZzH81Xwj3
  44577. QEUxeCp6
  44578. -----END CERTIFICATE-----
  44579. GlobalSign Root E46
  44580. ===================
  44581. -----BEGIN CERTIFICATE-----
  44582. MIICCzCCAZGgAwIBAgISEdK7ujNu1LzmJGjFDYQdmOhDMAoGCCqGSM49BAMDMEYxCzAJBgNVBAYT
  44583. AkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRwwGgYDVQQDExNHbG9iYWxTaWduIFJvb3Qg
  44584. RTQ2MB4XDTE5MDMyMDAwMDAwMFoXDTQ2MDMyMDAwMDAwMFowRjELMAkGA1UEBhMCQkUxGTAXBgNV
  44585. BAoTEEdsb2JhbFNpZ24gbnYtc2ExHDAaBgNVBAMTE0dsb2JhbFNpZ24gUm9vdCBFNDYwdjAQBgcq
  44586. hkjOPQIBBgUrgQQAIgNiAAScDrHPt+ieUnd1NPqlRqetMhkytAepJ8qUuwzSChDH2omwlwxwEwkB
  44587. jtjqR+q+soArzfwoDdusvKSGN+1wCAB16pMLey5SnCNoIwZD7JIvU4Tb+0cUB+hflGddyXqBPCCj
  44588. QjBAMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBQxCpCPtsad0kRL
  44589. gLWi5h+xEk8blTAKBggqhkjOPQQDAwNoADBlAjEA31SQ7Zvvi5QCkxeCmb6zniz2C5GMn0oUsfZk
  44590. vLtoURMMA/cVi4RguYv/Uo7njLwcAjA8+RHUjE7AwWHCFUyqqx0LMV87HOIAl0Qx5v5zli/altP+
  44591. CAezNIm8BZ/3Hobui3A=
  44592. -----END CERTIFICATE-----
  44593. GLOBALTRUST 2020
  44594. ================
  44595. -----BEGIN CERTIFICATE-----
  44596. MIIFgjCCA2qgAwIBAgILWku9WvtPilv6ZeUwDQYJKoZIhvcNAQELBQAwTTELMAkGA1UEBhMCQVQx
  44597. IzAhBgNVBAoTGmUtY29tbWVyY2UgbW9uaXRvcmluZyBHbWJIMRkwFwYDVQQDExBHTE9CQUxUUlVT
  44598. VCAyMDIwMB4XDTIwMDIxMDAwMDAwMFoXDTQwMDYxMDAwMDAwMFowTTELMAkGA1UEBhMCQVQxIzAh
  44599. BgNVBAoTGmUtY29tbWVyY2UgbW9uaXRvcmluZyBHbWJIMRkwFwYDVQQDExBHTE9CQUxUUlVTVCAy
  44600. MDIwMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAri5WrRsc7/aVj6B3GyvTY4+ETUWi
  44601. D59bRatZe1E0+eyLinjF3WuvvcTfk0Uev5E4C64OFudBc/jbu9G4UeDLgztzOG53ig9ZYybNpyrO
  44602. VPu44sB8R85gfD+yc/LAGbaKkoc1DZAoouQVBGM+uq/ufF7MpotQsjj3QWPKzv9pj2gOlTblzLmM
  44603. CcpL3TGQlsjMH/1WljTbjhzqLL6FLmPdqqmV0/0plRPwyJiT2S0WR5ARg6I6IqIoV6Lr/sCMKKCm
  44604. fecqQjuCgGOlYx8ZzHyyZqjC0203b+J+BlHZRYQfEs4kUmSFC0iAToexIiIwquuuvuAC4EDosEKA
  44605. A1GqtH6qRNdDYfOiaxaJSaSjpCuKAsR49GiKweR6NrFvG5Ybd0mN1MkGco/PU+PcF4UgStyYJ9OR
  44606. JitHHmkHr96i5OTUawuzXnzUJIBHKWk7buis/UDr2O1xcSvy6Fgd60GXIsUf1DnQJ4+H4xj04KlG
  44607. DfV0OoIu0G4skaMxXDtG6nsEEFZegB31pWXogvziB4xiRfUg3kZwhqG8k9MedKZssCz3AwyIDMvU
  44608. clOGvGBG85hqwvG/Q/lwIHfKN0F5VVJjjVsSn8VoxIidrPIwq7ejMZdnrY8XD2zHc+0klGvIg5rQ
  44609. mjdJBKuxFshsSUktq6HQjJLyQUp5ISXbY9e2nKd+Qmn7OmMCAwEAAaNjMGEwDwYDVR0TAQH/BAUw
  44610. AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFNwuH9FhN3nkq9XVsxJxaD1qaJwiMB8GA1Ud
  44611. IwQYMBaAFNwuH9FhN3nkq9XVsxJxaD1qaJwiMA0GCSqGSIb3DQEBCwUAA4ICAQCR8EICaEDuw2jA
  44612. VC/f7GLDw56KoDEoqoOOpFaWEhCGVrqXctJUMHytGdUdaG/7FELYjQ7ztdGl4wJCXtzoRlgHNQIw
  44613. 4Lx0SsFDKv/bGtCwr2zD/cuz9X9tAy5ZVp0tLTWMstZDFyySCstd6IwPS3BD0IL/qMy/pJTAvoe9
  44614. iuOTe8aPmxadJ2W8esVCgmxcB9CpwYhgROmYhRZf+I/KARDOJcP5YBugxZfD0yyIMaK9MOzQ0MAS
  44615. 8cE54+X1+NZK3TTN+2/BT+MAi1bikvcoskJ3ciNnxz8RFbLEAwW+uxF7Cr+obuf/WEPPm2eggAe2
  44616. HcqtbepBEX4tdJP7wry+UUTF72glJ4DjyKDUEuzZpTcdN3y0kcra1LGWge9oXHYQSa9+pTeAsRxS
  44617. vTOBTI/53WXZFM2KJVj04sWDpQmQ1GwUY7VA3+vA/MRYfg0UFodUJ25W5HCEuGwyEn6CMUO+1918
  44618. oa2u1qsgEu8KwxCMSZY13At1XrFP1U80DhEgB3VDRemjEdqso5nCtnkn4rnvyOL2NSl6dPrFf4IF
  44619. YqYK6miyeUcGbvJXqBUzxvd4Sj1Ce2t+/vdG6tHrju+IaFvowdlxfv1k7/9nR4hYJS8+hge9+6jl
  44620. gqispdNpQ80xiEmEU5LAsTkbOYMBMMTyqfrQA71yN2BWHzZ8vTmR9W0Nv3vXkg==
  44621. -----END CERTIFICATE-----
  44622. ANF Secure Server Root CA
  44623. =========================
  44624. -----BEGIN CERTIFICATE-----
  44625. MIIF7zCCA9egAwIBAgIIDdPjvGz5a7EwDQYJKoZIhvcNAQELBQAwgYQxEjAQBgNVBAUTCUc2MzI4
  44626. NzUxMDELMAkGA1UEBhMCRVMxJzAlBgNVBAoTHkFORiBBdXRvcmlkYWQgZGUgQ2VydGlmaWNhY2lv
  44627. bjEUMBIGA1UECxMLQU5GIENBIFJhaXoxIjAgBgNVBAMTGUFORiBTZWN1cmUgU2VydmVyIFJvb3Qg
  44628. Q0EwHhcNMTkwOTA0MTAwMDM4WhcNMzkwODMwMTAwMDM4WjCBhDESMBAGA1UEBRMJRzYzMjg3NTEw
  44629. MQswCQYDVQQGEwJFUzEnMCUGA1UEChMeQU5GIEF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uMRQw
  44630. EgYDVQQLEwtBTkYgQ0EgUmFpejEiMCAGA1UEAxMZQU5GIFNlY3VyZSBTZXJ2ZXIgUm9vdCBDQTCC
  44631. AiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANvrayvmZFSVgpCjcqQZAZ2cC4Ffc0m6p6zz
  44632. BE57lgvsEeBbphzOG9INgxwruJ4dfkUyYA8H6XdYfp9qyGFOtibBTI3/TO80sh9l2Ll49a2pcbnv
  44633. T1gdpd50IJeh7WhM3pIXS7yr/2WanvtH2Vdy8wmhrnZEE26cLUQ5vPnHO6RYPUG9tMJJo8gN0pcv
  44634. B2VSAKduyK9o7PQUlrZXH1bDOZ8rbeTzPvY1ZNoMHKGESy9LS+IsJJ1tk0DrtSOOMspvRdOoiXse
  44635. zx76W0OLzc2oD2rKDF65nkeP8Nm2CgtYZRczuSPkdxl9y0oukntPLxB3sY0vaJxizOBQ+OyRp1RM
  44636. VwnVdmPF6GUe7m1qzwmd+nxPrWAI/VaZDxUse6mAq4xhj0oHdkLePfTdsiQzW7i1o0TJrH93PB0j
  44637. 7IKppuLIBkwC/qxcmZkLLxCKpvR/1Yd0DVlJRfbwcVw5Kda/SiOL9V8BY9KHcyi1Swr1+KuCLH5z
  44638. JTIdC2MKF4EA/7Z2Xue0sUDKIbvVgFHlSFJnLNJhiQcND85Cd8BEc5xEUKDbEAotlRyBr+Qc5RQe
  44639. 8TZBAQIvfXOn3kLMTOmJDVb3n5HUA8ZsyY/b2BzgQJhdZpmYgG4t/wHFzstGH6wCxkPmrqKEPMVO
  44640. Hj1tyRRM4y5Bu8o5vzY8KhmqQYdOpc5LMnndkEl/AgMBAAGjYzBhMB8GA1UdIwQYMBaAFJxf0Gxj
  44641. o1+TypOYCK2Mh6UsXME3MB0GA1UdDgQWBBScX9BsY6Nfk8qTmAitjIelLFzBNzAOBgNVHQ8BAf8E
  44642. BAMCAYYwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEATh65isagmD9uw2nAalxJ
  44643. UqzLK114OMHVVISfk/CHGT0sZonrDUL8zPB1hT+L9IBdeeUXZ701guLyPI59WzbLWoAAKfLOKyzx
  44644. j6ptBZNscsdW699QIyjlRRA96Gejrw5VD5AJYu9LWaL2U/HANeQvwSS9eS9OICI7/RogsKQOLHDt
  44645. dD+4E5UGUcjohybKpFtqFiGS3XNgnhAY3jyB6ugYw3yJ8otQPr0R4hUDqDZ9MwFsSBXXiJCZBMXM
  44646. 5gf0vPSQ7RPi6ovDj6MzD8EpTBNO2hVWcXNyglD2mjN8orGoGjR0ZVzO0eurU+AagNjqOknkJjCb
  44647. 5RyKqKkVMoaZkgoQI1YS4PbOTOK7vtuNknMBZi9iPrJyJ0U27U1W45eZ/zo1PqVUSlJZS2Db7v54
  44648. EX9K3BR5YLZrZAPbFYPhor72I5dQ8AkzNqdxliXzuUJ92zg/LFis6ELhDtjTO0wugumDLmsx2d1H
  44649. hk9tl5EuT+IocTUW0fJz/iUrB0ckYyfI+PbZa/wSMVYIwFNCr5zQM378BvAxRAMU8Vjq8moNqRGy
  44650. g77FGr8H6lnco4g175x2MjxNBiLOFeXdntiP2t7SxDnlF4HPOEfrf4htWRvfn0IUrn7PqLBmZdo3
  44651. r5+qPeoott7VMVgWglvquxl1AnMaykgaIZOQCo6ThKd9OyMYkomgjaw=
  44652. -----END CERTIFICATE-----
  44653. Certum EC-384 CA
  44654. ================
  44655. -----BEGIN CERTIFICATE-----
  44656. MIICZTCCAeugAwIBAgIQeI8nXIESUiClBNAt3bpz9DAKBggqhkjOPQQDAzB0MQswCQYDVQQGEwJQ
  44657. TDEhMB8GA1UEChMYQXNzZWNvIERhdGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2Vy
  44658. dGlmaWNhdGlvbiBBdXRob3JpdHkxGTAXBgNVBAMTEENlcnR1bSBFQy0zODQgQ0EwHhcNMTgwMzI2
  44659. MDcyNDU0WhcNNDMwMzI2MDcyNDU0WjB0MQswCQYDVQQGEwJQTDEhMB8GA1UEChMYQXNzZWNvIERh
  44660. dGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkx
  44661. GTAXBgNVBAMTEENlcnR1bSBFQy0zODQgQ0EwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAATEKI6rGFtq
  44662. vm5kN2PkzeyrOvfMobgOgknXhimfoZTy42B4mIF4Bk3y7JoOV2CDn7TmFy8as10CW4kjPMIRBSqn
  44663. iBMY81CE1700LCeJVf/OTOffph8oxPBUw7l8t1Ot68KjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  44664. VR0OBBYEFI0GZnQkdjrzife81r1HfS+8EF9LMA4GA1UdDwEB/wQEAwIBBjAKBggqhkjOPQQDAwNo
  44665. ADBlAjADVS2m5hjEfO/JUG7BJw+ch69u1RsIGL2SKcHvlJF40jocVYli5RsJHrpka/F2tNQCMQC0
  44666. QoSZ/6vnnvuRlydd3LBbMHHOXjgaatkl5+r3YZJW+OraNsKHZZYuciUvf9/DE8k=
  44667. -----END CERTIFICATE-----
  44668. Certum Trusted Root CA
  44669. ======================
  44670. -----BEGIN CERTIFICATE-----
  44671. MIIFwDCCA6igAwIBAgIQHr9ZULjJgDdMBvfrVU+17TANBgkqhkiG9w0BAQ0FADB6MQswCQYDVQQG
  44672. EwJQTDEhMB8GA1UEChMYQXNzZWNvIERhdGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0g
  44673. Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkxHzAdBgNVBAMTFkNlcnR1bSBUcnVzdGVkIFJvb3QgQ0Ew
  44674. HhcNMTgwMzE2MTIxMDEzWhcNNDMwMzE2MTIxMDEzWjB6MQswCQYDVQQGEwJQTDEhMB8GA1UEChMY
  44675. QXNzZWNvIERhdGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlvbiBB
  44676. dXRob3JpdHkxHzAdBgNVBAMTFkNlcnR1bSBUcnVzdGVkIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEB
  44677. AQUAA4ICDwAwggIKAoICAQDRLY67tzbqbTeRn06TpwXkKQMlzhyC93yZn0EGze2jusDbCSzBfN8p
  44678. fktlL5On1AFrAygYo9idBcEq2EXxkd7fO9CAAozPOA/qp1x4EaTByIVcJdPTsuclzxFUl6s1wB52
  44679. HO8AU5853BSlLCIls3Jy/I2z5T4IHhQqNwuIPMqw9MjCoa68wb4pZ1Xi/K1ZXP69VyywkI3C7Te2
  44680. fJmItdUDmj0VDT06qKhF8JVOJVkdzZhpu9PMMsmN74H+rX2Ju7pgE8pllWeg8xn2A1bUatMn4qGt
  44681. g/BKEiJ3HAVz4hlxQsDsdUaakFjgao4rpUYwBI4Zshfjvqm6f1bxJAPXsiEodg42MEx51UGamqi4
  44682. NboMOvJEGyCI98Ul1z3G4z5D3Yf+xOr1Uz5MZf87Sst4WmsXXw3Hw09Omiqi7VdNIuJGmj8PkTQk
  44683. fVXjjJU30xrwCSss0smNtA0Aq2cpKNgB9RkEth2+dv5yXMSFytKAQd8FqKPVhJBPC/PgP5sZ0jeJ
  44684. P/J7UhyM9uH3PAeXjA6iWYEMspA90+NZRu0PqafegGtaqge2Gcu8V/OXIXoMsSt0Puvap2ctTMSY
  44685. njYJdmZm/Bo/6khUHL4wvYBQv3y1zgD2DGHZ5yQD4OMBgQ692IU0iL2yNqh7XAjlRICMb/gv1SHK
  44686. HRzQ+8S1h9E6Tsd2tTVItQIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSM+xx1
  44687. vALTn04uSNn5YFSqxLNP+jAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQENBQADggIBAEii1QAL
  44688. LtA/vBzVtVRJHlpr9OTy4EA34MwUe7nJ+jW1dReTagVphZzNTxl4WxmB82M+w85bj/UvXgF2Ez8s
  44689. ALnNllI5SW0ETsXpD4YN4fqzX4IS8TrOZgYkNCvozMrnadyHncI013nR03e4qllY/p0m+jiGPp2K
  44690. h2RX5Rc64vmNueMzeMGQ2Ljdt4NR5MTMI9UGfOZR0800McD2RrsLrfw9EAUqO0qRJe6M1ISHgCq8
  44691. CYyqOhNf6DR5UMEQGfnTKB7U0VEwKbOukGfWHwpjscWpxkIxYxeU72nLL/qMFH3EQxiJ2fAyQOaA
  44692. 4kZf5ePBAFmo+eggvIksDkc0C+pXwlM2/KfUrzHN/gLldfq5Jwn58/U7yn2fqSLLiMmq0Uc9Nneo
  44693. WWRrJ8/vJ8HjJLWG965+Mk2weWjROeiQWMODvA8s1pfrzgzhIMfatz7DP78v3DSk+yshzWePS/Tj
  44694. 6tQ/50+6uaWTRRxmHyH6ZF5v4HaUMst19W7l9o/HuKTMqJZ9ZPskWkoDbGs4xugDQ5r3V7mzKWmT
  44695. OPQD8rv7gmsHINFSH5pkAnuYZttcTVoP0ISVoDwUQwbKytu4QTbaakRnh6+v40URFWkIsr4WOZck
  44696. bxJF0WddCajJFdr60qZfE2Efv4WstK2tBZQIgx51F9NxO5NQI1mg7TyRVJ12AMXDuDjb
  44697. -----END CERTIFICATE-----
  44698. TunTrust Root CA
  44699. ================
  44700. -----BEGIN CERTIFICATE-----
  44701. MIIFszCCA5ugAwIBAgIUEwLV4kBMkkaGFmddtLu7sms+/BMwDQYJKoZIhvcNAQELBQAwYTELMAkG
  44702. A1UEBhMCVE4xNzA1BgNVBAoMLkFnZW5jZSBOYXRpb25hbGUgZGUgQ2VydGlmaWNhdGlvbiBFbGVj
  44703. dHJvbmlxdWUxGTAXBgNVBAMMEFR1blRydXN0IFJvb3QgQ0EwHhcNMTkwNDI2MDg1NzU2WhcNNDQw
  44704. NDI2MDg1NzU2WjBhMQswCQYDVQQGEwJUTjE3MDUGA1UECgwuQWdlbmNlIE5hdGlvbmFsZSBkZSBD
  44705. ZXJ0aWZpY2F0aW9uIEVsZWN0cm9uaXF1ZTEZMBcGA1UEAwwQVHVuVHJ1c3QgUm9vdCBDQTCCAiIw
  44706. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMPN0/y9BFPdDCA61YguBUtB9YOCfvdZn56eY+hz
  44707. 2vYGqU8ftPkLHzmMmiDQfgbU7DTZhrx1W4eI8NLZ1KMKsmwb60ksPqxd2JQDoOw05TDENX37Jk0b
  44708. bjBU2PWARZw5rZzJJQRNmpA+TkBuimvNKWfGzC3gdOgFVwpIUPp6Q9p+7FuaDmJ2/uqdHYVy7BG7
  44709. NegfJ7/Boce7SBbdVtfMTqDhuazb1YMZGoXRlJfXyqNlC/M4+QKu3fZnz8k/9YosRxqZbwUN/dAd
  44710. gjH8KcwAWJeRTIAAHDOFli/LQcKLEITDCSSJH7UP2dl3RxiSlGBcx5kDPP73lad9UKGAwqmDrViW
  44711. VSHbhlnUr8a83YFuB9tgYv7sEG7aaAH0gxupPqJbI9dkxt/con3YS7qC0lH4Zr8GRuR5KiY2eY8f
  44712. Tpkdso8MDhz/yV3A/ZAQprE38806JG60hZC/gLkMjNWb1sjxVj8agIl6qeIbMlEsPvLfe/ZdeikZ
  44713. juXIvTZxi11Mwh0/rViizz1wTaZQmCXcI/m4WEEIcb9PuISgjwBUFfyRbVinljvrS5YnzWuioYas
  44714. DXxU5mZMZl+QviGaAkYt5IPCgLnPSz7ofzwB7I9ezX/SKEIBlYrilz0QIX32nRzFNKHsLA4KUiwS
  44715. VXAkPcvCFDVDXSdOvsC9qnyW5/yeYa1E0wCXAgMBAAGjYzBhMB0GA1UdDgQWBBQGmpsfU33x9aTI
  44716. 04Y+oXNZtPdEITAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFAaamx9TffH1pMjThj6hc1m0
  44717. 90QhMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAgEAqgVutt0Vyb+zxiD2BkewhpMl
  44718. 0425yAA/l/VSJ4hxyXT968pk21vvHl26v9Hr7lxpuhbI87mP0zYuQEkHDVneixCwSQXi/5E/S7fd
  44719. Ao74gShczNxtr18UnH1YeA32gAm56Q6XKRm4t+v4FstVEuTGfbvE7Pi1HE4+Z7/FXxttbUcoqgRY
  44720. YdZ2vyJ/0Adqp2RT8JeNnYA/u8EH22Wv5psymsNUk8QcCMNE+3tjEUPRahphanltkE8pjkcFwRJp
  44721. adbGNjHh/PqAulxPxOu3Mqz4dWEX1xAZufHSCe96Qp1bWgvUxpVOKs7/B9dPfhgGiPEZtdmYu65x
  44722. xBzndFlY7wyJz4sfdZMaBBSSSFCp61cpABbjNhzI+L/wM9VBD8TMPN3pM0MBkRArHtG5Xc0yGYuP
  44723. jCB31yLEQtyEFpslbei0VXF/sHyz03FJuc9SpAQ/3D2gu68zngowYI7bnV2UqL1g52KAdoGDDIzM
  44724. MEZJ4gzSqK/rYXHv5yJiqfdcZGyfFoxnNidF9Ql7v/YQCvGwjVRDjAS6oz/v4jXH+XTgbzRB0L9z
  44725. ZVcg+ZtnemZoJE6AZb0QmQZZ8mWvuMZHu/2QeItBcy6vVR/cO5JyboTT0GFMDcx2V+IthSIVNg3r
  44726. AZ3r2OvEhJn7wAzMMujjd9qDRIueVSjAi1jTkD5OGwDxFa2DK5o=
  44727. -----END CERTIFICATE-----
  44728. HARICA TLS RSA Root CA 2021
  44729. ===========================
  44730. -----BEGIN CERTIFICATE-----
  44731. MIIFpDCCA4ygAwIBAgIQOcqTHO9D88aOk8f0ZIk4fjANBgkqhkiG9w0BAQsFADBsMQswCQYDVQQG
  44732. EwJHUjE3MDUGA1UECgwuSGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9u
  44733. cyBDQTEkMCIGA1UEAwwbSEFSSUNBIFRMUyBSU0EgUm9vdCBDQSAyMDIxMB4XDTIxMDIxOTEwNTUz
  44734. OFoXDTQ1MDIxMzEwNTUzN1owbDELMAkGA1UEBhMCR1IxNzA1BgNVBAoMLkhlbGxlbmljIEFjYWRl
  44735. bWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ0ExJDAiBgNVBAMMG0hBUklDQSBUTFMgUlNB
  44736. IFJvb3QgQ0EgMjAyMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAIvC569lmwVnlskN
  44737. JLnQDmT8zuIkGCyEf3dRywQRNrhe7Wlxp57kJQmXZ8FHws+RFjZiPTgE4VGC/6zStGndLuwRo0Xu
  44738. a2s7TL+MjaQenRG56Tj5eg4MmOIjHdFOY9TnuEFE+2uva9of08WRiFukiZLRgeaMOVig1mlDqa2Y
  44739. Ulhu2wr7a89o+uOkXjpFc5gH6l8Cct4MpbOfrqkdtx2z/IpZ525yZa31MJQjB/OCFks1mJxTuy/K
  44740. 5FrZx40d/JiZ+yykgmvwKh+OC19xXFyuQnspiYHLA6OZyoieC0AJQTPb5lh6/a6ZcMBaD9YThnEv
  44741. dmn8kN3bLW7R8pv1GmuebxWMevBLKKAiOIAkbDakO/IwkfN4E8/BPzWr8R0RI7VDIp4BkrcYAuUR
  44742. 0YLbFQDMYTfBKnya4dC6s1BG7oKsnTH4+yPiAwBIcKMJJnkVU2DzOFytOOqBAGMUuTNe3QvboEUH
  44743. GjMJ+E20pwKmafTCWQWIZYVWrkvL4N48fS0ayOn7H6NhStYqE613TBoYm5EPWNgGVMWX+Ko/IIqm
  44744. haZ39qb8HOLubpQzKoNQhArlT4b4UEV4AIHrW2jjJo3Me1xR9BQsQL4aYB16cmEdH2MtiKrOokWQ
  44745. CPxrvrNQKlr9qEgYRtaQQJKQCoReaDH46+0N0x3GfZkYVVYnZS6NRcUk7M7jAgMBAAGjQjBAMA8G
  44746. A1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFApII6ZgpJIKM+qTW8VX6iVNvRLuMA4GA1UdDwEB/wQE
  44747. AwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAPpBIqm5iFSVmewzVjIuJndftTgfvnNAUX15QvWiWkKQU
  44748. EapobQk1OUAJ2vQJLDSle1mESSmXdMgHHkdt8s4cUCbjnj1AUz/3f5Z2EMVGpdAgS1D0NTsY9FVq
  44749. QRtHBmg8uwkIYtlfVUKqrFOFrJVWNlar5AWMxajaH6NpvVMPxP/cyuN+8kyIhkdGGvMA9YCRotxD
  44750. QpSbIPDRzbLrLFPCU3hKTwSUQZqPJzLB5UkZv/HywouoCjkxKLR9YjYsTewfM7Z+d21+UPCfDtcR
  44751. j88YxeMn/ibvBZ3PzzfF0HvaO7AWhAw6k9a+F9sPPg4ZeAnHqQJyIkv3N3a6dcSFA1pj1bF1BcK5
  44752. vZStjBWZp5N99sXzqnTPBIWUmAD04vnKJGW/4GKvyMX6ssmeVkjaef2WdhW+o45WxLM0/L5H9MG0
  44753. qPzVMIho7suuyWPEdr6sOBjhXlzPrjoiUevRi7PzKzMHVIf6tLITe7pTBGIBnfHAT+7hOtSLIBD6
  44754. Alfm78ELt5BGnBkpjNxvoEppaZS3JGWg/6w/zgH7IS79aPib8qXPMThcFarmlwDB31qlpzmq6YR/
  44755. PFGoOtmUW4y/Twhx5duoXNTSpv4Ao8YWxw/ogM4cKGR0GQjTQuPOAF1/sdwTsOEFy9EgqoZ0njnn
  44756. kf3/W9b3raYvAwtt41dU63ZTGI0RmLo=
  44757. -----END CERTIFICATE-----
  44758. HARICA TLS ECC Root CA 2021
  44759. ===========================
  44760. -----BEGIN CERTIFICATE-----
  44761. MIICVDCCAdugAwIBAgIQZ3SdjXfYO2rbIvT/WeK/zjAKBggqhkjOPQQDAzBsMQswCQYDVQQGEwJH
  44762. UjE3MDUGA1UECgwuSGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBD
  44763. QTEkMCIGA1UEAwwbSEFSSUNBIFRMUyBFQ0MgUm9vdCBDQSAyMDIxMB4XDTIxMDIxOTExMDExMFoX
  44764. DTQ1MDIxMzExMDEwOVowbDELMAkGA1UEBhMCR1IxNzA1BgNVBAoMLkhlbGxlbmljIEFjYWRlbWlj
  44765. IGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ0ExJDAiBgNVBAMMG0hBUklDQSBUTFMgRUNDIFJv
  44766. b3QgQ0EgMjAyMTB2MBAGByqGSM49AgEGBSuBBAAiA2IABDgI/rGgltJ6rK9JOtDA4MM7KKrxcm1l
  44767. AEeIhPyaJmuqS7psBAqIXhfyVYf8MLA04jRYVxqEU+kw2anylnTDUR9YSTHMmE5gEYd103KUkE+b
  44768. ECUqqHgtvpBBWJAVcqeht6NCMEAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUyRtTgRL+BNUW
  44769. 0aq8mm+3oJUZbsowDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMDA2cAMGQCMBHervjcToiwqfAi
  44770. rcJRQO9gcS3ujwLEXQNwSaSS6sUUiHCm0w2wqsosQJz76YJumgIwK0eaB8bRwoF8yguWGEEbo/Qw
  44771. CZ61IygNnxS2PFOiTAZpffpskcYqSUXm7LcT4Tps
  44772. -----END CERTIFICATE-----
  44773. Autoridad de Certificacion Firmaprofesional CIF A62634068
  44774. =========================================================
  44775. -----BEGIN CERTIFICATE-----
  44776. MIIGFDCCA/ygAwIBAgIIG3Dp0v+ubHEwDQYJKoZIhvcNAQELBQAwUTELMAkGA1UEBhMCRVMxQjBA
  44777. BgNVBAMMOUF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1hcHJvZmVzaW9uYWwgQ0lGIEE2
  44778. MjYzNDA2ODAeFw0xNDA5MjMxNTIyMDdaFw0zNjA1MDUxNTIyMDdaMFExCzAJBgNVBAYTAkVTMUIw
  44779. QAYDVQQDDDlBdXRvcmlkYWQgZGUgQ2VydGlmaWNhY2lvbiBGaXJtYXByb2Zlc2lvbmFsIENJRiBB
  44780. NjI2MzQwNjgwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKlmuO6vj78aI14H9M2uDD
  44781. Utd9thDIAl6zQyrET2qyyhxdKJp4ERppWVevtSBC5IsP5t9bpgOSL/UR5GLXMnE42QQMcas9UX4P
  44782. B99jBVzpv5RvwSmCwLTaUbDBPLutN0pcyvFLNg4kq7/DhHf9qFD0sefGL9ItWY16Ck6WaVICqjaY
  44783. 7Pz6FIMMNx/Jkjd/14Et5cS54D40/mf0PmbR0/RAz15iNA9wBj4gGFrO93IbJWyTdBSTo3OxDqqH
  44784. ECNZXyAFGUftaI6SEspd/NYrspI8IM/hX68gvqB2f3bl7BqGYTM+53u0P6APjqK5am+5hyZvQWyI
  44785. plD9amML9ZMWGxmPsu2bm8mQ9QEM3xk9Dz44I8kvjwzRAv4bVdZO0I08r0+k8/6vKtMFnXkIoctX
  44786. MbScyJCyZ/QYFpM6/EfY0XiWMR+6KwxfXZmtY4laJCB22N/9q06mIqqdXuYnin1oKaPnirjaEbsX
  44787. LZmdEyRG98Xi2J+Of8ePdG1asuhy9azuJBCtLxTa/y2aRnFHvkLfuwHb9H/TKI8xWVvTyQKmtFLK
  44788. bpf7Q8UIJm+K9Lv9nyiqDdVF8xM6HdjAeI9BZzwelGSuewvF6NkBiDkal4ZkQdU7hwxu+g/GvUgU
  44789. vzlN1J5Bto+WHWOWk9mVBngxaJ43BjuAiUVhOSPHG0SjFeUc+JIwuwIDAQABo4HvMIHsMB0GA1Ud
  44790. DgQWBBRlzeurNR4APn7VdMActHNHDhpkLzASBgNVHRMBAf8ECDAGAQH/AgEBMIGmBgNVHSAEgZ4w
  44791. gZswgZgGBFUdIAAwgY8wLwYIKwYBBQUHAgEWI2h0dHA6Ly93d3cuZmlybWFwcm9mZXNpb25hbC5j
  44792. b20vY3BzMFwGCCsGAQUFBwICMFAeTgBQAGEAcwBlAG8AIABkAGUAIABsAGEAIABCAG8AbgBhAG4A
  44793. bwB2AGEAIAA0ADcAIABCAGEAcgBjAGUAbABvAG4AYQAgADAAOAAwADEANzAOBgNVHQ8BAf8EBAMC
  44794. AQYwDQYJKoZIhvcNAQELBQADggIBAHSHKAIrdx9miWTtj3QuRhy7qPj4Cx2Dtjqn6EWKB7fgPiDL
  44795. 4QjbEwj4KKE1soCzC1HA01aajTNFSa9J8OA9B3pFE1r/yJfY0xgsfZb43aJlQ3CTkBW6kN/oGbDb
  44796. LIpgD7dvlAceHabJhfa9NPhAeGIQcDq+fUs5gakQ1JZBu/hfHAsdCPKxsIl68veg4MSPi3i1O1il
  44797. I45PVf42O+AMt8oqMEEgtIDNrvx2ZnOorm7hfNoD6JQg5iKj0B+QXSBTFCZX2lSX3xZEEAEeiGaP
  44798. cjiT3SC3NL7X8e5jjkd5KAb881lFJWAiMxujX6i6KtoaPc1A6ozuBRWV1aUsIC+nmCjuRfzxuIgA
  44799. LI9C2lHVnOUTaHFFQ4ueCyE8S1wF3BqfmI7avSKecs2tCsvMo2ebKHTEm9caPARYpoKdrcd7b/+A
  44800. lun4jWq9GJAd/0kakFI3ky88Al2CdgtR5xbHV/g4+afNmyJU72OwFW1TZQNKXkqgsqeOSQBZONXH
  44801. 9IBk9W6VULgRfhVwOEqwf9DEMnDAGf/JOC0ULGb0QkTmVXYbgBVX/8Cnp6o5qtjTcNAuuuuUavpf
  44802. NIbnYrX9ivAwhZTJryQCL2/W3Wf+47BVTwSYT6RBVuKT0Gro1vP7ZeDOdcQxWQzugsgMYDNKGbqE
  44803. ZycPvEJdvSRUDewdcAZfpLz6IHxV
  44804. -----END CERTIFICATE-----
  44805. vTrus ECC Root CA
  44806. =================
  44807. -----BEGIN CERTIFICATE-----
  44808. MIICDzCCAZWgAwIBAgIUbmq8WapTvpg5Z6LSa6Q75m0c1towCgYIKoZIzj0EAwMwRzELMAkGA1UE
  44809. BhMCQ04xHDAaBgNVBAoTE2lUcnVzQ2hpbmEgQ28uLEx0ZC4xGjAYBgNVBAMTEXZUcnVzIEVDQyBS
  44810. b290IENBMB4XDTE4MDczMTA3MjY0NFoXDTQzMDczMTA3MjY0NFowRzELMAkGA1UEBhMCQ04xHDAa
  44811. BgNVBAoTE2lUcnVzQ2hpbmEgQ28uLEx0ZC4xGjAYBgNVBAMTEXZUcnVzIEVDQyBSb290IENBMHYw
  44812. EAYHKoZIzj0CAQYFK4EEACIDYgAEZVBKrox5lkqqHAjDo6LN/llWQXf9JpRCux3NCNtzslt188+c
  44813. ToL0v/hhJoVs1oVbcnDS/dtitN9Ti72xRFhiQgnH+n9bEOf+QP3A2MMrMudwpremIFUde4BdS49n
  44814. TPEQo0IwQDAdBgNVHQ4EFgQUmDnNvtiyjPeyq+GtJK97fKHbH88wDwYDVR0TAQH/BAUwAwEB/zAO
  44815. BgNVHQ8BAf8EBAMCAQYwCgYIKoZIzj0EAwMDaAAwZQIwV53dVvHH4+m4SVBrm2nDb+zDfSXkV5UT
  44816. QJtS0zvzQBm8JsctBp61ezaf9SXUY2sAAjEA6dPGnlaaKsyh2j/IZivTWJwghfqrkYpwcBE4YGQL
  44817. YgmRWAD5Tfs0aNoJrSEGGJTO
  44818. -----END CERTIFICATE-----
  44819. vTrus Root CA
  44820. =============
  44821. -----BEGIN CERTIFICATE-----
  44822. MIIFVjCCAz6gAwIBAgIUQ+NxE9izWRRdt86M/TX9b7wFjUUwDQYJKoZIhvcNAQELBQAwQzELMAkG
  44823. A1UEBhMCQ04xHDAaBgNVBAoTE2lUcnVzQ2hpbmEgQ28uLEx0ZC4xFjAUBgNVBAMTDXZUcnVzIFJv
  44824. b3QgQ0EwHhcNMTgwNzMxMDcyNDA1WhcNNDMwNzMxMDcyNDA1WjBDMQswCQYDVQQGEwJDTjEcMBoG
  44825. A1UEChMTaVRydXNDaGluYSBDby4sTHRkLjEWMBQGA1UEAxMNdlRydXMgUm9vdCBDQTCCAiIwDQYJ
  44826. KoZIhvcNAQEBBQADggIPADCCAgoCggIBAL1VfGHTuB0EYgWgrmy3cLRB6ksDXhA/kFocizuwZots
  44827. SKYcIrrVQJLuM7IjWcmOvFjai57QGfIvWcaMY1q6n6MLsLOaXLoRuBLpDLvPbmyAhykUAyyNJJrI
  44828. ZIO1aqwTLDPxn9wsYTwaP3BVm60AUn/PBLn+NvqcwBauYv6WTEN+VRS+GrPSbcKvdmaVayqwlHeF
  44829. XgQPYh1jdfdr58tbmnDsPmcF8P4HCIDPKNsFxhQnL4Z98Cfe/+Z+M0jnCx5Y0ScrUw5XSmXX+6KA
  44830. YPxMvDVTAWqXcoKv8R1w6Jz1717CbMdHflqUhSZNO7rrTOiwCcJlwp2dCZtOtZcFrPUGoPc2BX70
  44831. kLJrxLT5ZOrpGgrIDajtJ8nU57O5q4IikCc9Kuh8kO+8T/3iCiSn3mUkpF3qwHYw03dQ+A0Em5Q2
  44832. AXPKBlim0zvc+gRGE1WKyURHuFE5Gi7oNOJ5y1lKCn+8pu8fA2dqWSslYpPZUxlmPCdiKYZNpGvu
  44833. /9ROutW04o5IWgAZCfEF2c6Rsffr6TlP9m8EQ5pV9T4FFL2/s1m02I4zhKOQUqqzApVg+QxMaPnu
  44834. 1RcN+HFXtSXkKe5lXa/R7jwXC1pDxaWG6iSe4gUH3DRCEpHWOXSuTEGC2/KmSNGzm/MzqvOmwMVO
  44835. 9fSddmPmAsYiS8GVP1BkLFTltvA8Kc9XAgMBAAGjQjBAMB0GA1UdDgQWBBRUYnBj8XWEQ1iO0RYg
  44836. scasGrz2iTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOC
  44837. AgEAKbqSSaet8PFww+SX8J+pJdVrnjT+5hpk9jprUrIQeBqfTNqK2uwcN1LgQkv7bHbKJAs5EhWd
  44838. nxEt/Hlk3ODg9d3gV8mlsnZwUKT+twpw1aA08XXXTUm6EdGz2OyC/+sOxL9kLX1jbhd47F18iMjr
  44839. jld22VkE+rxSH0Ws8HqA7Oxvdq6R2xCOBNyS36D25q5J08FsEhvMKar5CKXiNxTKsbhm7xqC5PD4
  44840. 8acWabfbqWE8n/Uxy+QARsIvdLGx14HuqCaVvIivTDUHKgLKeBRtRytAVunLKmChZwOgzoy8sHJn
  44841. xDHO2zTlJQNgJXtxmOTAGytfdELSS8VZCAeHvsXDf+eW2eHcKJfWjwXj9ZtOyh1QRwVTsMo554Wg
  44842. icEFOwE30z9J4nfrI8iIZjs9OXYhRvHsXyO466JmdXTBQPfYaJqT4i2pLr0cox7IdMakLXogqzu4
  44843. sEb9b91fUlV1YvCXoHzXOP0l382gmxDPi7g4Xl7FtKYCNqEeXxzP4padKar9mK5S4fNBUvupLnKW
  44844. nyfjqnN9+BojZns7q2WwMgFLFT49ok8MKzWixtlnEjUwzXYuFrOZnk1PTi07NEPhmg4NpGaXutIc
  44845. SkwsKouLgU9xGqndXHt7CMUADTdA43x7VF8vhV929vensBxXVsFy6K2ir40zSbofitzmdHxghm+H
  44846. l3s=
  44847. -----END CERTIFICATE-----
  44848. ISRG Root X2
  44849. ============
  44850. -----BEGIN CERTIFICATE-----
  44851. MIICGzCCAaGgAwIBAgIQQdKd0XLq7qeAwSxs6S+HUjAKBggqhkjOPQQDAzBPMQswCQYDVQQGEwJV
  44852. UzEpMCcGA1UEChMgSW50ZXJuZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElT
  44853. UkcgUm9vdCBYMjAeFw0yMDA5MDQwMDAwMDBaFw00MDA5MTcxNjAwMDBaME8xCzAJBgNVBAYTAlVT
  44854. MSkwJwYDVQQKEyBJbnRlcm5ldCBTZWN1cml0eSBSZXNlYXJjaCBHcm91cDEVMBMGA1UEAxMMSVNS
  44855. RyBSb290IFgyMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEzZvVn4CDCuwJSvMWSj5cz3es3mcFDR0H
  44856. ttwW+1qLFNvicWDEukWVEYmO6gbf9yoWHKS5xcUy4APgHoIYOIvXRdgKam7mAHf7AlF9ItgKbppb
  44857. d9/w+kHsOdx1ymgHDB/qo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNV
  44858. HQ4EFgQUfEKWrt5LSDv6kviejM9ti6lyN5UwCgYIKoZIzj0EAwMDaAAwZQIwe3lORlCEwkSHRhtF
  44859. cP9Ymd70/aTSVaYgLXTWNLxBo1BfASdWtL4ndQavEi51mI38AjEAi/V3bNTIZargCyzuFJ0nN6T5
  44860. U6VR5CmD1/iQMVtCnwr1/q4AaOeMSQ+2b1tbFfLn
  44861. -----END CERTIFICATE-----
  44862. HiPKI Root CA - G1
  44863. ==================
  44864. -----BEGIN CERTIFICATE-----
  44865. MIIFajCCA1KgAwIBAgIQLd2szmKXlKFD6LDNdmpeYDANBgkqhkiG9w0BAQsFADBPMQswCQYDVQQG
  44866. EwJUVzEjMCEGA1UECgwaQ2h1bmdod2EgVGVsZWNvbSBDby4sIEx0ZC4xGzAZBgNVBAMMEkhpUEtJ
  44867. IFJvb3QgQ0EgLSBHMTAeFw0xOTAyMjIwOTQ2MDRaFw0zNzEyMzExNTU5NTlaME8xCzAJBgNVBAYT
  44868. AlRXMSMwIQYDVQQKDBpDaHVuZ2h3YSBUZWxlY29tIENvLiwgTHRkLjEbMBkGA1UEAwwSSGlQS0kg
  44869. Um9vdCBDQSAtIEcxMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA9B5/UnMyDHPkvRN0
  44870. o9QwqNCuS9i233VHZvR85zkEHmpwINJaR3JnVfSl6J3VHiGh8Ge6zCFovkRTv4354twvVcg3Px+k
  44871. wJyz5HdcoEb+d/oaoDjq7Zpy3iu9lFc6uux55199QmQ5eiY29yTw1S+6lZgRZq2XNdZ1AYDgr/SE
  44872. YYwNHl98h5ZeQa/rh+r4XfEuiAU+TCK72h8q3VJGZDnzQs7ZngyzsHeXZJzA9KMuH5UHsBffMNsA
  44873. GJZMoYFL3QRtU6M9/Aes1MU3guvklQgZKILSQjqj2FPseYlgSGDIcpJQ3AOPgz+yQlda22rpEZfd
  44874. hSi8MEyr48KxRURHH+CKFgeW0iEPU8DtqX7UTuybCeyvQqww1r/REEXgphaypcXTT3OUM3ECoWqj
  44875. 1jOXTyFjHluP2cFeRXF3D4FdXyGarYPM+l7WjSNfGz1BryB1ZlpK9p/7qxj3ccC2HTHsOyDry+K4
  44876. 9a6SsvfhhEvyovKTmiKe0xRvNlS9H15ZFblzqMF8b3ti6RZsR1pl8w4Rm0bZ/W3c1pzAtH2lsN0/
  44877. Vm+h+fbkEkj9Bn8SV7apI09bA8PgcSojt/ewsTu8mL3WmKgMa/aOEmem8rJY5AIJEzypuxC00jBF
  44878. 8ez3ABHfZfjcK0NVvxaXxA/VLGGEqnKG/uY6fsI/fe78LxQ+5oXdUG+3Se0CAwEAAaNCMEAwDwYD
  44879. VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU8ncX+l6o/vY9cdVouslGDDjYr7AwDgYDVR0PAQH/BAQD
  44880. AgGGMA0GCSqGSIb3DQEBCwUAA4ICAQBQUfB13HAE4/+qddRxosuej6ip0691x1TPOhwEmSKsxBHi
  44881. 7zNKpiMdDg1H2DfHb680f0+BazVP6XKlMeJ45/dOlBhbQH3PayFUhuaVevvGyuqcSE5XCV0vrPSl
  44882. tJczWNWseanMX/mF+lLFjfiRFOs6DRfQUsJ748JzjkZ4Bjgs6FzaZsT0pPBWGTMpWmWSBUdGSquE
  44883. wx4noR8RkpkndZMPvDY7l1ePJlsMu5wP1G4wB9TcXzZoZjmDlicmisjEOf6aIW/Vcobpf2Lll07Q
  44884. JNBAsNB1CI69aO4I1258EHBGG3zgiLKecoaZAeO/n0kZtCW+VmWuF2PlHt/o/0elv+EmBYTksMCv
  44885. 5wiZqAxeJoBF1PhoL5aPruJKHJwWDBNvOIf2u8g0X5IDUXlwpt/L9ZlNec1OvFefQ05rLisY+Gpz
  44886. jLrFNe85akEez3GoorKGB1s6yeHvP2UEgEcyRHCVTjFnanRbEEV16rCf0OY1/k6fi8wrkkVbbiVg
  44887. hUbN0aqwdmaTd5a+g744tiROJgvM7XpWGuDpWsZkrUx6AEhEL7lAuxM+vhV4nYWBSipX3tUZQ9rb
  44888. yltHhoMLP7YNdnhzeSJesYAfz77RP1YQmCuVh6EfnWQUYDksswBVLuT1sw5XxJFBAJw/6KXf6vb/
  44889. yPCtbVKoF6ubYfwSUTXkJf2vqmqGOQ==
  44890. -----END CERTIFICATE-----
  44891. GlobalSign ECC Root CA - R4
  44892. ===========================
  44893. -----BEGIN CERTIFICATE-----
  44894. MIIB3DCCAYOgAwIBAgINAgPlfvU/k/2lCSGypjAKBggqhkjOPQQDAjBQMSQwIgYDVQQLExtHbG9i
  44895. YWxTaWduIEVDQyBSb290IENBIC0gUjQxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkds
  44896. b2JhbFNpZ24wHhcNMTIxMTEzMDAwMDAwWhcNMzgwMTE5MDMxNDA3WjBQMSQwIgYDVQQLExtHbG9i
  44897. YWxTaWduIEVDQyBSb290IENBIC0gUjQxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkds
  44898. b2JhbFNpZ24wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAS4xnnTj2wlDp8uORkcA6SumuU5BwkW
  44899. ymOxuYb4ilfBV85C+nOh92VC/x7BALJucw7/xyHlGKSq2XE/qNS5zowdo0IwQDAOBgNVHQ8BAf8E
  44900. BAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUVLB7rUW44kB/+wpu+74zyTyjhNUwCgYI
  44901. KoZIzj0EAwIDRwAwRAIgIk90crlgr/HmnKAWBVBfw147bmF0774BxL4YSFlhgjICICadVGNA3jdg
  44902. UM/I2O2dgq43mLyjj0xMqTQrbO/7lZsm
  44903. -----END CERTIFICATE-----
  44904. GTS Root R1
  44905. ===========
  44906. -----BEGIN CERTIFICATE-----
  44907. MIIFVzCCAz+gAwIBAgINAgPlk28xsBNJiGuiFzANBgkqhkiG9w0BAQwFADBHMQswCQYDVQQGEwJV
  44908. UzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3Qg
  44909. UjEwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UE
  44910. ChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjEwggIiMA0G
  44911. CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2EQKLHuOhd5s73L+UPreVp0A8of2C+X0yBoJx9vaM
  44912. f/vo27xqLpeXo4xL+Sv2sfnOhB2x+cWX3u+58qPpvBKJXqeqUqv4IyfLpLGcY9vXmX7wCl7raKb0
  44913. xlpHDU0QM+NOsROjyBhsS+z8CZDfnWQpJSMHobTSPS5g4M/SCYe7zUjwTcLCeoiKu7rPWRnWr4+w
  44914. B7CeMfGCwcDfLqZtbBkOtdh+JhpFAz2weaSUKK0PfyblqAj+lug8aJRT7oM6iCsVlgmy4HqMLnXW
  44915. nOunVmSPlk9orj2XwoSPwLxAwAtcvfaHszVsrBhQf4TgTM2S0yDpM7xSma8ytSmzJSq0SPly4cpk
  44916. 9+aCEI3oncKKiPo4Zor8Y/kB+Xj9e1x3+naH+uzfsQ55lVe0vSbv1gHR6xYKu44LtcXFilWr06zq
  44917. kUspzBmkMiVOKvFlRNACzqrOSbTqn3yDsEB750Orp2yjj32JgfpMpf/VjsPOS+C12LOORc92wO1A
  44918. K/1TD7Cn1TsNsYqiA94xrcx36m97PtbfkSIS5r762DL8EGMUUXLeXdYWk70paDPvOmbsB4om3xPX
  44919. V2V4J95eSRQAogB/mqghtqmxlbCluQ0WEdrHbEg8QOB+DVrNVjzRlwW5y0vtOUucxD/SVRNuJLDW
  44920. cfr0wbrM7Rv1/oFB2ACYPTrIrnqYNxgFlQIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0T
  44921. AQH/BAUwAwEB/zAdBgNVHQ4EFgQU5K8rJnEaK0gnhS9SZizv8IkTcT4wDQYJKoZIhvcNAQEMBQAD
  44922. ggIBAJ+qQibbC5u+/x6Wki4+omVKapi6Ist9wTrYggoGxval3sBOh2Z5ofmmWJyq+bXmYOfg6LEe
  44923. QkEzCzc9zolwFcq1JKjPa7XSQCGYzyI0zzvFIoTgxQ6KfF2I5DUkzps+GlQebtuyh6f88/qBVRRi
  44924. ClmpIgUxPoLW7ttXNLwzldMXG+gnoot7TiYaelpkttGsN/H9oPM47HLwEXWdyzRSjeZ2axfG34ar
  44925. J45JK3VmgRAhpuo+9K4l/3wV3s6MJT/KYnAK9y8JZgfIPxz88NtFMN9iiMG1D53Dn0reWVlHxYci
  44926. NuaCp+0KueIHoI17eko8cdLiA6EfMgfdG+RCzgwARWGAtQsgWSl4vflVy2PFPEz0tv/bal8xa5me
  44927. LMFrUKTX5hgUvYU/Z6tGn6D/Qqc6f1zLXbBwHSs09dR2CQzreExZBfMzQsNhFRAbd03OIozUhfJF
  44928. fbdT6u9AWpQKXCBfTkBdYiJ23//OYb2MI3jSNwLgjt7RETeJ9r/tSQdirpLsQBqvFAnZ0E6yove+
  44929. 7u7Y/9waLd64NnHi/Hm3lCXRSHNboTXns5lndcEZOitHTtNCjv0xyBZm2tIMPNuzjsmhDYAPexZ3
  44930. FL//2wmUspO8IFgV6dtxQ/PeEMMA3KgqlbbC1j+Qa3bbbP6MvPJwNQzcmRk13NfIRmPVNnGuV/u3
  44931. gm3c
  44932. -----END CERTIFICATE-----
  44933. GTS Root R2
  44934. ===========
  44935. -----BEGIN CERTIFICATE-----
  44936. MIIFVzCCAz+gAwIBAgINAgPlrsWNBCUaqxElqjANBgkqhkiG9w0BAQwFADBHMQswCQYDVQQGEwJV
  44937. UzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3Qg
  44938. UjIwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UE
  44939. ChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjIwggIiMA0G
  44940. CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDO3v2m++zsFDQ8BwZabFn3GTXd98GdVarTzTukk3Lv
  44941. CvptnfbwhYBboUhSnznFt+4orO/LdmgUud+tAWyZH8QiHZ/+cnfgLFuv5AS/T3KgGjSY6Dlo7JUl
  44942. e3ah5mm5hRm9iYz+re026nO8/4Piy33B0s5Ks40FnotJk9/BW9BuXvAuMC6C/Pq8tBcKSOWIm8Wb
  44943. a96wyrQD8Nr0kLhlZPdcTK3ofmZemde4wj7I0BOdre7kRXuJVfeKH2JShBKzwkCX44ofR5GmdFrS
  44944. +LFjKBC4swm4VndAoiaYecb+3yXuPuWgf9RhD1FLPD+M2uFwdNjCaKH5wQzpoeJ/u1U8dgbuak7M
  44945. kogwTZq9TwtImoS1mKPV+3PBV2HdKFZ1E66HjucMUQkQdYhMvI35ezzUIkgfKtzra7tEscszcTJG
  44946. r61K8YzodDqs5xoic4DSMPclQsciOzsSrZYuxsN2B6ogtzVJV+mSSeh2FnIxZyuWfoqjx5RWIr9q
  44947. S34BIbIjMt/kmkRtWVtd9QCgHJvGeJeNkP+byKq0rxFROV7Z+2et1VsRnTKaG73VululycslaVNV
  44948. J1zgyjbLiGH7HrfQy+4W+9OmTN6SpdTi3/UGVN4unUu0kzCqgc7dGtxRcw1PcOnlthYhGXmy5okL
  44949. dWTK1au8CcEYof/UVKGFPP0UJAOyh9OktwIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0T
  44950. AQH/BAUwAwEB/zAdBgNVHQ4EFgQUu//KjiOfT5nK2+JopqUVJxce2Q4wDQYJKoZIhvcNAQEMBQAD
  44951. ggIBAB/Kzt3HvqGf2SdMC9wXmBFqiN495nFWcrKeGk6c1SuYJF2ba3uwM4IJvd8lRuqYnrYb/oM8
  44952. 0mJhwQTtzuDFycgTE1XnqGOtjHsB/ncw4c5omwX4Eu55MaBBRTUoCnGkJE+M3DyCB19m3H0Q/gxh
  44953. swWV7uGugQ+o+MePTagjAiZrHYNSVc61LwDKgEDg4XSsYPWHgJ2uNmSRXbBoGOqKYcl3qJfEycel
  44954. /FVL8/B/uWU9J2jQzGv6U53hkRrJXRqWbTKH7QMgyALOWr7Z6v2yTcQvG99fevX4i8buMTolUVVn
  44955. jWQye+mew4K6Ki3pHrTgSAai/GevHyICc/sgCq+dVEuhzf9gR7A/Xe8bVr2XIZYtCtFenTgCR2y5
  44956. 9PYjJbigapordwj6xLEokCZYCDzifqrXPW+6MYgKBesntaFJ7qBFVHvmJ2WZICGoo7z7GJa7Um8M
  44957. 7YNRTOlZ4iBgxcJlkoKM8xAfDoqXvneCbT+PHV28SSe9zE8P4c52hgQjxcCMElv924SgJPFI/2R8
  44958. 0L5cFtHvma3AH/vLrrw4IgYmZNralw4/KBVEqE8AyvCazM90arQ+POuV7LXTWtiBmelDGDfrs7vR
  44959. WGJB82bSj6p4lVQgw1oudCvV0b4YacCs1aTPObpRhANl6WLAYv7YTVWW4tAR+kg0Eeye7QUd5MjW
  44960. HYbL
  44961. -----END CERTIFICATE-----
  44962. GTS Root R3
  44963. ===========
  44964. -----BEGIN CERTIFICATE-----
  44965. MIICCTCCAY6gAwIBAgINAgPluILrIPglJ209ZjAKBggqhkjOPQQDAzBHMQswCQYDVQQGEwJVUzEi
  44966. MCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjMw
  44967. HhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZ
  44968. R29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjMwdjAQBgcqhkjO
  44969. PQIBBgUrgQQAIgNiAAQfTzOHMymKoYTey8chWEGJ6ladK0uFxh1MJ7x/JlFyb+Kf1qPKzEUURout
  44970. 736GjOyxfi//qXGdGIRFBEFVbivqJn+7kAHjSxm65FSWRQmx1WyRRK2EE46ajA2ADDL24CejQjBA
  44971. MA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTB8Sa6oC2uhYHP0/Eq
  44972. Er24Cmf9vDAKBggqhkjOPQQDAwNpADBmAjEA9uEglRR7VKOQFhG/hMjqb2sXnh5GmCCbn9MN2azT
  44973. L818+FsuVbu/3ZL3pAzcMeGiAjEA/JdmZuVDFhOD3cffL74UOO0BzrEXGhF16b0DjyZ+hOXJYKaV
  44974. 11RZt+cRLInUue4X
  44975. -----END CERTIFICATE-----
  44976. GTS Root R4
  44977. ===========
  44978. -----BEGIN CERTIFICATE-----
  44979. MIICCTCCAY6gAwIBAgINAgPlwGjvYxqccpBQUjAKBggqhkjOPQQDAzBHMQswCQYDVQQGEwJVUzEi
  44980. MCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjQw
  44981. HhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZ
  44982. R29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjQwdjAQBgcqhkjO
  44983. PQIBBgUrgQQAIgNiAATzdHOnaItgrkO4NcWBMHtLSZ37wWHO5t5GvWvVYRg1rkDdc/eJkTBa6zzu
  44984. hXyiQHY7qca4R9gq55KRanPpsXI5nymfopjTX15YhmUPoYRlBtHci8nHc8iMai/lxKvRHYqjQjBA
  44985. MA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSATNbrdP9JNqPV2Py1
  44986. PsVq8JQdjDAKBggqhkjOPQQDAwNpADBmAjEA6ED/g94D9J+uHXqnLrmvT/aDHQ4thQEd0dlq7A/C
  44987. r8deVl5c1RxYIigL9zC2L7F8AjEA8GE8p/SgguMh1YQdc4acLa/KNJvxn7kjNuK8YAOdgLOaVsjh
  44988. 4rsUecrNIdSUtUlD
  44989. -----END CERTIFICATE-----
  44990. Telia Root CA v2
  44991. ================
  44992. -----BEGIN CERTIFICATE-----
  44993. MIIFdDCCA1ygAwIBAgIPAWdfJ9b+euPkrL4JWwWeMA0GCSqGSIb3DQEBCwUAMEQxCzAJBgNVBAYT
  44994. AkZJMRowGAYDVQQKDBFUZWxpYSBGaW5sYW5kIE95ajEZMBcGA1UEAwwQVGVsaWEgUm9vdCBDQSB2
  44995. MjAeFw0xODExMjkxMTU1NTRaFw00MzExMjkxMTU1NTRaMEQxCzAJBgNVBAYTAkZJMRowGAYDVQQK
  44996. DBFUZWxpYSBGaW5sYW5kIE95ajEZMBcGA1UEAwwQVGVsaWEgUm9vdCBDQSB2MjCCAiIwDQYJKoZI
  44997. hvcNAQEBBQADggIPADCCAgoCggIBALLQPwe84nvQa5n44ndp586dpAO8gm2h/oFlH0wnrI4AuhZ7
  44998. 6zBqAMCzdGh+sq/H1WKzej9Qyow2RCRj0jbpDIX2Q3bVTKFgcmfiKDOlyzG4OiIjNLh9vVYiQJ3q
  44999. 9HsDrWj8soFPmNB06o3lfc1jw6P23pLCWBnglrvFxKk9pXSW/q/5iaq9lRdU2HhE8Qx3FZLgmEKn
  45000. pNaqIJLNwaCzlrI6hEKNfdWV5Nbb6WLEWLN5xYzTNTODn3WhUidhOPFZPY5Q4L15POdslv5e2QJl
  45001. tI5c0BE0312/UqeBAMN/mUWZFdUXyApT7GPzmX3MaRKGwhfwAZ6/hLzRUssbkmbOpFPlob/E2wnW
  45002. 5olWK8jjfN7j/4nlNW4o6GwLI1GpJQXrSPjdscr6bAhR77cYbETKJuFzxokGgeWKrLDiKca5JLNr
  45003. RBH0pUPCTEPlcDaMtjNXepUugqD0XBCzYYP2AgWGLnwtbNwDRm41k9V6lS/eINhbfpSQBGq6WT0E
  45004. BXWdN6IOLj3rwaRSg/7Qa9RmjtzG6RJOHSpXqhC8fF6CfaamyfItufUXJ63RDolUK5X6wK0dmBR4
  45005. M0KGCqlztft0DbcbMBnEWg4cJ7faGND/isgFuvGqHKI3t+ZIpEYslOqodmJHixBTB0hXbOKSTbau
  45006. BcvcwUpej6w9GU7C7WB1K9vBykLVAgMBAAGjYzBhMB8GA1UdIwQYMBaAFHKs5DN5qkWH9v2sHZ7W
  45007. xy+G2CQ5MB0GA1UdDgQWBBRyrOQzeapFh/b9rB2e1scvhtgkOTAOBgNVHQ8BAf8EBAMCAQYwDwYD
  45008. VR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEAoDtZpwmUPjaE0n4vOaWWl/oRrfxn83EJ
  45009. 8rKJhGdEr7nv7ZbsnGTbMjBvZ5qsfl+yqwE2foH65IRe0qw24GtixX1LDoJt0nZi0f6X+J8wfBj5
  45010. tFJ3gh1229MdqfDBmgC9bXXYfef6xzijnHDoRnkDry5023X4blMMA8iZGok1GTzTyVR8qPAs5m4H
  45011. eW9q4ebqkYJpCh3DflminmtGFZhb069GHWLIzoBSSRE/yQQSwxN8PzuKlts8oB4KtItUsiRnDe+C
  45012. y748fdHif64W1lZYudogsYMVoe+KTTJvQS8TUoKU1xrBeKJR3Stwbbca+few4GeXVtt8YVMJAygC
  45013. QMez2P2ccGrGKMOF6eLtGpOg3kuYooQ+BXcBlj37tCAPnHICehIv1aO6UXivKitEZU61/Qrowc15
  45014. h2Er3oBXRb9n8ZuRXqWk7FlIEA04x7D6w0RtBPV4UBySllva9bguulvP5fBqnUsvWHMtTy3EHD70
  45015. sz+rFQ47GUGKpMFXEmZxTPpT41frYpUJnlTd0cI8Vzy9OK2YZLe4A5pTVmBds9hCG1xLEooc6+t9
  45016. xnppxyd/pPiL8uSUZodL6ZQHCRJ5irLrdATczvREWeAWysUsWNc8e89ihmpQfTU2Zqf7N+cox9jQ
  45017. raVplI/owd8k+BsHMYeB2F326CjYSlKArBPuUBQemMc=
  45018. -----END CERTIFICATE-----
  45019. D-TRUST BR Root CA 1 2020
  45020. =========================
  45021. -----BEGIN CERTIFICATE-----
  45022. MIIC2zCCAmCgAwIBAgIQfMmPK4TX3+oPyWWa00tNljAKBggqhkjOPQQDAzBIMQswCQYDVQQGEwJE
  45023. RTEVMBMGA1UEChMMRC1UcnVzdCBHbWJIMSIwIAYDVQQDExlELVRSVVNUIEJSIFJvb3QgQ0EgMSAy
  45024. MDIwMB4XDTIwMDIxMTA5NDUwMFoXDTM1MDIxMTA5NDQ1OVowSDELMAkGA1UEBhMCREUxFTATBgNV
  45025. BAoTDEQtVHJ1c3QgR21iSDEiMCAGA1UEAxMZRC1UUlVTVCBCUiBSb290IENBIDEgMjAyMDB2MBAG
  45026. ByqGSM49AgEGBSuBBAAiA2IABMbLxyjR+4T1mu9CFCDhQ2tuda38KwOE1HaTJddZO0Flax7mNCq7
  45027. dPYSzuht56vkPE4/RAiLzRZxy7+SmfSk1zxQVFKQhYN4lGdnoxwJGT11NIXe7WB9xwy0QVK5buXu
  45028. QqOCAQ0wggEJMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFHOREKv/VbNafAkl1bK6CKBrqx9t
  45029. MA4GA1UdDwEB/wQEAwIBBjCBxgYDVR0fBIG+MIG7MD6gPKA6hjhodHRwOi8vY3JsLmQtdHJ1c3Qu
  45030. bmV0L2NybC9kLXRydXN0X2JyX3Jvb3RfY2FfMV8yMDIwLmNybDB5oHegdYZzbGRhcDovL2RpcmVj
  45031. dG9yeS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwQlIlMjBSb290JTIwQ0ElMjAxJTIwMjAyMCxP
  45032. PUQtVHJ1c3QlMjBHbWJILEM9REU/Y2VydGlmaWNhdGVyZXZvY2F0aW9ubGlzdDAKBggqhkjOPQQD
  45033. AwNpADBmAjEAlJAtE/rhY/hhY+ithXhUkZy4kzg+GkHaQBZTQgjKL47xPoFWwKrY7RjEsK70Pvom
  45034. AjEA8yjixtsrmfu3Ubgko6SUeho/5jbiA1czijDLgsfWFBHVdWNbFJWcHwHP2NVypw87
  45035. -----END CERTIFICATE-----
  45036. D-TRUST EV Root CA 1 2020
  45037. =========================
  45038. -----BEGIN CERTIFICATE-----
  45039. MIIC2zCCAmCgAwIBAgIQXwJB13qHfEwDo6yWjfv/0DAKBggqhkjOPQQDAzBIMQswCQYDVQQGEwJE
  45040. RTEVMBMGA1UEChMMRC1UcnVzdCBHbWJIMSIwIAYDVQQDExlELVRSVVNUIEVWIFJvb3QgQ0EgMSAy
  45041. MDIwMB4XDTIwMDIxMTEwMDAwMFoXDTM1MDIxMTA5NTk1OVowSDELMAkGA1UEBhMCREUxFTATBgNV
  45042. BAoTDEQtVHJ1c3QgR21iSDEiMCAGA1UEAxMZRC1UUlVTVCBFViBSb290IENBIDEgMjAyMDB2MBAG
  45043. ByqGSM49AgEGBSuBBAAiA2IABPEL3YZDIBnfl4XoIkqbz52Yv7QFJsnL46bSj8WeeHsxiamJrSc8
  45044. ZRCC/N/DnU7wMyPE0jL1HLDfMxddxfCxivnvubcUyilKwg+pf3VlSSowZ/Rk99Yad9rDwpdhQntJ
  45045. raOCAQ0wggEJMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFH8QARY3OqQo5FD4pPfsazK2/umL
  45046. MA4GA1UdDwEB/wQEAwIBBjCBxgYDVR0fBIG+MIG7MD6gPKA6hjhodHRwOi8vY3JsLmQtdHJ1c3Qu
  45047. bmV0L2NybC9kLXRydXN0X2V2X3Jvb3RfY2FfMV8yMDIwLmNybDB5oHegdYZzbGRhcDovL2RpcmVj
  45048. dG9yeS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwRVYlMjBSb290JTIwQ0ElMjAxJTIwMjAyMCxP
  45049. PUQtVHJ1c3QlMjBHbWJILEM9REU/Y2VydGlmaWNhdGVyZXZvY2F0aW9ubGlzdDAKBggqhkjOPQQD
  45050. AwNpADBmAjEAyjzGKnXCXnViOTYAYFqLwZOZzNnbQTs7h5kXO9XMT8oi96CAy/m0sRtW9XLS/BnR
  45051. AjEAkfcwkz8QRitxpNA7RJvAKQIFskF3UfN5Wp6OFKBOQtJbgfM0agPnIjhQW+0ZT0MW
  45052. -----END CERTIFICATE-----
  45053. DigiCert TLS ECC P384 Root G5
  45054. =============================
  45055. -----BEGIN CERTIFICATE-----
  45056. MIICGTCCAZ+gAwIBAgIQCeCTZaz32ci5PhwLBCou8zAKBggqhkjOPQQDAzBOMQswCQYDVQQGEwJV
  45057. UzEXMBUGA1UEChMORGlnaUNlcnQsIEluYy4xJjAkBgNVBAMTHURpZ2lDZXJ0IFRMUyBFQ0MgUDM4
  45058. NCBSb290IEc1MB4XDTIxMDExNTAwMDAwMFoXDTQ2MDExNDIzNTk1OVowTjELMAkGA1UEBhMCVVMx
  45059. FzAVBgNVBAoTDkRpZ2lDZXJ0LCBJbmMuMSYwJAYDVQQDEx1EaWdpQ2VydCBUTFMgRUNDIFAzODQg
  45060. Um9vdCBHNTB2MBAGByqGSM49AgEGBSuBBAAiA2IABMFEoc8Rl1Ca3iOCNQfN0MsYndLxf3c1Tzvd
  45061. lHJS7cI7+Oz6e2tYIOyZrsn8aLN1udsJ7MgT9U7GCh1mMEy7H0cKPGEQQil8pQgO4CLp0zVozptj
  45062. n4S1mU1YoI71VOeVyaNCMEAwHQYDVR0OBBYEFMFRRVBZqz7nLFr6ICISB4CIfBFqMA4GA1UdDwEB
  45063. /wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MAoGCCqGSM49BAMDA2gAMGUCMQCJao1H5+z8blUD2Wds
  45064. Jk6Dxv3J+ysTvLd6jLRl0mlpYxNjOyZQLgGheQaRnUi/wr4CMEfDFXuxoJGZSZOoPHzoRgaLLPIx
  45065. AJSdYsiJvRmEFOml+wG4DXZDjC5Ty3zfDBeWUA==
  45066. -----END CERTIFICATE-----
  45067. DigiCert TLS RSA4096 Root G5
  45068. ============================
  45069. -----BEGIN CERTIFICATE-----
  45070. MIIFZjCCA06gAwIBAgIQCPm0eKj6ftpqMzeJ3nzPijANBgkqhkiG9w0BAQwFADBNMQswCQYDVQQG
  45071. EwJVUzEXMBUGA1UEChMORGlnaUNlcnQsIEluYy4xJTAjBgNVBAMTHERpZ2lDZXJ0IFRMUyBSU0E0
  45072. MDk2IFJvb3QgRzUwHhcNMjEwMTE1MDAwMDAwWhcNNDYwMTE0MjM1OTU5WjBNMQswCQYDVQQGEwJV
  45073. UzEXMBUGA1UEChMORGlnaUNlcnQsIEluYy4xJTAjBgNVBAMTHERpZ2lDZXJ0IFRMUyBSU0E0MDk2
  45074. IFJvb3QgRzUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCz0PTJeRGd/fxmgefM1eS8
  45075. 7IE+ajWOLrfn3q/5B03PMJ3qCQuZvWxX2hhKuHisOjmopkisLnLlvevxGs3npAOpPxG02C+JFvuU
  45076. AT27L/gTBaF4HI4o4EXgg/RZG5Wzrn4DReW+wkL+7vI8toUTmDKdFqgpwgscONyfMXdcvyej/Ces
  45077. tyu9dJsXLfKB2l2w4SMXPohKEiPQ6s+d3gMXsUJKoBZMpG2T6T867jp8nVid9E6P/DsjyG244gXa
  45078. zOvswzH016cpVIDPRFtMbzCe88zdH5RDnU1/cHAN1DrRN/BsnZvAFJNY781BOHW8EwOVfH/jXOnV
  45079. DdXifBBiqmvwPXbzP6PosMH976pXTayGpxi0KcEsDr9kvimM2AItzVwv8n/vFfQMFawKsPHTDU9q
  45080. TXeXAaDxZre3zu/O7Oyldcqs4+Fj97ihBMi8ez9dLRYiVu1ISf6nL3kwJZu6ay0/nTvEF+cdLvvy
  45081. z6b84xQslpghjLSR6Rlgg/IwKwZzUNWYOwbpx4oMYIwo+FKbbuH2TbsGJJvXKyY//SovcfXWJL5/
  45082. MZ4PbeiPT02jP/816t9JXkGPhvnxd3lLG7SjXi/7RgLQZhNeXoVPzthwiHvOAbWWl9fNff2C+MIk
  45083. wcoBOU+NosEUQB+cZtUMCUbW8tDRSHZWOkPLtgoRObqME2wGtZ7P6wIDAQABo0IwQDAdBgNVHQ4E
  45084. FgQUUTMc7TZArxfTJc1paPKvTiM+s0EwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMBAf8w
  45085. DQYJKoZIhvcNAQEMBQADggIBAGCmr1tfV9qJ20tQqcQjNSH/0GEwhJG3PxDPJY7Jv0Y02cEhJhxw
  45086. GXIeo8mH/qlDZJY6yFMECrZBu8RHANmfGBg7sg7zNOok992vIGCukihfNudd5N7HPNtQOa27PShN
  45087. lnx2xlv0wdsUpasZYgcYQF+Xkdycx6u1UQ3maVNVzDl92sURVXLFO4uJ+DQtpBflF+aZfTCIITfN
  45088. MBc9uPK8qHWgQ9w+iUuQrm0D4ByjoJYJu32jtyoQREtGBzRj7TG5BO6jm5qu5jF49OokYTurWGT/
  45089. u4cnYiWB39yhL/btp/96j1EuMPikAdKFOV8BmZZvWltwGUb+hmA+rYAQCd05JS9Yf7vSdPD3Rh9G
  45090. OUrYU9DzLjtxpdRv/PNn5AeP3SYZ4Y1b+qOTEZvpyDrDVWiakuFSdjjo4bq9+0/V77PnSIMx8IIh
  45091. 47a+p6tv75/fTM8BuGJqIz3nCU2AG3swpMPdB380vqQmsvZB6Akd4yCYqjdP//fx4ilwMUc/dNAU
  45092. FvohigLVigmUdy7yWSiLfFCSCmZ4OIN1xLVaqBHG5cGdZlXPU8Sv13WFqUITVuwhd4GTWgzqltlJ
  45093. yqEI8pc7bZsEGCREjnwB8twl2F6GmrE52/WRMmrRpnCKovfepEWFJqgejF0pW8hL2JpqA15w8oVP
  45094. bEtoL8pU9ozaMv7Da4M/OMZ+
  45095. -----END CERTIFICATE-----
  45096. Certainly Root R1
  45097. =================
  45098. -----BEGIN CERTIFICATE-----
  45099. MIIFRzCCAy+gAwIBAgIRAI4P+UuQcWhlM1T01EQ5t+AwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UE
  45100. BhMCVVMxEjAQBgNVBAoTCUNlcnRhaW5seTEaMBgGA1UEAxMRQ2VydGFpbmx5IFJvb3QgUjEwHhcN
  45101. MjEwNDAxMDAwMDAwWhcNNDYwNDAxMDAwMDAwWjA9MQswCQYDVQQGEwJVUzESMBAGA1UEChMJQ2Vy
  45102. dGFpbmx5MRowGAYDVQQDExFDZXJ0YWlubHkgUm9vdCBSMTCCAiIwDQYJKoZIhvcNAQEBBQADggIP
  45103. ADCCAgoCggIBANA21B/q3avk0bbm+yLA3RMNansiExyXPGhjZjKcA7WNpIGD2ngwEc/csiu+kr+O
  45104. 5MQTvqRoTNoCaBZ0vrLdBORrKt03H2As2/X3oXyVtwxwhi7xOu9S98zTm/mLvg7fMbedaFySpvXl
  45105. 8wo0tf97ouSHocavFwDvA5HtqRxOcT3Si2yJ9HiG5mpJoM610rCrm/b01C7jcvk2xusVtyWMOvwl
  45106. DbMicyF0yEqWYZL1LwsYpfSt4u5BvQF5+paMjRcCMLT5r3gajLQ2EBAHBXDQ9DGQilHFhiZ5shGI
  45107. XsXwClTNSaa/ApzSRKft43jvRl5tcdF5cBxGX1HpyTfcX35pe0HfNEXgO4T0oYoKNp43zGJS4YkN
  45108. KPl6I7ENPT2a/Z2B7yyQwHtETrtJ4A5KVpK8y7XdeReJkd5hiXSSqOMyhb5OhaRLWcsrxXiOcVTQ
  45109. AjeZjOVJ6uBUcqQRBi8LjMFbvrWhsFNunLhgkR9Za/kt9JQKl7XsxXYDVBtlUrpMklZRNaBA2Cnb
  45110. rlJ2Oy0wQJuK0EJWtLeIAaSHO1OWzaMWj/Nmqhexx2DgwUMFDO6bW2BvBlyHWyf5QBGenDPBt+U1
  45111. VwV/J84XIIwc/PH72jEpSe31C4SnT8H2TsIonPru4K8H+zMReiFPCyEQtkA6qyI6BJyLm4SGcprS
  45112. p6XEtHWRqSsjAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1Ud
  45113. DgQWBBTgqj8ljZ9EXME66C6ud0yEPmcM9DANBgkqhkiG9w0BAQsFAAOCAgEAuVevuBLaV4OPaAsz
  45114. HQNTVfSVcOQrPbA56/qJYv331hgELyE03fFo8NWWWt7CgKPBjcZq91l3rhVkz1t5BXdm6ozTaw3d
  45115. 8VkswTOlMIAVRQdFGjEitpIAq5lNOo93r6kiyi9jyhXWx8bwPWz8HA2YEGGeEaIi1wrykXprOQ4v
  45116. MMM2SZ/g6Q8CRFA3lFV96p/2O7qUpUzpvD5RtOjKkjZUbVwlKNrdrRT90+7iIgXr0PK3aBLXWopB
  45117. GsaSpVo7Y0VPv+E6dyIvXL9G+VoDhRNCX8reU9ditaY1BMJH/5n9hN9czulegChB8n3nHpDYT3Y+
  45118. gjwN/KUD+nsa2UUeYNrEjvn8K8l7lcUq/6qJ34IxD3L/DCfXCh5WAFAeDJDBlrXYFIW7pw0WwfgH
  45119. JBu6haEaBQmAupVjyTrsJZ9/nbqkRxWbRHDxakvWOF5D8xh+UG7pWijmZeZ3Gzr9Hb4DJqPb1OG7
  45120. fpYnKx3upPvaJVQTA945xsMfTZDsjxtK0hzthZU4UHlG1sGQUDGpXJpuHfUzVounmdLyyCwzk5Iw
  45121. x06MZTMQZBf9JBeW0Y3COmor6xOLRPIh80oat3df1+2IpHLlOR+Vnb5nwXARPbv0+Em34yaXOp/S
  45122. X3z7wJl8OSngex2/DaeP0ik0biQVy96QXr8axGbqwua6OV+KmalBWQewLK8=
  45123. -----END CERTIFICATE-----
  45124. Certainly Root E1
  45125. =================
  45126. -----BEGIN CERTIFICATE-----
  45127. MIIB9zCCAX2gAwIBAgIQBiUzsUcDMydc+Y2aub/M+DAKBggqhkjOPQQDAzA9MQswCQYDVQQGEwJV
  45128. UzESMBAGA1UEChMJQ2VydGFpbmx5MRowGAYDVQQDExFDZXJ0YWlubHkgUm9vdCBFMTAeFw0yMTA0
  45129. MDEwMDAwMDBaFw00NjA0MDEwMDAwMDBaMD0xCzAJBgNVBAYTAlVTMRIwEAYDVQQKEwlDZXJ0YWlu
  45130. bHkxGjAYBgNVBAMTEUNlcnRhaW5seSBSb290IEUxMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE3m/4
  45131. fxzf7flHh4axpMCK+IKXgOqPyEpeKn2IaKcBYhSRJHpcnqMXfYqGITQYUBsQ3tA3SybHGWCA6TS9
  45132. YBk2QNYphwk8kXr2vBMj3VlOBF7PyAIcGFPBMdjaIOlEjeR2o0IwQDAOBgNVHQ8BAf8EBAMCAQYw
  45133. DwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU8ygYy2R17ikq6+2uI1g4hevIIgcwCgYIKoZIzj0E
  45134. AwMDaAAwZQIxALGOWiDDshliTd6wT99u0nCK8Z9+aozmut6Dacpps6kFtZaSF4fC0urQe87YQVt8
  45135. rgIwRt7qy12a7DLCZRawTDBcMPPaTnOGBtjOiQRINzf43TNRnXCve1XYAS59BWQOhriR
  45136. -----END CERTIFICATE-----
  45137. Security Communication RootCA3
  45138. ==============================
  45139. -----BEGIN CERTIFICATE-----
  45140. MIIFfzCCA2egAwIBAgIJAOF8N0D9G/5nMA0GCSqGSIb3DQEBDAUAMF0xCzAJBgNVBAYTAkpQMSUw
  45141. IwYDVQQKExxTRUNPTSBUcnVzdCBTeXN0ZW1zIENPLixMVEQuMScwJQYDVQQDEx5TZWN1cml0eSBD
  45142. b21tdW5pY2F0aW9uIFJvb3RDQTMwHhcNMTYwNjE2MDYxNzE2WhcNMzgwMTE4MDYxNzE2WjBdMQsw
  45143. CQYDVQQGEwJKUDElMCMGA1UEChMcU0VDT00gVHJ1c3QgU3lzdGVtcyBDTy4sTFRELjEnMCUGA1UE
  45144. AxMeU2VjdXJpdHkgQ29tbXVuaWNhdGlvbiBSb290Q0EzMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  45145. MIICCgKCAgEA48lySfcw3gl8qUCBWNO0Ot26YQ+TUG5pPDXC7ltzkBtnTCHsXzW7OT4rCmDvu20r
  45146. hvtxosis5FaU+cmvsXLUIKx00rgVrVH+hXShuRD+BYD5UpOzQD11EKzAlrenfna84xtSGc4RHwsE
  45147. NPXY9Wk8d/Nk9A2qhd7gCVAEF5aEt8iKvE1y/By7z/MGTfmfZPd+pmaGNXHIEYBMwXFAWB6+oHP2
  45148. /D5Q4eAvJj1+XCO1eXDe+uDRpdYMQXF79+qMHIjH7Iv10S9VlkZ8WjtYO/u62C21Jdp6Ts9EriGm
  45149. npjKIG58u4iFW/vAEGK78vknR+/RiTlDxN/e4UG/VHMgly1s2vPUB6PmudhvrvyMGS7TZ2crldtY
  45150. XLVqAvO4g160a75BflcJdURQVc1aEWEhCmHCqYj9E7wtiS/NYeCVvsq1e+F7NGcLH7YMx3weGVPK
  45151. p7FKFSBWFHA9K4IsD50VHUeAR/94mQ4xr28+j+2GaR57GIgUssL8gjMunEst+3A7caoreyYn8xrC
  45152. 3PsXuKHqy6C0rtOUfnrQq8PsOC0RLoi/1D+tEjtCrI8Cbn3M0V9hvqG8OmpI6iZVIhZdXw3/JzOf
  45153. GAN0iltSIEdrRU0id4xVJ/CvHozJgyJUt5rQT9nO/NkuHJYosQLTA70lUhw0Zk8jq/R3gpYd0Vcw
  45154. CBEF/VfR2ccCAwEAAaNCMEAwHQYDVR0OBBYEFGQUfPxYchamCik0FW8qy7z8r6irMA4GA1UdDwEB
  45155. /wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBDAUAA4ICAQDcAiMI4u8hOscNtybS
  45156. YpOnpSNyByCCYN8Y11StaSWSntkUz5m5UoHPrmyKO1o5yGwBQ8IibQLwYs1OY0PAFNr0Y/Dq9HHu
  45157. Tofjcan0yVflLl8cebsjqodEV+m9NU1Bu0soo5iyG9kLFwfl9+qd9XbXv8S2gVj/yP9kaWJ5rW4O
  45158. H3/uHWnlt3Jxs/6lATWUVCvAUm2PVcTJ0rjLyjQIUYWg9by0F1jqClx6vWPGOi//lkkZhOpn2ASx
  45159. YfQAW0q3nHE3GYV5v4GwxxMOdnE+OoAGrgYWp421wsTL/0ClXI2lyTrtcoHKXJg80jQDdwj98ClZ
  45160. XSEIx2C/pHF7uNkegr4Jr2VvKKu/S7XuPghHJ6APbw+LP6yVGPO5DtxnVW5inkYO0QR4ynKudtml
  45161. +LLfiAlhi+8kTtFZP1rUPcmTPCtk9YENFpb3ksP+MW/oKjJ0DvRMmEoYDjBU1cXrvMUVnuiZIesn
  45162. KwkK2/HmcBhWuwzkvvnoEKQTkrgc4NtnHVMDpCKn3F2SEDzq//wbEBrD2NCcnWXL0CsnMQMeNuE9
  45163. dnUM/0Umud1RvCPHX9jYhxBAEg09ODfnRDwYwFMJZI//1ZqmfHAuc1Uh6N//g7kdPjIe1qZ9LPFm
  45164. 6Vwdp6POXiUyK+OVrCoHzrQoeIY8LaadTdJ0MN1kURXbg4NR16/9M51NZg==
  45165. -----END CERTIFICATE-----
  45166. Security Communication ECC RootCA1
  45167. ==================================
  45168. -----BEGIN CERTIFICATE-----
  45169. MIICODCCAb6gAwIBAgIJANZdm7N4gS7rMAoGCCqGSM49BAMDMGExCzAJBgNVBAYTAkpQMSUwIwYD
  45170. VQQKExxTRUNPTSBUcnVzdCBTeXN0ZW1zIENPLixMVEQuMSswKQYDVQQDEyJTZWN1cml0eSBDb21t
  45171. dW5pY2F0aW9uIEVDQyBSb290Q0ExMB4XDTE2MDYxNjA1MTUyOFoXDTM4MDExODA1MTUyOFowYTEL
  45172. MAkGA1UEBhMCSlAxJTAjBgNVBAoTHFNFQ09NIFRydXN0IFN5c3RlbXMgQ08uLExURC4xKzApBgNV
  45173. BAMTIlNlY3VyaXR5IENvbW11bmljYXRpb24gRUNDIFJvb3RDQTEwdjAQBgcqhkjOPQIBBgUrgQQA
  45174. IgNiAASkpW9gAwPDvTH00xecK4R1rOX9PVdu12O/5gSJko6BnOPpR27KkBLIE+CnnfdldB9sELLo
  45175. 5OnvbYUymUSxXv3MdhDYW72ixvnWQuRXdtyQwjWpS4g8EkdtXP9JTxpKULGjQjBAMB0GA1UdDgQW
  45176. BBSGHOf+LaVKiwj+KBH6vqNm+GBZLzAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAK
  45177. BggqhkjOPQQDAwNoADBlAjAVXUI9/Lbu9zuxNuie9sRGKEkz0FhDKmMpzE2xtHqiuQ04pV1IKv3L
  45178. snNdo4gIxwwCMQDAqy0Obe0YottT6SXbVQjgUMzfRGEWgqtJsLKB7HOHeLRMsmIbEvoWTSVLY70e
  45179. N9k=
  45180. -----END CERTIFICATE-----
  45181. BJCA Global Root CA1
  45182. ====================
  45183. -----BEGIN CERTIFICATE-----
  45184. MIIFdDCCA1ygAwIBAgIQVW9l47TZkGobCdFsPsBsIDANBgkqhkiG9w0BAQsFADBUMQswCQYDVQQG
  45185. EwJDTjEmMCQGA1UECgwdQkVJSklORyBDRVJUSUZJQ0FURSBBVVRIT1JJVFkxHTAbBgNVBAMMFEJK
  45186. Q0EgR2xvYmFsIFJvb3QgQ0ExMB4XDTE5MTIxOTAzMTYxN1oXDTQ0MTIxMjAzMTYxN1owVDELMAkG
  45187. A1UEBhMCQ04xJjAkBgNVBAoMHUJFSUpJTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZMR0wGwYDVQQD
  45188. DBRCSkNBIEdsb2JhbCBSb290IENBMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAPFm
  45189. CL3ZxRVhy4QEQaVpN3cdwbB7+sN3SJATcmTRuHyQNZ0YeYjjlwE8R4HyDqKYDZ4/N+AZspDyRhyS
  45190. sTphzvq3Rp4Dhtczbu33RYx2N95ulpH3134rhxfVizXuhJFyV9xgw8O558dnJCNPYwpj9mZ9S1Wn
  45191. P3hkSWkSl+BMDdMJoDIwOvqfwPKcxRIqLhy1BDPapDgRat7GGPZHOiJBhyL8xIkoVNiMpTAK+BcW
  45192. yqw3/XmnkRd4OJmtWO2y3syJfQOcs4ll5+M7sSKGjwZteAf9kRJ/sGsciQ35uMt0WwfCyPQ10WRj
  45193. eulumijWML3mG90Vr4TqnMfK9Q7q8l0ph49pczm+LiRvRSGsxdRpJQaDrXpIhRMsDQa4bHlW/KNn
  45194. MoH1V6XKV0Jp6VwkYe/iMBhORJhVb3rCk9gZtt58R4oRTklH2yiUAguUSiz5EtBP6DF+bHq/pj+b
  45195. OT0CFqMYs2esWz8sgytnOYFcuX6U1WTdno9uruh8W7TXakdI136z1C2OVnZOz2nxbkRs1CTqjSSh
  45196. GL+9V/6pmTW12xB3uD1IutbB5/EjPtffhZ0nPNRAvQoMvfXnjSXWgXSHRtQpdaJCbPdzied9v3pK
  45197. H9MiyRVVz99vfFXQpIsHETdfg6YmV6YBW37+WGgHqel62bno/1Afq8K0wM7o6v0PvY1NuLxxAgMB
  45198. AAGjQjBAMB0GA1UdDgQWBBTF7+3M2I0hxkjk49cULqcWk+WYATAPBgNVHRMBAf8EBTADAQH/MA4G
  45199. A1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAgEAUoKsITQfI/Ki2Pm4rzc2IInRNwPWaZ+4
  45200. YRC6ojGYWUfo0Q0lHhVBDOAqVdVXUsv45Mdpox1NcQJeXyFFYEhcCY5JEMEE3KliawLwQ8hOnThJ
  45201. dMkycFRtwUf8jrQ2ntScvd0g1lPJGKm1Vrl2i5VnZu69mP6u775u+2D2/VnGKhs/I0qUJDAnyIm8
  45202. 60Qkmss9vk/Ves6OF8tiwdneHg56/0OGNFK8YT88X7vZdrRTvJez/opMEi4r89fO4aL/3Xtw+zuh
  45203. TaRjAv04l5U/BXCga99igUOLtFkNSoxUnMW7gZ/NfaXvCyUeOiDbHPwfmGcCCtRzRBPbUYQaVQNW
  45204. 4AB+dAb/OMRyHdOoP2gxXdMJxy6MW2Pg6Nwe0uxhHvLe5e/2mXZgLR6UcnHGCyoyx5JO1UbXHfmp
  45205. GQrI+pXObSOYqgs4rZpWDW+N8TEAiMEXnM0ZNjX+VVOg4DwzX5Ze4jLp3zO7Bkqp2IRzznfSxqxx
  45206. 4VyjHQy7Ct9f4qNx2No3WqB4K/TUfet27fJhcKVlmtOJNBir+3I+17Q9eVzYH6Eze9mCUAyTF6ps
  45207. 3MKCuwJXNq+YJyo5UOGwifUll35HaBC07HPKs5fRJNz2YqAo07WjuGS3iGJCz51TzZm+ZGiPTx4S
  45208. SPfSKcOYKMryMguTjClPPGAyzQWWYezyr/6zcCwupvI=
  45209. -----END CERTIFICATE-----
  45210. BJCA Global Root CA2
  45211. ====================
  45212. -----BEGIN CERTIFICATE-----
  45213. MIICJTCCAaugAwIBAgIQLBcIfWQqwP6FGFkGz7RK6zAKBggqhkjOPQQDAzBUMQswCQYDVQQGEwJD
  45214. TjEmMCQGA1UECgwdQkVJSklORyBDRVJUSUZJQ0FURSBBVVRIT1JJVFkxHTAbBgNVBAMMFEJKQ0Eg
  45215. R2xvYmFsIFJvb3QgQ0EyMB4XDTE5MTIxOTAzMTgyMVoXDTQ0MTIxMjAzMTgyMVowVDELMAkGA1UE
  45216. BhMCQ04xJjAkBgNVBAoMHUJFSUpJTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZMR0wGwYDVQQDDBRC
  45217. SkNBIEdsb2JhbCBSb290IENBMjB2MBAGByqGSM49AgEGBSuBBAAiA2IABJ3LgJGNU2e1uVCxA/jl
  45218. SR9BIgmwUVJY1is0j8USRhTFiy8shP8sbqjV8QnjAyEUxEM9fMEsxEtqSs3ph+B99iK++kpRuDCK
  45219. /eHeGBIK9ke35xe/J4rUQUyWPGCWwf0VHKNCMEAwHQYDVR0OBBYEFNJKsVF/BvDRgh9Obl+rg/xI
  45220. 1LCRMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMAoGCCqGSM49BAMDA2gAMGUCMBq8
  45221. W9f+qdJUDkpd0m2xQNz0Q9XSSpkZElaA94M04TVOSG0ED1cxMDAtsaqdAzjbBgIxAMvMh1PLet8g
  45222. UXOQwKhbYdDFUDn9hf7B43j4ptZLvZuHjw/l1lOWqzzIQNph91Oj9w==
  45223. -----END CERTIFICATE-----
  45224. Sectigo Public Server Authentication Root E46
  45225. =============================================
  45226. -----BEGIN CERTIFICATE-----
  45227. MIICOjCCAcGgAwIBAgIQQvLM2htpN0RfFf51KBC49DAKBggqhkjOPQQDAzBfMQswCQYDVQQGEwJH
  45228. QjEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMTYwNAYDVQQDEy1TZWN0aWdvIFB1YmxpYyBTZXJ2
  45229. ZXIgQXV0aGVudGljYXRpb24gUm9vdCBFNDYwHhcNMjEwMzIyMDAwMDAwWhcNNDYwMzIxMjM1OTU5
  45230. WjBfMQswCQYDVQQGEwJHQjEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMTYwNAYDVQQDEy1TZWN0
  45231. aWdvIFB1YmxpYyBTZXJ2ZXIgQXV0aGVudGljYXRpb24gUm9vdCBFNDYwdjAQBgcqhkjOPQIBBgUr
  45232. gQQAIgNiAAR2+pmpbiDt+dd34wc7qNs9Xzjoq1WmVk/WSOrsfy2qw7LFeeyZYX8QeccCWvkEN/U0
  45233. NSt3zn8gj1KjAIns1aeibVvjS5KToID1AZTc8GgHHs3u/iVStSBDHBv+6xnOQ6OjQjBAMB0GA1Ud
  45234. DgQWBBTRItpMWfFLXyY4qp3W7usNw/upYTAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB
  45235. /zAKBggqhkjOPQQDAwNnADBkAjAn7qRaqCG76UeXlImldCBteU/IvZNeWBj7LRoAasm4PdCkT0RH
  45236. lAFWovgzJQxC36oCMB3q4S6ILuH5px0CMk7yn2xVdOOurvulGu7t0vzCAxHrRVxgED1cf5kDW21U
  45237. SAGKcw==
  45238. -----END CERTIFICATE-----
  45239. Sectigo Public Server Authentication Root R46
  45240. =============================================
  45241. -----BEGIN CERTIFICATE-----
  45242. MIIFijCCA3KgAwIBAgIQdY39i658BwD6qSWn4cetFDANBgkqhkiG9w0BAQwFADBfMQswCQYDVQQG
  45243. EwJHQjEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMTYwNAYDVQQDEy1TZWN0aWdvIFB1YmxpYyBT
  45244. ZXJ2ZXIgQXV0aGVudGljYXRpb24gUm9vdCBSNDYwHhcNMjEwMzIyMDAwMDAwWhcNNDYwMzIxMjM1
  45245. OTU5WjBfMQswCQYDVQQGEwJHQjEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMTYwNAYDVQQDEy1T
  45246. ZWN0aWdvIFB1YmxpYyBTZXJ2ZXIgQXV0aGVudGljYXRpb24gUm9vdCBSNDYwggIiMA0GCSqGSIb3
  45247. DQEBAQUAA4ICDwAwggIKAoICAQCTvtU2UnXYASOgHEdCSe5jtrch/cSV1UgrJnwUUxDaef0rty2k
  45248. 1Cz66jLdScK5vQ9IPXtamFSvnl0xdE8H/FAh3aTPaE8bEmNtJZlMKpnzSDBh+oF8HqcIStw+Kxwf
  45249. GExxqjWMrfhu6DtK2eWUAtaJhBOqbchPM8xQljeSM9xfiOefVNlI8JhD1mb9nxc4Q8UBUQvX4yMP
  45250. FF1bFOdLvt30yNoDN9HWOaEhUTCDsG3XME6WW5HwcCSrv0WBZEMNvSE6Lzzpng3LILVCJ8zab5vu
  45251. ZDCQOc2TZYEhMbUjUDM3IuM47fgxMMxF/mL50V0yeUKH32rMVhlATc6qu/m1dkmU8Sf4kaWD5Qaz
  45252. Yw6A3OASVYCmO2a0OYctyPDQ0RTp5A1NDvZdV3LFOxxHVp3i1fuBYYzMTYCQNFu31xR13NgESJ/A
  45253. wSiItOkcyqex8Va3e0lMWeUgFaiEAin6OJRpmkkGj80feRQXEgyDet4fsZfu+Zd4KKTIRJLpfSYF
  45254. plhym3kT2BFfrsU4YjRosoYwjviQYZ4ybPUHNs2iTG7sijbt8uaZFURww3y8nDnAtOFr94MlI1fZ
  45255. EoDlSfB1D++N6xybVCi0ITz8fAr/73trdf+LHaAZBav6+CuBQug4urv7qv094PPK306Xlynt8xhW
  45256. 6aWWrL3DkJiy4Pmi1KZHQ3xtzwIDAQABo0IwQDAdBgNVHQ4EFgQUVnNYZJX5khqwEioEYnmhQBWI
  45257. IUkwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAC9c
  45258. mTz8Bl6MlC5w6tIyMY208FHVvArzZJ8HXtXBc2hkeqK5Duj5XYUtqDdFqij0lgVQYKlJfp/imTYp
  45259. E0RHap1VIDzYm/EDMrraQKFz6oOht0SmDpkBm+S8f74TlH7Kph52gDY9hAaLMyZlbcp+nv4fjFg4
  45260. exqDsQ+8FxG75gbMY/qB8oFM2gsQa6H61SilzwZAFv97fRheORKkU55+MkIQpiGRqRxOF3yEvJ+M
  45261. 0ejf5lG5Nkc/kLnHvALcWxxPDkjBJYOcCj+esQMzEhonrPcibCTRAUH4WAP+JWgiH5paPHxsnnVI
  45262. 84HxZmduTILA7rpXDhjvLpr3Etiga+kFpaHpaPi8TD8SHkXoUsCjvxInebnMMTzD9joiFgOgyY9m
  45263. pFuiTdaBJQbpdqQACj7LzTWb4OE4y2BThihCQRxEV+ioratF4yUQvNs+ZUH7G6aXD+u5dHn5Hrwd
  45264. Vw1Hr8Mvn4dGp+smWg9WY7ViYG4A++MnESLn/pmPNPW56MORcr3Ywx65LvKRRFHQV80MNNVIIb/b
  45265. E/FmJUNS0nAiNs2fxBx1IK1jcmMGDw4nztJqDby1ORrp0XZ60Vzk50lJLVU3aPAaOpg+VBeHVOmm
  45266. J1CJeyAvP/+/oYtKR5j/K3tJPsMpRmAYQqszKbrAKbkTidOIijlBO8n9pu0f9GBj39ItVQGL
  45267. -----END CERTIFICATE-----
  45268. SSL.com TLS RSA Root CA 2022
  45269. ============================
  45270. -----BEGIN CERTIFICATE-----
  45271. MIIFiTCCA3GgAwIBAgIQb77arXO9CEDii02+1PdbkTANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQG
  45272. EwJVUzEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMSUwIwYDVQQDDBxTU0wuY29tIFRMUyBSU0Eg
  45273. Um9vdCBDQSAyMDIyMB4XDTIyMDgyNTE2MzQyMloXDTQ2MDgxOTE2MzQyMVowTjELMAkGA1UEBhMC
  45274. VVMxGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjElMCMGA1UEAwwcU1NMLmNvbSBUTFMgUlNBIFJv
  45275. b3QgQ0EgMjAyMjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANCkCXJPQIgSYT41I57u
  45276. 9nTPL3tYPc48DRAokC+X94xI2KDYJbFMsBFMF3NQ0CJKY7uB0ylu1bUJPiYYf7ISf5OYt6/wNr/y
  45277. 7hienDtSxUcZXXTzZGbVXcdotL8bHAajvI9AI7YexoS9UcQbOcGV0insS657Lb85/bRi3pZ7Qcac
  45278. oOAGcvvwB5cJOYF0r/c0WRFXCsJbwST0MXMwgsadugL3PnxEX4MN8/HdIGkWCVDi1FW24IBydm5M
  45279. R7d1VVm0U3TZlMZBrViKMWYPHqIbKUBOL9975hYsLfy/7PO0+r4Y9ptJ1O4Fbtk085zx7AGL0SDG
  45280. D6C1vBdOSHtRwvzpXGk3R2azaPgVKPC506QVzFpPulJwoxJF3ca6TvvC0PeoUidtbnm1jPx7jMEW
  45281. TO6Af77wdr5BUxIzrlo4QqvXDz5BjXYHMtWrifZOZ9mxQnUjbvPNQrL8VfVThxc7wDNY8VLS+YCk
  45282. 8OjwO4s4zKTGkH8PnP2L0aPP2oOnaclQNtVcBdIKQXTbYxE3waWglksejBYSd66UNHsef8JmAOSq
  45283. g+qKkK3ONkRN0VHpvB/zagX9wHQfJRlAUW7qglFA35u5CCoGAtUjHBPW6dvbxrB6y3snm/vg1UYk
  45284. 7RBLY0ulBY+6uB0rpvqR4pJSvezrZ5dtmi2fgTIFZzL7SAg/2SW4BCUvAgMBAAGjYzBhMA8GA1Ud
  45285. EwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAU+y437uOEeicuzRk1sTN8/9REQrkwHQYDVR0OBBYEFPsu
  45286. N+7jhHonLs0ZNbEzfP/UREK5MA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAjYlt
  45287. hEUY8U+zoO9opMAdrDC8Z2awms22qyIZZtM7QbUQnRC6cm4pJCAcAZli05bg4vsMQtfhWsSWTVTN
  45288. j8pDU/0quOr4ZcoBwq1gaAafORpR2eCNJvkLTqVTJXojpBzOCBvfR4iyrT7gJ4eLSYwfqUdYe5by
  45289. iB0YrrPRpgqU+tvT5TgKa3kSM/tKWTcWQA673vWJDPFs0/dRa1419dvAJuoSc06pkZCmF8NsLzjU
  45290. o3KUQyxi4U5cMj29TH0ZR6LDSeeWP4+a0zvkEdiLA9z2tmBVGKaBUfPhqBVq6+AL8BQx1rmMRTqo
  45291. ENjwuSfr98t67wVylrXEj5ZzxOhWc5y8aVFjvO9nHEMaX3cZHxj4HCUp+UmZKbaSPaKDN7Egkaib
  45292. MOlqbLQjk2UEqxHzDh1TJElTHaE/nUiSEeJ9DU/1172iWD54nR4fK/4huxoTtrEoZP2wAgDHbICi
  45293. vRZQIA9ygV/MlP+7mea6kMvq+cYMwq7FGc4zoWtcu358NFcXrfA/rs3qr5nsLFR+jM4uElZI7xc7
  45294. P0peYNLcdDa8pUNjyw9bowJWCZ4kLOGGgYz+qxcs+sjiMho6/4UIyYOf8kpIEFR3N+2ivEC+5BB0
  45295. 9+Rbu7nzifmPQdjH5FCQNYA+HLhNkNPU98OwoX6EyneSMSy4kLGCenROmxMmtNVQZlR4rmA=
  45296. -----END CERTIFICATE-----
  45297. SSL.com TLS ECC Root CA 2022
  45298. ============================
  45299. -----BEGIN CERTIFICATE-----
  45300. MIICOjCCAcCgAwIBAgIQFAP1q/s3ixdAW+JDsqXRxDAKBggqhkjOPQQDAzBOMQswCQYDVQQGEwJV
  45301. UzEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMSUwIwYDVQQDDBxTU0wuY29tIFRMUyBFQ0MgUm9v
  45302. dCBDQSAyMDIyMB4XDTIyMDgyNTE2MzM0OFoXDTQ2MDgxOTE2MzM0N1owTjELMAkGA1UEBhMCVVMx
  45303. GDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjElMCMGA1UEAwwcU1NMLmNvbSBUTFMgRUNDIFJvb3Qg
  45304. Q0EgMjAyMjB2MBAGByqGSM49AgEGBSuBBAAiA2IABEUpNXP6wrgjzhR9qLFNoFs27iosU8NgCTWy
  45305. JGYmacCzldZdkkAZDsalE3D07xJRKF3nzL35PIXBz5SQySvOkkJYWWf9lCcQZIxPBLFNSeR7T5v1
  45306. 5wj4A4j3p8OSSxlUgaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBSJjy+j6CugFFR7
  45307. 81a4Jl9nOAuc0DAdBgNVHQ4EFgQUiY8vo+groBRUe/NWuCZfZzgLnNAwDgYDVR0PAQH/BAQDAgGG
  45308. MAoGCCqGSM49BAMDA2gAMGUCMFXjIlbp15IkWE8elDIPDAI2wv2sdDJO4fscgIijzPvX6yv/N33w
  45309. 7deedWo1dlJF4AIxAMeNb0Igj762TVntd00pxCAgRWSGOlDGxK0tk/UYfXLtqc/ErFc2KAhl3zx5
  45310. Zn6g6g==
  45311. -----END CERTIFICATE-----
  45312. Atos TrustedRoot Root CA ECC TLS 2021
  45313. =====================================
  45314. -----BEGIN CERTIFICATE-----
  45315. MIICFTCCAZugAwIBAgIQPZg7pmY9kGP3fiZXOATvADAKBggqhkjOPQQDAzBMMS4wLAYDVQQDDCVB
  45316. dG9zIFRydXN0ZWRSb290IFJvb3QgQ0EgRUNDIFRMUyAyMDIxMQ0wCwYDVQQKDARBdG9zMQswCQYD
  45317. VQQGEwJERTAeFw0yMTA0MjIwOTI2MjNaFw00MTA0MTcwOTI2MjJaMEwxLjAsBgNVBAMMJUF0b3Mg
  45318. VHJ1c3RlZFJvb3QgUm9vdCBDQSBFQ0MgVExTIDIwMjExDTALBgNVBAoMBEF0b3MxCzAJBgNVBAYT
  45319. AkRFMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEloZYKDcKZ9Cg3iQZGeHkBQcfl+3oZIK59sRxUM6K
  45320. DP/XtXa7oWyTbIOiaG6l2b4siJVBzV3dscqDY4PMwL502eCdpO5KTlbgmClBk1IQ1SQ4AjJn8ZQS
  45321. b+/Xxd4u/RmAo0IwQDAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBR2KCXWfeBmmnoJsmo7jjPX
  45322. NtNPojAOBgNVHQ8BAf8EBAMCAYYwCgYIKoZIzj0EAwMDaAAwZQIwW5kp85wxtolrbNa9d+F851F+
  45323. uDrNozZffPc8dz7kUK2o59JZDCaOMDtuCCrCp1rIAjEAmeMM56PDr9NJLkaCI2ZdyQAUEv049OGY
  45324. a3cpetskz2VAv9LcjBHo9H1/IISpQuQo
  45325. -----END CERTIFICATE-----
  45326. Atos TrustedRoot Root CA RSA TLS 2021
  45327. =====================================
  45328. -----BEGIN CERTIFICATE-----
  45329. MIIFZDCCA0ygAwIBAgIQU9XP5hmTC/srBRLYwiqipDANBgkqhkiG9w0BAQwFADBMMS4wLAYDVQQD
  45330. DCVBdG9zIFRydXN0ZWRSb290IFJvb3QgQ0EgUlNBIFRMUyAyMDIxMQ0wCwYDVQQKDARBdG9zMQsw
  45331. CQYDVQQGEwJERTAeFw0yMTA0MjIwOTIxMTBaFw00MTA0MTcwOTIxMDlaMEwxLjAsBgNVBAMMJUF0
  45332. b3MgVHJ1c3RlZFJvb3QgUm9vdCBDQSBSU0EgVExTIDIwMjExDTALBgNVBAoMBEF0b3MxCzAJBgNV
  45333. BAYTAkRFMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAtoAOxHm9BYx9sKOdTSJNy/BB
  45334. l01Z4NH+VoyX8te9j2y3I49f1cTYQcvyAh5x5en2XssIKl4w8i1mx4QbZFc4nXUtVsYvYe+W/CBG
  45335. vevUez8/fEc4BKkbqlLfEzfTFRVOvV98r61jx3ncCHvVoOX3W3WsgFWZkmGbzSoXfduP9LVq6hdK
  45336. ZChmFSlsAvFr1bqjM9xaZ6cF4r9lthawEO3NUDPJcFDsGY6wx/J0W2tExn2WuZgIWWbeKQGb9Cpt
  45337. 0xU6kGpn8bRrZtkh68rZYnxGEFzedUlnnkL5/nWpo63/dgpnQOPF943HhZpZnmKaau1Fh5hnstVK
  45338. PNe0OwANwI8f4UDErmwh3El+fsqyjW22v5MvoVw+j8rtgI5Y4dtXz4U2OLJxpAmMkokIiEjxQGMY
  45339. sluMWuPD0xeqqxmjLBvk1cbiZnrXghmmOxYsL3GHX0WelXOTwkKBIROW1527k2gV+p2kHYzygeBY
  45340. Br3JtuP2iV2J+axEoctr+hbxx1A9JNr3w+SH1VbxT5Aw+kUJWdo0zuATHAR8ANSbhqRAvNncTFd+
  45341. rrcztl524WWLZt+NyteYr842mIycg5kDcPOvdO3GDjbnvezBc6eUWsuSZIKmAMFwoW4sKeFYV+xa
  45342. fJlrJaSQOoD0IJ2azsct+bJLKZWD6TWNp0lIpw9MGZHQ9b8Q4HECAwEAAaNCMEAwDwYDVR0TAQH/
  45343. BAUwAwEB/zAdBgNVHQ4EFgQUdEmZ0f+0emhFdcN+tNzMzjkz2ggwDgYDVR0PAQH/BAQDAgGGMA0G
  45344. CSqGSIb3DQEBDAUAA4ICAQAjQ1MkYlxt/T7Cz1UAbMVWiLkO3TriJQ2VSpfKgInuKs1l+NsW4AmS
  45345. 4BjHeJi78+xCUvuppILXTdiK/ORO/auQxDh1MoSf/7OwKwIzNsAQkG8dnK/haZPso0UvFJ/1TCpl
  45346. Q3IM98P4lYsU84UgYt1UU90s3BiVaU+DR3BAM1h3Egyi61IxHkzJqM7F78PRreBrAwA0JrRUITWX
  45347. AdxfG/F851X6LWh3e9NpzNMOa7pNdkTWwhWaJuywxfW70Xp0wmzNxbVe9kzmWy2B27O3Opee7c9G
  45348. slA9hGCZcbUztVdF5kJHdWoOsAgMrr3e97sPWD2PAzHoPYJQyi9eDF20l74gNAf0xBLh7tew2Vkt
  45349. afcxBPTy+av5EzH4AXcOPUIjJsyacmdRIXrMPIWo6iFqO9taPKU0nprALN+AnCng33eU0aKAQv9q
  45350. TFsR0PXNor6uzFFcw9VUewyu1rkGd4Di7wcaaMxZUa1+XGdrudviB0JbuAEFWDlN5LuYo7Ey7Nmj
  45351. 1m+UI/87tyll5gfp77YZ6ufCOB0yiJA8EytuzO+rdwY0d4RPcuSBhPm5dDTedk+SKlOxJTnbPP/l
  45352. PqYO5Wue/9vsL3SD3460s6neFE3/MaNFcyT6lSnMEpcEoji2jbDwN/zIIX8/syQbPYtuzE2wFg2W
  45353. HYMfRsCbvUOZ58SWLs5fyQ==
  45354. -----END CERTIFICATE-----
  45355. <?php
  45356. namespace Composer\CaBundle;
  45357. use Psr\Log\LoggerInterface;
  45358. use Symfony\Component\Process\PhpProcess;
  45359. class CaBundle
  45360. {
  45361. private static $caPath;
  45362. private static $caFileValidity = array();
  45363. private static $useOpensslParse;
  45364. public static function getSystemCaRootBundlePath(LoggerInterface $logger = null)
  45365. {
  45366. if (self::$caPath !== null) {
  45367. return self::$caPath;
  45368. }
  45369. $caBundlePaths = array();
  45370. $caBundlePaths[] = self::getEnvVariable('SSL_CERT_FILE');
  45371. $caBundlePaths[] = self::getEnvVariable('SSL_CERT_DIR');
  45372. $caBundlePaths[] = ini_get('openssl.cafile');
  45373. $caBundlePaths[] = ini_get('openssl.capath');
  45374. $otherLocations = array(
  45375. '/etc/pki/tls/certs/ca-bundle.crt',
  45376. '/etc/ssl/certs/ca-certificates.crt',
  45377. '/etc/ssl/ca-bundle.pem',
  45378. '/usr/local/share/certs/ca-root-nss.crt',
  45379. '/usr/ssl/certs/ca-bundle.crt',
  45380. '/opt/local/share/curl/curl-ca-bundle.crt',
  45381. '/usr/local/share/curl/curl-ca-bundle.crt',
  45382. '/usr/share/ssl/certs/ca-bundle.crt',
  45383. '/etc/ssl/cert.pem',
  45384. '/usr/local/etc/ssl/cert.pem',
  45385. '/usr/local/etc/openssl/cert.pem',
  45386. '/usr/local/etc/openssl@1.1/cert.pem',
  45387. );
  45388. foreach($otherLocations as $location) {
  45389. $otherLocations[] = dirname($location);
  45390. }
  45391. $caBundlePaths = array_merge($caBundlePaths, $otherLocations);
  45392. foreach ($caBundlePaths as $caBundle) {
  45393. if ($caBundle && self::caFileUsable($caBundle, $logger)) {
  45394. return self::$caPath = $caBundle;
  45395. }
  45396. if ($caBundle && self::caDirUsable($caBundle, $logger)) {
  45397. return self::$caPath = $caBundle;
  45398. }
  45399. }
  45400. return self::$caPath = static::getBundledCaBundlePath();
  45401. }
  45402. public static function getBundledCaBundlePath()
  45403. {
  45404. $caBundleFile = __DIR__.'/../res/cacert.pem';
  45405. if (0 === strpos($caBundleFile, 'phar://')) {
  45406. $tempCaBundleFile = tempnam(sys_get_temp_dir(), 'openssl-ca-bundle-');
  45407. if (false === $tempCaBundleFile) {
  45408. throw new \RuntimeException('Could not create a temporary file to store the bundled CA file');
  45409. }
  45410. file_put_contents(
  45411. $tempCaBundleFile,
  45412. file_get_contents($caBundleFile)
  45413. );
  45414. register_shutdown_function(function() use ($tempCaBundleFile) {
  45415. @unlink($tempCaBundleFile);
  45416. });
  45417. $caBundleFile = $tempCaBundleFile;
  45418. }
  45419. return $caBundleFile;
  45420. }
  45421. public static function validateCaFile($filename, LoggerInterface $logger = null)
  45422. {
  45423. static $warned = false;
  45424. if (isset(self::$caFileValidity[$filename])) {
  45425. return self::$caFileValidity[$filename];
  45426. }
  45427. $contents = file_get_contents($filename);
  45428. if (!static::isOpensslParseSafe()) {
  45429. if (!$warned && $logger) {
  45430. $logger->warning(sprintf(
  45431. 'Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.',
  45432. PHP_VERSION
  45433. ));
  45434. $warned = true;
  45435. }
  45436. $isValid = !empty($contents);
  45437. } elseif (is_string($contents) && strlen($contents) > 0) {
  45438. $contents = preg_replace("/^(\\-+(?:BEGIN|END))\\s+TRUSTED\\s+(CERTIFICATE\\-+)\$/m", '$1 $2', $contents);
  45439. if (null === $contents) {
  45440. $isValid = false;
  45441. } else {
  45442. $isValid = (bool) openssl_x509_parse($contents);
  45443. }
  45444. } else {
  45445. $isValid = false;
  45446. }
  45447. if ($logger) {
  45448. $logger->debug('Checked CA file '.realpath($filename).': '.($isValid ? 'valid' : 'invalid'));
  45449. }
  45450. return self::$caFileValidity[$filename] = $isValid;
  45451. }
  45452. public static function isOpensslParseSafe()
  45453. {
  45454. if (null !== self::$useOpensslParse) {
  45455. return self::$useOpensslParse;
  45456. }
  45457. if (PHP_VERSION_ID >= 50600) {
  45458. return self::$useOpensslParse = true;
  45459. }
  45460. if (
  45461. (PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50328)
  45462. || (PHP_VERSION_ID < 50500 && PHP_VERSION_ID >= 50423)
  45463. || PHP_VERSION_ID >= 50507
  45464. ) {
  45465. return self::$useOpensslParse = true;
  45466. }
  45467. if (defined('PHP_WINDOWS_VERSION_BUILD')) {
  45468. return self::$useOpensslParse = false;
  45469. }
  45470. $compareDistroVersionPrefix = function ($prefix, $fixedVersion) {
  45471. $regex = '{^'.preg_quote($prefix).'([0-9]+)$}';
  45472. if (preg_match($regex, PHP_VERSION, $m)) {
  45473. return ((int) $m[1]) >= $fixedVersion;
  45474. }
  45475. return false;
  45476. };
  45477. if (
  45478. $compareDistroVersionPrefix('5.3.3-7+squeeze', 18)
  45479. || $compareDistroVersionPrefix('5.4.4-14+deb7u', 7)
  45480. || $compareDistroVersionPrefix('5.3.10-1ubuntu3.', 9)
  45481. ) {
  45482. return self::$useOpensslParse = true;
  45483. }
  45484. if (!class_exists('Symfony\Component\Process\PhpProcess')) {
  45485. return self::$useOpensslParse = false;
  45486. }
  45487. $cert = 'LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUVwRENDQTR5Z0F3SUJBZ0lKQUp6dThyNnU2ZUJjTUEwR0NTcUdTSWIzRFFFQkJRVUFNSUhETVFzd0NRWUQKVlFRR0V3SkVSVEVjTUJvR0ExVUVDQXdUVG05eVpISm9aV2x1TFZkbGMzUm1ZV3hsYmpFUU1BNEdBMVVFQnd3SApTOE9Ed3Jac2JqRVVNQklHQTFVRUNnd0xVMlZyZEdsdmJrVnBibk14SHpBZEJnTlZCQXNNRmsxaGJHbGphVzkxCmN5QkRaWEowSUZObFkzUnBiMjR4SVRBZkJnTlZCQU1NR0cxaGJHbGphVzkxY3k1elpXdDBhVzl1WldsdWN5NWsKWlRFcU1DZ0dDU3FHU0liM0RRRUpBUlliYzNSbFptRnVMbVZ6YzJWeVFITmxhM1JwYjI1bGFXNXpMbVJsTUhVWQpaREU1TnpBd01UQXhNREF3TURBd1dnQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBCkFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUEKQUFBQUFBQVhEVEUwTVRFeU9ERXhNemt6TlZvd2djTXhDekFKQmdOVkJBWVRBa1JGTVJ3d0dnWURWUVFJREJOTwpiM0prY21obGFXNHRWMlZ6ZEdaaGJHVnVNUkF3RGdZRFZRUUhEQWRMdzRQQ3RteHVNUlF3RWdZRFZRUUtEQXRUClpXdDBhVzl1UldsdWN6RWZNQjBHQTFVRUN3d1dUV0ZzYVdOcGIzVnpJRU5sY25RZ1UyVmpkR2x2YmpFaE1COEcKQTFVRUF3d1liV0ZzYVdOcGIzVnpMbk5sYTNScGIyNWxhVzV6TG1SbE1Tb3dLQVlKS29aSWh2Y05BUWtCRmh0egpkR1ZtWVc0dVpYTnpaWEpBYzJWcmRHbHZibVZwYm5NdVpHVXdnZ0VpTUEwR0NTcUdTSWIzRFFFQkFRVUFBNElCCkR3QXdnZ0VLQW9JQkFRRERBZjNobDdKWTBYY0ZuaXlFSnBTU0RxbjBPcUJyNlFQNjV1c0pQUnQvOFBhRG9xQnUKd0VZVC9OYSs2ZnNnUGpDMHVLOURaZ1dnMnRIV1dvYW5TYmxBTW96NVBINlorUzRTSFJaN2UyZERJalBqZGhqaAowbUxnMlVNTzV5cDBWNzk3R2dzOWxOdDZKUmZIODFNTjJvYlhXczROdHp0TE11RDZlZ3FwcjhkRGJyMzRhT3M4CnBrZHVpNVVhd1Raa3N5NXBMUEhxNWNNaEZHbTA2djY1Q0xvMFYyUGQ5K0tBb2tQclBjTjVLTEtlYno3bUxwazYKU01lRVhPS1A0aWRFcXh5UTdPN2ZCdUhNZWRzUWh1K3ByWTNzaTNCVXlLZlF0UDVDWm5YMmJwMHdLSHhYMTJEWAoxbmZGSXQ5RGJHdkhUY3lPdU4rblpMUEJtM3ZXeG50eUlJdlZBZ01CQUFHalFqQkFNQWtHQTFVZEV3UUNNQUF3CkVRWUpZSVpJQVliNFFnRUJCQVFEQWdlQU1Bc0dBMVVkRHdRRUF3SUZvREFUQmdOVkhTVUVEREFLQmdnckJnRUYKQlFjREFqQU5CZ2txaGtpRzl3MEJBUVVGQUFPQ0FRRUFHMGZaWVlDVGJkajFYWWMrMVNub2FQUit2SThDOENhRAo4KzBVWWhkbnlVNGdnYTBCQWNEclk5ZTk0ZUVBdTZacXljRjZGakxxWFhkQWJvcHBXb2NyNlQ2R0QxeDMzQ2tsClZBcnpHL0t4UW9oR0QySmVxa2hJTWxEb214SE83a2EzOStPYThpMnZXTFZ5alU4QVp2V01BcnVIYTRFRU55RzcKbFcyQWFnYUZLRkNyOVRuWFRmcmR4R1ZFYnY3S1ZRNmJkaGc1cDVTanBXSDErTXEwM3VSM1pYUEJZZHlWODMxOQpvMGxWajFLRkkyRENML2xpV2lzSlJvb2YrMWNSMzVDdGQwd1lCY3BCNlRac2xNY09QbDc2ZHdLd0pnZUpvMlFnClpzZm1jMnZDMS9xT2xOdU5xLzBUenprVkd2OEVUVDNDZ2FVK1VYZTRYT1Z2a2NjZWJKbjJkZz09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K';
  45488. $script = <<<'EOT'
  45489. error_reporting(-1);
  45490. $info = openssl_x509_parse(base64_decode('%s'));
  45491. var_dump(PHP_VERSION, $info['issuer']['emailAddress'], $info['validFrom_time_t']);
  45492. EOT;
  45493. $script = '<'."?php\n".sprintf($script, $cert);
  45494. try {
  45495. $process = new PhpProcess($script);
  45496. $process->mustRun();
  45497. } catch (\Exception $e) {
  45498. return self::$useOpensslParse = false;
  45499. }
  45500. $output = preg_split('{\r?\n}', trim($process->getOutput()));
  45501. $errorOutput = trim($process->getErrorOutput());
  45502. if (
  45503. is_array($output)
  45504. && count($output) === 3
  45505. && $output[0] === sprintf('string(%d) "%s"', strlen(PHP_VERSION), PHP_VERSION)
  45506. && $output[1] === 'string(27) "stefan.esser@sektioneins.de"'
  45507. && $output[2] === 'int(-1)'
  45508. && preg_match('{openssl_x509_parse\(\): illegal (?:ASN1 data type for|length in) timestamp in - on line \d+}', $errorOutput)
  45509. ) {
  45510. return self::$useOpensslParse = true;
  45511. }
  45512. return self::$useOpensslParse = false;
  45513. }
  45514. public static function reset()
  45515. {
  45516. self::$caFileValidity = array();
  45517. self::$caPath = null;
  45518. self::$useOpensslParse = null;
  45519. }
  45520. private static function getEnvVariable($name)
  45521. {
  45522. if (isset($_SERVER[$name])) {
  45523. return (string) $_SERVER[$name];
  45524. }
  45525. if (PHP_SAPI === 'cli' && ($value = getenv($name)) !== false && $value !== null) {
  45526. return (string) $value;
  45527. }
  45528. return false;
  45529. }
  45530. private static function caFileUsable($certFile, LoggerInterface $logger = null)
  45531. {
  45532. return $certFile
  45533. && static::isFile($certFile, $logger)
  45534. && static::isReadable($certFile, $logger)
  45535. && static::validateCaFile($certFile, $logger);
  45536. }
  45537. private static function caDirUsable($certDir, LoggerInterface $logger = null)
  45538. {
  45539. return $certDir
  45540. && static::isDir($certDir, $logger)
  45541. && static::isReadable($certDir, $logger)
  45542. && static::glob($certDir . '/*', $logger);
  45543. }
  45544. private static function isFile($certFile, LoggerInterface $logger = null)
  45545. {
  45546. $isFile = @is_file($certFile);
  45547. if (!$isFile && $logger) {
  45548. $logger->debug(sprintf('Checked CA file %s does not exist or it is not a file.', $certFile));
  45549. }
  45550. return $isFile;
  45551. }
  45552. private static function isDir($certDir, LoggerInterface $logger = null)
  45553. {
  45554. $isDir = @is_dir($certDir);
  45555. if (!$isDir && $logger) {
  45556. $logger->debug(sprintf('Checked directory %s does not exist or it is not a directory.', $certDir));
  45557. }
  45558. return $isDir;
  45559. }
  45560. private static function isReadable($certFileOrDir, LoggerInterface $logger = null)
  45561. {
  45562. $isReadable = @is_readable($certFileOrDir);
  45563. if (!$isReadable && $logger) {
  45564. $logger->debug(sprintf('Checked file or directory %s is not readable.', $certFileOrDir));
  45565. }
  45566. return $isReadable;
  45567. }
  45568. private static function glob($pattern, LoggerInterface $logger = null)
  45569. {
  45570. $certs = glob($pattern);
  45571. if ($certs === false) {
  45572. if ($logger) {
  45573. $logger->debug(sprintf("An error occurred while trying to find certificates for pattern: %s", $pattern));
  45574. }
  45575. return false;
  45576. }
  45577. if (count($certs) === 0) {
  45578. if ($logger) {
  45579. $logger->debug(sprintf("No CA files found for pattern: %s", $pattern));
  45580. }
  45581. return false;
  45582. }
  45583. return true;
  45584. }
  45585. }
  45586. Copyright (C) 2022 Composer
  45587. Permission is hereby granted, free of charge, to any person obtaining a copy of
  45588. this software and associated documentation files (the "Software"), to deal in
  45589. the Software without restriction, including without limitation the rights to
  45590. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  45591. of the Software, and to permit persons to whom the Software is furnished to do
  45592. so, subject to the following conditions:
  45593. The above copyright notice and this permission notice shall be included in all
  45594. copies or substantial portions of the Software.
  45595. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  45596. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  45597. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  45598. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  45599. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  45600. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  45601. SOFTWARE.
  45602. <?php declare(strict_types=1);
  45603. namespace Composer\ClassMapGenerator;
  45604. class ClassMap implements \Countable
  45605. {
  45606. public $map = [];
  45607. private $ambiguousClasses = [];
  45608. private $psrViolations = [];
  45609. public function getMap(): array
  45610. {
  45611. return $this->map;
  45612. }
  45613. public function getPsrViolations(): array
  45614. {
  45615. return $this->psrViolations;
  45616. }
  45617. public function getAmbiguousClasses(): array
  45618. {
  45619. return $this->ambiguousClasses;
  45620. }
  45621. public function sort(): void
  45622. {
  45623. ksort($this->map);
  45624. }
  45625. public function addClass(string $className, string $path): void
  45626. {
  45627. $this->map[$className] = $path;
  45628. }
  45629. public function getClassPath(string $className): string
  45630. {
  45631. if (!isset($this->map[$className])) {
  45632. throw new \OutOfBoundsException('Class '.$className.' is not present in the map');
  45633. }
  45634. return $this->map[$className];
  45635. }
  45636. public function hasClass(string $className): bool
  45637. {
  45638. return isset($this->map[$className]);
  45639. }
  45640. public function addPsrViolation(string $warning): void
  45641. {
  45642. $this->psrViolations[] = $warning;
  45643. }
  45644. public function addAmbiguousClass(string $className, string $path): void
  45645. {
  45646. $this->ambiguousClasses[$className][] = $path;
  45647. }
  45648. public function count(): int
  45649. {
  45650. return \count($this->map);
  45651. }
  45652. }
  45653. <?php declare(strict_types=1);
  45654. namespace Composer\ClassMapGenerator;
  45655. use Composer\Pcre\Preg;
  45656. use Symfony\Component\Finder\Finder;
  45657. use Composer\IO\IOInterface;
  45658. class ClassMapGenerator
  45659. {
  45660. private $extensions;
  45661. private $scannedFiles = null;
  45662. private $classMap;
  45663. public function __construct(array $extensions = ['php', 'inc'])
  45664. {
  45665. $this->extensions = $extensions;
  45666. $this->classMap = new ClassMap;
  45667. }
  45668. public function avoidDuplicateScans(FileList $scannedFiles = null): self
  45669. {
  45670. $this->scannedFiles = $scannedFiles ?? new FileList;
  45671. return $this;
  45672. }
  45673. public static function createMap($path): array
  45674. {
  45675. $generator = new self();
  45676. $generator->scanPaths($path);
  45677. return $generator->getClassMap()->getMap();
  45678. }
  45679. public function getClassMap(): ClassMap
  45680. {
  45681. return $this->classMap;
  45682. }
  45683. public function scanPaths($path, string $excluded = null, string $autoloadType = 'classmap', ?string $namespace = null): void
  45684. {
  45685. if (!in_array($autoloadType, ['psr-0', 'psr-4', 'classmap'], true)) {
  45686. throw new \InvalidArgumentException('$autoloadType must be one of: "psr-0", "psr-4" or "classmap"');
  45687. }
  45688. if ('classmap' !== $autoloadType) {
  45689. if (!is_string($path)) {
  45690. throw new \InvalidArgumentException('$path must be a string when specifying a psr-0 or psr-4 autoload type');
  45691. }
  45692. if (!is_string($namespace)) {
  45693. throw new \InvalidArgumentException('$namespace must be given (even if it is an empty string if you do not want to filter) when specifying a psr-0 or psr-4 autoload type');
  45694. }
  45695. $basePath = $path;
  45696. }
  45697. if (is_string($path)) {
  45698. if (is_file($path)) {
  45699. $path = [new \SplFileInfo($path)];
  45700. } elseif (is_dir($path) || strpos($path, '*') !== false) {
  45701. $path = Finder::create()
  45702. ->files()
  45703. ->followLinks()
  45704. ->name('/\.(?:'.implode('|', array_map('preg_quote', $this->extensions)).')$/')
  45705. ->in($path);
  45706. } else {
  45707. throw new \RuntimeException(
  45708. 'Could not scan for classes inside "'.$path.'" which does not appear to be a file nor a folder'
  45709. );
  45710. }
  45711. }
  45712. $cwd = realpath(self::getCwd());
  45713. foreach ($path as $file) {
  45714. $filePath = $file->getPathname();
  45715. if (!in_array(pathinfo($filePath, PATHINFO_EXTENSION), $this->extensions, true)) {
  45716. continue;
  45717. }
  45718. if (!self::isAbsolutePath($filePath)) {
  45719. $filePath = $cwd . '/' . $filePath;
  45720. $filePath = self::normalizePath($filePath);
  45721. } else {
  45722. $filePath = Preg::replace('{[\\\\/]{2,}}', '/', $filePath);
  45723. }
  45724. if ('' === $filePath) {
  45725. throw new \LogicException('Got an empty $filePath for '.$file->getPathname());
  45726. }
  45727. $realPath = realpath($filePath);
  45728. if (false === $realPath) {
  45729. throw new \RuntimeException('realpath of '.$filePath.' failed to resolve, got false');
  45730. }
  45731. if ($this->scannedFiles !== null && $this->scannedFiles->contains($realPath)) {
  45732. continue;
  45733. }
  45734. if (null !== $excluded && Preg::isMatch($excluded, strtr($realPath, '\\', '/'))) {
  45735. continue;
  45736. }
  45737. if (null !== $excluded && Preg::isMatch($excluded, strtr($filePath, '\\', '/'))) {
  45738. continue;
  45739. }
  45740. $classes = PhpFileParser::findClasses($filePath);
  45741. if ('classmap' !== $autoloadType && isset($namespace)) {
  45742. $classes = $this->filterByNamespace($classes, $filePath, $namespace, $autoloadType, $basePath);
  45743. if (\count($classes) > 0 && $this->scannedFiles !== null) {
  45744. $this->scannedFiles->add($realPath);
  45745. }
  45746. } elseif ($this->scannedFiles !== null) {
  45747. $this->scannedFiles->add($realPath);
  45748. }
  45749. foreach ($classes as $class) {
  45750. if (!$this->classMap->hasClass($class)) {
  45751. $this->classMap->addClass($class, $filePath);
  45752. } elseif ($filePath !== $this->classMap->getClassPath($class) && !Preg::isMatch('{/(test|fixture|example|stub)s?/}i', strtr($this->classMap->getClassPath($class).' '.$filePath, '\\', '/'))) {
  45753. $this->classMap->addAmbiguousClass($class, $filePath);
  45754. }
  45755. }
  45756. }
  45757. }
  45758. private function filterByNamespace(array $classes, string $filePath, string $baseNamespace, string $namespaceType, string $basePath): array
  45759. {
  45760. $validClasses = [];
  45761. $rejectedClasses = [];
  45762. $realSubPath = substr($filePath, strlen($basePath) + 1);
  45763. $dotPosition = strrpos($realSubPath, '.');
  45764. $realSubPath = substr($realSubPath, 0, $dotPosition === false ? PHP_INT_MAX : $dotPosition);
  45765. foreach ($classes as $class) {
  45766. if ('' !== $baseNamespace && 0 !== strpos($class, $baseNamespace)) {
  45767. continue;
  45768. }
  45769. if ('psr-0' === $namespaceType) {
  45770. $namespaceLength = strrpos($class, '\\');
  45771. if (false !== $namespaceLength) {
  45772. $namespace = substr($class, 0, $namespaceLength + 1);
  45773. $className = substr($class, $namespaceLength + 1);
  45774. $subPath = str_replace('\\', DIRECTORY_SEPARATOR, $namespace)
  45775. . str_replace('_', DIRECTORY_SEPARATOR, $className);
  45776. } else {
  45777. $subPath = str_replace('_', DIRECTORY_SEPARATOR, $class);
  45778. }
  45779. } elseif ('psr-4' === $namespaceType) {
  45780. $subNamespace = ('' !== $baseNamespace) ? substr($class, strlen($baseNamespace)) : $class;
  45781. $subPath = str_replace('\\', DIRECTORY_SEPARATOR, $subNamespace);
  45782. } else {
  45783. throw new \InvalidArgumentException('$namespaceType must be "psr-0" or "psr-4"');
  45784. }
  45785. if ($subPath === $realSubPath) {
  45786. $validClasses[] = $class;
  45787. } else {
  45788. $rejectedClasses[] = $class;
  45789. }
  45790. }
  45791. if (\count($validClasses) === 0) {
  45792. foreach ($rejectedClasses as $class) {
  45793. $this->classMap->addPsrViolation("Class $class located in ".Preg::replace('{^'.preg_quote(self::getCwd()).'}', '.', $filePath, 1)." does not comply with $namespaceType autoloading standard. Skipping.");
  45794. }
  45795. return [];
  45796. }
  45797. return $validClasses;
  45798. }
  45799. private static function isAbsolutePath(string $path)
  45800. {
  45801. return strpos($path, '/') === 0 || substr($path, 1, 1) === ':' || strpos($path, '\\\\') === 0;
  45802. }
  45803. private static function normalizePath(string $path)
  45804. {
  45805. $parts = [];
  45806. $path = strtr($path, '\\', '/');
  45807. $prefix = '';
  45808. $absolute = '';
  45809. if (strpos($path, '//') === 0 && \strlen($path) > 2) {
  45810. $absolute = '//';
  45811. $path = substr($path, 2);
  45812. }
  45813. if (Preg::isMatchStrictGroups('{^( [0-9a-z]{2,}+: (?: // (?: [a-z]: )? )? | [a-z]: )}ix', $path, $match)) {
  45814. $prefix = $match[1];
  45815. $path = substr($path, \strlen($prefix));
  45816. }
  45817. if (strpos($path, '/') === 0) {
  45818. $absolute = '/';
  45819. $path = substr($path, 1);
  45820. }
  45821. $up = false;
  45822. foreach (explode('/', $path) as $chunk) {
  45823. if ('..' === $chunk && (\strlen($absolute) > 0 || $up)) {
  45824. array_pop($parts);
  45825. $up = !(\count($parts) === 0 || '..' === end($parts));
  45826. } elseif ('.' !== $chunk && '' !== $chunk) {
  45827. $parts[] = $chunk;
  45828. $up = '..' !== $chunk;
  45829. }
  45830. }
  45831. $prefix = Preg::replaceCallback('{(?:^|://)[a-z]:$}i', function (array $m) { return strtoupper((string) $m[0]); }, $prefix);
  45832. return $prefix.$absolute.implode('/', $parts);
  45833. }
  45834. private static function getCwd(): string
  45835. {
  45836. $cwd = getcwd();
  45837. if (false === $cwd) {
  45838. throw new \RuntimeException('Could not determine the current working directory');
  45839. }
  45840. return $cwd;
  45841. }
  45842. }
  45843. <?php declare(strict_types=1);
  45844. namespace Composer\ClassMapGenerator;
  45845. class FileList
  45846. {
  45847. public $files = [];
  45848. public function add(string $path): void
  45849. {
  45850. $this->files[$path] = true;
  45851. }
  45852. public function contains(string $path): bool
  45853. {
  45854. return isset($this->files[$path]);
  45855. }
  45856. }
  45857. <?php declare(strict_types=1);
  45858. namespace Composer\ClassMapGenerator;
  45859. use Composer\Pcre\Preg;
  45860. class PhpFileCleaner
  45861. {
  45862. private static $typeConfig;
  45863. private static $restPattern;
  45864. private $contents;
  45865. private $len;
  45866. private $maxMatches;
  45867. private $index = 0;
  45868. public static function setTypeConfig(array $types): void
  45869. {
  45870. foreach ($types as $type) {
  45871. self::$typeConfig[$type[0]] = array(
  45872. 'name' => $type,
  45873. 'length' => \strlen($type),
  45874. 'pattern' => '{.\b(?<![\$:>])'.$type.'\s++[a-zA-Z_\x7f-\xff:][a-zA-Z0-9_\x7f-\xff:\-]*+}Ais',
  45875. );
  45876. }
  45877. self::$restPattern = '{[^?"\'</'.implode('', array_keys(self::$typeConfig)).']+}A';
  45878. }
  45879. public function __construct(string $contents, int $maxMatches)
  45880. {
  45881. $this->contents = $contents;
  45882. $this->len = \strlen($this->contents);
  45883. $this->maxMatches = $maxMatches;
  45884. }
  45885. public function clean(): string
  45886. {
  45887. $clean = '';
  45888. while ($this->index < $this->len) {
  45889. $this->skipToPhp();
  45890. $clean .= '<?';
  45891. while ($this->index < $this->len) {
  45892. $char = $this->contents[$this->index];
  45893. if ($char === '?' && $this->peek('>')) {
  45894. $clean .= '?>';
  45895. $this->index += 2;
  45896. continue 2;
  45897. }
  45898. if ($char === '"') {
  45899. $this->skipString('"');
  45900. $clean .= 'null';
  45901. continue;
  45902. }
  45903. if ($char === "'") {
  45904. $this->skipString("'");
  45905. $clean .= 'null';
  45906. continue;
  45907. }
  45908. 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)) {
  45909. $this->index += \strlen($match[0]);
  45910. $this->skipHeredoc($match[2]);
  45911. $clean .= 'null';
  45912. continue;
  45913. }
  45914. if ($char === '/') {
  45915. if ($this->peek('/')) {
  45916. $this->skipToNewline();
  45917. continue;
  45918. }
  45919. if ($this->peek('*')) {
  45920. $this->skipComment();
  45921. continue;
  45922. }
  45923. }
  45924. if ($this->maxMatches === 1 && isset(self::$typeConfig[$char])) {
  45925. $type = self::$typeConfig[$char];
  45926. if (
  45927. \substr($this->contents, $this->index, $type['length']) === $type['name']
  45928. && Preg::isMatch($type['pattern'], $this->contents, $match, 0, $this->index - 1)
  45929. ) {
  45930. $clean .= $match[0];
  45931. return $clean;
  45932. }
  45933. }
  45934. $this->index += 1;
  45935. if ($this->match(self::$restPattern, $match)) {
  45936. $clean .= $char . $match[0];
  45937. $this->index += \strlen($match[0]);
  45938. } else {
  45939. $clean .= $char;
  45940. }
  45941. }
  45942. }
  45943. return $clean;
  45944. }
  45945. private function skipToPhp(): void
  45946. {
  45947. while ($this->index < $this->len) {
  45948. if ($this->contents[$this->index] === '<' && $this->peek('?')) {
  45949. $this->index += 2;
  45950. break;
  45951. }
  45952. $this->index += 1;
  45953. }
  45954. }
  45955. private function skipString(string $delimiter): void
  45956. {
  45957. $this->index += 1;
  45958. while ($this->index < $this->len) {
  45959. if ($this->contents[$this->index] === '\\' && ($this->peek('\\') || $this->peek($delimiter))) {
  45960. $this->index += 2;
  45961. continue;
  45962. }
  45963. if ($this->contents[$this->index] === $delimiter) {
  45964. $this->index += 1;
  45965. break;
  45966. }
  45967. $this->index += 1;
  45968. }
  45969. }
  45970. private function skipComment(): void
  45971. {
  45972. $this->index += 2;
  45973. while ($this->index < $this->len) {
  45974. if ($this->contents[$this->index] === '*' && $this->peek('/')) {
  45975. $this->index += 2;
  45976. break;
  45977. }
  45978. $this->index += 1;
  45979. }
  45980. }
  45981. private function skipToNewline(): void
  45982. {
  45983. while ($this->index < $this->len) {
  45984. if ($this->contents[$this->index] === "\r" || $this->contents[$this->index] === "\n") {
  45985. return;
  45986. }
  45987. $this->index += 1;
  45988. }
  45989. }
  45990. private function skipHeredoc(string $delimiter): void
  45991. {
  45992. $firstDelimiterChar = $delimiter[0];
  45993. $delimiterLength = \strlen($delimiter);
  45994. $delimiterPattern = '{'.preg_quote($delimiter).'(?![a-zA-Z0-9_\x80-\xff])}A';
  45995. while ($this->index < $this->len) {
  45996. switch ($this->contents[$this->index]) {
  45997. case "\t":
  45998. case " ":
  45999. $this->index += 1;
  46000. continue 2;
  46001. case $firstDelimiterChar:
  46002. if (
  46003. \substr($this->contents, $this->index, $delimiterLength) === $delimiter
  46004. && $this->match($delimiterPattern)
  46005. ) {
  46006. $this->index += $delimiterLength;
  46007. return;
  46008. }
  46009. break;
  46010. }
  46011. while ($this->index < $this->len) {
  46012. $this->skipToNewline();
  46013. while ($this->index < $this->len && ($this->contents[$this->index] === "\r" || $this->contents[$this->index] === "\n")) {
  46014. $this->index += 1;
  46015. }
  46016. break;
  46017. }
  46018. }
  46019. }
  46020. private function peek(string $char): bool
  46021. {
  46022. return $this->index + 1 < $this->len && $this->contents[$this->index + 1] === $char;
  46023. }
  46024. private function match(string $regex, array &$match = null): bool
  46025. {
  46026. return Preg::isMatch($regex, $this->contents, $match, 0, $this->index);
  46027. }
  46028. }
  46029. <?php declare(strict_types=1);
  46030. namespace Composer\ClassMapGenerator;
  46031. use Composer\Pcre\Preg;
  46032. class PhpFileParser
  46033. {
  46034. public static function findClasses(string $path): array
  46035. {
  46036. $extraTypes = self::getExtraTypes();
  46037. $contents = @php_strip_whitespace($path);
  46038. if ('' === $contents) {
  46039. if (!file_exists($path)) {
  46040. $message = 'File at "%s" does not exist, check your classmap definitions';
  46041. } elseif (!self::isReadable($path)) {
  46042. $message = 'File at "%s" is not readable, check its permissions';
  46043. } elseif ('' === trim((string) file_get_contents($path))) {
  46044. return array();
  46045. } else {
  46046. $message = 'File at "%s" could not be parsed as PHP, it may be binary or corrupted';
  46047. }
  46048. $error = error_get_last();
  46049. if (isset($error['message'])) {
  46050. $message .= PHP_EOL . 'The following message may be helpful:' . PHP_EOL . $error['message'];
  46051. }
  46052. throw new \RuntimeException(sprintf($message, $path));
  46053. }
  46054. Preg::matchAllStrictGroups('{\b(?:class|interface|trait'.$extraTypes.')\s}i', $contents, $matches);
  46055. if (0 === \count($matches)) {
  46056. return array();
  46057. }
  46058. $p = new PhpFileCleaner($contents, count($matches[0]));
  46059. $contents = $p->clean();
  46060. unset($p);
  46061. Preg::matchAll('{
  46062. (?:
  46063. \b(?<![\$:>])(?P<type>class|interface|trait'.$extraTypes.') \s++ (?P<name>[a-zA-Z_\x7f-\xff:][a-zA-Z0-9_\x7f-\xff:\-]*+)
  46064. | \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*+ [\{;]
  46065. )
  46066. }ix', $contents, $matches);
  46067. $classes = array();
  46068. $namespace = '';
  46069. for ($i = 0, $len = count($matches['type']); $i < $len; $i++) {
  46070. if (isset($matches['ns'][$i]) && $matches['ns'][$i] !== '') {
  46071. $namespace = str_replace(array(' ', "\t", "\r", "\n"), '', (string) $matches['nsname'][$i]) . '\\';
  46072. } else {
  46073. $name = $matches['name'][$i];
  46074. assert(is_string($name));
  46075. if ($name === 'extends' || $name === 'implements') {
  46076. continue;
  46077. }
  46078. if ($name[0] === ':') {
  46079. $name = 'xhp'.substr(str_replace(array('-', ':'), array('_', '__'), $name), 1);
  46080. } elseif (strtolower((string) $matches['type'][$i]) === 'enum') {
  46081. $colonPos = strrpos($name, ':');
  46082. if (false !== $colonPos) {
  46083. $name = substr($name, 0, $colonPos);
  46084. }
  46085. }
  46086. $classes[] = ltrim($namespace . $name, '\\');
  46087. }
  46088. }
  46089. return $classes;
  46090. }
  46091. private static function getExtraTypes(): string
  46092. {
  46093. static $extraTypes = null;
  46094. if (null === $extraTypes) {
  46095. $extraTypes = '';
  46096. if (PHP_VERSION_ID >= 80100 || (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '3.3', '>='))) {
  46097. $extraTypes .= '|enum';
  46098. }
  46099. PhpFileCleaner::setTypeConfig(array_merge(['class', 'interface', 'trait'], array_filter(explode('|', $extraTypes))));
  46100. }
  46101. return $extraTypes;
  46102. }
  46103. private static function isReadable(string $path)
  46104. {
  46105. if (is_readable($path)) {
  46106. return true;
  46107. }
  46108. if (is_file($path)) {
  46109. return false !== @file_get_contents($path, false, null, 0, 1);
  46110. }
  46111. return false;
  46112. }
  46113. }
  46114. <?php return array(
  46115. 'root' => array(
  46116. 'name' => 'composer/composer',
  46117. 'pretty_version' => '2.6.6',
  46118. 'version' => '2.6.6.0',
  46119. 'reference' => '683557bd2466072777309d039534bb1332d0dda5',
  46120. 'type' => 'library',
  46121. 'install_path' => __DIR__ . '/../../',
  46122. 'aliases' => array(),
  46123. 'dev' => false,
  46124. ),
  46125. 'versions' => array(
  46126. 'composer/ca-bundle' => array(
  46127. 'pretty_version' => '1.3.7',
  46128. 'version' => '1.3.7.0',
  46129. 'reference' => '76e46335014860eec1aa5a724799a00a2e47cc85',
  46130. 'type' => 'library',
  46131. 'install_path' => __DIR__ . '/./ca-bundle',
  46132. 'aliases' => array(),
  46133. 'dev_requirement' => false,
  46134. ),
  46135. 'composer/class-map-generator' => array(
  46136. 'pretty_version' => '1.1.0',
  46137. 'version' => '1.1.0.0',
  46138. 'reference' => '953cc4ea32e0c31f2185549c7d216d7921f03da9',
  46139. 'type' => 'library',
  46140. 'install_path' => __DIR__ . '/./class-map-generator',
  46141. 'aliases' => array(),
  46142. 'dev_requirement' => false,
  46143. ),
  46144. 'composer/composer' => array(
  46145. 'pretty_version' => '2.6.6',
  46146. 'version' => '2.6.6.0',
  46147. 'reference' => '683557bd2466072777309d039534bb1332d0dda5',
  46148. 'type' => 'library',
  46149. 'install_path' => __DIR__ . '/../../',
  46150. 'aliases' => array(),
  46151. 'dev_requirement' => false,
  46152. ),
  46153. 'composer/metadata-minifier' => array(
  46154. 'pretty_version' => '1.0.0',
  46155. 'version' => '1.0.0.0',
  46156. 'reference' => 'c549d23829536f0d0e984aaabbf02af91f443207',
  46157. 'type' => 'library',
  46158. 'install_path' => __DIR__ . '/./metadata-minifier',
  46159. 'aliases' => array(),
  46160. 'dev_requirement' => false,
  46161. ),
  46162. 'composer/pcre' => array(
  46163. 'pretty_version' => '2.1.1',
  46164. 'version' => '2.1.1.0',
  46165. 'reference' => 'b439557066cd445732fa57cbc8d905394b4db8a0',
  46166. 'type' => 'library',
  46167. 'install_path' => __DIR__ . '/./pcre',
  46168. 'aliases' => array(),
  46169. 'dev_requirement' => false,
  46170. ),
  46171. 'composer/semver' => array(
  46172. 'pretty_version' => '3.4.0',
  46173. 'version' => '3.4.0.0',
  46174. 'reference' => '35e8d0af4486141bc745f23a29cc2091eb624a32',
  46175. 'type' => 'library',
  46176. 'install_path' => __DIR__ . '/./semver',
  46177. 'aliases' => array(),
  46178. 'dev_requirement' => false,
  46179. ),
  46180. 'composer/spdx-licenses' => array(
  46181. 'pretty_version' => '1.5.7',
  46182. 'version' => '1.5.7.0',
  46183. 'reference' => 'c848241796da2abf65837d51dce1fae55a960149',
  46184. 'type' => 'library',
  46185. 'install_path' => __DIR__ . '/./spdx-licenses',
  46186. 'aliases' => array(),
  46187. 'dev_requirement' => false,
  46188. ),
  46189. 'composer/xdebug-handler' => array(
  46190. 'pretty_version' => '3.0.3',
  46191. 'version' => '3.0.3.0',
  46192. 'reference' => 'ced299686f41dce890debac69273b47ffe98a40c',
  46193. 'type' => 'library',
  46194. 'install_path' => __DIR__ . '/./xdebug-handler',
  46195. 'aliases' => array(),
  46196. 'dev_requirement' => false,
  46197. ),
  46198. 'justinrainbow/json-schema' => array(
  46199. 'pretty_version' => 'v5.2.13',
  46200. 'version' => '5.2.13.0',
  46201. 'reference' => 'fbbe7e5d79f618997bc3332a6f49246036c45793',
  46202. 'type' => 'library',
  46203. 'install_path' => __DIR__ . '/../justinrainbow/json-schema',
  46204. 'aliases' => array(),
  46205. 'dev_requirement' => false,
  46206. ),
  46207. 'psr/container' => array(
  46208. 'pretty_version' => '1.1.1',
  46209. 'version' => '1.1.1.0',
  46210. 'reference' => '8622567409010282b7aeebe4bb841fe98b58dcaf',
  46211. 'type' => 'library',
  46212. 'install_path' => __DIR__ . '/../psr/container',
  46213. 'aliases' => array(),
  46214. 'dev_requirement' => false,
  46215. ),
  46216. 'psr/log' => array(
  46217. 'pretty_version' => '1.1.4',
  46218. 'version' => '1.1.4.0',
  46219. 'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11',
  46220. 'type' => 'library',
  46221. 'install_path' => __DIR__ . '/../psr/log',
  46222. 'aliases' => array(),
  46223. 'dev_requirement' => false,
  46224. ),
  46225. 'psr/log-implementation' => array(
  46226. 'dev_requirement' => false,
  46227. 'provided' => array(
  46228. 0 => '1.0|2.0',
  46229. ),
  46230. ),
  46231. 'react/promise' => array(
  46232. 'pretty_version' => 'v3.0.0',
  46233. 'version' => '3.0.0.0',
  46234. 'reference' => 'c86753c76fd3be465d93b308f18d189f01a22be4',
  46235. 'type' => 'library',
  46236. 'install_path' => __DIR__ . '/../react/promise',
  46237. 'aliases' => array(),
  46238. 'dev_requirement' => false,
  46239. ),
  46240. 'seld/jsonlint' => array(
  46241. 'pretty_version' => '1.10.0',
  46242. 'version' => '1.10.0.0',
  46243. 'reference' => '594fd6462aad8ecee0b45ca5045acea4776667f1',
  46244. 'type' => 'library',
  46245. 'install_path' => __DIR__ . '/../seld/jsonlint',
  46246. 'aliases' => array(),
  46247. 'dev_requirement' => false,
  46248. ),
  46249. 'seld/phar-utils' => array(
  46250. 'pretty_version' => '1.2.1',
  46251. 'version' => '1.2.1.0',
  46252. 'reference' => 'ea2f4014f163c1be4c601b9b7bd6af81ba8d701c',
  46253. 'type' => 'library',
  46254. 'install_path' => __DIR__ . '/../seld/phar-utils',
  46255. 'aliases' => array(),
  46256. 'dev_requirement' => false,
  46257. ),
  46258. 'seld/signal-handler' => array(
  46259. 'pretty_version' => '2.0.2',
  46260. 'version' => '2.0.2.0',
  46261. 'reference' => '04a6112e883ad76c0ada8e4a9f7520bbfdb6bb98',
  46262. 'type' => 'library',
  46263. 'install_path' => __DIR__ . '/../seld/signal-handler',
  46264. 'aliases' => array(),
  46265. 'dev_requirement' => false,
  46266. ),
  46267. 'symfony/console' => array(
  46268. 'pretty_version' => 'v5.4.28',
  46269. 'version' => '5.4.28.0',
  46270. 'reference' => 'f4f71842f24c2023b91237c72a365306f3c58827',
  46271. 'type' => 'library',
  46272. 'install_path' => __DIR__ . '/../symfony/console',
  46273. 'aliases' => array(),
  46274. 'dev_requirement' => false,
  46275. ),
  46276. 'symfony/deprecation-contracts' => array(
  46277. 'pretty_version' => 'v2.5.2',
  46278. 'version' => '2.5.2.0',
  46279. 'reference' => 'e8b495ea28c1d97b5e0c121748d6f9b53d075c66',
  46280. 'type' => 'library',
  46281. 'install_path' => __DIR__ . '/../symfony/deprecation-contracts',
  46282. 'aliases' => array(),
  46283. 'dev_requirement' => false,
  46284. ),
  46285. 'symfony/filesystem' => array(
  46286. 'pretty_version' => 'v5.4.25',
  46287. 'version' => '5.4.25.0',
  46288. 'reference' => '0ce3a62c9579a53358d3a7eb6b3dfb79789a6364',
  46289. 'type' => 'library',
  46290. 'install_path' => __DIR__ . '/../symfony/filesystem',
  46291. 'aliases' => array(),
  46292. 'dev_requirement' => false,
  46293. ),
  46294. 'symfony/finder' => array(
  46295. 'pretty_version' => 'v5.4.27',
  46296. 'version' => '5.4.27.0',
  46297. 'reference' => 'ff4bce3c33451e7ec778070e45bd23f74214cd5d',
  46298. 'type' => 'library',
  46299. 'install_path' => __DIR__ . '/../symfony/finder',
  46300. 'aliases' => array(),
  46301. 'dev_requirement' => false,
  46302. ),
  46303. 'symfony/polyfill-ctype' => array(
  46304. 'pretty_version' => 'v1.28.0',
  46305. 'version' => '1.28.0.0',
  46306. 'reference' => 'ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb',
  46307. 'type' => 'library',
  46308. 'install_path' => __DIR__ . '/../symfony/polyfill-ctype',
  46309. 'aliases' => array(),
  46310. 'dev_requirement' => false,
  46311. ),
  46312. 'symfony/polyfill-intl-grapheme' => array(
  46313. 'pretty_version' => 'v1.28.0',
  46314. 'version' => '1.28.0.0',
  46315. 'reference' => '875e90aeea2777b6f135677f618529449334a612',
  46316. 'type' => 'library',
  46317. 'install_path' => __DIR__ . '/../symfony/polyfill-intl-grapheme',
  46318. 'aliases' => array(),
  46319. 'dev_requirement' => false,
  46320. ),
  46321. 'symfony/polyfill-intl-normalizer' => array(
  46322. 'pretty_version' => 'v1.28.0',
  46323. 'version' => '1.28.0.0',
  46324. 'reference' => '8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92',
  46325. 'type' => 'library',
  46326. 'install_path' => __DIR__ . '/../symfony/polyfill-intl-normalizer',
  46327. 'aliases' => array(),
  46328. 'dev_requirement' => false,
  46329. ),
  46330. 'symfony/polyfill-mbstring' => array(
  46331. 'pretty_version' => 'v1.28.0',
  46332. 'version' => '1.28.0.0',
  46333. 'reference' => '42292d99c55abe617799667f454222c54c60e229',
  46334. 'type' => 'library',
  46335. 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring',
  46336. 'aliases' => array(),
  46337. 'dev_requirement' => false,
  46338. ),
  46339. 'symfony/polyfill-php73' => array(
  46340. 'pretty_version' => 'v1.28.0',
  46341. 'version' => '1.28.0.0',
  46342. 'reference' => 'fe2f306d1d9d346a7fee353d0d5012e401e984b5',
  46343. 'type' => 'library',
  46344. 'install_path' => __DIR__ . '/../symfony/polyfill-php73',
  46345. 'aliases' => array(),
  46346. 'dev_requirement' => false,
  46347. ),
  46348. 'symfony/polyfill-php80' => array(
  46349. 'pretty_version' => 'v1.28.0',
  46350. 'version' => '1.28.0.0',
  46351. 'reference' => '6caa57379c4aec19c0a12a38b59b26487dcfe4b5',
  46352. 'type' => 'library',
  46353. 'install_path' => __DIR__ . '/../symfony/polyfill-php80',
  46354. 'aliases' => array(),
  46355. 'dev_requirement' => false,
  46356. ),
  46357. 'symfony/polyfill-php81' => array(
  46358. 'pretty_version' => 'v1.28.0',
  46359. 'version' => '1.28.0.0',
  46360. 'reference' => '7581cd600fa9fd681b797d00b02f068e2f13263b',
  46361. 'type' => 'library',
  46362. 'install_path' => __DIR__ . '/../symfony/polyfill-php81',
  46363. 'aliases' => array(),
  46364. 'dev_requirement' => false,
  46365. ),
  46366. 'symfony/process' => array(
  46367. 'pretty_version' => 'v5.4.28',
  46368. 'version' => '5.4.28.0',
  46369. 'reference' => '45261e1fccad1b5447a8d7a8e67aa7b4a9798b7b',
  46370. 'type' => 'library',
  46371. 'install_path' => __DIR__ . '/../symfony/process',
  46372. 'aliases' => array(),
  46373. 'dev_requirement' => false,
  46374. ),
  46375. 'symfony/service-contracts' => array(
  46376. 'pretty_version' => 'v2.5.2',
  46377. 'version' => '2.5.2.0',
  46378. 'reference' => '4b426aac47d6427cc1a1d0f7e2ac724627f5966c',
  46379. 'type' => 'library',
  46380. 'install_path' => __DIR__ . '/../symfony/service-contracts',
  46381. 'aliases' => array(),
  46382. 'dev_requirement' => false,
  46383. ),
  46384. 'symfony/string' => array(
  46385. 'pretty_version' => 'v5.4.29',
  46386. 'version' => '5.4.29.0',
  46387. 'reference' => 'e41bdc93def20eaf3bfc1537c4e0a2b0680a152d',
  46388. 'type' => 'library',
  46389. 'install_path' => __DIR__ . '/../symfony/string',
  46390. 'aliases' => array(),
  46391. 'dev_requirement' => false,
  46392. ),
  46393. ),
  46394. );
  46395. Copyright (C) 2021 Composer
  46396. Permission is hereby granted, free of charge, to any person obtaining a copy of
  46397. this software and associated documentation files (the "Software"), to deal in
  46398. the Software without restriction, including without limitation the rights to
  46399. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  46400. of the Software, and to permit persons to whom the Software is furnished to do
  46401. so, subject to the following conditions:
  46402. The above copyright notice and this permission notice shall be included in all
  46403. copies or substantial portions of the Software.
  46404. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  46405. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  46406. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  46407. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  46408. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  46409. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  46410. SOFTWARE.
  46411. <?php
  46412. namespace Composer\MetadataMinifier;
  46413. class MetadataMinifier
  46414. {
  46415. public static function expand(array $versions)
  46416. {
  46417. $expanded = array();
  46418. $expandedVersion = null;
  46419. foreach ($versions as $versionData) {
  46420. if (!$expandedVersion) {
  46421. $expandedVersion = $versionData;
  46422. $expanded[] = $expandedVersion;
  46423. continue;
  46424. }
  46425. foreach ($versionData as $key => $val) {
  46426. if ($val === '__unset') {
  46427. unset($expandedVersion[$key]);
  46428. } else {
  46429. $expandedVersion[$key] = $val;
  46430. }
  46431. }
  46432. $expanded[] = $expandedVersion;
  46433. }
  46434. return $expanded;
  46435. }
  46436. public static function minify(array $versions)
  46437. {
  46438. $minifiedVersions = array();
  46439. $lastKnownVersionData = null;
  46440. foreach ($versions as $version) {
  46441. if (!$lastKnownVersionData) {
  46442. $lastKnownVersionData = $version;
  46443. $minifiedVersions[] = $version;
  46444. continue;
  46445. }
  46446. $minifiedVersion = array();
  46447. foreach ($version as $key => $val) {
  46448. if (!isset($lastKnownVersionData[$key]) || $lastKnownVersionData[$key] !== $val) {
  46449. $minifiedVersion[$key] = $val;
  46450. $lastKnownVersionData[$key] = $val;
  46451. }
  46452. }
  46453. foreach ($lastKnownVersionData as $key => $val) {
  46454. if (!isset($version[$key])) {
  46455. $minifiedVersion[$key] = "__unset";
  46456. unset($lastKnownVersionData[$key]);
  46457. }
  46458. }
  46459. $minifiedVersions[] = $minifiedVersion;
  46460. }
  46461. return $minifiedVersions;
  46462. }
  46463. }
  46464. Copyright (C) 2021 Composer
  46465. Permission is hereby granted, free of charge, to any person obtaining a copy of
  46466. this software and associated documentation files (the "Software"), to deal in
  46467. the Software without restriction, including without limitation the rights to
  46468. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  46469. of the Software, and to permit persons to whom the Software is furnished to do
  46470. so, subject to the following conditions:
  46471. The above copyright notice and this permission notice shall be included in all
  46472. copies or substantial portions of the Software.
  46473. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  46474. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  46475. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  46476. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  46477. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  46478. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  46479. SOFTWARE.
  46480. <?php
  46481. namespace Composer\Pcre;
  46482. final class MatchAllResult
  46483. {
  46484. public $matches;
  46485. public $count;
  46486. public $matched;
  46487. public function __construct(int $count, array $matches)
  46488. {
  46489. $this->matches = $matches;
  46490. $this->matched = (bool) $count;
  46491. $this->count = $count;
  46492. }
  46493. }
  46494. <?php
  46495. namespace Composer\Pcre;
  46496. final class MatchAllStrictGroupsResult
  46497. {
  46498. public $matches;
  46499. public $count;
  46500. public $matched;
  46501. public function __construct(int $count, array $matches)
  46502. {
  46503. $this->matches = $matches;
  46504. $this->matched = (bool) $count;
  46505. $this->count = $count;
  46506. }
  46507. }
  46508. <?php
  46509. namespace Composer\Pcre;
  46510. final class MatchAllWithOffsetsResult
  46511. {
  46512. public $matches;
  46513. public $count;
  46514. public $matched;
  46515. public function __construct(int $count, array $matches)
  46516. {
  46517. $this->matches = $matches;
  46518. $this->matched = (bool) $count;
  46519. $this->count = $count;
  46520. }
  46521. }
  46522. <?php
  46523. namespace Composer\Pcre;
  46524. final class MatchResult
  46525. {
  46526. public $matches;
  46527. public $matched;
  46528. public function __construct(int $count, array $matches)
  46529. {
  46530. $this->matches = $matches;
  46531. $this->matched = (bool) $count;
  46532. }
  46533. }
  46534. <?php
  46535. namespace Composer\Pcre;
  46536. final class MatchStrictGroupsResult
  46537. {
  46538. public $matches;
  46539. public $matched;
  46540. public function __construct(int $count, array $matches)
  46541. {
  46542. $this->matches = $matches;
  46543. $this->matched = (bool) $count;
  46544. }
  46545. }
  46546. <?php
  46547. namespace Composer\Pcre;
  46548. final class MatchWithOffsetsResult
  46549. {
  46550. public $matches;
  46551. public $matched;
  46552. public function __construct(int $count, array $matches)
  46553. {
  46554. $this->matches = $matches;
  46555. $this->matched = (bool) $count;
  46556. }
  46557. }
  46558. <?php
  46559. namespace Composer\Pcre;
  46560. class PcreException extends \RuntimeException
  46561. {
  46562. public static function fromFunction($function, $pattern)
  46563. {
  46564. $code = preg_last_error();
  46565. if (is_array($pattern)) {
  46566. $pattern = implode(', ', $pattern);
  46567. }
  46568. return new PcreException($function.'(): failed executing "'.$pattern.'": '.self::pcreLastErrorMessage($code), $code);
  46569. }
  46570. private static function pcreLastErrorMessage($code)
  46571. {
  46572. if (function_exists('preg_last_error_msg')) {
  46573. return preg_last_error_msg();
  46574. }
  46575. if (PHP_VERSION_ID < 70201 && $code === 0) {
  46576. return 'UNDEFINED_ERROR';
  46577. }
  46578. $constants = get_defined_constants(true);
  46579. if (!isset($constants['pcre'])) {
  46580. return 'UNDEFINED_ERROR';
  46581. }
  46582. foreach ($constants['pcre'] as $const => $val) {
  46583. if ($val === $code && substr($const, -6) === '_ERROR') {
  46584. return $const;
  46585. }
  46586. }
  46587. return 'UNDEFINED_ERROR';
  46588. }
  46589. }
  46590. <?php
  46591. namespace Composer\Pcre;
  46592. class Preg
  46593. {
  46594. public const ARRAY_MSG = '$subject as an array is not supported. You can use \'foreach\' instead.';
  46595. public const INVALID_TYPE_MSG = '$subject must be a string, %s given.';
  46596. public static function match(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int
  46597. {
  46598. self::checkOffsetCapture($flags, 'matchWithOffsets');
  46599. $result = self::pregMatch($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL, $offset);
  46600. if ($result === false) {
  46601. throw PcreException::fromFunction('preg_match', $pattern);
  46602. }
  46603. return $result;
  46604. }
  46605. public static function matchStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int
  46606. {
  46607. $result = self::match($pattern, $subject, $matchesInternal, $flags, $offset);
  46608. $matches = self::enforceNonNullMatches($pattern, $matchesInternal, 'match');
  46609. return $result;
  46610. }
  46611. public static function matchWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): int
  46612. {
  46613. $result = self::pregMatch($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL | PREG_OFFSET_CAPTURE, $offset);
  46614. if ($result === false) {
  46615. throw PcreException::fromFunction('preg_match', $pattern);
  46616. }
  46617. return $result;
  46618. }
  46619. public static function matchAll(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int
  46620. {
  46621. self::checkOffsetCapture($flags, 'matchAllWithOffsets');
  46622. self::checkSetOrder($flags);
  46623. $result = preg_match_all($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL, $offset);
  46624. if (!is_int($result)) {
  46625. throw PcreException::fromFunction('preg_match_all', $pattern);
  46626. }
  46627. return $result;
  46628. }
  46629. public static function matchAllStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int
  46630. {
  46631. $result = self::matchAll($pattern, $subject, $matchesInternal, $flags, $offset);
  46632. $matches = self::enforceNonNullMatchAll($pattern, $matchesInternal, 'matchAll');
  46633. return $result;
  46634. }
  46635. public static function matchAllWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): int
  46636. {
  46637. self::checkSetOrder($flags);
  46638. $result = preg_match_all($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL | PREG_OFFSET_CAPTURE, $offset);
  46639. if (!is_int($result)) {
  46640. throw PcreException::fromFunction('preg_match_all', $pattern);
  46641. }
  46642. return $result;
  46643. }
  46644. public static function replace($pattern, $replacement, $subject, int $limit = -1, int &$count = null): string
  46645. {
  46646. if (!is_scalar($subject)) {
  46647. if (is_array($subject)) {
  46648. throw new \InvalidArgumentException(static::ARRAY_MSG);
  46649. }
  46650. throw new \TypeError(sprintf(static::INVALID_TYPE_MSG, gettype($subject)));
  46651. }
  46652. $result = preg_replace($pattern, $replacement, $subject, $limit, $count);
  46653. if ($result === null) {
  46654. throw PcreException::fromFunction('preg_replace', $pattern);
  46655. }
  46656. return $result;
  46657. }
  46658. public static function replaceCallback($pattern, callable $replacement, $subject, int $limit = -1, int &$count = null, int $flags = 0): string
  46659. {
  46660. if (!is_scalar($subject)) {
  46661. if (is_array($subject)) {
  46662. throw new \InvalidArgumentException(static::ARRAY_MSG);
  46663. }
  46664. throw new \TypeError(sprintf(static::INVALID_TYPE_MSG, gettype($subject)));
  46665. }
  46666. if (PHP_VERSION_ID >= 70400) {
  46667. $result = preg_replace_callback($pattern, $replacement, $subject, $limit, $count, $flags);
  46668. } else {
  46669. $result = preg_replace_callback($pattern, $replacement, $subject, $limit, $count);
  46670. }
  46671. if ($result === null) {
  46672. throw PcreException::fromFunction('preg_replace_callback', $pattern);
  46673. }
  46674. return $result;
  46675. }
  46676. public static function replaceCallbackArray(array $pattern, $subject, int $limit = -1, int &$count = null, int $flags = 0): string
  46677. {
  46678. if (!is_scalar($subject)) {
  46679. if (is_array($subject)) {
  46680. throw new \InvalidArgumentException(static::ARRAY_MSG);
  46681. }
  46682. throw new \TypeError(sprintf(static::INVALID_TYPE_MSG, gettype($subject)));
  46683. }
  46684. if (PHP_VERSION_ID >= 70400) {
  46685. $result = preg_replace_callback_array($pattern, $subject, $limit, $count, $flags);
  46686. } else {
  46687. $result = preg_replace_callback_array($pattern, $subject, $limit, $count);
  46688. }
  46689. if ($result === null) {
  46690. $pattern = array_keys($pattern);
  46691. throw PcreException::fromFunction('preg_replace_callback_array', $pattern);
  46692. }
  46693. return $result;
  46694. }
  46695. public static function split(string $pattern, string $subject, int $limit = -1, int $flags = 0): array
  46696. {
  46697. if (($flags & PREG_SPLIT_OFFSET_CAPTURE) !== 0) {
  46698. throw new \InvalidArgumentException('PREG_SPLIT_OFFSET_CAPTURE is not supported as it changes the type of $matches, use splitWithOffsets() instead');
  46699. }
  46700. $result = preg_split($pattern, $subject, $limit, $flags);
  46701. if ($result === false) {
  46702. throw PcreException::fromFunction('preg_split', $pattern);
  46703. }
  46704. return $result;
  46705. }
  46706. public static function splitWithOffsets(string $pattern, string $subject, int $limit = -1, int $flags = 0): array
  46707. {
  46708. $result = preg_split($pattern, $subject, $limit, $flags | PREG_SPLIT_OFFSET_CAPTURE);
  46709. if ($result === false) {
  46710. throw PcreException::fromFunction('preg_split', $pattern);
  46711. }
  46712. return $result;
  46713. }
  46714. public static function grep(string $pattern, array $array, int $flags = 0): array
  46715. {
  46716. $result = preg_grep($pattern, $array, $flags);
  46717. if ($result === false) {
  46718. throw PcreException::fromFunction('preg_grep', $pattern);
  46719. }
  46720. return $result;
  46721. }
  46722. public static function isMatch(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool
  46723. {
  46724. return (bool) static::match($pattern, $subject, $matches, $flags, $offset);
  46725. }
  46726. public static function isMatchStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool
  46727. {
  46728. return (bool) self::matchStrictGroups($pattern, $subject, $matches, $flags, $offset);
  46729. }
  46730. public static function isMatchAll(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool
  46731. {
  46732. return (bool) static::matchAll($pattern, $subject, $matches, $flags, $offset);
  46733. }
  46734. public static function isMatchAllStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool
  46735. {
  46736. return (bool) self::matchAllStrictGroups($pattern, $subject, $matches, $flags, $offset);
  46737. }
  46738. public static function isMatchWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): bool
  46739. {
  46740. return (bool) static::matchWithOffsets($pattern, $subject, $matches, $flags, $offset);
  46741. }
  46742. public static function isMatchAllWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): bool
  46743. {
  46744. return (bool) static::matchAllWithOffsets($pattern, $subject, $matches, $flags, $offset);
  46745. }
  46746. private static function checkOffsetCapture(int $flags, string $useFunctionName): void
  46747. {
  46748. if (($flags & PREG_OFFSET_CAPTURE) !== 0) {
  46749. throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the type of $matches, use ' . $useFunctionName . '() instead');
  46750. }
  46751. }
  46752. private static function checkSetOrder(int $flags): void
  46753. {
  46754. if (($flags & PREG_SET_ORDER) !== 0) {
  46755. throw new \InvalidArgumentException('PREG_SET_ORDER is not supported as it changes the type of $matches');
  46756. }
  46757. }
  46758. private static function enforceNonNullMatches(string $pattern, array $matches, string $variantMethod)
  46759. {
  46760. foreach ($matches as $group => $match) {
  46761. if (null === $match) {
  46762. throw new UnexpectedNullMatchException('Pattern "'.$pattern.'" had an unexpected unmatched group "'.$group.'", make sure the pattern always matches or use '.$variantMethod.'() instead.');
  46763. }
  46764. }
  46765. return $matches;
  46766. }
  46767. private static function enforceNonNullMatchAll(string $pattern, array $matches, string $variantMethod)
  46768. {
  46769. foreach ($matches as $group => $groupMatches) {
  46770. foreach ($groupMatches as $match) {
  46771. if (null === $match) {
  46772. throw new UnexpectedNullMatchException('Pattern "'.$pattern.'" had an unexpected unmatched group "'.$group.'", make sure the pattern always matches or use '.$variantMethod.'() instead.');
  46773. }
  46774. }
  46775. }
  46776. return $matches;
  46777. }
  46778. private static function pregMatch(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0)
  46779. {
  46780. if (PHP_VERSION_ID >= 70400) {
  46781. return preg_match($pattern, $subject, $matches, $flags, $offset);
  46782. }
  46783. $result = preg_match_all($pattern, $subject, $matchesInternal, $flags, $offset);
  46784. if (!is_int($result)) {
  46785. throw PcreException::fromFunction('preg_match', $pattern);
  46786. }
  46787. if ($result === 0) {
  46788. $matches = [];
  46789. } else {
  46790. $matches = array_map(function ($m) { return reset($m); }, $matchesInternal);
  46791. $result = min($result, 1);
  46792. }
  46793. return $result;
  46794. }
  46795. }
  46796. <?php
  46797. namespace Composer\Pcre;
  46798. class Regex
  46799. {
  46800. public static function isMatch(string $pattern, string $subject, int $offset = 0): bool
  46801. {
  46802. return (bool) Preg::match($pattern, $subject, $matches, 0, $offset);
  46803. }
  46804. public static function match(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchResult
  46805. {
  46806. self::checkOffsetCapture($flags, 'matchWithOffsets');
  46807. $count = Preg::match($pattern, $subject, $matches, $flags, $offset);
  46808. return new MatchResult($count, $matches);
  46809. }
  46810. public static function matchStrictGroups(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchStrictGroupsResult
  46811. {
  46812. $count = Preg::matchStrictGroups($pattern, $subject, $matches, $flags, $offset);
  46813. return new MatchStrictGroupsResult($count, $matches);
  46814. }
  46815. public static function matchWithOffsets(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchWithOffsetsResult
  46816. {
  46817. $count = Preg::matchWithOffsets($pattern, $subject, $matches, $flags, $offset);
  46818. return new MatchWithOffsetsResult($count, $matches);
  46819. }
  46820. public static function matchAll(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchAllResult
  46821. {
  46822. self::checkOffsetCapture($flags, 'matchAllWithOffsets');
  46823. self::checkSetOrder($flags);
  46824. $count = Preg::matchAll($pattern, $subject, $matches, $flags, $offset);
  46825. return new MatchAllResult($count, $matches);
  46826. }
  46827. public static function matchAllStrictGroups(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchAllStrictGroupsResult
  46828. {
  46829. self::checkOffsetCapture($flags, 'matchAllWithOffsets');
  46830. self::checkSetOrder($flags);
  46831. $count = Preg::matchAllStrictGroups($pattern, $subject, $matches, $flags, $offset);
  46832. return new MatchAllStrictGroupsResult($count, $matches);
  46833. }
  46834. public static function matchAllWithOffsets(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchAllWithOffsetsResult
  46835. {
  46836. self::checkSetOrder($flags);
  46837. $count = Preg::matchAllWithOffsets($pattern, $subject, $matches, $flags, $offset);
  46838. return new MatchAllWithOffsetsResult($count, $matches);
  46839. }
  46840. public static function replace($pattern, $replacement, $subject, int $limit = -1): ReplaceResult
  46841. {
  46842. $result = Preg::replace($pattern, $replacement, $subject, $limit, $count);
  46843. return new ReplaceResult($count, $result);
  46844. }
  46845. public static function replaceCallback($pattern, callable $replacement, $subject, int $limit = -1, int $flags = 0): ReplaceResult
  46846. {
  46847. $result = Preg::replaceCallback($pattern, $replacement, $subject, $limit, $count, $flags);
  46848. return new ReplaceResult($count, $result);
  46849. }
  46850. public static function replaceCallbackArray(array $pattern, $subject, int $limit = -1, int $flags = 0): ReplaceResult
  46851. {
  46852. $result = Preg::replaceCallbackArray($pattern, $subject, $limit, $count, $flags);
  46853. return new ReplaceResult($count, $result);
  46854. }
  46855. private static function checkOffsetCapture(int $flags, string $useFunctionName): void
  46856. {
  46857. if (($flags & PREG_OFFSET_CAPTURE) !== 0) {
  46858. throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the return type, use '.$useFunctionName.'() instead');
  46859. }
  46860. }
  46861. private static function checkSetOrder(int $flags): void
  46862. {
  46863. if (($flags & PREG_SET_ORDER) !== 0) {
  46864. throw new \InvalidArgumentException('PREG_SET_ORDER is not supported as it changes the return type');
  46865. }
  46866. }
  46867. }
  46868. <?php
  46869. namespace Composer\Pcre;
  46870. final class ReplaceResult
  46871. {
  46872. public $result;
  46873. public $count;
  46874. public $matched;
  46875. public function __construct(int $count, string $result)
  46876. {
  46877. $this->count = $count;
  46878. $this->matched = (bool) $count;
  46879. $this->result = $result;
  46880. }
  46881. }
  46882. <?php
  46883. namespace Composer\Pcre;
  46884. class UnexpectedNullMatchException extends PcreException
  46885. {
  46886. public static function fromFunction($function, $pattern)
  46887. {
  46888. throw new \LogicException('fromFunction should not be called on '.self::class.', use '.PcreException::class);
  46889. }
  46890. }
  46891. Copyright (C) 2015 Composer
  46892. Permission is hereby granted, free of charge, to any person obtaining a copy of
  46893. this software and associated documentation files (the "Software"), to deal in
  46894. the Software without restriction, including without limitation the rights to
  46895. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  46896. of the Software, and to permit persons to whom the Software is furnished to do
  46897. so, subject to the following conditions:
  46898. The above copyright notice and this permission notice shall be included in all
  46899. copies or substantial portions of the Software.
  46900. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  46901. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  46902. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  46903. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  46904. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  46905. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  46906. SOFTWARE.
  46907. <?php
  46908. namespace Composer\Semver;
  46909. use Composer\Semver\Constraint\Constraint;
  46910. class Comparator
  46911. {
  46912. public static function greaterThan($version1, $version2)
  46913. {
  46914. return self::compare($version1, '>', $version2);
  46915. }
  46916. public static function greaterThanOrEqualTo($version1, $version2)
  46917. {
  46918. return self::compare($version1, '>=', $version2);
  46919. }
  46920. public static function lessThan($version1, $version2)
  46921. {
  46922. return self::compare($version1, '<', $version2);
  46923. }
  46924. public static function lessThanOrEqualTo($version1, $version2)
  46925. {
  46926. return self::compare($version1, '<=', $version2);
  46927. }
  46928. public static function equalTo($version1, $version2)
  46929. {
  46930. return self::compare($version1, '==', $version2);
  46931. }
  46932. public static function notEqualTo($version1, $version2)
  46933. {
  46934. return self::compare($version1, '!=', $version2);
  46935. }
  46936. public static function compare($version1, $operator, $version2)
  46937. {
  46938. $constraint = new Constraint($operator, $version2);
  46939. return $constraint->matchSpecific(new Constraint('==', $version1), true);
  46940. }
  46941. }
  46942. <?php
  46943. namespace Composer\Semver;
  46944. use Composer\Semver\Constraint\Constraint;
  46945. use Composer\Semver\Constraint\ConstraintInterface;
  46946. class CompilingMatcher
  46947. {
  46948. private static $compiledCheckerCache = array();
  46949. private static $resultCache = array();
  46950. private static $enabled;
  46951. private static $transOpInt = array(
  46952. Constraint::OP_EQ => Constraint::STR_OP_EQ,
  46953. Constraint::OP_LT => Constraint::STR_OP_LT,
  46954. Constraint::OP_LE => Constraint::STR_OP_LE,
  46955. Constraint::OP_GT => Constraint::STR_OP_GT,
  46956. Constraint::OP_GE => Constraint::STR_OP_GE,
  46957. Constraint::OP_NE => Constraint::STR_OP_NE,
  46958. );
  46959. public static function clear()
  46960. {
  46961. self::$resultCache = array();
  46962. self::$compiledCheckerCache = array();
  46963. }
  46964. public static function match(ConstraintInterface $constraint, $operator, $version)
  46965. {
  46966. $resultCacheKey = $operator.$constraint.';'.$version;
  46967. if (isset(self::$resultCache[$resultCacheKey])) {
  46968. return self::$resultCache[$resultCacheKey];
  46969. }
  46970. if (self::$enabled === null) {
  46971. self::$enabled = !\in_array('eval', explode(',', (string) ini_get('disable_functions')), true);
  46972. }
  46973. if (!self::$enabled) {
  46974. return self::$resultCache[$resultCacheKey] = $constraint->matches(new Constraint(self::$transOpInt[$operator], $version));
  46975. }
  46976. $cacheKey = $operator.$constraint;
  46977. if (!isset(self::$compiledCheckerCache[$cacheKey])) {
  46978. $code = $constraint->compile($operator);
  46979. self::$compiledCheckerCache[$cacheKey] = $function = eval('return function($v, $b){return '.$code.';};');
  46980. } else {
  46981. $function = self::$compiledCheckerCache[$cacheKey];
  46982. }
  46983. return self::$resultCache[$resultCacheKey] = $function($version, strpos($version, 'dev-') === 0);
  46984. }
  46985. }
  46986. <?php
  46987. namespace Composer\Semver\Constraint;
  46988. class Bound
  46989. {
  46990. private $version;
  46991. private $isInclusive;
  46992. public function __construct($version, $isInclusive)
  46993. {
  46994. $this->version = $version;
  46995. $this->isInclusive = $isInclusive;
  46996. }
  46997. public function getVersion()
  46998. {
  46999. return $this->version;
  47000. }
  47001. public function isInclusive()
  47002. {
  47003. return $this->isInclusive;
  47004. }
  47005. public function isZero()
  47006. {
  47007. return $this->getVersion() === '0.0.0.0-dev' && $this->isInclusive();
  47008. }
  47009. public function isPositiveInfinity()
  47010. {
  47011. return $this->getVersion() === PHP_INT_MAX.'.0.0.0' && !$this->isInclusive();
  47012. }
  47013. public function compareTo(Bound $other, $operator)
  47014. {
  47015. if (!\in_array($operator, array('<', '>'), true)) {
  47016. throw new \InvalidArgumentException('Does not support any other operator other than > or <.');
  47017. }
  47018. if ($this == $other) {
  47019. return false;
  47020. }
  47021. $compareResult = version_compare($this->getVersion(), $other->getVersion());
  47022. if (0 !== $compareResult) {
  47023. return (('>' === $operator) ? 1 : -1) === $compareResult;
  47024. }
  47025. return '>' === $operator ? $other->isInclusive() : !$other->isInclusive();
  47026. }
  47027. public function __toString()
  47028. {
  47029. return sprintf(
  47030. '%s [%s]',
  47031. $this->getVersion(),
  47032. $this->isInclusive() ? 'inclusive' : 'exclusive'
  47033. );
  47034. }
  47035. public static function zero()
  47036. {
  47037. return new Bound('0.0.0.0-dev', true);
  47038. }
  47039. public static function positiveInfinity()
  47040. {
  47041. return new Bound(PHP_INT_MAX.'.0.0.0', false);
  47042. }
  47043. }
  47044. <?php
  47045. namespace Composer\Semver\Constraint;
  47046. class Constraint implements ConstraintInterface
  47047. {
  47048. const OP_EQ = 0;
  47049. const OP_LT = 1;
  47050. const OP_LE = 2;
  47051. const OP_GT = 3;
  47052. const OP_GE = 4;
  47053. const OP_NE = 5;
  47054. const STR_OP_EQ = '==';
  47055. const STR_OP_EQ_ALT = '=';
  47056. const STR_OP_LT = '<';
  47057. const STR_OP_LE = '<=';
  47058. const STR_OP_GT = '>';
  47059. const STR_OP_GE = '>=';
  47060. const STR_OP_NE = '!=';
  47061. const STR_OP_NE_ALT = '<>';
  47062. private static $transOpStr = array(
  47063. '=' => self::OP_EQ,
  47064. '==' => self::OP_EQ,
  47065. '<' => self::OP_LT,
  47066. '<=' => self::OP_LE,
  47067. '>' => self::OP_GT,
  47068. '>=' => self::OP_GE,
  47069. '<>' => self::OP_NE,
  47070. '!=' => self::OP_NE,
  47071. );
  47072. private static $transOpInt = array(
  47073. self::OP_EQ => '==',
  47074. self::OP_LT => '<',
  47075. self::OP_LE => '<=',
  47076. self::OP_GT => '>',
  47077. self::OP_GE => '>=',
  47078. self::OP_NE => '!=',
  47079. );
  47080. protected $operator;
  47081. protected $version;
  47082. protected $prettyString;
  47083. protected $lowerBound;
  47084. protected $upperBound;
  47085. public function __construct($operator, $version)
  47086. {
  47087. if (!isset(self::$transOpStr[$operator])) {
  47088. throw new \InvalidArgumentException(sprintf(
  47089. 'Invalid operator "%s" given, expected one of: %s',
  47090. $operator,
  47091. implode(', ', self::getSupportedOperators())
  47092. ));
  47093. }
  47094. $this->operator = self::$transOpStr[$operator];
  47095. $this->version = $version;
  47096. }
  47097. public function getVersion()
  47098. {
  47099. return $this->version;
  47100. }
  47101. public function getOperator()
  47102. {
  47103. return self::$transOpInt[$this->operator];
  47104. }
  47105. public function matches(ConstraintInterface $provider)
  47106. {
  47107. if ($provider instanceof self) {
  47108. return $this->matchSpecific($provider);
  47109. }
  47110. return $provider->matches($this);
  47111. }
  47112. public function setPrettyString($prettyString)
  47113. {
  47114. $this->prettyString = $prettyString;
  47115. }
  47116. public function getPrettyString()
  47117. {
  47118. if ($this->prettyString) {
  47119. return $this->prettyString;
  47120. }
  47121. return $this->__toString();
  47122. }
  47123. public static function getSupportedOperators()
  47124. {
  47125. return array_keys(self::$transOpStr);
  47126. }
  47127. public static function getOperatorConstant($operator)
  47128. {
  47129. return self::$transOpStr[$operator];
  47130. }
  47131. public function versionCompare($a, $b, $operator, $compareBranches = false)
  47132. {
  47133. if (!isset(self::$transOpStr[$operator])) {
  47134. throw new \InvalidArgumentException(sprintf(
  47135. 'Invalid operator "%s" given, expected one of: %s',
  47136. $operator,
  47137. implode(', ', self::getSupportedOperators())
  47138. ));
  47139. }
  47140. $aIsBranch = strpos($a, 'dev-') === 0;
  47141. $bIsBranch = strpos($b, 'dev-') === 0;
  47142. if ($operator === '!=' && ($aIsBranch || $bIsBranch)) {
  47143. return $a !== $b;
  47144. }
  47145. if ($aIsBranch && $bIsBranch) {
  47146. return $operator === '==' && $a === $b;
  47147. }
  47148. if (!$compareBranches && ($aIsBranch || $bIsBranch)) {
  47149. return false;
  47150. }
  47151. return \version_compare($a, $b, $operator);
  47152. }
  47153. public function compile($otherOperator)
  47154. {
  47155. if (strpos($this->version, 'dev-') === 0) {
  47156. if (self::OP_EQ === $this->operator) {
  47157. if (self::OP_EQ === $otherOperator) {
  47158. return sprintf('$b && $v === %s', \var_export($this->version, true));
  47159. }
  47160. if (self::OP_NE === $otherOperator) {
  47161. return sprintf('!$b || $v !== %s', \var_export($this->version, true));
  47162. }
  47163. return 'false';
  47164. }
  47165. if (self::OP_NE === $this->operator) {
  47166. if (self::OP_EQ === $otherOperator) {
  47167. return sprintf('!$b || $v !== %s', \var_export($this->version, true));
  47168. }
  47169. if (self::OP_NE === $otherOperator) {
  47170. return 'true';
  47171. }
  47172. return '!$b';
  47173. }
  47174. return 'false';
  47175. }
  47176. if (self::OP_EQ === $this->operator) {
  47177. if (self::OP_EQ === $otherOperator) {
  47178. return sprintf('\version_compare($v, %s, \'==\')', \var_export($this->version, true));
  47179. }
  47180. if (self::OP_NE === $otherOperator) {
  47181. return sprintf('$b || \version_compare($v, %s, \'!=\')', \var_export($this->version, true));
  47182. }
  47183. return sprintf('!$b && \version_compare(%s, $v, \'%s\')', \var_export($this->version, true), self::$transOpInt[$otherOperator]);
  47184. }
  47185. if (self::OP_NE === $this->operator) {
  47186. if (self::OP_EQ === $otherOperator) {
  47187. return sprintf('$b || (!$b && \version_compare($v, %s, \'!=\'))', \var_export($this->version, true));
  47188. }
  47189. if (self::OP_NE === $otherOperator) {
  47190. return 'true';
  47191. }
  47192. return '!$b';
  47193. }
  47194. if (self::OP_LT === $this->operator || self::OP_LE === $this->operator) {
  47195. if (self::OP_LT === $otherOperator || self::OP_LE === $otherOperator) {
  47196. return '!$b';
  47197. }
  47198. } else {
  47199. if (self::OP_GT === $otherOperator || self::OP_GE === $otherOperator) {
  47200. return '!$b';
  47201. }
  47202. }
  47203. if (self::OP_NE === $otherOperator) {
  47204. return 'true';
  47205. }
  47206. $codeComparison = sprintf('\version_compare($v, %s, \'%s\')', \var_export($this->version, true), self::$transOpInt[$this->operator]);
  47207. if ($this->operator === self::OP_LE) {
  47208. if ($otherOperator === self::OP_GT) {
  47209. return sprintf('!$b && \version_compare($v, %s, \'!=\') && ', \var_export($this->version, true)) . $codeComparison;
  47210. }
  47211. } elseif ($this->operator === self::OP_GE) {
  47212. if ($otherOperator === self::OP_LT) {
  47213. return sprintf('!$b && \version_compare($v, %s, \'!=\') && ', \var_export($this->version, true)) . $codeComparison;
  47214. }
  47215. }
  47216. return sprintf('!$b && %s', $codeComparison);
  47217. }
  47218. public function matchSpecific(Constraint $provider, $compareBranches = false)
  47219. {
  47220. $noEqualOp = str_replace('=', '', self::$transOpInt[$this->operator]);
  47221. $providerNoEqualOp = str_replace('=', '', self::$transOpInt[$provider->operator]);
  47222. $isEqualOp = self::OP_EQ === $this->operator;
  47223. $isNonEqualOp = self::OP_NE === $this->operator;
  47224. $isProviderEqualOp = self::OP_EQ === $provider->operator;
  47225. $isProviderNonEqualOp = self::OP_NE === $provider->operator;
  47226. if ($isNonEqualOp || $isProviderNonEqualOp) {
  47227. if ($isNonEqualOp && !$isProviderNonEqualOp && !$isProviderEqualOp && strpos($provider->version, 'dev-') === 0) {
  47228. return false;
  47229. }
  47230. if ($isProviderNonEqualOp && !$isNonEqualOp && !$isEqualOp && strpos($this->version, 'dev-') === 0) {
  47231. return false;
  47232. }
  47233. if (!$isEqualOp && !$isProviderEqualOp) {
  47234. return true;
  47235. }
  47236. return $this->versionCompare($provider->version, $this->version, '!=', $compareBranches);
  47237. }
  47238. if ($this->operator !== self::OP_EQ && $noEqualOp === $providerNoEqualOp) {
  47239. return !(strpos($this->version, 'dev-') === 0 || strpos($provider->version, 'dev-') === 0);
  47240. }
  47241. $version1 = $isEqualOp ? $this->version : $provider->version;
  47242. $version2 = $isEqualOp ? $provider->version : $this->version;
  47243. $operator = $isEqualOp ? $provider->operator : $this->operator;
  47244. if ($this->versionCompare($version1, $version2, self::$transOpInt[$operator], $compareBranches)) {
  47245. return !(self::$transOpInt[$provider->operator] === $providerNoEqualOp
  47246. && self::$transOpInt[$this->operator] !== $noEqualOp
  47247. && \version_compare($provider->version, $this->version, '=='));
  47248. }
  47249. return false;
  47250. }
  47251. public function __toString()
  47252. {
  47253. return self::$transOpInt[$this->operator] . ' ' . $this->version;
  47254. }
  47255. public function getLowerBound()
  47256. {
  47257. $this->extractBounds();
  47258. return $this->lowerBound;
  47259. }
  47260. public function getUpperBound()
  47261. {
  47262. $this->extractBounds();
  47263. return $this->upperBound;
  47264. }
  47265. private function extractBounds()
  47266. {
  47267. if (null !== $this->lowerBound) {
  47268. return;
  47269. }
  47270. if (strpos($this->version, 'dev-') === 0) {
  47271. $this->lowerBound = Bound::zero();
  47272. $this->upperBound = Bound::positiveInfinity();
  47273. return;
  47274. }
  47275. switch ($this->operator) {
  47276. case self::OP_EQ:
  47277. $this->lowerBound = new Bound($this->version, true);
  47278. $this->upperBound = new Bound($this->version, true);
  47279. break;
  47280. case self::OP_LT:
  47281. $this->lowerBound = Bound::zero();
  47282. $this->upperBound = new Bound($this->version, false);
  47283. break;
  47284. case self::OP_LE:
  47285. $this->lowerBound = Bound::zero();
  47286. $this->upperBound = new Bound($this->version, true);
  47287. break;
  47288. case self::OP_GT:
  47289. $this->lowerBound = new Bound($this->version, false);
  47290. $this->upperBound = Bound::positiveInfinity();
  47291. break;
  47292. case self::OP_GE:
  47293. $this->lowerBound = new Bound($this->version, true);
  47294. $this->upperBound = Bound::positiveInfinity();
  47295. break;
  47296. case self::OP_NE:
  47297. $this->lowerBound = Bound::zero();
  47298. $this->upperBound = Bound::positiveInfinity();
  47299. break;
  47300. }
  47301. }
  47302. }
  47303. <?php
  47304. namespace Composer\Semver\Constraint;
  47305. interface ConstraintInterface
  47306. {
  47307. public function matches(ConstraintInterface $provider);
  47308. public function compile($otherOperator);
  47309. public function getUpperBound();
  47310. public function getLowerBound();
  47311. public function getPrettyString();
  47312. public function setPrettyString($prettyString);
  47313. public function __toString();
  47314. }
  47315. <?php
  47316. namespace Composer\Semver\Constraint;
  47317. class MatchAllConstraint implements ConstraintInterface
  47318. {
  47319. protected $prettyString;
  47320. public function matches(ConstraintInterface $provider)
  47321. {
  47322. return true;
  47323. }
  47324. public function compile($otherOperator)
  47325. {
  47326. return 'true';
  47327. }
  47328. public function setPrettyString($prettyString)
  47329. {
  47330. $this->prettyString = $prettyString;
  47331. }
  47332. public function getPrettyString()
  47333. {
  47334. if ($this->prettyString) {
  47335. return $this->prettyString;
  47336. }
  47337. return (string) $this;
  47338. }
  47339. public function __toString()
  47340. {
  47341. return '*';
  47342. }
  47343. public function getUpperBound()
  47344. {
  47345. return Bound::positiveInfinity();
  47346. }
  47347. public function getLowerBound()
  47348. {
  47349. return Bound::zero();
  47350. }
  47351. }
  47352. <?php
  47353. namespace Composer\Semver\Constraint;
  47354. class MatchNoneConstraint implements ConstraintInterface
  47355. {
  47356. protected $prettyString;
  47357. public function matches(ConstraintInterface $provider)
  47358. {
  47359. return false;
  47360. }
  47361. public function compile($otherOperator)
  47362. {
  47363. return 'false';
  47364. }
  47365. public function setPrettyString($prettyString)
  47366. {
  47367. $this->prettyString = $prettyString;
  47368. }
  47369. public function getPrettyString()
  47370. {
  47371. if ($this->prettyString) {
  47372. return $this->prettyString;
  47373. }
  47374. return (string) $this;
  47375. }
  47376. public function __toString()
  47377. {
  47378. return '[]';
  47379. }
  47380. public function getUpperBound()
  47381. {
  47382. return new Bound('0.0.0.0-dev', false);
  47383. }
  47384. public function getLowerBound()
  47385. {
  47386. return new Bound('0.0.0.0-dev', false);
  47387. }
  47388. }
  47389. <?php
  47390. namespace Composer\Semver\Constraint;
  47391. class MultiConstraint implements ConstraintInterface
  47392. {
  47393. protected $constraints;
  47394. protected $prettyString;
  47395. protected $string;
  47396. protected $conjunctive;
  47397. protected $lowerBound;
  47398. protected $upperBound;
  47399. public function __construct(array $constraints, $conjunctive = true)
  47400. {
  47401. if (\count($constraints) < 2) {
  47402. throw new \InvalidArgumentException(
  47403. 'Must provide at least two constraints for a MultiConstraint. Use '.
  47404. 'the regular Constraint class for one constraint only or MatchAllConstraint for none. You may use '.
  47405. 'MultiConstraint::create() which optimizes and handles those cases automatically.'
  47406. );
  47407. }
  47408. $this->constraints = $constraints;
  47409. $this->conjunctive = $conjunctive;
  47410. }
  47411. public function getConstraints()
  47412. {
  47413. return $this->constraints;
  47414. }
  47415. public function isConjunctive()
  47416. {
  47417. return $this->conjunctive;
  47418. }
  47419. public function isDisjunctive()
  47420. {
  47421. return !$this->conjunctive;
  47422. }
  47423. public function compile($otherOperator)
  47424. {
  47425. $parts = array();
  47426. foreach ($this->constraints as $constraint) {
  47427. $code = $constraint->compile($otherOperator);
  47428. if ($code === 'true') {
  47429. if (!$this->conjunctive) {
  47430. return 'true';
  47431. }
  47432. } elseif ($code === 'false') {
  47433. if ($this->conjunctive) {
  47434. return 'false';
  47435. }
  47436. } else {
  47437. $parts[] = '('.$code.')';
  47438. }
  47439. }
  47440. if (!$parts) {
  47441. return $this->conjunctive ? 'true' : 'false';
  47442. }
  47443. return $this->conjunctive ? implode('&&', $parts) : implode('||', $parts);
  47444. }
  47445. public function matches(ConstraintInterface $provider)
  47446. {
  47447. if (false === $this->conjunctive) {
  47448. foreach ($this->constraints as $constraint) {
  47449. if ($provider->matches($constraint)) {
  47450. return true;
  47451. }
  47452. }
  47453. return false;
  47454. }
  47455. if ($provider instanceof MultiConstraint && $provider->isDisjunctive()) {
  47456. return $provider->matches($this);
  47457. }
  47458. foreach ($this->constraints as $constraint) {
  47459. if (!$provider->matches($constraint)) {
  47460. return false;
  47461. }
  47462. }
  47463. return true;
  47464. }
  47465. public function setPrettyString($prettyString)
  47466. {
  47467. $this->prettyString = $prettyString;
  47468. }
  47469. public function getPrettyString()
  47470. {
  47471. if ($this->prettyString) {
  47472. return $this->prettyString;
  47473. }
  47474. return (string) $this;
  47475. }
  47476. public function __toString()
  47477. {
  47478. if ($this->string !== null) {
  47479. return $this->string;
  47480. }
  47481. $constraints = array();
  47482. foreach ($this->constraints as $constraint) {
  47483. $constraints[] = (string) $constraint;
  47484. }
  47485. return $this->string = '[' . implode($this->conjunctive ? ' ' : ' || ', $constraints) . ']';
  47486. }
  47487. public function getLowerBound()
  47488. {
  47489. $this->extractBounds();
  47490. if (null === $this->lowerBound) {
  47491. throw new \LogicException('extractBounds should have populated the lowerBound property');
  47492. }
  47493. return $this->lowerBound;
  47494. }
  47495. public function getUpperBound()
  47496. {
  47497. $this->extractBounds();
  47498. if (null === $this->upperBound) {
  47499. throw new \LogicException('extractBounds should have populated the upperBound property');
  47500. }
  47501. return $this->upperBound;
  47502. }
  47503. public static function create(array $constraints, $conjunctive = true)
  47504. {
  47505. if (0 === \count($constraints)) {
  47506. return new MatchAllConstraint();
  47507. }
  47508. if (1 === \count($constraints)) {
  47509. return $constraints[0];
  47510. }
  47511. $optimized = self::optimizeConstraints($constraints, $conjunctive);
  47512. if ($optimized !== null) {
  47513. list($constraints, $conjunctive) = $optimized;
  47514. if (\count($constraints) === 1) {
  47515. return $constraints[0];
  47516. }
  47517. }
  47518. return new self($constraints, $conjunctive);
  47519. }
  47520. private static function optimizeConstraints(array $constraints, $conjunctive)
  47521. {
  47522. if (!$conjunctive) {
  47523. $left = $constraints[0];
  47524. $mergedConstraints = array();
  47525. $optimized = false;
  47526. for ($i = 1, $l = \count($constraints); $i < $l; $i++) {
  47527. $right = $constraints[$i];
  47528. if (
  47529. $left instanceof self
  47530. && $left->conjunctive
  47531. && $right instanceof self
  47532. && $right->conjunctive
  47533. && \count($left->constraints) === 2
  47534. && \count($right->constraints) === 2
  47535. && ($left0 = (string) $left->constraints[0])
  47536. && $left0[0] === '>' && $left0[1] === '='
  47537. && ($left1 = (string) $left->constraints[1])
  47538. && $left1[0] === '<'
  47539. && ($right0 = (string) $right->constraints[0])
  47540. && $right0[0] === '>' && $right0[1] === '='
  47541. && ($right1 = (string) $right->constraints[1])
  47542. && $right1[0] === '<'
  47543. && substr($left1, 2) === substr($right0, 3)
  47544. ) {
  47545. $optimized = true;
  47546. $left = new MultiConstraint(
  47547. array(
  47548. $left->constraints[0],
  47549. $right->constraints[1],
  47550. ),
  47551. true);
  47552. } else {
  47553. $mergedConstraints[] = $left;
  47554. $left = $right;
  47555. }
  47556. }
  47557. if ($optimized) {
  47558. $mergedConstraints[] = $left;
  47559. return array($mergedConstraints, false);
  47560. }
  47561. }
  47562. return null;
  47563. }
  47564. private function extractBounds()
  47565. {
  47566. if (null !== $this->lowerBound) {
  47567. return;
  47568. }
  47569. foreach ($this->constraints as $constraint) {
  47570. if (null === $this->lowerBound || null === $this->upperBound) {
  47571. $this->lowerBound = $constraint->getLowerBound();
  47572. $this->upperBound = $constraint->getUpperBound();
  47573. continue;
  47574. }
  47575. if ($constraint->getLowerBound()->compareTo($this->lowerBound, $this->isConjunctive() ? '>' : '<')) {
  47576. $this->lowerBound = $constraint->getLowerBound();
  47577. }
  47578. if ($constraint->getUpperBound()->compareTo($this->upperBound, $this->isConjunctive() ? '<' : '>')) {
  47579. $this->upperBound = $constraint->getUpperBound();
  47580. }
  47581. }
  47582. }
  47583. }
  47584. <?php
  47585. namespace Composer\Semver;
  47586. use Composer\Semver\Constraint\Constraint;
  47587. class Interval
  47588. {
  47589. private $start;
  47590. private $end;
  47591. public function __construct(Constraint $start, Constraint $end)
  47592. {
  47593. $this->start = $start;
  47594. $this->end = $end;
  47595. }
  47596. public function getStart()
  47597. {
  47598. return $this->start;
  47599. }
  47600. public function getEnd()
  47601. {
  47602. return $this->end;
  47603. }
  47604. public static function fromZero()
  47605. {
  47606. static $zero;
  47607. if (null === $zero) {
  47608. $zero = new Constraint('>=', '0.0.0.0-dev');
  47609. }
  47610. return $zero;
  47611. }
  47612. public static function untilPositiveInfinity()
  47613. {
  47614. static $positiveInfinity;
  47615. if (null === $positiveInfinity) {
  47616. $positiveInfinity = new Constraint('<', PHP_INT_MAX.'.0.0.0');
  47617. }
  47618. return $positiveInfinity;
  47619. }
  47620. public static function any()
  47621. {
  47622. return new self(self::fromZero(), self::untilPositiveInfinity());
  47623. }
  47624. public static function anyDev()
  47625. {
  47626. return array('names' => array(), 'exclude' => true);
  47627. }
  47628. public static function noDev()
  47629. {
  47630. return array('names' => array(), 'exclude' => false);
  47631. }
  47632. }
  47633. <?php
  47634. namespace Composer\Semver;
  47635. use Composer\Semver\Constraint\Constraint;
  47636. use Composer\Semver\Constraint\ConstraintInterface;
  47637. use Composer\Semver\Constraint\MatchAllConstraint;
  47638. use Composer\Semver\Constraint\MatchNoneConstraint;
  47639. use Composer\Semver\Constraint\MultiConstraint;
  47640. class Intervals
  47641. {
  47642. private static $intervalsCache = array();
  47643. private static $opSortOrder = array(
  47644. '>=' => -3,
  47645. '<' => -2,
  47646. '>' => 2,
  47647. '<=' => 3,
  47648. );
  47649. public static function clear()
  47650. {
  47651. self::$intervalsCache = array();
  47652. }
  47653. public static function isSubsetOf(ConstraintInterface $candidate, ConstraintInterface $constraint)
  47654. {
  47655. if ($constraint instanceof MatchAllConstraint) {
  47656. return true;
  47657. }
  47658. if ($candidate instanceof MatchNoneConstraint || $constraint instanceof MatchNoneConstraint) {
  47659. return false;
  47660. }
  47661. $intersectionIntervals = self::get(new MultiConstraint(array($candidate, $constraint), true));
  47662. $candidateIntervals = self::get($candidate);
  47663. if (\count($intersectionIntervals['numeric']) !== \count($candidateIntervals['numeric'])) {
  47664. return false;
  47665. }
  47666. foreach ($intersectionIntervals['numeric'] as $index => $interval) {
  47667. if (!isset($candidateIntervals['numeric'][$index])) {
  47668. return false;
  47669. }
  47670. if ((string) $candidateIntervals['numeric'][$index]->getStart() !== (string) $interval->getStart()) {
  47671. return false;
  47672. }
  47673. if ((string) $candidateIntervals['numeric'][$index]->getEnd() !== (string) $interval->getEnd()) {
  47674. return false;
  47675. }
  47676. }
  47677. if ($intersectionIntervals['branches']['exclude'] !== $candidateIntervals['branches']['exclude']) {
  47678. return false;
  47679. }
  47680. if (\count($intersectionIntervals['branches']['names']) !== \count($candidateIntervals['branches']['names'])) {
  47681. return false;
  47682. }
  47683. foreach ($intersectionIntervals['branches']['names'] as $index => $name) {
  47684. if ($name !== $candidateIntervals['branches']['names'][$index]) {
  47685. return false;
  47686. }
  47687. }
  47688. return true;
  47689. }
  47690. public static function haveIntersections(ConstraintInterface $a, ConstraintInterface $b)
  47691. {
  47692. if ($a instanceof MatchAllConstraint || $b instanceof MatchAllConstraint) {
  47693. return true;
  47694. }
  47695. if ($a instanceof MatchNoneConstraint || $b instanceof MatchNoneConstraint) {
  47696. return false;
  47697. }
  47698. $intersectionIntervals = self::generateIntervals(new MultiConstraint(array($a, $b), true), true);
  47699. return \count($intersectionIntervals['numeric']) > 0 || $intersectionIntervals['branches']['exclude'] || \count($intersectionIntervals['branches']['names']) > 0;
  47700. }
  47701. public static function compactConstraint(ConstraintInterface $constraint)
  47702. {
  47703. if (!$constraint instanceof MultiConstraint) {
  47704. return $constraint;
  47705. }
  47706. $intervals = self::generateIntervals($constraint);
  47707. $constraints = array();
  47708. $hasNumericMatchAll = false;
  47709. if (\count($intervals['numeric']) === 1 && (string) $intervals['numeric'][0]->getStart() === (string) Interval::fromZero() && (string) $intervals['numeric'][0]->getEnd() === (string) Interval::untilPositiveInfinity()) {
  47710. $constraints[] = $intervals['numeric'][0]->getStart();
  47711. $hasNumericMatchAll = true;
  47712. } else {
  47713. $unEqualConstraints = array();
  47714. for ($i = 0, $count = \count($intervals['numeric']); $i < $count; $i++) {
  47715. $interval = $intervals['numeric'][$i];
  47716. if ($interval->getEnd()->getOperator() === '<' && $i+1 < $count) {
  47717. $nextInterval = $intervals['numeric'][$i+1];
  47718. if ($interval->getEnd()->getVersion() === $nextInterval->getStart()->getVersion() && $nextInterval->getStart()->getOperator() === '>') {
  47719. if (\count($unEqualConstraints) === 0 && (string) $interval->getStart() !== (string) Interval::fromZero()) {
  47720. $unEqualConstraints[] = $interval->getStart();
  47721. }
  47722. $unEqualConstraints[] = new Constraint('!=', $interval->getEnd()->getVersion());
  47723. continue;
  47724. }
  47725. }
  47726. if (\count($unEqualConstraints) > 0) {
  47727. if ((string) $interval->getEnd() !== (string) Interval::untilPositiveInfinity()) {
  47728. $unEqualConstraints[] = $interval->getEnd();
  47729. }
  47730. if (\count($unEqualConstraints) > 1) {
  47731. $constraints[] = new MultiConstraint($unEqualConstraints, true);
  47732. } else {
  47733. $constraints[] = $unEqualConstraints[0];
  47734. }
  47735. $unEqualConstraints = array();
  47736. continue;
  47737. }
  47738. if ($interval->getStart()->getVersion() === $interval->getEnd()->getVersion() && $interval->getStart()->getOperator() === '>=' && $interval->getEnd()->getOperator() === '<=') {
  47739. $constraints[] = new Constraint('==', $interval->getStart()->getVersion());
  47740. continue;
  47741. }
  47742. if ((string) $interval->getStart() === (string) Interval::fromZero()) {
  47743. $constraints[] = $interval->getEnd();
  47744. } elseif ((string) $interval->getEnd() === (string) Interval::untilPositiveInfinity()) {
  47745. $constraints[] = $interval->getStart();
  47746. } else {
  47747. $constraints[] = new MultiConstraint(array($interval->getStart(), $interval->getEnd()), true);
  47748. }
  47749. }
  47750. }
  47751. $devConstraints = array();
  47752. if (0 === \count($intervals['branches']['names'])) {
  47753. if ($intervals['branches']['exclude']) {
  47754. if ($hasNumericMatchAll) {
  47755. return new MatchAllConstraint;
  47756. }
  47757. }
  47758. } else {
  47759. foreach ($intervals['branches']['names'] as $branchName) {
  47760. if ($intervals['branches']['exclude']) {
  47761. $devConstraints[] = new Constraint('!=', $branchName);
  47762. } else {
  47763. $devConstraints[] = new Constraint('==', $branchName);
  47764. }
  47765. }
  47766. if ($intervals['branches']['exclude']) {
  47767. if (\count($constraints) > 1) {
  47768. return new MultiConstraint(array_merge(
  47769. array(new MultiConstraint($constraints, false)),
  47770. $devConstraints
  47771. ), true);
  47772. }
  47773. if (\count($constraints) === 1 && (string)$constraints[0] === (string)Interval::fromZero()) {
  47774. if (\count($devConstraints) > 1) {
  47775. return new MultiConstraint($devConstraints, true);
  47776. }
  47777. return $devConstraints[0];
  47778. }
  47779. return new MultiConstraint(array_merge($constraints, $devConstraints), true);
  47780. }
  47781. $constraints = array_merge($constraints, $devConstraints);
  47782. }
  47783. if (\count($constraints) > 1) {
  47784. return new MultiConstraint($constraints, false);
  47785. }
  47786. if (\count($constraints) === 1) {
  47787. return $constraints[0];
  47788. }
  47789. return new MatchNoneConstraint;
  47790. }
  47791. public static function get(ConstraintInterface $constraint)
  47792. {
  47793. $key = (string) $constraint;
  47794. if (!isset(self::$intervalsCache[$key])) {
  47795. self::$intervalsCache[$key] = self::generateIntervals($constraint);
  47796. }
  47797. return self::$intervalsCache[$key];
  47798. }
  47799. private static function generateIntervals(ConstraintInterface $constraint, $stopOnFirstValidInterval = false)
  47800. {
  47801. if ($constraint instanceof MatchAllConstraint) {
  47802. return array('numeric' => array(new Interval(Interval::fromZero(), Interval::untilPositiveInfinity())), 'branches' => Interval::anyDev());
  47803. }
  47804. if ($constraint instanceof MatchNoneConstraint) {
  47805. return array('numeric' => array(), 'branches' => array('names' => array(), 'exclude' => false));
  47806. }
  47807. if ($constraint instanceof Constraint) {
  47808. return self::generateSingleConstraintIntervals($constraint);
  47809. }
  47810. if (!$constraint instanceof MultiConstraint) {
  47811. throw new \UnexpectedValueException('The constraint passed in should be an MatchAllConstraint, Constraint or MultiConstraint instance, got '.\get_class($constraint).'.');
  47812. }
  47813. $constraints = $constraint->getConstraints();
  47814. $numericGroups = array();
  47815. $constraintBranches = array();
  47816. foreach ($constraints as $c) {
  47817. $res = self::get($c);
  47818. $numericGroups[] = $res['numeric'];
  47819. $constraintBranches[] = $res['branches'];
  47820. }
  47821. if ($constraint->isDisjunctive()) {
  47822. $branches = Interval::noDev();
  47823. foreach ($constraintBranches as $b) {
  47824. if ($b['exclude']) {
  47825. if ($branches['exclude']) {
  47826. $branches['names'] = array_intersect($branches['names'], $b['names']);
  47827. } else {
  47828. $branches['exclude'] = true;
  47829. $branches['names'] = array_diff($b['names'], $branches['names']);
  47830. }
  47831. } else {
  47832. if ($branches['exclude']) {
  47833. $branches['names'] = array_diff($branches['names'], $b['names']);
  47834. } else {
  47835. $branches['names'] = array_merge($branches['names'], $b['names']);
  47836. }
  47837. }
  47838. }
  47839. } else {
  47840. $branches = Interval::anyDev();
  47841. foreach ($constraintBranches as $b) {
  47842. if ($b['exclude']) {
  47843. if ($branches['exclude']) {
  47844. $branches['names'] = array_merge($branches['names'], $b['names']);
  47845. } else {
  47846. $branches['names'] = array_diff($branches['names'], $b['names']);
  47847. }
  47848. } else {
  47849. if ($branches['exclude']) {
  47850. $branches['names'] = array_diff($b['names'], $branches['names']);
  47851. $branches['exclude'] = false;
  47852. } else {
  47853. $branches['names'] = array_intersect($branches['names'], $b['names']);
  47854. }
  47855. }
  47856. }
  47857. }
  47858. $branches['names'] = array_unique($branches['names']);
  47859. if (\count($numericGroups) === 1) {
  47860. return array('numeric' => $numericGroups[0], 'branches' => $branches);
  47861. }
  47862. $borders = array();
  47863. foreach ($numericGroups as $group) {
  47864. foreach ($group as $interval) {
  47865. $borders[] = array('version' => $interval->getStart()->getVersion(), 'operator' => $interval->getStart()->getOperator(), 'side' => 'start');
  47866. $borders[] = array('version' => $interval->getEnd()->getVersion(), 'operator' => $interval->getEnd()->getOperator(), 'side' => 'end');
  47867. }
  47868. }
  47869. $opSortOrder = self::$opSortOrder;
  47870. usort($borders, function ($a, $b) use ($opSortOrder) {
  47871. $order = version_compare($a['version'], $b['version']);
  47872. if ($order === 0) {
  47873. return $opSortOrder[$a['operator']] - $opSortOrder[$b['operator']];
  47874. }
  47875. return $order;
  47876. });
  47877. $activeIntervals = 0;
  47878. $intervals = array();
  47879. $index = 0;
  47880. $activationThreshold = $constraint->isConjunctive() ? \count($numericGroups) : 1;
  47881. $start = null;
  47882. foreach ($borders as $border) {
  47883. if ($border['side'] === 'start') {
  47884. $activeIntervals++;
  47885. } else {
  47886. $activeIntervals--;
  47887. }
  47888. if (!$start && $activeIntervals >= $activationThreshold) {
  47889. $start = new Constraint($border['operator'], $border['version']);
  47890. } elseif ($start && $activeIntervals < $activationThreshold) {
  47891. if (
  47892. version_compare($start->getVersion(), $border['version'], '=')
  47893. && (
  47894. ($start->getOperator() === '>' && $border['operator'] === '<=')
  47895. || ($start->getOperator() === '>=' && $border['operator'] === '<')
  47896. )
  47897. ) {
  47898. unset($intervals[$index]);
  47899. } else {
  47900. $intervals[$index] = new Interval($start, new Constraint($border['operator'], $border['version']));
  47901. $index++;
  47902. if ($stopOnFirstValidInterval) {
  47903. break;
  47904. }
  47905. }
  47906. $start = null;
  47907. }
  47908. }
  47909. return array('numeric' => $intervals, 'branches' => $branches);
  47910. }
  47911. private static function generateSingleConstraintIntervals(Constraint $constraint)
  47912. {
  47913. $op = $constraint->getOperator();
  47914. if (strpos($constraint->getVersion(), 'dev-') === 0) {
  47915. $intervals = array();
  47916. $branches = array('names' => array(), 'exclude' => false);
  47917. if ($op === '!=') {
  47918. $intervals[] = new Interval(Interval::fromZero(), Interval::untilPositiveInfinity());
  47919. $branches = array('names' => array($constraint->getVersion()), 'exclude' => true);
  47920. } elseif ($op === '==') {
  47921. $branches['names'][] = $constraint->getVersion();
  47922. }
  47923. return array(
  47924. 'numeric' => $intervals,
  47925. 'branches' => $branches,
  47926. );
  47927. }
  47928. if ($op[0] === '>') {
  47929. return array('numeric' => array(new Interval($constraint, Interval::untilPositiveInfinity())), 'branches' => Interval::noDev());
  47930. }
  47931. if ($op[0] === '<') {
  47932. return array('numeric' => array(new Interval(Interval::fromZero(), $constraint)), 'branches' => Interval::noDev());
  47933. }
  47934. if ($op === '!=') {
  47935. return array('numeric' => array(
  47936. new Interval(Interval::fromZero(), new Constraint('<', $constraint->getVersion())),
  47937. new Interval(new Constraint('>', $constraint->getVersion()), Interval::untilPositiveInfinity()),
  47938. ), 'branches' => Interval::anyDev());
  47939. }
  47940. return array('numeric' => array(
  47941. new Interval(new Constraint('>=', $constraint->getVersion()), new Constraint('<=', $constraint->getVersion())),
  47942. ), 'branches' => Interval::noDev());
  47943. }
  47944. }
  47945. <?php
  47946. namespace Composer\Semver;
  47947. use Composer\Semver\Constraint\Constraint;
  47948. class Semver
  47949. {
  47950. const SORT_ASC = 1;
  47951. const SORT_DESC = -1;
  47952. private static $versionParser;
  47953. public static function satisfies($version, $constraints)
  47954. {
  47955. if (null === self::$versionParser) {
  47956. self::$versionParser = new VersionParser();
  47957. }
  47958. $versionParser = self::$versionParser;
  47959. $provider = new Constraint('==', $versionParser->normalize($version));
  47960. $parsedConstraints = $versionParser->parseConstraints($constraints);
  47961. return $parsedConstraints->matches($provider);
  47962. }
  47963. public static function satisfiedBy(array $versions, $constraints)
  47964. {
  47965. $versions = array_filter($versions, function ($version) use ($constraints) {
  47966. return Semver::satisfies($version, $constraints);
  47967. });
  47968. return array_values($versions);
  47969. }
  47970. public static function sort(array $versions)
  47971. {
  47972. return self::usort($versions, self::SORT_ASC);
  47973. }
  47974. public static function rsort(array $versions)
  47975. {
  47976. return self::usort($versions, self::SORT_DESC);
  47977. }
  47978. private static function usort(array $versions, $direction)
  47979. {
  47980. if (null === self::$versionParser) {
  47981. self::$versionParser = new VersionParser();
  47982. }
  47983. $versionParser = self::$versionParser;
  47984. $normalized = array();
  47985. foreach ($versions as $key => $version) {
  47986. $normalizedVersion = $versionParser->normalize($version);
  47987. $normalizedVersion = $versionParser->normalizeDefaultBranch($normalizedVersion);
  47988. $normalized[] = array($normalizedVersion, $key);
  47989. }
  47990. usort($normalized, function (array $left, array $right) use ($direction) {
  47991. if ($left[0] === $right[0]) {
  47992. return 0;
  47993. }
  47994. if (Comparator::lessThan($left[0], $right[0])) {
  47995. return -$direction;
  47996. }
  47997. return $direction;
  47998. });
  47999. $sorted = array();
  48000. foreach ($normalized as $item) {
  48001. $sorted[] = $versions[$item[1]];
  48002. }
  48003. return $sorted;
  48004. }
  48005. }
  48006. <?php
  48007. namespace Composer\Semver;
  48008. use Composer\Semver\Constraint\ConstraintInterface;
  48009. use Composer\Semver\Constraint\MatchAllConstraint;
  48010. use Composer\Semver\Constraint\MultiConstraint;
  48011. use Composer\Semver\Constraint\Constraint;
  48012. class VersionParser
  48013. {
  48014. private static $modifierRegex = '[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)((?:[.-]?\d+)*+)?)?([.-]?dev)?';
  48015. private static $stabilitiesRegex = 'stable|RC|beta|alpha|dev';
  48016. public static function parseStability($version)
  48017. {
  48018. $version = (string) preg_replace('{#.+$}', '', (string) $version);
  48019. if (strpos($version, 'dev-') === 0 || '-dev' === substr($version, -4)) {
  48020. return 'dev';
  48021. }
  48022. preg_match('{' . self::$modifierRegex . '(?:\+.*)?$}i', strtolower($version), $match);
  48023. if (!empty($match[3])) {
  48024. return 'dev';
  48025. }
  48026. if (!empty($match[1])) {
  48027. if ('beta' === $match[1] || 'b' === $match[1]) {
  48028. return 'beta';
  48029. }
  48030. if ('alpha' === $match[1] || 'a' === $match[1]) {
  48031. return 'alpha';
  48032. }
  48033. if ('rc' === $match[1]) {
  48034. return 'RC';
  48035. }
  48036. }
  48037. return 'stable';
  48038. }
  48039. public static function normalizeStability($stability)
  48040. {
  48041. $stability = strtolower((string) $stability);
  48042. return $stability === 'rc' ? 'RC' : $stability;
  48043. }
  48044. public function normalize($version, $fullVersion = null)
  48045. {
  48046. $version = trim((string) $version);
  48047. $origVersion = $version;
  48048. if (null === $fullVersion) {
  48049. $fullVersion = $version;
  48050. }
  48051. if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $version, $match)) {
  48052. $version = $match[1];
  48053. }
  48054. if (preg_match('{@(?:' . self::$stabilitiesRegex . ')$}i', $version, $match)) {
  48055. $version = substr($version, 0, strlen($version) - strlen($match[0]));
  48056. }
  48057. if (\in_array($version, array('master', 'trunk', 'default'), true)) {
  48058. $version = 'dev-' . $version;
  48059. }
  48060. if (stripos($version, 'dev-') === 0) {
  48061. return 'dev-' . substr($version, 4);
  48062. }
  48063. if (preg_match('{^([^,\s+]++)\+[^\s]++$}', $version, $match)) {
  48064. $version = $match[1];
  48065. }
  48066. if (preg_match('{^v?(\d{1,5}+)(\.\d++)?(\.\d++)?(\.\d++)?' . self::$modifierRegex . '$}i', $version, $matches)) {
  48067. $version = $matches[1]
  48068. . (!empty($matches[2]) ? $matches[2] : '.0')
  48069. . (!empty($matches[3]) ? $matches[3] : '.0')
  48070. . (!empty($matches[4]) ? $matches[4] : '.0');
  48071. $index = 5;
  48072. } elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3}){0,2})' . self::$modifierRegex . '$}i', $version, $matches)) {
  48073. $version = (string) preg_replace('{\D}', '.', $matches[1]);
  48074. $index = 2;
  48075. }
  48076. if (isset($index)) {
  48077. if (!empty($matches[$index])) {
  48078. if ('stable' === $matches[$index]) {
  48079. return $version;
  48080. }
  48081. $version .= '-' . $this->expandStability($matches[$index]) . (isset($matches[$index + 1]) && '' !== $matches[$index + 1] ? ltrim($matches[$index + 1], '.-') : '');
  48082. }
  48083. if (!empty($matches[$index + 2])) {
  48084. $version .= '-dev';
  48085. }
  48086. return $version;
  48087. }
  48088. if (preg_match('{(.*?)[.-]?dev$}i', $version, $match)) {
  48089. try {
  48090. $normalized = $this->normalizeBranch($match[1]);
  48091. if (strpos($normalized, 'dev-') === false) {
  48092. return $normalized;
  48093. }
  48094. } catch (\Exception $e) {
  48095. }
  48096. }
  48097. $extraMessage = '';
  48098. if (preg_match('{ +as +' . preg_quote($version) . '(?:@(?:'.self::$stabilitiesRegex.'))?$}', $fullVersion)) {
  48099. $extraMessage = ' in "' . $fullVersion . '", the alias must be an exact version';
  48100. } elseif (preg_match('{^' . preg_quote($version) . '(?:@(?:'.self::$stabilitiesRegex.'))? +as +}', $fullVersion)) {
  48101. $extraMessage = ' in "' . $fullVersion . '", the alias source must be an exact version, if it is a branch name you should prefix it with dev-';
  48102. }
  48103. throw new \UnexpectedValueException('Invalid version string "' . $origVersion . '"' . $extraMessage);
  48104. }
  48105. public function parseNumericAliasPrefix($branch)
  48106. {
  48107. if (preg_match('{^(?P<version>(\d++\\.)*\d++)(?:\.x)?-dev$}i', (string) $branch, $matches)) {
  48108. return $matches['version'] . '.';
  48109. }
  48110. return false;
  48111. }
  48112. public function normalizeBranch($name)
  48113. {
  48114. $name = trim((string) $name);
  48115. if (preg_match('{^v?(\d++)(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?$}i', $name, $matches)) {
  48116. $version = '';
  48117. for ($i = 1; $i < 5; ++$i) {
  48118. $version .= isset($matches[$i]) ? str_replace(array('*', 'X'), 'x', $matches[$i]) : '.x';
  48119. }
  48120. return str_replace('x', '9999999', $version) . '-dev';
  48121. }
  48122. return 'dev-' . $name;
  48123. }
  48124. public function normalizeDefaultBranch($name)
  48125. {
  48126. if ($name === 'dev-master' || $name === 'dev-default' || $name === 'dev-trunk') {
  48127. return '9999999-dev';
  48128. }
  48129. return (string) $name;
  48130. }
  48131. public function parseConstraints($constraints)
  48132. {
  48133. $prettyConstraint = (string) $constraints;
  48134. $orConstraints = preg_split('{\s*\|\|?\s*}', trim((string) $constraints));
  48135. if (false === $orConstraints) {
  48136. throw new \RuntimeException('Failed to preg_split string: '.$constraints);
  48137. }
  48138. $orGroups = array();
  48139. foreach ($orConstraints as $orConstraint) {
  48140. $andConstraints = preg_split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $orConstraint);
  48141. if (false === $andConstraints) {
  48142. throw new \RuntimeException('Failed to preg_split string: '.$orConstraint);
  48143. }
  48144. if (\count($andConstraints) > 1) {
  48145. $constraintObjects = array();
  48146. foreach ($andConstraints as $andConstraint) {
  48147. foreach ($this->parseConstraint($andConstraint) as $parsedAndConstraint) {
  48148. $constraintObjects[] = $parsedAndConstraint;
  48149. }
  48150. }
  48151. } else {
  48152. $constraintObjects = $this->parseConstraint($andConstraints[0]);
  48153. }
  48154. if (1 === \count($constraintObjects)) {
  48155. $constraint = $constraintObjects[0];
  48156. } else {
  48157. $constraint = new MultiConstraint($constraintObjects);
  48158. }
  48159. $orGroups[] = $constraint;
  48160. }
  48161. $parsedConstraint = MultiConstraint::create($orGroups, false);
  48162. $parsedConstraint->setPrettyString($prettyConstraint);
  48163. return $parsedConstraint;
  48164. }
  48165. private function parseConstraint($constraint)
  48166. {
  48167. if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $constraint, $match)) {
  48168. $constraint = $match[1];
  48169. }
  48170. if (preg_match('{^([^,\s]*?)@(' . self::$stabilitiesRegex . ')$}i', $constraint, $match)) {
  48171. $constraint = '' !== $match[1] ? $match[1] : '*';
  48172. if ($match[2] !== 'stable') {
  48173. $stabilityModifier = $match[2];
  48174. }
  48175. }
  48176. if (preg_match('{^(dev-[^,\s@]+?|[^,\s@]+?\.x-dev)#.+$}i', $constraint, $match)) {
  48177. $constraint = $match[1];
  48178. }
  48179. if (preg_match('{^(v)?[xX*](\.[xX*])*$}i', $constraint, $match)) {
  48180. if (!empty($match[1]) || !empty($match[2])) {
  48181. return array(new Constraint('>=', '0.0.0.0-dev'));
  48182. }
  48183. return array(new MatchAllConstraint());
  48184. }
  48185. $versionRegex = 'v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.(\d++))?(?:' . self::$modifierRegex . '|\.([xX*][.-]?dev))(?:\+[^\s]+)?';
  48186. if (preg_match('{^~>?' . $versionRegex . '$}i', $constraint, $matches)) {
  48187. if (strpos($constraint, '~>') === 0) {
  48188. throw new \UnexpectedValueException(
  48189. 'Could not parse version constraint ' . $constraint . ': ' .
  48190. 'Invalid operator "~>", you probably meant to use the "~" operator'
  48191. );
  48192. }
  48193. if (isset($matches[4]) && '' !== $matches[4] && null !== $matches[4]) {
  48194. $position = 4;
  48195. } elseif (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
  48196. $position = 3;
  48197. } elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
  48198. $position = 2;
  48199. } else {
  48200. $position = 1;
  48201. }
  48202. if (!empty($matches[8])) {
  48203. $position++;
  48204. }
  48205. $stabilitySuffix = '';
  48206. if (empty($matches[5]) && empty($matches[7]) && empty($matches[8])) {
  48207. $stabilitySuffix .= '-dev';
  48208. }
  48209. $lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
  48210. $lowerBound = new Constraint('>=', $lowVersion);
  48211. $highPosition = max(1, $position - 1);
  48212. $highVersion = $this->manipulateVersionString($matches, $highPosition, 1) . '-dev';
  48213. $upperBound = new Constraint('<', $highVersion);
  48214. return array(
  48215. $lowerBound,
  48216. $upperBound,
  48217. );
  48218. }
  48219. if (preg_match('{^\^' . $versionRegex . '($)}i', $constraint, $matches)) {
  48220. if ('0' !== $matches[1] || '' === $matches[2] || null === $matches[2]) {
  48221. $position = 1;
  48222. } elseif ('0' !== $matches[2] || '' === $matches[3] || null === $matches[3]) {
  48223. $position = 2;
  48224. } else {
  48225. $position = 3;
  48226. }
  48227. $stabilitySuffix = '';
  48228. if (empty($matches[5]) && empty($matches[7]) && empty($matches[8])) {
  48229. $stabilitySuffix .= '-dev';
  48230. }
  48231. $lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
  48232. $lowerBound = new Constraint('>=', $lowVersion);
  48233. $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';
  48234. $upperBound = new Constraint('<', $highVersion);
  48235. return array(
  48236. $lowerBound,
  48237. $upperBound,
  48238. );
  48239. }
  48240. if (preg_match('{^v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.[xX*])++$}', $constraint, $matches)) {
  48241. if (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
  48242. $position = 3;
  48243. } elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
  48244. $position = 2;
  48245. } else {
  48246. $position = 1;
  48247. }
  48248. $lowVersion = $this->manipulateVersionString($matches, $position) . '-dev';
  48249. $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';
  48250. if ($lowVersion === '0.0.0.0-dev') {
  48251. return array(new Constraint('<', $highVersion));
  48252. }
  48253. return array(
  48254. new Constraint('>=', $lowVersion),
  48255. new Constraint('<', $highVersion),
  48256. );
  48257. }
  48258. if (preg_match('{^(?P<from>' . $versionRegex . ') +- +(?P<to>' . $versionRegex . ')($)}i', $constraint, $matches)) {
  48259. $lowStabilitySuffix = '';
  48260. if (empty($matches[6]) && empty($matches[8]) && empty($matches[9])) {
  48261. $lowStabilitySuffix = '-dev';
  48262. }
  48263. $lowVersion = $this->normalize($matches['from']);
  48264. $lowerBound = new Constraint('>=', $lowVersion . $lowStabilitySuffix);
  48265. $empty = function ($x) {
  48266. return ($x === 0 || $x === '0') ? false : empty($x);
  48267. };
  48268. if ((!$empty($matches[12]) && !$empty($matches[13])) || !empty($matches[15]) || !empty($matches[17]) || !empty($matches[18])) {
  48269. $highVersion = $this->normalize($matches['to']);
  48270. $upperBound = new Constraint('<=', $highVersion);
  48271. } else {
  48272. $highMatch = array('', $matches[11], $matches[12], $matches[13], $matches[14]);
  48273. $this->normalize($matches['to']);
  48274. $highVersion = $this->manipulateVersionString($highMatch, $empty($matches[12]) ? 1 : 2, 1) . '-dev';
  48275. $upperBound = new Constraint('<', $highVersion);
  48276. }
  48277. return array(
  48278. $lowerBound,
  48279. $upperBound,
  48280. );
  48281. }
  48282. if (preg_match('{^(<>|!=|>=?|<=?|==?)?\s*(.*)}', $constraint, $matches)) {
  48283. try {
  48284. try {
  48285. $version = $this->normalize($matches[2]);
  48286. } catch (\UnexpectedValueException $e) {
  48287. if (substr($matches[2], -4) === '-dev' && preg_match('{^[0-9a-zA-Z-./]+$}', $matches[2])) {
  48288. $version = $this->normalize('dev-'.substr($matches[2], 0, -4));
  48289. } else {
  48290. throw $e;
  48291. }
  48292. }
  48293. $op = $matches[1] ?: '=';
  48294. if ($op !== '==' && $op !== '=' && !empty($stabilityModifier) && self::parseStability($version) === 'stable') {
  48295. $version .= '-' . $stabilityModifier;
  48296. } elseif ('<' === $op || '>=' === $op) {
  48297. if (!preg_match('/-' . self::$modifierRegex . '$/', strtolower($matches[2]))) {
  48298. if (strpos($matches[2], 'dev-') !== 0) {
  48299. $version .= '-dev';
  48300. }
  48301. }
  48302. }
  48303. return array(new Constraint($matches[1] ?: '=', $version));
  48304. } catch (\Exception $e) {
  48305. }
  48306. }
  48307. $message = 'Could not parse version constraint ' . $constraint;
  48308. if (isset($e)) {
  48309. $message .= ': ' . $e->getMessage();
  48310. }
  48311. throw new \UnexpectedValueException($message);
  48312. }
  48313. private function manipulateVersionString(array $matches, $position, $increment = 0, $pad = '0')
  48314. {
  48315. for ($i = 4; $i > 0; --$i) {
  48316. if ($i > $position) {
  48317. $matches[$i] = $pad;
  48318. } elseif ($i === $position && $increment) {
  48319. $matches[$i] += $increment;
  48320. if ($matches[$i] < 0) {
  48321. $matches[$i] = $pad;
  48322. --$position;
  48323. if ($i === 1) {
  48324. return null;
  48325. }
  48326. }
  48327. }
  48328. }
  48329. return $matches[1] . '.' . $matches[2] . '.' . $matches[3] . '.' . $matches[4];
  48330. }
  48331. private function expandStability($stability)
  48332. {
  48333. $stability = strtolower($stability);
  48334. switch ($stability) {
  48335. case 'a':
  48336. return 'alpha';
  48337. case 'b':
  48338. return 'beta';
  48339. case 'p':
  48340. case 'pl':
  48341. return 'patch';
  48342. case 'rc':
  48343. return 'RC';
  48344. default:
  48345. return $stability;
  48346. }
  48347. }
  48348. }
  48349. Copyright (C) 2015 Composer
  48350. Permission is hereby granted, free of charge, to any person obtaining a copy of
  48351. this software and associated documentation files (the "Software"), to deal in
  48352. the Software without restriction, including without limitation the rights to
  48353. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  48354. of the Software, and to permit persons to whom the Software is furnished to do
  48355. so, subject to the following conditions:
  48356. The above copyright notice and this permission notice shall be included in all
  48357. copies or substantial portions of the Software.
  48358. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  48359. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  48360. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  48361. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  48362. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  48363. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  48364. SOFTWARE.
  48365. {
  48366. "389-exception": [
  48367. "389 Directory Server Exception"
  48368. ],
  48369. "Autoconf-exception-2.0": [
  48370. "Autoconf exception 2.0"
  48371. ],
  48372. "Autoconf-exception-3.0": [
  48373. "Autoconf exception 3.0"
  48374. ],
  48375. "Bison-exception-2.2": [
  48376. "Bison exception 2.2"
  48377. ],
  48378. "Bootloader-exception": [
  48379. "Bootloader Distribution Exception"
  48380. ],
  48381. "Classpath-exception-2.0": [
  48382. "Classpath exception 2.0"
  48383. ],
  48384. "CLISP-exception-2.0": [
  48385. "CLISP exception 2.0"
  48386. ],
  48387. "DigiRule-FOSS-exception": [
  48388. "DigiRule FOSS License Exception"
  48389. ],
  48390. "eCos-exception-2.0": [
  48391. "eCos exception 2.0"
  48392. ],
  48393. "Fawkes-Runtime-exception": [
  48394. "Fawkes Runtime Exception"
  48395. ],
  48396. "FLTK-exception": [
  48397. "FLTK exception"
  48398. ],
  48399. "Font-exception-2.0": [
  48400. "Font exception 2.0"
  48401. ],
  48402. "freertos-exception-2.0": [
  48403. "FreeRTOS Exception 2.0"
  48404. ],
  48405. "GCC-exception-2.0": [
  48406. "GCC Runtime Library exception 2.0"
  48407. ],
  48408. "GCC-exception-3.1": [
  48409. "GCC Runtime Library exception 3.1"
  48410. ],
  48411. "gnu-javamail-exception": [
  48412. "GNU JavaMail exception"
  48413. ],
  48414. "GPL-3.0-linking-exception": [
  48415. "GPL-3.0 Linking Exception"
  48416. ],
  48417. "GPL-3.0-linking-source-exception": [
  48418. "GPL-3.0 Linking Exception (with Corresponding Source)"
  48419. ],
  48420. "GPL-CC-1.0": [
  48421. "GPL Cooperation Commitment 1.0"
  48422. ],
  48423. "i2p-gpl-java-exception": [
  48424. "i2p GPL+Java Exception"
  48425. ],
  48426. "LGPL-3.0-linking-exception": [
  48427. "LGPL-3.0 Linking Exception"
  48428. ],
  48429. "Libtool-exception": [
  48430. "Libtool Exception"
  48431. ],
  48432. "Linux-syscall-note": [
  48433. "Linux Syscall Note"
  48434. ],
  48435. "LLVM-exception": [
  48436. "LLVM Exception"
  48437. ],
  48438. "LZMA-exception": [
  48439. "LZMA exception"
  48440. ],
  48441. "mif-exception": [
  48442. "Macros and Inline Functions Exception"
  48443. ],
  48444. "Nokia-Qt-exception-1.1": [
  48445. "Nokia Qt LGPL exception 1.1"
  48446. ],
  48447. "OCaml-LGPL-linking-exception": [
  48448. "OCaml LGPL Linking Exception"
  48449. ],
  48450. "OCCT-exception-1.0": [
  48451. "Open CASCADE Exception 1.0"
  48452. ],
  48453. "OpenJDK-assembly-exception-1.0": [
  48454. "OpenJDK Assembly exception 1.0"
  48455. ],
  48456. "openvpn-openssl-exception": [
  48457. "OpenVPN OpenSSL Exception"
  48458. ],
  48459. "PS-or-PDF-font-exception-20170817": [
  48460. "PS/PDF font exception (2017-08-17)"
  48461. ],
  48462. "Qt-GPL-exception-1.0": [
  48463. "Qt GPL exception 1.0"
  48464. ],
  48465. "Qt-LGPL-exception-1.1": [
  48466. "Qt LGPL exception 1.1"
  48467. ],
  48468. "Qwt-exception-1.0": [
  48469. "Qwt exception 1.0"
  48470. ],
  48471. "SHL-2.0": [
  48472. "Solderpad Hardware License v2.0"
  48473. ],
  48474. "SHL-2.1": [
  48475. "Solderpad Hardware License v2.1"
  48476. ],
  48477. "Swift-exception": [
  48478. "Swift Exception"
  48479. ],
  48480. "u-boot-exception-2.0": [
  48481. "U-Boot exception 2.0"
  48482. ],
  48483. "Universal-FOSS-exception-1.0": [
  48484. "Universal FOSS Exception, Version 1.0"
  48485. ],
  48486. "WxWindows-exception-3.1": [
  48487. "WxWindows Library Exception 3.1"
  48488. ]
  48489. }{
  48490. "0BSD": [
  48491. "BSD Zero Clause License",
  48492. true,
  48493. false
  48494. ],
  48495. "AAL": [
  48496. "Attribution Assurance License",
  48497. true,
  48498. false
  48499. ],
  48500. "Abstyles": [
  48501. "Abstyles License",
  48502. false,
  48503. false
  48504. ],
  48505. "Adobe-2006": [
  48506. "Adobe Systems Incorporated Source Code License Agreement",
  48507. false,
  48508. false
  48509. ],
  48510. "Adobe-Glyph": [
  48511. "Adobe Glyph List License",
  48512. false,
  48513. false
  48514. ],
  48515. "ADSL": [
  48516. "Amazon Digital Services License",
  48517. false,
  48518. false
  48519. ],
  48520. "AFL-1.1": [
  48521. "Academic Free License v1.1",
  48522. true,
  48523. false
  48524. ],
  48525. "AFL-1.2": [
  48526. "Academic Free License v1.2",
  48527. true,
  48528. false
  48529. ],
  48530. "AFL-2.0": [
  48531. "Academic Free License v2.0",
  48532. true,
  48533. false
  48534. ],
  48535. "AFL-2.1": [
  48536. "Academic Free License v2.1",
  48537. true,
  48538. false
  48539. ],
  48540. "AFL-3.0": [
  48541. "Academic Free License v3.0",
  48542. true,
  48543. false
  48544. ],
  48545. "Afmparse": [
  48546. "Afmparse License",
  48547. false,
  48548. false
  48549. ],
  48550. "AGPL-1.0": [
  48551. "Affero General Public License v1.0",
  48552. false,
  48553. true
  48554. ],
  48555. "AGPL-1.0-only": [
  48556. "Affero General Public License v1.0 only",
  48557. false,
  48558. false
  48559. ],
  48560. "AGPL-1.0-or-later": [
  48561. "Affero General Public License v1.0 or later",
  48562. false,
  48563. false
  48564. ],
  48565. "AGPL-3.0": [
  48566. "GNU Affero General Public License v3.0",
  48567. true,
  48568. true
  48569. ],
  48570. "AGPL-3.0-only": [
  48571. "GNU Affero General Public License v3.0 only",
  48572. true,
  48573. false
  48574. ],
  48575. "AGPL-3.0-or-later": [
  48576. "GNU Affero General Public License v3.0 or later",
  48577. true,
  48578. false
  48579. ],
  48580. "Aladdin": [
  48581. "Aladdin Free Public License",
  48582. false,
  48583. false
  48584. ],
  48585. "AMDPLPA": [
  48586. "AMD's plpa_map.c License",
  48587. false,
  48588. false
  48589. ],
  48590. "AML": [
  48591. "Apple MIT License",
  48592. false,
  48593. false
  48594. ],
  48595. "AMPAS": [
  48596. "Academy of Motion Picture Arts and Sciences BSD",
  48597. false,
  48598. false
  48599. ],
  48600. "ANTLR-PD": [
  48601. "ANTLR Software Rights Notice",
  48602. false,
  48603. false
  48604. ],
  48605. "ANTLR-PD-fallback": [
  48606. "ANTLR Software Rights Notice with license fallback",
  48607. false,
  48608. false
  48609. ],
  48610. "Apache-1.0": [
  48611. "Apache License 1.0",
  48612. false,
  48613. false
  48614. ],
  48615. "Apache-1.1": [
  48616. "Apache License 1.1",
  48617. true,
  48618. false
  48619. ],
  48620. "Apache-2.0": [
  48621. "Apache License 2.0",
  48622. true,
  48623. false
  48624. ],
  48625. "APAFML": [
  48626. "Adobe Postscript AFM License",
  48627. false,
  48628. false
  48629. ],
  48630. "APL-1.0": [
  48631. "Adaptive Public License 1.0",
  48632. true,
  48633. false
  48634. ],
  48635. "App-s2p": [
  48636. "App::s2p License",
  48637. false,
  48638. false
  48639. ],
  48640. "APSL-1.0": [
  48641. "Apple Public Source License 1.0",
  48642. true,
  48643. false
  48644. ],
  48645. "APSL-1.1": [
  48646. "Apple Public Source License 1.1",
  48647. true,
  48648. false
  48649. ],
  48650. "APSL-1.2": [
  48651. "Apple Public Source License 1.2",
  48652. true,
  48653. false
  48654. ],
  48655. "APSL-2.0": [
  48656. "Apple Public Source License 2.0",
  48657. true,
  48658. false
  48659. ],
  48660. "Arphic-1999": [
  48661. "Arphic Public License",
  48662. false,
  48663. false
  48664. ],
  48665. "Artistic-1.0": [
  48666. "Artistic License 1.0",
  48667. true,
  48668. false
  48669. ],
  48670. "Artistic-1.0-cl8": [
  48671. "Artistic License 1.0 w/clause 8",
  48672. true,
  48673. false
  48674. ],
  48675. "Artistic-1.0-Perl": [
  48676. "Artistic License 1.0 (Perl)",
  48677. true,
  48678. false
  48679. ],
  48680. "Artistic-2.0": [
  48681. "Artistic License 2.0",
  48682. true,
  48683. false
  48684. ],
  48685. "Baekmuk": [
  48686. "Baekmuk License",
  48687. false,
  48688. false
  48689. ],
  48690. "Bahyph": [
  48691. "Bahyph License",
  48692. false,
  48693. false
  48694. ],
  48695. "Barr": [
  48696. "Barr License",
  48697. false,
  48698. false
  48699. ],
  48700. "Beerware": [
  48701. "Beerware License",
  48702. false,
  48703. false
  48704. ],
  48705. "Bitstream-Vera": [
  48706. "Bitstream Vera Font License",
  48707. false,
  48708. false
  48709. ],
  48710. "BitTorrent-1.0": [
  48711. "BitTorrent Open Source License v1.0",
  48712. false,
  48713. false
  48714. ],
  48715. "BitTorrent-1.1": [
  48716. "BitTorrent Open Source License v1.1",
  48717. false,
  48718. false
  48719. ],
  48720. "blessing": [
  48721. "SQLite Blessing",
  48722. false,
  48723. false
  48724. ],
  48725. "BlueOak-1.0.0": [
  48726. "Blue Oak Model License 1.0.0",
  48727. false,
  48728. false
  48729. ],
  48730. "Borceux": [
  48731. "Borceux license",
  48732. false,
  48733. false
  48734. ],
  48735. "BSD-1-Clause": [
  48736. "BSD 1-Clause License",
  48737. true,
  48738. false
  48739. ],
  48740. "BSD-2-Clause": [
  48741. "BSD 2-Clause \"Simplified\" License",
  48742. true,
  48743. false
  48744. ],
  48745. "BSD-2-Clause-FreeBSD": [
  48746. "BSD 2-Clause FreeBSD License",
  48747. false,
  48748. true
  48749. ],
  48750. "BSD-2-Clause-NetBSD": [
  48751. "BSD 2-Clause NetBSD License",
  48752. false,
  48753. true
  48754. ],
  48755. "BSD-2-Clause-Patent": [
  48756. "BSD-2-Clause Plus Patent License",
  48757. true,
  48758. false
  48759. ],
  48760. "BSD-2-Clause-Views": [
  48761. "BSD 2-Clause with views sentence",
  48762. false,
  48763. false
  48764. ],
  48765. "BSD-3-Clause": [
  48766. "BSD 3-Clause \"New\" or \"Revised\" License",
  48767. true,
  48768. false
  48769. ],
  48770. "BSD-3-Clause-Attribution": [
  48771. "BSD with attribution",
  48772. false,
  48773. false
  48774. ],
  48775. "BSD-3-Clause-Clear": [
  48776. "BSD 3-Clause Clear License",
  48777. false,
  48778. false
  48779. ],
  48780. "BSD-3-Clause-LBNL": [
  48781. "Lawrence Berkeley National Labs BSD variant license",
  48782. true,
  48783. false
  48784. ],
  48785. "BSD-3-Clause-Modification": [
  48786. "BSD 3-Clause Modification",
  48787. false,
  48788. false
  48789. ],
  48790. "BSD-3-Clause-No-Military-License": [
  48791. "BSD 3-Clause No Military License",
  48792. false,
  48793. false
  48794. ],
  48795. "BSD-3-Clause-No-Nuclear-License": [
  48796. "BSD 3-Clause No Nuclear License",
  48797. false,
  48798. false
  48799. ],
  48800. "BSD-3-Clause-No-Nuclear-License-2014": [
  48801. "BSD 3-Clause No Nuclear License 2014",
  48802. false,
  48803. false
  48804. ],
  48805. "BSD-3-Clause-No-Nuclear-Warranty": [
  48806. "BSD 3-Clause No Nuclear Warranty",
  48807. false,
  48808. false
  48809. ],
  48810. "BSD-3-Clause-Open-MPI": [
  48811. "BSD 3-Clause Open MPI variant",
  48812. false,
  48813. false
  48814. ],
  48815. "BSD-4-Clause": [
  48816. "BSD 4-Clause \"Original\" or \"Old\" License",
  48817. false,
  48818. false
  48819. ],
  48820. "BSD-4-Clause-Shortened": [
  48821. "BSD 4 Clause Shortened",
  48822. false,
  48823. false
  48824. ],
  48825. "BSD-4-Clause-UC": [
  48826. "BSD-4-Clause (University of California-Specific)",
  48827. false,
  48828. false
  48829. ],
  48830. "BSD-Protection": [
  48831. "BSD Protection License",
  48832. false,
  48833. false
  48834. ],
  48835. "BSD-Source-Code": [
  48836. "BSD Source Code Attribution",
  48837. false,
  48838. false
  48839. ],
  48840. "BSL-1.0": [
  48841. "Boost Software License 1.0",
  48842. true,
  48843. false
  48844. ],
  48845. "BUSL-1.1": [
  48846. "Business Source License 1.1",
  48847. false,
  48848. false
  48849. ],
  48850. "bzip2-1.0.5": [
  48851. "bzip2 and libbzip2 License v1.0.5",
  48852. false,
  48853. true
  48854. ],
  48855. "bzip2-1.0.6": [
  48856. "bzip2 and libbzip2 License v1.0.6",
  48857. false,
  48858. false
  48859. ],
  48860. "C-UDA-1.0": [
  48861. "Computational Use of Data Agreement v1.0",
  48862. false,
  48863. false
  48864. ],
  48865. "CAL-1.0": [
  48866. "Cryptographic Autonomy License 1.0",
  48867. true,
  48868. false
  48869. ],
  48870. "CAL-1.0-Combined-Work-Exception": [
  48871. "Cryptographic Autonomy License 1.0 (Combined Work Exception)",
  48872. true,
  48873. false
  48874. ],
  48875. "Caldera": [
  48876. "Caldera License",
  48877. false,
  48878. false
  48879. ],
  48880. "CATOSL-1.1": [
  48881. "Computer Associates Trusted Open Source License 1.1",
  48882. true,
  48883. false
  48884. ],
  48885. "CC-BY-1.0": [
  48886. "Creative Commons Attribution 1.0 Generic",
  48887. false,
  48888. false
  48889. ],
  48890. "CC-BY-2.0": [
  48891. "Creative Commons Attribution 2.0 Generic",
  48892. false,
  48893. false
  48894. ],
  48895. "CC-BY-2.5": [
  48896. "Creative Commons Attribution 2.5 Generic",
  48897. false,
  48898. false
  48899. ],
  48900. "CC-BY-2.5-AU": [
  48901. "Creative Commons Attribution 2.5 Australia",
  48902. false,
  48903. false
  48904. ],
  48905. "CC-BY-3.0": [
  48906. "Creative Commons Attribution 3.0 Unported",
  48907. false,
  48908. false
  48909. ],
  48910. "CC-BY-3.0-AT": [
  48911. "Creative Commons Attribution 3.0 Austria",
  48912. false,
  48913. false
  48914. ],
  48915. "CC-BY-3.0-DE": [
  48916. "Creative Commons Attribution 3.0 Germany",
  48917. false,
  48918. false
  48919. ],
  48920. "CC-BY-3.0-NL": [
  48921. "Creative Commons Attribution 3.0 Netherlands",
  48922. false,
  48923. false
  48924. ],
  48925. "CC-BY-3.0-US": [
  48926. "Creative Commons Attribution 3.0 United States",
  48927. false,
  48928. false
  48929. ],
  48930. "CC-BY-4.0": [
  48931. "Creative Commons Attribution 4.0 International",
  48932. false,
  48933. false
  48934. ],
  48935. "CC-BY-NC-1.0": [
  48936. "Creative Commons Attribution Non Commercial 1.0 Generic",
  48937. false,
  48938. false
  48939. ],
  48940. "CC-BY-NC-2.0": [
  48941. "Creative Commons Attribution Non Commercial 2.0 Generic",
  48942. false,
  48943. false
  48944. ],
  48945. "CC-BY-NC-2.5": [
  48946. "Creative Commons Attribution Non Commercial 2.5 Generic",
  48947. false,
  48948. false
  48949. ],
  48950. "CC-BY-NC-3.0": [
  48951. "Creative Commons Attribution Non Commercial 3.0 Unported",
  48952. false,
  48953. false
  48954. ],
  48955. "CC-BY-NC-3.0-DE": [
  48956. "Creative Commons Attribution Non Commercial 3.0 Germany",
  48957. false,
  48958. false
  48959. ],
  48960. "CC-BY-NC-4.0": [
  48961. "Creative Commons Attribution Non Commercial 4.0 International",
  48962. false,
  48963. false
  48964. ],
  48965. "CC-BY-NC-ND-1.0": [
  48966. "Creative Commons Attribution Non Commercial No Derivatives 1.0 Generic",
  48967. false,
  48968. false
  48969. ],
  48970. "CC-BY-NC-ND-2.0": [
  48971. "Creative Commons Attribution Non Commercial No Derivatives 2.0 Generic",
  48972. false,
  48973. false
  48974. ],
  48975. "CC-BY-NC-ND-2.5": [
  48976. "Creative Commons Attribution Non Commercial No Derivatives 2.5 Generic",
  48977. false,
  48978. false
  48979. ],
  48980. "CC-BY-NC-ND-3.0": [
  48981. "Creative Commons Attribution Non Commercial No Derivatives 3.0 Unported",
  48982. false,
  48983. false
  48984. ],
  48985. "CC-BY-NC-ND-3.0-DE": [
  48986. "Creative Commons Attribution Non Commercial No Derivatives 3.0 Germany",
  48987. false,
  48988. false
  48989. ],
  48990. "CC-BY-NC-ND-3.0-IGO": [
  48991. "Creative Commons Attribution Non Commercial No Derivatives 3.0 IGO",
  48992. false,
  48993. false
  48994. ],
  48995. "CC-BY-NC-ND-4.0": [
  48996. "Creative Commons Attribution Non Commercial No Derivatives 4.0 International",
  48997. false,
  48998. false
  48999. ],
  49000. "CC-BY-NC-SA-1.0": [
  49001. "Creative Commons Attribution Non Commercial Share Alike 1.0 Generic",
  49002. false,
  49003. false
  49004. ],
  49005. "CC-BY-NC-SA-2.0": [
  49006. "Creative Commons Attribution Non Commercial Share Alike 2.0 Generic",
  49007. false,
  49008. false
  49009. ],
  49010. "CC-BY-NC-SA-2.0-FR": [
  49011. "Creative Commons Attribution-NonCommercial-ShareAlike 2.0 France",
  49012. false,
  49013. false
  49014. ],
  49015. "CC-BY-NC-SA-2.0-UK": [
  49016. "Creative Commons Attribution Non Commercial Share Alike 2.0 England and Wales",
  49017. false,
  49018. false
  49019. ],
  49020. "CC-BY-NC-SA-2.5": [
  49021. "Creative Commons Attribution Non Commercial Share Alike 2.5 Generic",
  49022. false,
  49023. false
  49024. ],
  49025. "CC-BY-NC-SA-3.0": [
  49026. "Creative Commons Attribution Non Commercial Share Alike 3.0 Unported",
  49027. false,
  49028. false
  49029. ],
  49030. "CC-BY-NC-SA-3.0-DE": [
  49031. "Creative Commons Attribution Non Commercial Share Alike 3.0 Germany",
  49032. false,
  49033. false
  49034. ],
  49035. "CC-BY-NC-SA-3.0-IGO": [
  49036. "Creative Commons Attribution Non Commercial Share Alike 3.0 IGO",
  49037. false,
  49038. false
  49039. ],
  49040. "CC-BY-NC-SA-4.0": [
  49041. "Creative Commons Attribution Non Commercial Share Alike 4.0 International",
  49042. false,
  49043. false
  49044. ],
  49045. "CC-BY-ND-1.0": [
  49046. "Creative Commons Attribution No Derivatives 1.0 Generic",
  49047. false,
  49048. false
  49049. ],
  49050. "CC-BY-ND-2.0": [
  49051. "Creative Commons Attribution No Derivatives 2.0 Generic",
  49052. false,
  49053. false
  49054. ],
  49055. "CC-BY-ND-2.5": [
  49056. "Creative Commons Attribution No Derivatives 2.5 Generic",
  49057. false,
  49058. false
  49059. ],
  49060. "CC-BY-ND-3.0": [
  49061. "Creative Commons Attribution No Derivatives 3.0 Unported",
  49062. false,
  49063. false
  49064. ],
  49065. "CC-BY-ND-3.0-DE": [
  49066. "Creative Commons Attribution No Derivatives 3.0 Germany",
  49067. false,
  49068. false
  49069. ],
  49070. "CC-BY-ND-4.0": [
  49071. "Creative Commons Attribution No Derivatives 4.0 International",
  49072. false,
  49073. false
  49074. ],
  49075. "CC-BY-SA-1.0": [
  49076. "Creative Commons Attribution Share Alike 1.0 Generic",
  49077. false,
  49078. false
  49079. ],
  49080. "CC-BY-SA-2.0": [
  49081. "Creative Commons Attribution Share Alike 2.0 Generic",
  49082. false,
  49083. false
  49084. ],
  49085. "CC-BY-SA-2.0-UK": [
  49086. "Creative Commons Attribution Share Alike 2.0 England and Wales",
  49087. false,
  49088. false
  49089. ],
  49090. "CC-BY-SA-2.1-JP": [
  49091. "Creative Commons Attribution Share Alike 2.1 Japan",
  49092. false,
  49093. false
  49094. ],
  49095. "CC-BY-SA-2.5": [
  49096. "Creative Commons Attribution Share Alike 2.5 Generic",
  49097. false,
  49098. false
  49099. ],
  49100. "CC-BY-SA-3.0": [
  49101. "Creative Commons Attribution Share Alike 3.0 Unported",
  49102. false,
  49103. false
  49104. ],
  49105. "CC-BY-SA-3.0-AT": [
  49106. "Creative Commons Attribution Share Alike 3.0 Austria",
  49107. false,
  49108. false
  49109. ],
  49110. "CC-BY-SA-3.0-DE": [
  49111. "Creative Commons Attribution Share Alike 3.0 Germany",
  49112. false,
  49113. false
  49114. ],
  49115. "CC-BY-SA-4.0": [
  49116. "Creative Commons Attribution Share Alike 4.0 International",
  49117. false,
  49118. false
  49119. ],
  49120. "CC-PDDC": [
  49121. "Creative Commons Public Domain Dedication and Certification",
  49122. false,
  49123. false
  49124. ],
  49125. "CC0-1.0": [
  49126. "Creative Commons Zero v1.0 Universal",
  49127. false,
  49128. false
  49129. ],
  49130. "CDDL-1.0": [
  49131. "Common Development and Distribution License 1.0",
  49132. true,
  49133. false
  49134. ],
  49135. "CDDL-1.1": [
  49136. "Common Development and Distribution License 1.1",
  49137. false,
  49138. false
  49139. ],
  49140. "CDL-1.0": [
  49141. "Common Documentation License 1.0",
  49142. false,
  49143. false
  49144. ],
  49145. "CDLA-Permissive-1.0": [
  49146. "Community Data License Agreement Permissive 1.0",
  49147. false,
  49148. false
  49149. ],
  49150. "CDLA-Permissive-2.0": [
  49151. "Community Data License Agreement Permissive 2.0",
  49152. false,
  49153. false
  49154. ],
  49155. "CDLA-Sharing-1.0": [
  49156. "Community Data License Agreement Sharing 1.0",
  49157. false,
  49158. false
  49159. ],
  49160. "CECILL-1.0": [
  49161. "CeCILL Free Software License Agreement v1.0",
  49162. false,
  49163. false
  49164. ],
  49165. "CECILL-1.1": [
  49166. "CeCILL Free Software License Agreement v1.1",
  49167. false,
  49168. false
  49169. ],
  49170. "CECILL-2.0": [
  49171. "CeCILL Free Software License Agreement v2.0",
  49172. false,
  49173. false
  49174. ],
  49175. "CECILL-2.1": [
  49176. "CeCILL Free Software License Agreement v2.1",
  49177. true,
  49178. false
  49179. ],
  49180. "CECILL-B": [
  49181. "CeCILL-B Free Software License Agreement",
  49182. false,
  49183. false
  49184. ],
  49185. "CECILL-C": [
  49186. "CeCILL-C Free Software License Agreement",
  49187. false,
  49188. false
  49189. ],
  49190. "CERN-OHL-1.1": [
  49191. "CERN Open Hardware Licence v1.1",
  49192. false,
  49193. false
  49194. ],
  49195. "CERN-OHL-1.2": [
  49196. "CERN Open Hardware Licence v1.2",
  49197. false,
  49198. false
  49199. ],
  49200. "CERN-OHL-P-2.0": [
  49201. "CERN Open Hardware Licence Version 2 - Permissive",
  49202. true,
  49203. false
  49204. ],
  49205. "CERN-OHL-S-2.0": [
  49206. "CERN Open Hardware Licence Version 2 - Strongly Reciprocal",
  49207. true,
  49208. false
  49209. ],
  49210. "CERN-OHL-W-2.0": [
  49211. "CERN Open Hardware Licence Version 2 - Weakly Reciprocal",
  49212. true,
  49213. false
  49214. ],
  49215. "ClArtistic": [
  49216. "Clarified Artistic License",
  49217. false,
  49218. false
  49219. ],
  49220. "CNRI-Jython": [
  49221. "CNRI Jython License",
  49222. false,
  49223. false
  49224. ],
  49225. "CNRI-Python": [
  49226. "CNRI Python License",
  49227. true,
  49228. false
  49229. ],
  49230. "CNRI-Python-GPL-Compatible": [
  49231. "CNRI Python Open Source GPL Compatible License Agreement",
  49232. false,
  49233. false
  49234. ],
  49235. "COIL-1.0": [
  49236. "Copyfree Open Innovation License",
  49237. false,
  49238. false
  49239. ],
  49240. "Community-Spec-1.0": [
  49241. "Community Specification License 1.0",
  49242. false,
  49243. false
  49244. ],
  49245. "Condor-1.1": [
  49246. "Condor Public License v1.1",
  49247. false,
  49248. false
  49249. ],
  49250. "copyleft-next-0.3.0": [
  49251. "copyleft-next 0.3.0",
  49252. false,
  49253. false
  49254. ],
  49255. "copyleft-next-0.3.1": [
  49256. "copyleft-next 0.3.1",
  49257. false,
  49258. false
  49259. ],
  49260. "CPAL-1.0": [
  49261. "Common Public Attribution License 1.0",
  49262. true,
  49263. false
  49264. ],
  49265. "CPL-1.0": [
  49266. "Common Public License 1.0",
  49267. true,
  49268. false
  49269. ],
  49270. "CPOL-1.02": [
  49271. "Code Project Open License 1.02",
  49272. false,
  49273. false
  49274. ],
  49275. "Crossword": [
  49276. "Crossword License",
  49277. false,
  49278. false
  49279. ],
  49280. "CrystalStacker": [
  49281. "CrystalStacker License",
  49282. false,
  49283. false
  49284. ],
  49285. "CUA-OPL-1.0": [
  49286. "CUA Office Public License v1.0",
  49287. true,
  49288. false
  49289. ],
  49290. "Cube": [
  49291. "Cube License",
  49292. false,
  49293. false
  49294. ],
  49295. "curl": [
  49296. "curl License",
  49297. false,
  49298. false
  49299. ],
  49300. "D-FSL-1.0": [
  49301. "Deutsche Freie Software Lizenz",
  49302. false,
  49303. false
  49304. ],
  49305. "diffmark": [
  49306. "diffmark license",
  49307. false,
  49308. false
  49309. ],
  49310. "DL-DE-BY-2.0": [
  49311. "Data licence Germany \u2013 attribution \u2013 version 2.0",
  49312. false,
  49313. false
  49314. ],
  49315. "DOC": [
  49316. "DOC License",
  49317. false,
  49318. false
  49319. ],
  49320. "Dotseqn": [
  49321. "Dotseqn License",
  49322. false,
  49323. false
  49324. ],
  49325. "DRL-1.0": [
  49326. "Detection Rule License 1.0",
  49327. false,
  49328. false
  49329. ],
  49330. "DSDP": [
  49331. "DSDP License",
  49332. false,
  49333. false
  49334. ],
  49335. "dvipdfm": [
  49336. "dvipdfm License",
  49337. false,
  49338. false
  49339. ],
  49340. "ECL-1.0": [
  49341. "Educational Community License v1.0",
  49342. true,
  49343. false
  49344. ],
  49345. "ECL-2.0": [
  49346. "Educational Community License v2.0",
  49347. true,
  49348. false
  49349. ],
  49350. "eCos-2.0": [
  49351. "eCos license version 2.0",
  49352. false,
  49353. true
  49354. ],
  49355. "EFL-1.0": [
  49356. "Eiffel Forum License v1.0",
  49357. true,
  49358. false
  49359. ],
  49360. "EFL-2.0": [
  49361. "Eiffel Forum License v2.0",
  49362. true,
  49363. false
  49364. ],
  49365. "eGenix": [
  49366. "eGenix.com Public License 1.1.0",
  49367. false,
  49368. false
  49369. ],
  49370. "Elastic-2.0": [
  49371. "Elastic License 2.0",
  49372. false,
  49373. false
  49374. ],
  49375. "Entessa": [
  49376. "Entessa Public License v1.0",
  49377. true,
  49378. false
  49379. ],
  49380. "EPICS": [
  49381. "EPICS Open License",
  49382. false,
  49383. false
  49384. ],
  49385. "EPL-1.0": [
  49386. "Eclipse Public License 1.0",
  49387. true,
  49388. false
  49389. ],
  49390. "EPL-2.0": [
  49391. "Eclipse Public License 2.0",
  49392. true,
  49393. false
  49394. ],
  49395. "ErlPL-1.1": [
  49396. "Erlang Public License v1.1",
  49397. false,
  49398. false
  49399. ],
  49400. "etalab-2.0": [
  49401. "Etalab Open License 2.0",
  49402. false,
  49403. false
  49404. ],
  49405. "EUDatagrid": [
  49406. "EU DataGrid Software License",
  49407. true,
  49408. false
  49409. ],
  49410. "EUPL-1.0": [
  49411. "European Union Public License 1.0",
  49412. false,
  49413. false
  49414. ],
  49415. "EUPL-1.1": [
  49416. "European Union Public License 1.1",
  49417. true,
  49418. false
  49419. ],
  49420. "EUPL-1.2": [
  49421. "European Union Public License 1.2",
  49422. true,
  49423. false
  49424. ],
  49425. "Eurosym": [
  49426. "Eurosym License",
  49427. false,
  49428. false
  49429. ],
  49430. "Fair": [
  49431. "Fair License",
  49432. true,
  49433. false
  49434. ],
  49435. "FDK-AAC": [
  49436. "Fraunhofer FDK AAC Codec Library",
  49437. false,
  49438. false
  49439. ],
  49440. "Frameworx-1.0": [
  49441. "Frameworx Open License 1.0",
  49442. true,
  49443. false
  49444. ],
  49445. "FreeBSD-DOC": [
  49446. "FreeBSD Documentation License",
  49447. false,
  49448. false
  49449. ],
  49450. "FreeImage": [
  49451. "FreeImage Public License v1.0",
  49452. false,
  49453. false
  49454. ],
  49455. "FSFAP": [
  49456. "FSF All Permissive License",
  49457. false,
  49458. false
  49459. ],
  49460. "FSFUL": [
  49461. "FSF Unlimited License",
  49462. false,
  49463. false
  49464. ],
  49465. "FSFULLR": [
  49466. "FSF Unlimited License (with License Retention)",
  49467. false,
  49468. false
  49469. ],
  49470. "FTL": [
  49471. "Freetype Project License",
  49472. false,
  49473. false
  49474. ],
  49475. "GD": [
  49476. "GD License",
  49477. false,
  49478. false
  49479. ],
  49480. "GFDL-1.1": [
  49481. "GNU Free Documentation License v1.1",
  49482. false,
  49483. true
  49484. ],
  49485. "GFDL-1.1-invariants-only": [
  49486. "GNU Free Documentation License v1.1 only - invariants",
  49487. false,
  49488. false
  49489. ],
  49490. "GFDL-1.1-invariants-or-later": [
  49491. "GNU Free Documentation License v1.1 or later - invariants",
  49492. false,
  49493. false
  49494. ],
  49495. "GFDL-1.1-no-invariants-only": [
  49496. "GNU Free Documentation License v1.1 only - no invariants",
  49497. false,
  49498. false
  49499. ],
  49500. "GFDL-1.1-no-invariants-or-later": [
  49501. "GNU Free Documentation License v1.1 or later - no invariants",
  49502. false,
  49503. false
  49504. ],
  49505. "GFDL-1.1-only": [
  49506. "GNU Free Documentation License v1.1 only",
  49507. false,
  49508. false
  49509. ],
  49510. "GFDL-1.1-or-later": [
  49511. "GNU Free Documentation License v1.1 or later",
  49512. false,
  49513. false
  49514. ],
  49515. "GFDL-1.2": [
  49516. "GNU Free Documentation License v1.2",
  49517. false,
  49518. true
  49519. ],
  49520. "GFDL-1.2-invariants-only": [
  49521. "GNU Free Documentation License v1.2 only - invariants",
  49522. false,
  49523. false
  49524. ],
  49525. "GFDL-1.2-invariants-or-later": [
  49526. "GNU Free Documentation License v1.2 or later - invariants",
  49527. false,
  49528. false
  49529. ],
  49530. "GFDL-1.2-no-invariants-only": [
  49531. "GNU Free Documentation License v1.2 only - no invariants",
  49532. false,
  49533. false
  49534. ],
  49535. "GFDL-1.2-no-invariants-or-later": [
  49536. "GNU Free Documentation License v1.2 or later - no invariants",
  49537. false,
  49538. false
  49539. ],
  49540. "GFDL-1.2-only": [
  49541. "GNU Free Documentation License v1.2 only",
  49542. false,
  49543. false
  49544. ],
  49545. "GFDL-1.2-or-later": [
  49546. "GNU Free Documentation License v1.2 or later",
  49547. false,
  49548. false
  49549. ],
  49550. "GFDL-1.3": [
  49551. "GNU Free Documentation License v1.3",
  49552. false,
  49553. true
  49554. ],
  49555. "GFDL-1.3-invariants-only": [
  49556. "GNU Free Documentation License v1.3 only - invariants",
  49557. false,
  49558. false
  49559. ],
  49560. "GFDL-1.3-invariants-or-later": [
  49561. "GNU Free Documentation License v1.3 or later - invariants",
  49562. false,
  49563. false
  49564. ],
  49565. "GFDL-1.3-no-invariants-only": [
  49566. "GNU Free Documentation License v1.3 only - no invariants",
  49567. false,
  49568. false
  49569. ],
  49570. "GFDL-1.3-no-invariants-or-later": [
  49571. "GNU Free Documentation License v1.3 or later - no invariants",
  49572. false,
  49573. false
  49574. ],
  49575. "GFDL-1.3-only": [
  49576. "GNU Free Documentation License v1.3 only",
  49577. false,
  49578. false
  49579. ],
  49580. "GFDL-1.3-or-later": [
  49581. "GNU Free Documentation License v1.3 or later",
  49582. false,
  49583. false
  49584. ],
  49585. "Giftware": [
  49586. "Giftware License",
  49587. false,
  49588. false
  49589. ],
  49590. "GL2PS": [
  49591. "GL2PS License",
  49592. false,
  49593. false
  49594. ],
  49595. "Glide": [
  49596. "3dfx Glide License",
  49597. false,
  49598. false
  49599. ],
  49600. "Glulxe": [
  49601. "Glulxe License",
  49602. false,
  49603. false
  49604. ],
  49605. "GLWTPL": [
  49606. "Good Luck With That Public License",
  49607. false,
  49608. false
  49609. ],
  49610. "gnuplot": [
  49611. "gnuplot License",
  49612. false,
  49613. false
  49614. ],
  49615. "GPL-1.0": [
  49616. "GNU General Public License v1.0 only",
  49617. false,
  49618. true
  49619. ],
  49620. "GPL-1.0+": [
  49621. "GNU General Public License v1.0 or later",
  49622. false,
  49623. true
  49624. ],
  49625. "GPL-1.0-only": [
  49626. "GNU General Public License v1.0 only",
  49627. false,
  49628. false
  49629. ],
  49630. "GPL-1.0-or-later": [
  49631. "GNU General Public License v1.0 or later",
  49632. false,
  49633. false
  49634. ],
  49635. "GPL-2.0": [
  49636. "GNU General Public License v2.0 only",
  49637. true,
  49638. true
  49639. ],
  49640. "GPL-2.0+": [
  49641. "GNU General Public License v2.0 or later",
  49642. true,
  49643. true
  49644. ],
  49645. "GPL-2.0-only": [
  49646. "GNU General Public License v2.0 only",
  49647. true,
  49648. false
  49649. ],
  49650. "GPL-2.0-or-later": [
  49651. "GNU General Public License v2.0 or later",
  49652. true,
  49653. false
  49654. ],
  49655. "GPL-2.0-with-autoconf-exception": [
  49656. "GNU General Public License v2.0 w/Autoconf exception",
  49657. false,
  49658. true
  49659. ],
  49660. "GPL-2.0-with-bison-exception": [
  49661. "GNU General Public License v2.0 w/Bison exception",
  49662. false,
  49663. true
  49664. ],
  49665. "GPL-2.0-with-classpath-exception": [
  49666. "GNU General Public License v2.0 w/Classpath exception",
  49667. false,
  49668. true
  49669. ],
  49670. "GPL-2.0-with-font-exception": [
  49671. "GNU General Public License v2.0 w/Font exception",
  49672. false,
  49673. true
  49674. ],
  49675. "GPL-2.0-with-GCC-exception": [
  49676. "GNU General Public License v2.0 w/GCC Runtime Library exception",
  49677. false,
  49678. true
  49679. ],
  49680. "GPL-3.0": [
  49681. "GNU General Public License v3.0 only",
  49682. true,
  49683. true
  49684. ],
  49685. "GPL-3.0+": [
  49686. "GNU General Public License v3.0 or later",
  49687. true,
  49688. true
  49689. ],
  49690. "GPL-3.0-only": [
  49691. "GNU General Public License v3.0 only",
  49692. true,
  49693. false
  49694. ],
  49695. "GPL-3.0-or-later": [
  49696. "GNU General Public License v3.0 or later",
  49697. true,
  49698. false
  49699. ],
  49700. "GPL-3.0-with-autoconf-exception": [
  49701. "GNU General Public License v3.0 w/Autoconf exception",
  49702. false,
  49703. true
  49704. ],
  49705. "GPL-3.0-with-GCC-exception": [
  49706. "GNU General Public License v3.0 w/GCC Runtime Library exception",
  49707. true,
  49708. true
  49709. ],
  49710. "gSOAP-1.3b": [
  49711. "gSOAP Public License v1.3b",
  49712. false,
  49713. false
  49714. ],
  49715. "HaskellReport": [
  49716. "Haskell Language Report License",
  49717. false,
  49718. false
  49719. ],
  49720. "Hippocratic-2.1": [
  49721. "Hippocratic License 2.1",
  49722. false,
  49723. false
  49724. ],
  49725. "HPND": [
  49726. "Historical Permission Notice and Disclaimer",
  49727. true,
  49728. false
  49729. ],
  49730. "HPND-sell-variant": [
  49731. "Historical Permission Notice and Disclaimer - sell variant",
  49732. false,
  49733. false
  49734. ],
  49735. "HTMLTIDY": [
  49736. "HTML Tidy License",
  49737. false,
  49738. false
  49739. ],
  49740. "IBM-pibs": [
  49741. "IBM PowerPC Initialization and Boot Software",
  49742. false,
  49743. false
  49744. ],
  49745. "ICU": [
  49746. "ICU License",
  49747. false,
  49748. false
  49749. ],
  49750. "IJG": [
  49751. "Independent JPEG Group License",
  49752. false,
  49753. false
  49754. ],
  49755. "ImageMagick": [
  49756. "ImageMagick License",
  49757. false,
  49758. false
  49759. ],
  49760. "iMatix": [
  49761. "iMatix Standard Function Library Agreement",
  49762. false,
  49763. false
  49764. ],
  49765. "Imlib2": [
  49766. "Imlib2 License",
  49767. false,
  49768. false
  49769. ],
  49770. "Info-ZIP": [
  49771. "Info-ZIP License",
  49772. false,
  49773. false
  49774. ],
  49775. "Intel": [
  49776. "Intel Open Source License",
  49777. true,
  49778. false
  49779. ],
  49780. "Intel-ACPI": [
  49781. "Intel ACPI Software License Agreement",
  49782. false,
  49783. false
  49784. ],
  49785. "Interbase-1.0": [
  49786. "Interbase Public License v1.0",
  49787. false,
  49788. false
  49789. ],
  49790. "IPA": [
  49791. "IPA Font License",
  49792. true,
  49793. false
  49794. ],
  49795. "IPL-1.0": [
  49796. "IBM Public License v1.0",
  49797. true,
  49798. false
  49799. ],
  49800. "ISC": [
  49801. "ISC License",
  49802. true,
  49803. false
  49804. ],
  49805. "Jam": [
  49806. "Jam License",
  49807. true,
  49808. false
  49809. ],
  49810. "JasPer-2.0": [
  49811. "JasPer License",
  49812. false,
  49813. false
  49814. ],
  49815. "JPNIC": [
  49816. "Japan Network Information Center License",
  49817. false,
  49818. false
  49819. ],
  49820. "JSON": [
  49821. "JSON License",
  49822. false,
  49823. false
  49824. ],
  49825. "KiCad-libraries-exception": [
  49826. "KiCad Libraries Exception",
  49827. false,
  49828. false
  49829. ],
  49830. "LAL-1.2": [
  49831. "Licence Art Libre 1.2",
  49832. false,
  49833. false
  49834. ],
  49835. "LAL-1.3": [
  49836. "Licence Art Libre 1.3",
  49837. false,
  49838. false
  49839. ],
  49840. "Latex2e": [
  49841. "Latex2e License",
  49842. false,
  49843. false
  49844. ],
  49845. "Leptonica": [
  49846. "Leptonica License",
  49847. false,
  49848. false
  49849. ],
  49850. "LGPL-2.0": [
  49851. "GNU Library General Public License v2 only",
  49852. true,
  49853. true
  49854. ],
  49855. "LGPL-2.0+": [
  49856. "GNU Library General Public License v2 or later",
  49857. true,
  49858. true
  49859. ],
  49860. "LGPL-2.0-only": [
  49861. "GNU Library General Public License v2 only",
  49862. true,
  49863. false
  49864. ],
  49865. "LGPL-2.0-or-later": [
  49866. "GNU Library General Public License v2 or later",
  49867. true,
  49868. false
  49869. ],
  49870. "LGPL-2.1": [
  49871. "GNU Lesser General Public License v2.1 only",
  49872. true,
  49873. true
  49874. ],
  49875. "LGPL-2.1+": [
  49876. "GNU Library General Public License v2.1 or later",
  49877. true,
  49878. true
  49879. ],
  49880. "LGPL-2.1-only": [
  49881. "GNU Lesser General Public License v2.1 only",
  49882. true,
  49883. false
  49884. ],
  49885. "LGPL-2.1-or-later": [
  49886. "GNU Lesser General Public License v2.1 or later",
  49887. true,
  49888. false
  49889. ],
  49890. "LGPL-3.0": [
  49891. "GNU Lesser General Public License v3.0 only",
  49892. true,
  49893. true
  49894. ],
  49895. "LGPL-3.0+": [
  49896. "GNU Lesser General Public License v3.0 or later",
  49897. true,
  49898. true
  49899. ],
  49900. "LGPL-3.0-only": [
  49901. "GNU Lesser General Public License v3.0 only",
  49902. true,
  49903. false
  49904. ],
  49905. "LGPL-3.0-or-later": [
  49906. "GNU Lesser General Public License v3.0 or later",
  49907. true,
  49908. false
  49909. ],
  49910. "LGPLLR": [
  49911. "Lesser General Public License For Linguistic Resources",
  49912. false,
  49913. false
  49914. ],
  49915. "Libpng": [
  49916. "libpng License",
  49917. false,
  49918. false
  49919. ],
  49920. "libpng-2.0": [
  49921. "PNG Reference Library version 2",
  49922. false,
  49923. false
  49924. ],
  49925. "libselinux-1.0": [
  49926. "libselinux public domain notice",
  49927. false,
  49928. false
  49929. ],
  49930. "libtiff": [
  49931. "libtiff License",
  49932. false,
  49933. false
  49934. ],
  49935. "LiLiQ-P-1.1": [
  49936. "Licence Libre du Qu\u00e9bec \u2013 Permissive version 1.1",
  49937. true,
  49938. false
  49939. ],
  49940. "LiLiQ-R-1.1": [
  49941. "Licence Libre du Qu\u00e9bec \u2013 R\u00e9ciprocit\u00e9 version 1.1",
  49942. true,
  49943. false
  49944. ],
  49945. "LiLiQ-Rplus-1.1": [
  49946. "Licence Libre du Qu\u00e9bec \u2013 R\u00e9ciprocit\u00e9 forte version 1.1",
  49947. true,
  49948. false
  49949. ],
  49950. "Linux-man-pages-copyleft": [
  49951. "Linux man-pages Copyleft",
  49952. false,
  49953. false
  49954. ],
  49955. "Linux-OpenIB": [
  49956. "Linux Kernel Variant of OpenIB.org license",
  49957. false,
  49958. false
  49959. ],
  49960. "LPL-1.0": [
  49961. "Lucent Public License Version 1.0",
  49962. true,
  49963. false
  49964. ],
  49965. "LPL-1.02": [
  49966. "Lucent Public License v1.02",
  49967. true,
  49968. false
  49969. ],
  49970. "LPPL-1.0": [
  49971. "LaTeX Project Public License v1.0",
  49972. false,
  49973. false
  49974. ],
  49975. "LPPL-1.1": [
  49976. "LaTeX Project Public License v1.1",
  49977. false,
  49978. false
  49979. ],
  49980. "LPPL-1.2": [
  49981. "LaTeX Project Public License v1.2",
  49982. false,
  49983. false
  49984. ],
  49985. "LPPL-1.3a": [
  49986. "LaTeX Project Public License v1.3a",
  49987. false,
  49988. false
  49989. ],
  49990. "LPPL-1.3c": [
  49991. "LaTeX Project Public License v1.3c",
  49992. true,
  49993. false
  49994. ],
  49995. "MakeIndex": [
  49996. "MakeIndex License",
  49997. false,
  49998. false
  49999. ],
  50000. "MirOS": [
  50001. "The MirOS Licence",
  50002. true,
  50003. false
  50004. ],
  50005. "MIT": [
  50006. "MIT License",
  50007. true,
  50008. false
  50009. ],
  50010. "MIT-0": [
  50011. "MIT No Attribution",
  50012. true,
  50013. false
  50014. ],
  50015. "MIT-advertising": [
  50016. "Enlightenment License (e16)",
  50017. false,
  50018. false
  50019. ],
  50020. "MIT-CMU": [
  50021. "CMU License",
  50022. false,
  50023. false
  50024. ],
  50025. "MIT-enna": [
  50026. "enna License",
  50027. false,
  50028. false
  50029. ],
  50030. "MIT-feh": [
  50031. "feh License",
  50032. false,
  50033. false
  50034. ],
  50035. "MIT-Modern-Variant": [
  50036. "MIT License Modern Variant",
  50037. true,
  50038. false
  50039. ],
  50040. "MIT-open-group": [
  50041. "MIT Open Group variant",
  50042. false,
  50043. false
  50044. ],
  50045. "MITNFA": [
  50046. "MIT +no-false-attribs license",
  50047. false,
  50048. false
  50049. ],
  50050. "Motosoto": [
  50051. "Motosoto License",
  50052. true,
  50053. false
  50054. ],
  50055. "mpich2": [
  50056. "mpich2 License",
  50057. false,
  50058. false
  50059. ],
  50060. "MPL-1.0": [
  50061. "Mozilla Public License 1.0",
  50062. true,
  50063. false
  50064. ],
  50065. "MPL-1.1": [
  50066. "Mozilla Public License 1.1",
  50067. true,
  50068. false
  50069. ],
  50070. "MPL-2.0": [
  50071. "Mozilla Public License 2.0",
  50072. true,
  50073. false
  50074. ],
  50075. "MPL-2.0-no-copyleft-exception": [
  50076. "Mozilla Public License 2.0 (no copyleft exception)",
  50077. true,
  50078. false
  50079. ],
  50080. "mplus": [
  50081. "mplus Font License",
  50082. false,
  50083. false
  50084. ],
  50085. "MS-PL": [
  50086. "Microsoft Public License",
  50087. true,
  50088. false
  50089. ],
  50090. "MS-RL": [
  50091. "Microsoft Reciprocal License",
  50092. true,
  50093. false
  50094. ],
  50095. "MTLL": [
  50096. "Matrix Template Library License",
  50097. false,
  50098. false
  50099. ],
  50100. "MulanPSL-1.0": [
  50101. "Mulan Permissive Software License, Version 1",
  50102. false,
  50103. false
  50104. ],
  50105. "MulanPSL-2.0": [
  50106. "Mulan Permissive Software License, Version 2",
  50107. true,
  50108. false
  50109. ],
  50110. "Multics": [
  50111. "Multics License",
  50112. true,
  50113. false
  50114. ],
  50115. "Mup": [
  50116. "Mup License",
  50117. false,
  50118. false
  50119. ],
  50120. "NAIST-2003": [
  50121. "Nara Institute of Science and Technology License (2003)",
  50122. false,
  50123. false
  50124. ],
  50125. "NASA-1.3": [
  50126. "NASA Open Source Agreement 1.3",
  50127. true,
  50128. false
  50129. ],
  50130. "Naumen": [
  50131. "Naumen Public License",
  50132. true,
  50133. false
  50134. ],
  50135. "NBPL-1.0": [
  50136. "Net Boolean Public License v1",
  50137. false,
  50138. false
  50139. ],
  50140. "NCGL-UK-2.0": [
  50141. "Non-Commercial Government Licence",
  50142. false,
  50143. false
  50144. ],
  50145. "NCSA": [
  50146. "University of Illinois/NCSA Open Source License",
  50147. true,
  50148. false
  50149. ],
  50150. "Net-SNMP": [
  50151. "Net-SNMP License",
  50152. false,
  50153. false
  50154. ],
  50155. "NetCDF": [
  50156. "NetCDF license",
  50157. false,
  50158. false
  50159. ],
  50160. "Newsletr": [
  50161. "Newsletr License",
  50162. false,
  50163. false
  50164. ],
  50165. "NGPL": [
  50166. "Nethack General Public License",
  50167. true,
  50168. false
  50169. ],
  50170. "NIST-PD": [
  50171. "NIST Public Domain Notice",
  50172. false,
  50173. false
  50174. ],
  50175. "NIST-PD-fallback": [
  50176. "NIST Public Domain Notice with license fallback",
  50177. false,
  50178. false
  50179. ],
  50180. "NLOD-1.0": [
  50181. "Norwegian Licence for Open Government Data (NLOD) 1.0",
  50182. false,
  50183. false
  50184. ],
  50185. "NLOD-2.0": [
  50186. "Norwegian Licence for Open Government Data (NLOD) 2.0",
  50187. false,
  50188. false
  50189. ],
  50190. "NLPL": [
  50191. "No Limit Public License",
  50192. false,
  50193. false
  50194. ],
  50195. "Nokia": [
  50196. "Nokia Open Source License",
  50197. true,
  50198. false
  50199. ],
  50200. "NOSL": [
  50201. "Netizen Open Source License",
  50202. false,
  50203. false
  50204. ],
  50205. "Noweb": [
  50206. "Noweb License",
  50207. false,
  50208. false
  50209. ],
  50210. "NPL-1.0": [
  50211. "Netscape Public License v1.0",
  50212. false,
  50213. false
  50214. ],
  50215. "NPL-1.1": [
  50216. "Netscape Public License v1.1",
  50217. false,
  50218. false
  50219. ],
  50220. "NPOSL-3.0": [
  50221. "Non-Profit Open Software License 3.0",
  50222. true,
  50223. false
  50224. ],
  50225. "NRL": [
  50226. "NRL License",
  50227. false,
  50228. false
  50229. ],
  50230. "NTP": [
  50231. "NTP License",
  50232. true,
  50233. false
  50234. ],
  50235. "NTP-0": [
  50236. "NTP No Attribution",
  50237. false,
  50238. false
  50239. ],
  50240. "Nunit": [
  50241. "Nunit License",
  50242. false,
  50243. true
  50244. ],
  50245. "O-UDA-1.0": [
  50246. "Open Use of Data Agreement v1.0",
  50247. false,
  50248. false
  50249. ],
  50250. "OCCT-PL": [
  50251. "Open CASCADE Technology Public License",
  50252. false,
  50253. false
  50254. ],
  50255. "OCLC-2.0": [
  50256. "OCLC Research Public License 2.0",
  50257. true,
  50258. false
  50259. ],
  50260. "ODbL-1.0": [
  50261. "Open Data Commons Open Database License v1.0",
  50262. false,
  50263. false
  50264. ],
  50265. "ODC-By-1.0": [
  50266. "Open Data Commons Attribution License v1.0",
  50267. false,
  50268. false
  50269. ],
  50270. "OFL-1.0": [
  50271. "SIL Open Font License 1.0",
  50272. false,
  50273. false
  50274. ],
  50275. "OFL-1.0-no-RFN": [
  50276. "SIL Open Font License 1.0 with no Reserved Font Name",
  50277. false,
  50278. false
  50279. ],
  50280. "OFL-1.0-RFN": [
  50281. "SIL Open Font License 1.0 with Reserved Font Name",
  50282. false,
  50283. false
  50284. ],
  50285. "OFL-1.1": [
  50286. "SIL Open Font License 1.1",
  50287. true,
  50288. false
  50289. ],
  50290. "OFL-1.1-no-RFN": [
  50291. "SIL Open Font License 1.1 with no Reserved Font Name",
  50292. true,
  50293. false
  50294. ],
  50295. "OFL-1.1-RFN": [
  50296. "SIL Open Font License 1.1 with Reserved Font Name",
  50297. true,
  50298. false
  50299. ],
  50300. "OGC-1.0": [
  50301. "OGC Software License, Version 1.0",
  50302. false,
  50303. false
  50304. ],
  50305. "OGDL-Taiwan-1.0": [
  50306. "Taiwan Open Government Data License, version 1.0",
  50307. false,
  50308. false
  50309. ],
  50310. "OGL-Canada-2.0": [
  50311. "Open Government Licence - Canada",
  50312. false,
  50313. false
  50314. ],
  50315. "OGL-UK-1.0": [
  50316. "Open Government Licence v1.0",
  50317. false,
  50318. false
  50319. ],
  50320. "OGL-UK-2.0": [
  50321. "Open Government Licence v2.0",
  50322. false,
  50323. false
  50324. ],
  50325. "OGL-UK-3.0": [
  50326. "Open Government Licence v3.0",
  50327. false,
  50328. false
  50329. ],
  50330. "OGTSL": [
  50331. "Open Group Test Suite License",
  50332. true,
  50333. false
  50334. ],
  50335. "OLDAP-1.1": [
  50336. "Open LDAP Public License v1.1",
  50337. false,
  50338. false
  50339. ],
  50340. "OLDAP-1.2": [
  50341. "Open LDAP Public License v1.2",
  50342. false,
  50343. false
  50344. ],
  50345. "OLDAP-1.3": [
  50346. "Open LDAP Public License v1.3",
  50347. false,
  50348. false
  50349. ],
  50350. "OLDAP-1.4": [
  50351. "Open LDAP Public License v1.4",
  50352. false,
  50353. false
  50354. ],
  50355. "OLDAP-2.0": [
  50356. "Open LDAP Public License v2.0 (or possibly 2.0A and 2.0B)",
  50357. false,
  50358. false
  50359. ],
  50360. "OLDAP-2.0.1": [
  50361. "Open LDAP Public License v2.0.1",
  50362. false,
  50363. false
  50364. ],
  50365. "OLDAP-2.1": [
  50366. "Open LDAP Public License v2.1",
  50367. false,
  50368. false
  50369. ],
  50370. "OLDAP-2.2": [
  50371. "Open LDAP Public License v2.2",
  50372. false,
  50373. false
  50374. ],
  50375. "OLDAP-2.2.1": [
  50376. "Open LDAP Public License v2.2.1",
  50377. false,
  50378. false
  50379. ],
  50380. "OLDAP-2.2.2": [
  50381. "Open LDAP Public License 2.2.2",
  50382. false,
  50383. false
  50384. ],
  50385. "OLDAP-2.3": [
  50386. "Open LDAP Public License v2.3",
  50387. false,
  50388. false
  50389. ],
  50390. "OLDAP-2.4": [
  50391. "Open LDAP Public License v2.4",
  50392. false,
  50393. false
  50394. ],
  50395. "OLDAP-2.5": [
  50396. "Open LDAP Public License v2.5",
  50397. false,
  50398. false
  50399. ],
  50400. "OLDAP-2.6": [
  50401. "Open LDAP Public License v2.6",
  50402. false,
  50403. false
  50404. ],
  50405. "OLDAP-2.7": [
  50406. "Open LDAP Public License v2.7",
  50407. false,
  50408. false
  50409. ],
  50410. "OLDAP-2.8": [
  50411. "Open LDAP Public License v2.8",
  50412. true,
  50413. false
  50414. ],
  50415. "OML": [
  50416. "Open Market License",
  50417. false,
  50418. false
  50419. ],
  50420. "OpenSSL": [
  50421. "OpenSSL License",
  50422. false,
  50423. false
  50424. ],
  50425. "OPL-1.0": [
  50426. "Open Public License v1.0",
  50427. false,
  50428. false
  50429. ],
  50430. "OPUBL-1.0": [
  50431. "Open Publication License v1.0",
  50432. false,
  50433. false
  50434. ],
  50435. "OSET-PL-2.1": [
  50436. "OSET Public License version 2.1",
  50437. true,
  50438. false
  50439. ],
  50440. "OSL-1.0": [
  50441. "Open Software License 1.0",
  50442. true,
  50443. false
  50444. ],
  50445. "OSL-1.1": [
  50446. "Open Software License 1.1",
  50447. false,
  50448. false
  50449. ],
  50450. "OSL-2.0": [
  50451. "Open Software License 2.0",
  50452. true,
  50453. false
  50454. ],
  50455. "OSL-2.1": [
  50456. "Open Software License 2.1",
  50457. true,
  50458. false
  50459. ],
  50460. "OSL-3.0": [
  50461. "Open Software License 3.0",
  50462. true,
  50463. false
  50464. ],
  50465. "Parity-6.0.0": [
  50466. "The Parity Public License 6.0.0",
  50467. false,
  50468. false
  50469. ],
  50470. "Parity-7.0.0": [
  50471. "The Parity Public License 7.0.0",
  50472. false,
  50473. false
  50474. ],
  50475. "PDDL-1.0": [
  50476. "Open Data Commons Public Domain Dedication & License 1.0",
  50477. false,
  50478. false
  50479. ],
  50480. "PHP-3.0": [
  50481. "PHP License v3.0",
  50482. true,
  50483. false
  50484. ],
  50485. "PHP-3.01": [
  50486. "PHP License v3.01",
  50487. true,
  50488. false
  50489. ],
  50490. "Plexus": [
  50491. "Plexus Classworlds License",
  50492. false,
  50493. false
  50494. ],
  50495. "PolyForm-Noncommercial-1.0.0": [
  50496. "PolyForm Noncommercial License 1.0.0",
  50497. false,
  50498. false
  50499. ],
  50500. "PolyForm-Small-Business-1.0.0": [
  50501. "PolyForm Small Business License 1.0.0",
  50502. false,
  50503. false
  50504. ],
  50505. "PostgreSQL": [
  50506. "PostgreSQL License",
  50507. true,
  50508. false
  50509. ],
  50510. "PSF-2.0": [
  50511. "Python Software Foundation License 2.0",
  50512. false,
  50513. false
  50514. ],
  50515. "psfrag": [
  50516. "psfrag License",
  50517. false,
  50518. false
  50519. ],
  50520. "psutils": [
  50521. "psutils License",
  50522. false,
  50523. false
  50524. ],
  50525. "Python-2.0": [
  50526. "Python License 2.0",
  50527. true,
  50528. false
  50529. ],
  50530. "Qhull": [
  50531. "Qhull License",
  50532. false,
  50533. false
  50534. ],
  50535. "QPL-1.0": [
  50536. "Q Public License 1.0",
  50537. true,
  50538. false
  50539. ],
  50540. "Rdisc": [
  50541. "Rdisc License",
  50542. false,
  50543. false
  50544. ],
  50545. "RHeCos-1.1": [
  50546. "Red Hat eCos Public License v1.1",
  50547. false,
  50548. false
  50549. ],
  50550. "RPL-1.1": [
  50551. "Reciprocal Public License 1.1",
  50552. true,
  50553. false
  50554. ],
  50555. "RPL-1.5": [
  50556. "Reciprocal Public License 1.5",
  50557. true,
  50558. false
  50559. ],
  50560. "RPSL-1.0": [
  50561. "RealNetworks Public Source License v1.0",
  50562. true,
  50563. false
  50564. ],
  50565. "RSA-MD": [
  50566. "RSA Message-Digest License",
  50567. false,
  50568. false
  50569. ],
  50570. "RSCPL": [
  50571. "Ricoh Source Code Public License",
  50572. true,
  50573. false
  50574. ],
  50575. "Ruby": [
  50576. "Ruby License",
  50577. false,
  50578. false
  50579. ],
  50580. "SAX-PD": [
  50581. "Sax Public Domain Notice",
  50582. false,
  50583. false
  50584. ],
  50585. "Saxpath": [
  50586. "Saxpath License",
  50587. false,
  50588. false
  50589. ],
  50590. "SCEA": [
  50591. "SCEA Shared Source License",
  50592. false,
  50593. false
  50594. ],
  50595. "SchemeReport": [
  50596. "Scheme Language Report License",
  50597. false,
  50598. false
  50599. ],
  50600. "Sendmail": [
  50601. "Sendmail License",
  50602. false,
  50603. false
  50604. ],
  50605. "Sendmail-8.23": [
  50606. "Sendmail License 8.23",
  50607. false,
  50608. false
  50609. ],
  50610. "SGI-B-1.0": [
  50611. "SGI Free Software License B v1.0",
  50612. false,
  50613. false
  50614. ],
  50615. "SGI-B-1.1": [
  50616. "SGI Free Software License B v1.1",
  50617. false,
  50618. false
  50619. ],
  50620. "SGI-B-2.0": [
  50621. "SGI Free Software License B v2.0",
  50622. false,
  50623. false
  50624. ],
  50625. "SHL-0.5": [
  50626. "Solderpad Hardware License v0.5",
  50627. false,
  50628. false
  50629. ],
  50630. "SHL-0.51": [
  50631. "Solderpad Hardware License, Version 0.51",
  50632. false,
  50633. false
  50634. ],
  50635. "SimPL-2.0": [
  50636. "Simple Public License 2.0",
  50637. true,
  50638. false
  50639. ],
  50640. "SISSL": [
  50641. "Sun Industry Standards Source License v1.1",
  50642. true,
  50643. false
  50644. ],
  50645. "SISSL-1.2": [
  50646. "Sun Industry Standards Source License v1.2",
  50647. false,
  50648. false
  50649. ],
  50650. "Sleepycat": [
  50651. "Sleepycat License",
  50652. true,
  50653. false
  50654. ],
  50655. "SMLNJ": [
  50656. "Standard ML of New Jersey License",
  50657. false,
  50658. false
  50659. ],
  50660. "SMPPL": [
  50661. "Secure Messaging Protocol Public License",
  50662. false,
  50663. false
  50664. ],
  50665. "SNIA": [
  50666. "SNIA Public License 1.1",
  50667. false,
  50668. false
  50669. ],
  50670. "Spencer-86": [
  50671. "Spencer License 86",
  50672. false,
  50673. false
  50674. ],
  50675. "Spencer-94": [
  50676. "Spencer License 94",
  50677. false,
  50678. false
  50679. ],
  50680. "Spencer-99": [
  50681. "Spencer License 99",
  50682. false,
  50683. false
  50684. ],
  50685. "SPL-1.0": [
  50686. "Sun Public License v1.0",
  50687. true,
  50688. false
  50689. ],
  50690. "SSH-OpenSSH": [
  50691. "SSH OpenSSH license",
  50692. false,
  50693. false
  50694. ],
  50695. "SSH-short": [
  50696. "SSH short notice",
  50697. false,
  50698. false
  50699. ],
  50700. "SSPL-1.0": [
  50701. "Server Side Public License, v 1",
  50702. false,
  50703. false
  50704. ],
  50705. "StandardML-NJ": [
  50706. "Standard ML of New Jersey License",
  50707. false,
  50708. true
  50709. ],
  50710. "SugarCRM-1.1.3": [
  50711. "SugarCRM Public License v1.1.3",
  50712. false,
  50713. false
  50714. ],
  50715. "SWL": [
  50716. "Scheme Widget Library (SWL) Software License Agreement",
  50717. false,
  50718. false
  50719. ],
  50720. "TAPR-OHL-1.0": [
  50721. "TAPR Open Hardware License v1.0",
  50722. false,
  50723. false
  50724. ],
  50725. "TCL": [
  50726. "TCL/TK License",
  50727. false,
  50728. false
  50729. ],
  50730. "TCP-wrappers": [
  50731. "TCP Wrappers License",
  50732. false,
  50733. false
  50734. ],
  50735. "TMate": [
  50736. "TMate Open Source License",
  50737. false,
  50738. false
  50739. ],
  50740. "TORQUE-1.1": [
  50741. "TORQUE v2.5+ Software License v1.1",
  50742. false,
  50743. false
  50744. ],
  50745. "TOSL": [
  50746. "Trusster Open Source License",
  50747. false,
  50748. false
  50749. ],
  50750. "TU-Berlin-1.0": [
  50751. "Technische Universitaet Berlin License 1.0",
  50752. false,
  50753. false
  50754. ],
  50755. "TU-Berlin-2.0": [
  50756. "Technische Universitaet Berlin License 2.0",
  50757. false,
  50758. false
  50759. ],
  50760. "UCL-1.0": [
  50761. "Upstream Compatibility License v1.0",
  50762. true,
  50763. false
  50764. ],
  50765. "Unicode-DFS-2015": [
  50766. "Unicode License Agreement - Data Files and Software (2015)",
  50767. false,
  50768. false
  50769. ],
  50770. "Unicode-DFS-2016": [
  50771. "Unicode License Agreement - Data Files and Software (2016)",
  50772. true,
  50773. false
  50774. ],
  50775. "Unicode-TOU": [
  50776. "Unicode Terms of Use",
  50777. false,
  50778. false
  50779. ],
  50780. "Unlicense": [
  50781. "The Unlicense",
  50782. true,
  50783. false
  50784. ],
  50785. "UPL-1.0": [
  50786. "Universal Permissive License v1.0",
  50787. true,
  50788. false
  50789. ],
  50790. "Vim": [
  50791. "Vim License",
  50792. false,
  50793. false
  50794. ],
  50795. "VOSTROM": [
  50796. "VOSTROM Public License for Open Source",
  50797. false,
  50798. false
  50799. ],
  50800. "VSL-1.0": [
  50801. "Vovida Software License v1.0",
  50802. true,
  50803. false
  50804. ],
  50805. "W3C": [
  50806. "W3C Software Notice and License (2002-12-31)",
  50807. true,
  50808. false
  50809. ],
  50810. "W3C-19980720": [
  50811. "W3C Software Notice and License (1998-07-20)",
  50812. false,
  50813. false
  50814. ],
  50815. "W3C-20150513": [
  50816. "W3C Software Notice and Document License (2015-05-13)",
  50817. false,
  50818. false
  50819. ],
  50820. "Watcom-1.0": [
  50821. "Sybase Open Watcom Public License 1.0",
  50822. true,
  50823. false
  50824. ],
  50825. "Wsuipa": [
  50826. "Wsuipa License",
  50827. false,
  50828. false
  50829. ],
  50830. "WTFPL": [
  50831. "Do What The F*ck You Want To Public License",
  50832. false,
  50833. false
  50834. ],
  50835. "wxWindows": [
  50836. "wxWindows Library License",
  50837. true,
  50838. true
  50839. ],
  50840. "X11": [
  50841. "X11 License",
  50842. false,
  50843. false
  50844. ],
  50845. "X11-distribute-modifications-variant": [
  50846. "X11 License Distribution Modification Variant",
  50847. false,
  50848. false
  50849. ],
  50850. "Xerox": [
  50851. "Xerox License",
  50852. false,
  50853. false
  50854. ],
  50855. "XFree86-1.1": [
  50856. "XFree86 License 1.1",
  50857. false,
  50858. false
  50859. ],
  50860. "xinetd": [
  50861. "xinetd License",
  50862. false,
  50863. false
  50864. ],
  50865. "Xnet": [
  50866. "X.Net License",
  50867. true,
  50868. false
  50869. ],
  50870. "xpp": [
  50871. "XPP License",
  50872. false,
  50873. false
  50874. ],
  50875. "XSkat": [
  50876. "XSkat License",
  50877. false,
  50878. false
  50879. ],
  50880. "YPL-1.0": [
  50881. "Yahoo! Public License v1.0",
  50882. false,
  50883. false
  50884. ],
  50885. "YPL-1.1": [
  50886. "Yahoo! Public License v1.1",
  50887. false,
  50888. false
  50889. ],
  50890. "Zed": [
  50891. "Zed License",
  50892. false,
  50893. false
  50894. ],
  50895. "Zend-2.0": [
  50896. "Zend License v2.0",
  50897. false,
  50898. false
  50899. ],
  50900. "Zimbra-1.3": [
  50901. "Zimbra Public License v1.3",
  50902. false,
  50903. false
  50904. ],
  50905. "Zimbra-1.4": [
  50906. "Zimbra Public License v1.4",
  50907. false,
  50908. false
  50909. ],
  50910. "Zlib": [
  50911. "zlib License",
  50912. true,
  50913. false
  50914. ],
  50915. "zlib-acknowledgement": [
  50916. "zlib/libpng License with Acknowledgement",
  50917. false,
  50918. false
  50919. ],
  50920. "ZPL-1.1": [
  50921. "Zope Public License 1.1",
  50922. false,
  50923. false
  50924. ],
  50925. "ZPL-2.0": [
  50926. "Zope Public License 2.0",
  50927. true,
  50928. false
  50929. ],
  50930. "ZPL-2.1": [
  50931. "Zope Public License 2.1",
  50932. true,
  50933. false
  50934. ]
  50935. }<?php
  50936. namespace Composer\Spdx;
  50937. class SpdxLicenses
  50938. {
  50939. const LICENSES_FILE = 'spdx-licenses.json';
  50940. const EXCEPTIONS_FILE = 'spdx-exceptions.json';
  50941. private $licenses;
  50942. private $licensesExpression;
  50943. private $exceptions;
  50944. private $exceptionsExpression;
  50945. public function __construct()
  50946. {
  50947. $this->loadLicenses();
  50948. $this->loadExceptions();
  50949. }
  50950. public function getLicenseByIdentifier($identifier)
  50951. {
  50952. $key = strtolower($identifier);
  50953. if (!isset($this->licenses[$key])) {
  50954. return null;
  50955. }
  50956. list($identifier, $name, $isOsiApproved, $isDeprecatedLicenseId) = $this->licenses[$key];
  50957. return array(
  50958. $name,
  50959. $isOsiApproved,
  50960. 'https://spdx.org/licenses/' . $identifier . '.html#licenseText',
  50961. $isDeprecatedLicenseId,
  50962. );
  50963. }
  50964. public function getLicenses()
  50965. {
  50966. return $this->licenses;
  50967. }
  50968. public function getExceptionByIdentifier($identifier)
  50969. {
  50970. $key = strtolower($identifier);
  50971. if (!isset($this->exceptions[$key])) {
  50972. return null;
  50973. }
  50974. list($identifier, $name) = $this->exceptions[$key];
  50975. return array(
  50976. $name,
  50977. 'https://spdx.org/licenses/' . $identifier . '.html#licenseExceptionText',
  50978. );
  50979. }
  50980. public function getIdentifierByName($name)
  50981. {
  50982. foreach ($this->licenses as $licenseData) {
  50983. if ($licenseData[1] === $name) {
  50984. return $licenseData[0];
  50985. }
  50986. }
  50987. foreach ($this->exceptions as $licenseData) {
  50988. if ($licenseData[1] === $name) {
  50989. return $licenseData[0];
  50990. }
  50991. }
  50992. return null;
  50993. }
  50994. public function isOsiApprovedByIdentifier($identifier)
  50995. {
  50996. return $this->licenses[strtolower($identifier)][2];
  50997. }
  50998. public function isDeprecatedByIdentifier($identifier)
  50999. {
  51000. return $this->licenses[strtolower($identifier)][3];
  51001. }
  51002. public function validate($license)
  51003. {
  51004. if (is_array($license)) {
  51005. $count = count($license);
  51006. if ($count !== count(array_filter($license, 'is_string'))) {
  51007. throw new \InvalidArgumentException('Array of strings expected.');
  51008. }
  51009. $license = $count > 1 ? '(' . implode(' OR ', $license) . ')' : (string) reset($license);
  51010. }
  51011. if (!is_string($license)) {
  51012. throw new \InvalidArgumentException(sprintf(
  51013. 'Array or String expected, %s given.',
  51014. gettype($license)
  51015. ));
  51016. }
  51017. return $this->isValidLicenseString($license);
  51018. }
  51019. public static function getResourcesDir()
  51020. {
  51021. return dirname(__DIR__) . '/res';
  51022. }
  51023. private function loadLicenses()
  51024. {
  51025. if (null !== $this->licenses) {
  51026. return;
  51027. }
  51028. $json = file_get_contents(self::getResourcesDir() . '/' . self::LICENSES_FILE);
  51029. if (false === $json) {
  51030. throw new \RuntimeException('Missing license file in ' . self::getResourcesDir() . '/' . self::LICENSES_FILE);
  51031. }
  51032. $this->licenses = array();
  51033. foreach (json_decode($json, true) as $identifier => $license) {
  51034. $this->licenses[strtolower($identifier)] = array($identifier, $license[0], $license[1], $license[2]);
  51035. }
  51036. }
  51037. private function loadExceptions()
  51038. {
  51039. if (null !== $this->exceptions) {
  51040. return;
  51041. }
  51042. $json = file_get_contents(self::getResourcesDir() . '/' . self::EXCEPTIONS_FILE);
  51043. if (false === $json) {
  51044. throw new \RuntimeException('Missing exceptions file in ' . self::getResourcesDir() . '/' . self::EXCEPTIONS_FILE);
  51045. }
  51046. $this->exceptions = array();
  51047. foreach (json_decode($json, true) as $identifier => $exception) {
  51048. $this->exceptions[strtolower($identifier)] = array($identifier, $exception[0]);
  51049. }
  51050. }
  51051. private function getLicensesExpression()
  51052. {
  51053. if (null === $this->licensesExpression) {
  51054. $licenses = array_map('preg_quote', array_keys($this->licenses));
  51055. rsort($licenses);
  51056. $licenses = implode('|', $licenses);
  51057. $this->licensesExpression = $licenses;
  51058. }
  51059. return $this->licensesExpression;
  51060. }
  51061. private function getExceptionsExpression()
  51062. {
  51063. if (null === $this->exceptionsExpression) {
  51064. $exceptions = array_map('preg_quote', array_keys($this->exceptions));
  51065. rsort($exceptions);
  51066. $exceptions = implode('|', $exceptions);
  51067. $this->exceptionsExpression = $exceptions;
  51068. }
  51069. return $this->exceptionsExpression;
  51070. }
  51071. private function isValidLicenseString($license)
  51072. {
  51073. if (isset($this->licenses[strtolower($license)])) {
  51074. return true;
  51075. }
  51076. $licenses = $this->getLicensesExpression();
  51077. $exceptions = $this->getExceptionsExpression();
  51078. $regex = <<<REGEX
  51079. {
  51080. (?(DEFINE)
  51081. # idstring: 1*( ALPHA / DIGIT / - / . )
  51082. (?<idstring>[\pL\pN.-]{1,})
  51083. # license-id: taken from list
  51084. (?<licenseid>{$licenses})
  51085. # license-exception-id: taken from list
  51086. (?<licenseexceptionid>{$exceptions})
  51087. # license-ref: [DocumentRef-1*(idstring):]LicenseRef-1*(idstring)
  51088. (?<licenseref>(?:DocumentRef-(?&idstring):)?LicenseRef-(?&idstring))
  51089. # simple-expresssion: license-id / license-id+ / license-ref
  51090. (?<simple_expression>(?&licenseid)\+? | (?&licenseid) | (?&licenseref))
  51091. # compound-expression: 1*(
  51092. # simple-expression /
  51093. # simple-expression WITH license-exception-id /
  51094. # compound-expression AND compound-expression /
  51095. # compound-expression OR compound-expression
  51096. # ) / ( compound-expression ) )
  51097. (?<compound_head>
  51098. (?&simple_expression) ( \s+ WITH \s+ (?&licenseexceptionid))?
  51099. | \( \s* (?&compound_expression) \s* \)
  51100. )
  51101. (?<compound_expression>
  51102. (?&compound_head) (?: \s+ (?:AND|OR) \s+ (?&compound_expression))?
  51103. )
  51104. # license-expression: 1*1(simple-expression / compound-expression)
  51105. (?<license_expression>(?&compound_expression) | (?&simple_expression))
  51106. ) # end of define
  51107. ^(NONE | NOASSERTION | (?&license_expression))$
  51108. }xi
  51109. REGEX;
  51110. $match = preg_match($regex, $license);
  51111. if (0 === $match) {
  51112. return false;
  51113. }
  51114. if (false === $match) {
  51115. throw new \RuntimeException('Regex failed to compile/run.');
  51116. }
  51117. return true;
  51118. }
  51119. }
  51120. MIT License
  51121. Copyright (c) 2017 Composer
  51122. Permission is hereby granted, free of charge, to any person obtaining a copy
  51123. of this software and associated documentation files (the "Software"), to deal
  51124. in the Software without restriction, including without limitation the rights
  51125. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  51126. copies of the Software, and to permit persons to whom the Software is
  51127. furnished to do so, subject to the following conditions:
  51128. The above copyright notice and this permission notice shall be included in all
  51129. copies or substantial portions of the Software.
  51130. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  51131. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  51132. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  51133. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  51134. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  51135. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  51136. SOFTWARE.
  51137. <?php
  51138. declare(strict_types=1);
  51139. namespace Composer\XdebugHandler;
  51140. class PhpConfig
  51141. {
  51142. public function useOriginal(): array
  51143. {
  51144. $this->getDataAndReset();
  51145. return [];
  51146. }
  51147. public function useStandard(): array
  51148. {
  51149. $data = $this->getDataAndReset();
  51150. if ($data !== null) {
  51151. return ['-n', '-c', $data['tmpIni']];
  51152. }
  51153. return [];
  51154. }
  51155. public function usePersistent(): array
  51156. {
  51157. $data = $this->getDataAndReset();
  51158. if ($data !== null) {
  51159. $this->updateEnv('PHPRC', $data['tmpIni']);
  51160. $this->updateEnv('PHP_INI_SCAN_DIR', '');
  51161. }
  51162. return [];
  51163. }
  51164. private function getDataAndReset(): ?array
  51165. {
  51166. $data = XdebugHandler::getRestartSettings();
  51167. if ($data !== null) {
  51168. $this->updateEnv('PHPRC', $data['phprc']);
  51169. $this->updateEnv('PHP_INI_SCAN_DIR', $data['scanDir']);
  51170. }
  51171. return $data;
  51172. }
  51173. private function updateEnv(string $name, $value): void
  51174. {
  51175. Process::setEnv($name, false !== $value ? $value : null);
  51176. }
  51177. }
  51178. <?php
  51179. declare(strict_types=1);
  51180. namespace Composer\XdebugHandler;
  51181. use Composer\Pcre\Preg;
  51182. class Process
  51183. {
  51184. public static function escape(string $arg, bool $meta = true, bool $module = false): string
  51185. {
  51186. if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
  51187. return "'".str_replace("'", "'\\''", $arg)."'";
  51188. }
  51189. $quote = strpbrk($arg, " \t") !== false || $arg === '';
  51190. $arg = Preg::replace('/(\\\\*)"/', '$1$1\\"', $arg, -1, $dquotes);
  51191. if ($meta) {
  51192. $meta = $dquotes || Preg::isMatch('/%[^%]+%/', $arg);
  51193. if (!$meta) {
  51194. $quote = $quote || strpbrk($arg, '^&|<>()') !== false;
  51195. } elseif ($module && !$dquotes && $quote) {
  51196. $meta = false;
  51197. }
  51198. }
  51199. if ($quote) {
  51200. $arg = '"'.(Preg::replace('/(\\\\*)$/', '$1$1', $arg)).'"';
  51201. }
  51202. if ($meta) {
  51203. $arg = Preg::replace('/(["^&|<>()%])/', '^$1', $arg);
  51204. }
  51205. return $arg;
  51206. }
  51207. public static function escapeShellCommand(array $args): string
  51208. {
  51209. $command = '';
  51210. $module = array_shift($args);
  51211. if ($module !== null) {
  51212. $command = self::escape($module, true, true);
  51213. foreach ($args as $arg) {
  51214. $command .= ' '.self::escape($arg);
  51215. }
  51216. }
  51217. return $command;
  51218. }
  51219. public static function setEnv(string $name, ?string $value = null): bool
  51220. {
  51221. $unset = null === $value;
  51222. if (!putenv($unset ? $name : $name.'='.$value)) {
  51223. return false;
  51224. }
  51225. if ($unset) {
  51226. unset($_SERVER[$name]);
  51227. } else {
  51228. $_SERVER[$name] = $value;
  51229. }
  51230. if (false !== stripos((string) ini_get('variables_order'), 'E')) {
  51231. if ($unset) {
  51232. unset($_ENV[$name]);
  51233. } else {
  51234. $_ENV[$name] = $value;
  51235. }
  51236. }
  51237. return true;
  51238. }
  51239. }
  51240. <?php
  51241. declare(strict_types=1);
  51242. namespace Composer\XdebugHandler;
  51243. use Psr\Log\LoggerInterface;
  51244. use Psr\Log\LogLevel;
  51245. class Status
  51246. {
  51247. const ENV_RESTART = 'XDEBUG_HANDLER_RESTART';
  51248. const CHECK = 'Check';
  51249. const ERROR = 'Error';
  51250. const INFO = 'Info';
  51251. const NORESTART = 'NoRestart';
  51252. const RESTART = 'Restart';
  51253. const RESTARTING = 'Restarting';
  51254. const RESTARTED = 'Restarted';
  51255. private $debug;
  51256. private $envAllowXdebug;
  51257. private $loaded;
  51258. private $logger;
  51259. private $modeOff;
  51260. private $time;
  51261. public function __construct(string $envAllowXdebug, bool $debug)
  51262. {
  51263. $start = getenv(self::ENV_RESTART);
  51264. Process::setEnv(self::ENV_RESTART);
  51265. $this->time = is_numeric($start) ? round((microtime(true) - $start) * 1000) : 0;
  51266. $this->envAllowXdebug = $envAllowXdebug;
  51267. $this->debug = $debug && defined('STDERR');
  51268. $this->modeOff = false;
  51269. }
  51270. public function setLogger(LoggerInterface $logger): void
  51271. {
  51272. $this->logger = $logger;
  51273. }
  51274. public function report(string $op, ?string $data): void
  51275. {
  51276. if ($this->logger !== null || $this->debug) {
  51277. $callable = [$this, 'report'.$op];
  51278. if (!is_callable($callable)) {
  51279. throw new \InvalidArgumentException('Unknown op handler: '.$op);
  51280. }
  51281. $params = $data !== null ? [$data] : [];
  51282. call_user_func_array($callable, $params);
  51283. }
  51284. }
  51285. private function output(string $text, ?string $level = null): void
  51286. {
  51287. if ($this->logger !== null) {
  51288. $this->logger->log($level !== null ? $level: LogLevel::DEBUG, $text);
  51289. }
  51290. if ($this->debug) {
  51291. fwrite(STDERR, sprintf('xdebug-handler[%d] %s', getmypid(), $text.PHP_EOL));
  51292. }
  51293. }
  51294. private function reportCheck(string $loaded): void
  51295. {
  51296. list($version, $mode) = explode('|', $loaded);
  51297. if ($version !== '') {
  51298. $this->loaded = '('.$version.')'.($mode !== '' ? ' xdebug.mode='.$mode : '');
  51299. }
  51300. $this->modeOff = $mode === 'off';
  51301. $this->output('Checking '.$this->envAllowXdebug);
  51302. }
  51303. private function reportError(string $error): void
  51304. {
  51305. $this->output(sprintf('No restart (%s)', $error), LogLevel::WARNING);
  51306. }
  51307. private function reportInfo(string $info): void
  51308. {
  51309. $this->output($info);
  51310. }
  51311. private function reportNoRestart(): void
  51312. {
  51313. $this->output($this->getLoadedMessage());
  51314. if ($this->loaded !== null) {
  51315. $text = sprintf('No restart (%s)', $this->getEnvAllow());
  51316. if (!((bool) getenv($this->envAllowXdebug))) {
  51317. $text .= ' Allowed by '.($this->modeOff ? 'xdebug.mode' : 'application');
  51318. }
  51319. $this->output($text);
  51320. }
  51321. }
  51322. private function reportRestart(): void
  51323. {
  51324. $this->output($this->getLoadedMessage());
  51325. Process::setEnv(self::ENV_RESTART, (string) microtime(true));
  51326. }
  51327. private function reportRestarted(): void
  51328. {
  51329. $loaded = $this->getLoadedMessage();
  51330. $text = sprintf('Restarted (%d ms). %s', $this->time, $loaded);
  51331. $level = $this->loaded !== null ? LogLevel::WARNING : null;
  51332. $this->output($text, $level);
  51333. }
  51334. private function reportRestarting(string $command): void
  51335. {
  51336. $text = sprintf('Process restarting (%s)', $this->getEnvAllow());
  51337. $this->output($text);
  51338. $text = 'Running '.$command;
  51339. $this->output($text);
  51340. }
  51341. private function getEnvAllow(): string
  51342. {
  51343. return $this->envAllowXdebug.'='.getenv($this->envAllowXdebug);
  51344. }
  51345. private function getLoadedMessage(): string
  51346. {
  51347. $loaded = $this->loaded !== null ? sprintf('loaded %s', $this->loaded) : 'not loaded';
  51348. return 'The Xdebug extension is '.$loaded;
  51349. }
  51350. }
  51351. <?php
  51352. declare(strict_types=1);
  51353. namespace Composer\XdebugHandler;
  51354. use Composer\Pcre\Preg;
  51355. use Psr\Log\LoggerInterface;
  51356. class XdebugHandler
  51357. {
  51358. const SUFFIX_ALLOW = '_ALLOW_XDEBUG';
  51359. const SUFFIX_INIS = '_ORIGINAL_INIS';
  51360. const RESTART_ID = 'internal';
  51361. const RESTART_SETTINGS = 'XDEBUG_HANDLER_SETTINGS';
  51362. const DEBUG = 'XDEBUG_HANDLER_DEBUG';
  51363. protected $tmpIni;
  51364. private static $inRestart;
  51365. private static $name;
  51366. private static $skipped;
  51367. private static $xdebugActive;
  51368. private static $xdebugMode;
  51369. private static $xdebugVersion;
  51370. private $cli;
  51371. private $debug;
  51372. private $envAllowXdebug;
  51373. private $envOriginalInis;
  51374. private $persistent;
  51375. private $script;
  51376. private $statusWriter;
  51377. public function __construct(string $envPrefix)
  51378. {
  51379. if ($envPrefix === '') {
  51380. throw new \RuntimeException('Invalid constructor parameter');
  51381. }
  51382. self::$name = strtoupper($envPrefix);
  51383. $this->envAllowXdebug = self::$name.self::SUFFIX_ALLOW;
  51384. $this->envOriginalInis = self::$name.self::SUFFIX_INIS;
  51385. self::setXdebugDetails();
  51386. self::$inRestart = false;
  51387. if ($this->cli = PHP_SAPI === 'cli') {
  51388. $this->debug = (string) getenv(self::DEBUG);
  51389. }
  51390. $this->statusWriter = new Status($this->envAllowXdebug, (bool) $this->debug);
  51391. }
  51392. public function setLogger(LoggerInterface $logger): self
  51393. {
  51394. $this->statusWriter->setLogger($logger);
  51395. return $this;
  51396. }
  51397. public function setMainScript(string $script): self
  51398. {
  51399. $this->script = $script;
  51400. return $this;
  51401. }
  51402. public function setPersistent(): self
  51403. {
  51404. $this->persistent = true;
  51405. return $this;
  51406. }
  51407. public function check(): void
  51408. {
  51409. $this->notify(Status::CHECK, self::$xdebugVersion.'|'.self::$xdebugMode);
  51410. $envArgs = explode('|', (string) getenv($this->envAllowXdebug));
  51411. if (!((bool) $envArgs[0]) && $this->requiresRestart(self::$xdebugActive)) {
  51412. $this->notify(Status::RESTART);
  51413. if ($this->prepareRestart()) {
  51414. $command = $this->getCommand();
  51415. $this->restart($command);
  51416. }
  51417. return;
  51418. }
  51419. if (self::RESTART_ID === $envArgs[0] && count($envArgs) === 5) {
  51420. $this->notify(Status::RESTARTED);
  51421. Process::setEnv($this->envAllowXdebug);
  51422. self::$inRestart = true;
  51423. if (self::$xdebugVersion === null) {
  51424. self::$skipped = $envArgs[1];
  51425. }
  51426. $this->tryEnableSignals();
  51427. $this->setEnvRestartSettings($envArgs);
  51428. return;
  51429. }
  51430. $this->notify(Status::NORESTART);
  51431. $settings = self::getRestartSettings();
  51432. if ($settings !== null) {
  51433. $this->syncSettings($settings);
  51434. }
  51435. }
  51436. public static function getAllIniFiles(): array
  51437. {
  51438. if (self::$name !== null) {
  51439. $env = getenv(self::$name.self::SUFFIX_INIS);
  51440. if (false !== $env) {
  51441. return explode(PATH_SEPARATOR, $env);
  51442. }
  51443. }
  51444. $paths = [(string) php_ini_loaded_file()];
  51445. $scanned = php_ini_scanned_files();
  51446. if ($scanned !== false) {
  51447. $paths = array_merge($paths, array_map('trim', explode(',', $scanned)));
  51448. }
  51449. return $paths;
  51450. }
  51451. public static function getRestartSettings(): ?array
  51452. {
  51453. $envArgs = explode('|', (string) getenv(self::RESTART_SETTINGS));
  51454. if (count($envArgs) !== 6
  51455. || (!self::$inRestart && php_ini_loaded_file() !== $envArgs[0])) {
  51456. return null;
  51457. }
  51458. return [
  51459. 'tmpIni' => $envArgs[0],
  51460. 'scannedInis' => (bool) $envArgs[1],
  51461. 'scanDir' => '*' === $envArgs[2] ? false : $envArgs[2],
  51462. 'phprc' => '*' === $envArgs[3] ? false : $envArgs[3],
  51463. 'inis' => explode(PATH_SEPARATOR, $envArgs[4]),
  51464. 'skipped' => $envArgs[5],
  51465. ];
  51466. }
  51467. public static function getSkippedVersion(): string
  51468. {
  51469. return (string) self::$skipped;
  51470. }
  51471. public static function isXdebugActive(): bool
  51472. {
  51473. self::setXdebugDetails();
  51474. return self::$xdebugActive;
  51475. }
  51476. protected function requiresRestart(bool $default): bool
  51477. {
  51478. return $default;
  51479. }
  51480. protected function restart(array $command): void
  51481. {
  51482. $this->doRestart($command);
  51483. }
  51484. private function doRestart(array $command): void
  51485. {
  51486. $this->tryEnableSignals();
  51487. $this->notify(Status::RESTARTING, implode(' ', $command));
  51488. if (PHP_VERSION_ID >= 70400) {
  51489. $cmd = $command;
  51490. } else {
  51491. $cmd = Process::escapeShellCommand($command);
  51492. if (defined('PHP_WINDOWS_VERSION_BUILD')) {
  51493. $cmd = '"'.$cmd.'"';
  51494. }
  51495. }
  51496. $process = proc_open($cmd, [], $pipes);
  51497. if (is_resource($process)) {
  51498. $exitCode = proc_close($process);
  51499. }
  51500. if (!isset($exitCode)) {
  51501. $this->notify(Status::ERROR, 'Unable to restart process');
  51502. $exitCode = -1;
  51503. } else {
  51504. $this->notify(Status::INFO, 'Restarted process exited '.$exitCode);
  51505. }
  51506. if ($this->debug === '2') {
  51507. $this->notify(Status::INFO, 'Temp ini saved: '.$this->tmpIni);
  51508. } else {
  51509. @unlink((string) $this->tmpIni);
  51510. }
  51511. exit($exitCode);
  51512. }
  51513. private function prepareRestart(): bool
  51514. {
  51515. $error = null;
  51516. $iniFiles = self::getAllIniFiles();
  51517. $scannedInis = count($iniFiles) > 1;
  51518. $tmpDir = sys_get_temp_dir();
  51519. if (!$this->cli) {
  51520. $error = 'Unsupported SAPI: '.PHP_SAPI;
  51521. } elseif (!$this->checkConfiguration($info)) {
  51522. $error = $info;
  51523. } elseif (!$this->checkMainScript()) {
  51524. $error = 'Unable to access main script: '.$this->script;
  51525. } elseif (!$this->writeTmpIni($iniFiles, $tmpDir, $error)) {
  51526. $error = $error !== null ? $error : 'Unable to create temp ini file at: '.$tmpDir;
  51527. } elseif (!$this->setEnvironment($scannedInis, $iniFiles)) {
  51528. $error = 'Unable to set environment variables';
  51529. }
  51530. if ($error !== null) {
  51531. $this->notify(Status::ERROR, $error);
  51532. }
  51533. return $error === null;
  51534. }
  51535. private function writeTmpIni(array $iniFiles, string $tmpDir, ?string &$error): bool
  51536. {
  51537. if (($tmpfile = @tempnam($tmpDir, '')) === false) {
  51538. return false;
  51539. }
  51540. $this->tmpIni = $tmpfile;
  51541. if ($iniFiles[0] === '') {
  51542. array_shift($iniFiles);
  51543. }
  51544. $content = '';
  51545. $sectionRegex = '/^\s*\[(?:PATH|HOST)\s*=/mi';
  51546. $xdebugRegex = '/^\s*(zend_extension\s*=.*xdebug.*)$/mi';
  51547. foreach ($iniFiles as $file) {
  51548. if (($data = @file_get_contents($file)) === false) {
  51549. $error = 'Unable to read ini: '.$file;
  51550. return false;
  51551. }
  51552. if (Preg::isMatchWithOffsets($sectionRegex, $data, $matches, PREG_OFFSET_CAPTURE)) {
  51553. $data = substr($data, 0, $matches[0][1]);
  51554. }
  51555. $content .= Preg::replace($xdebugRegex, ';$1', $data).PHP_EOL;
  51556. }
  51557. $config = parse_ini_string($content);
  51558. $loaded = ini_get_all(null, false);
  51559. if (false === $config || false === $loaded) {
  51560. $error = 'Unable to parse ini data';
  51561. return false;
  51562. }
  51563. $content .= $this->mergeLoadedConfig($loaded, $config);
  51564. $content .= 'opcache.enable_cli=0'.PHP_EOL;
  51565. return (bool) @file_put_contents($this->tmpIni, $content);
  51566. }
  51567. private function getCommand(): array
  51568. {
  51569. $php = [PHP_BINARY];
  51570. $args = array_slice($_SERVER['argv'], 1);
  51571. if (!$this->persistent) {
  51572. array_push($php, '-n', '-c', $this->tmpIni);
  51573. }
  51574. return array_merge($php, [$this->script], $args);
  51575. }
  51576. private function setEnvironment(bool $scannedInis, array $iniFiles): bool
  51577. {
  51578. $scanDir = getenv('PHP_INI_SCAN_DIR');
  51579. $phprc = getenv('PHPRC');
  51580. if (!putenv($this->envOriginalInis.'='.implode(PATH_SEPARATOR, $iniFiles))) {
  51581. return false;
  51582. }
  51583. if ($this->persistent) {
  51584. if (!putenv('PHP_INI_SCAN_DIR=') || !putenv('PHPRC='.$this->tmpIni)) {
  51585. return false;
  51586. }
  51587. }
  51588. $envArgs = [
  51589. self::RESTART_ID,
  51590. self::$xdebugVersion,
  51591. (int) $scannedInis,
  51592. false === $scanDir ? '*' : $scanDir,
  51593. false === $phprc ? '*' : $phprc,
  51594. ];
  51595. return putenv($this->envAllowXdebug.'='.implode('|', $envArgs));
  51596. }
  51597. private function notify(string $op, ?string $data = null): void
  51598. {
  51599. $this->statusWriter->report($op, $data);
  51600. }
  51601. private function mergeLoadedConfig(array $loadedConfig, array $iniConfig): string
  51602. {
  51603. $content = '';
  51604. foreach ($loadedConfig as $name => $value) {
  51605. if (!is_string($value)
  51606. || strpos($name, 'xdebug') === 0
  51607. || $name === 'apc.mmap_file_mask') {
  51608. continue;
  51609. }
  51610. if (!isset($iniConfig[$name]) || $iniConfig[$name] !== $value) {
  51611. $content .= $name.'="'.addcslashes($value, '\\"').'"'.PHP_EOL;
  51612. }
  51613. }
  51614. return $content;
  51615. }
  51616. private function checkMainScript(): bool
  51617. {
  51618. if ($this->script !== null) {
  51619. return file_exists($this->script) || '--' === $this->script;
  51620. }
  51621. if (file_exists($this->script = $_SERVER['argv'][0])) {
  51622. return true;
  51623. }
  51624. $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
  51625. $main = end($trace);
  51626. if ($main !== false && isset($main['file'])) {
  51627. return file_exists($this->script = $main['file']);
  51628. }
  51629. return false;
  51630. }
  51631. private function setEnvRestartSettings(array $envArgs): void
  51632. {
  51633. $settings = [
  51634. php_ini_loaded_file(),
  51635. $envArgs[2],
  51636. $envArgs[3],
  51637. $envArgs[4],
  51638. getenv($this->envOriginalInis),
  51639. self::$skipped,
  51640. ];
  51641. Process::setEnv(self::RESTART_SETTINGS, implode('|', $settings));
  51642. }
  51643. private function syncSettings(array $settings): void
  51644. {
  51645. if (false === getenv($this->envOriginalInis)) {
  51646. Process::setEnv($this->envOriginalInis, implode(PATH_SEPARATOR, $settings['inis']));
  51647. }
  51648. self::$skipped = $settings['skipped'];
  51649. $this->notify(Status::INFO, 'Process called with existing restart settings');
  51650. }
  51651. private function checkConfiguration(?string &$info): bool
  51652. {
  51653. if (!function_exists('proc_open')) {
  51654. $info = 'proc_open function is disabled';
  51655. return false;
  51656. }
  51657. if (extension_loaded('uopz') && !((bool) ini_get('uopz.disable'))) {
  51658. if (function_exists('uopz_allow_exit')) {
  51659. @uopz_allow_exit(true);
  51660. } else {
  51661. $info = 'uopz extension is not compatible';
  51662. return false;
  51663. }
  51664. }
  51665. if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 70400) {
  51666. $workingDir = getcwd();
  51667. if ($workingDir === false) {
  51668. $info = 'unable to determine working directory';
  51669. return false;
  51670. }
  51671. if (0 === strpos($workingDir, '\\\\')) {
  51672. $info = 'cmd.exe does not support UNC paths: '.$workingDir;
  51673. return false;
  51674. }
  51675. }
  51676. return true;
  51677. }
  51678. private function tryEnableSignals(): void
  51679. {
  51680. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  51681. pcntl_async_signals(true);
  51682. $message = 'Async signals enabled';
  51683. if (!self::$inRestart) {
  51684. pcntl_signal(SIGINT, SIG_IGN);
  51685. } elseif (is_int(pcntl_signal_get_handler(SIGINT))) {
  51686. pcntl_signal(SIGINT, SIG_DFL);
  51687. }
  51688. }
  51689. if (!self::$inRestart && function_exists('sapi_windows_set_ctrl_handler')) {
  51690. sapi_windows_set_ctrl_handler(function ($evt) {});
  51691. }
  51692. }
  51693. private static function setXdebugDetails(): void
  51694. {
  51695. if (self::$xdebugActive !== null) {
  51696. return;
  51697. }
  51698. self::$xdebugActive = false;
  51699. if (!extension_loaded('xdebug')) {
  51700. return;
  51701. }
  51702. $version = phpversion('xdebug');
  51703. self::$xdebugVersion = $version !== false ? $version : 'unknown';
  51704. if (version_compare(self::$xdebugVersion, '3.1', '>=')) {
  51705. $modes = xdebug_info('mode');
  51706. self::$xdebugMode = count($modes) === 0 ? 'off' : implode(',', $modes);
  51707. self::$xdebugActive = self::$xdebugMode !== 'off';
  51708. return;
  51709. }
  51710. $iniMode = ini_get('xdebug.mode');
  51711. if ($iniMode === false) {
  51712. self::$xdebugActive = true;
  51713. return;
  51714. }
  51715. $envMode = (string) getenv('XDEBUG_MODE');
  51716. if ($envMode !== '') {
  51717. self::$xdebugMode = $envMode;
  51718. } else {
  51719. self::$xdebugMode = $iniMode !== '' ? $iniMode : 'off';
  51720. }
  51721. if (Preg::isMatch('/^,+$/', str_replace(' ', '', self::$xdebugMode))) {
  51722. self::$xdebugMode = 'off';
  51723. }
  51724. self::$xdebugActive = self::$xdebugMode !== 'off';
  51725. }
  51726. }
  51727. MIT License
  51728. Copyright (c) 2016
  51729. Permission is hereby granted, free of charge, to any person obtaining a copy
  51730. of this software and associated documentation files (the "Software"), to deal
  51731. in the Software without restriction, including without limitation the rights
  51732. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  51733. copies of the Software, and to permit persons to whom the Software is
  51734. furnished to do so, subject to the following conditions:
  51735. The above copyright notice and this permission notice shall be included in all
  51736. copies or substantial portions of the Software.
  51737. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  51738. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  51739. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  51740. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  51741. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  51742. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  51743. SOFTWARE.
  51744. <?php
  51745. namespace JsonSchema\Constraints;
  51746. use JsonSchema\Entity\JsonPointer;
  51747. use JsonSchema\Exception\InvalidArgumentException;
  51748. use JsonSchema\Exception\ValidationException;
  51749. use JsonSchema\Validator;
  51750. class BaseConstraint
  51751. {
  51752. protected $errors = array();
  51753. protected $errorMask = Validator::ERROR_NONE;
  51754. protected $factory;
  51755. public function __construct(Factory $factory = null)
  51756. {
  51757. $this->factory = $factory ?: new Factory();
  51758. }
  51759. public function addError(JsonPointer $path = null, $message, $constraint = '', array $more = null)
  51760. {
  51761. $error = array(
  51762. 'property' => $this->convertJsonPointerIntoPropertyPath($path ?: new JsonPointer('')),
  51763. 'pointer' => ltrim(strval($path ?: new JsonPointer('')), '#'),
  51764. 'message' => $message,
  51765. 'constraint' => $constraint,
  51766. 'context' => $this->factory->getErrorContext(),
  51767. );
  51768. if ($this->factory->getConfig(Constraint::CHECK_MODE_EXCEPTIONS)) {
  51769. throw new ValidationException(sprintf('Error validating %s: %s', $error['pointer'], $error['message']));
  51770. }
  51771. if (is_array($more) && count($more) > 0) {
  51772. $error += $more;
  51773. }
  51774. $this->errors[] = $error;
  51775. $this->errorMask |= $error['context'];
  51776. }
  51777. public function addErrors(array $errors)
  51778. {
  51779. if ($errors) {
  51780. $this->errors = array_merge($this->errors, $errors);
  51781. $errorMask = &$this->errorMask;
  51782. array_walk($errors, function ($error) use (&$errorMask) {
  51783. if (isset($error['context'])) {
  51784. $errorMask |= $error['context'];
  51785. }
  51786. });
  51787. }
  51788. }
  51789. public function getErrors($errorContext = Validator::ERROR_ALL)
  51790. {
  51791. if ($errorContext === Validator::ERROR_ALL) {
  51792. return $this->errors;
  51793. }
  51794. return array_filter($this->errors, function ($error) use ($errorContext) {
  51795. if ($errorContext & $error['context']) {
  51796. return true;
  51797. }
  51798. });
  51799. }
  51800. public function numErrors($errorContext = Validator::ERROR_ALL)
  51801. {
  51802. if ($errorContext === Validator::ERROR_ALL) {
  51803. return count($this->errors);
  51804. }
  51805. return count($this->getErrors($errorContext));
  51806. }
  51807. public function isValid()
  51808. {
  51809. return !$this->getErrors();
  51810. }
  51811. public function reset()
  51812. {
  51813. $this->errors = array();
  51814. $this->errorMask = Validator::ERROR_NONE;
  51815. }
  51816. public function getErrorMask()
  51817. {
  51818. return $this->errorMask;
  51819. }
  51820. public static function arrayToObjectRecursive($array)
  51821. {
  51822. $json = json_encode($array);
  51823. if (json_last_error() !== \JSON_ERROR_NONE) {
  51824. $message = 'Unable to encode schema array as JSON';
  51825. if (function_exists('json_last_error_msg')) {
  51826. $message .= ': ' . json_last_error_msg();
  51827. }
  51828. throw new InvalidArgumentException($message);
  51829. }
  51830. return (object) json_decode($json);
  51831. }
  51832. }
  51833. <?php
  51834. namespace JsonSchema\Constraints;
  51835. use JsonSchema\Entity\JsonPointer;
  51836. class CollectionConstraint extends Constraint
  51837. {
  51838. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null)
  51839. {
  51840. if (isset($schema->minItems) && count($value) < $schema->minItems) {
  51841. $this->addError($path, 'There must be a minimum of ' . $schema->minItems . ' items in the array', 'minItems', array('minItems' => $schema->minItems));
  51842. }
  51843. if (isset($schema->maxItems) && count($value) > $schema->maxItems) {
  51844. $this->addError($path, 'There must be a maximum of ' . $schema->maxItems . ' items in the array', 'maxItems', array('maxItems' => $schema->maxItems));
  51845. }
  51846. if (isset($schema->uniqueItems) && $schema->uniqueItems) {
  51847. $unique = $value;
  51848. if (is_array($value) && count($value)) {
  51849. $unique = array_map(function ($e) {
  51850. return var_export($e, true);
  51851. }, $value);
  51852. }
  51853. if (count(array_unique($unique)) != count($value)) {
  51854. $this->addError($path, 'There are no duplicates allowed in the array', 'uniqueItems');
  51855. }
  51856. }
  51857. if (isset($schema->items)) {
  51858. $this->validateItems($value, $schema, $path, $i);
  51859. }
  51860. }
  51861. protected function validateItems(&$value, $schema = null, JsonPointer $path = null, $i = null)
  51862. {
  51863. if (is_object($schema->items)) {
  51864. foreach ($value as $k => &$v) {
  51865. $initErrors = $this->getErrors();
  51866. $this->checkUndefined($v, $schema->items, $path, $k);
  51867. if (count($initErrors) < count($this->getErrors()) && (isset($schema->additionalItems) && $schema->additionalItems !== false)) {
  51868. $secondErrors = $this->getErrors();
  51869. $this->checkUndefined($v, $schema->additionalItems, $path, $k);
  51870. }
  51871. if (isset($secondErrors) && count($secondErrors) < count($this->getErrors())) {
  51872. $this->errors = $secondErrors;
  51873. } elseif (isset($secondErrors) && count($secondErrors) === count($this->getErrors())) {
  51874. $this->errors = $initErrors;
  51875. }
  51876. }
  51877. unset($v);
  51878. } else {
  51879. foreach ($value as $k => &$v) {
  51880. if (array_key_exists($k, $schema->items)) {
  51881. $this->checkUndefined($v, $schema->items[$k], $path, $k);
  51882. } else {
  51883. if (property_exists($schema, 'additionalItems')) {
  51884. if ($schema->additionalItems !== false) {
  51885. $this->checkUndefined($v, $schema->additionalItems, $path, $k);
  51886. } else {
  51887. $this->addError(
  51888. $path, 'The item ' . $i . '[' . $k . '] is not defined and the definition does not allow additional items', 'additionalItems', array('additionalItems' => $schema->additionalItems));
  51889. }
  51890. } else {
  51891. $this->checkUndefined($v, new \stdClass(), $path, $k);
  51892. }
  51893. }
  51894. }
  51895. unset($v);
  51896. if (count($value) > 0) {
  51897. for ($k = count($value); $k < count($schema->items); $k++) {
  51898. $undefinedInstance = $this->factory->createInstanceFor('undefined');
  51899. $this->checkUndefined($undefinedInstance, $schema->items[$k], $path, $k);
  51900. }
  51901. }
  51902. }
  51903. }
  51904. }
  51905. <?php
  51906. namespace JsonSchema\Constraints;
  51907. use JsonSchema\Entity\JsonPointer;
  51908. abstract class Constraint extends BaseConstraint implements ConstraintInterface
  51909. {
  51910. protected $inlineSchemaProperty = '$schema';
  51911. const CHECK_MODE_NONE = 0x00000000;
  51912. const CHECK_MODE_NORMAL = 0x00000001;
  51913. const CHECK_MODE_TYPE_CAST = 0x00000002;
  51914. const CHECK_MODE_COERCE_TYPES = 0x00000004;
  51915. const CHECK_MODE_APPLY_DEFAULTS = 0x00000008;
  51916. const CHECK_MODE_EXCEPTIONS = 0x00000010;
  51917. const CHECK_MODE_DISABLE_FORMAT = 0x00000020;
  51918. const CHECK_MODE_ONLY_REQUIRED_DEFAULTS = 0x00000080;
  51919. const CHECK_MODE_VALIDATE_SCHEMA = 0x00000100;
  51920. protected function incrementPath(JsonPointer $path = null, $i)
  51921. {
  51922. $path = $path ?: new JsonPointer('');
  51923. if ($i === null || $i === '') {
  51924. return $path;
  51925. }
  51926. $path = $path->withPropertyPaths(
  51927. array_merge(
  51928. $path->getPropertyPaths(),
  51929. array($i)
  51930. )
  51931. );
  51932. return $path;
  51933. }
  51934. protected function checkArray(&$value, $schema = null, JsonPointer $path = null, $i = null)
  51935. {
  51936. $validator = $this->factory->createInstanceFor('collection');
  51937. $validator->check($value, $schema, $path, $i);
  51938. $this->addErrors($validator->getErrors());
  51939. }
  51940. protected function checkObject(&$value, $schema = null, JsonPointer $path = null, $properties = null,
  51941. $additionalProperties = null, $patternProperties = null, $appliedDefaults = array())
  51942. {
  51943. $validator = $this->factory->createInstanceFor('object');
  51944. $validator->check($value, $schema, $path, $properties, $additionalProperties, $patternProperties, $appliedDefaults);
  51945. $this->addErrors($validator->getErrors());
  51946. }
  51947. protected function checkType(&$value, $schema = null, JsonPointer $path = null, $i = null)
  51948. {
  51949. $validator = $this->factory->createInstanceFor('type');
  51950. $validator->check($value, $schema, $path, $i);
  51951. $this->addErrors($validator->getErrors());
  51952. }
  51953. protected function checkUndefined(&$value, $schema = null, JsonPointer $path = null, $i = null, $fromDefault = false)
  51954. {
  51955. $validator = $this->factory->createInstanceFor('undefined');
  51956. $validator->check($value, $this->factory->getSchemaStorage()->resolveRefSchema($schema), $path, $i, $fromDefault);
  51957. $this->addErrors($validator->getErrors());
  51958. }
  51959. protected function checkString($value, $schema = null, JsonPointer $path = null, $i = null)
  51960. {
  51961. $validator = $this->factory->createInstanceFor('string');
  51962. $validator->check($value, $schema, $path, $i);
  51963. $this->addErrors($validator->getErrors());
  51964. }
  51965. protected function checkNumber($value, $schema = null, JsonPointer $path = null, $i = null)
  51966. {
  51967. $validator = $this->factory->createInstanceFor('number');
  51968. $validator->check($value, $schema, $path, $i);
  51969. $this->addErrors($validator->getErrors());
  51970. }
  51971. protected function checkEnum($value, $schema = null, JsonPointer $path = null, $i = null)
  51972. {
  51973. $validator = $this->factory->createInstanceFor('enum');
  51974. $validator->check($value, $schema, $path, $i);
  51975. $this->addErrors($validator->getErrors());
  51976. }
  51977. protected function checkFormat($value, $schema = null, JsonPointer $path = null, $i = null)
  51978. {
  51979. $validator = $this->factory->createInstanceFor('format');
  51980. $validator->check($value, $schema, $path, $i);
  51981. $this->addErrors($validator->getErrors());
  51982. }
  51983. protected function getTypeCheck()
  51984. {
  51985. return $this->factory->getTypeCheck();
  51986. }
  51987. protected function convertJsonPointerIntoPropertyPath(JsonPointer $pointer)
  51988. {
  51989. $result = array_map(
  51990. function ($path) {
  51991. return sprintf(is_numeric($path) ? '[%d]' : '.%s', $path);
  51992. },
  51993. $pointer->getPropertyPaths()
  51994. );
  51995. return trim(implode('', $result), '.');
  51996. }
  51997. }
  51998. <?php
  51999. namespace JsonSchema\Constraints;
  52000. use JsonSchema\Entity\JsonPointer;
  52001. interface ConstraintInterface
  52002. {
  52003. public function getErrors();
  52004. public function addErrors(array $errors);
  52005. public function addError(JsonPointer $path = null, $message, $constraint='', array $more = null);
  52006. public function isValid();
  52007. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null);
  52008. }
  52009. <?php
  52010. namespace JsonSchema\Constraints;
  52011. use JsonSchema\Entity\JsonPointer;
  52012. class EnumConstraint extends Constraint
  52013. {
  52014. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  52015. {
  52016. if ($element instanceof UndefinedConstraint && (!isset($schema->required) || !$schema->required)) {
  52017. return;
  52018. }
  52019. $type = gettype($element);
  52020. foreach ($schema->enum as $enum) {
  52021. $enumType = gettype($enum);
  52022. if ($this->factory->getConfig(self::CHECK_MODE_TYPE_CAST) && $type == 'array' && $enumType == 'object') {
  52023. if ((object) $element == $enum) {
  52024. return;
  52025. }
  52026. }
  52027. if ($type === gettype($enum)) {
  52028. if ($type == 'object') {
  52029. if ($element == $enum) {
  52030. return;
  52031. }
  52032. } elseif ($element === $enum) {
  52033. return;
  52034. }
  52035. }
  52036. }
  52037. $this->addError($path, 'Does not have a value in the enumeration ' . json_encode($schema->enum), 'enum', array('enum' => $schema->enum));
  52038. }
  52039. }
  52040. <?php
  52041. namespace JsonSchema\Constraints;
  52042. use JsonSchema\Exception\InvalidArgumentException;
  52043. use JsonSchema\SchemaStorage;
  52044. use JsonSchema\SchemaStorageInterface;
  52045. use JsonSchema\Uri\UriRetriever;
  52046. use JsonSchema\UriRetrieverInterface;
  52047. use JsonSchema\Validator;
  52048. class Factory
  52049. {
  52050. protected $schemaStorage;
  52051. protected $uriRetriever;
  52052. private $checkMode = Constraint::CHECK_MODE_NORMAL;
  52053. private $typeCheck = array();
  52054. protected $errorContext = Validator::ERROR_DOCUMENT_VALIDATION;
  52055. protected $constraintMap = array(
  52056. 'array' => 'JsonSchema\Constraints\CollectionConstraint',
  52057. 'collection' => 'JsonSchema\Constraints\CollectionConstraint',
  52058. 'object' => 'JsonSchema\Constraints\ObjectConstraint',
  52059. 'type' => 'JsonSchema\Constraints\TypeConstraint',
  52060. 'undefined' => 'JsonSchema\Constraints\UndefinedConstraint',
  52061. 'string' => 'JsonSchema\Constraints\StringConstraint',
  52062. 'number' => 'JsonSchema\Constraints\NumberConstraint',
  52063. 'enum' => 'JsonSchema\Constraints\EnumConstraint',
  52064. 'format' => 'JsonSchema\Constraints\FormatConstraint',
  52065. 'schema' => 'JsonSchema\Constraints\SchemaConstraint',
  52066. 'validator' => 'JsonSchema\Validator'
  52067. );
  52068. private $instanceCache = array();
  52069. public function __construct(
  52070. SchemaStorageInterface $schemaStorage = null,
  52071. UriRetrieverInterface $uriRetriever = null,
  52072. $checkMode = Constraint::CHECK_MODE_NORMAL
  52073. ) {
  52074. $this->setConfig($checkMode);
  52075. $this->uriRetriever = $uriRetriever ?: new UriRetriever();
  52076. $this->schemaStorage = $schemaStorage ?: new SchemaStorage($this->uriRetriever);
  52077. }
  52078. public function setConfig($checkMode = Constraint::CHECK_MODE_NORMAL)
  52079. {
  52080. $this->checkMode = $checkMode;
  52081. }
  52082. public function addConfig($options)
  52083. {
  52084. $this->checkMode |= $options;
  52085. }
  52086. public function removeConfig($options)
  52087. {
  52088. $this->checkMode &= ~$options;
  52089. }
  52090. public function getConfig($options = null)
  52091. {
  52092. if ($options === null) {
  52093. return $this->checkMode;
  52094. }
  52095. return $this->checkMode & $options;
  52096. }
  52097. public function getUriRetriever()
  52098. {
  52099. return $this->uriRetriever;
  52100. }
  52101. public function getSchemaStorage()
  52102. {
  52103. return $this->schemaStorage;
  52104. }
  52105. public function getTypeCheck()
  52106. {
  52107. if (!isset($this->typeCheck[$this->checkMode])) {
  52108. $this->typeCheck[$this->checkMode] = ($this->checkMode & Constraint::CHECK_MODE_TYPE_CAST)
  52109. ? new TypeCheck\LooseTypeCheck()
  52110. : new TypeCheck\StrictTypeCheck();
  52111. }
  52112. return $this->typeCheck[$this->checkMode];
  52113. }
  52114. public function setConstraintClass($name, $class)
  52115. {
  52116. if (!class_exists($class)) {
  52117. throw new InvalidArgumentException('Unknown constraint ' . $name);
  52118. }
  52119. if (!in_array('JsonSchema\Constraints\ConstraintInterface', class_implements($class))) {
  52120. throw new InvalidArgumentException('Invalid class ' . $name);
  52121. }
  52122. $this->constraintMap[$name] = $class;
  52123. return $this;
  52124. }
  52125. public function createInstanceFor($constraintName)
  52126. {
  52127. if (!isset($this->constraintMap[$constraintName])) {
  52128. throw new InvalidArgumentException('Unknown constraint ' . $constraintName);
  52129. }
  52130. if (!isset($this->instanceCache[$constraintName])) {
  52131. $this->instanceCache[$constraintName] = new $this->constraintMap[$constraintName]($this);
  52132. }
  52133. return clone $this->instanceCache[$constraintName];
  52134. }
  52135. public function getErrorContext()
  52136. {
  52137. return $this->errorContext;
  52138. }
  52139. public function setErrorContext($errorContext)
  52140. {
  52141. $this->errorContext = $errorContext;
  52142. }
  52143. }
  52144. <?php
  52145. namespace JsonSchema\Constraints;
  52146. use JsonSchema\Entity\JsonPointer;
  52147. use JsonSchema\Rfc3339;
  52148. class FormatConstraint extends Constraint
  52149. {
  52150. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  52151. {
  52152. if (!isset($schema->format) || $this->factory->getConfig(self::CHECK_MODE_DISABLE_FORMAT)) {
  52153. return;
  52154. }
  52155. switch ($schema->format) {
  52156. case 'date':
  52157. if (!$date = $this->validateDateTime($element, 'Y-m-d')) {
  52158. $this->addError($path, sprintf('Invalid date %s, expected format YYYY-MM-DD', json_encode($element)), 'format', array('format' => $schema->format));
  52159. }
  52160. break;
  52161. case 'time':
  52162. if (!$this->validateDateTime($element, 'H:i:s')) {
  52163. $this->addError($path, sprintf('Invalid time %s, expected format hh:mm:ss', json_encode($element)), 'format', array('format' => $schema->format));
  52164. }
  52165. break;
  52166. case 'date-time':
  52167. if (null === Rfc3339::createFromString($element)) {
  52168. $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));
  52169. }
  52170. break;
  52171. case 'utc-millisec':
  52172. if (!$this->validateDateTime($element, 'U')) {
  52173. $this->addError($path, sprintf('Invalid time %s, expected integer of milliseconds since Epoch', json_encode($element)), 'format', array('format' => $schema->format));
  52174. }
  52175. break;
  52176. case 'regex':
  52177. if (!$this->validateRegex($element)) {
  52178. $this->addError($path, 'Invalid regex format ' . $element, 'format', array('format' => $schema->format));
  52179. }
  52180. break;
  52181. case 'color':
  52182. if (!$this->validateColor($element)) {
  52183. $this->addError($path, 'Invalid color', 'format', array('format' => $schema->format));
  52184. }
  52185. break;
  52186. case 'style':
  52187. if (!$this->validateStyle($element)) {
  52188. $this->addError($path, 'Invalid style', 'format', array('format' => $schema->format));
  52189. }
  52190. break;
  52191. case 'phone':
  52192. if (!$this->validatePhone($element)) {
  52193. $this->addError($path, 'Invalid phone number', 'format', array('format' => $schema->format));
  52194. }
  52195. break;
  52196. case 'uri':
  52197. if (null === filter_var($element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE)) {
  52198. $this->addError($path, 'Invalid URL format', 'format', array('format' => $schema->format));
  52199. }
  52200. break;
  52201. case 'uriref':
  52202. case 'uri-reference':
  52203. if (null === filter_var($element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE)) {
  52204. if (substr($element, 0, 2) === '//') {
  52205. $validURL = filter_var('scheme:' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  52206. } elseif (substr($element, 0, 1) === '/') {
  52207. $validURL = filter_var('scheme://host' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  52208. } elseif (strlen($element)) {
  52209. $pathParts = explode('/', $element, 2);
  52210. if (strpos($pathParts[0], ':') !== false) {
  52211. $validURL = null;
  52212. } else {
  52213. $validURL = filter_var('scheme://host/' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  52214. }
  52215. } else {
  52216. $validURL = null;
  52217. }
  52218. if ($validURL === null) {
  52219. $this->addError($path, 'Invalid URL format', 'format', array('format' => $schema->format));
  52220. }
  52221. }
  52222. break;
  52223. case 'email':
  52224. $filterFlags = FILTER_NULL_ON_FAILURE;
  52225. if (defined('FILTER_FLAG_EMAIL_UNICODE')) {
  52226. $filterFlags |= constant('FILTER_FLAG_EMAIL_UNICODE');
  52227. }
  52228. if (null === filter_var($element, FILTER_VALIDATE_EMAIL, $filterFlags)) {
  52229. $this->addError($path, 'Invalid email', 'format', array('format' => $schema->format));
  52230. }
  52231. break;
  52232. case 'ip-address':
  52233. case 'ipv4':
  52234. if (null === filter_var($element, FILTER_VALIDATE_IP, FILTER_NULL_ON_FAILURE | FILTER_FLAG_IPV4)) {
  52235. $this->addError($path, 'Invalid IP address', 'format', array('format' => $schema->format));
  52236. }
  52237. break;
  52238. case 'ipv6':
  52239. if (null === filter_var($element, FILTER_VALIDATE_IP, FILTER_NULL_ON_FAILURE | FILTER_FLAG_IPV6)) {
  52240. $this->addError($path, 'Invalid IP address', 'format', array('format' => $schema->format));
  52241. }
  52242. break;
  52243. case 'host-name':
  52244. case 'hostname':
  52245. if (!$this->validateHostname($element)) {
  52246. $this->addError($path, 'Invalid hostname', 'format', array('format' => $schema->format));
  52247. }
  52248. break;
  52249. default:
  52250. break;
  52251. }
  52252. }
  52253. protected function validateDateTime($datetime, $format)
  52254. {
  52255. $dt = \DateTime::createFromFormat($format, $datetime);
  52256. if (!$dt) {
  52257. return false;
  52258. }
  52259. if ($datetime === $dt->format($format)) {
  52260. return true;
  52261. }
  52262. if ((strpos('u', $format) !== -1) && (preg_match('/\.\d+Z$/', $datetime))) {
  52263. return true;
  52264. }
  52265. return false;
  52266. }
  52267. protected function validateRegex($regex)
  52268. {
  52269. return false !== @preg_match('/' . $regex . '/u', '');
  52270. }
  52271. protected function validateColor($color)
  52272. {
  52273. if (in_array(strtolower($color), array('aqua', 'black', 'blue', 'fuchsia',
  52274. 'gray', 'green', 'lime', 'maroon', 'navy', 'olive', 'orange', 'purple',
  52275. 'red', 'silver', 'teal', 'white', 'yellow'))) {
  52276. return true;
  52277. }
  52278. return preg_match('/^#([a-f0-9]{3}|[a-f0-9]{6})$/i', $color);
  52279. }
  52280. protected function validateStyle($style)
  52281. {
  52282. $properties = explode(';', rtrim($style, ';'));
  52283. $invalidEntries = preg_grep('/^\s*[-a-z]+\s*:\s*.+$/i', $properties, PREG_GREP_INVERT);
  52284. return empty($invalidEntries);
  52285. }
  52286. protected function validatePhone($phone)
  52287. {
  52288. return preg_match('/^\+?(\(\d{3}\)|\d{3}) \d{3} \d{4}$/', $phone);
  52289. }
  52290. protected function validateHostname($host)
  52291. {
  52292. $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';
  52293. return preg_match($hostnameRegex, $host);
  52294. }
  52295. }
  52296. <?php
  52297. namespace JsonSchema\Constraints;
  52298. use JsonSchema\Entity\JsonPointer;
  52299. class NumberConstraint extends Constraint
  52300. {
  52301. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  52302. {
  52303. if (isset($schema->exclusiveMinimum)) {
  52304. if (isset($schema->minimum)) {
  52305. if ($schema->exclusiveMinimum && $element <= $schema->minimum) {
  52306. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'exclusiveMinimum', array('minimum' => $schema->minimum));
  52307. } elseif ($element < $schema->minimum) {
  52308. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'minimum', array('minimum' => $schema->minimum));
  52309. }
  52310. } else {
  52311. $this->addError($path, 'Use of exclusiveMinimum requires presence of minimum', 'missingMinimum');
  52312. }
  52313. } elseif (isset($schema->minimum) && $element < $schema->minimum) {
  52314. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'minimum', array('minimum' => $schema->minimum));
  52315. }
  52316. if (isset($schema->exclusiveMaximum)) {
  52317. if (isset($schema->maximum)) {
  52318. if ($schema->exclusiveMaximum && $element >= $schema->maximum) {
  52319. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'exclusiveMaximum', array('maximum' => $schema->maximum));
  52320. } elseif ($element > $schema->maximum) {
  52321. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'maximum', array('maximum' => $schema->maximum));
  52322. }
  52323. } else {
  52324. $this->addError($path, 'Use of exclusiveMaximum requires presence of maximum', 'missingMaximum');
  52325. }
  52326. } elseif (isset($schema->maximum) && $element > $schema->maximum) {
  52327. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'maximum', array('maximum' => $schema->maximum));
  52328. }
  52329. if (isset($schema->divisibleBy) && $this->fmod($element, $schema->divisibleBy) != 0) {
  52330. $this->addError($path, 'Is not divisible by ' . $schema->divisibleBy, 'divisibleBy', array('divisibleBy' => $schema->divisibleBy));
  52331. }
  52332. if (isset($schema->multipleOf) && $this->fmod($element, $schema->multipleOf) != 0) {
  52333. $this->addError($path, 'Must be a multiple of ' . $schema->multipleOf, 'multipleOf', array('multipleOf' => $schema->multipleOf));
  52334. }
  52335. $this->checkFormat($element, $schema, $path, $i);
  52336. }
  52337. private function fmod($number1, $number2)
  52338. {
  52339. $modulus = ($number1 - round($number1 / $number2) * $number2);
  52340. $precision = 0.0000000001;
  52341. if (-$precision < $modulus && $modulus < $precision) {
  52342. return 0.0;
  52343. }
  52344. return $modulus;
  52345. }
  52346. }
  52347. <?php
  52348. namespace JsonSchema\Constraints;
  52349. use JsonSchema\Entity\JsonPointer;
  52350. class ObjectConstraint extends Constraint
  52351. {
  52352. protected $appliedDefaults = array();
  52353. public function check(&$element, $schema = null, JsonPointer $path = null, $properties = null,
  52354. $additionalProp = null, $patternProperties = null, $appliedDefaults = array())
  52355. {
  52356. if ($element instanceof UndefinedConstraint) {
  52357. return;
  52358. }
  52359. $this->appliedDefaults = $appliedDefaults;
  52360. $matches = array();
  52361. if ($patternProperties) {
  52362. $matches = $this->validatePatternProperties($element, $path, $patternProperties);
  52363. }
  52364. if ($properties) {
  52365. $this->validateProperties($element, $properties, $path);
  52366. }
  52367. $this->validateElement($element, $matches, $schema, $path, $properties, $additionalProp);
  52368. }
  52369. public function validatePatternProperties($element, JsonPointer $path = null, $patternProperties)
  52370. {
  52371. $try = array('/', '#', '+', '~', '%');
  52372. $matches = array();
  52373. foreach ($patternProperties as $pregex => $schema) {
  52374. $delimiter = '/';
  52375. foreach ($try as $delimiter) {
  52376. if (strpos($pregex, $delimiter) === false) {
  52377. break;
  52378. }
  52379. }
  52380. if (@preg_match($delimiter . $pregex . $delimiter . 'u', '') === false) {
  52381. $this->addError($path, 'The pattern "' . $pregex . '" is invalid', 'pregex', array('pregex' => $pregex));
  52382. continue;
  52383. }
  52384. foreach ($element as $i => $value) {
  52385. if (preg_match($delimiter . $pregex . $delimiter . 'u', $i)) {
  52386. $matches[] = $i;
  52387. $this->checkUndefined($value, $schema ?: new \stdClass(), $path, $i, in_array($i, $this->appliedDefaults));
  52388. }
  52389. }
  52390. }
  52391. return $matches;
  52392. }
  52393. public function validateElement($element, $matches, $schema = null, JsonPointer $path = null,
  52394. $properties = null, $additionalProp = null)
  52395. {
  52396. $this->validateMinMaxConstraint($element, $schema, $path);
  52397. foreach ($element as $i => $value) {
  52398. $definition = $this->getProperty($properties, $i);
  52399. if (!in_array($i, $matches) && $additionalProp === false && $this->inlineSchemaProperty !== $i && !$definition) {
  52400. $this->addError($path, 'The property ' . $i . ' is not defined and the definition does not allow additional properties', 'additionalProp');
  52401. }
  52402. if (!in_array($i, $matches) && $additionalProp && !$definition) {
  52403. if ($additionalProp === true) {
  52404. $this->checkUndefined($value, null, $path, $i, in_array($i, $this->appliedDefaults));
  52405. } else {
  52406. $this->checkUndefined($value, $additionalProp, $path, $i, in_array($i, $this->appliedDefaults));
  52407. }
  52408. }
  52409. $require = $this->getProperty($definition, 'requires');
  52410. if ($require && !$this->getProperty($element, $require)) {
  52411. $this->addError($path, 'The presence of the property ' . $i . ' requires that ' . $require . ' also be present', 'requires');
  52412. }
  52413. $property = $this->getProperty($element, $i, $this->factory->createInstanceFor('undefined'));
  52414. if (is_object($property)) {
  52415. $this->validateMinMaxConstraint(!($property instanceof UndefinedConstraint) ? $property : $element, $definition, $path);
  52416. }
  52417. }
  52418. }
  52419. public function validateProperties(&$element, $properties = null, JsonPointer $path = null)
  52420. {
  52421. $undefinedConstraint = $this->factory->createInstanceFor('undefined');
  52422. foreach ($properties as $i => $value) {
  52423. $property = &$this->getProperty($element, $i, $undefinedConstraint);
  52424. $definition = $this->getProperty($properties, $i);
  52425. if (is_object($definition)) {
  52426. $this->checkUndefined($property, $definition, $path, $i, in_array($i, $this->appliedDefaults));
  52427. }
  52428. }
  52429. }
  52430. protected function &getProperty(&$element, $property, $fallback = null)
  52431. {
  52432. if (is_array($element) && (isset($element[$property]) || array_key_exists($property, $element)) ) {
  52433. return $element[$property];
  52434. } elseif (is_object($element) && property_exists($element, $property)) {
  52435. return $element->$property;
  52436. }
  52437. return $fallback;
  52438. }
  52439. protected function validateMinMaxConstraint($element, $objectDefinition, JsonPointer $path = null)
  52440. {
  52441. if (isset($objectDefinition->minProperties) && !is_object($objectDefinition->minProperties)) {
  52442. if ($this->getTypeCheck()->propertyCount($element) < $objectDefinition->minProperties) {
  52443. $this->addError($path, 'Must contain a minimum of ' . $objectDefinition->minProperties . ' properties', 'minProperties', array('minProperties' => $objectDefinition->minProperties));
  52444. }
  52445. }
  52446. if (isset($objectDefinition->maxProperties) && !is_object($objectDefinition->maxProperties)) {
  52447. if ($this->getTypeCheck()->propertyCount($element) > $objectDefinition->maxProperties) {
  52448. $this->addError($path, 'Must contain no more than ' . $objectDefinition->maxProperties . ' properties', 'maxProperties', array('maxProperties' => $objectDefinition->maxProperties));
  52449. }
  52450. }
  52451. }
  52452. }
  52453. <?php
  52454. namespace JsonSchema\Constraints;
  52455. use JsonSchema\Entity\JsonPointer;
  52456. use JsonSchema\Exception\InvalidArgumentException;
  52457. use JsonSchema\Exception\InvalidSchemaException;
  52458. use JsonSchema\Exception\RuntimeException;
  52459. use JsonSchema\Validator;
  52460. class SchemaConstraint extends Constraint
  52461. {
  52462. const DEFAULT_SCHEMA_SPEC = 'http://json-schema.org/draft-04/schema#';
  52463. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  52464. {
  52465. if ($schema !== null) {
  52466. $validationSchema = $schema;
  52467. } elseif ($this->getTypeCheck()->propertyExists($element, $this->inlineSchemaProperty)) {
  52468. $validationSchema = $this->getTypeCheck()->propertyGet($element, $this->inlineSchemaProperty);
  52469. } else {
  52470. throw new InvalidArgumentException('no schema found to verify against');
  52471. }
  52472. if (is_array($validationSchema)) {
  52473. $validationSchema = BaseConstraint::arrayToObjectRecursive($validationSchema);
  52474. }
  52475. if ($this->factory->getConfig(self::CHECK_MODE_VALIDATE_SCHEMA)) {
  52476. if (!$this->getTypeCheck()->isObject($validationSchema)) {
  52477. throw new RuntimeException('Cannot validate the schema of a non-object');
  52478. }
  52479. if ($this->getTypeCheck()->propertyExists($validationSchema, '$schema')) {
  52480. $schemaSpec = $this->getTypeCheck()->propertyGet($validationSchema, '$schema');
  52481. } else {
  52482. $schemaSpec = self::DEFAULT_SCHEMA_SPEC;
  52483. }
  52484. $schemaStorage = $this->factory->getSchemaStorage();
  52485. if (!$this->getTypeCheck()->isObject($schemaSpec)) {
  52486. $schemaSpec = $schemaStorage->getSchema($schemaSpec);
  52487. }
  52488. $initialErrorCount = $this->numErrors();
  52489. $initialConfig = $this->factory->getConfig();
  52490. $initialContext = $this->factory->getErrorContext();
  52491. $this->factory->removeConfig(self::CHECK_MODE_VALIDATE_SCHEMA | self::CHECK_MODE_APPLY_DEFAULTS);
  52492. $this->factory->addConfig(self::CHECK_MODE_TYPE_CAST);
  52493. $this->factory->setErrorContext(Validator::ERROR_SCHEMA_VALIDATION);
  52494. try {
  52495. $this->check($validationSchema, $schemaSpec);
  52496. } catch (\Exception $e) {
  52497. if ($this->factory->getConfig(self::CHECK_MODE_EXCEPTIONS)) {
  52498. throw new InvalidSchemaException('Schema did not pass validation', 0, $e);
  52499. }
  52500. }
  52501. if ($this->numErrors() > $initialErrorCount) {
  52502. $this->addError($path, 'Schema is not valid', 'schema');
  52503. }
  52504. $this->factory->setConfig($initialConfig);
  52505. $this->factory->setErrorContext($initialContext);
  52506. }
  52507. $this->checkUndefined($element, $validationSchema, $path, $i);
  52508. }
  52509. }
  52510. <?php
  52511. namespace JsonSchema\Constraints;
  52512. use JsonSchema\Entity\JsonPointer;
  52513. class StringConstraint extends Constraint
  52514. {
  52515. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  52516. {
  52517. if (isset($schema->maxLength) && $this->strlen($element) > $schema->maxLength) {
  52518. $this->addError($path, 'Must be at most ' . $schema->maxLength . ' characters long', 'maxLength', array(
  52519. 'maxLength' => $schema->maxLength,
  52520. ));
  52521. }
  52522. if (isset($schema->minLength) && $this->strlen($element) < $schema->minLength) {
  52523. $this->addError($path, 'Must be at least ' . $schema->minLength . ' characters long', 'minLength', array(
  52524. 'minLength' => $schema->minLength,
  52525. ));
  52526. }
  52527. if (isset($schema->pattern) && !preg_match('#' . str_replace('#', '\\#', $schema->pattern) . '#u', $element)) {
  52528. $this->addError($path, 'Does not match the regex pattern ' . $schema->pattern, 'pattern', array(
  52529. 'pattern' => $schema->pattern,
  52530. ));
  52531. }
  52532. $this->checkFormat($element, $schema, $path, $i);
  52533. }
  52534. private function strlen($string)
  52535. {
  52536. if (extension_loaded('mbstring')) {
  52537. return mb_strlen($string, mb_detect_encoding($string));
  52538. }
  52539. return strlen($string);
  52540. }
  52541. }
  52542. <?php
  52543. namespace JsonSchema\Constraints\TypeCheck;
  52544. class LooseTypeCheck implements TypeCheckInterface
  52545. {
  52546. public static function isObject($value)
  52547. {
  52548. return
  52549. is_object($value) ||
  52550. (is_array($value) && (count($value) == 0 || self::isAssociativeArray($value)));
  52551. }
  52552. public static function isArray($value)
  52553. {
  52554. return
  52555. is_array($value) &&
  52556. (count($value) == 0 || !self::isAssociativeArray($value));
  52557. }
  52558. public static function propertyGet($value, $property)
  52559. {
  52560. if (is_object($value)) {
  52561. return $value->{$property};
  52562. }
  52563. return $value[$property];
  52564. }
  52565. public static function propertySet(&$value, $property, $data)
  52566. {
  52567. if (is_object($value)) {
  52568. $value->{$property} = $data;
  52569. } else {
  52570. $value[$property] = $data;
  52571. }
  52572. }
  52573. public static function propertyExists($value, $property)
  52574. {
  52575. if (is_object($value)) {
  52576. return property_exists($value, $property);
  52577. }
  52578. return array_key_exists($property, $value);
  52579. }
  52580. public static function propertyCount($value)
  52581. {
  52582. if (is_object($value)) {
  52583. return count(get_object_vars($value));
  52584. }
  52585. return count($value);
  52586. }
  52587. private static function isAssociativeArray($arr)
  52588. {
  52589. return array_keys($arr) !== range(0, count($arr) - 1);
  52590. }
  52591. }
  52592. <?php
  52593. namespace JsonSchema\Constraints\TypeCheck;
  52594. class StrictTypeCheck implements TypeCheckInterface
  52595. {
  52596. public static function isObject($value)
  52597. {
  52598. return is_object($value);
  52599. }
  52600. public static function isArray($value)
  52601. {
  52602. return is_array($value);
  52603. }
  52604. public static function propertyGet($value, $property)
  52605. {
  52606. return $value->{$property};
  52607. }
  52608. public static function propertySet(&$value, $property, $data)
  52609. {
  52610. $value->{$property} = $data;
  52611. }
  52612. public static function propertyExists($value, $property)
  52613. {
  52614. return property_exists($value, $property);
  52615. }
  52616. public static function propertyCount($value)
  52617. {
  52618. if (!is_object($value)) {
  52619. return 0;
  52620. }
  52621. return count(get_object_vars($value));
  52622. }
  52623. }
  52624. <?php
  52625. namespace JsonSchema\Constraints\TypeCheck;
  52626. interface TypeCheckInterface
  52627. {
  52628. public static function isObject($value);
  52629. public static function isArray($value);
  52630. public static function propertyGet($value, $property);
  52631. public static function propertySet(&$value, $property, $data);
  52632. public static function propertyExists($value, $property);
  52633. public static function propertyCount($value);
  52634. }
  52635. <?php
  52636. namespace JsonSchema\Constraints;
  52637. use JsonSchema\Entity\JsonPointer;
  52638. use JsonSchema\Exception\InvalidArgumentException;
  52639. use UnexpectedValueException as StandardUnexpectedValueException;
  52640. class TypeConstraint extends Constraint
  52641. {
  52642. public static $wording = array(
  52643. 'integer' => 'an integer',
  52644. 'number' => 'a number',
  52645. 'boolean' => 'a boolean',
  52646. 'object' => 'an object',
  52647. 'array' => 'an array',
  52648. 'string' => 'a string',
  52649. 'null' => 'a null',
  52650. 'any' => null,
  52651. 0 => null,
  52652. );
  52653. public function check(&$value = null, $schema = null, JsonPointer $path = null, $i = null)
  52654. {
  52655. $type = isset($schema->type) ? $schema->type : null;
  52656. $isValid = false;
  52657. $wording = array();
  52658. if (is_array($type)) {
  52659. $this->validateTypesArray($value, $type, $wording, $isValid, $path);
  52660. } elseif (is_object($type)) {
  52661. $this->checkUndefined($value, $type, $path);
  52662. return;
  52663. } else {
  52664. $isValid = $this->validateType($value, $type);
  52665. }
  52666. if ($isValid === false) {
  52667. if (!is_array($type)) {
  52668. $this->validateTypeNameWording($type);
  52669. $wording[] = self::$wording[$type];
  52670. }
  52671. $this->addError($path, ucwords(gettype($value)) . ' value found, but ' .
  52672. $this->implodeWith($wording, ', ', 'or') . ' is required', 'type');
  52673. }
  52674. }
  52675. protected function validateTypesArray(&$value, array $type, &$validTypesWording, &$isValid, $path)
  52676. {
  52677. foreach ($type as $tp) {
  52678. if (is_object($tp)) {
  52679. if (!$isValid) {
  52680. $validator = $this->factory->createInstanceFor('type');
  52681. $subSchema = new \stdClass();
  52682. $subSchema->type = $tp;
  52683. $validator->check($value, $subSchema, $path, null);
  52684. $error = $validator->getErrors();
  52685. $isValid = !(bool) $error;
  52686. $validTypesWording[] = self::$wording['object'];
  52687. }
  52688. } else {
  52689. $this->validateTypeNameWording($tp);
  52690. $validTypesWording[] = self::$wording[$tp];
  52691. if (!$isValid) {
  52692. $isValid = $this->validateType($value, $tp);
  52693. }
  52694. }
  52695. }
  52696. }
  52697. protected function implodeWith(array $elements, $delimiter = ', ', $listEnd = false)
  52698. {
  52699. if ($listEnd === false || !isset($elements[1])) {
  52700. return implode($delimiter, $elements);
  52701. }
  52702. $lastElement = array_slice($elements, -1);
  52703. $firsElements = join($delimiter, array_slice($elements, 0, -1));
  52704. $implodedElements = array_merge(array($firsElements), $lastElement);
  52705. return join(" $listEnd ", $implodedElements);
  52706. }
  52707. protected function validateTypeNameWording($type)
  52708. {
  52709. if (!array_key_exists($type, self::$wording)) {
  52710. throw new StandardUnexpectedValueException(
  52711. sprintf(
  52712. 'No wording for %s available, expected wordings are: [%s]',
  52713. var_export($type, true),
  52714. implode(', ', array_filter(self::$wording)))
  52715. );
  52716. }
  52717. }
  52718. protected function validateType(&$value, $type)
  52719. {
  52720. if (!$type) {
  52721. return true;
  52722. }
  52723. if ('any' === $type) {
  52724. return true;
  52725. }
  52726. if ('object' === $type) {
  52727. return $this->getTypeCheck()->isObject($value);
  52728. }
  52729. if ('array' === $type) {
  52730. return $this->getTypeCheck()->isArray($value);
  52731. }
  52732. $coerce = $this->factory->getConfig(Constraint::CHECK_MODE_COERCE_TYPES);
  52733. if ('integer' === $type) {
  52734. if ($coerce) {
  52735. $value = $this->toInteger($value);
  52736. }
  52737. return is_int($value);
  52738. }
  52739. if ('number' === $type) {
  52740. if ($coerce) {
  52741. $value = $this->toNumber($value);
  52742. }
  52743. return is_numeric($value) && !is_string($value);
  52744. }
  52745. if ('boolean' === $type) {
  52746. if ($coerce) {
  52747. $value = $this->toBoolean($value);
  52748. }
  52749. return is_bool($value);
  52750. }
  52751. if ('string' === $type) {
  52752. return is_string($value);
  52753. }
  52754. if ('email' === $type) {
  52755. return is_string($value);
  52756. }
  52757. if ('null' === $type) {
  52758. return is_null($value);
  52759. }
  52760. throw new InvalidArgumentException((is_object($value) ? 'object' : $value) . ' is an invalid type for ' . $type);
  52761. }
  52762. protected function toBoolean($value)
  52763. {
  52764. if ($value === 'true') {
  52765. return true;
  52766. }
  52767. if ($value === 'false') {
  52768. return false;
  52769. }
  52770. return $value;
  52771. }
  52772. protected function toNumber($value)
  52773. {
  52774. if (is_numeric($value)) {
  52775. return $value + 0;
  52776. }
  52777. return $value;
  52778. }
  52779. protected function toInteger($value)
  52780. {
  52781. if (is_numeric($value) && (int) $value == $value) {
  52782. return (int) $value;
  52783. }
  52784. return $value;
  52785. }
  52786. }
  52787. <?php
  52788. namespace JsonSchema\Constraints;
  52789. use JsonSchema\Constraints\TypeCheck\LooseTypeCheck;
  52790. use JsonSchema\Entity\JsonPointer;
  52791. use JsonSchema\Exception\ValidationException;
  52792. use JsonSchema\Uri\UriResolver;
  52793. #[\AllowDynamicProperties]
  52794. class UndefinedConstraint extends Constraint
  52795. {
  52796. protected $appliedDefaults = array();
  52797. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null, $fromDefault = false)
  52798. {
  52799. if (is_null($schema) || !is_object($schema)) {
  52800. return;
  52801. }
  52802. $path = $this->incrementPath($path ?: new JsonPointer(''), $i);
  52803. if ($fromDefault) {
  52804. $path->setFromDefault();
  52805. }
  52806. $this->validateCommonProperties($value, $schema, $path, $i);
  52807. $this->validateOfProperties($value, $schema, $path, '');
  52808. $this->validateTypes($value, $schema, $path, $i);
  52809. }
  52810. public function validateTypes(&$value, $schema, JsonPointer $path, $i = null)
  52811. {
  52812. if ($this->getTypeCheck()->isArray($value)) {
  52813. $this->checkArray($value, $schema, $path, $i);
  52814. }
  52815. if (LooseTypeCheck::isObject($value)) {
  52816. $this->checkObject(
  52817. $value,
  52818. $schema,
  52819. $path,
  52820. isset($schema->properties) ? $schema->properties : null,
  52821. isset($schema->additionalProperties) ? $schema->additionalProperties : null,
  52822. isset($schema->patternProperties) ? $schema->patternProperties : null,
  52823. $this->appliedDefaults
  52824. );
  52825. }
  52826. if (is_string($value)) {
  52827. $this->checkString($value, $schema, $path, $i);
  52828. }
  52829. if (is_numeric($value)) {
  52830. $this->checkNumber($value, $schema, $path, $i);
  52831. }
  52832. if (isset($schema->enum)) {
  52833. $this->checkEnum($value, $schema, $path, $i);
  52834. }
  52835. }
  52836. protected function validateCommonProperties(&$value, $schema, JsonPointer $path, $i = '')
  52837. {
  52838. if (isset($schema->extends)) {
  52839. if (is_string($schema->extends)) {
  52840. $schema->extends = $this->validateUri($schema, $schema->extends);
  52841. }
  52842. if (is_array($schema->extends)) {
  52843. foreach ($schema->extends as $extends) {
  52844. $this->checkUndefined($value, $extends, $path, $i);
  52845. }
  52846. } else {
  52847. $this->checkUndefined($value, $schema->extends, $path, $i);
  52848. }
  52849. }
  52850. if (!$path->fromDefault()) {
  52851. $this->applyDefaultValues($value, $schema, $path);
  52852. }
  52853. if ($this->getTypeCheck()->isObject($value)) {
  52854. if (!($value instanceof self) && isset($schema->required) && is_array($schema->required)) {
  52855. foreach ($schema->required as $required) {
  52856. if (!$this->getTypeCheck()->propertyExists($value, $required)) {
  52857. $this->addError(
  52858. $this->incrementPath($path ?: new JsonPointer(''), $required),
  52859. 'The property ' . $required . ' is required',
  52860. 'required'
  52861. );
  52862. }
  52863. }
  52864. } elseif (isset($schema->required) && !is_array($schema->required)) {
  52865. if ($schema->required && $value instanceof self) {
  52866. $propertyPaths = $path->getPropertyPaths();
  52867. $propertyName = end($propertyPaths);
  52868. $this->addError(
  52869. $path,
  52870. 'The property ' . $propertyName . ' is required',
  52871. 'required'
  52872. );
  52873. }
  52874. } else {
  52875. if ($value instanceof self) {
  52876. return;
  52877. }
  52878. }
  52879. }
  52880. if (!($value instanceof self)) {
  52881. $this->checkType($value, $schema, $path, $i);
  52882. }
  52883. if (isset($schema->disallow)) {
  52884. $initErrors = $this->getErrors();
  52885. $typeSchema = new \stdClass();
  52886. $typeSchema->type = $schema->disallow;
  52887. $this->checkType($value, $typeSchema, $path);
  52888. if (count($this->getErrors()) == count($initErrors)) {
  52889. $this->addError($path, 'Disallowed value was matched', 'disallow');
  52890. } else {
  52891. $this->errors = $initErrors;
  52892. }
  52893. }
  52894. if (isset($schema->not)) {
  52895. $initErrors = $this->getErrors();
  52896. $this->checkUndefined($value, $schema->not, $path, $i);
  52897. if (count($this->getErrors()) == count($initErrors)) {
  52898. $this->addError($path, 'Matched a schema which it should not', 'not');
  52899. } else {
  52900. $this->errors = $initErrors;
  52901. }
  52902. }
  52903. if (isset($schema->dependencies) && $this->getTypeCheck()->isObject($value)) {
  52904. $this->validateDependencies($value, $schema->dependencies, $path);
  52905. }
  52906. }
  52907. private function shouldApplyDefaultValue($requiredOnly, $schema, $name = null, $parentSchema = null)
  52908. {
  52909. if (!$requiredOnly) {
  52910. return true;
  52911. }
  52912. if (
  52913. $name !== null
  52914. && isset($parentSchema->required)
  52915. && is_array($parentSchema->required)
  52916. && in_array($name, $parentSchema->required)
  52917. ) {
  52918. return true;
  52919. }
  52920. if (isset($schema->required) && !is_array($schema->required) && $schema->required) {
  52921. return true;
  52922. }
  52923. return false;
  52924. }
  52925. protected function applyDefaultValues(&$value, $schema, $path)
  52926. {
  52927. if (!$this->factory->getConfig(self::CHECK_MODE_APPLY_DEFAULTS)) {
  52928. return;
  52929. }
  52930. $requiredOnly = $this->factory->getConfig(self::CHECK_MODE_ONLY_REQUIRED_DEFAULTS);
  52931. if (isset($schema->properties) && LooseTypeCheck::isObject($value)) {
  52932. foreach ($schema->properties as $currentProperty => $propertyDefinition) {
  52933. $propertyDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($propertyDefinition);
  52934. if (
  52935. !LooseTypeCheck::propertyExists($value, $currentProperty)
  52936. && property_exists($propertyDefinition, 'default')
  52937. && $this->shouldApplyDefaultValue($requiredOnly, $propertyDefinition, $currentProperty, $schema)
  52938. ) {
  52939. if (is_object($propertyDefinition->default)) {
  52940. LooseTypeCheck::propertySet($value, $currentProperty, clone $propertyDefinition->default);
  52941. } else {
  52942. LooseTypeCheck::propertySet($value, $currentProperty, $propertyDefinition->default);
  52943. }
  52944. $this->appliedDefaults[] = $currentProperty;
  52945. }
  52946. }
  52947. } elseif (isset($schema->items) && LooseTypeCheck::isArray($value)) {
  52948. $items = array();
  52949. if (LooseTypeCheck::isArray($schema->items)) {
  52950. $items = $schema->items;
  52951. } elseif (isset($schema->minItems) && count($value) < $schema->minItems) {
  52952. $items = array_fill(count($value), $schema->minItems - count($value), $schema->items);
  52953. }
  52954. foreach ($items as $currentItem => $itemDefinition) {
  52955. $itemDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($itemDefinition);
  52956. if (
  52957. !array_key_exists($currentItem, $value)
  52958. && property_exists($itemDefinition, 'default')
  52959. && $this->shouldApplyDefaultValue($requiredOnly, $itemDefinition)) {
  52960. if (is_object($itemDefinition->default)) {
  52961. $value[$currentItem] = clone $itemDefinition->default;
  52962. } else {
  52963. $value[$currentItem] = $itemDefinition->default;
  52964. }
  52965. }
  52966. $path->setFromDefault();
  52967. }
  52968. } elseif (
  52969. $value instanceof self
  52970. && property_exists($schema, 'default')
  52971. && $this->shouldApplyDefaultValue($requiredOnly, $schema)) {
  52972. $value = is_object($schema->default) ? clone $schema->default : $schema->default;
  52973. $path->setFromDefault();
  52974. }
  52975. }
  52976. protected function validateOfProperties(&$value, $schema, JsonPointer $path, $i = '')
  52977. {
  52978. if ($value instanceof self) {
  52979. return;
  52980. }
  52981. if (isset($schema->allOf)) {
  52982. $isValid = true;
  52983. foreach ($schema->allOf as $allOf) {
  52984. $initErrors = $this->getErrors();
  52985. $this->checkUndefined($value, $allOf, $path, $i);
  52986. $isValid = $isValid && (count($this->getErrors()) == count($initErrors));
  52987. }
  52988. if (!$isValid) {
  52989. $this->addError($path, 'Failed to match all schemas', 'allOf');
  52990. }
  52991. }
  52992. if (isset($schema->anyOf)) {
  52993. $isValid = false;
  52994. $startErrors = $this->getErrors();
  52995. $caughtException = null;
  52996. foreach ($schema->anyOf as $anyOf) {
  52997. $initErrors = $this->getErrors();
  52998. try {
  52999. $this->checkUndefined($value, $anyOf, $path, $i);
  53000. if ($isValid = (count($this->getErrors()) == count($initErrors))) {
  53001. break;
  53002. }
  53003. } catch (ValidationException $e) {
  53004. $isValid = false;
  53005. }
  53006. }
  53007. if (!$isValid) {
  53008. $this->addError($path, 'Failed to match at least one schema', 'anyOf');
  53009. } else {
  53010. $this->errors = $startErrors;
  53011. }
  53012. }
  53013. if (isset($schema->oneOf)) {
  53014. $allErrors = array();
  53015. $matchedSchemas = 0;
  53016. $startErrors = $this->getErrors();
  53017. foreach ($schema->oneOf as $oneOf) {
  53018. try {
  53019. $this->errors = array();
  53020. $this->checkUndefined($value, $oneOf, $path, $i);
  53021. if (count($this->getErrors()) == 0) {
  53022. $matchedSchemas++;
  53023. }
  53024. $allErrors = array_merge($allErrors, array_values($this->getErrors()));
  53025. } catch (ValidationException $e) {
  53026. }
  53027. }
  53028. if ($matchedSchemas !== 1) {
  53029. $this->addErrors(array_merge($allErrors, $startErrors));
  53030. $this->addError($path, 'Failed to match exactly one schema', 'oneOf');
  53031. } else {
  53032. $this->errors = $startErrors;
  53033. }
  53034. }
  53035. }
  53036. protected function validateDependencies($value, $dependencies, JsonPointer $path, $i = '')
  53037. {
  53038. foreach ($dependencies as $key => $dependency) {
  53039. if ($this->getTypeCheck()->propertyExists($value, $key)) {
  53040. if (is_string($dependency)) {
  53041. if (!$this->getTypeCheck()->propertyExists($value, $dependency)) {
  53042. $this->addError($path, "$key depends on $dependency and $dependency is missing", 'dependencies');
  53043. }
  53044. } elseif (is_array($dependency)) {
  53045. foreach ($dependency as $d) {
  53046. if (!$this->getTypeCheck()->propertyExists($value, $d)) {
  53047. $this->addError($path, "$key depends on $d and $d is missing", 'dependencies');
  53048. }
  53049. }
  53050. } elseif (is_object($dependency)) {
  53051. $this->checkUndefined($value, $dependency, $path, $i);
  53052. }
  53053. }
  53054. }
  53055. }
  53056. protected function validateUri($schema, $schemaUri = null)
  53057. {
  53058. $resolver = new UriResolver();
  53059. $retriever = $this->factory->getUriRetriever();
  53060. $jsonSchema = null;
  53061. if ($resolver->isValid($schemaUri)) {
  53062. $schemaId = property_exists($schema, 'id') ? $schema->id : null;
  53063. $jsonSchema = $retriever->retrieve($schemaId, $schemaUri);
  53064. }
  53065. return $jsonSchema;
  53066. }
  53067. }
  53068. <?php
  53069. namespace JsonSchema\Entity;
  53070. use JsonSchema\Exception\InvalidArgumentException;
  53071. class JsonPointer
  53072. {
  53073. private $filename;
  53074. private $propertyPaths = array();
  53075. private $fromDefault = false;
  53076. public function __construct($value)
  53077. {
  53078. if (!is_string($value)) {
  53079. throw new InvalidArgumentException('Ref value must be a string');
  53080. }
  53081. $splitRef = explode('#', $value, 2);
  53082. $this->filename = $splitRef[0];
  53083. if (array_key_exists(1, $splitRef)) {
  53084. $this->propertyPaths = $this->decodePropertyPaths($splitRef[1]);
  53085. }
  53086. }
  53087. private function decodePropertyPaths($propertyPathString)
  53088. {
  53089. $paths = array();
  53090. foreach (explode('/', trim($propertyPathString, '/')) as $path) {
  53091. $path = $this->decodePath($path);
  53092. if (is_string($path) && '' !== $path) {
  53093. $paths[] = $path;
  53094. }
  53095. }
  53096. return $paths;
  53097. }
  53098. private function encodePropertyPaths()
  53099. {
  53100. return array_map(
  53101. array($this, 'encodePath'),
  53102. $this->getPropertyPaths()
  53103. );
  53104. }
  53105. private function decodePath($path)
  53106. {
  53107. return strtr($path, array('~1' => '/', '~0' => '~', '%25' => '%'));
  53108. }
  53109. private function encodePath($path)
  53110. {
  53111. return strtr($path, array('/' => '~1', '~' => '~0', '%' => '%25'));
  53112. }
  53113. public function getFilename()
  53114. {
  53115. return $this->filename;
  53116. }
  53117. public function getPropertyPaths()
  53118. {
  53119. return $this->propertyPaths;
  53120. }
  53121. public function withPropertyPaths(array $propertyPaths)
  53122. {
  53123. $new = clone $this;
  53124. $new->propertyPaths = $propertyPaths;
  53125. return $new;
  53126. }
  53127. public function getPropertyPathAsString()
  53128. {
  53129. return rtrim('#/' . implode('/', $this->encodePropertyPaths()), '/');
  53130. }
  53131. public function __toString()
  53132. {
  53133. return $this->getFilename() . $this->getPropertyPathAsString();
  53134. }
  53135. public function setFromDefault()
  53136. {
  53137. $this->fromDefault = true;
  53138. }
  53139. public function fromDefault()
  53140. {
  53141. return $this->fromDefault;
  53142. }
  53143. }
  53144. <?php
  53145. namespace JsonSchema\Exception;
  53146. interface ExceptionInterface
  53147. {
  53148. }
  53149. <?php
  53150. namespace JsonSchema\Exception;
  53151. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  53152. {
  53153. }
  53154. <?php
  53155. namespace JsonSchema\Exception;
  53156. class InvalidConfigException extends RuntimeException
  53157. {
  53158. }
  53159. <?php
  53160. namespace JsonSchema\Exception;
  53161. class InvalidSchemaException extends RuntimeException
  53162. {
  53163. }
  53164. <?php
  53165. namespace JsonSchema\Exception;
  53166. class InvalidSchemaMediaTypeException extends RuntimeException
  53167. {
  53168. }
  53169. <?php
  53170. namespace JsonSchema\Exception;
  53171. class InvalidSourceUriException extends InvalidArgumentException
  53172. {
  53173. }
  53174. <?php
  53175. namespace JsonSchema\Exception;
  53176. class JsonDecodingException extends RuntimeException
  53177. {
  53178. public function __construct($code = JSON_ERROR_NONE, \Exception $previous = null)
  53179. {
  53180. switch ($code) {
  53181. case JSON_ERROR_DEPTH:
  53182. $message = 'The maximum stack depth has been exceeded';
  53183. break;
  53184. case JSON_ERROR_STATE_MISMATCH:
  53185. $message = 'Invalid or malformed JSON';
  53186. break;
  53187. case JSON_ERROR_CTRL_CHAR:
  53188. $message = 'Control character error, possibly incorrectly encoded';
  53189. break;
  53190. case JSON_ERROR_UTF8:
  53191. $message = 'Malformed UTF-8 characters, possibly incorrectly encoded';
  53192. break;
  53193. case JSON_ERROR_SYNTAX:
  53194. $message = 'JSON syntax is malformed';
  53195. break;
  53196. default:
  53197. $message = 'Syntax error';
  53198. }
  53199. parent::__construct($message, $code, $previous);
  53200. }
  53201. }
  53202. <?php
  53203. namespace JsonSchema\Exception;
  53204. class ResourceNotFoundException extends RuntimeException
  53205. {
  53206. }
  53207. <?php
  53208. namespace JsonSchema\Exception;
  53209. class RuntimeException extends \RuntimeException implements ExceptionInterface
  53210. {
  53211. }
  53212. <?php
  53213. namespace JsonSchema\Exception;
  53214. class UnresolvableJsonPointerException extends InvalidArgumentException
  53215. {
  53216. }
  53217. <?php
  53218. namespace JsonSchema\Exception;
  53219. class UriResolverException extends RuntimeException
  53220. {
  53221. }
  53222. <?php
  53223. namespace JsonSchema\Exception;
  53224. class ValidationException extends RuntimeException
  53225. {
  53226. }
  53227. <?php
  53228. namespace JsonSchema\Iterator;
  53229. class ObjectIterator implements \Iterator, \Countable
  53230. {
  53231. private $object;
  53232. private $position = 0;
  53233. private $data = array();
  53234. private $initialized = false;
  53235. public function __construct($object)
  53236. {
  53237. $this->object = $object;
  53238. }
  53239. public function current()
  53240. {
  53241. $this->initialize();
  53242. return $this->data[$this->position];
  53243. }
  53244. public function next()
  53245. {
  53246. $this->initialize();
  53247. $this->position++;
  53248. }
  53249. public function key()
  53250. {
  53251. $this->initialize();
  53252. return $this->position;
  53253. }
  53254. public function valid()
  53255. {
  53256. $this->initialize();
  53257. return isset($this->data[$this->position]);
  53258. }
  53259. public function rewind()
  53260. {
  53261. $this->initialize();
  53262. $this->position = 0;
  53263. }
  53264. public function count()
  53265. {
  53266. $this->initialize();
  53267. return count($this->data);
  53268. }
  53269. private function initialize()
  53270. {
  53271. if (!$this->initialized) {
  53272. $this->data = $this->buildDataFromObject($this->object);
  53273. $this->initialized = true;
  53274. }
  53275. }
  53276. private function buildDataFromObject($object)
  53277. {
  53278. $result = array();
  53279. $stack = new \SplStack();
  53280. $stack->push($object);
  53281. while (!$stack->isEmpty()) {
  53282. $current = $stack->pop();
  53283. if (is_object($current)) {
  53284. array_push($result, $current);
  53285. }
  53286. foreach ($this->getDataFromItem($current) as $propertyName => $propertyValue) {
  53287. if (is_object($propertyValue) || is_array($propertyValue)) {
  53288. $stack->push($propertyValue);
  53289. }
  53290. }
  53291. }
  53292. return $result;
  53293. }
  53294. private function getDataFromItem($item)
  53295. {
  53296. if (!is_object($item) && !is_array($item)) {
  53297. return array();
  53298. }
  53299. return is_object($item) ? get_object_vars($item) : $item;
  53300. }
  53301. }
  53302. <?php
  53303. namespace JsonSchema;
  53304. class Rfc3339
  53305. {
  53306. const REGEX = '/^(\d{4}-\d{2}-\d{2}[T ]{1}\d{2}:\d{2}:\d{2})(\.\d+)?(Z|([+-]\d{2}):?(\d{2}))$/';
  53307. public static function createFromString($string)
  53308. {
  53309. if (!preg_match(self::REGEX, strtoupper($string), $matches)) {
  53310. return null;
  53311. }
  53312. $dateAndTime = $matches[1];
  53313. $microseconds = $matches[2] ?: '.000000';
  53314. $timeZone = 'Z' !== $matches[3] ? $matches[4] . ':' . $matches[5] : '+00:00';
  53315. $dateFormat = strpos($dateAndTime, 'T') === false ? 'Y-m-d H:i:s.uP' : 'Y-m-d\TH:i:s.uP';
  53316. $dateTime = \DateTime::createFromFormat($dateFormat, $dateAndTime . $microseconds . $timeZone, new \DateTimeZone('UTC'));
  53317. return $dateTime ?: null;
  53318. }
  53319. }
  53320. <?php
  53321. namespace JsonSchema;
  53322. use JsonSchema\Constraints\BaseConstraint;
  53323. use JsonSchema\Entity\JsonPointer;
  53324. use JsonSchema\Exception\UnresolvableJsonPointerException;
  53325. use JsonSchema\Uri\UriResolver;
  53326. use JsonSchema\Uri\UriRetriever;
  53327. class SchemaStorage implements SchemaStorageInterface
  53328. {
  53329. const INTERNAL_PROVIDED_SCHEMA_URI = 'internal://provided-schema/';
  53330. protected $uriRetriever;
  53331. protected $uriResolver;
  53332. protected $schemas = array();
  53333. public function __construct(
  53334. UriRetrieverInterface $uriRetriever = null,
  53335. UriResolverInterface $uriResolver = null
  53336. ) {
  53337. $this->uriRetriever = $uriRetriever ?: new UriRetriever();
  53338. $this->uriResolver = $uriResolver ?: new UriResolver();
  53339. }
  53340. public function getUriRetriever()
  53341. {
  53342. return $this->uriRetriever;
  53343. }
  53344. public function getUriResolver()
  53345. {
  53346. return $this->uriResolver;
  53347. }
  53348. public function addSchema($id, $schema = null)
  53349. {
  53350. if (is_null($schema) && $id !== self::INTERNAL_PROVIDED_SCHEMA_URI) {
  53351. $schema = $this->uriRetriever->retrieve($id);
  53352. }
  53353. if (is_array($schema)) {
  53354. $schema = BaseConstraint::arrayToObjectRecursive($schema);
  53355. }
  53356. if (is_object($schema) && property_exists($schema, 'id')) {
  53357. if ($schema->id == 'http://json-schema.org/draft-04/schema#') {
  53358. $schema->properties->id->format = 'uri-reference';
  53359. } elseif ($schema->id == 'http://json-schema.org/draft-03/schema#') {
  53360. $schema->properties->id->format = 'uri-reference';
  53361. $schema->properties->{'$ref'}->format = 'uri-reference';
  53362. }
  53363. }
  53364. $this->expandRefs($schema, $id);
  53365. $this->schemas[$id] = $schema;
  53366. }
  53367. private function expandRefs(&$schema, $base = null)
  53368. {
  53369. if (!is_object($schema)) {
  53370. if (is_array($schema)) {
  53371. foreach ($schema as &$member) {
  53372. $this->expandRefs($member, $base);
  53373. }
  53374. }
  53375. return;
  53376. }
  53377. if (property_exists($schema, 'id') && is_string($schema->id) && $base != $schema->id) {
  53378. $base = $this->uriResolver->resolve($schema->id, $base);
  53379. }
  53380. if (property_exists($schema, '$ref') && is_string($schema->{'$ref'})) {
  53381. $refPointer = new JsonPointer($this->uriResolver->resolve($schema->{'$ref'}, $base));
  53382. $schema->{'$ref'} = (string) $refPointer;
  53383. }
  53384. foreach ($schema as &$member) {
  53385. $this->expandRefs($member, $base);
  53386. }
  53387. }
  53388. public function getSchema($id)
  53389. {
  53390. if (!array_key_exists($id, $this->schemas)) {
  53391. $this->addSchema($id);
  53392. }
  53393. return $this->schemas[$id];
  53394. }
  53395. public function resolveRef($ref)
  53396. {
  53397. $jsonPointer = new JsonPointer($ref);
  53398. $fileName = $jsonPointer->getFilename();
  53399. if (!strlen($fileName)) {
  53400. throw new UnresolvableJsonPointerException(sprintf(
  53401. "Could not resolve fragment '%s': no file is defined",
  53402. $jsonPointer->getPropertyPathAsString()
  53403. ));
  53404. }
  53405. $refSchema = $this->getSchema($fileName);
  53406. foreach ($jsonPointer->getPropertyPaths() as $path) {
  53407. if (is_object($refSchema) && property_exists($refSchema, $path)) {
  53408. $refSchema = $this->resolveRefSchema($refSchema->{$path});
  53409. } elseif (is_array($refSchema) && array_key_exists($path, $refSchema)) {
  53410. $refSchema = $this->resolveRefSchema($refSchema[$path]);
  53411. } else {
  53412. throw new UnresolvableJsonPointerException(sprintf(
  53413. 'File: %s is found, but could not resolve fragment: %s',
  53414. $jsonPointer->getFilename(),
  53415. $jsonPointer->getPropertyPathAsString()
  53416. ));
  53417. }
  53418. }
  53419. return $refSchema;
  53420. }
  53421. public function resolveRefSchema($refSchema)
  53422. {
  53423. if (is_object($refSchema) && property_exists($refSchema, '$ref') && is_string($refSchema->{'$ref'})) {
  53424. $newSchema = $this->resolveRef($refSchema->{'$ref'});
  53425. $refSchema = (object) (get_object_vars($refSchema) + get_object_vars($newSchema));
  53426. unset($refSchema->{'$ref'});
  53427. }
  53428. return $refSchema;
  53429. }
  53430. }
  53431. <?php
  53432. namespace JsonSchema;
  53433. interface SchemaStorageInterface
  53434. {
  53435. public function addSchema($id, $schema = null);
  53436. public function getSchema($id);
  53437. public function resolveRef($ref);
  53438. public function resolveRefSchema($refSchema);
  53439. }
  53440. <?php
  53441. namespace JsonSchema\Uri\Retrievers;
  53442. abstract class AbstractRetriever implements UriRetrieverInterface
  53443. {
  53444. protected $contentType;
  53445. public function getContentType()
  53446. {
  53447. return $this->contentType;
  53448. }
  53449. }
  53450. <?php
  53451. namespace JsonSchema\Uri\Retrievers;
  53452. use JsonSchema\Exception\RuntimeException;
  53453. use JsonSchema\Validator;
  53454. class Curl extends AbstractRetriever
  53455. {
  53456. protected $messageBody;
  53457. public function __construct()
  53458. {
  53459. if (!function_exists('curl_init')) {
  53460. throw new RuntimeException('cURL not installed');
  53461. }
  53462. }
  53463. public function retrieve($uri)
  53464. {
  53465. $ch = curl_init();
  53466. curl_setopt($ch, CURLOPT_URL, $uri);
  53467. curl_setopt($ch, CURLOPT_HEADER, true);
  53468. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  53469. curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: ' . Validator::SCHEMA_MEDIA_TYPE));
  53470. $response = curl_exec($ch);
  53471. if (false === $response) {
  53472. throw new \JsonSchema\Exception\ResourceNotFoundException('JSON schema not found');
  53473. }
  53474. $this->fetchMessageBody($response);
  53475. $this->fetchContentType($response);
  53476. curl_close($ch);
  53477. return $this->messageBody;
  53478. }
  53479. private function fetchMessageBody($response)
  53480. {
  53481. preg_match("/(?:\r\n){2}(.*)$/ms", $response, $match);
  53482. $this->messageBody = $match[1];
  53483. }
  53484. protected function fetchContentType($response)
  53485. {
  53486. if (0 < preg_match("/Content-Type:(\V*)/ims", $response, $match)) {
  53487. $this->contentType = trim($match[1]);
  53488. return true;
  53489. }
  53490. return false;
  53491. }
  53492. }
  53493. <?php
  53494. namespace JsonSchema\Uri\Retrievers;
  53495. use JsonSchema\Exception\ResourceNotFoundException;
  53496. class FileGetContents extends AbstractRetriever
  53497. {
  53498. protected $messageBody;
  53499. public function retrieve($uri)
  53500. {
  53501. $errorMessage = null;
  53502. set_error_handler(function ($errno, $errstr) use (&$errorMessage) {
  53503. $errorMessage = $errstr;
  53504. });
  53505. $response = file_get_contents($uri);
  53506. restore_error_handler();
  53507. if ($errorMessage) {
  53508. throw new ResourceNotFoundException($errorMessage);
  53509. }
  53510. if (false === $response) {
  53511. throw new ResourceNotFoundException('JSON schema not found at ' . $uri);
  53512. }
  53513. if ($response == ''
  53514. && substr($uri, 0, 7) == 'file://' && substr($uri, -1) == '/'
  53515. ) {
  53516. throw new ResourceNotFoundException('JSON schema not found at ' . $uri);
  53517. }
  53518. $this->messageBody = $response;
  53519. if (!empty($http_response_header)) {
  53520. $this->fetchContentType($http_response_header);
  53521. } else {
  53522. $this->contentType = null;
  53523. }
  53524. return $this->messageBody;
  53525. }
  53526. private function fetchContentType(array $headers)
  53527. {
  53528. foreach ($headers as $header) {
  53529. if ($this->contentType = self::getContentTypeMatchInHeader($header)) {
  53530. return true;
  53531. }
  53532. }
  53533. return false;
  53534. }
  53535. protected static function getContentTypeMatchInHeader($header)
  53536. {
  53537. if (0 < preg_match("/Content-Type:(\V*)/ims", $header, $match)) {
  53538. return trim($match[1]);
  53539. }
  53540. return null;
  53541. }
  53542. }
  53543. <?php
  53544. namespace JsonSchema\Uri\Retrievers;
  53545. use JsonSchema\Validator;
  53546. class PredefinedArray extends AbstractRetriever
  53547. {
  53548. private $schemas;
  53549. public function __construct(array $schemas, $contentType = Validator::SCHEMA_MEDIA_TYPE)
  53550. {
  53551. $this->schemas = $schemas;
  53552. $this->contentType = $contentType;
  53553. }
  53554. public function retrieve($uri)
  53555. {
  53556. if (!array_key_exists($uri, $this->schemas)) {
  53557. throw new \JsonSchema\Exception\ResourceNotFoundException(sprintf(
  53558. 'The JSON schema "%s" was not found.',
  53559. $uri
  53560. ));
  53561. }
  53562. return $this->schemas[$uri];
  53563. }
  53564. }
  53565. <?php
  53566. namespace JsonSchema\Uri\Retrievers;
  53567. interface UriRetrieverInterface
  53568. {
  53569. public function retrieve($uri);
  53570. public function getContentType();
  53571. }
  53572. <?php
  53573. namespace JsonSchema\Uri;
  53574. use JsonSchema\Exception\UriResolverException;
  53575. use JsonSchema\UriResolverInterface;
  53576. class UriResolver implements UriResolverInterface
  53577. {
  53578. public function parse($uri)
  53579. {
  53580. preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
  53581. $components = array();
  53582. if (5 < count($match)) {
  53583. $components = array(
  53584. 'scheme' => $match[2],
  53585. 'authority' => $match[4],
  53586. 'path' => $match[5]
  53587. );
  53588. }
  53589. if (7 < count($match)) {
  53590. $components['query'] = $match[7];
  53591. }
  53592. if (9 < count($match)) {
  53593. $components['fragment'] = $match[9];
  53594. }
  53595. return $components;
  53596. }
  53597. public function generate(array $components)
  53598. {
  53599. $uri = $components['scheme'] . '://'
  53600. . $components['authority']
  53601. . $components['path'];
  53602. if (array_key_exists('query', $components) && strlen($components['query'])) {
  53603. $uri .= '?' . $components['query'];
  53604. }
  53605. if (array_key_exists('fragment', $components)) {
  53606. $uri .= '#' . $components['fragment'];
  53607. }
  53608. return $uri;
  53609. }
  53610. public function resolve($uri, $baseUri = null)
  53611. {
  53612. if (
  53613. !is_null($baseUri) &&
  53614. !filter_var($baseUri, \FILTER_VALIDATE_URL) &&
  53615. !preg_match('|^[^/]+://|u', $baseUri)
  53616. ) {
  53617. if (is_file($baseUri)) {
  53618. $baseUri = 'file://' . realpath($baseUri);
  53619. } elseif (is_dir($baseUri)) {
  53620. $baseUri = 'file://' . realpath($baseUri) . '/';
  53621. } else {
  53622. $baseUri = 'file://' . getcwd() . '/' . $baseUri;
  53623. }
  53624. }
  53625. if ($uri == '') {
  53626. return $baseUri;
  53627. }
  53628. $components = $this->parse($uri);
  53629. $path = $components['path'];
  53630. if (!empty($components['scheme'])) {
  53631. return $uri;
  53632. }
  53633. $baseComponents = $this->parse($baseUri);
  53634. $basePath = $baseComponents['path'];
  53635. $baseComponents['path'] = self::combineRelativePathWithBasePath($path, $basePath);
  53636. if (isset($components['fragment'])) {
  53637. $baseComponents['fragment'] = $components['fragment'];
  53638. }
  53639. return $this->generate($baseComponents);
  53640. }
  53641. public static function combineRelativePathWithBasePath($relativePath, $basePath)
  53642. {
  53643. $relativePath = self::normalizePath($relativePath);
  53644. if ($relativePath == '') {
  53645. return $basePath;
  53646. }
  53647. if ($relativePath[0] == '/') {
  53648. return $relativePath;
  53649. }
  53650. $basePathSegments = explode('/', $basePath);
  53651. preg_match('|^/?(\.\./(?:\./)*)*|', $relativePath, $match);
  53652. $numLevelUp = strlen($match[0]) /3 + 1;
  53653. if ($numLevelUp >= count($basePathSegments)) {
  53654. throw new UriResolverException(sprintf("Unable to resolve URI '%s' from base '%s'", $relativePath, $basePath));
  53655. }
  53656. $basePathSegments = array_slice($basePathSegments, 0, -$numLevelUp);
  53657. $path = preg_replace('|^/?(\.\./(\./)*)*|', '', $relativePath);
  53658. return implode('/', $basePathSegments) . '/' . $path;
  53659. }
  53660. private static function normalizePath($path)
  53661. {
  53662. $path = preg_replace('|((?<!\.)\./)*|', '', $path);
  53663. $path = preg_replace('|//|', '/', $path);
  53664. return $path;
  53665. }
  53666. public function isValid($uri)
  53667. {
  53668. $components = $this->parse($uri);
  53669. return !empty($components);
  53670. }
  53671. }
  53672. <?php
  53673. namespace JsonSchema\Uri;
  53674. use JsonSchema\Exception\InvalidSchemaMediaTypeException;
  53675. use JsonSchema\Exception\JsonDecodingException;
  53676. use JsonSchema\Exception\ResourceNotFoundException;
  53677. use JsonSchema\Uri\Retrievers\FileGetContents;
  53678. use JsonSchema\Uri\Retrievers\UriRetrieverInterface;
  53679. use JsonSchema\UriRetrieverInterface as BaseUriRetrieverInterface;
  53680. use JsonSchema\Validator;
  53681. class UriRetriever implements BaseUriRetrieverInterface
  53682. {
  53683. protected $translationMap = array(
  53684. '|^https?://json-schema.org/draft-(0[34])/schema#?|' => 'package://dist/schema/json-schema-draft-$1.json'
  53685. );
  53686. protected $allowedInvalidContentTypeEndpoints = array(
  53687. 'http://json-schema.org/',
  53688. 'https://json-schema.org/'
  53689. );
  53690. protected $uriRetriever = null;
  53691. private $schemaCache = array();
  53692. public function addInvalidContentTypeEndpoint($endpoint)
  53693. {
  53694. $this->allowedInvalidContentTypeEndpoints[] = $endpoint;
  53695. }
  53696. public function confirmMediaType($uriRetriever, $uri)
  53697. {
  53698. $contentType = $uriRetriever->getContentType();
  53699. if (is_null($contentType)) {
  53700. return;
  53701. }
  53702. if (in_array($contentType, array(Validator::SCHEMA_MEDIA_TYPE, 'application/json'))) {
  53703. return;
  53704. }
  53705. foreach ($this->allowedInvalidContentTypeEndpoints as $endpoint) {
  53706. if (strpos($uri, $endpoint) === 0) {
  53707. return true;
  53708. }
  53709. }
  53710. throw new InvalidSchemaMediaTypeException(sprintf('Media type %s expected', Validator::SCHEMA_MEDIA_TYPE));
  53711. }
  53712. public function getUriRetriever()
  53713. {
  53714. if (is_null($this->uriRetriever)) {
  53715. $this->setUriRetriever(new FileGetContents());
  53716. }
  53717. return $this->uriRetriever;
  53718. }
  53719. public function resolvePointer($jsonSchema, $uri)
  53720. {
  53721. $resolver = new UriResolver();
  53722. $parsed = $resolver->parse($uri);
  53723. if (empty($parsed['fragment'])) {
  53724. return $jsonSchema;
  53725. }
  53726. $path = explode('/', $parsed['fragment']);
  53727. while ($path) {
  53728. $pathElement = array_shift($path);
  53729. if (!empty($pathElement)) {
  53730. $pathElement = str_replace('~1', '/', $pathElement);
  53731. $pathElement = str_replace('~0', '~', $pathElement);
  53732. if (!empty($jsonSchema->$pathElement)) {
  53733. $jsonSchema = $jsonSchema->$pathElement;
  53734. } else {
  53735. throw new ResourceNotFoundException(
  53736. 'Fragment "' . $parsed['fragment'] . '" not found'
  53737. . ' in ' . $uri
  53738. );
  53739. }
  53740. if (!is_object($jsonSchema)) {
  53741. throw new ResourceNotFoundException(
  53742. 'Fragment part "' . $pathElement . '" is no object '
  53743. . ' in ' . $uri
  53744. );
  53745. }
  53746. }
  53747. }
  53748. return $jsonSchema;
  53749. }
  53750. public function retrieve($uri, $baseUri = null, $translate = true)
  53751. {
  53752. $resolver = new UriResolver();
  53753. $resolvedUri = $fetchUri = $resolver->resolve($uri, $baseUri);
  53754. $arParts = $resolver->parse($resolvedUri);
  53755. if (isset($arParts['fragment'])) {
  53756. unset($arParts['fragment']);
  53757. $fetchUri = $resolver->generate($arParts);
  53758. }
  53759. if ($translate) {
  53760. $fetchUri = $this->translate($fetchUri);
  53761. }
  53762. $jsonSchema = $this->loadSchema($fetchUri);
  53763. $jsonSchema = $this->resolvePointer($jsonSchema, $resolvedUri);
  53764. if ($jsonSchema instanceof \stdClass) {
  53765. $jsonSchema->id = $resolvedUri;
  53766. }
  53767. return $jsonSchema;
  53768. }
  53769. protected function loadSchema($fetchUri)
  53770. {
  53771. if (isset($this->schemaCache[$fetchUri])) {
  53772. return $this->schemaCache[$fetchUri];
  53773. }
  53774. $uriRetriever = $this->getUriRetriever();
  53775. $contents = $this->uriRetriever->retrieve($fetchUri);
  53776. $this->confirmMediaType($uriRetriever, $fetchUri);
  53777. $jsonSchema = json_decode($contents);
  53778. if (JSON_ERROR_NONE < $error = json_last_error()) {
  53779. throw new JsonDecodingException($error);
  53780. }
  53781. $this->schemaCache[$fetchUri] = $jsonSchema;
  53782. return $jsonSchema;
  53783. }
  53784. public function setUriRetriever(UriRetrieverInterface $uriRetriever)
  53785. {
  53786. $this->uriRetriever = $uriRetriever;
  53787. return $this;
  53788. }
  53789. public function parse($uri)
  53790. {
  53791. preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
  53792. $components = array();
  53793. if (5 < count($match)) {
  53794. $components = array(
  53795. 'scheme' => $match[2],
  53796. 'authority' => $match[4],
  53797. 'path' => $match[5]
  53798. );
  53799. }
  53800. if (7 < count($match)) {
  53801. $components['query'] = $match[7];
  53802. }
  53803. if (9 < count($match)) {
  53804. $components['fragment'] = $match[9];
  53805. }
  53806. return $components;
  53807. }
  53808. public function generate(array $components)
  53809. {
  53810. $uri = $components['scheme'] . '://'
  53811. . $components['authority']
  53812. . $components['path'];
  53813. if (array_key_exists('query', $components)) {
  53814. $uri .= $components['query'];
  53815. }
  53816. if (array_key_exists('fragment', $components)) {
  53817. $uri .= $components['fragment'];
  53818. }
  53819. return $uri;
  53820. }
  53821. public function resolve($uri, $baseUri = null)
  53822. {
  53823. $components = $this->parse($uri);
  53824. $path = $components['path'];
  53825. if ((array_key_exists('scheme', $components)) && ('http' === $components['scheme'])) {
  53826. return $uri;
  53827. }
  53828. $baseComponents = $this->parse($baseUri);
  53829. $basePath = $baseComponents['path'];
  53830. $baseComponents['path'] = UriResolver::combineRelativePathWithBasePath($path, $basePath);
  53831. return $this->generate($baseComponents);
  53832. }
  53833. public function isValid($uri)
  53834. {
  53835. $components = $this->parse($uri);
  53836. return !empty($components);
  53837. }
  53838. public function setTranslation($from, $to)
  53839. {
  53840. $this->translationMap[$from] = $to;
  53841. }
  53842. public function translate($uri)
  53843. {
  53844. foreach ($this->translationMap as $from => $to) {
  53845. $uri = preg_replace($from, $to, $uri);
  53846. }
  53847. $uri = preg_replace('|^package://|', sprintf('file://%s/', realpath(__DIR__ . '/../../..')), $uri);
  53848. return $uri;
  53849. }
  53850. }
  53851. <?php
  53852. namespace JsonSchema;
  53853. interface UriResolverInterface
  53854. {
  53855. public function resolve($uri, $baseUri = null);
  53856. }
  53857. <?php
  53858. namespace JsonSchema;
  53859. interface UriRetrieverInterface
  53860. {
  53861. public function retrieve($uri, $baseUri = null);
  53862. }
  53863. <?php
  53864. namespace JsonSchema;
  53865. use JsonSchema\Constraints\BaseConstraint;
  53866. use JsonSchema\Constraints\Constraint;
  53867. class Validator extends BaseConstraint
  53868. {
  53869. const SCHEMA_MEDIA_TYPE = 'application/schema+json';
  53870. const ERROR_NONE = 0x00000000;
  53871. const ERROR_ALL = 0xFFFFFFFF;
  53872. const ERROR_DOCUMENT_VALIDATION = 0x00000001;
  53873. const ERROR_SCHEMA_VALIDATION = 0x00000002;
  53874. public function validate(&$value, $schema = null, $checkMode = null)
  53875. {
  53876. if (is_array($schema)) {
  53877. $schema = self::arrayToObjectRecursive($schema);
  53878. }
  53879. $initialCheckMode = $this->factory->getConfig();
  53880. if ($checkMode !== null) {
  53881. $this->factory->setConfig($checkMode);
  53882. }
  53883. if (is_object($schema) && property_exists($schema, 'id')) {
  53884. $schemaURI = $schema->id;
  53885. } else {
  53886. $schemaURI = SchemaStorage::INTERNAL_PROVIDED_SCHEMA_URI;
  53887. }
  53888. $this->factory->getSchemaStorage()->addSchema($schemaURI, $schema);
  53889. $validator = $this->factory->createInstanceFor('schema');
  53890. $validator->check(
  53891. $value,
  53892. $this->factory->getSchemaStorage()->getSchema($schemaURI)
  53893. );
  53894. $this->factory->setConfig($initialCheckMode);
  53895. $this->addErrors(array_unique($validator->getErrors(), SORT_REGULAR));
  53896. return $validator->getErrorMask();
  53897. }
  53898. public function check($value, $schema)
  53899. {
  53900. return $this->validate($value, $schema);
  53901. }
  53902. public function coerce(&$value, $schema)
  53903. {
  53904. return $this->validate($value, $schema, Constraint::CHECK_MODE_COERCE_TYPES);
  53905. }
  53906. }
  53907. The MIT License (MIT)
  53908. Copyright (c) 2013-2016 container-interop
  53909. Copyright (c) 2016 PHP Framework Interoperability Group
  53910. Permission is hereby granted, free of charge, to any person obtaining a copy of
  53911. this software and associated documentation files (the "Software"), to deal in
  53912. the Software without restriction, including without limitation the rights to
  53913. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  53914. the Software, and to permit persons to whom the Software is furnished to do so,
  53915. subject to the following conditions:
  53916. The above copyright notice and this permission notice shall be included in all
  53917. copies or substantial portions of the Software.
  53918. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  53919. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  53920. FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  53921. COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  53922. IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  53923. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  53924. <?php
  53925. namespace Psr\Container;
  53926. interface ContainerExceptionInterface
  53927. {
  53928. }
  53929. <?php
  53930. declare(strict_types=1);
  53931. namespace Psr\Container;
  53932. interface ContainerInterface
  53933. {
  53934. public function get(string $id);
  53935. public function has(string $id);
  53936. }
  53937. <?php
  53938. namespace Psr\Container;
  53939. interface NotFoundExceptionInterface extends ContainerExceptionInterface
  53940. {
  53941. }
  53942. Copyright (c) 2012 PHP Framework Interoperability Group
  53943. Permission is hereby granted, free of charge, to any person obtaining a copy
  53944. of this software and associated documentation files (the "Software"), to deal
  53945. in the Software without restriction, including without limitation the rights
  53946. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  53947. copies of the Software, and to permit persons to whom the Software is
  53948. furnished to do so, subject to the following conditions:
  53949. The above copyright notice and this permission notice shall be included in
  53950. all copies or substantial portions of the Software.
  53951. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  53952. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  53953. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  53954. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  53955. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  53956. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  53957. THE SOFTWARE.
  53958. <?php
  53959. namespace Psr\Log;
  53960. abstract class AbstractLogger implements LoggerInterface
  53961. {
  53962. public function emergency($message, array $context = array())
  53963. {
  53964. $this->log(LogLevel::EMERGENCY, $message, $context);
  53965. }
  53966. public function alert($message, array $context = array())
  53967. {
  53968. $this->log(LogLevel::ALERT, $message, $context);
  53969. }
  53970. public function critical($message, array $context = array())
  53971. {
  53972. $this->log(LogLevel::CRITICAL, $message, $context);
  53973. }
  53974. public function error($message, array $context = array())
  53975. {
  53976. $this->log(LogLevel::ERROR, $message, $context);
  53977. }
  53978. public function warning($message, array $context = array())
  53979. {
  53980. $this->log(LogLevel::WARNING, $message, $context);
  53981. }
  53982. public function notice($message, array $context = array())
  53983. {
  53984. $this->log(LogLevel::NOTICE, $message, $context);
  53985. }
  53986. public function info($message, array $context = array())
  53987. {
  53988. $this->log(LogLevel::INFO, $message, $context);
  53989. }
  53990. public function debug($message, array $context = array())
  53991. {
  53992. $this->log(LogLevel::DEBUG, $message, $context);
  53993. }
  53994. }
  53995. <?php
  53996. namespace Psr\Log;
  53997. class InvalidArgumentException extends \InvalidArgumentException
  53998. {
  53999. }
  54000. <?php
  54001. namespace Psr\Log;
  54002. class LogLevel
  54003. {
  54004. const EMERGENCY = 'emergency';
  54005. const ALERT = 'alert';
  54006. const CRITICAL = 'critical';
  54007. const ERROR = 'error';
  54008. const WARNING = 'warning';
  54009. const NOTICE = 'notice';
  54010. const INFO = 'info';
  54011. const DEBUG = 'debug';
  54012. }
  54013. <?php
  54014. namespace Psr\Log;
  54015. interface LoggerAwareInterface
  54016. {
  54017. public function setLogger(LoggerInterface $logger);
  54018. }
  54019. <?php
  54020. namespace Psr\Log;
  54021. trait LoggerAwareTrait
  54022. {
  54023. protected $logger;
  54024. public function setLogger(LoggerInterface $logger)
  54025. {
  54026. $this->logger = $logger;
  54027. }
  54028. }
  54029. <?php
  54030. namespace Psr\Log;
  54031. interface LoggerInterface
  54032. {
  54033. public function emergency($message, array $context = array());
  54034. public function alert($message, array $context = array());
  54035. public function critical($message, array $context = array());
  54036. public function error($message, array $context = array());
  54037. public function warning($message, array $context = array());
  54038. public function notice($message, array $context = array());
  54039. public function info($message, array $context = array());
  54040. public function debug($message, array $context = array());
  54041. public function log($level, $message, array $context = array());
  54042. }
  54043. <?php
  54044. namespace Psr\Log;
  54045. trait LoggerTrait
  54046. {
  54047. public function emergency($message, array $context = array())
  54048. {
  54049. $this->log(LogLevel::EMERGENCY, $message, $context);
  54050. }
  54051. public function alert($message, array $context = array())
  54052. {
  54053. $this->log(LogLevel::ALERT, $message, $context);
  54054. }
  54055. public function critical($message, array $context = array())
  54056. {
  54057. $this->log(LogLevel::CRITICAL, $message, $context);
  54058. }
  54059. public function error($message, array $context = array())
  54060. {
  54061. $this->log(LogLevel::ERROR, $message, $context);
  54062. }
  54063. public function warning($message, array $context = array())
  54064. {
  54065. $this->log(LogLevel::WARNING, $message, $context);
  54066. }
  54067. public function notice($message, array $context = array())
  54068. {
  54069. $this->log(LogLevel::NOTICE, $message, $context);
  54070. }
  54071. public function info($message, array $context = array())
  54072. {
  54073. $this->log(LogLevel::INFO, $message, $context);
  54074. }
  54075. public function debug($message, array $context = array())
  54076. {
  54077. $this->log(LogLevel::DEBUG, $message, $context);
  54078. }
  54079. abstract public function log($level, $message, array $context = array());
  54080. }
  54081. <?php
  54082. namespace Psr\Log;
  54083. class NullLogger extends AbstractLogger
  54084. {
  54085. public function log($level, $message, array $context = array())
  54086. {
  54087. }
  54088. }
  54089. <?php
  54090. namespace Psr\Log\Test;
  54091. class DummyTest
  54092. {
  54093. public function __toString()
  54094. {
  54095. return 'DummyTest';
  54096. }
  54097. }
  54098. <?php
  54099. namespace Psr\Log\Test;
  54100. use Psr\Log\LoggerInterface;
  54101. use Psr\Log\LogLevel;
  54102. use PHPUnit\Framework\TestCase;
  54103. abstract class LoggerInterfaceTest extends TestCase
  54104. {
  54105. abstract public function getLogger();
  54106. abstract public function getLogs();
  54107. public function testImplements()
  54108. {
  54109. $this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger());
  54110. }
  54111. public function testLogsAtAllLevels($level, $message)
  54112. {
  54113. $logger = $this->getLogger();
  54114. $logger->{$level}($message, array('user' => 'Bob'));
  54115. $logger->log($level, $message, array('user' => 'Bob'));
  54116. $expected = array(
  54117. $level.' message of level '.$level.' with context: Bob',
  54118. $level.' message of level '.$level.' with context: Bob',
  54119. );
  54120. $this->assertEquals($expected, $this->getLogs());
  54121. }
  54122. public function provideLevelsAndMessages()
  54123. {
  54124. return array(
  54125. LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'),
  54126. LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'),
  54127. LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'),
  54128. LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'),
  54129. LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'),
  54130. LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'),
  54131. LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'),
  54132. LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'),
  54133. );
  54134. }
  54135. public function testThrowsOnInvalidLevel()
  54136. {
  54137. $logger = $this->getLogger();
  54138. $logger->log('invalid level', 'Foo');
  54139. }
  54140. public function testContextReplacement()
  54141. {
  54142. $logger = $this->getLogger();
  54143. $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar'));
  54144. $expected = array('info {Message {nothing} Bob Bar a}');
  54145. $this->assertEquals($expected, $this->getLogs());
  54146. }
  54147. public function testObjectCastToString()
  54148. {
  54149. if (method_exists($this, 'createPartialMock')) {
  54150. $dummy = $this->createPartialMock('Psr\Log\Test\DummyTest', array('__toString'));
  54151. } else {
  54152. $dummy = $this->getMock('Psr\Log\Test\DummyTest', array('__toString'));
  54153. }
  54154. $dummy->expects($this->once())
  54155. ->method('__toString')
  54156. ->will($this->returnValue('DUMMY'));
  54157. $this->getLogger()->warning($dummy);
  54158. $expected = array('warning DUMMY');
  54159. $this->assertEquals($expected, $this->getLogs());
  54160. }
  54161. public function testContextCanContainAnything()
  54162. {
  54163. $closed = fopen('php://memory', 'r');
  54164. fclose($closed);
  54165. $context = array(
  54166. 'bool' => true,
  54167. 'null' => null,
  54168. 'string' => 'Foo',
  54169. 'int' => 0,
  54170. 'float' => 0.5,
  54171. 'nested' => array('with object' => new DummyTest),
  54172. 'object' => new \DateTime,
  54173. 'resource' => fopen('php://memory', 'r'),
  54174. 'closed' => $closed,
  54175. );
  54176. $this->getLogger()->warning('Crazy context data', $context);
  54177. $expected = array('warning Crazy context data');
  54178. $this->assertEquals($expected, $this->getLogs());
  54179. }
  54180. public function testContextExceptionKeyCanBeExceptionOrOtherValues()
  54181. {
  54182. $logger = $this->getLogger();
  54183. $logger->warning('Random message', array('exception' => 'oops'));
  54184. $logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail')));
  54185. $expected = array(
  54186. 'warning Random message',
  54187. 'critical Uncaught Exception!'
  54188. );
  54189. $this->assertEquals($expected, $this->getLogs());
  54190. }
  54191. }
  54192. <?php
  54193. namespace Psr\Log\Test;
  54194. use Psr\Log\AbstractLogger;
  54195. class TestLogger extends AbstractLogger
  54196. {
  54197. public $records = [];
  54198. public $recordsByLevel = [];
  54199. public function log($level, $message, array $context = [])
  54200. {
  54201. $record = [
  54202. 'level' => $level,
  54203. 'message' => $message,
  54204. 'context' => $context,
  54205. ];
  54206. $this->recordsByLevel[$record['level']][] = $record;
  54207. $this->records[] = $record;
  54208. }
  54209. public function hasRecords($level)
  54210. {
  54211. return isset($this->recordsByLevel[$level]);
  54212. }
  54213. public function hasRecord($record, $level)
  54214. {
  54215. if (is_string($record)) {
  54216. $record = ['message' => $record];
  54217. }
  54218. return $this->hasRecordThatPasses(function ($rec) use ($record) {
  54219. if ($rec['message'] !== $record['message']) {
  54220. return false;
  54221. }
  54222. if (isset($record['context']) && $rec['context'] !== $record['context']) {
  54223. return false;
  54224. }
  54225. return true;
  54226. }, $level);
  54227. }
  54228. public function hasRecordThatContains($message, $level)
  54229. {
  54230. return $this->hasRecordThatPasses(function ($rec) use ($message) {
  54231. return strpos($rec['message'], $message) !== false;
  54232. }, $level);
  54233. }
  54234. public function hasRecordThatMatches($regex, $level)
  54235. {
  54236. return $this->hasRecordThatPasses(function ($rec) use ($regex) {
  54237. return preg_match($regex, $rec['message']) > 0;
  54238. }, $level);
  54239. }
  54240. public function hasRecordThatPasses(callable $predicate, $level)
  54241. {
  54242. if (!isset($this->recordsByLevel[$level])) {
  54243. return false;
  54244. }
  54245. foreach ($this->recordsByLevel[$level] as $i => $rec) {
  54246. if (call_user_func($predicate, $rec, $i)) {
  54247. return true;
  54248. }
  54249. }
  54250. return false;
  54251. }
  54252. public function __call($method, $args)
  54253. {
  54254. if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) {
  54255. $genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3];
  54256. $level = strtolower($matches[2]);
  54257. if (method_exists($this, $genericMethod)) {
  54258. $args[] = $level;
  54259. return call_user_func_array([$this, $genericMethod], $args);
  54260. }
  54261. }
  54262. throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()');
  54263. }
  54264. public function reset()
  54265. {
  54266. $this->records = [];
  54267. $this->recordsByLevel = [];
  54268. }
  54269. }
  54270. The MIT License (MIT)
  54271. Copyright (c) 2012 Jan Sorgalla, Christian Lück, Cees-Jan Kiewiet, Chris Boden
  54272. Permission is hereby granted, free of charge, to any person
  54273. obtaining a copy of this software and associated documentation
  54274. files (the "Software"), to deal in the Software without
  54275. restriction, including without limitation the rights to use,
  54276. copy, modify, merge, publish, distribute, sublicense, and/or sell
  54277. copies of the Software, and to permit persons to whom the
  54278. Software is furnished to do so, subject to the following
  54279. conditions:
  54280. The above copyright notice and this permission notice shall be
  54281. included in all copies or substantial portions of the Software.
  54282. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  54283. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  54284. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  54285. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  54286. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  54287. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  54288. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  54289. OTHER DEALINGS IN THE SOFTWARE.
  54290. <?php
  54291. namespace React\Promise;
  54292. final class Deferred
  54293. {
  54294. private $promise;
  54295. private $resolveCallback;
  54296. private $rejectCallback;
  54297. public function __construct(callable $canceller = null)
  54298. {
  54299. $this->promise = new Promise(function ($resolve, $reject): void {
  54300. $this->resolveCallback = $resolve;
  54301. $this->rejectCallback = $reject;
  54302. }, $canceller);
  54303. }
  54304. public function promise(): PromiseInterface
  54305. {
  54306. return $this->promise;
  54307. }
  54308. public function resolve($value): void
  54309. {
  54310. ($this->resolveCallback)($value);
  54311. }
  54312. public function reject(\Throwable $reason): void
  54313. {
  54314. ($this->rejectCallback)($reason);
  54315. }
  54316. }
  54317. <?php
  54318. namespace React\Promise\Exception;
  54319. class CompositeException extends \Exception
  54320. {
  54321. private $throwables;
  54322. public function __construct(array $throwables, string $message = '', int $code = 0, ?\Throwable $previous = null)
  54323. {
  54324. parent::__construct($message, $code, $previous);
  54325. $this->throwables = $throwables;
  54326. }
  54327. public function getThrowables(): array
  54328. {
  54329. return $this->throwables;
  54330. }
  54331. }
  54332. <?php
  54333. namespace React\Promise\Exception;
  54334. class LengthException extends \LengthException
  54335. {
  54336. }
  54337. <?php
  54338. namespace React\Promise\Internal;
  54339. final class CancellationQueue
  54340. {
  54341. private $started = false;
  54342. private $queue = [];
  54343. public function __invoke(): void
  54344. {
  54345. if ($this->started) {
  54346. return;
  54347. }
  54348. $this->started = true;
  54349. $this->drain();
  54350. }
  54351. public function enqueue($cancellable): void
  54352. {
  54353. if (!\is_object($cancellable) || !\method_exists($cancellable, 'then') || !\method_exists($cancellable, 'cancel')) {
  54354. return;
  54355. }
  54356. $length = \array_push($this->queue, $cancellable);
  54357. if ($this->started && 1 === $length) {
  54358. $this->drain();
  54359. }
  54360. }
  54361. private function drain(): void
  54362. {
  54363. for ($i = \key($this->queue); isset($this->queue[$i]); $i++) {
  54364. $cancellable = $this->queue[$i];
  54365. assert(\method_exists($cancellable, 'cancel'));
  54366. $exception = null;
  54367. try {
  54368. $cancellable->cancel();
  54369. } catch (\Throwable $exception) {
  54370. }
  54371. unset($this->queue[$i]);
  54372. if ($exception) {
  54373. throw $exception;
  54374. }
  54375. }
  54376. $this->queue = [];
  54377. }
  54378. }
  54379. <?php
  54380. namespace React\Promise\Internal;
  54381. use React\Promise\PromiseInterface;
  54382. use function React\Promise\resolve;
  54383. final class FulfilledPromise implements PromiseInterface
  54384. {
  54385. private $value;
  54386. public function __construct($value = null)
  54387. {
  54388. if ($value instanceof PromiseInterface) {
  54389. throw new \InvalidArgumentException('You cannot create React\Promise\FulfilledPromise with a promise. Use React\Promise\resolve($promiseOrValue) instead.');
  54390. }
  54391. $this->value = $value;
  54392. }
  54393. public function then(callable $onFulfilled = null, callable $onRejected = null): PromiseInterface
  54394. {
  54395. if (null === $onFulfilled) {
  54396. return $this;
  54397. }
  54398. try {
  54399. $result = $onFulfilled($this->value);
  54400. return resolve($result);
  54401. } catch (\Throwable $exception) {
  54402. return new RejectedPromise($exception);
  54403. }
  54404. }
  54405. public function catch(callable $onRejected): PromiseInterface
  54406. {
  54407. return $this;
  54408. }
  54409. public function finally(callable $onFulfilledOrRejected): PromiseInterface
  54410. {
  54411. return $this->then(function ($value) use ($onFulfilledOrRejected): PromiseInterface {
  54412. return resolve($onFulfilledOrRejected())->then(function () use ($value) {
  54413. return $value;
  54414. });
  54415. });
  54416. }
  54417. public function cancel(): void
  54418. {
  54419. }
  54420. public function otherwise(callable $onRejected): PromiseInterface
  54421. {
  54422. return $this->catch($onRejected);
  54423. }
  54424. public function always(callable $onFulfilledOrRejected): PromiseInterface
  54425. {
  54426. return $this->finally($onFulfilledOrRejected);
  54427. }
  54428. }
  54429. <?php
  54430. namespace React\Promise\Internal;
  54431. use React\Promise\PromiseInterface;
  54432. use function React\Promise\_checkTypehint;
  54433. use function React\Promise\resolve;
  54434. use function React\Promise\set_rejection_handler;
  54435. final class RejectedPromise implements PromiseInterface
  54436. {
  54437. private $reason;
  54438. private $handled = false;
  54439. public function __construct(\Throwable $reason)
  54440. {
  54441. $this->reason = $reason;
  54442. }
  54443. public function __destruct()
  54444. {
  54445. if ($this->handled) {
  54446. return;
  54447. }
  54448. $handler = set_rejection_handler(null);
  54449. if ($handler === null) {
  54450. $message = 'Unhandled promise rejection with ' . \get_class($this->reason) . ': ' . $this->reason->getMessage() . ' in ' . $this->reason->getFile() . ':' . $this->reason->getLine() . PHP_EOL;
  54451. $message .= 'Stack trace:' . PHP_EOL . $this->reason->getTraceAsString();
  54452. \error_log($message);
  54453. return;
  54454. }
  54455. try {
  54456. $handler($this->reason);
  54457. } catch (\Throwable $e) {
  54458. $message = 'Fatal error: Uncaught ' . \get_class($e) . ' from unhandled promise rejection handler: ' . $e->getMessage() . ' in ' . $e->getFile() . ':' . $e->getLine() . PHP_EOL;
  54459. $message .= 'Stack trace:' . PHP_EOL . $e->getTraceAsString();
  54460. \error_log($message);
  54461. exit(255);
  54462. }
  54463. }
  54464. public function then(callable $onFulfilled = null, callable $onRejected = null): PromiseInterface
  54465. {
  54466. if (null === $onRejected) {
  54467. return $this;
  54468. }
  54469. $this->handled = true;
  54470. try {
  54471. return resolve($onRejected($this->reason));
  54472. } catch (\Throwable $exception) {
  54473. return new RejectedPromise($exception);
  54474. }
  54475. }
  54476. public function catch(callable $onRejected): PromiseInterface
  54477. {
  54478. if (!_checkTypehint($onRejected, $this->reason)) {
  54479. return $this;
  54480. }
  54481. return $this->then(null, $onRejected);
  54482. }
  54483. public function finally(callable $onFulfilledOrRejected): PromiseInterface
  54484. {
  54485. return $this->then(null, function (\Throwable $reason) use ($onFulfilledOrRejected): PromiseInterface {
  54486. return resolve($onFulfilledOrRejected())->then(function () use ($reason): PromiseInterface {
  54487. return new RejectedPromise($reason);
  54488. });
  54489. });
  54490. }
  54491. public function cancel(): void
  54492. {
  54493. $this->handled = true;
  54494. }
  54495. public function otherwise(callable $onRejected): PromiseInterface
  54496. {
  54497. return $this->catch($onRejected);
  54498. }
  54499. public function always(callable $onFulfilledOrRejected): PromiseInterface
  54500. {
  54501. return $this->finally($onFulfilledOrRejected);
  54502. }
  54503. }
  54504. <?php
  54505. namespace React\Promise;
  54506. use React\Promise\Internal\RejectedPromise;
  54507. final class Promise implements PromiseInterface
  54508. {
  54509. private $canceller;
  54510. private $result;
  54511. private $handlers = [];
  54512. private $requiredCancelRequests = 0;
  54513. private $cancelled = false;
  54514. public function __construct(callable $resolver, callable $canceller = null)
  54515. {
  54516. $this->canceller = $canceller;
  54517. $cb = $resolver;
  54518. $resolver = $canceller = null;
  54519. $this->call($cb);
  54520. }
  54521. public function then(callable $onFulfilled = null, callable $onRejected = null): PromiseInterface
  54522. {
  54523. if (null !== $this->result) {
  54524. return $this->result->then($onFulfilled, $onRejected);
  54525. }
  54526. if (null === $this->canceller) {
  54527. return new static($this->resolver($onFulfilled, $onRejected));
  54528. }
  54529. $parent = $this;
  54530. ++$parent->requiredCancelRequests;
  54531. return new static(
  54532. $this->resolver($onFulfilled, $onRejected),
  54533. static function () use (&$parent) {
  54534. assert($parent instanceof self);
  54535. --$parent->requiredCancelRequests;
  54536. if ($parent->requiredCancelRequests <= 0) {
  54537. $parent->cancel();
  54538. }
  54539. $parent = null;
  54540. }
  54541. );
  54542. }
  54543. public function catch(callable $onRejected): PromiseInterface
  54544. {
  54545. return $this->then(null, static function ($reason) use ($onRejected) {
  54546. if (!_checkTypehint($onRejected, $reason)) {
  54547. return new RejectedPromise($reason);
  54548. }
  54549. return $onRejected($reason);
  54550. });
  54551. }
  54552. public function finally(callable $onFulfilledOrRejected): PromiseInterface
  54553. {
  54554. return $this->then(static function ($value) use ($onFulfilledOrRejected) {
  54555. return resolve($onFulfilledOrRejected())->then(function () use ($value) {
  54556. return $value;
  54557. });
  54558. }, static function ($reason) use ($onFulfilledOrRejected) {
  54559. return resolve($onFulfilledOrRejected())->then(function () use ($reason) {
  54560. return new RejectedPromise($reason);
  54561. });
  54562. });
  54563. }
  54564. public function cancel(): void
  54565. {
  54566. $this->cancelled = true;
  54567. $canceller = $this->canceller;
  54568. $this->canceller = null;
  54569. $parentCanceller = null;
  54570. if (null !== $this->result) {
  54571. if ($this->result instanceof RejectedPromise) {
  54572. $this->result->cancel();
  54573. }
  54574. $root = $this->unwrap($this->result);
  54575. if (!$root instanceof self || null !== $root->result) {
  54576. return;
  54577. }
  54578. $root->requiredCancelRequests--;
  54579. if ($root->requiredCancelRequests <= 0) {
  54580. $parentCanceller = [$root, 'cancel'];
  54581. }
  54582. }
  54583. if (null !== $canceller) {
  54584. $this->call($canceller);
  54585. }
  54586. if ($parentCanceller) {
  54587. $parentCanceller();
  54588. }
  54589. }
  54590. public function otherwise(callable $onRejected): PromiseInterface
  54591. {
  54592. return $this->catch($onRejected);
  54593. }
  54594. public function always(callable $onFulfilledOrRejected): PromiseInterface
  54595. {
  54596. return $this->finally($onFulfilledOrRejected);
  54597. }
  54598. private function resolver(callable $onFulfilled = null, callable $onRejected = null): callable
  54599. {
  54600. return function ($resolve, $reject) use ($onFulfilled, $onRejected) {
  54601. $this->handlers[] = static function (PromiseInterface $promise) use ($onFulfilled, $onRejected, $resolve, $reject) {
  54602. $promise = $promise->then($onFulfilled, $onRejected);
  54603. if ($promise instanceof self && $promise->result === null) {
  54604. $promise->handlers[] = static function (PromiseInterface $promise) use ($resolve, $reject) {
  54605. $promise->then($resolve, $reject);
  54606. };
  54607. } else {
  54608. $promise->then($resolve, $reject);
  54609. }
  54610. };
  54611. };
  54612. }
  54613. private function reject(\Throwable $reason): void
  54614. {
  54615. if (null !== $this->result) {
  54616. return;
  54617. }
  54618. $this->settle(reject($reason));
  54619. }
  54620. private function settle(PromiseInterface $result): void
  54621. {
  54622. $result = $this->unwrap($result);
  54623. if ($result === $this) {
  54624. $result = new RejectedPromise(
  54625. new \LogicException('Cannot resolve a promise with itself.')
  54626. );
  54627. }
  54628. if ($result instanceof self) {
  54629. $result->requiredCancelRequests++;
  54630. } else {
  54631. $this->canceller = null;
  54632. }
  54633. $handlers = $this->handlers;
  54634. $this->handlers = [];
  54635. $this->result = $result;
  54636. foreach ($handlers as $handler) {
  54637. $handler($result);
  54638. }
  54639. if ($this->cancelled && $result instanceof RejectedPromise) {
  54640. $result->cancel();
  54641. }
  54642. }
  54643. private function unwrap(PromiseInterface $promise): PromiseInterface
  54644. {
  54645. while ($promise instanceof self && null !== $promise->result) {
  54646. $promise = $promise->result;
  54647. }
  54648. return $promise;
  54649. }
  54650. private function call(callable $cb): void
  54651. {
  54652. $callback = $cb;
  54653. $cb = null;
  54654. if (\is_array($callback)) {
  54655. $ref = new \ReflectionMethod($callback[0], $callback[1]);
  54656. } elseif (\is_object($callback) && !$callback instanceof \Closure) {
  54657. $ref = new \ReflectionMethod($callback, '__invoke');
  54658. } else {
  54659. assert($callback instanceof \Closure || \is_string($callback));
  54660. $ref = new \ReflectionFunction($callback);
  54661. }
  54662. $args = $ref->getNumberOfParameters();
  54663. try {
  54664. if ($args === 0) {
  54665. $callback();
  54666. } else {
  54667. $target =& $this;
  54668. $callback(
  54669. static function ($value) use (&$target) {
  54670. if ($target !== null) {
  54671. $target->settle(resolve($value));
  54672. $target = null;
  54673. }
  54674. },
  54675. static function (\Throwable $reason) use (&$target) {
  54676. if ($target !== null) {
  54677. $target->reject($reason);
  54678. $target = null;
  54679. }
  54680. }
  54681. );
  54682. }
  54683. } catch (\Throwable $e) {
  54684. $target = null;
  54685. $this->reject($e);
  54686. }
  54687. }
  54688. }
  54689. <?php
  54690. namespace React\Promise;
  54691. interface PromiseInterface
  54692. {
  54693. public function then(?callable $onFulfilled = null, ?callable $onRejected = null): PromiseInterface;
  54694. public function catch(callable $onRejected): PromiseInterface;
  54695. public function finally(callable $onFulfilledOrRejected): PromiseInterface;
  54696. public function cancel(): void;
  54697. public function otherwise(callable $onRejected): PromiseInterface;
  54698. public function always(callable $onFulfilledOrRejected): PromiseInterface;
  54699. }
  54700. <?php
  54701. namespace React\Promise;
  54702. use React\Promise\Exception\CompositeException;
  54703. use React\Promise\Internal\FulfilledPromise;
  54704. use React\Promise\Internal\RejectedPromise;
  54705. function resolve($promiseOrValue): PromiseInterface
  54706. {
  54707. if ($promiseOrValue instanceof PromiseInterface) {
  54708. return $promiseOrValue;
  54709. }
  54710. if (\is_object($promiseOrValue) && \method_exists($promiseOrValue, 'then')) {
  54711. $canceller = null;
  54712. if (\method_exists($promiseOrValue, 'cancel')) {
  54713. $canceller = [$promiseOrValue, 'cancel'];
  54714. assert(\is_callable($canceller));
  54715. }
  54716. return new Promise(function ($resolve, $reject) use ($promiseOrValue): void {
  54717. $promiseOrValue->then($resolve, $reject);
  54718. }, $canceller);
  54719. }
  54720. return new FulfilledPromise($promiseOrValue);
  54721. }
  54722. function reject(\Throwable $reason): PromiseInterface
  54723. {
  54724. return new RejectedPromise($reason);
  54725. }
  54726. function all(iterable $promisesOrValues): PromiseInterface
  54727. {
  54728. $cancellationQueue = new Internal\CancellationQueue();
  54729. return new Promise(function ($resolve, $reject) use ($promisesOrValues, $cancellationQueue): void {
  54730. $toResolve = 0;
  54731. $continue = true;
  54732. $values = [];
  54733. foreach ($promisesOrValues as $i => $promiseOrValue) {
  54734. $cancellationQueue->enqueue($promiseOrValue);
  54735. $values[$i] = null;
  54736. ++$toResolve;
  54737. resolve($promiseOrValue)->then(
  54738. function ($value) use ($i, &$values, &$toResolve, &$continue, $resolve): void {
  54739. $values[$i] = $value;
  54740. if (0 === --$toResolve && !$continue) {
  54741. $resolve($values);
  54742. }
  54743. },
  54744. function (\Throwable $reason) use (&$continue, $reject): void {
  54745. $continue = false;
  54746. $reject($reason);
  54747. }
  54748. );
  54749. if (!$continue && !\is_array($promisesOrValues)) {
  54750. break;
  54751. }
  54752. }
  54753. $continue = false;
  54754. if ($toResolve === 0) {
  54755. $resolve($values);
  54756. }
  54757. }, $cancellationQueue);
  54758. }
  54759. function race(iterable $promisesOrValues): PromiseInterface
  54760. {
  54761. $cancellationQueue = new Internal\CancellationQueue();
  54762. return new Promise(function (callable $resolve, callable $reject) use ($promisesOrValues, $cancellationQueue): void {
  54763. $continue = true;
  54764. foreach ($promisesOrValues as $promiseOrValue) {
  54765. $cancellationQueue->enqueue($promiseOrValue);
  54766. resolve($promiseOrValue)->then($resolve, $reject)->finally(function () use (&$continue): void {
  54767. $continue = false;
  54768. });
  54769. if (!$continue && !\is_array($promisesOrValues)) {
  54770. break;
  54771. }
  54772. }
  54773. }, $cancellationQueue);
  54774. }
  54775. function any(iterable $promisesOrValues): PromiseInterface
  54776. {
  54777. $cancellationQueue = new Internal\CancellationQueue();
  54778. return new Promise(function ($resolve, $reject) use ($promisesOrValues, $cancellationQueue): void {
  54779. $toReject = 0;
  54780. $continue = true;
  54781. $reasons = [];
  54782. foreach ($promisesOrValues as $i => $promiseOrValue) {
  54783. $cancellationQueue->enqueue($promiseOrValue);
  54784. ++$toReject;
  54785. resolve($promiseOrValue)->then(
  54786. function ($value) use ($resolve, &$continue): void {
  54787. $continue = false;
  54788. $resolve($value);
  54789. },
  54790. function (\Throwable $reason) use ($i, &$reasons, &$toReject, $reject, &$continue): void {
  54791. $reasons[$i] = $reason;
  54792. if (0 === --$toReject && !$continue) {
  54793. $reject(new CompositeException(
  54794. $reasons,
  54795. 'All promises rejected.'
  54796. ));
  54797. }
  54798. }
  54799. );
  54800. if (!$continue && !\is_array($promisesOrValues)) {
  54801. break;
  54802. }
  54803. }
  54804. $continue = false;
  54805. if ($toReject === 0 && !$reasons) {
  54806. $reject(new Exception\LengthException(
  54807. 'Must contain at least 1 item but contains only 0 items.'
  54808. ));
  54809. } elseif ($toReject === 0) {
  54810. $reject(new CompositeException(
  54811. $reasons,
  54812. 'All promises rejected.'
  54813. ));
  54814. }
  54815. }, $cancellationQueue);
  54816. }
  54817. function set_rejection_handler(?callable $callback): ?callable
  54818. {
  54819. static $current = null;
  54820. $previous = $current;
  54821. $current = $callback;
  54822. return $previous;
  54823. }
  54824. function _checkTypehint(callable $callback, \Throwable $reason): bool
  54825. {
  54826. if (\is_array($callback)) {
  54827. $callbackReflection = new \ReflectionMethod($callback[0], $callback[1]);
  54828. } elseif (\is_object($callback) && !$callback instanceof \Closure) {
  54829. $callbackReflection = new \ReflectionMethod($callback, '__invoke');
  54830. } else {
  54831. assert($callback instanceof \Closure || \is_string($callback));
  54832. $callbackReflection = new \ReflectionFunction($callback);
  54833. }
  54834. $parameters = $callbackReflection->getParameters();
  54835. if (!isset($parameters[0])) {
  54836. return true;
  54837. }
  54838. $expectedException = $parameters[0];
  54839. $type = $expectedException->getType();
  54840. $isTypeUnion = true;
  54841. $types = [];
  54842. switch (true) {
  54843. case $type === null:
  54844. break;
  54845. case $type instanceof \ReflectionNamedType:
  54846. $types = [$type];
  54847. break;
  54848. case $type instanceof \ReflectionIntersectionType:
  54849. $isTypeUnion = false;
  54850. case $type instanceof \ReflectionUnionType;
  54851. $types = $type->getTypes();
  54852. break;
  54853. default:
  54854. throw new \LogicException('Unexpected return value of ReflectionParameter::getType');
  54855. }
  54856. if (empty($types)) {
  54857. return true;
  54858. }
  54859. foreach ($types as $type) {
  54860. if ($type instanceof \ReflectionIntersectionType) {
  54861. foreach ($type->getTypes() as $typeToMatch) {
  54862. assert($typeToMatch instanceof \ReflectionNamedType);
  54863. $name = $typeToMatch->getName();
  54864. if (!($matches = (!$typeToMatch->isBuiltin() && $reason instanceof $name))) {
  54865. break;
  54866. }
  54867. }
  54868. assert(isset($matches));
  54869. } else {
  54870. assert($type instanceof \ReflectionNamedType);
  54871. $name = $type->getName();
  54872. $matches = !$type->isBuiltin() && $reason instanceof $name;
  54873. }
  54874. if ($matches) {
  54875. if ($isTypeUnion) {
  54876. return true;
  54877. }
  54878. } else {
  54879. if (!$isTypeUnion) {
  54880. return false;
  54881. }
  54882. }
  54883. }
  54884. return $isTypeUnion ? false : true;
  54885. }
  54886. <?php
  54887. if (!\function_exists('React\Promise\resolve')) {
  54888. require __DIR__.'/functions.php';
  54889. }
  54890. Copyright (c) 2011 Jordi Boggiano
  54891. Permission is hereby granted, free of charge, to any person obtaining a copy
  54892. of this software and associated documentation files (the "Software"), to deal
  54893. in the Software without restriction, including without limitation the rights
  54894. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  54895. copies of the Software, and to permit persons to whom the Software is furnished
  54896. to do so, subject to the following conditions:
  54897. The above copyright notice and this permission notice shall be included in all
  54898. copies or substantial portions of the Software.
  54899. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  54900. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  54901. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  54902. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  54903. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  54904. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  54905. THE SOFTWARE.
  54906. <?php
  54907. namespace Seld\JsonLint;
  54908. class DuplicateKeyException extends ParsingException
  54909. {
  54910. protected $details;
  54911. public function __construct($message, $key, array $details)
  54912. {
  54913. $details['key'] = $key;
  54914. parent::__construct($message, $details);
  54915. }
  54916. public function getKey()
  54917. {
  54918. return $this->details['key'];
  54919. }
  54920. public function getDetails()
  54921. {
  54922. return $this->details;
  54923. }
  54924. }
  54925. <?php
  54926. namespace Seld\JsonLint;
  54927. use stdClass;
  54928. class JsonParser
  54929. {
  54930. const DETECT_KEY_CONFLICTS = 1;
  54931. const ALLOW_DUPLICATE_KEYS = 2;
  54932. const PARSE_TO_ASSOC = 4;
  54933. const ALLOW_COMMENTS = 8;
  54934. private $lexer;
  54935. private $flags;
  54936. private $stack;
  54937. private $vstack;
  54938. private $lstack;
  54939. private $symbols = array(
  54940. 'error' => 2,
  54941. 'JSONString' => 3,
  54942. 'STRING' => 4,
  54943. 'JSONNumber' => 5,
  54944. 'NUMBER' => 6,
  54945. 'JSONNullLiteral' => 7,
  54946. 'NULL' => 8,
  54947. 'JSONBooleanLiteral' => 9,
  54948. 'TRUE' => 10,
  54949. 'FALSE' => 11,
  54950. 'JSONText' => 12,
  54951. 'JSONValue' => 13,
  54952. 'EOF' => 14,
  54953. 'JSONObject' => 15,
  54954. 'JSONArray' => 16,
  54955. '{' => 17,
  54956. '}' => 18,
  54957. 'JSONMemberList' => 19,
  54958. 'JSONMember' => 20,
  54959. ':' => 21,
  54960. ',' => 22,
  54961. '[' => 23,
  54962. ']' => 24,
  54963. 'JSONElementList' => 25,
  54964. '$accept' => 0,
  54965. '$end' => 1,
  54966. );
  54967. private $terminals_ = array(
  54968. 2 => "error",
  54969. 4 => "STRING",
  54970. 6 => "NUMBER",
  54971. 8 => "NULL",
  54972. 10 => "TRUE",
  54973. 11 => "FALSE",
  54974. 14 => "EOF",
  54975. 17 => "{",
  54976. 18 => "}",
  54977. 21 => ":",
  54978. 22 => ",",
  54979. 23 => "[",
  54980. 24 => "]",
  54981. );
  54982. private $productions_ = array(
  54983. 1 => array(3, 1),
  54984. 2 => array(5, 1),
  54985. 3 => array(7, 1),
  54986. 4 => array(9, 1),
  54987. 5 => array(9, 1),
  54988. 6 => array(12, 2),
  54989. 7 => array(13, 1),
  54990. 8 => array(13, 1),
  54991. 9 => array(13, 1),
  54992. 10 => array(13, 1),
  54993. 11 => array(13, 1),
  54994. 12 => array(13, 1),
  54995. 13 => array(15, 2),
  54996. 14 => array(15, 3),
  54997. 15 => array(20, 3),
  54998. 16 => array(19, 1),
  54999. 17 => array(19, 3),
  55000. 18 => array(16, 2),
  55001. 19 => array(16, 3),
  55002. 20 => array(25, 1),
  55003. 21 => array(25, 3)
  55004. );
  55005. private $table = array(
  55006. 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)),
  55007. 1 => array( 1 => array(3)),
  55008. 2 => array( 14 => array(1,16)),
  55009. 3 => array( 14 => array(2,7), 18 => array(2,7), 22 => array(2,7), 24 => array(2,7)),
  55010. 4 => array( 14 => array(2,8), 18 => array(2,8), 22 => array(2,8), 24 => array(2,8)),
  55011. 5 => array( 14 => array(2,9), 18 => array(2,9), 22 => array(2,9), 24 => array(2,9)),
  55012. 6 => array( 14 => array(2,10), 18 => array(2,10), 22 => array(2,10), 24 => array(2,10)),
  55013. 7 => array( 14 => array(2,11), 18 => array(2,11), 22 => array(2,11), 24 => array(2,11)),
  55014. 8 => array( 14 => array(2,12), 18 => array(2,12), 22 => array(2,12), 24 => array(2,12)),
  55015. 9 => array( 14 => array(2,3), 18 => array(2,3), 22 => array(2,3), 24 => array(2,3)),
  55016. 10 => array( 14 => array(2,4), 18 => array(2,4), 22 => array(2,4), 24 => array(2,4)),
  55017. 11 => array( 14 => array(2,5), 18 => array(2,5), 22 => array(2,5), 24 => array(2,5)),
  55018. 12 => array( 14 => array(2,1), 18 => array(2,1), 21 => array(2,1), 22 => array(2,1), 24 => array(2,1)),
  55019. 13 => array( 14 => array(2,2), 18 => array(2,2), 22 => array(2,2), 24 => array(2,2)),
  55020. 14 => array( 3 => 20, 4 => array(1,12), 18 => array(1,17), 19 => 18, 20 => 19 ),
  55021. 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 ),
  55022. 16 => array( 1 => array(2,6)),
  55023. 17 => array( 14 => array(2,13), 18 => array(2,13), 22 => array(2,13), 24 => array(2,13)),
  55024. 18 => array( 18 => array(1,24), 22 => array(1,25)),
  55025. 19 => array( 18 => array(2,16), 22 => array(2,16)),
  55026. 20 => array( 21 => array(1,26)),
  55027. 21 => array( 14 => array(2,18), 18 => array(2,18), 22 => array(2,18), 24 => array(2,18)),
  55028. 22 => array( 22 => array(1,28), 24 => array(1,27)),
  55029. 23 => array( 22 => array(2,20), 24 => array(2,20)),
  55030. 24 => array( 14 => array(2,14), 18 => array(2,14), 22 => array(2,14), 24 => array(2,14)),
  55031. 25 => array( 3 => 20, 4 => array(1,12), 20 => 29 ),
  55032. 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)),
  55033. 27 => array( 14 => array(2,19), 18 => array(2,19), 22 => array(2,19), 24 => array(2,19)),
  55034. 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)),
  55035. 29 => array( 18 => array(2,17), 22 => array(2,17)),
  55036. 30 => array( 18 => array(2,15), 22 => array(2,15)),
  55037. 31 => array( 22 => array(2,21), 24 => array(2,21)),
  55038. );
  55039. private $defaultActions = array(
  55040. 16 => array(2, 6)
  55041. );
  55042. public function lint($input, $flags = 0)
  55043. {
  55044. try {
  55045. $this->parse($input, $flags);
  55046. } catch (ParsingException $e) {
  55047. return $e;
  55048. }
  55049. return null;
  55050. }
  55051. public function parse($input, $flags = 0)
  55052. {
  55053. $this->failOnBOM($input);
  55054. $this->flags = $flags;
  55055. $this->stack = array(0);
  55056. $this->vstack = array(null);
  55057. $this->lstack = array();
  55058. $yytext = '';
  55059. $yylineno = 0;
  55060. $yyleng = 0;
  55061. $recovering = 0;
  55062. $this->lexer = new Lexer($flags);
  55063. $this->lexer->setInput($input);
  55064. $yyloc = $this->lexer->yylloc;
  55065. $this->lstack[] = $yyloc;
  55066. $symbol = null;
  55067. $preErrorSymbol = null;
  55068. $action = null;
  55069. $a = null;
  55070. $r = null;
  55071. $p = null;
  55072. $len = null;
  55073. $newState = null;
  55074. $expected = null;
  55075. $errStr = null;
  55076. while (true) {
  55077. $state = $this->stack[\count($this->stack)-1];
  55078. if (isset($this->defaultActions[$state])) {
  55079. $action = $this->defaultActions[$state];
  55080. } else {
  55081. if ($symbol === null) {
  55082. $symbol = $this->lexer->lex();
  55083. }
  55084. $action = isset($this->table[$state][$symbol]) ? $this->table[$state][$symbol] : false;
  55085. }
  55086. if (!$action || !$action[0]) {
  55087. assert(isset($symbol));
  55088. if (!$recovering) {
  55089. $expected = array();
  55090. foreach ($this->table[$state] as $p => $ignore) {
  55091. if (isset($this->terminals_[$p]) && $p > 2) {
  55092. $expected[] = "'" . $this->terminals_[$p] . "'";
  55093. }
  55094. }
  55095. $message = null;
  55096. if (\in_array("'STRING'", $expected) && \in_array(substr($this->lexer->match, 0, 1), array('"', "'"))) {
  55097. $message = "Invalid string";
  55098. if ("'" === substr($this->lexer->match, 0, 1)) {
  55099. $message .= ", it appears you used single quotes instead of double quotes";
  55100. } elseif (preg_match('{".+?(\\\\[^"bfnrt/\\\\u](...)?)}', $this->lexer->getFullUpcomingInput(), $match)) {
  55101. $message .= ", it appears you have an unescaped backslash at: ".$match[1];
  55102. } elseif (preg_match('{"(?:[^"]+|\\\\")*$}m', $this->lexer->getFullUpcomingInput())) {
  55103. $message .= ", it appears you forgot to terminate a string, or attempted to write a multiline string which is invalid";
  55104. }
  55105. }
  55106. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  55107. $errStr .= $this->lexer->showPosition() . "\n";
  55108. if ($message) {
  55109. $errStr .= $message;
  55110. } else {
  55111. $errStr .= (\count($expected) > 1) ? "Expected one of: " : "Expected: ";
  55112. $errStr .= implode(', ', $expected);
  55113. }
  55114. if (',' === substr(trim($this->lexer->getPastInput()), -1)) {
  55115. $errStr .= " - It appears you have an extra trailing comma";
  55116. }
  55117. $this->parseError($errStr, array(
  55118. 'text' => $this->lexer->match,
  55119. 'token' => isset($this->terminals_[$symbol]) ? $this->terminals_[$symbol] : $symbol,
  55120. 'line' => $this->lexer->yylineno,
  55121. 'loc' => $yyloc,
  55122. 'expected' => $expected,
  55123. ));
  55124. }
  55125. if ($recovering == 3) {
  55126. if ($symbol === Lexer::EOF) {
  55127. throw new ParsingException($errStr ?: 'Parsing halted.');
  55128. }
  55129. $yyleng = $this->lexer->yyleng;
  55130. $yytext = $this->lexer->yytext;
  55131. $yylineno = $this->lexer->yylineno;
  55132. $yyloc = $this->lexer->yylloc;
  55133. $symbol = $this->lexer->lex();
  55134. }
  55135. while (true) {
  55136. if (\array_key_exists(Lexer::T_ERROR, $this->table[$state])) {
  55137. break;
  55138. }
  55139. if ($state == 0) {
  55140. throw new ParsingException($errStr ?: 'Parsing halted.');
  55141. }
  55142. $this->popStack(1);
  55143. $state = $this->stack[\count($this->stack)-1];
  55144. }
  55145. $preErrorSymbol = $symbol;
  55146. $symbol = Lexer::T_ERROR;
  55147. $state = $this->stack[\count($this->stack)-1];
  55148. $action = isset($this->table[$state][Lexer::T_ERROR]) ? $this->table[$state][Lexer::T_ERROR] : false;
  55149. if ($action === false) {
  55150. throw new \LogicException('No table value found for '.$state.' => '.Lexer::T_ERROR);
  55151. }
  55152. $recovering = 3;
  55153. }
  55154. if (\is_array($action[0]) && \count($action) > 1) {
  55155. throw new ParsingException('Parse Error: multiple actions possible at state: ' . $state . ', token: ' . $symbol);
  55156. }
  55157. switch ($action[0]) {
  55158. case 1:
  55159. assert(isset($symbol));
  55160. $this->stack[] = $symbol;
  55161. $this->vstack[] = $this->lexer->yytext;
  55162. $this->lstack[] = $this->lexer->yylloc;
  55163. $this->stack[] = $action[1];
  55164. $symbol = null;
  55165. if (!$preErrorSymbol) {
  55166. $yyleng = $this->lexer->yyleng;
  55167. $yytext = $this->lexer->yytext;
  55168. $yylineno = $this->lexer->yylineno;
  55169. $yyloc = $this->lexer->yylloc;
  55170. if ($recovering > 0) {
  55171. $recovering--;
  55172. }
  55173. } else {
  55174. $symbol = $preErrorSymbol;
  55175. $preErrorSymbol = null;
  55176. }
  55177. break;
  55178. case 2:
  55179. $len = $this->productions_[$action[1]][1];
  55180. $currentToken = $this->vstack[\count($this->vstack) - $len];
  55181. $position = array(
  55182. 'first_line' => $this->lstack[\count($this->lstack) - ($len ?: 1)]['first_line'],
  55183. 'last_line' => $this->lstack[\count($this->lstack) - 1]['last_line'],
  55184. 'first_column' => $this->lstack[\count($this->lstack) - ($len ?: 1)]['first_column'],
  55185. 'last_column' => $this->lstack[\count($this->lstack) - 1]['last_column'],
  55186. );
  55187. list($newToken, $actionResult) = $this->performAction($currentToken, $yytext, $yyleng, $yylineno, $action[1]);
  55188. if (!$actionResult instanceof Undefined) {
  55189. return $actionResult;
  55190. }
  55191. if ($len) {
  55192. $this->popStack($len);
  55193. }
  55194. $this->stack[] = $this->productions_[$action[1]][0];
  55195. $this->vstack[] = $newToken;
  55196. $this->lstack[] = $position;
  55197. $newState = $this->table[$this->stack[\count($this->stack)-2]][$this->stack[\count($this->stack)-1]];
  55198. $this->stack[] = $newState;
  55199. break;
  55200. case 3:
  55201. return true;
  55202. }
  55203. }
  55204. }
  55205. protected function parseError($str, $hash = null)
  55206. {
  55207. throw new ParsingException($str, $hash ?: array());
  55208. }
  55209. private function performAction($currentToken, $yytext, $yyleng, $yylineno, $yystate)
  55210. {
  55211. $token = $currentToken;
  55212. $len = \count($this->vstack) - 1;
  55213. switch ($yystate) {
  55214. case 1:
  55215. $yytext = preg_replace_callback('{(?:\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4})}', array($this, 'stringInterpolation'), $yytext);
  55216. $token = $yytext;
  55217. break;
  55218. case 2:
  55219. if (strpos($yytext, 'e') !== false || strpos($yytext, 'E') !== false) {
  55220. $token = \floatval($yytext);
  55221. } else {
  55222. $token = strpos($yytext, '.') === false ? \intval($yytext) : \floatval($yytext);
  55223. }
  55224. break;
  55225. case 3:
  55226. $token = null;
  55227. break;
  55228. case 4:
  55229. $token = true;
  55230. break;
  55231. case 5:
  55232. $token = false;
  55233. break;
  55234. case 6:
  55235. $token = $this->vstack[$len-1];
  55236. return array($token, $token);
  55237. case 13:
  55238. if ($this->flags & self::PARSE_TO_ASSOC) {
  55239. $token = array();
  55240. } else {
  55241. $token = new stdClass;
  55242. }
  55243. break;
  55244. case 14:
  55245. $token = $this->vstack[$len-1];
  55246. break;
  55247. case 15:
  55248. $token = array($this->vstack[$len-2], $this->vstack[$len]);
  55249. break;
  55250. case 16:
  55251. assert(\is_array($this->vstack[$len]));
  55252. if (PHP_VERSION_ID < 70100) {
  55253. $property = $this->vstack[$len][0] === '' ? '_empty_' : $this->vstack[$len][0];
  55254. } else {
  55255. $property = $this->vstack[$len][0];
  55256. }
  55257. if ($this->flags & self::PARSE_TO_ASSOC) {
  55258. $token = array();
  55259. $token[$property] = $this->vstack[$len][1];
  55260. } else {
  55261. $token = new stdClass;
  55262. $token->$property = $this->vstack[$len][1];
  55263. }
  55264. break;
  55265. case 17:
  55266. assert(\is_array($this->vstack[$len]));
  55267. if ($this->flags & self::PARSE_TO_ASSOC) {
  55268. assert(\is_array($this->vstack[$len-2]));
  55269. $token =& $this->vstack[$len-2];
  55270. $key = $this->vstack[$len][0];
  55271. if (($this->flags & self::DETECT_KEY_CONFLICTS) && isset($this->vstack[$len-2][$key])) {
  55272. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  55273. $errStr .= $this->lexer->showPosition() . "\n";
  55274. $errStr .= "Duplicate key: ".$this->vstack[$len][0];
  55275. throw new DuplicateKeyException($errStr, $this->vstack[$len][0], array('line' => $yylineno+1));
  55276. } elseif (($this->flags & self::ALLOW_DUPLICATE_KEYS) && isset($this->vstack[$len-2][$key])) {
  55277. $duplicateCount = 1;
  55278. do {
  55279. $duplicateKey = $key . '.' . $duplicateCount++;
  55280. } while (isset($this->vstack[$len-2][$duplicateKey]));
  55281. $key = $duplicateKey;
  55282. }
  55283. $this->vstack[$len-2][$key] = $this->vstack[$len][1];
  55284. } else {
  55285. assert($this->vstack[$len-2] instanceof stdClass);
  55286. $token = $this->vstack[$len-2];
  55287. if (PHP_VERSION_ID < 70100) {
  55288. $key = $this->vstack[$len][0] === '' ? '_empty_' : $this->vstack[$len][0];
  55289. } else {
  55290. $key = $this->vstack[$len][0];
  55291. }
  55292. if (($this->flags & self::DETECT_KEY_CONFLICTS) && isset($this->vstack[$len-2]->{$key})) {
  55293. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  55294. $errStr .= $this->lexer->showPosition() . "\n";
  55295. $errStr .= "Duplicate key: ".$this->vstack[$len][0];
  55296. throw new DuplicateKeyException($errStr, $this->vstack[$len][0], array('line' => $yylineno+1));
  55297. } elseif (($this->flags & self::ALLOW_DUPLICATE_KEYS) && isset($this->vstack[$len-2]->{$key})) {
  55298. $duplicateCount = 1;
  55299. do {
  55300. $duplicateKey = $key . '.' . $duplicateCount++;
  55301. } while (isset($this->vstack[$len-2]->$duplicateKey));
  55302. $key = $duplicateKey;
  55303. }
  55304. $this->vstack[$len-2]->$key = $this->vstack[$len][1];
  55305. }
  55306. break;
  55307. case 18:
  55308. $token = array();
  55309. break;
  55310. case 19:
  55311. $token = $this->vstack[$len-1];
  55312. break;
  55313. case 20:
  55314. $token = array($this->vstack[$len]);
  55315. break;
  55316. case 21:
  55317. assert(\is_array($this->vstack[$len-2]));
  55318. $this->vstack[$len-2][] = $this->vstack[$len];
  55319. $token = $this->vstack[$len-2];
  55320. break;
  55321. }
  55322. return array($token, new Undefined());
  55323. }
  55324. private function stringInterpolation($match)
  55325. {
  55326. switch ($match[0]) {
  55327. case '\\\\':
  55328. return '\\';
  55329. case '\"':
  55330. return '"';
  55331. case '\b':
  55332. return \chr(8);
  55333. case '\f':
  55334. return \chr(12);
  55335. case '\n':
  55336. return "\n";
  55337. case '\r':
  55338. return "\r";
  55339. case '\t':
  55340. return "\t";
  55341. case '\/':
  55342. return "/";
  55343. default:
  55344. return html_entity_decode('&#x'.ltrim(substr($match[0], 2), '0').';', ENT_QUOTES, 'UTF-8');
  55345. }
  55346. }
  55347. private function popStack($n)
  55348. {
  55349. $this->stack = \array_slice($this->stack, 0, - (2 * $n));
  55350. $this->vstack = \array_slice($this->vstack, 0, - $n);
  55351. $this->lstack = \array_slice($this->lstack, 0, - $n);
  55352. }
  55353. private function failOnBOM($input)
  55354. {
  55355. $bom = "\xEF\xBB\xBF";
  55356. if (substr($input, 0, 3) === $bom) {
  55357. $this->parseError("BOM detected, make sure your input does not include a Unicode Byte-Order-Mark");
  55358. }
  55359. }
  55360. }
  55361. <?php
  55362. namespace Seld\JsonLint;
  55363. class Lexer
  55364. {
  55365. const EOF = 1;
  55366. const T_INVALID = -1;
  55367. const T_SKIP_WHITESPACE = 0;
  55368. const T_ERROR = 2;
  55369. const T_BREAK_LINE = 3;
  55370. const T_COMMENT = 30;
  55371. const T_OPEN_COMMENT = 31;
  55372. const T_CLOSE_COMMENT = 32;
  55373. private $rules = array(
  55374. 0 => '/\G\s*\n\r?/',
  55375. 1 => '/\G\s+/',
  55376. 2 => '/\G-?([0-9]|[1-9][0-9]+)(\.[0-9]+)?([eE][+-]?[0-9]+)?\b/',
  55377. 3 => '{\G"(?>\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^\0-\x1f\\\\"]++)*+"}',
  55378. 4 => '/\G\{/',
  55379. 5 => '/\G\}/',
  55380. 6 => '/\G\[/',
  55381. 7 => '/\G\]/',
  55382. 8 => '/\G,/',
  55383. 9 => '/\G:/',
  55384. 10 => '/\Gtrue\b/',
  55385. 11 => '/\Gfalse\b/',
  55386. 12 => '/\Gnull\b/',
  55387. 13 => '/\G$/',
  55388. 14 => '/\G\/\//',
  55389. 15 => '/\G\/\*/',
  55390. 16 => '/\G\*\//',
  55391. 17 => '/\G./',
  55392. );
  55393. private $input;
  55394. private $more;
  55395. private $done;
  55396. private $offset;
  55397. private $flags;
  55398. public $match;
  55399. public $yylineno;
  55400. public $yyleng;
  55401. public $yytext;
  55402. public $yylloc;
  55403. public function __construct($flags = 0)
  55404. {
  55405. $this->flags = $flags;
  55406. }
  55407. public function lex()
  55408. {
  55409. while (true) {
  55410. $symbol = $this->next();
  55411. switch ($symbol) {
  55412. case self::T_SKIP_WHITESPACE:
  55413. case self::T_BREAK_LINE:
  55414. break;
  55415. case self::T_COMMENT:
  55416. case self::T_OPEN_COMMENT:
  55417. if (!($this->flags & JsonParser::ALLOW_COMMENTS)) {
  55418. $this->parseError('Lexical error on line ' . ($this->yylineno+1) . ". Comments are not allowed.\n" . $this->showPosition());
  55419. }
  55420. $this->skipUntil($symbol === self::T_COMMENT ? self::T_BREAK_LINE : self::T_CLOSE_COMMENT);
  55421. if ($this->done) {
  55422. return 14;
  55423. }
  55424. break;
  55425. case self::T_CLOSE_COMMENT:
  55426. $this->parseError('Lexical error on line ' . ($this->yylineno+1) . ". Unexpected token.\n" . $this->showPosition());
  55427. default:
  55428. return $symbol;
  55429. }
  55430. }
  55431. }
  55432. public function setInput($input)
  55433. {
  55434. $this->input = $input;
  55435. $this->more = false;
  55436. $this->done = false;
  55437. $this->offset = 0;
  55438. $this->yylineno = $this->yyleng = 0;
  55439. $this->yytext = $this->match = '';
  55440. $this->yylloc = array('first_line' => 1, 'first_column' => 0, 'last_line' => 1, 'last_column' => 0);
  55441. return $this;
  55442. }
  55443. public function showPosition()
  55444. {
  55445. $pre = str_replace("\n", '', $this->getPastInput());
  55446. $c = str_repeat('-', max(0, \strlen($pre) - 1));
  55447. return $pre . str_replace("\n", '', $this->getUpcomingInput()) . "\n" . $c . "^";
  55448. }
  55449. public function getPastInput()
  55450. {
  55451. $pastLength = $this->offset - \strlen($this->match);
  55452. return ($pastLength > 20 ? '...' : '') . substr($this->input, max(0, $pastLength - 20), min(20, $pastLength));
  55453. }
  55454. public function getUpcomingInput()
  55455. {
  55456. $next = $this->match;
  55457. if (\strlen($next) < 20) {
  55458. $next .= substr($this->input, $this->offset, 20 - \strlen($next));
  55459. }
  55460. return substr($next, 0, 20) . (\strlen($next) > 20 ? '...' : '');
  55461. }
  55462. public function getFullUpcomingInput()
  55463. {
  55464. $next = $this->match;
  55465. if (substr($next, 0, 1) === '"' && substr_count($next, '"') === 1) {
  55466. $len = \strlen($this->input);
  55467. if ($len === $this->offset) {
  55468. $strEnd = $len;
  55469. } else {
  55470. $strEnd = min(strpos($this->input, '"', $this->offset + 1) ?: $len, strpos($this->input, "\n", $this->offset + 1) ?: $len);
  55471. }
  55472. $next .= substr($this->input, $this->offset, $strEnd - $this->offset);
  55473. } elseif (\strlen($next) < 20) {
  55474. $next .= substr($this->input, $this->offset, 20 - \strlen($next));
  55475. }
  55476. return $next;
  55477. }
  55478. protected function parseError($str)
  55479. {
  55480. throw new ParsingException($str);
  55481. }
  55482. private function skipUntil($token)
  55483. {
  55484. $symbol = $this->next();
  55485. while ($symbol !== $token && false === $this->done) {
  55486. $symbol = $this->next();
  55487. }
  55488. }
  55489. private function next()
  55490. {
  55491. if ($this->done) {
  55492. return self::EOF;
  55493. }
  55494. if ($this->offset === \strlen($this->input)) {
  55495. $this->done = true;
  55496. }
  55497. $token = null;
  55498. $match = null;
  55499. $col = null;
  55500. $lines = null;
  55501. if (!$this->more) {
  55502. $this->yytext = '';
  55503. $this->match = '';
  55504. }
  55505. $rulesLen = count($this->rules);
  55506. for ($i=0; $i < $rulesLen; $i++) {
  55507. if (preg_match($this->rules[$i], $this->input, $match, 0, $this->offset)) {
  55508. $lines = explode("\n", $match[0]);
  55509. array_shift($lines);
  55510. $lineCount = \count($lines);
  55511. $this->yylineno += $lineCount;
  55512. $this->yylloc = array(
  55513. 'first_line' => $this->yylloc['last_line'],
  55514. 'last_line' => $this->yylineno+1,
  55515. 'first_column' => $this->yylloc['last_column'],
  55516. 'last_column' => $lineCount > 0 ? \strlen($lines[$lineCount - 1]) : $this->yylloc['last_column'] + \strlen($match[0]),
  55517. );
  55518. $this->yytext .= $match[0];
  55519. $this->match .= $match[0];
  55520. $this->yyleng = \strlen($this->yytext);
  55521. $this->more = false;
  55522. $this->offset += \strlen($match[0]);
  55523. return $this->performAction($i);
  55524. }
  55525. }
  55526. if ($this->offset === \strlen($this->input)) {
  55527. return self::EOF;
  55528. }
  55529. $this->parseError(
  55530. 'Lexical error on line ' . ($this->yylineno+1) . ". Unrecognized text.\n" . $this->showPosition()
  55531. );
  55532. }
  55533. private function performAction($rule)
  55534. {
  55535. switch ($rule) {
  55536. case 0:
  55537. return self::T_BREAK_LINE;
  55538. case 1:
  55539. return self::T_SKIP_WHITESPACE;
  55540. case 2:
  55541. return 6;
  55542. case 3:
  55543. $this->yytext = substr($this->yytext, 1, $this->yyleng-2);
  55544. return 4;
  55545. case 4:
  55546. return 17;
  55547. case 5:
  55548. return 18;
  55549. case 6:
  55550. return 23;
  55551. case 7:
  55552. return 24;
  55553. case 8:
  55554. return 22;
  55555. case 9:
  55556. return 21;
  55557. case 10:
  55558. return 10;
  55559. case 11:
  55560. return 11;
  55561. case 12:
  55562. return 8;
  55563. case 13:
  55564. return 14;
  55565. case 14:
  55566. return self::T_COMMENT;
  55567. case 15:
  55568. return self::T_OPEN_COMMENT;
  55569. case 16:
  55570. return self::T_CLOSE_COMMENT;
  55571. case 17:
  55572. return self::T_INVALID;
  55573. default:
  55574. throw new \LogicException('Unsupported rule '.$rule);
  55575. }
  55576. }
  55577. }
  55578. <?php
  55579. namespace Seld\JsonLint;
  55580. class ParsingException extends \Exception
  55581. {
  55582. protected $details;
  55583. public function __construct($message, $details = array())
  55584. {
  55585. $this->details = $details;
  55586. parent::__construct($message);
  55587. }
  55588. public function getDetails()
  55589. {
  55590. return $this->details;
  55591. }
  55592. }
  55593. <?php
  55594. namespace Seld\JsonLint;
  55595. class Undefined
  55596. {
  55597. }
  55598. Copyright (c) 2015 Jordi Boggiano
  55599. Permission is hereby granted, free of charge, to any person obtaining a copy
  55600. of this software and associated documentation files (the "Software"), to deal
  55601. in the Software without restriction, including without limitation the rights
  55602. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  55603. copies of the Software, and to permit persons to whom the Software is furnished
  55604. to do so, subject to the following conditions:
  55605. The above copyright notice and this permission notice shall be included in all
  55606. copies or substantial portions of the Software.
  55607. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  55608. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  55609. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  55610. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  55611. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  55612. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  55613. THE SOFTWARE.
  55614. <?php
  55615. namespace Seld\PharUtils;
  55616. class Linter
  55617. {
  55618. public static function lint($path, array $excludedPaths = array())
  55619. {
  55620. $php = defined('PHP_BINARY') ? PHP_BINARY : 'php';
  55621. if ($isWindows = defined('PHP_WINDOWS_VERSION_BUILD')) {
  55622. $tmpFile = @tempnam(sys_get_temp_dir(), '');
  55623. if (!$tmpFile || !is_writable($tmpFile)) {
  55624. throw new \RuntimeException('Unable to create temp file');
  55625. }
  55626. $php = self::escapeWindowsPath($php);
  55627. $tmpFile = self::escapeWindowsPath($tmpFile);
  55628. if (PHP_VERSION_ID >= 80000) {
  55629. $format = '%s -l %s';
  55630. } else {
  55631. $format = '"%s -l %s"';
  55632. }
  55633. $command = sprintf($format, $php, $tmpFile);
  55634. } else {
  55635. $command = "'".$php."' -l";
  55636. }
  55637. $descriptorspec = array(
  55638. 0 => array('pipe', 'r'),
  55639. 1 => array('pipe', 'w'),
  55640. 2 => array('pipe', 'w')
  55641. );
  55642. $baseLen = strlen(realpath($path)) + 7 + 1;
  55643. foreach (new \RecursiveIteratorIterator(new \Phar($path)) as $file) {
  55644. if ($file->isDir()) {
  55645. continue;
  55646. }
  55647. if (substr($file, -4) === '.php') {
  55648. $filename = (string) $file;
  55649. if (in_array(substr($filename, $baseLen), $excludedPaths, true)) {
  55650. continue;
  55651. }
  55652. if ($isWindows) {
  55653. file_put_contents($tmpFile, file_get_contents($filename));
  55654. }
  55655. $process = proc_open($command, $descriptorspec, $pipes);
  55656. if (is_resource($process)) {
  55657. if (!$isWindows) {
  55658. fwrite($pipes[0], file_get_contents($filename));
  55659. }
  55660. fclose($pipes[0]);
  55661. $stdout = stream_get_contents($pipes[1]);
  55662. fclose($pipes[1]);
  55663. $stderr = stream_get_contents($pipes[2]);
  55664. fclose($pipes[2]);
  55665. $exitCode = proc_close($process);
  55666. if ($exitCode !== 0) {
  55667. if ($isWindows) {
  55668. $stderr = str_replace($tmpFile, $filename, $stderr);
  55669. }
  55670. throw new \UnexpectedValueException('Failed linting '.$file.': '.$stderr);
  55671. }
  55672. } else {
  55673. throw new \RuntimeException('Could not start linter process');
  55674. }
  55675. }
  55676. }
  55677. if ($isWindows) {
  55678. @unlink($tmpFile);
  55679. }
  55680. }
  55681. private static function escapeWindowsPath($path)
  55682. {
  55683. if (strpbrk($path, " ()") !== false) {
  55684. $path = '"'.$path.'"';
  55685. }
  55686. return $path;
  55687. }
  55688. }
  55689. <?php
  55690. namespace Seld\PharUtils;
  55691. class Timestamps
  55692. {
  55693. private $contents;
  55694. public function __construct($file)
  55695. {
  55696. $this->contents = file_get_contents($file);
  55697. }
  55698. public function updateTimestamps($timestamp = null)
  55699. {
  55700. if ($timestamp instanceof \DateTime || $timestamp instanceof \DateTimeInterface) {
  55701. $timestamp = $timestamp->getTimestamp();
  55702. } elseif (is_string($timestamp)) {
  55703. $timestamp = strtotime($timestamp);
  55704. } elseif (!is_int($timestamp)) {
  55705. $timestamp = strtotime('1984-12-24T00:00:00Z');
  55706. }
  55707. if (!preg_match('{__HALT_COMPILER\(\);(?: +\?>)?\r?\n}', $this->contents, $match, PREG_OFFSET_CAPTURE)) {
  55708. throw new \RuntimeException('Could not detect the stub\'s end in the phar');
  55709. }
  55710. $pos = $match[0][1] + strlen($match[0][0]);
  55711. $stubEnd = $pos + $this->readUint($pos, 4);
  55712. $pos += 4;
  55713. $numFiles = $this->readUint($pos, 4);
  55714. $pos += 4;
  55715. $pos += 2;
  55716. $pos += 4;
  55717. $aliasLength = $this->readUint($pos, 4);
  55718. $pos += 4 + $aliasLength;
  55719. $metadataLength = $this->readUint($pos, 4);
  55720. $pos += 4 + $metadataLength;
  55721. while ($pos < $stubEnd) {
  55722. $filenameLength = $this->readUint($pos, 4);
  55723. $pos += 4 + $filenameLength;
  55724. $pos += 4;
  55725. $timeStampBytes = pack('L', $timestamp);
  55726. $this->contents[$pos + 0] = $timeStampBytes[0];
  55727. $this->contents[$pos + 1] = $timeStampBytes[1];
  55728. $this->contents[$pos + 2] = $timeStampBytes[2];
  55729. $this->contents[$pos + 3] = $timeStampBytes[3];
  55730. $pos += 4*4;
  55731. $metadataLength = $this->readUint($pos, 4);
  55732. $pos += 4 + $metadataLength;
  55733. $numFiles--;
  55734. }
  55735. if ($numFiles !== 0) {
  55736. throw new \LogicException('All files were not processed, something must have gone wrong');
  55737. }
  55738. }
  55739. public function save($path, $signatureAlgo)
  55740. {
  55741. $pos = $this->determineSignatureBegin();
  55742. $algos = array(
  55743. \Phar::MD5 => 'md5',
  55744. \Phar::SHA1 => 'sha1',
  55745. \Phar::SHA256 => 'sha256',
  55746. \Phar::SHA512 => 'sha512',
  55747. );
  55748. if (!isset($algos[$signatureAlgo])) {
  55749. throw new \UnexpectedValueException('Invalid hash algorithm given: '.$signatureAlgo.' expected one of Phar::MD5, Phar::SHA1, Phar::SHA256 or Phar::SHA512');
  55750. }
  55751. $algo = $algos[$signatureAlgo];
  55752. $signature = hash($algo, substr($this->contents, 0, $pos), true)
  55753. . pack('L', $signatureAlgo)
  55754. . 'GBMB';
  55755. $this->contents = substr($this->contents, 0, $pos) . $signature;
  55756. return file_put_contents($path, $this->contents);
  55757. }
  55758. private function readUint($pos, $bytes)
  55759. {
  55760. $res = unpack('V', substr($this->contents, $pos, $bytes));
  55761. return $res[1];
  55762. }
  55763. private function determineSignatureBegin()
  55764. {
  55765. if (!preg_match('{__HALT_COMPILER\(\);(?: +\?>)?\r?\n}', $this->contents, $match, PREG_OFFSET_CAPTURE)) {
  55766. throw new \RuntimeException('Could not detect the stub\'s end in the phar');
  55767. }
  55768. $pos = $match[0][1] + strlen($match[0][0]);
  55769. $manifestEnd = $pos + 4 + $this->readUint($pos, 4);
  55770. $pos += 4;
  55771. $numFiles = $this->readUint($pos, 4);
  55772. $pos += 4;
  55773. $pos += 2;
  55774. $pos += 4;
  55775. $aliasLength = $this->readUint($pos, 4);
  55776. $pos += 4 + $aliasLength;
  55777. $metadataLength = $this->readUint($pos, 4);
  55778. $pos += 4 + $metadataLength;
  55779. $compressedSizes = 0;
  55780. while (($numFiles > 0) && ($pos < $manifestEnd - 24)) {
  55781. $filenameLength = $this->readUint($pos, 4);
  55782. $pos += 4 + $filenameLength;
  55783. $pos += 2*4;
  55784. $compressedSizes += $this->readUint($pos, 4);
  55785. $pos += 3*4;
  55786. $metadataLength = $this->readUint($pos, 4);
  55787. $pos += 4 + $metadataLength;
  55788. $numFiles--;
  55789. }
  55790. if ($numFiles !== 0) {
  55791. throw new \LogicException('All files were not processed, something must have gone wrong');
  55792. }
  55793. return $manifestEnd + $compressedSizes;
  55794. }
  55795. }
  55796. Copyright (c) 2015 Jordi Boggiano
  55797. Permission is hereby granted, free of charge, to any person obtaining a copy
  55798. of this software and associated documentation files (the "Software"), to deal
  55799. in the Software without restriction, including without limitation the rights
  55800. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  55801. copies of the Software, and to permit persons to whom the Software is furnished
  55802. to do so, subject to the following conditions:
  55803. The above copyright notice and this permission notice shall be included in all
  55804. copies or substantial portions of the Software.
  55805. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  55806. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  55807. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  55808. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  55809. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  55810. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  55811. THE SOFTWARE.
  55812. <?php
  55813. namespace Seld\Signal;
  55814. use Psr\Log\LoggerInterface;
  55815. use Closure;
  55816. use WeakReference;
  55817. final class SignalHandler
  55818. {
  55819. public const SIGHUP = 'SIGHUP';
  55820. public const SIGINT = 'SIGINT';
  55821. public const SIGQUIT = 'SIGQUIT';
  55822. public const SIGILL = 'SIGILL';
  55823. public const SIGTRAP = 'SIGTRAP';
  55824. public const SIGABRT = 'SIGABRT';
  55825. public const SIGIOT = 'SIGIOT';
  55826. public const SIGBUS = 'SIGBUS';
  55827. public const SIGFPE = 'SIGFPE';
  55828. public const SIGKILL = 'SIGKILL';
  55829. public const SIGUSR1 = 'SIGUSR1';
  55830. public const SIGUSR2 = 'SIGUSR2';
  55831. public const SIGSEGV = 'SIGSEGV';
  55832. public const SIGPIPE = 'SIGPIPE';
  55833. public const SIGALRM = 'SIGALRM';
  55834. public const SIGTERM = 'SIGTERM';
  55835. public const SIGSTKFLT = 'SIGSTKFLT';
  55836. public const SIGCLD = 'SIGCLD';
  55837. public const SIGCHLD = 'SIGCHLD';
  55838. public const SIGCONT = 'SIGCONT';
  55839. public const SIGSTOP = 'SIGSTOP';
  55840. public const SIGTSTP = 'SIGTSTP';
  55841. public const SIGTTIN = 'SIGTTIN';
  55842. public const SIGTTOU = 'SIGTTOU';
  55843. public const SIGURG = 'SIGURG';
  55844. public const SIGXCPU = 'SIGXCPU';
  55845. public const SIGXFSZ = 'SIGXFSZ';
  55846. public const SIGVTALRM = 'SIGVTALRM';
  55847. public const SIGPROF = 'SIGPROF';
  55848. public const SIGWINCH = 'SIGWINCH';
  55849. public const SIGPOLL = 'SIGPOLL';
  55850. public const SIGIO = 'SIGIO';
  55851. public const SIGPWR = 'SIGPWR';
  55852. public const SIGSYS = 'SIGSYS';
  55853. public const SIGBABY = 'SIGBABY';
  55854. public const SIGBREAK = 'SIGBREAK';
  55855. private const ALL_SIGNALS = [
  55856. self::SIGHUP, self::SIGINT, self::SIGQUIT, self::SIGILL, self::SIGTRAP, self::SIGABRT, self::SIGIOT, self::SIGBUS,
  55857. self::SIGFPE, self::SIGKILL, self::SIGUSR1, self::SIGUSR2, self::SIGSEGV, self::SIGPIPE, self::SIGALRM, self::SIGTERM,
  55858. self::SIGSTKFLT, self::SIGCLD, self::SIGCHLD, self::SIGCONT, self::SIGSTOP, self::SIGTSTP, self::SIGTTIN, self::SIGTTOU,
  55859. self::SIGURG, self::SIGXCPU, self::SIGXFSZ, self::SIGVTALRM, self::SIGPROF, self::SIGWINCH, self::SIGPOLL, self::SIGIO,
  55860. self::SIGPWR, self::SIGSYS, self::SIGBABY, self::SIGBREAK
  55861. ];
  55862. private $triggered = null;
  55863. private $signals;
  55864. private $loggerOrCallback;
  55865. private static $handlers = [];
  55866. private static $windowsHandler = null;
  55867. private function __construct(array $signals, $loggerOrCallback)
  55868. {
  55869. if (!is_callable($loggerOrCallback) && !$loggerOrCallback instanceof LoggerInterface && $loggerOrCallback !== null) {
  55870. throw new \InvalidArgumentException('$loggerOrCallback must be a '.LoggerInterface::class.' instance, a callable, or null, '.(is_object($loggerOrCallback) ? get_class($loggerOrCallback) : gettype($loggerOrCallback)).' received.');
  55871. }
  55872. $this->signals = $signals;
  55873. $this->loggerOrCallback = $loggerOrCallback;
  55874. }
  55875. private function trigger(string $signalName): void
  55876. {
  55877. $this->triggered = $signalName;
  55878. if ($this->loggerOrCallback instanceof LoggerInterface) {
  55879. $this->loggerOrCallback->info('Received '.$signalName);
  55880. } elseif ($this->loggerOrCallback !== null) {
  55881. ($this->loggerOrCallback)($signalName, $this);
  55882. }
  55883. }
  55884. public function isTriggered(): bool
  55885. {
  55886. return $this->triggered !== null;
  55887. }
  55888. public function exitWithLastSignal(): void
  55889. {
  55890. $signal = $this->triggered ?? 'SIGINT';
  55891. $signal = defined($signal) ? constant($signal) : 2;
  55892. if (function_exists('posix_kill') && function_exists('posix_getpid')) {
  55893. pcntl_signal($signal, SIG_DFL);
  55894. posix_kill(posix_getpid(), $signal);
  55895. }
  55896. exit(128 + $signal);
  55897. }
  55898. public function reset(): void
  55899. {
  55900. $this->triggered = null;
  55901. }
  55902. public function __destruct()
  55903. {
  55904. $this->unregister();
  55905. }
  55906. public static function create(?array $signals = null, $loggerOrCallback = null): self
  55907. {
  55908. if ($signals === null) {
  55909. $signals = [self::SIGINT, self::SIGTERM];
  55910. }
  55911. $signals = array_map(function ($signal) {
  55912. if (is_int($signal)) {
  55913. return self::getSignalName($signal);
  55914. } elseif (!in_array($signal, self::ALL_SIGNALS, true)) {
  55915. throw new \InvalidArgumentException('$signals must be an array of SIG* constants or self::SIG* constants, got '.var_export($signal, true));
  55916. }
  55917. return $signal;
  55918. }, (array) $signals);
  55919. $handler = new self($signals, $loggerOrCallback);
  55920. if (PHP_VERSION_ID >= 80000) {
  55921. array_unshift(self::$handlers, WeakReference::create($handler));
  55922. } else {
  55923. array_unshift(self::$handlers, $handler);
  55924. }
  55925. if (function_exists('sapi_windows_set_ctrl_handler') && PHP_SAPI === 'cli' && (in_array(self::SIGINT, $signals, true) || in_array(self::SIGBREAK, $signals, true))) {
  55926. if (null === self::$windowsHandler) {
  55927. self::$windowsHandler = Closure::fromCallable([self::class, 'handleWindowsSignal']);
  55928. sapi_windows_set_ctrl_handler(self::$windowsHandler);
  55929. }
  55930. }
  55931. if (function_exists('pcntl_signal') && function_exists('pcntl_async_signals')) {
  55932. pcntl_async_signals(true);
  55933. self::registerPcntlHandler($signals);
  55934. }
  55935. return $handler;
  55936. }
  55937. public function unregister(): void
  55938. {
  55939. $signals = $this->signals;
  55940. $index = false;
  55941. foreach (self::$handlers as $key => $handler) {
  55942. if (($handler instanceof WeakReference && $handler->get() === $this) || $handler === $this) {
  55943. $index = $key;
  55944. break;
  55945. }
  55946. }
  55947. if ($index === false) {
  55948. return;
  55949. }
  55950. unset(self::$handlers[$index]);
  55951. if (self::$windowsHandler !== null && (in_array(self::SIGINT, $signals, true) || in_array(self::SIGBREAK, $signals, true))) {
  55952. if (self::getHandlerFor(self::SIGINT) === null && self::getHandlerFor(self::SIGBREAK) === null) {
  55953. sapi_windows_set_ctrl_handler(self::$windowsHandler, false);
  55954. self::$windowsHandler = null;
  55955. }
  55956. }
  55957. if (function_exists('pcntl_signal')) {
  55958. foreach ($signals as $signal) {
  55959. if (!defined($signal)) {
  55960. continue;
  55961. }
  55962. if (self::getHandlerFor($signal) !== null) {
  55963. continue;
  55964. }
  55965. pcntl_signal(constant($signal), SIG_DFL);
  55966. }
  55967. }
  55968. }
  55969. public static function unregisterAll(): void
  55970. {
  55971. if (self::$windowsHandler !== null) {
  55972. sapi_windows_set_ctrl_handler(self::$windowsHandler, false);
  55973. self::$windowsHandler = null;
  55974. }
  55975. foreach (self::$handlers as $key => $handler) {
  55976. if ($handler instanceof WeakReference) {
  55977. $handler = $handler->get();
  55978. if ($handler === null) {
  55979. unset(self::$handlers[$key]);
  55980. continue;
  55981. }
  55982. }
  55983. $handler->unregister();
  55984. }
  55985. }
  55986. private static function registerPcntlHandler(array $signals): void
  55987. {
  55988. static $callable;
  55989. if ($callable === null) {
  55990. $callable = Closure::fromCallable([self::class, 'handlePcntlSignal']);
  55991. }
  55992. foreach ($signals as $signal) {
  55993. if (!defined($signal)) {
  55994. continue;
  55995. }
  55996. pcntl_signal(constant($signal), $callable);
  55997. }
  55998. }
  55999. private static function handleWindowsSignal(int $event): void
  56000. {
  56001. if (PHP_WINDOWS_EVENT_CTRL_C === $event) {
  56002. self::callHandlerFor(self::SIGINT);
  56003. } elseif (PHP_WINDOWS_EVENT_CTRL_BREAK === $event) {
  56004. self::callHandlerFor(self::SIGBREAK);
  56005. }
  56006. }
  56007. private static function handlePcntlSignal(int $signal): void
  56008. {
  56009. self::callHandlerFor(self::getSignalName($signal));
  56010. }
  56011. private static function callHandlerFor(string $signal): void
  56012. {
  56013. $handler = self::getHandlerFor($signal);
  56014. if ($handler !== null) {
  56015. $handler->trigger($signal);
  56016. }
  56017. }
  56018. private static function getHandlerFor(string $signal): ?self
  56019. {
  56020. foreach (self::$handlers as $key => $handler) {
  56021. if ($handler instanceof WeakReference) {
  56022. $handler = $handler->get();
  56023. if ($handler === null) {
  56024. unset(self::$handlers[$key]);
  56025. continue;
  56026. }
  56027. }
  56028. if (in_array($signal, $handler->signals, true)) {
  56029. return $handler;
  56030. }
  56031. }
  56032. return null;
  56033. }
  56034. private static function getSignalName(int $signo): string
  56035. {
  56036. static $signals = null;
  56037. if ($signals === null) {
  56038. $signals = [];
  56039. foreach (self::ALL_SIGNALS as $value) {
  56040. if (defined($value)) {
  56041. $signals[constant($value)] = $value;
  56042. }
  56043. }
  56044. }
  56045. if (isset($signals[$signo])) {
  56046. return $signals[$signo];
  56047. }
  56048. throw new \InvalidArgumentException('Unknown signal #'.$signo);
  56049. }
  56050. }
  56051. <?php
  56052. namespace Symfony\Component\Console;
  56053. use Symfony\Component\Console\Command\Command;
  56054. use Symfony\Component\Console\Command\CompleteCommand;
  56055. use Symfony\Component\Console\Command\DumpCompletionCommand;
  56056. use Symfony\Component\Console\Command\HelpCommand;
  56057. use Symfony\Component\Console\Command\LazyCommand;
  56058. use Symfony\Component\Console\Command\ListCommand;
  56059. use Symfony\Component\Console\Command\SignalableCommandInterface;
  56060. use Symfony\Component\Console\CommandLoader\CommandLoaderInterface;
  56061. use Symfony\Component\Console\Completion\CompletionInput;
  56062. use Symfony\Component\Console\Completion\CompletionSuggestions;
  56063. use Symfony\Component\Console\Event\ConsoleCommandEvent;
  56064. use Symfony\Component\Console\Event\ConsoleErrorEvent;
  56065. use Symfony\Component\Console\Event\ConsoleSignalEvent;
  56066. use Symfony\Component\Console\Event\ConsoleTerminateEvent;
  56067. use Symfony\Component\Console\Exception\CommandNotFoundException;
  56068. use Symfony\Component\Console\Exception\ExceptionInterface;
  56069. use Symfony\Component\Console\Exception\LogicException;
  56070. use Symfony\Component\Console\Exception\NamespaceNotFoundException;
  56071. use Symfony\Component\Console\Exception\RuntimeException;
  56072. use Symfony\Component\Console\Formatter\OutputFormatter;
  56073. use Symfony\Component\Console\Helper\DebugFormatterHelper;
  56074. use Symfony\Component\Console\Helper\FormatterHelper;
  56075. use Symfony\Component\Console\Helper\Helper;
  56076. use Symfony\Component\Console\Helper\HelperSet;
  56077. use Symfony\Component\Console\Helper\ProcessHelper;
  56078. use Symfony\Component\Console\Helper\QuestionHelper;
  56079. use Symfony\Component\Console\Input\ArgvInput;
  56080. use Symfony\Component\Console\Input\ArrayInput;
  56081. use Symfony\Component\Console\Input\InputArgument;
  56082. use Symfony\Component\Console\Input\InputAwareInterface;
  56083. use Symfony\Component\Console\Input\InputDefinition;
  56084. use Symfony\Component\Console\Input\InputInterface;
  56085. use Symfony\Component\Console\Input\InputOption;
  56086. use Symfony\Component\Console\Output\ConsoleOutput;
  56087. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  56088. use Symfony\Component\Console\Output\OutputInterface;
  56089. use Symfony\Component\Console\SignalRegistry\SignalRegistry;
  56090. use Symfony\Component\Console\Style\SymfonyStyle;
  56091. use Symfony\Component\ErrorHandler\ErrorHandler;
  56092. use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
  56093. use Symfony\Contracts\Service\ResetInterface;
  56094. class Application implements ResetInterface
  56095. {
  56096. private $commands = [];
  56097. private $wantHelps = false;
  56098. private $runningCommand;
  56099. private $name;
  56100. private $version;
  56101. private $commandLoader;
  56102. private $catchExceptions = true;
  56103. private $autoExit = true;
  56104. private $definition;
  56105. private $helperSet;
  56106. private $dispatcher;
  56107. private $terminal;
  56108. private $defaultCommand;
  56109. private $singleCommand = false;
  56110. private $initialized;
  56111. private $signalRegistry;
  56112. private $signalsToDispatchEvent = [];
  56113. public function __construct(string $name = 'UNKNOWN', string $version = 'UNKNOWN')
  56114. {
  56115. $this->name = $name;
  56116. $this->version = $version;
  56117. $this->terminal = new Terminal();
  56118. $this->defaultCommand = 'list';
  56119. if (\defined('SIGINT') && SignalRegistry::isSupported()) {
  56120. $this->signalRegistry = new SignalRegistry();
  56121. $this->signalsToDispatchEvent = [\SIGINT, \SIGTERM, \SIGUSR1, \SIGUSR2];
  56122. }
  56123. }
  56124. public function setDispatcher(EventDispatcherInterface $dispatcher)
  56125. {
  56126. $this->dispatcher = $dispatcher;
  56127. }
  56128. public function setCommandLoader(CommandLoaderInterface $commandLoader)
  56129. {
  56130. $this->commandLoader = $commandLoader;
  56131. }
  56132. public function getSignalRegistry(): SignalRegistry
  56133. {
  56134. if (!$this->signalRegistry) {
  56135. 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.');
  56136. }
  56137. return $this->signalRegistry;
  56138. }
  56139. public function setSignalsToDispatchEvent(int ...$signalsToDispatchEvent)
  56140. {
  56141. $this->signalsToDispatchEvent = $signalsToDispatchEvent;
  56142. }
  56143. public function run(InputInterface $input = null, OutputInterface $output = null)
  56144. {
  56145. if (\function_exists('putenv')) {
  56146. @putenv('LINES='.$this->terminal->getHeight());
  56147. @putenv('COLUMNS='.$this->terminal->getWidth());
  56148. }
  56149. if (null === $input) {
  56150. $input = new ArgvInput();
  56151. }
  56152. if (null === $output) {
  56153. $output = new ConsoleOutput();
  56154. }
  56155. $renderException = function (\Throwable $e) use ($output) {
  56156. if ($output instanceof ConsoleOutputInterface) {
  56157. $this->renderThrowable($e, $output->getErrorOutput());
  56158. } else {
  56159. $this->renderThrowable($e, $output);
  56160. }
  56161. };
  56162. if ($phpHandler = set_exception_handler($renderException)) {
  56163. restore_exception_handler();
  56164. if (!\is_array($phpHandler) || !$phpHandler[0] instanceof ErrorHandler) {
  56165. $errorHandler = true;
  56166. } elseif ($errorHandler = $phpHandler[0]->setExceptionHandler($renderException)) {
  56167. $phpHandler[0]->setExceptionHandler($errorHandler);
  56168. }
  56169. }
  56170. $this->configureIO($input, $output);
  56171. try {
  56172. $exitCode = $this->doRun($input, $output);
  56173. } catch (\Exception $e) {
  56174. if (!$this->catchExceptions) {
  56175. throw $e;
  56176. }
  56177. $renderException($e);
  56178. $exitCode = $e->getCode();
  56179. if (is_numeric($exitCode)) {
  56180. $exitCode = (int) $exitCode;
  56181. if ($exitCode <= 0) {
  56182. $exitCode = 1;
  56183. }
  56184. } else {
  56185. $exitCode = 1;
  56186. }
  56187. } finally {
  56188. if (!$phpHandler) {
  56189. if (set_exception_handler($renderException) === $renderException) {
  56190. restore_exception_handler();
  56191. }
  56192. restore_exception_handler();
  56193. } elseif (!$errorHandler) {
  56194. $finalHandler = $phpHandler[0]->setExceptionHandler(null);
  56195. if ($finalHandler !== $renderException) {
  56196. $phpHandler[0]->setExceptionHandler($finalHandler);
  56197. }
  56198. }
  56199. }
  56200. if ($this->autoExit) {
  56201. if ($exitCode > 255) {
  56202. $exitCode = 255;
  56203. }
  56204. exit($exitCode);
  56205. }
  56206. return $exitCode;
  56207. }
  56208. public function doRun(InputInterface $input, OutputInterface $output)
  56209. {
  56210. if (true === $input->hasParameterOption(['--version', '-V'], true)) {
  56211. $output->writeln($this->getLongVersion());
  56212. return 0;
  56213. }
  56214. try {
  56215. $input->bind($this->getDefinition());
  56216. } catch (ExceptionInterface $e) {
  56217. }
  56218. $name = $this->getCommandName($input);
  56219. if (true === $input->hasParameterOption(['--help', '-h'], true)) {
  56220. if (!$name) {
  56221. $name = 'help';
  56222. $input = new ArrayInput(['command_name' => $this->defaultCommand]);
  56223. } else {
  56224. $this->wantHelps = true;
  56225. }
  56226. }
  56227. if (!$name) {
  56228. $name = $this->defaultCommand;
  56229. $definition = $this->getDefinition();
  56230. $definition->setArguments(array_merge(
  56231. $definition->getArguments(),
  56232. [
  56233. 'command' => new InputArgument('command', InputArgument::OPTIONAL, $definition->getArgument('command')->getDescription(), $name),
  56234. ]
  56235. ));
  56236. }
  56237. try {
  56238. $this->runningCommand = null;
  56239. $command = $this->find($name);
  56240. } catch (\Throwable $e) {
  56241. if (!($e instanceof CommandNotFoundException && !$e instanceof NamespaceNotFoundException) || 1 !== \count($alternatives = $e->getAlternatives()) || !$input->isInteractive()) {
  56242. if (null !== $this->dispatcher) {
  56243. $event = new ConsoleErrorEvent($input, $output, $e);
  56244. $this->dispatcher->dispatch($event, ConsoleEvents::ERROR);
  56245. if (0 === $event->getExitCode()) {
  56246. return 0;
  56247. }
  56248. $e = $event->getError();
  56249. }
  56250. throw $e;
  56251. }
  56252. $alternative = $alternatives[0];
  56253. $style = new SymfonyStyle($input, $output);
  56254. $output->writeln('');
  56255. $formattedBlock = (new FormatterHelper())->formatBlock(sprintf('Command "%s" is not defined.', $name), 'error', true);
  56256. $output->writeln($formattedBlock);
  56257. if (!$style->confirm(sprintf('Do you want to run "%s" instead? ', $alternative), false)) {
  56258. if (null !== $this->dispatcher) {
  56259. $event = new ConsoleErrorEvent($input, $output, $e);
  56260. $this->dispatcher->dispatch($event, ConsoleEvents::ERROR);
  56261. return $event->getExitCode();
  56262. }
  56263. return 1;
  56264. }
  56265. $command = $this->find($alternative);
  56266. }
  56267. if ($command instanceof LazyCommand) {
  56268. $command = $command->getCommand();
  56269. }
  56270. $this->runningCommand = $command;
  56271. $exitCode = $this->doRunCommand($command, $input, $output);
  56272. $this->runningCommand = null;
  56273. return $exitCode;
  56274. }
  56275. public function reset()
  56276. {
  56277. }
  56278. public function setHelperSet(HelperSet $helperSet)
  56279. {
  56280. $this->helperSet = $helperSet;
  56281. }
  56282. public function getHelperSet()
  56283. {
  56284. if (!$this->helperSet) {
  56285. $this->helperSet = $this->getDefaultHelperSet();
  56286. }
  56287. return $this->helperSet;
  56288. }
  56289. public function setDefinition(InputDefinition $definition)
  56290. {
  56291. $this->definition = $definition;
  56292. }
  56293. public function getDefinition()
  56294. {
  56295. if (!$this->definition) {
  56296. $this->definition = $this->getDefaultInputDefinition();
  56297. }
  56298. if ($this->singleCommand) {
  56299. $inputDefinition = $this->definition;
  56300. $inputDefinition->setArguments();
  56301. return $inputDefinition;
  56302. }
  56303. return $this->definition;
  56304. }
  56305. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  56306. {
  56307. if (
  56308. CompletionInput::TYPE_ARGUMENT_VALUE === $input->getCompletionType()
  56309. && 'command' === $input->getCompletionName()
  56310. ) {
  56311. $commandNames = [];
  56312. foreach ($this->all() as $name => $command) {
  56313. if ($command->isHidden() || $command->getName() !== $name) {
  56314. continue;
  56315. }
  56316. $commandNames[] = $command->getName();
  56317. foreach ($command->getAliases() as $name) {
  56318. $commandNames[] = $name;
  56319. }
  56320. }
  56321. $suggestions->suggestValues(array_filter($commandNames));
  56322. return;
  56323. }
  56324. if (CompletionInput::TYPE_OPTION_NAME === $input->getCompletionType()) {
  56325. $suggestions->suggestOptions($this->getDefinition()->getOptions());
  56326. return;
  56327. }
  56328. }
  56329. public function getHelp()
  56330. {
  56331. return $this->getLongVersion();
  56332. }
  56333. public function areExceptionsCaught()
  56334. {
  56335. return $this->catchExceptions;
  56336. }
  56337. public function setCatchExceptions(bool $boolean)
  56338. {
  56339. $this->catchExceptions = $boolean;
  56340. }
  56341. public function isAutoExitEnabled()
  56342. {
  56343. return $this->autoExit;
  56344. }
  56345. public function setAutoExit(bool $boolean)
  56346. {
  56347. $this->autoExit = $boolean;
  56348. }
  56349. public function getName()
  56350. {
  56351. return $this->name;
  56352. }
  56353. public function setName(string $name)
  56354. {
  56355. $this->name = $name;
  56356. }
  56357. public function getVersion()
  56358. {
  56359. return $this->version;
  56360. }
  56361. public function setVersion(string $version)
  56362. {
  56363. $this->version = $version;
  56364. }
  56365. public function getLongVersion()
  56366. {
  56367. if ('UNKNOWN' !== $this->getName()) {
  56368. if ('UNKNOWN' !== $this->getVersion()) {
  56369. return sprintf('%s <info>%s</info>', $this->getName(), $this->getVersion());
  56370. }
  56371. return $this->getName();
  56372. }
  56373. return 'Console Tool';
  56374. }
  56375. public function register(string $name)
  56376. {
  56377. return $this->add(new Command($name));
  56378. }
  56379. public function addCommands(array $commands)
  56380. {
  56381. foreach ($commands as $command) {
  56382. $this->add($command);
  56383. }
  56384. }
  56385. public function add(Command $command)
  56386. {
  56387. $this->init();
  56388. $command->setApplication($this);
  56389. if (!$command->isEnabled()) {
  56390. $command->setApplication(null);
  56391. return null;
  56392. }
  56393. if (!$command instanceof LazyCommand) {
  56394. $command->getDefinition();
  56395. }
  56396. if (!$command->getName()) {
  56397. throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', get_debug_type($command)));
  56398. }
  56399. $this->commands[$command->getName()] = $command;
  56400. foreach ($command->getAliases() as $alias) {
  56401. $this->commands[$alias] = $command;
  56402. }
  56403. return $command;
  56404. }
  56405. public function get(string $name)
  56406. {
  56407. $this->init();
  56408. if (!$this->has($name)) {
  56409. throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
  56410. }
  56411. if (!isset($this->commands[$name])) {
  56412. 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));
  56413. }
  56414. $command = $this->commands[$name];
  56415. if ($this->wantHelps) {
  56416. $this->wantHelps = false;
  56417. $helpCommand = $this->get('help');
  56418. $helpCommand->setCommand($command);
  56419. return $helpCommand;
  56420. }
  56421. return $command;
  56422. }
  56423. public function has(string $name)
  56424. {
  56425. $this->init();
  56426. return isset($this->commands[$name]) || ($this->commandLoader && $this->commandLoader->has($name) && $this->add($this->commandLoader->get($name)));
  56427. }
  56428. public function getNamespaces()
  56429. {
  56430. $namespaces = [];
  56431. foreach ($this->all() as $command) {
  56432. if ($command->isHidden()) {
  56433. continue;
  56434. }
  56435. $namespaces[] = $this->extractAllNamespaces($command->getName());
  56436. foreach ($command->getAliases() as $alias) {
  56437. $namespaces[] = $this->extractAllNamespaces($alias);
  56438. }
  56439. }
  56440. return array_values(array_unique(array_filter(array_merge([], ...$namespaces))));
  56441. }
  56442. public function findNamespace(string $namespace)
  56443. {
  56444. $allNamespaces = $this->getNamespaces();
  56445. $expr = implode('[^:]*:', array_map('preg_quote', explode(':', $namespace))).'[^:]*';
  56446. $namespaces = preg_grep('{^'.$expr.'}', $allNamespaces);
  56447. if (empty($namespaces)) {
  56448. $message = sprintf('There are no commands defined in the "%s" namespace.', $namespace);
  56449. if ($alternatives = $this->findAlternatives($namespace, $allNamespaces)) {
  56450. if (1 == \count($alternatives)) {
  56451. $message .= "\n\nDid you mean this?\n ";
  56452. } else {
  56453. $message .= "\n\nDid you mean one of these?\n ";
  56454. }
  56455. $message .= implode("\n ", $alternatives);
  56456. }
  56457. throw new NamespaceNotFoundException($message, $alternatives);
  56458. }
  56459. $exact = \in_array($namespace, $namespaces, true);
  56460. if (\count($namespaces) > 1 && !$exact) {
  56461. 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));
  56462. }
  56463. return $exact ? $namespace : reset($namespaces);
  56464. }
  56465. public function find(string $name)
  56466. {
  56467. $this->init();
  56468. $aliases = [];
  56469. foreach ($this->commands as $command) {
  56470. foreach ($command->getAliases() as $alias) {
  56471. if (!$this->has($alias)) {
  56472. $this->commands[$alias] = $command;
  56473. }
  56474. }
  56475. }
  56476. if ($this->has($name)) {
  56477. return $this->get($name);
  56478. }
  56479. $allCommands = $this->commandLoader ? array_merge($this->commandLoader->getNames(), array_keys($this->commands)) : array_keys($this->commands);
  56480. $expr = implode('[^:]*:', array_map('preg_quote', explode(':', $name))).'[^:]*';
  56481. $commands = preg_grep('{^'.$expr.'}', $allCommands);
  56482. if (empty($commands)) {
  56483. $commands = preg_grep('{^'.$expr.'}i', $allCommands);
  56484. }
  56485. if (empty($commands) || \count(preg_grep('{^'.$expr.'$}i', $commands)) < 1) {
  56486. if (false !== $pos = strrpos($name, ':')) {
  56487. $this->findNamespace(substr($name, 0, $pos));
  56488. }
  56489. $message = sprintf('Command "%s" is not defined.', $name);
  56490. if ($alternatives = $this->findAlternatives($name, $allCommands)) {
  56491. $alternatives = array_filter($alternatives, function ($name) {
  56492. return !$this->get($name)->isHidden();
  56493. });
  56494. if (1 == \count($alternatives)) {
  56495. $message .= "\n\nDid you mean this?\n ";
  56496. } else {
  56497. $message .= "\n\nDid you mean one of these?\n ";
  56498. }
  56499. $message .= implode("\n ", $alternatives);
  56500. }
  56501. throw new CommandNotFoundException($message, array_values($alternatives));
  56502. }
  56503. if (\count($commands) > 1) {
  56504. $commandList = $this->commandLoader ? array_merge(array_flip($this->commandLoader->getNames()), $this->commands) : $this->commands;
  56505. $commands = array_unique(array_filter($commands, function ($nameOrAlias) use (&$commandList, $commands, &$aliases) {
  56506. if (!$commandList[$nameOrAlias] instanceof Command) {
  56507. $commandList[$nameOrAlias] = $this->commandLoader->get($nameOrAlias);
  56508. }
  56509. $commandName = $commandList[$nameOrAlias]->getName();
  56510. $aliases[$nameOrAlias] = $commandName;
  56511. return $commandName === $nameOrAlias || !\in_array($commandName, $commands);
  56512. }));
  56513. }
  56514. if (\count($commands) > 1) {
  56515. $usableWidth = $this->terminal->getWidth() - 10;
  56516. $abbrevs = array_values($commands);
  56517. $maxLen = 0;
  56518. foreach ($abbrevs as $abbrev) {
  56519. $maxLen = max(Helper::width($abbrev), $maxLen);
  56520. }
  56521. $abbrevs = array_map(function ($cmd) use ($commandList, $usableWidth, $maxLen, &$commands) {
  56522. if ($commandList[$cmd]->isHidden()) {
  56523. unset($commands[array_search($cmd, $commands)]);
  56524. return false;
  56525. }
  56526. $abbrev = str_pad($cmd, $maxLen, ' ').' '.$commandList[$cmd]->getDescription();
  56527. return Helper::width($abbrev) > $usableWidth ? Helper::substr($abbrev, 0, $usableWidth - 3).'...' : $abbrev;
  56528. }, array_values($commands));
  56529. if (\count($commands) > 1) {
  56530. $suggestions = $this->getAbbreviationSuggestions(array_filter($abbrevs));
  56531. throw new CommandNotFoundException(sprintf("Command \"%s\" is ambiguous.\nDid you mean one of these?\n%s.", $name, $suggestions), array_values($commands));
  56532. }
  56533. }
  56534. $command = $this->get(reset($commands));
  56535. if ($command->isHidden()) {
  56536. throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
  56537. }
  56538. return $command;
  56539. }
  56540. public function all(string $namespace = null)
  56541. {
  56542. $this->init();
  56543. if (null === $namespace) {
  56544. if (!$this->commandLoader) {
  56545. return $this->commands;
  56546. }
  56547. $commands = $this->commands;
  56548. foreach ($this->commandLoader->getNames() as $name) {
  56549. if (!isset($commands[$name]) && $this->has($name)) {
  56550. $commands[$name] = $this->get($name);
  56551. }
  56552. }
  56553. return $commands;
  56554. }
  56555. $commands = [];
  56556. foreach ($this->commands as $name => $command) {
  56557. if ($namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1)) {
  56558. $commands[$name] = $command;
  56559. }
  56560. }
  56561. if ($this->commandLoader) {
  56562. foreach ($this->commandLoader->getNames() as $name) {
  56563. if (!isset($commands[$name]) && $namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1) && $this->has($name)) {
  56564. $commands[$name] = $this->get($name);
  56565. }
  56566. }
  56567. }
  56568. return $commands;
  56569. }
  56570. public static function getAbbreviations(array $names)
  56571. {
  56572. $abbrevs = [];
  56573. foreach ($names as $name) {
  56574. for ($len = \strlen($name); $len > 0; --$len) {
  56575. $abbrev = substr($name, 0, $len);
  56576. $abbrevs[$abbrev][] = $name;
  56577. }
  56578. }
  56579. return $abbrevs;
  56580. }
  56581. public function renderThrowable(\Throwable $e, OutputInterface $output): void
  56582. {
  56583. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  56584. $this->doRenderThrowable($e, $output);
  56585. if (null !== $this->runningCommand) {
  56586. $output->writeln(sprintf('<info>%s</info>', OutputFormatter::escape(sprintf($this->runningCommand->getSynopsis(), $this->getName()))), OutputInterface::VERBOSITY_QUIET);
  56587. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  56588. }
  56589. }
  56590. protected function doRenderThrowable(\Throwable $e, OutputInterface $output): void
  56591. {
  56592. do {
  56593. $message = trim($e->getMessage());
  56594. if ('' === $message || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
  56595. $class = get_debug_type($e);
  56596. $title = sprintf(' [%s%s] ', $class, 0 !== ($code = $e->getCode()) ? ' ('.$code.')' : '');
  56597. $len = Helper::width($title);
  56598. } else {
  56599. $len = 0;
  56600. }
  56601. if (str_contains($message, "@anonymous\0")) {
  56602. $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) {
  56603. return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0];
  56604. }, $message);
  56605. }
  56606. $width = $this->terminal->getWidth() ? $this->terminal->getWidth() - 1 : \PHP_INT_MAX;
  56607. $lines = [];
  56608. foreach ('' !== $message ? preg_split('/\r?\n/', $message) : [] as $line) {
  56609. foreach ($this->splitStringByWidth($line, $width - 4) as $line) {
  56610. $lineLength = Helper::width($line) + 4;
  56611. $lines[] = [$line, $lineLength];
  56612. $len = max($lineLength, $len);
  56613. }
  56614. }
  56615. $messages = [];
  56616. if (!$e instanceof ExceptionInterface || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
  56617. $messages[] = sprintf('<comment>%s</comment>', OutputFormatter::escape(sprintf('In %s line %s:', basename($e->getFile()) ?: 'n/a', $e->getLine() ?: 'n/a')));
  56618. }
  56619. $messages[] = $emptyLine = sprintf('<error>%s</error>', str_repeat(' ', $len));
  56620. if ('' === $message || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
  56621. $messages[] = sprintf('<error>%s%s</error>', $title, str_repeat(' ', max(0, $len - Helper::width($title))));
  56622. }
  56623. foreach ($lines as $line) {
  56624. $messages[] = sprintf('<error> %s %s</error>', OutputFormatter::escape($line[0]), str_repeat(' ', $len - $line[1]));
  56625. }
  56626. $messages[] = $emptyLine;
  56627. $messages[] = '';
  56628. $output->writeln($messages, OutputInterface::VERBOSITY_QUIET);
  56629. if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
  56630. $output->writeln('<comment>Exception trace:</comment>', OutputInterface::VERBOSITY_QUIET);
  56631. $trace = $e->getTrace();
  56632. array_unshift($trace, [
  56633. 'function' => '',
  56634. 'file' => $e->getFile() ?: 'n/a',
  56635. 'line' => $e->getLine() ?: 'n/a',
  56636. 'args' => [],
  56637. ]);
  56638. for ($i = 0, $count = \count($trace); $i < $count; ++$i) {
  56639. $class = $trace[$i]['class'] ?? '';
  56640. $type = $trace[$i]['type'] ?? '';
  56641. $function = $trace[$i]['function'] ?? '';
  56642. $file = $trace[$i]['file'] ?? 'n/a';
  56643. $line = $trace[$i]['line'] ?? 'n/a';
  56644. $output->writeln(sprintf(' %s%s at <info>%s:%s</info>', $class, $function ? $type.$function.'()' : '', $file, $line), OutputInterface::VERBOSITY_QUIET);
  56645. }
  56646. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  56647. }
  56648. } while ($e = $e->getPrevious());
  56649. }
  56650. protected function configureIO(InputInterface $input, OutputInterface $output)
  56651. {
  56652. if (true === $input->hasParameterOption(['--ansi'], true)) {
  56653. $output->setDecorated(true);
  56654. } elseif (true === $input->hasParameterOption(['--no-ansi'], true)) {
  56655. $output->setDecorated(false);
  56656. }
  56657. if (true === $input->hasParameterOption(['--no-interaction', '-n'], true)) {
  56658. $input->setInteractive(false);
  56659. }
  56660. switch ($shellVerbosity = (int) getenv('SHELL_VERBOSITY')) {
  56661. case -1:
  56662. $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
  56663. break;
  56664. case 1:
  56665. $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
  56666. break;
  56667. case 2:
  56668. $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
  56669. break;
  56670. case 3:
  56671. $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
  56672. break;
  56673. default:
  56674. $shellVerbosity = 0;
  56675. break;
  56676. }
  56677. if (true === $input->hasParameterOption(['--quiet', '-q'], true)) {
  56678. $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
  56679. $shellVerbosity = -1;
  56680. } else {
  56681. if ($input->hasParameterOption('-vvv', true) || $input->hasParameterOption('--verbose=3', true) || 3 === $input->getParameterOption('--verbose', false, true)) {
  56682. $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
  56683. $shellVerbosity = 3;
  56684. } elseif ($input->hasParameterOption('-vv', true) || $input->hasParameterOption('--verbose=2', true) || 2 === $input->getParameterOption('--verbose', false, true)) {
  56685. $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
  56686. $shellVerbosity = 2;
  56687. } elseif ($input->hasParameterOption('-v', true) || $input->hasParameterOption('--verbose=1', true) || $input->hasParameterOption('--verbose', true) || $input->getParameterOption('--verbose', false, true)) {
  56688. $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
  56689. $shellVerbosity = 1;
  56690. }
  56691. }
  56692. if (-1 === $shellVerbosity) {
  56693. $input->setInteractive(false);
  56694. }
  56695. if (\function_exists('putenv')) {
  56696. @putenv('SHELL_VERBOSITY='.$shellVerbosity);
  56697. }
  56698. $_ENV['SHELL_VERBOSITY'] = $shellVerbosity;
  56699. $_SERVER['SHELL_VERBOSITY'] = $shellVerbosity;
  56700. }
  56701. protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
  56702. {
  56703. foreach ($command->getHelperSet() as $helper) {
  56704. if ($helper instanceof InputAwareInterface) {
  56705. $helper->setInput($input);
  56706. }
  56707. }
  56708. if ($this->signalsToDispatchEvent) {
  56709. $commandSignals = $command instanceof SignalableCommandInterface ? $command->getSubscribedSignals() : [];
  56710. if ($commandSignals || null !== $this->dispatcher) {
  56711. if (!$this->signalRegistry) {
  56712. 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.');
  56713. }
  56714. if (Terminal::hasSttyAvailable()) {
  56715. $sttyMode = shell_exec('stty -g');
  56716. foreach ([\SIGINT, \SIGTERM] as $signal) {
  56717. $this->signalRegistry->register($signal, static function () use ($sttyMode) {
  56718. shell_exec('stty '.$sttyMode);
  56719. });
  56720. }
  56721. }
  56722. }
  56723. if (null !== $this->dispatcher) {
  56724. foreach ($this->signalsToDispatchEvent as $signal) {
  56725. $event = new ConsoleSignalEvent($command, $input, $output, $signal);
  56726. $this->signalRegistry->register($signal, function ($signal, $hasNext) use ($event) {
  56727. $this->dispatcher->dispatch($event, ConsoleEvents::SIGNAL);
  56728. if (!$hasNext) {
  56729. if (!\in_array($signal, [\SIGUSR1, \SIGUSR2], true)) {
  56730. exit(0);
  56731. }
  56732. }
  56733. });
  56734. }
  56735. }
  56736. foreach ($commandSignals as $signal) {
  56737. $this->signalRegistry->register($signal, [$command, 'handleSignal']);
  56738. }
  56739. }
  56740. if (null === $this->dispatcher) {
  56741. return $command->run($input, $output);
  56742. }
  56743. try {
  56744. $command->mergeApplicationDefinition();
  56745. $input->bind($command->getDefinition());
  56746. } catch (ExceptionInterface $e) {
  56747. }
  56748. $event = new ConsoleCommandEvent($command, $input, $output);
  56749. $e = null;
  56750. try {
  56751. $this->dispatcher->dispatch($event, ConsoleEvents::COMMAND);
  56752. if ($event->commandShouldRun()) {
  56753. $exitCode = $command->run($input, $output);
  56754. } else {
  56755. $exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
  56756. }
  56757. } catch (\Throwable $e) {
  56758. $event = new ConsoleErrorEvent($input, $output, $e, $command);
  56759. $this->dispatcher->dispatch($event, ConsoleEvents::ERROR);
  56760. $e = $event->getError();
  56761. if (0 === $exitCode = $event->getExitCode()) {
  56762. $e = null;
  56763. }
  56764. }
  56765. $event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
  56766. $this->dispatcher->dispatch($event, ConsoleEvents::TERMINATE);
  56767. if (null !== $e) {
  56768. throw $e;
  56769. }
  56770. return $event->getExitCode();
  56771. }
  56772. protected function getCommandName(InputInterface $input)
  56773. {
  56774. return $this->singleCommand ? $this->defaultCommand : $input->getFirstArgument();
  56775. }
  56776. protected function getDefaultInputDefinition()
  56777. {
  56778. return new InputDefinition([
  56779. new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'),
  56780. 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'),
  56781. new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'),
  56782. 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'),
  56783. new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version'),
  56784. new InputOption('--ansi', '', InputOption::VALUE_NEGATABLE, 'Force (or disable --no-ansi) ANSI output', null),
  56785. new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question'),
  56786. ]);
  56787. }
  56788. protected function getDefaultCommands()
  56789. {
  56790. return [new HelpCommand(), new ListCommand(), new CompleteCommand(), new DumpCompletionCommand()];
  56791. }
  56792. protected function getDefaultHelperSet()
  56793. {
  56794. return new HelperSet([
  56795. new FormatterHelper(),
  56796. new DebugFormatterHelper(),
  56797. new ProcessHelper(),
  56798. new QuestionHelper(),
  56799. ]);
  56800. }
  56801. private function getAbbreviationSuggestions(array $abbrevs): string
  56802. {
  56803. return ' '.implode("\n ", $abbrevs);
  56804. }
  56805. public function extractNamespace(string $name, int $limit = null)
  56806. {
  56807. $parts = explode(':', $name, -1);
  56808. return implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit));
  56809. }
  56810. private function findAlternatives(string $name, iterable $collection): array
  56811. {
  56812. $threshold = 1e3;
  56813. $alternatives = [];
  56814. $collectionParts = [];
  56815. foreach ($collection as $item) {
  56816. $collectionParts[$item] = explode(':', $item);
  56817. }
  56818. foreach (explode(':', $name) as $i => $subname) {
  56819. foreach ($collectionParts as $collectionName => $parts) {
  56820. $exists = isset($alternatives[$collectionName]);
  56821. if (!isset($parts[$i]) && $exists) {
  56822. $alternatives[$collectionName] += $threshold;
  56823. continue;
  56824. } elseif (!isset($parts[$i])) {
  56825. continue;
  56826. }
  56827. $lev = levenshtein($subname, $parts[$i]);
  56828. if ($lev <= \strlen($subname) / 3 || '' !== $subname && str_contains($parts[$i], $subname)) {
  56829. $alternatives[$collectionName] = $exists ? $alternatives[$collectionName] + $lev : $lev;
  56830. } elseif ($exists) {
  56831. $alternatives[$collectionName] += $threshold;
  56832. }
  56833. }
  56834. }
  56835. foreach ($collection as $item) {
  56836. $lev = levenshtein($name, $item);
  56837. if ($lev <= \strlen($name) / 3 || str_contains($item, $name)) {
  56838. $alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev;
  56839. }
  56840. }
  56841. $alternatives = array_filter($alternatives, function ($lev) use ($threshold) { return $lev < 2 * $threshold; });
  56842. ksort($alternatives, \SORT_NATURAL | \SORT_FLAG_CASE);
  56843. return array_keys($alternatives);
  56844. }
  56845. public function setDefaultCommand(string $commandName, bool $isSingleCommand = false)
  56846. {
  56847. $this->defaultCommand = explode('|', ltrim($commandName, '|'))[0];
  56848. if ($isSingleCommand) {
  56849. $this->find($commandName);
  56850. $this->singleCommand = true;
  56851. }
  56852. return $this;
  56853. }
  56854. public function isSingleCommand(): bool
  56855. {
  56856. return $this->singleCommand;
  56857. }
  56858. private function splitStringByWidth(string $string, int $width): array
  56859. {
  56860. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  56861. return str_split($string, $width);
  56862. }
  56863. $utf8String = mb_convert_encoding($string, 'utf8', $encoding);
  56864. $lines = [];
  56865. $line = '';
  56866. $offset = 0;
  56867. while (preg_match('/.{1,10000}/u', $utf8String, $m, 0, $offset)) {
  56868. $offset += \strlen($m[0]);
  56869. foreach (preg_split('//u', $m[0]) as $char) {
  56870. if (mb_strwidth($line.$char, 'utf8') <= $width) {
  56871. $line .= $char;
  56872. continue;
  56873. }
  56874. $lines[] = str_pad($line, $width);
  56875. $line = $char;
  56876. }
  56877. }
  56878. $lines[] = \count($lines) ? str_pad($line, $width) : $line;
  56879. mb_convert_variables($encoding, 'utf8', $lines);
  56880. return $lines;
  56881. }
  56882. private function extractAllNamespaces(string $name): array
  56883. {
  56884. $parts = explode(':', $name, -1);
  56885. $namespaces = [];
  56886. foreach ($parts as $part) {
  56887. if (\count($namespaces)) {
  56888. $namespaces[] = end($namespaces).':'.$part;
  56889. } else {
  56890. $namespaces[] = $part;
  56891. }
  56892. }
  56893. return $namespaces;
  56894. }
  56895. private function init()
  56896. {
  56897. if ($this->initialized) {
  56898. return;
  56899. }
  56900. $this->initialized = true;
  56901. foreach ($this->getDefaultCommands() as $command) {
  56902. $this->add($command);
  56903. }
  56904. }
  56905. }
  56906. <?php
  56907. namespace Symfony\Component\Console\Attribute;
  56908. #[\Attribute(\Attribute::TARGET_CLASS)]
  56909. class AsCommand
  56910. {
  56911. public function __construct(
  56912. public string $name,
  56913. public ?string $description = null,
  56914. array $aliases = [],
  56915. bool $hidden = false,
  56916. ) {
  56917. if (!$hidden && !$aliases) {
  56918. return;
  56919. }
  56920. $name = explode('|', $name);
  56921. $name = array_merge($name, $aliases);
  56922. if ($hidden && '' !== $name[0]) {
  56923. array_unshift($name, '');
  56924. }
  56925. $this->name = implode('|', $name);
  56926. }
  56927. }
  56928. <?php
  56929. namespace Symfony\Component\Console\CI;
  56930. use Symfony\Component\Console\Output\OutputInterface;
  56931. class GithubActionReporter
  56932. {
  56933. private $output;
  56934. private const ESCAPED_DATA = [
  56935. '%' => '%25',
  56936. "\r" => '%0D',
  56937. "\n" => '%0A',
  56938. ];
  56939. private const ESCAPED_PROPERTIES = [
  56940. '%' => '%25',
  56941. "\r" => '%0D',
  56942. "\n" => '%0A',
  56943. ':' => '%3A',
  56944. ',' => '%2C',
  56945. ];
  56946. public function __construct(OutputInterface $output)
  56947. {
  56948. $this->output = $output;
  56949. }
  56950. public static function isGithubActionEnvironment(): bool
  56951. {
  56952. return false !== getenv('GITHUB_ACTIONS');
  56953. }
  56954. public function error(string $message, string $file = null, int $line = null, int $col = null): void
  56955. {
  56956. $this->log('error', $message, $file, $line, $col);
  56957. }
  56958. public function warning(string $message, string $file = null, int $line = null, int $col = null): void
  56959. {
  56960. $this->log('warning', $message, $file, $line, $col);
  56961. }
  56962. public function debug(string $message, string $file = null, int $line = null, int $col = null): void
  56963. {
  56964. $this->log('debug', $message, $file, $line, $col);
  56965. }
  56966. private function log(string $type, string $message, string $file = null, int $line = null, int $col = null): void
  56967. {
  56968. $message = strtr($message, self::ESCAPED_DATA);
  56969. if (!$file) {
  56970. $this->output->writeln(sprintf('::%s::%s', $type, $message));
  56971. return;
  56972. }
  56973. $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));
  56974. }
  56975. }
  56976. <?php
  56977. namespace Symfony\Component\Console;
  56978. use Symfony\Component\Console\Exception\InvalidArgumentException;
  56979. final class Color
  56980. {
  56981. private const COLORS = [
  56982. 'black' => 0,
  56983. 'red' => 1,
  56984. 'green' => 2,
  56985. 'yellow' => 3,
  56986. 'blue' => 4,
  56987. 'magenta' => 5,
  56988. 'cyan' => 6,
  56989. 'white' => 7,
  56990. 'default' => 9,
  56991. ];
  56992. private const BRIGHT_COLORS = [
  56993. 'gray' => 0,
  56994. 'bright-red' => 1,
  56995. 'bright-green' => 2,
  56996. 'bright-yellow' => 3,
  56997. 'bright-blue' => 4,
  56998. 'bright-magenta' => 5,
  56999. 'bright-cyan' => 6,
  57000. 'bright-white' => 7,
  57001. ];
  57002. private const AVAILABLE_OPTIONS = [
  57003. 'bold' => ['set' => 1, 'unset' => 22],
  57004. 'underscore' => ['set' => 4, 'unset' => 24],
  57005. 'blink' => ['set' => 5, 'unset' => 25],
  57006. 'reverse' => ['set' => 7, 'unset' => 27],
  57007. 'conceal' => ['set' => 8, 'unset' => 28],
  57008. ];
  57009. private $foreground;
  57010. private $background;
  57011. private $options = [];
  57012. public function __construct(string $foreground = '', string $background = '', array $options = [])
  57013. {
  57014. $this->foreground = $this->parseColor($foreground);
  57015. $this->background = $this->parseColor($background, true);
  57016. foreach ($options as $option) {
  57017. if (!isset(self::AVAILABLE_OPTIONS[$option])) {
  57018. throw new InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s).', $option, implode(', ', array_keys(self::AVAILABLE_OPTIONS))));
  57019. }
  57020. $this->options[$option] = self::AVAILABLE_OPTIONS[$option];
  57021. }
  57022. }
  57023. public function apply(string $text): string
  57024. {
  57025. return $this->set().$text.$this->unset();
  57026. }
  57027. public function set(): string
  57028. {
  57029. $setCodes = [];
  57030. if ('' !== $this->foreground) {
  57031. $setCodes[] = $this->foreground;
  57032. }
  57033. if ('' !== $this->background) {
  57034. $setCodes[] = $this->background;
  57035. }
  57036. foreach ($this->options as $option) {
  57037. $setCodes[] = $option['set'];
  57038. }
  57039. if (0 === \count($setCodes)) {
  57040. return '';
  57041. }
  57042. return sprintf("\033[%sm", implode(';', $setCodes));
  57043. }
  57044. public function unset(): string
  57045. {
  57046. $unsetCodes = [];
  57047. if ('' !== $this->foreground) {
  57048. $unsetCodes[] = 39;
  57049. }
  57050. if ('' !== $this->background) {
  57051. $unsetCodes[] = 49;
  57052. }
  57053. foreach ($this->options as $option) {
  57054. $unsetCodes[] = $option['unset'];
  57055. }
  57056. if (0 === \count($unsetCodes)) {
  57057. return '';
  57058. }
  57059. return sprintf("\033[%sm", implode(';', $unsetCodes));
  57060. }
  57061. private function parseColor(string $color, bool $background = false): string
  57062. {
  57063. if ('' === $color) {
  57064. return '';
  57065. }
  57066. if ('#' === $color[0]) {
  57067. $color = substr($color, 1);
  57068. if (3 === \strlen($color)) {
  57069. $color = $color[0].$color[0].$color[1].$color[1].$color[2].$color[2];
  57070. }
  57071. if (6 !== \strlen($color)) {
  57072. throw new InvalidArgumentException(sprintf('Invalid "%s" color.', $color));
  57073. }
  57074. return ($background ? '4' : '3').$this->convertHexColorToAnsi(hexdec($color));
  57075. }
  57076. if (isset(self::COLORS[$color])) {
  57077. return ($background ? '4' : '3').self::COLORS[$color];
  57078. }
  57079. if (isset(self::BRIGHT_COLORS[$color])) {
  57080. return ($background ? '10' : '9').self::BRIGHT_COLORS[$color];
  57081. }
  57082. throw new InvalidArgumentException(sprintf('Invalid "%s" color; expected one of (%s).', $color, implode(', ', array_merge(array_keys(self::COLORS), array_keys(self::BRIGHT_COLORS)))));
  57083. }
  57084. private function convertHexColorToAnsi(int $color): string
  57085. {
  57086. $r = ($color >> 16) & 255;
  57087. $g = ($color >> 8) & 255;
  57088. $b = $color & 255;
  57089. if ('truecolor' !== getenv('COLORTERM')) {
  57090. return (string) $this->degradeHexColorToAnsi($r, $g, $b);
  57091. }
  57092. return sprintf('8;2;%d;%d;%d', $r, $g, $b);
  57093. }
  57094. private function degradeHexColorToAnsi(int $r, int $g, int $b): int
  57095. {
  57096. if (0 === round($this->getSaturation($r, $g, $b) / 50)) {
  57097. return 0;
  57098. }
  57099. return (round($b / 255) << 2) | (round($g / 255) << 1) | round($r / 255);
  57100. }
  57101. private function getSaturation(int $r, int $g, int $b): int
  57102. {
  57103. $r = $r / 255;
  57104. $g = $g / 255;
  57105. $b = $b / 255;
  57106. $v = max($r, $g, $b);
  57107. if (0 === $diff = $v - min($r, $g, $b)) {
  57108. return 0;
  57109. }
  57110. return (int) $diff * 100 / $v;
  57111. }
  57112. }
  57113. <?php
  57114. namespace Symfony\Component\Console\Command;
  57115. use Symfony\Component\Console\Application;
  57116. use Symfony\Component\Console\Attribute\AsCommand;
  57117. use Symfony\Component\Console\Completion\CompletionInput;
  57118. use Symfony\Component\Console\Completion\CompletionSuggestions;
  57119. use Symfony\Component\Console\Exception\ExceptionInterface;
  57120. use Symfony\Component\Console\Exception\InvalidArgumentException;
  57121. use Symfony\Component\Console\Exception\LogicException;
  57122. use Symfony\Component\Console\Helper\HelperSet;
  57123. use Symfony\Component\Console\Input\InputArgument;
  57124. use Symfony\Component\Console\Input\InputDefinition;
  57125. use Symfony\Component\Console\Input\InputInterface;
  57126. use Symfony\Component\Console\Input\InputOption;
  57127. use Symfony\Component\Console\Output\OutputInterface;
  57128. class Command
  57129. {
  57130. public const SUCCESS = 0;
  57131. public const FAILURE = 1;
  57132. public const INVALID = 2;
  57133. protected static $defaultName;
  57134. protected static $defaultDescription;
  57135. private $application;
  57136. private $name;
  57137. private $processTitle;
  57138. private $aliases = [];
  57139. private $definition;
  57140. private $hidden = false;
  57141. private $help = '';
  57142. private $description = '';
  57143. private $fullDefinition;
  57144. private $ignoreValidationErrors = false;
  57145. private $code;
  57146. private $synopsis = [];
  57147. private $usages = [];
  57148. private $helperSet;
  57149. public static function getDefaultName()
  57150. {
  57151. $class = static::class;
  57152. if (\PHP_VERSION_ID >= 80000 && $attribute = (new \ReflectionClass($class))->getAttributes(AsCommand::class)) {
  57153. return $attribute[0]->newInstance()->name;
  57154. }
  57155. $r = new \ReflectionProperty($class, 'defaultName');
  57156. return $class === $r->class ? static::$defaultName : null;
  57157. }
  57158. public static function getDefaultDescription(): ?string
  57159. {
  57160. $class = static::class;
  57161. if (\PHP_VERSION_ID >= 80000 && $attribute = (new \ReflectionClass($class))->getAttributes(AsCommand::class)) {
  57162. return $attribute[0]->newInstance()->description;
  57163. }
  57164. $r = new \ReflectionProperty($class, 'defaultDescription');
  57165. return $class === $r->class ? static::$defaultDescription : null;
  57166. }
  57167. public function __construct(string $name = null)
  57168. {
  57169. $this->definition = new InputDefinition();
  57170. if (null === $name && null !== $name = static::getDefaultName()) {
  57171. $aliases = explode('|', $name);
  57172. if ('' === $name = array_shift($aliases)) {
  57173. $this->setHidden(true);
  57174. $name = array_shift($aliases);
  57175. }
  57176. $this->setAliases($aliases);
  57177. }
  57178. if (null !== $name) {
  57179. $this->setName($name);
  57180. }
  57181. if ('' === $this->description) {
  57182. $this->setDescription(static::getDefaultDescription() ?? '');
  57183. }
  57184. $this->configure();
  57185. }
  57186. public function ignoreValidationErrors()
  57187. {
  57188. $this->ignoreValidationErrors = true;
  57189. }
  57190. public function setApplication(Application $application = null)
  57191. {
  57192. $this->application = $application;
  57193. if ($application) {
  57194. $this->setHelperSet($application->getHelperSet());
  57195. } else {
  57196. $this->helperSet = null;
  57197. }
  57198. $this->fullDefinition = null;
  57199. }
  57200. public function setHelperSet(HelperSet $helperSet)
  57201. {
  57202. $this->helperSet = $helperSet;
  57203. }
  57204. public function getHelperSet()
  57205. {
  57206. return $this->helperSet;
  57207. }
  57208. public function getApplication()
  57209. {
  57210. return $this->application;
  57211. }
  57212. public function isEnabled()
  57213. {
  57214. return true;
  57215. }
  57216. protected function configure()
  57217. {
  57218. }
  57219. protected function execute(InputInterface $input, OutputInterface $output)
  57220. {
  57221. throw new LogicException('You must override the execute() method in the concrete command class.');
  57222. }
  57223. protected function interact(InputInterface $input, OutputInterface $output)
  57224. {
  57225. }
  57226. protected function initialize(InputInterface $input, OutputInterface $output)
  57227. {
  57228. }
  57229. public function run(InputInterface $input, OutputInterface $output)
  57230. {
  57231. $this->mergeApplicationDefinition();
  57232. try {
  57233. $input->bind($this->getDefinition());
  57234. } catch (ExceptionInterface $e) {
  57235. if (!$this->ignoreValidationErrors) {
  57236. throw $e;
  57237. }
  57238. }
  57239. $this->initialize($input, $output);
  57240. if (null !== $this->processTitle) {
  57241. if (\function_exists('cli_set_process_title')) {
  57242. if (!@cli_set_process_title($this->processTitle)) {
  57243. if ('Darwin' === \PHP_OS) {
  57244. $output->writeln('<comment>Running "cli_set_process_title" as an unprivileged user is not supported on MacOS.</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE);
  57245. } else {
  57246. cli_set_process_title($this->processTitle);
  57247. }
  57248. }
  57249. } elseif (\function_exists('setproctitle')) {
  57250. setproctitle($this->processTitle);
  57251. } elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) {
  57252. $output->writeln('<comment>Install the proctitle PECL to be able to change the process title.</comment>');
  57253. }
  57254. }
  57255. if ($input->isInteractive()) {
  57256. $this->interact($input, $output);
  57257. }
  57258. if ($input->hasArgument('command') && null === $input->getArgument('command')) {
  57259. $input->setArgument('command', $this->getName());
  57260. }
  57261. $input->validate();
  57262. if ($this->code) {
  57263. $statusCode = ($this->code)($input, $output);
  57264. } else {
  57265. $statusCode = $this->execute($input, $output);
  57266. if (!\is_int($statusCode)) {
  57267. throw new \TypeError(sprintf('Return value of "%s::execute()" must be of the type int, "%s" returned.', static::class, get_debug_type($statusCode)));
  57268. }
  57269. }
  57270. return is_numeric($statusCode) ? (int) $statusCode : 0;
  57271. }
  57272. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  57273. {
  57274. }
  57275. public function setCode(callable $code)
  57276. {
  57277. if ($code instanceof \Closure) {
  57278. $r = new \ReflectionFunction($code);
  57279. if (null === $r->getClosureThis()) {
  57280. set_error_handler(static function () {});
  57281. try {
  57282. if ($c = \Closure::bind($code, $this)) {
  57283. $code = $c;
  57284. }
  57285. } finally {
  57286. restore_error_handler();
  57287. }
  57288. }
  57289. }
  57290. $this->code = $code;
  57291. return $this;
  57292. }
  57293. public function mergeApplicationDefinition(bool $mergeArgs = true)
  57294. {
  57295. if (null === $this->application) {
  57296. return;
  57297. }
  57298. $this->fullDefinition = new InputDefinition();
  57299. $this->fullDefinition->setOptions($this->definition->getOptions());
  57300. $this->fullDefinition->addOptions($this->application->getDefinition()->getOptions());
  57301. if ($mergeArgs) {
  57302. $this->fullDefinition->setArguments($this->application->getDefinition()->getArguments());
  57303. $this->fullDefinition->addArguments($this->definition->getArguments());
  57304. } else {
  57305. $this->fullDefinition->setArguments($this->definition->getArguments());
  57306. }
  57307. }
  57308. public function setDefinition($definition)
  57309. {
  57310. if ($definition instanceof InputDefinition) {
  57311. $this->definition = $definition;
  57312. } else {
  57313. $this->definition->setDefinition($definition);
  57314. }
  57315. $this->fullDefinition = null;
  57316. return $this;
  57317. }
  57318. public function getDefinition()
  57319. {
  57320. return $this->fullDefinition ?? $this->getNativeDefinition();
  57321. }
  57322. public function getNativeDefinition()
  57323. {
  57324. if (null === $this->definition) {
  57325. throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', static::class));
  57326. }
  57327. return $this->definition;
  57328. }
  57329. public function addArgument(string $name, int $mode = null, string $description = '', $default = null)
  57330. {
  57331. $this->definition->addArgument(new InputArgument($name, $mode, $description, $default));
  57332. if (null !== $this->fullDefinition) {
  57333. $this->fullDefinition->addArgument(new InputArgument($name, $mode, $description, $default));
  57334. }
  57335. return $this;
  57336. }
  57337. public function addOption(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null)
  57338. {
  57339. $this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default));
  57340. if (null !== $this->fullDefinition) {
  57341. $this->fullDefinition->addOption(new InputOption($name, $shortcut, $mode, $description, $default));
  57342. }
  57343. return $this;
  57344. }
  57345. public function setName(string $name)
  57346. {
  57347. $this->validateName($name);
  57348. $this->name = $name;
  57349. return $this;
  57350. }
  57351. public function setProcessTitle(string $title)
  57352. {
  57353. $this->processTitle = $title;
  57354. return $this;
  57355. }
  57356. public function getName()
  57357. {
  57358. return $this->name;
  57359. }
  57360. public function setHidden(bool $hidden )
  57361. {
  57362. $this->hidden = $hidden;
  57363. return $this;
  57364. }
  57365. public function isHidden()
  57366. {
  57367. return $this->hidden;
  57368. }
  57369. public function setDescription(string $description)
  57370. {
  57371. $this->description = $description;
  57372. return $this;
  57373. }
  57374. public function getDescription()
  57375. {
  57376. return $this->description;
  57377. }
  57378. public function setHelp(string $help)
  57379. {
  57380. $this->help = $help;
  57381. return $this;
  57382. }
  57383. public function getHelp()
  57384. {
  57385. return $this->help;
  57386. }
  57387. public function getProcessedHelp()
  57388. {
  57389. $name = $this->name;
  57390. $isSingleCommand = $this->application && $this->application->isSingleCommand();
  57391. $placeholders = [
  57392. '%command.name%',
  57393. '%command.full_name%',
  57394. ];
  57395. $replacements = [
  57396. $name,
  57397. $isSingleCommand ? $_SERVER['PHP_SELF'] : $_SERVER['PHP_SELF'].' '.$name,
  57398. ];
  57399. return str_replace($placeholders, $replacements, $this->getHelp() ?: $this->getDescription());
  57400. }
  57401. public function setAliases(iterable $aliases)
  57402. {
  57403. $list = [];
  57404. foreach ($aliases as $alias) {
  57405. $this->validateName($alias);
  57406. $list[] = $alias;
  57407. }
  57408. $this->aliases = \is_array($aliases) ? $aliases : $list;
  57409. return $this;
  57410. }
  57411. public function getAliases()
  57412. {
  57413. return $this->aliases;
  57414. }
  57415. public function getSynopsis(bool $short = false)
  57416. {
  57417. $key = $short ? 'short' : 'long';
  57418. if (!isset($this->synopsis[$key])) {
  57419. $this->synopsis[$key] = trim(sprintf('%s %s', $this->name, $this->definition->getSynopsis($short)));
  57420. }
  57421. return $this->synopsis[$key];
  57422. }
  57423. public function addUsage(string $usage)
  57424. {
  57425. if (!str_starts_with($usage, $this->name)) {
  57426. $usage = sprintf('%s %s', $this->name, $usage);
  57427. }
  57428. $this->usages[] = $usage;
  57429. return $this;
  57430. }
  57431. public function getUsages()
  57432. {
  57433. return $this->usages;
  57434. }
  57435. public function getHelper(string $name)
  57436. {
  57437. if (null === $this->helperSet) {
  57438. 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));
  57439. }
  57440. return $this->helperSet->get($name);
  57441. }
  57442. private function validateName(string $name)
  57443. {
  57444. if (!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) {
  57445. throw new InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name));
  57446. }
  57447. }
  57448. }
  57449. <?php
  57450. namespace Symfony\Component\Console\Command;
  57451. use Symfony\Component\Console\Completion\CompletionInput;
  57452. use Symfony\Component\Console\Completion\CompletionSuggestions;
  57453. use Symfony\Component\Console\Completion\Output\BashCompletionOutput;
  57454. use Symfony\Component\Console\Completion\Output\CompletionOutputInterface;
  57455. use Symfony\Component\Console\Exception\CommandNotFoundException;
  57456. use Symfony\Component\Console\Exception\ExceptionInterface;
  57457. use Symfony\Component\Console\Input\InputInterface;
  57458. use Symfony\Component\Console\Input\InputOption;
  57459. use Symfony\Component\Console\Output\OutputInterface;
  57460. final class CompleteCommand extends Command
  57461. {
  57462. protected static $defaultName = '|_complete';
  57463. protected static $defaultDescription = 'Internal command to provide shell completion suggestions';
  57464. private $completionOutputs;
  57465. private $isDebug = false;
  57466. public function __construct(array $completionOutputs = [])
  57467. {
  57468. $this->completionOutputs = $completionOutputs + ['bash' => BashCompletionOutput::class];
  57469. parent::__construct();
  57470. }
  57471. protected function configure(): void
  57472. {
  57473. $this
  57474. ->addOption('shell', 's', InputOption::VALUE_REQUIRED, 'The shell type ("'.implode('", "', array_keys($this->completionOutputs)).'")')
  57475. ->addOption('input', 'i', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'An array of input tokens (e.g. COMP_WORDS or argv)')
  57476. ->addOption('current', 'c', InputOption::VALUE_REQUIRED, 'The index of the "input" array that the cursor is in (e.g. COMP_CWORD)')
  57477. ->addOption('symfony', 'S', InputOption::VALUE_REQUIRED, 'The version of the completion script')
  57478. ;
  57479. }
  57480. protected function initialize(InputInterface $input, OutputInterface $output)
  57481. {
  57482. $this->isDebug = filter_var(getenv('SYMFONY_COMPLETION_DEBUG'), \FILTER_VALIDATE_BOOLEAN);
  57483. }
  57484. protected function execute(InputInterface $input, OutputInterface $output): int
  57485. {
  57486. try {
  57487. $shell = $input->getOption('shell');
  57488. if (!$shell) {
  57489. throw new \RuntimeException('The "--shell" option must be set.');
  57490. }
  57491. if (!$completionOutput = $this->completionOutputs[$shell] ?? false) {
  57492. throw new \RuntimeException(sprintf('Shell completion is not supported for your shell: "%s" (supported: "%s").', $shell, implode('", "', array_keys($this->completionOutputs))));
  57493. }
  57494. $completionInput = $this->createCompletionInput($input);
  57495. $suggestions = new CompletionSuggestions();
  57496. $this->log([
  57497. '',
  57498. '<comment>'.date('Y-m-d H:i:s').'</>',
  57499. '<info>Input:</> <comment>("|" indicates the cursor position)</>',
  57500. ' '.(string) $completionInput,
  57501. '<info>Command:</>',
  57502. ' '.(string) implode(' ', $_SERVER['argv']),
  57503. '<info>Messages:</>',
  57504. ]);
  57505. $command = $this->findCommand($completionInput, $output);
  57506. if (null === $command) {
  57507. $this->log(' No command found, completing using the Application class.');
  57508. $this->getApplication()->complete($completionInput, $suggestions);
  57509. } elseif (
  57510. $completionInput->mustSuggestArgumentValuesFor('command')
  57511. && $command->getName() !== $completionInput->getCompletionValue()
  57512. && !\in_array($completionInput->getCompletionValue(), $command->getAliases(), true)
  57513. ) {
  57514. $this->log(' No command found, completing using the Application class.');
  57515. $suggestions->suggestValues(array_filter(array_merge([$command->getName()], $command->getAliases())));
  57516. } else {
  57517. $command->mergeApplicationDefinition();
  57518. $completionInput->bind($command->getDefinition());
  57519. if (CompletionInput::TYPE_OPTION_NAME === $completionInput->getCompletionType()) {
  57520. $this->log(' Completing option names for the <comment>'.\get_class($command instanceof LazyCommand ? $command->getCommand() : $command).'</> command.');
  57521. $suggestions->suggestOptions($command->getDefinition()->getOptions());
  57522. } else {
  57523. $this->log([
  57524. ' Completing using the <comment>'.\get_class($command instanceof LazyCommand ? $command->getCommand() : $command).'</> class.',
  57525. ' Completing <comment>'.$completionInput->getCompletionType().'</> for <comment>'.$completionInput->getCompletionName().'</>',
  57526. ]);
  57527. if (null !== $compval = $completionInput->getCompletionValue()) {
  57528. $this->log(' Current value: <comment>'.$compval.'</>');
  57529. }
  57530. $command->complete($completionInput, $suggestions);
  57531. }
  57532. }
  57533. $completionOutput = new $completionOutput();
  57534. $this->log('<info>Suggestions:</>');
  57535. if ($options = $suggestions->getOptionSuggestions()) {
  57536. $this->log(' --'.implode(' --', array_map(function ($o) { return $o->getName(); }, $options)));
  57537. } elseif ($values = $suggestions->getValueSuggestions()) {
  57538. $this->log(' '.implode(' ', $values));
  57539. } else {
  57540. $this->log(' <comment>No suggestions were provided</>');
  57541. }
  57542. $completionOutput->write($suggestions, $output);
  57543. } catch (\Throwable $e) {
  57544. $this->log([
  57545. '<error>Error!</error>',
  57546. (string) $e,
  57547. ]);
  57548. if ($output->isDebug()) {
  57549. throw $e;
  57550. }
  57551. return 2;
  57552. }
  57553. return 0;
  57554. }
  57555. private function createCompletionInput(InputInterface $input): CompletionInput
  57556. {
  57557. $currentIndex = $input->getOption('current');
  57558. if (!$currentIndex || !ctype_digit($currentIndex)) {
  57559. throw new \RuntimeException('The "--current" option must be set and it must be an integer.');
  57560. }
  57561. $completionInput = CompletionInput::fromTokens($input->getOption('input'), (int) $currentIndex);
  57562. try {
  57563. $completionInput->bind($this->getApplication()->getDefinition());
  57564. } catch (ExceptionInterface $e) {
  57565. }
  57566. return $completionInput;
  57567. }
  57568. private function findCommand(CompletionInput $completionInput, OutputInterface $output): ?Command
  57569. {
  57570. try {
  57571. $inputName = $completionInput->getFirstArgument();
  57572. if (null === $inputName) {
  57573. return null;
  57574. }
  57575. return $this->getApplication()->find($inputName);
  57576. } catch (CommandNotFoundException $e) {
  57577. }
  57578. return null;
  57579. }
  57580. private function log($messages): void
  57581. {
  57582. if (!$this->isDebug) {
  57583. return;
  57584. }
  57585. $commandName = basename($_SERVER['argv'][0]);
  57586. file_put_contents(sys_get_temp_dir().'/sf_'.$commandName.'.log', implode(\PHP_EOL, (array) $messages).\PHP_EOL, \FILE_APPEND);
  57587. }
  57588. }
  57589. <?php
  57590. namespace Symfony\Component\Console\Command;
  57591. use Symfony\Component\Console\Completion\CompletionInput;
  57592. use Symfony\Component\Console\Completion\CompletionSuggestions;
  57593. use Symfony\Component\Console\Input\InputArgument;
  57594. use Symfony\Component\Console\Input\InputInterface;
  57595. use Symfony\Component\Console\Input\InputOption;
  57596. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  57597. use Symfony\Component\Console\Output\OutputInterface;
  57598. use Symfony\Component\Process\Process;
  57599. final class DumpCompletionCommand extends Command
  57600. {
  57601. protected static $defaultName = 'completion';
  57602. protected static $defaultDescription = 'Dump the shell completion script';
  57603. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  57604. {
  57605. if ($input->mustSuggestArgumentValuesFor('shell')) {
  57606. $suggestions->suggestValues($this->getSupportedShells());
  57607. }
  57608. }
  57609. protected function configure()
  57610. {
  57611. $fullCommand = $_SERVER['PHP_SELF'];
  57612. $commandName = basename($fullCommand);
  57613. $fullCommand = @realpath($fullCommand) ?: $fullCommand;
  57614. $this
  57615. ->setHelp(<<<EOH
  57616. The <info>%command.name%</> command dumps the shell completion script required
  57617. to use shell autocompletion (currently only bash completion is supported).
  57618. <comment>Static installation
  57619. -------------------</>
  57620. Dump the script to a global completion file and restart your shell:
  57621. <info>%command.full_name% bash | sudo tee /etc/bash_completion.d/{$commandName}</>
  57622. Or dump the script to a local file and source it:
  57623. <info>%command.full_name% bash > completion.sh</>
  57624. <comment># source the file whenever you use the project</>
  57625. <info>source completion.sh</>
  57626. <comment># or add this line at the end of your "~/.bashrc" file:</>
  57627. <info>source /path/to/completion.sh</>
  57628. <comment>Dynamic installation
  57629. --------------------</>
  57630. Add this to the end of your shell configuration file (e.g. <info>"~/.bashrc"</>):
  57631. <info>eval "$({$fullCommand} completion bash)"</>
  57632. EOH
  57633. )
  57634. ->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')
  57635. ->addOption('debug', null, InputOption::VALUE_NONE, 'Tail the completion debug log')
  57636. ;
  57637. }
  57638. protected function execute(InputInterface $input, OutputInterface $output): int
  57639. {
  57640. $commandName = basename($_SERVER['argv'][0]);
  57641. if ($input->getOption('debug')) {
  57642. $this->tailDebugLog($commandName, $output);
  57643. return 0;
  57644. }
  57645. $shell = $input->getArgument('shell') ?? self::guessShell();
  57646. $completionFile = __DIR__.'/../Resources/completion.'.$shell;
  57647. if (!file_exists($completionFile)) {
  57648. $supportedShells = $this->getSupportedShells();
  57649. if ($output instanceof ConsoleOutputInterface) {
  57650. $output = $output->getErrorOutput();
  57651. }
  57652. if ($shell) {
  57653. $output->writeln(sprintf('<error>Detected shell "%s", which is not supported by Symfony shell completion (supported shells: "%s").</>', $shell, implode('", "', $supportedShells)));
  57654. } else {
  57655. $output->writeln(sprintf('<error>Shell not detected, Symfony shell completion only supports "%s").</>', implode('", "', $supportedShells)));
  57656. }
  57657. return 2;
  57658. }
  57659. $output->write(str_replace(['{{ COMMAND_NAME }}', '{{ VERSION }}'], [$commandName, $this->getApplication()->getVersion()], file_get_contents($completionFile)));
  57660. return 0;
  57661. }
  57662. private static function guessShell(): string
  57663. {
  57664. return basename($_SERVER['SHELL'] ?? '');
  57665. }
  57666. private function tailDebugLog(string $commandName, OutputInterface $output): void
  57667. {
  57668. $debugFile = sys_get_temp_dir().'/sf_'.$commandName.'.log';
  57669. if (!file_exists($debugFile)) {
  57670. touch($debugFile);
  57671. }
  57672. $process = new Process(['tail', '-f', $debugFile], null, null, null, 0);
  57673. $process->run(function (string $type, string $line) use ($output): void {
  57674. $output->write($line);
  57675. });
  57676. }
  57677. private function getSupportedShells(): array
  57678. {
  57679. $shells = [];
  57680. foreach (new \DirectoryIterator(__DIR__.'/../Resources/') as $file) {
  57681. if (str_starts_with($file->getBasename(), 'completion.') && $file->isFile()) {
  57682. $shells[] = $file->getExtension();
  57683. }
  57684. }
  57685. return $shells;
  57686. }
  57687. }
  57688. <?php
  57689. namespace Symfony\Component\Console\Command;
  57690. use Symfony\Component\Console\Completion\CompletionInput;
  57691. use Symfony\Component\Console\Completion\CompletionSuggestions;
  57692. use Symfony\Component\Console\Descriptor\ApplicationDescription;
  57693. use Symfony\Component\Console\Helper\DescriptorHelper;
  57694. use Symfony\Component\Console\Input\InputArgument;
  57695. use Symfony\Component\Console\Input\InputInterface;
  57696. use Symfony\Component\Console\Input\InputOption;
  57697. use Symfony\Component\Console\Output\OutputInterface;
  57698. class HelpCommand extends Command
  57699. {
  57700. private $command;
  57701. protected function configure()
  57702. {
  57703. $this->ignoreValidationErrors();
  57704. $this
  57705. ->setName('help')
  57706. ->setDefinition([
  57707. new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'),
  57708. new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
  57709. new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'),
  57710. ])
  57711. ->setDescription('Display help for a command')
  57712. ->setHelp(<<<'EOF'
  57713. The <info>%command.name%</info> command displays help for a given command:
  57714. <info>%command.full_name% list</info>
  57715. You can also output the help in other formats by using the <comment>--format</comment> option:
  57716. <info>%command.full_name% --format=xml list</info>
  57717. To display the list of available commands, please use the <info>list</info> command.
  57718. EOF
  57719. )
  57720. ;
  57721. }
  57722. public function setCommand(Command $command)
  57723. {
  57724. $this->command = $command;
  57725. }
  57726. protected function execute(InputInterface $input, OutputInterface $output)
  57727. {
  57728. if (null === $this->command) {
  57729. $this->command = $this->getApplication()->find($input->getArgument('command_name'));
  57730. }
  57731. $helper = new DescriptorHelper();
  57732. $helper->describe($output, $this->command, [
  57733. 'format' => $input->getOption('format'),
  57734. 'raw_text' => $input->getOption('raw'),
  57735. ]);
  57736. $this->command = null;
  57737. return 0;
  57738. }
  57739. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  57740. {
  57741. if ($input->mustSuggestArgumentValuesFor('command_name')) {
  57742. $descriptor = new ApplicationDescription($this->getApplication());
  57743. $suggestions->suggestValues(array_keys($descriptor->getCommands()));
  57744. return;
  57745. }
  57746. if ($input->mustSuggestOptionValuesFor('format')) {
  57747. $helper = new DescriptorHelper();
  57748. $suggestions->suggestValues($helper->getFormats());
  57749. }
  57750. }
  57751. }
  57752. <?php
  57753. namespace Symfony\Component\Console\Command;
  57754. use Symfony\Component\Console\Application;
  57755. use Symfony\Component\Console\Completion\CompletionInput;
  57756. use Symfony\Component\Console\Completion\CompletionSuggestions;
  57757. use Symfony\Component\Console\Helper\HelperSet;
  57758. use Symfony\Component\Console\Input\InputDefinition;
  57759. use Symfony\Component\Console\Input\InputInterface;
  57760. use Symfony\Component\Console\Output\OutputInterface;
  57761. final class LazyCommand extends Command
  57762. {
  57763. private $command;
  57764. private $isEnabled;
  57765. public function __construct(string $name, array $aliases, string $description, bool $isHidden, \Closure $commandFactory, ?bool $isEnabled = true)
  57766. {
  57767. $this->setName($name)
  57768. ->setAliases($aliases)
  57769. ->setHidden($isHidden)
  57770. ->setDescription($description);
  57771. $this->command = $commandFactory;
  57772. $this->isEnabled = $isEnabled;
  57773. }
  57774. public function ignoreValidationErrors(): void
  57775. {
  57776. $this->getCommand()->ignoreValidationErrors();
  57777. }
  57778. public function setApplication(Application $application = null): void
  57779. {
  57780. if ($this->command instanceof parent) {
  57781. $this->command->setApplication($application);
  57782. }
  57783. parent::setApplication($application);
  57784. }
  57785. public function setHelperSet(HelperSet $helperSet): void
  57786. {
  57787. if ($this->command instanceof parent) {
  57788. $this->command->setHelperSet($helperSet);
  57789. }
  57790. parent::setHelperSet($helperSet);
  57791. }
  57792. public function isEnabled(): bool
  57793. {
  57794. return $this->isEnabled ?? $this->getCommand()->isEnabled();
  57795. }
  57796. public function run(InputInterface $input, OutputInterface $output): int
  57797. {
  57798. return $this->getCommand()->run($input, $output);
  57799. }
  57800. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  57801. {
  57802. $this->getCommand()->complete($input, $suggestions);
  57803. }
  57804. public function setCode(callable $code): self
  57805. {
  57806. $this->getCommand()->setCode($code);
  57807. return $this;
  57808. }
  57809. public function mergeApplicationDefinition(bool $mergeArgs = true): void
  57810. {
  57811. $this->getCommand()->mergeApplicationDefinition($mergeArgs);
  57812. }
  57813. public function setDefinition($definition): self
  57814. {
  57815. $this->getCommand()->setDefinition($definition);
  57816. return $this;
  57817. }
  57818. public function getDefinition(): InputDefinition
  57819. {
  57820. return $this->getCommand()->getDefinition();
  57821. }
  57822. public function getNativeDefinition(): InputDefinition
  57823. {
  57824. return $this->getCommand()->getNativeDefinition();
  57825. }
  57826. public function addArgument(string $name, int $mode = null, string $description = '', $default = null): self
  57827. {
  57828. $this->getCommand()->addArgument($name, $mode, $description, $default);
  57829. return $this;
  57830. }
  57831. public function addOption(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null): self
  57832. {
  57833. $this->getCommand()->addOption($name, $shortcut, $mode, $description, $default);
  57834. return $this;
  57835. }
  57836. public function setProcessTitle(string $title): self
  57837. {
  57838. $this->getCommand()->setProcessTitle($title);
  57839. return $this;
  57840. }
  57841. public function setHelp(string $help): self
  57842. {
  57843. $this->getCommand()->setHelp($help);
  57844. return $this;
  57845. }
  57846. public function getHelp(): string
  57847. {
  57848. return $this->getCommand()->getHelp();
  57849. }
  57850. public function getProcessedHelp(): string
  57851. {
  57852. return $this->getCommand()->getProcessedHelp();
  57853. }
  57854. public function getSynopsis(bool $short = false): string
  57855. {
  57856. return $this->getCommand()->getSynopsis($short);
  57857. }
  57858. public function addUsage(string $usage): self
  57859. {
  57860. $this->getCommand()->addUsage($usage);
  57861. return $this;
  57862. }
  57863. public function getUsages(): array
  57864. {
  57865. return $this->getCommand()->getUsages();
  57866. }
  57867. public function getHelper(string $name)
  57868. {
  57869. return $this->getCommand()->getHelper($name);
  57870. }
  57871. public function getCommand(): parent
  57872. {
  57873. if (!$this->command instanceof \Closure) {
  57874. return $this->command;
  57875. }
  57876. $command = $this->command = ($this->command)();
  57877. $command->setApplication($this->getApplication());
  57878. if (null !== $this->getHelperSet()) {
  57879. $command->setHelperSet($this->getHelperSet());
  57880. }
  57881. $command->setName($this->getName())
  57882. ->setAliases($this->getAliases())
  57883. ->setHidden($this->isHidden())
  57884. ->setDescription($this->getDescription());
  57885. $command->getDefinition();
  57886. return $command;
  57887. }
  57888. }
  57889. <?php
  57890. namespace Symfony\Component\Console\Command;
  57891. use Symfony\Component\Console\Completion\CompletionInput;
  57892. use Symfony\Component\Console\Completion\CompletionSuggestions;
  57893. use Symfony\Component\Console\Descriptor\ApplicationDescription;
  57894. use Symfony\Component\Console\Helper\DescriptorHelper;
  57895. use Symfony\Component\Console\Input\InputArgument;
  57896. use Symfony\Component\Console\Input\InputInterface;
  57897. use Symfony\Component\Console\Input\InputOption;
  57898. use Symfony\Component\Console\Output\OutputInterface;
  57899. class ListCommand extends Command
  57900. {
  57901. protected function configure()
  57902. {
  57903. $this
  57904. ->setName('list')
  57905. ->setDefinition([
  57906. new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
  57907. new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'),
  57908. new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
  57909. new InputOption('short', null, InputOption::VALUE_NONE, 'To skip describing commands\' arguments'),
  57910. ])
  57911. ->setDescription('List commands')
  57912. ->setHelp(<<<'EOF'
  57913. The <info>%command.name%</info> command lists all commands:
  57914. <info>%command.full_name%</info>
  57915. You can also display the commands for a specific namespace:
  57916. <info>%command.full_name% test</info>
  57917. You can also output the information in other formats by using the <comment>--format</comment> option:
  57918. <info>%command.full_name% --format=xml</info>
  57919. It's also possible to get raw list of commands (useful for embedding command runner):
  57920. <info>%command.full_name% --raw</info>
  57921. EOF
  57922. )
  57923. ;
  57924. }
  57925. protected function execute(InputInterface $input, OutputInterface $output)
  57926. {
  57927. $helper = new DescriptorHelper();
  57928. $helper->describe($output, $this->getApplication(), [
  57929. 'format' => $input->getOption('format'),
  57930. 'raw_text' => $input->getOption('raw'),
  57931. 'namespace' => $input->getArgument('namespace'),
  57932. 'short' => $input->getOption('short'),
  57933. ]);
  57934. return 0;
  57935. }
  57936. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  57937. {
  57938. if ($input->mustSuggestArgumentValuesFor('namespace')) {
  57939. $descriptor = new ApplicationDescription($this->getApplication());
  57940. $suggestions->suggestValues(array_keys($descriptor->getNamespaces()));
  57941. return;
  57942. }
  57943. if ($input->mustSuggestOptionValuesFor('format')) {
  57944. $helper = new DescriptorHelper();
  57945. $suggestions->suggestValues($helper->getFormats());
  57946. }
  57947. }
  57948. }
  57949. <?php
  57950. namespace Symfony\Component\Console\Command;
  57951. use Symfony\Component\Console\Exception\LogicException;
  57952. use Symfony\Component\Lock\LockFactory;
  57953. use Symfony\Component\Lock\LockInterface;
  57954. use Symfony\Component\Lock\Store\FlockStore;
  57955. use Symfony\Component\Lock\Store\SemaphoreStore;
  57956. trait LockableTrait
  57957. {
  57958. private $lock;
  57959. private function lock(string $name = null, bool $blocking = false): bool
  57960. {
  57961. if (!class_exists(SemaphoreStore::class)) {
  57962. throw new LogicException('To enable the locking feature you must install the symfony/lock component.');
  57963. }
  57964. if (null !== $this->lock) {
  57965. throw new LogicException('A lock is already in place.');
  57966. }
  57967. if (SemaphoreStore::isSupported()) {
  57968. $store = new SemaphoreStore();
  57969. } else {
  57970. $store = new FlockStore();
  57971. }
  57972. $this->lock = (new LockFactory($store))->createLock($name ?: $this->getName());
  57973. if (!$this->lock->acquire($blocking)) {
  57974. $this->lock = null;
  57975. return false;
  57976. }
  57977. return true;
  57978. }
  57979. private function release()
  57980. {
  57981. if ($this->lock) {
  57982. $this->lock->release();
  57983. $this->lock = null;
  57984. }
  57985. }
  57986. }
  57987. <?php
  57988. namespace Symfony\Component\Console\Command;
  57989. interface SignalableCommandInterface
  57990. {
  57991. public function getSubscribedSignals(): array;
  57992. public function handleSignal(int $signal): void;
  57993. }
  57994. <?php
  57995. namespace Symfony\Component\Console\CommandLoader;
  57996. use Symfony\Component\Console\Command\Command;
  57997. use Symfony\Component\Console\Exception\CommandNotFoundException;
  57998. interface CommandLoaderInterface
  57999. {
  58000. public function get(string $name);
  58001. public function has(string $name);
  58002. public function getNames();
  58003. }
  58004. <?php
  58005. namespace Symfony\Component\Console\CommandLoader;
  58006. use Psr\Container\ContainerInterface;
  58007. use Symfony\Component\Console\Exception\CommandNotFoundException;
  58008. class ContainerCommandLoader implements CommandLoaderInterface
  58009. {
  58010. private $container;
  58011. private $commandMap;
  58012. public function __construct(ContainerInterface $container, array $commandMap)
  58013. {
  58014. $this->container = $container;
  58015. $this->commandMap = $commandMap;
  58016. }
  58017. public function get(string $name)
  58018. {
  58019. if (!$this->has($name)) {
  58020. throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name));
  58021. }
  58022. return $this->container->get($this->commandMap[$name]);
  58023. }
  58024. public function has(string $name)
  58025. {
  58026. return isset($this->commandMap[$name]) && $this->container->has($this->commandMap[$name]);
  58027. }
  58028. public function getNames()
  58029. {
  58030. return array_keys($this->commandMap);
  58031. }
  58032. }
  58033. <?php
  58034. namespace Symfony\Component\Console\CommandLoader;
  58035. use Symfony\Component\Console\Exception\CommandNotFoundException;
  58036. class FactoryCommandLoader implements CommandLoaderInterface
  58037. {
  58038. private $factories;
  58039. public function __construct(array $factories)
  58040. {
  58041. $this->factories = $factories;
  58042. }
  58043. public function has(string $name)
  58044. {
  58045. return isset($this->factories[$name]);
  58046. }
  58047. public function get(string $name)
  58048. {
  58049. if (!isset($this->factories[$name])) {
  58050. throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name));
  58051. }
  58052. $factory = $this->factories[$name];
  58053. return $factory();
  58054. }
  58055. public function getNames()
  58056. {
  58057. return array_keys($this->factories);
  58058. }
  58059. }
  58060. <?php
  58061. namespace Symfony\Component\Console\Completion;
  58062. use Symfony\Component\Console\Exception\RuntimeException;
  58063. use Symfony\Component\Console\Input\ArgvInput;
  58064. use Symfony\Component\Console\Input\InputDefinition;
  58065. use Symfony\Component\Console\Input\InputOption;
  58066. final class CompletionInput extends ArgvInput
  58067. {
  58068. public const TYPE_ARGUMENT_VALUE = 'argument_value';
  58069. public const TYPE_OPTION_VALUE = 'option_value';
  58070. public const TYPE_OPTION_NAME = 'option_name';
  58071. public const TYPE_NONE = 'none';
  58072. private $tokens;
  58073. private $currentIndex;
  58074. private $completionType;
  58075. private $completionName = null;
  58076. private $completionValue = '';
  58077. public static function fromString(string $inputStr, int $currentIndex): self
  58078. {
  58079. preg_match_all('/(?<=^|\s)([\'"]?)(.+?)(?<!\\\\)\1(?=$|\s)/', $inputStr, $tokens);
  58080. return self::fromTokens($tokens[0], $currentIndex);
  58081. }
  58082. public static function fromTokens(array $tokens, int $currentIndex): self
  58083. {
  58084. $input = new self($tokens);
  58085. $input->tokens = $tokens;
  58086. $input->currentIndex = $currentIndex;
  58087. return $input;
  58088. }
  58089. public function bind(InputDefinition $definition): void
  58090. {
  58091. parent::bind($definition);
  58092. $relevantToken = $this->getRelevantToken();
  58093. if ('-' === $relevantToken[0]) {
  58094. [$optionToken, $optionValue] = explode('=', $relevantToken, 2) + ['', ''];
  58095. $option = $this->getOptionFromToken($optionToken);
  58096. if (null === $option && !$this->isCursorFree()) {
  58097. $this->completionType = self::TYPE_OPTION_NAME;
  58098. $this->completionValue = $relevantToken;
  58099. return;
  58100. }
  58101. if (null !== $option && $option->acceptValue()) {
  58102. $this->completionType = self::TYPE_OPTION_VALUE;
  58103. $this->completionName = $option->getName();
  58104. $this->completionValue = $optionValue ?: (!str_starts_with($optionToken, '--') ? substr($optionToken, 2) : '');
  58105. return;
  58106. }
  58107. }
  58108. $previousToken = $this->tokens[$this->currentIndex - 1];
  58109. if ('-' === $previousToken[0] && '' !== trim($previousToken, '-')) {
  58110. $previousOption = $this->getOptionFromToken($previousToken);
  58111. if (null !== $previousOption && $previousOption->acceptValue()) {
  58112. $this->completionType = self::TYPE_OPTION_VALUE;
  58113. $this->completionName = $previousOption->getName();
  58114. $this->completionValue = $relevantToken;
  58115. return;
  58116. }
  58117. }
  58118. $this->completionType = self::TYPE_ARGUMENT_VALUE;
  58119. foreach ($this->definition->getArguments() as $argumentName => $argument) {
  58120. if (!isset($this->arguments[$argumentName])) {
  58121. break;
  58122. }
  58123. $argumentValue = $this->arguments[$argumentName];
  58124. $this->completionName = $argumentName;
  58125. if (\is_array($argumentValue)) {
  58126. $this->completionValue = $argumentValue ? $argumentValue[array_key_last($argumentValue)] : null;
  58127. } else {
  58128. $this->completionValue = $argumentValue;
  58129. }
  58130. }
  58131. if ($this->currentIndex >= \count($this->tokens)) {
  58132. if (!isset($this->arguments[$argumentName]) || $this->definition->getArgument($argumentName)->isArray()) {
  58133. $this->completionName = $argumentName;
  58134. $this->completionValue = '';
  58135. } else {
  58136. $this->completionType = self::TYPE_NONE;
  58137. $this->completionName = null;
  58138. $this->completionValue = '';
  58139. }
  58140. }
  58141. }
  58142. public function getCompletionType(): string
  58143. {
  58144. return $this->completionType;
  58145. }
  58146. public function getCompletionName(): ?string
  58147. {
  58148. return $this->completionName;
  58149. }
  58150. public function getCompletionValue(): string
  58151. {
  58152. return $this->completionValue;
  58153. }
  58154. public function mustSuggestOptionValuesFor(string $optionName): bool
  58155. {
  58156. return self::TYPE_OPTION_VALUE === $this->getCompletionType() && $optionName === $this->getCompletionName();
  58157. }
  58158. public function mustSuggestArgumentValuesFor(string $argumentName): bool
  58159. {
  58160. return self::TYPE_ARGUMENT_VALUE === $this->getCompletionType() && $argumentName === $this->getCompletionName();
  58161. }
  58162. protected function parseToken(string $token, bool $parseOptions): bool
  58163. {
  58164. try {
  58165. return parent::parseToken($token, $parseOptions);
  58166. } catch (RuntimeException $e) {
  58167. }
  58168. return $parseOptions;
  58169. }
  58170. private function getOptionFromToken(string $optionToken): ?InputOption
  58171. {
  58172. $optionName = ltrim($optionToken, '-');
  58173. if (!$optionName) {
  58174. return null;
  58175. }
  58176. if ('-' === ($optionToken[1] ?? ' ')) {
  58177. return $this->definition->hasOption($optionName) ? $this->definition->getOption($optionName) : null;
  58178. }
  58179. return $this->definition->hasShortcut($optionName[0]) ? $this->definition->getOptionForShortcut($optionName[0]) : null;
  58180. }
  58181. private function getRelevantToken(): string
  58182. {
  58183. return $this->tokens[$this->isCursorFree() ? $this->currentIndex - 1 : $this->currentIndex];
  58184. }
  58185. private function isCursorFree(): bool
  58186. {
  58187. $nrOfTokens = \count($this->tokens);
  58188. if ($this->currentIndex > $nrOfTokens) {
  58189. throw new \LogicException('Current index is invalid, it must be the number of input tokens or one more.');
  58190. }
  58191. return $this->currentIndex >= $nrOfTokens;
  58192. }
  58193. public function __toString()
  58194. {
  58195. $str = '';
  58196. foreach ($this->tokens as $i => $token) {
  58197. $str .= $token;
  58198. if ($this->currentIndex === $i) {
  58199. $str .= '|';
  58200. }
  58201. $str .= ' ';
  58202. }
  58203. if ($this->currentIndex > $i) {
  58204. $str .= '|';
  58205. }
  58206. return rtrim($str);
  58207. }
  58208. }
  58209. <?php
  58210. namespace Symfony\Component\Console\Completion;
  58211. use Symfony\Component\Console\Input\InputOption;
  58212. final class CompletionSuggestions
  58213. {
  58214. private $valueSuggestions = [];
  58215. private $optionSuggestions = [];
  58216. public function suggestValue($value): self
  58217. {
  58218. $this->valueSuggestions[] = !$value instanceof Suggestion ? new Suggestion($value) : $value;
  58219. return $this;
  58220. }
  58221. public function suggestValues(array $values): self
  58222. {
  58223. foreach ($values as $value) {
  58224. $this->suggestValue($value);
  58225. }
  58226. return $this;
  58227. }
  58228. public function suggestOption(InputOption $option): self
  58229. {
  58230. $this->optionSuggestions[] = $option;
  58231. return $this;
  58232. }
  58233. public function suggestOptions(array $options): self
  58234. {
  58235. foreach ($options as $option) {
  58236. $this->suggestOption($option);
  58237. }
  58238. return $this;
  58239. }
  58240. public function getOptionSuggestions(): array
  58241. {
  58242. return $this->optionSuggestions;
  58243. }
  58244. public function getValueSuggestions(): array
  58245. {
  58246. return $this->valueSuggestions;
  58247. }
  58248. }
  58249. <?php
  58250. namespace Symfony\Component\Console\Completion\Output;
  58251. use Symfony\Component\Console\Completion\CompletionSuggestions;
  58252. use Symfony\Component\Console\Output\OutputInterface;
  58253. class BashCompletionOutput implements CompletionOutputInterface
  58254. {
  58255. public function write(CompletionSuggestions $suggestions, OutputInterface $output): void
  58256. {
  58257. $values = $suggestions->getValueSuggestions();
  58258. foreach ($suggestions->getOptionSuggestions() as $option) {
  58259. $values[] = '--'.$option->getName();
  58260. if ($option->isNegatable()) {
  58261. $values[] = '--no-'.$option->getName();
  58262. }
  58263. }
  58264. $output->writeln(implode("\n", $values));
  58265. }
  58266. }
  58267. <?php
  58268. namespace Symfony\Component\Console\Completion\Output;
  58269. use Symfony\Component\Console\Completion\CompletionSuggestions;
  58270. use Symfony\Component\Console\Output\OutputInterface;
  58271. interface CompletionOutputInterface
  58272. {
  58273. public function write(CompletionSuggestions $suggestions, OutputInterface $output): void;
  58274. }
  58275. <?php
  58276. namespace Symfony\Component\Console\Completion;
  58277. class Suggestion
  58278. {
  58279. private $value;
  58280. public function __construct(string $value)
  58281. {
  58282. $this->value = $value;
  58283. }
  58284. public function getValue(): string
  58285. {
  58286. return $this->value;
  58287. }
  58288. public function __toString(): string
  58289. {
  58290. return $this->getValue();
  58291. }
  58292. }
  58293. <?php
  58294. namespace Symfony\Component\Console;
  58295. use Symfony\Component\Console\Event\ConsoleCommandEvent;
  58296. use Symfony\Component\Console\Event\ConsoleErrorEvent;
  58297. use Symfony\Component\Console\Event\ConsoleSignalEvent;
  58298. use Symfony\Component\Console\Event\ConsoleTerminateEvent;
  58299. final class ConsoleEvents
  58300. {
  58301. public const COMMAND = 'console.command';
  58302. public const SIGNAL = 'console.signal';
  58303. public const TERMINATE = 'console.terminate';
  58304. public const ERROR = 'console.error';
  58305. public const ALIASES = [
  58306. ConsoleCommandEvent::class => self::COMMAND,
  58307. ConsoleErrorEvent::class => self::ERROR,
  58308. ConsoleSignalEvent::class => self::SIGNAL,
  58309. ConsoleTerminateEvent::class => self::TERMINATE,
  58310. ];
  58311. }
  58312. <?php
  58313. namespace Symfony\Component\Console;
  58314. use Symfony\Component\Console\Output\OutputInterface;
  58315. final class Cursor
  58316. {
  58317. private $output;
  58318. private $input;
  58319. public function __construct(OutputInterface $output, $input = null)
  58320. {
  58321. $this->output = $output;
  58322. $this->input = $input ?? (\defined('STDIN') ? \STDIN : fopen('php://input', 'r+'));
  58323. }
  58324. public function moveUp(int $lines = 1): self
  58325. {
  58326. $this->output->write(sprintf("\x1b[%dA", $lines));
  58327. return $this;
  58328. }
  58329. public function moveDown(int $lines = 1): self
  58330. {
  58331. $this->output->write(sprintf("\x1b[%dB", $lines));
  58332. return $this;
  58333. }
  58334. public function moveRight(int $columns = 1): self
  58335. {
  58336. $this->output->write(sprintf("\x1b[%dC", $columns));
  58337. return $this;
  58338. }
  58339. public function moveLeft(int $columns = 1): self
  58340. {
  58341. $this->output->write(sprintf("\x1b[%dD", $columns));
  58342. return $this;
  58343. }
  58344. public function moveToColumn(int $column): self
  58345. {
  58346. $this->output->write(sprintf("\x1b[%dG", $column));
  58347. return $this;
  58348. }
  58349. public function moveToPosition(int $column, int $row): self
  58350. {
  58351. $this->output->write(sprintf("\x1b[%d;%dH", $row + 1, $column));
  58352. return $this;
  58353. }
  58354. public function savePosition(): self
  58355. {
  58356. $this->output->write("\x1b7");
  58357. return $this;
  58358. }
  58359. public function restorePosition(): self
  58360. {
  58361. $this->output->write("\x1b8");
  58362. return $this;
  58363. }
  58364. public function hide(): self
  58365. {
  58366. $this->output->write("\x1b[?25l");
  58367. return $this;
  58368. }
  58369. public function show(): self
  58370. {
  58371. $this->output->write("\x1b[?25h\x1b[?0c");
  58372. return $this;
  58373. }
  58374. public function clearLine(): self
  58375. {
  58376. $this->output->write("\x1b[2K");
  58377. return $this;
  58378. }
  58379. public function clearLineAfter(): self
  58380. {
  58381. $this->output->write("\x1b[K");
  58382. return $this;
  58383. }
  58384. public function clearOutput(): self
  58385. {
  58386. $this->output->write("\x1b[0J");
  58387. return $this;
  58388. }
  58389. public function clearScreen(): self
  58390. {
  58391. $this->output->write("\x1b[2J");
  58392. return $this;
  58393. }
  58394. public function getCurrentPosition(): array
  58395. {
  58396. static $isTtySupported;
  58397. if (null === $isTtySupported && \function_exists('proc_open')) {
  58398. $isTtySupported = (bool) @proc_open('echo 1 >/dev/null', [['file', '/dev/tty', 'r'], ['file', '/dev/tty', 'w'], ['file', '/dev/tty', 'w']], $pipes);
  58399. }
  58400. if (!$isTtySupported) {
  58401. return [1, 1];
  58402. }
  58403. $sttyMode = shell_exec('stty -g');
  58404. shell_exec('stty -icanon -echo');
  58405. @fwrite($this->input, "\033[6n");
  58406. $code = trim(fread($this->input, 1024));
  58407. shell_exec(sprintf('stty %s', $sttyMode));
  58408. sscanf($code, "\033[%d;%dR", $row, $col);
  58409. return [$col, $row];
  58410. }
  58411. }
  58412. <?php
  58413. namespace Symfony\Component\Console\DependencyInjection;
  58414. use Symfony\Component\Console\Command\Command;
  58415. use Symfony\Component\Console\Command\LazyCommand;
  58416. use Symfony\Component\Console\CommandLoader\ContainerCommandLoader;
  58417. use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
  58418. use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
  58419. use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
  58420. use Symfony\Component\DependencyInjection\ContainerBuilder;
  58421. use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
  58422. use Symfony\Component\DependencyInjection\Reference;
  58423. use Symfony\Component\DependencyInjection\TypedReference;
  58424. class AddConsoleCommandPass implements CompilerPassInterface
  58425. {
  58426. private $commandLoaderServiceId;
  58427. private $commandTag;
  58428. private $noPreloadTag;
  58429. private $privateTagName;
  58430. public function __construct(string $commandLoaderServiceId = 'console.command_loader', string $commandTag = 'console.command', string $noPreloadTag = 'container.no_preload', string $privateTagName = 'container.private')
  58431. {
  58432. if (0 < \func_num_args()) {
  58433. trigger_deprecation('symfony/console', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);
  58434. }
  58435. $this->commandLoaderServiceId = $commandLoaderServiceId;
  58436. $this->commandTag = $commandTag;
  58437. $this->noPreloadTag = $noPreloadTag;
  58438. $this->privateTagName = $privateTagName;
  58439. }
  58440. public function process(ContainerBuilder $container)
  58441. {
  58442. $commandServices = $container->findTaggedServiceIds($this->commandTag, true);
  58443. $lazyCommandMap = [];
  58444. $lazyCommandRefs = [];
  58445. $serviceIds = [];
  58446. foreach ($commandServices as $id => $tags) {
  58447. $definition = $container->getDefinition($id);
  58448. $definition->addTag($this->noPreloadTag);
  58449. $class = $container->getParameterBag()->resolveValue($definition->getClass());
  58450. if (isset($tags[0]['command'])) {
  58451. $aliases = $tags[0]['command'];
  58452. } else {
  58453. if (!$r = $container->getReflectionClass($class)) {
  58454. throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id));
  58455. }
  58456. if (!$r->isSubclassOf(Command::class)) {
  58457. throw new InvalidArgumentException(sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, $this->commandTag, Command::class));
  58458. }
  58459. $aliases = str_replace('%', '%%', $class::getDefaultName() ?? '');
  58460. }
  58461. $aliases = explode('|', $aliases ?? '');
  58462. $commandName = array_shift($aliases);
  58463. if ($isHidden = '' === $commandName) {
  58464. $commandName = array_shift($aliases);
  58465. }
  58466. if (null === $commandName) {
  58467. if (!$definition->isPublic() || $definition->isPrivate() || $definition->hasTag($this->privateTagName)) {
  58468. $commandId = 'console.command.public_alias.'.$id;
  58469. $container->setAlias($commandId, $id)->setPublic(true);
  58470. $id = $commandId;
  58471. }
  58472. $serviceIds[] = $id;
  58473. continue;
  58474. }
  58475. $description = $tags[0]['description'] ?? null;
  58476. unset($tags[0]);
  58477. $lazyCommandMap[$commandName] = $id;
  58478. $lazyCommandRefs[$id] = new TypedReference($id, $class);
  58479. foreach ($aliases as $alias) {
  58480. $lazyCommandMap[$alias] = $id;
  58481. }
  58482. foreach ($tags as $tag) {
  58483. if (isset($tag['command'])) {
  58484. $aliases[] = $tag['command'];
  58485. $lazyCommandMap[$tag['command']] = $id;
  58486. }
  58487. $description = $description ?? $tag['description'] ?? null;
  58488. }
  58489. $definition->addMethodCall('setName', [$commandName]);
  58490. if ($aliases) {
  58491. $definition->addMethodCall('setAliases', [$aliases]);
  58492. }
  58493. if ($isHidden) {
  58494. $definition->addMethodCall('setHidden', [true]);
  58495. }
  58496. if (!$description) {
  58497. if (!$r = $container->getReflectionClass($class)) {
  58498. throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id));
  58499. }
  58500. if (!$r->isSubclassOf(Command::class)) {
  58501. throw new InvalidArgumentException(sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, $this->commandTag, Command::class));
  58502. }
  58503. $description = str_replace('%', '%%', $class::getDefaultDescription() ?? '');
  58504. }
  58505. if ($description) {
  58506. $definition->addMethodCall('setDescription', [$description]);
  58507. $container->register('.'.$id.'.lazy', LazyCommand::class)
  58508. ->setArguments([$commandName, $aliases, $description, $isHidden, new ServiceClosureArgument($lazyCommandRefs[$id])]);
  58509. $lazyCommandRefs[$id] = new Reference('.'.$id.'.lazy');
  58510. }
  58511. }
  58512. $container
  58513. ->register($this->commandLoaderServiceId, ContainerCommandLoader::class)
  58514. ->setPublic(true)
  58515. ->addTag($this->noPreloadTag)
  58516. ->setArguments([ServiceLocatorTagPass::register($container, $lazyCommandRefs), $lazyCommandMap]);
  58517. $container->setParameter('console.command.ids', $serviceIds);
  58518. }
  58519. }
  58520. <?php
  58521. namespace Symfony\Component\Console\Descriptor;
  58522. use Symfony\Component\Console\Application;
  58523. use Symfony\Component\Console\Command\Command;
  58524. use Symfony\Component\Console\Exception\CommandNotFoundException;
  58525. class ApplicationDescription
  58526. {
  58527. public const GLOBAL_NAMESPACE = '_global';
  58528. private $application;
  58529. private $namespace;
  58530. private $showHidden;
  58531. private $namespaces;
  58532. private $commands;
  58533. private $aliases;
  58534. public function __construct(Application $application, string $namespace = null, bool $showHidden = false)
  58535. {
  58536. $this->application = $application;
  58537. $this->namespace = $namespace;
  58538. $this->showHidden = $showHidden;
  58539. }
  58540. public function getNamespaces(): array
  58541. {
  58542. if (null === $this->namespaces) {
  58543. $this->inspectApplication();
  58544. }
  58545. return $this->namespaces;
  58546. }
  58547. public function getCommands(): array
  58548. {
  58549. if (null === $this->commands) {
  58550. $this->inspectApplication();
  58551. }
  58552. return $this->commands;
  58553. }
  58554. public function getCommand(string $name): Command
  58555. {
  58556. if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) {
  58557. throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name));
  58558. }
  58559. return $this->commands[$name] ?? $this->aliases[$name];
  58560. }
  58561. private function inspectApplication()
  58562. {
  58563. $this->commands = [];
  58564. $this->namespaces = [];
  58565. $all = $this->application->all($this->namespace ? $this->application->findNamespace($this->namespace) : null);
  58566. foreach ($this->sortCommands($all) as $namespace => $commands) {
  58567. $names = [];
  58568. foreach ($commands as $name => $command) {
  58569. if (!$command->getName() || (!$this->showHidden && $command->isHidden())) {
  58570. continue;
  58571. }
  58572. if ($command->getName() === $name) {
  58573. $this->commands[$name] = $command;
  58574. } else {
  58575. $this->aliases[$name] = $command;
  58576. }
  58577. $names[] = $name;
  58578. }
  58579. $this->namespaces[$namespace] = ['id' => $namespace, 'commands' => $names];
  58580. }
  58581. }
  58582. private function sortCommands(array $commands): array
  58583. {
  58584. $namespacedCommands = [];
  58585. $globalCommands = [];
  58586. $sortedCommands = [];
  58587. foreach ($commands as $name => $command) {
  58588. $key = $this->application->extractNamespace($name, 1);
  58589. if (\in_array($key, ['', self::GLOBAL_NAMESPACE], true)) {
  58590. $globalCommands[$name] = $command;
  58591. } else {
  58592. $namespacedCommands[$key][$name] = $command;
  58593. }
  58594. }
  58595. if ($globalCommands) {
  58596. ksort($globalCommands);
  58597. $sortedCommands[self::GLOBAL_NAMESPACE] = $globalCommands;
  58598. }
  58599. if ($namespacedCommands) {
  58600. ksort($namespacedCommands, \SORT_STRING);
  58601. foreach ($namespacedCommands as $key => $commandsSet) {
  58602. ksort($commandsSet);
  58603. $sortedCommands[$key] = $commandsSet;
  58604. }
  58605. }
  58606. return $sortedCommands;
  58607. }
  58608. }
  58609. <?php
  58610. namespace Symfony\Component\Console\Descriptor;
  58611. use Symfony\Component\Console\Application;
  58612. use Symfony\Component\Console\Command\Command;
  58613. use Symfony\Component\Console\Exception\InvalidArgumentException;
  58614. use Symfony\Component\Console\Input\InputArgument;
  58615. use Symfony\Component\Console\Input\InputDefinition;
  58616. use Symfony\Component\Console\Input\InputOption;
  58617. use Symfony\Component\Console\Output\OutputInterface;
  58618. abstract class Descriptor implements DescriptorInterface
  58619. {
  58620. protected $output;
  58621. public function describe(OutputInterface $output, object $object, array $options = [])
  58622. {
  58623. $this->output = $output;
  58624. switch (true) {
  58625. case $object instanceof InputArgument:
  58626. $this->describeInputArgument($object, $options);
  58627. break;
  58628. case $object instanceof InputOption:
  58629. $this->describeInputOption($object, $options);
  58630. break;
  58631. case $object instanceof InputDefinition:
  58632. $this->describeInputDefinition($object, $options);
  58633. break;
  58634. case $object instanceof Command:
  58635. $this->describeCommand($object, $options);
  58636. break;
  58637. case $object instanceof Application:
  58638. $this->describeApplication($object, $options);
  58639. break;
  58640. default:
  58641. throw new InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_debug_type($object)));
  58642. }
  58643. }
  58644. protected function write(string $content, bool $decorated = false)
  58645. {
  58646. $this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW);
  58647. }
  58648. abstract protected function describeInputArgument(InputArgument $argument, array $options = []);
  58649. abstract protected function describeInputOption(InputOption $option, array $options = []);
  58650. abstract protected function describeInputDefinition(InputDefinition $definition, array $options = []);
  58651. abstract protected function describeCommand(Command $command, array $options = []);
  58652. abstract protected function describeApplication(Application $application, array $options = []);
  58653. }
  58654. <?php
  58655. namespace Symfony\Component\Console\Descriptor;
  58656. use Symfony\Component\Console\Output\OutputInterface;
  58657. interface DescriptorInterface
  58658. {
  58659. public function describe(OutputInterface $output, object $object, array $options = []);
  58660. }
  58661. <?php
  58662. namespace Symfony\Component\Console\Descriptor;
  58663. use Symfony\Component\Console\Application;
  58664. use Symfony\Component\Console\Command\Command;
  58665. use Symfony\Component\Console\Input\InputArgument;
  58666. use Symfony\Component\Console\Input\InputDefinition;
  58667. use Symfony\Component\Console\Input\InputOption;
  58668. class JsonDescriptor extends Descriptor
  58669. {
  58670. protected function describeInputArgument(InputArgument $argument, array $options = [])
  58671. {
  58672. $this->writeData($this->getInputArgumentData($argument), $options);
  58673. }
  58674. protected function describeInputOption(InputOption $option, array $options = [])
  58675. {
  58676. $this->writeData($this->getInputOptionData($option), $options);
  58677. if ($option->isNegatable()) {
  58678. $this->writeData($this->getInputOptionData($option, true), $options);
  58679. }
  58680. }
  58681. protected function describeInputDefinition(InputDefinition $definition, array $options = [])
  58682. {
  58683. $this->writeData($this->getInputDefinitionData($definition), $options);
  58684. }
  58685. protected function describeCommand(Command $command, array $options = [])
  58686. {
  58687. $this->writeData($this->getCommandData($command, $options['short'] ?? false), $options);
  58688. }
  58689. protected function describeApplication(Application $application, array $options = [])
  58690. {
  58691. $describedNamespace = $options['namespace'] ?? null;
  58692. $description = new ApplicationDescription($application, $describedNamespace, true);
  58693. $commands = [];
  58694. foreach ($description->getCommands() as $command) {
  58695. $commands[] = $this->getCommandData($command, $options['short'] ?? false);
  58696. }
  58697. $data = [];
  58698. if ('UNKNOWN' !== $application->getName()) {
  58699. $data['application']['name'] = $application->getName();
  58700. if ('UNKNOWN' !== $application->getVersion()) {
  58701. $data['application']['version'] = $application->getVersion();
  58702. }
  58703. }
  58704. $data['commands'] = $commands;
  58705. if ($describedNamespace) {
  58706. $data['namespace'] = $describedNamespace;
  58707. } else {
  58708. $data['namespaces'] = array_values($description->getNamespaces());
  58709. }
  58710. $this->writeData($data, $options);
  58711. }
  58712. private function writeData(array $data, array $options)
  58713. {
  58714. $flags = $options['json_encoding'] ?? 0;
  58715. $this->write(json_encode($data, $flags));
  58716. }
  58717. private function getInputArgumentData(InputArgument $argument): array
  58718. {
  58719. return [
  58720. 'name' => $argument->getName(),
  58721. 'is_required' => $argument->isRequired(),
  58722. 'is_array' => $argument->isArray(),
  58723. 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $argument->getDescription()),
  58724. 'default' => \INF === $argument->getDefault() ? 'INF' : $argument->getDefault(),
  58725. ];
  58726. }
  58727. private function getInputOptionData(InputOption $option, bool $negated = false): array
  58728. {
  58729. return $negated ? [
  58730. 'name' => '--no-'.$option->getName(),
  58731. 'shortcut' => '',
  58732. 'accept_value' => false,
  58733. 'is_value_required' => false,
  58734. 'is_multiple' => false,
  58735. 'description' => 'Negate the "--'.$option->getName().'" option',
  58736. 'default' => false,
  58737. ] : [
  58738. 'name' => '--'.$option->getName(),
  58739. 'shortcut' => $option->getShortcut() ? '-'.str_replace('|', '|-', $option->getShortcut()) : '',
  58740. 'accept_value' => $option->acceptValue(),
  58741. 'is_value_required' => $option->isValueRequired(),
  58742. 'is_multiple' => $option->isArray(),
  58743. 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()),
  58744. 'default' => \INF === $option->getDefault() ? 'INF' : $option->getDefault(),
  58745. ];
  58746. }
  58747. private function getInputDefinitionData(InputDefinition $definition): array
  58748. {
  58749. $inputArguments = [];
  58750. foreach ($definition->getArguments() as $name => $argument) {
  58751. $inputArguments[$name] = $this->getInputArgumentData($argument);
  58752. }
  58753. $inputOptions = [];
  58754. foreach ($definition->getOptions() as $name => $option) {
  58755. $inputOptions[$name] = $this->getInputOptionData($option);
  58756. if ($option->isNegatable()) {
  58757. $inputOptions['no-'.$name] = $this->getInputOptionData($option, true);
  58758. }
  58759. }
  58760. return ['arguments' => $inputArguments, 'options' => $inputOptions];
  58761. }
  58762. private function getCommandData(Command $command, bool $short = false): array
  58763. {
  58764. $data = [
  58765. 'name' => $command->getName(),
  58766. 'description' => $command->getDescription(),
  58767. ];
  58768. if ($short) {
  58769. $data += [
  58770. 'usage' => $command->getAliases(),
  58771. ];
  58772. } else {
  58773. $command->mergeApplicationDefinition(false);
  58774. $data += [
  58775. 'usage' => array_merge([$command->getSynopsis()], $command->getUsages(), $command->getAliases()),
  58776. 'help' => $command->getProcessedHelp(),
  58777. 'definition' => $this->getInputDefinitionData($command->getDefinition()),
  58778. ];
  58779. }
  58780. $data['hidden'] = $command->isHidden();
  58781. return $data;
  58782. }
  58783. }
  58784. <?php
  58785. namespace Symfony\Component\Console\Descriptor;
  58786. use Symfony\Component\Console\Application;
  58787. use Symfony\Component\Console\Command\Command;
  58788. use Symfony\Component\Console\Helper\Helper;
  58789. use Symfony\Component\Console\Input\InputArgument;
  58790. use Symfony\Component\Console\Input\InputDefinition;
  58791. use Symfony\Component\Console\Input\InputOption;
  58792. use Symfony\Component\Console\Output\OutputInterface;
  58793. class MarkdownDescriptor extends Descriptor
  58794. {
  58795. public function describe(OutputInterface $output, object $object, array $options = [])
  58796. {
  58797. $decorated = $output->isDecorated();
  58798. $output->setDecorated(false);
  58799. parent::describe($output, $object, $options);
  58800. $output->setDecorated($decorated);
  58801. }
  58802. protected function write(string $content, bool $decorated = true)
  58803. {
  58804. parent::write($content, $decorated);
  58805. }
  58806. protected function describeInputArgument(InputArgument $argument, array $options = [])
  58807. {
  58808. $this->write(
  58809. '#### `'.($argument->getName() ?: '<none>')."`\n\n"
  58810. .($argument->getDescription() ? preg_replace('/\s*[\r\n]\s*/', "\n", $argument->getDescription())."\n\n" : '')
  58811. .'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n"
  58812. .'* Is array: '.($argument->isArray() ? 'yes' : 'no')."\n"
  58813. .'* Default: `'.str_replace("\n", '', var_export($argument->getDefault(), true)).'`'
  58814. );
  58815. }
  58816. protected function describeInputOption(InputOption $option, array $options = [])
  58817. {
  58818. $name = '--'.$option->getName();
  58819. if ($option->isNegatable()) {
  58820. $name .= '|--no-'.$option->getName();
  58821. }
  58822. if ($option->getShortcut()) {
  58823. $name .= '|-'.str_replace('|', '|-', $option->getShortcut()).'';
  58824. }
  58825. $this->write(
  58826. '#### `'.$name.'`'."\n\n"
  58827. .($option->getDescription() ? preg_replace('/\s*[\r\n]\s*/', "\n", $option->getDescription())."\n\n" : '')
  58828. .'* Accept value: '.($option->acceptValue() ? 'yes' : 'no')."\n"
  58829. .'* Is value required: '.($option->isValueRequired() ? 'yes' : 'no')."\n"
  58830. .'* Is multiple: '.($option->isArray() ? 'yes' : 'no')."\n"
  58831. .'* Is negatable: '.($option->isNegatable() ? 'yes' : 'no')."\n"
  58832. .'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`'
  58833. );
  58834. }
  58835. protected function describeInputDefinition(InputDefinition $definition, array $options = [])
  58836. {
  58837. if ($showArguments = \count($definition->getArguments()) > 0) {
  58838. $this->write('### Arguments');
  58839. foreach ($definition->getArguments() as $argument) {
  58840. $this->write("\n\n");
  58841. if (null !== $describeInputArgument = $this->describeInputArgument($argument)) {
  58842. $this->write($describeInputArgument);
  58843. }
  58844. }
  58845. }
  58846. if (\count($definition->getOptions()) > 0) {
  58847. if ($showArguments) {
  58848. $this->write("\n\n");
  58849. }
  58850. $this->write('### Options');
  58851. foreach ($definition->getOptions() as $option) {
  58852. $this->write("\n\n");
  58853. if (null !== $describeInputOption = $this->describeInputOption($option)) {
  58854. $this->write($describeInputOption);
  58855. }
  58856. }
  58857. }
  58858. }
  58859. protected function describeCommand(Command $command, array $options = [])
  58860. {
  58861. if ($options['short'] ?? false) {
  58862. $this->write(
  58863. '`'.$command->getName()."`\n"
  58864. .str_repeat('-', Helper::width($command->getName()) + 2)."\n\n"
  58865. .($command->getDescription() ? $command->getDescription()."\n\n" : '')
  58866. .'### Usage'."\n\n"
  58867. .array_reduce($command->getAliases(), function ($carry, $usage) {
  58868. return $carry.'* `'.$usage.'`'."\n";
  58869. })
  58870. );
  58871. return;
  58872. }
  58873. $command->mergeApplicationDefinition(false);
  58874. $this->write(
  58875. '`'.$command->getName()."`\n"
  58876. .str_repeat('-', Helper::width($command->getName()) + 2)."\n\n"
  58877. .($command->getDescription() ? $command->getDescription()."\n\n" : '')
  58878. .'### Usage'."\n\n"
  58879. .array_reduce(array_merge([$command->getSynopsis()], $command->getAliases(), $command->getUsages()), function ($carry, $usage) {
  58880. return $carry.'* `'.$usage.'`'."\n";
  58881. })
  58882. );
  58883. if ($help = $command->getProcessedHelp()) {
  58884. $this->write("\n");
  58885. $this->write($help);
  58886. }
  58887. $definition = $command->getDefinition();
  58888. if ($definition->getOptions() || $definition->getArguments()) {
  58889. $this->write("\n\n");
  58890. $this->describeInputDefinition($definition);
  58891. }
  58892. }
  58893. protected function describeApplication(Application $application, array $options = [])
  58894. {
  58895. $describedNamespace = $options['namespace'] ?? null;
  58896. $description = new ApplicationDescription($application, $describedNamespace);
  58897. $title = $this->getApplicationTitle($application);
  58898. $this->write($title."\n".str_repeat('=', Helper::width($title)));
  58899. foreach ($description->getNamespaces() as $namespace) {
  58900. if (ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
  58901. $this->write("\n\n");
  58902. $this->write('**'.$namespace['id'].':**');
  58903. }
  58904. $this->write("\n\n");
  58905. $this->write(implode("\n", array_map(function ($commandName) use ($description) {
  58906. return sprintf('* [`%s`](#%s)', $commandName, str_replace(':', '', $description->getCommand($commandName)->getName()));
  58907. }, $namespace['commands'])));
  58908. }
  58909. foreach ($description->getCommands() as $command) {
  58910. $this->write("\n\n");
  58911. if (null !== $describeCommand = $this->describeCommand($command, $options)) {
  58912. $this->write($describeCommand);
  58913. }
  58914. }
  58915. }
  58916. private function getApplicationTitle(Application $application): string
  58917. {
  58918. if ('UNKNOWN' !== $application->getName()) {
  58919. if ('UNKNOWN' !== $application->getVersion()) {
  58920. return sprintf('%s %s', $application->getName(), $application->getVersion());
  58921. }
  58922. return $application->getName();
  58923. }
  58924. return 'Console Tool';
  58925. }
  58926. }
  58927. <?php
  58928. namespace Symfony\Component\Console\Descriptor;
  58929. use Symfony\Component\Console\Application;
  58930. use Symfony\Component\Console\Command\Command;
  58931. use Symfony\Component\Console\Formatter\OutputFormatter;
  58932. use Symfony\Component\Console\Helper\Helper;
  58933. use Symfony\Component\Console\Input\InputArgument;
  58934. use Symfony\Component\Console\Input\InputDefinition;
  58935. use Symfony\Component\Console\Input\InputOption;
  58936. class TextDescriptor extends Descriptor
  58937. {
  58938. protected function describeInputArgument(InputArgument $argument, array $options = [])
  58939. {
  58940. if (null !== $argument->getDefault() && (!\is_array($argument->getDefault()) || \count($argument->getDefault()))) {
  58941. $default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($argument->getDefault()));
  58942. } else {
  58943. $default = '';
  58944. }
  58945. $totalWidth = $options['total_width'] ?? Helper::width($argument->getName());
  58946. $spacingWidth = $totalWidth - \strlen($argument->getName());
  58947. $this->writeText(sprintf(' <info>%s</info> %s%s%s',
  58948. $argument->getName(),
  58949. str_repeat(' ', $spacingWidth),
  58950. preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $argument->getDescription()),
  58951. $default
  58952. ), $options);
  58953. }
  58954. protected function describeInputOption(InputOption $option, array $options = [])
  58955. {
  58956. if ($option->acceptValue() && null !== $option->getDefault() && (!\is_array($option->getDefault()) || \count($option->getDefault()))) {
  58957. $default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($option->getDefault()));
  58958. } else {
  58959. $default = '';
  58960. }
  58961. $value = '';
  58962. if ($option->acceptValue()) {
  58963. $value = '='.strtoupper($option->getName());
  58964. if ($option->isValueOptional()) {
  58965. $value = '['.$value.']';
  58966. }
  58967. }
  58968. $totalWidth = $options['total_width'] ?? $this->calculateTotalWidthForOptions([$option]);
  58969. $synopsis = sprintf('%s%s',
  58970. $option->getShortcut() ? sprintf('-%s, ', $option->getShortcut()) : ' ',
  58971. sprintf($option->isNegatable() ? '--%1$s|--no-%1$s' : '--%1$s%2$s', $option->getName(), $value)
  58972. );
  58973. $spacingWidth = $totalWidth - Helper::width($synopsis);
  58974. $this->writeText(sprintf(' <info>%s</info> %s%s%s%s',
  58975. $synopsis,
  58976. str_repeat(' ', $spacingWidth),
  58977. preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $option->getDescription()),
  58978. $default,
  58979. $option->isArray() ? '<comment> (multiple values allowed)</comment>' : ''
  58980. ), $options);
  58981. }
  58982. protected function describeInputDefinition(InputDefinition $definition, array $options = [])
  58983. {
  58984. $totalWidth = $this->calculateTotalWidthForOptions($definition->getOptions());
  58985. foreach ($definition->getArguments() as $argument) {
  58986. $totalWidth = max($totalWidth, Helper::width($argument->getName()));
  58987. }
  58988. if ($definition->getArguments()) {
  58989. $this->writeText('<comment>Arguments:</comment>', $options);
  58990. $this->writeText("\n");
  58991. foreach ($definition->getArguments() as $argument) {
  58992. $this->describeInputArgument($argument, array_merge($options, ['total_width' => $totalWidth]));
  58993. $this->writeText("\n");
  58994. }
  58995. }
  58996. if ($definition->getArguments() && $definition->getOptions()) {
  58997. $this->writeText("\n");
  58998. }
  58999. if ($definition->getOptions()) {
  59000. $laterOptions = [];
  59001. $this->writeText('<comment>Options:</comment>', $options);
  59002. foreach ($definition->getOptions() as $option) {
  59003. if (\strlen($option->getShortcut() ?? '') > 1) {
  59004. $laterOptions[] = $option;
  59005. continue;
  59006. }
  59007. $this->writeText("\n");
  59008. $this->describeInputOption($option, array_merge($options, ['total_width' => $totalWidth]));
  59009. }
  59010. foreach ($laterOptions as $option) {
  59011. $this->writeText("\n");
  59012. $this->describeInputOption($option, array_merge($options, ['total_width' => $totalWidth]));
  59013. }
  59014. }
  59015. }
  59016. protected function describeCommand(Command $command, array $options = [])
  59017. {
  59018. $command->mergeApplicationDefinition(false);
  59019. if ($description = $command->getDescription()) {
  59020. $this->writeText('<comment>Description:</comment>', $options);
  59021. $this->writeText("\n");
  59022. $this->writeText(' '.$description);
  59023. $this->writeText("\n\n");
  59024. }
  59025. $this->writeText('<comment>Usage:</comment>', $options);
  59026. foreach (array_merge([$command->getSynopsis(true)], $command->getAliases(), $command->getUsages()) as $usage) {
  59027. $this->writeText("\n");
  59028. $this->writeText(' '.OutputFormatter::escape($usage), $options);
  59029. }
  59030. $this->writeText("\n");
  59031. $definition = $command->getDefinition();
  59032. if ($definition->getOptions() || $definition->getArguments()) {
  59033. $this->writeText("\n");
  59034. $this->describeInputDefinition($definition, $options);
  59035. $this->writeText("\n");
  59036. }
  59037. $help = $command->getProcessedHelp();
  59038. if ($help && $help !== $description) {
  59039. $this->writeText("\n");
  59040. $this->writeText('<comment>Help:</comment>', $options);
  59041. $this->writeText("\n");
  59042. $this->writeText(' '.str_replace("\n", "\n ", $help), $options);
  59043. $this->writeText("\n");
  59044. }
  59045. }
  59046. protected function describeApplication(Application $application, array $options = [])
  59047. {
  59048. $describedNamespace = $options['namespace'] ?? null;
  59049. $description = new ApplicationDescription($application, $describedNamespace);
  59050. if (isset($options['raw_text']) && $options['raw_text']) {
  59051. $width = $this->getColumnWidth($description->getCommands());
  59052. foreach ($description->getCommands() as $command) {
  59053. $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
  59054. $this->writeText("\n");
  59055. }
  59056. } else {
  59057. if ('' != $help = $application->getHelp()) {
  59058. $this->writeText("$help\n\n", $options);
  59059. }
  59060. $this->writeText("<comment>Usage:</comment>\n", $options);
  59061. $this->writeText(" command [options] [arguments]\n\n", $options);
  59062. $this->describeInputDefinition(new InputDefinition($application->getDefinition()->getOptions()), $options);
  59063. $this->writeText("\n");
  59064. $this->writeText("\n");
  59065. $commands = $description->getCommands();
  59066. $namespaces = $description->getNamespaces();
  59067. if ($describedNamespace && $namespaces) {
  59068. $describedNamespaceInfo = reset($namespaces);
  59069. foreach ($describedNamespaceInfo['commands'] as $name) {
  59070. $commands[$name] = $description->getCommand($name);
  59071. }
  59072. }
  59073. $width = $this->getColumnWidth(array_merge(...array_values(array_map(function ($namespace) use ($commands) {
  59074. return array_intersect($namespace['commands'], array_keys($commands));
  59075. }, array_values($namespaces)))));
  59076. if ($describedNamespace) {
  59077. $this->writeText(sprintf('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace), $options);
  59078. } else {
  59079. $this->writeText('<comment>Available commands:</comment>', $options);
  59080. }
  59081. foreach ($namespaces as $namespace) {
  59082. $namespace['commands'] = array_filter($namespace['commands'], function ($name) use ($commands) {
  59083. return isset($commands[$name]);
  59084. });
  59085. if (!$namespace['commands']) {
  59086. continue;
  59087. }
  59088. if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
  59089. $this->writeText("\n");
  59090. $this->writeText(' <comment>'.$namespace['id'].'</comment>', $options);
  59091. }
  59092. foreach ($namespace['commands'] as $name) {
  59093. $this->writeText("\n");
  59094. $spacingWidth = $width - Helper::width($name);
  59095. $command = $commands[$name];
  59096. $commandAliases = $name === $command->getName() ? $this->getCommandAliasesText($command) : '';
  59097. $this->writeText(sprintf(' <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $commandAliases.$command->getDescription()), $options);
  59098. }
  59099. }
  59100. $this->writeText("\n");
  59101. }
  59102. }
  59103. private function writeText(string $content, array $options = [])
  59104. {
  59105. $this->write(
  59106. isset($options['raw_text']) && $options['raw_text'] ? strip_tags($content) : $content,
  59107. isset($options['raw_output']) ? !$options['raw_output'] : true
  59108. );
  59109. }
  59110. private function getCommandAliasesText(Command $command): string
  59111. {
  59112. $text = '';
  59113. $aliases = $command->getAliases();
  59114. if ($aliases) {
  59115. $text = '['.implode('|', $aliases).'] ';
  59116. }
  59117. return $text;
  59118. }
  59119. private function formatDefaultValue($default): string
  59120. {
  59121. if (\INF === $default) {
  59122. return 'INF';
  59123. }
  59124. if (\is_string($default)) {
  59125. $default = OutputFormatter::escape($default);
  59126. } elseif (\is_array($default)) {
  59127. foreach ($default as $key => $value) {
  59128. if (\is_string($value)) {
  59129. $default[$key] = OutputFormatter::escape($value);
  59130. }
  59131. }
  59132. }
  59133. return str_replace('\\\\', '\\', json_encode($default, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE));
  59134. }
  59135. private function getColumnWidth(array $commands): int
  59136. {
  59137. $widths = [];
  59138. foreach ($commands as $command) {
  59139. if ($command instanceof Command) {
  59140. $widths[] = Helper::width($command->getName());
  59141. foreach ($command->getAliases() as $alias) {
  59142. $widths[] = Helper::width($alias);
  59143. }
  59144. } else {
  59145. $widths[] = Helper::width($command);
  59146. }
  59147. }
  59148. return $widths ? max($widths) + 2 : 0;
  59149. }
  59150. private function calculateTotalWidthForOptions(array $options): int
  59151. {
  59152. $totalWidth = 0;
  59153. foreach ($options as $option) {
  59154. $nameLength = 1 + max(Helper::width($option->getShortcut()), 1) + 4 + Helper::width($option->getName());
  59155. if ($option->isNegatable()) {
  59156. $nameLength += 6 + Helper::width($option->getName());
  59157. } elseif ($option->acceptValue()) {
  59158. $valueLength = 1 + Helper::width($option->getName());
  59159. $valueLength += $option->isValueOptional() ? 2 : 0;
  59160. $nameLength += $valueLength;
  59161. }
  59162. $totalWidth = max($totalWidth, $nameLength);
  59163. }
  59164. return $totalWidth;
  59165. }
  59166. }
  59167. <?php
  59168. namespace Symfony\Component\Console\Descriptor;
  59169. use Symfony\Component\Console\Application;
  59170. use Symfony\Component\Console\Command\Command;
  59171. use Symfony\Component\Console\Input\InputArgument;
  59172. use Symfony\Component\Console\Input\InputDefinition;
  59173. use Symfony\Component\Console\Input\InputOption;
  59174. class XmlDescriptor extends Descriptor
  59175. {
  59176. public function getInputDefinitionDocument(InputDefinition $definition): \DOMDocument
  59177. {
  59178. $dom = new \DOMDocument('1.0', 'UTF-8');
  59179. $dom->appendChild($definitionXML = $dom->createElement('definition'));
  59180. $definitionXML->appendChild($argumentsXML = $dom->createElement('arguments'));
  59181. foreach ($definition->getArguments() as $argument) {
  59182. $this->appendDocument($argumentsXML, $this->getInputArgumentDocument($argument));
  59183. }
  59184. $definitionXML->appendChild($optionsXML = $dom->createElement('options'));
  59185. foreach ($definition->getOptions() as $option) {
  59186. $this->appendDocument($optionsXML, $this->getInputOptionDocument($option));
  59187. }
  59188. return $dom;
  59189. }
  59190. public function getCommandDocument(Command $command, bool $short = false): \DOMDocument
  59191. {
  59192. $dom = new \DOMDocument('1.0', 'UTF-8');
  59193. $dom->appendChild($commandXML = $dom->createElement('command'));
  59194. $commandXML->setAttribute('id', $command->getName());
  59195. $commandXML->setAttribute('name', $command->getName());
  59196. $commandXML->setAttribute('hidden', $command->isHidden() ? 1 : 0);
  59197. $commandXML->appendChild($usagesXML = $dom->createElement('usages'));
  59198. $commandXML->appendChild($descriptionXML = $dom->createElement('description'));
  59199. $descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getDescription())));
  59200. if ($short) {
  59201. foreach ($command->getAliases() as $usage) {
  59202. $usagesXML->appendChild($dom->createElement('usage', $usage));
  59203. }
  59204. } else {
  59205. $command->mergeApplicationDefinition(false);
  59206. foreach (array_merge([$command->getSynopsis()], $command->getAliases(), $command->getUsages()) as $usage) {
  59207. $usagesXML->appendChild($dom->createElement('usage', $usage));
  59208. }
  59209. $commandXML->appendChild($helpXML = $dom->createElement('help'));
  59210. $helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getProcessedHelp())));
  59211. $definitionXML = $this->getInputDefinitionDocument($command->getDefinition());
  59212. $this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0));
  59213. }
  59214. return $dom;
  59215. }
  59216. public function getApplicationDocument(Application $application, string $namespace = null, bool $short = false): \DOMDocument
  59217. {
  59218. $dom = new \DOMDocument('1.0', 'UTF-8');
  59219. $dom->appendChild($rootXml = $dom->createElement('symfony'));
  59220. if ('UNKNOWN' !== $application->getName()) {
  59221. $rootXml->setAttribute('name', $application->getName());
  59222. if ('UNKNOWN' !== $application->getVersion()) {
  59223. $rootXml->setAttribute('version', $application->getVersion());
  59224. }
  59225. }
  59226. $rootXml->appendChild($commandsXML = $dom->createElement('commands'));
  59227. $description = new ApplicationDescription($application, $namespace, true);
  59228. if ($namespace) {
  59229. $commandsXML->setAttribute('namespace', $namespace);
  59230. }
  59231. foreach ($description->getCommands() as $command) {
  59232. $this->appendDocument($commandsXML, $this->getCommandDocument($command, $short));
  59233. }
  59234. if (!$namespace) {
  59235. $rootXml->appendChild($namespacesXML = $dom->createElement('namespaces'));
  59236. foreach ($description->getNamespaces() as $namespaceDescription) {
  59237. $namespacesXML->appendChild($namespaceArrayXML = $dom->createElement('namespace'));
  59238. $namespaceArrayXML->setAttribute('id', $namespaceDescription['id']);
  59239. foreach ($namespaceDescription['commands'] as $name) {
  59240. $namespaceArrayXML->appendChild($commandXML = $dom->createElement('command'));
  59241. $commandXML->appendChild($dom->createTextNode($name));
  59242. }
  59243. }
  59244. }
  59245. return $dom;
  59246. }
  59247. protected function describeInputArgument(InputArgument $argument, array $options = [])
  59248. {
  59249. $this->writeDocument($this->getInputArgumentDocument($argument));
  59250. }
  59251. protected function describeInputOption(InputOption $option, array $options = [])
  59252. {
  59253. $this->writeDocument($this->getInputOptionDocument($option));
  59254. }
  59255. protected function describeInputDefinition(InputDefinition $definition, array $options = [])
  59256. {
  59257. $this->writeDocument($this->getInputDefinitionDocument($definition));
  59258. }
  59259. protected function describeCommand(Command $command, array $options = [])
  59260. {
  59261. $this->writeDocument($this->getCommandDocument($command, $options['short'] ?? false));
  59262. }
  59263. protected function describeApplication(Application $application, array $options = [])
  59264. {
  59265. $this->writeDocument($this->getApplicationDocument($application, $options['namespace'] ?? null, $options['short'] ?? false));
  59266. }
  59267. private function appendDocument(\DOMNode $parentNode, \DOMNode $importedParent)
  59268. {
  59269. foreach ($importedParent->childNodes as $childNode) {
  59270. $parentNode->appendChild($parentNode->ownerDocument->importNode($childNode, true));
  59271. }
  59272. }
  59273. private function writeDocument(\DOMDocument $dom)
  59274. {
  59275. $dom->formatOutput = true;
  59276. $this->write($dom->saveXML());
  59277. }
  59278. private function getInputArgumentDocument(InputArgument $argument): \DOMDocument
  59279. {
  59280. $dom = new \DOMDocument('1.0', 'UTF-8');
  59281. $dom->appendChild($objectXML = $dom->createElement('argument'));
  59282. $objectXML->setAttribute('name', $argument->getName());
  59283. $objectXML->setAttribute('is_required', $argument->isRequired() ? 1 : 0);
  59284. $objectXML->setAttribute('is_array', $argument->isArray() ? 1 : 0);
  59285. $objectXML->appendChild($descriptionXML = $dom->createElement('description'));
  59286. $descriptionXML->appendChild($dom->createTextNode($argument->getDescription()));
  59287. $objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
  59288. $defaults = \is_array($argument->getDefault()) ? $argument->getDefault() : (\is_bool($argument->getDefault()) ? [var_export($argument->getDefault(), true)] : ($argument->getDefault() ? [$argument->getDefault()] : []));
  59289. foreach ($defaults as $default) {
  59290. $defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
  59291. $defaultXML->appendChild($dom->createTextNode($default));
  59292. }
  59293. return $dom;
  59294. }
  59295. private function getInputOptionDocument(InputOption $option): \DOMDocument
  59296. {
  59297. $dom = new \DOMDocument('1.0', 'UTF-8');
  59298. $dom->appendChild($objectXML = $dom->createElement('option'));
  59299. $objectXML->setAttribute('name', '--'.$option->getName());
  59300. $pos = strpos($option->getShortcut() ?? '', '|');
  59301. if (false !== $pos) {
  59302. $objectXML->setAttribute('shortcut', '-'.substr($option->getShortcut(), 0, $pos));
  59303. $objectXML->setAttribute('shortcuts', '-'.str_replace('|', '|-', $option->getShortcut()));
  59304. } else {
  59305. $objectXML->setAttribute('shortcut', $option->getShortcut() ? '-'.$option->getShortcut() : '');
  59306. }
  59307. $objectXML->setAttribute('accept_value', $option->acceptValue() ? 1 : 0);
  59308. $objectXML->setAttribute('is_value_required', $option->isValueRequired() ? 1 : 0);
  59309. $objectXML->setAttribute('is_multiple', $option->isArray() ? 1 : 0);
  59310. $objectXML->appendChild($descriptionXML = $dom->createElement('description'));
  59311. $descriptionXML->appendChild($dom->createTextNode($option->getDescription()));
  59312. if ($option->acceptValue()) {
  59313. $defaults = \is_array($option->getDefault()) ? $option->getDefault() : (\is_bool($option->getDefault()) ? [var_export($option->getDefault(), true)] : ($option->getDefault() ? [$option->getDefault()] : []));
  59314. $objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
  59315. if (!empty($defaults)) {
  59316. foreach ($defaults as $default) {
  59317. $defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
  59318. $defaultXML->appendChild($dom->createTextNode($default));
  59319. }
  59320. }
  59321. }
  59322. if ($option->isNegatable()) {
  59323. $dom->appendChild($objectXML = $dom->createElement('option'));
  59324. $objectXML->setAttribute('name', '--no-'.$option->getName());
  59325. $objectXML->setAttribute('shortcut', '');
  59326. $objectXML->setAttribute('accept_value', 0);
  59327. $objectXML->setAttribute('is_value_required', 0);
  59328. $objectXML->setAttribute('is_multiple', 0);
  59329. $objectXML->appendChild($descriptionXML = $dom->createElement('description'));
  59330. $descriptionXML->appendChild($dom->createTextNode('Negate the "--'.$option->getName().'" option'));
  59331. }
  59332. return $dom;
  59333. }
  59334. }
  59335. <?php
  59336. namespace Symfony\Component\Console\Event;
  59337. final class ConsoleCommandEvent extends ConsoleEvent
  59338. {
  59339. public const RETURN_CODE_DISABLED = 113;
  59340. private $commandShouldRun = true;
  59341. public function disableCommand(): bool
  59342. {
  59343. return $this->commandShouldRun = false;
  59344. }
  59345. public function enableCommand(): bool
  59346. {
  59347. return $this->commandShouldRun = true;
  59348. }
  59349. public function commandShouldRun(): bool
  59350. {
  59351. return $this->commandShouldRun;
  59352. }
  59353. }
  59354. <?php
  59355. namespace Symfony\Component\Console\Event;
  59356. use Symfony\Component\Console\Command\Command;
  59357. use Symfony\Component\Console\Input\InputInterface;
  59358. use Symfony\Component\Console\Output\OutputInterface;
  59359. final class ConsoleErrorEvent extends ConsoleEvent
  59360. {
  59361. private $error;
  59362. private $exitCode;
  59363. public function __construct(InputInterface $input, OutputInterface $output, \Throwable $error, Command $command = null)
  59364. {
  59365. parent::__construct($command, $input, $output);
  59366. $this->error = $error;
  59367. }
  59368. public function getError(): \Throwable
  59369. {
  59370. return $this->error;
  59371. }
  59372. public function setError(\Throwable $error): void
  59373. {
  59374. $this->error = $error;
  59375. }
  59376. public function setExitCode(int $exitCode): void
  59377. {
  59378. $this->exitCode = $exitCode;
  59379. $r = new \ReflectionProperty($this->error, 'code');
  59380. $r->setAccessible(true);
  59381. $r->setValue($this->error, $this->exitCode);
  59382. }
  59383. public function getExitCode(): int
  59384. {
  59385. return $this->exitCode ?? (\is_int($this->error->getCode()) && 0 !== $this->error->getCode() ? $this->error->getCode() : 1);
  59386. }
  59387. }
  59388. <?php
  59389. namespace Symfony\Component\Console\Event;
  59390. use Symfony\Component\Console\Command\Command;
  59391. use Symfony\Component\Console\Input\InputInterface;
  59392. use Symfony\Component\Console\Output\OutputInterface;
  59393. use Symfony\Contracts\EventDispatcher\Event;
  59394. class ConsoleEvent extends Event
  59395. {
  59396. protected $command;
  59397. private $input;
  59398. private $output;
  59399. public function __construct(?Command $command, InputInterface $input, OutputInterface $output)
  59400. {
  59401. $this->command = $command;
  59402. $this->input = $input;
  59403. $this->output = $output;
  59404. }
  59405. public function getCommand()
  59406. {
  59407. return $this->command;
  59408. }
  59409. public function getInput()
  59410. {
  59411. return $this->input;
  59412. }
  59413. public function getOutput()
  59414. {
  59415. return $this->output;
  59416. }
  59417. }
  59418. <?php
  59419. namespace Symfony\Component\Console\Event;
  59420. use Symfony\Component\Console\Command\Command;
  59421. use Symfony\Component\Console\Input\InputInterface;
  59422. use Symfony\Component\Console\Output\OutputInterface;
  59423. final class ConsoleSignalEvent extends ConsoleEvent
  59424. {
  59425. private $handlingSignal;
  59426. public function __construct(Command $command, InputInterface $input, OutputInterface $output, int $handlingSignal)
  59427. {
  59428. parent::__construct($command, $input, $output);
  59429. $this->handlingSignal = $handlingSignal;
  59430. }
  59431. public function getHandlingSignal(): int
  59432. {
  59433. return $this->handlingSignal;
  59434. }
  59435. }
  59436. <?php
  59437. namespace Symfony\Component\Console\Event;
  59438. use Symfony\Component\Console\Command\Command;
  59439. use Symfony\Component\Console\Input\InputInterface;
  59440. use Symfony\Component\Console\Output\OutputInterface;
  59441. final class ConsoleTerminateEvent extends ConsoleEvent
  59442. {
  59443. private $exitCode;
  59444. public function __construct(Command $command, InputInterface $input, OutputInterface $output, int $exitCode)
  59445. {
  59446. parent::__construct($command, $input, $output);
  59447. $this->setExitCode($exitCode);
  59448. }
  59449. public function setExitCode(int $exitCode): void
  59450. {
  59451. $this->exitCode = $exitCode;
  59452. }
  59453. public function getExitCode(): int
  59454. {
  59455. return $this->exitCode;
  59456. }
  59457. }
  59458. <?php
  59459. namespace Symfony\Component\Console\EventListener;
  59460. use Psr\Log\LoggerInterface;
  59461. use Symfony\Component\Console\ConsoleEvents;
  59462. use Symfony\Component\Console\Event\ConsoleErrorEvent;
  59463. use Symfony\Component\Console\Event\ConsoleEvent;
  59464. use Symfony\Component\Console\Event\ConsoleTerminateEvent;
  59465. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  59466. class ErrorListener implements EventSubscriberInterface
  59467. {
  59468. private $logger;
  59469. public function __construct(LoggerInterface $logger = null)
  59470. {
  59471. $this->logger = $logger;
  59472. }
  59473. public function onConsoleError(ConsoleErrorEvent $event)
  59474. {
  59475. if (null === $this->logger) {
  59476. return;
  59477. }
  59478. $error = $event->getError();
  59479. if (!$inputString = $this->getInputString($event)) {
  59480. $this->logger->critical('An error occurred while using the console. Message: "{message}"', ['exception' => $error, 'message' => $error->getMessage()]);
  59481. return;
  59482. }
  59483. $this->logger->critical('Error thrown while running command "{command}". Message: "{message}"', ['exception' => $error, 'command' => $inputString, 'message' => $error->getMessage()]);
  59484. }
  59485. public function onConsoleTerminate(ConsoleTerminateEvent $event)
  59486. {
  59487. if (null === $this->logger) {
  59488. return;
  59489. }
  59490. $exitCode = $event->getExitCode();
  59491. if (0 === $exitCode) {
  59492. return;
  59493. }
  59494. if (!$inputString = $this->getInputString($event)) {
  59495. $this->logger->debug('The console exited with code "{code}"', ['code' => $exitCode]);
  59496. return;
  59497. }
  59498. $this->logger->debug('Command "{command}" exited with code "{code}"', ['command' => $inputString, 'code' => $exitCode]);
  59499. }
  59500. public static function getSubscribedEvents()
  59501. {
  59502. return [
  59503. ConsoleEvents::ERROR => ['onConsoleError', -128],
  59504. ConsoleEvents::TERMINATE => ['onConsoleTerminate', -128],
  59505. ];
  59506. }
  59507. private static function getInputString(ConsoleEvent $event): ?string
  59508. {
  59509. $commandName = $event->getCommand() ? $event->getCommand()->getName() : null;
  59510. $input = $event->getInput();
  59511. if (method_exists($input, '__toString')) {
  59512. if ($commandName) {
  59513. return str_replace(["'$commandName'", "\"$commandName\""], $commandName, (string) $input);
  59514. }
  59515. return (string) $input;
  59516. }
  59517. return $commandName;
  59518. }
  59519. }
  59520. <?php
  59521. namespace Symfony\Component\Console\Exception;
  59522. class CommandNotFoundException extends \InvalidArgumentException implements ExceptionInterface
  59523. {
  59524. private $alternatives;
  59525. public function __construct(string $message, array $alternatives = [], int $code = 0, \Throwable $previous = null)
  59526. {
  59527. parent::__construct($message, $code, $previous);
  59528. $this->alternatives = $alternatives;
  59529. }
  59530. public function getAlternatives()
  59531. {
  59532. return $this->alternatives;
  59533. }
  59534. }
  59535. <?php
  59536. namespace Symfony\Component\Console\Exception;
  59537. interface ExceptionInterface extends \Throwable
  59538. {
  59539. }
  59540. <?php
  59541. namespace Symfony\Component\Console\Exception;
  59542. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  59543. {
  59544. }
  59545. <?php
  59546. namespace Symfony\Component\Console\Exception;
  59547. class InvalidOptionException extends \InvalidArgumentException implements ExceptionInterface
  59548. {
  59549. }
  59550. <?php
  59551. namespace Symfony\Component\Console\Exception;
  59552. class LogicException extends \LogicException implements ExceptionInterface
  59553. {
  59554. }
  59555. <?php
  59556. namespace Symfony\Component\Console\Exception;
  59557. class MissingInputException extends RuntimeException implements ExceptionInterface
  59558. {
  59559. }
  59560. <?php
  59561. namespace Symfony\Component\Console\Exception;
  59562. class NamespaceNotFoundException extends CommandNotFoundException
  59563. {
  59564. }
  59565. <?php
  59566. namespace Symfony\Component\Console\Exception;
  59567. class RuntimeException extends \RuntimeException implements ExceptionInterface
  59568. {
  59569. }
  59570. <?php
  59571. namespace Symfony\Component\Console\Formatter;
  59572. final class NullOutputFormatter implements OutputFormatterInterface
  59573. {
  59574. private $style;
  59575. public function format(?string $message): ?string
  59576. {
  59577. return null;
  59578. }
  59579. public function getStyle(string $name): OutputFormatterStyleInterface
  59580. {
  59581. return $this->style ?? $this->style = new NullOutputFormatterStyle();
  59582. }
  59583. public function hasStyle(string $name): bool
  59584. {
  59585. return false;
  59586. }
  59587. public function isDecorated(): bool
  59588. {
  59589. return false;
  59590. }
  59591. public function setDecorated(bool $decorated): void
  59592. {
  59593. }
  59594. public function setStyle(string $name, OutputFormatterStyleInterface $style): void
  59595. {
  59596. }
  59597. }
  59598. <?php
  59599. namespace Symfony\Component\Console\Formatter;
  59600. final class NullOutputFormatterStyle implements OutputFormatterStyleInterface
  59601. {
  59602. public function apply(string $text): string
  59603. {
  59604. return $text;
  59605. }
  59606. public function setBackground(string $color = null): void
  59607. {
  59608. }
  59609. public function setForeground(string $color = null): void
  59610. {
  59611. }
  59612. public function setOption(string $option): void
  59613. {
  59614. }
  59615. public function setOptions(array $options): void
  59616. {
  59617. }
  59618. public function unsetOption(string $option): void
  59619. {
  59620. }
  59621. }
  59622. <?php
  59623. namespace Symfony\Component\Console\Formatter;
  59624. use Symfony\Component\Console\Exception\InvalidArgumentException;
  59625. use function Symfony\Component\String\b;
  59626. class OutputFormatter implements WrappableOutputFormatterInterface
  59627. {
  59628. private $decorated;
  59629. private $styles = [];
  59630. private $styleStack;
  59631. public function __clone()
  59632. {
  59633. $this->styleStack = clone $this->styleStack;
  59634. foreach ($this->styles as $key => $value) {
  59635. $this->styles[$key] = clone $value;
  59636. }
  59637. }
  59638. public static function escape(string $text)
  59639. {
  59640. $text = preg_replace('/([^\\\\]|^)([<>])/', '$1\\\\$2', $text);
  59641. return self::escapeTrailingBackslash($text);
  59642. }
  59643. public static function escapeTrailingBackslash(string $text): string
  59644. {
  59645. if (str_ends_with($text, '\\')) {
  59646. $len = \strlen($text);
  59647. $text = rtrim($text, '\\');
  59648. $text = str_replace("\0", '', $text);
  59649. $text .= str_repeat("\0", $len - \strlen($text));
  59650. }
  59651. return $text;
  59652. }
  59653. public function __construct(bool $decorated = false, array $styles = [])
  59654. {
  59655. $this->decorated = $decorated;
  59656. $this->setStyle('error', new OutputFormatterStyle('white', 'red'));
  59657. $this->setStyle('info', new OutputFormatterStyle('green'));
  59658. $this->setStyle('comment', new OutputFormatterStyle('yellow'));
  59659. $this->setStyle('question', new OutputFormatterStyle('black', 'cyan'));
  59660. foreach ($styles as $name => $style) {
  59661. $this->setStyle($name, $style);
  59662. }
  59663. $this->styleStack = new OutputFormatterStyleStack();
  59664. }
  59665. public function setDecorated(bool $decorated)
  59666. {
  59667. $this->decorated = $decorated;
  59668. }
  59669. public function isDecorated()
  59670. {
  59671. return $this->decorated;
  59672. }
  59673. public function setStyle(string $name, OutputFormatterStyleInterface $style)
  59674. {
  59675. $this->styles[strtolower($name)] = $style;
  59676. }
  59677. public function hasStyle(string $name)
  59678. {
  59679. return isset($this->styles[strtolower($name)]);
  59680. }
  59681. public function getStyle(string $name)
  59682. {
  59683. if (!$this->hasStyle($name)) {
  59684. throw new InvalidArgumentException(sprintf('Undefined style: "%s".', $name));
  59685. }
  59686. return $this->styles[strtolower($name)];
  59687. }
  59688. public function format(?string $message)
  59689. {
  59690. return $this->formatAndWrap($message, 0);
  59691. }
  59692. public function formatAndWrap(?string $message, int $width)
  59693. {
  59694. if (null === $message) {
  59695. return '';
  59696. }
  59697. $offset = 0;
  59698. $output = '';
  59699. $openTagRegex = '[a-z](?:[^\\\\<>]*+ | \\\\.)*';
  59700. $closeTagRegex = '[a-z][^<>]*+';
  59701. $currentLineLength = 0;
  59702. preg_match_all("#<(($openTagRegex) | /($closeTagRegex)?)>#ix", $message, $matches, \PREG_OFFSET_CAPTURE);
  59703. foreach ($matches[0] as $i => $match) {
  59704. $pos = $match[1];
  59705. $text = $match[0];
  59706. if (0 != $pos && '\\' == $message[$pos - 1]) {
  59707. continue;
  59708. }
  59709. $output .= $this->applyCurrentStyle(substr($message, $offset, $pos - $offset), $output, $width, $currentLineLength);
  59710. $offset = $pos + \strlen($text);
  59711. if ($open = '/' != $text[1]) {
  59712. $tag = $matches[1][$i][0];
  59713. } else {
  59714. $tag = $matches[3][$i][0] ?? '';
  59715. }
  59716. if (!$open && !$tag) {
  59717. $this->styleStack->pop();
  59718. } elseif (null === $style = $this->createStyleFromString($tag)) {
  59719. $output .= $this->applyCurrentStyle($text, $output, $width, $currentLineLength);
  59720. } elseif ($open) {
  59721. $this->styleStack->push($style);
  59722. } else {
  59723. $this->styleStack->pop($style);
  59724. }
  59725. }
  59726. $output .= $this->applyCurrentStyle(substr($message, $offset), $output, $width, $currentLineLength);
  59727. return strtr($output, ["\0" => '\\', '\\<' => '<', '\\>' => '>']);
  59728. }
  59729. public function getStyleStack()
  59730. {
  59731. return $this->styleStack;
  59732. }
  59733. private function createStyleFromString(string $string): ?OutputFormatterStyleInterface
  59734. {
  59735. if (isset($this->styles[$string])) {
  59736. return $this->styles[$string];
  59737. }
  59738. if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', $string, $matches, \PREG_SET_ORDER)) {
  59739. return null;
  59740. }
  59741. $style = new OutputFormatterStyle();
  59742. foreach ($matches as $match) {
  59743. array_shift($match);
  59744. $match[0] = strtolower($match[0]);
  59745. if ('fg' == $match[0]) {
  59746. $style->setForeground(strtolower($match[1]));
  59747. } elseif ('bg' == $match[0]) {
  59748. $style->setBackground(strtolower($match[1]));
  59749. } elseif ('href' === $match[0]) {
  59750. $url = preg_replace('{\\\\([<>])}', '$1', $match[1]);
  59751. $style->setHref($url);
  59752. } elseif ('options' === $match[0]) {
  59753. preg_match_all('([^,;]+)', strtolower($match[1]), $options);
  59754. $options = array_shift($options);
  59755. foreach ($options as $option) {
  59756. $style->setOption($option);
  59757. }
  59758. } else {
  59759. return null;
  59760. }
  59761. }
  59762. return $style;
  59763. }
  59764. private function applyCurrentStyle(string $text, string $current, int $width, int &$currentLineLength): string
  59765. {
  59766. if ('' === $text) {
  59767. return '';
  59768. }
  59769. if (!$width) {
  59770. return $this->isDecorated() ? $this->styleStack->getCurrent()->apply($text) : $text;
  59771. }
  59772. if (!$currentLineLength && '' !== $current) {
  59773. $text = ltrim($text);
  59774. }
  59775. if ($currentLineLength) {
  59776. $prefix = substr($text, 0, $i = $width - $currentLineLength)."\n";
  59777. $text = substr($text, $i);
  59778. } else {
  59779. $prefix = '';
  59780. }
  59781. preg_match('~(\\n)$~', $text, $matches);
  59782. $text = $prefix.$this->addLineBreaks($text, $width);
  59783. $text = rtrim($text, "\n").($matches[1] ?? '');
  59784. if (!$currentLineLength && '' !== $current && "\n" !== substr($current, -1)) {
  59785. $text = "\n".$text;
  59786. }
  59787. $lines = explode("\n", $text);
  59788. foreach ($lines as $line) {
  59789. $currentLineLength += \strlen($line);
  59790. if ($width <= $currentLineLength) {
  59791. $currentLineLength = 0;
  59792. }
  59793. }
  59794. if ($this->isDecorated()) {
  59795. foreach ($lines as $i => $line) {
  59796. $lines[$i] = $this->styleStack->getCurrent()->apply($line);
  59797. }
  59798. }
  59799. return implode("\n", $lines);
  59800. }
  59801. private function addLineBreaks(string $text, int $width): string
  59802. {
  59803. $encoding = mb_detect_encoding($text, null, true) ?: 'UTF-8';
  59804. return b($text)->toCodePointString($encoding)->wordwrap($width, "\n", true)->toByteString($encoding);
  59805. }
  59806. }
  59807. <?php
  59808. namespace Symfony\Component\Console\Formatter;
  59809. interface OutputFormatterInterface
  59810. {
  59811. public function setDecorated(bool $decorated);
  59812. public function isDecorated();
  59813. public function setStyle(string $name, OutputFormatterStyleInterface $style);
  59814. public function hasStyle(string $name);
  59815. public function getStyle(string $name);
  59816. public function format(?string $message);
  59817. }
  59818. <?php
  59819. namespace Symfony\Component\Console\Formatter;
  59820. use Symfony\Component\Console\Color;
  59821. class OutputFormatterStyle implements OutputFormatterStyleInterface
  59822. {
  59823. private $color;
  59824. private $foreground;
  59825. private $background;
  59826. private $options;
  59827. private $href;
  59828. private $handlesHrefGracefully;
  59829. public function __construct(string $foreground = null, string $background = null, array $options = [])
  59830. {
  59831. $this->color = new Color($this->foreground = $foreground ?: '', $this->background = $background ?: '', $this->options = $options);
  59832. }
  59833. public function setForeground(string $color = null)
  59834. {
  59835. $this->color = new Color($this->foreground = $color ?: '', $this->background, $this->options);
  59836. }
  59837. public function setBackground(string $color = null)
  59838. {
  59839. $this->color = new Color($this->foreground, $this->background = $color ?: '', $this->options);
  59840. }
  59841. public function setHref(string $url): void
  59842. {
  59843. $this->href = $url;
  59844. }
  59845. public function setOption(string $option)
  59846. {
  59847. $this->options[] = $option;
  59848. $this->color = new Color($this->foreground, $this->background, $this->options);
  59849. }
  59850. public function unsetOption(string $option)
  59851. {
  59852. $pos = array_search($option, $this->options);
  59853. if (false !== $pos) {
  59854. unset($this->options[$pos]);
  59855. }
  59856. $this->color = new Color($this->foreground, $this->background, $this->options);
  59857. }
  59858. public function setOptions(array $options)
  59859. {
  59860. $this->color = new Color($this->foreground, $this->background, $this->options = $options);
  59861. }
  59862. public function apply(string $text)
  59863. {
  59864. if (null === $this->handlesHrefGracefully) {
  59865. $this->handlesHrefGracefully = 'JetBrains-JediTerm' !== getenv('TERMINAL_EMULATOR')
  59866. && (!getenv('KONSOLE_VERSION') || (int) getenv('KONSOLE_VERSION') > 201100)
  59867. && !isset($_SERVER['IDEA_INITIAL_DIRECTORY']);
  59868. }
  59869. if (null !== $this->href && $this->handlesHrefGracefully) {
  59870. $text = "\033]8;;$this->href\033\\$text\033]8;;\033\\";
  59871. }
  59872. return $this->color->apply($text);
  59873. }
  59874. }
  59875. <?php
  59876. namespace Symfony\Component\Console\Formatter;
  59877. interface OutputFormatterStyleInterface
  59878. {
  59879. public function setForeground(string $color = null);
  59880. public function setBackground(string $color = null);
  59881. public function setOption(string $option);
  59882. public function unsetOption(string $option);
  59883. public function setOptions(array $options);
  59884. public function apply(string $text);
  59885. }
  59886. <?php
  59887. namespace Symfony\Component\Console\Formatter;
  59888. use Symfony\Component\Console\Exception\InvalidArgumentException;
  59889. use Symfony\Contracts\Service\ResetInterface;
  59890. class OutputFormatterStyleStack implements ResetInterface
  59891. {
  59892. private $styles;
  59893. private $emptyStyle;
  59894. public function __construct(OutputFormatterStyleInterface $emptyStyle = null)
  59895. {
  59896. $this->emptyStyle = $emptyStyle ?? new OutputFormatterStyle();
  59897. $this->reset();
  59898. }
  59899. public function reset()
  59900. {
  59901. $this->styles = [];
  59902. }
  59903. public function push(OutputFormatterStyleInterface $style)
  59904. {
  59905. $this->styles[] = $style;
  59906. }
  59907. public function pop(OutputFormatterStyleInterface $style = null)
  59908. {
  59909. if (empty($this->styles)) {
  59910. return $this->emptyStyle;
  59911. }
  59912. if (null === $style) {
  59913. return array_pop($this->styles);
  59914. }
  59915. foreach (array_reverse($this->styles, true) as $index => $stackedStyle) {
  59916. if ($style->apply('') === $stackedStyle->apply('')) {
  59917. $this->styles = \array_slice($this->styles, 0, $index);
  59918. return $stackedStyle;
  59919. }
  59920. }
  59921. throw new InvalidArgumentException('Incorrectly nested style tag found.');
  59922. }
  59923. public function getCurrent()
  59924. {
  59925. if (empty($this->styles)) {
  59926. return $this->emptyStyle;
  59927. }
  59928. return $this->styles[\count($this->styles) - 1];
  59929. }
  59930. public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle)
  59931. {
  59932. $this->emptyStyle = $emptyStyle;
  59933. return $this;
  59934. }
  59935. public function getEmptyStyle()
  59936. {
  59937. return $this->emptyStyle;
  59938. }
  59939. }
  59940. <?php
  59941. namespace Symfony\Component\Console\Formatter;
  59942. interface WrappableOutputFormatterInterface extends OutputFormatterInterface
  59943. {
  59944. public function formatAndWrap(?string $message, int $width);
  59945. }
  59946. <?php
  59947. namespace Symfony\Component\Console\Helper;
  59948. class DebugFormatterHelper extends Helper
  59949. {
  59950. private const COLORS = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default'];
  59951. private $started = [];
  59952. private $count = -1;
  59953. public function start(string $id, string $message, string $prefix = 'RUN')
  59954. {
  59955. $this->started[$id] = ['border' => ++$this->count % \count(self::COLORS)];
  59956. return sprintf("%s<bg=blue;fg=white> %s </> <fg=blue>%s</>\n", $this->getBorder($id), $prefix, $message);
  59957. }
  59958. public function progress(string $id, string $buffer, bool $error = false, string $prefix = 'OUT', string $errorPrefix = 'ERR')
  59959. {
  59960. $message = '';
  59961. if ($error) {
  59962. if (isset($this->started[$id]['out'])) {
  59963. $message .= "\n";
  59964. unset($this->started[$id]['out']);
  59965. }
  59966. if (!isset($this->started[$id]['err'])) {
  59967. $message .= sprintf('%s<bg=red;fg=white> %s </> ', $this->getBorder($id), $errorPrefix);
  59968. $this->started[$id]['err'] = true;
  59969. }
  59970. $message .= str_replace("\n", sprintf("\n%s<bg=red;fg=white> %s </> ", $this->getBorder($id), $errorPrefix), $buffer);
  59971. } else {
  59972. if (isset($this->started[$id]['err'])) {
  59973. $message .= "\n";
  59974. unset($this->started[$id]['err']);
  59975. }
  59976. if (!isset($this->started[$id]['out'])) {
  59977. $message .= sprintf('%s<bg=green;fg=white> %s </> ', $this->getBorder($id), $prefix);
  59978. $this->started[$id]['out'] = true;
  59979. }
  59980. $message .= str_replace("\n", sprintf("\n%s<bg=green;fg=white> %s </> ", $this->getBorder($id), $prefix), $buffer);
  59981. }
  59982. return $message;
  59983. }
  59984. public function stop(string $id, string $message, bool $successful, string $prefix = 'RES')
  59985. {
  59986. $trailingEOL = isset($this->started[$id]['out']) || isset($this->started[$id]['err']) ? "\n" : '';
  59987. if ($successful) {
  59988. return sprintf("%s%s<bg=green;fg=white> %s </> <fg=green>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
  59989. }
  59990. $message = sprintf("%s%s<bg=red;fg=white> %s </> <fg=red>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
  59991. unset($this->started[$id]['out'], $this->started[$id]['err']);
  59992. return $message;
  59993. }
  59994. private function getBorder(string $id): string
  59995. {
  59996. return sprintf('<bg=%s> </>', self::COLORS[$this->started[$id]['border']]);
  59997. }
  59998. public function getName()
  59999. {
  60000. return 'debug_formatter';
  60001. }
  60002. }
  60003. <?php
  60004. namespace Symfony\Component\Console\Helper;
  60005. use Symfony\Component\Console\Descriptor\DescriptorInterface;
  60006. use Symfony\Component\Console\Descriptor\JsonDescriptor;
  60007. use Symfony\Component\Console\Descriptor\MarkdownDescriptor;
  60008. use Symfony\Component\Console\Descriptor\TextDescriptor;
  60009. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  60010. use Symfony\Component\Console\Exception\InvalidArgumentException;
  60011. use Symfony\Component\Console\Output\OutputInterface;
  60012. class DescriptorHelper extends Helper
  60013. {
  60014. private $descriptors = [];
  60015. public function __construct()
  60016. {
  60017. $this
  60018. ->register('txt', new TextDescriptor())
  60019. ->register('xml', new XmlDescriptor())
  60020. ->register('json', new JsonDescriptor())
  60021. ->register('md', new MarkdownDescriptor())
  60022. ;
  60023. }
  60024. public function describe(OutputInterface $output, ?object $object, array $options = [])
  60025. {
  60026. $options = array_merge([
  60027. 'raw_text' => false,
  60028. 'format' => 'txt',
  60029. ], $options);
  60030. if (!isset($this->descriptors[$options['format']])) {
  60031. throw new InvalidArgumentException(sprintf('Unsupported format "%s".', $options['format']));
  60032. }
  60033. $descriptor = $this->descriptors[$options['format']];
  60034. $descriptor->describe($output, $object, $options);
  60035. }
  60036. public function register(string $format, DescriptorInterface $descriptor)
  60037. {
  60038. $this->descriptors[$format] = $descriptor;
  60039. return $this;
  60040. }
  60041. public function getName()
  60042. {
  60043. return 'descriptor';
  60044. }
  60045. public function getFormats(): array
  60046. {
  60047. return array_keys($this->descriptors);
  60048. }
  60049. }
  60050. <?php
  60051. namespace Symfony\Component\Console\Helper;
  60052. use Symfony\Component\Console\Output\OutputInterface;
  60053. use Symfony\Component\VarDumper\Cloner\ClonerInterface;
  60054. use Symfony\Component\VarDumper\Cloner\VarCloner;
  60055. use Symfony\Component\VarDumper\Dumper\CliDumper;
  60056. final class Dumper
  60057. {
  60058. private $output;
  60059. private $dumper;
  60060. private $cloner;
  60061. private $handler;
  60062. public function __construct(OutputInterface $output, CliDumper $dumper = null, ClonerInterface $cloner = null)
  60063. {
  60064. $this->output = $output;
  60065. $this->dumper = $dumper;
  60066. $this->cloner = $cloner;
  60067. if (class_exists(CliDumper::class)) {
  60068. $this->handler = function ($var): string {
  60069. $dumper = $this->dumper ?? $this->dumper = new CliDumper(null, null, CliDumper::DUMP_LIGHT_ARRAY | CliDumper::DUMP_COMMA_SEPARATOR);
  60070. $dumper->setColors($this->output->isDecorated());
  60071. return rtrim($dumper->dump(($this->cloner ?? $this->cloner = new VarCloner())->cloneVar($var)->withRefHandles(false), true));
  60072. };
  60073. } else {
  60074. $this->handler = function ($var): string {
  60075. switch (true) {
  60076. case null === $var:
  60077. return 'null';
  60078. case true === $var:
  60079. return 'true';
  60080. case false === $var:
  60081. return 'false';
  60082. case \is_string($var):
  60083. return '"'.$var.'"';
  60084. default:
  60085. return rtrim(print_r($var, true));
  60086. }
  60087. };
  60088. }
  60089. }
  60090. public function __invoke($var): string
  60091. {
  60092. return ($this->handler)($var);
  60093. }
  60094. }
  60095. <?php
  60096. namespace Symfony\Component\Console\Helper;
  60097. use Symfony\Component\Console\Formatter\OutputFormatter;
  60098. class FormatterHelper extends Helper
  60099. {
  60100. public function formatSection(string $section, string $message, string $style = 'info')
  60101. {
  60102. return sprintf('<%s>[%s]</%s> %s', $style, $section, $style, $message);
  60103. }
  60104. public function formatBlock($messages, string $style, bool $large = false)
  60105. {
  60106. if (!\is_array($messages)) {
  60107. $messages = [$messages];
  60108. }
  60109. $len = 0;
  60110. $lines = [];
  60111. foreach ($messages as $message) {
  60112. $message = OutputFormatter::escape($message);
  60113. $lines[] = sprintf($large ? ' %s ' : ' %s ', $message);
  60114. $len = max(self::width($message) + ($large ? 4 : 2), $len);
  60115. }
  60116. $messages = $large ? [str_repeat(' ', $len)] : [];
  60117. for ($i = 0; isset($lines[$i]); ++$i) {
  60118. $messages[] = $lines[$i].str_repeat(' ', $len - self::width($lines[$i]));
  60119. }
  60120. if ($large) {
  60121. $messages[] = str_repeat(' ', $len);
  60122. }
  60123. for ($i = 0; isset($messages[$i]); ++$i) {
  60124. $messages[$i] = sprintf('<%s>%s</%s>', $style, $messages[$i], $style);
  60125. }
  60126. return implode("\n", $messages);
  60127. }
  60128. public function truncate(string $message, int $length, string $suffix = '...')
  60129. {
  60130. $computedLength = $length - self::width($suffix);
  60131. if ($computedLength > self::width($message)) {
  60132. return $message;
  60133. }
  60134. return self::substr($message, 0, $length).$suffix;
  60135. }
  60136. public function getName()
  60137. {
  60138. return 'formatter';
  60139. }
  60140. }
  60141. <?php
  60142. namespace Symfony\Component\Console\Helper;
  60143. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  60144. use Symfony\Component\String\UnicodeString;
  60145. abstract class Helper implements HelperInterface
  60146. {
  60147. protected $helperSet = null;
  60148. public function setHelperSet(HelperSet $helperSet = null)
  60149. {
  60150. $this->helperSet = $helperSet;
  60151. }
  60152. public function getHelperSet()
  60153. {
  60154. return $this->helperSet;
  60155. }
  60156. public static function strlen(?string $string)
  60157. {
  60158. 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__);
  60159. return self::width($string);
  60160. }
  60161. public static function width(?string $string): int
  60162. {
  60163. $string ?? $string = '';
  60164. if (preg_match('//u', $string)) {
  60165. return (new UnicodeString($string))->width(false);
  60166. }
  60167. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  60168. return \strlen($string);
  60169. }
  60170. return mb_strwidth($string, $encoding);
  60171. }
  60172. public static function length(?string $string): int
  60173. {
  60174. $string ?? $string = '';
  60175. if (preg_match('//u', $string)) {
  60176. return (new UnicodeString($string))->length();
  60177. }
  60178. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  60179. return \strlen($string);
  60180. }
  60181. return mb_strlen($string, $encoding);
  60182. }
  60183. public static function substr(?string $string, int $from, int $length = null)
  60184. {
  60185. $string ?? $string = '';
  60186. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  60187. return substr($string, $from, $length);
  60188. }
  60189. return mb_substr($string, $from, $length, $encoding);
  60190. }
  60191. public static function formatTime($secs)
  60192. {
  60193. static $timeFormats = [
  60194. [0, '< 1 sec'],
  60195. [1, '1 sec'],
  60196. [2, 'secs', 1],
  60197. [60, '1 min'],
  60198. [120, 'mins', 60],
  60199. [3600, '1 hr'],
  60200. [7200, 'hrs', 3600],
  60201. [86400, '1 day'],
  60202. [172800, 'days', 86400],
  60203. ];
  60204. foreach ($timeFormats as $index => $format) {
  60205. if ($secs >= $format[0]) {
  60206. if ((isset($timeFormats[$index + 1]) && $secs < $timeFormats[$index + 1][0])
  60207. || $index == \count($timeFormats) - 1
  60208. ) {
  60209. if (2 == \count($format)) {
  60210. return $format[1];
  60211. }
  60212. return floor($secs / $format[2]).' '.$format[1];
  60213. }
  60214. }
  60215. }
  60216. }
  60217. public static function formatMemory(int $memory)
  60218. {
  60219. if ($memory >= 1024 * 1024 * 1024) {
  60220. return sprintf('%.1f GiB', $memory / 1024 / 1024 / 1024);
  60221. }
  60222. if ($memory >= 1024 * 1024) {
  60223. return sprintf('%.1f MiB', $memory / 1024 / 1024);
  60224. }
  60225. if ($memory >= 1024) {
  60226. return sprintf('%d KiB', $memory / 1024);
  60227. }
  60228. return sprintf('%d B', $memory);
  60229. }
  60230. public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, ?string $string)
  60231. {
  60232. trigger_deprecation('symfony/console', '5.3', 'Method "%s()" is deprecated and will be removed in Symfony 6.0. Use Helper::removeDecoration() instead.', __METHOD__);
  60233. return self::width(self::removeDecoration($formatter, $string));
  60234. }
  60235. public static function removeDecoration(OutputFormatterInterface $formatter, ?string $string)
  60236. {
  60237. $isDecorated = $formatter->isDecorated();
  60238. $formatter->setDecorated(false);
  60239. $string = $formatter->format($string ?? '');
  60240. $string = preg_replace("/\033\[[^m]*m/", '', $string ?? '');
  60241. $string = preg_replace('/\\033]8;[^;]*;[^\\033]*\\033\\\\/', '', $string ?? '');
  60242. $formatter->setDecorated($isDecorated);
  60243. return $string;
  60244. }
  60245. }
  60246. <?php
  60247. namespace Symfony\Component\Console\Helper;
  60248. interface HelperInterface
  60249. {
  60250. public function setHelperSet(HelperSet $helperSet = null);
  60251. public function getHelperSet();
  60252. public function getName();
  60253. }
  60254. <?php
  60255. namespace Symfony\Component\Console\Helper;
  60256. use Symfony\Component\Console\Command\Command;
  60257. use Symfony\Component\Console\Exception\InvalidArgumentException;
  60258. class HelperSet implements \IteratorAggregate
  60259. {
  60260. private $helpers = [];
  60261. private $command;
  60262. public function __construct(array $helpers = [])
  60263. {
  60264. foreach ($helpers as $alias => $helper) {
  60265. $this->set($helper, \is_int($alias) ? null : $alias);
  60266. }
  60267. }
  60268. public function set(HelperInterface $helper, string $alias = null)
  60269. {
  60270. $this->helpers[$helper->getName()] = $helper;
  60271. if (null !== $alias) {
  60272. $this->helpers[$alias] = $helper;
  60273. }
  60274. $helper->setHelperSet($this);
  60275. }
  60276. public function has(string $name)
  60277. {
  60278. return isset($this->helpers[$name]);
  60279. }
  60280. public function get(string $name)
  60281. {
  60282. if (!$this->has($name)) {
  60283. throw new InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
  60284. }
  60285. return $this->helpers[$name];
  60286. }
  60287. public function setCommand(Command $command = null)
  60288. {
  60289. trigger_deprecation('symfony/console', '5.4', 'Method "%s()" is deprecated.', __METHOD__);
  60290. $this->command = $command;
  60291. }
  60292. public function getCommand()
  60293. {
  60294. trigger_deprecation('symfony/console', '5.4', 'Method "%s()" is deprecated.', __METHOD__);
  60295. return $this->command;
  60296. }
  60297. #[\ReturnTypeWillChange]
  60298. public function getIterator()
  60299. {
  60300. return new \ArrayIterator($this->helpers);
  60301. }
  60302. }
  60303. <?php
  60304. namespace Symfony\Component\Console\Helper;
  60305. use Symfony\Component\Console\Input\InputAwareInterface;
  60306. use Symfony\Component\Console\Input\InputInterface;
  60307. abstract class InputAwareHelper extends Helper implements InputAwareInterface
  60308. {
  60309. protected $input;
  60310. public function setInput(InputInterface $input)
  60311. {
  60312. $this->input = $input;
  60313. }
  60314. }
  60315. <?php
  60316. namespace Symfony\Component\Console\Helper;
  60317. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  60318. use Symfony\Component\Console\Output\OutputInterface;
  60319. use Symfony\Component\Process\Exception\ProcessFailedException;
  60320. use Symfony\Component\Process\Process;
  60321. class ProcessHelper extends Helper
  60322. {
  60323. public function run(OutputInterface $output, $cmd, string $error = null, callable $callback = null, int $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE): Process
  60324. {
  60325. if (!class_exists(Process::class)) {
  60326. throw new \LogicException('The ProcessHelper cannot be run as the Process component is not installed. Try running "compose require symfony/process".');
  60327. }
  60328. if ($output instanceof ConsoleOutputInterface) {
  60329. $output = $output->getErrorOutput();
  60330. }
  60331. $formatter = $this->getHelperSet()->get('debug_formatter');
  60332. if ($cmd instanceof Process) {
  60333. $cmd = [$cmd];
  60334. }
  60335. if (!\is_array($cmd)) {
  60336. 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)));
  60337. }
  60338. if (\is_string($cmd[0] ?? null)) {
  60339. $process = new Process($cmd);
  60340. $cmd = [];
  60341. } elseif (($cmd[0] ?? null) instanceof Process) {
  60342. $process = $cmd[0];
  60343. unset($cmd[0]);
  60344. } else {
  60345. 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__));
  60346. }
  60347. if ($verbosity <= $output->getVerbosity()) {
  60348. $output->write($formatter->start(spl_object_hash($process), $this->escapeString($process->getCommandLine())));
  60349. }
  60350. if ($output->isDebug()) {
  60351. $callback = $this->wrapCallback($output, $process, $callback);
  60352. }
  60353. $process->run($callback, $cmd);
  60354. if ($verbosity <= $output->getVerbosity()) {
  60355. $message = $process->isSuccessful() ? 'Command ran successfully' : sprintf('%s Command did not run successfully', $process->getExitCode());
  60356. $output->write($formatter->stop(spl_object_hash($process), $message, $process->isSuccessful()));
  60357. }
  60358. if (!$process->isSuccessful() && null !== $error) {
  60359. $output->writeln(sprintf('<error>%s</error>', $this->escapeString($error)));
  60360. }
  60361. return $process;
  60362. }
  60363. public function mustRun(OutputInterface $output, $cmd, string $error = null, callable $callback = null): Process
  60364. {
  60365. $process = $this->run($output, $cmd, $error, $callback);
  60366. if (!$process->isSuccessful()) {
  60367. throw new ProcessFailedException($process);
  60368. }
  60369. return $process;
  60370. }
  60371. public function wrapCallback(OutputInterface $output, Process $process, callable $callback = null): callable
  60372. {
  60373. if ($output instanceof ConsoleOutputInterface) {
  60374. $output = $output->getErrorOutput();
  60375. }
  60376. $formatter = $this->getHelperSet()->get('debug_formatter');
  60377. return function ($type, $buffer) use ($output, $process, $callback, $formatter) {
  60378. $output->write($formatter->progress(spl_object_hash($process), $this->escapeString($buffer), Process::ERR === $type));
  60379. if (null !== $callback) {
  60380. $callback($type, $buffer);
  60381. }
  60382. };
  60383. }
  60384. private function escapeString(string $str): string
  60385. {
  60386. return str_replace('<', '\\<', $str);
  60387. }
  60388. public function getName(): string
  60389. {
  60390. return 'process';
  60391. }
  60392. }
  60393. <?php
  60394. namespace Symfony\Component\Console\Helper;
  60395. use Symfony\Component\Console\Cursor;
  60396. use Symfony\Component\Console\Exception\LogicException;
  60397. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  60398. use Symfony\Component\Console\Output\ConsoleSectionOutput;
  60399. use Symfony\Component\Console\Output\OutputInterface;
  60400. use Symfony\Component\Console\Terminal;
  60401. final class ProgressBar
  60402. {
  60403. public const FORMAT_VERBOSE = 'verbose';
  60404. public const FORMAT_VERY_VERBOSE = 'very_verbose';
  60405. public const FORMAT_DEBUG = 'debug';
  60406. public const FORMAT_NORMAL = 'normal';
  60407. private const FORMAT_VERBOSE_NOMAX = 'verbose_nomax';
  60408. private const FORMAT_VERY_VERBOSE_NOMAX = 'very_verbose_nomax';
  60409. private const FORMAT_DEBUG_NOMAX = 'debug_nomax';
  60410. private const FORMAT_NORMAL_NOMAX = 'normal_nomax';
  60411. private $barWidth = 28;
  60412. private $barChar;
  60413. private $emptyBarChar = '-';
  60414. private $progressChar = '>';
  60415. private $format;
  60416. private $internalFormat;
  60417. private $redrawFreq = 1;
  60418. private $writeCount;
  60419. private $lastWriteTime;
  60420. private $minSecondsBetweenRedraws = 0;
  60421. private $maxSecondsBetweenRedraws = 1;
  60422. private $output;
  60423. private $step = 0;
  60424. private $max;
  60425. private $startTime;
  60426. private $stepWidth;
  60427. private $percent = 0.0;
  60428. private $messages = [];
  60429. private $overwrite = true;
  60430. private $terminal;
  60431. private $previousMessage;
  60432. private $cursor;
  60433. private static $formatters;
  60434. private static $formats;
  60435. public function __construct(OutputInterface $output, int $max = 0, float $minSecondsBetweenRedraws = 1 / 25)
  60436. {
  60437. if ($output instanceof ConsoleOutputInterface) {
  60438. $output = $output->getErrorOutput();
  60439. }
  60440. $this->output = $output;
  60441. $this->setMaxSteps($max);
  60442. $this->terminal = new Terminal();
  60443. if (0 < $minSecondsBetweenRedraws) {
  60444. $this->redrawFreq = null;
  60445. $this->minSecondsBetweenRedraws = $minSecondsBetweenRedraws;
  60446. }
  60447. if (!$this->output->isDecorated()) {
  60448. $this->overwrite = false;
  60449. $this->redrawFreq = null;
  60450. }
  60451. $this->startTime = time();
  60452. $this->cursor = new Cursor($output);
  60453. }
  60454. public static function setPlaceholderFormatterDefinition(string $name, callable $callable): void
  60455. {
  60456. if (!self::$formatters) {
  60457. self::$formatters = self::initPlaceholderFormatters();
  60458. }
  60459. self::$formatters[$name] = $callable;
  60460. }
  60461. public static function getPlaceholderFormatterDefinition(string $name): ?callable
  60462. {
  60463. if (!self::$formatters) {
  60464. self::$formatters = self::initPlaceholderFormatters();
  60465. }
  60466. return self::$formatters[$name] ?? null;
  60467. }
  60468. public static function setFormatDefinition(string $name, string $format): void
  60469. {
  60470. if (!self::$formats) {
  60471. self::$formats = self::initFormats();
  60472. }
  60473. self::$formats[$name] = $format;
  60474. }
  60475. public static function getFormatDefinition(string $name): ?string
  60476. {
  60477. if (!self::$formats) {
  60478. self::$formats = self::initFormats();
  60479. }
  60480. return self::$formats[$name] ?? null;
  60481. }
  60482. public function setMessage(string $message, string $name = 'message')
  60483. {
  60484. $this->messages[$name] = $message;
  60485. }
  60486. public function getMessage(string $name = 'message')
  60487. {
  60488. return $this->messages[$name];
  60489. }
  60490. public function getStartTime(): int
  60491. {
  60492. return $this->startTime;
  60493. }
  60494. public function getMaxSteps(): int
  60495. {
  60496. return $this->max;
  60497. }
  60498. public function getProgress(): int
  60499. {
  60500. return $this->step;
  60501. }
  60502. private function getStepWidth(): int
  60503. {
  60504. return $this->stepWidth;
  60505. }
  60506. public function getProgressPercent(): float
  60507. {
  60508. return $this->percent;
  60509. }
  60510. public function getBarOffset(): float
  60511. {
  60512. return floor($this->max ? $this->percent * $this->barWidth : (null === $this->redrawFreq ? (int) (min(5, $this->barWidth / 15) * $this->writeCount) : $this->step) % $this->barWidth);
  60513. }
  60514. public function getEstimated(): float
  60515. {
  60516. if (!$this->step) {
  60517. return 0;
  60518. }
  60519. return round((time() - $this->startTime) / $this->step * $this->max);
  60520. }
  60521. public function getRemaining(): float
  60522. {
  60523. if (!$this->step) {
  60524. return 0;
  60525. }
  60526. return round((time() - $this->startTime) / $this->step * ($this->max - $this->step));
  60527. }
  60528. public function setBarWidth(int $size)
  60529. {
  60530. $this->barWidth = max(1, $size);
  60531. }
  60532. public function getBarWidth(): int
  60533. {
  60534. return $this->barWidth;
  60535. }
  60536. public function setBarCharacter(string $char)
  60537. {
  60538. $this->barChar = $char;
  60539. }
  60540. public function getBarCharacter(): string
  60541. {
  60542. return $this->barChar ?? ($this->max ? '=' : $this->emptyBarChar);
  60543. }
  60544. public function setEmptyBarCharacter(string $char)
  60545. {
  60546. $this->emptyBarChar = $char;
  60547. }
  60548. public function getEmptyBarCharacter(): string
  60549. {
  60550. return $this->emptyBarChar;
  60551. }
  60552. public function setProgressCharacter(string $char)
  60553. {
  60554. $this->progressChar = $char;
  60555. }
  60556. public function getProgressCharacter(): string
  60557. {
  60558. return $this->progressChar;
  60559. }
  60560. public function setFormat(string $format)
  60561. {
  60562. $this->format = null;
  60563. $this->internalFormat = $format;
  60564. }
  60565. public function setRedrawFrequency(?int $freq)
  60566. {
  60567. $this->redrawFreq = null !== $freq ? max(1, $freq) : null;
  60568. }
  60569. public function minSecondsBetweenRedraws(float $seconds): void
  60570. {
  60571. $this->minSecondsBetweenRedraws = $seconds;
  60572. }
  60573. public function maxSecondsBetweenRedraws(float $seconds): void
  60574. {
  60575. $this->maxSecondsBetweenRedraws = $seconds;
  60576. }
  60577. public function iterate(iterable $iterable, int $max = null): iterable
  60578. {
  60579. $this->start($max ?? (is_countable($iterable) ? \count($iterable) : 0));
  60580. foreach ($iterable as $key => $value) {
  60581. yield $key => $value;
  60582. $this->advance();
  60583. }
  60584. $this->finish();
  60585. }
  60586. public function start(int $max = null)
  60587. {
  60588. $this->startTime = time();
  60589. $this->step = 0;
  60590. $this->percent = 0.0;
  60591. if (null !== $max) {
  60592. $this->setMaxSteps($max);
  60593. }
  60594. $this->display();
  60595. }
  60596. public function advance(int $step = 1)
  60597. {
  60598. $this->setProgress($this->step + $step);
  60599. }
  60600. public function setOverwrite(bool $overwrite)
  60601. {
  60602. $this->overwrite = $overwrite;
  60603. }
  60604. public function setProgress(int $step)
  60605. {
  60606. if ($this->max && $step > $this->max) {
  60607. $this->max = $step;
  60608. } elseif ($step < 0) {
  60609. $step = 0;
  60610. }
  60611. $redrawFreq = $this->redrawFreq ?? (($this->max ?: 10) / 10);
  60612. $prevPeriod = (int) ($this->step / $redrawFreq);
  60613. $currPeriod = (int) ($step / $redrawFreq);
  60614. $this->step = $step;
  60615. $this->percent = $this->max ? (float) $this->step / $this->max : 0;
  60616. $timeInterval = microtime(true) - $this->lastWriteTime;
  60617. if ($this->max === $step) {
  60618. $this->display();
  60619. return;
  60620. }
  60621. if ($timeInterval < $this->minSecondsBetweenRedraws) {
  60622. return;
  60623. }
  60624. if ($prevPeriod !== $currPeriod || $timeInterval >= $this->maxSecondsBetweenRedraws) {
  60625. $this->display();
  60626. }
  60627. }
  60628. public function setMaxSteps(int $max)
  60629. {
  60630. $this->format = null;
  60631. $this->max = max(0, $max);
  60632. $this->stepWidth = $this->max ? Helper::width((string) $this->max) : 4;
  60633. }
  60634. public function finish(): void
  60635. {
  60636. if (!$this->max) {
  60637. $this->max = $this->step;
  60638. }
  60639. if ($this->step === $this->max && !$this->overwrite) {
  60640. return;
  60641. }
  60642. $this->setProgress($this->max);
  60643. }
  60644. public function display(): void
  60645. {
  60646. if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) {
  60647. return;
  60648. }
  60649. if (null === $this->format) {
  60650. $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
  60651. }
  60652. $this->overwrite($this->buildLine());
  60653. }
  60654. public function clear(): void
  60655. {
  60656. if (!$this->overwrite) {
  60657. return;
  60658. }
  60659. if (null === $this->format) {
  60660. $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
  60661. }
  60662. $this->overwrite('');
  60663. }
  60664. private function setRealFormat(string $format)
  60665. {
  60666. if (!$this->max && null !== self::getFormatDefinition($format.'_nomax')) {
  60667. $this->format = self::getFormatDefinition($format.'_nomax');
  60668. } elseif (null !== self::getFormatDefinition($format)) {
  60669. $this->format = self::getFormatDefinition($format);
  60670. } else {
  60671. $this->format = $format;
  60672. }
  60673. }
  60674. private function overwrite(string $message): void
  60675. {
  60676. if ($this->previousMessage === $message) {
  60677. return;
  60678. }
  60679. $originalMessage = $message;
  60680. if ($this->overwrite) {
  60681. if (null !== $this->previousMessage) {
  60682. if ($this->output instanceof ConsoleSectionOutput) {
  60683. $messageLines = explode("\n", $this->previousMessage);
  60684. $lineCount = \count($messageLines);
  60685. foreach ($messageLines as $messageLine) {
  60686. $messageLineLength = Helper::width(Helper::removeDecoration($this->output->getFormatter(), $messageLine));
  60687. if ($messageLineLength > $this->terminal->getWidth()) {
  60688. $lineCount += floor($messageLineLength / $this->terminal->getWidth());
  60689. }
  60690. }
  60691. $this->output->clear($lineCount);
  60692. } else {
  60693. $lineCount = substr_count($this->previousMessage, "\n");
  60694. for ($i = 0; $i < $lineCount; ++$i) {
  60695. $this->cursor->moveToColumn(1);
  60696. $this->cursor->clearLine();
  60697. $this->cursor->moveUp();
  60698. }
  60699. $this->cursor->moveToColumn(1);
  60700. $this->cursor->clearLine();
  60701. }
  60702. }
  60703. } elseif ($this->step > 0) {
  60704. $message = \PHP_EOL.$message;
  60705. }
  60706. $this->previousMessage = $originalMessage;
  60707. $this->lastWriteTime = microtime(true);
  60708. $this->output->write($message);
  60709. ++$this->writeCount;
  60710. }
  60711. private function determineBestFormat(): string
  60712. {
  60713. switch ($this->output->getVerbosity()) {
  60714. case OutputInterface::VERBOSITY_VERBOSE:
  60715. return $this->max ? self::FORMAT_VERBOSE : self::FORMAT_VERBOSE_NOMAX;
  60716. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  60717. return $this->max ? self::FORMAT_VERY_VERBOSE : self::FORMAT_VERY_VERBOSE_NOMAX;
  60718. case OutputInterface::VERBOSITY_DEBUG:
  60719. return $this->max ? self::FORMAT_DEBUG : self::FORMAT_DEBUG_NOMAX;
  60720. default:
  60721. return $this->max ? self::FORMAT_NORMAL : self::FORMAT_NORMAL_NOMAX;
  60722. }
  60723. }
  60724. private static function initPlaceholderFormatters(): array
  60725. {
  60726. return [
  60727. 'bar' => function (self $bar, OutputInterface $output) {
  60728. $completeBars = $bar->getBarOffset();
  60729. $display = str_repeat($bar->getBarCharacter(), $completeBars);
  60730. if ($completeBars < $bar->getBarWidth()) {
  60731. $emptyBars = $bar->getBarWidth() - $completeBars - Helper::length(Helper::removeDecoration($output->getFormatter(), $bar->getProgressCharacter()));
  60732. $display .= $bar->getProgressCharacter().str_repeat($bar->getEmptyBarCharacter(), $emptyBars);
  60733. }
  60734. return $display;
  60735. },
  60736. 'elapsed' => function (self $bar) {
  60737. return Helper::formatTime(time() - $bar->getStartTime());
  60738. },
  60739. 'remaining' => function (self $bar) {
  60740. if (!$bar->getMaxSteps()) {
  60741. throw new LogicException('Unable to display the remaining time if the maximum number of steps is not set.');
  60742. }
  60743. return Helper::formatTime($bar->getRemaining());
  60744. },
  60745. 'estimated' => function (self $bar) {
  60746. if (!$bar->getMaxSteps()) {
  60747. throw new LogicException('Unable to display the estimated time if the maximum number of steps is not set.');
  60748. }
  60749. return Helper::formatTime($bar->getEstimated());
  60750. },
  60751. 'memory' => function (self $bar) {
  60752. return Helper::formatMemory(memory_get_usage(true));
  60753. },
  60754. 'current' => function (self $bar) {
  60755. return str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', \STR_PAD_LEFT);
  60756. },
  60757. 'max' => function (self $bar) {
  60758. return $bar->getMaxSteps();
  60759. },
  60760. 'percent' => function (self $bar) {
  60761. return floor($bar->getProgressPercent() * 100);
  60762. },
  60763. ];
  60764. }
  60765. private static function initFormats(): array
  60766. {
  60767. return [
  60768. self::FORMAT_NORMAL => ' %current%/%max% [%bar%] %percent:3s%%',
  60769. self::FORMAT_NORMAL_NOMAX => ' %current% [%bar%]',
  60770. self::FORMAT_VERBOSE => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%',
  60771. self::FORMAT_VERBOSE_NOMAX => ' %current% [%bar%] %elapsed:6s%',
  60772. self::FORMAT_VERY_VERBOSE => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%',
  60773. self::FORMAT_VERY_VERBOSE_NOMAX => ' %current% [%bar%] %elapsed:6s%',
  60774. self::FORMAT_DEBUG => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%',
  60775. self::FORMAT_DEBUG_NOMAX => ' %current% [%bar%] %elapsed:6s% %memory:6s%',
  60776. ];
  60777. }
  60778. private function buildLine(): string
  60779. {
  60780. $regex = "{%([a-z\-_]+)(?:\:([^%]+))?%}i";
  60781. $callback = function ($matches) {
  60782. if ($formatter = $this::getPlaceholderFormatterDefinition($matches[1])) {
  60783. $text = $formatter($this, $this->output);
  60784. } elseif (isset($this->messages[$matches[1]])) {
  60785. $text = $this->messages[$matches[1]];
  60786. } else {
  60787. return $matches[0];
  60788. }
  60789. if (isset($matches[2])) {
  60790. $text = sprintf('%'.$matches[2], $text);
  60791. }
  60792. return $text;
  60793. };
  60794. $line = preg_replace_callback($regex, $callback, $this->format);
  60795. $linesLength = array_map(function ($subLine) {
  60796. return Helper::width(Helper::removeDecoration($this->output->getFormatter(), rtrim($subLine, "\r")));
  60797. }, explode("\n", $line));
  60798. $linesWidth = max($linesLength);
  60799. $terminalWidth = $this->terminal->getWidth();
  60800. if ($linesWidth <= $terminalWidth) {
  60801. return $line;
  60802. }
  60803. $this->setBarWidth($this->barWidth - $linesWidth + $terminalWidth);
  60804. return preg_replace_callback($regex, $callback, $this->format);
  60805. }
  60806. }
  60807. <?php
  60808. namespace Symfony\Component\Console\Helper;
  60809. use Symfony\Component\Console\Exception\InvalidArgumentException;
  60810. use Symfony\Component\Console\Exception\LogicException;
  60811. use Symfony\Component\Console\Output\OutputInterface;
  60812. class ProgressIndicator
  60813. {
  60814. private const FORMATS = [
  60815. 'normal' => ' %indicator% %message%',
  60816. 'normal_no_ansi' => ' %message%',
  60817. 'verbose' => ' %indicator% %message% (%elapsed:6s%)',
  60818. 'verbose_no_ansi' => ' %message% (%elapsed:6s%)',
  60819. 'very_verbose' => ' %indicator% %message% (%elapsed:6s%, %memory:6s%)',
  60820. 'very_verbose_no_ansi' => ' %message% (%elapsed:6s%, %memory:6s%)',
  60821. ];
  60822. private $output;
  60823. private $startTime;
  60824. private $format;
  60825. private $message;
  60826. private $indicatorValues;
  60827. private $indicatorCurrent;
  60828. private $indicatorChangeInterval;
  60829. private $indicatorUpdateTime;
  60830. private $started = false;
  60831. private static $formatters;
  60832. public function __construct(OutputInterface $output, string $format = null, int $indicatorChangeInterval = 100, array $indicatorValues = null)
  60833. {
  60834. $this->output = $output;
  60835. if (null === $format) {
  60836. $format = $this->determineBestFormat();
  60837. }
  60838. if (null === $indicatorValues) {
  60839. $indicatorValues = ['-', '\\', '|', '/'];
  60840. }
  60841. $indicatorValues = array_values($indicatorValues);
  60842. if (2 > \count($indicatorValues)) {
  60843. throw new InvalidArgumentException('Must have at least 2 indicator value characters.');
  60844. }
  60845. $this->format = self::getFormatDefinition($format);
  60846. $this->indicatorChangeInterval = $indicatorChangeInterval;
  60847. $this->indicatorValues = $indicatorValues;
  60848. $this->startTime = time();
  60849. }
  60850. public function setMessage(?string $message)
  60851. {
  60852. $this->message = $message;
  60853. $this->display();
  60854. }
  60855. public function start(string $message)
  60856. {
  60857. if ($this->started) {
  60858. throw new LogicException('Progress indicator already started.');
  60859. }
  60860. $this->message = $message;
  60861. $this->started = true;
  60862. $this->startTime = time();
  60863. $this->indicatorUpdateTime = $this->getCurrentTimeInMilliseconds() + $this->indicatorChangeInterval;
  60864. $this->indicatorCurrent = 0;
  60865. $this->display();
  60866. }
  60867. public function advance()
  60868. {
  60869. if (!$this->started) {
  60870. throw new LogicException('Progress indicator has not yet been started.');
  60871. }
  60872. if (!$this->output->isDecorated()) {
  60873. return;
  60874. }
  60875. $currentTime = $this->getCurrentTimeInMilliseconds();
  60876. if ($currentTime < $this->indicatorUpdateTime) {
  60877. return;
  60878. }
  60879. $this->indicatorUpdateTime = $currentTime + $this->indicatorChangeInterval;
  60880. ++$this->indicatorCurrent;
  60881. $this->display();
  60882. }
  60883. public function finish(string $message)
  60884. {
  60885. if (!$this->started) {
  60886. throw new LogicException('Progress indicator has not yet been started.');
  60887. }
  60888. $this->message = $message;
  60889. $this->display();
  60890. $this->output->writeln('');
  60891. $this->started = false;
  60892. }
  60893. public static function getFormatDefinition(string $name)
  60894. {
  60895. return self::FORMATS[$name] ?? null;
  60896. }
  60897. public static function setPlaceholderFormatterDefinition(string $name, callable $callable)
  60898. {
  60899. if (!self::$formatters) {
  60900. self::$formatters = self::initPlaceholderFormatters();
  60901. }
  60902. self::$formatters[$name] = $callable;
  60903. }
  60904. public static function getPlaceholderFormatterDefinition(string $name)
  60905. {
  60906. if (!self::$formatters) {
  60907. self::$formatters = self::initPlaceholderFormatters();
  60908. }
  60909. return self::$formatters[$name] ?? null;
  60910. }
  60911. private function display()
  60912. {
  60913. if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) {
  60914. return;
  60915. }
  60916. $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) {
  60917. if ($formatter = self::getPlaceholderFormatterDefinition($matches[1])) {
  60918. return $formatter($this);
  60919. }
  60920. return $matches[0];
  60921. }, $this->format ?? ''));
  60922. }
  60923. private function determineBestFormat(): string
  60924. {
  60925. switch ($this->output->getVerbosity()) {
  60926. case OutputInterface::VERBOSITY_VERBOSE:
  60927. return $this->output->isDecorated() ? 'verbose' : 'verbose_no_ansi';
  60928. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  60929. case OutputInterface::VERBOSITY_DEBUG:
  60930. return $this->output->isDecorated() ? 'very_verbose' : 'very_verbose_no_ansi';
  60931. default:
  60932. return $this->output->isDecorated() ? 'normal' : 'normal_no_ansi';
  60933. }
  60934. }
  60935. private function overwrite(string $message)
  60936. {
  60937. if ($this->output->isDecorated()) {
  60938. $this->output->write("\x0D\x1B[2K");
  60939. $this->output->write($message);
  60940. } else {
  60941. $this->output->writeln($message);
  60942. }
  60943. }
  60944. private function getCurrentTimeInMilliseconds(): float
  60945. {
  60946. return round(microtime(true) * 1000);
  60947. }
  60948. private static function initPlaceholderFormatters(): array
  60949. {
  60950. return [
  60951. 'indicator' => function (self $indicator) {
  60952. return $indicator->indicatorValues[$indicator->indicatorCurrent % \count($indicator->indicatorValues)];
  60953. },
  60954. 'message' => function (self $indicator) {
  60955. return $indicator->message;
  60956. },
  60957. 'elapsed' => function (self $indicator) {
  60958. return Helper::formatTime(time() - $indicator->startTime);
  60959. },
  60960. 'memory' => function () {
  60961. return Helper::formatMemory(memory_get_usage(true));
  60962. },
  60963. ];
  60964. }
  60965. }
  60966. <?php
  60967. namespace Symfony\Component\Console\Helper;
  60968. use Symfony\Component\Console\Cursor;
  60969. use Symfony\Component\Console\Exception\MissingInputException;
  60970. use Symfony\Component\Console\Exception\RuntimeException;
  60971. use Symfony\Component\Console\Formatter\OutputFormatter;
  60972. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  60973. use Symfony\Component\Console\Input\InputInterface;
  60974. use Symfony\Component\Console\Input\StreamableInputInterface;
  60975. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  60976. use Symfony\Component\Console\Output\ConsoleSectionOutput;
  60977. use Symfony\Component\Console\Output\OutputInterface;
  60978. use Symfony\Component\Console\Question\ChoiceQuestion;
  60979. use Symfony\Component\Console\Question\Question;
  60980. use Symfony\Component\Console\Terminal;
  60981. use function Symfony\Component\String\s;
  60982. class QuestionHelper extends Helper
  60983. {
  60984. private $inputStream;
  60985. private static $stty = true;
  60986. private static $stdinIsInteractive;
  60987. public function ask(InputInterface $input, OutputInterface $output, Question $question)
  60988. {
  60989. if ($output instanceof ConsoleOutputInterface) {
  60990. $output = $output->getErrorOutput();
  60991. }
  60992. if (!$input->isInteractive()) {
  60993. return $this->getDefaultAnswer($question);
  60994. }
  60995. if ($input instanceof StreamableInputInterface && $stream = $input->getStream()) {
  60996. $this->inputStream = $stream;
  60997. }
  60998. try {
  60999. if (!$question->getValidator()) {
  61000. return $this->doAsk($output, $question);
  61001. }
  61002. $interviewer = function () use ($output, $question) {
  61003. return $this->doAsk($output, $question);
  61004. };
  61005. return $this->validateAttempts($interviewer, $output, $question);
  61006. } catch (MissingInputException $exception) {
  61007. $input->setInteractive(false);
  61008. if (null === $fallbackOutput = $this->getDefaultAnswer($question)) {
  61009. throw $exception;
  61010. }
  61011. return $fallbackOutput;
  61012. }
  61013. }
  61014. public function getName()
  61015. {
  61016. return 'question';
  61017. }
  61018. public static function disableStty()
  61019. {
  61020. self::$stty = false;
  61021. }
  61022. private function doAsk(OutputInterface $output, Question $question)
  61023. {
  61024. $this->writePrompt($output, $question);
  61025. $inputStream = $this->inputStream ?: \STDIN;
  61026. $autocomplete = $question->getAutocompleterCallback();
  61027. if (null === $autocomplete || !self::$stty || !Terminal::hasSttyAvailable()) {
  61028. $ret = false;
  61029. if ($question->isHidden()) {
  61030. try {
  61031. $hiddenResponse = $this->getHiddenResponse($output, $inputStream, $question->isTrimmable());
  61032. $ret = $question->isTrimmable() ? trim($hiddenResponse) : $hiddenResponse;
  61033. } catch (RuntimeException $e) {
  61034. if (!$question->isHiddenFallback()) {
  61035. throw $e;
  61036. }
  61037. }
  61038. }
  61039. if (false === $ret) {
  61040. $isBlocked = stream_get_meta_data($inputStream)['blocked'] ?? true;
  61041. if (!$isBlocked) {
  61042. stream_set_blocking($inputStream, true);
  61043. }
  61044. $ret = $this->readInput($inputStream, $question);
  61045. if (!$isBlocked) {
  61046. stream_set_blocking($inputStream, false);
  61047. }
  61048. if (false === $ret) {
  61049. throw new MissingInputException('Aborted.');
  61050. }
  61051. if ($question->isTrimmable()) {
  61052. $ret = trim($ret);
  61053. }
  61054. }
  61055. } else {
  61056. $autocomplete = $this->autocomplete($output, $question, $inputStream, $autocomplete);
  61057. $ret = $question->isTrimmable() ? trim($autocomplete) : $autocomplete;
  61058. }
  61059. if ($output instanceof ConsoleSectionOutput) {
  61060. $output->addContent($ret);
  61061. }
  61062. $ret = \strlen($ret) > 0 ? $ret : $question->getDefault();
  61063. if ($normalizer = $question->getNormalizer()) {
  61064. return $normalizer($ret);
  61065. }
  61066. return $ret;
  61067. }
  61068. private function getDefaultAnswer(Question $question)
  61069. {
  61070. $default = $question->getDefault();
  61071. if (null === $default) {
  61072. return $default;
  61073. }
  61074. if ($validator = $question->getValidator()) {
  61075. return \call_user_func($question->getValidator(), $default);
  61076. } elseif ($question instanceof ChoiceQuestion) {
  61077. $choices = $question->getChoices();
  61078. if (!$question->isMultiselect()) {
  61079. return $choices[$default] ?? $default;
  61080. }
  61081. $default = explode(',', $default);
  61082. foreach ($default as $k => $v) {
  61083. $v = $question->isTrimmable() ? trim($v) : $v;
  61084. $default[$k] = $choices[$v] ?? $v;
  61085. }
  61086. }
  61087. return $default;
  61088. }
  61089. protected function writePrompt(OutputInterface $output, Question $question)
  61090. {
  61091. $message = $question->getQuestion();
  61092. if ($question instanceof ChoiceQuestion) {
  61093. $output->writeln(array_merge([
  61094. $question->getQuestion(),
  61095. ], $this->formatChoiceQuestionChoices($question, 'info')));
  61096. $message = $question->getPrompt();
  61097. }
  61098. $output->write($message);
  61099. }
  61100. protected function formatChoiceQuestionChoices(ChoiceQuestion $question, string $tag)
  61101. {
  61102. $messages = [];
  61103. $maxWidth = max(array_map([__CLASS__, 'width'], array_keys($choices = $question->getChoices())));
  61104. foreach ($choices as $key => $value) {
  61105. $padding = str_repeat(' ', $maxWidth - self::width($key));
  61106. $messages[] = sprintf(" [<$tag>%s$padding</$tag>] %s", $key, $value);
  61107. }
  61108. return $messages;
  61109. }
  61110. protected function writeError(OutputInterface $output, \Exception $error)
  61111. {
  61112. if (null !== $this->getHelperSet() && $this->getHelperSet()->has('formatter')) {
  61113. $message = $this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error');
  61114. } else {
  61115. $message = '<error>'.$error->getMessage().'</error>';
  61116. }
  61117. $output->writeln($message);
  61118. }
  61119. private function autocomplete(OutputInterface $output, Question $question, $inputStream, callable $autocomplete): string
  61120. {
  61121. $cursor = new Cursor($output, $inputStream);
  61122. $fullChoice = '';
  61123. $ret = '';
  61124. $i = 0;
  61125. $ofs = -1;
  61126. $matches = $autocomplete($ret);
  61127. $numMatches = \count($matches);
  61128. $sttyMode = shell_exec('stty -g');
  61129. $isStdin = 'php://stdin' === (stream_get_meta_data($inputStream)['uri'] ?? null);
  61130. $r = [$inputStream];
  61131. $w = [];
  61132. shell_exec('stty -icanon -echo');
  61133. $output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white'));
  61134. while (!feof($inputStream)) {
  61135. while ($isStdin && 0 === @stream_select($r, $w, $w, 0, 100)) {
  61136. $r = [$inputStream];
  61137. }
  61138. $c = fread($inputStream, 1);
  61139. if (false === $c || ('' === $ret && '' === $c && null === $question->getDefault())) {
  61140. shell_exec('stty '.$sttyMode);
  61141. throw new MissingInputException('Aborted.');
  61142. } elseif ("\177" === $c) {
  61143. if (0 === $numMatches && 0 !== $i) {
  61144. --$i;
  61145. $cursor->moveLeft(s($fullChoice)->slice(-1)->width(false));
  61146. $fullChoice = self::substr($fullChoice, 0, $i);
  61147. }
  61148. if (0 === $i) {
  61149. $ofs = -1;
  61150. $matches = $autocomplete($ret);
  61151. $numMatches = \count($matches);
  61152. } else {
  61153. $numMatches = 0;
  61154. }
  61155. $ret = self::substr($ret, 0, $i);
  61156. } elseif ("\033" === $c) {
  61157. $c .= fread($inputStream, 2);
  61158. if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) {
  61159. if ('A' === $c[2] && -1 === $ofs) {
  61160. $ofs = 0;
  61161. }
  61162. if (0 === $numMatches) {
  61163. continue;
  61164. }
  61165. $ofs += ('A' === $c[2]) ? -1 : 1;
  61166. $ofs = ($numMatches + $ofs) % $numMatches;
  61167. }
  61168. } elseif (\ord($c) < 32) {
  61169. if ("\t" === $c || "\n" === $c) {
  61170. if ($numMatches > 0 && -1 !== $ofs) {
  61171. $ret = (string) $matches[$ofs];
  61172. $remainingCharacters = substr($ret, \strlen(trim($this->mostRecentlyEnteredValue($fullChoice))));
  61173. $output->write($remainingCharacters);
  61174. $fullChoice .= $remainingCharacters;
  61175. $i = (false === $encoding = mb_detect_encoding($fullChoice, null, true)) ? \strlen($fullChoice) : mb_strlen($fullChoice, $encoding);
  61176. $matches = array_filter(
  61177. $autocomplete($ret),
  61178. function ($match) use ($ret) {
  61179. return '' === $ret || str_starts_with($match, $ret);
  61180. }
  61181. );
  61182. $numMatches = \count($matches);
  61183. $ofs = -1;
  61184. }
  61185. if ("\n" === $c) {
  61186. $output->write($c);
  61187. break;
  61188. }
  61189. $numMatches = 0;
  61190. }
  61191. continue;
  61192. } else {
  61193. if ("\x80" <= $c) {
  61194. $c .= fread($inputStream, ["\xC0" => 1, "\xD0" => 1, "\xE0" => 2, "\xF0" => 3][$c & "\xF0"]);
  61195. }
  61196. $output->write($c);
  61197. $ret .= $c;
  61198. $fullChoice .= $c;
  61199. ++$i;
  61200. $tempRet = $ret;
  61201. if ($question instanceof ChoiceQuestion && $question->isMultiselect()) {
  61202. $tempRet = $this->mostRecentlyEnteredValue($fullChoice);
  61203. }
  61204. $numMatches = 0;
  61205. $ofs = 0;
  61206. foreach ($autocomplete($ret) as $value) {
  61207. if (str_starts_with($value, $tempRet)) {
  61208. $matches[$numMatches++] = $value;
  61209. }
  61210. }
  61211. }
  61212. $cursor->clearLineAfter();
  61213. if ($numMatches > 0 && -1 !== $ofs) {
  61214. $cursor->savePosition();
  61215. $charactersEntered = \strlen(trim($this->mostRecentlyEnteredValue($fullChoice)));
  61216. $output->write('<hl>'.OutputFormatter::escapeTrailingBackslash(substr($matches[$ofs], $charactersEntered)).'</hl>');
  61217. $cursor->restorePosition();
  61218. }
  61219. }
  61220. shell_exec('stty '.$sttyMode);
  61221. return $fullChoice;
  61222. }
  61223. private function mostRecentlyEnteredValue(string $entered): string
  61224. {
  61225. if (!str_contains($entered, ',')) {
  61226. return $entered;
  61227. }
  61228. $choices = explode(',', $entered);
  61229. if ('' !== $lastChoice = trim($choices[\count($choices) - 1])) {
  61230. return $lastChoice;
  61231. }
  61232. return $entered;
  61233. }
  61234. private function getHiddenResponse(OutputInterface $output, $inputStream, bool $trimmable = true): string
  61235. {
  61236. if ('\\' === \DIRECTORY_SEPARATOR) {
  61237. $exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
  61238. if ('phar:' === substr(__FILE__, 0, 5)) {
  61239. $tmpExe = sys_get_temp_dir().'/hiddeninput.exe';
  61240. copy($exe, $tmpExe);
  61241. $exe = $tmpExe;
  61242. }
  61243. $sExec = shell_exec('"'.$exe.'"');
  61244. $value = $trimmable ? rtrim($sExec) : $sExec;
  61245. $output->writeln('');
  61246. if (isset($tmpExe)) {
  61247. unlink($tmpExe);
  61248. }
  61249. return $value;
  61250. }
  61251. if (self::$stty && Terminal::hasSttyAvailable()) {
  61252. $sttyMode = shell_exec('stty -g');
  61253. shell_exec('stty -echo');
  61254. } elseif ($this->isInteractiveInput($inputStream)) {
  61255. throw new RuntimeException('Unable to hide the response.');
  61256. }
  61257. $value = fgets($inputStream, 4096);
  61258. if (self::$stty && Terminal::hasSttyAvailable()) {
  61259. shell_exec('stty '.$sttyMode);
  61260. }
  61261. if (false === $value) {
  61262. throw new MissingInputException('Aborted.');
  61263. }
  61264. if ($trimmable) {
  61265. $value = trim($value);
  61266. }
  61267. $output->writeln('');
  61268. return $value;
  61269. }
  61270. private function validateAttempts(callable $interviewer, OutputInterface $output, Question $question)
  61271. {
  61272. $error = null;
  61273. $attempts = $question->getMaxAttempts();
  61274. while (null === $attempts || $attempts--) {
  61275. if (null !== $error) {
  61276. $this->writeError($output, $error);
  61277. }
  61278. try {
  61279. return $question->getValidator()($interviewer());
  61280. } catch (RuntimeException $e) {
  61281. throw $e;
  61282. } catch (\Exception $error) {
  61283. }
  61284. }
  61285. throw $error;
  61286. }
  61287. private function isInteractiveInput($inputStream): bool
  61288. {
  61289. if ('php://stdin' !== (stream_get_meta_data($inputStream)['uri'] ?? null)) {
  61290. return false;
  61291. }
  61292. if (null !== self::$stdinIsInteractive) {
  61293. return self::$stdinIsInteractive;
  61294. }
  61295. if (\function_exists('stream_isatty')) {
  61296. return self::$stdinIsInteractive = @stream_isatty(fopen('php://stdin', 'r'));
  61297. }
  61298. if (\function_exists('posix_isatty')) {
  61299. return self::$stdinIsInteractive = @posix_isatty(fopen('php://stdin', 'r'));
  61300. }
  61301. if (!\function_exists('shell_exec')) {
  61302. return self::$stdinIsInteractive = true;
  61303. }
  61304. return self::$stdinIsInteractive = (bool) shell_exec('stty 2> '.('\\' === \DIRECTORY_SEPARATOR ? 'NUL' : '/dev/null'));
  61305. }
  61306. private function readInput($inputStream, Question $question)
  61307. {
  61308. if (!$question->isMultiline()) {
  61309. $cp = $this->setIOCodepage();
  61310. $ret = fgets($inputStream, 4096);
  61311. return $this->resetIOCodepage($cp, $ret);
  61312. }
  61313. $multiLineStreamReader = $this->cloneInputStream($inputStream);
  61314. if (null === $multiLineStreamReader) {
  61315. return false;
  61316. }
  61317. $ret = '';
  61318. $cp = $this->setIOCodepage();
  61319. while (false !== ($char = fgetc($multiLineStreamReader))) {
  61320. if (\PHP_EOL === "{$ret}{$char}") {
  61321. break;
  61322. }
  61323. $ret .= $char;
  61324. }
  61325. return $this->resetIOCodepage($cp, $ret);
  61326. }
  61327. private function setIOCodepage(): int
  61328. {
  61329. if (\function_exists('sapi_windows_cp_set')) {
  61330. $cp = sapi_windows_cp_get();
  61331. sapi_windows_cp_set(sapi_windows_cp_get('oem'));
  61332. return $cp;
  61333. }
  61334. return 0;
  61335. }
  61336. private function resetIOCodepage(int $cp, $input)
  61337. {
  61338. if (0 !== $cp) {
  61339. sapi_windows_cp_set($cp);
  61340. if (false !== $input && '' !== $input) {
  61341. $input = sapi_windows_cp_conv(sapi_windows_cp_get('oem'), $cp, $input);
  61342. }
  61343. }
  61344. return $input;
  61345. }
  61346. private function cloneInputStream($inputStream)
  61347. {
  61348. $streamMetaData = stream_get_meta_data($inputStream);
  61349. $seekable = $streamMetaData['seekable'] ?? false;
  61350. $mode = $streamMetaData['mode'] ?? 'rb';
  61351. $uri = $streamMetaData['uri'] ?? null;
  61352. if (null === $uri) {
  61353. return null;
  61354. }
  61355. $cloneStream = fopen($uri, $mode);
  61356. if (true === $seekable && !\in_array($mode, ['r', 'rb', 'rt'])) {
  61357. $offset = ftell($inputStream);
  61358. rewind($inputStream);
  61359. stream_copy_to_stream($inputStream, $cloneStream);
  61360. fseek($inputStream, $offset);
  61361. fseek($cloneStream, $offset);
  61362. }
  61363. return $cloneStream;
  61364. }
  61365. }
  61366. <?php
  61367. namespace Symfony\Component\Console\Helper;
  61368. use Symfony\Component\Console\Formatter\OutputFormatter;
  61369. use Symfony\Component\Console\Output\OutputInterface;
  61370. use Symfony\Component\Console\Question\ChoiceQuestion;
  61371. use Symfony\Component\Console\Question\ConfirmationQuestion;
  61372. use Symfony\Component\Console\Question\Question;
  61373. use Symfony\Component\Console\Style\SymfonyStyle;
  61374. class SymfonyQuestionHelper extends QuestionHelper
  61375. {
  61376. protected function writePrompt(OutputInterface $output, Question $question)
  61377. {
  61378. $text = OutputFormatter::escapeTrailingBackslash($question->getQuestion());
  61379. $default = $question->getDefault();
  61380. if ($question->isMultiline()) {
  61381. $text .= sprintf(' (press %s to continue)', $this->getEofShortcut());
  61382. }
  61383. switch (true) {
  61384. case null === $default:
  61385. $text = sprintf(' <info>%s</info>:', $text);
  61386. break;
  61387. case $question instanceof ConfirmationQuestion:
  61388. $text = sprintf(' <info>%s (yes/no)</info> [<comment>%s</comment>]:', $text, $default ? 'yes' : 'no');
  61389. break;
  61390. case $question instanceof ChoiceQuestion && $question->isMultiselect():
  61391. $choices = $question->getChoices();
  61392. $default = explode(',', $default);
  61393. foreach ($default as $key => $value) {
  61394. $default[$key] = $choices[trim($value)];
  61395. }
  61396. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(implode(', ', $default)));
  61397. break;
  61398. case $question instanceof ChoiceQuestion:
  61399. $choices = $question->getChoices();
  61400. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($choices[$default] ?? $default));
  61401. break;
  61402. default:
  61403. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($default));
  61404. }
  61405. $output->writeln($text);
  61406. $prompt = ' > ';
  61407. if ($question instanceof ChoiceQuestion) {
  61408. $output->writeln($this->formatChoiceQuestionChoices($question, 'comment'));
  61409. $prompt = $question->getPrompt();
  61410. }
  61411. $output->write($prompt);
  61412. }
  61413. protected function writeError(OutputInterface $output, \Exception $error)
  61414. {
  61415. if ($output instanceof SymfonyStyle) {
  61416. $output->newLine();
  61417. $output->error($error->getMessage());
  61418. return;
  61419. }
  61420. parent::writeError($output, $error);
  61421. }
  61422. private function getEofShortcut(): string
  61423. {
  61424. if ('Windows' === \PHP_OS_FAMILY) {
  61425. return '<comment>Ctrl+Z</comment> then <comment>Enter</comment>';
  61426. }
  61427. return '<comment>Ctrl+D</comment>';
  61428. }
  61429. }
  61430. <?php
  61431. namespace Symfony\Component\Console\Helper;
  61432. use Symfony\Component\Console\Exception\InvalidArgumentException;
  61433. use Symfony\Component\Console\Exception\RuntimeException;
  61434. use Symfony\Component\Console\Formatter\OutputFormatter;
  61435. use Symfony\Component\Console\Formatter\WrappableOutputFormatterInterface;
  61436. use Symfony\Component\Console\Output\ConsoleSectionOutput;
  61437. use Symfony\Component\Console\Output\OutputInterface;
  61438. class Table
  61439. {
  61440. private const SEPARATOR_TOP = 0;
  61441. private const SEPARATOR_TOP_BOTTOM = 1;
  61442. private const SEPARATOR_MID = 2;
  61443. private const SEPARATOR_BOTTOM = 3;
  61444. private const BORDER_OUTSIDE = 0;
  61445. private const BORDER_INSIDE = 1;
  61446. private $headerTitle;
  61447. private $footerTitle;
  61448. private $headers = [];
  61449. private $rows = [];
  61450. private $horizontal = false;
  61451. private $effectiveColumnWidths = [];
  61452. private $numberOfColumns;
  61453. private $output;
  61454. private $style;
  61455. private $columnStyles = [];
  61456. private $columnWidths = [];
  61457. private $columnMaxWidths = [];
  61458. private static $styles;
  61459. private $rendered = false;
  61460. public function __construct(OutputInterface $output)
  61461. {
  61462. $this->output = $output;
  61463. if (!self::$styles) {
  61464. self::$styles = self::initStyles();
  61465. }
  61466. $this->setStyle('default');
  61467. }
  61468. public static function setStyleDefinition(string $name, TableStyle $style)
  61469. {
  61470. if (!self::$styles) {
  61471. self::$styles = self::initStyles();
  61472. }
  61473. self::$styles[$name] = $style;
  61474. }
  61475. public static function getStyleDefinition(string $name)
  61476. {
  61477. if (!self::$styles) {
  61478. self::$styles = self::initStyles();
  61479. }
  61480. if (isset(self::$styles[$name])) {
  61481. return self::$styles[$name];
  61482. }
  61483. throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
  61484. }
  61485. public function setStyle($name)
  61486. {
  61487. $this->style = $this->resolveStyle($name);
  61488. return $this;
  61489. }
  61490. public function getStyle()
  61491. {
  61492. return $this->style;
  61493. }
  61494. public function setColumnStyle(int $columnIndex, $name)
  61495. {
  61496. $this->columnStyles[$columnIndex] = $this->resolveStyle($name);
  61497. return $this;
  61498. }
  61499. public function getColumnStyle(int $columnIndex)
  61500. {
  61501. return $this->columnStyles[$columnIndex] ?? $this->getStyle();
  61502. }
  61503. public function setColumnWidth(int $columnIndex, int $width)
  61504. {
  61505. $this->columnWidths[$columnIndex] = $width;
  61506. return $this;
  61507. }
  61508. public function setColumnWidths(array $widths)
  61509. {
  61510. $this->columnWidths = [];
  61511. foreach ($widths as $index => $width) {
  61512. $this->setColumnWidth($index, $width);
  61513. }
  61514. return $this;
  61515. }
  61516. public function setColumnMaxWidth(int $columnIndex, int $width): self
  61517. {
  61518. if (!$this->output->getFormatter() instanceof WrappableOutputFormatterInterface) {
  61519. 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())));
  61520. }
  61521. $this->columnMaxWidths[$columnIndex] = $width;
  61522. return $this;
  61523. }
  61524. public function setHeaders(array $headers)
  61525. {
  61526. $headers = array_values($headers);
  61527. if (!empty($headers) && !\is_array($headers[0])) {
  61528. $headers = [$headers];
  61529. }
  61530. $this->headers = $headers;
  61531. return $this;
  61532. }
  61533. public function setRows(array $rows)
  61534. {
  61535. $this->rows = [];
  61536. return $this->addRows($rows);
  61537. }
  61538. public function addRows(array $rows)
  61539. {
  61540. foreach ($rows as $row) {
  61541. $this->addRow($row);
  61542. }
  61543. return $this;
  61544. }
  61545. public function addRow($row)
  61546. {
  61547. if ($row instanceof TableSeparator) {
  61548. $this->rows[] = $row;
  61549. return $this;
  61550. }
  61551. if (!\is_array($row)) {
  61552. throw new InvalidArgumentException('A row must be an array or a TableSeparator instance.');
  61553. }
  61554. $this->rows[] = array_values($row);
  61555. return $this;
  61556. }
  61557. public function appendRow($row): self
  61558. {
  61559. if (!$this->output instanceof ConsoleSectionOutput) {
  61560. throw new RuntimeException(sprintf('Output should be an instance of "%s" when calling "%s".', ConsoleSectionOutput::class, __METHOD__));
  61561. }
  61562. if ($this->rendered) {
  61563. $this->output->clear($this->calculateRowCount());
  61564. }
  61565. $this->addRow($row);
  61566. $this->render();
  61567. return $this;
  61568. }
  61569. public function setRow($column, array $row)
  61570. {
  61571. $this->rows[$column] = $row;
  61572. return $this;
  61573. }
  61574. public function setHeaderTitle(?string $title): self
  61575. {
  61576. $this->headerTitle = $title;
  61577. return $this;
  61578. }
  61579. public function setFooterTitle(?string $title): self
  61580. {
  61581. $this->footerTitle = $title;
  61582. return $this;
  61583. }
  61584. public function setHorizontal(bool $horizontal = true): self
  61585. {
  61586. $this->horizontal = $horizontal;
  61587. return $this;
  61588. }
  61589. public function render()
  61590. {
  61591. $divider = new TableSeparator();
  61592. if ($this->horizontal) {
  61593. $rows = [];
  61594. foreach ($this->headers[0] ?? [] as $i => $header) {
  61595. $rows[$i] = [$header];
  61596. foreach ($this->rows as $row) {
  61597. if ($row instanceof TableSeparator) {
  61598. continue;
  61599. }
  61600. if (isset($row[$i])) {
  61601. $rows[$i][] = $row[$i];
  61602. } elseif ($rows[$i][0] instanceof TableCell && $rows[$i][0]->getColspan() >= 2) {
  61603. } else {
  61604. $rows[$i][] = null;
  61605. }
  61606. }
  61607. }
  61608. } else {
  61609. $rows = array_merge($this->headers, [$divider], $this->rows);
  61610. }
  61611. $this->calculateNumberOfColumns($rows);
  61612. $rowGroups = $this->buildTableRows($rows);
  61613. $this->calculateColumnsWidth($rowGroups);
  61614. $isHeader = !$this->horizontal;
  61615. $isFirstRow = $this->horizontal;
  61616. $hasTitle = (bool) $this->headerTitle;
  61617. foreach ($rowGroups as $rowGroup) {
  61618. $isHeaderSeparatorRendered = false;
  61619. foreach ($rowGroup as $row) {
  61620. if ($divider === $row) {
  61621. $isHeader = false;
  61622. $isFirstRow = true;
  61623. continue;
  61624. }
  61625. if ($row instanceof TableSeparator) {
  61626. $this->renderRowSeparator();
  61627. continue;
  61628. }
  61629. if (!$row) {
  61630. continue;
  61631. }
  61632. if ($isHeader && !$isHeaderSeparatorRendered) {
  61633. $this->renderRowSeparator(
  61634. $isHeader ? self::SEPARATOR_TOP : self::SEPARATOR_TOP_BOTTOM,
  61635. $hasTitle ? $this->headerTitle : null,
  61636. $hasTitle ? $this->style->getHeaderTitleFormat() : null
  61637. );
  61638. $hasTitle = false;
  61639. $isHeaderSeparatorRendered = true;
  61640. }
  61641. if ($isFirstRow) {
  61642. $this->renderRowSeparator(
  61643. $isHeader ? self::SEPARATOR_TOP : self::SEPARATOR_TOP_BOTTOM,
  61644. $hasTitle ? $this->headerTitle : null,
  61645. $hasTitle ? $this->style->getHeaderTitleFormat() : null
  61646. );
  61647. $isFirstRow = false;
  61648. $hasTitle = false;
  61649. }
  61650. if ($this->horizontal) {
  61651. $this->renderRow($row, $this->style->getCellRowFormat(), $this->style->getCellHeaderFormat());
  61652. } else {
  61653. $this->renderRow($row, $isHeader ? $this->style->getCellHeaderFormat() : $this->style->getCellRowFormat());
  61654. }
  61655. }
  61656. }
  61657. $this->renderRowSeparator(self::SEPARATOR_BOTTOM, $this->footerTitle, $this->style->getFooterTitleFormat());
  61658. $this->cleanup();
  61659. $this->rendered = true;
  61660. }
  61661. private function renderRowSeparator(int $type = self::SEPARATOR_MID, string $title = null, string $titleFormat = null)
  61662. {
  61663. if (0 === $count = $this->numberOfColumns) {
  61664. return;
  61665. }
  61666. $borders = $this->style->getBorderChars();
  61667. if (!$borders[0] && !$borders[2] && !$this->style->getCrossingChar()) {
  61668. return;
  61669. }
  61670. $crossings = $this->style->getCrossingChars();
  61671. if (self::SEPARATOR_MID === $type) {
  61672. [$horizontal, $leftChar, $midChar, $rightChar] = [$borders[2], $crossings[8], $crossings[0], $crossings[4]];
  61673. } elseif (self::SEPARATOR_TOP === $type) {
  61674. [$horizontal, $leftChar, $midChar, $rightChar] = [$borders[0], $crossings[1], $crossings[2], $crossings[3]];
  61675. } elseif (self::SEPARATOR_TOP_BOTTOM === $type) {
  61676. [$horizontal, $leftChar, $midChar, $rightChar] = [$borders[0], $crossings[9], $crossings[10], $crossings[11]];
  61677. } else {
  61678. [$horizontal, $leftChar, $midChar, $rightChar] = [$borders[0], $crossings[7], $crossings[6], $crossings[5]];
  61679. }
  61680. $markup = $leftChar;
  61681. for ($column = 0; $column < $count; ++$column) {
  61682. $markup .= str_repeat($horizontal, $this->effectiveColumnWidths[$column]);
  61683. $markup .= $column === $count - 1 ? $rightChar : $midChar;
  61684. }
  61685. if (null !== $title) {
  61686. $titleLength = Helper::width(Helper::removeDecoration($formatter = $this->output->getFormatter(), $formattedTitle = sprintf($titleFormat, $title)));
  61687. $markupLength = Helper::width($markup);
  61688. if ($titleLength > $limit = $markupLength - 4) {
  61689. $titleLength = $limit;
  61690. $formatLength = Helper::width(Helper::removeDecoration($formatter, sprintf($titleFormat, '')));
  61691. $formattedTitle = sprintf($titleFormat, Helper::substr($title, 0, $limit - $formatLength - 3).'...');
  61692. }
  61693. $titleStart = intdiv($markupLength - $titleLength, 2);
  61694. if (false === mb_detect_encoding($markup, null, true)) {
  61695. $markup = substr_replace($markup, $formattedTitle, $titleStart, $titleLength);
  61696. } else {
  61697. $markup = mb_substr($markup, 0, $titleStart).$formattedTitle.mb_substr($markup, $titleStart + $titleLength);
  61698. }
  61699. }
  61700. $this->output->writeln(sprintf($this->style->getBorderFormat(), $markup));
  61701. }
  61702. private function renderColumnSeparator(int $type = self::BORDER_OUTSIDE): string
  61703. {
  61704. $borders = $this->style->getBorderChars();
  61705. return sprintf($this->style->getBorderFormat(), self::BORDER_OUTSIDE === $type ? $borders[1] : $borders[3]);
  61706. }
  61707. private function renderRow(array $row, string $cellFormat, string $firstCellFormat = null)
  61708. {
  61709. $rowContent = $this->renderColumnSeparator(self::BORDER_OUTSIDE);
  61710. $columns = $this->getRowColumns($row);
  61711. $last = \count($columns) - 1;
  61712. foreach ($columns as $i => $column) {
  61713. if ($firstCellFormat && 0 === $i) {
  61714. $rowContent .= $this->renderCell($row, $column, $firstCellFormat);
  61715. } else {
  61716. $rowContent .= $this->renderCell($row, $column, $cellFormat);
  61717. }
  61718. $rowContent .= $this->renderColumnSeparator($last === $i ? self::BORDER_OUTSIDE : self::BORDER_INSIDE);
  61719. }
  61720. $this->output->writeln($rowContent);
  61721. }
  61722. private function renderCell(array $row, int $column, string $cellFormat): string
  61723. {
  61724. $cell = $row[$column] ?? '';
  61725. $width = $this->effectiveColumnWidths[$column];
  61726. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  61727. foreach (range($column + 1, $column + $cell->getColspan() - 1) as $nextColumn) {
  61728. $width += $this->getColumnSeparatorWidth() + $this->effectiveColumnWidths[$nextColumn];
  61729. }
  61730. }
  61731. if (false !== $encoding = mb_detect_encoding($cell, null, true)) {
  61732. $width += \strlen($cell) - mb_strwidth($cell, $encoding);
  61733. }
  61734. $style = $this->getColumnStyle($column);
  61735. if ($cell instanceof TableSeparator) {
  61736. return sprintf($style->getBorderFormat(), str_repeat($style->getBorderChars()[2], $width));
  61737. }
  61738. $width += Helper::length($cell) - Helper::length(Helper::removeDecoration($this->output->getFormatter(), $cell));
  61739. $content = sprintf($style->getCellRowContentFormat(), $cell);
  61740. $padType = $style->getPadType();
  61741. if ($cell instanceof TableCell && $cell->getStyle() instanceof TableCellStyle) {
  61742. $isNotStyledByTag = !preg_match('/^<(\w+|(\w+=[\w,]+;?)*)>.+<\/(\w+|(\w+=\w+;?)*)?>$/', $cell);
  61743. if ($isNotStyledByTag) {
  61744. $cellFormat = $cell->getStyle()->getCellFormat();
  61745. if (!\is_string($cellFormat)) {
  61746. $tag = http_build_query($cell->getStyle()->getTagOptions(), '', ';');
  61747. $cellFormat = '<'.$tag.'>%s</>';
  61748. }
  61749. if (strstr($content, '</>')) {
  61750. $content = str_replace('</>', '', $content);
  61751. $width -= 3;
  61752. }
  61753. if (strstr($content, '<fg=default;bg=default>')) {
  61754. $content = str_replace('<fg=default;bg=default>', '', $content);
  61755. $width -= \strlen('<fg=default;bg=default>');
  61756. }
  61757. }
  61758. $padType = $cell->getStyle()->getPadByAlign();
  61759. }
  61760. return sprintf($cellFormat, str_pad($content, $width, $style->getPaddingChar(), $padType));
  61761. }
  61762. private function calculateNumberOfColumns(array $rows)
  61763. {
  61764. $columns = [0];
  61765. foreach ($rows as $row) {
  61766. if ($row instanceof TableSeparator) {
  61767. continue;
  61768. }
  61769. $columns[] = $this->getNumberOfColumns($row);
  61770. }
  61771. $this->numberOfColumns = max($columns);
  61772. }
  61773. private function buildTableRows(array $rows): TableRows
  61774. {
  61775. $formatter = $this->output->getFormatter();
  61776. $unmergedRows = [];
  61777. for ($rowKey = 0; $rowKey < \count($rows); ++$rowKey) {
  61778. $rows = $this->fillNextRows($rows, $rowKey);
  61779. foreach ($rows[$rowKey] as $column => $cell) {
  61780. $colspan = $cell instanceof TableCell ? $cell->getColspan() : 1;
  61781. if (isset($this->columnMaxWidths[$column]) && Helper::width(Helper::removeDecoration($formatter, $cell)) > $this->columnMaxWidths[$column]) {
  61782. $cell = $formatter->formatAndWrap($cell, $this->columnMaxWidths[$column] * $colspan);
  61783. }
  61784. if (!strstr($cell ?? '', "\n")) {
  61785. continue;
  61786. }
  61787. $escaped = implode("\n", array_map([OutputFormatter::class, 'escapeTrailingBackslash'], explode("\n", $cell)));
  61788. $cell = $cell instanceof TableCell ? new TableCell($escaped, ['colspan' => $cell->getColspan()]) : $escaped;
  61789. $lines = explode("\n", str_replace("\n", "<fg=default;bg=default></>\n", $cell));
  61790. foreach ($lines as $lineKey => $line) {
  61791. if ($colspan > 1) {
  61792. $line = new TableCell($line, ['colspan' => $colspan]);
  61793. }
  61794. if (0 === $lineKey) {
  61795. $rows[$rowKey][$column] = $line;
  61796. } else {
  61797. if (!\array_key_exists($rowKey, $unmergedRows) || !\array_key_exists($lineKey, $unmergedRows[$rowKey])) {
  61798. $unmergedRows[$rowKey][$lineKey] = $this->copyRow($rows, $rowKey);
  61799. }
  61800. $unmergedRows[$rowKey][$lineKey][$column] = $line;
  61801. }
  61802. }
  61803. }
  61804. }
  61805. return new TableRows(function () use ($rows, $unmergedRows): \Traversable {
  61806. foreach ($rows as $rowKey => $row) {
  61807. $rowGroup = [$row instanceof TableSeparator ? $row : $this->fillCells($row)];
  61808. if (isset($unmergedRows[$rowKey])) {
  61809. foreach ($unmergedRows[$rowKey] as $row) {
  61810. $rowGroup[] = $row instanceof TableSeparator ? $row : $this->fillCells($row);
  61811. }
  61812. }
  61813. yield $rowGroup;
  61814. }
  61815. });
  61816. }
  61817. private function calculateRowCount(): int
  61818. {
  61819. $numberOfRows = \count(iterator_to_array($this->buildTableRows(array_merge($this->headers, [new TableSeparator()], $this->rows))));
  61820. if ($this->headers) {
  61821. ++$numberOfRows;
  61822. }
  61823. if (\count($this->rows) > 0) {
  61824. ++$numberOfRows;
  61825. }
  61826. return $numberOfRows;
  61827. }
  61828. private function fillNextRows(array $rows, int $line): array
  61829. {
  61830. $unmergedRows = [];
  61831. foreach ($rows[$line] as $column => $cell) {
  61832. if (null !== $cell && !$cell instanceof TableCell && !\is_scalar($cell) && !(\is_object($cell) && method_exists($cell, '__toString'))) {
  61833. throw new InvalidArgumentException(sprintf('A cell must be a TableCell, a scalar or an object implementing "__toString()", "%s" given.', get_debug_type($cell)));
  61834. }
  61835. if ($cell instanceof TableCell && $cell->getRowspan() > 1) {
  61836. $nbLines = $cell->getRowspan() - 1;
  61837. $lines = [$cell];
  61838. if (strstr($cell, "\n")) {
  61839. $lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
  61840. $nbLines = \count($lines) > $nbLines ? substr_count($cell, "\n") : $nbLines;
  61841. $rows[$line][$column] = new TableCell($lines[0], ['colspan' => $cell->getColspan(), 'style' => $cell->getStyle()]);
  61842. unset($lines[0]);
  61843. }
  61844. $unmergedRows = array_replace_recursive(array_fill($line + 1, $nbLines, []), $unmergedRows);
  61845. foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
  61846. $value = $lines[$unmergedRowKey - $line] ?? '';
  61847. $unmergedRows[$unmergedRowKey][$column] = new TableCell($value, ['colspan' => $cell->getColspan(), 'style' => $cell->getStyle()]);
  61848. if ($nbLines === $unmergedRowKey - $line) {
  61849. break;
  61850. }
  61851. }
  61852. }
  61853. }
  61854. foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
  61855. if (isset($rows[$unmergedRowKey]) && \is_array($rows[$unmergedRowKey]) && ($this->getNumberOfColumns($rows[$unmergedRowKey]) + $this->getNumberOfColumns($unmergedRows[$unmergedRowKey]) <= $this->numberOfColumns)) {
  61856. foreach ($unmergedRow as $cellKey => $cell) {
  61857. array_splice($rows[$unmergedRowKey], $cellKey, 0, [$cell]);
  61858. }
  61859. } else {
  61860. $row = $this->copyRow($rows, $unmergedRowKey - 1);
  61861. foreach ($unmergedRow as $column => $cell) {
  61862. if (!empty($cell)) {
  61863. $row[$column] = $unmergedRow[$column];
  61864. }
  61865. }
  61866. array_splice($rows, $unmergedRowKey, 0, [$row]);
  61867. }
  61868. }
  61869. return $rows;
  61870. }
  61871. private function fillCells(iterable $row)
  61872. {
  61873. $newRow = [];
  61874. foreach ($row as $column => $cell) {
  61875. $newRow[] = $cell;
  61876. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  61877. foreach (range($column + 1, $column + $cell->getColspan() - 1) as $position) {
  61878. $newRow[] = '';
  61879. }
  61880. }
  61881. }
  61882. return $newRow ?: $row;
  61883. }
  61884. private function copyRow(array $rows, int $line): array
  61885. {
  61886. $row = $rows[$line];
  61887. foreach ($row as $cellKey => $cellValue) {
  61888. $row[$cellKey] = '';
  61889. if ($cellValue instanceof TableCell) {
  61890. $row[$cellKey] = new TableCell('', ['colspan' => $cellValue->getColspan()]);
  61891. }
  61892. }
  61893. return $row;
  61894. }
  61895. private function getNumberOfColumns(array $row): int
  61896. {
  61897. $columns = \count($row);
  61898. foreach ($row as $column) {
  61899. $columns += $column instanceof TableCell ? ($column->getColspan() - 1) : 0;
  61900. }
  61901. return $columns;
  61902. }
  61903. private function getRowColumns(array $row): array
  61904. {
  61905. $columns = range(0, $this->numberOfColumns - 1);
  61906. foreach ($row as $cellKey => $cell) {
  61907. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  61908. $columns = array_diff($columns, range($cellKey + 1, $cellKey + $cell->getColspan() - 1));
  61909. }
  61910. }
  61911. return $columns;
  61912. }
  61913. private function calculateColumnsWidth(iterable $groups)
  61914. {
  61915. for ($column = 0; $column < $this->numberOfColumns; ++$column) {
  61916. $lengths = [];
  61917. foreach ($groups as $group) {
  61918. foreach ($group as $row) {
  61919. if ($row instanceof TableSeparator) {
  61920. continue;
  61921. }
  61922. foreach ($row as $i => $cell) {
  61923. if ($cell instanceof TableCell) {
  61924. $textContent = Helper::removeDecoration($this->output->getFormatter(), $cell);
  61925. $textLength = Helper::width($textContent);
  61926. if ($textLength > 0) {
  61927. $contentColumns = mb_str_split($textContent, ceil($textLength / $cell->getColspan()));
  61928. foreach ($contentColumns as $position => $content) {
  61929. $row[$i + $position] = $content;
  61930. }
  61931. }
  61932. }
  61933. }
  61934. $lengths[] = $this->getCellWidth($row, $column);
  61935. }
  61936. }
  61937. $this->effectiveColumnWidths[$column] = max($lengths) + Helper::width($this->style->getCellRowContentFormat()) - 2;
  61938. }
  61939. }
  61940. private function getColumnSeparatorWidth(): int
  61941. {
  61942. return Helper::width(sprintf($this->style->getBorderFormat(), $this->style->getBorderChars()[3]));
  61943. }
  61944. private function getCellWidth(array $row, int $column): int
  61945. {
  61946. $cellWidth = 0;
  61947. if (isset($row[$column])) {
  61948. $cell = $row[$column];
  61949. $cellWidth = Helper::width(Helper::removeDecoration($this->output->getFormatter(), $cell));
  61950. }
  61951. $columnWidth = $this->columnWidths[$column] ?? 0;
  61952. $cellWidth = max($cellWidth, $columnWidth);
  61953. return isset($this->columnMaxWidths[$column]) ? min($this->columnMaxWidths[$column], $cellWidth) : $cellWidth;
  61954. }
  61955. private function cleanup()
  61956. {
  61957. $this->effectiveColumnWidths = [];
  61958. $this->numberOfColumns = null;
  61959. }
  61960. private static function initStyles(): array
  61961. {
  61962. $borderless = new TableStyle();
  61963. $borderless
  61964. ->setHorizontalBorderChars('=')
  61965. ->setVerticalBorderChars(' ')
  61966. ->setDefaultCrossingChar(' ')
  61967. ;
  61968. $compact = new TableStyle();
  61969. $compact
  61970. ->setHorizontalBorderChars('')
  61971. ->setVerticalBorderChars('')
  61972. ->setDefaultCrossingChar('')
  61973. ->setCellRowContentFormat('%s ')
  61974. ;
  61975. $styleGuide = new TableStyle();
  61976. $styleGuide
  61977. ->setHorizontalBorderChars('-')
  61978. ->setVerticalBorderChars(' ')
  61979. ->setDefaultCrossingChar(' ')
  61980. ->setCellHeaderFormat('%s')
  61981. ;
  61982. $box = (new TableStyle())
  61983. ->setHorizontalBorderChars('─')
  61984. ->setVerticalBorderChars('│')
  61985. ->setCrossingChars('┼', '┌', '┬', '�', '┤', '┘', '┴', '└', '├')
  61986. ;
  61987. $boxDouble = (new TableStyle())
  61988. ->setHorizontalBorderChars('�', '─')
  61989. ->setVerticalBorderChars('║', '│')
  61990. ->setCrossingChars('┼', '╔', '╤', '╗', '╢', '�', '╧', '╚', '╟', '╠', '╪', '╣')
  61991. ;
  61992. return [
  61993. 'default' => new TableStyle(),
  61994. 'borderless' => $borderless,
  61995. 'compact' => $compact,
  61996. 'symfony-style-guide' => $styleGuide,
  61997. 'box' => $box,
  61998. 'box-double' => $boxDouble,
  61999. ];
  62000. }
  62001. private function resolveStyle($name): TableStyle
  62002. {
  62003. if ($name instanceof TableStyle) {
  62004. return $name;
  62005. }
  62006. if (isset(self::$styles[$name])) {
  62007. return self::$styles[$name];
  62008. }
  62009. throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
  62010. }
  62011. }
  62012. <?php
  62013. namespace Symfony\Component\Console\Helper;
  62014. use Symfony\Component\Console\Exception\InvalidArgumentException;
  62015. class TableCell
  62016. {
  62017. private $value;
  62018. private $options = [
  62019. 'rowspan' => 1,
  62020. 'colspan' => 1,
  62021. 'style' => null,
  62022. ];
  62023. public function __construct(string $value = '', array $options = [])
  62024. {
  62025. $this->value = $value;
  62026. if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
  62027. throw new InvalidArgumentException(sprintf('The TableCell does not support the following options: \'%s\'.', implode('\', \'', $diff)));
  62028. }
  62029. if (isset($options['style']) && !$options['style'] instanceof TableCellStyle) {
  62030. throw new InvalidArgumentException('The style option must be an instance of "TableCellStyle".');
  62031. }
  62032. $this->options = array_merge($this->options, $options);
  62033. }
  62034. public function __toString()
  62035. {
  62036. return $this->value;
  62037. }
  62038. public function getColspan()
  62039. {
  62040. return (int) $this->options['colspan'];
  62041. }
  62042. public function getRowspan()
  62043. {
  62044. return (int) $this->options['rowspan'];
  62045. }
  62046. public function getStyle(): ?TableCellStyle
  62047. {
  62048. return $this->options['style'];
  62049. }
  62050. }
  62051. <?php
  62052. namespace Symfony\Component\Console\Helper;
  62053. use Symfony\Component\Console\Exception\InvalidArgumentException;
  62054. class TableCellStyle
  62055. {
  62056. public const DEFAULT_ALIGN = 'left';
  62057. private const TAG_OPTIONS = [
  62058. 'fg',
  62059. 'bg',
  62060. 'options',
  62061. ];
  62062. private const ALIGN_MAP = [
  62063. 'left' => \STR_PAD_RIGHT,
  62064. 'center' => \STR_PAD_BOTH,
  62065. 'right' => \STR_PAD_LEFT,
  62066. ];
  62067. private $options = [
  62068. 'fg' => 'default',
  62069. 'bg' => 'default',
  62070. 'options' => null,
  62071. 'align' => self::DEFAULT_ALIGN,
  62072. 'cellFormat' => null,
  62073. ];
  62074. public function __construct(array $options = [])
  62075. {
  62076. if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
  62077. throw new InvalidArgumentException(sprintf('The TableCellStyle does not support the following options: \'%s\'.', implode('\', \'', $diff)));
  62078. }
  62079. if (isset($options['align']) && !\array_key_exists($options['align'], self::ALIGN_MAP)) {
  62080. throw new InvalidArgumentException(sprintf('Wrong align value. Value must be following: \'%s\'.', implode('\', \'', array_keys(self::ALIGN_MAP))));
  62081. }
  62082. $this->options = array_merge($this->options, $options);
  62083. }
  62084. public function getOptions(): array
  62085. {
  62086. return $this->options;
  62087. }
  62088. public function getTagOptions()
  62089. {
  62090. return array_filter(
  62091. $this->getOptions(),
  62092. function ($key) {
  62093. return \in_array($key, self::TAG_OPTIONS) && isset($this->options[$key]);
  62094. },
  62095. \ARRAY_FILTER_USE_KEY
  62096. );
  62097. }
  62098. public function getPadByAlign()
  62099. {
  62100. return self::ALIGN_MAP[$this->getOptions()['align']];
  62101. }
  62102. public function getCellFormat(): ?string
  62103. {
  62104. return $this->getOptions()['cellFormat'];
  62105. }
  62106. }
  62107. <?php
  62108. namespace Symfony\Component\Console\Helper;
  62109. class TableRows implements \IteratorAggregate
  62110. {
  62111. private $generator;
  62112. public function __construct(\Closure $generator)
  62113. {
  62114. $this->generator = $generator;
  62115. }
  62116. public function getIterator(): \Traversable
  62117. {
  62118. return ($this->generator)();
  62119. }
  62120. }
  62121. <?php
  62122. namespace Symfony\Component\Console\Helper;
  62123. class TableSeparator extends TableCell
  62124. {
  62125. public function __construct(array $options = [])
  62126. {
  62127. parent::__construct('', $options);
  62128. }
  62129. }
  62130. <?php
  62131. namespace Symfony\Component\Console\Helper;
  62132. use Symfony\Component\Console\Exception\InvalidArgumentException;
  62133. use Symfony\Component\Console\Exception\LogicException;
  62134. class TableStyle
  62135. {
  62136. private $paddingChar = ' ';
  62137. private $horizontalOutsideBorderChar = '-';
  62138. private $horizontalInsideBorderChar = '-';
  62139. private $verticalOutsideBorderChar = '|';
  62140. private $verticalInsideBorderChar = '|';
  62141. private $crossingChar = '+';
  62142. private $crossingTopRightChar = '+';
  62143. private $crossingTopMidChar = '+';
  62144. private $crossingTopLeftChar = '+';
  62145. private $crossingMidRightChar = '+';
  62146. private $crossingBottomRightChar = '+';
  62147. private $crossingBottomMidChar = '+';
  62148. private $crossingBottomLeftChar = '+';
  62149. private $crossingMidLeftChar = '+';
  62150. private $crossingTopLeftBottomChar = '+';
  62151. private $crossingTopMidBottomChar = '+';
  62152. private $crossingTopRightBottomChar = '+';
  62153. private $headerTitleFormat = '<fg=black;bg=white;options=bold> %s </>';
  62154. private $footerTitleFormat = '<fg=black;bg=white;options=bold> %s </>';
  62155. private $cellHeaderFormat = '<info>%s</info>';
  62156. private $cellRowFormat = '%s';
  62157. private $cellRowContentFormat = ' %s ';
  62158. private $borderFormat = '%s';
  62159. private $padType = \STR_PAD_RIGHT;
  62160. public function setPaddingChar(string $paddingChar)
  62161. {
  62162. if (!$paddingChar) {
  62163. throw new LogicException('The padding char must not be empty.');
  62164. }
  62165. $this->paddingChar = $paddingChar;
  62166. return $this;
  62167. }
  62168. public function getPaddingChar()
  62169. {
  62170. return $this->paddingChar;
  62171. }
  62172. public function setHorizontalBorderChars(string $outside, string $inside = null): self
  62173. {
  62174. $this->horizontalOutsideBorderChar = $outside;
  62175. $this->horizontalInsideBorderChar = $inside ?? $outside;
  62176. return $this;
  62177. }
  62178. public function setVerticalBorderChars(string $outside, string $inside = null): self
  62179. {
  62180. $this->verticalOutsideBorderChar = $outside;
  62181. $this->verticalInsideBorderChar = $inside ?? $outside;
  62182. return $this;
  62183. }
  62184. public function getBorderChars(): array
  62185. {
  62186. return [
  62187. $this->horizontalOutsideBorderChar,
  62188. $this->verticalOutsideBorderChar,
  62189. $this->horizontalInsideBorderChar,
  62190. $this->verticalInsideBorderChar,
  62191. ];
  62192. }
  62193. 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
  62194. {
  62195. $this->crossingChar = $cross;
  62196. $this->crossingTopLeftChar = $topLeft;
  62197. $this->crossingTopMidChar = $topMid;
  62198. $this->crossingTopRightChar = $topRight;
  62199. $this->crossingMidRightChar = $midRight;
  62200. $this->crossingBottomRightChar = $bottomRight;
  62201. $this->crossingBottomMidChar = $bottomMid;
  62202. $this->crossingBottomLeftChar = $bottomLeft;
  62203. $this->crossingMidLeftChar = $midLeft;
  62204. $this->crossingTopLeftBottomChar = $topLeftBottom ?? $midLeft;
  62205. $this->crossingTopMidBottomChar = $topMidBottom ?? $cross;
  62206. $this->crossingTopRightBottomChar = $topRightBottom ?? $midRight;
  62207. return $this;
  62208. }
  62209. public function setDefaultCrossingChar(string $char): self
  62210. {
  62211. return $this->setCrossingChars($char, $char, $char, $char, $char, $char, $char, $char, $char);
  62212. }
  62213. public function getCrossingChar()
  62214. {
  62215. return $this->crossingChar;
  62216. }
  62217. public function getCrossingChars(): array
  62218. {
  62219. return [
  62220. $this->crossingChar,
  62221. $this->crossingTopLeftChar,
  62222. $this->crossingTopMidChar,
  62223. $this->crossingTopRightChar,
  62224. $this->crossingMidRightChar,
  62225. $this->crossingBottomRightChar,
  62226. $this->crossingBottomMidChar,
  62227. $this->crossingBottomLeftChar,
  62228. $this->crossingMidLeftChar,
  62229. $this->crossingTopLeftBottomChar,
  62230. $this->crossingTopMidBottomChar,
  62231. $this->crossingTopRightBottomChar,
  62232. ];
  62233. }
  62234. public function setCellHeaderFormat(string $cellHeaderFormat)
  62235. {
  62236. $this->cellHeaderFormat = $cellHeaderFormat;
  62237. return $this;
  62238. }
  62239. public function getCellHeaderFormat()
  62240. {
  62241. return $this->cellHeaderFormat;
  62242. }
  62243. public function setCellRowFormat(string $cellRowFormat)
  62244. {
  62245. $this->cellRowFormat = $cellRowFormat;
  62246. return $this;
  62247. }
  62248. public function getCellRowFormat()
  62249. {
  62250. return $this->cellRowFormat;
  62251. }
  62252. public function setCellRowContentFormat(string $cellRowContentFormat)
  62253. {
  62254. $this->cellRowContentFormat = $cellRowContentFormat;
  62255. return $this;
  62256. }
  62257. public function getCellRowContentFormat()
  62258. {
  62259. return $this->cellRowContentFormat;
  62260. }
  62261. public function setBorderFormat(string $borderFormat)
  62262. {
  62263. $this->borderFormat = $borderFormat;
  62264. return $this;
  62265. }
  62266. public function getBorderFormat()
  62267. {
  62268. return $this->borderFormat;
  62269. }
  62270. public function setPadType(int $padType)
  62271. {
  62272. if (!\in_array($padType, [\STR_PAD_LEFT, \STR_PAD_RIGHT, \STR_PAD_BOTH], true)) {
  62273. throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).');
  62274. }
  62275. $this->padType = $padType;
  62276. return $this;
  62277. }
  62278. public function getPadType()
  62279. {
  62280. return $this->padType;
  62281. }
  62282. public function getHeaderTitleFormat(): string
  62283. {
  62284. return $this->headerTitleFormat;
  62285. }
  62286. public function setHeaderTitleFormat(string $format): self
  62287. {
  62288. $this->headerTitleFormat = $format;
  62289. return $this;
  62290. }
  62291. public function getFooterTitleFormat(): string
  62292. {
  62293. return $this->footerTitleFormat;
  62294. }
  62295. public function setFooterTitleFormat(string $format): self
  62296. {
  62297. $this->footerTitleFormat = $format;
  62298. return $this;
  62299. }
  62300. }
  62301. <?php
  62302. namespace Symfony\Component\Console\Input;
  62303. use Symfony\Component\Console\Exception\RuntimeException;
  62304. class ArgvInput extends Input
  62305. {
  62306. private $tokens;
  62307. private $parsed;
  62308. public function __construct(array $argv = null, InputDefinition $definition = null)
  62309. {
  62310. $argv = $argv ?? $_SERVER['argv'] ?? [];
  62311. array_shift($argv);
  62312. $this->tokens = $argv;
  62313. parent::__construct($definition);
  62314. }
  62315. protected function setTokens(array $tokens)
  62316. {
  62317. $this->tokens = $tokens;
  62318. }
  62319. protected function parse()
  62320. {
  62321. $parseOptions = true;
  62322. $this->parsed = $this->tokens;
  62323. while (null !== $token = array_shift($this->parsed)) {
  62324. $parseOptions = $this->parseToken($token, $parseOptions);
  62325. }
  62326. }
  62327. protected function parseToken(string $token, bool $parseOptions): bool
  62328. {
  62329. if ($parseOptions && '' == $token) {
  62330. $this->parseArgument($token);
  62331. } elseif ($parseOptions && '--' == $token) {
  62332. return false;
  62333. } elseif ($parseOptions && str_starts_with($token, '--')) {
  62334. $this->parseLongOption($token);
  62335. } elseif ($parseOptions && '-' === $token[0] && '-' !== $token) {
  62336. $this->parseShortOption($token);
  62337. } else {
  62338. $this->parseArgument($token);
  62339. }
  62340. return $parseOptions;
  62341. }
  62342. private function parseShortOption(string $token)
  62343. {
  62344. $name = substr($token, 1);
  62345. if (\strlen($name) > 1) {
  62346. if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptValue()) {
  62347. $this->addShortOption($name[0], substr($name, 1));
  62348. } else {
  62349. $this->parseShortOptionSet($name);
  62350. }
  62351. } else {
  62352. $this->addShortOption($name, null);
  62353. }
  62354. }
  62355. private function parseShortOptionSet(string $name)
  62356. {
  62357. $len = \strlen($name);
  62358. for ($i = 0; $i < $len; ++$i) {
  62359. if (!$this->definition->hasShortcut($name[$i])) {
  62360. $encoding = mb_detect_encoding($name, null, true);
  62361. throw new RuntimeException(sprintf('The "-%s" option does not exist.', false === $encoding ? $name[$i] : mb_substr($name, $i, 1, $encoding)));
  62362. }
  62363. $option = $this->definition->getOptionForShortcut($name[$i]);
  62364. if ($option->acceptValue()) {
  62365. $this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1));
  62366. break;
  62367. } else {
  62368. $this->addLongOption($option->getName(), null);
  62369. }
  62370. }
  62371. }
  62372. private function parseLongOption(string $token)
  62373. {
  62374. $name = substr($token, 2);
  62375. if (false !== $pos = strpos($name, '=')) {
  62376. if ('' === $value = substr($name, $pos + 1)) {
  62377. array_unshift($this->parsed, $value);
  62378. }
  62379. $this->addLongOption(substr($name, 0, $pos), $value);
  62380. } else {
  62381. $this->addLongOption($name, null);
  62382. }
  62383. }
  62384. private function parseArgument(string $token)
  62385. {
  62386. $c = \count($this->arguments);
  62387. if ($this->definition->hasArgument($c)) {
  62388. $arg = $this->definition->getArgument($c);
  62389. $this->arguments[$arg->getName()] = $arg->isArray() ? [$token] : $token;
  62390. } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) {
  62391. $arg = $this->definition->getArgument($c - 1);
  62392. $this->arguments[$arg->getName()][] = $token;
  62393. } else {
  62394. $all = $this->definition->getArguments();
  62395. $symfonyCommandName = null;
  62396. if (($inputArgument = $all[$key = array_key_first($all)] ?? null) && 'command' === $inputArgument->getName()) {
  62397. $symfonyCommandName = $this->arguments['command'] ?? null;
  62398. unset($all[$key]);
  62399. }
  62400. if (\count($all)) {
  62401. if ($symfonyCommandName) {
  62402. $message = sprintf('Too many arguments to "%s" command, expected arguments "%s".', $symfonyCommandName, implode('" "', array_keys($all)));
  62403. } else {
  62404. $message = sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all)));
  62405. }
  62406. } elseif ($symfonyCommandName) {
  62407. $message = sprintf('No arguments expected for "%s" command, got "%s".', $symfonyCommandName, $token);
  62408. } else {
  62409. $message = sprintf('No arguments expected, got "%s".', $token);
  62410. }
  62411. throw new RuntimeException($message);
  62412. }
  62413. }
  62414. private function addShortOption(string $shortcut, $value)
  62415. {
  62416. if (!$this->definition->hasShortcut($shortcut)) {
  62417. throw new RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut));
  62418. }
  62419. $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
  62420. }
  62421. private function addLongOption(string $name, $value)
  62422. {
  62423. if (!$this->definition->hasOption($name)) {
  62424. if (!$this->definition->hasNegation($name)) {
  62425. throw new RuntimeException(sprintf('The "--%s" option does not exist.', $name));
  62426. }
  62427. $optionName = $this->definition->negationToName($name);
  62428. if (null !== $value) {
  62429. throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name));
  62430. }
  62431. $this->options[$optionName] = false;
  62432. return;
  62433. }
  62434. $option = $this->definition->getOption($name);
  62435. if (null !== $value && !$option->acceptValue()) {
  62436. throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name));
  62437. }
  62438. if (\in_array($value, ['', null], true) && $option->acceptValue() && \count($this->parsed)) {
  62439. $next = array_shift($this->parsed);
  62440. if ((isset($next[0]) && '-' !== $next[0]) || \in_array($next, ['', null], true)) {
  62441. $value = $next;
  62442. } else {
  62443. array_unshift($this->parsed, $next);
  62444. }
  62445. }
  62446. if (null === $value) {
  62447. if ($option->isValueRequired()) {
  62448. throw new RuntimeException(sprintf('The "--%s" option requires a value.', $name));
  62449. }
  62450. if (!$option->isArray() && !$option->isValueOptional()) {
  62451. $value = true;
  62452. }
  62453. }
  62454. if ($option->isArray()) {
  62455. $this->options[$name][] = $value;
  62456. } else {
  62457. $this->options[$name] = $value;
  62458. }
  62459. }
  62460. public function getFirstArgument()
  62461. {
  62462. $isOption = false;
  62463. foreach ($this->tokens as $i => $token) {
  62464. if ($token && '-' === $token[0]) {
  62465. if (str_contains($token, '=') || !isset($this->tokens[$i + 1])) {
  62466. continue;
  62467. }
  62468. $name = '-' === $token[1] ? substr($token, 2) : substr($token, -1);
  62469. if (!isset($this->options[$name]) && !$this->definition->hasShortcut($name)) {
  62470. } elseif ((isset($this->options[$name]) || isset($this->options[$name = $this->definition->shortcutToName($name)])) && $this->tokens[$i + 1] === $this->options[$name]) {
  62471. $isOption = true;
  62472. }
  62473. continue;
  62474. }
  62475. if ($isOption) {
  62476. $isOption = false;
  62477. continue;
  62478. }
  62479. return $token;
  62480. }
  62481. return null;
  62482. }
  62483. public function hasParameterOption($values, bool $onlyParams = false)
  62484. {
  62485. $values = (array) $values;
  62486. foreach ($this->tokens as $token) {
  62487. if ($onlyParams && '--' === $token) {
  62488. return false;
  62489. }
  62490. foreach ($values as $value) {
  62491. $leading = str_starts_with($value, '--') ? $value.'=' : $value;
  62492. if ($token === $value || '' !== $leading && str_starts_with($token, $leading)) {
  62493. return true;
  62494. }
  62495. }
  62496. }
  62497. return false;
  62498. }
  62499. public function getParameterOption($values, $default = false, bool $onlyParams = false)
  62500. {
  62501. $values = (array) $values;
  62502. $tokens = $this->tokens;
  62503. while (0 < \count($tokens)) {
  62504. $token = array_shift($tokens);
  62505. if ($onlyParams && '--' === $token) {
  62506. return $default;
  62507. }
  62508. foreach ($values as $value) {
  62509. if ($token === $value) {
  62510. return array_shift($tokens);
  62511. }
  62512. $leading = str_starts_with($value, '--') ? $value.'=' : $value;
  62513. if ('' !== $leading && str_starts_with($token, $leading)) {
  62514. return substr($token, \strlen($leading));
  62515. }
  62516. }
  62517. }
  62518. return $default;
  62519. }
  62520. public function __toString()
  62521. {
  62522. $tokens = array_map(function ($token) {
  62523. if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) {
  62524. return $match[1].$this->escapeToken($match[2]);
  62525. }
  62526. if ($token && '-' !== $token[0]) {
  62527. return $this->escapeToken($token);
  62528. }
  62529. return $token;
  62530. }, $this->tokens);
  62531. return implode(' ', $tokens);
  62532. }
  62533. }
  62534. <?php
  62535. namespace Symfony\Component\Console\Input;
  62536. use Symfony\Component\Console\Exception\InvalidArgumentException;
  62537. use Symfony\Component\Console\Exception\InvalidOptionException;
  62538. class ArrayInput extends Input
  62539. {
  62540. private $parameters;
  62541. public function __construct(array $parameters, InputDefinition $definition = null)
  62542. {
  62543. $this->parameters = $parameters;
  62544. parent::__construct($definition);
  62545. }
  62546. public function getFirstArgument()
  62547. {
  62548. foreach ($this->parameters as $param => $value) {
  62549. if ($param && \is_string($param) && '-' === $param[0]) {
  62550. continue;
  62551. }
  62552. return $value;
  62553. }
  62554. return null;
  62555. }
  62556. public function hasParameterOption($values, bool $onlyParams = false)
  62557. {
  62558. $values = (array) $values;
  62559. foreach ($this->parameters as $k => $v) {
  62560. if (!\is_int($k)) {
  62561. $v = $k;
  62562. }
  62563. if ($onlyParams && '--' === $v) {
  62564. return false;
  62565. }
  62566. if (\in_array($v, $values)) {
  62567. return true;
  62568. }
  62569. }
  62570. return false;
  62571. }
  62572. public function getParameterOption($values, $default = false, bool $onlyParams = false)
  62573. {
  62574. $values = (array) $values;
  62575. foreach ($this->parameters as $k => $v) {
  62576. if ($onlyParams && ('--' === $k || (\is_int($k) && '--' === $v))) {
  62577. return $default;
  62578. }
  62579. if (\is_int($k)) {
  62580. if (\in_array($v, $values)) {
  62581. return true;
  62582. }
  62583. } elseif (\in_array($k, $values)) {
  62584. return $v;
  62585. }
  62586. }
  62587. return $default;
  62588. }
  62589. public function __toString()
  62590. {
  62591. $params = [];
  62592. foreach ($this->parameters as $param => $val) {
  62593. if ($param && \is_string($param) && '-' === $param[0]) {
  62594. $glue = ('-' === $param[1]) ? '=' : ' ';
  62595. if (\is_array($val)) {
  62596. foreach ($val as $v) {
  62597. $params[] = $param.('' != $v ? $glue.$this->escapeToken($v) : '');
  62598. }
  62599. } else {
  62600. $params[] = $param.('' != $val ? $glue.$this->escapeToken($val) : '');
  62601. }
  62602. } else {
  62603. $params[] = \is_array($val) ? implode(' ', array_map([$this, 'escapeToken'], $val)) : $this->escapeToken($val);
  62604. }
  62605. }
  62606. return implode(' ', $params);
  62607. }
  62608. protected function parse()
  62609. {
  62610. foreach ($this->parameters as $key => $value) {
  62611. if ('--' === $key) {
  62612. return;
  62613. }
  62614. if (str_starts_with($key, '--')) {
  62615. $this->addLongOption(substr($key, 2), $value);
  62616. } elseif (str_starts_with($key, '-')) {
  62617. $this->addShortOption(substr($key, 1), $value);
  62618. } else {
  62619. $this->addArgument($key, $value);
  62620. }
  62621. }
  62622. }
  62623. private function addShortOption(string $shortcut, $value)
  62624. {
  62625. if (!$this->definition->hasShortcut($shortcut)) {
  62626. throw new InvalidOptionException(sprintf('The "-%s" option does not exist.', $shortcut));
  62627. }
  62628. $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
  62629. }
  62630. private function addLongOption(string $name, $value)
  62631. {
  62632. if (!$this->definition->hasOption($name)) {
  62633. if (!$this->definition->hasNegation($name)) {
  62634. throw new InvalidOptionException(sprintf('The "--%s" option does not exist.', $name));
  62635. }
  62636. $optionName = $this->definition->negationToName($name);
  62637. $this->options[$optionName] = false;
  62638. return;
  62639. }
  62640. $option = $this->definition->getOption($name);
  62641. if (null === $value) {
  62642. if ($option->isValueRequired()) {
  62643. throw new InvalidOptionException(sprintf('The "--%s" option requires a value.', $name));
  62644. }
  62645. if (!$option->isValueOptional()) {
  62646. $value = true;
  62647. }
  62648. }
  62649. $this->options[$name] = $value;
  62650. }
  62651. private function addArgument($name, $value)
  62652. {
  62653. if (!$this->definition->hasArgument($name)) {
  62654. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  62655. }
  62656. $this->arguments[$name] = $value;
  62657. }
  62658. }
  62659. <?php
  62660. namespace Symfony\Component\Console\Input;
  62661. use Symfony\Component\Console\Exception\InvalidArgumentException;
  62662. use Symfony\Component\Console\Exception\RuntimeException;
  62663. abstract class Input implements InputInterface, StreamableInputInterface
  62664. {
  62665. protected $definition;
  62666. protected $stream;
  62667. protected $options = [];
  62668. protected $arguments = [];
  62669. protected $interactive = true;
  62670. public function __construct(InputDefinition $definition = null)
  62671. {
  62672. if (null === $definition) {
  62673. $this->definition = new InputDefinition();
  62674. } else {
  62675. $this->bind($definition);
  62676. $this->validate();
  62677. }
  62678. }
  62679. public function bind(InputDefinition $definition)
  62680. {
  62681. $this->arguments = [];
  62682. $this->options = [];
  62683. $this->definition = $definition;
  62684. $this->parse();
  62685. }
  62686. abstract protected function parse();
  62687. public function validate()
  62688. {
  62689. $definition = $this->definition;
  62690. $givenArguments = $this->arguments;
  62691. $missingArguments = array_filter(array_keys($definition->getArguments()), function ($argument) use ($definition, $givenArguments) {
  62692. return !\array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired();
  62693. });
  62694. if (\count($missingArguments) > 0) {
  62695. throw new RuntimeException(sprintf('Not enough arguments (missing: "%s").', implode(', ', $missingArguments)));
  62696. }
  62697. }
  62698. public function isInteractive()
  62699. {
  62700. return $this->interactive;
  62701. }
  62702. public function setInteractive(bool $interactive)
  62703. {
  62704. $this->interactive = $interactive;
  62705. }
  62706. public function getArguments()
  62707. {
  62708. return array_merge($this->definition->getArgumentDefaults(), $this->arguments);
  62709. }
  62710. public function getArgument(string $name)
  62711. {
  62712. if (!$this->definition->hasArgument($name)) {
  62713. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  62714. }
  62715. return $this->arguments[$name] ?? $this->definition->getArgument($name)->getDefault();
  62716. }
  62717. public function setArgument(string $name, $value)
  62718. {
  62719. if (!$this->definition->hasArgument($name)) {
  62720. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  62721. }
  62722. $this->arguments[$name] = $value;
  62723. }
  62724. public function hasArgument(string $name)
  62725. {
  62726. return $this->definition->hasArgument($name);
  62727. }
  62728. public function getOptions()
  62729. {
  62730. return array_merge($this->definition->getOptionDefaults(), $this->options);
  62731. }
  62732. public function getOption(string $name)
  62733. {
  62734. if ($this->definition->hasNegation($name)) {
  62735. if (null === $value = $this->getOption($this->definition->negationToName($name))) {
  62736. return $value;
  62737. }
  62738. return !$value;
  62739. }
  62740. if (!$this->definition->hasOption($name)) {
  62741. throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
  62742. }
  62743. return \array_key_exists($name, $this->options) ? $this->options[$name] : $this->definition->getOption($name)->getDefault();
  62744. }
  62745. public function setOption(string $name, $value)
  62746. {
  62747. if ($this->definition->hasNegation($name)) {
  62748. $this->options[$this->definition->negationToName($name)] = !$value;
  62749. return;
  62750. } elseif (!$this->definition->hasOption($name)) {
  62751. throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
  62752. }
  62753. $this->options[$name] = $value;
  62754. }
  62755. public function hasOption(string $name)
  62756. {
  62757. return $this->definition->hasOption($name) || $this->definition->hasNegation($name);
  62758. }
  62759. public function escapeToken(string $token)
  62760. {
  62761. return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token);
  62762. }
  62763. public function setStream($stream)
  62764. {
  62765. $this->stream = $stream;
  62766. }
  62767. public function getStream()
  62768. {
  62769. return $this->stream;
  62770. }
  62771. }
  62772. <?php
  62773. namespace Symfony\Component\Console\Input;
  62774. use Symfony\Component\Console\Exception\InvalidArgumentException;
  62775. use Symfony\Component\Console\Exception\LogicException;
  62776. class InputArgument
  62777. {
  62778. public const REQUIRED = 1;
  62779. public const OPTIONAL = 2;
  62780. public const IS_ARRAY = 4;
  62781. private $name;
  62782. private $mode;
  62783. private $default;
  62784. private $description;
  62785. public function __construct(string $name, int $mode = null, string $description = '', $default = null)
  62786. {
  62787. if (null === $mode) {
  62788. $mode = self::OPTIONAL;
  62789. } elseif ($mode > 7 || $mode < 1) {
  62790. throw new InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode));
  62791. }
  62792. $this->name = $name;
  62793. $this->mode = $mode;
  62794. $this->description = $description;
  62795. $this->setDefault($default);
  62796. }
  62797. public function getName()
  62798. {
  62799. return $this->name;
  62800. }
  62801. public function isRequired()
  62802. {
  62803. return self::REQUIRED === (self::REQUIRED & $this->mode);
  62804. }
  62805. public function isArray()
  62806. {
  62807. return self::IS_ARRAY === (self::IS_ARRAY & $this->mode);
  62808. }
  62809. public function setDefault($default = null)
  62810. {
  62811. if ($this->isRequired() && null !== $default) {
  62812. throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.');
  62813. }
  62814. if ($this->isArray()) {
  62815. if (null === $default) {
  62816. $default = [];
  62817. } elseif (!\is_array($default)) {
  62818. throw new LogicException('A default value for an array argument must be an array.');
  62819. }
  62820. }
  62821. $this->default = $default;
  62822. }
  62823. public function getDefault()
  62824. {
  62825. return $this->default;
  62826. }
  62827. public function getDescription()
  62828. {
  62829. return $this->description;
  62830. }
  62831. }
  62832. <?php
  62833. namespace Symfony\Component\Console\Input;
  62834. interface InputAwareInterface
  62835. {
  62836. public function setInput(InputInterface $input);
  62837. }
  62838. <?php
  62839. namespace Symfony\Component\Console\Input;
  62840. use Symfony\Component\Console\Exception\InvalidArgumentException;
  62841. use Symfony\Component\Console\Exception\LogicException;
  62842. class InputDefinition
  62843. {
  62844. private $arguments;
  62845. private $requiredCount;
  62846. private $lastArrayArgument;
  62847. private $lastOptionalArgument;
  62848. private $options;
  62849. private $negations;
  62850. private $shortcuts;
  62851. public function __construct(array $definition = [])
  62852. {
  62853. $this->setDefinition($definition);
  62854. }
  62855. public function setDefinition(array $definition)
  62856. {
  62857. $arguments = [];
  62858. $options = [];
  62859. foreach ($definition as $item) {
  62860. if ($item instanceof InputOption) {
  62861. $options[] = $item;
  62862. } else {
  62863. $arguments[] = $item;
  62864. }
  62865. }
  62866. $this->setArguments($arguments);
  62867. $this->setOptions($options);
  62868. }
  62869. public function setArguments(array $arguments = [])
  62870. {
  62871. $this->arguments = [];
  62872. $this->requiredCount = 0;
  62873. $this->lastOptionalArgument = null;
  62874. $this->lastArrayArgument = null;
  62875. $this->addArguments($arguments);
  62876. }
  62877. public function addArguments(?array $arguments = [])
  62878. {
  62879. if (null !== $arguments) {
  62880. foreach ($arguments as $argument) {
  62881. $this->addArgument($argument);
  62882. }
  62883. }
  62884. }
  62885. public function addArgument(InputArgument $argument)
  62886. {
  62887. if (isset($this->arguments[$argument->getName()])) {
  62888. throw new LogicException(sprintf('An argument with name "%s" already exists.', $argument->getName()));
  62889. }
  62890. if (null !== $this->lastArrayArgument) {
  62891. throw new LogicException(sprintf('Cannot add a required argument "%s" after an array argument "%s".', $argument->getName(), $this->lastArrayArgument->getName()));
  62892. }
  62893. if ($argument->isRequired() && null !== $this->lastOptionalArgument) {
  62894. throw new LogicException(sprintf('Cannot add a required argument "%s" after an optional one "%s".', $argument->getName(), $this->lastOptionalArgument->getName()));
  62895. }
  62896. if ($argument->isArray()) {
  62897. $this->lastArrayArgument = $argument;
  62898. }
  62899. if ($argument->isRequired()) {
  62900. ++$this->requiredCount;
  62901. } else {
  62902. $this->lastOptionalArgument = $argument;
  62903. }
  62904. $this->arguments[$argument->getName()] = $argument;
  62905. }
  62906. public function getArgument($name)
  62907. {
  62908. if (!$this->hasArgument($name)) {
  62909. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  62910. }
  62911. $arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
  62912. return $arguments[$name];
  62913. }
  62914. public function hasArgument($name)
  62915. {
  62916. $arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
  62917. return isset($arguments[$name]);
  62918. }
  62919. public function getArguments()
  62920. {
  62921. return $this->arguments;
  62922. }
  62923. public function getArgumentCount()
  62924. {
  62925. return null !== $this->lastArrayArgument ? \PHP_INT_MAX : \count($this->arguments);
  62926. }
  62927. public function getArgumentRequiredCount()
  62928. {
  62929. return $this->requiredCount;
  62930. }
  62931. public function getArgumentDefaults()
  62932. {
  62933. $values = [];
  62934. foreach ($this->arguments as $argument) {
  62935. $values[$argument->getName()] = $argument->getDefault();
  62936. }
  62937. return $values;
  62938. }
  62939. public function setOptions(array $options = [])
  62940. {
  62941. $this->options = [];
  62942. $this->shortcuts = [];
  62943. $this->negations = [];
  62944. $this->addOptions($options);
  62945. }
  62946. public function addOptions(array $options = [])
  62947. {
  62948. foreach ($options as $option) {
  62949. $this->addOption($option);
  62950. }
  62951. }
  62952. public function addOption(InputOption $option)
  62953. {
  62954. if (isset($this->options[$option->getName()]) && !$option->equals($this->options[$option->getName()])) {
  62955. throw new LogicException(sprintf('An option named "%s" already exists.', $option->getName()));
  62956. }
  62957. if (isset($this->negations[$option->getName()])) {
  62958. throw new LogicException(sprintf('An option named "%s" already exists.', $option->getName()));
  62959. }
  62960. if ($option->getShortcut()) {
  62961. foreach (explode('|', $option->getShortcut()) as $shortcut) {
  62962. if (isset($this->shortcuts[$shortcut]) && !$option->equals($this->options[$this->shortcuts[$shortcut]])) {
  62963. throw new LogicException(sprintf('An option with shortcut "%s" already exists.', $shortcut));
  62964. }
  62965. }
  62966. }
  62967. $this->options[$option->getName()] = $option;
  62968. if ($option->getShortcut()) {
  62969. foreach (explode('|', $option->getShortcut()) as $shortcut) {
  62970. $this->shortcuts[$shortcut] = $option->getName();
  62971. }
  62972. }
  62973. if ($option->isNegatable()) {
  62974. $negatedName = 'no-'.$option->getName();
  62975. if (isset($this->options[$negatedName])) {
  62976. throw new LogicException(sprintf('An option named "%s" already exists.', $negatedName));
  62977. }
  62978. $this->negations[$negatedName] = $option->getName();
  62979. }
  62980. }
  62981. public function getOption(string $name)
  62982. {
  62983. if (!$this->hasOption($name)) {
  62984. throw new InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name));
  62985. }
  62986. return $this->options[$name];
  62987. }
  62988. public function hasOption(string $name)
  62989. {
  62990. return isset($this->options[$name]);
  62991. }
  62992. public function getOptions()
  62993. {
  62994. return $this->options;
  62995. }
  62996. public function hasShortcut(string $name)
  62997. {
  62998. return isset($this->shortcuts[$name]);
  62999. }
  63000. public function hasNegation(string $name): bool
  63001. {
  63002. return isset($this->negations[$name]);
  63003. }
  63004. public function getOptionForShortcut(string $shortcut)
  63005. {
  63006. return $this->getOption($this->shortcutToName($shortcut));
  63007. }
  63008. public function getOptionDefaults()
  63009. {
  63010. $values = [];
  63011. foreach ($this->options as $option) {
  63012. $values[$option->getName()] = $option->getDefault();
  63013. }
  63014. return $values;
  63015. }
  63016. public function shortcutToName(string $shortcut): string
  63017. {
  63018. if (!isset($this->shortcuts[$shortcut])) {
  63019. throw new InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut));
  63020. }
  63021. return $this->shortcuts[$shortcut];
  63022. }
  63023. public function negationToName(string $negation): string
  63024. {
  63025. if (!isset($this->negations[$negation])) {
  63026. throw new InvalidArgumentException(sprintf('The "--%s" option does not exist.', $negation));
  63027. }
  63028. return $this->negations[$negation];
  63029. }
  63030. public function getSynopsis(bool $short = false)
  63031. {
  63032. $elements = [];
  63033. if ($short && $this->getOptions()) {
  63034. $elements[] = '[options]';
  63035. } elseif (!$short) {
  63036. foreach ($this->getOptions() as $option) {
  63037. $value = '';
  63038. if ($option->acceptValue()) {
  63039. $value = sprintf(
  63040. ' %s%s%s',
  63041. $option->isValueOptional() ? '[' : '',
  63042. strtoupper($option->getName()),
  63043. $option->isValueOptional() ? ']' : ''
  63044. );
  63045. }
  63046. $shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : '';
  63047. $negation = $option->isNegatable() ? sprintf('|--no-%s', $option->getName()) : '';
  63048. $elements[] = sprintf('[%s--%s%s%s]', $shortcut, $option->getName(), $value, $negation);
  63049. }
  63050. }
  63051. if (\count($elements) && $this->getArguments()) {
  63052. $elements[] = '[--]';
  63053. }
  63054. $tail = '';
  63055. foreach ($this->getArguments() as $argument) {
  63056. $element = '<'.$argument->getName().'>';
  63057. if ($argument->isArray()) {
  63058. $element .= '...';
  63059. }
  63060. if (!$argument->isRequired()) {
  63061. $element = '['.$element;
  63062. $tail .= ']';
  63063. }
  63064. $elements[] = $element;
  63065. }
  63066. return implode(' ', $elements).$tail;
  63067. }
  63068. }
  63069. <?php
  63070. namespace Symfony\Component\Console\Input;
  63071. use Symfony\Component\Console\Exception\InvalidArgumentException;
  63072. use Symfony\Component\Console\Exception\RuntimeException;
  63073. interface InputInterface
  63074. {
  63075. public function getFirstArgument();
  63076. public function hasParameterOption($values, bool $onlyParams = false);
  63077. public function getParameterOption($values, $default = false, bool $onlyParams = false);
  63078. public function bind(InputDefinition $definition);
  63079. public function validate();
  63080. public function getArguments();
  63081. public function getArgument(string $name);
  63082. public function setArgument(string $name, $value);
  63083. public function hasArgument(string $name);
  63084. public function getOptions();
  63085. public function getOption(string $name);
  63086. public function setOption(string $name, $value);
  63087. public function hasOption(string $name);
  63088. public function isInteractive();
  63089. public function setInteractive(bool $interactive);
  63090. }
  63091. <?php
  63092. namespace Symfony\Component\Console\Input;
  63093. use Symfony\Component\Console\Exception\InvalidArgumentException;
  63094. use Symfony\Component\Console\Exception\LogicException;
  63095. class InputOption
  63096. {
  63097. public const VALUE_NONE = 1;
  63098. public const VALUE_REQUIRED = 2;
  63099. public const VALUE_OPTIONAL = 4;
  63100. public const VALUE_IS_ARRAY = 8;
  63101. public const VALUE_NEGATABLE = 16;
  63102. private $name;
  63103. private $shortcut;
  63104. private $mode;
  63105. private $default;
  63106. private $description;
  63107. public function __construct(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null)
  63108. {
  63109. if (str_starts_with($name, '--')) {
  63110. $name = substr($name, 2);
  63111. }
  63112. if (empty($name)) {
  63113. throw new InvalidArgumentException('An option name cannot be empty.');
  63114. }
  63115. if (empty($shortcut)) {
  63116. $shortcut = null;
  63117. }
  63118. if (null !== $shortcut) {
  63119. if (\is_array($shortcut)) {
  63120. $shortcut = implode('|', $shortcut);
  63121. }
  63122. $shortcuts = preg_split('{(\|)-?}', ltrim($shortcut, '-'));
  63123. $shortcuts = array_filter($shortcuts);
  63124. $shortcut = implode('|', $shortcuts);
  63125. if (empty($shortcut)) {
  63126. throw new InvalidArgumentException('An option shortcut cannot be empty.');
  63127. }
  63128. }
  63129. if (null === $mode) {
  63130. $mode = self::VALUE_NONE;
  63131. } elseif ($mode >= (self::VALUE_NEGATABLE << 1) || $mode < 1) {
  63132. throw new InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode));
  63133. }
  63134. $this->name = $name;
  63135. $this->shortcut = $shortcut;
  63136. $this->mode = $mode;
  63137. $this->description = $description;
  63138. if ($this->isArray() && !$this->acceptValue()) {
  63139. throw new InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.');
  63140. }
  63141. if ($this->isNegatable() && $this->acceptValue()) {
  63142. throw new InvalidArgumentException('Impossible to have an option mode VALUE_NEGATABLE if the option also accepts a value.');
  63143. }
  63144. $this->setDefault($default);
  63145. }
  63146. public function getShortcut()
  63147. {
  63148. return $this->shortcut;
  63149. }
  63150. public function getName()
  63151. {
  63152. return $this->name;
  63153. }
  63154. public function acceptValue()
  63155. {
  63156. return $this->isValueRequired() || $this->isValueOptional();
  63157. }
  63158. public function isValueRequired()
  63159. {
  63160. return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode);
  63161. }
  63162. public function isValueOptional()
  63163. {
  63164. return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode);
  63165. }
  63166. public function isArray()
  63167. {
  63168. return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode);
  63169. }
  63170. public function isNegatable(): bool
  63171. {
  63172. return self::VALUE_NEGATABLE === (self::VALUE_NEGATABLE & $this->mode);
  63173. }
  63174. public function setDefault($default = null)
  63175. {
  63176. if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) {
  63177. throw new LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.');
  63178. }
  63179. if ($this->isArray()) {
  63180. if (null === $default) {
  63181. $default = [];
  63182. } elseif (!\is_array($default)) {
  63183. throw new LogicException('A default value for an array option must be an array.');
  63184. }
  63185. }
  63186. $this->default = $this->acceptValue() || $this->isNegatable() ? $default : false;
  63187. }
  63188. public function getDefault()
  63189. {
  63190. return $this->default;
  63191. }
  63192. public function getDescription()
  63193. {
  63194. return $this->description;
  63195. }
  63196. public function equals(self $option)
  63197. {
  63198. return $option->getName() === $this->getName()
  63199. && $option->getShortcut() === $this->getShortcut()
  63200. && $option->getDefault() === $this->getDefault()
  63201. && $option->isNegatable() === $this->isNegatable()
  63202. && $option->isArray() === $this->isArray()
  63203. && $option->isValueRequired() === $this->isValueRequired()
  63204. && $option->isValueOptional() === $this->isValueOptional()
  63205. ;
  63206. }
  63207. }
  63208. <?php
  63209. namespace Symfony\Component\Console\Input;
  63210. interface StreamableInputInterface extends InputInterface
  63211. {
  63212. public function setStream($stream);
  63213. public function getStream();
  63214. }
  63215. <?php
  63216. namespace Symfony\Component\Console\Input;
  63217. use Symfony\Component\Console\Exception\InvalidArgumentException;
  63218. class StringInput extends ArgvInput
  63219. {
  63220. public const REGEX_STRING = '([^\s]+?)(?:\s|(?<!\\\\)"|(?<!\\\\)\'|$)';
  63221. public const REGEX_UNQUOTED_STRING = '([^\s\\\\]+?)';
  63222. public const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')';
  63223. public function __construct(string $input)
  63224. {
  63225. parent::__construct([]);
  63226. $this->setTokens($this->tokenize($input));
  63227. }
  63228. private function tokenize(string $input): array
  63229. {
  63230. $tokens = [];
  63231. $length = \strlen($input);
  63232. $cursor = 0;
  63233. $token = null;
  63234. while ($cursor < $length) {
  63235. if ('\\' === $input[$cursor]) {
  63236. $token .= $input[++$cursor] ?? '';
  63237. ++$cursor;
  63238. continue;
  63239. }
  63240. if (preg_match('/\s+/A', $input, $match, 0, $cursor)) {
  63241. if (null !== $token) {
  63242. $tokens[] = $token;
  63243. $token = null;
  63244. }
  63245. } elseif (preg_match('/([^="\'\s]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, 0, $cursor)) {
  63246. $token .= $match[1].$match[2].stripcslashes(str_replace(['"\'', '\'"', '\'\'', '""'], '', substr($match[3], 1, -1)));
  63247. } elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, 0, $cursor)) {
  63248. $token .= stripcslashes(substr($match[0], 1, -1));
  63249. } elseif (preg_match('/'.self::REGEX_UNQUOTED_STRING.'/A', $input, $match, 0, $cursor)) {
  63250. $token .= $match[1];
  63251. } else {
  63252. throw new InvalidArgumentException(sprintf('Unable to parse input near "... %s ...".', substr($input, $cursor, 10)));
  63253. }
  63254. $cursor += \strlen($match[0]);
  63255. }
  63256. if (null !== $token) {
  63257. $tokens[] = $token;
  63258. }
  63259. return $tokens;
  63260. }
  63261. }
  63262. Copyright (c) 2004-present Fabien Potencier
  63263. Permission is hereby granted, free of charge, to any person obtaining a copy
  63264. of this software and associated documentation files (the "Software"), to deal
  63265. in the Software without restriction, including without limitation the rights
  63266. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  63267. copies of the Software, and to permit persons to whom the Software is furnished
  63268. to do so, subject to the following conditions:
  63269. The above copyright notice and this permission notice shall be included in all
  63270. copies or substantial portions of the Software.
  63271. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  63272. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  63273. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  63274. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  63275. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  63276. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  63277. THE SOFTWARE.
  63278. <?php
  63279. namespace Symfony\Component\Console\Logger;
  63280. use Psr\Log\AbstractLogger;
  63281. use Psr\Log\InvalidArgumentException;
  63282. use Psr\Log\LogLevel;
  63283. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  63284. use Symfony\Component\Console\Output\OutputInterface;
  63285. class ConsoleLogger extends AbstractLogger
  63286. {
  63287. public const INFO = 'info';
  63288. public const ERROR = 'error';
  63289. private $output;
  63290. private $verbosityLevelMap = [
  63291. LogLevel::EMERGENCY => OutputInterface::VERBOSITY_NORMAL,
  63292. LogLevel::ALERT => OutputInterface::VERBOSITY_NORMAL,
  63293. LogLevel::CRITICAL => OutputInterface::VERBOSITY_NORMAL,
  63294. LogLevel::ERROR => OutputInterface::VERBOSITY_NORMAL,
  63295. LogLevel::WARNING => OutputInterface::VERBOSITY_NORMAL,
  63296. LogLevel::NOTICE => OutputInterface::VERBOSITY_VERBOSE,
  63297. LogLevel::INFO => OutputInterface::VERBOSITY_VERY_VERBOSE,
  63298. LogLevel::DEBUG => OutputInterface::VERBOSITY_DEBUG,
  63299. ];
  63300. private $formatLevelMap = [
  63301. LogLevel::EMERGENCY => self::ERROR,
  63302. LogLevel::ALERT => self::ERROR,
  63303. LogLevel::CRITICAL => self::ERROR,
  63304. LogLevel::ERROR => self::ERROR,
  63305. LogLevel::WARNING => self::INFO,
  63306. LogLevel::NOTICE => self::INFO,
  63307. LogLevel::INFO => self::INFO,
  63308. LogLevel::DEBUG => self::INFO,
  63309. ];
  63310. private $errored = false;
  63311. public function __construct(OutputInterface $output, array $verbosityLevelMap = [], array $formatLevelMap = [])
  63312. {
  63313. $this->output = $output;
  63314. $this->verbosityLevelMap = $verbosityLevelMap + $this->verbosityLevelMap;
  63315. $this->formatLevelMap = $formatLevelMap + $this->formatLevelMap;
  63316. }
  63317. public function log($level, $message, array $context = [])
  63318. {
  63319. if (!isset($this->verbosityLevelMap[$level])) {
  63320. throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
  63321. }
  63322. $output = $this->output;
  63323. if (self::ERROR === $this->formatLevelMap[$level]) {
  63324. if ($this->output instanceof ConsoleOutputInterface) {
  63325. $output = $output->getErrorOutput();
  63326. }
  63327. $this->errored = true;
  63328. }
  63329. if ($output->getVerbosity() >= $this->verbosityLevelMap[$level]) {
  63330. $output->writeln(sprintf('<%1$s>[%2$s] %3$s</%1$s>', $this->formatLevelMap[$level], $level, $this->interpolate($message, $context)), $this->verbosityLevelMap[$level]);
  63331. }
  63332. }
  63333. public function hasErrored()
  63334. {
  63335. return $this->errored;
  63336. }
  63337. private function interpolate(string $message, array $context): string
  63338. {
  63339. if (!str_contains($message, '{')) {
  63340. return $message;
  63341. }
  63342. $replacements = [];
  63343. foreach ($context as $key => $val) {
  63344. if (null === $val || \is_scalar($val) || (\is_object($val) && method_exists($val, '__toString'))) {
  63345. $replacements["{{$key}}"] = $val;
  63346. } elseif ($val instanceof \DateTimeInterface) {
  63347. $replacements["{{$key}}"] = $val->format(\DateTime::RFC3339);
  63348. } elseif (\is_object($val)) {
  63349. $replacements["{{$key}}"] = '[object '.\get_class($val).']';
  63350. } else {
  63351. $replacements["{{$key}}"] = '['.\gettype($val).']';
  63352. }
  63353. }
  63354. return strtr($message, $replacements);
  63355. }
  63356. }
  63357. <?php
  63358. namespace Symfony\Component\Console\Output;
  63359. class BufferedOutput extends Output
  63360. {
  63361. private $buffer = '';
  63362. public function fetch()
  63363. {
  63364. $content = $this->buffer;
  63365. $this->buffer = '';
  63366. return $content;
  63367. }
  63368. protected function doWrite(string $message, bool $newline)
  63369. {
  63370. $this->buffer .= $message;
  63371. if ($newline) {
  63372. $this->buffer .= \PHP_EOL;
  63373. }
  63374. }
  63375. }
  63376. <?php
  63377. namespace Symfony\Component\Console\Output;
  63378. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  63379. class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
  63380. {
  63381. private $stderr;
  63382. private $consoleSectionOutputs = [];
  63383. public function __construct(int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = null, OutputFormatterInterface $formatter = null)
  63384. {
  63385. parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter);
  63386. if (null === $formatter) {
  63387. $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated);
  63388. return;
  63389. }
  63390. $actualDecorated = $this->isDecorated();
  63391. $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated, $this->getFormatter());
  63392. if (null === $decorated) {
  63393. $this->setDecorated($actualDecorated && $this->stderr->isDecorated());
  63394. }
  63395. }
  63396. public function section(): ConsoleSectionOutput
  63397. {
  63398. return new ConsoleSectionOutput($this->getStream(), $this->consoleSectionOutputs, $this->getVerbosity(), $this->isDecorated(), $this->getFormatter());
  63399. }
  63400. public function setDecorated(bool $decorated)
  63401. {
  63402. parent::setDecorated($decorated);
  63403. $this->stderr->setDecorated($decorated);
  63404. }
  63405. public function setFormatter(OutputFormatterInterface $formatter)
  63406. {
  63407. parent::setFormatter($formatter);
  63408. $this->stderr->setFormatter($formatter);
  63409. }
  63410. public function setVerbosity(int $level)
  63411. {
  63412. parent::setVerbosity($level);
  63413. $this->stderr->setVerbosity($level);
  63414. }
  63415. public function getErrorOutput()
  63416. {
  63417. return $this->stderr;
  63418. }
  63419. public function setErrorOutput(OutputInterface $error)
  63420. {
  63421. $this->stderr = $error;
  63422. }
  63423. protected function hasStdoutSupport()
  63424. {
  63425. return false === $this->isRunningOS400();
  63426. }
  63427. protected function hasStderrSupport()
  63428. {
  63429. return false === $this->isRunningOS400();
  63430. }
  63431. private function isRunningOS400(): bool
  63432. {
  63433. $checks = [
  63434. \function_exists('php_uname') ? php_uname('s') : '',
  63435. getenv('OSTYPE'),
  63436. \PHP_OS,
  63437. ];
  63438. return false !== stripos(implode(';', $checks), 'OS400');
  63439. }
  63440. private function openOutputStream()
  63441. {
  63442. if (!$this->hasStdoutSupport()) {
  63443. return fopen('php://output', 'w');
  63444. }
  63445. return \defined('STDOUT') ? \STDOUT : (@fopen('php://stdout', 'w') ?: fopen('php://output', 'w'));
  63446. }
  63447. private function openErrorStream()
  63448. {
  63449. if (!$this->hasStderrSupport()) {
  63450. return fopen('php://output', 'w');
  63451. }
  63452. return \defined('STDERR') ? \STDERR : (@fopen('php://stderr', 'w') ?: fopen('php://output', 'w'));
  63453. }
  63454. }
  63455. <?php
  63456. namespace Symfony\Component\Console\Output;
  63457. interface ConsoleOutputInterface extends OutputInterface
  63458. {
  63459. public function getErrorOutput();
  63460. public function setErrorOutput(OutputInterface $error);
  63461. public function section(): ConsoleSectionOutput;
  63462. }
  63463. <?php
  63464. namespace Symfony\Component\Console\Output;
  63465. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  63466. use Symfony\Component\Console\Helper\Helper;
  63467. use Symfony\Component\Console\Terminal;
  63468. class ConsoleSectionOutput extends StreamOutput
  63469. {
  63470. private $content = [];
  63471. private $lines = 0;
  63472. private $sections;
  63473. private $terminal;
  63474. public function __construct($stream, array &$sections, int $verbosity, bool $decorated, OutputFormatterInterface $formatter)
  63475. {
  63476. parent::__construct($stream, $verbosity, $decorated, $formatter);
  63477. array_unshift($sections, $this);
  63478. $this->sections = &$sections;
  63479. $this->terminal = new Terminal();
  63480. }
  63481. public function clear(int $lines = null)
  63482. {
  63483. if (empty($this->content) || !$this->isDecorated()) {
  63484. return;
  63485. }
  63486. if ($lines) {
  63487. array_splice($this->content, -($lines * 2));
  63488. } else {
  63489. $lines = $this->lines;
  63490. $this->content = [];
  63491. }
  63492. $this->lines -= $lines;
  63493. parent::doWrite($this->popStreamContentUntilCurrentSection($lines), false);
  63494. }
  63495. public function overwrite($message)
  63496. {
  63497. $this->clear();
  63498. $this->writeln($message);
  63499. }
  63500. public function getContent(): string
  63501. {
  63502. return implode('', $this->content);
  63503. }
  63504. public function addContent(string $input)
  63505. {
  63506. foreach (explode(\PHP_EOL, $input) as $lineContent) {
  63507. $this->lines += ceil($this->getDisplayLength($lineContent) / $this->terminal->getWidth()) ?: 1;
  63508. $this->content[] = $lineContent;
  63509. $this->content[] = \PHP_EOL;
  63510. }
  63511. }
  63512. protected function doWrite(string $message, bool $newline)
  63513. {
  63514. if (!$this->isDecorated()) {
  63515. parent::doWrite($message, $newline);
  63516. return;
  63517. }
  63518. $erasedContent = $this->popStreamContentUntilCurrentSection();
  63519. $this->addContent($message);
  63520. parent::doWrite($message, true);
  63521. parent::doWrite($erasedContent, false);
  63522. }
  63523. private function popStreamContentUntilCurrentSection(int $numberOfLinesToClearFromCurrentSection = 0): string
  63524. {
  63525. $numberOfLinesToClear = $numberOfLinesToClearFromCurrentSection;
  63526. $erasedContent = [];
  63527. foreach ($this->sections as $section) {
  63528. if ($section === $this) {
  63529. break;
  63530. }
  63531. $numberOfLinesToClear += $section->lines;
  63532. $erasedContent[] = $section->getContent();
  63533. }
  63534. if ($numberOfLinesToClear > 0) {
  63535. parent::doWrite(sprintf("\x1b[%dA", $numberOfLinesToClear), false);
  63536. parent::doWrite("\x1b[0J", false);
  63537. }
  63538. return implode('', array_reverse($erasedContent));
  63539. }
  63540. private function getDisplayLength(string $text): int
  63541. {
  63542. return Helper::width(Helper::removeDecoration($this->getFormatter(), str_replace("\t", ' ', $text)));
  63543. }
  63544. }
  63545. <?php
  63546. namespace Symfony\Component\Console\Output;
  63547. use Symfony\Component\Console\Formatter\NullOutputFormatter;
  63548. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  63549. class NullOutput implements OutputInterface
  63550. {
  63551. private $formatter;
  63552. public function setFormatter(OutputFormatterInterface $formatter)
  63553. {
  63554. }
  63555. public function getFormatter()
  63556. {
  63557. if ($this->formatter) {
  63558. return $this->formatter;
  63559. }
  63560. return $this->formatter = new NullOutputFormatter();
  63561. }
  63562. public function setDecorated(bool $decorated)
  63563. {
  63564. }
  63565. public function isDecorated()
  63566. {
  63567. return false;
  63568. }
  63569. public function setVerbosity(int $level)
  63570. {
  63571. }
  63572. public function getVerbosity()
  63573. {
  63574. return self::VERBOSITY_QUIET;
  63575. }
  63576. public function isQuiet()
  63577. {
  63578. return true;
  63579. }
  63580. public function isVerbose()
  63581. {
  63582. return false;
  63583. }
  63584. public function isVeryVerbose()
  63585. {
  63586. return false;
  63587. }
  63588. public function isDebug()
  63589. {
  63590. return false;
  63591. }
  63592. public function writeln($messages, int $options = self::OUTPUT_NORMAL)
  63593. {
  63594. }
  63595. public function write($messages, bool $newline = false, int $options = self::OUTPUT_NORMAL)
  63596. {
  63597. }
  63598. }
  63599. <?php
  63600. namespace Symfony\Component\Console\Output;
  63601. use Symfony\Component\Console\Formatter\OutputFormatter;
  63602. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  63603. abstract class Output implements OutputInterface
  63604. {
  63605. private $verbosity;
  63606. private $formatter;
  63607. public function __construct(?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, OutputFormatterInterface $formatter = null)
  63608. {
  63609. $this->verbosity = $verbosity ?? self::VERBOSITY_NORMAL;
  63610. $this->formatter = $formatter ?? new OutputFormatter();
  63611. $this->formatter->setDecorated($decorated);
  63612. }
  63613. public function setFormatter(OutputFormatterInterface $formatter)
  63614. {
  63615. $this->formatter = $formatter;
  63616. }
  63617. public function getFormatter()
  63618. {
  63619. return $this->formatter;
  63620. }
  63621. public function setDecorated(bool $decorated)
  63622. {
  63623. $this->formatter->setDecorated($decorated);
  63624. }
  63625. public function isDecorated()
  63626. {
  63627. return $this->formatter->isDecorated();
  63628. }
  63629. public function setVerbosity(int $level)
  63630. {
  63631. $this->verbosity = $level;
  63632. }
  63633. public function getVerbosity()
  63634. {
  63635. return $this->verbosity;
  63636. }
  63637. public function isQuiet()
  63638. {
  63639. return self::VERBOSITY_QUIET === $this->verbosity;
  63640. }
  63641. public function isVerbose()
  63642. {
  63643. return self::VERBOSITY_VERBOSE <= $this->verbosity;
  63644. }
  63645. public function isVeryVerbose()
  63646. {
  63647. return self::VERBOSITY_VERY_VERBOSE <= $this->verbosity;
  63648. }
  63649. public function isDebug()
  63650. {
  63651. return self::VERBOSITY_DEBUG <= $this->verbosity;
  63652. }
  63653. public function writeln($messages, int $options = self::OUTPUT_NORMAL)
  63654. {
  63655. $this->write($messages, true, $options);
  63656. }
  63657. public function write($messages, bool $newline = false, int $options = self::OUTPUT_NORMAL)
  63658. {
  63659. if (!is_iterable($messages)) {
  63660. $messages = [$messages];
  63661. }
  63662. $types = self::OUTPUT_NORMAL | self::OUTPUT_RAW | self::OUTPUT_PLAIN;
  63663. $type = $types & $options ?: self::OUTPUT_NORMAL;
  63664. $verbosities = self::VERBOSITY_QUIET | self::VERBOSITY_NORMAL | self::VERBOSITY_VERBOSE | self::VERBOSITY_VERY_VERBOSE | self::VERBOSITY_DEBUG;
  63665. $verbosity = $verbosities & $options ?: self::VERBOSITY_NORMAL;
  63666. if ($verbosity > $this->getVerbosity()) {
  63667. return;
  63668. }
  63669. foreach ($messages as $message) {
  63670. switch ($type) {
  63671. case OutputInterface::OUTPUT_NORMAL:
  63672. $message = $this->formatter->format($message);
  63673. break;
  63674. case OutputInterface::OUTPUT_RAW:
  63675. break;
  63676. case OutputInterface::OUTPUT_PLAIN:
  63677. $message = strip_tags($this->formatter->format($message));
  63678. break;
  63679. }
  63680. $this->doWrite($message ?? '', $newline);
  63681. }
  63682. }
  63683. abstract protected function doWrite(string $message, bool $newline);
  63684. }
  63685. <?php
  63686. namespace Symfony\Component\Console\Output;
  63687. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  63688. interface OutputInterface
  63689. {
  63690. public const VERBOSITY_QUIET = 16;
  63691. public const VERBOSITY_NORMAL = 32;
  63692. public const VERBOSITY_VERBOSE = 64;
  63693. public const VERBOSITY_VERY_VERBOSE = 128;
  63694. public const VERBOSITY_DEBUG = 256;
  63695. public const OUTPUT_NORMAL = 1;
  63696. public const OUTPUT_RAW = 2;
  63697. public const OUTPUT_PLAIN = 4;
  63698. public function write($messages, bool $newline = false, int $options = 0);
  63699. public function writeln($messages, int $options = 0);
  63700. public function setVerbosity(int $level);
  63701. public function getVerbosity();
  63702. public function isQuiet();
  63703. public function isVerbose();
  63704. public function isVeryVerbose();
  63705. public function isDebug();
  63706. public function setDecorated(bool $decorated);
  63707. public function isDecorated();
  63708. public function setFormatter(OutputFormatterInterface $formatter);
  63709. public function getFormatter();
  63710. }
  63711. <?php
  63712. namespace Symfony\Component\Console\Output;
  63713. use Symfony\Component\Console\Exception\InvalidArgumentException;
  63714. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  63715. class StreamOutput extends Output
  63716. {
  63717. private $stream;
  63718. public function __construct($stream, int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = null, OutputFormatterInterface $formatter = null)
  63719. {
  63720. if (!\is_resource($stream) || 'stream' !== get_resource_type($stream)) {
  63721. throw new InvalidArgumentException('The StreamOutput class needs a stream as its first argument.');
  63722. }
  63723. $this->stream = $stream;
  63724. if (null === $decorated) {
  63725. $decorated = $this->hasColorSupport();
  63726. }
  63727. parent::__construct($verbosity, $decorated, $formatter);
  63728. }
  63729. public function getStream()
  63730. {
  63731. return $this->stream;
  63732. }
  63733. protected function doWrite(string $message, bool $newline)
  63734. {
  63735. if ($newline) {
  63736. $message .= \PHP_EOL;
  63737. }
  63738. @fwrite($this->stream, $message);
  63739. fflush($this->stream);
  63740. }
  63741. protected function hasColorSupport()
  63742. {
  63743. if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) {
  63744. return false;
  63745. }
  63746. if ('Hyper' === getenv('TERM_PROGRAM')) {
  63747. return true;
  63748. }
  63749. if (\DIRECTORY_SEPARATOR === '\\') {
  63750. return (\function_exists('sapi_windows_vt100_support')
  63751. && @sapi_windows_vt100_support($this->stream))
  63752. || false !== getenv('ANSICON')
  63753. || 'ON' === getenv('ConEmuANSI')
  63754. || 'xterm' === getenv('TERM');
  63755. }
  63756. return stream_isatty($this->stream);
  63757. }
  63758. }
  63759. <?php
  63760. namespace Symfony\Component\Console\Output;
  63761. use Symfony\Component\Console\Exception\InvalidArgumentException;
  63762. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  63763. class TrimmedBufferOutput extends Output
  63764. {
  63765. private $maxLength;
  63766. private $buffer = '';
  63767. public function __construct(int $maxLength, ?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, OutputFormatterInterface $formatter = null)
  63768. {
  63769. if ($maxLength <= 0) {
  63770. throw new InvalidArgumentException(sprintf('"%s()" expects a strictly positive maxLength. Got %d.', __METHOD__, $maxLength));
  63771. }
  63772. parent::__construct($verbosity, $decorated, $formatter);
  63773. $this->maxLength = $maxLength;
  63774. }
  63775. public function fetch()
  63776. {
  63777. $content = $this->buffer;
  63778. $this->buffer = '';
  63779. return $content;
  63780. }
  63781. protected function doWrite(string $message, bool $newline)
  63782. {
  63783. $this->buffer .= $message;
  63784. if ($newline) {
  63785. $this->buffer .= \PHP_EOL;
  63786. }
  63787. $this->buffer = substr($this->buffer, 0 - $this->maxLength);
  63788. }
  63789. }
  63790. <?php
  63791. namespace Symfony\Component\Console\Question;
  63792. use Symfony\Component\Console\Exception\InvalidArgumentException;
  63793. class ChoiceQuestion extends Question
  63794. {
  63795. private $choices;
  63796. private $multiselect = false;
  63797. private $prompt = ' > ';
  63798. private $errorMessage = 'Value "%s" is invalid';
  63799. public function __construct(string $question, array $choices, $default = null)
  63800. {
  63801. if (!$choices) {
  63802. throw new \LogicException('Choice question must have at least 1 choice available.');
  63803. }
  63804. parent::__construct($question, $default);
  63805. $this->choices = $choices;
  63806. $this->setValidator($this->getDefaultValidator());
  63807. $this->setAutocompleterValues($choices);
  63808. }
  63809. public function getChoices()
  63810. {
  63811. return $this->choices;
  63812. }
  63813. public function setMultiselect(bool $multiselect)
  63814. {
  63815. $this->multiselect = $multiselect;
  63816. $this->setValidator($this->getDefaultValidator());
  63817. return $this;
  63818. }
  63819. public function isMultiselect()
  63820. {
  63821. return $this->multiselect;
  63822. }
  63823. public function getPrompt()
  63824. {
  63825. return $this->prompt;
  63826. }
  63827. public function setPrompt(string $prompt)
  63828. {
  63829. $this->prompt = $prompt;
  63830. return $this;
  63831. }
  63832. public function setErrorMessage(string $errorMessage)
  63833. {
  63834. $this->errorMessage = $errorMessage;
  63835. $this->setValidator($this->getDefaultValidator());
  63836. return $this;
  63837. }
  63838. private function getDefaultValidator(): callable
  63839. {
  63840. $choices = $this->choices;
  63841. $errorMessage = $this->errorMessage;
  63842. $multiselect = $this->multiselect;
  63843. $isAssoc = $this->isAssoc($choices);
  63844. return function ($selected) use ($choices, $errorMessage, $multiselect, $isAssoc) {
  63845. if ($multiselect) {
  63846. if (!preg_match('/^[^,]+(?:,[^,]+)*$/', (string) $selected, $matches)) {
  63847. throw new InvalidArgumentException(sprintf($errorMessage, $selected));
  63848. }
  63849. $selectedChoices = explode(',', (string) $selected);
  63850. } else {
  63851. $selectedChoices = [$selected];
  63852. }
  63853. if ($this->isTrimmable()) {
  63854. foreach ($selectedChoices as $k => $v) {
  63855. $selectedChoices[$k] = trim((string) $v);
  63856. }
  63857. }
  63858. $multiselectChoices = [];
  63859. foreach ($selectedChoices as $value) {
  63860. $results = [];
  63861. foreach ($choices as $key => $choice) {
  63862. if ($choice === $value) {
  63863. $results[] = $key;
  63864. }
  63865. }
  63866. if (\count($results) > 1) {
  63867. throw new InvalidArgumentException(sprintf('The provided answer is ambiguous. Value should be one of "%s".', implode('" or "', $results)));
  63868. }
  63869. $result = array_search($value, $choices);
  63870. if (!$isAssoc) {
  63871. if (false !== $result) {
  63872. $result = $choices[$result];
  63873. } elseif (isset($choices[$value])) {
  63874. $result = $choices[$value];
  63875. }
  63876. } elseif (false === $result && isset($choices[$value])) {
  63877. $result = $value;
  63878. }
  63879. if (false === $result) {
  63880. throw new InvalidArgumentException(sprintf($errorMessage, $value));
  63881. }
  63882. $multiselectChoices[] = $isAssoc ? (string) $result : $result;
  63883. }
  63884. if ($multiselect) {
  63885. return $multiselectChoices;
  63886. }
  63887. return current($multiselectChoices);
  63888. };
  63889. }
  63890. }
  63891. <?php
  63892. namespace Symfony\Component\Console\Question;
  63893. class ConfirmationQuestion extends Question
  63894. {
  63895. private $trueAnswerRegex;
  63896. public function __construct(string $question, bool $default = true, string $trueAnswerRegex = '/^y/i')
  63897. {
  63898. parent::__construct($question, $default);
  63899. $this->trueAnswerRegex = $trueAnswerRegex;
  63900. $this->setNormalizer($this->getDefaultNormalizer());
  63901. }
  63902. private function getDefaultNormalizer(): callable
  63903. {
  63904. $default = $this->getDefault();
  63905. $regex = $this->trueAnswerRegex;
  63906. return function ($answer) use ($default, $regex) {
  63907. if (\is_bool($answer)) {
  63908. return $answer;
  63909. }
  63910. $answerIsTrue = (bool) preg_match($regex, $answer);
  63911. if (false === $default) {
  63912. return $answer && $answerIsTrue;
  63913. }
  63914. return '' === $answer || $answerIsTrue;
  63915. };
  63916. }
  63917. }
  63918. <?php
  63919. namespace Symfony\Component\Console\Question;
  63920. use Symfony\Component\Console\Exception\InvalidArgumentException;
  63921. use Symfony\Component\Console\Exception\LogicException;
  63922. class Question
  63923. {
  63924. private $question;
  63925. private $attempts;
  63926. private $hidden = false;
  63927. private $hiddenFallback = true;
  63928. private $autocompleterCallback;
  63929. private $validator;
  63930. private $default;
  63931. private $normalizer;
  63932. private $trimmable = true;
  63933. private $multiline = false;
  63934. public function __construct(string $question, $default = null)
  63935. {
  63936. $this->question = $question;
  63937. $this->default = $default;
  63938. }
  63939. public function getQuestion()
  63940. {
  63941. return $this->question;
  63942. }
  63943. public function getDefault()
  63944. {
  63945. return $this->default;
  63946. }
  63947. public function isMultiline(): bool
  63948. {
  63949. return $this->multiline;
  63950. }
  63951. public function setMultiline(bool $multiline): self
  63952. {
  63953. $this->multiline = $multiline;
  63954. return $this;
  63955. }
  63956. public function isHidden()
  63957. {
  63958. return $this->hidden;
  63959. }
  63960. public function setHidden(bool $hidden)
  63961. {
  63962. if ($this->autocompleterCallback) {
  63963. throw new LogicException('A hidden question cannot use the autocompleter.');
  63964. }
  63965. $this->hidden = $hidden;
  63966. return $this;
  63967. }
  63968. public function isHiddenFallback()
  63969. {
  63970. return $this->hiddenFallback;
  63971. }
  63972. public function setHiddenFallback(bool $fallback)
  63973. {
  63974. $this->hiddenFallback = $fallback;
  63975. return $this;
  63976. }
  63977. public function getAutocompleterValues()
  63978. {
  63979. $callback = $this->getAutocompleterCallback();
  63980. return $callback ? $callback('') : null;
  63981. }
  63982. public function setAutocompleterValues(?iterable $values)
  63983. {
  63984. if (\is_array($values)) {
  63985. $values = $this->isAssoc($values) ? array_merge(array_keys($values), array_values($values)) : array_values($values);
  63986. $callback = static function () use ($values) {
  63987. return $values;
  63988. };
  63989. } elseif ($values instanceof \Traversable) {
  63990. $valueCache = null;
  63991. $callback = static function () use ($values, &$valueCache) {
  63992. return $valueCache ?? $valueCache = iterator_to_array($values, false);
  63993. };
  63994. } else {
  63995. $callback = null;
  63996. }
  63997. return $this->setAutocompleterCallback($callback);
  63998. }
  63999. public function getAutocompleterCallback(): ?callable
  64000. {
  64001. return $this->autocompleterCallback;
  64002. }
  64003. public function setAutocompleterCallback(callable $callback = null): self
  64004. {
  64005. if ($this->hidden && null !== $callback) {
  64006. throw new LogicException('A hidden question cannot use the autocompleter.');
  64007. }
  64008. $this->autocompleterCallback = $callback;
  64009. return $this;
  64010. }
  64011. public function setValidator(callable $validator = null)
  64012. {
  64013. $this->validator = $validator;
  64014. return $this;
  64015. }
  64016. public function getValidator()
  64017. {
  64018. return $this->validator;
  64019. }
  64020. public function setMaxAttempts(?int $attempts)
  64021. {
  64022. if (null !== $attempts && $attempts < 1) {
  64023. throw new InvalidArgumentException('Maximum number of attempts must be a positive value.');
  64024. }
  64025. $this->attempts = $attempts;
  64026. return $this;
  64027. }
  64028. public function getMaxAttempts()
  64029. {
  64030. return $this->attempts;
  64031. }
  64032. public function setNormalizer(callable $normalizer)
  64033. {
  64034. $this->normalizer = $normalizer;
  64035. return $this;
  64036. }
  64037. public function getNormalizer()
  64038. {
  64039. return $this->normalizer;
  64040. }
  64041. protected function isAssoc(array $array)
  64042. {
  64043. return (bool) \count(array_filter(array_keys($array), 'is_string'));
  64044. }
  64045. public function isTrimmable(): bool
  64046. {
  64047. return $this->trimmable;
  64048. }
  64049. public function setTrimmable(bool $trimmable): self
  64050. {
  64051. $this->trimmable = $trimmable;
  64052. return $this;
  64053. }
  64054. }
  64055. MZ��������ÿÿ��¸�������@�����������������������������������è���º�´ Í!¸LÍ!This program cannot be run in DOS mode.
  64056. $�������Æ,Í;§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��������à�  ��
  64057. ���������8������ ����@����������������������`�����?œ���@�����������������������������"��P����@�� �������������������P��p���!�����������������������������8!��@������������ ��Ø���������������������������.text��� ������
  64058. ����������������� ��`.rdata����� ���
  64059. �����������������@��@.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
  64060. 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
  64061. 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
  64062. 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">
  64063. <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
  64064. <security>
  64065. <requestedPrivileges>
  64066. <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
  64067. </requestedPrivileges>
  64068. </security>
  64069. </trustInfo>
  64070. <dependency>
  64071. <dependentAssembly>
  64072. <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
  64073. </dependentAssembly>
  64074. </dependency>
  64075. </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��������������������������������������������������������������������������������������������������������������������������������������������������# This file is part of the Symfony package.
  64076. #
  64077. # (c) Fabien Potencier <fabien@symfony.com>
  64078. #
  64079. # For the full copyright and license information, please view
  64080. # https://symfony.com/doc/current/contributing/code/license.html
  64081. _sf_{{ COMMAND_NAME }}() {
  64082. # Use newline as only separator to allow space in completion values
  64083. IFS=$'\n'
  64084. local sf_cmd="${COMP_WORDS[0]}"
  64085. # for an alias, get the real script behind it
  64086. sf_cmd_type=$(type -t $sf_cmd)
  64087. if [[ $sf_cmd_type == "alias" ]]; then
  64088. sf_cmd=$(alias $sf_cmd | sed -E "s/alias $sf_cmd='(.*)'/\1/")
  64089. elif [[ $sf_cmd_type == "file" ]]; then
  64090. sf_cmd=$(type -p $sf_cmd)
  64091. fi
  64092. if [[ $sf_cmd_type != "function" && ! -x $sf_cmd ]]; then
  64093. return 1
  64094. fi
  64095. local cur prev words cword
  64096. _get_comp_words_by_ref -n := cur prev words cword
  64097. local completecmd=("$sf_cmd" "_complete" "--no-interaction" "-sbash" "-c$cword" "-S{{ VERSION }}")
  64098. for w in ${words[@]}; do
  64099. w=$(printf -- '%b' "$w")
  64100. # remove quotes from typed values
  64101. quote="${w:0:1}"
  64102. if [ "$quote" == \' ]; then
  64103. w="${w%\'}"
  64104. w="${w#\'}"
  64105. elif [ "$quote" == \" ]; then
  64106. w="${w%\"}"
  64107. w="${w#\"}"
  64108. fi
  64109. # empty values are ignored
  64110. if [ ! -z "$w" ]; then
  64111. completecmd+=("-i$w")
  64112. fi
  64113. done
  64114. local sfcomplete
  64115. if sfcomplete=$(${completecmd[@]} 2>&1); then
  64116. local quote suggestions
  64117. quote=${cur:0:1}
  64118. # Use single quotes by default if suggestions contains backslash (FQCN)
  64119. if [ "$quote" == '' ] && [[ "$sfcomplete" =~ \\ ]]; then
  64120. quote=\'
  64121. fi
  64122. if [ "$quote" == \' ]; then
  64123. # single quotes: no additional escaping (does not accept ' in values)
  64124. suggestions=$(for s in $sfcomplete; do printf $'%q%q%q\n' "$quote" "$s" "$quote"; done)
  64125. elif [ "$quote" == \" ]; then
  64126. # double quotes: double escaping for \ $ ` "
  64127. suggestions=$(for s in $sfcomplete; do
  64128. s=${s//\\/\\\\}
  64129. s=${s//\$/\\\$}
  64130. s=${s//\`/\\\`}
  64131. s=${s//\"/\\\"}
  64132. printf $'%q%q%q\n' "$quote" "$s" "$quote";
  64133. done)
  64134. else
  64135. # no quotes: double escaping
  64136. suggestions=$(for s in $sfcomplete; do printf $'%q\n' $(printf '%q' "$s"); done)
  64137. fi
  64138. COMPREPLY=($(IFS=$'\n' compgen -W "$suggestions" -- $(printf -- "%q" "$cur")))
  64139. __ltrim_colon_completions "$cur"
  64140. else
  64141. if [[ "$sfcomplete" != *"Command \"_complete\" is not defined."* ]]; then
  64142. >&2 echo
  64143. >&2 echo $sfcomplete
  64144. fi
  64145. return 1
  64146. fi
  64147. }
  64148. complete -F _sf_{{ COMMAND_NAME }} {{ COMMAND_NAME }}
  64149. <?php
  64150. namespace Symfony\Component\Console\SignalRegistry;
  64151. final class SignalRegistry
  64152. {
  64153. private $signalHandlers = [];
  64154. public function __construct()
  64155. {
  64156. if (\function_exists('pcntl_async_signals')) {
  64157. pcntl_async_signals(true);
  64158. }
  64159. }
  64160. public function register(int $signal, callable $signalHandler): void
  64161. {
  64162. if (!isset($this->signalHandlers[$signal])) {
  64163. $previousCallback = pcntl_signal_get_handler($signal);
  64164. if (\is_callable($previousCallback)) {
  64165. $this->signalHandlers[$signal][] = $previousCallback;
  64166. }
  64167. }
  64168. $this->signalHandlers[$signal][] = $signalHandler;
  64169. pcntl_signal($signal, [$this, 'handle']);
  64170. }
  64171. public static function isSupported(): bool
  64172. {
  64173. if (!\function_exists('pcntl_signal')) {
  64174. return false;
  64175. }
  64176. if (\in_array('pcntl_signal', explode(',', \ini_get('disable_functions')))) {
  64177. return false;
  64178. }
  64179. return true;
  64180. }
  64181. public function handle(int $signal): void
  64182. {
  64183. $count = \count($this->signalHandlers[$signal]);
  64184. foreach ($this->signalHandlers[$signal] as $i => $signalHandler) {
  64185. $hasNext = $i !== $count - 1;
  64186. $signalHandler($signal, $hasNext);
  64187. }
  64188. }
  64189. }
  64190. <?php
  64191. namespace Symfony\Component\Console;
  64192. use Symfony\Component\Console\Command\Command;
  64193. use Symfony\Component\Console\Input\InputInterface;
  64194. use Symfony\Component\Console\Output\OutputInterface;
  64195. class SingleCommandApplication extends Command
  64196. {
  64197. private $version = 'UNKNOWN';
  64198. private $autoExit = true;
  64199. private $running = false;
  64200. public function setVersion(string $version): self
  64201. {
  64202. $this->version = $version;
  64203. return $this;
  64204. }
  64205. public function setAutoExit(bool $autoExit): self
  64206. {
  64207. $this->autoExit = $autoExit;
  64208. return $this;
  64209. }
  64210. public function run(InputInterface $input = null, OutputInterface $output = null): int
  64211. {
  64212. if ($this->running) {
  64213. return parent::run($input, $output);
  64214. }
  64215. $application = new Application($this->getName() ?: 'UNKNOWN', $this->version);
  64216. $application->setAutoExit($this->autoExit);
  64217. $this->setName($_SERVER['argv'][0]);
  64218. $application->add($this);
  64219. $application->setDefaultCommand($this->getName(), true);
  64220. $this->running = true;
  64221. try {
  64222. $ret = $application->run($input, $output);
  64223. } finally {
  64224. $this->running = false;
  64225. }
  64226. return $ret ?? 1;
  64227. }
  64228. }
  64229. <?php
  64230. namespace Symfony\Component\Console\Style;
  64231. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  64232. use Symfony\Component\Console\Helper\ProgressBar;
  64233. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  64234. use Symfony\Component\Console\Output\OutputInterface;
  64235. abstract class OutputStyle implements OutputInterface, StyleInterface
  64236. {
  64237. private $output;
  64238. public function __construct(OutputInterface $output)
  64239. {
  64240. $this->output = $output;
  64241. }
  64242. public function newLine(int $count = 1)
  64243. {
  64244. $this->output->write(str_repeat(\PHP_EOL, $count));
  64245. }
  64246. public function createProgressBar(int $max = 0)
  64247. {
  64248. return new ProgressBar($this->output, $max);
  64249. }
  64250. public function write($messages, bool $newline = false, int $type = self::OUTPUT_NORMAL)
  64251. {
  64252. $this->output->write($messages, $newline, $type);
  64253. }
  64254. public function writeln($messages, int $type = self::OUTPUT_NORMAL)
  64255. {
  64256. $this->output->writeln($messages, $type);
  64257. }
  64258. public function setVerbosity(int $level)
  64259. {
  64260. $this->output->setVerbosity($level);
  64261. }
  64262. public function getVerbosity()
  64263. {
  64264. return $this->output->getVerbosity();
  64265. }
  64266. public function setDecorated(bool $decorated)
  64267. {
  64268. $this->output->setDecorated($decorated);
  64269. }
  64270. public function isDecorated()
  64271. {
  64272. return $this->output->isDecorated();
  64273. }
  64274. public function setFormatter(OutputFormatterInterface $formatter)
  64275. {
  64276. $this->output->setFormatter($formatter);
  64277. }
  64278. public function getFormatter()
  64279. {
  64280. return $this->output->getFormatter();
  64281. }
  64282. public function isQuiet()
  64283. {
  64284. return $this->output->isQuiet();
  64285. }
  64286. public function isVerbose()
  64287. {
  64288. return $this->output->isVerbose();
  64289. }
  64290. public function isVeryVerbose()
  64291. {
  64292. return $this->output->isVeryVerbose();
  64293. }
  64294. public function isDebug()
  64295. {
  64296. return $this->output->isDebug();
  64297. }
  64298. protected function getErrorOutput()
  64299. {
  64300. if (!$this->output instanceof ConsoleOutputInterface) {
  64301. return $this->output;
  64302. }
  64303. return $this->output->getErrorOutput();
  64304. }
  64305. }
  64306. <?php
  64307. namespace Symfony\Component\Console\Style;
  64308. interface StyleInterface
  64309. {
  64310. public function title(string $message);
  64311. public function section(string $message);
  64312. public function listing(array $elements);
  64313. public function text($message);
  64314. public function success($message);
  64315. public function error($message);
  64316. public function warning($message);
  64317. public function note($message);
  64318. public function caution($message);
  64319. public function table(array $headers, array $rows);
  64320. public function ask(string $question, string $default = null, callable $validator = null);
  64321. public function askHidden(string $question, callable $validator = null);
  64322. public function confirm(string $question, bool $default = true);
  64323. public function choice(string $question, array $choices, $default = null);
  64324. public function newLine(int $count = 1);
  64325. public function progressStart(int $max = 0);
  64326. public function progressAdvance(int $step = 1);
  64327. public function progressFinish();
  64328. }
  64329. <?php
  64330. namespace Symfony\Component\Console\Style;
  64331. use Symfony\Component\Console\Exception\InvalidArgumentException;
  64332. use Symfony\Component\Console\Exception\RuntimeException;
  64333. use Symfony\Component\Console\Formatter\OutputFormatter;
  64334. use Symfony\Component\Console\Helper\Helper;
  64335. use Symfony\Component\Console\Helper\ProgressBar;
  64336. use Symfony\Component\Console\Helper\SymfonyQuestionHelper;
  64337. use Symfony\Component\Console\Helper\Table;
  64338. use Symfony\Component\Console\Helper\TableCell;
  64339. use Symfony\Component\Console\Helper\TableSeparator;
  64340. use Symfony\Component\Console\Input\InputInterface;
  64341. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  64342. use Symfony\Component\Console\Output\OutputInterface;
  64343. use Symfony\Component\Console\Output\TrimmedBufferOutput;
  64344. use Symfony\Component\Console\Question\ChoiceQuestion;
  64345. use Symfony\Component\Console\Question\ConfirmationQuestion;
  64346. use Symfony\Component\Console\Question\Question;
  64347. use Symfony\Component\Console\Terminal;
  64348. class SymfonyStyle extends OutputStyle
  64349. {
  64350. public const MAX_LINE_LENGTH = 120;
  64351. private $input;
  64352. private $output;
  64353. private $questionHelper;
  64354. private $progressBar;
  64355. private $lineLength;
  64356. private $bufferedOutput;
  64357. public function __construct(InputInterface $input, OutputInterface $output)
  64358. {
  64359. $this->input = $input;
  64360. $this->bufferedOutput = new TrimmedBufferOutput(\DIRECTORY_SEPARATOR === '\\' ? 4 : 2, $output->getVerbosity(), false, clone $output->getFormatter());
  64361. $width = (new Terminal())->getWidth() ?: self::MAX_LINE_LENGTH;
  64362. $this->lineLength = min($width - (int) (\DIRECTORY_SEPARATOR === '\\'), self::MAX_LINE_LENGTH);
  64363. parent::__construct($this->output = $output);
  64364. }
  64365. public function block($messages, string $type = null, string $style = null, string $prefix = ' ', bool $padding = false, bool $escape = true)
  64366. {
  64367. $messages = \is_array($messages) ? array_values($messages) : [$messages];
  64368. $this->autoPrependBlock();
  64369. $this->writeln($this->createBlock($messages, $type, $style, $prefix, $padding, $escape));
  64370. $this->newLine();
  64371. }
  64372. public function title(string $message)
  64373. {
  64374. $this->autoPrependBlock();
  64375. $this->writeln([
  64376. sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
  64377. sprintf('<comment>%s</>', str_repeat('=', Helper::width(Helper::removeDecoration($this->getFormatter(), $message)))),
  64378. ]);
  64379. $this->newLine();
  64380. }
  64381. public function section(string $message)
  64382. {
  64383. $this->autoPrependBlock();
  64384. $this->writeln([
  64385. sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
  64386. sprintf('<comment>%s</>', str_repeat('-', Helper::width(Helper::removeDecoration($this->getFormatter(), $message)))),
  64387. ]);
  64388. $this->newLine();
  64389. }
  64390. public function listing(array $elements)
  64391. {
  64392. $this->autoPrependText();
  64393. $elements = array_map(function ($element) {
  64394. return sprintf(' * %s', $element);
  64395. }, $elements);
  64396. $this->writeln($elements);
  64397. $this->newLine();
  64398. }
  64399. public function text($message)
  64400. {
  64401. $this->autoPrependText();
  64402. $messages = \is_array($message) ? array_values($message) : [$message];
  64403. foreach ($messages as $message) {
  64404. $this->writeln(sprintf(' %s', $message));
  64405. }
  64406. }
  64407. public function comment($message)
  64408. {
  64409. $this->block($message, null, null, '<fg=default;bg=default> // </>', false, false);
  64410. }
  64411. public function success($message)
  64412. {
  64413. $this->block($message, 'OK', 'fg=black;bg=green', ' ', true);
  64414. }
  64415. public function error($message)
  64416. {
  64417. $this->block($message, 'ERROR', 'fg=white;bg=red', ' ', true);
  64418. }
  64419. public function warning($message)
  64420. {
  64421. $this->block($message, 'WARNING', 'fg=black;bg=yellow', ' ', true);
  64422. }
  64423. public function note($message)
  64424. {
  64425. $this->block($message, 'NOTE', 'fg=yellow', ' ! ');
  64426. }
  64427. public function info($message)
  64428. {
  64429. $this->block($message, 'INFO', 'fg=green', ' ', true);
  64430. }
  64431. public function caution($message)
  64432. {
  64433. $this->block($message, 'CAUTION', 'fg=white;bg=red', ' ! ', true);
  64434. }
  64435. public function table(array $headers, array $rows)
  64436. {
  64437. $this->createTable()
  64438. ->setHeaders($headers)
  64439. ->setRows($rows)
  64440. ->render()
  64441. ;
  64442. $this->newLine();
  64443. }
  64444. public function horizontalTable(array $headers, array $rows)
  64445. {
  64446. $this->createTable()
  64447. ->setHorizontal(true)
  64448. ->setHeaders($headers)
  64449. ->setRows($rows)
  64450. ->render()
  64451. ;
  64452. $this->newLine();
  64453. }
  64454. public function definitionList(...$list)
  64455. {
  64456. $headers = [];
  64457. $row = [];
  64458. foreach ($list as $value) {
  64459. if ($value instanceof TableSeparator) {
  64460. $headers[] = $value;
  64461. $row[] = $value;
  64462. continue;
  64463. }
  64464. if (\is_string($value)) {
  64465. $headers[] = new TableCell($value, ['colspan' => 2]);
  64466. $row[] = null;
  64467. continue;
  64468. }
  64469. if (!\is_array($value)) {
  64470. throw new InvalidArgumentException('Value should be an array, string, or an instance of TableSeparator.');
  64471. }
  64472. $headers[] = key($value);
  64473. $row[] = current($value);
  64474. }
  64475. $this->horizontalTable($headers, [$row]);
  64476. }
  64477. public function ask(string $question, string $default = null, callable $validator = null)
  64478. {
  64479. $question = new Question($question, $default);
  64480. $question->setValidator($validator);
  64481. return $this->askQuestion($question);
  64482. }
  64483. public function askHidden(string $question, callable $validator = null)
  64484. {
  64485. $question = new Question($question);
  64486. $question->setHidden(true);
  64487. $question->setValidator($validator);
  64488. return $this->askQuestion($question);
  64489. }
  64490. public function confirm(string $question, bool $default = true)
  64491. {
  64492. return $this->askQuestion(new ConfirmationQuestion($question, $default));
  64493. }
  64494. public function choice(string $question, array $choices, $default = null)
  64495. {
  64496. if (null !== $default) {
  64497. $values = array_flip($choices);
  64498. $default = $values[$default] ?? $default;
  64499. }
  64500. return $this->askQuestion(new ChoiceQuestion($question, $choices, $default));
  64501. }
  64502. public function progressStart(int $max = 0)
  64503. {
  64504. $this->progressBar = $this->createProgressBar($max);
  64505. $this->progressBar->start();
  64506. }
  64507. public function progressAdvance(int $step = 1)
  64508. {
  64509. $this->getProgressBar()->advance($step);
  64510. }
  64511. public function progressFinish()
  64512. {
  64513. $this->getProgressBar()->finish();
  64514. $this->newLine(2);
  64515. $this->progressBar = null;
  64516. }
  64517. public function createProgressBar(int $max = 0)
  64518. {
  64519. $progressBar = parent::createProgressBar($max);
  64520. if ('\\' !== \DIRECTORY_SEPARATOR || 'Hyper' === getenv('TERM_PROGRAM')) {
  64521. $progressBar->setEmptyBarCharacter('â–‘');
  64522. $progressBar->setProgressCharacter('');
  64523. $progressBar->setBarCharacter('â–“');
  64524. }
  64525. return $progressBar;
  64526. }
  64527. public function progressIterate(iterable $iterable, int $max = null): iterable
  64528. {
  64529. yield from $this->createProgressBar()->iterate($iterable, $max);
  64530. $this->newLine(2);
  64531. }
  64532. public function askQuestion(Question $question)
  64533. {
  64534. if ($this->input->isInteractive()) {
  64535. $this->autoPrependBlock();
  64536. }
  64537. if (!$this->questionHelper) {
  64538. $this->questionHelper = new SymfonyQuestionHelper();
  64539. }
  64540. $answer = $this->questionHelper->ask($this->input, $this, $question);
  64541. if ($this->input->isInteractive()) {
  64542. $this->newLine();
  64543. $this->bufferedOutput->write("\n");
  64544. }
  64545. return $answer;
  64546. }
  64547. public function writeln($messages, int $type = self::OUTPUT_NORMAL)
  64548. {
  64549. if (!is_iterable($messages)) {
  64550. $messages = [$messages];
  64551. }
  64552. foreach ($messages as $message) {
  64553. parent::writeln($message, $type);
  64554. $this->writeBuffer($message, true, $type);
  64555. }
  64556. }
  64557. public function write($messages, bool $newline = false, int $type = self::OUTPUT_NORMAL)
  64558. {
  64559. if (!is_iterable($messages)) {
  64560. $messages = [$messages];
  64561. }
  64562. foreach ($messages as $message) {
  64563. parent::write($message, $newline, $type);
  64564. $this->writeBuffer($message, $newline, $type);
  64565. }
  64566. }
  64567. public function newLine(int $count = 1)
  64568. {
  64569. parent::newLine($count);
  64570. $this->bufferedOutput->write(str_repeat("\n", $count));
  64571. }
  64572. public function getErrorStyle()
  64573. {
  64574. return new self($this->input, $this->getErrorOutput());
  64575. }
  64576. public function createTable(): Table
  64577. {
  64578. $output = $this->output instanceof ConsoleOutputInterface ? $this->output->section() : $this->output;
  64579. $style = clone Table::getStyleDefinition('symfony-style-guide');
  64580. $style->setCellHeaderFormat('<info>%s</info>');
  64581. return (new Table($output))->setStyle($style);
  64582. }
  64583. private function getProgressBar(): ProgressBar
  64584. {
  64585. if (!$this->progressBar) {
  64586. throw new RuntimeException('The ProgressBar is not started.');
  64587. }
  64588. return $this->progressBar;
  64589. }
  64590. private function autoPrependBlock(): void
  64591. {
  64592. $chars = substr(str_replace(\PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2);
  64593. if (!isset($chars[0])) {
  64594. $this->newLine();
  64595. return;
  64596. }
  64597. $this->newLine(2 - substr_count($chars, "\n"));
  64598. }
  64599. private function autoPrependText(): void
  64600. {
  64601. $fetched = $this->bufferedOutput->fetch();
  64602. if (!str_ends_with($fetched, "\n")) {
  64603. $this->newLine();
  64604. }
  64605. }
  64606. private function writeBuffer(string $message, bool $newLine, int $type): void
  64607. {
  64608. $this->bufferedOutput->write($message, $newLine, $type);
  64609. }
  64610. private function createBlock(iterable $messages, string $type = null, string $style = null, string $prefix = ' ', bool $padding = false, bool $escape = false): array
  64611. {
  64612. $indentLength = 0;
  64613. $prefixLength = Helper::width(Helper::removeDecoration($this->getFormatter(), $prefix));
  64614. $lines = [];
  64615. if (null !== $type) {
  64616. $type = sprintf('[%s] ', $type);
  64617. $indentLength = \strlen($type);
  64618. $lineIndentation = str_repeat(' ', $indentLength);
  64619. }
  64620. foreach ($messages as $key => $message) {
  64621. if ($escape) {
  64622. $message = OutputFormatter::escape($message);
  64623. }
  64624. $decorationLength = Helper::width($message) - Helper::width(Helper::removeDecoration($this->getFormatter(), $message));
  64625. $messageLineLength = min($this->lineLength - $prefixLength - $indentLength + $decorationLength, $this->lineLength);
  64626. $messageLines = explode(\PHP_EOL, wordwrap($message, $messageLineLength, \PHP_EOL, true));
  64627. foreach ($messageLines as $messageLine) {
  64628. $lines[] = $messageLine;
  64629. }
  64630. if (\count($messages) > 1 && $key < \count($messages) - 1) {
  64631. $lines[] = '';
  64632. }
  64633. }
  64634. $firstLineIndex = 0;
  64635. if ($padding && $this->isDecorated()) {
  64636. $firstLineIndex = 1;
  64637. array_unshift($lines, '');
  64638. $lines[] = '';
  64639. }
  64640. foreach ($lines as $i => &$line) {
  64641. if (null !== $type) {
  64642. $line = $firstLineIndex === $i ? $type.$line : $lineIndentation.$line;
  64643. }
  64644. $line = $prefix.$line;
  64645. $line .= str_repeat(' ', max($this->lineLength - Helper::width(Helper::removeDecoration($this->getFormatter(), $line)), 0));
  64646. if ($style) {
  64647. $line = sprintf('<%s>%s</>', $style, $line);
  64648. }
  64649. }
  64650. return $lines;
  64651. }
  64652. }
  64653. <?php
  64654. namespace Symfony\Component\Console;
  64655. class Terminal
  64656. {
  64657. private static $width;
  64658. private static $height;
  64659. private static $stty;
  64660. public function getWidth()
  64661. {
  64662. $width = getenv('COLUMNS');
  64663. if (false !== $width) {
  64664. return (int) trim($width);
  64665. }
  64666. if (null === self::$width) {
  64667. self::initDimensions();
  64668. }
  64669. return self::$width ?: 80;
  64670. }
  64671. public function getHeight()
  64672. {
  64673. $height = getenv('LINES');
  64674. if (false !== $height) {
  64675. return (int) trim($height);
  64676. }
  64677. if (null === self::$height) {
  64678. self::initDimensions();
  64679. }
  64680. return self::$height ?: 50;
  64681. }
  64682. public static function hasSttyAvailable(): bool
  64683. {
  64684. if (null !== self::$stty) {
  64685. return self::$stty;
  64686. }
  64687. if (!\function_exists('shell_exec')) {
  64688. return false;
  64689. }
  64690. return self::$stty = (bool) shell_exec('stty 2> '.('\\' === \DIRECTORY_SEPARATOR ? 'NUL' : '/dev/null'));
  64691. }
  64692. private static function initDimensions()
  64693. {
  64694. if ('\\' === \DIRECTORY_SEPARATOR) {
  64695. $ansicon = getenv('ANSICON');
  64696. if (false !== $ansicon && preg_match('/^(\d+)x(\d+)(?: \((\d+)x(\d+)\))?$/', trim($ansicon), $matches)) {
  64697. self::$width = (int) $matches[1];
  64698. self::$height = isset($matches[4]) ? (int) $matches[4] : (int) $matches[2];
  64699. } elseif (!self::hasVt100Support() && self::hasSttyAvailable()) {
  64700. self::initDimensionsUsingStty();
  64701. } elseif (null !== $dimensions = self::getConsoleMode()) {
  64702. self::$width = (int) $dimensions[0];
  64703. self::$height = (int) $dimensions[1];
  64704. }
  64705. } else {
  64706. self::initDimensionsUsingStty();
  64707. }
  64708. }
  64709. private static function hasVt100Support(): bool
  64710. {
  64711. return \function_exists('sapi_windows_vt100_support') && sapi_windows_vt100_support(fopen('php://stdout', 'w'));
  64712. }
  64713. private static function initDimensionsUsingStty()
  64714. {
  64715. if ($sttyString = self::getSttyColumns()) {
  64716. if (preg_match('/rows.(\d+);.columns.(\d+);/i', $sttyString, $matches)) {
  64717. self::$width = (int) $matches[2];
  64718. self::$height = (int) $matches[1];
  64719. } elseif (preg_match('/;.(\d+).rows;.(\d+).columns/i', $sttyString, $matches)) {
  64720. self::$width = (int) $matches[2];
  64721. self::$height = (int) $matches[1];
  64722. }
  64723. }
  64724. }
  64725. private static function getConsoleMode(): ?array
  64726. {
  64727. $info = self::readFromProcess('mode CON');
  64728. if (null === $info || !preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) {
  64729. return null;
  64730. }
  64731. return [(int) $matches[2], (int) $matches[1]];
  64732. }
  64733. private static function getSttyColumns(): ?string
  64734. {
  64735. return self::readFromProcess('stty -a | grep columns');
  64736. }
  64737. private static function readFromProcess(string $command): ?string
  64738. {
  64739. if (!\function_exists('proc_open')) {
  64740. return null;
  64741. }
  64742. $descriptorspec = [
  64743. 1 => ['pipe', 'w'],
  64744. 2 => ['pipe', 'w'],
  64745. ];
  64746. $cp = \function_exists('sapi_windows_cp_set') ? sapi_windows_cp_get() : 0;
  64747. $process = proc_open($command, $descriptorspec, $pipes, null, null, ['suppress_errors' => true]);
  64748. if (!\is_resource($process)) {
  64749. return null;
  64750. }
  64751. $info = stream_get_contents($pipes[1]);
  64752. fclose($pipes[1]);
  64753. fclose($pipes[2]);
  64754. proc_close($process);
  64755. if ($cp) {
  64756. sapi_windows_cp_set($cp);
  64757. }
  64758. return $info;
  64759. }
  64760. }
  64761. <?php
  64762. namespace Symfony\Component\Console\Tester;
  64763. use Symfony\Component\Console\Application;
  64764. use Symfony\Component\Console\Input\ArrayInput;
  64765. class ApplicationTester
  64766. {
  64767. use TesterTrait;
  64768. private $application;
  64769. public function __construct(Application $application)
  64770. {
  64771. $this->application = $application;
  64772. }
  64773. public function run(array $input, array $options = [])
  64774. {
  64775. $prevShellVerbosity = getenv('SHELL_VERBOSITY');
  64776. try {
  64777. $this->input = new ArrayInput($input);
  64778. if (isset($options['interactive'])) {
  64779. $this->input->setInteractive($options['interactive']);
  64780. }
  64781. if ($this->inputs) {
  64782. $this->input->setStream(self::createStream($this->inputs));
  64783. }
  64784. $this->initOutput($options);
  64785. return $this->statusCode = $this->application->run($this->input, $this->output);
  64786. } finally {
  64787. if (false === $prevShellVerbosity) {
  64788. if (\function_exists('putenv')) {
  64789. @putenv('SHELL_VERBOSITY');
  64790. }
  64791. unset($_ENV['SHELL_VERBOSITY']);
  64792. unset($_SERVER['SHELL_VERBOSITY']);
  64793. } else {
  64794. if (\function_exists('putenv')) {
  64795. @putenv('SHELL_VERBOSITY='.$prevShellVerbosity);
  64796. }
  64797. $_ENV['SHELL_VERBOSITY'] = $prevShellVerbosity;
  64798. $_SERVER['SHELL_VERBOSITY'] = $prevShellVerbosity;
  64799. }
  64800. }
  64801. }
  64802. }
  64803. <?php
  64804. namespace Symfony\Component\Console\Tester;
  64805. use Symfony\Component\Console\Command\Command;
  64806. use Symfony\Component\Console\Completion\CompletionInput;
  64807. use Symfony\Component\Console\Completion\CompletionSuggestions;
  64808. class CommandCompletionTester
  64809. {
  64810. private $command;
  64811. public function __construct(Command $command)
  64812. {
  64813. $this->command = $command;
  64814. }
  64815. public function complete(array $input): array
  64816. {
  64817. $currentIndex = \count($input);
  64818. if ('' === end($input)) {
  64819. array_pop($input);
  64820. }
  64821. array_unshift($input, $this->command->getName());
  64822. $completionInput = CompletionInput::fromTokens($input, $currentIndex);
  64823. $completionInput->bind($this->command->getDefinition());
  64824. $suggestions = new CompletionSuggestions();
  64825. $this->command->complete($completionInput, $suggestions);
  64826. $options = [];
  64827. foreach ($suggestions->getOptionSuggestions() as $option) {
  64828. $options[] = '--'.$option->getName();
  64829. }
  64830. return array_map('strval', array_merge($options, $suggestions->getValueSuggestions()));
  64831. }
  64832. }
  64833. <?php
  64834. namespace Symfony\Component\Console\Tester;
  64835. use Symfony\Component\Console\Command\Command;
  64836. use Symfony\Component\Console\Input\ArrayInput;
  64837. class CommandTester
  64838. {
  64839. use TesterTrait;
  64840. private $command;
  64841. public function __construct(Command $command)
  64842. {
  64843. $this->command = $command;
  64844. }
  64845. public function execute(array $input, array $options = [])
  64846. {
  64847. if (!isset($input['command'])
  64848. && (null !== $application = $this->command->getApplication())
  64849. && $application->getDefinition()->hasArgument('command')
  64850. ) {
  64851. $input = array_merge(['command' => $this->command->getName()], $input);
  64852. }
  64853. $this->input = new ArrayInput($input);
  64854. $this->input->setStream(self::createStream($this->inputs));
  64855. if (isset($options['interactive'])) {
  64856. $this->input->setInteractive($options['interactive']);
  64857. }
  64858. if (!isset($options['decorated'])) {
  64859. $options['decorated'] = false;
  64860. }
  64861. $this->initOutput($options);
  64862. return $this->statusCode = $this->command->run($this->input, $this->output);
  64863. }
  64864. }
  64865. <?php
  64866. namespace Symfony\Component\Console\Tester\Constraint;
  64867. use PHPUnit\Framework\Constraint\Constraint;
  64868. use Symfony\Component\Console\Command\Command;
  64869. final class CommandIsSuccessful extends Constraint
  64870. {
  64871. public function toString(): string
  64872. {
  64873. return 'is successful';
  64874. }
  64875. protected function matches($other): bool
  64876. {
  64877. return Command::SUCCESS === $other;
  64878. }
  64879. protected function failureDescription($other): string
  64880. {
  64881. return 'the command '.$this->toString();
  64882. }
  64883. protected function additionalFailureDescription($other): string
  64884. {
  64885. $mapping = [
  64886. Command::FAILURE => 'Command failed.',
  64887. Command::INVALID => 'Command was invalid.',
  64888. ];
  64889. return $mapping[$other] ?? sprintf('Command returned exit status %d.', $other);
  64890. }
  64891. }
  64892. <?php
  64893. namespace Symfony\Component\Console\Tester;
  64894. use PHPUnit\Framework\Assert;
  64895. use Symfony\Component\Console\Input\InputInterface;
  64896. use Symfony\Component\Console\Output\ConsoleOutput;
  64897. use Symfony\Component\Console\Output\OutputInterface;
  64898. use Symfony\Component\Console\Output\StreamOutput;
  64899. use Symfony\Component\Console\Tester\Constraint\CommandIsSuccessful;
  64900. trait TesterTrait
  64901. {
  64902. private $output;
  64903. private $inputs = [];
  64904. private $captureStreamsIndependently = false;
  64905. private $input;
  64906. private $statusCode;
  64907. public function getDisplay(bool $normalize = false)
  64908. {
  64909. if (null === $this->output) {
  64910. throw new \RuntimeException('Output not initialized, did you execute the command before requesting the display?');
  64911. }
  64912. rewind($this->output->getStream());
  64913. $display = stream_get_contents($this->output->getStream());
  64914. if ($normalize) {
  64915. $display = str_replace(\PHP_EOL, "\n", $display);
  64916. }
  64917. return $display;
  64918. }
  64919. public function getErrorOutput(bool $normalize = false)
  64920. {
  64921. if (!$this->captureStreamsIndependently) {
  64922. throw new \LogicException('The error output is not available when the tester is run without "capture_stderr_separately" option set.');
  64923. }
  64924. rewind($this->output->getErrorOutput()->getStream());
  64925. $display = stream_get_contents($this->output->getErrorOutput()->getStream());
  64926. if ($normalize) {
  64927. $display = str_replace(\PHP_EOL, "\n", $display);
  64928. }
  64929. return $display;
  64930. }
  64931. public function getInput()
  64932. {
  64933. return $this->input;
  64934. }
  64935. public function getOutput()
  64936. {
  64937. return $this->output;
  64938. }
  64939. public function getStatusCode()
  64940. {
  64941. if (null === $this->statusCode) {
  64942. throw new \RuntimeException('Status code not initialized, did you execute the command before requesting the status code?');
  64943. }
  64944. return $this->statusCode;
  64945. }
  64946. public function assertCommandIsSuccessful(string $message = ''): void
  64947. {
  64948. Assert::assertThat($this->statusCode, new CommandIsSuccessful(), $message);
  64949. }
  64950. public function setInputs(array $inputs)
  64951. {
  64952. $this->inputs = $inputs;
  64953. return $this;
  64954. }
  64955. private function initOutput(array $options)
  64956. {
  64957. $this->captureStreamsIndependently = \array_key_exists('capture_stderr_separately', $options) && $options['capture_stderr_separately'];
  64958. if (!$this->captureStreamsIndependently) {
  64959. $this->output = new StreamOutput(fopen('php://memory', 'w', false));
  64960. if (isset($options['decorated'])) {
  64961. $this->output->setDecorated($options['decorated']);
  64962. }
  64963. if (isset($options['verbosity'])) {
  64964. $this->output->setVerbosity($options['verbosity']);
  64965. }
  64966. } else {
  64967. $this->output = new ConsoleOutput(
  64968. $options['verbosity'] ?? ConsoleOutput::VERBOSITY_NORMAL,
  64969. $options['decorated'] ?? null
  64970. );
  64971. $errorOutput = new StreamOutput(fopen('php://memory', 'w', false));
  64972. $errorOutput->setFormatter($this->output->getFormatter());
  64973. $errorOutput->setVerbosity($this->output->getVerbosity());
  64974. $errorOutput->setDecorated($this->output->isDecorated());
  64975. $reflectedOutput = new \ReflectionObject($this->output);
  64976. $strErrProperty = $reflectedOutput->getProperty('stderr');
  64977. $strErrProperty->setAccessible(true);
  64978. $strErrProperty->setValue($this->output, $errorOutput);
  64979. $reflectedParent = $reflectedOutput->getParentClass();
  64980. $streamProperty = $reflectedParent->getProperty('stream');
  64981. $streamProperty->setAccessible(true);
  64982. $streamProperty->setValue($this->output, fopen('php://memory', 'w', false));
  64983. }
  64984. }
  64985. private static function createStream(array $inputs)
  64986. {
  64987. $stream = fopen('php://memory', 'r+', false);
  64988. foreach ($inputs as $input) {
  64989. fwrite($stream, $input.\PHP_EOL);
  64990. }
  64991. rewind($stream);
  64992. return $stream;
  64993. }
  64994. }
  64995. Copyright (c) 2020-2022 Fabien Potencier
  64996. Permission is hereby granted, free of charge, to any person obtaining a copy
  64997. of this software and associated documentation files (the "Software"), to deal
  64998. in the Software without restriction, including without limitation the rights
  64999. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  65000. copies of the Software, and to permit persons to whom the Software is furnished
  65001. to do so, subject to the following conditions:
  65002. The above copyright notice and this permission notice shall be included in all
  65003. copies or substantial portions of the Software.
  65004. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  65005. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  65006. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  65007. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  65008. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  65009. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  65010. THE SOFTWARE.
  65011. <?php
  65012. if (!function_exists('trigger_deprecation')) {
  65013. function trigger_deprecation(string $package, string $version, string $message, ...$args): void
  65014. {
  65015. @trigger_error(($package || $version ? "Since $package $version: " : '').($args ? vsprintf($message, $args) : $message), \E_USER_DEPRECATED);
  65016. }
  65017. }
  65018. <?php
  65019. namespace Symfony\Component\Filesystem\Exception;
  65020. interface ExceptionInterface extends \Throwable
  65021. {
  65022. }
  65023. <?php
  65024. namespace Symfony\Component\Filesystem\Exception;
  65025. class FileNotFoundException extends IOException
  65026. {
  65027. public function __construct(string $message = null, int $code = 0, \Throwable $previous = null, string $path = null)
  65028. {
  65029. if (null === $message) {
  65030. if (null === $path) {
  65031. $message = 'File could not be found.';
  65032. } else {
  65033. $message = sprintf('File "%s" could not be found.', $path);
  65034. }
  65035. }
  65036. parent::__construct($message, $code, $previous, $path);
  65037. }
  65038. }
  65039. <?php
  65040. namespace Symfony\Component\Filesystem\Exception;
  65041. class IOException extends \RuntimeException implements IOExceptionInterface
  65042. {
  65043. private $path;
  65044. public function __construct(string $message, int $code = 0, \Throwable $previous = null, string $path = null)
  65045. {
  65046. $this->path = $path;
  65047. parent::__construct($message, $code, $previous);
  65048. }
  65049. public function getPath()
  65050. {
  65051. return $this->path;
  65052. }
  65053. }
  65054. <?php
  65055. namespace Symfony\Component\Filesystem\Exception;
  65056. interface IOExceptionInterface extends ExceptionInterface
  65057. {
  65058. public function getPath();
  65059. }
  65060. <?php
  65061. namespace Symfony\Component\Filesystem\Exception;
  65062. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  65063. {
  65064. }
  65065. <?php
  65066. namespace Symfony\Component\Filesystem\Exception;
  65067. class RuntimeException extends \RuntimeException implements ExceptionInterface
  65068. {
  65069. }
  65070. <?php
  65071. namespace Symfony\Component\Filesystem;
  65072. use Symfony\Component\Filesystem\Exception\FileNotFoundException;
  65073. use Symfony\Component\Filesystem\Exception\InvalidArgumentException;
  65074. use Symfony\Component\Filesystem\Exception\IOException;
  65075. class Filesystem
  65076. {
  65077. private static $lastError;
  65078. public function copy(string $originFile, string $targetFile, bool $overwriteNewerFiles = false)
  65079. {
  65080. $originIsLocal = stream_is_local($originFile) || 0 === stripos($originFile, 'file://');
  65081. if ($originIsLocal && !is_file($originFile)) {
  65082. throw new FileNotFoundException(sprintf('Failed to copy "%s" because file does not exist.', $originFile), 0, null, $originFile);
  65083. }
  65084. $this->mkdir(\dirname($targetFile));
  65085. $doCopy = true;
  65086. if (!$overwriteNewerFiles && null === parse_url($originFile, \PHP_URL_HOST) && is_file($targetFile)) {
  65087. $doCopy = filemtime($originFile) > filemtime($targetFile);
  65088. }
  65089. if ($doCopy) {
  65090. if (!$source = self::box('fopen', $originFile, 'r')) {
  65091. 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);
  65092. }
  65093. if (!$target = self::box('fopen', $targetFile, 'w', false, stream_context_create(['ftp' => ['overwrite' => true]]))) {
  65094. 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);
  65095. }
  65096. $bytesCopied = stream_copy_to_stream($source, $target);
  65097. fclose($source);
  65098. fclose($target);
  65099. unset($source, $target);
  65100. if (!is_file($targetFile)) {
  65101. throw new IOException(sprintf('Failed to copy "%s" to "%s".', $originFile, $targetFile), 0, null, $originFile);
  65102. }
  65103. if ($originIsLocal) {
  65104. self::box('chmod', $targetFile, fileperms($targetFile) | (fileperms($originFile) & 0111));
  65105. if ($bytesCopied !== $bytesOrigin = filesize($originFile)) {
  65106. 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);
  65107. }
  65108. }
  65109. }
  65110. }
  65111. public function mkdir($dirs, int $mode = 0777)
  65112. {
  65113. foreach ($this->toIterable($dirs) as $dir) {
  65114. if (is_dir($dir)) {
  65115. continue;
  65116. }
  65117. if (!self::box('mkdir', $dir, $mode, true) && !is_dir($dir)) {
  65118. throw new IOException(sprintf('Failed to create "%s": ', $dir).self::$lastError, 0, null, $dir);
  65119. }
  65120. }
  65121. }
  65122. public function exists($files)
  65123. {
  65124. $maxPathLength = \PHP_MAXPATHLEN - 2;
  65125. foreach ($this->toIterable($files) as $file) {
  65126. if (\strlen($file) > $maxPathLength) {
  65127. throw new IOException(sprintf('Could not check if file exist because path length exceeds %d characters.', $maxPathLength), 0, null, $file);
  65128. }
  65129. if (!file_exists($file)) {
  65130. return false;
  65131. }
  65132. }
  65133. return true;
  65134. }
  65135. public function touch($files, int $time = null, int $atime = null)
  65136. {
  65137. foreach ($this->toIterable($files) as $file) {
  65138. if (!($time ? self::box('touch', $file, $time, $atime) : self::box('touch', $file))) {
  65139. throw new IOException(sprintf('Failed to touch "%s": ', $file).self::$lastError, 0, null, $file);
  65140. }
  65141. }
  65142. }
  65143. public function remove($files)
  65144. {
  65145. if ($files instanceof \Traversable) {
  65146. $files = iterator_to_array($files, false);
  65147. } elseif (!\is_array($files)) {
  65148. $files = [$files];
  65149. }
  65150. self::doRemove($files, false);
  65151. }
  65152. private static function doRemove(array $files, bool $isRecursive): void
  65153. {
  65154. $files = array_reverse($files);
  65155. foreach ($files as $file) {
  65156. if (is_link($file)) {
  65157. if (!(self::box('unlink', $file) || '\\' !== \DIRECTORY_SEPARATOR || self::box('rmdir', $file)) && file_exists($file)) {
  65158. throw new IOException(sprintf('Failed to remove symlink "%s": ', $file).self::$lastError);
  65159. }
  65160. } elseif (is_dir($file)) {
  65161. if (!$isRecursive) {
  65162. $tmpName = \dirname(realpath($file)).'/.'.strrev(strtr(base64_encode(random_bytes(2)), '/=', '-_'));
  65163. if (file_exists($tmpName)) {
  65164. try {
  65165. self::doRemove([$tmpName], true);
  65166. } catch (IOException $e) {
  65167. }
  65168. }
  65169. if (!file_exists($tmpName) && self::box('rename', $file, $tmpName)) {
  65170. $origFile = $file;
  65171. $file = $tmpName;
  65172. } else {
  65173. $origFile = null;
  65174. }
  65175. }
  65176. $files = new \FilesystemIterator($file, \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS);
  65177. self::doRemove(iterator_to_array($files, true), true);
  65178. if (!self::box('rmdir', $file) && file_exists($file) && !$isRecursive) {
  65179. $lastError = self::$lastError;
  65180. if (null !== $origFile && self::box('rename', $file, $origFile)) {
  65181. $file = $origFile;
  65182. }
  65183. throw new IOException(sprintf('Failed to remove directory "%s": ', $file).$lastError);
  65184. }
  65185. } elseif (!self::box('unlink', $file) && (str_contains(self::$lastError, 'Permission denied') || file_exists($file))) {
  65186. throw new IOException(sprintf('Failed to remove file "%s": ', $file).self::$lastError);
  65187. }
  65188. }
  65189. }
  65190. public function chmod($files, int $mode, int $umask = 0000, bool $recursive = false)
  65191. {
  65192. foreach ($this->toIterable($files) as $file) {
  65193. if ((\PHP_VERSION_ID < 80000 || \is_int($mode)) && !self::box('chmod', $file, $mode & ~$umask)) {
  65194. throw new IOException(sprintf('Failed to chmod file "%s": ', $file).self::$lastError, 0, null, $file);
  65195. }
  65196. if ($recursive && is_dir($file) && !is_link($file)) {
  65197. $this->chmod(new \FilesystemIterator($file), $mode, $umask, true);
  65198. }
  65199. }
  65200. }
  65201. public function chown($files, $user, bool $recursive = false)
  65202. {
  65203. foreach ($this->toIterable($files) as $file) {
  65204. if ($recursive && is_dir($file) && !is_link($file)) {
  65205. $this->chown(new \FilesystemIterator($file), $user, true);
  65206. }
  65207. if (is_link($file) && \function_exists('lchown')) {
  65208. if (!self::box('lchown', $file, $user)) {
  65209. throw new IOException(sprintf('Failed to chown file "%s": ', $file).self::$lastError, 0, null, $file);
  65210. }
  65211. } else {
  65212. if (!self::box('chown', $file, $user)) {
  65213. throw new IOException(sprintf('Failed to chown file "%s": ', $file).self::$lastError, 0, null, $file);
  65214. }
  65215. }
  65216. }
  65217. }
  65218. public function chgrp($files, $group, bool $recursive = false)
  65219. {
  65220. foreach ($this->toIterable($files) as $file) {
  65221. if ($recursive && is_dir($file) && !is_link($file)) {
  65222. $this->chgrp(new \FilesystemIterator($file), $group, true);
  65223. }
  65224. if (is_link($file) && \function_exists('lchgrp')) {
  65225. if (!self::box('lchgrp', $file, $group)) {
  65226. throw new IOException(sprintf('Failed to chgrp file "%s": ', $file).self::$lastError, 0, null, $file);
  65227. }
  65228. } else {
  65229. if (!self::box('chgrp', $file, $group)) {
  65230. throw new IOException(sprintf('Failed to chgrp file "%s": ', $file).self::$lastError, 0, null, $file);
  65231. }
  65232. }
  65233. }
  65234. }
  65235. public function rename(string $origin, string $target, bool $overwrite = false)
  65236. {
  65237. if (!$overwrite && $this->isReadable($target)) {
  65238. throw new IOException(sprintf('Cannot rename because the target "%s" already exists.', $target), 0, null, $target);
  65239. }
  65240. if (!self::box('rename', $origin, $target)) {
  65241. if (is_dir($origin)) {
  65242. $this->mirror($origin, $target, null, ['override' => $overwrite, 'delete' => $overwrite]);
  65243. $this->remove($origin);
  65244. return;
  65245. }
  65246. throw new IOException(sprintf('Cannot rename "%s" to "%s": ', $origin, $target).self::$lastError, 0, null, $target);
  65247. }
  65248. }
  65249. private function isReadable(string $filename): bool
  65250. {
  65251. $maxPathLength = \PHP_MAXPATHLEN - 2;
  65252. if (\strlen($filename) > $maxPathLength) {
  65253. throw new IOException(sprintf('Could not check if file is readable because path length exceeds %d characters.', $maxPathLength), 0, null, $filename);
  65254. }
  65255. return is_readable($filename);
  65256. }
  65257. public function symlink(string $originDir, string $targetDir, bool $copyOnWindows = false)
  65258. {
  65259. self::assertFunctionExists('symlink');
  65260. if ('\\' === \DIRECTORY_SEPARATOR) {
  65261. $originDir = strtr($originDir, '/', '\\');
  65262. $targetDir = strtr($targetDir, '/', '\\');
  65263. if ($copyOnWindows) {
  65264. $this->mirror($originDir, $targetDir);
  65265. return;
  65266. }
  65267. }
  65268. $this->mkdir(\dirname($targetDir));
  65269. if (is_link($targetDir)) {
  65270. if (readlink($targetDir) === $originDir) {
  65271. return;
  65272. }
  65273. $this->remove($targetDir);
  65274. }
  65275. if (!self::box('symlink', $originDir, $targetDir)) {
  65276. $this->linkException($originDir, $targetDir, 'symbolic');
  65277. }
  65278. }
  65279. public function hardlink(string $originFile, $targetFiles)
  65280. {
  65281. self::assertFunctionExists('link');
  65282. if (!$this->exists($originFile)) {
  65283. throw new FileNotFoundException(null, 0, null, $originFile);
  65284. }
  65285. if (!is_file($originFile)) {
  65286. throw new FileNotFoundException(sprintf('Origin file "%s" is not a file.', $originFile));
  65287. }
  65288. foreach ($this->toIterable($targetFiles) as $targetFile) {
  65289. if (is_file($targetFile)) {
  65290. if (fileinode($originFile) === fileinode($targetFile)) {
  65291. continue;
  65292. }
  65293. $this->remove($targetFile);
  65294. }
  65295. if (!self::box('link', $originFile, $targetFile)) {
  65296. $this->linkException($originFile, $targetFile, 'hard');
  65297. }
  65298. }
  65299. }
  65300. private function linkException(string $origin, string $target, string $linkType)
  65301. {
  65302. if (self::$lastError) {
  65303. if ('\\' === \DIRECTORY_SEPARATOR && str_contains(self::$lastError, 'error code(1314)')) {
  65304. 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);
  65305. }
  65306. }
  65307. throw new IOException(sprintf('Failed to create "%s" link from "%s" to "%s": ', $linkType, $origin, $target).self::$lastError, 0, null, $target);
  65308. }
  65309. public function readlink(string $path, bool $canonicalize = false)
  65310. {
  65311. if (!$canonicalize && !is_link($path)) {
  65312. return null;
  65313. }
  65314. if ($canonicalize) {
  65315. if (!$this->exists($path)) {
  65316. return null;
  65317. }
  65318. if ('\\' === \DIRECTORY_SEPARATOR && \PHP_VERSION_ID < 70410) {
  65319. $path = readlink($path);
  65320. }
  65321. return realpath($path);
  65322. }
  65323. if ('\\' === \DIRECTORY_SEPARATOR && \PHP_VERSION_ID < 70400) {
  65324. return realpath($path);
  65325. }
  65326. return readlink($path);
  65327. }
  65328. public function makePathRelative(string $endPath, string $startPath)
  65329. {
  65330. if (!$this->isAbsolutePath($startPath)) {
  65331. throw new InvalidArgumentException(sprintf('The start path "%s" is not absolute.', $startPath));
  65332. }
  65333. if (!$this->isAbsolutePath($endPath)) {
  65334. throw new InvalidArgumentException(sprintf('The end path "%s" is not absolute.', $endPath));
  65335. }
  65336. if ('\\' === \DIRECTORY_SEPARATOR) {
  65337. $endPath = str_replace('\\', '/', $endPath);
  65338. $startPath = str_replace('\\', '/', $startPath);
  65339. }
  65340. $splitDriveLetter = function ($path) {
  65341. return (\strlen($path) > 2 && ':' === $path[1] && '/' === $path[2] && ctype_alpha($path[0]))
  65342. ? [substr($path, 2), strtoupper($path[0])]
  65343. : [$path, null];
  65344. };
  65345. $splitPath = function ($path) {
  65346. $result = [];
  65347. foreach (explode('/', trim($path, '/')) as $segment) {
  65348. if ('..' === $segment) {
  65349. array_pop($result);
  65350. } elseif ('.' !== $segment && '' !== $segment) {
  65351. $result[] = $segment;
  65352. }
  65353. }
  65354. return $result;
  65355. };
  65356. [$endPath, $endDriveLetter] = $splitDriveLetter($endPath);
  65357. [$startPath, $startDriveLetter] = $splitDriveLetter($startPath);
  65358. $startPathArr = $splitPath($startPath);
  65359. $endPathArr = $splitPath($endPath);
  65360. if ($endDriveLetter && $startDriveLetter && $endDriveLetter != $startDriveLetter) {
  65361. return $endDriveLetter.':/'.($endPathArr ? implode('/', $endPathArr).'/' : '');
  65362. }
  65363. $index = 0;
  65364. while (isset($startPathArr[$index]) && isset($endPathArr[$index]) && $startPathArr[$index] === $endPathArr[$index]) {
  65365. ++$index;
  65366. }
  65367. if (1 === \count($startPathArr) && '' === $startPathArr[0]) {
  65368. $depth = 0;
  65369. } else {
  65370. $depth = \count($startPathArr) - $index;
  65371. }
  65372. $traverser = str_repeat('../', $depth);
  65373. $endPathRemainder = implode('/', \array_slice($endPathArr, $index));
  65374. $relativePath = $traverser.('' !== $endPathRemainder ? $endPathRemainder.'/' : '');
  65375. return '' === $relativePath ? './' : $relativePath;
  65376. }
  65377. public function mirror(string $originDir, string $targetDir, \Traversable $iterator = null, array $options = [])
  65378. {
  65379. $targetDir = rtrim($targetDir, '/\\');
  65380. $originDir = rtrim($originDir, '/\\');
  65381. $originDirLen = \strlen($originDir);
  65382. if (!$this->exists($originDir)) {
  65383. throw new IOException(sprintf('The origin directory specified "%s" was not found.', $originDir), 0, null, $originDir);
  65384. }
  65385. if ($this->exists($targetDir) && isset($options['delete']) && $options['delete']) {
  65386. $deleteIterator = $iterator;
  65387. if (null === $deleteIterator) {
  65388. $flags = \FilesystemIterator::SKIP_DOTS;
  65389. $deleteIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($targetDir, $flags), \RecursiveIteratorIterator::CHILD_FIRST);
  65390. }
  65391. $targetDirLen = \strlen($targetDir);
  65392. foreach ($deleteIterator as $file) {
  65393. $origin = $originDir.substr($file->getPathname(), $targetDirLen);
  65394. if (!$this->exists($origin)) {
  65395. $this->remove($file);
  65396. }
  65397. }
  65398. }
  65399. $copyOnWindows = $options['copy_on_windows'] ?? false;
  65400. if (null === $iterator) {
  65401. $flags = $copyOnWindows ? \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS : \FilesystemIterator::SKIP_DOTS;
  65402. $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($originDir, $flags), \RecursiveIteratorIterator::SELF_FIRST);
  65403. }
  65404. $this->mkdir($targetDir);
  65405. $filesCreatedWhileMirroring = [];
  65406. foreach ($iterator as $file) {
  65407. if ($file->getPathname() === $targetDir || $file->getRealPath() === $targetDir || isset($filesCreatedWhileMirroring[$file->getRealPath()])) {
  65408. continue;
  65409. }
  65410. $target = $targetDir.substr($file->getPathname(), $originDirLen);
  65411. $filesCreatedWhileMirroring[$target] = true;
  65412. if (!$copyOnWindows && is_link($file)) {
  65413. $this->symlink($file->getLinkTarget(), $target);
  65414. } elseif (is_dir($file)) {
  65415. $this->mkdir($target);
  65416. } elseif (is_file($file)) {
  65417. $this->copy($file, $target, $options['override'] ?? false);
  65418. } else {
  65419. throw new IOException(sprintf('Unable to guess "%s" file type.', $file), 0, null, $file);
  65420. }
  65421. }
  65422. }
  65423. public function isAbsolutePath(string $file)
  65424. {
  65425. return '' !== $file && (strspn($file, '/\\', 0, 1)
  65426. || (\strlen($file) > 3 && ctype_alpha($file[0])
  65427. && ':' === $file[1]
  65428. && strspn($file, '/\\', 2, 1)
  65429. )
  65430. || null !== parse_url($file, \PHP_URL_SCHEME)
  65431. );
  65432. }
  65433. public function tempnam(string $dir, string $prefix)
  65434. {
  65435. $suffix = \func_num_args() > 2 ? func_get_arg(2) : '';
  65436. [$scheme, $hierarchy] = $this->getSchemeAndHierarchy($dir);
  65437. if ((null === $scheme || 'file' === $scheme || 'gs' === $scheme) && '' === $suffix) {
  65438. if ($tmpFile = self::box('tempnam', $hierarchy, $prefix)) {
  65439. if (null !== $scheme && 'gs' !== $scheme) {
  65440. return $scheme.'://'.$tmpFile;
  65441. }
  65442. return $tmpFile;
  65443. }
  65444. throw new IOException('A temporary file could not be created: '.self::$lastError);
  65445. }
  65446. for ($i = 0; $i < 10; ++$i) {
  65447. $tmpFile = $dir.'/'.$prefix.uniqid(mt_rand(), true).$suffix;
  65448. if (!$handle = self::box('fopen', $tmpFile, 'x+')) {
  65449. continue;
  65450. }
  65451. self::box('fclose', $handle);
  65452. return $tmpFile;
  65453. }
  65454. throw new IOException('A temporary file could not be created: '.self::$lastError);
  65455. }
  65456. public function dumpFile(string $filename, $content)
  65457. {
  65458. if (\is_array($content)) {
  65459. throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be string or resource, array given.', __METHOD__));
  65460. }
  65461. $dir = \dirname($filename);
  65462. if (is_link($filename) && $linkTarget = $this->readlink($filename)) {
  65463. $this->dumpFile(Path::makeAbsolute($linkTarget, $dir), $content);
  65464. return;
  65465. }
  65466. if (!is_dir($dir)) {
  65467. $this->mkdir($dir);
  65468. }
  65469. $tmpFile = $this->tempnam($dir, basename($filename));
  65470. try {
  65471. if (false === self::box('file_put_contents', $tmpFile, $content)) {
  65472. throw new IOException(sprintf('Failed to write file "%s": ', $filename).self::$lastError, 0, null, $filename);
  65473. }
  65474. self::box('chmod', $tmpFile, file_exists($filename) ? fileperms($filename) : 0666 & ~umask());
  65475. $this->rename($tmpFile, $filename, true);
  65476. } finally {
  65477. if (file_exists($tmpFile)) {
  65478. self::box('unlink', $tmpFile);
  65479. }
  65480. }
  65481. }
  65482. public function appendToFile(string $filename, $content)
  65483. {
  65484. if (\is_array($content)) {
  65485. throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be string or resource, array given.', __METHOD__));
  65486. }
  65487. $dir = \dirname($filename);
  65488. if (!is_dir($dir)) {
  65489. $this->mkdir($dir);
  65490. }
  65491. $lock = \func_num_args() > 2 && func_get_arg(2);
  65492. if (false === self::box('file_put_contents', $filename, $content, \FILE_APPEND | ($lock ? \LOCK_EX : 0))) {
  65493. throw new IOException(sprintf('Failed to write file "%s": ', $filename).self::$lastError, 0, null, $filename);
  65494. }
  65495. }
  65496. private function toIterable($files): iterable
  65497. {
  65498. return is_iterable($files) ? $files : [$files];
  65499. }
  65500. private function getSchemeAndHierarchy(string $filename): array
  65501. {
  65502. $components = explode('://', $filename, 2);
  65503. return 2 === \count($components) ? [$components[0], $components[1]] : [null, $components[0]];
  65504. }
  65505. private static function assertFunctionExists(string $func): void
  65506. {
  65507. if (!\function_exists($func)) {
  65508. throw new IOException(sprintf('Unable to perform filesystem operation because the "%s()" function has been disabled.', $func));
  65509. }
  65510. }
  65511. private static function box(string $func, ...$args)
  65512. {
  65513. self::assertFunctionExists($func);
  65514. self::$lastError = null;
  65515. set_error_handler(__CLASS__.'::handleError');
  65516. try {
  65517. return $func(...$args);
  65518. } finally {
  65519. restore_error_handler();
  65520. }
  65521. }
  65522. public static function handleError(int $type, string $msg)
  65523. {
  65524. self::$lastError = $msg;
  65525. }
  65526. }
  65527. Copyright (c) 2004-present Fabien Potencier
  65528. Permission is hereby granted, free of charge, to any person obtaining a copy
  65529. of this software and associated documentation files (the "Software"), to deal
  65530. in the Software without restriction, including without limitation the rights
  65531. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  65532. copies of the Software, and to permit persons to whom the Software is furnished
  65533. to do so, subject to the following conditions:
  65534. The above copyright notice and this permission notice shall be included in all
  65535. copies or substantial portions of the Software.
  65536. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  65537. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  65538. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  65539. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  65540. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  65541. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  65542. THE SOFTWARE.
  65543. <?php
  65544. namespace Symfony\Component\Filesystem;
  65545. use Symfony\Component\Filesystem\Exception\InvalidArgumentException;
  65546. use Symfony\Component\Filesystem\Exception\RuntimeException;
  65547. final class Path
  65548. {
  65549. private const CLEANUP_THRESHOLD = 1250;
  65550. private const CLEANUP_SIZE = 1000;
  65551. private static $buffer = [];
  65552. private static $bufferSize = 0;
  65553. public static function canonicalize(string $path): string
  65554. {
  65555. if ('' === $path) {
  65556. return '';
  65557. }
  65558. if (isset(self::$buffer[$path])) {
  65559. return self::$buffer[$path];
  65560. }
  65561. if ('~' === $path[0]) {
  65562. $path = self::getHomeDirectory().substr($path, 1);
  65563. }
  65564. $path = self::normalize($path);
  65565. [$root, $pathWithoutRoot] = self::split($path);
  65566. $canonicalParts = self::findCanonicalParts($root, $pathWithoutRoot);
  65567. self::$buffer[$path] = $canonicalPath = $root.implode('/', $canonicalParts);
  65568. ++self::$bufferSize;
  65569. if (self::$bufferSize > self::CLEANUP_THRESHOLD) {
  65570. self::$buffer = \array_slice(self::$buffer, -self::CLEANUP_SIZE, null, true);
  65571. self::$bufferSize = self::CLEANUP_SIZE;
  65572. }
  65573. return $canonicalPath;
  65574. }
  65575. public static function normalize(string $path): string
  65576. {
  65577. return str_replace('\\', '/', $path);
  65578. }
  65579. public static function getDirectory(string $path): string
  65580. {
  65581. if ('' === $path) {
  65582. return '';
  65583. }
  65584. $path = self::canonicalize($path);
  65585. if (false !== $schemeSeparatorPosition = strpos($path, '://')) {
  65586. $scheme = substr($path, 0, $schemeSeparatorPosition + 3);
  65587. $path = substr($path, $schemeSeparatorPosition + 3);
  65588. } else {
  65589. $scheme = '';
  65590. }
  65591. if (false === $dirSeparatorPosition = strrpos($path, '/')) {
  65592. return '';
  65593. }
  65594. if (0 === $dirSeparatorPosition) {
  65595. return $scheme.'/';
  65596. }
  65597. if (2 === $dirSeparatorPosition && ctype_alpha($path[0]) && ':' === $path[1]) {
  65598. return $scheme.substr($path, 0, 3);
  65599. }
  65600. return $scheme.substr($path, 0, $dirSeparatorPosition);
  65601. }
  65602. public static function getHomeDirectory(): string
  65603. {
  65604. if (getenv('HOME')) {
  65605. return self::canonicalize(getenv('HOME'));
  65606. }
  65607. if (getenv('HOMEDRIVE') && getenv('HOMEPATH')) {
  65608. return self::canonicalize(getenv('HOMEDRIVE').getenv('HOMEPATH'));
  65609. }
  65610. throw new RuntimeException("Cannot find the home directory path: Your environment or operating system isn't supported.");
  65611. }
  65612. public static function getRoot(string $path): string
  65613. {
  65614. if ('' === $path) {
  65615. return '';
  65616. }
  65617. if (false !== $schemeSeparatorPosition = strpos($path, '://')) {
  65618. $scheme = substr($path, 0, $schemeSeparatorPosition + 3);
  65619. $path = substr($path, $schemeSeparatorPosition + 3);
  65620. } else {
  65621. $scheme = '';
  65622. }
  65623. $firstCharacter = $path[0];
  65624. if ('/' === $firstCharacter || '\\' === $firstCharacter) {
  65625. return $scheme.'/';
  65626. }
  65627. $length = \strlen($path);
  65628. if ($length > 1 && ':' === $path[1] && ctype_alpha($firstCharacter)) {
  65629. if (2 === $length) {
  65630. return $scheme.$path.'/';
  65631. }
  65632. if ('/' === $path[2] || '\\' === $path[2]) {
  65633. return $scheme.$firstCharacter.$path[1].'/';
  65634. }
  65635. }
  65636. return '';
  65637. }
  65638. public static function getFilenameWithoutExtension(string $path, string $extension = null): string
  65639. {
  65640. if ('' === $path) {
  65641. return '';
  65642. }
  65643. if (null !== $extension) {
  65644. return rtrim(basename($path, $extension), '.');
  65645. }
  65646. return pathinfo($path, \PATHINFO_FILENAME);
  65647. }
  65648. public static function getExtension(string $path, bool $forceLowerCase = false): string
  65649. {
  65650. if ('' === $path) {
  65651. return '';
  65652. }
  65653. $extension = pathinfo($path, \PATHINFO_EXTENSION);
  65654. if ($forceLowerCase) {
  65655. $extension = self::toLower($extension);
  65656. }
  65657. return $extension;
  65658. }
  65659. public static function hasExtension(string $path, $extensions = null, bool $ignoreCase = false): bool
  65660. {
  65661. if ('' === $path) {
  65662. return false;
  65663. }
  65664. $actualExtension = self::getExtension($path, $ignoreCase);
  65665. if ([] === $extensions || null === $extensions) {
  65666. return '' !== $actualExtension;
  65667. }
  65668. if (\is_string($extensions)) {
  65669. $extensions = [$extensions];
  65670. }
  65671. foreach ($extensions as $key => $extension) {
  65672. if ($ignoreCase) {
  65673. $extension = self::toLower($extension);
  65674. }
  65675. $extensions[$key] = ltrim($extension, '.');
  65676. }
  65677. return \in_array($actualExtension, $extensions, true);
  65678. }
  65679. public static function changeExtension(string $path, string $extension): string
  65680. {
  65681. if ('' === $path) {
  65682. return '';
  65683. }
  65684. $actualExtension = self::getExtension($path);
  65685. $extension = ltrim($extension, '.');
  65686. if ('/' === substr($path, -1)) {
  65687. return $path;
  65688. }
  65689. if (empty($actualExtension)) {
  65690. return $path.('.' === substr($path, -1) ? '' : '.').$extension;
  65691. }
  65692. return substr($path, 0, -\strlen($actualExtension)).$extension;
  65693. }
  65694. public static function isAbsolute(string $path): bool
  65695. {
  65696. if ('' === $path) {
  65697. return false;
  65698. }
  65699. if (false !== $schemeSeparatorPosition = strpos($path, '://')) {
  65700. $path = substr($path, $schemeSeparatorPosition + 3);
  65701. }
  65702. $firstCharacter = $path[0];
  65703. if ('/' === $firstCharacter || '\\' === $firstCharacter) {
  65704. return true;
  65705. }
  65706. if (\strlen($path) > 1 && ctype_alpha($firstCharacter) && ':' === $path[1]) {
  65707. if (2 === \strlen($path)) {
  65708. return true;
  65709. }
  65710. if ('/' === $path[2] || '\\' === $path[2]) {
  65711. return true;
  65712. }
  65713. }
  65714. return false;
  65715. }
  65716. public static function isRelative(string $path): bool
  65717. {
  65718. return !self::isAbsolute($path);
  65719. }
  65720. public static function makeAbsolute(string $path, string $basePath): string
  65721. {
  65722. if ('' === $basePath) {
  65723. throw new InvalidArgumentException(sprintf('The base path must be a non-empty string. Got: "%s".', $basePath));
  65724. }
  65725. if (!self::isAbsolute($basePath)) {
  65726. throw new InvalidArgumentException(sprintf('The base path "%s" is not an absolute path.', $basePath));
  65727. }
  65728. if (self::isAbsolute($path)) {
  65729. return self::canonicalize($path);
  65730. }
  65731. if (false !== $schemeSeparatorPosition = strpos($basePath, '://')) {
  65732. $scheme = substr($basePath, 0, $schemeSeparatorPosition + 3);
  65733. $basePath = substr($basePath, $schemeSeparatorPosition + 3);
  65734. } else {
  65735. $scheme = '';
  65736. }
  65737. return $scheme.self::canonicalize(rtrim($basePath, '/\\').'/'.$path);
  65738. }
  65739. public static function makeRelative(string $path, string $basePath): string
  65740. {
  65741. $path = self::canonicalize($path);
  65742. $basePath = self::canonicalize($basePath);
  65743. [$root, $relativePath] = self::split($path);
  65744. [$baseRoot, $relativeBasePath] = self::split($basePath);
  65745. if ('' === $root && '' !== $baseRoot) {
  65746. if ('' === $relativeBasePath) {
  65747. $relativePath = ltrim($relativePath, './\\');
  65748. }
  65749. return $relativePath;
  65750. }
  65751. if ('' !== $root && '' === $baseRoot) {
  65752. 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));
  65753. }
  65754. if ($baseRoot && $root !== $baseRoot) {
  65755. 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));
  65756. }
  65757. if ('' === $relativeBasePath) {
  65758. return $relativePath;
  65759. }
  65760. $parts = explode('/', $relativePath);
  65761. $baseParts = explode('/', $relativeBasePath);
  65762. $dotDotPrefix = '';
  65763. $match = true;
  65764. foreach ($baseParts as $index => $basePart) {
  65765. if ($match && isset($parts[$index]) && $basePart === $parts[$index]) {
  65766. unset($parts[$index]);
  65767. continue;
  65768. }
  65769. $match = false;
  65770. $dotDotPrefix .= '../';
  65771. }
  65772. return rtrim($dotDotPrefix.implode('/', $parts), '/');
  65773. }
  65774. public static function isLocal(string $path): bool
  65775. {
  65776. return '' !== $path && false === strpos($path, '://');
  65777. }
  65778. public static function getLongestCommonBasePath(string ...$paths): ?string
  65779. {
  65780. [$bpRoot, $basePath] = self::split(self::canonicalize(reset($paths)));
  65781. for (next($paths); null !== key($paths) && '' !== $basePath; next($paths)) {
  65782. [$root, $path] = self::split(self::canonicalize(current($paths)));
  65783. if ($root !== $bpRoot) {
  65784. return null;
  65785. }
  65786. while (true) {
  65787. if ('.' === $basePath) {
  65788. $basePath = '';
  65789. continue 2;
  65790. }
  65791. if (0 === strpos($path.'/', $basePath.'/')) {
  65792. continue 2;
  65793. }
  65794. $basePath = \dirname($basePath);
  65795. }
  65796. }
  65797. return $bpRoot.$basePath;
  65798. }
  65799. public static function join(string ...$paths): string
  65800. {
  65801. $finalPath = null;
  65802. $wasScheme = false;
  65803. foreach ($paths as $path) {
  65804. if ('' === $path) {
  65805. continue;
  65806. }
  65807. if (null === $finalPath) {
  65808. $finalPath = $path;
  65809. $wasScheme = (false !== strpos($path, '://'));
  65810. continue;
  65811. }
  65812. if (!\in_array(substr($finalPath, -1), ['/', '\\'])) {
  65813. $finalPath .= '/';
  65814. }
  65815. $finalPath .= $wasScheme ? $path : ltrim($path, '/');
  65816. $wasScheme = false;
  65817. }
  65818. if (null === $finalPath) {
  65819. return '';
  65820. }
  65821. return self::canonicalize($finalPath);
  65822. }
  65823. public static function isBasePath(string $basePath, string $ofPath): bool
  65824. {
  65825. $basePath = self::canonicalize($basePath);
  65826. $ofPath = self::canonicalize($ofPath);
  65827. return 0 === strpos($ofPath.'/', rtrim($basePath, '/').'/');
  65828. }
  65829. private static function findCanonicalParts(string $root, string $pathWithoutRoot): array
  65830. {
  65831. $parts = explode('/', $pathWithoutRoot);
  65832. $canonicalParts = [];
  65833. foreach ($parts as $part) {
  65834. if ('.' === $part || '' === $part) {
  65835. continue;
  65836. }
  65837. if ('..' === $part && \count($canonicalParts) > 0 && '..' !== $canonicalParts[\count($canonicalParts) - 1]) {
  65838. array_pop($canonicalParts);
  65839. continue;
  65840. }
  65841. if ('..' !== $part || '' === $root) {
  65842. $canonicalParts[] = $part;
  65843. }
  65844. }
  65845. return $canonicalParts;
  65846. }
  65847. private static function split(string $path): array
  65848. {
  65849. if ('' === $path) {
  65850. return ['', ''];
  65851. }
  65852. if (false !== $schemeSeparatorPosition = strpos($path, '://')) {
  65853. $root = substr($path, 0, $schemeSeparatorPosition + 3);
  65854. $path = substr($path, $schemeSeparatorPosition + 3);
  65855. } else {
  65856. $root = '';
  65857. }
  65858. $length = \strlen($path);
  65859. if (0 === strpos($path, '/')) {
  65860. $root .= '/';
  65861. $path = $length > 1 ? substr($path, 1) : '';
  65862. } elseif ($length > 1 && ctype_alpha($path[0]) && ':' === $path[1]) {
  65863. if (2 === $length) {
  65864. $root .= $path.'/';
  65865. $path = '';
  65866. } elseif ('/' === $path[2]) {
  65867. $root .= substr($path, 0, 3);
  65868. $path = $length > 3 ? substr($path, 3) : '';
  65869. }
  65870. }
  65871. return [$root, $path];
  65872. }
  65873. private static function toLower(string $string): string
  65874. {
  65875. if (false !== $encoding = mb_detect_encoding($string, null, true)) {
  65876. return mb_strtolower($string, $encoding);
  65877. }
  65878. return strtolower($string);
  65879. }
  65880. private function __construct()
  65881. {
  65882. }
  65883. }
  65884. <?php
  65885. namespace Symfony\Component\Finder\Comparator;
  65886. class Comparator
  65887. {
  65888. private $target;
  65889. private $operator = '==';
  65890. public function __construct(string $target = null, string $operator = '==')
  65891. {
  65892. if (null === $target) {
  65893. trigger_deprecation('symfony/finder', '5.4', 'Constructing a "%s" without setting "$target" is deprecated.', __CLASS__);
  65894. }
  65895. $this->target = $target;
  65896. $this->doSetOperator($operator);
  65897. }
  65898. public function getTarget()
  65899. {
  65900. if (null === $this->target) {
  65901. trigger_deprecation('symfony/finder', '5.4', 'Calling "%s" without initializing the target is deprecated.', __METHOD__);
  65902. }
  65903. return $this->target;
  65904. }
  65905. public function setTarget(string $target)
  65906. {
  65907. trigger_deprecation('symfony/finder', '5.4', '"%s" is deprecated. Set the target via the constructor instead.', __METHOD__);
  65908. $this->target = $target;
  65909. }
  65910. public function getOperator()
  65911. {
  65912. return $this->operator;
  65913. }
  65914. public function setOperator(string $operator)
  65915. {
  65916. trigger_deprecation('symfony/finder', '5.4', '"%s" is deprecated. Set the operator via the constructor instead.', __METHOD__);
  65917. $this->doSetOperator('' === $operator ? '==' : $operator);
  65918. }
  65919. public function test($test)
  65920. {
  65921. if (null === $this->target) {
  65922. trigger_deprecation('symfony/finder', '5.4', 'Calling "%s" without initializing the target is deprecated.', __METHOD__);
  65923. }
  65924. switch ($this->operator) {
  65925. case '>':
  65926. return $test > $this->target;
  65927. case '>=':
  65928. return $test >= $this->target;
  65929. case '<':
  65930. return $test < $this->target;
  65931. case '<=':
  65932. return $test <= $this->target;
  65933. case '!=':
  65934. return $test != $this->target;
  65935. }
  65936. return $test == $this->target;
  65937. }
  65938. private function doSetOperator(string $operator): void
  65939. {
  65940. if (!\in_array($operator, ['>', '<', '>=', '<=', '==', '!='])) {
  65941. throw new \InvalidArgumentException(sprintf('Invalid operator "%s".', $operator));
  65942. }
  65943. $this->operator = $operator;
  65944. }
  65945. }
  65946. <?php
  65947. namespace Symfony\Component\Finder\Comparator;
  65948. class DateComparator extends Comparator
  65949. {
  65950. public function __construct(string $test)
  65951. {
  65952. if (!preg_match('#^\s*(==|!=|[<>]=?|after|since|before|until)?\s*(.+?)\s*$#i', $test, $matches)) {
  65953. throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a date test.', $test));
  65954. }
  65955. try {
  65956. $date = new \DateTime($matches[2]);
  65957. $target = $date->format('U');
  65958. } catch (\Exception $e) {
  65959. throw new \InvalidArgumentException(sprintf('"%s" is not a valid date.', $matches[2]));
  65960. }
  65961. $operator = $matches[1] ?? '==';
  65962. if ('since' === $operator || 'after' === $operator) {
  65963. $operator = '>';
  65964. }
  65965. if ('until' === $operator || 'before' === $operator) {
  65966. $operator = '<';
  65967. }
  65968. parent::__construct($target, $operator);
  65969. }
  65970. }
  65971. <?php
  65972. namespace Symfony\Component\Finder\Comparator;
  65973. class NumberComparator extends Comparator
  65974. {
  65975. public function __construct(?string $test)
  65976. {
  65977. if (null === $test || !preg_match('#^\s*(==|!=|[<>]=?)?\s*([0-9\.]+)\s*([kmg]i?)?\s*$#i', $test, $matches)) {
  65978. throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a number test.', $test ?? 'null'));
  65979. }
  65980. $target = $matches[2];
  65981. if (!is_numeric($target)) {
  65982. throw new \InvalidArgumentException(sprintf('Invalid number "%s".', $target));
  65983. }
  65984. if (isset($matches[3])) {
  65985. switch (strtolower($matches[3])) {
  65986. case 'k':
  65987. $target *= 1000;
  65988. break;
  65989. case 'ki':
  65990. $target *= 1024;
  65991. break;
  65992. case 'm':
  65993. $target *= 1000000;
  65994. break;
  65995. case 'mi':
  65996. $target *= 1024 * 1024;
  65997. break;
  65998. case 'g':
  65999. $target *= 1000000000;
  66000. break;
  66001. case 'gi':
  66002. $target *= 1024 * 1024 * 1024;
  66003. break;
  66004. }
  66005. }
  66006. parent::__construct($target, $matches[1] ?: '==');
  66007. }
  66008. }
  66009. <?php
  66010. namespace Symfony\Component\Finder\Exception;
  66011. class AccessDeniedException extends \UnexpectedValueException
  66012. {
  66013. }
  66014. <?php
  66015. namespace Symfony\Component\Finder\Exception;
  66016. class DirectoryNotFoundException extends \InvalidArgumentException
  66017. {
  66018. }
  66019. <?php
  66020. namespace Symfony\Component\Finder;
  66021. use Symfony\Component\Finder\Comparator\DateComparator;
  66022. use Symfony\Component\Finder\Comparator\NumberComparator;
  66023. use Symfony\Component\Finder\Exception\DirectoryNotFoundException;
  66024. use Symfony\Component\Finder\Iterator\CustomFilterIterator;
  66025. use Symfony\Component\Finder\Iterator\DateRangeFilterIterator;
  66026. use Symfony\Component\Finder\Iterator\DepthRangeFilterIterator;
  66027. use Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator;
  66028. use Symfony\Component\Finder\Iterator\FilecontentFilterIterator;
  66029. use Symfony\Component\Finder\Iterator\FilenameFilterIterator;
  66030. use Symfony\Component\Finder\Iterator\LazyIterator;
  66031. use Symfony\Component\Finder\Iterator\SizeRangeFilterIterator;
  66032. use Symfony\Component\Finder\Iterator\SortableIterator;
  66033. class Finder implements \IteratorAggregate, \Countable
  66034. {
  66035. public const IGNORE_VCS_FILES = 1;
  66036. public const IGNORE_DOT_FILES = 2;
  66037. public const IGNORE_VCS_IGNORED_FILES = 4;
  66038. private $mode = 0;
  66039. private $names = [];
  66040. private $notNames = [];
  66041. private $exclude = [];
  66042. private $filters = [];
  66043. private $depths = [];
  66044. private $sizes = [];
  66045. private $followLinks = false;
  66046. private $reverseSorting = false;
  66047. private $sort = false;
  66048. private $ignore = 0;
  66049. private $dirs = [];
  66050. private $dates = [];
  66051. private $iterators = [];
  66052. private $contains = [];
  66053. private $notContains = [];
  66054. private $paths = [];
  66055. private $notPaths = [];
  66056. private $ignoreUnreadableDirs = false;
  66057. private static $vcsPatterns = ['.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg'];
  66058. public function __construct()
  66059. {
  66060. $this->ignore = static::IGNORE_VCS_FILES | static::IGNORE_DOT_FILES;
  66061. }
  66062. public static function create()
  66063. {
  66064. return new static();
  66065. }
  66066. public function directories()
  66067. {
  66068. $this->mode = Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES;
  66069. return $this;
  66070. }
  66071. public function files()
  66072. {
  66073. $this->mode = Iterator\FileTypeFilterIterator::ONLY_FILES;
  66074. return $this;
  66075. }
  66076. public function depth($levels)
  66077. {
  66078. foreach ((array) $levels as $level) {
  66079. $this->depths[] = new Comparator\NumberComparator($level);
  66080. }
  66081. return $this;
  66082. }
  66083. public function date($dates)
  66084. {
  66085. foreach ((array) $dates as $date) {
  66086. $this->dates[] = new Comparator\DateComparator($date);
  66087. }
  66088. return $this;
  66089. }
  66090. public function name($patterns)
  66091. {
  66092. $this->names = array_merge($this->names, (array) $patterns);
  66093. return $this;
  66094. }
  66095. public function notName($patterns)
  66096. {
  66097. $this->notNames = array_merge($this->notNames, (array) $patterns);
  66098. return $this;
  66099. }
  66100. public function contains($patterns)
  66101. {
  66102. $this->contains = array_merge($this->contains, (array) $patterns);
  66103. return $this;
  66104. }
  66105. public function notContains($patterns)
  66106. {
  66107. $this->notContains = array_merge($this->notContains, (array) $patterns);
  66108. return $this;
  66109. }
  66110. public function path($patterns)
  66111. {
  66112. $this->paths = array_merge($this->paths, (array) $patterns);
  66113. return $this;
  66114. }
  66115. public function notPath($patterns)
  66116. {
  66117. $this->notPaths = array_merge($this->notPaths, (array) $patterns);
  66118. return $this;
  66119. }
  66120. public function size($sizes)
  66121. {
  66122. foreach ((array) $sizes as $size) {
  66123. $this->sizes[] = new Comparator\NumberComparator($size);
  66124. }
  66125. return $this;
  66126. }
  66127. public function exclude($dirs)
  66128. {
  66129. $this->exclude = array_merge($this->exclude, (array) $dirs);
  66130. return $this;
  66131. }
  66132. public function ignoreDotFiles(bool $ignoreDotFiles)
  66133. {
  66134. if ($ignoreDotFiles) {
  66135. $this->ignore |= static::IGNORE_DOT_FILES;
  66136. } else {
  66137. $this->ignore &= ~static::IGNORE_DOT_FILES;
  66138. }
  66139. return $this;
  66140. }
  66141. public function ignoreVCS(bool $ignoreVCS)
  66142. {
  66143. if ($ignoreVCS) {
  66144. $this->ignore |= static::IGNORE_VCS_FILES;
  66145. } else {
  66146. $this->ignore &= ~static::IGNORE_VCS_FILES;
  66147. }
  66148. return $this;
  66149. }
  66150. public function ignoreVCSIgnored(bool $ignoreVCSIgnored)
  66151. {
  66152. if ($ignoreVCSIgnored) {
  66153. $this->ignore |= static::IGNORE_VCS_IGNORED_FILES;
  66154. } else {
  66155. $this->ignore &= ~static::IGNORE_VCS_IGNORED_FILES;
  66156. }
  66157. return $this;
  66158. }
  66159. public static function addVCSPattern($pattern)
  66160. {
  66161. foreach ((array) $pattern as $p) {
  66162. self::$vcsPatterns[] = $p;
  66163. }
  66164. self::$vcsPatterns = array_unique(self::$vcsPatterns);
  66165. }
  66166. public function sort(\Closure $closure)
  66167. {
  66168. $this->sort = $closure;
  66169. return $this;
  66170. }
  66171. public function sortByName(bool $useNaturalSort = false)
  66172. {
  66173. $this->sort = $useNaturalSort ? Iterator\SortableIterator::SORT_BY_NAME_NATURAL : Iterator\SortableIterator::SORT_BY_NAME;
  66174. return $this;
  66175. }
  66176. public function sortByType()
  66177. {
  66178. $this->sort = Iterator\SortableIterator::SORT_BY_TYPE;
  66179. return $this;
  66180. }
  66181. public function sortByAccessedTime()
  66182. {
  66183. $this->sort = Iterator\SortableIterator::SORT_BY_ACCESSED_TIME;
  66184. return $this;
  66185. }
  66186. public function reverseSorting()
  66187. {
  66188. $this->reverseSorting = true;
  66189. return $this;
  66190. }
  66191. public function sortByChangedTime()
  66192. {
  66193. $this->sort = Iterator\SortableIterator::SORT_BY_CHANGED_TIME;
  66194. return $this;
  66195. }
  66196. public function sortByModifiedTime()
  66197. {
  66198. $this->sort = Iterator\SortableIterator::SORT_BY_MODIFIED_TIME;
  66199. return $this;
  66200. }
  66201. public function filter(\Closure $closure)
  66202. {
  66203. $this->filters[] = $closure;
  66204. return $this;
  66205. }
  66206. public function followLinks()
  66207. {
  66208. $this->followLinks = true;
  66209. return $this;
  66210. }
  66211. public function ignoreUnreadableDirs(bool $ignore = true)
  66212. {
  66213. $this->ignoreUnreadableDirs = $ignore;
  66214. return $this;
  66215. }
  66216. public function in($dirs)
  66217. {
  66218. $resolvedDirs = [];
  66219. foreach ((array) $dirs as $dir) {
  66220. if (is_dir($dir)) {
  66221. $resolvedDirs[] = [$this->normalizeDir($dir)];
  66222. } elseif ($glob = glob($dir, (\defined('GLOB_BRACE') ? \GLOB_BRACE : 0) | \GLOB_ONLYDIR | \GLOB_NOSORT)) {
  66223. sort($glob);
  66224. $resolvedDirs[] = array_map([$this, 'normalizeDir'], $glob);
  66225. } else {
  66226. throw new DirectoryNotFoundException(sprintf('The "%s" directory does not exist.', $dir));
  66227. }
  66228. }
  66229. $this->dirs = array_merge($this->dirs, ...$resolvedDirs);
  66230. return $this;
  66231. }
  66232. #[\ReturnTypeWillChange]
  66233. public function getIterator()
  66234. {
  66235. if (0 === \count($this->dirs) && 0 === \count($this->iterators)) {
  66236. throw new \LogicException('You must call one of in() or append() methods before iterating over a Finder.');
  66237. }
  66238. if (1 === \count($this->dirs) && 0 === \count($this->iterators)) {
  66239. $iterator = $this->searchInDirectory($this->dirs[0]);
  66240. if ($this->sort || $this->reverseSorting) {
  66241. $iterator = (new Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting))->getIterator();
  66242. }
  66243. return $iterator;
  66244. }
  66245. $iterator = new \AppendIterator();
  66246. foreach ($this->dirs as $dir) {
  66247. $iterator->append(new \IteratorIterator(new LazyIterator(function () use ($dir) {
  66248. return $this->searchInDirectory($dir);
  66249. })));
  66250. }
  66251. foreach ($this->iterators as $it) {
  66252. $iterator->append($it);
  66253. }
  66254. if ($this->sort || $this->reverseSorting) {
  66255. $iterator = (new Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting))->getIterator();
  66256. }
  66257. return $iterator;
  66258. }
  66259. public function append(iterable $iterator)
  66260. {
  66261. if ($iterator instanceof \IteratorAggregate) {
  66262. $this->iterators[] = $iterator->getIterator();
  66263. } elseif ($iterator instanceof \Iterator) {
  66264. $this->iterators[] = $iterator;
  66265. } elseif (is_iterable($iterator)) {
  66266. $it = new \ArrayIterator();
  66267. foreach ($iterator as $file) {
  66268. $file = $file instanceof \SplFileInfo ? $file : new \SplFileInfo($file);
  66269. $it[$file->getPathname()] = $file;
  66270. }
  66271. $this->iterators[] = $it;
  66272. } else {
  66273. throw new \InvalidArgumentException('Finder::append() method wrong argument type.');
  66274. }
  66275. return $this;
  66276. }
  66277. public function hasResults()
  66278. {
  66279. foreach ($this->getIterator() as $_) {
  66280. return true;
  66281. }
  66282. return false;
  66283. }
  66284. #[\ReturnTypeWillChange]
  66285. public function count()
  66286. {
  66287. return iterator_count($this->getIterator());
  66288. }
  66289. private function searchInDirectory(string $dir): \Iterator
  66290. {
  66291. $exclude = $this->exclude;
  66292. $notPaths = $this->notPaths;
  66293. if (static::IGNORE_VCS_FILES === (static::IGNORE_VCS_FILES & $this->ignore)) {
  66294. $exclude = array_merge($exclude, self::$vcsPatterns);
  66295. }
  66296. if (static::IGNORE_DOT_FILES === (static::IGNORE_DOT_FILES & $this->ignore)) {
  66297. $notPaths[] = '#(^|/)\..+(/|$)#';
  66298. }
  66299. $minDepth = 0;
  66300. $maxDepth = \PHP_INT_MAX;
  66301. foreach ($this->depths as $comparator) {
  66302. switch ($comparator->getOperator()) {
  66303. case '>':
  66304. $minDepth = $comparator->getTarget() + 1;
  66305. break;
  66306. case '>=':
  66307. $minDepth = $comparator->getTarget();
  66308. break;
  66309. case '<':
  66310. $maxDepth = $comparator->getTarget() - 1;
  66311. break;
  66312. case '<=':
  66313. $maxDepth = $comparator->getTarget();
  66314. break;
  66315. default:
  66316. $minDepth = $maxDepth = $comparator->getTarget();
  66317. }
  66318. }
  66319. $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
  66320. if ($this->followLinks) {
  66321. $flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
  66322. }
  66323. $iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
  66324. if ($exclude) {
  66325. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $exclude);
  66326. }
  66327. $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
  66328. if ($minDepth > 0 || $maxDepth < \PHP_INT_MAX) {
  66329. $iterator = new Iterator\DepthRangeFilterIterator($iterator, $minDepth, $maxDepth);
  66330. }
  66331. if ($this->mode) {
  66332. $iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
  66333. }
  66334. if ($this->names || $this->notNames) {
  66335. $iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
  66336. }
  66337. if ($this->contains || $this->notContains) {
  66338. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  66339. }
  66340. if ($this->sizes) {
  66341. $iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes);
  66342. }
  66343. if ($this->dates) {
  66344. $iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates);
  66345. }
  66346. if ($this->filters) {
  66347. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  66348. }
  66349. if ($this->paths || $notPaths) {
  66350. $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $notPaths);
  66351. }
  66352. if (static::IGNORE_VCS_IGNORED_FILES === (static::IGNORE_VCS_IGNORED_FILES & $this->ignore)) {
  66353. $iterator = new Iterator\VcsIgnoredFilterIterator($iterator, $dir);
  66354. }
  66355. return $iterator;
  66356. }
  66357. private function normalizeDir(string $dir): string
  66358. {
  66359. if ('/' === $dir) {
  66360. return $dir;
  66361. }
  66362. $dir = rtrim($dir, '/'.\DIRECTORY_SEPARATOR);
  66363. if (preg_match('#^(ssh2\.)?s?ftp://#', $dir)) {
  66364. $dir .= '/';
  66365. }
  66366. return $dir;
  66367. }
  66368. }
  66369. <?php
  66370. namespace Symfony\Component\Finder;
  66371. class Gitignore
  66372. {
  66373. public static function toRegex(string $gitignoreFileContent): string
  66374. {
  66375. return self::buildRegex($gitignoreFileContent, false);
  66376. }
  66377. public static function toRegexMatchingNegatedPatterns(string $gitignoreFileContent): string
  66378. {
  66379. return self::buildRegex($gitignoreFileContent, true);
  66380. }
  66381. private static function buildRegex(string $gitignoreFileContent, bool $inverted): string
  66382. {
  66383. $gitignoreFileContent = preg_replace('~(?<!\\\\)#[^\n\r]*~', '', $gitignoreFileContent);
  66384. $gitignoreLines = preg_split('~\r\n?|\n~', $gitignoreFileContent);
  66385. $res = self::lineToRegex('');
  66386. foreach ($gitignoreLines as $line) {
  66387. $line = preg_replace('~(?<!\\\\)[ \t]+$~', '', $line);
  66388. if ('!' === substr($line, 0, 1)) {
  66389. $line = substr($line, 1);
  66390. $isNegative = true;
  66391. } else {
  66392. $isNegative = false;
  66393. }
  66394. if ('' !== $line) {
  66395. if ($isNegative xor $inverted) {
  66396. $res = '(?!'.self::lineToRegex($line).'$)'.$res;
  66397. } else {
  66398. $res = '(?:'.$res.'|'.self::lineToRegex($line).')';
  66399. }
  66400. }
  66401. }
  66402. return '~^(?:'.$res.')~s';
  66403. }
  66404. private static function lineToRegex(string $gitignoreLine): string
  66405. {
  66406. if ('' === $gitignoreLine) {
  66407. return '$f';
  66408. }
  66409. $slashPos = strpos($gitignoreLine, '/');
  66410. if (false !== $slashPos && \strlen($gitignoreLine) - 1 !== $slashPos) {
  66411. if (0 === $slashPos) {
  66412. $gitignoreLine = substr($gitignoreLine, 1);
  66413. }
  66414. $isAbsolute = true;
  66415. } else {
  66416. $isAbsolute = false;
  66417. }
  66418. $regex = preg_quote(str_replace('\\', '', $gitignoreLine), '~');
  66419. $regex = preg_replace_callback('~\\\\\[((?:\\\\!)?)([^\[\]]*)\\\\\]~', function (array $matches): string {
  66420. return '['.('' !== $matches[1] ? '^' : '').str_replace('\\-', '-', $matches[2]).']';
  66421. }, $regex);
  66422. $regex = preg_replace('~(?:(?:\\\\\*){2,}(/?))+~', '(?:(?:(?!//).(?<!//))+$1)?', $regex);
  66423. $regex = preg_replace('~\\\\\*~', '[^/]*', $regex);
  66424. $regex = preg_replace('~\\\\\?~', '[^/]', $regex);
  66425. return ($isAbsolute ? '' : '(?:[^/]+/)*')
  66426. .$regex
  66427. .(!str_ends_with($gitignoreLine, '/') ? '(?:$|/)' : '');
  66428. }
  66429. }
  66430. <?php
  66431. namespace Symfony\Component\Finder;
  66432. class Glob
  66433. {
  66434. public static function toRegex(string $glob, bool $strictLeadingDot = true, bool $strictWildcardSlash = true, string $delimiter = '#')
  66435. {
  66436. $firstByte = true;
  66437. $escaping = false;
  66438. $inCurlies = 0;
  66439. $regex = '';
  66440. $sizeGlob = \strlen($glob);
  66441. for ($i = 0; $i < $sizeGlob; ++$i) {
  66442. $car = $glob[$i];
  66443. if ($firstByte && $strictLeadingDot && '.' !== $car) {
  66444. $regex .= '(?=[^\.])';
  66445. }
  66446. $firstByte = '/' === $car;
  66447. if ($firstByte && $strictWildcardSlash && isset($glob[$i + 2]) && '**' === $glob[$i + 1].$glob[$i + 2] && (!isset($glob[$i + 3]) || '/' === $glob[$i + 3])) {
  66448. $car = '[^/]++/';
  66449. if (!isset($glob[$i + 3])) {
  66450. $car .= '?';
  66451. }
  66452. if ($strictLeadingDot) {
  66453. $car = '(?=[^\.])'.$car;
  66454. }
  66455. $car = '/(?:'.$car.')*';
  66456. $i += 2 + isset($glob[$i + 3]);
  66457. if ('/' === $delimiter) {
  66458. $car = str_replace('/', '\\/', $car);
  66459. }
  66460. }
  66461. if ($delimiter === $car || '.' === $car || '(' === $car || ')' === $car || '|' === $car || '+' === $car || '^' === $car || '$' === $car) {
  66462. $regex .= "\\$car";
  66463. } elseif ('*' === $car) {
  66464. $regex .= $escaping ? '\\*' : ($strictWildcardSlash ? '[^/]*' : '.*');
  66465. } elseif ('?' === $car) {
  66466. $regex .= $escaping ? '\\?' : ($strictWildcardSlash ? '[^/]' : '.');
  66467. } elseif ('{' === $car) {
  66468. $regex .= $escaping ? '\\{' : '(';
  66469. if (!$escaping) {
  66470. ++$inCurlies;
  66471. }
  66472. } elseif ('}' === $car && $inCurlies) {
  66473. $regex .= $escaping ? '}' : ')';
  66474. if (!$escaping) {
  66475. --$inCurlies;
  66476. }
  66477. } elseif (',' === $car && $inCurlies) {
  66478. $regex .= $escaping ? ',' : '|';
  66479. } elseif ('\\' === $car) {
  66480. if ($escaping) {
  66481. $regex .= '\\\\';
  66482. $escaping = false;
  66483. } else {
  66484. $escaping = true;
  66485. }
  66486. continue;
  66487. } else {
  66488. $regex .= $car;
  66489. }
  66490. $escaping = false;
  66491. }
  66492. return $delimiter.'^'.$regex.'$'.$delimiter;
  66493. }
  66494. }
  66495. <?php
  66496. namespace Symfony\Component\Finder\Iterator;
  66497. class CustomFilterIterator extends \FilterIterator
  66498. {
  66499. private $filters = [];
  66500. public function __construct(\Iterator $iterator, array $filters)
  66501. {
  66502. foreach ($filters as $filter) {
  66503. if (!\is_callable($filter)) {
  66504. throw new \InvalidArgumentException('Invalid PHP callback.');
  66505. }
  66506. }
  66507. $this->filters = $filters;
  66508. parent::__construct($iterator);
  66509. }
  66510. #[\ReturnTypeWillChange]
  66511. public function accept()
  66512. {
  66513. $fileinfo = $this->current();
  66514. foreach ($this->filters as $filter) {
  66515. if (false === $filter($fileinfo)) {
  66516. return false;
  66517. }
  66518. }
  66519. return true;
  66520. }
  66521. }
  66522. <?php
  66523. namespace Symfony\Component\Finder\Iterator;
  66524. use Symfony\Component\Finder\Comparator\DateComparator;
  66525. class DateRangeFilterIterator extends \FilterIterator
  66526. {
  66527. private $comparators = [];
  66528. public function __construct(\Iterator $iterator, array $comparators)
  66529. {
  66530. $this->comparators = $comparators;
  66531. parent::__construct($iterator);
  66532. }
  66533. #[\ReturnTypeWillChange]
  66534. public function accept()
  66535. {
  66536. $fileinfo = $this->current();
  66537. if (!file_exists($fileinfo->getPathname())) {
  66538. return false;
  66539. }
  66540. $filedate = $fileinfo->getMTime();
  66541. foreach ($this->comparators as $compare) {
  66542. if (!$compare->test($filedate)) {
  66543. return false;
  66544. }
  66545. }
  66546. return true;
  66547. }
  66548. }
  66549. <?php
  66550. namespace Symfony\Component\Finder\Iterator;
  66551. class DepthRangeFilterIterator extends \FilterIterator
  66552. {
  66553. private $minDepth = 0;
  66554. public function __construct(\RecursiveIteratorIterator $iterator, int $minDepth = 0, int $maxDepth = \PHP_INT_MAX)
  66555. {
  66556. $this->minDepth = $minDepth;
  66557. $iterator->setMaxDepth(\PHP_INT_MAX === $maxDepth ? -1 : $maxDepth);
  66558. parent::__construct($iterator);
  66559. }
  66560. #[\ReturnTypeWillChange]
  66561. public function accept()
  66562. {
  66563. return $this->getInnerIterator()->getDepth() >= $this->minDepth;
  66564. }
  66565. }
  66566. <?php
  66567. namespace Symfony\Component\Finder\Iterator;
  66568. class ExcludeDirectoryFilterIterator extends \FilterIterator implements \RecursiveIterator
  66569. {
  66570. private $iterator;
  66571. private $isRecursive;
  66572. private $excludedDirs = [];
  66573. private $excludedPattern;
  66574. public function __construct(\Iterator $iterator, array $directories)
  66575. {
  66576. $this->iterator = $iterator;
  66577. $this->isRecursive = $iterator instanceof \RecursiveIterator;
  66578. $patterns = [];
  66579. foreach ($directories as $directory) {
  66580. $directory = rtrim($directory, '/');
  66581. if (!$this->isRecursive || str_contains($directory, '/')) {
  66582. $patterns[] = preg_quote($directory, '#');
  66583. } else {
  66584. $this->excludedDirs[$directory] = true;
  66585. }
  66586. }
  66587. if ($patterns) {
  66588. $this->excludedPattern = '#(?:^|/)(?:'.implode('|', $patterns).')(?:/|$)#';
  66589. }
  66590. parent::__construct($iterator);
  66591. }
  66592. #[\ReturnTypeWillChange]
  66593. public function accept()
  66594. {
  66595. if ($this->isRecursive && isset($this->excludedDirs[$this->getFilename()]) && $this->isDir()) {
  66596. return false;
  66597. }
  66598. if ($this->excludedPattern) {
  66599. $path = $this->isDir() ? $this->current()->getRelativePathname() : $this->current()->getRelativePath();
  66600. $path = str_replace('\\', '/', $path);
  66601. return !preg_match($this->excludedPattern, $path);
  66602. }
  66603. return true;
  66604. }
  66605. #[\ReturnTypeWillChange]
  66606. public function hasChildren()
  66607. {
  66608. return $this->isRecursive && $this->iterator->hasChildren();
  66609. }
  66610. #[\ReturnTypeWillChange]
  66611. public function getChildren()
  66612. {
  66613. $children = new self($this->iterator->getChildren(), []);
  66614. $children->excludedDirs = $this->excludedDirs;
  66615. $children->excludedPattern = $this->excludedPattern;
  66616. return $children;
  66617. }
  66618. }
  66619. <?php
  66620. namespace Symfony\Component\Finder\Iterator;
  66621. class FileTypeFilterIterator extends \FilterIterator
  66622. {
  66623. public const ONLY_FILES = 1;
  66624. public const ONLY_DIRECTORIES = 2;
  66625. private $mode;
  66626. public function __construct(\Iterator $iterator, int $mode)
  66627. {
  66628. $this->mode = $mode;
  66629. parent::__construct($iterator);
  66630. }
  66631. #[\ReturnTypeWillChange]
  66632. public function accept()
  66633. {
  66634. $fileinfo = $this->current();
  66635. if (self::ONLY_DIRECTORIES === (self::ONLY_DIRECTORIES & $this->mode) && $fileinfo->isFile()) {
  66636. return false;
  66637. } elseif (self::ONLY_FILES === (self::ONLY_FILES & $this->mode) && $fileinfo->isDir()) {
  66638. return false;
  66639. }
  66640. return true;
  66641. }
  66642. }
  66643. <?php
  66644. namespace Symfony\Component\Finder\Iterator;
  66645. class FilecontentFilterIterator extends MultiplePcreFilterIterator
  66646. {
  66647. #[\ReturnTypeWillChange]
  66648. public function accept()
  66649. {
  66650. if (!$this->matchRegexps && !$this->noMatchRegexps) {
  66651. return true;
  66652. }
  66653. $fileinfo = $this->current();
  66654. if ($fileinfo->isDir() || !$fileinfo->isReadable()) {
  66655. return false;
  66656. }
  66657. $content = $fileinfo->getContents();
  66658. if (!$content) {
  66659. return false;
  66660. }
  66661. return $this->isAccepted($content);
  66662. }
  66663. protected function toRegex(string $str)
  66664. {
  66665. return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
  66666. }
  66667. }
  66668. <?php
  66669. namespace Symfony\Component\Finder\Iterator;
  66670. use Symfony\Component\Finder\Glob;
  66671. class FilenameFilterIterator extends MultiplePcreFilterIterator
  66672. {
  66673. #[\ReturnTypeWillChange]
  66674. public function accept()
  66675. {
  66676. return $this->isAccepted($this->current()->getFilename());
  66677. }
  66678. protected function toRegex(string $str)
  66679. {
  66680. return $this->isRegex($str) ? $str : Glob::toRegex($str);
  66681. }
  66682. }
  66683. <?php
  66684. namespace Symfony\Component\Finder\Iterator;
  66685. class LazyIterator implements \IteratorAggregate
  66686. {
  66687. private $iteratorFactory;
  66688. public function __construct(callable $iteratorFactory)
  66689. {
  66690. $this->iteratorFactory = $iteratorFactory;
  66691. }
  66692. public function getIterator(): \Traversable
  66693. {
  66694. yield from ($this->iteratorFactory)();
  66695. }
  66696. }
  66697. <?php
  66698. namespace Symfony\Component\Finder\Iterator;
  66699. abstract class MultiplePcreFilterIterator extends \FilterIterator
  66700. {
  66701. protected $matchRegexps = [];
  66702. protected $noMatchRegexps = [];
  66703. public function __construct(\Iterator $iterator, array $matchPatterns, array $noMatchPatterns)
  66704. {
  66705. foreach ($matchPatterns as $pattern) {
  66706. $this->matchRegexps[] = $this->toRegex($pattern);
  66707. }
  66708. foreach ($noMatchPatterns as $pattern) {
  66709. $this->noMatchRegexps[] = $this->toRegex($pattern);
  66710. }
  66711. parent::__construct($iterator);
  66712. }
  66713. protected function isAccepted(string $string)
  66714. {
  66715. foreach ($this->noMatchRegexps as $regex) {
  66716. if (preg_match($regex, $string)) {
  66717. return false;
  66718. }
  66719. }
  66720. if ($this->matchRegexps) {
  66721. foreach ($this->matchRegexps as $regex) {
  66722. if (preg_match($regex, $string)) {
  66723. return true;
  66724. }
  66725. }
  66726. return false;
  66727. }
  66728. return true;
  66729. }
  66730. protected function isRegex(string $str)
  66731. {
  66732. $availableModifiers = 'imsxuADU';
  66733. if (\PHP_VERSION_ID >= 80200) {
  66734. $availableModifiers .= 'n';
  66735. }
  66736. if (preg_match('/^(.{3,}?)['.$availableModifiers.']*$/', $str, $m)) {
  66737. $start = substr($m[1], 0, 1);
  66738. $end = substr($m[1], -1);
  66739. if ($start === $end) {
  66740. return !preg_match('/[*?[:alnum:] \\\\]/', $start);
  66741. }
  66742. foreach ([['{', '}'], ['(', ')'], ['[', ']'], ['<', '>']] as $delimiters) {
  66743. if ($start === $delimiters[0] && $end === $delimiters[1]) {
  66744. return true;
  66745. }
  66746. }
  66747. }
  66748. return false;
  66749. }
  66750. abstract protected function toRegex(string $str);
  66751. }
  66752. <?php
  66753. namespace Symfony\Component\Finder\Iterator;
  66754. class PathFilterIterator extends MultiplePcreFilterIterator
  66755. {
  66756. #[\ReturnTypeWillChange]
  66757. public function accept()
  66758. {
  66759. $filename = $this->current()->getRelativePathname();
  66760. if ('\\' === \DIRECTORY_SEPARATOR) {
  66761. $filename = str_replace('\\', '/', $filename);
  66762. }
  66763. return $this->isAccepted($filename);
  66764. }
  66765. protected function toRegex(string $str)
  66766. {
  66767. return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
  66768. }
  66769. }
  66770. <?php
  66771. namespace Symfony\Component\Finder\Iterator;
  66772. use Symfony\Component\Finder\Exception\AccessDeniedException;
  66773. use Symfony\Component\Finder\SplFileInfo;
  66774. class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
  66775. {
  66776. private $ignoreUnreadableDirs;
  66777. private $ignoreFirstRewind = true;
  66778. private $rootPath;
  66779. private $subPath;
  66780. private $directorySeparator = '/';
  66781. public function __construct(string $path, int $flags, bool $ignoreUnreadableDirs = false)
  66782. {
  66783. if ($flags & (self::CURRENT_AS_PATHNAME | self::CURRENT_AS_SELF)) {
  66784. throw new \RuntimeException('This iterator only support returning current as fileinfo.');
  66785. }
  66786. parent::__construct($path, $flags);
  66787. $this->ignoreUnreadableDirs = $ignoreUnreadableDirs;
  66788. $this->rootPath = $path;
  66789. if ('/' !== \DIRECTORY_SEPARATOR && !($flags & self::UNIX_PATHS)) {
  66790. $this->directorySeparator = \DIRECTORY_SEPARATOR;
  66791. }
  66792. }
  66793. #[\ReturnTypeWillChange]
  66794. public function current()
  66795. {
  66796. if (null === $subPathname = $this->subPath) {
  66797. $subPathname = $this->subPath = $this->getSubPath();
  66798. }
  66799. if ('' !== $subPathname) {
  66800. $subPathname .= $this->directorySeparator;
  66801. }
  66802. $subPathname .= $this->getFilename();
  66803. if ('/' !== $basePath = $this->rootPath) {
  66804. $basePath .= $this->directorySeparator;
  66805. }
  66806. return new SplFileInfo($basePath.$subPathname, $this->subPath, $subPathname);
  66807. }
  66808. #[\ReturnTypeWillChange]
  66809. public function hasChildren($allowLinks = false)
  66810. {
  66811. $hasChildren = parent::hasChildren($allowLinks);
  66812. if (!$hasChildren || !$this->ignoreUnreadableDirs) {
  66813. return $hasChildren;
  66814. }
  66815. try {
  66816. parent::getChildren();
  66817. return true;
  66818. } catch (\UnexpectedValueException $e) {
  66819. return false;
  66820. }
  66821. }
  66822. #[\ReturnTypeWillChange]
  66823. public function getChildren()
  66824. {
  66825. try {
  66826. $children = parent::getChildren();
  66827. if ($children instanceof self) {
  66828. $children->ignoreUnreadableDirs = $this->ignoreUnreadableDirs;
  66829. $children->rootPath = $this->rootPath;
  66830. }
  66831. return $children;
  66832. } catch (\UnexpectedValueException $e) {
  66833. throw new AccessDeniedException($e->getMessage(), $e->getCode(), $e);
  66834. }
  66835. }
  66836. #[\ReturnTypeWillChange]
  66837. public function next()
  66838. {
  66839. $this->ignoreFirstRewind = false;
  66840. parent::next();
  66841. }
  66842. #[\ReturnTypeWillChange]
  66843. public function rewind()
  66844. {
  66845. if ($this->ignoreFirstRewind) {
  66846. $this->ignoreFirstRewind = false;
  66847. return;
  66848. }
  66849. parent::rewind();
  66850. }
  66851. }
  66852. <?php
  66853. namespace Symfony\Component\Finder\Iterator;
  66854. use Symfony\Component\Finder\Comparator\NumberComparator;
  66855. class SizeRangeFilterIterator extends \FilterIterator
  66856. {
  66857. private $comparators = [];
  66858. public function __construct(\Iterator $iterator, array $comparators)
  66859. {
  66860. $this->comparators = $comparators;
  66861. parent::__construct($iterator);
  66862. }
  66863. #[\ReturnTypeWillChange]
  66864. public function accept()
  66865. {
  66866. $fileinfo = $this->current();
  66867. if (!$fileinfo->isFile()) {
  66868. return true;
  66869. }
  66870. $filesize = $fileinfo->getSize();
  66871. foreach ($this->comparators as $compare) {
  66872. if (!$compare->test($filesize)) {
  66873. return false;
  66874. }
  66875. }
  66876. return true;
  66877. }
  66878. }
  66879. <?php
  66880. namespace Symfony\Component\Finder\Iterator;
  66881. class SortableIterator implements \IteratorAggregate
  66882. {
  66883. public const SORT_BY_NONE = 0;
  66884. public const SORT_BY_NAME = 1;
  66885. public const SORT_BY_TYPE = 2;
  66886. public const SORT_BY_ACCESSED_TIME = 3;
  66887. public const SORT_BY_CHANGED_TIME = 4;
  66888. public const SORT_BY_MODIFIED_TIME = 5;
  66889. public const SORT_BY_NAME_NATURAL = 6;
  66890. private $iterator;
  66891. private $sort;
  66892. public function __construct(\Traversable $iterator, $sort, bool $reverseOrder = false)
  66893. {
  66894. $this->iterator = $iterator;
  66895. $order = $reverseOrder ? -1 : 1;
  66896. if (self::SORT_BY_NAME === $sort) {
  66897. $this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
  66898. return $order * strcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
  66899. };
  66900. } elseif (self::SORT_BY_NAME_NATURAL === $sort) {
  66901. $this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
  66902. return $order * strnatcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
  66903. };
  66904. } elseif (self::SORT_BY_TYPE === $sort) {
  66905. $this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
  66906. if ($a->isDir() && $b->isFile()) {
  66907. return -$order;
  66908. } elseif ($a->isFile() && $b->isDir()) {
  66909. return $order;
  66910. }
  66911. return $order * strcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
  66912. };
  66913. } elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
  66914. $this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
  66915. return $order * ($a->getATime() - $b->getATime());
  66916. };
  66917. } elseif (self::SORT_BY_CHANGED_TIME === $sort) {
  66918. $this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
  66919. return $order * ($a->getCTime() - $b->getCTime());
  66920. };
  66921. } elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
  66922. $this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
  66923. return $order * ($a->getMTime() - $b->getMTime());
  66924. };
  66925. } elseif (self::SORT_BY_NONE === $sort) {
  66926. $this->sort = $order;
  66927. } elseif (\is_callable($sort)) {
  66928. $this->sort = $reverseOrder ? static function (\SplFileInfo $a, \SplFileInfo $b) use ($sort) { return -$sort($a, $b); } : $sort;
  66929. } else {
  66930. throw new \InvalidArgumentException('The SortableIterator takes a PHP callable or a valid built-in sort algorithm as an argument.');
  66931. }
  66932. }
  66933. #[\ReturnTypeWillChange]
  66934. public function getIterator()
  66935. {
  66936. if (1 === $this->sort) {
  66937. return $this->iterator;
  66938. }
  66939. $array = iterator_to_array($this->iterator, true);
  66940. if (-1 === $this->sort) {
  66941. $array = array_reverse($array);
  66942. } else {
  66943. uasort($array, $this->sort);
  66944. }
  66945. return new \ArrayIterator($array);
  66946. }
  66947. }
  66948. <?php
  66949. namespace Symfony\Component\Finder\Iterator;
  66950. use Symfony\Component\Finder\Gitignore;
  66951. final class VcsIgnoredFilterIterator extends \FilterIterator
  66952. {
  66953. private $baseDir;
  66954. private $gitignoreFilesCache = [];
  66955. private $ignoredPathsCache = [];
  66956. public function __construct(\Iterator $iterator, string $baseDir)
  66957. {
  66958. $this->baseDir = $this->normalizePath($baseDir);
  66959. parent::__construct($iterator);
  66960. }
  66961. public function accept(): bool
  66962. {
  66963. $file = $this->current();
  66964. $fileRealPath = $this->normalizePath($file->getRealPath());
  66965. return !$this->isIgnored($fileRealPath);
  66966. }
  66967. private function isIgnored(string $fileRealPath): bool
  66968. {
  66969. if (is_dir($fileRealPath) && !str_ends_with($fileRealPath, '/')) {
  66970. $fileRealPath .= '/';
  66971. }
  66972. if (isset($this->ignoredPathsCache[$fileRealPath])) {
  66973. return $this->ignoredPathsCache[$fileRealPath];
  66974. }
  66975. $ignored = false;
  66976. foreach ($this->parentsDirectoryDownward($fileRealPath) as $parentDirectory) {
  66977. if ($this->isIgnored($parentDirectory)) {
  66978. break;
  66979. }
  66980. $fileRelativePath = substr($fileRealPath, \strlen($parentDirectory) + 1);
  66981. if (null === $regexps = $this->readGitignoreFile("{$parentDirectory}/.gitignore")) {
  66982. continue;
  66983. }
  66984. [$exclusionRegex, $inclusionRegex] = $regexps;
  66985. if (preg_match($exclusionRegex, $fileRelativePath)) {
  66986. $ignored = true;
  66987. continue;
  66988. }
  66989. if (preg_match($inclusionRegex, $fileRelativePath)) {
  66990. $ignored = false;
  66991. }
  66992. }
  66993. return $this->ignoredPathsCache[$fileRealPath] = $ignored;
  66994. }
  66995. private function parentsDirectoryDownward(string $fileRealPath): array
  66996. {
  66997. $parentDirectories = [];
  66998. $parentDirectory = $fileRealPath;
  66999. while (true) {
  67000. $newParentDirectory = \dirname($parentDirectory);
  67001. if ($newParentDirectory === $parentDirectory) {
  67002. break;
  67003. }
  67004. $parentDirectory = $newParentDirectory;
  67005. if (0 !== strpos($parentDirectory, $this->baseDir)) {
  67006. break;
  67007. }
  67008. $parentDirectories[] = $parentDirectory;
  67009. }
  67010. return array_reverse($parentDirectories);
  67011. }
  67012. private function readGitignoreFile(string $path): ?array
  67013. {
  67014. if (\array_key_exists($path, $this->gitignoreFilesCache)) {
  67015. return $this->gitignoreFilesCache[$path];
  67016. }
  67017. if (!file_exists($path)) {
  67018. return $this->gitignoreFilesCache[$path] = null;
  67019. }
  67020. if (!is_file($path) || !is_readable($path)) {
  67021. throw new \RuntimeException("The \"ignoreVCSIgnored\" option cannot be used by the Finder as the \"{$path}\" file is not readable.");
  67022. }
  67023. $gitignoreFileContent = file_get_contents($path);
  67024. return $this->gitignoreFilesCache[$path] = [
  67025. Gitignore::toRegex($gitignoreFileContent),
  67026. Gitignore::toRegexMatchingNegatedPatterns($gitignoreFileContent),
  67027. ];
  67028. }
  67029. private function normalizePath(string $path): string
  67030. {
  67031. if ('\\' === \DIRECTORY_SEPARATOR) {
  67032. return str_replace('\\', '/', $path);
  67033. }
  67034. return $path;
  67035. }
  67036. }
  67037. Copyright (c) 2004-present Fabien Potencier
  67038. Permission is hereby granted, free of charge, to any person obtaining a copy
  67039. of this software and associated documentation files (the "Software"), to deal
  67040. in the Software without restriction, including without limitation the rights
  67041. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  67042. copies of the Software, and to permit persons to whom the Software is furnished
  67043. to do so, subject to the following conditions:
  67044. The above copyright notice and this permission notice shall be included in all
  67045. copies or substantial portions of the Software.
  67046. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  67047. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  67048. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  67049. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  67050. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  67051. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  67052. THE SOFTWARE.
  67053. <?php
  67054. namespace Symfony\Component\Finder;
  67055. class SplFileInfo extends \SplFileInfo
  67056. {
  67057. private $relativePath;
  67058. private $relativePathname;
  67059. public function __construct(string $file, string $relativePath, string $relativePathname)
  67060. {
  67061. parent::__construct($file);
  67062. $this->relativePath = $relativePath;
  67063. $this->relativePathname = $relativePathname;
  67064. }
  67065. public function getRelativePath()
  67066. {
  67067. return $this->relativePath;
  67068. }
  67069. public function getRelativePathname()
  67070. {
  67071. return $this->relativePathname;
  67072. }
  67073. public function getFilenameWithoutExtension(): string
  67074. {
  67075. $filename = $this->getFilename();
  67076. return pathinfo($filename, \PATHINFO_FILENAME);
  67077. }
  67078. public function getContents()
  67079. {
  67080. set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
  67081. try {
  67082. $content = file_get_contents($this->getPathname());
  67083. } finally {
  67084. restore_error_handler();
  67085. }
  67086. if (false === $content) {
  67087. throw new \RuntimeException($error);
  67088. }
  67089. return $content;
  67090. }
  67091. }
  67092. <?php
  67093. namespace Symfony\Polyfill\Ctype;
  67094. final class Ctype
  67095. {
  67096. public static function ctype_alnum($text)
  67097. {
  67098. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  67099. return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z0-9]/', $text);
  67100. }
  67101. public static function ctype_alpha($text)
  67102. {
  67103. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  67104. return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z]/', $text);
  67105. }
  67106. public static function ctype_cntrl($text)
  67107. {
  67108. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  67109. return \is_string($text) && '' !== $text && !preg_match('/[^\x00-\x1f\x7f]/', $text);
  67110. }
  67111. public static function ctype_digit($text)
  67112. {
  67113. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  67114. return \is_string($text) && '' !== $text && !preg_match('/[^0-9]/', $text);
  67115. }
  67116. public static function ctype_graph($text)
  67117. {
  67118. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  67119. return \is_string($text) && '' !== $text && !preg_match('/[^!-~]/', $text);
  67120. }
  67121. public static function ctype_lower($text)
  67122. {
  67123. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  67124. return \is_string($text) && '' !== $text && !preg_match('/[^a-z]/', $text);
  67125. }
  67126. public static function ctype_print($text)
  67127. {
  67128. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  67129. return \is_string($text) && '' !== $text && !preg_match('/[^ -~]/', $text);
  67130. }
  67131. public static function ctype_punct($text)
  67132. {
  67133. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  67134. return \is_string($text) && '' !== $text && !preg_match('/[^!-\/\:-@\[-`\{-~]/', $text);
  67135. }
  67136. public static function ctype_space($text)
  67137. {
  67138. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  67139. return \is_string($text) && '' !== $text && !preg_match('/[^\s]/', $text);
  67140. }
  67141. public static function ctype_upper($text)
  67142. {
  67143. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  67144. return \is_string($text) && '' !== $text && !preg_match('/[^A-Z]/', $text);
  67145. }
  67146. public static function ctype_xdigit($text)
  67147. {
  67148. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  67149. return \is_string($text) && '' !== $text && !preg_match('/[^A-Fa-f0-9]/', $text);
  67150. }
  67151. private static function convert_int_to_char_for_ctype($int, $function)
  67152. {
  67153. if (!\is_int($int)) {
  67154. return $int;
  67155. }
  67156. if ($int < -128 || $int > 255) {
  67157. return (string) $int;
  67158. }
  67159. if (\PHP_VERSION_ID >= 80100) {
  67160. @trigger_error($function.'(): Argument of type int will be interpreted as string in the future', \E_USER_DEPRECATED);
  67161. }
  67162. if ($int < 0) {
  67163. $int += 256;
  67164. }
  67165. return \chr($int);
  67166. }
  67167. }
  67168. Copyright (c) 2018-present Fabien Potencier
  67169. Permission is hereby granted, free of charge, to any person obtaining a copy
  67170. of this software and associated documentation files (the "Software"), to deal
  67171. in the Software without restriction, including without limitation the rights
  67172. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  67173. copies of the Software, and to permit persons to whom the Software is furnished
  67174. to do so, subject to the following conditions:
  67175. The above copyright notice and this permission notice shall be included in all
  67176. copies or substantial portions of the Software.
  67177. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  67178. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  67179. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  67180. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  67181. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  67182. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  67183. THE SOFTWARE.
  67184. <?php
  67185. use Symfony\Polyfill\Ctype as p;
  67186. if (\PHP_VERSION_ID >= 80000) {
  67187. return require __DIR__.'/bootstrap80.php';
  67188. }
  67189. if (!function_exists('ctype_alnum')) {
  67190. function ctype_alnum($text) { return p\Ctype::ctype_alnum($text); }
  67191. }
  67192. if (!function_exists('ctype_alpha')) {
  67193. function ctype_alpha($text) { return p\Ctype::ctype_alpha($text); }
  67194. }
  67195. if (!function_exists('ctype_cntrl')) {
  67196. function ctype_cntrl($text) { return p\Ctype::ctype_cntrl($text); }
  67197. }
  67198. if (!function_exists('ctype_digit')) {
  67199. function ctype_digit($text) { return p\Ctype::ctype_digit($text); }
  67200. }
  67201. if (!function_exists('ctype_graph')) {
  67202. function ctype_graph($text) { return p\Ctype::ctype_graph($text); }
  67203. }
  67204. if (!function_exists('ctype_lower')) {
  67205. function ctype_lower($text) { return p\Ctype::ctype_lower($text); }
  67206. }
  67207. if (!function_exists('ctype_print')) {
  67208. function ctype_print($text) { return p\Ctype::ctype_print($text); }
  67209. }
  67210. if (!function_exists('ctype_punct')) {
  67211. function ctype_punct($text) { return p\Ctype::ctype_punct($text); }
  67212. }
  67213. if (!function_exists('ctype_space')) {
  67214. function ctype_space($text) { return p\Ctype::ctype_space($text); }
  67215. }
  67216. if (!function_exists('ctype_upper')) {
  67217. function ctype_upper($text) { return p\Ctype::ctype_upper($text); }
  67218. }
  67219. if (!function_exists('ctype_xdigit')) {
  67220. function ctype_xdigit($text) { return p\Ctype::ctype_xdigit($text); }
  67221. }
  67222. <?php
  67223. use Symfony\Polyfill\Ctype as p;
  67224. if (!function_exists('ctype_alnum')) {
  67225. function ctype_alnum(mixed $text): bool { return p\Ctype::ctype_alnum($text); }
  67226. }
  67227. if (!function_exists('ctype_alpha')) {
  67228. function ctype_alpha(mixed $text): bool { return p\Ctype::ctype_alpha($text); }
  67229. }
  67230. if (!function_exists('ctype_cntrl')) {
  67231. function ctype_cntrl(mixed $text): bool { return p\Ctype::ctype_cntrl($text); }
  67232. }
  67233. if (!function_exists('ctype_digit')) {
  67234. function ctype_digit(mixed $text): bool { return p\Ctype::ctype_digit($text); }
  67235. }
  67236. if (!function_exists('ctype_graph')) {
  67237. function ctype_graph(mixed $text): bool { return p\Ctype::ctype_graph($text); }
  67238. }
  67239. if (!function_exists('ctype_lower')) {
  67240. function ctype_lower(mixed $text): bool { return p\Ctype::ctype_lower($text); }
  67241. }
  67242. if (!function_exists('ctype_print')) {
  67243. function ctype_print(mixed $text): bool { return p\Ctype::ctype_print($text); }
  67244. }
  67245. if (!function_exists('ctype_punct')) {
  67246. function ctype_punct(mixed $text): bool { return p\Ctype::ctype_punct($text); }
  67247. }
  67248. if (!function_exists('ctype_space')) {
  67249. function ctype_space(mixed $text): bool { return p\Ctype::ctype_space($text); }
  67250. }
  67251. if (!function_exists('ctype_upper')) {
  67252. function ctype_upper(mixed $text): bool { return p\Ctype::ctype_upper($text); }
  67253. }
  67254. if (!function_exists('ctype_xdigit')) {
  67255. function ctype_xdigit(mixed $text): bool { return p\Ctype::ctype_xdigit($text); }
  67256. }
  67257. <?php
  67258. namespace Symfony\Polyfill\Intl\Grapheme;
  67259. \define('SYMFONY_GRAPHEME_CLUSTER_RX', ((float) \PCRE_VERSION < 10 ? (float) \PCRE_VERSION >= 8.32 : (float) \PCRE_VERSION >= 10.39) ? '\X' : Grapheme::GRAPHEME_CLUSTER_RX);
  67260. final class Grapheme
  67261. {
  67262. 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}])';
  67263. private const CASE_FOLD = [
  67264. ['µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"],
  67265. ['μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', '�', 'ε', "\xE1\xB9\xA1", 'ι'],
  67266. ];
  67267. public static function grapheme_extract($s, $size, $type = \GRAPHEME_EXTR_COUNT, $start = 0, &$next = 0)
  67268. {
  67269. if (0 > $start) {
  67270. $start = \strlen($s) + $start;
  67271. }
  67272. if (!\is_scalar($s)) {
  67273. $hasError = false;
  67274. set_error_handler(function () use (&$hasError) { $hasError = true; });
  67275. $next = substr($s, $start);
  67276. restore_error_handler();
  67277. if ($hasError) {
  67278. substr($s, $start);
  67279. $s = '';
  67280. } else {
  67281. $s = $next;
  67282. }
  67283. } else {
  67284. $s = substr($s, $start);
  67285. }
  67286. $size = (int) $size;
  67287. $type = (int) $type;
  67288. $start = (int) $start;
  67289. if (\GRAPHEME_EXTR_COUNT !== $type && \GRAPHEME_EXTR_MAXBYTES !== $type && \GRAPHEME_EXTR_MAXCHARS !== $type) {
  67290. if (80000 > \PHP_VERSION_ID) {
  67291. return false;
  67292. }
  67293. throw new \ValueError('grapheme_extract(): Argument #3 ($type) must be one of GRAPHEME_EXTR_COUNT, GRAPHEME_EXTR_MAXBYTES, or GRAPHEME_EXTR_MAXCHARS');
  67294. }
  67295. if (!isset($s[0]) || 0 > $size || 0 > $start) {
  67296. return false;
  67297. }
  67298. if (0 === $size) {
  67299. return '';
  67300. }
  67301. $next = $start;
  67302. $s = preg_split('/('.SYMFONY_GRAPHEME_CLUSTER_RX.')/u', "\r\n".$s, $size + 1, \PREG_SPLIT_NO_EMPTY | \PREG_SPLIT_DELIM_CAPTURE);
  67303. if (!isset($s[1])) {
  67304. return false;
  67305. }
  67306. $i = 1;
  67307. $ret = '';
  67308. do {
  67309. if (\GRAPHEME_EXTR_COUNT === $type) {
  67310. --$size;
  67311. } elseif (\GRAPHEME_EXTR_MAXBYTES === $type) {
  67312. $size -= \strlen($s[$i]);
  67313. } else {
  67314. $size -= iconv_strlen($s[$i], 'UTF-8//IGNORE');
  67315. }
  67316. if ($size >= 0) {
  67317. $ret .= $s[$i];
  67318. }
  67319. } while (isset($s[++$i]) && $size > 0);
  67320. $next += \strlen($ret);
  67321. return $ret;
  67322. }
  67323. public static function grapheme_strlen($s)
  67324. {
  67325. preg_replace('/'.SYMFONY_GRAPHEME_CLUSTER_RX.'/u', '', $s, -1, $len);
  67326. return 0 === $len && '' !== $s ? null : $len;
  67327. }
  67328. public static function grapheme_substr($s, $start, $len = null)
  67329. {
  67330. if (null === $len) {
  67331. $len = 2147483647;
  67332. }
  67333. preg_match_all('/'.SYMFONY_GRAPHEME_CLUSTER_RX.'/u', $s, $s);
  67334. $slen = \count($s[0]);
  67335. $start = (int) $start;
  67336. if (0 > $start) {
  67337. $start += $slen;
  67338. }
  67339. if (0 > $start) {
  67340. if (\PHP_VERSION_ID < 80000) {
  67341. return false;
  67342. }
  67343. $start = 0;
  67344. }
  67345. if ($start >= $slen) {
  67346. return \PHP_VERSION_ID >= 80000 ? '' : false;
  67347. }
  67348. $rem = $slen - $start;
  67349. if (0 > $len) {
  67350. $len += $rem;
  67351. }
  67352. if (0 === $len) {
  67353. return '';
  67354. }
  67355. if (0 > $len) {
  67356. return \PHP_VERSION_ID >= 80000 ? '' : false;
  67357. }
  67358. if ($len > $rem) {
  67359. $len = $rem;
  67360. }
  67361. return implode('', \array_slice($s[0], $start, $len));
  67362. }
  67363. public static function grapheme_strpos($s, $needle, $offset = 0)
  67364. {
  67365. return self::grapheme_position($s, $needle, $offset, 0);
  67366. }
  67367. public static function grapheme_stripos($s, $needle, $offset = 0)
  67368. {
  67369. return self::grapheme_position($s, $needle, $offset, 1);
  67370. }
  67371. public static function grapheme_strrpos($s, $needle, $offset = 0)
  67372. {
  67373. return self::grapheme_position($s, $needle, $offset, 2);
  67374. }
  67375. public static function grapheme_strripos($s, $needle, $offset = 0)
  67376. {
  67377. return self::grapheme_position($s, $needle, $offset, 3);
  67378. }
  67379. public static function grapheme_stristr($s, $needle, $beforeNeedle = false)
  67380. {
  67381. return mb_stristr($s, $needle, $beforeNeedle, 'UTF-8');
  67382. }
  67383. public static function grapheme_strstr($s, $needle, $beforeNeedle = false)
  67384. {
  67385. return mb_strstr($s, $needle, $beforeNeedle, 'UTF-8');
  67386. }
  67387. private static function grapheme_position($s, $needle, $offset, $mode)
  67388. {
  67389. $needle = (string) $needle;
  67390. if (80000 > \PHP_VERSION_ID && !preg_match('/./us', $needle)) {
  67391. return false;
  67392. }
  67393. $s = (string) $s;
  67394. if (!preg_match('/./us', $s)) {
  67395. return false;
  67396. }
  67397. if ($offset > 0) {
  67398. $s = self::grapheme_substr($s, $offset);
  67399. } elseif ($offset < 0) {
  67400. if (2 > $mode) {
  67401. $offset += self::grapheme_strlen($s);
  67402. $s = self::grapheme_substr($s, $offset);
  67403. if (0 > $offset) {
  67404. $offset = 0;
  67405. }
  67406. } elseif (0 > $offset += self::grapheme_strlen($needle)) {
  67407. $s = self::grapheme_substr($s, 0, $offset);
  67408. $offset = 0;
  67409. } else {
  67410. $offset = 0;
  67411. }
  67412. }
  67413. $caseInsensitive = $mode & 1;
  67414. $reverse = $mode & 2;
  67415. if ($caseInsensitive) {
  67416. $mode = \defined('MB_CASE_FOLD_SIMPLE') ? \MB_CASE_FOLD_SIMPLE : \MB_CASE_LOWER;
  67417. $s = mb_convert_case($s, $mode, 'UTF-8');
  67418. $needle = mb_convert_case($needle, $mode, 'UTF-8');
  67419. if (!\defined('MB_CASE_FOLD_SIMPLE')) {
  67420. $s = str_replace(self::CASE_FOLD[0], self::CASE_FOLD[1], $s);
  67421. $needle = str_replace(self::CASE_FOLD[0], self::CASE_FOLD[1], $needle);
  67422. }
  67423. }
  67424. if ($reverse) {
  67425. $needlePos = strrpos($s, $needle);
  67426. } else {
  67427. $needlePos = strpos($s, $needle);
  67428. }
  67429. return false !== $needlePos ? self::grapheme_strlen(substr($s, 0, $needlePos)) + $offset : false;
  67430. }
  67431. }
  67432. Copyright (c) 2015-present Fabien Potencier
  67433. Permission is hereby granted, free of charge, to any person obtaining a copy
  67434. of this software and associated documentation files (the "Software"), to deal
  67435. in the Software without restriction, including without limitation the rights
  67436. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  67437. copies of the Software, and to permit persons to whom the Software is furnished
  67438. to do so, subject to the following conditions:
  67439. The above copyright notice and this permission notice shall be included in all
  67440. copies or substantial portions of the Software.
  67441. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  67442. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  67443. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  67444. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  67445. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  67446. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  67447. THE SOFTWARE.
  67448. <?php
  67449. use Symfony\Polyfill\Intl\Grapheme as p;
  67450. if (extension_loaded('intl')) {
  67451. return;
  67452. }
  67453. if (\PHP_VERSION_ID >= 80000) {
  67454. return require __DIR__.'/bootstrap80.php';
  67455. }
  67456. if (!defined('GRAPHEME_EXTR_COUNT')) {
  67457. define('GRAPHEME_EXTR_COUNT', 0);
  67458. }
  67459. if (!defined('GRAPHEME_EXTR_MAXBYTES')) {
  67460. define('GRAPHEME_EXTR_MAXBYTES', 1);
  67461. }
  67462. if (!defined('GRAPHEME_EXTR_MAXCHARS')) {
  67463. define('GRAPHEME_EXTR_MAXCHARS', 2);
  67464. }
  67465. if (!function_exists('grapheme_extract')) {
  67466. function grapheme_extract($haystack, $size, $type = 0, $start = 0, &$next = 0) { return p\Grapheme::grapheme_extract($haystack, $size, $type, $start, $next); }
  67467. }
  67468. if (!function_exists('grapheme_stripos')) {
  67469. function grapheme_stripos($haystack, $needle, $offset = 0) { return p\Grapheme::grapheme_stripos($haystack, $needle, $offset); }
  67470. }
  67471. if (!function_exists('grapheme_stristr')) {
  67472. function grapheme_stristr($haystack, $needle, $beforeNeedle = false) { return p\Grapheme::grapheme_stristr($haystack, $needle, $beforeNeedle); }
  67473. }
  67474. if (!function_exists('grapheme_strlen')) {
  67475. function grapheme_strlen($input) { return p\Grapheme::grapheme_strlen($input); }
  67476. }
  67477. if (!function_exists('grapheme_strpos')) {
  67478. function grapheme_strpos($haystack, $needle, $offset = 0) { return p\Grapheme::grapheme_strpos($haystack, $needle, $offset); }
  67479. }
  67480. if (!function_exists('grapheme_strripos')) {
  67481. function grapheme_strripos($haystack, $needle, $offset = 0) { return p\Grapheme::grapheme_strripos($haystack, $needle, $offset); }
  67482. }
  67483. if (!function_exists('grapheme_strrpos')) {
  67484. function grapheme_strrpos($haystack, $needle, $offset = 0) { return p\Grapheme::grapheme_strrpos($haystack, $needle, $offset); }
  67485. }
  67486. if (!function_exists('grapheme_strstr')) {
  67487. function grapheme_strstr($haystack, $needle, $beforeNeedle = false) { return p\Grapheme::grapheme_strstr($haystack, $needle, $beforeNeedle); }
  67488. }
  67489. if (!function_exists('grapheme_substr')) {
  67490. function grapheme_substr($string, $offset, $length = null) { return p\Grapheme::grapheme_substr($string, $offset, $length); }
  67491. }
  67492. <?php
  67493. use Symfony\Polyfill\Intl\Grapheme as p;
  67494. if (!defined('GRAPHEME_EXTR_COUNT')) {
  67495. define('GRAPHEME_EXTR_COUNT', 0);
  67496. }
  67497. if (!defined('GRAPHEME_EXTR_MAXBYTES')) {
  67498. define('GRAPHEME_EXTR_MAXBYTES', 1);
  67499. }
  67500. if (!defined('GRAPHEME_EXTR_MAXCHARS')) {
  67501. define('GRAPHEME_EXTR_MAXCHARS', 2);
  67502. }
  67503. if (!function_exists('grapheme_extract')) {
  67504. 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); }
  67505. }
  67506. if (!function_exists('grapheme_stripos')) {
  67507. function grapheme_stripos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_stripos((string) $haystack, (string) $needle, (int) $offset); }
  67508. }
  67509. if (!function_exists('grapheme_stristr')) {
  67510. function grapheme_stristr(?string $haystack, ?string $needle, ?bool $beforeNeedle = false): string|false { return p\Grapheme::grapheme_stristr((string) $haystack, (string) $needle, (bool) $beforeNeedle); }
  67511. }
  67512. if (!function_exists('grapheme_strlen')) {
  67513. function grapheme_strlen(?string $string): int|false|null { return p\Grapheme::grapheme_strlen((string) $string); }
  67514. }
  67515. if (!function_exists('grapheme_strpos')) {
  67516. function grapheme_strpos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_strpos((string) $haystack, (string) $needle, (int) $offset); }
  67517. }
  67518. if (!function_exists('grapheme_strripos')) {
  67519. function grapheme_strripos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_strripos((string) $haystack, (string) $needle, (int) $offset); }
  67520. }
  67521. if (!function_exists('grapheme_strrpos')) {
  67522. function grapheme_strrpos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_strrpos((string) $haystack, (string) $needle, (int) $offset); }
  67523. }
  67524. if (!function_exists('grapheme_strstr')) {
  67525. function grapheme_strstr(?string $haystack, ?string $needle, ?bool $beforeNeedle = false): string|false { return p\Grapheme::grapheme_strstr((string) $haystack, (string) $needle, (bool) $beforeNeedle); }
  67526. }
  67527. if (!function_exists('grapheme_substr')) {
  67528. function grapheme_substr(?string $string, ?int $offset, ?int $length = null): string|false { return p\Grapheme::grapheme_substr((string) $string, (int) $offset, $length); }
  67529. }
  67530. Copyright (c) 2015-present Fabien Potencier
  67531. Permission is hereby granted, free of charge, to any person obtaining a copy
  67532. of this software and associated documentation files (the "Software"), to deal
  67533. in the Software without restriction, including without limitation the rights
  67534. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  67535. copies of the Software, and to permit persons to whom the Software is furnished
  67536. to do so, subject to the following conditions:
  67537. The above copyright notice and this permission notice shall be included in all
  67538. copies or substantial portions of the Software.
  67539. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  67540. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  67541. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  67542. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  67543. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  67544. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  67545. THE SOFTWARE.
  67546. <?php
  67547. namespace Symfony\Polyfill\Intl\Normalizer;
  67548. class Normalizer
  67549. {
  67550. public const FORM_D = \Normalizer::FORM_D;
  67551. public const FORM_KD = \Normalizer::FORM_KD;
  67552. public const FORM_C = \Normalizer::FORM_C;
  67553. public const FORM_KC = \Normalizer::FORM_KC;
  67554. public const NFD = \Normalizer::NFD;
  67555. public const NFKD = \Normalizer::NFKD;
  67556. public const NFC = \Normalizer::NFC;
  67557. public const NFKC = \Normalizer::NFKC;
  67558. private static $C;
  67559. private static $D;
  67560. private static $KD;
  67561. private static $cC;
  67562. private static $ulenMask = ["\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4];
  67563. 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";
  67564. public static function isNormalized(string $s, int $form = self::FORM_C)
  67565. {
  67566. if (!\in_array($form, [self::NFD, self::NFKD, self::NFC, self::NFKC])) {
  67567. return false;
  67568. }
  67569. if (!isset($s[strspn($s, self::$ASCII)])) {
  67570. return true;
  67571. }
  67572. if (self::NFC == $form && preg_match('//u', $s) && !preg_match('/[^\x00-\x{2FF}]/u', $s)) {
  67573. return true;
  67574. }
  67575. return self::normalize($s, $form) === $s;
  67576. }
  67577. public static function normalize(string $s, int $form = self::FORM_C)
  67578. {
  67579. if (!preg_match('//u', $s)) {
  67580. return false;
  67581. }
  67582. switch ($form) {
  67583. case self::NFC: $C = true; $K = false; break;
  67584. case self::NFD: $C = false; $K = false; break;
  67585. case self::NFKC: $C = true; $K = true; break;
  67586. case self::NFKD: $C = false; $K = true; break;
  67587. default:
  67588. if (\defined('Normalizer::NONE') && \Normalizer::NONE == $form) {
  67589. return $s;
  67590. }
  67591. if (80000 > \PHP_VERSION_ID) {
  67592. return false;
  67593. }
  67594. throw new \ValueError('normalizer_normalize(): Argument #2 ($form) must be a a valid normalization form');
  67595. }
  67596. if ('' === $s) {
  67597. return '';
  67598. }
  67599. if ($K && null === self::$KD) {
  67600. self::$KD = self::getData('compatibilityDecomposition');
  67601. }
  67602. if (null === self::$D) {
  67603. self::$D = self::getData('canonicalDecomposition');
  67604. self::$cC = self::getData('combiningClass');
  67605. }
  67606. if (null !== $mbEncoding = (2 & (int) \ini_get('mbstring.func_overload')) ? mb_internal_encoding() : null) {
  67607. mb_internal_encoding('8bit');
  67608. }
  67609. $r = self::decompose($s, $K);
  67610. if ($C) {
  67611. if (null === self::$C) {
  67612. self::$C = self::getData('canonicalComposition');
  67613. }
  67614. $r = self::recompose($r);
  67615. }
  67616. if (null !== $mbEncoding) {
  67617. mb_internal_encoding($mbEncoding);
  67618. }
  67619. return $r;
  67620. }
  67621. private static function recompose($s)
  67622. {
  67623. $ASCII = self::$ASCII;
  67624. $compMap = self::$C;
  67625. $combClass = self::$cC;
  67626. $ulenMask = self::$ulenMask;
  67627. $result = $tail = '';
  67628. $i = $s[0] < "\x80" ? 1 : $ulenMask[$s[0] & "\xF0"];
  67629. $len = \strlen($s);
  67630. $lastUchr = substr($s, 0, $i);
  67631. $lastUcls = isset($combClass[$lastUchr]) ? 256 : 0;
  67632. while ($i < $len) {
  67633. if ($s[$i] < "\x80") {
  67634. if ($tail) {
  67635. $lastUchr .= $tail;
  67636. $tail = '';
  67637. }
  67638. if ($j = strspn($s, $ASCII, $i + 1)) {
  67639. $lastUchr .= substr($s, $i, $j);
  67640. $i += $j;
  67641. }
  67642. $result .= $lastUchr;
  67643. $lastUchr = $s[$i];
  67644. $lastUcls = 0;
  67645. ++$i;
  67646. continue;
  67647. }
  67648. $ulen = $ulenMask[$s[$i] & "\xF0"];
  67649. $uchr = substr($s, $i, $ulen);
  67650. if ($lastUchr < "\xE1\x84\x80" || "\xE1\x84\x92" < $lastUchr
  67651. || $uchr < "\xE1\x85\xA1" || "\xE1\x85\xB5" < $uchr
  67652. || $lastUcls) {
  67653. $ucls = $combClass[$uchr] ?? 0;
  67654. if (isset($compMap[$lastUchr.$uchr]) && (!$lastUcls || $lastUcls < $ucls)) {
  67655. $lastUchr = $compMap[$lastUchr.$uchr];
  67656. } elseif ($lastUcls = $ucls) {
  67657. $tail .= $uchr;
  67658. } else {
  67659. if ($tail) {
  67660. $lastUchr .= $tail;
  67661. $tail = '';
  67662. }
  67663. $result .= $lastUchr;
  67664. $lastUchr = $uchr;
  67665. }
  67666. } else {
  67667. $L = \ord($lastUchr[2]) - 0x80;
  67668. $V = \ord($uchr[2]) - 0xA1;
  67669. $T = 0;
  67670. $uchr = substr($s, $i + $ulen, 3);
  67671. if ("\xE1\x86\xA7" <= $uchr && $uchr <= "\xE1\x87\x82") {
  67672. $T = \ord($uchr[2]) - 0xA7;
  67673. 0 > $T && $T += 0x40;
  67674. $ulen += 3;
  67675. }
  67676. $L = 0xAC00 + ($L * 21 + $V) * 28 + $T;
  67677. $lastUchr = \chr(0xE0 | $L >> 12).\chr(0x80 | $L >> 6 & 0x3F).\chr(0x80 | $L & 0x3F);
  67678. }
  67679. $i += $ulen;
  67680. }
  67681. return $result.$lastUchr.$tail;
  67682. }
  67683. private static function decompose($s, $c)
  67684. {
  67685. $result = '';
  67686. $ASCII = self::$ASCII;
  67687. $decompMap = self::$D;
  67688. $combClass = self::$cC;
  67689. $ulenMask = self::$ulenMask;
  67690. if ($c) {
  67691. $compatMap = self::$KD;
  67692. }
  67693. $c = [];
  67694. $i = 0;
  67695. $len = \strlen($s);
  67696. while ($i < $len) {
  67697. if ($s[$i] < "\x80") {
  67698. if ($c) {
  67699. ksort($c);
  67700. $result .= implode('', $c);
  67701. $c = [];
  67702. }
  67703. $j = 1 + strspn($s, $ASCII, $i + 1);
  67704. $result .= substr($s, $i, $j);
  67705. $i += $j;
  67706. continue;
  67707. }
  67708. $ulen = $ulenMask[$s[$i] & "\xF0"];
  67709. $uchr = substr($s, $i, $ulen);
  67710. $i += $ulen;
  67711. if ($uchr < "\xEA\xB0\x80" || "\xED\x9E\xA3" < $uchr) {
  67712. if ($uchr !== $j = $compatMap[$uchr] ?? ($decompMap[$uchr] ?? $uchr)) {
  67713. $uchr = $j;
  67714. $j = \strlen($uchr);
  67715. $ulen = $uchr[0] < "\x80" ? 1 : $ulenMask[$uchr[0] & "\xF0"];
  67716. if ($ulen != $j) {
  67717. $j -= $ulen;
  67718. $i -= $j;
  67719. if (0 > $i) {
  67720. $s = str_repeat(' ', -$i).$s;
  67721. $len -= $i;
  67722. $i = 0;
  67723. }
  67724. while ($j--) {
  67725. $s[$i + $j] = $uchr[$ulen + $j];
  67726. }
  67727. $uchr = substr($uchr, 0, $ulen);
  67728. }
  67729. }
  67730. if (isset($combClass[$uchr])) {
  67731. if (!isset($c[$combClass[$uchr]])) {
  67732. $c[$combClass[$uchr]] = '';
  67733. }
  67734. $c[$combClass[$uchr]] .= $uchr;
  67735. continue;
  67736. }
  67737. } else {
  67738. $uchr = unpack('C*', $uchr);
  67739. $j = (($uchr[1] - 224) << 12) + (($uchr[2] - 128) << 6) + $uchr[3] - 0xAC80;
  67740. $uchr = "\xE1\x84".\chr(0x80 + (int) ($j / 588))
  67741. ."\xE1\x85".\chr(0xA1 + (int) (($j % 588) / 28));
  67742. if ($j %= 28) {
  67743. $uchr .= $j < 25
  67744. ? ("\xE1\x86".\chr(0xA7 + $j))
  67745. : ("\xE1\x87".\chr(0x67 + $j));
  67746. }
  67747. }
  67748. if ($c) {
  67749. ksort($c);
  67750. $result .= implode('', $c);
  67751. $c = [];
  67752. }
  67753. $result .= $uchr;
  67754. }
  67755. if ($c) {
  67756. ksort($c);
  67757. $result .= implode('', $c);
  67758. }
  67759. return $result;
  67760. }
  67761. private static function getData($file)
  67762. {
  67763. if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) {
  67764. return require $file;
  67765. }
  67766. return false;
  67767. }
  67768. }
  67769. <?php
  67770. class Normalizer extends Symfony\Polyfill\Intl\Normalizer\Normalizer
  67771. {
  67772. public const NONE = 2;
  67773. public const FORM_D = 4;
  67774. public const FORM_KD = 8;
  67775. public const FORM_C = 16;
  67776. public const FORM_KC = 32;
  67777. public const NFD = 4;
  67778. public const NFKD = 8;
  67779. public const NFC = 16;
  67780. public const NFKC = 32;
  67781. }
  67782. <?php
  67783. return array (
  67784. 'À' => 'À',
  67785. 'A�' => '�',
  67786. 'Â' => 'Â',
  67787. 'Ã' => 'Ã',
  67788. 'Ä' => 'Ä',
  67789. 'AÌŠ' => 'Ã…',
  67790. 'Ç' => 'Ç',
  67791. 'È' => 'È',
  67792. 'E�' => 'É',
  67793. 'Ê' => 'Ê',
  67794. 'Ë' => 'Ë',
  67795. 'Ì' => 'Ì',
  67796. 'I�' => '�',
  67797. 'IÌ‚' => 'ÃŽ',
  67798. 'Ï' => '�',
  67799. 'Ñ' => 'Ñ',
  67800. 'OÌ€' => 'Ã’',
  67801. 'O�' => 'Ó',
  67802. 'Ô' => 'Ô',
  67803. 'Õ' => 'Õ',
  67804. 'Ö' => 'Ö',
  67805. 'Ù' => 'Ù',
  67806. 'U�' => 'Ú',
  67807. 'Û' => 'Û',
  67808. 'Ü' => 'Ü',
  67809. 'Y�' => '�',
  67810. 'à' => 'à',
  67811. 'a�' => 'á',
  67812. 'â' => 'â',
  67813. 'ã' => 'ã',
  67814. 'ä' => 'ä',
  67815. 'aÌŠ' => 'Ã¥',
  67816. 'ç' => 'ç',
  67817. 'è' => 'è',
  67818. 'e�' => 'é',
  67819. 'ê' => 'ê',
  67820. 'ë' => 'ë',
  67821. 'ì' => 'ì',
  67822. 'i�' => 'í',
  67823. 'î' => 'î',
  67824. 'ï' => 'ï',
  67825. 'ñ' => 'ñ',
  67826. 'ò' => 'ò',
  67827. 'o�' => 'ó',
  67828. 'ô' => 'ô',
  67829. 'õ' => 'õ',
  67830. 'ö' => 'ö',
  67831. 'ù' => 'ù',
  67832. 'u�' => 'ú',
  67833. 'û' => 'û',
  67834. 'ü' => 'ü',
  67835. 'y�' => 'ý',
  67836. 'ÿ' => 'ÿ',
  67837. 'AÌ„' => 'Ä€',
  67838. 'ā' => '�',
  67839. 'Ă' => 'Ă',
  67840. 'ă' => 'ă',
  67841. 'Ą' => 'Ą',
  67842. 'ą' => 'ą',
  67843. 'C�' => 'Ć',
  67844. 'c�' => 'ć',
  67845. 'Ĉ' => 'Ĉ',
  67846. 'ĉ' => 'ĉ',
  67847. 'Ċ' => 'Ċ',
  67848. 'ċ' => 'ċ',
  67849. 'Č' => 'Č',
  67850. 'č' => '�',
  67851. 'Ď' => 'Ď',
  67852. 'ď' => '�',
  67853. 'EÌ„' => 'Ä’',
  67854. 'ē' => 'ē',
  67855. 'Ĕ' => 'Ĕ',
  67856. 'ĕ' => 'ĕ',
  67857. 'Ė' => 'Ė',
  67858. 'ė' => 'ė',
  67859. 'Ę' => 'Ę',
  67860. 'ę' => 'ę',
  67861. 'Ě' => 'Ě',
  67862. 'ě' => 'ě',
  67863. 'Ĝ' => 'Ĝ',
  67864. 'ĝ' => '�',
  67865. 'Ğ' => 'Ğ',
  67866. 'ğ' => 'ğ',
  67867. 'Ġ' => 'Ġ',
  67868. 'ġ' => 'ġ',
  67869. 'Ģ' => 'Ģ',
  67870. 'ģ' => 'ģ',
  67871. 'Ĥ' => 'Ĥ',
  67872. 'ĥ' => 'ĥ',
  67873. 'Ĩ' => 'Ĩ',
  67874. 'ĩ' => 'ĩ',
  67875. 'Ī' => 'Ī',
  67876. 'ī' => 'ī',
  67877. 'Ĭ' => 'Ĭ',
  67878. 'ĭ' => 'ĭ',
  67879. 'Į' => 'Į',
  67880. 'į' => 'į',
  67881. 'İ' => 'İ',
  67882. 'JÌ‚' => 'Ä´',
  67883. 'ĵ' => 'ĵ',
  67884. 'Ķ' => 'Ķ',
  67885. 'ķ' => 'ķ',
  67886. 'L�' => 'Ĺ',
  67887. 'l�' => 'ĺ',
  67888. 'Ļ' => 'Ļ',
  67889. 'ļ' => 'ļ',
  67890. 'Ľ' => 'Ľ',
  67891. 'ľ' => 'ľ',
  67892. 'N�' => 'Ń',
  67893. 'n�' => 'ń',
  67894. 'Ņ' => 'Ņ',
  67895. 'ņ' => 'ņ',
  67896. 'Ň' => 'Ň',
  67897. 'ň' => 'ň',
  67898. 'Ō' => 'Ō',
  67899. 'ō' => '�',
  67900. 'Ŏ' => 'Ŏ',
  67901. 'ŏ' => '�',
  67902. 'Ő' => '�',
  67903. 'ő' => 'ő',
  67904. 'R�' => 'Ŕ',
  67905. 'r�' => 'ŕ',
  67906. 'Ŗ' => 'Ŗ',
  67907. 'ŗ' => 'ŗ',
  67908. 'Ř' => 'Ř',
  67909. 'ř' => 'ř',
  67910. 'S�' => 'Ś',
  67911. 's�' => 'ś',
  67912. 'Ŝ' => 'Ŝ',
  67913. 'ŝ' => '�',
  67914. 'Ş' => 'Ş',
  67915. 'ş' => 'ş',
  67916. 'Š' => 'Š',
  67917. 'š' => 'š',
  67918. 'Ţ' => 'Ţ',
  67919. 'ţ' => 'ţ',
  67920. 'Ť' => 'Ť',
  67921. 'ť' => 'ť',
  67922. 'Ũ' => 'Ũ',
  67923. 'ũ' => 'ũ',
  67924. 'Ū' => 'Ū',
  67925. 'ū' => 'ū',
  67926. 'Ŭ' => 'Ŭ',
  67927. 'ŭ' => 'ŭ',
  67928. 'UÌŠ' => 'Å®',
  67929. 'ů' => 'ů',
  67930. 'Ű' => 'Ű',
  67931. 'ű' => 'ű',
  67932. 'Ų' => 'Ų',
  67933. 'ų' => 'ų',
  67934. 'WÌ‚' => 'Å´',
  67935. 'ŵ' => 'ŵ',
  67936. 'Ŷ' => 'Ŷ',
  67937. 'ŷ' => 'ŷ',
  67938. 'Ÿ' => 'Ÿ',
  67939. 'Z�' => 'Ź',
  67940. 'z�' => 'ź',
  67941. 'Ż' => 'Ż',
  67942. 'ż' => 'ż',
  67943. 'Ž' => 'Ž',
  67944. 'ž' => 'ž',
  67945. 'OÌ›' => 'Æ ',
  67946. 'oÌ›' => 'Æ¡',
  67947. 'Ư' => 'Ư',
  67948. 'ư' => 'ư',
  67949. 'Ǎ' => '�',
  67950. 'ǎ' => 'ǎ',
  67951. 'Ǐ' => '�',
  67952. 'ǐ' => '�',
  67953. 'Ǒ' => 'Ǒ',
  67954. 'ǒ' => 'ǒ',
  67955. 'Ǔ' => 'Ǔ',
  67956. 'ǔ' => 'ǔ',
  67957. 'Ǖ' => 'Ǖ',
  67958. 'ǖ' => 'ǖ',
  67959. 'Ü�' => 'Ǘ',
  67960. 'ü�' => 'ǘ',
  67961. 'Ǚ' => 'Ǚ',
  67962. 'ǚ' => 'ǚ',
  67963. 'Ǜ' => 'Ǜ',
  67964. 'ǜ' => 'ǜ',
  67965. 'Ǟ' => 'Ǟ',
  67966. 'ǟ' => 'ǟ',
  67967. 'Ǡ' => 'Ǡ',
  67968. 'ǡ' => 'ǡ',
  67969. 'Ǣ' => 'Ǣ',
  67970. 'ǣ' => 'ǣ',
  67971. 'Ǧ' => 'Ǧ',
  67972. 'ǧ' => 'ǧ',
  67973. 'Ǩ' => 'Ǩ',
  67974. 'ǩ' => 'ǩ',
  67975. 'Ǫ' => 'Ǫ',
  67976. 'ǫ' => 'ǫ',
  67977. 'Ǭ' => 'Ǭ',
  67978. 'ǭ' => 'ǭ',
  67979. 'Ǯ' => 'Ǯ',
  67980. 'ǯ' => 'ǯ',
  67981. 'ǰ' => 'ǰ',
  67982. 'G�' => 'Ǵ',
  67983. 'g�' => 'ǵ',
  67984. 'Ǹ' => 'Ǹ',
  67985. 'ǹ' => 'ǹ',
  67986. 'Å�' => 'Ǻ',
  67987. 'å�' => 'ǻ',
  67988. 'Æ�' => 'Ǽ',
  67989. 'æ�' => 'ǽ',
  67990. 'Ø�' => 'Ǿ',
  67991. 'ø�' => 'ǿ',
  67992. 'A�' => 'Ȁ',
  67993. 'a�' => '�',
  67994. 'AÌ‘' => 'È‚',
  67995. 'ȃ' => 'ȃ',
  67996. 'E�' => 'Ȅ',
  67997. 'e�' => 'ȅ',
  67998. 'Ȇ' => 'Ȇ',
  67999. 'ȇ' => 'ȇ',
  68000. 'I�' => 'Ȉ',
  68001. 'i�' => 'ȉ',
  68002. 'IÌ‘' => 'ÈŠ',
  68003. 'ȋ' => 'ȋ',
  68004. 'O�' => 'Ȍ',
  68005. 'o�' => '�',
  68006. 'OÌ‘' => 'ÈŽ',
  68007. 'ȏ' => '�',
  68008. 'R�' => '�',
  68009. 'r�' => 'ȑ',
  68010. 'RÌ‘' => 'È’',
  68011. 'ȓ' => 'ȓ',
  68012. 'U�' => 'Ȕ',
  68013. 'u�' => 'ȕ',
  68014. 'UÌ‘' => 'È–',
  68015. 'ȗ' => 'ȗ',
  68016. 'Ș' => 'Ș',
  68017. 'ș' => 'ș',
  68018. 'Ț' => 'Ț',
  68019. 'ț' => 'ț',
  68020. 'Ȟ' => 'Ȟ',
  68021. 'ȟ' => 'ȟ',
  68022. 'Ȧ' => 'Ȧ',
  68023. 'ȧ' => 'ȧ',
  68024. 'Ȩ' => 'Ȩ',
  68025. 'ȩ' => 'ȩ',
  68026. 'Ȫ' => 'Ȫ',
  68027. 'ȫ' => 'ȫ',
  68028. 'Ȭ' => 'Ȭ',
  68029. 'ȭ' => 'ȭ',
  68030. 'Ȯ' => 'Ȯ',
  68031. 'ȯ' => 'ȯ',
  68032. 'Ȱ' => 'Ȱ',
  68033. 'ȱ' => 'ȱ',
  68034. 'Ȳ' => 'Ȳ',
  68035. 'ȳ' => 'ȳ',
  68036. '¨�' => '΅',
  68037. 'Α�' => 'Ά',
  68038. 'Ε�' => 'Έ',
  68039. 'Η�' => 'Ή',
  68040. 'Ι�' => 'Ί',
  68041. 'Ο�' => 'Ό',
  68042. 'Υ�' => 'Ύ',
  68043. 'Ω�' => '�',
  68044. 'ϊ�' => '�',
  68045. 'Ϊ' => 'Ϊ',
  68046. 'Ϋ' => 'Ϋ',
  68047. 'α�' => 'ά',
  68048. 'ε�' => 'έ',
  68049. 'η�' => 'ή',
  68050. 'ι�' => 'ί',
  68051. 'ϋ�' => 'ΰ',
  68052. 'ϊ' => 'ϊ',
  68053. 'ϋ' => 'ϋ',
  68054. 'ο�' => 'ό',
  68055. 'υ�' => '�',
  68056. 'ω�' => 'ώ',
  68057. 'ϒ�' => 'ϓ',
  68058. 'ϔ' => 'ϔ',
  68059. 'Ѐ' => 'Ѐ',
  68060. 'Ё' => '�',
  68061. 'Г�' => 'Ѓ',
  68062. 'Ї' => 'Ї',
  68063. 'К�' => 'Ќ',
  68064. 'Ѝ' => '�',
  68065. 'Ў' => 'Ў',
  68066. 'Й' => 'Й',
  68067. 'й' => 'й',
  68068. 'ѐ' => '�',
  68069. 'ё' => 'ё',
  68070. 'г�' => 'ѓ',
  68071. 'ї' => 'ї',
  68072. 'к�' => 'ќ',
  68073. 'ѝ' => '�',
  68074. 'ў' => 'ў',
  68075. 'Ѵ�' => 'Ѷ',
  68076. 'ѵ�' => 'ѷ',
  68077. 'Ӂ' => '�',
  68078. 'ӂ' => 'ӂ',
  68079. '�̆' => '�',
  68080. 'ӑ' => 'ӑ',
  68081. '�̈' => 'Ӓ',
  68082. 'ӓ' => 'ӓ',
  68083. 'Ӗ' => 'Ӗ',
  68084. 'ӗ' => 'ӗ',
  68085. 'Ӛ' => 'Ӛ',
  68086. 'ӛ' => 'ӛ',
  68087. 'Ӝ' => 'Ӝ',
  68088. 'ӝ' => '�',
  68089. 'Ӟ' => 'Ӟ',
  68090. 'ӟ' => 'ӟ',
  68091. 'Ӣ' => 'Ӣ',
  68092. 'ӣ' => 'ӣ',
  68093. 'Ӥ' => 'Ӥ',
  68094. 'ӥ' => 'ӥ',
  68095. 'Ӧ' => 'Ӧ',
  68096. 'ӧ' => 'ӧ',
  68097. 'Ӫ' => 'Ӫ',
  68098. 'ӫ' => 'ӫ',
  68099. 'Ӭ' => 'Ӭ',
  68100. '�̈' => 'ӭ',
  68101. 'Ӯ' => 'Ӯ',
  68102. 'ӯ' => 'ӯ',
  68103. 'Ӱ' => 'Ӱ',
  68104. 'ӱ' => 'ӱ',
  68105. 'Ӳ' => 'Ӳ',
  68106. 'ӳ' => 'ӳ',
  68107. 'Ӵ' => 'Ӵ',
  68108. 'ӵ' => 'ӵ',
  68109. 'Ӹ' => 'Ӹ',
  68110. 'ӹ' => 'ӹ',
  68111. 'آ' => 'آ',
  68112. 'أ' => 'أ',
  68113. 'ؤ' => 'ؤ',
  68114. 'إ' => 'إ',
  68115. 'ئ' => 'ئ',
  68116. 'Û•Ù”' => 'Û€',
  68117. 'Û�Ù”' => 'Û‚',
  68118. 'Û’Ù”' => 'Û“',
  68119. 'ऩ' => 'ऩ',
  68120. 'ऱ' => 'ऱ',
  68121. 'ऴ' => 'ऴ',
  68122. 'ো' => 'ো',
  68123. 'ৌ' => 'ৌ',
  68124. 'ୈ' => 'ୈ',
  68125. 'ୋ' => 'ୋ',
  68126. 'ୌ' => 'ୌ',
  68127. 'ஔ' => 'ஔ',
  68128. 'ொ' => 'ொ',
  68129. 'ோ' => 'ோ',
  68130. 'ௌ' => 'ௌ',
  68131. 'ై' => 'ై',
  68132. 'ೀ' => 'ೀ',
  68133. 'ೇ' => 'ೇ',
  68134. 'ೈ' => 'ೈ',
  68135. 'ೊ' => 'ೊ',
  68136. 'ೋ' => 'ೋ',
  68137. 'ൊ' => 'ൊ',
  68138. 'ോ' => 'ോ',
  68139. 'ൌ' => 'ൌ',
  68140. 'ේ' => 'ේ',
  68141. 'ෙ�' => 'ො',
  68142. 'ෝ' => '�',
  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. 'K�' => 'Ḱ',
  68205. 'k�' => 'ḱ',
  68206. 'Ḳ' => 'Ḳ',
  68207. 'ḳ' => 'ḳ',
  68208. 'Ḵ' => 'Ḵ',
  68209. 'ḵ' => 'ḵ',
  68210. 'Ḷ' => 'Ḷ',
  68211. 'ḷ' => 'ḷ',
  68212. 'Ḹ' => 'Ḹ',
  68213. 'ḹ' => 'ḹ',
  68214. 'Ḻ' => 'Ḻ',
  68215. 'ḻ' => 'ḻ',
  68216. 'Ḽ' => 'Ḽ',
  68217. 'ḽ' => 'ḽ',
  68218. 'M�' => 'Ḿ',
  68219. 'm�' => 'ḿ',
  68220. 'Ṁ' => 'Ṁ',
  68221. 'ṁ' => '�',
  68222. 'Ṃ' => 'Ṃ',
  68223. 'ṃ' => 'ṃ',
  68224. 'Ṅ' => 'Ṅ',
  68225. 'ṅ' => 'ṅ',
  68226. 'Ṇ' => 'Ṇ',
  68227. 'ṇ' => 'ṇ',
  68228. 'Ṉ' => 'Ṉ',
  68229. 'ṉ' => 'ṉ',
  68230. 'Ṋ' => 'Ṋ',
  68231. 'ṋ' => 'ṋ',
  68232. 'Õ�' => 'Ṍ',
  68233. 'õ�' => '�',
  68234. 'Ṏ' => 'Ṏ',
  68235. 'ṏ' => '�',
  68236. 'Ṑ' => '�',
  68237. '�̀' => 'ṑ',
  68238. 'Ō�' => 'Ṓ',
  68239. '��' => 'ṓ',
  68240. 'P�' => 'Ṕ',
  68241. 'p�' => 'ṕ',
  68242. 'Ṗ' => 'Ṗ',
  68243. 'ṗ' => 'ṗ',
  68244. 'Ṙ' => 'Ṙ',
  68245. 'ṙ' => 'ṙ',
  68246. 'Ṛ' => 'Ṛ',
  68247. 'ṛ' => 'ṛ',
  68248. 'Ṝ' => 'Ṝ',
  68249. 'ṝ' => '�',
  68250. 'Ṟ' => 'Ṟ',
  68251. 'ṟ' => 'ṟ',
  68252. 'Ṡ' => 'Ṡ',
  68253. 'ṡ' => 'ṡ',
  68254. 'SÌ£' => 'á¹¢',
  68255. 'ṣ' => 'ṣ',
  68256. 'Ṥ' => 'Ṥ',
  68257. 'ṥ' => 'ṥ',
  68258. 'Ṧ' => 'Ṧ',
  68259. 'ṧ' => 'ṧ',
  68260. 'Ṩ' => 'Ṩ',
  68261. 'ṩ' => 'ṩ',
  68262. 'Ṫ' => 'Ṫ',
  68263. 'ṫ' => 'ṫ',
  68264. 'Ṭ' => 'Ṭ',
  68265. 'ṭ' => 'ṭ',
  68266. 'Ṯ' => 'Ṯ',
  68267. 'ṯ' => 'ṯ',
  68268. 'TÌ­' => 'á¹°',
  68269. 'tÌ­' => 'á¹±',
  68270. 'Ṳ' => 'Ṳ',
  68271. 'ṳ' => 'ṳ',
  68272. 'Ṵ' => 'Ṵ',
  68273. 'ṵ' => 'ṵ',
  68274. 'UÌ­' => 'á¹¶',
  68275. 'uÌ­' => 'á¹·',
  68276. 'Ũ�' => 'Ṹ',
  68277. 'ũ�' => 'ṹ',
  68278. 'Ṻ' => 'Ṻ',
  68279. 'ṻ' => 'ṻ',
  68280. 'Ṽ' => 'Ṽ',
  68281. 'ṽ' => 'ṽ',
  68282. 'VÌ£' => 'á¹¾',
  68283. 'ṿ' => 'ṿ',
  68284. 'Ẁ' => 'Ẁ',
  68285. 'ẁ' => '�',
  68286. 'W�' => 'Ẃ',
  68287. 'w�' => 'ẃ',
  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. 'YÌ£' => 'á»´',
  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. 'ᾨ' => 'ᾨ',
  68549. 'ᾩ' => 'ᾩ',
  68550. 'ᾪ' => 'ᾪ',
  68551. 'ᾫ' => 'ᾫ',
  68552. 'ᾬ' => 'ᾬ',
  68553. 'á½­Í…' => 'á¾­',
  68554. 'ᾮ' => 'ᾮ',
  68555. 'ᾯ' => 'ᾯ',
  68556. 'ᾰ' => 'ᾰ',
  68557. 'ᾱ' => 'ᾱ',
  68558. 'á½°Í…' => 'á¾²',
  68559. 'ᾳ' => 'ᾳ',
  68560. 'ᾴ' => 'ᾴ',
  68561. 'ᾶ' => 'ᾶ',
  68562. 'á¾¶Í…' => 'á¾·',
  68563. 'Ᾰ' => 'Ᾰ',
  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. '⊮' => '⊮',
  68645. '⊯' => '⊯',
  68646. '⋠' => '⋠',
  68647. '⋡' => '⋡',
  68648. '⋢' => '⋢',
  68649. '⋣' => '⋣',
  68650. '⋪' => '⋪',
  68651. '⋫' => '⋫',
  68652. '⋬' => '⋬',
  68653. '⋭' => '⋭',
  68654. '�゙' => '�',
  68655. '�゙' => '�',
  68656. '�゙' => '�',
  68657. '�゙' => '�',
  68658. '�゙' => '�',
  68659. '�゙' => '�',
  68660. '�゙' => '�',
  68661. '�゙' => '�',
  68662. '�゙' => '�',
  68663. '�゙' => '�',
  68664. '�゙' => '�',
  68665. '�゙' => '�',
  68666. '�゙' => '�',
  68667. '�゙' => '�',
  68668. '�゙' => '�',
  68669. '�゙' => '�',
  68670. '�゚' => '�',
  68671. '�゙' => '�',
  68672. '�゚' => '�',
  68673. '�゙' => '�',
  68674. '�゚' => '�',
  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. <?php
  68727. return array (
  68728. 'À' => 'À',
  68729. '�' => 'A�',
  68730. 'Â' => 'Â',
  68731. 'Ã' => 'Ã',
  68732. 'Ä' => 'Ä',
  68733. 'Ã…' => 'AÌŠ',
  68734. 'Ç' => 'Ç',
  68735. 'È' => 'È',
  68736. 'É' => 'E�',
  68737. 'Ê' => 'Ê',
  68738. 'Ë' => 'Ë',
  68739. 'Ì' => 'Ì',
  68740. '�' => 'I�',
  68741. 'ÃŽ' => 'IÌ‚',
  68742. '�' => 'Ï',
  68743. 'Ñ' => 'Ñ',
  68744. 'Ã’' => 'OÌ€',
  68745. 'Ó' => 'O�',
  68746. 'Ô' => 'Ô',
  68747. 'Õ' => 'Õ',
  68748. 'Ö' => 'Ö',
  68749. 'Ù' => 'Ù',
  68750. 'Ú' => 'U�',
  68751. 'Û' => 'Û',
  68752. 'Ü' => 'Ü',
  68753. '�' => 'Y�',
  68754. 'à' => 'à',
  68755. 'á' => 'a�',
  68756. 'â' => 'â',
  68757. 'ã' => 'ã',
  68758. 'ä' => 'ä',
  68759. 'Ã¥' => 'aÌŠ',
  68760. 'ç' => 'ç',
  68761. 'è' => 'è',
  68762. 'é' => 'e�',
  68763. 'ê' => 'ê',
  68764. 'ë' => 'ë',
  68765. 'ì' => 'ì',
  68766. 'í' => 'i�',
  68767. 'î' => 'î',
  68768. 'ï' => 'ï',
  68769. 'ñ' => 'ñ',
  68770. 'ò' => 'ò',
  68771. 'ó' => 'o�',
  68772. 'ô' => 'ô',
  68773. 'õ' => 'õ',
  68774. 'ö' => 'ö',
  68775. 'ù' => 'ù',
  68776. 'ú' => 'u�',
  68777. 'û' => 'û',
  68778. 'ü' => 'ü',
  68779. 'ý' => 'y�',
  68780. 'ÿ' => 'ÿ',
  68781. 'Ä€' => 'AÌ„',
  68782. '�' => 'ā',
  68783. 'Ă' => 'Ă',
  68784. 'ă' => 'ă',
  68785. 'Ą' => 'Ą',
  68786. 'ą' => 'ą',
  68787. 'Ć' => 'C�',
  68788. 'ć' => 'c�',
  68789. 'Ĉ' => 'Ĉ',
  68790. 'ĉ' => 'ĉ',
  68791. 'Ċ' => 'Ċ',
  68792. 'ċ' => 'ċ',
  68793. 'Č' => 'Č',
  68794. '�' => 'č',
  68795. 'Ď' => 'Ď',
  68796. '�' => 'ď',
  68797. 'Ä’' => 'EÌ„',
  68798. 'ē' => 'ē',
  68799. 'Ĕ' => 'Ĕ',
  68800. 'ĕ' => 'ĕ',
  68801. 'Ė' => 'Ė',
  68802. 'ė' => 'ė',
  68803. 'Ę' => 'Ę',
  68804. 'ę' => 'ę',
  68805. 'Ě' => 'Ě',
  68806. 'ě' => 'ě',
  68807. 'Ĝ' => 'Ĝ',
  68808. '�' => 'ĝ',
  68809. 'Ğ' => 'Ğ',
  68810. 'ğ' => 'ğ',
  68811. 'Ġ' => 'Ġ',
  68812. 'ġ' => 'ġ',
  68813. 'Ģ' => 'Ģ',
  68814. 'ģ' => 'ģ',
  68815. 'Ĥ' => 'Ĥ',
  68816. 'ĥ' => 'ĥ',
  68817. 'Ĩ' => 'Ĩ',
  68818. 'ĩ' => 'ĩ',
  68819. 'Ī' => 'Ī',
  68820. 'ī' => 'ī',
  68821. 'Ĭ' => 'Ĭ',
  68822. 'ĭ' => 'ĭ',
  68823. 'Į' => 'Į',
  68824. 'į' => 'į',
  68825. 'İ' => 'İ',
  68826. 'Ä´' => 'JÌ‚',
  68827. 'ĵ' => 'ĵ',
  68828. 'Ķ' => 'Ķ',
  68829. 'ķ' => 'ķ',
  68830. 'Ĺ' => 'L�',
  68831. 'ĺ' => 'l�',
  68832. 'Ļ' => 'Ļ',
  68833. 'ļ' => 'ļ',
  68834. 'Ľ' => 'Ľ',
  68835. 'ľ' => 'ľ',
  68836. 'Ń' => 'N�',
  68837. 'ń' => 'n�',
  68838. 'Ņ' => 'Ņ',
  68839. 'ņ' => 'ņ',
  68840. 'Ň' => 'Ň',
  68841. 'ň' => 'ň',
  68842. 'Ō' => 'Ō',
  68843. '�' => 'ō',
  68844. 'Ŏ' => 'Ŏ',
  68845. '�' => 'ŏ',
  68846. '�' => 'Ő',
  68847. 'ő' => 'ő',
  68848. 'Ŕ' => 'R�',
  68849. 'ŕ' => 'r�',
  68850. 'Ŗ' => 'Ŗ',
  68851. 'ŗ' => 'ŗ',
  68852. 'Ř' => 'Ř',
  68853. 'ř' => 'ř',
  68854. 'Ś' => 'S�',
  68855. 'ś' => 's�',
  68856. 'Ŝ' => 'Ŝ',
  68857. '�' => 'ŝ',
  68858. 'Ş' => 'Ş',
  68859. 'ş' => 'ş',
  68860. 'Š' => 'Š',
  68861. 'š' => 'š',
  68862. 'Ţ' => 'Ţ',
  68863. 'ţ' => 'ţ',
  68864. 'Ť' => 'Ť',
  68865. 'ť' => 'ť',
  68866. 'Ũ' => 'Ũ',
  68867. 'ũ' => 'ũ',
  68868. 'Ū' => 'Ū',
  68869. 'ū' => 'ū',
  68870. 'Ŭ' => 'Ŭ',
  68871. 'ŭ' => 'ŭ',
  68872. 'Å®' => 'UÌŠ',
  68873. 'ů' => 'ů',
  68874. 'Ű' => 'Ű',
  68875. 'ű' => 'ű',
  68876. 'Ų' => 'Ų',
  68877. 'ų' => 'ų',
  68878. 'Å´' => 'WÌ‚',
  68879. 'ŵ' => 'ŵ',
  68880. 'Ŷ' => 'Ŷ',
  68881. 'ŷ' => 'ŷ',
  68882. 'Ÿ' => 'Ÿ',
  68883. 'Ź' => 'Z�',
  68884. 'ź' => 'z�',
  68885. 'Ż' => 'Ż',
  68886. 'ż' => 'ż',
  68887. 'Ž' => 'Ž',
  68888. 'ž' => 'ž',
  68889. 'Æ ' => 'OÌ›',
  68890. 'Æ¡' => 'oÌ›',
  68891. 'Ư' => 'Ư',
  68892. 'ư' => 'ư',
  68893. '�' => 'Ǎ',
  68894. 'ǎ' => 'ǎ',
  68895. '�' => 'Ǐ',
  68896. '�' => 'ǐ',
  68897. 'Ǒ' => 'Ǒ',
  68898. 'ǒ' => 'ǒ',
  68899. 'Ǔ' => 'Ǔ',
  68900. 'ǔ' => 'ǔ',
  68901. 'Ǖ' => 'Ǖ',
  68902. 'ǖ' => 'ǖ',
  68903. 'Ǘ' => 'Ü�',
  68904. 'ǘ' => 'ü�',
  68905. 'Ǚ' => 'Ǚ',
  68906. 'ǚ' => 'ǚ',
  68907. 'Ǜ' => 'Ǜ',
  68908. 'ǜ' => 'ǜ',
  68909. 'Ǟ' => 'Ǟ',
  68910. 'ǟ' => 'ǟ',
  68911. 'Ǡ' => 'Ǡ',
  68912. 'ǡ' => 'ǡ',
  68913. 'Ǣ' => 'Ǣ',
  68914. 'ǣ' => 'ǣ',
  68915. 'Ǧ' => 'Ǧ',
  68916. 'ǧ' => 'ǧ',
  68917. 'Ǩ' => 'Ǩ',
  68918. 'ǩ' => 'ǩ',
  68919. 'Ǫ' => 'Ǫ',
  68920. 'ǫ' => 'ǫ',
  68921. 'Ǭ' => 'Ǭ',
  68922. 'ǭ' => 'ǭ',
  68923. 'Ǯ' => 'Ǯ',
  68924. 'ǯ' => 'ǯ',
  68925. 'ǰ' => 'ǰ',
  68926. 'Ǵ' => 'G�',
  68927. 'ǵ' => 'g�',
  68928. 'Ǹ' => 'Ǹ',
  68929. 'ǹ' => 'ǹ',
  68930. 'Ǻ' => 'Å�',
  68931. 'ǻ' => 'å�',
  68932. 'Ǽ' => 'Æ�',
  68933. 'ǽ' => 'æ�',
  68934. 'Ǿ' => 'Ø�',
  68935. 'ǿ' => 'ø�',
  68936. 'Ȁ' => 'A�',
  68937. '�' => 'a�',
  68938. 'È‚' => 'AÌ‘',
  68939. 'ȃ' => 'ȃ',
  68940. 'Ȅ' => 'E�',
  68941. 'ȅ' => 'e�',
  68942. 'Ȇ' => 'Ȇ',
  68943. 'ȇ' => 'ȇ',
  68944. 'Ȉ' => 'I�',
  68945. 'ȉ' => 'i�',
  68946. 'ÈŠ' => 'IÌ‘',
  68947. 'ȋ' => 'ȋ',
  68948. 'Ȍ' => 'O�',
  68949. '�' => 'o�',
  68950. 'ÈŽ' => 'OÌ‘',
  68951. '�' => 'ȏ',
  68952. '�' => 'R�',
  68953. 'ȑ' => 'r�',
  68954. 'È’' => 'RÌ‘',
  68955. 'ȓ' => 'ȓ',
  68956. 'Ȕ' => 'U�',
  68957. 'ȕ' => 'u�',
  68958. 'È–' => 'UÌ‘',
  68959. 'ȗ' => 'ȗ',
  68960. 'Ș' => 'Ș',
  68961. 'ș' => 'ș',
  68962. 'Ț' => 'Ț',
  68963. 'ț' => 'ț',
  68964. 'Ȟ' => 'Ȟ',
  68965. 'ȟ' => 'ȟ',
  68966. 'Ȧ' => 'Ȧ',
  68967. 'ȧ' => 'ȧ',
  68968. 'Ȩ' => 'Ȩ',
  68969. 'ȩ' => 'ȩ',
  68970. 'Ȫ' => 'Ȫ',
  68971. 'ȫ' => 'ȫ',
  68972. 'Ȭ' => 'Ȭ',
  68973. 'ȭ' => 'ȭ',
  68974. 'Ȯ' => 'Ȯ',
  68975. 'ȯ' => 'ȯ',
  68976. 'Ȱ' => 'Ȱ',
  68977. 'ȱ' => 'ȱ',
  68978. 'Ȳ' => 'Ȳ',
  68979. 'ȳ' => 'ȳ',
  68980. 'Í€' => 'Ì€',
  68981. '�' => '�',
  68982. '̓' => '̓',
  68983. '̈́' => '̈�',
  68984. 'ʹ' => 'ʹ',
  68985. ';' => ';',
  68986. '΅' => '¨�',
  68987. 'Ά' => 'Α�',
  68988. '·' => '·',
  68989. 'Έ' => 'Ε�',
  68990. 'Ή' => 'Η�',
  68991. 'Ί' => 'Ι�',
  68992. 'Ό' => 'Ο�',
  68993. 'Ύ' => 'Υ�',
  68994. '�' => 'Ω�',
  68995. '�' => 'ϊ�',
  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. 'Ḱ' => 'K�',
  69192. 'ḱ' => 'k�',
  69193. 'Ḳ' => 'Ḳ',
  69194. 'ḳ' => 'ḳ',
  69195. 'Ḵ' => 'Ḵ',
  69196. 'ḵ' => 'ḵ',
  69197. 'Ḷ' => 'Ḷ',
  69198. 'ḷ' => 'ḷ',
  69199. 'Ḹ' => 'Ḹ',
  69200. 'ḹ' => 'ḹ',
  69201. 'Ḻ' => 'Ḻ',
  69202. 'ḻ' => 'ḻ',
  69203. 'Ḽ' => 'Ḽ',
  69204. 'ḽ' => 'ḽ',
  69205. 'Ḿ' => 'M�',
  69206. 'ḿ' => 'm�',
  69207. 'Ṁ' => 'Ṁ',
  69208. '�' => 'ṁ',
  69209. 'Ṃ' => 'Ṃ',
  69210. 'ṃ' => 'ṃ',
  69211. 'Ṅ' => 'Ṅ',
  69212. 'ṅ' => 'ṅ',
  69213. 'Ṇ' => 'Ṇ',
  69214. 'ṇ' => 'ṇ',
  69215. 'Ṉ' => 'Ṉ',
  69216. 'ṉ' => 'ṉ',
  69217. 'Ṋ' => 'Ṋ',
  69218. 'ṋ' => 'ṋ',
  69219. 'Ṍ' => 'Õ�',
  69220. '�' => 'õ�',
  69221. 'Ṏ' => 'Ṏ',
  69222. '�' => 'ṏ',
  69223. '�' => 'Ṑ',
  69224. 'ṑ' => 'ṑ',
  69225. 'Ṓ' => 'Ō�',
  69226. 'ṓ' => 'ō�',
  69227. 'Ṕ' => 'P�',
  69228. 'ṕ' => 'p�',
  69229. 'Ṗ' => 'Ṗ',
  69230. 'ṗ' => 'ṗ',
  69231. 'Ṙ' => 'Ṙ',
  69232. 'ṙ' => 'ṙ',
  69233. 'Ṛ' => 'Ṛ',
  69234. 'ṛ' => 'ṛ',
  69235. 'Ṝ' => 'Ṝ',
  69236. '�' => 'ṝ',
  69237. 'Ṟ' => 'Ṟ',
  69238. 'ṟ' => 'ṟ',
  69239. 'Ṡ' => 'Ṡ',
  69240. 'ṡ' => 'ṡ',
  69241. 'á¹¢' => 'SÌ£',
  69242. 'ṣ' => 'ṣ',
  69243. 'Ṥ' => 'S�̇',
  69244. 'ṥ' => 's�̇',
  69245. 'Ṧ' => 'Ṧ',
  69246. 'ṧ' => 'ṧ',
  69247. 'Ṩ' => 'Ṩ',
  69248. 'ṩ' => 'ṩ',
  69249. 'Ṫ' => 'Ṫ',
  69250. 'ṫ' => 'ṫ',
  69251. 'Ṭ' => 'Ṭ',
  69252. 'ṭ' => 'ṭ',
  69253. 'Ṯ' => 'Ṯ',
  69254. 'ṯ' => 'ṯ',
  69255. 'á¹°' => 'TÌ­',
  69256. 'á¹±' => 'tÌ­',
  69257. 'Ṳ' => 'Ṳ',
  69258. 'ṳ' => 'ṳ',
  69259. 'Ṵ' => 'Ṵ',
  69260. 'ṵ' => 'ṵ',
  69261. 'á¹¶' => 'UÌ­',
  69262. 'á¹·' => 'uÌ­',
  69263. 'Ṹ' => 'Ũ�',
  69264. 'ṹ' => 'ũ�',
  69265. 'Ṻ' => 'Ṻ',
  69266. 'ṻ' => 'ṻ',
  69267. 'Ṽ' => 'Ṽ',
  69268. 'ṽ' => 'ṽ',
  69269. 'á¹¾' => 'VÌ£',
  69270. 'ṿ' => 'ṿ',
  69271. 'Ẁ' => 'Ẁ',
  69272. '�' => 'ẁ',
  69273. 'Ẃ' => 'W�',
  69274. 'ẃ' => 'w�',
  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. 'á»´' => 'YÌ£',
  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. 'K' => 'K',
  69621. 'â„«' => 'AÌŠ',
  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. '率' => '率',
  69825. '異' => '異',
  69826. '北' => '北',
  69827. '磻' => '磻',
  69828. '便' => '便',
  69829. '復' => '復',
  69830. '不' => '�',
  69831. '泌' => '泌',
  69832. '數' => '數',
  69833. '索' => '索',
  69834. '參' => '�',
  69835. '塞' => '塞',
  69836. '省' => '�',
  69837. '葉' => '葉',
  69838. '說' => '說',
  69839. '殺' => '殺',
  69840. '辰' => '辰',
  69841. '沈' => '沈',
  69842. '拾' => '拾',
  69843. '若' => '若',
  69844. '掠' => '掠',
  69845. '略' => '略',
  69846. '亮' => '亮',
  69847. '兩' => '兩',
  69848. '凉' => '凉',
  69849. '梁' => '�',
  69850. '糧' => '糧',
  69851. '良' => '良',
  69852. '諒' => '諒',
  69853. '量' => '�',
  69854. '勵' => '勵',
  69855. '呂' => '呂',
  69856. '�' => '女',
  69857. '廬' => '廬',
  69858. '旅' => '旅',
  69859. '濾' => '濾',
  69860. '礪' => '礪',
  69861. '閭' => '閭',
  69862. '驪' => '驪',
  69863. '麗' => '麗',
  69864. '黎' => '黎',
  69865. '力' => '力',
  69866. '曆' => '曆',
  69867. '歷' => '歷',
  69868. '�' => '轢',
  69869. '年' => '年',
  69870. '�' => '�',
  69871. '�' => '戀',
  69872. '撚' => '撚',
  69873. '漣' => '漣',
  69874. '煉' => '煉',
  69875. '璉' => '璉',
  69876. '秊' => '秊',
  69877. '練' => '練',
  69878. '聯' => '�',
  69879. '輦' => '輦',
  69880. '蓮' => '蓮',
  69881. '連' => '連',
  69882. '鍊' => '�',
  69883. '列' => '列',
  69884. '�' => '劣',
  69885. '咽' => '咽',
  69886. '烈' => '烈',
  69887. '裂' => '裂',
  69888. '說' => '說',
  69889. '廉' => '廉',
  69890. '念' => '念',
  69891. '捻' => '�',
  69892. '殮' => '殮',
  69893. '簾' => '簾',
  69894. '獵' => '�',
  69895. '令' => '令',
  69896. '囹' => '囹',
  69897. '寧' => '寧',
  69898. '嶺' => '嶺',
  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. '憎' => '憎',
  70035. '懲' => '懲',
  70036. '�' => '�',
  70037. 'ï©‚' => 'æ—¢',
  70038. '暑' => '暑',
  70039. '梅' => '梅',
  70040. 'ï©…' => 'æµ·',
  70041. '渚' => '渚',
  70042. '漢' => '漢',
  70043. '煮' => '煮',
  70044. '爫' => '爫',
  70045. '琢' => '�',
  70046. '碑' => '碑',
  70047. '社' => '社',
  70048. '�' => '祉',
  70049. '祈' => '祈',
  70050. '�' => '�',
  70051. '�' => '祖',
  70052. '祝' => '�',
  70053. '禍' => '�',
  70054. '禎' => '禎',
  70055. 'ï©”' => 'ç©€',
  70056. '突' => '�',
  70057. '節' => '節',
  70058. 'ï©—' => 'ç·´',
  70059. '縉' => '縉',
  70060. '繁' => '�',
  70061. '署' => '署',
  70062. '者' => '者',
  70063. '臭' => '臭',
  70064. '�' => '艹',
  70065. '艹' => '艹',
  70066. '著' => '著',
  70067. '褐' => '�',
  70068. '視' => '視',
  70069. '謁' => '�',
  70070. '謹' => '謹',
  70071. '賓' => '賓',
  70072. 'ï©¥' => 'è´ˆ',
  70073. '辶' => '辶',
  70074. '逸' => '逸',
  70075. '難' => '難',
  70076. '響' => '響',
  70077. '頻' => '頻',
  70078. '恵' => '�',
  70079. '𤋮' => '𤋮',
  70080. '舘' => '舘',
  70081. '並' => '並',
  70082. '况' => '况',
  70083. '全' => '全',
  70084. '侀' => '侀',
  70085. 'ï©´' => 'å……',
  70086. '冀' => '冀',
  70087. '勇' => '勇',
  70088. '勺' => '勺',
  70089. '喝' => '�',
  70090. '啕' => '啕',
  70091. '喙' => '喙',
  70092. 'ï©»' => 'å—¢',
  70093. '塚' => '塚',
  70094. '墳' => '墳',
  70095. '奄' => '奄',
  70096. '奔' => '奔',
  70097. '婢' => '婢',
  70098. '�' => '嬨',
  70099. '廒' => '廒',
  70100. '廙' => '廙',
  70101. '彩' => '彩',
  70102. '徭' => '徭',
  70103. '惘' => '惘',
  70104. '慎' => '慎',
  70105. '愈' => '愈',
  70106. '憎' => '憎',
  70107. '慠' => '慠',
  70108. '懲' => '懲',
  70109. '戴' => '戴',
  70110. '�' => '�',
  70111. '搜' => '�',
  70112. '�' => '摒',
  70113. '�' => '敖',
  70114. '晴' => '晴',
  70115. '朗' => '朗',
  70116. '望' => '望',
  70117. '杖' => '�',
  70118. '歹' => '歹',
  70119. '殺' => '殺',
  70120. '流' => '�',
  70121. '滛' => '滛',
  70122. '滋' => '滋',
  70123. '漢' => '漢',
  70124. '瀞' => '瀞',
  70125. '煮' => '煮',
  70126. '�' => '瞧',
  70127. '爵' => '爵',
  70128. '犯' => '犯',
  70129. '猪' => '猪',
  70130. '瑱' => '瑱',
  70131. '甆' => '甆',
  70132. '画' => '画',
  70133. '瘝' => '�',
  70134. '瘟' => '瘟',
  70135. '益' => '益',
  70136. '盛' => '盛',
  70137. '直' => '直',
  70138. '睊' => '�',
  70139. '着' => '�',
  70140. '磌' => '磌',
  70141. '窱' => '窱',
  70142. '節' => '節',
  70143. '类' => '类',
  70144. '絛' => '絛',
  70145. '練' => '練',
  70146. '缾' => '缾',
  70147. '者' => '者',
  70148. '荒' => '�',
  70149. '華' => '�',
  70150. '蝹' => '�',
  70151. '襁' => '�',
  70152. '覆' => '覆',
  70153. '視' => '視',
  70154. '調' => '調',
  70155. '諸' => '諸',
  70156. '請' => '請',
  70157. '謁' => '�',
  70158. '諾' => '諾',
  70159. '諭' => '諭',
  70160. '謹' => '謹',
  70161. '變' => '變',
  70162. '�' => '贈',
  70163. '輸' => '輸',
  70164. '遲' => '�',
  70165. '醙' => '醙',
  70166. '鉶' => '鉶',
  70167. '陼' => '陼',
  70168. '難' => '難',
  70169. '靖' => '�',
  70170. '韛' => '韛',
  70171. '響' => '響',
  70172. 'ï«‹' => 'é ‹',
  70173. '頻' => '頻',
  70174. '�' => '鬒',
  70175. '龜' => '龜',
  70176. '�' => '𢡊',
  70177. '�' => '𢡄',
  70178. '𣏕' => '�',
  70179. '㮝' => '�',
  70180. '䀘' => '䀘',
  70181. '䀹' => '䀹',
  70182. '𥉉' => '𥉉',
  70183. '𥳐' => '�',
  70184. '𧻓' => '𧻓',
  70185. '齃' => '齃',
  70186. '龎' => '龎',
  70187. '�' => 'יִ',
  70188. 'ײַ' => 'ײַ',
  70189. 'שׁ' => 'ש�',
  70190. 'שׂ' => 'שׂ',
  70191. 'שּׁ' => 'שּ�',
  70192. 'שּׂ' => 'שּׂ',
  70193. 'אַ' => '�ַ',
  70194. 'אָ' => '�ָ',
  70195. 'אּ' => '�ּ',
  70196. 'בּ' => 'בּ',
  70197. 'גּ' => 'גּ',
  70198. 'דּ' => 'דּ',
  70199. 'הּ' => 'הּ',
  70200. 'וּ' => 'וּ',
  70201. 'זּ' => 'זּ',
  70202. 'טּ' => 'טּ',
  70203. 'יּ' => 'יּ',
  70204. 'ךּ' => 'ךּ',
  70205. 'כּ' => 'כּ',
  70206. 'לּ' => 'לּ',
  70207. 'מּ' => 'מּ',
  70208. 'ï­€' => '× Ö¼',
  70209. '�' => 'סּ',
  70210. 'ï­ƒ' => '×£Ö¼',
  70211. 'פּ' => 'פּ',
  70212. 'צּ' => 'צּ',
  70213. 'ï­‡' => '×§Ö¼',
  70214. 'רּ' => 'רּ',
  70215. 'שּ' => 'שּ',
  70216. 'תּ' => 'תּ',
  70217. 'וֹ' => 'וֹ',
  70218. 'בֿ' => 'בֿ',
  70219. 'ï­�' => '×›Ö¿',
  70220. 'פֿ' => 'פֿ',
  70221. '𑂚' => '𑂚',
  70222. '𑂜' => '𑂜',
  70223. '𑂫' => '𑂫',
  70224. '𑄮' => '𑄮',
  70225. '𑄯' => '𑄯',
  70226. '�' => '�𑌾',
  70227. '�' => '��',
  70228. '𑒻' => '𑒻',
  70229. '𑒼' => '𑒼',
  70230. '𑒾' => '𑒾',
  70231. '𑖺' => '𑖺',
  70232. '𑖻' => '𑖻',
  70233. '𑤸' => '𑤸',
  70234. '�' => '��',
  70235. '�' => '��',
  70236. '�' => '���',
  70237. '�' => '���',
  70238. '�' => '���',
  70239. '�' => '���',
  70240. '�' => '���',
  70241. '�' => '��',
  70242. '�' => '��',
  70243. '�' => '���',
  70244. '�' => '���',
  70245. '�' => '���',
  70246. '�' => '���',
  70247. '丽' => '丽',
  70248. '�' => '丸',
  70249. '乁' => '�',
  70250. '𠄢' => '𠄢',
  70251. '你' => '你',
  70252. '侮' => '侮',
  70253. '侻' => '侻',
  70254. '倂' => '倂',
  70255. '偺' => '�',
  70256. '備' => '備',
  70257. '僧' => '僧',
  70258. '像' => '�',
  70259. '㒞' => '㒞',
  70260. '�' => '𠘺',
  70261. '免' => '�',
  70262. '�' => '兔',
  70263. '�' => '兤',
  70264. '具' => '具',
  70265. '𠔜' => '𠔜',
  70266. '㒹' => '㒹',
  70267. '內' => '內',
  70268. '再' => '�',
  70269. '𠕋' => '𠕋',
  70270. '冗' => '冗',
  70271. '冤' => '冤',
  70272. '仌' => '仌',
  70273. '冬' => '冬',
  70274. '况' => '况',
  70275. '𩇟' => '𩇟',
  70276. '�' => '凵',
  70277. '刃' => '刃',
  70278. '㓟' => '㓟',
  70279. '刻' => '刻',
  70280. '剆' => '剆',
  70281. '割' => '割',
  70282. '剷' => '剷',
  70283. '㔕' => '㔕',
  70284. '勇' => '勇',
  70285. '勉' => '勉',
  70286. '勤' => '勤',
  70287. '勺' => '勺',
  70288. '包' => '包',
  70289. '匆' => '匆',
  70290. '北' => '北',
  70291. '卉' => '�',
  70292. '卑' => '�',
  70293. '博' => '�',
  70294. '即' => '�',
  70295. '卽' => '�',
  70296. '卿' => '�',
  70297. '卿' => '�',
  70298. '卿' => '�',
  70299. '𠨬' => '𠨬',
  70300. '灰' => '�',
  70301. '及' => '�',
  70302. '叟' => '�',
  70303. '𠭣' => '𠭣',
  70304. '叫' => '�',
  70305. '叱' => '�',
  70306. '吆' => '�',
  70307. '咞' => '咞',
  70308. '吸' => '�',
  70309. '呈' => '呈',
  70310. '周' => '周',
  70311. '咢' => '咢',
  70312. '�' => '哶',
  70313. '唐' => '�',
  70314. '啓' => '啓',
  70315. '啣' => '啣',
  70316. '善' => '善',
  70317. '善' => '善',
  70318. '喙' => '喙',
  70319. '喫' => '喫',
  70320. '喳' => '喳',
  70321. '嗂' => '嗂',
  70322. '圖' => '圖',
  70323. '嘆' => '嘆',
  70324. '�' => '圗',
  70325. '噑' => '噑',
  70326. '�' => '噴',
  70327. '�' => '切',
  70328. '壮' => '壮',
  70329. '城' => '城',
  70330. '埴' => '埴',
  70331. '堍' => '�',
  70332. '型' => '型',
  70333. '堲' => '堲',
  70334. '報' => '報',
  70335. '墬' => '墬',
  70336. '𡓤' => '𡓤',
  70337. '売' => '売',
  70338. '壷' => '壷',
  70339. '夆' => '夆',
  70340. '�' => '多',
  70341. '夢' => '夢',
  70342. '奢' => '奢',
  70343. '𡚨' => '𡚨',
  70344. '𡛪' => '𡛪',
  70345. '姬' => '姬',
  70346. '娛' => '娛',
  70347. '娧' => '娧',
  70348. '姘' => '姘',
  70349. '婦' => '婦',
  70350. '㛮' => '㛮',
  70351. '㛼' => '㛼',
  70352. '嬈' => '嬈',
  70353. '嬾' => '嬾',
  70354. '嬾' => '嬾',
  70355. '𡧈' => '𡧈',
  70356. '寃' => '寃',
  70357. '寘' => '寘',
  70358. '寧' => '寧',
  70359. '寳' => '寳',
  70360. '𡬘' => '𡬘',
  70361. '寿' => '寿',
  70362. '将' => '将',
  70363. '当' => '当',
  70364. '尢' => '尢',
  70365. '㞁' => '�',
  70366. '屠' => '屠',
  70367. '屮' => '屮',
  70368. '峀' => '峀',
  70369. '岍' => '�',
  70370. '𡷤' => '𡷤',
  70371. '嵃' => '嵃',
  70372. '𡷦' => '𡷦',
  70373. '嵮' => '嵮',
  70374. '嵫' => '嵫',
  70375. '嵼' => '嵼',
  70376. '�' => '巡',
  70377. '巢' => '巢',
  70378. '㠯' => '㠯',
  70379. '巽' => '巽',
  70380. '帨' => '帨',
  70381. '帽' => '帽',
  70382. '幩' => '幩',
  70383. '㡢' => '㡢',
  70384. '𢆃' => '𢆃',
  70385. '㡼' => '㡼',
  70386. '庰' => '庰',
  70387. '庳' => '庳',
  70388. '�' => '庶',
  70389. '廊' => '廊',
  70390. '�' => '𪎒',
  70391. '�' => '廾',
  70392. '𢌱' => '𢌱',
  70393. '𢌱' => '𢌱',
  70394. '舁' => '�',
  70395. '弢' => '弢',
  70396. '弢' => '弢',
  70397. '㣇' => '㣇',
  70398. '𣊸' => '𣊸',
  70399. '𦇚' => '𦇚',
  70400. '形' => '形',
  70401. '彫' => '彫',
  70402. '㣣' => '㣣',
  70403. '徚' => '徚',
  70404. '�' => '�',
  70405. '志' => '志',
  70406. '忹' => '忹',
  70407. '悁' => '�',
  70408. '㤺' => '㤺',
  70409. '㤜' => '㤜',
  70410. '悔' => '悔',
  70411. '𢛔' => '𢛔',
  70412. '惇' => '惇',
  70413. '慈' => '慈',
  70414. '慌' => '慌',
  70415. '慎' => '慎',
  70416. '慌' => '慌',
  70417. '慺' => '慺',
  70418. '憎' => '憎',
  70419. '憲' => '憲',
  70420. '憤' => '憤',
  70421. '憯' => '憯',
  70422. '懞' => '懞',
  70423. '懲' => '懲',
  70424. '懶' => '懶',
  70425. '成' => '�',
  70426. '戛' => '戛',
  70427. '扝' => '�',
  70428. '抱' => '抱',
  70429. '拔' => '拔',
  70430. '捐' => '�',
  70431. '𢬌' => '𢬌',
  70432. '挽' => '挽',
  70433. '拼' => '拼',
  70434. '捨' => '�',
  70435. '掃' => '掃',
  70436. '揤' => '�',
  70437. '𢯱' => '𢯱',
  70438. '搢' => '�',
  70439. '揅' => '�',
  70440. '�' => '掩',
  70441. '㨮' => '㨮',
  70442. '摩' => '摩',
  70443. '摾' => '摾',
  70444. '撝' => '�',
  70445. '摷' => '摷',
  70446. '㩬' => '㩬',
  70447. '敏' => '�',
  70448. '敬' => '敬',
  70449. '𣀊' => '𣀊',
  70450. '旣' => '旣',
  70451. '書' => '書',
  70452. '�' => '晉',
  70453. '㬙' => '㬙',
  70454. '�' => '暑',
  70455. '�' => '㬈',
  70456. '㫤' => '㫤',
  70457. '冒' => '冒',
  70458. '冕' => '冕',
  70459. '最' => '最',
  70460. '暜' => '暜',
  70461. '肭' => '肭',
  70462. '䏙' => '�',
  70463. '朗' => '朗',
  70464. '望' => '望',
  70465. '朡' => '朡',
  70466. '杞' => '�',
  70467. '杓' => '�',
  70468. '�' => '�',
  70469. '㭉' => '㭉',
  70470. '柺' => '柺',
  70471. '枅' => '枅',
  70472. '桒' => '桒',
  70473. '梅' => '梅',
  70474. '𣑭' => '𣑭',
  70475. '梎' => '梎',
  70476. '栟' => '栟',
  70477. '椔' => '椔',
  70478. '㮝' => '�',
  70479. '楂' => '楂',
  70480. '榣' => '榣',
  70481. '槪' => '槪',
  70482. '檨' => '檨',
  70483. '𣚣' => '𣚣',
  70484. '櫛' => '櫛',
  70485. '㰘' => '㰘',
  70486. '次' => '次',
  70487. '𣢧' => '𣢧',
  70488. '歔' => '歔',
  70489. '㱎' => '㱎',
  70490. '歲' => '歲',
  70491. '殟' => '殟',
  70492. '殺' => '殺',
  70493. '殻' => '殻',
  70494. '𣪍' => '�',
  70495. '𡴋' => '𡴋',
  70496. '𣫺' => '𣫺',
  70497. '汎' => '汎',
  70498. '𣲼' => '𣲼',
  70499. '沿' => '沿',
  70500. '泍' => '�',
  70501. '汧' => '汧',
  70502. '洖' => '洖',
  70503. '派' => '派',
  70504. '�' => '海',
  70505. '流' => '�',
  70506. '浩' => '浩',
  70507. '浸' => '浸',
  70508. '涅' => '涅',
  70509. '𣴞' => '𣴞',
  70510. '洴' => '洴',
  70511. '港' => '港',
  70512. '湮' => '湮',
  70513. '㴳' => '㴳',
  70514. '滋' => '滋',
  70515. '滇' => '滇',
  70516. '�' => '𣻑',
  70517. '淹' => '淹',
  70518. '�' => '潮',
  70519. '�' => '𣽞',
  70520. '𣾎' => '𣾎',
  70521. '濆' => '濆',
  70522. '瀹' => '瀹',
  70523. '瀞' => '瀞',
  70524. '瀛' => '瀛',
  70525. '㶖' => '㶖',
  70526. '灊' => '�',
  70527. '災' => '�',
  70528. '灷' => '�',
  70529. '炭' => '炭',
  70530. '𠔥' => '𠔥',
  70531. '煅' => '煅',
  70532. '�' => '𤉣',
  70533. '熜' => '熜',
  70534. '𤎫' => '𤎫',
  70535. '爨' => '爨',
  70536. '爵' => '爵',
  70537. '牐' => '�',
  70538. '𤘈' => '𤘈',
  70539. '犀' => '犀',
  70540. '犕' => '犕',
  70541. '𤜵' => '𤜵',
  70542. '𤠔' => '𤠔',
  70543. '獺' => '�',
  70544. '王' => '王',
  70545. '㺬' => '㺬',
  70546. '玥' => '玥',
  70547. '㺸' => '㺸',
  70548. '㺸' => '㺸',
  70549. '瑇' => '瑇',
  70550. '瑜' => '瑜',
  70551. '瑱' => '瑱',
  70552. '璅' => '璅',
  70553. '瓊' => '瓊',
  70554. '㼛' => '㼛',
  70555. '甤' => '甤',
  70556. '𤰶' => '𤰶',
  70557. '甾' => '甾',
  70558. '𤲒' => '𤲒',
  70559. '異' => '異',
  70560. '𢆟' => '𢆟',
  70561. '瘐' => '�',
  70562. '𤾡' => '𤾡',
  70563. '𤾸' => '𤾸',
  70564. '𥁄' => '�',
  70565. '㿼' => '㿼',
  70566. '䀈' => '䀈',
  70567. '直' => '直',
  70568. '�' => '𥃳',
  70569. '𥃲' => '𥃲',
  70570. '𥄙' => '𥄙',
  70571. '𥄳' => '𥄳',
  70572. '眞' => '眞',
  70573. '真' => '真',
  70574. '真' => '真',
  70575. '睊' => '�',
  70576. '䀹' => '䀹',
  70577. '瞋' => '瞋',
  70578. '䁆' => '�',
  70579. '䂖' => '䂖',
  70580. '�' => '�',
  70581. '硎' => '硎',
  70582. '�' => '碌',
  70583. '�' => '磌',
  70584. '䃣' => '䃣',
  70585. '𥘦' => '𥘦',
  70586. '祖' => '祖',
  70587. '𥚚' => '𥚚',
  70588. '𥛅' => '𥛅',
  70589. '福' => '�',
  70590. '秫' => '秫',
  70591. '䄯' => '䄯',
  70592. '穀' => '穀',
  70593. '穊' => '穊',
  70594. '穏' => '�',
  70595. '𥥼' => '𥥼',
  70596. '�' => '𥪧',
  70597. '𥪧' => '𥪧',
  70598. '竮' => '竮',
  70599. '䈂' => '䈂',
  70600. '𥮫' => '𥮫',
  70601. '篆' => '篆',
  70602. '築' => '築',
  70603. '䈧' => '䈧',
  70604. '𥲀' => '𥲀',
  70605. '糒' => '糒',
  70606. '䊠' => '䊠',
  70607. '糨' => '糨',
  70608. '糣' => '糣',
  70609. '紀' => '紀',
  70610. '𥾆' => '𥾆',
  70611. '絣' => '絣',
  70612. '䌁' => '�',
  70613. '緇' => '緇',
  70614. '縂' => '縂',
  70615. '繅' => '繅',
  70616. '䌴' => '䌴',
  70617. '𦈨' => '𦈨',
  70618. '𦉇' => '𦉇',
  70619. '䍙' => '�',
  70620. '𦋙' => '𦋙',
  70621. '罺' => '罺',
  70622. '𦌾' => '𦌾',
  70623. '羕' => '羕',
  70624. '翺' => '翺',
  70625. '者' => '者',
  70626. '𦓚' => '𦓚',
  70627. '𦔣' => '𦔣',
  70628. '聠' => '�',
  70629. '𦖨' => '𦖨',
  70630. '聰' => '�',
  70631. '𣍟' => '�',
  70632. '�' => '�',
  70633. '育' => '育',
  70634. '脃' => '脃',
  70635. '䐋' => '�',
  70636. '脾' => '脾',
  70637. '媵' => '媵',
  70638. '𦞧' => '𦞧',
  70639. '𦞵' => '𦞵',
  70640. '𣎓' => '𣎓',
  70641. '𣎜' => '𣎜',
  70642. '舁' => '�',
  70643. '舄' => '舄',
  70644. '�' => '辞',
  70645. '䑫' => '䑫',
  70646. '�' => '芑',
  70647. '�' => '芋',
  70648. '芝' => '�',
  70649. '劳' => '劳',
  70650. '花' => '花',
  70651. '芳' => '芳',
  70652. '芽' => '芽',
  70653. '苦' => '苦',
  70654. '𦬼' => '𦬼',
  70655. '若' => '若',
  70656. '茝' => '�',
  70657. '荣' => '�',
  70658. '莭' => '莭',
  70659. '茣' => '茣',
  70660. '�' => '莽',
  70661. '菧' => '�',
  70662. '著' => '著',
  70663. '荓' => '�',
  70664. '菊' => '�',
  70665. '菌' => '�',
  70666. '菜' => '�',
  70667. '𦰶' => '𦰶',
  70668. '𦵫' => '𦵫',
  70669. '𦳕' => '𦳕',
  70670. '䔫' => '䔫',
  70671. '蓱' => '蓱',
  70672. '蓳' => '蓳',
  70673. '蔖' => '蔖',
  70674. '𧏊' => '�',
  70675. '蕤' => '蕤',
  70676. '𦼬' => '𦼬',
  70677. '䕝' => '�',
  70678. '䕡' => '䕡',
  70679. '𦾱' => '𦾱',
  70680. '𧃒' => '𧃒',
  70681. '䕫' => '䕫',
  70682. '虐' => '�',
  70683. '虜' => '虜',
  70684. '虧' => '虧',
  70685. '虩' => '虩',
  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. <?php
  70791. return array (
  70792. 'Ì€' => 230,
  70793. '�' => 230,
  70794. 'Ì‚' => 230,
  70795. '̃' => 230,
  70796. 'Ì„' => 230,
  70797. 'Ì…' => 230,
  70798. '̆' => 230,
  70799. '̇' => 230,
  70800. '̈' => 230,
  70801. '̉' => 230,
  70802. 'ÌŠ' => 230,
  70803. 'Ì‹' => 230,
  70804. '̌' => 230,
  70805. '�' => 230,
  70806. 'ÌŽ' => 230,
  70807. '�' => 230,
  70808. '�' => 230,
  70809. 'Ì‘' => 230,
  70810. 'Ì’' => 230,
  70811. 'Ì“' => 230,
  70812. 'Ì”' => 230,
  70813. 'Ì•' => 232,
  70814. 'Ì–' => 220,
  70815. 'Ì—' => 220,
  70816. '̘' => 220,
  70817. 'Ì™' => 220,
  70818. 'Ìš' => 232,
  70819. 'Ì›' => 216,
  70820. '̜' => 220,
  70821. '�' => 220,
  70822. 'Ìž' => 220,
  70823. 'ÌŸ' => 220,
  70824. 'Ì ' => 220,
  70825. 'Ì¡' => 202,
  70826. 'Ì¢' => 202,
  70827. 'Ì£' => 220,
  70828. '̤' => 220,
  70829. 'Ì¥' => 220,
  70830. '̦' => 220,
  70831. '̧' => 202,
  70832. '̨' => 202,
  70833. 'Ì©' => 220,
  70834. '̪' => 220,
  70835. 'Ì«' => 220,
  70836. '̬' => 220,
  70837. 'Ì­' => 220,
  70838. 'Ì®' => 220,
  70839. '̯' => 220,
  70840. '̰' => 220,
  70841. '̱' => 220,
  70842. '̲' => 220,
  70843. '̳' => 220,
  70844. 'Ì´' => 1,
  70845. '̵' => 1,
  70846. '̶' => 1,
  70847. 'Ì·' => 1,
  70848. '̸' => 1,
  70849. '̹' => 220,
  70850. '̺' => 220,
  70851. 'Ì»' => 220,
  70852. '̼' => 220,
  70853. '̽' => 230,
  70854. '̾' => 230,
  70855. 'Ì¿' => 230,
  70856. 'Í€' => 230,
  70857. '�' => 230,
  70858. 'Í‚' => 230,
  70859. '̓' => 230,
  70860. 'Í„' => 230,
  70861. 'Í…' => 240,
  70862. '͆' => 230,
  70863. '͇' => 220,
  70864. '͈' => 220,
  70865. '͉' => 220,
  70866. 'ÍŠ' => 230,
  70867. 'Í‹' => 230,
  70868. '͌' => 230,
  70869. '�' => 220,
  70870. 'ÍŽ' => 220,
  70871. '�' => 230,
  70872. 'Í‘' => 230,
  70873. 'Í’' => 230,
  70874. 'Í“' => 220,
  70875. 'Í”' => 220,
  70876. 'Í•' => 220,
  70877. 'Í–' => 220,
  70878. 'Í—' => 230,
  70879. '͘' => 232,
  70880. 'Í™' => 220,
  70881. 'Íš' => 220,
  70882. 'Í›' => 230,
  70883. '͜' => 233,
  70884. '�' => 234,
  70885. 'Íž' => 234,
  70886. 'ÍŸ' => 233,
  70887. 'Í ' => 234,
  70888. 'Í¡' => 234,
  70889. 'Í¢' => 233,
  70890. 'Í£' => 230,
  70891. 'ͤ' => 230,
  70892. 'Í¥' => 230,
  70893. 'ͦ' => 230,
  70894. 'ͧ' => 230,
  70895. 'ͨ' => 230,
  70896. 'Í©' => 230,
  70897. 'ͪ' => 230,
  70898. 'Í«' => 230,
  70899. 'ͬ' => 230,
  70900. 'Í­' => 230,
  70901. 'Í®' => 230,
  70902. 'ͯ' => 230,
  70903. 'Òƒ' => 230,
  70904. 'Ò„' => 230,
  70905. 'Ò…' => 230,
  70906. 'Ò†' => 230,
  70907. 'Ò‡' => 230,
  70908. 'Ö‘' => 220,
  70909. 'Ö’' => 230,
  70910. 'Ö“' => 230,
  70911. 'Ö”' => 230,
  70912. 'Ö•' => 230,
  70913. 'Ö–' => 220,
  70914. 'Ö—' => 230,
  70915. 'Ö˜' => 230,
  70916. 'Ö™' => 230,
  70917. 'Öš' => 222,
  70918. 'Ö›' => 220,
  70919. '֜' => 230,
  70920. 'Ö�' => 230,
  70921. 'Öž' => 230,
  70922. 'ÖŸ' => 230,
  70923. 'Ö ' => 230,
  70924. 'Ö¡' => 230,
  70925. 'Ö¢' => 220,
  70926. 'Ö£' => 220,
  70927. 'Ö¤' => 220,
  70928. 'Ö¥' => 220,
  70929. 'Ö¦' => 220,
  70930. 'Ö§' => 220,
  70931. 'Ö¨' => 230,
  70932. 'Ö©' => 230,
  70933. 'Öª' => 220,
  70934. 'Ö«' => 230,
  70935. 'Ö¬' => 230,
  70936. 'Ö­' => 222,
  70937. 'Ö®' => 228,
  70938. 'Ö¯' => 230,
  70939. 'Ö°' => 10,
  70940. 'Ö±' => 11,
  70941. 'Ö²' => 12,
  70942. 'Ö³' => 13,
  70943. 'Ö´' => 14,
  70944. 'Öµ' => 15,
  70945. 'Ö¶' => 16,
  70946. 'Ö·' => 17,
  70947. 'Ö¸' => 18,
  70948. 'Ö¹' => 19,
  70949. 'Öº' => 19,
  70950. 'Ö»' => 20,
  70951. 'Ö¼' => 21,
  70952. 'Ö½' => 22,
  70953. 'Ö¿' => 23,
  70954. '�' => 24,
  70955. 'ׂ' => 25,
  70956. 'ׄ' => 230,
  70957. '×…' => 220,
  70958. 'ׇ' => 18,
  70959. '�' => 230,
  70960. 'Ø‘' => 230,
  70961. 'Ø’' => 230,
  70962. 'Ø“' => 230,
  70963. 'Ø”' => 230,
  70964. 'Ø•' => 230,
  70965. 'Ø–' => 230,
  70966. 'Ø—' => 230,
  70967. 'ؘ' => 30,
  70968. 'Ø™' => 31,
  70969. 'Øš' => 32,
  70970. 'Ù‹' => 27,
  70971. 'ٌ' => 28,
  70972. 'Ù�' => 29,
  70973. 'ÙŽ' => 30,
  70974. 'Ù�' => 31,
  70975. 'Ù�' => 32,
  70976. 'Ù‘' => 33,
  70977. 'Ù’' => 34,
  70978. 'Ù“' => 230,
  70979. 'Ù”' => 230,
  70980. 'Ù•' => 220,
  70981. 'Ù–' => 220,
  70982. 'Ù—' => 230,
  70983. 'Ù˜' => 230,
  70984. 'Ù™' => 230,
  70985. 'Ùš' => 230,
  70986. 'Ù›' => 230,
  70987. 'ٜ' => 220,
  70988. 'Ù�' => 230,
  70989. 'Ùž' => 230,
  70990. 'ÙŸ' => 220,
  70991. 'Ù°' => 35,
  70992. 'Û–' => 230,
  70993. 'Û—' => 230,
  70994. 'Û˜' => 230,
  70995. 'Û™' => 230,
  70996. 'Ûš' => 230,
  70997. 'Û›' => 230,
  70998. 'ۜ' => 230,
  70999. 'ÛŸ' => 230,
  71000. 'Û ' => 230,
  71001. 'Û¡' => 230,
  71002. 'Û¢' => 230,
  71003. 'Û£' => 220,
  71004. 'Û¤' => 230,
  71005. 'Û§' => 230,
  71006. 'Û¨' => 230,
  71007. 'Ûª' => 220,
  71008. 'Û«' => 230,
  71009. 'Û¬' => 230,
  71010. 'Û­' => 220,
  71011. 'Ü‘' => 36,
  71012. 'ܰ' => 230,
  71013. 'ܱ' => 220,
  71014. 'ܲ' => 230,
  71015. 'ܳ' => 230,
  71016. 'Ü´' => 220,
  71017. 'ܵ' => 230,
  71018. 'ܶ' => 230,
  71019. 'Ü·' => 220,
  71020. 'ܸ' => 220,
  71021. 'ܹ' => 220,
  71022. 'ܺ' => 230,
  71023. 'Ü»' => 220,
  71024. 'ܼ' => 220,
  71025. 'ܽ' => 230,
  71026. 'ܾ' => 220,
  71027. 'Ü¿' => 230,
  71028. 'Ý€' => 230,
  71029. '�' => 230,
  71030. 'Ý‚' => 220,
  71031. '݃' => 230,
  71032. 'Ý„' => 220,
  71033. 'Ý…' => 230,
  71034. '݆' => 220,
  71035. '݇' => 230,
  71036. '݈' => 220,
  71037. '݉' => 230,
  71038. 'ÝŠ' => 230,
  71039. 'ß«' => 230,
  71040. '߬' => 230,
  71041. 'ß­' => 230,
  71042. 'ß®' => 230,
  71043. '߯' => 230,
  71044. 'ß°' => 230,
  71045. 'ß±' => 230,
  71046. 'ß²' => 220,
  71047. 'ß³' => 230,
  71048. 'ß½' => 220,
  71049. 'à –' => 230,
  71050. 'à —' => 230,
  71051. 'à ˜' => 230,
  71052. 'à ™' => 230,
  71053. 'à ›' => 230,
  71054. 'ࠜ' => 230,
  71055. 'à �' => 230,
  71056. 'à ž' => 230,
  71057. 'à Ÿ' => 230,
  71058. 'à  ' => 230,
  71059. 'à ¡' => 230,
  71060. 'à ¢' => 230,
  71061. 'à £' => 230,
  71062. 'à ¥' => 230,
  71063. 'à ¦' => 230,
  71064. 'à §' => 230,
  71065. 'à ©' => 230,
  71066. 'à ª' => 230,
  71067. 'à «' => 230,
  71068. 'à ¬' => 230,
  71069. 'à ­' => 230,
  71070. 'à¡™' => 220,
  71071. '࡚' => 220,
  71072. 'à¡›' => 220,
  71073. '࣓' => 220,
  71074. 'ࣔ' => 230,
  71075. 'ࣕ' => 230,
  71076. 'ࣖ' => 230,
  71077. 'ࣗ' => 230,
  71078. 'ࣘ' => 230,
  71079. 'ࣙ' => 230,
  71080. 'ࣚ' => 230,
  71081. 'ࣛ' => 230,
  71082. 'ࣜ' => 230,
  71083. '�' => 230,
  71084. 'ࣞ' => 230,
  71085. 'ࣟ' => 230,
  71086. '࣠' => 230,
  71087. '࣡' => 230,
  71088. 'ࣣ' => 220,
  71089. 'ࣤ' => 230,
  71090. 'ࣥ' => 230,
  71091. 'ࣦ' => 220,
  71092. 'ࣧ' => 230,
  71093. 'ࣨ' => 230,
  71094. 'ࣩ' => 220,
  71095. '࣪' => 230,
  71096. '࣫' => 230,
  71097. '࣬' => 230,
  71098. '࣭' => 220,
  71099. '࣮' => 220,
  71100. '࣯' => 220,
  71101. 'ࣰ' => 27,
  71102. 'ࣱ' => 28,
  71103. 'ࣲ' => 29,
  71104. 'ࣳ' => 230,
  71105. 'ࣴ' => 230,
  71106. 'ࣵ' => 230,
  71107. 'ࣶ' => 220,
  71108. 'ࣷ' => 230,
  71109. 'ࣸ' => 230,
  71110. 'ࣹ' => 220,
  71111. 'ࣺ' => 220,
  71112. 'ࣻ' => 230,
  71113. 'ࣼ' => 230,
  71114. 'ࣽ' => 230,
  71115. 'ࣾ' => 230,
  71116. 'ࣿ' => 230,
  71117. '़' => 7,
  71118. '�' => 9,
  71119. '॑' => 230,
  71120. '॒' => 220,
  71121. '॓' => 230,
  71122. '॔' => 230,
  71123. '়' => 7,
  71124. '�' => 9,
  71125. 'à§¾' => 230,
  71126. '਼' => 7,
  71127. '�' => 9,
  71128. '઼' => 7,
  71129. '�' => 9,
  71130. '଼' => 7,
  71131. 'à­�' => 9,
  71132. '�' => 9,
  71133. '�' => 9,
  71134. 'ౕ' => 84,
  71135. 'à±–' => 91,
  71136. '಼' => 7,
  71137. '�' => 9,
  71138. 'à´»' => 9,
  71139. 'à´¼' => 9,
  71140. '�' => 9,
  71141. 'à·Š' => 9,
  71142. 'ุ' => 103,
  71143. 'ู' => 103,
  71144. 'ฺ' => 9,
  71145. '่' => 107,
  71146. '้' => 107,
  71147. '๊' => 107,
  71148. '๋' => 107,
  71149. 'ຸ' => 118,
  71150. 'ູ' => 118,
  71151. '຺' => 9,
  71152. '່' => 122,
  71153. '້' => 122,
  71154. '໊' => 122,
  71155. '໋' => 122,
  71156. '༘' => 220,
  71157. '༙' => 220,
  71158. '༵' => 220,
  71159. '༷' => 220,
  71160. '༹' => 216,
  71161. 'ཱ' => 129,
  71162. 'ི' => 130,
  71163. 'ུ' => 132,
  71164. 'ེ' => 130,
  71165. 'ཻ' => 130,
  71166. 'ོ' => 130,
  71167. 'ཽ' => 130,
  71168. 'ྀ' => 130,
  71169. 'ྂ' => 230,
  71170. 'ྃ' => 230,
  71171. '྄' => 9,
  71172. '྆' => 230,
  71173. '྇' => 230,
  71174. '࿆' => 220,
  71175. '့' => 7,
  71176. '္' => 9,
  71177. '်' => 9,
  71178. '�' => 220,
  71179. '�' => 230,
  71180. '�' => 230,
  71181. '�' => 230,
  71182. '᜔' => 9,
  71183. '᜴' => 9,
  71184. '្' => 9,
  71185. '�' => 230,
  71186. 'ᢩ' => 228,
  71187. '᤹' => 222,
  71188. '᤺' => 230,
  71189. '᤻' => 220,
  71190. 'ᨗ' => 230,
  71191. 'ᨘ' => 220,
  71192. 'á© ' => 9,
  71193. '᩵' => 230,
  71194. 'á©¶' => 230,
  71195. 'á©·' => 230,
  71196. '᩸' => 230,
  71197. '᩹' => 230,
  71198. '᩺' => 230,
  71199. 'á©»' => 230,
  71200. '᩼' => 230,
  71201. 'á©¿' => 220,
  71202. '᪰' => 230,
  71203. '᪱' => 230,
  71204. '᪲' => 230,
  71205. '᪳' => 230,
  71206. '᪴' => 230,
  71207. '᪵' => 220,
  71208. '᪶' => 220,
  71209. '᪷' => 220,
  71210. '᪸' => 220,
  71211. '᪹' => 220,
  71212. '᪺' => 220,
  71213. '᪻' => 230,
  71214. '᪼' => 230,
  71215. '᪽' => 220,
  71216. 'ᪿ' => 220,
  71217. 'á«€' => 220,
  71218. '᬴' => 7,
  71219. 'á­„' => 9,
  71220. 'á­«' => 230,
  71221. 'á­¬' => 220,
  71222. 'á­­' => 230,
  71223. 'á­®' => 230,
  71224. 'á­¯' => 230,
  71225. 'á­°' => 230,
  71226. 'á­±' => 230,
  71227. 'á­²' => 230,
  71228. 'á­³' => 230,
  71229. '᮪' => 9,
  71230. '᮫' => 9,
  71231. '᯦' => 7,
  71232. '᯲' => 9,
  71233. '᯳' => 9,
  71234. 'á°·' => 7,
  71235. '�' => 230,
  71236. '᳑' => 230,
  71237. 'á³’' => 230,
  71238. 'á³”' => 1,
  71239. '᳕' => 220,
  71240. 'á³–' => 220,
  71241. 'á³—' => 220,
  71242. '᳘' => 220,
  71243. 'á³™' => 220,
  71244. '᳚' => 230,
  71245. 'á³›' => 230,
  71246. '᳜' => 220,
  71247. '�' => 220,
  71248. '᳞' => 220,
  71249. '᳟' => 220,
  71250. 'á³ ' => 230,
  71251. 'á³¢' => 1,
  71252. 'á³£' => 1,
  71253. '᳤' => 1,
  71254. 'á³¥' => 1,
  71255. '᳦' => 1,
  71256. 'á³§' => 1,
  71257. '᳨' => 1,
  71258. 'á³­' => 220,
  71259. 'á³´' => 230,
  71260. '᳸' => 230,
  71261. 'á³¹' => 230,
  71262. 'á·€' => 230,
  71263. 'á·�' => 230,
  71264. 'á·‚' => 220,
  71265. 'á·ƒ' => 230,
  71266. 'á·„' => 230,
  71267. 'á·…' => 230,
  71268. 'á·†' => 230,
  71269. 'á·‡' => 230,
  71270. 'á·ˆ' => 230,
  71271. 'á·‰' => 230,
  71272. 'á·Š' => 220,
  71273. 'á·‹' => 230,
  71274. '᷌' => 230,
  71275. 'á·�' => 234,
  71276. 'á·Ž' => 214,
  71277. 'á·�' => 220,
  71278. 'á·�' => 202,
  71279. 'á·‘' => 230,
  71280. 'á·’' => 230,
  71281. 'á·“' => 230,
  71282. 'á·”' => 230,
  71283. 'á·•' => 230,
  71284. 'á·–' => 230,
  71285. 'á·—' => 230,
  71286. 'á·˜' => 230,
  71287. 'á·™' => 230,
  71288. 'á·š' => 230,
  71289. 'á·›' => 230,
  71290. 'ᷜ' => 230,
  71291. 'á·�' => 230,
  71292. 'á·ž' => 230,
  71293. 'á·Ÿ' => 230,
  71294. 'á· ' => 230,
  71295. 'á·¡' => 230,
  71296. 'á·¢' => 230,
  71297. 'á·£' => 230,
  71298. 'á·¤' => 230,
  71299. 'á·¥' => 230,
  71300. 'á·¦' => 230,
  71301. 'á·§' => 230,
  71302. 'á·¨' => 230,
  71303. 'á·©' => 230,
  71304. 'á·ª' => 230,
  71305. 'á·«' => 230,
  71306. 'á·¬' => 230,
  71307. 'á·­' => 230,
  71308. 'á·®' => 230,
  71309. 'á·¯' => 230,
  71310. 'á·°' => 230,
  71311. 'á·±' => 230,
  71312. 'á·²' => 230,
  71313. 'á·³' => 230,
  71314. 'á·´' => 230,
  71315. 'á·µ' => 230,
  71316. 'á·¶' => 232,
  71317. 'á··' => 228,
  71318. 'á·¸' => 228,
  71319. 'á·¹' => 220,
  71320. 'á·»' => 230,
  71321. 'á·¼' => 233,
  71322. 'á·½' => 220,
  71323. 'á·¾' => 230,
  71324. 'á·¿' => 220,
  71325. '�' => 230,
  71326. '⃑' => 230,
  71327. '⃒' => 1,
  71328. '⃓' => 1,
  71329. '⃔' => 230,
  71330. '⃕' => 230,
  71331. '⃖' => 230,
  71332. '⃗' => 230,
  71333. '⃘' => 1,
  71334. '⃙' => 1,
  71335. '⃚' => 1,
  71336. '⃛' => 230,
  71337. '⃜' => 230,
  71338. '⃡' => 230,
  71339. '⃥' => 1,
  71340. '⃦' => 1,
  71341. '⃧' => 230,
  71342. '⃨' => 220,
  71343. '⃩' => 230,
  71344. '⃪' => 1,
  71345. '⃫' => 1,
  71346. '⃬' => 220,
  71347. '⃭' => 220,
  71348. '⃮' => 220,
  71349. '⃯' => 220,
  71350. '⃰' => 230,
  71351. '⳯' => 230,
  71352. 'â³°' => 230,
  71353. 'â³±' => 230,
  71354. '⵿' => 9,
  71355. 'â· ' => 230,
  71356. 'â·¡' => 230,
  71357. 'â·¢' => 230,
  71358. 'â·£' => 230,
  71359. 'â·¤' => 230,
  71360. 'â·¥' => 230,
  71361. 'â·¦' => 230,
  71362. 'â·§' => 230,
  71363. 'â·¨' => 230,
  71364. 'â·©' => 230,
  71365. 'â·ª' => 230,
  71366. 'â·«' => 230,
  71367. 'â·¬' => 230,
  71368. 'â·­' => 230,
  71369. 'â·®' => 230,
  71370. 'â·¯' => 230,
  71371. 'â·°' => 230,
  71372. 'â·±' => 230,
  71373. 'â·²' => 230,
  71374. 'â·³' => 230,
  71375. 'â·´' => 230,
  71376. 'â·µ' => 230,
  71377. 'â·¶' => 230,
  71378. 'â··' => 230,
  71379. 'â·¸' => 230,
  71380. 'â·¹' => 230,
  71381. 'â·º' => 230,
  71382. 'â·»' => 230,
  71383. 'â·¼' => 230,
  71384. 'â·½' => 230,
  71385. 'â·¾' => 230,
  71386. 'â·¿' => 230,
  71387. '〪' => 218,
  71388. '〫' => 228,
  71389. '〬' => 232,
  71390. '〭' => 222,
  71391. '〮' => 224,
  71392. '〯' => 224,
  71393. 'ã‚™' => 8,
  71394. '゚' => 8,
  71395. '꙯' => 230,
  71396. 'ê™´' => 230,
  71397. 'ꙵ' => 230,
  71398. 'ê™¶' => 230,
  71399. 'ê™·' => 230,
  71400. 'ꙸ' => 230,
  71401. 'ꙹ' => 230,
  71402. 'ꙺ' => 230,
  71403. 'ê™»' => 230,
  71404. '꙼' => 230,
  71405. '꙽' => 230,
  71406. 'êšž' => 230,
  71407. 'ꚟ' => 230,
  71408. 'ê›°' => 230,
  71409. 'ê›±' => 230,
  71410. 'ê †' => 9,
  71411. 'ê ¬' => 9,
  71412. '꣄' => 9,
  71413. '꣠' => 230,
  71414. '꣡' => 230,
  71415. '꣢' => 230,
  71416. '꣣' => 230,
  71417. '꣤' => 230,
  71418. '꣥' => 230,
  71419. '꣦' => 230,
  71420. '꣧' => 230,
  71421. '꣨' => 230,
  71422. '꣩' => 230,
  71423. '꣪' => 230,
  71424. '꣫' => 230,
  71425. '꣬' => 230,
  71426. '꣭' => 230,
  71427. '꣮' => 230,
  71428. '꣯' => 230,
  71429. '꣰' => 230,
  71430. '꣱' => 230,
  71431. '꤫' => 220,
  71432. '꤬' => 220,
  71433. '꤭' => 220,
  71434. '꥓' => 9,
  71435. '꦳' => 7,
  71436. 'ê§€' => 9,
  71437. 'ꪰ' => 230,
  71438. 'ꪲ' => 230,
  71439. 'ꪳ' => 230,
  71440. 'ꪴ' => 220,
  71441. 'ꪷ' => 230,
  71442. 'ꪸ' => 230,
  71443. 'ꪾ' => 230,
  71444. '꪿' => 230,
  71445. '�' => 230,
  71446. 'ê«¶' => 9,
  71447. '꯭' => 9,
  71448. 'ﬞ' => 26,
  71449. '︠' => 230,
  71450. '︡' => 230,
  71451. '︢' => 230,
  71452. '︣' => 230,
  71453. '︤' => 230,
  71454. '︥' => 230,
  71455. '︦' => 230,
  71456. '︧' => 220,
  71457. '︨' => 220,
  71458. '︩' => 220,
  71459. '︪' => 220,
  71460. '︫' => 220,
  71461. '︬' => 220,
  71462. '︭' => 220,
  71463. '︮' => 230,
  71464. '︯' => 230,
  71465. '�' => 220,
  71466. '�' => 220,
  71467. '�' => 230,
  71468. '�' => 230,
  71469. '�' => 230,
  71470. '�' => 230,
  71471. '�' => 230,
  71472. '�' => 220,
  71473. '�' => 230,
  71474. '�' => 230,
  71475. '�' => 1,
  71476. '�' => 220,
  71477. '�' => 9,
  71478. '�' => 230,
  71479. '�' => 220,
  71480. '�' => 230,
  71481. '�' => 230,
  71482. '�' => 230,
  71483. '�' => 230,
  71484. '�' => 230,
  71485. '�' => 230,
  71486. '�' => 220,
  71487. '�' => 220,
  71488. '�' => 230,
  71489. '�' => 230,
  71490. '�' => 230,
  71491. '�' => 220,
  71492. '�' => 230,
  71493. '�' => 220,
  71494. '�' => 220,
  71495. '�' => 220,
  71496. '�' => 220,
  71497. '�' => 9,
  71498. '�' => 9,
  71499. 'ð‘‚¹' => 9,
  71500. '𑂺' => 7,
  71501. 'ð‘„€' => 230,
  71502. '�' => 230,
  71503. 'ð‘„‚' => 230,
  71504. 'ð‘„³' => 9,
  71505. 'ð‘„´' => 9,
  71506. 'ð‘…³' => 7,
  71507. '𑇀' => 9,
  71508. '𑇊' => 7,
  71509. '𑈵' => 9,
  71510. '𑈶' => 7,
  71511. 'ð‘‹©' => 7,
  71512. '𑋪' => 9,
  71513. '𑌻' => 7,
  71514. '𑌼' => 7,
  71515. '�' => 9,
  71516. '�' => 230,
  71517. '�' => 230,
  71518. '�' => 230,
  71519. '�' => 230,
  71520. '�' => 230,
  71521. '�' => 230,
  71522. '�' => 230,
  71523. '�' => 230,
  71524. '�' => 230,
  71525. '�' => 230,
  71526. '�' => 230,
  71527. '�' => 230,
  71528. 'ð‘‘‚' => 9,
  71529. '𑑆' => 7,
  71530. 'ð‘‘ž' => 230,
  71531. 'ð‘“‚' => 9,
  71532. '𑓃' => 7,
  71533. 'ð‘–¿' => 9,
  71534. 'ð‘—€' => 7,
  71535. '𑘿' => 9,
  71536. '𑚶' => 9,
  71537. '𑚷' => 7,
  71538. '𑜫' => 9,
  71539. 'ð‘ ¹' => 9,
  71540. 'ð‘ º' => 7,
  71541. '𑤽' => 9,
  71542. '𑤾' => 9,
  71543. '𑥃' => 7,
  71544. 'ð‘§ ' => 9,
  71545. '𑨴' => 9,
  71546. '𑩇' => 9,
  71547. '𑪙' => 9,
  71548. 'ð‘°¿' => 9,
  71549. '𑵂' => 7,
  71550. '𑵄' => 9,
  71551. '𑵅' => 9,
  71552. 'ð‘¶—' => 9,
  71553. 'ð–«°' => 1,
  71554. 'ð–«±' => 1,
  71555. 'ð–«²' => 1,
  71556. 'ð–«³' => 1,
  71557. 'ð–«´' => 1,
  71558. 'ð–¬°' => 230,
  71559. '𖬱' => 230,
  71560. '𖬲' => 230,
  71561. '𖬳' => 230,
  71562. 'ð–¬´' => 230,
  71563. '𖬵' => 230,
  71564. '𖬶' => 230,
  71565. 'ð–¿°' => 6,
  71566. 'ð–¿±' => 6,
  71567. '𛲞' => 1,
  71568. '�' => 216,
  71569. '�' => 216,
  71570. '�' => 1,
  71571. '�' => 1,
  71572. '�' => 1,
  71573. '�' => 226,
  71574. '�' => 216,
  71575. '�' => 216,
  71576. '�' => 216,
  71577. '�' => 216,
  71578. '�' => 216,
  71579. '�' => 220,
  71580. '�' => 220,
  71581. '�' => 220,
  71582. '�' => 220,
  71583. '�' => 220,
  71584. '�' => 220,
  71585. '�' => 220,
  71586. '�' => 220,
  71587. '�' => 230,
  71588. '�' => 230,
  71589. '�' => 230,
  71590. '�' => 230,
  71591. '�' => 230,
  71592. '�' => 220,
  71593. '�' => 220,
  71594. '�' => 230,
  71595. '�' => 230,
  71596. '�' => 230,
  71597. '�' => 230,
  71598. '�' => 230,
  71599. '�' => 230,
  71600. '�' => 230,
  71601. '𞀀' => 230,
  71602. '�' => 230,
  71603. '𞀂' => 230,
  71604. '𞀃' => 230,
  71605. '𞀄' => 230,
  71606. '𞀅' => 230,
  71607. '𞀆' => 230,
  71608. '𞀈' => 230,
  71609. '𞀉' => 230,
  71610. '𞀊' => 230,
  71611. '𞀋' => 230,
  71612. '𞀌' => 230,
  71613. '�' => 230,
  71614. '𞀎' => 230,
  71615. '�' => 230,
  71616. '�' => 230,
  71617. '𞀑' => 230,
  71618. '𞀒' => 230,
  71619. '𞀓' => 230,
  71620. '𞀔' => 230,
  71621. '𞀕' => 230,
  71622. '𞀖' => 230,
  71623. '𞀗' => 230,
  71624. '𞀘' => 230,
  71625. '𞀛' => 230,
  71626. '𞀜' => 230,
  71627. '�' => 230,
  71628. '𞀞' => 230,
  71629. '𞀟' => 230,
  71630. '𞀠' => 230,
  71631. '𞀡' => 230,
  71632. '𞀣' => 230,
  71633. '𞀤' => 230,
  71634. '𞀦' => 230,
  71635. '𞀧' => 230,
  71636. '𞀨' => 230,
  71637. '𞀩' => 230,
  71638. '𞀪' => 230,
  71639. 'ðž„°' => 230,
  71640. '𞄱' => 230,
  71641. '𞄲' => 230,
  71642. '𞄳' => 230,
  71643. 'ðž„´' => 230,
  71644. '𞄵' => 230,
  71645. 'ðž„¶' => 230,
  71646. '𞋬' => 230,
  71647. 'ðž‹­' => 230,
  71648. 'ðž‹®' => 230,
  71649. '𞋯' => 230,
  71650. '�' => 220,
  71651. '𞣑' => 220,
  71652. '𞣒' => 220,
  71653. '𞣓' => 220,
  71654. '𞣔' => 220,
  71655. '𞣕' => 220,
  71656. '𞣖' => 220,
  71657. '𞥄' => 230,
  71658. '𞥅' => 230,
  71659. '𞥆' => 230,
  71660. '𞥇' => 230,
  71661. '𞥈' => 230,
  71662. '𞥉' => 230,
  71663. '𞥊' => 7,
  71664. );
  71665. <?php
  71666. return array (
  71667. ' ' => ' ',
  71668. '¨' => ' ̈',
  71669. 'ª' => 'a',
  71670. '¯' => ' ̄',
  71671. '²' => '2',
  71672. '³' => '3',
  71673. '´' => ' �',
  71674. 'µ' => 'μ',
  71675. '¸' => ' ̧',
  71676. '¹' => '1',
  71677. 'º' => 'o',
  71678. '¼' => '1�4',
  71679. '½' => '1�2',
  71680. '¾' => '3�4',
  71681. 'IJ' => 'IJ',
  71682. 'ij' => 'ij',
  71683. 'Ŀ' => 'L·',
  71684. 'ŀ' => 'l·',
  71685. 'ʼn' => 'ʼn',
  71686. 'Å¿' => 's',
  71687. 'DŽ' => 'DŽ',
  71688. 'Dž' => 'Dž',
  71689. 'dž' => 'dž',
  71690. 'LJ' => 'LJ',
  71691. 'Lj' => 'Lj',
  71692. 'lj' => 'lj',
  71693. 'ÇŠ' => 'NJ',
  71694. 'Ç‹' => 'Nj',
  71695. 'nj' => 'nj',
  71696. 'DZ' => 'DZ',
  71697. 'Dz' => 'Dz',
  71698. 'dz' => 'dz',
  71699. 'ʰ' => 'h',
  71700. 'ʱ' => 'ɦ',
  71701. 'ʲ' => 'j',
  71702. 'ʳ' => 'r',
  71703. 'ʴ' => 'ɹ',
  71704. 'ʵ' => 'ɻ',
  71705. 'ʶ' => '�',
  71706. 'Ê·' => 'w',
  71707. 'ʸ' => 'y',
  71708. '˘' => ' ̆',
  71709. '˙' => ' ̇',
  71710. 'Ëš' => ' ÌŠ',
  71711. '˛' => ' ̨',
  71712. '˜' => ' ̃',
  71713. '�' => ' ̋',
  71714. 'Ë ' => 'É£',
  71715. 'Ë¡' => 'l',
  71716. 'Ë¢' => 's',
  71717. 'Ë£' => 'x',
  71718. 'ˤ' => 'ʕ',
  71719. 'ͺ' => ' ͅ',
  71720. '΄' => ' �',
  71721. '΅' => ' ̈�',
  71722. '�' => 'β',
  71723. 'ϑ' => 'θ',
  71724. 'Ï’' => 'Î¥',
  71725. 'ϓ' => 'Υ�',
  71726. 'ϔ' => 'Ϋ',
  71727. 'ϕ' => 'φ',
  71728. 'Ï–' => 'Ï€',
  71729. 'ϰ' => 'κ',
  71730. 'ϱ' => '�',
  71731. 'ϲ' => 'ς',
  71732. 'ϴ' => 'Θ',
  71733. 'ϵ' => 'ε',
  71734. 'Ϲ' => 'Σ',
  71735. 'Ö‡' => 'Õ¥Ö‚',
  71736. 'ٵ' => 'اٴ',
  71737. 'ٶ' => 'وٴ',
  71738. 'Ù·' => 'Û‡Ù´',
  71739. 'ٸ' => 'يٴ',
  71740. 'ำ' => '�า',
  71741. 'ຳ' => '�າ',
  71742. 'ໜ' => 'ຫນ',
  71743. '�' => 'ຫມ',
  71744. '༌' => '་',
  71745. 'ཷ' => 'ྲཱྀ',
  71746. 'ཹ' => 'ླཱྀ',
  71747. 'ჼ' => 'ნ',
  71748. 'á´¬' => 'A',
  71749. 'ᴭ' => 'Æ',
  71750. 'á´®' => 'B',
  71751. 'á´°' => 'D',
  71752. 'á´±' => 'E',
  71753. 'á´²' => 'ÆŽ',
  71754. 'á´³' => 'G',
  71755. 'á´´' => 'H',
  71756. 'á´µ' => 'I',
  71757. 'á´¶' => 'J',
  71758. 'á´·' => 'K',
  71759. 'á´¸' => 'L',
  71760. 'á´¹' => 'M',
  71761. 'á´º' => 'N',
  71762. 'á´¼' => 'O',
  71763. 'á´½' => 'È¢',
  71764. 'á´¾' => 'P',
  71765. 'á´¿' => 'R',
  71766. 'áµ€' => 'T',
  71767. '�' => 'U',
  71768. 'ᵂ' => 'W',
  71769. 'ᵃ' => 'a',
  71770. 'ᵄ' => '�',
  71771. 'áµ…' => 'É‘',
  71772. 'ᵆ' => 'ᴂ',
  71773. 'ᵇ' => 'b',
  71774. 'ᵈ' => 'd',
  71775. 'ᵉ' => 'e',
  71776. 'ᵊ' => 'ə',
  71777. 'ᵋ' => 'ɛ',
  71778. 'ᵌ' => 'ɜ',
  71779. '�' => 'g',
  71780. '�' => 'k',
  71781. '�' => 'm',
  71782. 'ᵑ' => 'ŋ',
  71783. 'áµ’' => 'o',
  71784. 'ᵓ' => 'ɔ',
  71785. 'áµ”' => 'á´–',
  71786. 'ᵕ' => 'ᴗ',
  71787. 'áµ–' => 'p',
  71788. 'áµ—' => 't',
  71789. 'ᵘ' => 'u',
  71790. 'áµ™' => 'á´�',
  71791. 'ᵚ' => 'ɯ',
  71792. 'áµ›' => 'v',
  71793. 'ᵜ' => 'ᴥ',
  71794. '�' => 'β',
  71795. 'ᵞ' => 'γ',
  71796. 'ᵟ' => 'δ',
  71797. 'ᵠ' => 'φ',
  71798. 'ᵡ' => 'χ',
  71799. 'áµ¢' => 'i',
  71800. 'áµ£' => 'r',
  71801. 'ᵤ' => 'u',
  71802. 'áµ¥' => 'v',
  71803. 'ᵦ' => 'β',
  71804. 'ᵧ' => 'γ',
  71805. 'ᵨ' => '�',
  71806. 'ᵩ' => 'φ',
  71807. 'ᵪ' => 'χ',
  71808. 'ᵸ' => 'н',
  71809. 'á¶›' => 'É’',
  71810. 'ᶜ' => 'c',
  71811. '�' => 'ɕ',
  71812. 'ᶞ' => 'ð',
  71813. 'ᶟ' => 'ɜ',
  71814. 'á¶ ' => 'f',
  71815. 'á¶¡' => 'ÉŸ',
  71816. 'á¶¢' => 'É¡',
  71817. 'á¶£' => 'É¥',
  71818. 'ᶤ' => 'ɨ',
  71819. 'á¶¥' => 'É©',
  71820. 'ᶦ' => 'ɪ',
  71821. 'á¶§' => 'áµ»',
  71822. 'ᶨ' => '�',
  71823. 'á¶©' => 'É­',
  71824. 'ᶪ' => 'ᶅ',
  71825. 'á¶«' => 'ÊŸ',
  71826. 'ᶬ' => 'ɱ',
  71827. 'ᶭ' => 'ɰ',
  71828. 'ᶮ' => 'ɲ',
  71829. 'ᶯ' => 'ɳ',
  71830. 'á¶°' => 'É´',
  71831. 'ᶱ' => 'ɵ',
  71832. 'ᶲ' => 'ɸ',
  71833. 'á¶³' => 'Ê‚',
  71834. 'ᶴ' => 'ʃ',
  71835. 'á¶µ' => 'Æ«',
  71836. 'ᶶ' => 'ʉ',
  71837. 'á¶·' => 'ÊŠ',
  71838. 'ᶸ' => 'ᴜ',
  71839. 'á¶¹' => 'Ê‹',
  71840. 'ᶺ' => 'ʌ',
  71841. 'á¶»' => 'z',
  71842. 'ᶼ' => '�',
  71843. 'á¶½' => 'Ê‘',
  71844. 'á¶¾' => 'Ê’',
  71845. 'ᶿ' => 'θ',
  71846. 'ẚ' => 'aʾ',
  71847. 'ẛ' => 'ṡ',
  71848. 'á¾½' => ' Ì“',
  71849. '᾿' => ' ̓',
  71850. 'á¿€' => ' Í‚',
  71851. '�' => ' ̈͂',
  71852. '�' => ' ̓̀',
  71853. '῎' => ' ̓�',
  71854. '�' => ' ̓͂',
  71855. '�' => ' ̔̀',
  71856. '῞' => ' ̔�',
  71857. '῟' => ' ̔͂',
  71858. '῭' => ' ̈̀',
  71859. '΅' => ' ̈�',
  71860. '´' => ' �',
  71861. '῾' => ' ̔',
  71862. ' ' => ' ',
  71863. '�' => ' ',
  71864. ' ' => ' ',
  71865. ' ' => ' ',
  71866. ' ' => ' ',
  71867. ' ' => ' ',
  71868. ' ' => ' ',
  71869. ' ' => ' ',
  71870. ' ' => ' ',
  71871. ' ' => ' ',
  71872. ' ' => ' ',
  71873. '‑' => '�',
  71874. '‗' => ' ̳',
  71875. '․' => '.',
  71876. '‥' => '..',
  71877. '…' => '...',
  71878. ' ' => ' ',
  71879. '″' => '′′',
  71880. '‴' => '′′′',
  71881. '‶' => '‵‵',
  71882. '‷' => '‵‵‵',
  71883. '‼' => '!!',
  71884. '‾' => ' ̅',
  71885. '�' => '??',
  71886. '�' => '?!',
  71887. '�' => '!?',
  71888. '�' => '′′′′',
  71889. '�' => ' ',
  71890. '�' => '0',
  71891. '�' => 'i',
  71892. '�' => '4',
  71893. '�' => '5',
  71894. '�' => '6',
  71895. '�' => '7',
  71896. '�' => '8',
  71897. '�' => '9',
  71898. '�' => '+',
  71899. '�' => '−',
  71900. '�' => '=',
  71901. '�' => '(',
  71902. '�' => ')',
  71903. '�' => 'n',
  71904. 'â‚€' => '0',
  71905. '�' => '1',
  71906. 'â‚‚' => '2',
  71907. '₃' => '3',
  71908. 'â‚„' => '4',
  71909. 'â‚…' => '5',
  71910. '₆' => '6',
  71911. '₇' => '7',
  71912. '₈' => '8',
  71913. '₉' => '9',
  71914. '₊' => '+',
  71915. '₋' => '−',
  71916. '₌' => '=',
  71917. '�' => '(',
  71918. '₎' => ')',
  71919. '�' => 'a',
  71920. 'â‚‘' => 'e',
  71921. 'â‚’' => 'o',
  71922. 'â‚“' => 'x',
  71923. 'â‚”' => 'É™',
  71924. 'â‚•' => 'h',
  71925. 'â‚–' => 'k',
  71926. 'â‚—' => 'l',
  71927. 'ₘ' => 'm',
  71928. 'â‚™' => 'n',
  71929. 'ₚ' => 'p',
  71930. 'â‚›' => 's',
  71931. 'ₜ' => 't',
  71932. '₨' => 'Rs',
  71933. 'â„€' => 'a/c',
  71934. '�' => 'a/s',
  71935. 'â„‚' => 'C',
  71936. '℃' => '°C',
  71937. 'â„…' => 'c/o',
  71938. '℆' => 'c/u',
  71939. 'ℇ' => '�',
  71940. '℉' => '°F',
  71941. 'ℊ' => 'g',
  71942. 'â„‹' => 'H',
  71943. 'ℌ' => 'H',
  71944. '�' => 'H',
  71945. 'ℎ' => 'h',
  71946. '�' => 'ħ',
  71947. '�' => 'I',
  71948. 'â„‘' => 'I',
  71949. 'â„’' => 'L',
  71950. 'â„“' => 'l',
  71951. 'â„•' => 'N',
  71952. 'â„–' => 'No',
  71953. 'â„™' => 'P',
  71954. 'ℚ' => 'Q',
  71955. 'â„›' => 'R',
  71956. 'ℜ' => 'R',
  71957. '�' => 'R',
  71958. 'â„ ' => 'SM',
  71959. 'â„¡' => 'TEL',
  71960. 'â„¢' => 'TM',
  71961. 'ℤ' => 'Z',
  71962. 'ℨ' => 'Z',
  71963. 'ℬ' => 'B',
  71964. 'â„­' => 'C',
  71965. 'ℯ' => 'e',
  71966. 'â„°' => 'E',
  71967. 'ℱ' => 'F',
  71968. 'ℳ' => 'M',
  71969. 'â„´' => 'o',
  71970. 'ℵ' => '�',
  71971. 'ℶ' => 'ב',
  71972. 'â„·' => '×’',
  71973. 'ℸ' => 'ד',
  71974. 'ℹ' => 'i',
  71975. 'â„»' => 'FAX',
  71976. 'ℼ' => 'π',
  71977. 'ℽ' => 'γ',
  71978. 'ℾ' => 'Γ',
  71979. 'ℿ' => 'Π',
  71980. '⅀' => '∑',
  71981. 'â……' => 'D',
  71982. 'â…†' => 'd',
  71983. 'â…‡' => 'e',
  71984. 'â…ˆ' => 'i',
  71985. 'â…‰' => 'j',
  71986. '�' => '1�7',
  71987. '⅑' => '1�9',
  71988. '⅒' => '1�10',
  71989. '⅓' => '1�3',
  71990. '⅔' => '2�3',
  71991. '⅕' => '1�5',
  71992. '⅖' => '2�5',
  71993. '⅗' => '3�5',
  71994. '⅘' => '4�5',
  71995. '⅙' => '1�6',
  71996. '⅚' => '5�6',
  71997. '⅛' => '1�8',
  71998. '⅜' => '3�8',
  71999. '�' => '5�8',
  72000. '⅞' => '7�8',
  72001. '⅟' => '1�',
  72002. 'â… ' => 'I',
  72003. 'â…¡' => 'II',
  72004. 'â…¢' => 'III',
  72005. 'â…£' => 'IV',
  72006. 'â…¤' => 'V',
  72007. 'â…¥' => 'VI',
  72008. 'â…¦' => 'VII',
  72009. 'â…§' => 'VIII',
  72010. 'â…¨' => 'IX',
  72011. 'â…©' => 'X',
  72012. 'â…ª' => 'XI',
  72013. 'â…«' => 'XII',
  72014. 'â…¬' => 'L',
  72015. 'â…­' => 'C',
  72016. 'â…®' => 'D',
  72017. 'â…¯' => 'M',
  72018. 'â…°' => 'i',
  72019. 'â…±' => 'ii',
  72020. 'â…²' => 'iii',
  72021. 'â…³' => 'iv',
  72022. 'â…´' => 'v',
  72023. 'â…µ' => 'vi',
  72024. 'â…¶' => 'vii',
  72025. 'â…·' => 'viii',
  72026. 'â…¸' => 'ix',
  72027. 'â…¹' => 'x',
  72028. 'â…º' => 'xi',
  72029. 'â…»' => 'xii',
  72030. 'â…¼' => 'l',
  72031. 'â…½' => 'c',
  72032. 'â…¾' => 'd',
  72033. 'â…¿' => 'm',
  72034. '↉' => '0�3',
  72035. '∬' => '∫∫',
  72036. '∭' => '∫∫∫',
  72037. '∯' => '∮∮',
  72038. '∰' => '∮∮∮',
  72039. 'â‘ ' => '1',
  72040. 'â‘¡' => '2',
  72041. 'â‘¢' => '3',
  72042. 'â‘£' => '4',
  72043. '⑤' => '5',
  72044. 'â‘¥' => '6',
  72045. '⑦' => '7',
  72046. 'â‘§' => '8',
  72047. '⑨' => '9',
  72048. 'â‘©' => '10',
  72049. '⑪' => '11',
  72050. 'â‘«' => '12',
  72051. '⑬' => '13',
  72052. 'â‘­' => '14',
  72053. 'â‘®' => '15',
  72054. '⑯' => '16',
  72055. 'â‘°' => '17',
  72056. '⑱' => '18',
  72057. '⑲' => '19',
  72058. '⑳' => '20',
  72059. 'â‘´' => '(1)',
  72060. '⑵' => '(2)',
  72061. 'â‘¶' => '(3)',
  72062. 'â‘·' => '(4)',
  72063. '⑸' => '(5)',
  72064. '⑹' => '(6)',
  72065. '⑺' => '(7)',
  72066. 'â‘»' => '(8)',
  72067. '⑼' => '(9)',
  72068. '⑽' => '(10)',
  72069. '⑾' => '(11)',
  72070. 'â‘¿' => '(12)',
  72071. 'â’€' => '(13)',
  72072. 'â’�' => '(14)',
  72073. 'â’‚' => '(15)',
  72074. 'â’ƒ' => '(16)',
  72075. 'â’„' => '(17)',
  72076. 'â’…' => '(18)',
  72077. 'â’†' => '(19)',
  72078. 'â’‡' => '(20)',
  72079. 'â’ˆ' => '1.',
  72080. 'â’‰' => '2.',
  72081. 'â’Š' => '3.',
  72082. 'â’‹' => '4.',
  72083. '⒌' => '5.',
  72084. 'â’�' => '6.',
  72085. 'â’Ž' => '7.',
  72086. 'â’�' => '8.',
  72087. 'â’�' => '9.',
  72088. 'â’‘' => '10.',
  72089. 'â’’' => '11.',
  72090. 'â’“' => '12.',
  72091. 'â’”' => '13.',
  72092. 'â’•' => '14.',
  72093. 'â’–' => '15.',
  72094. 'â’—' => '16.',
  72095. 'â’˜' => '17.',
  72096. 'â’™' => '18.',
  72097. 'â’š' => '19.',
  72098. 'â’›' => '20.',
  72099. '⒜' => '(a)',
  72100. 'â’�' => '(b)',
  72101. 'â’ž' => '(c)',
  72102. 'â’Ÿ' => '(d)',
  72103. 'â’ ' => '(e)',
  72104. 'â’¡' => '(f)',
  72105. 'â’¢' => '(g)',
  72106. 'â’£' => '(h)',
  72107. 'â’¤' => '(i)',
  72108. 'â’¥' => '(j)',
  72109. 'â’¦' => '(k)',
  72110. 'â’§' => '(l)',
  72111. 'â’¨' => '(m)',
  72112. 'â’©' => '(n)',
  72113. 'â’ª' => '(o)',
  72114. 'â’«' => '(p)',
  72115. 'â’¬' => '(q)',
  72116. 'â’­' => '(r)',
  72117. 'â’®' => '(s)',
  72118. 'â’¯' => '(t)',
  72119. 'â’°' => '(u)',
  72120. 'â’±' => '(v)',
  72121. 'â’²' => '(w)',
  72122. 'â’³' => '(x)',
  72123. 'â’´' => '(y)',
  72124. 'â’µ' => '(z)',
  72125. 'â’¶' => 'A',
  72126. 'â’·' => 'B',
  72127. 'â’¸' => 'C',
  72128. 'â’¹' => 'D',
  72129. 'â’º' => 'E',
  72130. 'â’»' => 'F',
  72131. 'â’¼' => 'G',
  72132. 'â’½' => 'H',
  72133. 'â’¾' => 'I',
  72134. 'â’¿' => 'J',
  72135. 'â“€' => 'K',
  72136. '�' => 'L',
  72137. 'â“‚' => 'M',
  72138. 'Ⓝ' => 'N',
  72139. 'â“„' => 'O',
  72140. 'â“…' => 'P',
  72141. 'Ⓠ' => 'Q',
  72142. 'Ⓡ' => 'R',
  72143. 'Ⓢ' => 'S',
  72144. 'Ⓣ' => 'T',
  72145. 'Ⓤ' => 'U',
  72146. 'â“‹' => 'V',
  72147. 'Ⓦ' => 'W',
  72148. '�' => 'X',
  72149. 'Ⓨ' => 'Y',
  72150. '�' => 'Z',
  72151. '�' => 'a',
  72152. 'â“‘' => 'b',
  72153. 'â“’' => 'c',
  72154. 'â““' => 'd',
  72155. 'â“”' => 'e',
  72156. 'â“•' => 'f',
  72157. 'â“–' => 'g',
  72158. 'â“—' => 'h',
  72159. 'ⓘ' => 'i',
  72160. 'â“™' => 'j',
  72161. 'ⓚ' => 'k',
  72162. 'â“›' => 'l',
  72163. 'ⓜ' => 'm',
  72164. '�' => 'n',
  72165. 'ⓞ' => 'o',
  72166. 'ⓟ' => 'p',
  72167. 'â“ ' => 'q',
  72168. 'â“¡' => 'r',
  72169. 'â“¢' => 's',
  72170. 'â“£' => 't',
  72171. 'ⓤ' => 'u',
  72172. 'â“¥' => 'v',
  72173. 'ⓦ' => 'w',
  72174. 'â“§' => 'x',
  72175. 'ⓨ' => 'y',
  72176. 'â“©' => 'z',
  72177. '⓪' => '0',
  72178. '⨌' => '∫∫∫∫',
  72179. 'â©´' => '::=',
  72180. '⩵' => '==',
  72181. 'â©¶' => '===',
  72182. 'â±¼' => 'j',
  72183. 'â±½' => 'V',
  72184. 'ⵯ' => 'ⵡ',
  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. '�' => 'PTE',
  72590. '㉑' => '21',
  72591. '㉒' => '22',
  72592. '㉓' => '23',
  72593. '㉔' => '24',
  72594. '㉕' => '25',
  72595. '㉖' => '26',
  72596. '㉗' => '27',
  72597. '㉘' => '28',
  72598. '㉙' => '29',
  72599. '㉚' => '30',
  72600. '㉛' => '31',
  72601. '㉜' => '32',
  72602. '�' => '33',
  72603. '㉞' => '34',
  72604. '㉟' => '35',
  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. '㊱' => '36',
  72686. '㊲' => '37',
  72687. '㊳' => '38',
  72688. '㊴' => '39',
  72689. '㊵' => '40',
  72690. '㊶' => '41',
  72691. '㊷' => '42',
  72692. '㊸' => '43',
  72693. '㊹' => '44',
  72694. '㊺' => '45',
  72695. '㊻' => '46',
  72696. '㊼' => '47',
  72697. '㊽' => '48',
  72698. '㊾' => '49',
  72699. '㊿' => '50',
  72700. '㋀' => '1月',
  72701. '�' => '2月',
  72702. '㋂' => '3月',
  72703. '㋃' => '4月',
  72704. '㋄' => '5月',
  72705. '㋅' => '6月',
  72706. '㋆' => '7月',
  72707. '㋇' => '8月',
  72708. '㋈' => '9月',
  72709. '㋉' => '10月',
  72710. '㋊' => '11月',
  72711. '㋋' => '12月',
  72712. '㋌' => 'Hg',
  72713. '�' => 'erg',
  72714. '㋎' => 'eV',
  72715. '�' => 'LTD',
  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. '�' => '0点',
  72853. '�' => '1点',
  72854. '�' => '2点',
  72855. '�' => '3点',
  72856. '�' => '4点',
  72857. '�' => '5点',
  72858. '�' => '6点',
  72859. '�' => '7点',
  72860. '�' => '8点',
  72861. '�' => '9点',
  72862. '�' => '10点',
  72863. '�' => '11点',
  72864. '�' => '12点',
  72865. '�' => '13点',
  72866. '�' => '14点',
  72867. '�' => '15点',
  72868. '�' => '16点',
  72869. '�' => '17点',
  72870. '�' => '18点',
  72871. '�' => '19点',
  72872. '�' => '20点',
  72873. '�' => '21点',
  72874. '�' => '22点',
  72875. '�' => '23点',
  72876. '�' => '24点',
  72877. '�' => 'hPa',
  72878. '�' => 'da',
  72879. '�' => 'AU',
  72880. '�' => 'bar',
  72881. '�' => 'oV',
  72882. '�' => 'pc',
  72883. '�' => 'dm',
  72884. '�' => 'dm2',
  72885. '�' => 'dm3',
  72886. '�' => 'IU',
  72887. '�' => '平�',
  72888. '�' => '昭和',
  72889. '�' => '大正',
  72890. '�' => '明治',
  72891. '�' => '株�会社',
  72892. '㎀' => 'pA',
  72893. '�' => 'nA',
  72894. '㎂' => 'μA',
  72895. '㎃' => 'mA',
  72896. '㎄' => 'kA',
  72897. '㎅' => 'KB',
  72898. '㎆' => 'MB',
  72899. '㎇' => 'GB',
  72900. '㎈' => 'cal',
  72901. '㎉' => 'kcal',
  72902. '㎊' => 'pF',
  72903. '㎋' => 'nF',
  72904. '㎌' => 'μF',
  72905. '�' => 'μg',
  72906. '㎎' => 'mg',
  72907. '�' => 'kg',
  72908. '�' => 'Hz',
  72909. '㎑' => 'kHz',
  72910. '㎒' => 'MHz',
  72911. '㎓' => 'GHz',
  72912. '㎔' => 'THz',
  72913. '㎕' => 'μl',
  72914. '㎖' => 'ml',
  72915. '㎗' => 'dl',
  72916. '㎘' => 'kl',
  72917. '㎙' => 'fm',
  72918. '㎚' => 'nm',
  72919. '㎛' => 'μm',
  72920. '㎜' => 'mm',
  72921. '�' => 'cm',
  72922. '㎞' => 'km',
  72923. '㎟' => 'mm2',
  72924. '㎠' => 'cm2',
  72925. '㎡' => 'm2',
  72926. '㎢' => 'km2',
  72927. '㎣' => 'mm3',
  72928. '㎤' => 'cm3',
  72929. '㎥' => 'm3',
  72930. '㎦' => 'km3',
  72931. '㎧' => 'm∕s',
  72932. '㎨' => 'm∕s2',
  72933. '㎩' => 'Pa',
  72934. '㎪' => 'kPa',
  72935. '㎫' => 'MPa',
  72936. '㎬' => 'GPa',
  72937. '㎭' => 'rad',
  72938. '㎮' => 'rad∕s',
  72939. '㎯' => 'rad∕s2',
  72940. '㎰' => 'ps',
  72941. '㎱' => 'ns',
  72942. '㎲' => 'μs',
  72943. '㎳' => 'ms',
  72944. '㎴' => 'pV',
  72945. '㎵' => 'nV',
  72946. '㎶' => 'μV',
  72947. '㎷' => 'mV',
  72948. '㎸' => 'kV',
  72949. '㎹' => 'MV',
  72950. '㎺' => 'pW',
  72951. '㎻' => 'nW',
  72952. '㎼' => 'μW',
  72953. '㎽' => 'mW',
  72954. '㎾' => 'kW',
  72955. '㎿' => 'MW',
  72956. '�' => 'kΩ',
  72957. '�' => 'MΩ',
  72958. '�' => 'a.m.',
  72959. '�' => 'Bq',
  72960. '�' => 'cc',
  72961. '�' => 'cd',
  72962. '�' => 'C∕kg',
  72963. '�' => 'Co.',
  72964. '�' => 'dB',
  72965. '�' => 'Gy',
  72966. '�' => 'ha',
  72967. '�' => 'HP',
  72968. '�' => 'in',
  72969. '�' => 'KK',
  72970. '�' => 'KM',
  72971. '�' => 'kt',
  72972. '�' => 'lm',
  72973. '�' => 'ln',
  72974. '�' => 'log',
  72975. '�' => 'lx',
  72976. '�' => 'mb',
  72977. '�' => 'mil',
  72978. '�' => 'mol',
  72979. '�' => 'PH',
  72980. '�' => 'p.m.',
  72981. '�' => 'PPM',
  72982. '�' => 'PR',
  72983. '�' => 'sr',
  72984. '�' => 'Sv',
  72985. '�' => 'Wb',
  72986. '�' => 'V∕m',
  72987. '�' => 'A∕m',
  72988. '�' => '1日',
  72989. '�' => '2日',
  72990. '�' => '3日',
  72991. '�' => '4日',
  72992. '�' => '5日',
  72993. '�' => '6日',
  72994. '�' => '7日',
  72995. '�' => '8日',
  72996. '�' => '9日',
  72997. '�' => '10日',
  72998. '�' => '11日',
  72999. '�' => '12日',
  73000. '�' => '13日',
  73001. '�' => '14日',
  73002. '�' => '15日',
  73003. '�' => '16日',
  73004. '�' => '17日',
  73005. '�' => '18日',
  73006. '�' => '19日',
  73007. '�' => '20日',
  73008. '�' => '21日',
  73009. '�' => '22日',
  73010. '�' => '23日',
  73011. '�' => '24日',
  73012. '�' => '25日',
  73013. '�' => '26日',
  73014. '�' => '27日',
  73015. '�' => '28日',
  73016. '�' => '29日',
  73017. '�' => '30日',
  73018. '�' => '31日',
  73019. '�' => 'gal',
  73020. 'ꚜ' => 'ъ',
  73021. '�' => 'ь',
  73022. '�' => '�',
  73023. 'ꟸ' => 'Ħ',
  73024. 'ꟹ' => 'œ',
  73025. 'ꭜ' => 'ꜧ',
  73026. '�' => 'ꬷ',
  73027. 'ê­ž' => 'É«',
  73028. 'ê­Ÿ' => 'ê­’',
  73029. 'ꭩ' => '�',
  73030. 'ff' => 'ff',
  73031. '�' => 'fi',
  73032. 'fl' => 'fl',
  73033. 'ffi' => 'ffi',
  73034. 'ffl' => 'ffl',
  73035. 'ſt' => 'st',
  73036. 'st' => 'st',
  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. 'ï®®' => 'Û’',
  73148. 'ﮯ' => 'ے',
  73149. 'ï®°' => 'Û’Ù”',
  73150. 'ï®±' => 'Û’Ù”',
  73151. 'ﯓ' => 'ڭ',
  73152. 'ﯔ' => 'ڭ',
  73153. 'ﯕ' => 'ڭ',
  73154. 'ﯖ' => 'ڭ',
  73155. 'ﯗ' => 'ۇ',
  73156. 'ﯘ' => 'ۇ',
  73157. 'ﯙ' => 'ۆ',
  73158. 'ﯚ' => 'ۆ',
  73159. 'ﯛ' => 'ۈ',
  73160. 'ﯜ' => 'ۈ',
  73161. '�' => 'ۇٴ',
  73162. 'ﯞ' => 'ۋ',
  73163. 'ﯟ' => 'ۋ',
  73164. 'ﯠ' => 'ۅ',
  73165. 'ﯡ' => 'ۅ',
  73166. 'ﯢ' => 'ۉ',
  73167. 'ﯣ' => 'ۉ',
  73168. 'ﯤ' => '�',
  73169. 'ﯥ' => '�',
  73170. 'ﯦ' => '�',
  73171. 'ﯧ' => '�',
  73172. 'ﯨ' => 'ى',
  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. 'ﳋ' => 'لخ',
  73400. 'ﳌ' => 'لم',
  73401. '�' => 'له',
  73402. 'ﳎ' => 'مج',
  73403. '�' => 'مح',
  73404. '�' => 'مخ',
  73405. 'ﳑ' => 'مم',
  73406. 'ﳒ' => 'نج',
  73407. 'ﳓ' => 'نح',
  73408. 'ﳔ' => 'نخ',
  73409. 'ﳕ' => 'نم',
  73410. 'ﳖ' => 'نه',
  73411. 'ﳗ' => 'هج',
  73412. 'ﳘ' => 'هم',
  73413. 'ﳙ' => 'هٰ',
  73414. 'ﳚ' => 'يج',
  73415. 'ﳛ' => 'يح',
  73416. 'ﳜ' => 'يخ',
  73417. '�' => 'يم',
  73418. 'ﳞ' => 'يه',
  73419. 'ﳟ' => 'ئم',
  73420. 'ï³ ' => 'ÙŠÙ”Ù‡',
  73421. 'ﳡ' => 'بم',
  73422. 'ﳢ' => 'به',
  73423. 'ﳣ' => 'تم',
  73424. 'ﳤ' => 'ته',
  73425. 'ﳥ' => 'ثم',
  73426. 'ﳦ' => 'ثه',
  73427. 'ﳧ' => 'سم',
  73428. 'ﳨ' => 'سه',
  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. 'ﴡ' => 'صى',
  73486. 'ﴢ' => 'صي',
  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. 'ﵙ' => 'جمح',
  73524. 'ﵚ' => 'حمي',
  73525. 'ﵛ' => 'حمى',
  73526. 'ﵜ' => 'سحج',
  73527. '�' => 'سجح',
  73528. 'ﵞ' => 'سجى',
  73529. 'ﵟ' => 'سمح',
  73530. 'ﵠ' => 'سمح',
  73531. 'ﵡ' => 'سمج',
  73532. 'ﵢ' => 'سمم',
  73533. 'ﵣ' => 'سمم',
  73534. 'ﵤ' => 'صحح',
  73535. 'ﵥ' => 'صحح',
  73536. 'ﵦ' => 'صمم',
  73537. 'ﵧ' => 'شحم',
  73538. 'ﵨ' => 'شحم',
  73539. 'ﵩ' => 'شجي',
  73540. 'ﵪ' => 'شمخ',
  73541. 'ﵫ' => 'شمخ',
  73542. 'ﵬ' => 'شمم',
  73543. 'ﵭ' => 'شمم',
  73544. 'ﵮ' => 'ضحى',
  73545. 'ﵯ' => 'ضخم',
  73546. 'ﵰ' => 'ضخم',
  73547. 'ﵱ' => 'طمح',
  73548. 'ﵲ' => 'طمح',
  73549. 'ﵳ' => 'طمم',
  73550. 'ﵴ' => 'طمي',
  73551. 'ﵵ' => 'عجم',
  73552. 'ﵶ' => 'عمم',
  73553. 'ﵷ' => 'عمم',
  73554. 'ﵸ' => 'عمى',
  73555. 'ﵹ' => 'غمم',
  73556. 'ﵺ' => 'غمي',
  73557. 'ﵻ' => 'غمى',
  73558. 'ﵼ' => '�خم',
  73559. 'ﵽ' => '�خم',
  73560. 'ﵾ' => 'قمح',
  73561. 'ﵿ' => 'قمم',
  73562. 'ﶀ' => 'لحم',
  73563. '�' => 'لحي',
  73564. 'ﶂ' => 'لحى',
  73565. 'ﶃ' => 'لجج',
  73566. 'ﶄ' => 'لجج',
  73567. 'ﶅ' => 'لخم',
  73568. 'ﶆ' => 'لخم',
  73569. 'ﶇ' => 'لمح',
  73570. 'ﶈ' => 'لمح',
  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. '�' => '0',
  73866. '1' => '1',
  73867. 'ï¼’' => '2',
  73868. '3' => '3',
  73869. 'ï¼”' => '4',
  73870. '5' => '5',
  73871. 'ï¼–' => '6',
  73872. 'ï¼—' => '7',
  73873. '8' => '8',
  73874. 'ï¼™' => '9',
  73875. ':' => ':',
  73876. 'ï¼›' => ';',
  73877. '<' => '<',
  73878. '�' => '=',
  73879. '>' => '>',
  73880. '?' => '?',
  73881. 'ï¼ ' => '@',
  73882. 'A' => 'A',
  73883. 'ï¼¢' => 'B',
  73884. 'ï¼£' => 'C',
  73885. 'D' => 'D',
  73886. 'ï¼¥' => 'E',
  73887. 'F' => 'F',
  73888. 'ï¼§' => 'G',
  73889. 'H' => 'H',
  73890. 'I' => 'I',
  73891. 'J' => 'J',
  73892. 'K' => 'K',
  73893. 'L' => 'L',
  73894. 'ï¼­' => 'M',
  73895. 'ï¼®' => 'N',
  73896. 'O' => 'O',
  73897. 'ï¼°' => 'P',
  73898. 'ï¼±' => 'Q',
  73899. 'ï¼²' => 'R',
  73900. 'ï¼³' => 'S',
  73901. 'ï¼´' => 'T',
  73902. 'ï¼µ' => 'U',
  73903. 'ï¼¶' => 'V',
  73904. 'ï¼·' => 'W',
  73905. 'X' => 'X',
  73906. 'ï¼¹' => 'Y',
  73907. 'Z' => 'Z',
  73908. 'ï¼»' => '[',
  73909. 'ï¼¼' => '\\',
  73910. 'ï¼½' => ']',
  73911. 'ï¼¾' => '^',
  73912. '_' => '_',
  73913. 'ï½€' => '`',
  73914. '�' => 'a',
  73915. 'b' => 'b',
  73916. 'c' => 'c',
  73917. 'd' => 'd',
  73918. 'ï½…' => 'e',
  73919. 'f' => 'f',
  73920. 'g' => 'g',
  73921. 'h' => 'h',
  73922. 'i' => 'i',
  73923. 'j' => 'j',
  73924. 'k' => 'k',
  73925. 'l' => 'l',
  73926. '�' => 'm',
  73927. 'n' => 'n',
  73928. '�' => 'o',
  73929. '�' => 'p',
  73930. 'q' => 'q',
  73931. 'ï½’' => 'r',
  73932. 's' => 's',
  73933. 'ï½”' => 't',
  73934. 'u' => 'u',
  73935. 'ï½–' => 'v',
  73936. 'ï½—' => 'w',
  73937. 'x' => 'x',
  73938. 'ï½™' => 'y',
  73939. 'z' => 'z',
  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. '�' => 'A',
  74076. '�' => 'B',
  74077. '�' => 'C',
  74078. '�' => 'D',
  74079. '�' => 'E',
  74080. '�' => 'F',
  74081. '�' => 'G',
  74082. '�' => 'H',
  74083. '�' => 'I',
  74084. '�' => 'J',
  74085. '�' => 'K',
  74086. '�' => 'L',
  74087. '�' => 'M',
  74088. '�' => 'N',
  74089. '�' => 'O',
  74090. '�' => 'P',
  74091. '�' => 'Q',
  74092. '�' => 'R',
  74093. '�' => 'S',
  74094. '�' => 'T',
  74095. '�' => 'U',
  74096. '�' => 'V',
  74097. '�' => 'W',
  74098. '�' => 'X',
  74099. '�' => 'Y',
  74100. '�' => 'Z',
  74101. '�' => 'a',
  74102. '�' => 'b',
  74103. '�' => 'c',
  74104. '�' => 'd',
  74105. '�' => 'e',
  74106. '�' => 'f',
  74107. '�' => 'g',
  74108. '�' => 'h',
  74109. '�' => 'i',
  74110. '�' => 'j',
  74111. '�' => 'k',
  74112. '�' => 'l',
  74113. '�' => 'm',
  74114. '�' => 'n',
  74115. '�' => 'o',
  74116. '�' => 'p',
  74117. '�' => 'q',
  74118. '�' => 'r',
  74119. '�' => 's',
  74120. '�' => 't',
  74121. '�' => 'u',
  74122. '�' => 'v',
  74123. '�' => 'w',
  74124. '�' => 'x',
  74125. '�' => 'y',
  74126. '�' => 'z',
  74127. '�' => 'A',
  74128. '�' => 'B',
  74129. '�' => 'C',
  74130. '�' => 'D',
  74131. '�' => 'E',
  74132. '�' => 'F',
  74133. '�' => 'G',
  74134. '�' => 'H',
  74135. '�' => 'I',
  74136. '�' => 'J',
  74137. '�' => 'K',
  74138. '�' => 'L',
  74139. '�' => 'M',
  74140. '�' => 'N',
  74141. '�' => 'O',
  74142. '�' => 'P',
  74143. '�' => 'Q',
  74144. '�' => 'R',
  74145. '�' => 'S',
  74146. '�' => 'T',
  74147. '�' => 'U',
  74148. '�' => 'V',
  74149. '�' => 'W',
  74150. '�' => 'X',
  74151. '�' => 'Y',
  74152. '�' => 'Z',
  74153. '�' => 'a',
  74154. '�' => 'b',
  74155. '�' => 'c',
  74156. '�' => 'd',
  74157. '�' => 'e',
  74158. '�' => 'f',
  74159. '�' => 'g',
  74160. '�' => 'i',
  74161. '�' => 'j',
  74162. '�' => 'k',
  74163. '�' => 'l',
  74164. '�' => 'm',
  74165. '�' => 'n',
  74166. '�' => 'o',
  74167. '�' => 'p',
  74168. '�' => 'q',
  74169. '�' => 'r',
  74170. '�' => 's',
  74171. '�' => 't',
  74172. '�' => 'u',
  74173. '�' => 'v',
  74174. '�' => 'w',
  74175. '�' => 'x',
  74176. '�' => 'y',
  74177. '�' => 'z',
  74178. '�' => 'A',
  74179. '�' => 'B',
  74180. '�' => 'C',
  74181. '�' => 'D',
  74182. '�' => 'E',
  74183. '�' => 'F',
  74184. '�' => 'G',
  74185. '�' => 'H',
  74186. '�' => 'I',
  74187. '�' => 'J',
  74188. '�' => 'K',
  74189. '�' => 'L',
  74190. '�' => 'M',
  74191. '�' => 'N',
  74192. '�' => 'O',
  74193. '�' => 'P',
  74194. '�' => 'Q',
  74195. '�' => 'R',
  74196. '�' => 'S',
  74197. '�' => 'T',
  74198. '�' => 'U',
  74199. '�' => 'V',
  74200. '�' => 'W',
  74201. '�' => 'X',
  74202. '�' => 'Y',
  74203. '�' => 'Z',
  74204. '�' => 'a',
  74205. '�' => 'b',
  74206. '�' => 'c',
  74207. '�' => 'd',
  74208. '�' => 'e',
  74209. '�' => 'f',
  74210. '�' => 'g',
  74211. '�' => 'h',
  74212. '�' => 'i',
  74213. '�' => 'j',
  74214. '�' => 'k',
  74215. '�' => 'l',
  74216. '�' => 'm',
  74217. '�' => 'n',
  74218. '�' => 'o',
  74219. '�' => 'p',
  74220. '�' => 'q',
  74221. '�' => 'r',
  74222. '�' => 's',
  74223. '�' => 't',
  74224. '�' => 'u',
  74225. '�' => 'v',
  74226. '�' => 'w',
  74227. '�' => 'x',
  74228. '�' => 'y',
  74229. '�' => 'z',
  74230. '�' => 'A',
  74231. '�' => 'C',
  74232. '�' => 'D',
  74233. '�' => 'G',
  74234. '�' => 'J',
  74235. '�' => 'K',
  74236. '�' => 'N',
  74237. '�' => 'O',
  74238. '�' => 'P',
  74239. '�' => 'Q',
  74240. '�' => 'S',
  74241. '�' => 'T',
  74242. '�' => 'U',
  74243. '�' => 'V',
  74244. '�' => 'W',
  74245. '�' => 'X',
  74246. '�' => 'Y',
  74247. '�' => 'Z',
  74248. '�' => 'a',
  74249. '�' => 'b',
  74250. '�' => 'c',
  74251. '�' => 'd',
  74252. '�' => 'f',
  74253. '�' => 'h',
  74254. '�' => 'i',
  74255. '�' => 'j',
  74256. '�' => 'k',
  74257. '�' => 'l',
  74258. '�' => 'm',
  74259. '�' => 'n',
  74260. '�' => 'p',
  74261. '�' => 'q',
  74262. '�' => 'r',
  74263. '�' => 's',
  74264. '�' => 't',
  74265. '�' => 'u',
  74266. '�' => 'v',
  74267. '�' => 'w',
  74268. '�' => 'x',
  74269. '�' => 'y',
  74270. '�' => 'z',
  74271. '�' => 'A',
  74272. '�' => 'B',
  74273. '�' => 'C',
  74274. '�' => 'D',
  74275. '�' => 'E',
  74276. '�' => 'F',
  74277. '�' => 'G',
  74278. '�' => 'H',
  74279. '�' => 'I',
  74280. '�' => 'J',
  74281. '�' => 'K',
  74282. '�' => 'L',
  74283. '�' => 'M',
  74284. '�' => 'N',
  74285. '�' => 'O',
  74286. '�' => 'P',
  74287. '�' => 'Q',
  74288. '�' => 'R',
  74289. '�' => 'S',
  74290. '�' => 'T',
  74291. '�' => 'U',
  74292. '�' => 'V',
  74293. '�' => 'W',
  74294. '�' => 'X',
  74295. '�' => 'Y',
  74296. '�' => 'Z',
  74297. '�' => 'a',
  74298. '�' => 'b',
  74299. '�' => 'c',
  74300. '�' => 'd',
  74301. '�' => 'e',
  74302. '�' => 'f',
  74303. '�' => 'g',
  74304. '�' => 'h',
  74305. '�' => 'i',
  74306. '�' => 'j',
  74307. '�' => 'k',
  74308. '�' => 'l',
  74309. '�' => 'm',
  74310. '�' => 'n',
  74311. '�' => 'o',
  74312. '�' => 'p',
  74313. '�' => 'q',
  74314. '�' => 'r',
  74315. '�' => 's',
  74316. '�' => 't',
  74317. '�' => 'u',
  74318. '�' => 'v',
  74319. '�' => 'w',
  74320. '�' => 'x',
  74321. '�' => 'y',
  74322. '�' => 'z',
  74323. '�' => 'A',
  74324. '�' => 'B',
  74325. '�' => 'D',
  74326. '�' => 'E',
  74327. '�' => 'F',
  74328. '�' => 'G',
  74329. '�' => 'J',
  74330. '�' => 'K',
  74331. '�' => 'L',
  74332. '�' => 'M',
  74333. '�' => 'N',
  74334. '�' => 'O',
  74335. '�' => 'P',
  74336. '�' => 'Q',
  74337. '�' => 'S',
  74338. '�' => 'T',
  74339. '�' => 'U',
  74340. '�' => 'V',
  74341. '�' => 'W',
  74342. '�' => 'X',
  74343. '�' => 'Y',
  74344. '�' => 'a',
  74345. '�' => 'b',
  74346. '�' => 'c',
  74347. '�' => 'd',
  74348. '�' => 'e',
  74349. '�' => 'f',
  74350. '�' => 'g',
  74351. '�' => 'h',
  74352. '�' => 'i',
  74353. '�' => 'j',
  74354. '�' => 'k',
  74355. '�' => 'l',
  74356. '�' => 'm',
  74357. '�' => 'n',
  74358. '�' => 'o',
  74359. '�' => 'p',
  74360. '�' => 'q',
  74361. '�' => 'r',
  74362. '�' => 's',
  74363. '�' => 't',
  74364. '�' => 'u',
  74365. '�' => 'v',
  74366. '�' => 'w',
  74367. '�' => 'x',
  74368. '�' => 'y',
  74369. '�' => 'z',
  74370. '�' => 'A',
  74371. '�' => 'B',
  74372. '�' => 'D',
  74373. '�' => 'E',
  74374. '�' => 'F',
  74375. '�' => 'G',
  74376. '�' => 'I',
  74377. '�' => 'J',
  74378. '�' => 'K',
  74379. '�' => 'L',
  74380. '�' => 'M',
  74381. '�' => 'O',
  74382. '�' => 'S',
  74383. '�' => 'T',
  74384. '�' => 'U',
  74385. '�' => 'V',
  74386. '�' => 'W',
  74387. '�' => 'X',
  74388. '�' => 'Y',
  74389. '�' => 'a',
  74390. '�' => 'b',
  74391. '�' => 'c',
  74392. '�' => 'd',
  74393. '�' => 'e',
  74394. '�' => 'f',
  74395. '�' => 'g',
  74396. '�' => 'h',
  74397. '�' => 'i',
  74398. '�' => 'j',
  74399. '�' => 'k',
  74400. '�' => 'l',
  74401. '�' => 'm',
  74402. '�' => 'n',
  74403. '�' => 'o',
  74404. '�' => 'p',
  74405. '�' => 'q',
  74406. '�' => 'r',
  74407. '�' => 's',
  74408. '�' => 't',
  74409. '�' => 'u',
  74410. '�' => 'v',
  74411. '�' => 'w',
  74412. '�' => 'x',
  74413. '�' => 'y',
  74414. '�' => 'z',
  74415. '�' => 'A',
  74416. '�' => 'B',
  74417. '�' => 'C',
  74418. '�' => 'D',
  74419. '�' => 'E',
  74420. '�' => 'F',
  74421. '�' => 'G',
  74422. '�' => 'H',
  74423. '�' => 'I',
  74424. '�' => 'J',
  74425. '�' => 'K',
  74426. '�' => 'L',
  74427. '�' => 'M',
  74428. '�' => 'N',
  74429. '�' => 'O',
  74430. '�' => 'P',
  74431. '�' => 'Q',
  74432. '�' => 'R',
  74433. '�' => 'S',
  74434. '�' => 'T',
  74435. '�' => 'U',
  74436. '�' => 'V',
  74437. '�' => 'W',
  74438. '�' => 'X',
  74439. '�' => 'Y',
  74440. '�' => 'Z',
  74441. '�' => 'a',
  74442. '�' => 'b',
  74443. '�' => 'c',
  74444. '�' => 'd',
  74445. '�' => 'e',
  74446. '�' => 'f',
  74447. '�' => 'g',
  74448. '�' => 'h',
  74449. '�' => 'i',
  74450. '�' => 'j',
  74451. '�' => 'k',
  74452. '�' => 'l',
  74453. '�' => 'm',
  74454. '�' => 'n',
  74455. '�' => 'o',
  74456. '�' => 'p',
  74457. '�' => 'q',
  74458. '�' => 'r',
  74459. '�' => 's',
  74460. '�' => 't',
  74461. '�' => 'u',
  74462. '�' => 'v',
  74463. '�' => 'w',
  74464. '�' => 'x',
  74465. '�' => 'y',
  74466. '�' => 'z',
  74467. '�' => 'A',
  74468. '�' => 'B',
  74469. '�' => 'C',
  74470. '�' => 'D',
  74471. '�' => 'E',
  74472. '�' => 'F',
  74473. '�' => 'G',
  74474. '�' => 'H',
  74475. '�' => 'I',
  74476. '�' => 'J',
  74477. '�' => 'K',
  74478. '�' => 'L',
  74479. '�' => 'M',
  74480. '�' => 'N',
  74481. '�' => 'O',
  74482. '�' => 'P',
  74483. '�' => 'Q',
  74484. '�' => 'R',
  74485. '�' => 'S',
  74486. '�' => 'T',
  74487. '�' => 'U',
  74488. '�' => 'V',
  74489. '�' => 'W',
  74490. '�' => 'X',
  74491. '�' => 'Y',
  74492. '�' => 'Z',
  74493. '�' => 'a',
  74494. '�' => 'b',
  74495. '�' => 'c',
  74496. '�' => 'd',
  74497. '�' => 'e',
  74498. '�' => 'f',
  74499. '�' => 'g',
  74500. '�' => 'h',
  74501. '�' => 'i',
  74502. '�' => 'j',
  74503. '�' => 'k',
  74504. '�' => 'l',
  74505. '�' => 'm',
  74506. '�' => 'n',
  74507. '�' => 'o',
  74508. '�' => 'p',
  74509. '�' => 'q',
  74510. '�' => 'r',
  74511. '�' => 's',
  74512. '�' => 't',
  74513. '�' => 'u',
  74514. '�' => 'v',
  74515. '�' => 'w',
  74516. '�' => 'x',
  74517. '�' => 'y',
  74518. '�' => 'z',
  74519. '�' => 'A',
  74520. '�' => 'B',
  74521. '�' => 'C',
  74522. '�' => 'D',
  74523. '�' => 'E',
  74524. '�' => 'F',
  74525. '�' => 'G',
  74526. '�' => 'H',
  74527. '�' => 'I',
  74528. '�' => 'J',
  74529. '�' => 'K',
  74530. '�' => 'L',
  74531. '�' => 'M',
  74532. '�' => 'N',
  74533. '�' => 'O',
  74534. '�' => 'P',
  74535. '�' => 'Q',
  74536. '�' => 'R',
  74537. '�' => 'S',
  74538. '�' => 'T',
  74539. '�' => 'U',
  74540. '�' => 'V',
  74541. '�' => 'W',
  74542. '�' => 'X',
  74543. '�' => 'Y',
  74544. '�' => 'Z',
  74545. '�' => 'a',
  74546. '�' => 'b',
  74547. '�' => 'c',
  74548. '�' => 'd',
  74549. '�' => 'e',
  74550. '�' => 'f',
  74551. '�' => 'g',
  74552. '�' => 'h',
  74553. '�' => 'i',
  74554. '�' => 'j',
  74555. '�' => 'k',
  74556. '�' => 'l',
  74557. '�' => 'm',
  74558. '�' => 'n',
  74559. '�' => 'o',
  74560. '�' => 'p',
  74561. '�' => 'q',
  74562. '�' => 'r',
  74563. '�' => 's',
  74564. '�' => 't',
  74565. '�' => 'u',
  74566. '�' => 'v',
  74567. '�' => 'w',
  74568. '�' => 'x',
  74569. '�' => 'y',
  74570. '�' => 'z',
  74571. '�' => 'A',
  74572. '�' => 'B',
  74573. '�' => 'C',
  74574. '�' => 'D',
  74575. '�' => 'E',
  74576. '�' => 'F',
  74577. '�' => 'G',
  74578. '�' => 'H',
  74579. '�' => 'I',
  74580. '�' => 'J',
  74581. '�' => 'K',
  74582. '�' => 'L',
  74583. '�' => 'M',
  74584. '�' => 'N',
  74585. '�' => 'O',
  74586. '�' => 'P',
  74587. '�' => 'Q',
  74588. '�' => 'R',
  74589. '�' => 'S',
  74590. '�' => 'T',
  74591. '�' => 'U',
  74592. '�' => 'V',
  74593. '�' => 'W',
  74594. '�' => 'X',
  74595. '�' => 'Y',
  74596. '�' => 'Z',
  74597. '�' => 'a',
  74598. '�' => 'b',
  74599. '�' => 'c',
  74600. '�' => 'd',
  74601. '�' => 'e',
  74602. '�' => 'f',
  74603. '�' => 'g',
  74604. '�' => 'h',
  74605. '�' => 'i',
  74606. '�' => 'j',
  74607. '�' => 'k',
  74608. '�' => 'l',
  74609. '�' => 'm',
  74610. '�' => 'n',
  74611. '�' => 'o',
  74612. '�' => 'p',
  74613. '�' => 'q',
  74614. '�' => 'r',
  74615. '�' => 's',
  74616. '�' => 't',
  74617. '�' => 'u',
  74618. '�' => 'v',
  74619. '�' => 'w',
  74620. '�' => 'x',
  74621. '�' => 'y',
  74622. '�' => 'z',
  74623. '�' => 'A',
  74624. '�' => 'B',
  74625. '�' => 'C',
  74626. '�' => 'D',
  74627. '�' => 'E',
  74628. '�' => 'F',
  74629. '�' => 'G',
  74630. '�' => 'H',
  74631. '�' => 'I',
  74632. '�' => 'J',
  74633. '�' => 'K',
  74634. '�' => 'L',
  74635. '�' => 'M',
  74636. '�' => 'N',
  74637. '�' => 'O',
  74638. '�' => 'P',
  74639. '�' => 'Q',
  74640. '�' => 'R',
  74641. '�' => 'S',
  74642. '�' => 'T',
  74643. '�' => 'U',
  74644. '�' => 'V',
  74645. '�' => 'W',
  74646. '�' => 'X',
  74647. '�' => 'Y',
  74648. '�' => 'Z',
  74649. '�' => 'a',
  74650. '�' => 'b',
  74651. '�' => 'c',
  74652. '�' => 'd',
  74653. '�' => 'e',
  74654. '�' => 'f',
  74655. '�' => 'g',
  74656. '�' => 'h',
  74657. '�' => 'i',
  74658. '�' => 'j',
  74659. '�' => 'k',
  74660. '�' => 'l',
  74661. '�' => 'm',
  74662. '�' => 'n',
  74663. '�' => 'o',
  74664. '�' => 'p',
  74665. '�' => 'q',
  74666. '�' => 'r',
  74667. '�' => 's',
  74668. '�' => 't',
  74669. '�' => 'u',
  74670. '�' => 'v',
  74671. '�' => 'w',
  74672. '�' => 'x',
  74673. '�' => 'y',
  74674. '�' => 'z',
  74675. '�' => 'A',
  74676. '�' => 'B',
  74677. '�' => 'C',
  74678. '�' => 'D',
  74679. '�' => 'E',
  74680. '�' => 'F',
  74681. '�' => 'G',
  74682. '�' => 'H',
  74683. '�' => 'I',
  74684. '�' => 'J',
  74685. '�' => 'K',
  74686. '�' => 'L',
  74687. '�' => 'M',
  74688. '�' => 'N',
  74689. '�' => 'O',
  74690. '�' => 'P',
  74691. '�' => 'Q',
  74692. '�' => 'R',
  74693. '�' => 'S',
  74694. '�' => 'T',
  74695. '�' => 'U',
  74696. '�' => 'V',
  74697. '�' => 'W',
  74698. '�' => 'X',
  74699. '�' => 'Y',
  74700. '�' => 'Z',
  74701. '�' => 'a',
  74702. '�' => 'b',
  74703. '�' => 'c',
  74704. '�' => 'd',
  74705. '�' => 'e',
  74706. '�' => 'f',
  74707. '�' => 'g',
  74708. '�' => 'h',
  74709. '�' => 'i',
  74710. '�' => 'j',
  74711. '�' => 'k',
  74712. '�' => 'l',
  74713. '�' => 'm',
  74714. '�' => 'n',
  74715. '�' => 'o',
  74716. '�' => 'p',
  74717. '�' => 'q',
  74718. '�' => 'r',
  74719. '�' => 's',
  74720. '�' => 't',
  74721. '�' => 'u',
  74722. '�' => 'v',
  74723. '�' => 'w',
  74724. '�' => 'x',
  74725. '�' => 'y',
  74726. '�' => 'z',
  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. '�' => 'α',
  74814. '�' => 'β',
  74815. '�' => 'γ',
  74816. '�' => 'δ',
  74817. '�' => 'ε',
  74818. '�' => 'ζ',
  74819. '�' => 'η',
  74820. '�' => 'θ',
  74821. '�' => 'ι',
  74822. '�' => 'κ',
  74823. '�' => 'λ',
  74824. '�' => 'μ',
  74825. '�' => 'ν',
  74826. '�' => 'ξ',
  74827. '�' => 'ο',
  74828. '�' => 'π',
  74829. '�' => '�',
  74830. '�' => 'ς',
  74831. '�' => 'σ',
  74832. '�' => 'τ',
  74833. '�' => 'υ',
  74834. '�' => 'φ',
  74835. '�' => 'χ',
  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. '�' => 'σ',
  74890. '�' => 'τ',
  74891. '�' => 'υ',
  74892. '�' => 'φ',
  74893. '�' => 'χ',
  74894. '�' => 'ψ',
  74895. '�' => 'ω',
  74896. '�' => '∂',
  74897. '�' => 'ε',
  74898. '�' => 'θ',
  74899. '�' => 'κ',
  74900. '�' => 'φ',
  74901. '�' => '�',
  74902. '�' => 'π',
  74903. '�' => 'Α',
  74904. '�' => 'Β',
  74905. '�' => 'Γ',
  74906. '�' => 'Δ',
  74907. '�' => 'Ε',
  74908. '�' => 'Ζ',
  74909. '�' => 'Η',
  74910. '�' => 'Θ',
  74911. '�' => 'Ι',
  74912. '�' => 'Κ',
  74913. '�' => 'Λ',
  74914. '�' => 'Μ',
  74915. '�' => '�',
  74916. '�' => 'Ξ',
  74917. '�' => 'Ο',
  74918. '�' => 'Π',
  74919. '�' => 'Ρ',
  74920. '�' => 'Θ',
  74921. '�' => 'Σ',
  74922. '�' => 'Τ',
  74923. '�' => 'Υ',
  74924. '�' => 'Φ',
  74925. '�' => 'Χ',
  74926. '�' => 'Ψ',
  74927. '�' => 'Ω',
  74928. '�' => '∇',
  74929. '�' => 'α',
  74930. '�' => 'β',
  74931. '�' => 'γ',
  74932. '�' => 'δ',
  74933. '�' => 'ε',
  74934. '�' => 'ζ',
  74935. '�' => 'η',
  74936. '�' => 'θ',
  74937. '�' => 'ι',
  74938. '�' => 'κ',
  74939. '�' => 'λ',
  74940. '�' => 'μ',
  74941. '�' => 'ν',
  74942. '�' => 'ξ',
  74943. '�' => 'ο',
  74944. '�' => 'π',
  74945. '�' => '�',
  74946. '�' => 'ς',
  74947. '�' => 'σ',
  74948. '�' => 'τ',
  74949. '�' => 'υ',
  74950. '�' => 'φ',
  74951. '�' => 'χ',
  74952. '�' => 'ψ',
  74953. '�' => 'ω',
  74954. '�' => '∂',
  74955. '�' => 'ε',
  74956. '�' => 'θ',
  74957. '�' => 'κ',
  74958. '�' => 'φ',
  74959. '�' => '�',
  74960. '�' => 'π',
  74961. '�' => 'Α',
  74962. '�' => 'Β',
  74963. '�' => 'Γ',
  74964. '�' => 'Δ',
  74965. '�' => 'Ε',
  74966. '�' => 'Ζ',
  74967. '�' => 'Η',
  74968. '�' => 'Θ',
  74969. '�' => 'Ι',
  74970. '�' => 'Κ',
  74971. '�' => 'Λ',
  74972. '�' => 'Μ',
  74973. '�' => '�',
  74974. '�' => 'Ξ',
  74975. '�' => 'Ο',
  74976. '�' => 'Π',
  74977. '�' => 'Ρ',
  74978. '�' => 'Θ',
  74979. '�' => 'Σ',
  74980. '�' => 'Τ',
  74981. '�' => 'Υ',
  74982. '�' => 'Φ',
  74983. '�' => 'Χ',
  74984. '�' => 'Ψ',
  74985. '�' => 'Ω',
  74986. '�' => '∇',
  74987. '�' => 'α',
  74988. '�' => 'β',
  74989. '�' => 'γ',
  74990. '�' => 'δ',
  74991. '�' => 'ε',
  74992. '�' => 'ζ',
  74993. '�' => 'η',
  74994. '�' => 'θ',
  74995. '�' => 'ι',
  74996. '�' => 'κ',
  74997. '�' => 'λ',
  74998. '�' => 'μ',
  74999. '�' => 'ν',
  75000. '�' => 'ξ',
  75001. '�' => 'ο',
  75002. '�' => 'π',
  75003. '�' => '�',
  75004. '�' => 'ς',
  75005. '�' => 'σ',
  75006. '�' => 'τ',
  75007. '�' => 'υ',
  75008. '�' => 'φ',
  75009. '�' => 'χ',
  75010. '�' => 'ψ',
  75011. '�' => 'ω',
  75012. '�' => '∂',
  75013. '�' => 'ε',
  75014. '�' => 'θ',
  75015. '�' => 'κ',
  75016. '�' => 'φ',
  75017. '�' => '�',
  75018. '�' => 'π',
  75019. '�' => 'Ϝ',
  75020. '�' => '�',
  75021. '�' => '0',
  75022. '�' => '1',
  75023. '�' => '2',
  75024. '�' => '3',
  75025. '�' => '4',
  75026. '�' => '5',
  75027. '�' => '6',
  75028. '�' => '7',
  75029. '�' => '8',
  75030. '�' => '9',
  75031. '�' => '0',
  75032. '�' => '1',
  75033. '�' => '2',
  75034. '�' => '3',
  75035. '�' => '4',
  75036. '�' => '5',
  75037. '�' => '6',
  75038. '�' => '7',
  75039. '�' => '8',
  75040. '�' => '9',
  75041. '�' => '0',
  75042. '�' => '1',
  75043. '�' => '2',
  75044. '�' => '3',
  75045. '�' => '4',
  75046. '�' => '5',
  75047. '�' => '6',
  75048. '�' => '7',
  75049. '�' => '8',
  75050. '�' => '9',
  75051. '�' => '0',
  75052. '�' => '1',
  75053. '�' => '2',
  75054. '�' => '3',
  75055. '�' => '4',
  75056. '�' => '5',
  75057. '�' => '6',
  75058. '�' => '7',
  75059. '�' => '8',
  75060. '�' => '9',
  75061. '�' => '0',
  75062. '�' => '1',
  75063. '�' => '2',
  75064. '�' => '3',
  75065. '�' => '4',
  75066. '�' => '5',
  75067. '�' => '6',
  75068. '�' => '7',
  75069. '�' => '8',
  75070. '�' => '9',
  75071. '𞸀' => 'ا',
  75072. '�' => 'ب',
  75073. '𞸂' => 'ج',
  75074. '𞸃' => 'د',
  75075. '𞸅' => 'و',
  75076. '𞸆' => 'ز',
  75077. '𞸇' => 'ح',
  75078. '𞸈' => 'ط',
  75079. '𞸉' => 'ي',
  75080. '𞸊' => 'ك',
  75081. '𞸋' => 'ل',
  75082. '𞸌' => 'م',
  75083. '�' => 'ن',
  75084. '𞸎' => 'س',
  75085. '�' => 'ع',
  75086. '�' => '�',
  75087. '𞸑' => 'ص',
  75088. '𞸒' => 'ق',
  75089. '𞸓' => 'ر',
  75090. '𞸔' => 'ش',
  75091. '𞸕' => 'ت',
  75092. '𞸖' => 'ث',
  75093. '𞸗' => 'خ',
  75094. '𞸘' => 'ذ',
  75095. '𞸙' => 'ض',
  75096. '𞸚' => 'ظ',
  75097. '𞸛' => 'غ',
  75098. '𞸜' => 'ٮ',
  75099. '�' => 'ں',
  75100. '𞸞' => 'ڡ',
  75101. '𞸟' => 'ٯ',
  75102. '𞸡' => 'ب',
  75103. '𞸢' => 'ج',
  75104. '𞸤' => 'ه',
  75105. '𞸧' => 'ح',
  75106. '𞸩' => 'ي',
  75107. '𞸪' => 'ك',
  75108. '𞸫' => 'ل',
  75109. '𞸬' => 'م',
  75110. '𞸭' => 'ن',
  75111. '𞸮' => 'س',
  75112. '𞸯' => 'ع',
  75113. '𞸰' => '�',
  75114. '𞸱' => 'ص',
  75115. '𞸲' => 'ق',
  75116. '𞸴' => 'ش',
  75117. '𞸵' => 'ت',
  75118. '𞸶' => 'ث',
  75119. '𞸷' => 'خ',
  75120. '𞸹' => 'ض',
  75121. '𞸻' => 'غ',
  75122. '𞹂' => 'ج',
  75123. '𞹇' => 'ح',
  75124. '𞹉' => 'ي',
  75125. '𞹋' => 'ل',
  75126. '�' => 'ن',
  75127. '𞹎' => 'س',
  75128. '�' => 'ع',
  75129. '𞹑' => 'ص',
  75130. 'ðž¹’' => 'Ù‚',
  75131. 'ðž¹”' => 'Ø´',
  75132. 'ðž¹—' => 'Ø®',
  75133. '𞹙' => 'ض',
  75134. '𞹛' => 'غ',
  75135. '�' => 'ں',
  75136. '𞹟' => 'ٯ',
  75137. '𞹡' => 'ب',
  75138. '𞹢' => 'ج',
  75139. '𞹤' => 'ه',
  75140. 'ðž¹§' => 'Ø­',
  75141. '𞹨' => 'ط',
  75142. '𞹩' => 'ي',
  75143. '𞹪' => 'ك',
  75144. '𞹬' => 'م',
  75145. 'ðž¹­' => 'Ù†',
  75146. '𞹮' => 'س',
  75147. '𞹯' => 'ع',
  75148. 'ðž¹°' => 'Ù�',
  75149. '𞹱' => 'ص',
  75150. 'ðž¹²' => 'Ù‚',
  75151. 'ðž¹´' => 'Ø´',
  75152. '𞹵' => 'ت',
  75153. 'ðž¹¶' => 'Ø«',
  75154. 'ðž¹·' => 'Ø®',
  75155. '𞹹' => 'ض',
  75156. '𞹺' => 'ظ',
  75157. '𞹻' => 'غ',
  75158. 'ðž¹¼' => 'Ù®',
  75159. 'ðž¹¾' => 'Ú¡',
  75160. '𞺀' => 'ا',
  75161. '�' => 'ب',
  75162. '𞺂' => 'ج',
  75163. '𞺃' => 'د',
  75164. '𞺄' => 'ه',
  75165. '𞺅' => 'و',
  75166. '𞺆' => 'ز',
  75167. '𞺇' => 'ح',
  75168. '𞺈' => 'ط',
  75169. '𞺉' => 'ي',
  75170. '𞺋' => 'ل',
  75171. '𞺌' => 'م',
  75172. '�' => 'ن',
  75173. '𞺎' => 'س',
  75174. '�' => 'ع',
  75175. '�' => '�',
  75176. '𞺑' => 'ص',
  75177. '𞺒' => 'ق',
  75178. '𞺓' => 'ر',
  75179. '𞺔' => 'ش',
  75180. '𞺕' => 'ت',
  75181. '𞺖' => 'ث',
  75182. '𞺗' => 'خ',
  75183. '𞺘' => 'ذ',
  75184. '𞺙' => 'ض',
  75185. '𞺚' => 'ظ',
  75186. '𞺛' => 'غ',
  75187. '𞺡' => 'ب',
  75188. '𞺢' => 'ج',
  75189. '𞺣' => 'د',
  75190. '𞺥' => 'و',
  75191. '𞺦' => 'ز',
  75192. '𞺧' => 'ح',
  75193. '𞺨' => 'ط',
  75194. '𞺩' => 'ي',
  75195. '𞺫' => 'ل',
  75196. '𞺬' => 'م',
  75197. '𞺭' => 'ن',
  75198. '𞺮' => 'س',
  75199. '𞺯' => 'ع',
  75200. '𞺰' => '�',
  75201. '𞺱' => 'ص',
  75202. '𞺲' => 'ق',
  75203. '𞺳' => 'ر',
  75204. '𞺴' => 'ش',
  75205. '𞺵' => 'ت',
  75206. '𞺶' => 'ث',
  75207. '𞺷' => 'خ',
  75208. '𞺸' => 'ذ',
  75209. '𞺹' => 'ض',
  75210. '𞺺' => 'ظ',
  75211. '𞺻' => 'غ',
  75212. '🄀' => '0.',
  75213. '�' => '0,',
  75214. '🄂' => '1,',
  75215. '🄃' => '2,',
  75216. '🄄' => '3,',
  75217. '🄅' => '4,',
  75218. '🄆' => '5,',
  75219. '🄇' => '6,',
  75220. '🄈' => '7,',
  75221. '🄉' => '8,',
  75222. '🄊' => '9,',
  75223. '�' => '(A)',
  75224. '🄑' => '(B)',
  75225. '🄒' => '(C)',
  75226. '🄓' => '(D)',
  75227. '🄔' => '(E)',
  75228. '🄕' => '(F)',
  75229. '🄖' => '(G)',
  75230. '🄗' => '(H)',
  75231. '🄘' => '(I)',
  75232. '🄙' => '(J)',
  75233. '🄚' => '(K)',
  75234. '🄛' => '(L)',
  75235. '🄜' => '(M)',
  75236. '�' => '(N)',
  75237. '🄞' => '(O)',
  75238. '🄟' => '(P)',
  75239. '🄠' => '(Q)',
  75240. '🄡' => '(R)',
  75241. '🄢' => '(S)',
  75242. '🄣' => '(T)',
  75243. '🄤' => '(U)',
  75244. '🄥' => '(V)',
  75245. '🄦' => '(W)',
  75246. '🄧' => '(X)',
  75247. '🄨' => '(Y)',
  75248. '🄩' => '(Z)',
  75249. '🄪' => '〔S〕',
  75250. '🄫' => 'C',
  75251. '🄬' => 'R',
  75252. '🄭' => 'CD',
  75253. '🄮' => 'WZ',
  75254. '🄰' => 'A',
  75255. '🄱' => 'B',
  75256. '🄲' => 'C',
  75257. '🄳' => 'D',
  75258. '🄴' => 'E',
  75259. '🄵' => 'F',
  75260. '🄶' => 'G',
  75261. '🄷' => 'H',
  75262. '🄸' => 'I',
  75263. '🄹' => 'J',
  75264. '🄺' => 'K',
  75265. '🄻' => 'L',
  75266. '🄼' => 'M',
  75267. '🄽' => 'N',
  75268. '🄾' => 'O',
  75269. '🄿' => 'P',
  75270. '🅀' => 'Q',
  75271. '�' => 'R',
  75272. '🅂' => 'S',
  75273. '🅃' => 'T',
  75274. '🅄' => 'U',
  75275. '🅅' => 'V',
  75276. '🅆' => 'W',
  75277. '🅇' => 'X',
  75278. '🅈' => 'Y',
  75279. '🅉' => 'Z',
  75280. '🅊' => 'HV',
  75281. '🅋' => 'MV',
  75282. '🅌' => 'SD',
  75283. '�' => 'SS',
  75284. '🅎' => 'PPV',
  75285. '�' => 'WC',
  75286. '🅪' => 'MC',
  75287. '🅫' => 'MD',
  75288. '🅬' => 'MR',
  75289. '�' => 'DJ',
  75290. '🈀' => '��',
  75291. '�' => 'ココ',
  75292. '🈂' => 'サ',
  75293. '�' => '手',
  75294. '🈑' => '字',
  75295. '🈒' => '�',
  75296. '🈓' => 'デ',
  75297. '🈔' => '二',
  75298. '🈕' => '多',
  75299. '🈖' => '解',
  75300. '🈗' => '天',
  75301. '🈘' => '交',
  75302. '🈙' => '映',
  75303. '🈚' => '無',
  75304. '🈛' => '料',
  75305. '🈜' => '�',
  75306. '�' => '後',
  75307. '🈞' => '�',
  75308. '🈟' => '新',
  75309. '🈠' => '�',
  75310. '🈡' => '終',
  75311. '🈢' => '生',
  75312. '🈣' => '販',
  75313. '🈤' => '声',
  75314. '🈥' => '�',
  75315. '🈦' => '演',
  75316. '🈧' => '投',
  75317. '🈨' => '�',
  75318. '🈩' => '一',
  75319. '🈪' => '三',
  75320. '🈫' => '�',
  75321. '🈬' => '左',
  75322. '🈭' => '中',
  75323. '🈮' => '�',
  75324. '🈯' => '指',
  75325. '🈰' => '走',
  75326. '🈱' => '打',
  75327. '🈲' => '�',
  75328. '🈳' => '空',
  75329. '🈴' => '�',
  75330. '🈵' => '満',
  75331. '🈶' => '有',
  75332. '🈷' => '月',
  75333. '🈸' => '申',
  75334. '🈹' => '割',
  75335. '🈺' => '営',
  75336. '🈻' => '�',
  75337. '🉀' => '〔本〕',
  75338. '�' => '〔三〕',
  75339. '🉂' => '〔二〕',
  75340. '🉃' => '〔安〕',
  75341. '🉄' => '〔点〕',
  75342. '🉅' => '〔打〕',
  75343. '🉆' => '〔盗〕',
  75344. '🉇' => '〔�〕',
  75345. '🉈' => '〔敗〕',
  75346. '�' => '得',
  75347. '🉑' => '�',
  75348. '🯰' => '0',
  75349. '🯱' => '1',
  75350. '🯲' => '2',
  75351. '🯳' => '3',
  75352. '🯴' => '4',
  75353. '🯵' => '5',
  75354. '🯶' => '6',
  75355. '🯷' => '7',
  75356. '🯸' => '8',
  75357. '🯹' => '9',
  75358. );
  75359. <?php
  75360. use Symfony\Polyfill\Intl\Normalizer as p;
  75361. if (\PHP_VERSION_ID >= 80000) {
  75362. return require __DIR__.'/bootstrap80.php';
  75363. }
  75364. if (!function_exists('normalizer_is_normalized')) {
  75365. function normalizer_is_normalized($string, $form = p\Normalizer::FORM_C) { return p\Normalizer::isNormalized($string, $form); }
  75366. }
  75367. if (!function_exists('normalizer_normalize')) {
  75368. function normalizer_normalize($string, $form = p\Normalizer::FORM_C) { return p\Normalizer::normalize($string, $form); }
  75369. }
  75370. <?php
  75371. use Symfony\Polyfill\Intl\Normalizer as p;
  75372. if (!function_exists('normalizer_is_normalized')) {
  75373. function normalizer_is_normalized(?string $string, ?int $form = p\Normalizer::FORM_C): bool { return p\Normalizer::isNormalized((string) $string, (int) $form); }
  75374. }
  75375. if (!function_exists('normalizer_normalize')) {
  75376. function normalizer_normalize(?string $string, ?int $form = p\Normalizer::FORM_C): string|false { return p\Normalizer::normalize((string) $string, (int) $form); }
  75377. }
  75378. Copyright (c) 2015-present Fabien Potencier
  75379. Permission is hereby granted, free of charge, to any person obtaining a copy
  75380. of this software and associated documentation files (the "Software"), to deal
  75381. in the Software without restriction, including without limitation the rights
  75382. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  75383. copies of the Software, and to permit persons to whom the Software is furnished
  75384. to do so, subject to the following conditions:
  75385. The above copyright notice and this permission notice shall be included in all
  75386. copies or substantial portions of the Software.
  75387. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  75388. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  75389. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  75390. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  75391. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  75392. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  75393. THE SOFTWARE.
  75394. <?php
  75395. namespace Symfony\Polyfill\Mbstring;
  75396. final class Mbstring
  75397. {
  75398. public const MB_CASE_FOLD = \PHP_INT_MAX;
  75399. private const SIMPLE_CASE_FOLD = [
  75400. ['µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"],
  75401. ['μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', '�', 'ε', "\xE1\xB9\xA1", 'ι'],
  75402. ];
  75403. private static $encodingList = ['ASCII', 'UTF-8'];
  75404. private static $language = 'neutral';
  75405. private static $internalEncoding = 'UTF-8';
  75406. public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
  75407. {
  75408. if (\is_array($fromEncoding) || (null !== $fromEncoding && false !== strpos($fromEncoding, ','))) {
  75409. $fromEncoding = self::mb_detect_encoding($s, $fromEncoding);
  75410. } else {
  75411. $fromEncoding = self::getEncoding($fromEncoding);
  75412. }
  75413. $toEncoding = self::getEncoding($toEncoding);
  75414. if ('BASE64' === $fromEncoding) {
  75415. $s = base64_decode($s);
  75416. $fromEncoding = $toEncoding;
  75417. }
  75418. if ('BASE64' === $toEncoding) {
  75419. return base64_encode($s);
  75420. }
  75421. if ('HTML-ENTITIES' === $toEncoding || 'HTML' === $toEncoding) {
  75422. if ('HTML-ENTITIES' === $fromEncoding || 'HTML' === $fromEncoding) {
  75423. $fromEncoding = 'Windows-1252';
  75424. }
  75425. if ('UTF-8' !== $fromEncoding) {
  75426. $s = iconv($fromEncoding, 'UTF-8//IGNORE', $s);
  75427. }
  75428. return preg_replace_callback('/[\x80-\xFF]+/', [__CLASS__, 'html_encoding_callback'], $s);
  75429. }
  75430. if ('HTML-ENTITIES' === $fromEncoding) {
  75431. $s = html_entity_decode($s, \ENT_COMPAT, 'UTF-8');
  75432. $fromEncoding = 'UTF-8';
  75433. }
  75434. return iconv($fromEncoding, $toEncoding.'//IGNORE', $s);
  75435. }
  75436. public static function mb_convert_variables($toEncoding, $fromEncoding, &...$vars)
  75437. {
  75438. $ok = true;
  75439. array_walk_recursive($vars, function (&$v) use (&$ok, $toEncoding, $fromEncoding) {
  75440. if (false === $v = self::mb_convert_encoding($v, $toEncoding, $fromEncoding)) {
  75441. $ok = false;
  75442. }
  75443. });
  75444. return $ok ? $fromEncoding : false;
  75445. }
  75446. public static function mb_decode_mimeheader($s)
  75447. {
  75448. return iconv_mime_decode($s, 2, self::$internalEncoding);
  75449. }
  75450. public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null)
  75451. {
  75452. trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', \E_USER_WARNING);
  75453. }
  75454. public static function mb_decode_numericentity($s, $convmap, $encoding = null)
  75455. {
  75456. if (null !== $s && !\is_scalar($s) && !(\is_object($s) && method_exists($s, '__toString'))) {
  75457. trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', \E_USER_WARNING);
  75458. return null;
  75459. }
  75460. if (!\is_array($convmap) || (80000 > \PHP_VERSION_ID && !$convmap)) {
  75461. return false;
  75462. }
  75463. if (null !== $encoding && !\is_scalar($encoding)) {
  75464. trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', \E_USER_WARNING);
  75465. return '';
  75466. }
  75467. $s = (string) $s;
  75468. if ('' === $s) {
  75469. return '';
  75470. }
  75471. $encoding = self::getEncoding($encoding);
  75472. if ('UTF-8' === $encoding) {
  75473. $encoding = null;
  75474. if (!preg_match('//u', $s)) {
  75475. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  75476. }
  75477. } else {
  75478. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  75479. }
  75480. $cnt = floor(\count($convmap) / 4) * 4;
  75481. for ($i = 0; $i < $cnt; $i += 4) {
  75482. $convmap[$i] += $convmap[$i + 2];
  75483. $convmap[$i + 1] += $convmap[$i + 2];
  75484. }
  75485. $s = preg_replace_callback('/&#(?:0*([0-9]+)|x0*([0-9a-fA-F]+))(?!&);?/', function (array $m) use ($cnt, $convmap) {
  75486. $c = isset($m[2]) ? (int) hexdec($m[2]) : $m[1];
  75487. for ($i = 0; $i < $cnt; $i += 4) {
  75488. if ($c >= $convmap[$i] && $c <= $convmap[$i + 1]) {
  75489. return self::mb_chr($c - $convmap[$i + 2]);
  75490. }
  75491. }
  75492. return $m[0];
  75493. }, $s);
  75494. if (null === $encoding) {
  75495. return $s;
  75496. }
  75497. return iconv('UTF-8', $encoding.'//IGNORE', $s);
  75498. }
  75499. public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false)
  75500. {
  75501. if (null !== $s && !\is_scalar($s) && !(\is_object($s) && method_exists($s, '__toString'))) {
  75502. trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', \E_USER_WARNING);
  75503. return null;
  75504. }
  75505. if (!\is_array($convmap) || (80000 > \PHP_VERSION_ID && !$convmap)) {
  75506. return false;
  75507. }
  75508. if (null !== $encoding && !\is_scalar($encoding)) {
  75509. trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', \E_USER_WARNING);
  75510. return null;
  75511. }
  75512. if (null !== $is_hex && !\is_scalar($is_hex)) {
  75513. trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.\gettype($s).' given', \E_USER_WARNING);
  75514. return null;
  75515. }
  75516. $s = (string) $s;
  75517. if ('' === $s) {
  75518. return '';
  75519. }
  75520. $encoding = self::getEncoding($encoding);
  75521. if ('UTF-8' === $encoding) {
  75522. $encoding = null;
  75523. if (!preg_match('//u', $s)) {
  75524. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  75525. }
  75526. } else {
  75527. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  75528. }
  75529. static $ulenMask = ["\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4];
  75530. $cnt = floor(\count($convmap) / 4) * 4;
  75531. $i = 0;
  75532. $len = \strlen($s);
  75533. $result = '';
  75534. while ($i < $len) {
  75535. $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
  75536. $uchr = substr($s, $i, $ulen);
  75537. $i += $ulen;
  75538. $c = self::mb_ord($uchr);
  75539. for ($j = 0; $j < $cnt; $j += 4) {
  75540. if ($c >= $convmap[$j] && $c <= $convmap[$j + 1]) {
  75541. $cOffset = ($c + $convmap[$j + 2]) & $convmap[$j + 3];
  75542. $result .= $is_hex ? sprintf('&#x%X;', $cOffset) : '&#'.$cOffset.';';
  75543. continue 2;
  75544. }
  75545. }
  75546. $result .= $uchr;
  75547. }
  75548. if (null === $encoding) {
  75549. return $result;
  75550. }
  75551. return iconv('UTF-8', $encoding.'//IGNORE', $result);
  75552. }
  75553. public static function mb_convert_case($s, $mode, $encoding = null)
  75554. {
  75555. $s = (string) $s;
  75556. if ('' === $s) {
  75557. return '';
  75558. }
  75559. $encoding = self::getEncoding($encoding);
  75560. if ('UTF-8' === $encoding) {
  75561. $encoding = null;
  75562. if (!preg_match('//u', $s)) {
  75563. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  75564. }
  75565. } else {
  75566. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  75567. }
  75568. if (\MB_CASE_TITLE == $mode) {
  75569. static $titleRegexp = null;
  75570. if (null === $titleRegexp) {
  75571. $titleRegexp = self::getData('titleCaseRegexp');
  75572. }
  75573. $s = preg_replace_callback($titleRegexp, [__CLASS__, 'title_case'], $s);
  75574. } else {
  75575. if (\MB_CASE_UPPER == $mode) {
  75576. static $upper = null;
  75577. if (null === $upper) {
  75578. $upper = self::getData('upperCase');
  75579. }
  75580. $map = $upper;
  75581. } else {
  75582. if (self::MB_CASE_FOLD === $mode) {
  75583. static $caseFolding = null;
  75584. if (null === $caseFolding) {
  75585. $caseFolding = self::getData('caseFolding');
  75586. }
  75587. $s = strtr($s, $caseFolding);
  75588. }
  75589. static $lower = null;
  75590. if (null === $lower) {
  75591. $lower = self::getData('lowerCase');
  75592. }
  75593. $map = $lower;
  75594. }
  75595. static $ulenMask = ["\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4];
  75596. $i = 0;
  75597. $len = \strlen($s);
  75598. while ($i < $len) {
  75599. $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
  75600. $uchr = substr($s, $i, $ulen);
  75601. $i += $ulen;
  75602. if (isset($map[$uchr])) {
  75603. $uchr = $map[$uchr];
  75604. $nlen = \strlen($uchr);
  75605. if ($nlen == $ulen) {
  75606. $nlen = $i;
  75607. do {
  75608. $s[--$nlen] = $uchr[--$ulen];
  75609. } while ($ulen);
  75610. } else {
  75611. $s = substr_replace($s, $uchr, $i - $ulen, $ulen);
  75612. $len += $nlen - $ulen;
  75613. $i += $nlen - $ulen;
  75614. }
  75615. }
  75616. }
  75617. }
  75618. if (null === $encoding) {
  75619. return $s;
  75620. }
  75621. return iconv('UTF-8', $encoding.'//IGNORE', $s);
  75622. }
  75623. public static function mb_internal_encoding($encoding = null)
  75624. {
  75625. if (null === $encoding) {
  75626. return self::$internalEncoding;
  75627. }
  75628. $normalizedEncoding = self::getEncoding($encoding);
  75629. if ('UTF-8' === $normalizedEncoding || false !== @iconv($normalizedEncoding, $normalizedEncoding, ' ')) {
  75630. self::$internalEncoding = $normalizedEncoding;
  75631. return true;
  75632. }
  75633. if (80000 > \PHP_VERSION_ID) {
  75634. return false;
  75635. }
  75636. throw new \ValueError(sprintf('Argument #1 ($encoding) must be a valid encoding, "%s" given', $encoding));
  75637. }
  75638. public static function mb_language($lang = null)
  75639. {
  75640. if (null === $lang) {
  75641. return self::$language;
  75642. }
  75643. switch ($normalizedLang = strtolower($lang)) {
  75644. case 'uni':
  75645. case 'neutral':
  75646. self::$language = $normalizedLang;
  75647. return true;
  75648. }
  75649. if (80000 > \PHP_VERSION_ID) {
  75650. return false;
  75651. }
  75652. throw new \ValueError(sprintf('Argument #1 ($language) must be a valid language, "%s" given', $lang));
  75653. }
  75654. public static function mb_list_encodings()
  75655. {
  75656. return ['UTF-8'];
  75657. }
  75658. public static function mb_encoding_aliases($encoding)
  75659. {
  75660. switch (strtoupper($encoding)) {
  75661. case 'UTF8':
  75662. case 'UTF-8':
  75663. return ['utf8'];
  75664. }
  75665. return false;
  75666. }
  75667. public static function mb_check_encoding($var = null, $encoding = null)
  75668. {
  75669. if (PHP_VERSION_ID < 70200 && \is_array($var)) {
  75670. trigger_error('mb_check_encoding() expects parameter 1 to be string, array given', \E_USER_WARNING);
  75671. return null;
  75672. }
  75673. if (null === $encoding) {
  75674. if (null === $var) {
  75675. return false;
  75676. }
  75677. $encoding = self::$internalEncoding;
  75678. }
  75679. if (!\is_array($var)) {
  75680. return self::mb_detect_encoding($var, [$encoding]) || false !== @iconv($encoding, $encoding, $var);
  75681. }
  75682. foreach ($var as $key => $value) {
  75683. if (!self::mb_check_encoding($key, $encoding)) {
  75684. return false;
  75685. }
  75686. if (!self::mb_check_encoding($value, $encoding)) {
  75687. return false;
  75688. }
  75689. }
  75690. return true;
  75691. }
  75692. public static function mb_detect_encoding($str, $encodingList = null, $strict = false)
  75693. {
  75694. if (null === $encodingList) {
  75695. $encodingList = self::$encodingList;
  75696. } else {
  75697. if (!\is_array($encodingList)) {
  75698. $encodingList = array_map('trim', explode(',', $encodingList));
  75699. }
  75700. $encodingList = array_map('strtoupper', $encodingList);
  75701. }
  75702. foreach ($encodingList as $enc) {
  75703. switch ($enc) {
  75704. case 'ASCII':
  75705. if (!preg_match('/[\x80-\xFF]/', $str)) {
  75706. return $enc;
  75707. }
  75708. break;
  75709. case 'UTF8':
  75710. case 'UTF-8':
  75711. if (preg_match('//u', $str)) {
  75712. return 'UTF-8';
  75713. }
  75714. break;
  75715. default:
  75716. if (0 === strncmp($enc, 'ISO-8859-', 9)) {
  75717. return $enc;
  75718. }
  75719. }
  75720. }
  75721. return false;
  75722. }
  75723. public static function mb_detect_order($encodingList = null)
  75724. {
  75725. if (null === $encodingList) {
  75726. return self::$encodingList;
  75727. }
  75728. if (!\is_array($encodingList)) {
  75729. $encodingList = array_map('trim', explode(',', $encodingList));
  75730. }
  75731. $encodingList = array_map('strtoupper', $encodingList);
  75732. foreach ($encodingList as $enc) {
  75733. switch ($enc) {
  75734. default:
  75735. if (strncmp($enc, 'ISO-8859-', 9)) {
  75736. return false;
  75737. }
  75738. case 'ASCII':
  75739. case 'UTF8':
  75740. case 'UTF-8':
  75741. }
  75742. }
  75743. self::$encodingList = $encodingList;
  75744. return true;
  75745. }
  75746. public static function mb_strlen($s, $encoding = null)
  75747. {
  75748. $encoding = self::getEncoding($encoding);
  75749. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  75750. return \strlen($s);
  75751. }
  75752. return @iconv_strlen($s, $encoding);
  75753. }
  75754. public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null)
  75755. {
  75756. $encoding = self::getEncoding($encoding);
  75757. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  75758. return strpos($haystack, $needle, $offset);
  75759. }
  75760. $needle = (string) $needle;
  75761. if ('' === $needle) {
  75762. if (80000 > \PHP_VERSION_ID) {
  75763. trigger_error(__METHOD__.': Empty delimiter', \E_USER_WARNING);
  75764. return false;
  75765. }
  75766. return 0;
  75767. }
  75768. return iconv_strpos($haystack, $needle, $offset, $encoding);
  75769. }
  75770. public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null)
  75771. {
  75772. $encoding = self::getEncoding($encoding);
  75773. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  75774. return strrpos($haystack, $needle, $offset);
  75775. }
  75776. if ($offset != (int) $offset) {
  75777. $offset = 0;
  75778. } elseif ($offset = (int) $offset) {
  75779. if ($offset < 0) {
  75780. if (0 > $offset += self::mb_strlen($needle)) {
  75781. $haystack = self::mb_substr($haystack, 0, $offset, $encoding);
  75782. }
  75783. $offset = 0;
  75784. } else {
  75785. $haystack = self::mb_substr($haystack, $offset, 2147483647, $encoding);
  75786. }
  75787. }
  75788. $pos = '' !== $needle || 80000 > \PHP_VERSION_ID
  75789. ? iconv_strrpos($haystack, $needle, $encoding)
  75790. : self::mb_strlen($haystack, $encoding);
  75791. return false !== $pos ? $offset + $pos : false;
  75792. }
  75793. public static function mb_str_split($string, $split_length = 1, $encoding = null)
  75794. {
  75795. if (null !== $string && !\is_scalar($string) && !(\is_object($string) && method_exists($string, '__toString'))) {
  75796. trigger_error('mb_str_split() expects parameter 1 to be string, '.\gettype($string).' given', \E_USER_WARNING);
  75797. return null;
  75798. }
  75799. if (1 > $split_length = (int) $split_length) {
  75800. if (80000 > \PHP_VERSION_ID) {
  75801. trigger_error('The length of each segment must be greater than zero', \E_USER_WARNING);
  75802. return false;
  75803. }
  75804. throw new \ValueError('Argument #2 ($length) must be greater than 0');
  75805. }
  75806. if (null === $encoding) {
  75807. $encoding = mb_internal_encoding();
  75808. }
  75809. if ('UTF-8' === $encoding = self::getEncoding($encoding)) {
  75810. $rx = '/(';
  75811. while (65535 < $split_length) {
  75812. $rx .= '.{65535}';
  75813. $split_length -= 65535;
  75814. }
  75815. $rx .= '.{'.$split_length.'})/us';
  75816. return preg_split($rx, $string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY);
  75817. }
  75818. $result = [];
  75819. $length = mb_strlen($string, $encoding);
  75820. for ($i = 0; $i < $length; $i += $split_length) {
  75821. $result[] = mb_substr($string, $i, $split_length, $encoding);
  75822. }
  75823. return $result;
  75824. }
  75825. public static function mb_strtolower($s, $encoding = null)
  75826. {
  75827. return self::mb_convert_case($s, \MB_CASE_LOWER, $encoding);
  75828. }
  75829. public static function mb_strtoupper($s, $encoding = null)
  75830. {
  75831. return self::mb_convert_case($s, \MB_CASE_UPPER, $encoding);
  75832. }
  75833. public static function mb_substitute_character($c = null)
  75834. {
  75835. if (null === $c) {
  75836. return 'none';
  75837. }
  75838. if (0 === strcasecmp($c, 'none')) {
  75839. return true;
  75840. }
  75841. if (80000 > \PHP_VERSION_ID) {
  75842. return false;
  75843. }
  75844. if (\is_int($c) || 'long' === $c || 'entity' === $c) {
  75845. return false;
  75846. }
  75847. throw new \ValueError('Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint');
  75848. }
  75849. public static function mb_substr($s, $start, $length = null, $encoding = null)
  75850. {
  75851. $encoding = self::getEncoding($encoding);
  75852. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  75853. return (string) substr($s, $start, null === $length ? 2147483647 : $length);
  75854. }
  75855. if ($start < 0) {
  75856. $start = iconv_strlen($s, $encoding) + $start;
  75857. if ($start < 0) {
  75858. $start = 0;
  75859. }
  75860. }
  75861. if (null === $length) {
  75862. $length = 2147483647;
  75863. } elseif ($length < 0) {
  75864. $length = iconv_strlen($s, $encoding) + $length - $start;
  75865. if ($length < 0) {
  75866. return '';
  75867. }
  75868. }
  75869. return (string) iconv_substr($s, $start, $length, $encoding);
  75870. }
  75871. public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null)
  75872. {
  75873. [$haystack, $needle] = str_replace(self::SIMPLE_CASE_FOLD[0], self::SIMPLE_CASE_FOLD[1], [
  75874. self::mb_convert_case($haystack, \MB_CASE_LOWER, $encoding),
  75875. self::mb_convert_case($needle, \MB_CASE_LOWER, $encoding),
  75876. ]);
  75877. return self::mb_strpos($haystack, $needle, $offset, $encoding);
  75878. }
  75879. public static function mb_stristr($haystack, $needle, $part = false, $encoding = null)
  75880. {
  75881. $pos = self::mb_stripos($haystack, $needle, 0, $encoding);
  75882. return self::getSubpart($pos, $part, $haystack, $encoding);
  75883. }
  75884. public static function mb_strrchr($haystack, $needle, $part = false, $encoding = null)
  75885. {
  75886. $encoding = self::getEncoding($encoding);
  75887. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  75888. $pos = strrpos($haystack, $needle);
  75889. } else {
  75890. $needle = self::mb_substr($needle, 0, 1, $encoding);
  75891. $pos = iconv_strrpos($haystack, $needle, $encoding);
  75892. }
  75893. return self::getSubpart($pos, $part, $haystack, $encoding);
  75894. }
  75895. public static function mb_strrichr($haystack, $needle, $part = false, $encoding = null)
  75896. {
  75897. $needle = self::mb_substr($needle, 0, 1, $encoding);
  75898. $pos = self::mb_strripos($haystack, $needle, $encoding);
  75899. return self::getSubpart($pos, $part, $haystack, $encoding);
  75900. }
  75901. public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null)
  75902. {
  75903. $haystack = self::mb_convert_case($haystack, \MB_CASE_LOWER, $encoding);
  75904. $needle = self::mb_convert_case($needle, \MB_CASE_LOWER, $encoding);
  75905. $haystack = str_replace(self::SIMPLE_CASE_FOLD[0], self::SIMPLE_CASE_FOLD[1], $haystack);
  75906. $needle = str_replace(self::SIMPLE_CASE_FOLD[0], self::SIMPLE_CASE_FOLD[1], $needle);
  75907. return self::mb_strrpos($haystack, $needle, $offset, $encoding);
  75908. }
  75909. public static function mb_strstr($haystack, $needle, $part = false, $encoding = null)
  75910. {
  75911. $pos = strpos($haystack, $needle);
  75912. if (false === $pos) {
  75913. return false;
  75914. }
  75915. if ($part) {
  75916. return substr($haystack, 0, $pos);
  75917. }
  75918. return substr($haystack, $pos);
  75919. }
  75920. public static function mb_get_info($type = 'all')
  75921. {
  75922. $info = [
  75923. 'internal_encoding' => self::$internalEncoding,
  75924. 'http_output' => 'pass',
  75925. 'http_output_conv_mimetypes' => '^(text/|application/xhtml\+xml)',
  75926. 'func_overload' => 0,
  75927. 'func_overload_list' => 'no overload',
  75928. 'mail_charset' => 'UTF-8',
  75929. 'mail_header_encoding' => 'BASE64',
  75930. 'mail_body_encoding' => 'BASE64',
  75931. 'illegal_chars' => 0,
  75932. 'encoding_translation' => 'Off',
  75933. 'language' => self::$language,
  75934. 'detect_order' => self::$encodingList,
  75935. 'substitute_character' => 'none',
  75936. 'strict_detection' => 'Off',
  75937. ];
  75938. if ('all' === $type) {
  75939. return $info;
  75940. }
  75941. if (isset($info[$type])) {
  75942. return $info[$type];
  75943. }
  75944. return false;
  75945. }
  75946. public static function mb_http_input($type = '')
  75947. {
  75948. return false;
  75949. }
  75950. public static function mb_http_output($encoding = null)
  75951. {
  75952. return null !== $encoding ? 'pass' === $encoding : 'pass';
  75953. }
  75954. public static function mb_strwidth($s, $encoding = null)
  75955. {
  75956. $encoding = self::getEncoding($encoding);
  75957. if ('UTF-8' !== $encoding) {
  75958. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  75959. }
  75960. $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);
  75961. return ($wide << 1) + iconv_strlen($s, 'UTF-8');
  75962. }
  75963. public static function mb_substr_count($haystack, $needle, $encoding = null)
  75964. {
  75965. return substr_count($haystack, $needle);
  75966. }
  75967. public static function mb_output_handler($contents, $status)
  75968. {
  75969. return $contents;
  75970. }
  75971. public static function mb_chr($code, $encoding = null)
  75972. {
  75973. if (0x80 > $code %= 0x200000) {
  75974. $s = \chr($code);
  75975. } elseif (0x800 > $code) {
  75976. $s = \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
  75977. } elseif (0x10000 > $code) {
  75978. $s = \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  75979. } else {
  75980. $s = \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  75981. }
  75982. if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
  75983. $s = mb_convert_encoding($s, $encoding, 'UTF-8');
  75984. }
  75985. return $s;
  75986. }
  75987. public static function mb_ord($s, $encoding = null)
  75988. {
  75989. if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
  75990. $s = mb_convert_encoding($s, 'UTF-8', $encoding);
  75991. }
  75992. if (1 === \strlen($s)) {
  75993. return \ord($s);
  75994. }
  75995. $code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0;
  75996. if (0xF0 <= $code) {
  75997. return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80;
  75998. }
  75999. if (0xE0 <= $code) {
  76000. return (($code - 0xE0) << 12) + (($s[2] - 0x80) << 6) + $s[3] - 0x80;
  76001. }
  76002. if (0xC0 <= $code) {
  76003. return (($code - 0xC0) << 6) + $s[2] - 0x80;
  76004. }
  76005. return $code;
  76006. }
  76007. public static function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = \STR_PAD_RIGHT, string $encoding = null): string
  76008. {
  76009. if (!\in_array($pad_type, [\STR_PAD_RIGHT, \STR_PAD_LEFT, \STR_PAD_BOTH], true)) {
  76010. throw new \ValueError('mb_str_pad(): Argument #4 ($pad_type) must be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH');
  76011. }
  76012. if (null === $encoding) {
  76013. $encoding = self::mb_internal_encoding();
  76014. }
  76015. try {
  76016. $validEncoding = @self::mb_check_encoding('', $encoding);
  76017. } catch (\ValueError $e) {
  76018. throw new \ValueError(sprintf('mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given', $encoding));
  76019. }
  76020. if (!$validEncoding) {
  76021. throw new \ValueError(sprintf('mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given', $encoding));
  76022. }
  76023. if (self::mb_strlen($pad_string, $encoding) <= 0) {
  76024. throw new \ValueError('mb_str_pad(): Argument #3 ($pad_string) must be a non-empty string');
  76025. }
  76026. $paddingRequired = $length - self::mb_strlen($string, $encoding);
  76027. if ($paddingRequired < 1) {
  76028. return $string;
  76029. }
  76030. switch ($pad_type) {
  76031. case \STR_PAD_LEFT:
  76032. return self::mb_substr(str_repeat($pad_string, $paddingRequired), 0, $paddingRequired, $encoding).$string;
  76033. case \STR_PAD_RIGHT:
  76034. return $string.self::mb_substr(str_repeat($pad_string, $paddingRequired), 0, $paddingRequired, $encoding);
  76035. default:
  76036. $leftPaddingLength = floor($paddingRequired / 2);
  76037. $rightPaddingLength = $paddingRequired - $leftPaddingLength;
  76038. return self::mb_substr(str_repeat($pad_string, $leftPaddingLength), 0, $leftPaddingLength, $encoding).$string.self::mb_substr(str_repeat($pad_string, $rightPaddingLength), 0, $rightPaddingLength, $encoding);
  76039. }
  76040. }
  76041. private static function getSubpart($pos, $part, $haystack, $encoding)
  76042. {
  76043. if (false === $pos) {
  76044. return false;
  76045. }
  76046. if ($part) {
  76047. return self::mb_substr($haystack, 0, $pos, $encoding);
  76048. }
  76049. return self::mb_substr($haystack, $pos, null, $encoding);
  76050. }
  76051. private static function html_encoding_callback(array $m)
  76052. {
  76053. $i = 1;
  76054. $entities = '';
  76055. $m = unpack('C*', htmlentities($m[0], \ENT_COMPAT, 'UTF-8'));
  76056. while (isset($m[$i])) {
  76057. if (0x80 > $m[$i]) {
  76058. $entities .= \chr($m[$i++]);
  76059. continue;
  76060. }
  76061. if (0xF0 <= $m[$i]) {
  76062. $c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
  76063. } elseif (0xE0 <= $m[$i]) {
  76064. $c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
  76065. } else {
  76066. $c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80;
  76067. }
  76068. $entities .= '&#'.$c.';';
  76069. }
  76070. return $entities;
  76071. }
  76072. private static function title_case(array $s)
  76073. {
  76074. return self::mb_convert_case($s[1], \MB_CASE_UPPER, 'UTF-8').self::mb_convert_case($s[2], \MB_CASE_LOWER, 'UTF-8');
  76075. }
  76076. private static function getData($file)
  76077. {
  76078. if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) {
  76079. return require $file;
  76080. }
  76081. return false;
  76082. }
  76083. private static function getEncoding($encoding)
  76084. {
  76085. if (null === $encoding) {
  76086. return self::$internalEncoding;
  76087. }
  76088. if ('UTF-8' === $encoding) {
  76089. return 'UTF-8';
  76090. }
  76091. $encoding = strtoupper($encoding);
  76092. if ('8BIT' === $encoding || 'BINARY' === $encoding) {
  76093. return 'CP850';
  76094. }
  76095. if ('UTF8' === $encoding) {
  76096. return 'UTF-8';
  76097. }
  76098. return $encoding;
  76099. }
  76100. }
  76101. <?php
  76102. return [
  76103. 'İ' => 'i̇',
  76104. 'µ' => 'μ',
  76105. 'Å¿' => 's',
  76106. 'ͅ' => 'ι',
  76107. 'ς' => 'σ',
  76108. '�' => 'β',
  76109. 'ϑ' => 'θ',
  76110. 'ϕ' => 'φ',
  76111. 'Ï–' => 'Ï€',
  76112. 'ϰ' => 'κ',
  76113. 'ϱ' => '�',
  76114. 'ϵ' => 'ε',
  76115. 'ẛ' => 'ṡ',
  76116. 'ι' => 'ι',
  76117. 'ß' => 'ss',
  76118. 'ʼn' => 'ʼn',
  76119. 'ǰ' => 'ǰ',
  76120. '�' => '�',
  76121. 'ΰ' => 'ΰ',
  76122. 'Ö‡' => 'Õ¥Ö‚',
  76123. 'ẖ' => 'ẖ',
  76124. 'ẗ' => 'ẗ',
  76125. 'ẘ' => 'ẘ',
  76126. 'ẙ' => 'ẙ',
  76127. 'ẚ' => 'aʾ',
  76128. 'ẞ' => 'ss',
  76129. '�' => '�',
  76130. 'á½’' => 'á½’',
  76131. 'á½”' => 'á½”',
  76132. 'á½–' => 'á½–',
  76133. 'ᾀ' => 'ἀι',
  76134. '�' => '�ι',
  76135. 'ᾂ' => 'ἂι',
  76136. 'ᾃ' => 'ἃι',
  76137. 'ᾄ' => 'ἄι',
  76138. 'ᾅ' => 'ἅι',
  76139. 'ᾆ' => 'ἆι',
  76140. 'ᾇ' => 'ἇι',
  76141. 'ᾈ' => 'ἀι',
  76142. 'ᾉ' => '�ι',
  76143. 'ᾊ' => 'ἂι',
  76144. 'ᾋ' => 'ἃι',
  76145. 'ᾌ' => 'ἄι',
  76146. '�' => 'ἅι',
  76147. 'ᾎ' => 'ἆι',
  76148. '�' => 'ἇι',
  76149. '�' => 'ἠι',
  76150. 'ᾑ' => 'ἡι',
  76151. 'ᾒ' => 'ἢι',
  76152. 'ᾓ' => 'ἣι',
  76153. 'ᾔ' => 'ἤι',
  76154. 'ᾕ' => 'ἥι',
  76155. 'ᾖ' => 'ἦι',
  76156. 'ᾗ' => 'ἧι',
  76157. 'ᾘ' => 'ἠι',
  76158. 'ᾙ' => 'ἡι',
  76159. 'ᾚ' => 'ἢι',
  76160. 'ᾛ' => 'ἣι',
  76161. 'ᾜ' => 'ἤι',
  76162. '�' => 'ἥι',
  76163. 'ᾞ' => 'ἦι',
  76164. 'ᾟ' => 'ἧι',
  76165. 'ᾠ' => 'ὠι',
  76166. 'ᾡ' => 'ὡι',
  76167. 'ᾢ' => 'ὢι',
  76168. 'ᾣ' => 'ὣι',
  76169. 'ᾤ' => 'ὤι',
  76170. 'ᾥ' => 'ὥι',
  76171. 'ᾦ' => 'ὦι',
  76172. 'ᾧ' => 'ὧι',
  76173. 'ᾨ' => 'ὠι',
  76174. 'ᾩ' => 'ὡι',
  76175. 'ᾪ' => 'ὢι',
  76176. 'ᾫ' => 'ὣι',
  76177. 'ᾬ' => 'ὤι',
  76178. 'ᾭ' => 'ὥι',
  76179. 'ᾮ' => 'ὦι',
  76180. 'ᾯ' => 'ὧι',
  76181. 'ᾲ' => 'ὰι',
  76182. 'ᾳ' => 'αι',
  76183. 'ᾴ' => 'άι',
  76184. 'á¾¶' => 'á¾¶',
  76185. 'ᾷ' => 'ᾶι',
  76186. 'ᾼ' => 'αι',
  76187. 'ῂ' => 'ὴι',
  76188. 'ῃ' => 'ηι',
  76189. 'ῄ' => 'ήι',
  76190. 'ῆ' => 'ῆ',
  76191. 'ῇ' => 'ῆι',
  76192. 'ῌ' => 'ηι',
  76193. 'á¿’' => 'á¿’',
  76194. 'á¿–' => 'á¿–',
  76195. 'á¿—' => 'á¿—',
  76196. 'á¿¢' => 'á¿¢',
  76197. 'ῤ' => 'ῤ',
  76198. 'ῦ' => 'ῦ',
  76199. 'á¿§' => 'á¿§',
  76200. 'ῲ' => 'ὼι',
  76201. 'ῳ' => 'ωι',
  76202. 'ῴ' => 'ώι',
  76203. 'á¿¶' => 'á¿¶',
  76204. 'ῷ' => 'ῶι',
  76205. 'ῼ' => 'ωι',
  76206. 'ff' => 'ff',
  76207. '�' => 'fi',
  76208. 'fl' => 'fl',
  76209. 'ffi' => 'ffi',
  76210. 'ffl' => 'ffl',
  76211. 'ſt' => 'st',
  76212. 'st' => 'st',
  76213. 'ﬓ' => 'մն',
  76214. 'ﬔ' => 'մե',
  76215. 'ﬕ' => 'մի',
  76216. 'ﬖ' => 'վն',
  76217. 'ﬗ' => 'մխ',
  76218. ];
  76219. <?php
  76220. return array (
  76221. 'A' => 'a',
  76222. 'B' => 'b',
  76223. 'C' => 'c',
  76224. 'D' => 'd',
  76225. 'E' => 'e',
  76226. 'F' => 'f',
  76227. 'G' => 'g',
  76228. 'H' => 'h',
  76229. 'I' => 'i',
  76230. 'J' => 'j',
  76231. 'K' => 'k',
  76232. 'L' => 'l',
  76233. 'M' => 'm',
  76234. 'N' => 'n',
  76235. 'O' => 'o',
  76236. 'P' => 'p',
  76237. 'Q' => 'q',
  76238. 'R' => 'r',
  76239. 'S' => 's',
  76240. 'T' => 't',
  76241. 'U' => 'u',
  76242. 'V' => 'v',
  76243. 'W' => 'w',
  76244. 'X' => 'x',
  76245. 'Y' => 'y',
  76246. 'Z' => 'z',
  76247. 'À' => 'à',
  76248. '�' => 'á',
  76249. 'Â' => 'â',
  76250. 'Ã' => 'ã',
  76251. 'Ä' => 'ä',
  76252. 'Ã…' => 'Ã¥',
  76253. 'Æ' => 'æ',
  76254. 'Ç' => 'ç',
  76255. 'È' => 'è',
  76256. 'É' => 'é',
  76257. 'Ê' => 'ê',
  76258. 'Ë' => 'ë',
  76259. 'Ì' => 'ì',
  76260. '�' => 'í',
  76261. 'Î' => 'î',
  76262. '�' => 'ï',
  76263. '�' => 'ð',
  76264. 'Ñ' => 'ñ',
  76265. 'Ò' => 'ò',
  76266. 'Ó' => 'ó',
  76267. 'Ô' => 'ô',
  76268. 'Õ' => 'õ',
  76269. 'Ö' => 'ö',
  76270. 'Ø' => 'ø',
  76271. 'Ù' => 'ù',
  76272. 'Ú' => 'ú',
  76273. 'Û' => 'û',
  76274. 'Ü' => 'ü',
  76275. '�' => 'ý',
  76276. 'Þ' => 'þ',
  76277. 'Ā' => '�',
  76278. 'Ă' => 'ă',
  76279. 'Ä„' => 'Ä…',
  76280. 'Ć' => 'ć',
  76281. 'Ĉ' => 'ĉ',
  76282. 'ÄŠ' => 'Ä‹',
  76283. 'Č' => '�',
  76284. 'Ď' => '�',
  76285. '�' => 'đ',
  76286. 'Ä’' => 'Ä“',
  76287. 'Ä”' => 'Ä•',
  76288. 'Ä–' => 'Ä—',
  76289. 'Ę' => 'ę',
  76290. 'Äš' => 'Ä›',
  76291. 'Ĝ' => '�',
  76292. 'Äž' => 'ÄŸ',
  76293. 'Ä ' => 'Ä¡',
  76294. 'Ä¢' => 'Ä£',
  76295. 'Ĥ' => 'ĥ',
  76296. 'Ħ' => 'ħ',
  76297. 'Ĩ' => 'ĩ',
  76298. 'Ī' => 'ī',
  76299. 'Ĭ' => 'ĭ',
  76300. 'Į' => 'į',
  76301. 'İ' => 'i̇',
  76302. 'IJ' => 'ij',
  76303. 'Ĵ' => 'ĵ',
  76304. 'Ķ' => 'ķ',
  76305. 'Ĺ' => 'ĺ',
  76306. 'Ļ' => 'ļ',
  76307. 'Ľ' => 'ľ',
  76308. 'Ä¿' => 'Å€',
  76309. '�' => 'ł',
  76310. 'Ń' => 'ń',
  76311. 'Ņ' => 'ņ',
  76312. 'Ň' => 'ň',
  76313. 'ÅŠ' => 'Å‹',
  76314. 'Ō' => '�',
  76315. 'Ŏ' => '�',
  76316. '�' => 'ő',
  76317. 'Å’' => 'Å“',
  76318. 'Å”' => 'Å•',
  76319. 'Å–' => 'Å—',
  76320. 'Ř' => 'ř',
  76321. 'Åš' => 'Å›',
  76322. 'Ŝ' => '�',
  76323. 'Åž' => 'ÅŸ',
  76324. 'Å ' => 'Å¡',
  76325. 'Å¢' => 'Å£',
  76326. 'Ť' => 'ť',
  76327. 'Ŧ' => 'ŧ',
  76328. 'Ũ' => 'ũ',
  76329. 'Ū' => 'ū',
  76330. 'Ŭ' => 'ŭ',
  76331. 'Ů' => 'ů',
  76332. 'Ű' => 'ű',
  76333. 'Ų' => 'ų',
  76334. 'Ŵ' => 'ŵ',
  76335. 'Ŷ' => 'ŷ',
  76336. 'Ÿ' => 'ÿ',
  76337. 'Ź' => 'ź',
  76338. 'Ż' => 'ż',
  76339. 'Ž' => 'ž',
  76340. '�' => 'ɓ',
  76341. 'Ƃ' => 'ƃ',
  76342. 'Æ„' => 'Æ…',
  76343. 'Ɔ' => 'ɔ',
  76344. 'Ƈ' => 'ƈ',
  76345. 'Ɖ' => 'ɖ',
  76346. 'ÆŠ' => 'É—',
  76347. 'Ƌ' => 'ƌ',
  76348. 'Ǝ' => '�',
  76349. '�' => 'ə',
  76350. '�' => 'ɛ',
  76351. 'Æ‘' => 'Æ’',
  76352. 'Æ“' => 'É ',
  76353. 'Æ”' => 'É£',
  76354. 'Æ–' => 'É©',
  76355. 'Ɨ' => 'ɨ',
  76356. 'Ƙ' => 'ƙ',
  76357. 'Ɯ' => 'ɯ',
  76358. '�' => 'ɲ',
  76359. 'Ɵ' => 'ɵ',
  76360. 'Æ ' => 'Æ¡',
  76361. 'Æ¢' => 'Æ£',
  76362. 'Ƥ' => 'ƥ',
  76363. 'Ʀ' => 'ʀ',
  76364. 'Ƨ' => 'ƨ',
  76365. 'Ʃ' => 'ʃ',
  76366. 'Ƭ' => 'ƭ',
  76367. 'Ʈ' => 'ʈ',
  76368. 'Ư' => 'ư',
  76369. 'Ʊ' => 'ʊ',
  76370. 'Ʋ' => 'ʋ',
  76371. 'Ƴ' => 'ƴ',
  76372. 'Ƶ' => 'ƶ',
  76373. 'Æ·' => 'Ê’',
  76374. 'Ƹ' => 'ƹ',
  76375. 'Ƽ' => 'ƽ',
  76376. 'DŽ' => 'dž',
  76377. 'Dž' => 'dž',
  76378. 'LJ' => 'lj',
  76379. 'Lj' => 'lj',
  76380. 'NJ' => 'nj',
  76381. 'Nj' => 'nj',
  76382. '�' => 'ǎ',
  76383. '�' => '�',
  76384. 'Ç‘' => 'Ç’',
  76385. 'Ç“' => 'Ç”',
  76386. 'Ç•' => 'Ç–',
  76387. 'Ǘ' => 'ǘ',
  76388. 'Ç™' => 'Çš',
  76389. 'Ǜ' => 'ǜ',
  76390. 'Çž' => 'ÇŸ',
  76391. 'Ç ' => 'Ç¡',
  76392. 'Ç¢' => 'Ç£',
  76393. 'Ǥ' => 'ǥ',
  76394. 'Ǧ' => 'ǧ',
  76395. 'Ǩ' => 'ǩ',
  76396. 'Ǫ' => 'ǫ',
  76397. 'Ǭ' => 'ǭ',
  76398. 'Ǯ' => 'ǯ',
  76399. 'DZ' => 'dz',
  76400. 'Dz' => 'dz',
  76401. 'Ǵ' => 'ǵ',
  76402. 'Ƕ' => 'ƕ',
  76403. 'Ç·' => 'Æ¿',
  76404. 'Ǹ' => 'ǹ',
  76405. 'Ǻ' => 'ǻ',
  76406. 'Ǽ' => 'ǽ',
  76407. 'Ǿ' => 'ǿ',
  76408. 'Ȁ' => '�',
  76409. 'Ȃ' => 'ȃ',
  76410. 'È„' => 'È…',
  76411. 'Ȇ' => 'ȇ',
  76412. 'Ȉ' => 'ȉ',
  76413. 'ÈŠ' => 'È‹',
  76414. 'Ȍ' => '�',
  76415. 'Ȏ' => '�',
  76416. '�' => 'ȑ',
  76417. 'È’' => 'È“',
  76418. 'È”' => 'È•',
  76419. 'È–' => 'È—',
  76420. 'Ș' => 'ș',
  76421. 'Èš' => 'È›',
  76422. 'Ȝ' => '�',
  76423. 'Èž' => 'ÈŸ',
  76424. 'È ' => 'Æž',
  76425. 'È¢' => 'È£',
  76426. 'Ȥ' => 'ȥ',
  76427. 'Ȧ' => 'ȧ',
  76428. 'Ȩ' => 'ȩ',
  76429. 'Ȫ' => 'ȫ',
  76430. 'Ȭ' => 'ȭ',
  76431. 'Ȯ' => 'ȯ',
  76432. 'Ȱ' => 'ȱ',
  76433. 'Ȳ' => 'ȳ',
  76434. 'Ⱥ' => 'ⱥ',
  76435. 'Ȼ' => 'ȼ',
  76436. 'Ƚ' => 'ƚ',
  76437. 'Ⱦ' => 'ⱦ',
  76438. '�' => 'ɂ',
  76439. 'Ƀ' => 'ƀ',
  76440. 'Ʉ' => 'ʉ',
  76441. 'Ʌ' => 'ʌ',
  76442. 'Ɇ' => 'ɇ',
  76443. 'Ɉ' => 'ɉ',
  76444. 'ÉŠ' => 'É‹',
  76445. 'Ɍ' => '�',
  76446. 'Ɏ' => '�',
  76447. 'Ͱ' => 'ͱ',
  76448. 'Ͳ' => 'ͳ',
  76449. 'Ͷ' => 'ͷ',
  76450. 'Ϳ' => 'ϳ',
  76451. 'Ά' => 'ά',
  76452. 'Έ' => 'έ',
  76453. 'Ή' => 'ή',
  76454. 'Ί' => 'ί',
  76455. 'Ό' => 'ό',
  76456. 'Ύ' => '�',
  76457. '�' => 'ώ',
  76458. 'Α' => 'α',
  76459. 'Β' => 'β',
  76460. 'Γ' => 'γ',
  76461. 'Δ' => 'δ',
  76462. 'Ε' => 'ε',
  76463. 'Ζ' => 'ζ',
  76464. 'Η' => 'η',
  76465. 'Θ' => 'θ',
  76466. 'Ι' => 'ι',
  76467. 'Κ' => 'κ',
  76468. 'Λ' => 'λ',
  76469. 'Μ' => 'μ',
  76470. '�' => 'ν',
  76471. 'Ξ' => 'ξ',
  76472. 'Ο' => 'ο',
  76473. 'Π' => 'π',
  76474. 'Ρ' => '�',
  76475. 'Σ' => 'σ',
  76476. 'Τ' => 'τ',
  76477. 'Î¥' => 'Ï…',
  76478. 'Φ' => 'φ',
  76479. 'Χ' => 'χ',
  76480. 'Ψ' => 'ψ',
  76481. 'Ω' => 'ω',
  76482. 'Ϊ' => 'ϊ',
  76483. 'Ϋ' => 'ϋ',
  76484. '�' => 'ϗ',
  76485. 'Ϙ' => 'ϙ',
  76486. 'Ïš' => 'Ï›',
  76487. 'Ϝ' => '�',
  76488. 'Ïž' => 'ÏŸ',
  76489. 'Ï ' => 'Ï¡',
  76490. 'Ï¢' => 'Ï£',
  76491. 'Ϥ' => 'ϥ',
  76492. 'Ϧ' => 'ϧ',
  76493. 'Ϩ' => 'ϩ',
  76494. 'Ϫ' => 'ϫ',
  76495. 'Ϭ' => 'ϭ',
  76496. 'Ϯ' => 'ϯ',
  76497. 'ϴ' => 'θ',
  76498. 'Ϸ' => 'ϸ',
  76499. 'Ϲ' => 'ϲ',
  76500. 'Ϻ' => 'ϻ',
  76501. 'Ͻ' => 'ͻ',
  76502. 'Ͼ' => 'ͼ',
  76503. 'Ͽ' => 'ͽ',
  76504. 'Ѐ' => '�',
  76505. '�' => 'ё',
  76506. 'Ђ' => 'ђ',
  76507. 'Ѓ' => 'ѓ',
  76508. 'Є' => 'є',
  76509. 'Ð…' => 'Ñ•',
  76510. 'І' => 'і',
  76511. 'Ї' => 'ї',
  76512. 'Ј' => 'ј',
  76513. 'Љ' => 'љ',
  76514. 'Њ' => 'њ',
  76515. 'Ћ' => 'ћ',
  76516. 'Ќ' => 'ќ',
  76517. '�' => '�',
  76518. 'ÐŽ' => 'Ñž',
  76519. '�' => 'џ',
  76520. '�' => 'а',
  76521. 'Б' => 'б',
  76522. 'В' => 'в',
  76523. 'Г' => 'г',
  76524. 'Д' => 'д',
  76525. 'Е' => 'е',
  76526. 'Ж' => 'ж',
  76527. 'З' => 'з',
  76528. 'И' => 'и',
  76529. 'Й' => 'й',
  76530. 'К' => 'к',
  76531. 'Л' => 'л',
  76532. 'М' => 'м',
  76533. '�' => 'н',
  76534. 'О' => 'о',
  76535. 'П' => 'п',
  76536. 'Р' => 'р',
  76537. 'С' => '�',
  76538. 'Т' => 'т',
  76539. 'У' => 'у',
  76540. 'Ф' => 'ф',
  76541. 'Ð¥' => 'Ñ…',
  76542. 'Ц' => 'ц',
  76543. 'Ч' => 'ч',
  76544. 'Ш' => 'ш',
  76545. 'Щ' => 'щ',
  76546. 'Ъ' => 'ъ',
  76547. 'Ы' => 'ы',
  76548. 'Ь' => 'ь',
  76549. 'Э' => '�',
  76550. 'Ю' => 'ю',
  76551. 'Я' => '�',
  76552. 'Ñ ' => 'Ñ¡',
  76553. 'Ñ¢' => 'Ñ£',
  76554. 'Ѥ' => 'ѥ',
  76555. 'Ѧ' => 'ѧ',
  76556. 'Ѩ' => 'ѩ',
  76557. 'Ѫ' => 'ѫ',
  76558. 'Ѭ' => 'ѭ',
  76559. 'Ѯ' => 'ѯ',
  76560. 'Ѱ' => 'ѱ',
  76561. 'Ѳ' => 'ѳ',
  76562. 'Ѵ' => 'ѵ',
  76563. 'Ѷ' => 'ѷ',
  76564. 'Ѹ' => 'ѹ',
  76565. 'Ѻ' => 'ѻ',
  76566. 'Ѽ' => 'ѽ',
  76567. 'Ѿ' => 'ѿ',
  76568. 'Ò€' => 'Ò�',
  76569. 'ÒŠ' => 'Ò‹',
  76570. 'Ҍ' => '�',
  76571. 'ÒŽ' => 'Ò�',
  76572. 'Ò�' => 'Ò‘',
  76573. 'Ò’' => 'Ò“',
  76574. 'Ò”' => 'Ò•',
  76575. 'Ò–' => 'Ò—',
  76576. 'Ò˜' => 'Ò™',
  76577. 'Òš' => 'Ò›',
  76578. 'Ҝ' => '�',
  76579. 'Òž' => 'ÒŸ',
  76580. 'Ò ' => 'Ò¡',
  76581. 'Ò¢' => 'Ò£',
  76582. 'Ò¤' => 'Ò¥',
  76583. 'Ò¦' => 'Ò§',
  76584. 'Ò¨' => 'Ò©',
  76585. 'Òª' => 'Ò«',
  76586. 'Ò¬' => 'Ò­',
  76587. 'Ò®' => 'Ò¯',
  76588. 'Ò°' => 'Ò±',
  76589. 'Ò²' => 'Ò³',
  76590. 'Ò´' => 'Òµ',
  76591. 'Ò¶' => 'Ò·',
  76592. 'Ò¸' => 'Ò¹',
  76593. 'Òº' => 'Ò»',
  76594. 'Ò¼' => 'Ò½',
  76595. 'Ò¾' => 'Ò¿',
  76596. 'Ó€' => 'Ó�',
  76597. 'Ó�' => 'Ó‚',
  76598. 'Óƒ' => 'Ó„',
  76599. 'Ó…' => 'Ó†',
  76600. 'Ó‡' => 'Óˆ',
  76601. 'Ó‰' => 'ÓŠ',
  76602. 'Ӌ' => 'ӌ',
  76603. 'Ó�' => 'ÓŽ',
  76604. 'Ó�' => 'Ó‘',
  76605. 'Ó’' => 'Ó“',
  76606. 'Ó”' => 'Ó•',
  76607. 'Ó–' => 'Ó—',
  76608. 'Ó˜' => 'Ó™',
  76609. 'Óš' => 'Ó›',
  76610. 'Ӝ' => '�',
  76611. 'Óž' => 'ÓŸ',
  76612. 'Ó ' => 'Ó¡',
  76613. 'Ó¢' => 'Ó£',
  76614. 'Ó¤' => 'Ó¥',
  76615. 'Ó¦' => 'Ó§',
  76616. 'Ó¨' => 'Ó©',
  76617. 'Óª' => 'Ó«',
  76618. 'Ó¬' => 'Ó­',
  76619. 'Ó®' => 'Ó¯',
  76620. 'Ó°' => 'Ó±',
  76621. 'Ó²' => 'Ó³',
  76622. 'Ó´' => 'Óµ',
  76623. 'Ó¶' => 'Ó·',
  76624. 'Ó¸' => 'Ó¹',
  76625. 'Óº' => 'Ó»',
  76626. 'Ó¼' => 'Ó½',
  76627. 'Ó¾' => 'Ó¿',
  76628. 'Ô€' => 'Ô�',
  76629. 'Ô‚' => 'Ôƒ',
  76630. 'Ô„' => 'Ô…',
  76631. 'Ô†' => 'Ô‡',
  76632. 'Ôˆ' => 'Ô‰',
  76633. 'ÔŠ' => 'Ô‹',
  76634. 'Ԍ' => '�',
  76635. 'ÔŽ' => 'Ô�',
  76636. 'Ô�' => 'Ô‘',
  76637. 'Ô’' => 'Ô“',
  76638. 'Ô”' => 'Ô•',
  76639. 'Ô–' => 'Ô—',
  76640. 'Ô˜' => 'Ô™',
  76641. 'Ôš' => 'Ô›',
  76642. 'Ԝ' => '�',
  76643. 'Ôž' => 'ÔŸ',
  76644. 'Ô ' => 'Ô¡',
  76645. 'Ô¢' => 'Ô£',
  76646. 'Ô¤' => 'Ô¥',
  76647. 'Ô¦' => 'Ô§',
  76648. 'Ô¨' => 'Ô©',
  76649. 'Ôª' => 'Ô«',
  76650. 'Ô¬' => 'Ô­',
  76651. 'Ô®' => 'Ô¯',
  76652. 'Ô±' => 'Õ¡',
  76653. 'Ô²' => 'Õ¢',
  76654. 'Ô³' => 'Õ£',
  76655. 'Ô´' => 'Õ¤',
  76656. 'Ôµ' => 'Õ¥',
  76657. 'Ô¶' => 'Õ¦',
  76658. 'Ô·' => 'Õ§',
  76659. 'Ô¸' => 'Õ¨',
  76660. 'Ô¹' => 'Õ©',
  76661. 'Ôº' => 'Õª',
  76662. 'Ô»' => 'Õ«',
  76663. 'Ô¼' => 'Õ¬',
  76664. 'Ô½' => 'Õ­',
  76665. 'Ô¾' => 'Õ®',
  76666. 'Ô¿' => 'Õ¯',
  76667. 'Õ€' => 'Õ°',
  76668. 'Õ�' => 'Õ±',
  76669. 'Õ‚' => 'Õ²',
  76670. 'Õƒ' => 'Õ³',
  76671. 'Õ„' => 'Õ´',
  76672. 'Õ…' => 'Õµ',
  76673. 'Õ†' => 'Õ¶',
  76674. 'Õ‡' => 'Õ·',
  76675. 'Õˆ' => 'Õ¸',
  76676. 'Õ‰' => 'Õ¹',
  76677. 'ÕŠ' => 'Õº',
  76678. 'Õ‹' => 'Õ»',
  76679. 'Ռ' => 'ռ',
  76680. 'Õ�' => 'Õ½',
  76681. 'ÕŽ' => 'Õ¾',
  76682. 'Õ�' => 'Õ¿',
  76683. 'Õ�' => 'Ö€',
  76684. 'Õ‘' => 'Ö�',
  76685. 'Õ’' => 'Ö‚',
  76686. 'Õ“' => 'Öƒ',
  76687. 'Õ”' => 'Ö„',
  76688. 'Õ•' => 'Ö…',
  76689. 'Õ–' => 'Ö†',
  76690. 'á‚ ' => 'â´€',
  76691. 'á‚¡' => 'â´�',
  76692. 'á‚¢' => 'â´‚',
  76693. 'á‚£' => 'â´ƒ',
  76694. 'Ⴄ' => 'ⴄ',
  76695. 'á‚¥' => 'â´…',
  76696. 'Ⴆ' => 'ⴆ',
  76697. 'á‚§' => 'â´‡',
  76698. 'Ⴈ' => 'ⴈ',
  76699. 'á‚©' => 'â´‰',
  76700. 'Ⴊ' => 'ⴊ',
  76701. 'á‚«' => 'â´‹',
  76702. 'Ⴌ' => 'ⴌ',
  76703. 'á‚­' => 'â´�',
  76704. 'á‚®' => 'â´Ž',
  76705. 'Ⴏ' => '�',
  76706. 'á‚°' => 'â´�',
  76707. 'Ⴑ' => 'ⴑ',
  76708. 'Ⴒ' => 'ⴒ',
  76709. 'Ⴓ' => 'ⴓ',
  76710. 'á‚´' => 'â´”',
  76711. 'Ⴕ' => 'ⴕ',
  76712. 'á‚¶' => 'â´–',
  76713. 'á‚·' => 'â´—',
  76714. 'Ⴘ' => 'ⴘ',
  76715. 'Ⴙ' => 'ⴙ',
  76716. 'Ⴚ' => 'ⴚ',
  76717. 'á‚»' => 'â´›',
  76718. 'Ⴜ' => 'ⴜ',
  76719. 'Ⴝ' => '�',
  76720. 'Ⴞ' => 'ⴞ',
  76721. 'á‚¿' => 'â´Ÿ',
  76722. 'Ⴠ' => 'ⴠ',
  76723. '�' => 'ⴡ',
  76724. 'Ⴢ' => 'ⴢ',
  76725. 'Ⴣ' => 'ⴣ',
  76726. 'Ⴤ' => 'ⴤ',
  76727. 'Ⴥ' => 'ⴥ',
  76728. 'Ⴧ' => 'ⴧ',
  76729. '�' => 'ⴭ',
  76730. 'Ꭰ' => 'ꭰ',
  76731. 'Ꭱ' => 'ꭱ',
  76732. 'Ꭲ' => 'ꭲ',
  76733. 'Ꭳ' => 'ꭳ',
  76734. 'Ꭴ' => 'ꭴ',
  76735. 'Ꭵ' => 'ꭵ',
  76736. 'Ꭶ' => 'ꭶ',
  76737. 'Ꭷ' => 'ꭷ',
  76738. 'Ꭸ' => 'ꭸ',
  76739. 'Ꭹ' => 'ꭹ',
  76740. 'Ꭺ' => 'ꭺ',
  76741. 'Ꭻ' => 'ꭻ',
  76742. 'Ꭼ' => 'ꭼ',
  76743. 'Ꭽ' => 'ꭽ',
  76744. 'Ꭾ' => 'ꭾ',
  76745. 'Ꭿ' => 'ꭿ',
  76746. 'Ꮀ' => 'ꮀ',
  76747. 'Ꮁ' => '�',
  76748. 'Ꮂ' => 'ꮂ',
  76749. 'Ꮃ' => 'ꮃ',
  76750. 'Ꮄ' => 'ꮄ',
  76751. 'Ꮅ' => 'ꮅ',
  76752. 'Ꮆ' => 'ꮆ',
  76753. 'Ꮇ' => 'ꮇ',
  76754. 'Ꮈ' => 'ꮈ',
  76755. 'Ꮉ' => 'ꮉ',
  76756. 'Ꮊ' => 'ꮊ',
  76757. 'Ꮋ' => 'ꮋ',
  76758. 'Ꮌ' => 'ꮌ',
  76759. 'Ꮍ' => '�',
  76760. 'Ꮎ' => 'ꮎ',
  76761. 'Ꮏ' => '�',
  76762. '�' => '�',
  76763. '�' => 'ꮑ',
  76764. '�' => 'ꮒ',
  76765. '�' => 'ꮓ',
  76766. '�' => 'ꮔ',
  76767. '�' => 'ꮕ',
  76768. '�' => 'ꮖ',
  76769. '�' => 'ꮗ',
  76770. '�' => 'ꮘ',
  76771. '�' => 'ꮙ',
  76772. '�' => 'ꮚ',
  76773. '�' => 'ꮛ',
  76774. '�' => 'ꮜ',
  76775. '�' => '�',
  76776. '�' => 'ꮞ',
  76777. '�' => 'ꮟ',
  76778. '�' => 'ꮠ',
  76779. '�' => 'ꮡ',
  76780. '�' => 'ꮢ',
  76781. '�' => 'ꮣ',
  76782. '�' => 'ꮤ',
  76783. '�' => 'ꮥ',
  76784. '�' => 'ꮦ',
  76785. '�' => 'ꮧ',
  76786. '�' => 'ꮨ',
  76787. '�' => 'ꮩ',
  76788. '�' => 'ꮪ',
  76789. '�' => 'ꮫ',
  76790. '�' => 'ꮬ',
  76791. '�' => 'ꮭ',
  76792. '�' => 'ꮮ',
  76793. '�' => 'ꮯ',
  76794. '�' => 'ꮰ',
  76795. '�' => 'ꮱ',
  76796. '�' => 'ꮲ',
  76797. '�' => 'ꮳ',
  76798. '�' => 'ꮴ',
  76799. '�' => 'ꮵ',
  76800. '�' => 'ꮶ',
  76801. '�' => 'ꮷ',
  76802. '�' => 'ꮸ',
  76803. '�' => 'ꮹ',
  76804. '�' => 'ꮺ',
  76805. '�' => 'ꮻ',
  76806. '�' => 'ꮼ',
  76807. '�' => 'ꮽ',
  76808. '�' => 'ꮾ',
  76809. '�' => 'ꮿ',
  76810. '�' => '�',
  76811. '�' => '�',
  76812. '�' => '�',
  76813. '�' => '�',
  76814. '�' => '�',
  76815. '�' => '�',
  76816. '�' => '�',
  76817. 'Ბ' => 'ბ',
  76818. 'Გ' => 'გ',
  76819. 'Დ' => 'დ',
  76820. 'Ე' => 'ე',
  76821. 'Ვ' => 'ვ',
  76822. 'Ზ' => 'ზ',
  76823. 'Თ' => 'თ',
  76824. 'Ი' => 'ი',
  76825. 'Კ' => 'კ',
  76826. 'Ლ' => 'ლ',
  76827. 'Მ' => 'მ',
  76828. 'Ნ' => 'ნ',
  76829. '�' => '�',
  76830. 'Პ' => 'პ',
  76831. 'Ჟ' => 'ჟ',
  76832. 'Რ' => 'რ',
  76833. 'Ს' => 'ს',
  76834. 'Ტ' => 'ტ',
  76835. 'Უ' => 'უ',
  76836. 'Ფ' => 'ფ',
  76837. 'Ქ' => 'ქ',
  76838. 'Ღ' => 'ღ',
  76839. 'Ყ' => 'ყ',
  76840. 'Შ' => 'შ',
  76841. 'Ჩ' => 'ჩ',
  76842. 'Ც' => 'ც',
  76843. 'Ძ' => 'ძ',
  76844. 'Წ' => 'წ',
  76845. 'Ჭ' => 'ჭ',
  76846. 'Ხ' => 'ხ',
  76847. 'Ჯ' => 'ჯ',
  76848. 'Ჰ' => 'ჰ',
  76849. 'Ჱ' => 'ჱ',
  76850. 'Ჲ' => 'ჲ',
  76851. 'Ჳ' => 'ჳ',
  76852. 'Ჴ' => 'ჴ',
  76853. 'Ჵ' => 'ჵ',
  76854. 'Ჶ' => 'ჶ',
  76855. 'Ჷ' => 'ჷ',
  76856. 'Ჸ' => 'ჸ',
  76857. 'Ჹ' => 'ჹ',
  76858. 'Ჺ' => 'ჺ',
  76859. 'Ჽ' => 'ჽ',
  76860. 'Ჾ' => 'ჾ',
  76861. 'Ჿ' => 'ჿ',
  76862. 'Ḁ' => '�',
  76863. 'Ḃ' => 'ḃ',
  76864. 'Ḅ' => 'ḅ',
  76865. 'Ḇ' => 'ḇ',
  76866. 'Ḉ' => 'ḉ',
  76867. 'Ḋ' => 'ḋ',
  76868. 'Ḍ' => '�',
  76869. 'Ḏ' => '�',
  76870. '�' => 'ḑ',
  76871. 'Ḓ' => 'ḓ',
  76872. 'Ḕ' => 'ḕ',
  76873. 'Ḗ' => 'ḗ',
  76874. 'Ḙ' => 'ḙ',
  76875. 'Ḛ' => 'ḛ',
  76876. 'Ḝ' => '�',
  76877. 'Ḟ' => 'ḟ',
  76878. 'Ḡ' => 'ḡ',
  76879. 'Ḣ' => 'ḣ',
  76880. 'Ḥ' => 'ḥ',
  76881. 'Ḧ' => 'ḧ',
  76882. 'Ḩ' => 'ḩ',
  76883. 'Ḫ' => 'ḫ',
  76884. 'Ḭ' => 'ḭ',
  76885. 'Ḯ' => 'ḯ',
  76886. 'Ḱ' => 'ḱ',
  76887. 'Ḳ' => 'ḳ',
  76888. 'Ḵ' => 'ḵ',
  76889. 'Ḷ' => 'ḷ',
  76890. 'Ḹ' => 'ḹ',
  76891. 'Ḻ' => 'ḻ',
  76892. 'Ḽ' => 'ḽ',
  76893. 'Ḿ' => 'ḿ',
  76894. 'Ṁ' => '�',
  76895. 'Ṃ' => 'ṃ',
  76896. 'Ṅ' => 'ṅ',
  76897. 'Ṇ' => 'ṇ',
  76898. 'Ṉ' => 'ṉ',
  76899. 'Ṋ' => 'ṋ',
  76900. 'Ṍ' => '�',
  76901. 'Ṏ' => '�',
  76902. '�' => 'ṑ',
  76903. 'Ṓ' => 'ṓ',
  76904. 'Ṕ' => 'ṕ',
  76905. 'á¹–' => 'á¹—',
  76906. 'Ṙ' => 'ṙ',
  76907. 'Ṛ' => 'ṛ',
  76908. 'Ṝ' => '�',
  76909. 'Ṟ' => 'ṟ',
  76910. 'Ṡ' => 'ṡ',
  76911. 'á¹¢' => 'á¹£',
  76912. 'Ṥ' => 'ṥ',
  76913. 'Ṧ' => 'ṧ',
  76914. 'Ṩ' => 'ṩ',
  76915. 'Ṫ' => 'ṫ',
  76916. 'Ṭ' => 'ṭ',
  76917. 'Ṯ' => 'ṯ',
  76918. 'á¹°' => 'á¹±',
  76919. 'á¹²' => 'á¹³',
  76920. 'á¹´' => 'á¹µ',
  76921. 'á¹¶' => 'á¹·',
  76922. 'Ṹ' => 'ṹ',
  76923. 'Ṻ' => 'ṻ',
  76924. 'á¹¼' => 'á¹½',
  76925. 'Ṿ' => 'ṿ',
  76926. 'Ẁ' => '�',
  76927. 'Ẃ' => 'ẃ',
  76928. 'Ẅ' => 'ẅ',
  76929. 'Ẇ' => 'ẇ',
  76930. 'Ẉ' => 'ẉ',
  76931. 'Ẋ' => 'ẋ',
  76932. 'Ẍ' => '�',
  76933. 'Ẏ' => '�',
  76934. '�' => 'ẑ',
  76935. 'Ẓ' => 'ẓ',
  76936. 'Ẕ' => 'ẕ',
  76937. 'ẞ' => 'ß',
  76938. 'Ạ' => 'ạ',
  76939. 'Ả' => 'ả',
  76940. 'Ấ' => 'ấ',
  76941. 'Ầ' => 'ầ',
  76942. 'Ẩ' => 'ẩ',
  76943. 'Ẫ' => 'ẫ',
  76944. 'Ậ' => 'ậ',
  76945. 'Ắ' => 'ắ',
  76946. 'Ằ' => 'ằ',
  76947. 'Ẳ' => 'ẳ',
  76948. 'Ẵ' => 'ẵ',
  76949. 'Ặ' => 'ặ',
  76950. 'Ẹ' => 'ẹ',
  76951. 'Ẻ' => 'ẻ',
  76952. 'Ẽ' => 'ẽ',
  76953. 'Ế' => 'ế',
  76954. 'Ề' => '�',
  76955. 'Ể' => 'ể',
  76956. 'Ễ' => 'ễ',
  76957. 'Ệ' => 'ệ',
  76958. 'Ỉ' => 'ỉ',
  76959. 'Ị' => 'ị',
  76960. 'Ọ' => '�',
  76961. 'Ỏ' => '�',
  76962. '�' => 'ố',
  76963. 'Ồ' => 'ồ',
  76964. 'Ổ' => 'ổ',
  76965. 'á»–' => 'á»—',
  76966. 'Ộ' => 'ộ',
  76967. 'Ớ' => 'ớ',
  76968. 'Ờ' => '�',
  76969. 'Ở' => 'ở',
  76970. 'Ỡ' => 'ỡ',
  76971. 'Ợ' => 'ợ',
  76972. 'Ụ' => 'ụ',
  76973. 'Ủ' => 'ủ',
  76974. 'Ứ' => 'ứ',
  76975. 'Ừ' => 'ừ',
  76976. 'Ử' => 'ử',
  76977. 'Ữ' => 'ữ',
  76978. 'á»°' => 'á»±',
  76979. 'Ỳ' => 'ỳ',
  76980. 'Ỵ' => 'ỵ',
  76981. 'á»¶' => 'á»·',
  76982. 'Ỹ' => 'ỹ',
  76983. 'Ỻ' => 'ỻ',
  76984. 'Ỽ' => 'ỽ',
  76985. 'Ỿ' => 'ỿ',
  76986. 'Ἀ' => 'ἀ',
  76987. 'Ἁ' => '�',
  76988. 'Ἂ' => 'ἂ',
  76989. 'Ἃ' => 'ἃ',
  76990. 'Ἄ' => 'ἄ',
  76991. '�' => 'ἅ',
  76992. 'Ἆ' => 'ἆ',
  76993. '�' => 'ἇ',
  76994. 'Ἐ' => '�',
  76995. 'Ἑ' => 'ἑ',
  76996. 'Ἒ' => 'ἒ',
  76997. 'Ἓ' => 'ἓ',
  76998. 'Ἔ' => 'ἔ',
  76999. '�' => 'ἕ',
  77000. 'Ἠ' => 'ἠ',
  77001. 'Ἡ' => 'ἡ',
  77002. 'Ἢ' => 'ἢ',
  77003. 'Ἣ' => 'ἣ',
  77004. 'Ἤ' => 'ἤ',
  77005. 'á¼­' => 'á¼¥',
  77006. 'Ἦ' => 'ἦ',
  77007. 'Ἧ' => 'ἧ',
  77008. 'Ἰ' => 'ἰ',
  77009. 'á¼¹' => 'á¼±',
  77010. 'Ἲ' => 'ἲ',
  77011. 'á¼»' => 'á¼³',
  77012. 'á¼¼' => 'á¼´',
  77013. 'á¼½' => 'á¼µ',
  77014. 'á¼¾' => 'á¼¶',
  77015. 'Ἷ' => 'ἷ',
  77016. 'Ὀ' => 'ὀ',
  77017. 'Ὁ' => '�',
  77018. 'Ὂ' => 'ὂ',
  77019. 'Ὃ' => 'ὃ',
  77020. 'Ὄ' => 'ὄ',
  77021. '�' => 'ὅ',
  77022. 'Ὑ' => 'ὑ',
  77023. 'Ὓ' => 'ὓ',
  77024. '�' => 'ὕ',
  77025. 'Ὗ' => 'ὗ',
  77026. 'Ὠ' => 'ὠ',
  77027. 'Ὡ' => 'ὡ',
  77028. 'Ὢ' => 'ὢ',
  77029. 'Ὣ' => 'ὣ',
  77030. 'Ὤ' => 'ὤ',
  77031. 'á½­' => 'á½¥',
  77032. 'Ὦ' => 'ὦ',
  77033. 'Ὧ' => 'ὧ',
  77034. 'ᾈ' => 'ᾀ',
  77035. 'ᾉ' => '�',
  77036. 'ᾊ' => 'ᾂ',
  77037. 'ᾋ' => 'ᾃ',
  77038. 'ᾌ' => 'ᾄ',
  77039. '�' => 'ᾅ',
  77040. 'ᾎ' => 'ᾆ',
  77041. '�' => 'ᾇ',
  77042. 'ᾘ' => '�',
  77043. 'ᾙ' => 'ᾑ',
  77044. 'ᾚ' => 'ᾒ',
  77045. 'ᾛ' => 'ᾓ',
  77046. 'ᾜ' => 'ᾔ',
  77047. '�' => 'ᾕ',
  77048. 'ᾞ' => 'ᾖ',
  77049. 'ᾟ' => 'ᾗ',
  77050. 'ᾨ' => 'ᾠ',
  77051. 'ᾩ' => 'ᾡ',
  77052. 'ᾪ' => 'ᾢ',
  77053. 'ᾫ' => 'ᾣ',
  77054. 'ᾬ' => 'ᾤ',
  77055. 'á¾­' => 'á¾¥',
  77056. 'ᾮ' => 'ᾦ',
  77057. 'ᾯ' => 'ᾧ',
  77058. 'Ᾰ' => 'ᾰ',
  77059. 'á¾¹' => 'á¾±',
  77060. 'Ὰ' => 'ὰ',
  77061. 'á¾»' => 'á½±',
  77062. 'á¾¼' => 'á¾³',
  77063. 'Ὲ' => 'ὲ',
  77064. 'Έ' => 'έ',
  77065. 'Ὴ' => 'ὴ',
  77066. 'á¿‹' => 'á½µ',
  77067. 'ῌ' => 'ῃ',
  77068. 'Ῐ' => '�',
  77069. 'á¿™' => 'á¿‘',
  77070. 'Ὶ' => 'ὶ',
  77071. 'á¿›' => 'á½·',
  77072. 'Ῠ' => 'ῠ',
  77073. 'á¿©' => 'á¿¡',
  77074. 'Ὺ' => 'ὺ',
  77075. 'á¿«' => 'á½»',
  77076. 'Ῥ' => 'ῥ',
  77077. 'Ὸ' => 'ὸ',
  77078. 'Ό' => 'ό',
  77079. 'Ὼ' => 'ὼ',
  77080. 'á¿»' => 'á½½',
  77081. 'ῼ' => 'ῳ',
  77082. 'Ω' => 'ω',
  77083. 'K' => 'k',
  77084. 'â„«' => 'Ã¥',
  77085. 'Ⅎ' => 'ⅎ',
  77086. 'â… ' => 'â…°',
  77087. 'â…¡' => 'â…±',
  77088. 'â…¢' => 'â…²',
  77089. 'â…£' => 'â…³',
  77090. 'â…¤' => 'â…´',
  77091. 'â…¥' => 'â…µ',
  77092. 'â…¦' => 'â…¶',
  77093. 'â…§' => 'â…·',
  77094. 'â…¨' => 'â…¸',
  77095. 'â…©' => 'â…¹',
  77096. 'â…ª' => 'â…º',
  77097. 'â…«' => 'â…»',
  77098. 'â…¬' => 'â…¼',
  77099. 'â…­' => 'â…½',
  77100. 'â…®' => 'â…¾',
  77101. 'â…¯' => 'â…¿',
  77102. 'Ↄ' => 'ↄ',
  77103. 'Ⓐ' => '�',
  77104. 'â’·' => 'â“‘',
  77105. 'â’¸' => 'â“’',
  77106. 'â’¹' => 'â““',
  77107. 'â’º' => 'â“”',
  77108. 'â’»' => 'â“•',
  77109. 'â’¼' => 'â“–',
  77110. 'â’½' => 'â“—',
  77111. 'Ⓘ' => 'ⓘ',
  77112. 'â’¿' => 'â“™',
  77113. 'Ⓚ' => 'ⓚ',
  77114. '�' => 'ⓛ',
  77115. 'Ⓜ' => 'ⓜ',
  77116. 'Ⓝ' => '�',
  77117. 'Ⓞ' => 'ⓞ',
  77118. 'Ⓟ' => 'ⓟ',
  77119. 'Ⓠ' => 'ⓠ',
  77120. 'Ⓡ' => 'ⓡ',
  77121. 'Ⓢ' => 'ⓢ',
  77122. 'Ⓣ' => 'ⓣ',
  77123. 'Ⓤ' => 'ⓤ',
  77124. 'â“‹' => 'â“¥',
  77125. 'Ⓦ' => 'ⓦ',
  77126. '�' => 'ⓧ',
  77127. 'Ⓨ' => 'ⓨ',
  77128. '�' => 'ⓩ',
  77129. 'â°€' => 'â°°',
  77130. 'â°�' => 'â°±',
  77131. 'â°‚' => 'â°²',
  77132. 'â°ƒ' => 'â°³',
  77133. 'â°„' => 'â°´',
  77134. 'â°…' => 'â°µ',
  77135. 'â°†' => 'â°¶',
  77136. 'â°‡' => 'â°·',
  77137. 'â°ˆ' => 'â°¸',
  77138. 'â°‰' => 'â°¹',
  77139. 'â°Š' => 'â°º',
  77140. 'â°‹' => 'â°»',
  77141. 'Ⰼ' => 'ⰼ',
  77142. 'â°�' => 'â°½',
  77143. 'â°Ž' => 'â°¾',
  77144. 'â°�' => 'â°¿',
  77145. 'â°�' => 'â±€',
  77146. 'Ⱁ' => '�',
  77147. 'Ⱂ' => 'ⱂ',
  77148. 'Ⱃ' => 'ⱃ',
  77149. 'Ⱄ' => 'ⱄ',
  77150. 'â°•' => 'â±…',
  77151. 'Ⱆ' => 'ⱆ',
  77152. 'Ⱇ' => 'ⱇ',
  77153. 'Ⱈ' => 'ⱈ',
  77154. 'Ⱉ' => 'ⱉ',
  77155. 'Ⱊ' => 'ⱊ',
  77156. 'Ⱋ' => 'ⱋ',
  77157. 'Ⱌ' => 'ⱌ',
  77158. '�' => '�',
  77159. 'Ⱎ' => 'ⱎ',
  77160. 'Ⱏ' => '�',
  77161. 'Ⱐ' => '�',
  77162. 'Ⱑ' => 'ⱑ',
  77163. 'â°¢' => 'â±’',
  77164. 'Ⱓ' => 'ⱓ',
  77165. 'â°¤' => 'â±”',
  77166. 'Ⱕ' => 'ⱕ',
  77167. 'â°¦' => 'â±–',
  77168. 'â°§' => 'â±—',
  77169. 'Ⱘ' => 'ⱘ',
  77170. 'â°©' => 'â±™',
  77171. 'Ⱚ' => 'ⱚ',
  77172. 'â°«' => 'â±›',
  77173. 'Ⱜ' => 'ⱜ',
  77174. 'Ⱝ' => '�',
  77175. 'Ⱞ' => 'ⱞ',
  77176. 'Ⱡ' => 'ⱡ',
  77177. 'â±¢' => 'É«',
  77178. 'â±£' => 'áµ½',
  77179. 'Ɽ' => 'ɽ',
  77180. 'Ⱨ' => 'ⱨ',
  77181. 'Ⱪ' => 'ⱪ',
  77182. 'Ⱬ' => 'ⱬ',
  77183. 'â±­' => 'É‘',
  77184. 'Ɱ' => 'ɱ',
  77185. 'Ɐ' => '�',
  77186. 'â±°' => 'É’',
  77187. 'â±²' => 'â±³',
  77188. 'â±µ' => 'â±¶',
  77189. 'â±¾' => 'È¿',
  77190. 'Ɀ' => 'ɀ',
  77191. 'Ⲁ' => '�',
  77192. 'Ⲃ' => 'ⲃ',
  77193. 'Ⲅ' => 'ⲅ',
  77194. 'Ⲇ' => 'ⲇ',
  77195. 'Ⲉ' => 'ⲉ',
  77196. 'Ⲋ' => 'ⲋ',
  77197. 'Ⲍ' => '�',
  77198. 'Ⲏ' => '�',
  77199. '�' => 'ⲑ',
  77200. 'Ⲓ' => 'ⲓ',
  77201. 'Ⲕ' => 'ⲕ',
  77202. 'â²–' => 'â²—',
  77203. 'Ⲙ' => 'ⲙ',
  77204. 'Ⲛ' => 'ⲛ',
  77205. 'Ⲝ' => '�',
  77206. 'Ⲟ' => 'ⲟ',
  77207. 'Ⲡ' => 'ⲡ',
  77208. 'â²¢' => 'â²£',
  77209. 'Ⲥ' => 'ⲥ',
  77210. 'Ⲧ' => 'ⲧ',
  77211. 'Ⲩ' => 'ⲩ',
  77212. 'Ⲫ' => 'ⲫ',
  77213. 'Ⲭ' => 'ⲭ',
  77214. 'Ⲯ' => 'ⲯ',
  77215. 'â²°' => 'â²±',
  77216. 'â²²' => 'â²³',
  77217. 'â²´' => 'â²µ',
  77218. 'â²¶' => 'â²·',
  77219. 'Ⲹ' => 'ⲹ',
  77220. 'Ⲻ' => 'ⲻ',
  77221. 'â²¼' => 'â²½',
  77222. 'Ⲿ' => 'ⲿ',
  77223. 'Ⳁ' => '�',
  77224. 'Ⳃ' => 'ⳃ',
  77225. 'Ⳅ' => 'ⳅ',
  77226. 'Ⳇ' => 'ⳇ',
  77227. 'Ⳉ' => 'ⳉ',
  77228. 'Ⳋ' => 'ⳋ',
  77229. 'Ⳍ' => '�',
  77230. 'Ⳏ' => '�',
  77231. '�' => 'ⳑ',
  77232. 'Ⳓ' => 'ⳓ',
  77233. 'Ⳕ' => 'ⳕ',
  77234. 'â³–' => 'â³—',
  77235. 'Ⳙ' => 'ⳙ',
  77236. 'Ⳛ' => 'ⳛ',
  77237. 'Ⳝ' => '�',
  77238. 'Ⳟ' => 'ⳟ',
  77239. 'Ⳡ' => 'ⳡ',
  77240. 'â³¢' => 'â³£',
  77241. 'Ⳬ' => 'ⳬ',
  77242. 'â³­' => 'â³®',
  77243. 'â³²' => 'â³³',
  77244. 'Ꙁ' => '�',
  77245. 'Ꙃ' => 'ꙃ',
  77246. 'Ꙅ' => 'ꙅ',
  77247. 'Ꙇ' => 'ꙇ',
  77248. 'Ꙉ' => 'ꙉ',
  77249. 'Ꙋ' => 'ꙋ',
  77250. 'Ꙍ' => '�',
  77251. 'Ꙏ' => '�',
  77252. '�' => 'ꙑ',
  77253. 'Ꙓ' => 'ꙓ',
  77254. 'Ꙕ' => 'ꙕ',
  77255. 'ê™–' => 'ê™—',
  77256. 'Ꙙ' => 'ꙙ',
  77257. 'Ꙛ' => 'ꙛ',
  77258. 'Ꙝ' => '�',
  77259. 'Ꙟ' => 'ꙟ',
  77260. 'Ꙡ' => 'ꙡ',
  77261. 'Ꙣ' => 'ꙣ',
  77262. 'Ꙥ' => 'ꙥ',
  77263. 'Ꙧ' => 'ꙧ',
  77264. 'Ꙩ' => 'ꙩ',
  77265. 'Ꙫ' => 'ꙫ',
  77266. 'Ꙭ' => 'ꙭ',
  77267. 'Ꚁ' => '�',
  77268. 'Ꚃ' => 'ꚃ',
  77269. 'êš„' => 'êš…',
  77270. 'Ꚇ' => 'ꚇ',
  77271. 'Ꚉ' => 'ꚉ',
  77272. 'Ꚋ' => 'ꚋ',
  77273. 'Ꚍ' => '�',
  77274. 'Ꚏ' => '�',
  77275. '�' => 'ꚑ',
  77276. 'êš’' => 'êš“',
  77277. 'êš”' => 'êš•',
  77278. 'êš–' => 'êš—',
  77279. 'Ꚙ' => 'ꚙ',
  77280. 'êšš' => 'êš›',
  77281. 'Ꜣ' => 'ꜣ',
  77282. 'Ꜥ' => 'ꜥ',
  77283. 'Ꜧ' => 'ꜧ',
  77284. 'Ꜩ' => 'ꜩ',
  77285. 'Ꜫ' => 'ꜫ',
  77286. 'Ꜭ' => 'ꜭ',
  77287. 'Ꜯ' => 'ꜯ',
  77288. 'Ꜳ' => 'ꜳ',
  77289. 'Ꜵ' => 'ꜵ',
  77290. 'Ꜷ' => 'ꜷ',
  77291. 'Ꜹ' => 'ꜹ',
  77292. 'Ꜻ' => 'ꜻ',
  77293. 'Ꜽ' => 'ꜽ',
  77294. 'Ꜿ' => 'ꜿ',
  77295. '�' => '�',
  77296. '�' => '�',
  77297. '�' => '�',
  77298. '�' => '�',
  77299. '�' => '�',
  77300. '�' => '�',
  77301. '�' => '�',
  77302. '�' => '�',
  77303. '�' => '�',
  77304. '�' => '�',
  77305. '�' => '�',
  77306. '�' => '�',
  77307. '�' => '�',
  77308. '�' => '�',
  77309. '�' => '�',
  77310. '�' => '�',
  77311. '�' => '�',
  77312. '�' => '�',
  77313. '�' => '�',
  77314. '�' => '�',
  77315. '�' => '�',
  77316. '�' => '�',
  77317. '�' => '�',
  77318. '�' => '�',
  77319. '�' => '�',
  77320. '�' => '�',
  77321. '�' => 'ᵹ',
  77322. '�' => '�',
  77323. 'Ꞁ' => '�',
  77324. 'Ꞃ' => 'ꞃ',
  77325. 'êž„' => 'êž…',
  77326. 'Ꞇ' => 'ꞇ',
  77327. 'Ꞌ' => 'ꞌ',
  77328. '�' => 'ɥ',
  77329. '�' => 'ꞑ',
  77330. 'êž’' => 'êž“',
  77331. 'êž–' => 'êž—',
  77332. 'Ꞙ' => 'ꞙ',
  77333. 'êžš' => 'êž›',
  77334. 'Ꞝ' => '�',
  77335. 'Ꞟ' => 'ꞟ',
  77336. 'êž ' => 'êž¡',
  77337. 'Ꞣ' => 'ꞣ',
  77338. 'Ꞥ' => 'ꞥ',
  77339. 'Ꞧ' => 'ꞧ',
  77340. 'Ꞩ' => 'ꞩ',
  77341. 'Ɦ' => 'ɦ',
  77342. 'Ɜ' => 'ɜ',
  77343. 'Ɡ' => 'ɡ',
  77344. 'Ɬ' => 'ɬ',
  77345. 'Ɪ' => 'ɪ',
  77346. 'êž°' => 'Êž',
  77347. 'Ʇ' => 'ʇ',
  77348. 'Ʝ' => '�',
  77349. 'êž³' => 'ê­“',
  77350. 'êž´' => 'êžµ',
  77351. 'êž¶' => 'êž·',
  77352. 'Ꞹ' => 'ꞹ',
  77353. 'Ꞻ' => 'ꞻ',
  77354. 'êž¼' => 'êž½',
  77355. 'êž¾' => 'êž¿',
  77356. 'Ꟃ' => 'ꟃ',
  77357. 'Ꞔ' => 'ꞔ',
  77358. 'Ʂ' => 'ʂ',
  77359. 'Ᶎ' => 'ᶎ',
  77360. 'Ꟈ' => 'ꟈ',
  77361. 'Ꟊ' => 'ꟊ',
  77362. 'Ꟶ' => 'ꟶ',
  77363. 'A' => '�',
  77364. 'B' => 'b',
  77365. 'C' => 'c',
  77366. 'D' => 'd',
  77367. 'ï¼¥' => 'ï½…',
  77368. 'F' => 'f',
  77369. 'G' => 'g',
  77370. 'H' => 'h',
  77371. 'I' => 'i',
  77372. 'J' => 'j',
  77373. 'K' => 'k',
  77374. 'L' => 'l',
  77375. 'M' => '�',
  77376. 'N' => 'n',
  77377. 'O' => '�',
  77378. 'P' => '�',
  77379. 'Q' => 'q',
  77380. 'ï¼²' => 'ï½’',
  77381. 'S' => 's',
  77382. 'ï¼´' => 'ï½”',
  77383. 'U' => 'u',
  77384. 'ï¼¶' => 'ï½–',
  77385. 'ï¼·' => 'ï½—',
  77386. 'X' => 'x',
  77387. 'ï¼¹' => 'ï½™',
  77388. 'Z' => 'z',
  77389. '�' => '�',
  77390. '�' => '�',
  77391. '�' => '�',
  77392. '�' => '�',
  77393. '�' => '�',
  77394. '�' => '�',
  77395. '�' => '�',
  77396. '�' => '�',
  77397. '�' => '�',
  77398. '�' => '�',
  77399. '�' => '�',
  77400. '�' => '�',
  77401. '�' => '�',
  77402. '�' => '�',
  77403. '�' => '�',
  77404. '�' => '�',
  77405. '�' => '�',
  77406. '�' => '�',
  77407. '�' => '�',
  77408. '�' => '�',
  77409. '�' => '�',
  77410. '�' => '�',
  77411. '�' => '�',
  77412. '�' => '�',
  77413. '�' => '�',
  77414. '�' => '�',
  77415. '�' => '�',
  77416. '�' => '�',
  77417. '�' => '�',
  77418. '�' => '�',
  77419. '�' => '�',
  77420. '�' => '�',
  77421. '�' => '�',
  77422. '�' => '�',
  77423. '�' => '�',
  77424. '�' => '�',
  77425. '�' => '�',
  77426. '�' => '�',
  77427. '�' => '�',
  77428. '�' => '�',
  77429. '�' => '�',
  77430. '�' => '�',
  77431. '�' => '�',
  77432. '�' => '�',
  77433. '�' => '�',
  77434. '�' => '�',
  77435. '�' => '�',
  77436. '�' => '�',
  77437. '�' => '�',
  77438. '�' => '�',
  77439. '�' => '�',
  77440. '�' => '�',
  77441. '�' => '�',
  77442. '�' => '�',
  77443. '�' => '�',
  77444. '�' => '�',
  77445. '�' => '�',
  77446. '�' => '�',
  77447. '�' => '�',
  77448. '�' => '�',
  77449. '�' => '�',
  77450. '�' => '�',
  77451. '�' => '�',
  77452. '�' => '�',
  77453. '�' => '�',
  77454. '�' => '�',
  77455. '�' => '�',
  77456. '�' => '�',
  77457. '�' => '�',
  77458. '�' => '�',
  77459. '�' => '�',
  77460. '�' => '�',
  77461. '�' => '�',
  77462. '�' => '�',
  77463. '�' => '�',
  77464. '�' => '�',
  77465. '�' => '�',
  77466. '�' => '�',
  77467. '�' => '�',
  77468. '�' => '�',
  77469. '�' => '�',
  77470. '�' => '�',
  77471. '�' => '�',
  77472. '�' => '�',
  77473. '�' => '�',
  77474. '�' => '�',
  77475. '�' => '�',
  77476. '�' => '�',
  77477. '�' => '�',
  77478. '�' => '�',
  77479. '�' => '�',
  77480. '�' => '�',
  77481. '�' => '�',
  77482. '�' => '�',
  77483. '�' => '�',
  77484. '�' => '�',
  77485. '�' => '�',
  77486. '�' => '�',
  77487. '�' => '�',
  77488. '�' => '�',
  77489. '�' => '�',
  77490. '�' => '�',
  77491. '�' => '�',
  77492. '�' => '�',
  77493. '�' => '�',
  77494. '�' => '�',
  77495. '�' => '�',
  77496. '�' => '�',
  77497. '�' => '�',
  77498. '�' => '�',
  77499. '�' => '�',
  77500. '�' => '�',
  77501. '�' => '�',
  77502. '�' => '�',
  77503. '�' => '�',
  77504. '�' => '�',
  77505. '�' => '�',
  77506. '�' => '�',
  77507. '�' => '�',
  77508. '�' => '�',
  77509. '�' => '�',
  77510. '�' => '�',
  77511. '�' => '�',
  77512. '�' => '�',
  77513. '�' => '�',
  77514. '�' => '�',
  77515. '�' => '�',
  77516. 'ð‘¢ ' => 'ð‘£€',
  77517. '𑢡' => '�',
  77518. '𑢢' => '𑣂',
  77519. '𑢣' => '𑣃',
  77520. '𑢤' => '𑣄',
  77521. 'ð‘¢¥' => 'ð‘£…',
  77522. '𑢦' => '𑣆',
  77523. '𑢧' => '𑣇',
  77524. '𑢨' => '𑣈',
  77525. '𑢩' => '𑣉',
  77526. '𑢪' => '𑣊',
  77527. '𑢫' => '𑣋',
  77528. '𑢬' => '𑣌',
  77529. '𑢭' => '�',
  77530. '𑢮' => '𑣎',
  77531. '𑢯' => '�',
  77532. '𑢰' => '�',
  77533. '𑢱' => '𑣑',
  77534. 'ð‘¢²' => 'ð‘£’',
  77535. '𑢳' => '𑣓',
  77536. 'ð‘¢´' => 'ð‘£”',
  77537. '𑢵' => '𑣕',
  77538. 'ð‘¢¶' => 'ð‘£–',
  77539. 'ð‘¢·' => 'ð‘£—',
  77540. '𑢸' => '𑣘',
  77541. 'ð‘¢¹' => 'ð‘£™',
  77542. '𑢺' => '𑣚',
  77543. 'ð‘¢»' => 'ð‘£›',
  77544. '𑢼' => '𑣜',
  77545. '𑢽' => '�',
  77546. '𑢾' => '𑣞',
  77547. '𑢿' => '𑣟',
  77548. 'ð–¹€' => 'ð–¹ ',
  77549. '�' => '𖹡',
  77550. '𖹂' => '𖹢',
  77551. '𖹃' => '𖹣',
  77552. '𖹄' => '𖹤',
  77553. 'ð–¹…' => 'ð–¹¥',
  77554. '𖹆' => '𖹦',
  77555. '𖹇' => '𖹧',
  77556. '𖹈' => '𖹨',
  77557. '𖹉' => '𖹩',
  77558. '𖹊' => '𖹪',
  77559. '𖹋' => '𖹫',
  77560. '𖹌' => '𖹬',
  77561. '�' => '𖹭',
  77562. '𖹎' => '𖹮',
  77563. '�' => '𖹯',
  77564. '�' => '𖹰',
  77565. '𖹑' => '𖹱',
  77566. 'ð–¹’' => 'ð–¹²',
  77567. '𖹓' => '𖹳',
  77568. 'ð–¹”' => 'ð–¹´',
  77569. '𖹕' => '𖹵',
  77570. 'ð–¹–' => 'ð–¹¶',
  77571. 'ð–¹—' => 'ð–¹·',
  77572. '𖹘' => '𖹸',
  77573. 'ð–¹™' => 'ð–¹¹',
  77574. '𖹚' => '𖹺',
  77575. 'ð–¹›' => 'ð–¹»',
  77576. '𖹜' => '𖹼',
  77577. '�' => '𖹽',
  77578. '𖹞' => '𖹾',
  77579. '𖹟' => '𖹿',
  77580. '𞤀' => '𞤢',
  77581. '�' => '𞤣',
  77582. '𞤂' => '𞤤',
  77583. '𞤃' => '𞤥',
  77584. '𞤄' => '𞤦',
  77585. '𞤅' => '𞤧',
  77586. '𞤆' => '𞤨',
  77587. '𞤇' => '𞤩',
  77588. '𞤈' => '𞤪',
  77589. '𞤉' => '𞤫',
  77590. '𞤊' => '𞤬',
  77591. '𞤋' => '𞤭',
  77592. '𞤌' => '𞤮',
  77593. '�' => '𞤯',
  77594. '𞤎' => '𞤰',
  77595. '�' => '𞤱',
  77596. '�' => '𞤲',
  77597. '𞤑' => '𞤳',
  77598. '𞤒' => '𞤴',
  77599. '𞤓' => '𞤵',
  77600. '𞤔' => '𞤶',
  77601. '𞤕' => '𞤷',
  77602. '𞤖' => '𞤸',
  77603. '𞤗' => '𞤹',
  77604. '𞤘' => '𞤺',
  77605. '𞤙' => '𞤻',
  77606. '𞤚' => '𞤼',
  77607. '𞤛' => '𞤽',
  77608. '𞤜' => '𞤾',
  77609. '�' => '𞤿',
  77610. '𞤞' => '𞥀',
  77611. '𞤟' => '�',
  77612. '𞤠' => '𞥂',
  77613. '𞤡' => '𞥃',
  77614. );
  77615. <?php
  77616. 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';
  77617. <?php
  77618. return array (
  77619. 'a' => 'A',
  77620. 'b' => 'B',
  77621. 'c' => 'C',
  77622. 'd' => 'D',
  77623. 'e' => 'E',
  77624. 'f' => 'F',
  77625. 'g' => 'G',
  77626. 'h' => 'H',
  77627. 'i' => 'I',
  77628. 'j' => 'J',
  77629. 'k' => 'K',
  77630. 'l' => 'L',
  77631. 'm' => 'M',
  77632. 'n' => 'N',
  77633. 'o' => 'O',
  77634. 'p' => 'P',
  77635. 'q' => 'Q',
  77636. 'r' => 'R',
  77637. 's' => 'S',
  77638. 't' => 'T',
  77639. 'u' => 'U',
  77640. 'v' => 'V',
  77641. 'w' => 'W',
  77642. 'x' => 'X',
  77643. 'y' => 'Y',
  77644. 'z' => 'Z',
  77645. 'µ' => 'Μ',
  77646. 'à' => 'À',
  77647. 'á' => '�',
  77648. 'â' => 'Â',
  77649. 'ã' => 'Ã',
  77650. 'ä' => 'Ä',
  77651. 'Ã¥' => 'Ã…',
  77652. 'æ' => 'Æ',
  77653. 'ç' => 'Ç',
  77654. 'è' => 'È',
  77655. 'é' => 'É',
  77656. 'ê' => 'Ê',
  77657. 'ë' => 'Ë',
  77658. 'ì' => 'Ì',
  77659. 'í' => '�',
  77660. 'î' => 'Î',
  77661. 'ï' => '�',
  77662. 'ð' => '�',
  77663. 'ñ' => 'Ñ',
  77664. 'ò' => 'Ò',
  77665. 'ó' => 'Ó',
  77666. 'ô' => 'Ô',
  77667. 'õ' => 'Õ',
  77668. 'ö' => 'Ö',
  77669. 'ø' => 'Ø',
  77670. 'ù' => 'Ù',
  77671. 'ú' => 'Ú',
  77672. 'û' => 'Û',
  77673. 'ü' => 'Ü',
  77674. 'ý' => '�',
  77675. 'þ' => 'Þ',
  77676. 'ÿ' => 'Ÿ',
  77677. '�' => 'Ā',
  77678. 'ă' => 'Ă',
  77679. 'Ä…' => 'Ä„',
  77680. 'ć' => 'Ć',
  77681. 'ĉ' => 'Ĉ',
  77682. 'Ä‹' => 'ÄŠ',
  77683. '�' => 'Č',
  77684. '�' => 'Ď',
  77685. 'đ' => '�',
  77686. 'Ä“' => 'Ä’',
  77687. 'Ä•' => 'Ä”',
  77688. 'Ä—' => 'Ä–',
  77689. 'ę' => 'Ę',
  77690. 'Ä›' => 'Äš',
  77691. '�' => 'Ĝ',
  77692. 'ÄŸ' => 'Äž',
  77693. 'Ä¡' => 'Ä ',
  77694. 'Ä£' => 'Ä¢',
  77695. 'ĥ' => 'Ĥ',
  77696. 'ħ' => 'Ħ',
  77697. 'ĩ' => 'Ĩ',
  77698. 'ī' => 'Ī',
  77699. 'ĭ' => 'Ĭ',
  77700. 'į' => 'Į',
  77701. 'ı' => 'I',
  77702. 'ij' => 'IJ',
  77703. 'ĵ' => 'Ĵ',
  77704. 'ķ' => 'Ķ',
  77705. 'ĺ' => 'Ĺ',
  77706. 'ļ' => 'Ļ',
  77707. 'ľ' => 'Ľ',
  77708. 'Å€' => 'Ä¿',
  77709. 'ł' => '�',
  77710. 'ń' => 'Ń',
  77711. 'ņ' => 'Ņ',
  77712. 'ň' => 'Ň',
  77713. 'Å‹' => 'ÅŠ',
  77714. '�' => 'Ō',
  77715. '�' => 'Ŏ',
  77716. 'ő' => '�',
  77717. 'Å“' => 'Å’',
  77718. 'Å•' => 'Å”',
  77719. 'Å—' => 'Å–',
  77720. 'ř' => 'Ř',
  77721. 'Å›' => 'Åš',
  77722. '�' => 'Ŝ',
  77723. 'ÅŸ' => 'Åž',
  77724. 'Å¡' => 'Å ',
  77725. 'Å£' => 'Å¢',
  77726. 'ť' => 'Ť',
  77727. 'ŧ' => 'Ŧ',
  77728. 'ũ' => 'Ũ',
  77729. 'ū' => 'Ū',
  77730. 'ŭ' => 'Ŭ',
  77731. 'ů' => 'Ů',
  77732. 'ű' => 'Ű',
  77733. 'ų' => 'Ų',
  77734. 'ŵ' => 'Ŵ',
  77735. 'ŷ' => 'Ŷ',
  77736. 'ź' => 'Ź',
  77737. 'ż' => 'Ż',
  77738. 'ž' => 'Ž',
  77739. 'Å¿' => 'S',
  77740. 'ƀ' => 'Ƀ',
  77741. 'ƃ' => 'Ƃ',
  77742. 'Æ…' => 'Æ„',
  77743. 'ƈ' => 'Ƈ',
  77744. 'ƌ' => 'Ƌ',
  77745. 'Æ’' => 'Æ‘',
  77746. 'ƕ' => 'Ƕ',
  77747. 'ƙ' => 'Ƙ',
  77748. 'ƚ' => 'Ƚ',
  77749. 'Æž' => 'È ',
  77750. 'Æ¡' => 'Æ ',
  77751. 'Æ£' => 'Æ¢',
  77752. 'ƥ' => 'Ƥ',
  77753. 'ƨ' => 'Ƨ',
  77754. 'ƭ' => 'Ƭ',
  77755. 'ư' => 'Ư',
  77756. 'ƴ' => 'Ƴ',
  77757. 'ƶ' => 'Ƶ',
  77758. 'ƹ' => 'Ƹ',
  77759. 'ƽ' => 'Ƽ',
  77760. 'Æ¿' => 'Ç·',
  77761. 'Ç…' => 'Ç„',
  77762. 'dž' => 'DŽ',
  77763. 'Lj' => 'LJ',
  77764. 'lj' => 'LJ',
  77765. 'Ç‹' => 'ÇŠ',
  77766. 'nj' => 'NJ',
  77767. 'ǎ' => '�',
  77768. '�' => '�',
  77769. 'Ç’' => 'Ç‘',
  77770. 'Ç”' => 'Ç“',
  77771. 'Ç–' => 'Ç•',
  77772. 'ǘ' => 'Ǘ',
  77773. 'Çš' => 'Ç™',
  77774. 'ǜ' => 'Ǜ',
  77775. '�' => 'Ǝ',
  77776. 'ÇŸ' => 'Çž',
  77777. 'Ç¡' => 'Ç ',
  77778. 'Ç£' => 'Ç¢',
  77779. 'ǥ' => 'Ǥ',
  77780. 'ǧ' => 'Ǧ',
  77781. 'ǩ' => 'Ǩ',
  77782. 'ǫ' => 'Ǫ',
  77783. 'ǭ' => 'Ǭ',
  77784. 'ǯ' => 'Ǯ',
  77785. 'Dz' => 'DZ',
  77786. 'dz' => 'DZ',
  77787. 'ǵ' => 'Ǵ',
  77788. 'ǹ' => 'Ǹ',
  77789. 'ǻ' => 'Ǻ',
  77790. 'ǽ' => 'Ǽ',
  77791. 'ǿ' => 'Ǿ',
  77792. '�' => 'Ȁ',
  77793. 'ȃ' => 'Ȃ',
  77794. 'È…' => 'È„',
  77795. 'ȇ' => 'Ȇ',
  77796. 'ȉ' => 'Ȉ',
  77797. 'È‹' => 'ÈŠ',
  77798. '�' => 'Ȍ',
  77799. '�' => 'Ȏ',
  77800. 'ȑ' => '�',
  77801. 'È“' => 'È’',
  77802. 'È•' => 'È”',
  77803. 'È—' => 'È–',
  77804. 'ș' => 'Ș',
  77805. 'È›' => 'Èš',
  77806. '�' => 'Ȝ',
  77807. 'ÈŸ' => 'Èž',
  77808. 'È£' => 'È¢',
  77809. 'ȥ' => 'Ȥ',
  77810. 'ȧ' => 'Ȧ',
  77811. 'ȩ' => 'Ȩ',
  77812. 'ȫ' => 'Ȫ',
  77813. 'ȭ' => 'Ȭ',
  77814. 'ȯ' => 'Ȯ',
  77815. 'ȱ' => 'Ȱ',
  77816. 'ȳ' => 'Ȳ',
  77817. 'ȼ' => 'Ȼ',
  77818. 'È¿' => 'â±¾',
  77819. 'ɀ' => 'Ɀ',
  77820. 'ɂ' => '�',
  77821. 'ɇ' => 'Ɇ',
  77822. 'ɉ' => 'Ɉ',
  77823. 'É‹' => 'ÉŠ',
  77824. '�' => 'Ɍ',
  77825. '�' => 'Ɏ',
  77826. '�' => 'Ɐ',
  77827. 'É‘' => 'â±­',
  77828. 'É’' => 'â±°',
  77829. 'ɓ' => '�',
  77830. 'ɔ' => 'Ɔ',
  77831. 'ɖ' => 'Ɖ',
  77832. 'É—' => 'ÆŠ',
  77833. 'ə' => '�',
  77834. 'ɛ' => '�',
  77835. 'ɜ' => 'Ɜ',
  77836. 'É ' => 'Æ“',
  77837. 'ɡ' => 'Ɡ',
  77838. 'É£' => 'Æ”',
  77839. 'ɥ' => '�',
  77840. 'ɦ' => 'Ɦ',
  77841. 'ɨ' => 'Ɨ',
  77842. 'É©' => 'Æ–',
  77843. 'ɪ' => 'Ɪ',
  77844. 'É«' => 'â±¢',
  77845. 'ɬ' => 'Ɬ',
  77846. 'ɯ' => 'Ɯ',
  77847. 'ɱ' => 'Ɱ',
  77848. 'ɲ' => '�',
  77849. 'ɵ' => 'Ɵ',
  77850. 'ɽ' => 'Ɽ',
  77851. 'ʀ' => 'Ʀ',
  77852. 'ʂ' => 'Ʂ',
  77853. 'ʃ' => 'Ʃ',
  77854. 'ʇ' => 'Ʇ',
  77855. 'ʈ' => 'Ʈ',
  77856. 'ʉ' => 'Ʉ',
  77857. 'ʊ' => 'Ʊ',
  77858. 'ʋ' => 'Ʋ',
  77859. 'ʌ' => 'Ʌ',
  77860. 'Ê’' => 'Æ·',
  77861. '�' => 'Ʝ',
  77862. 'Êž' => 'êž°',
  77863. 'ͅ' => 'Ι',
  77864. 'ͱ' => 'Ͱ',
  77865. 'ͳ' => 'Ͳ',
  77866. 'ͷ' => 'Ͷ',
  77867. 'ͻ' => 'Ͻ',
  77868. 'ͼ' => 'Ͼ',
  77869. 'ͽ' => 'Ͽ',
  77870. 'ά' => 'Ά',
  77871. 'έ' => 'Έ',
  77872. 'ή' => 'Ή',
  77873. 'ί' => 'Ί',
  77874. 'α' => 'Α',
  77875. 'β' => 'Β',
  77876. 'γ' => 'Γ',
  77877. 'δ' => 'Δ',
  77878. 'ε' => 'Ε',
  77879. 'ζ' => 'Ζ',
  77880. 'η' => 'Η',
  77881. 'θ' => 'Θ',
  77882. 'ι' => 'Ι',
  77883. 'κ' => 'Κ',
  77884. 'λ' => 'Λ',
  77885. 'μ' => 'Μ',
  77886. 'ν' => '�',
  77887. 'ξ' => 'Ξ',
  77888. 'ο' => 'Ο',
  77889. 'π' => 'Π',
  77890. '�' => 'Ρ',
  77891. 'ς' => 'Σ',
  77892. 'σ' => 'Σ',
  77893. 'τ' => 'Τ',
  77894. 'Ï…' => 'Î¥',
  77895. 'φ' => 'Φ',
  77896. 'χ' => 'Χ',
  77897. 'ψ' => 'Ψ',
  77898. 'ω' => 'Ω',
  77899. 'ϊ' => 'Ϊ',
  77900. 'ϋ' => 'Ϋ',
  77901. 'ό' => 'Ό',
  77902. '�' => 'Ύ',
  77903. 'ώ' => '�',
  77904. '�' => 'Β',
  77905. 'ϑ' => 'Θ',
  77906. 'ϕ' => 'Φ',
  77907. 'ϖ' => 'Π',
  77908. 'ϗ' => '�',
  77909. 'ϙ' => 'Ϙ',
  77910. 'Ï›' => 'Ïš',
  77911. '�' => 'Ϝ',
  77912. 'ÏŸ' => 'Ïž',
  77913. 'Ï¡' => 'Ï ',
  77914. 'Ï£' => 'Ï¢',
  77915. 'ϥ' => 'Ϥ',
  77916. 'ϧ' => 'Ϧ',
  77917. 'ϩ' => 'Ϩ',
  77918. 'ϫ' => 'Ϫ',
  77919. 'ϭ' => 'Ϭ',
  77920. 'ϯ' => 'Ϯ',
  77921. 'ϰ' => 'Κ',
  77922. 'ϱ' => 'Ρ',
  77923. 'ϲ' => 'Ϲ',
  77924. 'ϳ' => 'Ϳ',
  77925. 'ϵ' => 'Ε',
  77926. 'ϸ' => 'Ϸ',
  77927. 'ϻ' => 'Ϻ',
  77928. 'а' => '�',
  77929. 'б' => 'Б',
  77930. 'в' => 'В',
  77931. 'г' => 'Г',
  77932. 'д' => 'Д',
  77933. 'е' => 'Е',
  77934. 'ж' => 'Ж',
  77935. 'з' => 'З',
  77936. 'и' => 'И',
  77937. 'й' => 'Й',
  77938. 'к' => 'К',
  77939. 'л' => 'Л',
  77940. 'м' => 'М',
  77941. 'н' => '�',
  77942. 'о' => 'О',
  77943. 'п' => 'П',
  77944. 'р' => 'Р',
  77945. '�' => 'С',
  77946. 'т' => 'Т',
  77947. 'у' => 'У',
  77948. 'ф' => 'Ф',
  77949. 'Ñ…' => 'Ð¥',
  77950. 'ц' => 'Ц',
  77951. 'ч' => 'Ч',
  77952. 'ш' => 'Ш',
  77953. 'щ' => 'Щ',
  77954. 'ъ' => 'Ъ',
  77955. 'ы' => 'Ы',
  77956. 'ь' => 'Ь',
  77957. '�' => 'Э',
  77958. 'ю' => 'Ю',
  77959. '�' => 'Я',
  77960. '�' => 'Ѐ',
  77961. 'ё' => '�',
  77962. 'ђ' => 'Ђ',
  77963. 'ѓ' => 'Ѓ',
  77964. 'є' => 'Є',
  77965. 'Ñ•' => 'Ð…',
  77966. 'і' => 'І',
  77967. 'ї' => 'Ї',
  77968. 'ј' => 'Ј',
  77969. 'љ' => 'Љ',
  77970. 'њ' => 'Њ',
  77971. 'ћ' => 'Ћ',
  77972. 'ќ' => 'Ќ',
  77973. '�' => '�',
  77974. 'Ñž' => 'ÐŽ',
  77975. 'џ' => '�',
  77976. 'Ñ¡' => 'Ñ ',
  77977. 'Ñ£' => 'Ñ¢',
  77978. 'ѥ' => 'Ѥ',
  77979. 'ѧ' => 'Ѧ',
  77980. 'ѩ' => 'Ѩ',
  77981. 'ѫ' => 'Ѫ',
  77982. 'ѭ' => 'Ѭ',
  77983. 'ѯ' => 'Ѯ',
  77984. 'ѱ' => 'Ѱ',
  77985. 'ѳ' => 'Ѳ',
  77986. 'ѵ' => 'Ѵ',
  77987. 'ѷ' => 'Ѷ',
  77988. 'ѹ' => 'Ѹ',
  77989. 'ѻ' => 'Ѻ',
  77990. 'ѽ' => 'Ѽ',
  77991. 'ѿ' => 'Ѿ',
  77992. 'Ò�' => 'Ò€',
  77993. 'Ò‹' => 'ÒŠ',
  77994. '�' => 'Ҍ',
  77995. 'Ò�' => 'ÒŽ',
  77996. 'Ò‘' => 'Ò�',
  77997. 'Ò“' => 'Ò’',
  77998. 'Ò•' => 'Ò”',
  77999. 'Ò—' => 'Ò–',
  78000. 'Ò™' => 'Ò˜',
  78001. 'Ò›' => 'Òš',
  78002. '�' => 'Ҝ',
  78003. 'ÒŸ' => 'Òž',
  78004. 'Ò¡' => 'Ò ',
  78005. 'Ò£' => 'Ò¢',
  78006. 'Ò¥' => 'Ò¤',
  78007. 'Ò§' => 'Ò¦',
  78008. 'Ò©' => 'Ò¨',
  78009. 'Ò«' => 'Òª',
  78010. 'Ò­' => 'Ò¬',
  78011. 'Ò¯' => 'Ò®',
  78012. 'Ò±' => 'Ò°',
  78013. 'Ò³' => 'Ò²',
  78014. 'Òµ' => 'Ò´',
  78015. 'Ò·' => 'Ò¶',
  78016. 'Ò¹' => 'Ò¸',
  78017. 'Ò»' => 'Òº',
  78018. 'Ò½' => 'Ò¼',
  78019. 'Ò¿' => 'Ò¾',
  78020. 'Ó‚' => 'Ó�',
  78021. 'Ó„' => 'Óƒ',
  78022. 'Ó†' => 'Ó…',
  78023. 'Óˆ' => 'Ó‡',
  78024. 'ÓŠ' => 'Ó‰',
  78025. 'ӌ' => 'Ӌ',
  78026. 'ÓŽ' => 'Ó�',
  78027. 'Ó�' => 'Ó€',
  78028. 'Ó‘' => 'Ó�',
  78029. 'Ó“' => 'Ó’',
  78030. 'Ó•' => 'Ó”',
  78031. 'Ó—' => 'Ó–',
  78032. 'Ó™' => 'Ó˜',
  78033. 'Ó›' => 'Óš',
  78034. '�' => 'Ӝ',
  78035. 'ÓŸ' => 'Óž',
  78036. 'Ó¡' => 'Ó ',
  78037. 'Ó£' => 'Ó¢',
  78038. 'Ó¥' => 'Ó¤',
  78039. 'Ó§' => 'Ó¦',
  78040. 'Ó©' => 'Ó¨',
  78041. 'Ó«' => 'Óª',
  78042. 'Ó­' => 'Ó¬',
  78043. 'Ó¯' => 'Ó®',
  78044. 'Ó±' => 'Ó°',
  78045. 'Ó³' => 'Ó²',
  78046. 'Óµ' => 'Ó´',
  78047. 'Ó·' => 'Ó¶',
  78048. 'Ó¹' => 'Ó¸',
  78049. 'Ó»' => 'Óº',
  78050. 'Ó½' => 'Ó¼',
  78051. 'Ó¿' => 'Ó¾',
  78052. 'Ô�' => 'Ô€',
  78053. 'Ôƒ' => 'Ô‚',
  78054. 'Ô…' => 'Ô„',
  78055. 'Ô‡' => 'Ô†',
  78056. 'Ô‰' => 'Ôˆ',
  78057. 'Ô‹' => 'ÔŠ',
  78058. '�' => 'Ԍ',
  78059. 'Ô�' => 'ÔŽ',
  78060. 'Ô‘' => 'Ô�',
  78061. 'Ô“' => 'Ô’',
  78062. 'Ô•' => 'Ô”',
  78063. 'Ô—' => 'Ô–',
  78064. 'Ô™' => 'Ô˜',
  78065. 'Ô›' => 'Ôš',
  78066. '�' => 'Ԝ',
  78067. 'ÔŸ' => 'Ôž',
  78068. 'Ô¡' => 'Ô ',
  78069. 'Ô£' => 'Ô¢',
  78070. 'Ô¥' => 'Ô¤',
  78071. 'Ô§' => 'Ô¦',
  78072. 'Ô©' => 'Ô¨',
  78073. 'Ô«' => 'Ôª',
  78074. 'Ô­' => 'Ô¬',
  78075. 'Ô¯' => 'Ô®',
  78076. 'Õ¡' => 'Ô±',
  78077. 'Õ¢' => 'Ô²',
  78078. 'Õ£' => 'Ô³',
  78079. 'Õ¤' => 'Ô´',
  78080. 'Õ¥' => 'Ôµ',
  78081. 'Õ¦' => 'Ô¶',
  78082. 'Õ§' => 'Ô·',
  78083. 'Õ¨' => 'Ô¸',
  78084. 'Õ©' => 'Ô¹',
  78085. 'Õª' => 'Ôº',
  78086. 'Õ«' => 'Ô»',
  78087. 'Õ¬' => 'Ô¼',
  78088. 'Õ­' => 'Ô½',
  78089. 'Õ®' => 'Ô¾',
  78090. 'Õ¯' => 'Ô¿',
  78091. 'Õ°' => 'Õ€',
  78092. 'Õ±' => 'Õ�',
  78093. 'Õ²' => 'Õ‚',
  78094. 'Õ³' => 'Õƒ',
  78095. 'Õ´' => 'Õ„',
  78096. 'Õµ' => 'Õ…',
  78097. 'Õ¶' => 'Õ†',
  78098. 'Õ·' => 'Õ‡',
  78099. 'Õ¸' => 'Õˆ',
  78100. 'Õ¹' => 'Õ‰',
  78101. 'Õº' => 'ÕŠ',
  78102. 'Õ»' => 'Õ‹',
  78103. 'ռ' => 'Ռ',
  78104. 'Õ½' => 'Õ�',
  78105. 'Õ¾' => 'ÕŽ',
  78106. 'Õ¿' => 'Õ�',
  78107. 'Ö€' => 'Õ�',
  78108. 'Ö�' => 'Õ‘',
  78109. 'Ö‚' => 'Õ’',
  78110. 'Öƒ' => 'Õ“',
  78111. 'Ö„' => 'Õ”',
  78112. 'Ö…' => 'Õ•',
  78113. 'Ö†' => 'Õ–',
  78114. '�' => '�',
  78115. 'ბ' => 'Ბ',
  78116. 'გ' => 'Გ',
  78117. 'დ' => 'Დ',
  78118. 'ე' => 'Ე',
  78119. 'ვ' => 'Ვ',
  78120. 'ზ' => 'Ზ',
  78121. 'თ' => 'Თ',
  78122. 'ი' => 'Ი',
  78123. 'კ' => 'Კ',
  78124. 'ლ' => 'Ლ',
  78125. 'მ' => 'Მ',
  78126. 'ნ' => 'Ნ',
  78127. '�' => '�',
  78128. 'პ' => 'Პ',
  78129. 'ჟ' => 'Ჟ',
  78130. 'რ' => 'Რ',
  78131. 'ს' => 'Ს',
  78132. 'ტ' => 'Ტ',
  78133. 'უ' => 'Უ',
  78134. 'ფ' => 'Ფ',
  78135. 'ქ' => 'Ქ',
  78136. 'ღ' => 'Ღ',
  78137. 'ყ' => 'Ყ',
  78138. 'შ' => 'Შ',
  78139. 'ჩ' => 'Ჩ',
  78140. 'ც' => 'Ც',
  78141. 'ძ' => 'Ძ',
  78142. 'წ' => 'Წ',
  78143. 'ჭ' => 'Ჭ',
  78144. 'ხ' => 'Ხ',
  78145. 'ჯ' => 'Ჯ',
  78146. 'ჰ' => 'Ჰ',
  78147. 'ჱ' => 'Ჱ',
  78148. 'ჲ' => 'Ჲ',
  78149. 'ჳ' => 'Ჳ',
  78150. 'ჴ' => 'Ჴ',
  78151. 'ჵ' => 'Ჵ',
  78152. 'ჶ' => 'Ჶ',
  78153. 'ჷ' => 'Ჷ',
  78154. 'ჸ' => 'Ჸ',
  78155. 'ჹ' => 'Ჹ',
  78156. 'ჺ' => 'Ჺ',
  78157. 'ჽ' => 'Ჽ',
  78158. 'ჾ' => 'Ჾ',
  78159. 'ჿ' => 'Ჿ',
  78160. '�' => '�',
  78161. '�' => '�',
  78162. '�' => '�',
  78163. '�' => '�',
  78164. '�' => '�',
  78165. '�' => '�',
  78166. 'á²€' => 'Ð’',
  78167. '�' => 'Д',
  78168. 'ᲂ' => 'О',
  78169. 'ᲃ' => 'С',
  78170. 'ᲄ' => 'Т',
  78171. 'ᲅ' => 'Т',
  78172. 'ᲆ' => 'Ъ',
  78173. 'ᲇ' => 'Ѣ',
  78174. 'ᲈ' => 'Ꙋ',
  78175. 'ᵹ' => '�',
  78176. 'áµ½' => 'â±£',
  78177. 'ᶎ' => 'Ᶎ',
  78178. '�' => 'Ḁ',
  78179. 'ḃ' => 'Ḃ',
  78180. 'ḅ' => 'Ḅ',
  78181. 'ḇ' => 'Ḇ',
  78182. 'ḉ' => 'Ḉ',
  78183. 'ḋ' => 'Ḋ',
  78184. '�' => 'Ḍ',
  78185. '�' => 'Ḏ',
  78186. 'ḑ' => '�',
  78187. 'ḓ' => 'Ḓ',
  78188. 'ḕ' => 'Ḕ',
  78189. 'ḗ' => 'Ḗ',
  78190. 'ḙ' => 'Ḙ',
  78191. 'ḛ' => 'Ḛ',
  78192. '�' => 'Ḝ',
  78193. 'ḟ' => 'Ḟ',
  78194. 'ḡ' => 'Ḡ',
  78195. 'ḣ' => 'Ḣ',
  78196. 'ḥ' => 'Ḥ',
  78197. 'ḧ' => 'Ḧ',
  78198. 'ḩ' => 'Ḩ',
  78199. 'ḫ' => 'Ḫ',
  78200. 'ḭ' => 'Ḭ',
  78201. 'ḯ' => 'Ḯ',
  78202. 'ḱ' => 'Ḱ',
  78203. 'ḳ' => 'Ḳ',
  78204. 'ḵ' => 'Ḵ',
  78205. 'ḷ' => 'Ḷ',
  78206. 'ḹ' => 'Ḹ',
  78207. 'ḻ' => 'Ḻ',
  78208. 'ḽ' => 'Ḽ',
  78209. 'ḿ' => 'Ḿ',
  78210. '�' => 'Ṁ',
  78211. 'ṃ' => 'Ṃ',
  78212. 'ṅ' => 'Ṅ',
  78213. 'ṇ' => 'Ṇ',
  78214. 'ṉ' => 'Ṉ',
  78215. 'ṋ' => 'Ṋ',
  78216. '�' => 'Ṍ',
  78217. '�' => 'Ṏ',
  78218. 'ṑ' => '�',
  78219. 'ṓ' => 'Ṓ',
  78220. 'ṕ' => 'Ṕ',
  78221. 'á¹—' => 'á¹–',
  78222. 'ṙ' => 'Ṙ',
  78223. 'ṛ' => 'Ṛ',
  78224. '�' => 'Ṝ',
  78225. 'ṟ' => 'Ṟ',
  78226. 'ṡ' => 'Ṡ',
  78227. 'á¹£' => 'á¹¢',
  78228. 'ṥ' => 'Ṥ',
  78229. 'ṧ' => 'Ṧ',
  78230. 'ṩ' => 'Ṩ',
  78231. 'ṫ' => 'Ṫ',
  78232. 'ṭ' => 'Ṭ',
  78233. 'ṯ' => 'Ṯ',
  78234. 'á¹±' => 'á¹°',
  78235. 'á¹³' => 'á¹²',
  78236. 'á¹µ' => 'á¹´',
  78237. 'á¹·' => 'á¹¶',
  78238. 'ṹ' => 'Ṹ',
  78239. 'ṻ' => 'Ṻ',
  78240. 'á¹½' => 'á¹¼',
  78241. 'ṿ' => 'Ṿ',
  78242. '�' => 'Ẁ',
  78243. 'ẃ' => 'Ẃ',
  78244. 'ẅ' => 'Ẅ',
  78245. 'ẇ' => 'Ẇ',
  78246. 'ẉ' => 'Ẉ',
  78247. 'ẋ' => 'Ẋ',
  78248. '�' => 'Ẍ',
  78249. '�' => 'Ẏ',
  78250. 'ẑ' => '�',
  78251. 'ẓ' => 'Ẓ',
  78252. 'ẕ' => 'Ẕ',
  78253. 'ẛ' => 'Ṡ',
  78254. 'ạ' => 'Ạ',
  78255. 'ả' => 'Ả',
  78256. 'ấ' => 'Ấ',
  78257. 'ầ' => 'Ầ',
  78258. 'ẩ' => 'Ẩ',
  78259. 'ẫ' => 'Ẫ',
  78260. 'ậ' => 'Ậ',
  78261. 'ắ' => 'Ắ',
  78262. 'ằ' => 'Ằ',
  78263. 'ẳ' => 'Ẳ',
  78264. 'ẵ' => 'Ẵ',
  78265. 'ặ' => 'Ặ',
  78266. 'ẹ' => 'Ẹ',
  78267. 'ẻ' => 'Ẻ',
  78268. 'ẽ' => 'Ẽ',
  78269. 'ế' => 'Ế',
  78270. '�' => 'Ề',
  78271. 'ể' => 'Ể',
  78272. 'ễ' => 'Ễ',
  78273. 'ệ' => 'Ệ',
  78274. 'ỉ' => 'Ỉ',
  78275. 'ị' => 'Ị',
  78276. '�' => 'Ọ',
  78277. '�' => 'Ỏ',
  78278. 'ố' => '�',
  78279. 'ồ' => 'Ồ',
  78280. 'ổ' => 'Ổ',
  78281. 'á»—' => 'á»–',
  78282. 'ộ' => 'Ộ',
  78283. 'ớ' => 'Ớ',
  78284. '�' => 'Ờ',
  78285. 'ở' => 'Ở',
  78286. 'ỡ' => 'Ỡ',
  78287. 'ợ' => 'Ợ',
  78288. 'ụ' => 'Ụ',
  78289. 'ủ' => 'Ủ',
  78290. 'ứ' => 'Ứ',
  78291. 'ừ' => 'Ừ',
  78292. 'ử' => 'Ử',
  78293. 'ữ' => 'Ữ',
  78294. 'á»±' => 'á»°',
  78295. 'ỳ' => 'Ỳ',
  78296. 'ỵ' => 'Ỵ',
  78297. 'á»·' => 'á»¶',
  78298. 'ỹ' => 'Ỹ',
  78299. 'ỻ' => 'Ỻ',
  78300. 'ỽ' => 'Ỽ',
  78301. 'ỿ' => 'Ỿ',
  78302. 'ἀ' => 'Ἀ',
  78303. '�' => 'Ἁ',
  78304. 'ἂ' => 'Ἂ',
  78305. 'ἃ' => 'Ἃ',
  78306. 'ἄ' => 'Ἄ',
  78307. 'ἅ' => '�',
  78308. 'ἆ' => 'Ἆ',
  78309. 'ἇ' => '�',
  78310. '�' => 'Ἐ',
  78311. 'ἑ' => 'Ἑ',
  78312. 'ἒ' => 'Ἒ',
  78313. 'ἓ' => 'Ἓ',
  78314. 'ἔ' => 'Ἔ',
  78315. 'ἕ' => '�',
  78316. 'ἠ' => 'Ἠ',
  78317. 'ἡ' => 'Ἡ',
  78318. 'ἢ' => 'Ἢ',
  78319. 'ἣ' => 'Ἣ',
  78320. 'ἤ' => 'Ἤ',
  78321. 'á¼¥' => 'á¼­',
  78322. 'ἦ' => 'Ἦ',
  78323. 'ἧ' => 'Ἧ',
  78324. 'ἰ' => 'Ἰ',
  78325. 'á¼±' => 'á¼¹',
  78326. 'ἲ' => 'Ἲ',
  78327. 'á¼³' => 'á¼»',
  78328. 'á¼´' => 'á¼¼',
  78329. 'á¼µ' => 'á¼½',
  78330. 'á¼¶' => 'á¼¾',
  78331. 'ἷ' => 'Ἷ',
  78332. 'ὀ' => 'Ὀ',
  78333. '�' => 'Ὁ',
  78334. 'ὂ' => 'Ὂ',
  78335. 'ὃ' => 'Ὃ',
  78336. 'ὄ' => 'Ὄ',
  78337. 'ὅ' => '�',
  78338. 'ὑ' => 'Ὑ',
  78339. 'ὓ' => 'Ὓ',
  78340. 'ὕ' => '�',
  78341. 'ὗ' => 'Ὗ',
  78342. 'ὠ' => 'Ὠ',
  78343. 'ὡ' => 'Ὡ',
  78344. 'ὢ' => 'Ὢ',
  78345. 'ὣ' => 'Ὣ',
  78346. 'ὤ' => 'Ὤ',
  78347. 'á½¥' => 'á½­',
  78348. 'ὦ' => 'Ὦ',
  78349. 'ὧ' => 'Ὧ',
  78350. 'ὰ' => 'Ὰ',
  78351. 'á½±' => 'á¾»',
  78352. 'ὲ' => 'Ὲ',
  78353. 'έ' => 'Έ',
  78354. 'ὴ' => 'Ὴ',
  78355. 'á½µ' => 'á¿‹',
  78356. 'ὶ' => 'Ὶ',
  78357. 'á½·' => 'á¿›',
  78358. 'ὸ' => 'Ὸ',
  78359. 'ό' => 'Ό',
  78360. 'ὺ' => 'Ὺ',
  78361. 'á½»' => 'á¿«',
  78362. 'ὼ' => 'Ὼ',
  78363. 'á½½' => 'á¿»',
  78364. 'ᾀ' => 'ἈΙ',
  78365. '�' => 'ἉΙ',
  78366. 'ᾂ' => 'ἊΙ',
  78367. 'ᾃ' => 'ἋΙ',
  78368. 'ᾄ' => 'ἌΙ',
  78369. 'ᾅ' => '�Ι',
  78370. 'ᾆ' => 'ἎΙ',
  78371. 'ᾇ' => '�Ι',
  78372. '�' => 'ἨΙ',
  78373. 'ᾑ' => 'ἩΙ',
  78374. 'ᾒ' => 'ἪΙ',
  78375. 'ᾓ' => 'ἫΙ',
  78376. 'ᾔ' => 'ἬΙ',
  78377. 'ᾕ' => 'ἭΙ',
  78378. 'ᾖ' => 'ἮΙ',
  78379. 'ᾗ' => 'ἯΙ',
  78380. 'ᾠ' => 'ὨΙ',
  78381. 'ᾡ' => 'ὩΙ',
  78382. 'ᾢ' => 'ὪΙ',
  78383. 'ᾣ' => 'ὫΙ',
  78384. 'ᾤ' => 'ὬΙ',
  78385. 'ᾥ' => 'ὭΙ',
  78386. 'ᾦ' => 'ὮΙ',
  78387. 'ᾧ' => 'ὯΙ',
  78388. 'ᾰ' => 'Ᾰ',
  78389. 'á¾±' => 'á¾¹',
  78390. 'ᾳ' => 'ΑΙ',
  78391. 'ι' => 'Ι',
  78392. 'ῃ' => 'ΗΙ',
  78393. '�' => 'Ῐ',
  78394. 'á¿‘' => 'á¿™',
  78395. 'ῠ' => 'Ῠ',
  78396. 'á¿¡' => 'á¿©',
  78397. 'ῥ' => 'Ῥ',
  78398. 'ῳ' => 'ΩΙ',
  78399. 'ⅎ' => 'Ⅎ',
  78400. 'â…°' => 'â… ',
  78401. 'â…±' => 'â…¡',
  78402. 'â…²' => 'â…¢',
  78403. 'â…³' => 'â…£',
  78404. 'â…´' => 'â…¤',
  78405. 'â…µ' => 'â…¥',
  78406. 'â…¶' => 'â…¦',
  78407. 'â…·' => 'â…§',
  78408. 'â…¸' => 'â…¨',
  78409. 'â…¹' => 'â…©',
  78410. 'â…º' => 'â…ª',
  78411. 'â…»' => 'â…«',
  78412. 'â…¼' => 'â…¬',
  78413. 'â…½' => 'â…­',
  78414. 'â…¾' => 'â…®',
  78415. 'â…¿' => 'â…¯',
  78416. 'ↄ' => 'Ↄ',
  78417. '�' => 'Ⓐ',
  78418. 'â“‘' => 'â’·',
  78419. 'â“’' => 'â’¸',
  78420. 'â““' => 'â’¹',
  78421. 'â“”' => 'â’º',
  78422. 'â“•' => 'â’»',
  78423. 'â“–' => 'â’¼',
  78424. 'â“—' => 'â’½',
  78425. 'ⓘ' => 'Ⓘ',
  78426. 'â“™' => 'â’¿',
  78427. 'ⓚ' => 'Ⓚ',
  78428. 'ⓛ' => '�',
  78429. 'ⓜ' => 'Ⓜ',
  78430. '�' => 'Ⓝ',
  78431. 'ⓞ' => 'Ⓞ',
  78432. 'ⓟ' => 'Ⓟ',
  78433. 'ⓠ' => 'Ⓠ',
  78434. 'ⓡ' => 'Ⓡ',
  78435. 'ⓢ' => 'Ⓢ',
  78436. 'ⓣ' => 'Ⓣ',
  78437. 'ⓤ' => 'Ⓤ',
  78438. 'â“¥' => 'â“‹',
  78439. 'ⓦ' => 'Ⓦ',
  78440. 'ⓧ' => '�',
  78441. 'ⓨ' => 'Ⓨ',
  78442. 'ⓩ' => '�',
  78443. 'â°°' => 'â°€',
  78444. 'â°±' => 'â°�',
  78445. 'â°²' => 'â°‚',
  78446. 'â°³' => 'â°ƒ',
  78447. 'â°´' => 'â°„',
  78448. 'â°µ' => 'â°…',
  78449. 'â°¶' => 'â°†',
  78450. 'â°·' => 'â°‡',
  78451. 'â°¸' => 'â°ˆ',
  78452. 'â°¹' => 'â°‰',
  78453. 'â°º' => 'â°Š',
  78454. 'â°»' => 'â°‹',
  78455. 'ⰼ' => 'Ⰼ',
  78456. 'â°½' => 'â°�',
  78457. 'â°¾' => 'â°Ž',
  78458. 'â°¿' => 'â°�',
  78459. 'â±€' => 'â°�',
  78460. '�' => 'Ⱁ',
  78461. 'ⱂ' => 'Ⱂ',
  78462. 'ⱃ' => 'Ⱃ',
  78463. 'ⱄ' => 'Ⱄ',
  78464. 'â±…' => 'â°•',
  78465. 'ⱆ' => 'Ⱆ',
  78466. 'ⱇ' => 'Ⱇ',
  78467. 'ⱈ' => 'Ⱈ',
  78468. 'ⱉ' => 'Ⱉ',
  78469. 'ⱊ' => 'Ⱊ',
  78470. 'ⱋ' => 'Ⱋ',
  78471. 'ⱌ' => 'Ⱌ',
  78472. '�' => '�',
  78473. 'ⱎ' => 'Ⱎ',
  78474. '�' => 'Ⱏ',
  78475. '�' => 'Ⱐ',
  78476. 'ⱑ' => 'Ⱑ',
  78477. 'â±’' => 'â°¢',
  78478. 'ⱓ' => 'Ⱓ',
  78479. 'â±”' => 'â°¤',
  78480. 'ⱕ' => 'Ⱕ',
  78481. 'â±–' => 'â°¦',
  78482. 'â±—' => 'â°§',
  78483. 'ⱘ' => 'Ⱘ',
  78484. 'â±™' => 'â°©',
  78485. 'ⱚ' => 'Ⱚ',
  78486. 'â±›' => 'â°«',
  78487. 'ⱜ' => 'Ⱜ',
  78488. '�' => 'Ⱝ',
  78489. 'ⱞ' => 'Ⱞ',
  78490. 'ⱡ' => 'Ⱡ',
  78491. 'ⱥ' => 'Ⱥ',
  78492. 'ⱦ' => 'Ⱦ',
  78493. 'ⱨ' => 'Ⱨ',
  78494. 'ⱪ' => 'Ⱪ',
  78495. 'ⱬ' => 'Ⱬ',
  78496. 'â±³' => 'â±²',
  78497. 'â±¶' => 'â±µ',
  78498. '�' => 'Ⲁ',
  78499. 'ⲃ' => 'Ⲃ',
  78500. 'ⲅ' => 'Ⲅ',
  78501. 'ⲇ' => 'Ⲇ',
  78502. 'ⲉ' => 'Ⲉ',
  78503. 'ⲋ' => 'Ⲋ',
  78504. '�' => 'Ⲍ',
  78505. '�' => 'Ⲏ',
  78506. 'ⲑ' => '�',
  78507. 'ⲓ' => 'Ⲓ',
  78508. 'ⲕ' => 'Ⲕ',
  78509. 'â²—' => 'â²–',
  78510. 'ⲙ' => 'Ⲙ',
  78511. 'ⲛ' => 'Ⲛ',
  78512. '�' => 'Ⲝ',
  78513. 'ⲟ' => 'Ⲟ',
  78514. 'ⲡ' => 'Ⲡ',
  78515. 'â²£' => 'â²¢',
  78516. 'ⲥ' => 'Ⲥ',
  78517. 'ⲧ' => 'Ⲧ',
  78518. 'ⲩ' => 'Ⲩ',
  78519. 'ⲫ' => 'Ⲫ',
  78520. 'ⲭ' => 'Ⲭ',
  78521. 'ⲯ' => 'Ⲯ',
  78522. 'â²±' => 'â²°',
  78523. 'â²³' => 'â²²',
  78524. 'â²µ' => 'â²´',
  78525. 'â²·' => 'â²¶',
  78526. 'ⲹ' => 'Ⲹ',
  78527. 'ⲻ' => 'Ⲻ',
  78528. 'â²½' => 'â²¼',
  78529. 'ⲿ' => 'Ⲿ',
  78530. '�' => 'Ⳁ',
  78531. 'ⳃ' => 'Ⳃ',
  78532. 'ⳅ' => 'Ⳅ',
  78533. 'ⳇ' => 'Ⳇ',
  78534. 'ⳉ' => 'Ⳉ',
  78535. 'ⳋ' => 'Ⳋ',
  78536. '�' => 'Ⳍ',
  78537. '�' => 'Ⳏ',
  78538. 'ⳑ' => '�',
  78539. 'ⳓ' => 'Ⳓ',
  78540. 'ⳕ' => 'Ⳕ',
  78541. 'â³—' => 'â³–',
  78542. 'ⳙ' => 'Ⳙ',
  78543. 'ⳛ' => 'Ⳛ',
  78544. '�' => 'Ⳝ',
  78545. 'ⳟ' => 'Ⳟ',
  78546. 'ⳡ' => 'Ⳡ',
  78547. 'â³£' => 'â³¢',
  78548. 'ⳬ' => 'Ⳬ',
  78549. 'â³®' => 'â³­',
  78550. 'â³³' => 'â³²',
  78551. 'â´€' => 'á‚ ',
  78552. 'â´�' => 'á‚¡',
  78553. 'â´‚' => 'á‚¢',
  78554. 'â´ƒ' => 'á‚£',
  78555. 'ⴄ' => 'Ⴄ',
  78556. 'â´…' => 'á‚¥',
  78557. 'ⴆ' => 'Ⴆ',
  78558. 'â´‡' => 'á‚§',
  78559. 'ⴈ' => 'Ⴈ',
  78560. 'â´‰' => 'á‚©',
  78561. 'ⴊ' => 'Ⴊ',
  78562. 'â´‹' => 'á‚«',
  78563. 'ⴌ' => 'Ⴌ',
  78564. 'â´�' => 'á‚­',
  78565. 'â´Ž' => 'á‚®',
  78566. '�' => 'Ⴏ',
  78567. 'â´�' => 'á‚°',
  78568. 'ⴑ' => 'Ⴑ',
  78569. 'ⴒ' => 'Ⴒ',
  78570. 'ⴓ' => 'Ⴓ',
  78571. 'â´”' => 'á‚´',
  78572. 'ⴕ' => 'Ⴕ',
  78573. 'â´–' => 'á‚¶',
  78574. 'â´—' => 'á‚·',
  78575. 'ⴘ' => 'Ⴘ',
  78576. 'ⴙ' => 'Ⴙ',
  78577. 'ⴚ' => 'Ⴚ',
  78578. 'â´›' => 'á‚»',
  78579. 'ⴜ' => 'Ⴜ',
  78580. '�' => 'Ⴝ',
  78581. 'ⴞ' => 'Ⴞ',
  78582. 'â´Ÿ' => 'á‚¿',
  78583. 'ⴠ' => 'Ⴠ',
  78584. 'ⴡ' => '�',
  78585. 'ⴢ' => 'Ⴢ',
  78586. 'ⴣ' => 'Ⴣ',
  78587. 'ⴤ' => 'Ⴤ',
  78588. 'ⴥ' => 'Ⴥ',
  78589. 'ⴧ' => 'Ⴧ',
  78590. 'ⴭ' => '�',
  78591. '�' => 'Ꙁ',
  78592. 'ꙃ' => 'Ꙃ',
  78593. 'ꙅ' => 'Ꙅ',
  78594. 'ꙇ' => 'Ꙇ',
  78595. 'ꙉ' => 'Ꙉ',
  78596. 'ꙋ' => 'Ꙋ',
  78597. '�' => 'Ꙍ',
  78598. '�' => 'Ꙏ',
  78599. 'ꙑ' => '�',
  78600. 'ꙓ' => 'Ꙓ',
  78601. 'ꙕ' => 'Ꙕ',
  78602. 'ê™—' => 'ê™–',
  78603. 'ꙙ' => 'Ꙙ',
  78604. 'ꙛ' => 'Ꙛ',
  78605. '�' => 'Ꙝ',
  78606. 'ꙟ' => 'Ꙟ',
  78607. 'ꙡ' => 'Ꙡ',
  78608. 'ꙣ' => 'Ꙣ',
  78609. 'ꙥ' => 'Ꙥ',
  78610. 'ꙧ' => 'Ꙧ',
  78611. 'ꙩ' => 'Ꙩ',
  78612. 'ꙫ' => 'Ꙫ',
  78613. 'ꙭ' => 'Ꙭ',
  78614. '�' => 'Ꚁ',
  78615. 'ꚃ' => 'Ꚃ',
  78616. 'êš…' => 'êš„',
  78617. 'ꚇ' => 'Ꚇ',
  78618. 'ꚉ' => 'Ꚉ',
  78619. 'ꚋ' => 'Ꚋ',
  78620. '�' => 'Ꚍ',
  78621. '�' => 'Ꚏ',
  78622. 'ꚑ' => '�',
  78623. 'êš“' => 'êš’',
  78624. 'êš•' => 'êš”',
  78625. 'êš—' => 'êš–',
  78626. 'ꚙ' => 'Ꚙ',
  78627. 'êš›' => 'êšš',
  78628. 'ꜣ' => 'Ꜣ',
  78629. 'ꜥ' => 'Ꜥ',
  78630. 'ꜧ' => 'Ꜧ',
  78631. 'ꜩ' => 'Ꜩ',
  78632. 'ꜫ' => 'Ꜫ',
  78633. 'ꜭ' => 'Ꜭ',
  78634. 'ꜯ' => 'Ꜯ',
  78635. 'ꜳ' => 'Ꜳ',
  78636. 'ꜵ' => 'Ꜵ',
  78637. 'ꜷ' => 'Ꜷ',
  78638. 'ꜹ' => 'Ꜹ',
  78639. 'ꜻ' => 'Ꜻ',
  78640. 'ꜽ' => 'Ꜽ',
  78641. 'ꜿ' => 'Ꜿ',
  78642. '�' => '�',
  78643. '�' => '�',
  78644. '�' => '�',
  78645. '�' => '�',
  78646. '�' => '�',
  78647. '�' => '�',
  78648. '�' => '�',
  78649. '�' => '�',
  78650. '�' => '�',
  78651. '�' => '�',
  78652. '�' => '�',
  78653. '�' => '�',
  78654. '�' => '�',
  78655. '�' => '�',
  78656. '�' => '�',
  78657. '�' => '�',
  78658. '�' => '�',
  78659. '�' => '�',
  78660. '�' => '�',
  78661. '�' => '�',
  78662. '�' => '�',
  78663. '�' => '�',
  78664. '�' => '�',
  78665. '�' => '�',
  78666. '�' => '�',
  78667. '�' => '�',
  78668. '�' => '�',
  78669. '�' => 'Ꞁ',
  78670. 'ꞃ' => 'Ꞃ',
  78671. 'êž…' => 'êž„',
  78672. 'ꞇ' => 'Ꞇ',
  78673. 'ꞌ' => 'Ꞌ',
  78674. 'ꞑ' => '�',
  78675. 'êž“' => 'êž’',
  78676. 'ꞔ' => 'Ꞔ',
  78677. 'êž—' => 'êž–',
  78678. 'ꞙ' => 'Ꞙ',
  78679. 'êž›' => 'êžš',
  78680. '�' => 'Ꞝ',
  78681. 'ꞟ' => 'Ꞟ',
  78682. 'êž¡' => 'êž ',
  78683. 'ꞣ' => 'Ꞣ',
  78684. 'ꞥ' => 'Ꞥ',
  78685. 'ꞧ' => 'Ꞧ',
  78686. 'ꞩ' => 'Ꞩ',
  78687. 'êžµ' => 'êž´',
  78688. 'êž·' => 'êž¶',
  78689. 'ꞹ' => 'Ꞹ',
  78690. 'ꞻ' => 'Ꞻ',
  78691. 'êž½' => 'êž¼',
  78692. 'êž¿' => 'êž¾',
  78693. 'ꟃ' => 'Ꟃ',
  78694. 'ꟈ' => 'Ꟈ',
  78695. 'ꟊ' => 'Ꟊ',
  78696. 'ꟶ' => 'Ꟶ',
  78697. 'ê­“' => 'êž³',
  78698. 'ꭰ' => 'Ꭰ',
  78699. 'ꭱ' => 'Ꭱ',
  78700. 'ꭲ' => 'Ꭲ',
  78701. 'ꭳ' => 'Ꭳ',
  78702. 'ꭴ' => 'Ꭴ',
  78703. 'ꭵ' => 'Ꭵ',
  78704. 'ꭶ' => 'Ꭶ',
  78705. 'ꭷ' => 'Ꭷ',
  78706. 'ꭸ' => 'Ꭸ',
  78707. 'ꭹ' => 'Ꭹ',
  78708. 'ꭺ' => 'Ꭺ',
  78709. 'ꭻ' => 'Ꭻ',
  78710. 'ꭼ' => 'Ꭼ',
  78711. 'ꭽ' => 'Ꭽ',
  78712. 'ꭾ' => 'Ꭾ',
  78713. 'ꭿ' => 'Ꭿ',
  78714. 'ꮀ' => 'Ꮀ',
  78715. '�' => 'Ꮁ',
  78716. 'ꮂ' => 'Ꮂ',
  78717. 'ꮃ' => 'Ꮃ',
  78718. 'ꮄ' => 'Ꮄ',
  78719. 'ꮅ' => 'Ꮅ',
  78720. 'ꮆ' => 'Ꮆ',
  78721. 'ꮇ' => 'Ꮇ',
  78722. 'ꮈ' => 'Ꮈ',
  78723. 'ꮉ' => 'Ꮉ',
  78724. 'ꮊ' => 'Ꮊ',
  78725. 'ꮋ' => 'Ꮋ',
  78726. 'ꮌ' => 'Ꮌ',
  78727. '�' => 'Ꮍ',
  78728. 'ꮎ' => 'Ꮎ',
  78729. '�' => 'Ꮏ',
  78730. '�' => '�',
  78731. 'ꮑ' => '�',
  78732. 'ꮒ' => '�',
  78733. 'ꮓ' => '�',
  78734. 'ꮔ' => '�',
  78735. 'ꮕ' => '�',
  78736. 'ꮖ' => '�',
  78737. 'ꮗ' => '�',
  78738. 'ꮘ' => '�',
  78739. 'ꮙ' => '�',
  78740. 'ꮚ' => '�',
  78741. 'ꮛ' => '�',
  78742. 'ꮜ' => '�',
  78743. '�' => '�',
  78744. 'ꮞ' => '�',
  78745. 'ꮟ' => '�',
  78746. 'ꮠ' => '�',
  78747. 'ꮡ' => '�',
  78748. 'ꮢ' => '�',
  78749. 'ꮣ' => '�',
  78750. 'ꮤ' => '�',
  78751. 'ꮥ' => '�',
  78752. 'ꮦ' => '�',
  78753. 'ꮧ' => '�',
  78754. 'ꮨ' => '�',
  78755. 'ꮩ' => '�',
  78756. 'ꮪ' => '�',
  78757. 'ꮫ' => '�',
  78758. 'ꮬ' => '�',
  78759. 'ꮭ' => '�',
  78760. 'ꮮ' => '�',
  78761. 'ꮯ' => '�',
  78762. 'ꮰ' => '�',
  78763. 'ꮱ' => '�',
  78764. 'ꮲ' => '�',
  78765. 'ꮳ' => '�',
  78766. 'ꮴ' => '�',
  78767. 'ꮵ' => '�',
  78768. 'ꮶ' => '�',
  78769. 'ꮷ' => '�',
  78770. 'ꮸ' => '�',
  78771. 'ꮹ' => '�',
  78772. 'ꮺ' => '�',
  78773. 'ꮻ' => '�',
  78774. 'ꮼ' => '�',
  78775. 'ꮽ' => '�',
  78776. 'ꮾ' => '�',
  78777. 'ꮿ' => '�',
  78778. '�' => 'A',
  78779. 'b' => 'B',
  78780. 'c' => 'C',
  78781. 'd' => 'D',
  78782. 'ï½…' => 'ï¼¥',
  78783. 'f' => 'F',
  78784. 'g' => 'G',
  78785. 'h' => 'H',
  78786. 'i' => 'I',
  78787. 'j' => 'J',
  78788. 'k' => 'K',
  78789. 'l' => 'L',
  78790. '�' => 'M',
  78791. 'n' => 'N',
  78792. '�' => 'O',
  78793. '�' => 'P',
  78794. 'q' => 'Q',
  78795. 'ï½’' => 'ï¼²',
  78796. 's' => 'S',
  78797. 'ï½”' => 'ï¼´',
  78798. 'u' => 'U',
  78799. 'ï½–' => 'ï¼¶',
  78800. 'ï½—' => 'ï¼·',
  78801. 'x' => 'X',
  78802. 'ï½™' => 'ï¼¹',
  78803. 'z' => 'Z',
  78804. '�' => '�',
  78805. '�' => '�',
  78806. '�' => '�',
  78807. '�' => '�',
  78808. '�' => '�',
  78809. '�' => '�',
  78810. '�' => '�',
  78811. '�' => '�',
  78812. '�' => '�',
  78813. '�' => '�',
  78814. '�' => '�',
  78815. '�' => '�',
  78816. '�' => '�',
  78817. '�' => '�',
  78818. '�' => '�',
  78819. '�' => '�',
  78820. '�' => '�',
  78821. '�' => '�',
  78822. '�' => '�',
  78823. '�' => '�',
  78824. '�' => '�',
  78825. '�' => '�',
  78826. '�' => '�',
  78827. '�' => '�',
  78828. '�' => '�',
  78829. '�' => '�',
  78830. '�' => '�',
  78831. '�' => '�',
  78832. '�' => '�',
  78833. '�' => '�',
  78834. '�' => '�',
  78835. '�' => '�',
  78836. '�' => '�',
  78837. '�' => '�',
  78838. '�' => '�',
  78839. '�' => '�',
  78840. '�' => '�',
  78841. '�' => '�',
  78842. '�' => '�',
  78843. '�' => '�',
  78844. '�' => '�',
  78845. '�' => '�',
  78846. '�' => '�',
  78847. '�' => '�',
  78848. '�' => '�',
  78849. '�' => '�',
  78850. '�' => '�',
  78851. '�' => '�',
  78852. '�' => '�',
  78853. '�' => '�',
  78854. '�' => '�',
  78855. '�' => '�',
  78856. '�' => '�',
  78857. '�' => '�',
  78858. '�' => '�',
  78859. '�' => '�',
  78860. '�' => '�',
  78861. '�' => '�',
  78862. '�' => '�',
  78863. '�' => '�',
  78864. '�' => '�',
  78865. '�' => '�',
  78866. '�' => '�',
  78867. '�' => '�',
  78868. '�' => '�',
  78869. '�' => '�',
  78870. '�' => '�',
  78871. '�' => '�',
  78872. '�' => '�',
  78873. '�' => '�',
  78874. '�' => '�',
  78875. '�' => '�',
  78876. '�' => '�',
  78877. '�' => '�',
  78878. '�' => '�',
  78879. '�' => '�',
  78880. '�' => '�',
  78881. '�' => '�',
  78882. '�' => '�',
  78883. '�' => '�',
  78884. '�' => '�',
  78885. '�' => '�',
  78886. '�' => '�',
  78887. '�' => '�',
  78888. '�' => '�',
  78889. '�' => '�',
  78890. '�' => '�',
  78891. '�' => '�',
  78892. '�' => '�',
  78893. '�' => '�',
  78894. '�' => '�',
  78895. '�' => '�',
  78896. '�' => '�',
  78897. '�' => '�',
  78898. '�' => '�',
  78899. '�' => '�',
  78900. '�' => '�',
  78901. '�' => '�',
  78902. '�' => '�',
  78903. '�' => '�',
  78904. '�' => '�',
  78905. '�' => '�',
  78906. '�' => '�',
  78907. '�' => '�',
  78908. '�' => '�',
  78909. '�' => '�',
  78910. '�' => '�',
  78911. '�' => '�',
  78912. '�' => '�',
  78913. '�' => '�',
  78914. '�' => '�',
  78915. '�' => '�',
  78916. '�' => '�',
  78917. '�' => '�',
  78918. '�' => '�',
  78919. '�' => '�',
  78920. '�' => '�',
  78921. '�' => '�',
  78922. '�' => '�',
  78923. '�' => '�',
  78924. '�' => '�',
  78925. '�' => '�',
  78926. '�' => '�',
  78927. '�' => '�',
  78928. '�' => '�',
  78929. '�' => '�',
  78930. '�' => '�',
  78931. 'ð‘£€' => 'ð‘¢ ',
  78932. '�' => '𑢡',
  78933. '𑣂' => '𑢢',
  78934. '𑣃' => '𑢣',
  78935. '𑣄' => '𑢤',
  78936. 'ð‘£…' => 'ð‘¢¥',
  78937. '𑣆' => '𑢦',
  78938. '𑣇' => '𑢧',
  78939. '𑣈' => '𑢨',
  78940. '𑣉' => '𑢩',
  78941. '𑣊' => '𑢪',
  78942. '𑣋' => '𑢫',
  78943. '𑣌' => '𑢬',
  78944. '�' => '𑢭',
  78945. '𑣎' => '𑢮',
  78946. '�' => '𑢯',
  78947. '�' => '𑢰',
  78948. '𑣑' => '𑢱',
  78949. 'ð‘£’' => 'ð‘¢²',
  78950. '𑣓' => '𑢳',
  78951. 'ð‘£”' => 'ð‘¢´',
  78952. '𑣕' => '𑢵',
  78953. 'ð‘£–' => 'ð‘¢¶',
  78954. 'ð‘£—' => 'ð‘¢·',
  78955. '𑣘' => '𑢸',
  78956. 'ð‘£™' => 'ð‘¢¹',
  78957. '𑣚' => '𑢺',
  78958. 'ð‘£›' => 'ð‘¢»',
  78959. '𑣜' => '𑢼',
  78960. '�' => '𑢽',
  78961. '𑣞' => '𑢾',
  78962. '𑣟' => '𑢿',
  78963. 'ð–¹ ' => 'ð–¹€',
  78964. '𖹡' => '�',
  78965. '𖹢' => '𖹂',
  78966. '𖹣' => '𖹃',
  78967. '𖹤' => '𖹄',
  78968. 'ð–¹¥' => 'ð–¹…',
  78969. '𖹦' => '𖹆',
  78970. '𖹧' => '𖹇',
  78971. '𖹨' => '𖹈',
  78972. '𖹩' => '𖹉',
  78973. '𖹪' => '𖹊',
  78974. '𖹫' => '𖹋',
  78975. '𖹬' => '𖹌',
  78976. '𖹭' => '�',
  78977. '𖹮' => '𖹎',
  78978. '𖹯' => '�',
  78979. '𖹰' => '�',
  78980. '𖹱' => '𖹑',
  78981. 'ð–¹²' => 'ð–¹’',
  78982. '𖹳' => '𖹓',
  78983. 'ð–¹´' => 'ð–¹”',
  78984. '𖹵' => '𖹕',
  78985. 'ð–¹¶' => 'ð–¹–',
  78986. 'ð–¹·' => 'ð–¹—',
  78987. '𖹸' => '𖹘',
  78988. 'ð–¹¹' => 'ð–¹™',
  78989. '𖹺' => '𖹚',
  78990. 'ð–¹»' => 'ð–¹›',
  78991. '𖹼' => '𖹜',
  78992. '𖹽' => '�',
  78993. '𖹾' => '𖹞',
  78994. '𖹿' => '𖹟',
  78995. '𞤢' => '𞤀',
  78996. '𞤣' => '�',
  78997. '𞤤' => '𞤂',
  78998. '𞤥' => '𞤃',
  78999. '𞤦' => '𞤄',
  79000. '𞤧' => '𞤅',
  79001. '𞤨' => '𞤆',
  79002. '𞤩' => '𞤇',
  79003. '𞤪' => '𞤈',
  79004. '𞤫' => '𞤉',
  79005. '𞤬' => '𞤊',
  79006. '𞤭' => '𞤋',
  79007. '𞤮' => '𞤌',
  79008. '𞤯' => '�',
  79009. '𞤰' => '𞤎',
  79010. '𞤱' => '�',
  79011. '𞤲' => '�',
  79012. '𞤳' => '𞤑',
  79013. '𞤴' => '𞤒',
  79014. '𞤵' => '𞤓',
  79015. '𞤶' => '𞤔',
  79016. '𞤷' => '𞤕',
  79017. '𞤸' => '𞤖',
  79018. '𞤹' => '𞤗',
  79019. '𞤺' => '𞤘',
  79020. '𞤻' => '𞤙',
  79021. '𞤼' => '𞤚',
  79022. '𞤽' => '𞤛',
  79023. '𞤾' => '𞤜',
  79024. '𞤿' => '�',
  79025. '𞥀' => '𞤞',
  79026. '�' => '𞤟',
  79027. '𞥂' => '𞤠',
  79028. '𞥃' => '𞤡',
  79029. 'ß' => 'SS',
  79030. 'ff' => 'FF',
  79031. '�' => 'FI',
  79032. 'fl' => 'FL',
  79033. 'ffi' => 'FFI',
  79034. 'ffl' => 'FFL',
  79035. 'ſt' => 'ST',
  79036. 'st' => 'ST',
  79037. 'Ö‡' => 'ÔµÕ’',
  79038. 'ﬓ' => 'ՄՆ',
  79039. 'ﬔ' => 'ՄԵ',
  79040. 'ﬕ' => 'ՄԻ',
  79041. 'ﬖ' => 'ՎՆ',
  79042. 'ﬗ' => 'ՄԽ',
  79043. 'ʼn' => 'ʼN',
  79044. '�' => 'Ϊ�',
  79045. 'ΰ' => 'Ϋ�',
  79046. 'ǰ' => 'J̌',
  79047. 'ẖ' => 'H̱',
  79048. 'ẗ' => 'T̈',
  79049. 'ẘ' => 'W̊',
  79050. 'ẙ' => 'Y̊',
  79051. 'ẚ' => 'Aʾ',
  79052. '�' => 'Υ̓',
  79053. 'ὒ' => 'Υ̓̀',
  79054. 'ὔ' => 'Υ̓�',
  79055. 'ὖ' => 'Υ̓͂',
  79056. 'ᾶ' => 'Α͂',
  79057. 'ῆ' => 'Η͂',
  79058. 'ῒ' => 'Ϊ̀',
  79059. 'ΐ' => 'Ϊ�',
  79060. 'ῖ' => 'Ι͂',
  79061. 'ῗ' => 'Ϊ͂',
  79062. 'ῢ' => 'Ϋ̀',
  79063. 'ΰ' => 'Ϋ�',
  79064. 'ῤ' => 'Ρ̓',
  79065. 'ῦ' => 'Υ͂',
  79066. 'ῧ' => 'Ϋ͂',
  79067. 'ῶ' => 'Ω͂',
  79068. 'ᾈ' => 'ἈΙ',
  79069. 'ᾉ' => 'ἉΙ',
  79070. 'ᾊ' => 'ἊΙ',
  79071. 'ᾋ' => 'ἋΙ',
  79072. 'ᾌ' => 'ἌΙ',
  79073. '�' => '�Ι',
  79074. 'ᾎ' => 'ἎΙ',
  79075. '�' => '�Ι',
  79076. 'ᾘ' => 'ἨΙ',
  79077. 'ᾙ' => 'ἩΙ',
  79078. 'ᾚ' => 'ἪΙ',
  79079. 'ᾛ' => 'ἫΙ',
  79080. 'ᾜ' => 'ἬΙ',
  79081. '�' => 'ἭΙ',
  79082. 'ᾞ' => 'ἮΙ',
  79083. 'ᾟ' => 'ἯΙ',
  79084. 'ᾨ' => 'ὨΙ',
  79085. 'ᾩ' => 'ὩΙ',
  79086. 'ᾪ' => 'ὪΙ',
  79087. 'ᾫ' => 'ὫΙ',
  79088. 'ᾬ' => 'ὬΙ',
  79089. 'ᾭ' => 'ὭΙ',
  79090. 'ᾮ' => 'ὮΙ',
  79091. 'ᾯ' => 'ὯΙ',
  79092. 'ᾼ' => 'ΑΙ',
  79093. 'ῌ' => 'ΗΙ',
  79094. 'ῼ' => 'ΩΙ',
  79095. 'ᾲ' => 'ᾺΙ',
  79096. 'ᾴ' => 'ΆΙ',
  79097. 'ῂ' => 'ῊΙ',
  79098. 'ῄ' => 'ΉΙ',
  79099. 'ῲ' => 'ῺΙ',
  79100. 'ῴ' => '�Ι',
  79101. 'ᾷ' => 'Α͂Ι',
  79102. 'ῇ' => 'Η͂Ι',
  79103. 'ῷ' => 'Ω͂Ι',
  79104. );
  79105. <?php
  79106. use Symfony\Polyfill\Mbstring as p;
  79107. if (\PHP_VERSION_ID >= 80000) {
  79108. return require __DIR__.'/bootstrap80.php';
  79109. }
  79110. if (!function_exists('mb_convert_encoding')) {
  79111. function mb_convert_encoding($string, $to_encoding, $from_encoding = null) { return p\Mbstring::mb_convert_encoding($string, $to_encoding, $from_encoding); }
  79112. }
  79113. if (!function_exists('mb_decode_mimeheader')) {
  79114. function mb_decode_mimeheader($string) { return p\Mbstring::mb_decode_mimeheader($string); }
  79115. }
  79116. if (!function_exists('mb_encode_mimeheader')) {
  79117. 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); }
  79118. }
  79119. if (!function_exists('mb_decode_numericentity')) {
  79120. function mb_decode_numericentity($string, $map, $encoding = null) { return p\Mbstring::mb_decode_numericentity($string, $map, $encoding); }
  79121. }
  79122. if (!function_exists('mb_encode_numericentity')) {
  79123. function mb_encode_numericentity($string, $map, $encoding = null, $hex = false) { return p\Mbstring::mb_encode_numericentity($string, $map, $encoding, $hex); }
  79124. }
  79125. if (!function_exists('mb_convert_case')) {
  79126. function mb_convert_case($string, $mode, $encoding = null) { return p\Mbstring::mb_convert_case($string, $mode, $encoding); }
  79127. }
  79128. if (!function_exists('mb_internal_encoding')) {
  79129. function mb_internal_encoding($encoding = null) { return p\Mbstring::mb_internal_encoding($encoding); }
  79130. }
  79131. if (!function_exists('mb_language')) {
  79132. function mb_language($language = null) { return p\Mbstring::mb_language($language); }
  79133. }
  79134. if (!function_exists('mb_list_encodings')) {
  79135. function mb_list_encodings() { return p\Mbstring::mb_list_encodings(); }
  79136. }
  79137. if (!function_exists('mb_encoding_aliases')) {
  79138. function mb_encoding_aliases($encoding) { return p\Mbstring::mb_encoding_aliases($encoding); }
  79139. }
  79140. if (!function_exists('mb_check_encoding')) {
  79141. function mb_check_encoding($value = null, $encoding = null) { return p\Mbstring::mb_check_encoding($value, $encoding); }
  79142. }
  79143. if (!function_exists('mb_detect_encoding')) {
  79144. function mb_detect_encoding($string, $encodings = null, $strict = false) { return p\Mbstring::mb_detect_encoding($string, $encodings, $strict); }
  79145. }
  79146. if (!function_exists('mb_detect_order')) {
  79147. function mb_detect_order($encoding = null) { return p\Mbstring::mb_detect_order($encoding); }
  79148. }
  79149. if (!function_exists('mb_parse_str')) {
  79150. function mb_parse_str($string, &$result = []) { parse_str($string, $result); return (bool) $result; }
  79151. }
  79152. if (!function_exists('mb_strlen')) {
  79153. function mb_strlen($string, $encoding = null) { return p\Mbstring::mb_strlen($string, $encoding); }
  79154. }
  79155. if (!function_exists('mb_strpos')) {
  79156. function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strpos($haystack, $needle, $offset, $encoding); }
  79157. }
  79158. if (!function_exists('mb_strtolower')) {
  79159. function mb_strtolower($string, $encoding = null) { return p\Mbstring::mb_strtolower($string, $encoding); }
  79160. }
  79161. if (!function_exists('mb_strtoupper')) {
  79162. function mb_strtoupper($string, $encoding = null) { return p\Mbstring::mb_strtoupper($string, $encoding); }
  79163. }
  79164. if (!function_exists('mb_substitute_character')) {
  79165. function mb_substitute_character($substitute_character = null) { return p\Mbstring::mb_substitute_character($substitute_character); }
  79166. }
  79167. if (!function_exists('mb_substr')) {
  79168. function mb_substr($string, $start, $length = 2147483647, $encoding = null) { return p\Mbstring::mb_substr($string, $start, $length, $encoding); }
  79169. }
  79170. if (!function_exists('mb_stripos')) {
  79171. function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_stripos($haystack, $needle, $offset, $encoding); }
  79172. }
  79173. if (!function_exists('mb_stristr')) {
  79174. function mb_stristr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_stristr($haystack, $needle, $before_needle, $encoding); }
  79175. }
  79176. if (!function_exists('mb_strrchr')) {
  79177. function mb_strrchr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strrchr($haystack, $needle, $before_needle, $encoding); }
  79178. }
  79179. if (!function_exists('mb_strrichr')) {
  79180. function mb_strrichr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strrichr($haystack, $needle, $before_needle, $encoding); }
  79181. }
  79182. if (!function_exists('mb_strripos')) {
  79183. function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strripos($haystack, $needle, $offset, $encoding); }
  79184. }
  79185. if (!function_exists('mb_strrpos')) {
  79186. function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strrpos($haystack, $needle, $offset, $encoding); }
  79187. }
  79188. if (!function_exists('mb_strstr')) {
  79189. function mb_strstr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strstr($haystack, $needle, $before_needle, $encoding); }
  79190. }
  79191. if (!function_exists('mb_get_info')) {
  79192. function mb_get_info($type = 'all') { return p\Mbstring::mb_get_info($type); }
  79193. }
  79194. if (!function_exists('mb_http_output')) {
  79195. function mb_http_output($encoding = null) { return p\Mbstring::mb_http_output($encoding); }
  79196. }
  79197. if (!function_exists('mb_strwidth')) {
  79198. function mb_strwidth($string, $encoding = null) { return p\Mbstring::mb_strwidth($string, $encoding); }
  79199. }
  79200. if (!function_exists('mb_substr_count')) {
  79201. function mb_substr_count($haystack, $needle, $encoding = null) { return p\Mbstring::mb_substr_count($haystack, $needle, $encoding); }
  79202. }
  79203. if (!function_exists('mb_output_handler')) {
  79204. function mb_output_handler($string, $status) { return p\Mbstring::mb_output_handler($string, $status); }
  79205. }
  79206. if (!function_exists('mb_http_input')) {
  79207. function mb_http_input($type = null) { return p\Mbstring::mb_http_input($type); }
  79208. }
  79209. if (!function_exists('mb_convert_variables')) {
  79210. function mb_convert_variables($to_encoding, $from_encoding, &...$vars) { return p\Mbstring::mb_convert_variables($to_encoding, $from_encoding, ...$vars); }
  79211. }
  79212. if (!function_exists('mb_ord')) {
  79213. function mb_ord($string, $encoding = null) { return p\Mbstring::mb_ord($string, $encoding); }
  79214. }
  79215. if (!function_exists('mb_chr')) {
  79216. function mb_chr($codepoint, $encoding = null) { return p\Mbstring::mb_chr($codepoint, $encoding); }
  79217. }
  79218. if (!function_exists('mb_scrub')) {
  79219. function mb_scrub($string, $encoding = null) { $encoding = null === $encoding ? mb_internal_encoding() : $encoding; return mb_convert_encoding($string, $encoding, $encoding); }
  79220. }
  79221. if (!function_exists('mb_str_split')) {
  79222. function mb_str_split($string, $length = 1, $encoding = null) { return p\Mbstring::mb_str_split($string, $length, $encoding); }
  79223. }
  79224. if (!function_exists('mb_str_pad')) {
  79225. function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = STR_PAD_RIGHT, ?string $encoding = null): string { return p\Mbstring::mb_str_pad($string, $length, $pad_string, $pad_type, $encoding); }
  79226. }
  79227. if (extension_loaded('mbstring')) {
  79228. return;
  79229. }
  79230. if (!defined('MB_CASE_UPPER')) {
  79231. define('MB_CASE_UPPER', 0);
  79232. }
  79233. if (!defined('MB_CASE_LOWER')) {
  79234. define('MB_CASE_LOWER', 1);
  79235. }
  79236. if (!defined('MB_CASE_TITLE')) {
  79237. define('MB_CASE_TITLE', 2);
  79238. }
  79239. <?php
  79240. use Symfony\Polyfill\Mbstring as p;
  79241. if (!function_exists('mb_convert_encoding')) {
  79242. 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); }
  79243. }
  79244. if (!function_exists('mb_decode_mimeheader')) {
  79245. function mb_decode_mimeheader(?string $string): string { return p\Mbstring::mb_decode_mimeheader((string) $string); }
  79246. }
  79247. if (!function_exists('mb_encode_mimeheader')) {
  79248. 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); }
  79249. }
  79250. if (!function_exists('mb_decode_numericentity')) {
  79251. function mb_decode_numericentity(?string $string, array $map, ?string $encoding = null): string { return p\Mbstring::mb_decode_numericentity((string) $string, $map, $encoding); }
  79252. }
  79253. if (!function_exists('mb_encode_numericentity')) {
  79254. 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); }
  79255. }
  79256. if (!function_exists('mb_convert_case')) {
  79257. function mb_convert_case(?string $string, ?int $mode, ?string $encoding = null): string { return p\Mbstring::mb_convert_case((string) $string, (int) $mode, $encoding); }
  79258. }
  79259. if (!function_exists('mb_internal_encoding')) {
  79260. function mb_internal_encoding(?string $encoding = null): string|bool { return p\Mbstring::mb_internal_encoding($encoding); }
  79261. }
  79262. if (!function_exists('mb_language')) {
  79263. function mb_language(?string $language = null): string|bool { return p\Mbstring::mb_language($language); }
  79264. }
  79265. if (!function_exists('mb_list_encodings')) {
  79266. function mb_list_encodings(): array { return p\Mbstring::mb_list_encodings(); }
  79267. }
  79268. if (!function_exists('mb_encoding_aliases')) {
  79269. function mb_encoding_aliases(?string $encoding): array { return p\Mbstring::mb_encoding_aliases((string) $encoding); }
  79270. }
  79271. if (!function_exists('mb_check_encoding')) {
  79272. function mb_check_encoding(array|string|null $value = null, ?string $encoding = null): bool { return p\Mbstring::mb_check_encoding($value, $encoding); }
  79273. }
  79274. if (!function_exists('mb_detect_encoding')) {
  79275. 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); }
  79276. }
  79277. if (!function_exists('mb_detect_order')) {
  79278. function mb_detect_order(array|string|null $encoding = null): array|bool { return p\Mbstring::mb_detect_order($encoding); }
  79279. }
  79280. if (!function_exists('mb_parse_str')) {
  79281. function mb_parse_str(?string $string, &$result = []): bool { parse_str((string) $string, $result); return (bool) $result; }
  79282. }
  79283. if (!function_exists('mb_strlen')) {
  79284. function mb_strlen(?string $string, ?string $encoding = null): int { return p\Mbstring::mb_strlen((string) $string, $encoding); }
  79285. }
  79286. if (!function_exists('mb_strpos')) {
  79287. 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); }
  79288. }
  79289. if (!function_exists('mb_strtolower')) {
  79290. function mb_strtolower(?string $string, ?string $encoding = null): string { return p\Mbstring::mb_strtolower((string) $string, $encoding); }
  79291. }
  79292. if (!function_exists('mb_strtoupper')) {
  79293. function mb_strtoupper(?string $string, ?string $encoding = null): string { return p\Mbstring::mb_strtoupper((string) $string, $encoding); }
  79294. }
  79295. if (!function_exists('mb_substitute_character')) {
  79296. function mb_substitute_character(string|int|null $substitute_character = null): string|int|bool { return p\Mbstring::mb_substitute_character($substitute_character); }
  79297. }
  79298. if (!function_exists('mb_substr')) {
  79299. 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); }
  79300. }
  79301. if (!function_exists('mb_stripos')) {
  79302. 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); }
  79303. }
  79304. if (!function_exists('mb_stristr')) {
  79305. 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); }
  79306. }
  79307. if (!function_exists('mb_strrchr')) {
  79308. 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); }
  79309. }
  79310. if (!function_exists('mb_strrichr')) {
  79311. 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); }
  79312. }
  79313. if (!function_exists('mb_strripos')) {
  79314. 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); }
  79315. }
  79316. if (!function_exists('mb_strrpos')) {
  79317. 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); }
  79318. }
  79319. if (!function_exists('mb_strstr')) {
  79320. 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); }
  79321. }
  79322. if (!function_exists('mb_get_info')) {
  79323. function mb_get_info(?string $type = 'all'): array|string|int|false { return p\Mbstring::mb_get_info((string) $type); }
  79324. }
  79325. if (!function_exists('mb_http_output')) {
  79326. function mb_http_output(?string $encoding = null): string|bool { return p\Mbstring::mb_http_output($encoding); }
  79327. }
  79328. if (!function_exists('mb_strwidth')) {
  79329. function mb_strwidth(?string $string, ?string $encoding = null): int { return p\Mbstring::mb_strwidth((string) $string, $encoding); }
  79330. }
  79331. if (!function_exists('mb_substr_count')) {
  79332. function mb_substr_count(?string $haystack, ?string $needle, ?string $encoding = null): int { return p\Mbstring::mb_substr_count((string) $haystack, (string) $needle, $encoding); }
  79333. }
  79334. if (!function_exists('mb_output_handler')) {
  79335. function mb_output_handler(?string $string, ?int $status): string { return p\Mbstring::mb_output_handler((string) $string, (int) $status); }
  79336. }
  79337. if (!function_exists('mb_http_input')) {
  79338. function mb_http_input(?string $type = null): array|string|false { return p\Mbstring::mb_http_input($type); }
  79339. }
  79340. if (!function_exists('mb_convert_variables')) {
  79341. 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); }
  79342. }
  79343. if (!function_exists('mb_ord')) {
  79344. function mb_ord(?string $string, ?string $encoding = null): int|false { return p\Mbstring::mb_ord((string) $string, $encoding); }
  79345. }
  79346. if (!function_exists('mb_chr')) {
  79347. function mb_chr(?int $codepoint, ?string $encoding = null): string|false { return p\Mbstring::mb_chr((int) $codepoint, $encoding); }
  79348. }
  79349. if (!function_exists('mb_scrub')) {
  79350. function mb_scrub(?string $string, ?string $encoding = null): string { $encoding ??= mb_internal_encoding(); return mb_convert_encoding((string) $string, $encoding, $encoding); }
  79351. }
  79352. if (!function_exists('mb_str_split')) {
  79353. function mb_str_split(?string $string, ?int $length = 1, ?string $encoding = null): array { return p\Mbstring::mb_str_split((string) $string, (int) $length, $encoding); }
  79354. }
  79355. if (!function_exists('mb_str_pad')) {
  79356. function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = STR_PAD_RIGHT, ?string $encoding = null): string { return p\Mbstring::mb_str_pad($string, $length, $pad_string, $pad_type, $encoding); }
  79357. }
  79358. if (extension_loaded('mbstring')) {
  79359. return;
  79360. }
  79361. if (!defined('MB_CASE_UPPER')) {
  79362. define('MB_CASE_UPPER', 0);
  79363. }
  79364. if (!defined('MB_CASE_LOWER')) {
  79365. define('MB_CASE_LOWER', 1);
  79366. }
  79367. if (!defined('MB_CASE_TITLE')) {
  79368. define('MB_CASE_TITLE', 2);
  79369. }
  79370. Copyright (c) 2018-present Fabien Potencier
  79371. Permission is hereby granted, free of charge, to any person obtaining a copy
  79372. of this software and associated documentation files (the "Software"), to deal
  79373. in the Software without restriction, including without limitation the rights
  79374. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  79375. copies of the Software, and to permit persons to whom the Software is furnished
  79376. to do so, subject to the following conditions:
  79377. The above copyright notice and this permission notice shall be included in all
  79378. copies or substantial portions of the Software.
  79379. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  79380. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  79381. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  79382. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  79383. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  79384. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  79385. THE SOFTWARE.
  79386. <?php
  79387. namespace Symfony\Polyfill\Php73;
  79388. final class Php73
  79389. {
  79390. public static $startAt = 1533462603;
  79391. public static function hrtime($asNum = false)
  79392. {
  79393. $ns = microtime(false);
  79394. $s = substr($ns, 11) - self::$startAt;
  79395. $ns = 1E9 * (float) $ns;
  79396. if ($asNum) {
  79397. $ns += $s * 1E9;
  79398. return \PHP_INT_SIZE === 4 ? $ns : (int) $ns;
  79399. }
  79400. return [$s, (int) $ns];
  79401. }
  79402. }
  79403. <?php
  79404. if (\PHP_VERSION_ID < 70300) {
  79405. class JsonException extends Exception
  79406. {
  79407. }
  79408. }
  79409. <?php
  79410. use Symfony\Polyfill\Php73 as p;
  79411. if (\PHP_VERSION_ID >= 70300) {
  79412. return;
  79413. }
  79414. if (!function_exists('is_countable')) {
  79415. function is_countable($value) { return is_array($value) || $value instanceof Countable || $value instanceof ResourceBundle || $value instanceof SimpleXmlElement; }
  79416. }
  79417. if (!function_exists('hrtime')) {
  79418. require_once __DIR__.'/Php73.php';
  79419. p\Php73::$startAt = (int) microtime(true);
  79420. function hrtime($as_number = false) { return p\Php73::hrtime($as_number); }
  79421. }
  79422. if (!function_exists('array_key_first')) {
  79423. function array_key_first(array $array) { foreach ($array as $key => $value) { return $key; } }
  79424. }
  79425. if (!function_exists('array_key_last')) {
  79426. function array_key_last(array $array) { return key(array_slice($array, -1, 1, true)); }
  79427. }
  79428. Copyright (c) 2020-present Fabien Potencier
  79429. Permission is hereby granted, free of charge, to any person obtaining a copy
  79430. of this software and associated documentation files (the "Software"), to deal
  79431. in the Software without restriction, including without limitation the rights
  79432. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  79433. copies of the Software, and to permit persons to whom the Software is furnished
  79434. to do so, subject to the following conditions:
  79435. The above copyright notice and this permission notice shall be included in all
  79436. copies or substantial portions of the Software.
  79437. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  79438. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  79439. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  79440. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  79441. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  79442. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  79443. THE SOFTWARE.
  79444. <?php
  79445. namespace Symfony\Polyfill\Php80;
  79446. final class Php80
  79447. {
  79448. public static function fdiv(float $dividend, float $divisor): float
  79449. {
  79450. return @($dividend / $divisor);
  79451. }
  79452. public static function get_debug_type($value): string
  79453. {
  79454. switch (true) {
  79455. case null === $value: return 'null';
  79456. case \is_bool($value): return 'bool';
  79457. case \is_string($value): return 'string';
  79458. case \is_array($value): return 'array';
  79459. case \is_int($value): return 'int';
  79460. case \is_float($value): return 'float';
  79461. case \is_object($value): break;
  79462. case $value instanceof \__PHP_Incomplete_Class: return '__PHP_Incomplete_Class';
  79463. default:
  79464. if (null === $type = @get_resource_type($value)) {
  79465. return 'unknown';
  79466. }
  79467. if ('Unknown' === $type) {
  79468. $type = 'closed';
  79469. }
  79470. return "resource ($type)";
  79471. }
  79472. $class = \get_class($value);
  79473. if (false === strpos($class, '@')) {
  79474. return $class;
  79475. }
  79476. return (get_parent_class($class) ?: key(class_implements($class)) ?: 'class').'@anonymous';
  79477. }
  79478. public static function get_resource_id($res): int
  79479. {
  79480. if (!\is_resource($res) && null === @get_resource_type($res)) {
  79481. throw new \TypeError(sprintf('Argument 1 passed to get_resource_id() must be of the type resource, %s given', get_debug_type($res)));
  79482. }
  79483. return (int) $res;
  79484. }
  79485. public static function preg_last_error_msg(): string
  79486. {
  79487. switch (preg_last_error()) {
  79488. case \PREG_INTERNAL_ERROR:
  79489. return 'Internal error';
  79490. case \PREG_BAD_UTF8_ERROR:
  79491. return 'Malformed UTF-8 characters, possibly incorrectly encoded';
  79492. case \PREG_BAD_UTF8_OFFSET_ERROR:
  79493. return 'The offset did not correspond to the beginning of a valid UTF-8 code point';
  79494. case \PREG_BACKTRACK_LIMIT_ERROR:
  79495. return 'Backtrack limit exhausted';
  79496. case \PREG_RECURSION_LIMIT_ERROR:
  79497. return 'Recursion limit exhausted';
  79498. case \PREG_JIT_STACKLIMIT_ERROR:
  79499. return 'JIT stack limit exhausted';
  79500. case \PREG_NO_ERROR:
  79501. return 'No error';
  79502. default:
  79503. return 'Unknown error';
  79504. }
  79505. }
  79506. public static function str_contains(string $haystack, string $needle): bool
  79507. {
  79508. return '' === $needle || false !== strpos($haystack, $needle);
  79509. }
  79510. public static function str_starts_with(string $haystack, string $needle): bool
  79511. {
  79512. return 0 === strncmp($haystack, $needle, \strlen($needle));
  79513. }
  79514. public static function str_ends_with(string $haystack, string $needle): bool
  79515. {
  79516. if ('' === $needle || $needle === $haystack) {
  79517. return true;
  79518. }
  79519. if ('' === $haystack) {
  79520. return false;
  79521. }
  79522. $needleLength = \strlen($needle);
  79523. return $needleLength <= \strlen($haystack) && 0 === substr_compare($haystack, $needle, -$needleLength);
  79524. }
  79525. }
  79526. <?php
  79527. namespace Symfony\Polyfill\Php80;
  79528. class PhpToken implements \Stringable
  79529. {
  79530. public $id;
  79531. public $text;
  79532. public $line;
  79533. public $pos;
  79534. public function __construct(int $id, string $text, int $line = -1, int $position = -1)
  79535. {
  79536. $this->id = $id;
  79537. $this->text = $text;
  79538. $this->line = $line;
  79539. $this->pos = $position;
  79540. }
  79541. public function getTokenName(): ?string
  79542. {
  79543. if ('UNKNOWN' === $name = token_name($this->id)) {
  79544. $name = \strlen($this->text) > 1 || \ord($this->text) < 32 ? null : $this->text;
  79545. }
  79546. return $name;
  79547. }
  79548. public function is($kind): bool
  79549. {
  79550. foreach ((array) $kind as $value) {
  79551. if (\in_array($value, [$this->id, $this->text], true)) {
  79552. return true;
  79553. }
  79554. }
  79555. return false;
  79556. }
  79557. public function isIgnorable(): bool
  79558. {
  79559. return \in_array($this->id, [\T_WHITESPACE, \T_COMMENT, \T_DOC_COMMENT, \T_OPEN_TAG], true);
  79560. }
  79561. public function __toString(): string
  79562. {
  79563. return (string) $this->text;
  79564. }
  79565. public static function tokenize(string $code, int $flags = 0): array
  79566. {
  79567. $line = 1;
  79568. $position = 0;
  79569. $tokens = token_get_all($code, $flags);
  79570. foreach ($tokens as $index => $token) {
  79571. if (\is_string($token)) {
  79572. $id = \ord($token);
  79573. $text = $token;
  79574. } else {
  79575. [$id, $text, $line] = $token;
  79576. }
  79577. $tokens[$index] = new static($id, $text, $line, $position);
  79578. $position += \strlen($text);
  79579. }
  79580. return $tokens;
  79581. }
  79582. }
  79583. <?php
  79584. #[Attribute(Attribute::TARGET_CLASS)]
  79585. final class Attribute
  79586. {
  79587. public const TARGET_CLASS = 1;
  79588. public const TARGET_FUNCTION = 2;
  79589. public const TARGET_METHOD = 4;
  79590. public const TARGET_PROPERTY = 8;
  79591. public const TARGET_CLASS_CONSTANT = 16;
  79592. public const TARGET_PARAMETER = 32;
  79593. public const TARGET_ALL = 63;
  79594. public const IS_REPEATABLE = 64;
  79595. public $flags;
  79596. public function __construct(int $flags = self::TARGET_ALL)
  79597. {
  79598. $this->flags = $flags;
  79599. }
  79600. }
  79601. <?php
  79602. if (\PHP_VERSION_ID < 80000 && extension_loaded('tokenizer')) {
  79603. class PhpToken extends Symfony\Polyfill\Php80\PhpToken
  79604. {
  79605. }
  79606. }
  79607. <?php
  79608. if (\PHP_VERSION_ID < 80000) {
  79609. interface Stringable
  79610. {
  79611. public function __toString();
  79612. }
  79613. }
  79614. <?php
  79615. if (\PHP_VERSION_ID < 80000) {
  79616. class UnhandledMatchError extends Error
  79617. {
  79618. }
  79619. }
  79620. <?php
  79621. if (\PHP_VERSION_ID < 80000) {
  79622. class ValueError extends Error
  79623. {
  79624. }
  79625. }
  79626. <?php
  79627. use Symfony\Polyfill\Php80 as p;
  79628. if (\PHP_VERSION_ID >= 80000) {
  79629. return;
  79630. }
  79631. if (!defined('FILTER_VALIDATE_BOOL') && defined('FILTER_VALIDATE_BOOLEAN')) {
  79632. define('FILTER_VALIDATE_BOOL', \FILTER_VALIDATE_BOOLEAN);
  79633. }
  79634. if (!function_exists('fdiv')) {
  79635. function fdiv(float $num1, float $num2): float { return p\Php80::fdiv($num1, $num2); }
  79636. }
  79637. if (!function_exists('preg_last_error_msg')) {
  79638. function preg_last_error_msg(): string { return p\Php80::preg_last_error_msg(); }
  79639. }
  79640. if (!function_exists('str_contains')) {
  79641. function str_contains(?string $haystack, ?string $needle): bool { return p\Php80::str_contains($haystack ?? '', $needle ?? ''); }
  79642. }
  79643. if (!function_exists('str_starts_with')) {
  79644. function str_starts_with(?string $haystack, ?string $needle): bool { return p\Php80::str_starts_with($haystack ?? '', $needle ?? ''); }
  79645. }
  79646. if (!function_exists('str_ends_with')) {
  79647. function str_ends_with(?string $haystack, ?string $needle): bool { return p\Php80::str_ends_with($haystack ?? '', $needle ?? ''); }
  79648. }
  79649. if (!function_exists('get_debug_type')) {
  79650. function get_debug_type($value): string { return p\Php80::get_debug_type($value); }
  79651. }
  79652. if (!function_exists('get_resource_id')) {
  79653. function get_resource_id($resource): int { return p\Php80::get_resource_id($resource); }
  79654. }
  79655. Copyright (c) 2021-present Fabien Potencier
  79656. Permission is hereby granted, free of charge, to any person obtaining a copy
  79657. of this software and associated documentation files (the "Software"), to deal
  79658. in the Software without restriction, including without limitation the rights
  79659. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  79660. copies of the Software, and to permit persons to whom the Software is furnished
  79661. to do so, subject to the following conditions:
  79662. The above copyright notice and this permission notice shall be included in all
  79663. copies or substantial portions of the Software.
  79664. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  79665. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  79666. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  79667. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  79668. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  79669. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  79670. THE SOFTWARE.
  79671. <?php
  79672. namespace Symfony\Polyfill\Php81;
  79673. final class Php81
  79674. {
  79675. public static function array_is_list(array $array): bool
  79676. {
  79677. if ([] === $array || $array === array_values($array)) {
  79678. return true;
  79679. }
  79680. $nextKey = -1;
  79681. foreach ($array as $k => $v) {
  79682. if ($k !== ++$nextKey) {
  79683. return false;
  79684. }
  79685. }
  79686. return true;
  79687. }
  79688. }
  79689. <?php
  79690. if (\PHP_VERSION_ID >= 70400 && extension_loaded('curl')) {
  79691. class CURLStringFile extends CURLFile
  79692. {
  79693. private $data;
  79694. public function __construct(string $data, string $postname, string $mime = 'application/octet-stream')
  79695. {
  79696. $this->data = $data;
  79697. parent::__construct('data://application/octet-stream;base64,'.base64_encode($data), $mime, $postname);
  79698. }
  79699. public function __set(string $name, $value): void
  79700. {
  79701. if ('data' !== $name) {
  79702. $this->$name = $value;
  79703. return;
  79704. }
  79705. if (is_object($value) ? !method_exists($value, '__toString') : !is_scalar($value)) {
  79706. throw new \TypeError('Cannot assign '.gettype($value).' to property CURLStringFile::$data of type string');
  79707. }
  79708. $this->name = 'data://application/octet-stream;base64,'.base64_encode($value);
  79709. }
  79710. public function __isset(string $name): bool
  79711. {
  79712. return isset($this->$name);
  79713. }
  79714. public function &__get(string $name)
  79715. {
  79716. return $this->$name;
  79717. }
  79718. }
  79719. }
  79720. <?php
  79721. if (\PHP_VERSION_ID < 80100) {
  79722. #[Attribute(Attribute::TARGET_METHOD)]
  79723. final class ReturnTypeWillChange
  79724. {
  79725. public function __construct()
  79726. {
  79727. }
  79728. }
  79729. }
  79730. <?php
  79731. use Symfony\Polyfill\Php81 as p;
  79732. if (\PHP_VERSION_ID >= 80100) {
  79733. return;
  79734. }
  79735. if (defined('MYSQLI_REFRESH_SLAVE') && !defined('MYSQLI_REFRESH_REPLICA')) {
  79736. define('MYSQLI_REFRESH_REPLICA', 64);
  79737. }
  79738. if (!function_exists('array_is_list')) {
  79739. function array_is_list(array $array): bool { return p\Php81::array_is_list($array); }
  79740. }
  79741. if (!function_exists('enum_exists')) {
  79742. function enum_exists(string $enum, bool $autoload = true): bool { return $autoload && class_exists($enum) && false; }
  79743. }
  79744. <?php
  79745. namespace Symfony\Component\Process\Exception;
  79746. interface ExceptionInterface extends \Throwable
  79747. {
  79748. }
  79749. <?php
  79750. namespace Symfony\Component\Process\Exception;
  79751. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  79752. {
  79753. }
  79754. <?php
  79755. namespace Symfony\Component\Process\Exception;
  79756. class LogicException extends \LogicException implements ExceptionInterface
  79757. {
  79758. }
  79759. <?php
  79760. namespace Symfony\Component\Process\Exception;
  79761. use Symfony\Component\Process\Process;
  79762. class ProcessFailedException extends RuntimeException
  79763. {
  79764. private $process;
  79765. public function __construct(Process $process)
  79766. {
  79767. if ($process->isSuccessful()) {
  79768. throw new InvalidArgumentException('Expected a failed process, but the given process was successful.');
  79769. }
  79770. $error = sprintf('The command "%s" failed.'."\n\nExit Code: %s(%s)\n\nWorking directory: %s",
  79771. $process->getCommandLine(),
  79772. $process->getExitCode(),
  79773. $process->getExitCodeText(),
  79774. $process->getWorkingDirectory()
  79775. );
  79776. if (!$process->isOutputDisabled()) {
  79777. $error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s",
  79778. $process->getOutput(),
  79779. $process->getErrorOutput()
  79780. );
  79781. }
  79782. parent::__construct($error);
  79783. $this->process = $process;
  79784. }
  79785. public function getProcess()
  79786. {
  79787. return $this->process;
  79788. }
  79789. }
  79790. <?php
  79791. namespace Symfony\Component\Process\Exception;
  79792. use Symfony\Component\Process\Process;
  79793. final class ProcessSignaledException extends RuntimeException
  79794. {
  79795. private $process;
  79796. public function __construct(Process $process)
  79797. {
  79798. $this->process = $process;
  79799. parent::__construct(sprintf('The process has been signaled with signal "%s".', $process->getTermSignal()));
  79800. }
  79801. public function getProcess(): Process
  79802. {
  79803. return $this->process;
  79804. }
  79805. public function getSignal(): int
  79806. {
  79807. return $this->getProcess()->getTermSignal();
  79808. }
  79809. }
  79810. <?php
  79811. namespace Symfony\Component\Process\Exception;
  79812. use Symfony\Component\Process\Process;
  79813. class ProcessTimedOutException extends RuntimeException
  79814. {
  79815. public const TYPE_GENERAL = 1;
  79816. public const TYPE_IDLE = 2;
  79817. private $process;
  79818. private $timeoutType;
  79819. public function __construct(Process $process, int $timeoutType)
  79820. {
  79821. $this->process = $process;
  79822. $this->timeoutType = $timeoutType;
  79823. parent::__construct(sprintf(
  79824. 'The process "%s" exceeded the timeout of %s seconds.',
  79825. $process->getCommandLine(),
  79826. $this->getExceededTimeout()
  79827. ));
  79828. }
  79829. public function getProcess()
  79830. {
  79831. return $this->process;
  79832. }
  79833. public function isGeneralTimeout()
  79834. {
  79835. return self::TYPE_GENERAL === $this->timeoutType;
  79836. }
  79837. public function isIdleTimeout()
  79838. {
  79839. return self::TYPE_IDLE === $this->timeoutType;
  79840. }
  79841. public function getExceededTimeout()
  79842. {
  79843. switch ($this->timeoutType) {
  79844. case self::TYPE_GENERAL:
  79845. return $this->process->getTimeout();
  79846. case self::TYPE_IDLE:
  79847. return $this->process->getIdleTimeout();
  79848. default:
  79849. throw new \LogicException(sprintf('Unknown timeout type "%d".', $this->timeoutType));
  79850. }
  79851. }
  79852. }
  79853. <?php
  79854. namespace Symfony\Component\Process\Exception;
  79855. class RuntimeException extends \RuntimeException implements ExceptionInterface
  79856. {
  79857. }
  79858. <?php
  79859. namespace Symfony\Component\Process;
  79860. class ExecutableFinder
  79861. {
  79862. private $suffixes = ['.exe', '.bat', '.cmd', '.com'];
  79863. public function setSuffixes(array $suffixes)
  79864. {
  79865. $this->suffixes = $suffixes;
  79866. }
  79867. public function addSuffix(string $suffix)
  79868. {
  79869. $this->suffixes[] = $suffix;
  79870. }
  79871. public function find(string $name, string $default = null, array $extraDirs = [])
  79872. {
  79873. if (\ini_get('open_basedir')) {
  79874. $searchPath = array_merge(explode(\PATH_SEPARATOR, \ini_get('open_basedir')), $extraDirs);
  79875. $dirs = [];
  79876. foreach ($searchPath as $path) {
  79877. if (@is_dir($path)) {
  79878. $dirs[] = $path;
  79879. } else {
  79880. if (basename($path) == $name && @is_executable($path)) {
  79881. return $path;
  79882. }
  79883. }
  79884. }
  79885. } else {
  79886. $dirs = array_merge(
  79887. explode(\PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')),
  79888. $extraDirs
  79889. );
  79890. }
  79891. $suffixes = [''];
  79892. if ('\\' === \DIRECTORY_SEPARATOR) {
  79893. $pathExt = getenv('PATHEXT');
  79894. $suffixes = array_merge($pathExt ? explode(\PATH_SEPARATOR, $pathExt) : $this->suffixes, $suffixes);
  79895. }
  79896. foreach ($suffixes as $suffix) {
  79897. foreach ($dirs as $dir) {
  79898. if (@is_file($file = $dir.\DIRECTORY_SEPARATOR.$name.$suffix) && ('\\' === \DIRECTORY_SEPARATOR || @is_executable($file))) {
  79899. return $file;
  79900. }
  79901. }
  79902. }
  79903. return $default;
  79904. }
  79905. }
  79906. <?php
  79907. namespace Symfony\Component\Process;
  79908. use Symfony\Component\Process\Exception\RuntimeException;
  79909. class InputStream implements \IteratorAggregate
  79910. {
  79911. private $onEmpty = null;
  79912. private $input = [];
  79913. private $open = true;
  79914. public function onEmpty(callable $onEmpty = null)
  79915. {
  79916. $this->onEmpty = $onEmpty;
  79917. }
  79918. public function write($input)
  79919. {
  79920. if (null === $input) {
  79921. return;
  79922. }
  79923. if ($this->isClosed()) {
  79924. throw new RuntimeException(sprintf('"%s" is closed.', static::class));
  79925. }
  79926. $this->input[] = ProcessUtils::validateInput(__METHOD__, $input);
  79927. }
  79928. public function close()
  79929. {
  79930. $this->open = false;
  79931. }
  79932. public function isClosed()
  79933. {
  79934. return !$this->open;
  79935. }
  79936. #[\ReturnTypeWillChange]
  79937. public function getIterator()
  79938. {
  79939. $this->open = true;
  79940. while ($this->open || $this->input) {
  79941. if (!$this->input) {
  79942. yield '';
  79943. continue;
  79944. }
  79945. $current = array_shift($this->input);
  79946. if ($current instanceof \Iterator) {
  79947. yield from $current;
  79948. } else {
  79949. yield $current;
  79950. }
  79951. if (!$this->input && $this->open && null !== $onEmpty = $this->onEmpty) {
  79952. $this->write($onEmpty($this));
  79953. }
  79954. }
  79955. }
  79956. }
  79957. Copyright (c) 2004-present Fabien Potencier
  79958. Permission is hereby granted, free of charge, to any person obtaining a copy
  79959. of this software and associated documentation files (the "Software"), to deal
  79960. in the Software without restriction, including without limitation the rights
  79961. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  79962. copies of the Software, and to permit persons to whom the Software is furnished
  79963. to do so, subject to the following conditions:
  79964. The above copyright notice and this permission notice shall be included in all
  79965. copies or substantial portions of the Software.
  79966. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  79967. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  79968. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  79969. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  79970. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  79971. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  79972. THE SOFTWARE.
  79973. <?php
  79974. namespace Symfony\Component\Process;
  79975. class PhpExecutableFinder
  79976. {
  79977. private $executableFinder;
  79978. public function __construct()
  79979. {
  79980. $this->executableFinder = new ExecutableFinder();
  79981. }
  79982. public function find(bool $includeArgs = true)
  79983. {
  79984. if ($php = getenv('PHP_BINARY')) {
  79985. if (!is_executable($php)) {
  79986. $command = '\\' === \DIRECTORY_SEPARATOR ? 'where' : 'command -v';
  79987. if ($php = strtok(exec($command.' '.escapeshellarg($php)), \PHP_EOL)) {
  79988. if (!is_executable($php)) {
  79989. return false;
  79990. }
  79991. } else {
  79992. return false;
  79993. }
  79994. }
  79995. if (@is_dir($php)) {
  79996. return false;
  79997. }
  79998. return $php;
  79999. }
  80000. $args = $this->findArguments();
  80001. $args = $includeArgs && $args ? ' '.implode(' ', $args) : '';
  80002. if (\PHP_BINARY && \in_array(\PHP_SAPI, ['cli', 'cli-server', 'phpdbg'], true)) {
  80003. return \PHP_BINARY.$args;
  80004. }
  80005. if ($php = getenv('PHP_PATH')) {
  80006. if (!@is_executable($php) || @is_dir($php)) {
  80007. return false;
  80008. }
  80009. return $php;
  80010. }
  80011. if ($php = getenv('PHP_PEAR_PHP_BIN')) {
  80012. if (@is_executable($php) && !@is_dir($php)) {
  80013. return $php;
  80014. }
  80015. }
  80016. if (@is_executable($php = \PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php')) && !@is_dir($php)) {
  80017. return $php;
  80018. }
  80019. $dirs = [\PHP_BINDIR];
  80020. if ('\\' === \DIRECTORY_SEPARATOR) {
  80021. $dirs[] = 'C:\xampp\php\\';
  80022. }
  80023. return $this->executableFinder->find('php', false, $dirs);
  80024. }
  80025. public function findArguments()
  80026. {
  80027. $arguments = [];
  80028. if ('phpdbg' === \PHP_SAPI) {
  80029. $arguments[] = '-qrr';
  80030. }
  80031. return $arguments;
  80032. }
  80033. }
  80034. <?php
  80035. namespace Symfony\Component\Process;
  80036. use Symfony\Component\Process\Exception\LogicException;
  80037. use Symfony\Component\Process\Exception\RuntimeException;
  80038. class PhpProcess extends Process
  80039. {
  80040. public function __construct(string $script, string $cwd = null, array $env = null, int $timeout = 60, array $php = null)
  80041. {
  80042. if (null === $php) {
  80043. $executableFinder = new PhpExecutableFinder();
  80044. $php = $executableFinder->find(false);
  80045. $php = false === $php ? null : array_merge([$php], $executableFinder->findArguments());
  80046. }
  80047. if ('phpdbg' === \PHP_SAPI) {
  80048. $file = tempnam(sys_get_temp_dir(), 'dbg');
  80049. file_put_contents($file, $script);
  80050. register_shutdown_function('unlink', $file);
  80051. $php[] = $file;
  80052. $script = null;
  80053. }
  80054. parent::__construct($php, $cwd, $env, $script, $timeout);
  80055. }
  80056. public static function fromShellCommandline(string $command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60)
  80057. {
  80058. throw new LogicException(sprintf('The "%s()" method cannot be called when using "%s".', __METHOD__, self::class));
  80059. }
  80060. public function start(callable $callback = null, array $env = [])
  80061. {
  80062. if (null === $this->getCommandLine()) {
  80063. throw new RuntimeException('Unable to find the PHP executable.');
  80064. }
  80065. parent::start($callback, $env);
  80066. }
  80067. }
  80068. <?php
  80069. namespace Symfony\Component\Process\Pipes;
  80070. use Symfony\Component\Process\Exception\InvalidArgumentException;
  80071. abstract class AbstractPipes implements PipesInterface
  80072. {
  80073. public $pipes = [];
  80074. private $inputBuffer = '';
  80075. private $input;
  80076. private $blocked = true;
  80077. private $lastError;
  80078. public function __construct($input)
  80079. {
  80080. if (\is_resource($input) || $input instanceof \Iterator) {
  80081. $this->input = $input;
  80082. } elseif (\is_string($input)) {
  80083. $this->inputBuffer = $input;
  80084. } else {
  80085. $this->inputBuffer = (string) $input;
  80086. }
  80087. }
  80088. public function close()
  80089. {
  80090. foreach ($this->pipes as $pipe) {
  80091. if (\is_resource($pipe)) {
  80092. fclose($pipe);
  80093. }
  80094. }
  80095. $this->pipes = [];
  80096. }
  80097. protected function hasSystemCallBeenInterrupted(): bool
  80098. {
  80099. $lastError = $this->lastError;
  80100. $this->lastError = null;
  80101. return null !== $lastError && false !== stripos($lastError, 'interrupted system call');
  80102. }
  80103. protected function unblock()
  80104. {
  80105. if (!$this->blocked) {
  80106. return;
  80107. }
  80108. foreach ($this->pipes as $pipe) {
  80109. stream_set_blocking($pipe, 0);
  80110. }
  80111. if (\is_resource($this->input)) {
  80112. stream_set_blocking($this->input, 0);
  80113. }
  80114. $this->blocked = false;
  80115. }
  80116. protected function write(): ?array
  80117. {
  80118. if (!isset($this->pipes[0])) {
  80119. return null;
  80120. }
  80121. $input = $this->input;
  80122. if ($input instanceof \Iterator) {
  80123. if (!$input->valid()) {
  80124. $input = null;
  80125. } elseif (\is_resource($input = $input->current())) {
  80126. stream_set_blocking($input, 0);
  80127. } elseif (!isset($this->inputBuffer[0])) {
  80128. if (!\is_string($input)) {
  80129. if (!\is_scalar($input)) {
  80130. 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)));
  80131. }
  80132. $input = (string) $input;
  80133. }
  80134. $this->inputBuffer = $input;
  80135. $this->input->next();
  80136. $input = null;
  80137. } else {
  80138. $input = null;
  80139. }
  80140. }
  80141. $r = $e = [];
  80142. $w = [$this->pipes[0]];
  80143. if (false === @stream_select($r, $w, $e, 0, 0)) {
  80144. return null;
  80145. }
  80146. foreach ($w as $stdin) {
  80147. if (isset($this->inputBuffer[0])) {
  80148. $written = fwrite($stdin, $this->inputBuffer);
  80149. $this->inputBuffer = substr($this->inputBuffer, $written);
  80150. if (isset($this->inputBuffer[0])) {
  80151. return [$this->pipes[0]];
  80152. }
  80153. }
  80154. if ($input) {
  80155. while (true) {
  80156. $data = fread($input, self::CHUNK_SIZE);
  80157. if (!isset($data[0])) {
  80158. break;
  80159. }
  80160. $written = fwrite($stdin, $data);
  80161. $data = substr($data, $written);
  80162. if (isset($data[0])) {
  80163. $this->inputBuffer = $data;
  80164. return [$this->pipes[0]];
  80165. }
  80166. }
  80167. if (feof($input)) {
  80168. if ($this->input instanceof \Iterator) {
  80169. $this->input->next();
  80170. } else {
  80171. $this->input = null;
  80172. }
  80173. }
  80174. }
  80175. }
  80176. if (!isset($this->inputBuffer[0]) && !($this->input instanceof \Iterator ? $this->input->valid() : $this->input)) {
  80177. $this->input = null;
  80178. fclose($this->pipes[0]);
  80179. unset($this->pipes[0]);
  80180. } elseif (!$w) {
  80181. return [$this->pipes[0]];
  80182. }
  80183. return null;
  80184. }
  80185. public function handleError(int $type, string $msg)
  80186. {
  80187. $this->lastError = $msg;
  80188. }
  80189. }
  80190. <?php
  80191. namespace Symfony\Component\Process\Pipes;
  80192. interface PipesInterface
  80193. {
  80194. public const CHUNK_SIZE = 16384;
  80195. public function getDescriptors(): array;
  80196. public function getFiles(): array;
  80197. public function readAndWrite(bool $blocking, bool $close = false): array;
  80198. public function areOpen(): bool;
  80199. public function haveReadSupport(): bool;
  80200. public function close();
  80201. }
  80202. <?php
  80203. namespace Symfony\Component\Process\Pipes;
  80204. use Symfony\Component\Process\Process;
  80205. class UnixPipes extends AbstractPipes
  80206. {
  80207. private $ttyMode;
  80208. private $ptyMode;
  80209. private $haveReadSupport;
  80210. public function __construct(?bool $ttyMode, bool $ptyMode, $input, bool $haveReadSupport)
  80211. {
  80212. $this->ttyMode = $ttyMode;
  80213. $this->ptyMode = $ptyMode;
  80214. $this->haveReadSupport = $haveReadSupport;
  80215. parent::__construct($input);
  80216. }
  80217. public function __sleep(): array
  80218. {
  80219. throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
  80220. }
  80221. public function __wakeup()
  80222. {
  80223. throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
  80224. }
  80225. public function __destruct()
  80226. {
  80227. $this->close();
  80228. }
  80229. public function getDescriptors(): array
  80230. {
  80231. if (!$this->haveReadSupport) {
  80232. $nullstream = fopen('/dev/null', 'c');
  80233. return [
  80234. ['pipe', 'r'],
  80235. $nullstream,
  80236. $nullstream,
  80237. ];
  80238. }
  80239. if ($this->ttyMode) {
  80240. return [
  80241. ['file', '/dev/tty', 'r'],
  80242. ['file', '/dev/tty', 'w'],
  80243. ['file', '/dev/tty', 'w'],
  80244. ];
  80245. }
  80246. if ($this->ptyMode && Process::isPtySupported()) {
  80247. return [
  80248. ['pty'],
  80249. ['pty'],
  80250. ['pty'],
  80251. ];
  80252. }
  80253. return [
  80254. ['pipe', 'r'],
  80255. ['pipe', 'w'],
  80256. ['pipe', 'w'],
  80257. ];
  80258. }
  80259. public function getFiles(): array
  80260. {
  80261. return [];
  80262. }
  80263. public function readAndWrite(bool $blocking, bool $close = false): array
  80264. {
  80265. $this->unblock();
  80266. $w = $this->write();
  80267. $read = $e = [];
  80268. $r = $this->pipes;
  80269. unset($r[0]);
  80270. set_error_handler([$this, 'handleError']);
  80271. if (($r || $w) && false === stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1E6 : 0)) {
  80272. restore_error_handler();
  80273. if (!$this->hasSystemCallBeenInterrupted()) {
  80274. $this->pipes = [];
  80275. }
  80276. return $read;
  80277. }
  80278. restore_error_handler();
  80279. foreach ($r as $pipe) {
  80280. $read[$type = array_search($pipe, $this->pipes, true)] = '';
  80281. do {
  80282. $data = @fread($pipe, self::CHUNK_SIZE);
  80283. $read[$type] .= $data;
  80284. } while (isset($data[0]) && ($close || isset($data[self::CHUNK_SIZE - 1])));
  80285. if (!isset($read[$type][0])) {
  80286. unset($read[$type]);
  80287. }
  80288. if ($close && feof($pipe)) {
  80289. fclose($pipe);
  80290. unset($this->pipes[$type]);
  80291. }
  80292. }
  80293. return $read;
  80294. }
  80295. public function haveReadSupport(): bool
  80296. {
  80297. return $this->haveReadSupport;
  80298. }
  80299. public function areOpen(): bool
  80300. {
  80301. return (bool) $this->pipes;
  80302. }
  80303. }
  80304. <?php
  80305. namespace Symfony\Component\Process\Pipes;
  80306. use Symfony\Component\Process\Exception\RuntimeException;
  80307. use Symfony\Component\Process\Process;
  80308. class WindowsPipes extends AbstractPipes
  80309. {
  80310. private $files = [];
  80311. private $fileHandles = [];
  80312. private $lockHandles = [];
  80313. private $readBytes = [
  80314. Process::STDOUT => 0,
  80315. Process::STDERR => 0,
  80316. ];
  80317. private $haveReadSupport;
  80318. public function __construct($input, bool $haveReadSupport)
  80319. {
  80320. $this->haveReadSupport = $haveReadSupport;
  80321. if ($this->haveReadSupport) {
  80322. $pipes = [
  80323. Process::STDOUT => Process::OUT,
  80324. Process::STDERR => Process::ERR,
  80325. ];
  80326. $tmpDir = sys_get_temp_dir();
  80327. $lastError = 'unknown reason';
  80328. set_error_handler(function ($type, $msg) use (&$lastError) { $lastError = $msg; });
  80329. for ($i = 0;; ++$i) {
  80330. foreach ($pipes as $pipe => $name) {
  80331. $file = sprintf('%s\\sf_proc_%02X.%s', $tmpDir, $i, $name);
  80332. if (!$h = fopen($file.'.lock', 'w')) {
  80333. if (file_exists($file.'.lock')) {
  80334. continue 2;
  80335. }
  80336. restore_error_handler();
  80337. throw new RuntimeException('A temporary file could not be opened to write the process output: '.$lastError);
  80338. }
  80339. if (!flock($h, \LOCK_EX | \LOCK_NB)) {
  80340. continue 2;
  80341. }
  80342. if (isset($this->lockHandles[$pipe])) {
  80343. flock($this->lockHandles[$pipe], \LOCK_UN);
  80344. fclose($this->lockHandles[$pipe]);
  80345. }
  80346. $this->lockHandles[$pipe] = $h;
  80347. if (!($h = fopen($file, 'w')) || !fclose($h) || !$h = fopen($file, 'r')) {
  80348. flock($this->lockHandles[$pipe], \LOCK_UN);
  80349. fclose($this->lockHandles[$pipe]);
  80350. unset($this->lockHandles[$pipe]);
  80351. continue 2;
  80352. }
  80353. $this->fileHandles[$pipe] = $h;
  80354. $this->files[$pipe] = $file;
  80355. }
  80356. break;
  80357. }
  80358. restore_error_handler();
  80359. }
  80360. parent::__construct($input);
  80361. }
  80362. public function __sleep(): array
  80363. {
  80364. throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
  80365. }
  80366. public function __wakeup()
  80367. {
  80368. throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
  80369. }
  80370. public function __destruct()
  80371. {
  80372. $this->close();
  80373. }
  80374. public function getDescriptors(): array
  80375. {
  80376. if (!$this->haveReadSupport) {
  80377. $nullstream = fopen('NUL', 'c');
  80378. return [
  80379. ['pipe', 'r'],
  80380. $nullstream,
  80381. $nullstream,
  80382. ];
  80383. }
  80384. return [
  80385. ['pipe', 'r'],
  80386. ['file', 'NUL', 'w'],
  80387. ['file', 'NUL', 'w'],
  80388. ];
  80389. }
  80390. public function getFiles(): array
  80391. {
  80392. return $this->files;
  80393. }
  80394. public function readAndWrite(bool $blocking, bool $close = false): array
  80395. {
  80396. $this->unblock();
  80397. $w = $this->write();
  80398. $read = $r = $e = [];
  80399. if ($blocking) {
  80400. if ($w) {
  80401. @stream_select($r, $w, $e, 0, Process::TIMEOUT_PRECISION * 1E6);
  80402. } elseif ($this->fileHandles) {
  80403. usleep(Process::TIMEOUT_PRECISION * 1E6);
  80404. }
  80405. }
  80406. foreach ($this->fileHandles as $type => $fileHandle) {
  80407. $data = stream_get_contents($fileHandle, -1, $this->readBytes[$type]);
  80408. if (isset($data[0])) {
  80409. $this->readBytes[$type] += \strlen($data);
  80410. $read[$type] = $data;
  80411. }
  80412. if ($close) {
  80413. ftruncate($fileHandle, 0);
  80414. fclose($fileHandle);
  80415. flock($this->lockHandles[$type], \LOCK_UN);
  80416. fclose($this->lockHandles[$type]);
  80417. unset($this->fileHandles[$type], $this->lockHandles[$type]);
  80418. }
  80419. }
  80420. return $read;
  80421. }
  80422. public function haveReadSupport(): bool
  80423. {
  80424. return $this->haveReadSupport;
  80425. }
  80426. public function areOpen(): bool
  80427. {
  80428. return $this->pipes && $this->fileHandles;
  80429. }
  80430. public function close()
  80431. {
  80432. parent::close();
  80433. foreach ($this->fileHandles as $type => $handle) {
  80434. ftruncate($handle, 0);
  80435. fclose($handle);
  80436. flock($this->lockHandles[$type], \LOCK_UN);
  80437. fclose($this->lockHandles[$type]);
  80438. }
  80439. $this->fileHandles = $this->lockHandles = [];
  80440. }
  80441. }
  80442. <?php
  80443. namespace Symfony\Component\Process;
  80444. use Symfony\Component\Process\Exception\InvalidArgumentException;
  80445. use Symfony\Component\Process\Exception\LogicException;
  80446. use Symfony\Component\Process\Exception\ProcessFailedException;
  80447. use Symfony\Component\Process\Exception\ProcessSignaledException;
  80448. use Symfony\Component\Process\Exception\ProcessTimedOutException;
  80449. use Symfony\Component\Process\Exception\RuntimeException;
  80450. use Symfony\Component\Process\Pipes\PipesInterface;
  80451. use Symfony\Component\Process\Pipes\UnixPipes;
  80452. use Symfony\Component\Process\Pipes\WindowsPipes;
  80453. class Process implements \IteratorAggregate
  80454. {
  80455. public const ERR = 'err';
  80456. public const OUT = 'out';
  80457. public const STATUS_READY = 'ready';
  80458. public const STATUS_STARTED = 'started';
  80459. public const STATUS_TERMINATED = 'terminated';
  80460. public const STDIN = 0;
  80461. public const STDOUT = 1;
  80462. public const STDERR = 2;
  80463. public const TIMEOUT_PRECISION = 0.2;
  80464. public const ITER_NON_BLOCKING = 1;
  80465. public const ITER_KEEP_OUTPUT = 2;
  80466. public const ITER_SKIP_OUT = 4;
  80467. public const ITER_SKIP_ERR = 8;
  80468. private $callback;
  80469. private $hasCallback = false;
  80470. private $commandline;
  80471. private $cwd;
  80472. private $env = [];
  80473. private $input;
  80474. private $starttime;
  80475. private $lastOutputTime;
  80476. private $timeout;
  80477. private $idleTimeout;
  80478. private $exitcode;
  80479. private $fallbackStatus = [];
  80480. private $processInformation;
  80481. private $outputDisabled = false;
  80482. private $stdout;
  80483. private $stderr;
  80484. private $process;
  80485. private $status = self::STATUS_READY;
  80486. private $incrementalOutputOffset = 0;
  80487. private $incrementalErrorOutputOffset = 0;
  80488. private $tty = false;
  80489. private $pty;
  80490. private $options = ['suppress_errors' => true, 'bypass_shell' => true];
  80491. private $useFileHandles = false;
  80492. private $processPipes;
  80493. private $latestSignal;
  80494. private static $sigchild;
  80495. public static $exitCodes = [
  80496. 0 => 'OK',
  80497. 1 => 'General error',
  80498. 2 => 'Misuse of shell builtins',
  80499. 126 => 'Invoked command cannot execute',
  80500. 127 => 'Command not found',
  80501. 128 => 'Invalid exit argument',
  80502. 129 => 'Hangup',
  80503. 130 => 'Interrupt',
  80504. 131 => 'Quit and dump core',
  80505. 132 => 'Illegal instruction',
  80506. 133 => 'Trace/breakpoint trap',
  80507. 134 => 'Process aborted',
  80508. 135 => 'Bus error: "access to undefined portion of memory object"',
  80509. 136 => 'Floating point exception: "erroneous arithmetic operation"',
  80510. 137 => 'Kill (terminate immediately)',
  80511. 138 => 'User-defined 1',
  80512. 139 => 'Segmentation violation',
  80513. 140 => 'User-defined 2',
  80514. 141 => 'Write to pipe with no one reading',
  80515. 142 => 'Signal raised by alarm',
  80516. 143 => 'Termination (request to terminate)',
  80517. 145 => 'Child process terminated, stopped (or continued*)',
  80518. 146 => 'Continue if stopped',
  80519. 147 => 'Stop executing temporarily',
  80520. 148 => 'Terminal stop signal',
  80521. 149 => 'Background process attempting to read from tty ("in")',
  80522. 150 => 'Background process attempting to write to tty ("out")',
  80523. 151 => 'Urgent data available on socket',
  80524. 152 => 'CPU time limit exceeded',
  80525. 153 => 'File size limit exceeded',
  80526. 154 => 'Signal raised by timer counting virtual time: "virtual timer expired"',
  80527. 155 => 'Profiling timer expired',
  80528. 157 => 'Pollable event',
  80529. 159 => 'Bad syscall',
  80530. ];
  80531. public function __construct(array $command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60)
  80532. {
  80533. if (!\function_exists('proc_open')) {
  80534. throw new LogicException('The Process class relies on proc_open, which is not available on your PHP installation.');
  80535. }
  80536. $this->commandline = $command;
  80537. $this->cwd = $cwd;
  80538. if (null === $this->cwd && (\defined('ZEND_THREAD_SAFE') || '\\' === \DIRECTORY_SEPARATOR)) {
  80539. $this->cwd = getcwd();
  80540. }
  80541. if (null !== $env) {
  80542. $this->setEnv($env);
  80543. }
  80544. $this->setInput($input);
  80545. $this->setTimeout($timeout);
  80546. $this->useFileHandles = '\\' === \DIRECTORY_SEPARATOR;
  80547. $this->pty = false;
  80548. }
  80549. public static function fromShellCommandline(string $command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60)
  80550. {
  80551. $process = new static([], $cwd, $env, $input, $timeout);
  80552. $process->commandline = $command;
  80553. return $process;
  80554. }
  80555. public function __sleep()
  80556. {
  80557. throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
  80558. }
  80559. public function __wakeup()
  80560. {
  80561. throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
  80562. }
  80563. public function __destruct()
  80564. {
  80565. if ($this->options['create_new_console'] ?? false) {
  80566. $this->processPipes->close();
  80567. } else {
  80568. $this->stop(0);
  80569. }
  80570. }
  80571. public function __clone()
  80572. {
  80573. $this->resetProcessData();
  80574. }
  80575. public function run(callable $callback = null, array $env = []): int
  80576. {
  80577. $this->start($callback, $env);
  80578. return $this->wait();
  80579. }
  80580. public function mustRun(callable $callback = null, array $env = []): self
  80581. {
  80582. if (0 !== $this->run($callback, $env)) {
  80583. throw new ProcessFailedException($this);
  80584. }
  80585. return $this;
  80586. }
  80587. public function start(callable $callback = null, array $env = [])
  80588. {
  80589. if ($this->isRunning()) {
  80590. throw new RuntimeException('Process is already running.');
  80591. }
  80592. $this->resetProcessData();
  80593. $this->starttime = $this->lastOutputTime = microtime(true);
  80594. $this->callback = $this->buildCallback($callback);
  80595. $this->hasCallback = null !== $callback;
  80596. $descriptors = $this->getDescriptors();
  80597. if ($this->env) {
  80598. $env += '\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($this->env, $env, 'strcasecmp') : $this->env;
  80599. }
  80600. $env += '\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($this->getDefaultEnv(), $env, 'strcasecmp') : $this->getDefaultEnv();
  80601. if (\is_array($commandline = $this->commandline)) {
  80602. $commandline = implode(' ', array_map([$this, 'escapeArgument'], $commandline));
  80603. if ('\\' !== \DIRECTORY_SEPARATOR) {
  80604. $commandline = 'exec '.$commandline;
  80605. }
  80606. } else {
  80607. $commandline = $this->replacePlaceholders($commandline, $env);
  80608. }
  80609. if ('\\' === \DIRECTORY_SEPARATOR) {
  80610. $commandline = $this->prepareWindowsCommandLine($commandline, $env);
  80611. } elseif (!$this->useFileHandles && $this->isSigchildEnabled()) {
  80612. $descriptors[3] = ['pipe', 'w'];
  80613. $commandline = '{ ('.$commandline.') <&3 3<&- 3>/dev/null & } 3<&0;';
  80614. $commandline .= 'pid=$!; echo $pid >&3; wait $pid 2>/dev/null; code=$?; echo $code >&3; exit $code';
  80615. $ptsWorkaround = fopen(__FILE__, 'r');
  80616. }
  80617. $envPairs = [];
  80618. foreach ($env as $k => $v) {
  80619. if (false !== $v && false === \in_array($k, ['argc', 'argv', 'ARGC', 'ARGV'], true)) {
  80620. $envPairs[] = $k.'='.$v;
  80621. }
  80622. }
  80623. if (!is_dir($this->cwd)) {
  80624. throw new RuntimeException(sprintf('The provided cwd "%s" does not exist.', $this->cwd));
  80625. }
  80626. $this->process = @proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options);
  80627. if (!\is_resource($this->process)) {
  80628. throw new RuntimeException('Unable to launch a new process.');
  80629. }
  80630. $this->status = self::STATUS_STARTED;
  80631. if (isset($descriptors[3])) {
  80632. $this->fallbackStatus['pid'] = (int) fgets($this->processPipes->pipes[3]);
  80633. }
  80634. if ($this->tty) {
  80635. return;
  80636. }
  80637. $this->updateStatus(false);
  80638. $this->checkTimeout();
  80639. }
  80640. public function restart(callable $callback = null, array $env = []): self
  80641. {
  80642. if ($this->isRunning()) {
  80643. throw new RuntimeException('Process is already running.');
  80644. }
  80645. $process = clone $this;
  80646. $process->start($callback, $env);
  80647. return $process;
  80648. }
  80649. public function wait(callable $callback = null)
  80650. {
  80651. $this->requireProcessIsStarted(__FUNCTION__);
  80652. $this->updateStatus(false);
  80653. if (null !== $callback) {
  80654. if (!$this->processPipes->haveReadSupport()) {
  80655. $this->stop(0);
  80656. throw new LogicException('Pass the callback to the "Process::start" method or call enableOutput to use a callback with "Process::wait".');
  80657. }
  80658. $this->callback = $this->buildCallback($callback);
  80659. }
  80660. do {
  80661. $this->checkTimeout();
  80662. $running = $this->isRunning() && ('\\' === \DIRECTORY_SEPARATOR || $this->processPipes->areOpen());
  80663. $this->readPipes($running, '\\' !== \DIRECTORY_SEPARATOR || !$running);
  80664. } while ($running);
  80665. while ($this->isRunning()) {
  80666. $this->checkTimeout();
  80667. usleep(1000);
  80668. }
  80669. if ($this->processInformation['signaled'] && $this->processInformation['termsig'] !== $this->latestSignal) {
  80670. throw new ProcessSignaledException($this);
  80671. }
  80672. return $this->exitcode;
  80673. }
  80674. public function waitUntil(callable $callback): bool
  80675. {
  80676. $this->requireProcessIsStarted(__FUNCTION__);
  80677. $this->updateStatus(false);
  80678. if (!$this->processPipes->haveReadSupport()) {
  80679. $this->stop(0);
  80680. throw new LogicException('Pass the callback to the "Process::start" method or call enableOutput to use a callback with "Process::waitUntil".');
  80681. }
  80682. $callback = $this->buildCallback($callback);
  80683. $ready = false;
  80684. while (true) {
  80685. $this->checkTimeout();
  80686. $running = '\\' === \DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen();
  80687. $output = $this->processPipes->readAndWrite($running, '\\' !== \DIRECTORY_SEPARATOR || !$running);
  80688. foreach ($output as $type => $data) {
  80689. if (3 !== $type) {
  80690. $ready = $callback(self::STDOUT === $type ? self::OUT : self::ERR, $data) || $ready;
  80691. } elseif (!isset($this->fallbackStatus['signaled'])) {
  80692. $this->fallbackStatus['exitcode'] = (int) $data;
  80693. }
  80694. }
  80695. if ($ready) {
  80696. return true;
  80697. }
  80698. if (!$running) {
  80699. return false;
  80700. }
  80701. usleep(1000);
  80702. }
  80703. }
  80704. public function getPid()
  80705. {
  80706. return $this->isRunning() ? $this->processInformation['pid'] : null;
  80707. }
  80708. public function signal(int $signal)
  80709. {
  80710. $this->doSignal($signal, true);
  80711. return $this;
  80712. }
  80713. public function disableOutput()
  80714. {
  80715. if ($this->isRunning()) {
  80716. throw new RuntimeException('Disabling output while the process is running is not possible.');
  80717. }
  80718. if (null !== $this->idleTimeout) {
  80719. throw new LogicException('Output cannot be disabled while an idle timeout is set.');
  80720. }
  80721. $this->outputDisabled = true;
  80722. return $this;
  80723. }
  80724. public function enableOutput()
  80725. {
  80726. if ($this->isRunning()) {
  80727. throw new RuntimeException('Enabling output while the process is running is not possible.');
  80728. }
  80729. $this->outputDisabled = false;
  80730. return $this;
  80731. }
  80732. public function isOutputDisabled()
  80733. {
  80734. return $this->outputDisabled;
  80735. }
  80736. public function getOutput()
  80737. {
  80738. $this->readPipesForOutput(__FUNCTION__);
  80739. if (false === $ret = stream_get_contents($this->stdout, -1, 0)) {
  80740. return '';
  80741. }
  80742. return $ret;
  80743. }
  80744. public function getIncrementalOutput()
  80745. {
  80746. $this->readPipesForOutput(__FUNCTION__);
  80747. $latest = stream_get_contents($this->stdout, -1, $this->incrementalOutputOffset);
  80748. $this->incrementalOutputOffset = ftell($this->stdout);
  80749. if (false === $latest) {
  80750. return '';
  80751. }
  80752. return $latest;
  80753. }
  80754. #[\ReturnTypeWillChange]
  80755. public function getIterator(int $flags = 0)
  80756. {
  80757. $this->readPipesForOutput(__FUNCTION__, false);
  80758. $clearOutput = !(self::ITER_KEEP_OUTPUT & $flags);
  80759. $blocking = !(self::ITER_NON_BLOCKING & $flags);
  80760. $yieldOut = !(self::ITER_SKIP_OUT & $flags);
  80761. $yieldErr = !(self::ITER_SKIP_ERR & $flags);
  80762. while (null !== $this->callback || ($yieldOut && !feof($this->stdout)) || ($yieldErr && !feof($this->stderr))) {
  80763. if ($yieldOut) {
  80764. $out = stream_get_contents($this->stdout, -1, $this->incrementalOutputOffset);
  80765. if (isset($out[0])) {
  80766. if ($clearOutput) {
  80767. $this->clearOutput();
  80768. } else {
  80769. $this->incrementalOutputOffset = ftell($this->stdout);
  80770. }
  80771. yield self::OUT => $out;
  80772. }
  80773. }
  80774. if ($yieldErr) {
  80775. $err = stream_get_contents($this->stderr, -1, $this->incrementalErrorOutputOffset);
  80776. if (isset($err[0])) {
  80777. if ($clearOutput) {
  80778. $this->clearErrorOutput();
  80779. } else {
  80780. $this->incrementalErrorOutputOffset = ftell($this->stderr);
  80781. }
  80782. yield self::ERR => $err;
  80783. }
  80784. }
  80785. if (!$blocking && !isset($out[0]) && !isset($err[0])) {
  80786. yield self::OUT => '';
  80787. }
  80788. $this->checkTimeout();
  80789. $this->readPipesForOutput(__FUNCTION__, $blocking);
  80790. }
  80791. }
  80792. public function clearOutput()
  80793. {
  80794. ftruncate($this->stdout, 0);
  80795. fseek($this->stdout, 0);
  80796. $this->incrementalOutputOffset = 0;
  80797. return $this;
  80798. }
  80799. public function getErrorOutput()
  80800. {
  80801. $this->readPipesForOutput(__FUNCTION__);
  80802. if (false === $ret = stream_get_contents($this->stderr, -1, 0)) {
  80803. return '';
  80804. }
  80805. return $ret;
  80806. }
  80807. public function getIncrementalErrorOutput()
  80808. {
  80809. $this->readPipesForOutput(__FUNCTION__);
  80810. $latest = stream_get_contents($this->stderr, -1, $this->incrementalErrorOutputOffset);
  80811. $this->incrementalErrorOutputOffset = ftell($this->stderr);
  80812. if (false === $latest) {
  80813. return '';
  80814. }
  80815. return $latest;
  80816. }
  80817. public function clearErrorOutput()
  80818. {
  80819. ftruncate($this->stderr, 0);
  80820. fseek($this->stderr, 0);
  80821. $this->incrementalErrorOutputOffset = 0;
  80822. return $this;
  80823. }
  80824. public function getExitCode()
  80825. {
  80826. $this->updateStatus(false);
  80827. return $this->exitcode;
  80828. }
  80829. public function getExitCodeText()
  80830. {
  80831. if (null === $exitcode = $this->getExitCode()) {
  80832. return null;
  80833. }
  80834. return self::$exitCodes[$exitcode] ?? 'Unknown error';
  80835. }
  80836. public function isSuccessful()
  80837. {
  80838. return 0 === $this->getExitCode();
  80839. }
  80840. public function hasBeenSignaled()
  80841. {
  80842. $this->requireProcessIsTerminated(__FUNCTION__);
  80843. return $this->processInformation['signaled'];
  80844. }
  80845. public function getTermSignal()
  80846. {
  80847. $this->requireProcessIsTerminated(__FUNCTION__);
  80848. if ($this->isSigchildEnabled() && -1 === $this->processInformation['termsig']) {
  80849. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal cannot be retrieved.');
  80850. }
  80851. return $this->processInformation['termsig'];
  80852. }
  80853. public function hasBeenStopped()
  80854. {
  80855. $this->requireProcessIsTerminated(__FUNCTION__);
  80856. return $this->processInformation['stopped'];
  80857. }
  80858. public function getStopSignal()
  80859. {
  80860. $this->requireProcessIsTerminated(__FUNCTION__);
  80861. return $this->processInformation['stopsig'];
  80862. }
  80863. public function isRunning()
  80864. {
  80865. if (self::STATUS_STARTED !== $this->status) {
  80866. return false;
  80867. }
  80868. $this->updateStatus(false);
  80869. return $this->processInformation['running'];
  80870. }
  80871. public function isStarted()
  80872. {
  80873. return self::STATUS_READY != $this->status;
  80874. }
  80875. public function isTerminated()
  80876. {
  80877. $this->updateStatus(false);
  80878. return self::STATUS_TERMINATED == $this->status;
  80879. }
  80880. public function getStatus()
  80881. {
  80882. $this->updateStatus(false);
  80883. return $this->status;
  80884. }
  80885. public function stop(float $timeout = 10, int $signal = null)
  80886. {
  80887. $timeoutMicro = microtime(true) + $timeout;
  80888. if ($this->isRunning()) {
  80889. $this->doSignal(15, false);
  80890. do {
  80891. usleep(1000);
  80892. } while ($this->isRunning() && microtime(true) < $timeoutMicro);
  80893. if ($this->isRunning()) {
  80894. $this->doSignal($signal ?: 9, false);
  80895. }
  80896. }
  80897. if ($this->isRunning()) {
  80898. if (isset($this->fallbackStatus['pid'])) {
  80899. unset($this->fallbackStatus['pid']);
  80900. return $this->stop(0, $signal);
  80901. }
  80902. $this->close();
  80903. }
  80904. return $this->exitcode;
  80905. }
  80906. public function addOutput(string $line)
  80907. {
  80908. $this->lastOutputTime = microtime(true);
  80909. fseek($this->stdout, 0, \SEEK_END);
  80910. fwrite($this->stdout, $line);
  80911. fseek($this->stdout, $this->incrementalOutputOffset);
  80912. }
  80913. public function addErrorOutput(string $line)
  80914. {
  80915. $this->lastOutputTime = microtime(true);
  80916. fseek($this->stderr, 0, \SEEK_END);
  80917. fwrite($this->stderr, $line);
  80918. fseek($this->stderr, $this->incrementalErrorOutputOffset);
  80919. }
  80920. public function getLastOutputTime(): ?float
  80921. {
  80922. return $this->lastOutputTime;
  80923. }
  80924. public function getCommandLine()
  80925. {
  80926. return \is_array($this->commandline) ? implode(' ', array_map([$this, 'escapeArgument'], $this->commandline)) : $this->commandline;
  80927. }
  80928. public function getTimeout()
  80929. {
  80930. return $this->timeout;
  80931. }
  80932. public function getIdleTimeout()
  80933. {
  80934. return $this->idleTimeout;
  80935. }
  80936. public function setTimeout(?float $timeout)
  80937. {
  80938. $this->timeout = $this->validateTimeout($timeout);
  80939. return $this;
  80940. }
  80941. public function setIdleTimeout(?float $timeout)
  80942. {
  80943. if (null !== $timeout && $this->outputDisabled) {
  80944. throw new LogicException('Idle timeout cannot be set while the output is disabled.');
  80945. }
  80946. $this->idleTimeout = $this->validateTimeout($timeout);
  80947. return $this;
  80948. }
  80949. public function setTty(bool $tty)
  80950. {
  80951. if ('\\' === \DIRECTORY_SEPARATOR && $tty) {
  80952. throw new RuntimeException('TTY mode is not supported on Windows platform.');
  80953. }
  80954. if ($tty && !self::isTtySupported()) {
  80955. throw new RuntimeException('TTY mode requires /dev/tty to be read/writable.');
  80956. }
  80957. $this->tty = $tty;
  80958. return $this;
  80959. }
  80960. public function isTty()
  80961. {
  80962. return $this->tty;
  80963. }
  80964. public function setPty(bool $bool)
  80965. {
  80966. $this->pty = $bool;
  80967. return $this;
  80968. }
  80969. public function isPty()
  80970. {
  80971. return $this->pty;
  80972. }
  80973. public function getWorkingDirectory()
  80974. {
  80975. if (null === $this->cwd) {
  80976. return getcwd() ?: null;
  80977. }
  80978. return $this->cwd;
  80979. }
  80980. public function setWorkingDirectory(string $cwd)
  80981. {
  80982. $this->cwd = $cwd;
  80983. return $this;
  80984. }
  80985. public function getEnv()
  80986. {
  80987. return $this->env;
  80988. }
  80989. public function setEnv(array $env)
  80990. {
  80991. $this->env = $env;
  80992. return $this;
  80993. }
  80994. public function getInput()
  80995. {
  80996. return $this->input;
  80997. }
  80998. public function setInput($input)
  80999. {
  81000. if ($this->isRunning()) {
  81001. throw new LogicException('Input cannot be set while the process is running.');
  81002. }
  81003. $this->input = ProcessUtils::validateInput(__METHOD__, $input);
  81004. return $this;
  81005. }
  81006. public function checkTimeout()
  81007. {
  81008. if (self::STATUS_STARTED !== $this->status) {
  81009. return;
  81010. }
  81011. if (null !== $this->timeout && $this->timeout < microtime(true) - $this->starttime) {
  81012. $this->stop(0);
  81013. throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_GENERAL);
  81014. }
  81015. if (null !== $this->idleTimeout && $this->idleTimeout < microtime(true) - $this->lastOutputTime) {
  81016. $this->stop(0);
  81017. throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_IDLE);
  81018. }
  81019. }
  81020. public function getStartTime(): float
  81021. {
  81022. if (!$this->isStarted()) {
  81023. throw new LogicException('Start time is only available after process start.');
  81024. }
  81025. return $this->starttime;
  81026. }
  81027. public function setOptions(array $options)
  81028. {
  81029. if ($this->isRunning()) {
  81030. throw new RuntimeException('Setting options while the process is running is not possible.');
  81031. }
  81032. $defaultOptions = $this->options;
  81033. $existingOptions = ['blocking_pipes', 'create_process_group', 'create_new_console'];
  81034. foreach ($options as $key => $value) {
  81035. if (!\in_array($key, $existingOptions)) {
  81036. $this->options = $defaultOptions;
  81037. throw new LogicException(sprintf('Invalid option "%s" passed to "%s()". Supported options are "%s".', $key, __METHOD__, implode('", "', $existingOptions)));
  81038. }
  81039. $this->options[$key] = $value;
  81040. }
  81041. }
  81042. public static function isTtySupported(): bool
  81043. {
  81044. static $isTtySupported;
  81045. if (null === $isTtySupported) {
  81046. $isTtySupported = (bool) @proc_open('echo 1 >/dev/null', [['file', '/dev/tty', 'r'], ['file', '/dev/tty', 'w'], ['file', '/dev/tty', 'w']], $pipes);
  81047. }
  81048. return $isTtySupported;
  81049. }
  81050. public static function isPtySupported()
  81051. {
  81052. static $result;
  81053. if (null !== $result) {
  81054. return $result;
  81055. }
  81056. if ('\\' === \DIRECTORY_SEPARATOR) {
  81057. return $result = false;
  81058. }
  81059. return $result = (bool) @proc_open('echo 1 >/dev/null', [['pty'], ['pty'], ['pty']], $pipes);
  81060. }
  81061. private function getDescriptors(): array
  81062. {
  81063. if ($this->input instanceof \Iterator) {
  81064. $this->input->rewind();
  81065. }
  81066. if ('\\' === \DIRECTORY_SEPARATOR) {
  81067. $this->processPipes = new WindowsPipes($this->input, !$this->outputDisabled || $this->hasCallback);
  81068. } else {
  81069. $this->processPipes = new UnixPipes($this->isTty(), $this->isPty(), $this->input, !$this->outputDisabled || $this->hasCallback);
  81070. }
  81071. return $this->processPipes->getDescriptors();
  81072. }
  81073. protected function buildCallback(callable $callback = null)
  81074. {
  81075. if ($this->outputDisabled) {
  81076. return function ($type, $data) use ($callback): bool {
  81077. return null !== $callback && $callback($type, $data);
  81078. };
  81079. }
  81080. $out = self::OUT;
  81081. return function ($type, $data) use ($callback, $out): bool {
  81082. if ($out == $type) {
  81083. $this->addOutput($data);
  81084. } else {
  81085. $this->addErrorOutput($data);
  81086. }
  81087. return null !== $callback && $callback($type, $data);
  81088. };
  81089. }
  81090. protected function updateStatus(bool $blocking)
  81091. {
  81092. if (self::STATUS_STARTED !== $this->status) {
  81093. return;
  81094. }
  81095. $this->processInformation = proc_get_status($this->process);
  81096. $running = $this->processInformation['running'];
  81097. $this->readPipes($running && $blocking, '\\' !== \DIRECTORY_SEPARATOR || !$running);
  81098. if ($this->fallbackStatus && $this->isSigchildEnabled()) {
  81099. $this->processInformation = $this->fallbackStatus + $this->processInformation;
  81100. }
  81101. if (!$running) {
  81102. $this->close();
  81103. }
  81104. }
  81105. protected function isSigchildEnabled()
  81106. {
  81107. if (null !== self::$sigchild) {
  81108. return self::$sigchild;
  81109. }
  81110. if (!\function_exists('phpinfo')) {
  81111. return self::$sigchild = false;
  81112. }
  81113. ob_start();
  81114. phpinfo(\INFO_GENERAL);
  81115. return self::$sigchild = str_contains(ob_get_clean(), '--enable-sigchild');
  81116. }
  81117. private function readPipesForOutput(string $caller, bool $blocking = false)
  81118. {
  81119. if ($this->outputDisabled) {
  81120. throw new LogicException('Output has been disabled.');
  81121. }
  81122. $this->requireProcessIsStarted($caller);
  81123. $this->updateStatus($blocking);
  81124. }
  81125. private function validateTimeout(?float $timeout): ?float
  81126. {
  81127. $timeout = (float) $timeout;
  81128. if (0.0 === $timeout) {
  81129. $timeout = null;
  81130. } elseif ($timeout < 0) {
  81131. throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
  81132. }
  81133. return $timeout;
  81134. }
  81135. private function readPipes(bool $blocking, bool $close)
  81136. {
  81137. $result = $this->processPipes->readAndWrite($blocking, $close);
  81138. $callback = $this->callback;
  81139. foreach ($result as $type => $data) {
  81140. if (3 !== $type) {
  81141. $callback(self::STDOUT === $type ? self::OUT : self::ERR, $data);
  81142. } elseif (!isset($this->fallbackStatus['signaled'])) {
  81143. $this->fallbackStatus['exitcode'] = (int) $data;
  81144. }
  81145. }
  81146. }
  81147. private function close(): int
  81148. {
  81149. $this->processPipes->close();
  81150. if (\is_resource($this->process)) {
  81151. proc_close($this->process);
  81152. }
  81153. $this->exitcode = $this->processInformation['exitcode'];
  81154. $this->status = self::STATUS_TERMINATED;
  81155. if (-1 === $this->exitcode) {
  81156. if ($this->processInformation['signaled'] && 0 < $this->processInformation['termsig']) {
  81157. $this->exitcode = 128 + $this->processInformation['termsig'];
  81158. } elseif ($this->isSigchildEnabled()) {
  81159. $this->processInformation['signaled'] = true;
  81160. $this->processInformation['termsig'] = -1;
  81161. }
  81162. }
  81163. $this->callback = null;
  81164. return $this->exitcode;
  81165. }
  81166. private function resetProcessData()
  81167. {
  81168. $this->starttime = null;
  81169. $this->callback = null;
  81170. $this->exitcode = null;
  81171. $this->fallbackStatus = [];
  81172. $this->processInformation = null;
  81173. $this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+');
  81174. $this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+');
  81175. $this->process = null;
  81176. $this->latestSignal = null;
  81177. $this->status = self::STATUS_READY;
  81178. $this->incrementalOutputOffset = 0;
  81179. $this->incrementalErrorOutputOffset = 0;
  81180. }
  81181. private function doSignal(int $signal, bool $throwException): bool
  81182. {
  81183. if (null === $pid = $this->getPid()) {
  81184. if ($throwException) {
  81185. throw new LogicException('Cannot send signal on a non running process.');
  81186. }
  81187. return false;
  81188. }
  81189. if ('\\' === \DIRECTORY_SEPARATOR) {
  81190. exec(sprintf('taskkill /F /T /PID %d 2>&1', $pid), $output, $exitCode);
  81191. if ($exitCode && $this->isRunning()) {
  81192. if ($throwException) {
  81193. throw new RuntimeException(sprintf('Unable to kill the process (%s).', implode(' ', $output)));
  81194. }
  81195. return false;
  81196. }
  81197. } else {
  81198. if (!$this->isSigchildEnabled()) {
  81199. $ok = @proc_terminate($this->process, $signal);
  81200. } elseif (\function_exists('posix_kill')) {
  81201. $ok = @posix_kill($pid, $signal);
  81202. } elseif ($ok = proc_open(sprintf('kill -%d %d', $signal, $pid), [2 => ['pipe', 'w']], $pipes)) {
  81203. $ok = false === fgets($pipes[2]);
  81204. }
  81205. if (!$ok) {
  81206. if ($throwException) {
  81207. throw new RuntimeException(sprintf('Error while sending signal "%s".', $signal));
  81208. }
  81209. return false;
  81210. }
  81211. }
  81212. $this->latestSignal = $signal;
  81213. $this->fallbackStatus['signaled'] = true;
  81214. $this->fallbackStatus['exitcode'] = -1;
  81215. $this->fallbackStatus['termsig'] = $this->latestSignal;
  81216. return true;
  81217. }
  81218. private function prepareWindowsCommandLine(string $cmd, array &$env): string
  81219. {
  81220. $uid = uniqid('', true);
  81221. $varCount = 0;
  81222. $varCache = [];
  81223. $cmd = preg_replace_callback(
  81224. '/"(?:(
  81225. [^"%!^]*+
  81226. (?:
  81227. (?: !LF! | "(?:\^[%!^])?+" )
  81228. [^"%!^]*+
  81229. )++
  81230. ) | [^"]*+ )"/x',
  81231. function ($m) use (&$env, &$varCache, &$varCount, $uid) {
  81232. if (!isset($m[1])) {
  81233. return $m[0];
  81234. }
  81235. if (isset($varCache[$m[0]])) {
  81236. return $varCache[$m[0]];
  81237. }
  81238. if (str_contains($value = $m[1], "\0")) {
  81239. $value = str_replace("\0", '?', $value);
  81240. }
  81241. if (false === strpbrk($value, "\"%!\n")) {
  81242. return '"'.$value.'"';
  81243. }
  81244. $value = str_replace(['!LF!', '"^!"', '"^%"', '"^^"', '""'], ["\n", '!', '%', '^', '"'], $value);
  81245. $value = '"'.preg_replace('/(\\\\*)"/', '$1$1\\"', $value).'"';
  81246. $var = $uid.++$varCount;
  81247. $env[$var] = $value;
  81248. return $varCache[$m[0]] = '!'.$var.'!';
  81249. },
  81250. $cmd
  81251. );
  81252. $cmd = 'cmd /V:ON /E:ON /D /C ('.str_replace("\n", ' ', $cmd).')';
  81253. foreach ($this->processPipes->getFiles() as $offset => $filename) {
  81254. $cmd .= ' '.$offset.'>"'.$filename.'"';
  81255. }
  81256. return $cmd;
  81257. }
  81258. private function requireProcessIsStarted(string $functionName)
  81259. {
  81260. if (!$this->isStarted()) {
  81261. throw new LogicException(sprintf('Process must be started before calling "%s()".', $functionName));
  81262. }
  81263. }
  81264. private function requireProcessIsTerminated(string $functionName)
  81265. {
  81266. if (!$this->isTerminated()) {
  81267. throw new LogicException(sprintf('Process must be terminated before calling "%s()".', $functionName));
  81268. }
  81269. }
  81270. private function escapeArgument(?string $argument): string
  81271. {
  81272. if ('' === $argument || null === $argument) {
  81273. return '""';
  81274. }
  81275. if ('\\' !== \DIRECTORY_SEPARATOR) {
  81276. return "'".str_replace("'", "'\\''", $argument)."'";
  81277. }
  81278. if (str_contains($argument, "\0")) {
  81279. $argument = str_replace("\0", '?', $argument);
  81280. }
  81281. if (!preg_match('/[\/()%!^"<>&|\s]/', $argument)) {
  81282. return $argument;
  81283. }
  81284. $argument = preg_replace('/(\\\\+)$/', '$1$1', $argument);
  81285. return '"'.str_replace(['"', '^', '%', '!', "\n"], ['""', '"^^"', '"^%"', '"^!"', '!LF!'], $argument).'"';
  81286. }
  81287. private function replacePlaceholders(string $commandline, array $env)
  81288. {
  81289. return preg_replace_callback('/"\$\{:([_a-zA-Z]++[_a-zA-Z0-9]*+)\}"/', function ($matches) use ($commandline, $env) {
  81290. if (!isset($env[$matches[1]]) || false === $env[$matches[1]]) {
  81291. throw new InvalidArgumentException(sprintf('Command line is missing a value for parameter "%s": ', $matches[1]).$commandline);
  81292. }
  81293. return $this->escapeArgument($env[$matches[1]]);
  81294. }, $commandline);
  81295. }
  81296. private function getDefaultEnv(): array
  81297. {
  81298. $env = getenv();
  81299. $env = ('\\' === \DIRECTORY_SEPARATOR ? array_intersect_ukey($env, $_SERVER, 'strcasecmp') : array_intersect_key($env, $_SERVER)) ?: $env;
  81300. return $_ENV + ('\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($env, $_ENV, 'strcasecmp') : $env);
  81301. }
  81302. }
  81303. <?php
  81304. namespace Symfony\Component\Process;
  81305. use Symfony\Component\Process\Exception\InvalidArgumentException;
  81306. class ProcessUtils
  81307. {
  81308. private function __construct()
  81309. {
  81310. }
  81311. public static function validateInput(string $caller, $input)
  81312. {
  81313. if (null !== $input) {
  81314. if (\is_resource($input)) {
  81315. return $input;
  81316. }
  81317. if (\is_string($input)) {
  81318. return $input;
  81319. }
  81320. if (\is_scalar($input)) {
  81321. return (string) $input;
  81322. }
  81323. if ($input instanceof Process) {
  81324. return $input->getIterator($input::ITER_SKIP_ERR);
  81325. }
  81326. if ($input instanceof \Iterator) {
  81327. return $input;
  81328. }
  81329. if ($input instanceof \Traversable) {
  81330. return new \IteratorIterator($input);
  81331. }
  81332. throw new InvalidArgumentException(sprintf('"%s" only accepts strings, Traversable objects or stream resources.', $caller));
  81333. }
  81334. return $input;
  81335. }
  81336. }
  81337. <?php
  81338. namespace Symfony\Contracts\Service\Attribute;
  81339. #[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
  81340. final class Required
  81341. {
  81342. }
  81343. <?php
  81344. namespace Symfony\Contracts\Service\Attribute;
  81345. use Symfony\Contracts\Service\ServiceSubscriberTrait;
  81346. #[\Attribute(\Attribute::TARGET_METHOD)]
  81347. final class SubscribedService
  81348. {
  81349. public function __construct(
  81350. public ?string $key = null
  81351. ) {
  81352. }
  81353. }
  81354. Copyright (c) 2018-2022 Fabien Potencier
  81355. Permission is hereby granted, free of charge, to any person obtaining a copy
  81356. of this software and associated documentation files (the "Software"), to deal
  81357. in the Software without restriction, including without limitation the rights
  81358. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  81359. copies of the Software, and to permit persons to whom the Software is furnished
  81360. to do so, subject to the following conditions:
  81361. The above copyright notice and this permission notice shall be included in all
  81362. copies or substantial portions of the Software.
  81363. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  81364. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  81365. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  81366. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  81367. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  81368. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  81369. THE SOFTWARE.
  81370. <?php
  81371. namespace Symfony\Contracts\Service;
  81372. interface ResetInterface
  81373. {
  81374. public function reset();
  81375. }
  81376. <?php
  81377. namespace Symfony\Contracts\Service;
  81378. use Psr\Container\ContainerExceptionInterface;
  81379. use Psr\Container\NotFoundExceptionInterface;
  81380. class_exists(ContainerExceptionInterface::class);
  81381. class_exists(NotFoundExceptionInterface::class);
  81382. trait ServiceLocatorTrait
  81383. {
  81384. private $factories;
  81385. private $loading = [];
  81386. private $providedTypes;
  81387. public function __construct(array $factories)
  81388. {
  81389. $this->factories = $factories;
  81390. }
  81391. public function has(string $id)
  81392. {
  81393. return isset($this->factories[$id]);
  81394. }
  81395. public function get(string $id)
  81396. {
  81397. if (!isset($this->factories[$id])) {
  81398. throw $this->createNotFoundException($id);
  81399. }
  81400. if (isset($this->loading[$id])) {
  81401. $ids = array_values($this->loading);
  81402. $ids = \array_slice($this->loading, array_search($id, $ids));
  81403. $ids[] = $id;
  81404. throw $this->createCircularReferenceException($id, $ids);
  81405. }
  81406. $this->loading[$id] = $id;
  81407. try {
  81408. return $this->factories[$id]($this);
  81409. } finally {
  81410. unset($this->loading[$id]);
  81411. }
  81412. }
  81413. public function getProvidedServices(): array
  81414. {
  81415. if (null === $this->providedTypes) {
  81416. $this->providedTypes = [];
  81417. foreach ($this->factories as $name => $factory) {
  81418. if (!\is_callable($factory)) {
  81419. $this->providedTypes[$name] = '?';
  81420. } else {
  81421. $type = (new \ReflectionFunction($factory))->getReturnType();
  81422. $this->providedTypes[$name] = $type ? ($type->allowsNull() ? '?' : '').($type instanceof \ReflectionNamedType ? $type->getName() : $type) : '?';
  81423. }
  81424. }
  81425. }
  81426. return $this->providedTypes;
  81427. }
  81428. private function createNotFoundException(string $id): NotFoundExceptionInterface
  81429. {
  81430. if (!$alternatives = array_keys($this->factories)) {
  81431. $message = 'is empty...';
  81432. } else {
  81433. $last = array_pop($alternatives);
  81434. if ($alternatives) {
  81435. $message = sprintf('only knows about the "%s" and "%s" services.', implode('", "', $alternatives), $last);
  81436. } else {
  81437. $message = sprintf('only knows about the "%s" service.', $last);
  81438. }
  81439. }
  81440. if ($this->loading) {
  81441. $message = sprintf('The service "%s" has a dependency on a non-existent service "%s". This locator %s', end($this->loading), $id, $message);
  81442. } else {
  81443. $message = sprintf('Service "%s" not found: the current service locator %s', $id, $message);
  81444. }
  81445. return new class($message) extends \InvalidArgumentException implements NotFoundExceptionInterface {
  81446. };
  81447. }
  81448. private function createCircularReferenceException(string $id, array $path): ContainerExceptionInterface
  81449. {
  81450. return new class(sprintf('Circular reference detected for service "%s", path: "%s".', $id, implode(' -> ', $path))) extends \RuntimeException implements ContainerExceptionInterface {
  81451. };
  81452. }
  81453. }
  81454. <?php
  81455. namespace Symfony\Contracts\Service;
  81456. use Psr\Container\ContainerInterface;
  81457. interface ServiceProviderInterface extends ContainerInterface
  81458. {
  81459. public function getProvidedServices(): array;
  81460. }
  81461. <?php
  81462. namespace Symfony\Contracts\Service;
  81463. interface ServiceSubscriberInterface
  81464. {
  81465. public static function getSubscribedServices();
  81466. }
  81467. <?php
  81468. namespace Symfony\Contracts\Service;
  81469. use Psr\Container\ContainerInterface;
  81470. use Symfony\Contracts\Service\Attribute\SubscribedService;
  81471. trait ServiceSubscriberTrait
  81472. {
  81473. protected $container;
  81474. public static function getSubscribedServices(): array
  81475. {
  81476. $services = method_exists(get_parent_class(self::class) ?: '', __FUNCTION__) ? parent::getSubscribedServices() : [];
  81477. $attributeOptIn = false;
  81478. if (\PHP_VERSION_ID >= 80000) {
  81479. foreach ((new \ReflectionClass(self::class))->getMethods() as $method) {
  81480. if (self::class !== $method->getDeclaringClass()->name) {
  81481. continue;
  81482. }
  81483. if (!$attribute = $method->getAttributes(SubscribedService::class)[0] ?? null) {
  81484. continue;
  81485. }
  81486. if ($method->isStatic() || $method->isAbstract() || $method->isGenerator() || $method->isInternal() || $method->getNumberOfRequiredParameters()) {
  81487. 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));
  81488. }
  81489. if (!$returnType = $method->getReturnType()) {
  81490. throw new \LogicException(sprintf('Cannot use "%s" on methods without a return type in "%s::%s()".', SubscribedService::class, $method->name, self::class));
  81491. }
  81492. $serviceId = $returnType instanceof \ReflectionNamedType ? $returnType->getName() : (string) $returnType;
  81493. if ($returnType->allowsNull()) {
  81494. $serviceId = '?'.$serviceId;
  81495. }
  81496. $services[$attribute->newInstance()->key ?? self::class.'::'.$method->name] = $serviceId;
  81497. $attributeOptIn = true;
  81498. }
  81499. }
  81500. if (!$attributeOptIn) {
  81501. foreach ((new \ReflectionClass(self::class))->getMethods() as $method) {
  81502. if ($method->isStatic() || $method->isAbstract() || $method->isGenerator() || $method->isInternal() || $method->getNumberOfRequiredParameters()) {
  81503. continue;
  81504. }
  81505. if (self::class !== $method->getDeclaringClass()->name) {
  81506. continue;
  81507. }
  81508. if (!($returnType = $method->getReturnType()) instanceof \ReflectionNamedType) {
  81509. continue;
  81510. }
  81511. if ($returnType->isBuiltin()) {
  81512. continue;
  81513. }
  81514. if (\PHP_VERSION_ID >= 80000) {
  81515. 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);
  81516. }
  81517. $services[self::class.'::'.$method->name] = '?'.($returnType instanceof \ReflectionNamedType ? $returnType->getName() : $returnType);
  81518. }
  81519. }
  81520. return $services;
  81521. }
  81522. public function setContainer(ContainerInterface $container)
  81523. {
  81524. $this->container = $container;
  81525. if (method_exists(get_parent_class(self::class) ?: '', __FUNCTION__)) {
  81526. return parent::setContainer($container);
  81527. }
  81528. return null;
  81529. }
  81530. }
  81531. <?php
  81532. namespace Symfony\Contracts\Service\Test;
  81533. use PHPUnit\Framework\TestCase;
  81534. use Psr\Container\ContainerInterface;
  81535. use Symfony\Contracts\Service\ServiceLocatorTrait;
  81536. abstract class ServiceLocatorTest extends TestCase
  81537. {
  81538. protected function getServiceLocator(array $factories)
  81539. {
  81540. return new class($factories) implements ContainerInterface {
  81541. use ServiceLocatorTrait;
  81542. };
  81543. }
  81544. public function testHas()
  81545. {
  81546. $locator = $this->getServiceLocator([
  81547. 'foo' => function () { return 'bar'; },
  81548. 'bar' => function () { return 'baz'; },
  81549. function () { return 'dummy'; },
  81550. ]);
  81551. $this->assertTrue($locator->has('foo'));
  81552. $this->assertTrue($locator->has('bar'));
  81553. $this->assertFalse($locator->has('dummy'));
  81554. }
  81555. public function testGet()
  81556. {
  81557. $locator = $this->getServiceLocator([
  81558. 'foo' => function () { return 'bar'; },
  81559. 'bar' => function () { return 'baz'; },
  81560. ]);
  81561. $this->assertSame('bar', $locator->get('foo'));
  81562. $this->assertSame('baz', $locator->get('bar'));
  81563. }
  81564. public function testGetDoesNotMemoize()
  81565. {
  81566. $i = 0;
  81567. $locator = $this->getServiceLocator([
  81568. 'foo' => function () use (&$i) {
  81569. ++$i;
  81570. return 'bar';
  81571. },
  81572. ]);
  81573. $this->assertSame('bar', $locator->get('foo'));
  81574. $this->assertSame('bar', $locator->get('foo'));
  81575. $this->assertSame(2, $i);
  81576. }
  81577. public function testThrowsOnUndefinedInternalService()
  81578. {
  81579. if (!$this->getExpectedException()) {
  81580. $this->expectException(\Psr\Container\NotFoundExceptionInterface::class);
  81581. $this->expectExceptionMessage('The service "foo" has a dependency on a non-existent service "bar". This locator only knows about the "foo" service.');
  81582. }
  81583. $locator = $this->getServiceLocator([
  81584. 'foo' => function () use (&$locator) { return $locator->get('bar'); },
  81585. ]);
  81586. $locator->get('foo');
  81587. }
  81588. public function testThrowsOnCircularReference()
  81589. {
  81590. $this->expectException(\Psr\Container\ContainerExceptionInterface::class);
  81591. $this->expectExceptionMessage('Circular reference detected for service "bar", path: "bar -> baz -> bar".');
  81592. $locator = $this->getServiceLocator([
  81593. 'foo' => function () use (&$locator) { return $locator->get('bar'); },
  81594. 'bar' => function () use (&$locator) { return $locator->get('baz'); },
  81595. 'baz' => function () use (&$locator) { return $locator->get('bar'); },
  81596. ]);
  81597. $locator->get('foo');
  81598. }
  81599. }
  81600. <?php
  81601. namespace Symfony\Component\String;
  81602. use Symfony\Component\String\Exception\ExceptionInterface;
  81603. use Symfony\Component\String\Exception\InvalidArgumentException;
  81604. use Symfony\Component\String\Exception\RuntimeException;
  81605. abstract class AbstractString implements \Stringable, \JsonSerializable
  81606. {
  81607. public const PREG_PATTERN_ORDER = \PREG_PATTERN_ORDER;
  81608. public const PREG_SET_ORDER = \PREG_SET_ORDER;
  81609. public const PREG_OFFSET_CAPTURE = \PREG_OFFSET_CAPTURE;
  81610. public const PREG_UNMATCHED_AS_NULL = \PREG_UNMATCHED_AS_NULL;
  81611. public const PREG_SPLIT = 0;
  81612. public const PREG_SPLIT_NO_EMPTY = \PREG_SPLIT_NO_EMPTY;
  81613. public const PREG_SPLIT_DELIM_CAPTURE = \PREG_SPLIT_DELIM_CAPTURE;
  81614. public const PREG_SPLIT_OFFSET_CAPTURE = \PREG_SPLIT_OFFSET_CAPTURE;
  81615. protected $string = '';
  81616. protected $ignoreCase = false;
  81617. abstract public function __construct(string $string = '');
  81618. public static function unwrap(array $values): array
  81619. {
  81620. foreach ($values as $k => $v) {
  81621. if ($v instanceof self) {
  81622. $values[$k] = $v->__toString();
  81623. } elseif (\is_array($v) && $values[$k] !== $v = static::unwrap($v)) {
  81624. $values[$k] = $v;
  81625. }
  81626. }
  81627. return $values;
  81628. }
  81629. public static function wrap(array $values): array
  81630. {
  81631. $i = 0;
  81632. $keys = null;
  81633. foreach ($values as $k => $v) {
  81634. if (\is_string($k) && '' !== $k && $k !== $j = (string) new static($k)) {
  81635. $keys = $keys ?? array_keys($values);
  81636. $keys[$i] = $j;
  81637. }
  81638. if (\is_string($v)) {
  81639. $values[$k] = new static($v);
  81640. } elseif (\is_array($v) && $values[$k] !== $v = static::wrap($v)) {
  81641. $values[$k] = $v;
  81642. }
  81643. ++$i;
  81644. }
  81645. return null !== $keys ? array_combine($keys, $values) : $values;
  81646. }
  81647. public function after($needle, bool $includeNeedle = false, int $offset = 0): self
  81648. {
  81649. $str = clone $this;
  81650. $i = \PHP_INT_MAX;
  81651. foreach ((array) $needle as $n) {
  81652. $n = (string) $n;
  81653. $j = $this->indexOf($n, $offset);
  81654. if (null !== $j && $j < $i) {
  81655. $i = $j;
  81656. $str->string = $n;
  81657. }
  81658. }
  81659. if (\PHP_INT_MAX === $i) {
  81660. return $str;
  81661. }
  81662. if (!$includeNeedle) {
  81663. $i += $str->length();
  81664. }
  81665. return $this->slice($i);
  81666. }
  81667. public function afterLast($needle, bool $includeNeedle = false, int $offset = 0): self
  81668. {
  81669. $str = clone $this;
  81670. $i = null;
  81671. foreach ((array) $needle as $n) {
  81672. $n = (string) $n;
  81673. $j = $this->indexOfLast($n, $offset);
  81674. if (null !== $j && $j >= $i) {
  81675. $i = $offset = $j;
  81676. $str->string = $n;
  81677. }
  81678. }
  81679. if (null === $i) {
  81680. return $str;
  81681. }
  81682. if (!$includeNeedle) {
  81683. $i += $str->length();
  81684. }
  81685. return $this->slice($i);
  81686. }
  81687. abstract public function append(string ...$suffix): self;
  81688. public function before($needle, bool $includeNeedle = false, int $offset = 0): self
  81689. {
  81690. $str = clone $this;
  81691. $i = \PHP_INT_MAX;
  81692. foreach ((array) $needle as $n) {
  81693. $n = (string) $n;
  81694. $j = $this->indexOf($n, $offset);
  81695. if (null !== $j && $j < $i) {
  81696. $i = $j;
  81697. $str->string = $n;
  81698. }
  81699. }
  81700. if (\PHP_INT_MAX === $i) {
  81701. return $str;
  81702. }
  81703. if ($includeNeedle) {
  81704. $i += $str->length();
  81705. }
  81706. return $this->slice(0, $i);
  81707. }
  81708. public function beforeLast($needle, bool $includeNeedle = false, int $offset = 0): self
  81709. {
  81710. $str = clone $this;
  81711. $i = null;
  81712. foreach ((array) $needle as $n) {
  81713. $n = (string) $n;
  81714. $j = $this->indexOfLast($n, $offset);
  81715. if (null !== $j && $j >= $i) {
  81716. $i = $offset = $j;
  81717. $str->string = $n;
  81718. }
  81719. }
  81720. if (null === $i) {
  81721. return $str;
  81722. }
  81723. if ($includeNeedle) {
  81724. $i += $str->length();
  81725. }
  81726. return $this->slice(0, $i);
  81727. }
  81728. public function bytesAt(int $offset): array
  81729. {
  81730. $str = $this->slice($offset, 1);
  81731. return '' === $str->string ? [] : array_values(unpack('C*', $str->string));
  81732. }
  81733. abstract public function camel(): self;
  81734. abstract public function chunk(int $length = 1): array;
  81735. public function collapseWhitespace(): self
  81736. {
  81737. $str = clone $this;
  81738. $str->string = trim(preg_replace("/(?:[ \n\r\t\x0C]{2,}+|[\n\r\t\x0C])/", ' ', $str->string), " \n\r\t\x0C");
  81739. return $str;
  81740. }
  81741. public function containsAny($needle): bool
  81742. {
  81743. return null !== $this->indexOf($needle);
  81744. }
  81745. public function endsWith($suffix): bool
  81746. {
  81747. if (!\is_array($suffix) && !$suffix instanceof \Traversable) {
  81748. throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
  81749. }
  81750. foreach ($suffix as $s) {
  81751. if ($this->endsWith((string) $s)) {
  81752. return true;
  81753. }
  81754. }
  81755. return false;
  81756. }
  81757. public function ensureEnd(string $suffix): self
  81758. {
  81759. if (!$this->endsWith($suffix)) {
  81760. return $this->append($suffix);
  81761. }
  81762. $suffix = preg_quote($suffix);
  81763. $regex = '{('.$suffix.')(?:'.$suffix.')++$}D';
  81764. return $this->replaceMatches($regex.($this->ignoreCase ? 'i' : ''), '$1');
  81765. }
  81766. public function ensureStart(string $prefix): self
  81767. {
  81768. $prefix = new static($prefix);
  81769. if (!$this->startsWith($prefix)) {
  81770. return $this->prepend($prefix);
  81771. }
  81772. $str = clone $this;
  81773. $i = $prefixLen = $prefix->length();
  81774. while ($this->indexOf($prefix, $i) === $i) {
  81775. $str = $str->slice($prefixLen);
  81776. $i += $prefixLen;
  81777. }
  81778. return $str;
  81779. }
  81780. public function equalsTo($string): bool
  81781. {
  81782. if (!\is_array($string) && !$string instanceof \Traversable) {
  81783. throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
  81784. }
  81785. foreach ($string as $s) {
  81786. if ($this->equalsTo((string) $s)) {
  81787. return true;
  81788. }
  81789. }
  81790. return false;
  81791. }
  81792. abstract public function folded(): self;
  81793. public function ignoreCase(): self
  81794. {
  81795. $str = clone $this;
  81796. $str->ignoreCase = true;
  81797. return $str;
  81798. }
  81799. public function indexOf($needle, int $offset = 0): ?int
  81800. {
  81801. if (!\is_array($needle) && !$needle instanceof \Traversable) {
  81802. throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
  81803. }
  81804. $i = \PHP_INT_MAX;
  81805. foreach ($needle as $n) {
  81806. $j = $this->indexOf((string) $n, $offset);
  81807. if (null !== $j && $j < $i) {
  81808. $i = $j;
  81809. }
  81810. }
  81811. return \PHP_INT_MAX === $i ? null : $i;
  81812. }
  81813. public function indexOfLast($needle, int $offset = 0): ?int
  81814. {
  81815. if (!\is_array($needle) && !$needle instanceof \Traversable) {
  81816. throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
  81817. }
  81818. $i = null;
  81819. foreach ($needle as $n) {
  81820. $j = $this->indexOfLast((string) $n, $offset);
  81821. if (null !== $j && $j >= $i) {
  81822. $i = $offset = $j;
  81823. }
  81824. }
  81825. return $i;
  81826. }
  81827. public function isEmpty(): bool
  81828. {
  81829. return '' === $this->string;
  81830. }
  81831. abstract public function join(array $strings, string $lastGlue = null): self;
  81832. public function jsonSerialize(): string
  81833. {
  81834. return $this->string;
  81835. }
  81836. abstract public function length(): int;
  81837. abstract public function lower(): self;
  81838. abstract public function match(string $regexp, int $flags = 0, int $offset = 0): array;
  81839. abstract public function padBoth(int $length, string $padStr = ' '): self;
  81840. abstract public function padEnd(int $length, string $padStr = ' '): self;
  81841. abstract public function padStart(int $length, string $padStr = ' '): self;
  81842. abstract public function prepend(string ...$prefix): self;
  81843. public function repeat(int $multiplier): self
  81844. {
  81845. if (0 > $multiplier) {
  81846. throw new InvalidArgumentException(sprintf('Multiplier must be positive, %d given.', $multiplier));
  81847. }
  81848. $str = clone $this;
  81849. $str->string = str_repeat($str->string, $multiplier);
  81850. return $str;
  81851. }
  81852. abstract public function replace(string $from, string $to): self;
  81853. abstract public function replaceMatches(string $fromRegexp, $to): self;
  81854. abstract public function reverse(): self;
  81855. abstract public function slice(int $start = 0, int $length = null): self;
  81856. abstract public function snake(): self;
  81857. abstract public function splice(string $replacement, int $start = 0, int $length = null): self;
  81858. public function split(string $delimiter, int $limit = null, int $flags = null): array
  81859. {
  81860. if (null === $flags) {
  81861. throw new \TypeError('Split behavior when $flags is null must be implemented by child classes.');
  81862. }
  81863. if ($this->ignoreCase) {
  81864. $delimiter .= 'i';
  81865. }
  81866. set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
  81867. try {
  81868. if (false === $chunks = preg_split($delimiter, $this->string, $limit, $flags)) {
  81869. $lastError = preg_last_error();
  81870. foreach (get_defined_constants(true)['pcre'] as $k => $v) {
  81871. if ($lastError === $v && '_ERROR' === substr($k, -6)) {
  81872. throw new RuntimeException('Splitting failed with '.$k.'.');
  81873. }
  81874. }
  81875. throw new RuntimeException('Splitting failed with unknown error code.');
  81876. }
  81877. } finally {
  81878. restore_error_handler();
  81879. }
  81880. $str = clone $this;
  81881. if (self::PREG_SPLIT_OFFSET_CAPTURE & $flags) {
  81882. foreach ($chunks as &$chunk) {
  81883. $str->string = $chunk[0];
  81884. $chunk[0] = clone $str;
  81885. }
  81886. } else {
  81887. foreach ($chunks as &$chunk) {
  81888. $str->string = $chunk;
  81889. $chunk = clone $str;
  81890. }
  81891. }
  81892. return $chunks;
  81893. }
  81894. public function startsWith($prefix): bool
  81895. {
  81896. if (!\is_array($prefix) && !$prefix instanceof \Traversable) {
  81897. throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
  81898. }
  81899. foreach ($prefix as $prefix) {
  81900. if ($this->startsWith((string) $prefix)) {
  81901. return true;
  81902. }
  81903. }
  81904. return false;
  81905. }
  81906. abstract public function title(bool $allWords = false): self;
  81907. public function toByteString(string $toEncoding = null): ByteString
  81908. {
  81909. $b = new ByteString();
  81910. $toEncoding = \in_array($toEncoding, ['utf8', 'utf-8', 'UTF8'], true) ? 'UTF-8' : $toEncoding;
  81911. if (null === $toEncoding || $toEncoding === $fromEncoding = $this instanceof AbstractUnicodeString || preg_match('//u', $b->string) ? 'UTF-8' : 'Windows-1252') {
  81912. $b->string = $this->string;
  81913. return $b;
  81914. }
  81915. set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
  81916. try {
  81917. try {
  81918. $b->string = mb_convert_encoding($this->string, $toEncoding, 'UTF-8');
  81919. } catch (InvalidArgumentException $e) {
  81920. if (!\function_exists('iconv')) {
  81921. throw $e;
  81922. }
  81923. $b->string = iconv('UTF-8', $toEncoding, $this->string);
  81924. }
  81925. } finally {
  81926. restore_error_handler();
  81927. }
  81928. return $b;
  81929. }
  81930. public function toCodePointString(): CodePointString
  81931. {
  81932. return new CodePointString($this->string);
  81933. }
  81934. public function toString(): string
  81935. {
  81936. return $this->string;
  81937. }
  81938. public function toUnicodeString(): UnicodeString
  81939. {
  81940. return new UnicodeString($this->string);
  81941. }
  81942. abstract public function trim(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): self;
  81943. abstract public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): self;
  81944. public function trimPrefix($prefix): self
  81945. {
  81946. if (\is_array($prefix) || $prefix instanceof \Traversable) {
  81947. foreach ($prefix as $s) {
  81948. $t = $this->trimPrefix($s);
  81949. if ($t->string !== $this->string) {
  81950. return $t;
  81951. }
  81952. }
  81953. return clone $this;
  81954. }
  81955. $str = clone $this;
  81956. if ($prefix instanceof self) {
  81957. $prefix = $prefix->string;
  81958. } else {
  81959. $prefix = (string) $prefix;
  81960. }
  81961. if ('' !== $prefix && \strlen($this->string) >= \strlen($prefix) && 0 === substr_compare($this->string, $prefix, 0, \strlen($prefix), $this->ignoreCase)) {
  81962. $str->string = substr($this->string, \strlen($prefix));
  81963. }
  81964. return $str;
  81965. }
  81966. abstract public function trimStart(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): self;
  81967. public function trimSuffix($suffix): self
  81968. {
  81969. if (\is_array($suffix) || $suffix instanceof \Traversable) {
  81970. foreach ($suffix as $s) {
  81971. $t = $this->trimSuffix($s);
  81972. if ($t->string !== $this->string) {
  81973. return $t;
  81974. }
  81975. }
  81976. return clone $this;
  81977. }
  81978. $str = clone $this;
  81979. if ($suffix instanceof self) {
  81980. $suffix = $suffix->string;
  81981. } else {
  81982. $suffix = (string) $suffix;
  81983. }
  81984. if ('' !== $suffix && \strlen($this->string) >= \strlen($suffix) && 0 === substr_compare($this->string, $suffix, -\strlen($suffix), null, $this->ignoreCase)) {
  81985. $str->string = substr($this->string, 0, -\strlen($suffix));
  81986. }
  81987. return $str;
  81988. }
  81989. public function truncate(int $length, string $ellipsis = '', bool $cut = true): self
  81990. {
  81991. $stringLength = $this->length();
  81992. if ($stringLength <= $length) {
  81993. return clone $this;
  81994. }
  81995. $ellipsisLength = '' !== $ellipsis ? (new static($ellipsis))->length() : 0;
  81996. if ($length < $ellipsisLength) {
  81997. $ellipsisLength = 0;
  81998. }
  81999. if (!$cut) {
  82000. if (null === $length = $this->indexOf([' ', "\r", "\n", "\t"], ($length ?: 1) - 1)) {
  82001. return clone $this;
  82002. }
  82003. $length += $ellipsisLength;
  82004. }
  82005. $str = $this->slice(0, $length - $ellipsisLength);
  82006. return $ellipsisLength ? $str->trimEnd()->append($ellipsis) : $str;
  82007. }
  82008. abstract public function upper(): self;
  82009. abstract public function width(bool $ignoreAnsiDecoration = true): int;
  82010. public function wordwrap(int $width = 75, string $break = "\n", bool $cut = false): self
  82011. {
  82012. $lines = '' !== $break ? $this->split($break) : [clone $this];
  82013. $chars = [];
  82014. $mask = '';
  82015. if (1 === \count($lines) && '' === $lines[0]->string) {
  82016. return $lines[0];
  82017. }
  82018. foreach ($lines as $i => $line) {
  82019. if ($i) {
  82020. $chars[] = $break;
  82021. $mask .= '#';
  82022. }
  82023. foreach ($line->chunk() as $char) {
  82024. $chars[] = $char->string;
  82025. $mask .= ' ' === $char->string ? ' ' : '?';
  82026. }
  82027. }
  82028. $string = '';
  82029. $j = 0;
  82030. $b = $i = -1;
  82031. $mask = wordwrap($mask, $width, '#', $cut);
  82032. while (false !== $b = strpos($mask, '#', $b + 1)) {
  82033. for (++$i; $i < $b; ++$i) {
  82034. $string .= $chars[$j];
  82035. unset($chars[$j++]);
  82036. }
  82037. if ($break === $chars[$j] || ' ' === $chars[$j]) {
  82038. unset($chars[$j++]);
  82039. }
  82040. $string .= $break;
  82041. }
  82042. $str = clone $this;
  82043. $str->string = $string.implode('', $chars);
  82044. return $str;
  82045. }
  82046. public function __sleep(): array
  82047. {
  82048. return ['string'];
  82049. }
  82050. public function __clone()
  82051. {
  82052. $this->ignoreCase = false;
  82053. }
  82054. public function __toString(): string
  82055. {
  82056. return $this->string;
  82057. }
  82058. }
  82059. <?php
  82060. namespace Symfony\Component\String;
  82061. use Symfony\Component\String\Exception\ExceptionInterface;
  82062. use Symfony\Component\String\Exception\InvalidArgumentException;
  82063. use Symfony\Component\String\Exception\RuntimeException;
  82064. abstract class AbstractUnicodeString extends AbstractString
  82065. {
  82066. public const NFC = \Normalizer::NFC;
  82067. public const NFD = \Normalizer::NFD;
  82068. public const NFKC = \Normalizer::NFKC;
  82069. public const NFKD = \Normalizer::NFKD;
  82070. 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";
  82071. private const FOLD_FROM = ['İ', 'µ', 'ſ', "\xCD\x85", 'ς', '�', 'ϑ', 'ϕ', 'ϖ', 'ϰ', 'ϱ', 'ϵ', 'ẛ', "\xE1\xBE\xBE", 'ß', 'ʼn', 'ǰ', '�', 'ΰ', 'և', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'ẚ', 'ẞ', '�', 'ὒ', 'ὔ', 'ὖ', 'ᾀ', '�', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ', '�', 'ᾎ', '�', '�', 'ᾑ', 'ᾒ', 'ᾓ', 'ᾔ', 'ᾕ', 'ᾖ', 'ᾗ', 'ᾘ', 'ᾙ', 'ᾚ', 'ᾛ', 'ᾜ', '�', 'ᾞ', 'ᾟ', 'ᾠ', 'ᾡ', 'ᾢ', 'ᾣ', 'ᾤ', 'ᾥ', 'ᾦ', 'ᾧ', 'ᾨ', 'ᾩ', 'ᾪ', 'ᾫ', 'ᾬ', 'ᾭ', 'ᾮ', 'ᾯ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'ᾼ', 'ῂ', 'ῃ', 'ῄ', 'ῆ', 'ῇ', 'ῌ', 'ῒ', 'ῖ', 'ῗ', 'ῢ', 'ῤ', 'ῦ', 'ῧ', 'ῲ', 'ῳ', 'ῴ', 'ῶ', 'ῷ', 'ῼ', 'ff', '�', 'fl', 'ffi', 'ffl', 'ſt', 'st', 'ﬓ', 'ﬔ', 'ﬕ', 'ﬖ', 'ﬗ'];
  82072. private const FOLD_TO = ['i̇', 'μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', '�', 'ε', 'ṡ', 'ι', 'ss', 'ʼn', 'ǰ', '�', 'ΰ', 'եւ', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'aʾ', 'ss', '�', 'ὒ', 'ὔ', 'ὖ', 'ἀι', '�ι', 'ἂι', 'ἃι', 'ἄι', 'ἅι', 'ἆι', 'ἇι', 'ἀι', '�ι', 'ἂι', 'ἃι', 'ἄι', 'ἅι', 'ἆι', 'ἇι', 'ἠι', 'ἡι', 'ἢι', 'ἣι', 'ἤι', 'ἥι', 'ἦι', 'ἧι', 'ἠι', 'ἡι', 'ἢι', 'ἣι', 'ἤι', 'ἥι', 'ἦι', 'ἧι', 'ὠι', 'ὡι', 'ὢι', 'ὣι', 'ὤι', 'ὥι', 'ὦι', 'ὧι', 'ὠι', 'ὡι', 'ὢι', 'ὣι', 'ὤι', 'ὥι', 'ὦι', 'ὧι', 'ὰι', 'αι', 'άι', 'ᾶ', 'ᾶι', 'αι', 'ὴι', 'ηι', 'ήι', 'ῆ', 'ῆι', 'ηι', 'ῒ', 'ῖ', 'ῗ', 'ῢ', 'ῤ', 'ῦ', 'ῧ', 'ὼι', 'ωι', 'ώι', 'ῶ', 'ῶι', 'ωι', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'st', 'st', 'մն', 'մե', 'մի', 'վն', 'մխ'];
  82073. private const UPPER_FROM = ['ß', 'ff', '�', 'fl', 'ffi', 'ffl', 'ſt', 'st', 'և', 'ﬓ', 'ﬔ', 'ﬕ', 'ﬖ', 'ﬗ', 'ʼn', '�', 'ΰ', 'ǰ', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'ẚ', '�', 'ὒ', 'ὔ', 'ὖ', 'ᾶ', 'ῆ', 'ῒ', 'ΐ', 'ῖ', 'ῗ', 'ῢ', 'ΰ', 'ῤ', 'ῦ', 'ῧ', 'ῶ'];
  82074. private const UPPER_TO = ['SS', 'FF', 'FI', 'FL', 'FFI', 'FFL', 'ST', 'ST', 'ԵՒ', 'ՄՆ', 'ՄԵ', 'ՄԻ', 'ՎՆ', 'ՄԽ', 'ʼN', 'Ϊ�', 'Ϋ�', 'J̌', 'H̱', 'T̈', 'W̊', 'Y̊', 'Aʾ', 'Υ̓', 'Υ̓̀', 'Υ̓�', 'Υ̓͂', 'Α͂', 'Η͂', 'Ϊ̀', 'Ϊ�', 'Ι͂', 'Ϊ͂', 'Ϋ̀', 'Ϋ�', 'Ρ̓', 'Υ͂', 'Ϋ͂', 'Ω͂'];
  82075. private const TRANSLIT_FROM = ['Æ', '�', 'Ø', 'Þ', 'ß', 'æ', 'ð', 'ø', 'þ', '�', 'đ', 'Ħ', 'ħ', 'ı', 'ĸ', 'Ŀ', 'ŀ', '�', 'ł', 'ʼn', 'Ŋ', 'ŋ', 'Œ', 'œ', 'Ŧ', 'ŧ', 'ƀ', '�', 'Ƃ', 'ƃ', 'Ƈ', 'ƈ', 'Ɖ', 'Ɗ', 'Ƌ', 'ƌ', '�', 'Ƒ', 'ƒ', 'Ɠ', 'ƕ', 'Ɩ', 'Ɨ', 'Ƙ', 'ƙ', 'ƚ', '�', 'ƞ', 'Ƣ', 'ƣ', 'Ƥ', 'ƥ', 'ƫ', 'Ƭ', 'ƭ', 'Ʈ', 'Ʋ', 'Ƴ', 'ƴ', 'Ƶ', 'ƶ', 'DŽ', 'Dž', 'dž', 'Ǥ', 'ǥ', 'ȡ', 'Ȥ', 'ȥ', 'ȴ', 'ȵ', 'ȶ', 'ȷ', 'ȸ', 'ȹ', 'Ⱥ', 'Ȼ', 'ȼ', 'Ƚ', 'Ⱦ', 'ȿ', 'ɀ', 'Ƀ', 'Ʉ', 'Ɇ', 'ɇ', 'Ɉ', 'ɉ', 'Ɍ', '�', 'Ɏ', '�', 'ɓ', 'ɕ', 'ɖ', 'ɗ', 'ɛ', 'ɟ', 'ɠ', 'ɡ', 'ɢ', 'ɦ', 'ɧ', 'ɨ', 'ɪ', 'ɫ', 'ɬ', 'ɭ', 'ɱ', 'ɲ', 'ɳ', 'ɴ', 'ɶ', 'ɼ', 'ɽ', 'ɾ', 'ʀ', 'ʂ', 'ʈ', 'ʉ', 'ʋ', '�', '�', 'ʑ', 'ʙ', 'ʛ', 'ʜ', '�', 'ʟ', 'ʠ', 'ʣ', 'ʥ', 'ʦ', 'ʪ', 'ʫ', 'ᴀ', '�', 'ᴃ', 'ᴄ', 'ᴅ', 'ᴆ', 'ᴇ', 'ᴊ', 'ᴋ', 'ᴌ', '�', '�', 'ᴘ', 'ᴛ', 'ᴜ', 'ᴠ', 'ᴡ', 'ᴢ', 'ᵫ', 'ᵬ', 'ᵭ', 'ᵮ', 'ᵯ', 'ᵰ', 'ᵱ', 'ᵲ', 'ᵳ', 'ᵴ', 'ᵵ', 'ᵶ', 'ᵺ', 'ᵻ', 'ᵽ', 'ᵾ', 'ᶀ', '�', 'ᶂ', 'ᶃ', 'ᶄ', 'ᶅ', 'ᶆ', 'ᶇ', 'ᶈ', 'ᶉ', 'ᶊ', 'ᶌ', '�', 'ᶎ', '�', 'ᶑ', 'ᶒ', 'ᶓ', 'ᶖ', 'ᶙ', 'ẚ', 'ẜ', '�', 'ẞ', 'Ỻ', 'ỻ', 'Ỽ', 'ỽ', 'Ỿ', 'ỿ', '©', '®', '₠', '₢', '₣', '₤', '₧', '₺', '₹', 'ℌ', '℞', '㎧', '㎮', '�', '�', '�', '�', '¼', '½', '¾', '⅓', '⅔', '⅕', '⅖', '⅗', '⅘', '⅙', '⅚', '⅛', '⅜', '�', '⅞', '⅟', '〇', '‘', '’', '‚', '‛', '“', '�', '„', '‟', '′', '″', '�', '〞', '«', '»', '‹', '›', '�', '‑', '‒', '–', '—', '―', '︱', '︲', '﹘', '‖', '�', '�', '�', '�', '�', '。', '〈', '〉', '《', '》', '〔', '〕', '〘', '〙', '〚', '〛', '︑', '︒', '︹', '︺', '︽', '︾', '︿', '﹀', '﹑', '�', '﹞', '⦅', '⦆', '。', '、', '×', '÷', '−', '∕', '∖', '∣', '∥', '≪', '≫', '⦅', '⦆'];
  82076. 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', '\'', '\'', ',', '\'', '"', '"', ',,', '"', '\'', '"', '"', '"', '<<', '>>', '<', '>', '-', '-', '-', '-', '-', '-', '-', '-', '-', '||', '/', '[', ']', '*', ',', '.', '<', '>', '<<', '>>', '[', ']', '[', ']', '[', ']', ',', '.', '[', ']', '<<', '>>', '<', '>', ',', '[', ']', '((', '))', '.', ',', '*', '/', '-', '/', '\\', '|', '||', '<<', '>>', '((', '))'];
  82077. private static $transliterators = [];
  82078. private static $tableZero;
  82079. private static $tableWide;
  82080. public static function fromCodePoints(int ...$codes): self
  82081. {
  82082. $string = '';
  82083. foreach ($codes as $code) {
  82084. if (0x80 > $code %= 0x200000) {
  82085. $string .= \chr($code);
  82086. } elseif (0x800 > $code) {
  82087. $string .= \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
  82088. } elseif (0x10000 > $code) {
  82089. $string .= \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  82090. } else {
  82091. $string .= \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  82092. }
  82093. }
  82094. return new static($string);
  82095. }
  82096. public function ascii(array $rules = []): self
  82097. {
  82098. $str = clone $this;
  82099. $s = $str->string;
  82100. $str->string = '';
  82101. array_unshift($rules, 'nfd');
  82102. $rules[] = 'latin-ascii';
  82103. if (\function_exists('transliterator_transliterate')) {
  82104. $rules[] = 'any-latin/bgn';
  82105. }
  82106. $rules[] = 'nfkd';
  82107. $rules[] = '[:nonspacing mark:] remove';
  82108. while (\strlen($s) - 1 > $i = strspn($s, self::ASCII)) {
  82109. if (0 < --$i) {
  82110. $str->string .= substr($s, 0, $i);
  82111. $s = substr($s, $i);
  82112. }
  82113. if (!$rule = array_shift($rules)) {
  82114. $rules = [];
  82115. }
  82116. if ($rule instanceof \Transliterator) {
  82117. $s = $rule->transliterate($s);
  82118. } elseif ($rule instanceof \Closure) {
  82119. $s = $rule($s);
  82120. } elseif ($rule) {
  82121. if ('nfd' === $rule = strtolower($rule)) {
  82122. normalizer_is_normalized($s, self::NFD) ?: $s = normalizer_normalize($s, self::NFD);
  82123. } elseif ('nfkd' === $rule) {
  82124. normalizer_is_normalized($s, self::NFKD) ?: $s = normalizer_normalize($s, self::NFKD);
  82125. } elseif ('[:nonspacing mark:] remove' === $rule) {
  82126. $s = preg_replace('/\p{Mn}++/u', '', $s);
  82127. } elseif ('latin-ascii' === $rule) {
  82128. $s = str_replace(self::TRANSLIT_FROM, self::TRANSLIT_TO, $s);
  82129. } elseif ('de-ascii' === $rule) {
  82130. $s = preg_replace("/([AUO])\u{0308}(?=\p{Ll})/u", '$1e', $s);
  82131. $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);
  82132. } elseif (\function_exists('transliterator_transliterate')) {
  82133. if (null === $transliterator = self::$transliterators[$rule] ?? self::$transliterators[$rule] = \Transliterator::create($rule)) {
  82134. if ('any-latin/bgn' === $rule) {
  82135. $rule = 'any-latin';
  82136. $transliterator = self::$transliterators[$rule] ?? self::$transliterators[$rule] = \Transliterator::create($rule);
  82137. }
  82138. if (null === $transliterator) {
  82139. throw new InvalidArgumentException(sprintf('Unknown transliteration rule "%s".', $rule));
  82140. }
  82141. self::$transliterators['any-latin/bgn'] = $transliterator;
  82142. }
  82143. $s = $transliterator->transliterate($s);
  82144. }
  82145. } elseif (!\function_exists('iconv')) {
  82146. $s = preg_replace('/[^\x00-\x7F]/u', '?', $s);
  82147. } else {
  82148. $s = @preg_replace_callback('/[^\x00-\x7F]/u', static function ($c) {
  82149. $c = (string) iconv('UTF-8', 'ASCII//TRANSLIT', $c[0]);
  82150. if ('' === $c && '' === iconv('UTF-8', 'ASCII//TRANSLIT', '²')) {
  82151. throw new \LogicException(sprintf('"%s" requires a translit-able iconv implementation, try installing "gnu-libiconv" if you\'re using Alpine Linux.', static::class));
  82152. }
  82153. return 1 < \strlen($c) ? ltrim($c, '\'`"^~') : ('' !== $c ? $c : '?');
  82154. }, $s);
  82155. }
  82156. }
  82157. $str->string .= $s;
  82158. return $str;
  82159. }
  82160. public function camel(): parent
  82161. {
  82162. $str = clone $this;
  82163. $str->string = str_replace(' ', '', preg_replace_callback('/\b.(?![A-Z]{2,})/u', static function ($m) use (&$i) {
  82164. return 1 === ++$i ? ('İ' === $m[0] ? 'i̇' : mb_strtolower($m[0], 'UTF-8')) : mb_convert_case($m[0], \MB_CASE_TITLE, 'UTF-8');
  82165. }, preg_replace('/[^\pL0-9]++/u', ' ', $this->string)));
  82166. return $str;
  82167. }
  82168. public function codePointsAt(int $offset): array
  82169. {
  82170. $str = $this->slice($offset, 1);
  82171. if ('' === $str->string) {
  82172. return [];
  82173. }
  82174. $codePoints = [];
  82175. foreach (preg_split('//u', $str->string, -1, \PREG_SPLIT_NO_EMPTY) as $c) {
  82176. $codePoints[] = mb_ord($c, 'UTF-8');
  82177. }
  82178. return $codePoints;
  82179. }
  82180. public function folded(bool $compat = true): parent
  82181. {
  82182. $str = clone $this;
  82183. if (!$compat || \PHP_VERSION_ID < 70300 || !\defined('Normalizer::NFKC_CF')) {
  82184. $str->string = normalizer_normalize($str->string, $compat ? \Normalizer::NFKC : \Normalizer::NFC);
  82185. $str->string = mb_strtolower(str_replace(self::FOLD_FROM, self::FOLD_TO, $this->string), 'UTF-8');
  82186. } else {
  82187. $str->string = normalizer_normalize($str->string, \Normalizer::NFKC_CF);
  82188. }
  82189. return $str;
  82190. }
  82191. public function join(array $strings, string $lastGlue = null): parent
  82192. {
  82193. $str = clone $this;
  82194. $tail = null !== $lastGlue && 1 < \count($strings) ? $lastGlue.array_pop($strings) : '';
  82195. $str->string = implode($this->string, $strings).$tail;
  82196. if (!preg_match('//u', $str->string)) {
  82197. throw new InvalidArgumentException('Invalid UTF-8 string.');
  82198. }
  82199. return $str;
  82200. }
  82201. public function lower(): parent
  82202. {
  82203. $str = clone $this;
  82204. $str->string = mb_strtolower(str_replace('İ', 'i̇', $str->string), 'UTF-8');
  82205. return $str;
  82206. }
  82207. public function match(string $regexp, int $flags = 0, int $offset = 0): array
  82208. {
  82209. $match = ((\PREG_PATTERN_ORDER | \PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match';
  82210. if ($this->ignoreCase) {
  82211. $regexp .= 'i';
  82212. }
  82213. set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
  82214. try {
  82215. if (false === $match($regexp.'u', $this->string, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset)) {
  82216. $lastError = preg_last_error();
  82217. foreach (get_defined_constants(true)['pcre'] as $k => $v) {
  82218. if ($lastError === $v && '_ERROR' === substr($k, -6)) {
  82219. throw new RuntimeException('Matching failed with '.$k.'.');
  82220. }
  82221. }
  82222. throw new RuntimeException('Matching failed with unknown error code.');
  82223. }
  82224. } finally {
  82225. restore_error_handler();
  82226. }
  82227. return $matches;
  82228. }
  82229. public function normalize(int $form = self::NFC): self
  82230. {
  82231. if (!\in_array($form, [self::NFC, self::NFD, self::NFKC, self::NFKD])) {
  82232. throw new InvalidArgumentException('Unsupported normalization form.');
  82233. }
  82234. $str = clone $this;
  82235. normalizer_is_normalized($str->string, $form) ?: $str->string = normalizer_normalize($str->string, $form);
  82236. return $str;
  82237. }
  82238. public function padBoth(int $length, string $padStr = ' '): parent
  82239. {
  82240. if ('' === $padStr || !preg_match('//u', $padStr)) {
  82241. throw new InvalidArgumentException('Invalid UTF-8 string.');
  82242. }
  82243. $pad = clone $this;
  82244. $pad->string = $padStr;
  82245. return $this->pad($length, $pad, \STR_PAD_BOTH);
  82246. }
  82247. public function padEnd(int $length, string $padStr = ' '): parent
  82248. {
  82249. if ('' === $padStr || !preg_match('//u', $padStr)) {
  82250. throw new InvalidArgumentException('Invalid UTF-8 string.');
  82251. }
  82252. $pad = clone $this;
  82253. $pad->string = $padStr;
  82254. return $this->pad($length, $pad, \STR_PAD_RIGHT);
  82255. }
  82256. public function padStart(int $length, string $padStr = ' '): parent
  82257. {
  82258. if ('' === $padStr || !preg_match('//u', $padStr)) {
  82259. throw new InvalidArgumentException('Invalid UTF-8 string.');
  82260. }
  82261. $pad = clone $this;
  82262. $pad->string = $padStr;
  82263. return $this->pad($length, $pad, \STR_PAD_LEFT);
  82264. }
  82265. public function replaceMatches(string $fromRegexp, $to): parent
  82266. {
  82267. if ($this->ignoreCase) {
  82268. $fromRegexp .= 'i';
  82269. }
  82270. if (\is_array($to) || $to instanceof \Closure) {
  82271. if (!\is_callable($to)) {
  82272. throw new \TypeError(sprintf('Argument 2 passed to "%s::replaceMatches()" must be callable, array given.', static::class));
  82273. }
  82274. $replace = 'preg_replace_callback';
  82275. $to = static function (array $m) use ($to): string {
  82276. $to = $to($m);
  82277. if ('' !== $to && (!\is_string($to) || !preg_match('//u', $to))) {
  82278. throw new InvalidArgumentException('Replace callback must return a valid UTF-8 string.');
  82279. }
  82280. return $to;
  82281. };
  82282. } elseif ('' !== $to && !preg_match('//u', $to)) {
  82283. throw new InvalidArgumentException('Invalid UTF-8 string.');
  82284. } else {
  82285. $replace = 'preg_replace';
  82286. }
  82287. set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
  82288. try {
  82289. if (null === $string = $replace($fromRegexp.'u', $to, $this->string)) {
  82290. $lastError = preg_last_error();
  82291. foreach (get_defined_constants(true)['pcre'] as $k => $v) {
  82292. if ($lastError === $v && '_ERROR' === substr($k, -6)) {
  82293. throw new RuntimeException('Matching failed with '.$k.'.');
  82294. }
  82295. }
  82296. throw new RuntimeException('Matching failed with unknown error code.');
  82297. }
  82298. } finally {
  82299. restore_error_handler();
  82300. }
  82301. $str = clone $this;
  82302. $str->string = $string;
  82303. return $str;
  82304. }
  82305. public function reverse(): parent
  82306. {
  82307. $str = clone $this;
  82308. $str->string = implode('', array_reverse(preg_split('/(\X)/u', $str->string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY)));
  82309. return $str;
  82310. }
  82311. public function snake(): parent
  82312. {
  82313. $str = $this->camel();
  82314. $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');
  82315. return $str;
  82316. }
  82317. public function title(bool $allWords = false): parent
  82318. {
  82319. $str = clone $this;
  82320. $limit = $allWords ? -1 : 1;
  82321. $str->string = preg_replace_callback('/\b./u', static function (array $m): string {
  82322. return mb_convert_case($m[0], \MB_CASE_TITLE, 'UTF-8');
  82323. }, $str->string, $limit);
  82324. return $str;
  82325. }
  82326. public function trim(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): parent
  82327. {
  82328. if (" \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}" !== $chars && !preg_match('//u', $chars)) {
  82329. throw new InvalidArgumentException('Invalid UTF-8 chars.');
  82330. }
  82331. $chars = preg_quote($chars);
  82332. $str = clone $this;
  82333. $str->string = preg_replace("{^[$chars]++|[$chars]++$}uD", '', $str->string);
  82334. return $str;
  82335. }
  82336. public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): parent
  82337. {
  82338. if (" \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}" !== $chars && !preg_match('//u', $chars)) {
  82339. throw new InvalidArgumentException('Invalid UTF-8 chars.');
  82340. }
  82341. $chars = preg_quote($chars);
  82342. $str = clone $this;
  82343. $str->string = preg_replace("{[$chars]++$}uD", '', $str->string);
  82344. return $str;
  82345. }
  82346. public function trimPrefix($prefix): parent
  82347. {
  82348. if (!$this->ignoreCase) {
  82349. return parent::trimPrefix($prefix);
  82350. }
  82351. $str = clone $this;
  82352. if ($prefix instanceof \Traversable) {
  82353. $prefix = iterator_to_array($prefix, false);
  82354. } elseif ($prefix instanceof parent) {
  82355. $prefix = $prefix->string;
  82356. }
  82357. $prefix = implode('|', array_map('preg_quote', (array) $prefix));
  82358. $str->string = preg_replace("{^(?:$prefix)}iuD", '', $this->string);
  82359. return $str;
  82360. }
  82361. public function trimStart(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): parent
  82362. {
  82363. if (" \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}" !== $chars && !preg_match('//u', $chars)) {
  82364. throw new InvalidArgumentException('Invalid UTF-8 chars.');
  82365. }
  82366. $chars = preg_quote($chars);
  82367. $str = clone $this;
  82368. $str->string = preg_replace("{^[$chars]++}uD", '', $str->string);
  82369. return $str;
  82370. }
  82371. public function trimSuffix($suffix): parent
  82372. {
  82373. if (!$this->ignoreCase) {
  82374. return parent::trimSuffix($suffix);
  82375. }
  82376. $str = clone $this;
  82377. if ($suffix instanceof \Traversable) {
  82378. $suffix = iterator_to_array($suffix, false);
  82379. } elseif ($suffix instanceof parent) {
  82380. $suffix = $suffix->string;
  82381. }
  82382. $suffix = implode('|', array_map('preg_quote', (array) $suffix));
  82383. $str->string = preg_replace("{(?:$suffix)$}iuD", '', $this->string);
  82384. return $str;
  82385. }
  82386. public function upper(): parent
  82387. {
  82388. $str = clone $this;
  82389. $str->string = mb_strtoupper($str->string, 'UTF-8');
  82390. if (\PHP_VERSION_ID < 70300) {
  82391. $str->string = str_replace(self::UPPER_FROM, self::UPPER_TO, $str->string);
  82392. }
  82393. return $str;
  82394. }
  82395. public function width(bool $ignoreAnsiDecoration = true): int
  82396. {
  82397. $width = 0;
  82398. $s = str_replace(["\x00", "\x05", "\x07"], '', $this->string);
  82399. if (false !== strpos($s, "\r")) {
  82400. $s = str_replace(["\r\n", "\r"], "\n", $s);
  82401. }
  82402. if (!$ignoreAnsiDecoration) {
  82403. $s = preg_replace('/[\p{Cc}\x7F]++/u', '', $s);
  82404. }
  82405. foreach (explode("\n", $s) as $s) {
  82406. if ($ignoreAnsiDecoration) {
  82407. $s = preg_replace('/(?:\x1B(?:
  82408. \[ [\x30-\x3F]*+ [\x20-\x2F]*+ [\x40-\x7E]
  82409. | [P\]X^_] .*? \x1B\\\\
  82410. | [\x41-\x7E]
  82411. )|[\p{Cc}\x7F]++)/xu', '', $s);
  82412. }
  82413. $lineWidth = $this->wcswidth($s);
  82414. if ($lineWidth > $width) {
  82415. $width = $lineWidth;
  82416. }
  82417. }
  82418. return $width;
  82419. }
  82420. private function pad(int $len, self $pad, int $type): parent
  82421. {
  82422. $sLen = $this->length();
  82423. if ($len <= $sLen) {
  82424. return clone $this;
  82425. }
  82426. $padLen = $pad->length();
  82427. $freeLen = $len - $sLen;
  82428. $len = $freeLen % $padLen;
  82429. switch ($type) {
  82430. case \STR_PAD_RIGHT:
  82431. return $this->append(str_repeat($pad->string, intdiv($freeLen, $padLen)).($len ? $pad->slice(0, $len) : ''));
  82432. case \STR_PAD_LEFT:
  82433. return $this->prepend(str_repeat($pad->string, intdiv($freeLen, $padLen)).($len ? $pad->slice(0, $len) : ''));
  82434. case \STR_PAD_BOTH:
  82435. $freeLen /= 2;
  82436. $rightLen = ceil($freeLen);
  82437. $len = $rightLen % $padLen;
  82438. $str = $this->append(str_repeat($pad->string, intdiv($rightLen, $padLen)).($len ? $pad->slice(0, $len) : ''));
  82439. $leftLen = floor($freeLen);
  82440. $len = $leftLen % $padLen;
  82441. return $str->prepend(str_repeat($pad->string, intdiv($leftLen, $padLen)).($len ? $pad->slice(0, $len) : ''));
  82442. default:
  82443. throw new InvalidArgumentException('Invalid padding type.');
  82444. }
  82445. }
  82446. private function wcswidth(string $string): int
  82447. {
  82448. $width = 0;
  82449. foreach (preg_split('//u', $string, -1, \PREG_SPLIT_NO_EMPTY) as $c) {
  82450. $codePoint = mb_ord($c, 'UTF-8');
  82451. if (0 === $codePoint
  82452. || 0x034F === $codePoint
  82453. || (0x200B <= $codePoint && 0x200F >= $codePoint)
  82454. || 0x2028 === $codePoint
  82455. || 0x2029 === $codePoint
  82456. || (0x202A <= $codePoint && 0x202E >= $codePoint)
  82457. || (0x2060 <= $codePoint && 0x2063 >= $codePoint)
  82458. ) {
  82459. continue;
  82460. }
  82461. if (32 > $codePoint
  82462. || (0x07F <= $codePoint && 0x0A0 > $codePoint)
  82463. ) {
  82464. return -1;
  82465. }
  82466. if (null === self::$tableZero) {
  82467. self::$tableZero = require __DIR__.'/Resources/data/wcswidth_table_zero.php';
  82468. }
  82469. if ($codePoint >= self::$tableZero[0][0] && $codePoint <= self::$tableZero[$ubound = \count(self::$tableZero) - 1][1]) {
  82470. $lbound = 0;
  82471. while ($ubound >= $lbound) {
  82472. $mid = floor(($lbound + $ubound) / 2);
  82473. if ($codePoint > self::$tableZero[$mid][1]) {
  82474. $lbound = $mid + 1;
  82475. } elseif ($codePoint < self::$tableZero[$mid][0]) {
  82476. $ubound = $mid - 1;
  82477. } else {
  82478. continue 2;
  82479. }
  82480. }
  82481. }
  82482. if (null === self::$tableWide) {
  82483. self::$tableWide = require __DIR__.'/Resources/data/wcswidth_table_wide.php';
  82484. }
  82485. if ($codePoint >= self::$tableWide[0][0] && $codePoint <= self::$tableWide[$ubound = \count(self::$tableWide) - 1][1]) {
  82486. $lbound = 0;
  82487. while ($ubound >= $lbound) {
  82488. $mid = floor(($lbound + $ubound) / 2);
  82489. if ($codePoint > self::$tableWide[$mid][1]) {
  82490. $lbound = $mid + 1;
  82491. } elseif ($codePoint < self::$tableWide[$mid][0]) {
  82492. $ubound = $mid - 1;
  82493. } else {
  82494. $width += 2;
  82495. continue 2;
  82496. }
  82497. }
  82498. }
  82499. ++$width;
  82500. }
  82501. return $width;
  82502. }
  82503. }
  82504. <?php
  82505. namespace Symfony\Component\String;
  82506. use Symfony\Component\String\Exception\ExceptionInterface;
  82507. use Symfony\Component\String\Exception\InvalidArgumentException;
  82508. use Symfony\Component\String\Exception\RuntimeException;
  82509. class ByteString extends AbstractString
  82510. {
  82511. private const ALPHABET_ALPHANUMERIC = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
  82512. public function __construct(string $string = '')
  82513. {
  82514. $this->string = $string;
  82515. }
  82516. public static function fromRandom(int $length = 16, string $alphabet = null): self
  82517. {
  82518. if ($length <= 0) {
  82519. throw new InvalidArgumentException(sprintf('A strictly positive length is expected, "%d" given.', $length));
  82520. }
  82521. $alphabet = $alphabet ?? self::ALPHABET_ALPHANUMERIC;
  82522. $alphabetSize = \strlen($alphabet);
  82523. $bits = (int) ceil(log($alphabetSize, 2.0));
  82524. if ($bits <= 0 || $bits > 56) {
  82525. throw new InvalidArgumentException('The length of the alphabet must in the [2^1, 2^56] range.');
  82526. }
  82527. $ret = '';
  82528. while ($length > 0) {
  82529. $urandomLength = (int) ceil(2 * $length * $bits / 8.0);
  82530. $data = random_bytes($urandomLength);
  82531. $unpackedData = 0;
  82532. $unpackedBits = 0;
  82533. for ($i = 0; $i < $urandomLength && $length > 0; ++$i) {
  82534. $unpackedData = ($unpackedData << 8) | \ord($data[$i]);
  82535. $unpackedBits += 8;
  82536. for (; $unpackedBits >= $bits && $length > 0; $unpackedBits -= $bits) {
  82537. $index = ($unpackedData & ((1 << $bits) - 1));
  82538. $unpackedData >>= $bits;
  82539. if ($index < $alphabetSize) {
  82540. $ret .= $alphabet[$index];
  82541. --$length;
  82542. }
  82543. }
  82544. }
  82545. }
  82546. return new static($ret);
  82547. }
  82548. public function bytesAt(int $offset): array
  82549. {
  82550. $str = $this->string[$offset] ?? '';
  82551. return '' === $str ? [] : [\ord($str)];
  82552. }
  82553. public function append(string ...$suffix): parent
  82554. {
  82555. $str = clone $this;
  82556. $str->string .= 1 >= \count($suffix) ? ($suffix[0] ?? '') : implode('', $suffix);
  82557. return $str;
  82558. }
  82559. public function camel(): parent
  82560. {
  82561. $str = clone $this;
  82562. $parts = explode(' ', trim(ucwords(preg_replace('/[^a-zA-Z0-9\x7f-\xff]++/', ' ', $this->string))));
  82563. $parts[0] = 1 !== \strlen($parts[0]) && ctype_upper($parts[0]) ? $parts[0] : lcfirst($parts[0]);
  82564. $str->string = implode('', $parts);
  82565. return $str;
  82566. }
  82567. public function chunk(int $length = 1): array
  82568. {
  82569. if (1 > $length) {
  82570. throw new InvalidArgumentException('The chunk length must be greater than zero.');
  82571. }
  82572. if ('' === $this->string) {
  82573. return [];
  82574. }
  82575. $str = clone $this;
  82576. $chunks = [];
  82577. foreach (str_split($this->string, $length) as $chunk) {
  82578. $str->string = $chunk;
  82579. $chunks[] = clone $str;
  82580. }
  82581. return $chunks;
  82582. }
  82583. public function endsWith($suffix): bool
  82584. {
  82585. if ($suffix instanceof parent) {
  82586. $suffix = $suffix->string;
  82587. } elseif (\is_array($suffix) || $suffix instanceof \Traversable) {
  82588. return parent::endsWith($suffix);
  82589. } else {
  82590. $suffix = (string) $suffix;
  82591. }
  82592. return '' !== $suffix && \strlen($this->string) >= \strlen($suffix) && 0 === substr_compare($this->string, $suffix, -\strlen($suffix), null, $this->ignoreCase);
  82593. }
  82594. public function equalsTo($string): bool
  82595. {
  82596. if ($string instanceof parent) {
  82597. $string = $string->string;
  82598. } elseif (\is_array($string) || $string instanceof \Traversable) {
  82599. return parent::equalsTo($string);
  82600. } else {
  82601. $string = (string) $string;
  82602. }
  82603. if ('' !== $string && $this->ignoreCase) {
  82604. return 0 === strcasecmp($string, $this->string);
  82605. }
  82606. return $string === $this->string;
  82607. }
  82608. public function folded(): parent
  82609. {
  82610. $str = clone $this;
  82611. $str->string = strtolower($str->string);
  82612. return $str;
  82613. }
  82614. public function indexOf($needle, int $offset = 0): ?int
  82615. {
  82616. if ($needle instanceof parent) {
  82617. $needle = $needle->string;
  82618. } elseif (\is_array($needle) || $needle instanceof \Traversable) {
  82619. return parent::indexOf($needle, $offset);
  82620. } else {
  82621. $needle = (string) $needle;
  82622. }
  82623. if ('' === $needle) {
  82624. return null;
  82625. }
  82626. $i = $this->ignoreCase ? stripos($this->string, $needle, $offset) : strpos($this->string, $needle, $offset);
  82627. return false === $i ? null : $i;
  82628. }
  82629. public function indexOfLast($needle, int $offset = 0): ?int
  82630. {
  82631. if ($needle instanceof parent) {
  82632. $needle = $needle->string;
  82633. } elseif (\is_array($needle) || $needle instanceof \Traversable) {
  82634. return parent::indexOfLast($needle, $offset);
  82635. } else {
  82636. $needle = (string) $needle;
  82637. }
  82638. if ('' === $needle) {
  82639. return null;
  82640. }
  82641. $i = $this->ignoreCase ? strripos($this->string, $needle, $offset) : strrpos($this->string, $needle, $offset);
  82642. return false === $i ? null : $i;
  82643. }
  82644. public function isUtf8(): bool
  82645. {
  82646. return '' === $this->string || preg_match('//u', $this->string);
  82647. }
  82648. public function join(array $strings, string $lastGlue = null): parent
  82649. {
  82650. $str = clone $this;
  82651. $tail = null !== $lastGlue && 1 < \count($strings) ? $lastGlue.array_pop($strings) : '';
  82652. $str->string = implode($this->string, $strings).$tail;
  82653. return $str;
  82654. }
  82655. public function length(): int
  82656. {
  82657. return \strlen($this->string);
  82658. }
  82659. public function lower(): parent
  82660. {
  82661. $str = clone $this;
  82662. $str->string = strtolower($str->string);
  82663. return $str;
  82664. }
  82665. public function match(string $regexp, int $flags = 0, int $offset = 0): array
  82666. {
  82667. $match = ((\PREG_PATTERN_ORDER | \PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match';
  82668. if ($this->ignoreCase) {
  82669. $regexp .= 'i';
  82670. }
  82671. set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
  82672. try {
  82673. if (false === $match($regexp, $this->string, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset)) {
  82674. $lastError = preg_last_error();
  82675. foreach (get_defined_constants(true)['pcre'] as $k => $v) {
  82676. if ($lastError === $v && '_ERROR' === substr($k, -6)) {
  82677. throw new RuntimeException('Matching failed with '.$k.'.');
  82678. }
  82679. }
  82680. throw new RuntimeException('Matching failed with unknown error code.');
  82681. }
  82682. } finally {
  82683. restore_error_handler();
  82684. }
  82685. return $matches;
  82686. }
  82687. public function padBoth(int $length, string $padStr = ' '): parent
  82688. {
  82689. $str = clone $this;
  82690. $str->string = str_pad($this->string, $length, $padStr, \STR_PAD_BOTH);
  82691. return $str;
  82692. }
  82693. public function padEnd(int $length, string $padStr = ' '): parent
  82694. {
  82695. $str = clone $this;
  82696. $str->string = str_pad($this->string, $length, $padStr, \STR_PAD_RIGHT);
  82697. return $str;
  82698. }
  82699. public function padStart(int $length, string $padStr = ' '): parent
  82700. {
  82701. $str = clone $this;
  82702. $str->string = str_pad($this->string, $length, $padStr, \STR_PAD_LEFT);
  82703. return $str;
  82704. }
  82705. public function prepend(string ...$prefix): parent
  82706. {
  82707. $str = clone $this;
  82708. $str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$str->string;
  82709. return $str;
  82710. }
  82711. public function replace(string $from, string $to): parent
  82712. {
  82713. $str = clone $this;
  82714. if ('' !== $from) {
  82715. $str->string = $this->ignoreCase ? str_ireplace($from, $to, $this->string) : str_replace($from, $to, $this->string);
  82716. }
  82717. return $str;
  82718. }
  82719. public function replaceMatches(string $fromRegexp, $to): parent
  82720. {
  82721. if ($this->ignoreCase) {
  82722. $fromRegexp .= 'i';
  82723. }
  82724. if (\is_array($to)) {
  82725. if (!\is_callable($to)) {
  82726. throw new \TypeError(sprintf('Argument 2 passed to "%s::replaceMatches()" must be callable, array given.', static::class));
  82727. }
  82728. $replace = 'preg_replace_callback';
  82729. } else {
  82730. $replace = $to instanceof \Closure ? 'preg_replace_callback' : 'preg_replace';
  82731. }
  82732. set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
  82733. try {
  82734. if (null === $string = $replace($fromRegexp, $to, $this->string)) {
  82735. $lastError = preg_last_error();
  82736. foreach (get_defined_constants(true)['pcre'] as $k => $v) {
  82737. if ($lastError === $v && '_ERROR' === substr($k, -6)) {
  82738. throw new RuntimeException('Matching failed with '.$k.'.');
  82739. }
  82740. }
  82741. throw new RuntimeException('Matching failed with unknown error code.');
  82742. }
  82743. } finally {
  82744. restore_error_handler();
  82745. }
  82746. $str = clone $this;
  82747. $str->string = $string;
  82748. return $str;
  82749. }
  82750. public function reverse(): parent
  82751. {
  82752. $str = clone $this;
  82753. $str->string = strrev($str->string);
  82754. return $str;
  82755. }
  82756. public function slice(int $start = 0, int $length = null): parent
  82757. {
  82758. $str = clone $this;
  82759. $str->string = (string) substr($this->string, $start, $length ?? \PHP_INT_MAX);
  82760. return $str;
  82761. }
  82762. public function snake(): parent
  82763. {
  82764. $str = $this->camel();
  82765. $str->string = strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], '\1_\2', $str->string));
  82766. return $str;
  82767. }
  82768. public function splice(string $replacement, int $start = 0, int $length = null): parent
  82769. {
  82770. $str = clone $this;
  82771. $str->string = substr_replace($this->string, $replacement, $start, $length ?? \PHP_INT_MAX);
  82772. return $str;
  82773. }
  82774. public function split(string $delimiter, int $limit = null, int $flags = null): array
  82775. {
  82776. if (1 > $limit = $limit ?? \PHP_INT_MAX) {
  82777. throw new InvalidArgumentException('Split limit must be a positive integer.');
  82778. }
  82779. if ('' === $delimiter) {
  82780. throw new InvalidArgumentException('Split delimiter is empty.');
  82781. }
  82782. if (null !== $flags) {
  82783. return parent::split($delimiter, $limit, $flags);
  82784. }
  82785. $str = clone $this;
  82786. $chunks = $this->ignoreCase
  82787. ? preg_split('{'.preg_quote($delimiter).'}iD', $this->string, $limit)
  82788. : explode($delimiter, $this->string, $limit);
  82789. foreach ($chunks as &$chunk) {
  82790. $str->string = $chunk;
  82791. $chunk = clone $str;
  82792. }
  82793. return $chunks;
  82794. }
  82795. public function startsWith($prefix): bool
  82796. {
  82797. if ($prefix instanceof parent) {
  82798. $prefix = $prefix->string;
  82799. } elseif (!\is_string($prefix)) {
  82800. return parent::startsWith($prefix);
  82801. }
  82802. return '' !== $prefix && 0 === ($this->ignoreCase ? strncasecmp($this->string, $prefix, \strlen($prefix)) : strncmp($this->string, $prefix, \strlen($prefix)));
  82803. }
  82804. public function title(bool $allWords = false): parent
  82805. {
  82806. $str = clone $this;
  82807. $str->string = $allWords ? ucwords($str->string) : ucfirst($str->string);
  82808. return $str;
  82809. }
  82810. public function toUnicodeString(string $fromEncoding = null): UnicodeString
  82811. {
  82812. return new UnicodeString($this->toCodePointString($fromEncoding)->string);
  82813. }
  82814. public function toCodePointString(string $fromEncoding = null): CodePointString
  82815. {
  82816. $u = new CodePointString();
  82817. if (\in_array($fromEncoding, [null, 'utf8', 'utf-8', 'UTF8', 'UTF-8'], true) && preg_match('//u', $this->string)) {
  82818. $u->string = $this->string;
  82819. return $u;
  82820. }
  82821. set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
  82822. try {
  82823. try {
  82824. $validEncoding = false !== mb_detect_encoding($this->string, $fromEncoding ?? 'Windows-1252', true);
  82825. } catch (InvalidArgumentException $e) {
  82826. if (!\function_exists('iconv')) {
  82827. throw $e;
  82828. }
  82829. $u->string = iconv($fromEncoding ?? 'Windows-1252', 'UTF-8', $this->string);
  82830. return $u;
  82831. }
  82832. } finally {
  82833. restore_error_handler();
  82834. }
  82835. if (!$validEncoding) {
  82836. throw new InvalidArgumentException(sprintf('Invalid "%s" string.', $fromEncoding ?? 'Windows-1252'));
  82837. }
  82838. $u->string = mb_convert_encoding($this->string, 'UTF-8', $fromEncoding ?? 'Windows-1252');
  82839. return $u;
  82840. }
  82841. public function trim(string $chars = " \t\n\r\0\x0B\x0C"): parent
  82842. {
  82843. $str = clone $this;
  82844. $str->string = trim($str->string, $chars);
  82845. return $str;
  82846. }
  82847. public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C"): parent
  82848. {
  82849. $str = clone $this;
  82850. $str->string = rtrim($str->string, $chars);
  82851. return $str;
  82852. }
  82853. public function trimStart(string $chars = " \t\n\r\0\x0B\x0C"): parent
  82854. {
  82855. $str = clone $this;
  82856. $str->string = ltrim($str->string, $chars);
  82857. return $str;
  82858. }
  82859. public function upper(): parent
  82860. {
  82861. $str = clone $this;
  82862. $str->string = strtoupper($str->string);
  82863. return $str;
  82864. }
  82865. public function width(bool $ignoreAnsiDecoration = true): int
  82866. {
  82867. $string = preg_match('//u', $this->string) ? $this->string : preg_replace('/[\x80-\xFF]/', '?', $this->string);
  82868. return (new CodePointString($string))->width($ignoreAnsiDecoration);
  82869. }
  82870. }
  82871. <?php
  82872. namespace Symfony\Component\String;
  82873. use Symfony\Component\String\Exception\ExceptionInterface;
  82874. use Symfony\Component\String\Exception\InvalidArgumentException;
  82875. class CodePointString extends AbstractUnicodeString
  82876. {
  82877. public function __construct(string $string = '')
  82878. {
  82879. if ('' !== $string && !preg_match('//u', $string)) {
  82880. throw new InvalidArgumentException('Invalid UTF-8 string.');
  82881. }
  82882. $this->string = $string;
  82883. }
  82884. public function append(string ...$suffix): AbstractString
  82885. {
  82886. $str = clone $this;
  82887. $str->string .= 1 >= \count($suffix) ? ($suffix[0] ?? '') : implode('', $suffix);
  82888. if (!preg_match('//u', $str->string)) {
  82889. throw new InvalidArgumentException('Invalid UTF-8 string.');
  82890. }
  82891. return $str;
  82892. }
  82893. public function chunk(int $length = 1): array
  82894. {
  82895. if (1 > $length) {
  82896. throw new InvalidArgumentException('The chunk length must be greater than zero.');
  82897. }
  82898. if ('' === $this->string) {
  82899. return [];
  82900. }
  82901. $rx = '/(';
  82902. while (65535 < $length) {
  82903. $rx .= '.{65535}';
  82904. $length -= 65535;
  82905. }
  82906. $rx .= '.{'.$length.'})/us';
  82907. $str = clone $this;
  82908. $chunks = [];
  82909. foreach (preg_split($rx, $this->string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY) as $chunk) {
  82910. $str->string = $chunk;
  82911. $chunks[] = clone $str;
  82912. }
  82913. return $chunks;
  82914. }
  82915. public function codePointsAt(int $offset): array
  82916. {
  82917. $str = $offset ? $this->slice($offset, 1) : $this;
  82918. return '' === $str->string ? [] : [mb_ord($str->string, 'UTF-8')];
  82919. }
  82920. public function endsWith($suffix): bool
  82921. {
  82922. if ($suffix instanceof AbstractString) {
  82923. $suffix = $suffix->string;
  82924. } elseif (\is_array($suffix) || $suffix instanceof \Traversable) {
  82925. return parent::endsWith($suffix);
  82926. } else {
  82927. $suffix = (string) $suffix;
  82928. }
  82929. if ('' === $suffix || !preg_match('//u', $suffix)) {
  82930. return false;
  82931. }
  82932. if ($this->ignoreCase) {
  82933. return preg_match('{'.preg_quote($suffix).'$}iuD', $this->string);
  82934. }
  82935. return \strlen($this->string) >= \strlen($suffix) && 0 === substr_compare($this->string, $suffix, -\strlen($suffix));
  82936. }
  82937. public function equalsTo($string): bool
  82938. {
  82939. if ($string instanceof AbstractString) {
  82940. $string = $string->string;
  82941. } elseif (\is_array($string) || $string instanceof \Traversable) {
  82942. return parent::equalsTo($string);
  82943. } else {
  82944. $string = (string) $string;
  82945. }
  82946. if ('' !== $string && $this->ignoreCase) {
  82947. return \strlen($string) === \strlen($this->string) && 0 === mb_stripos($this->string, $string, 0, 'UTF-8');
  82948. }
  82949. return $string === $this->string;
  82950. }
  82951. public function indexOf($needle, int $offset = 0): ?int
  82952. {
  82953. if ($needle instanceof AbstractString) {
  82954. $needle = $needle->string;
  82955. } elseif (\is_array($needle) || $needle instanceof \Traversable) {
  82956. return parent::indexOf($needle, $offset);
  82957. } else {
  82958. $needle = (string) $needle;
  82959. }
  82960. if ('' === $needle) {
  82961. return null;
  82962. }
  82963. $i = $this->ignoreCase ? mb_stripos($this->string, $needle, $offset, 'UTF-8') : mb_strpos($this->string, $needle, $offset, 'UTF-8');
  82964. return false === $i ? null : $i;
  82965. }
  82966. public function indexOfLast($needle, int $offset = 0): ?int
  82967. {
  82968. if ($needle instanceof AbstractString) {
  82969. $needle = $needle->string;
  82970. } elseif (\is_array($needle) || $needle instanceof \Traversable) {
  82971. return parent::indexOfLast($needle, $offset);
  82972. } else {
  82973. $needle = (string) $needle;
  82974. }
  82975. if ('' === $needle) {
  82976. return null;
  82977. }
  82978. $i = $this->ignoreCase ? mb_strripos($this->string, $needle, $offset, 'UTF-8') : mb_strrpos($this->string, $needle, $offset, 'UTF-8');
  82979. return false === $i ? null : $i;
  82980. }
  82981. public function length(): int
  82982. {
  82983. return mb_strlen($this->string, 'UTF-8');
  82984. }
  82985. public function prepend(string ...$prefix): AbstractString
  82986. {
  82987. $str = clone $this;
  82988. $str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$this->string;
  82989. if (!preg_match('//u', $str->string)) {
  82990. throw new InvalidArgumentException('Invalid UTF-8 string.');
  82991. }
  82992. return $str;
  82993. }
  82994. public function replace(string $from, string $to): AbstractString
  82995. {
  82996. $str = clone $this;
  82997. if ('' === $from || !preg_match('//u', $from)) {
  82998. return $str;
  82999. }
  83000. if ('' !== $to && !preg_match('//u', $to)) {
  83001. throw new InvalidArgumentException('Invalid UTF-8 string.');
  83002. }
  83003. if ($this->ignoreCase) {
  83004. $str->string = implode($to, preg_split('{'.preg_quote($from).'}iuD', $this->string));
  83005. } else {
  83006. $str->string = str_replace($from, $to, $this->string);
  83007. }
  83008. return $str;
  83009. }
  83010. public function slice(int $start = 0, int $length = null): AbstractString
  83011. {
  83012. $str = clone $this;
  83013. $str->string = mb_substr($this->string, $start, $length, 'UTF-8');
  83014. return $str;
  83015. }
  83016. public function splice(string $replacement, int $start = 0, int $length = null): AbstractString
  83017. {
  83018. if (!preg_match('//u', $replacement)) {
  83019. throw new InvalidArgumentException('Invalid UTF-8 string.');
  83020. }
  83021. $str = clone $this;
  83022. $start = $start ? \strlen(mb_substr($this->string, 0, $start, 'UTF-8')) : 0;
  83023. $length = $length ? \strlen(mb_substr($this->string, $start, $length, 'UTF-8')) : $length;
  83024. $str->string = substr_replace($this->string, $replacement, $start, $length ?? \PHP_INT_MAX);
  83025. return $str;
  83026. }
  83027. public function split(string $delimiter, int $limit = null, int $flags = null): array
  83028. {
  83029. if (1 > $limit = $limit ?? \PHP_INT_MAX) {
  83030. throw new InvalidArgumentException('Split limit must be a positive integer.');
  83031. }
  83032. if ('' === $delimiter) {
  83033. throw new InvalidArgumentException('Split delimiter is empty.');
  83034. }
  83035. if (null !== $flags) {
  83036. return parent::split($delimiter.'u', $limit, $flags);
  83037. }
  83038. if (!preg_match('//u', $delimiter)) {
  83039. throw new InvalidArgumentException('Split delimiter is not a valid UTF-8 string.');
  83040. }
  83041. $str = clone $this;
  83042. $chunks = $this->ignoreCase
  83043. ? preg_split('{'.preg_quote($delimiter).'}iuD', $this->string, $limit)
  83044. : explode($delimiter, $this->string, $limit);
  83045. foreach ($chunks as &$chunk) {
  83046. $str->string = $chunk;
  83047. $chunk = clone $str;
  83048. }
  83049. return $chunks;
  83050. }
  83051. public function startsWith($prefix): bool
  83052. {
  83053. if ($prefix instanceof AbstractString) {
  83054. $prefix = $prefix->string;
  83055. } elseif (\is_array($prefix) || $prefix instanceof \Traversable) {
  83056. return parent::startsWith($prefix);
  83057. } else {
  83058. $prefix = (string) $prefix;
  83059. }
  83060. if ('' === $prefix || !preg_match('//u', $prefix)) {
  83061. return false;
  83062. }
  83063. if ($this->ignoreCase) {
  83064. return 0 === mb_stripos($this->string, $prefix, 0, 'UTF-8');
  83065. }
  83066. return 0 === strncmp($this->string, $prefix, \strlen($prefix));
  83067. }
  83068. }
  83069. <?php
  83070. namespace Symfony\Component\String\Exception;
  83071. interface ExceptionInterface extends \Throwable
  83072. {
  83073. }
  83074. <?php
  83075. namespace Symfony\Component\String\Exception;
  83076. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  83077. {
  83078. }
  83079. <?php
  83080. namespace Symfony\Component\String\Exception;
  83081. class RuntimeException extends \RuntimeException implements ExceptionInterface
  83082. {
  83083. }
  83084. <?php
  83085. namespace Symfony\Component\String\Inflector;
  83086. final class EnglishInflector implements InflectorInterface
  83087. {
  83088. private const PLURAL_MAP = [
  83089. ['a', 1, true, true, ['on', 'um']],
  83090. ['ea', 2, true, true, 'a'],
  83091. ['secivres', 8, true, true, 'service'],
  83092. ['eci', 3, false, true, 'ouse'],
  83093. ['esee', 4, false, true, 'oose'],
  83094. ['i', 1, true, true, 'us'],
  83095. ['nem', 3, true, true, 'man'],
  83096. ['nerdlihc', 8, true, true, 'child'],
  83097. ['nexo', 4, false, false, 'ox'],
  83098. ['seci', 4, false, true, ['ex', 'ix', 'ice']],
  83099. ['sedoc', 5, false, true, 'code'],
  83100. ['seifles', 7, true, true, 'selfie'],
  83101. ['seibmoz', 7, true, true, 'zombie'],
  83102. ['seivom', 6, true, true, 'movie'],
  83103. ['seman', 5, true, false, 'name'],
  83104. ['sesutcep', 8, true, true, 'pectus'],
  83105. ['teef', 4, true, true, 'foot'],
  83106. ['eseeg', 5, true, true, 'goose'],
  83107. ['hteet', 5, true, true, 'tooth'],
  83108. ['swen', 4, true, true, 'news'],
  83109. ['seires', 6, true, true, 'series'],
  83110. ['sei', 3, false, true, 'y'],
  83111. ['sess', 4, true, false, 'ss'],
  83112. ['sesutats', 8, true, true, 'status'],
  83113. ['ses', 3, true, true, ['s', 'se', 'sis']],
  83114. ['sevit', 5, true, true, 'tive'],
  83115. ['sevird', 6, false, true, 'drive'],
  83116. ['sevi', 4, false, true, 'ife'],
  83117. ['sevom', 5, true, true, 'move'],
  83118. ['sev', 3, true, true, ['f', 've', 'ff']],
  83119. ['sexa', 4, false, false, ['ax', 'axe', 'axis']],
  83120. ['sex', 3, true, false, 'x'],
  83121. ['sezz', 4, true, false, 'z'],
  83122. ['suae', 4, false, true, 'eau'],
  83123. ['see', 3, true, true, 'ee'],
  83124. ['segd', 4, true, true, 'dge'],
  83125. ['se', 2, true, true, ['', 'e']],
  83126. ['sutats', 6, true, true, 'status'],
  83127. ['s', 1, true, true, ''],
  83128. ['xuae', 4, false, true, 'eau'],
  83129. ['elpoep', 6, true, true, 'person'],
  83130. ];
  83131. private const SINGULAR_MAP = [
  83132. ['airetirc', 8, false, false, 'criterion'],
  83133. ['aluben', 6, false, false, 'nebulae'],
  83134. ['dlihc', 5, true, true, 'children'],
  83135. ['eci', 3, false, true, 'ices'],
  83136. ['ecivres', 7, true, true, 'services'],
  83137. ['efi', 3, false, true, 'ives'],
  83138. ['eifles', 6, true, true, 'selfies'],
  83139. ['eivom', 5, true, true, 'movies'],
  83140. ['esuol', 5, false, true, 'lice'],
  83141. ['esuom', 5, false, true, 'mice'],
  83142. ['esoo', 4, false, true, 'eese'],
  83143. ['es', 2, true, true, 'ses'],
  83144. ['esoog', 5, true, true, 'geese'],
  83145. ['ev', 2, true, true, 'ves'],
  83146. ['evird', 5, false, true, 'drives'],
  83147. ['evit', 4, true, true, 'tives'],
  83148. ['evom', 4, true, true, 'moves'],
  83149. ['ffats', 5, true, true, 'staves'],
  83150. ['ff', 2, true, true, 'ffs'],
  83151. ['f', 1, true, true, ['fs', 'ves']],
  83152. ['hc', 2, true, true, 'ches'],
  83153. ['hs', 2, true, true, 'shes'],
  83154. ['htoot', 5, true, true, 'teeth'],
  83155. ['mu', 2, true, true, 'a'],
  83156. ['nam', 3, true, true, 'men'],
  83157. ['nosrep', 6, true, true, ['persons', 'people']],
  83158. ['noi', 3, true, true, 'ions'],
  83159. ['nop', 3, true, true, 'pons'],
  83160. ['nos', 3, true, true, 'sons'],
  83161. ['no', 2, true, true, 'a'],
  83162. ['ohce', 4, true, true, 'echoes'],
  83163. ['oreh', 4, true, true, 'heroes'],
  83164. ['salta', 5, true, true, 'atlases'],
  83165. ['siri', 4, true, true, 'irises'],
  83166. ['sis', 3, true, true, 'ses'],
  83167. ['ss', 2, true, false, 'sses'],
  83168. ['suballys', 8, true, true, 'syllabi'],
  83169. ['sub', 3, true, true, 'buses'],
  83170. ['suc', 3, true, true, 'cuses'],
  83171. ['sutats', 6, true, true, ['status', 'statuses']],
  83172. ['sutcep', 6, true, true, 'pectuses'],
  83173. ['su', 2, true, true, 'i'],
  83174. ['swen', 4, true, true, 'news'],
  83175. ['toof', 4, true, true, 'feet'],
  83176. ['uae', 3, false, true, ['eaus', 'eaux']],
  83177. ['xo', 2, false, false, 'oxen'],
  83178. ['xaoh', 4, true, false, 'hoaxes'],
  83179. ['xedni', 5, false, true, ['indicies', 'indexes']],
  83180. ['xo', 2, false, true, 'oxes'],
  83181. ['x', 1, true, false, ['cies', 'xes']],
  83182. ['xi', 2, false, true, 'ices'],
  83183. ['y', 1, false, true, 'ies'],
  83184. ['ziuq', 4, true, false, 'quizzes'],
  83185. ['z', 1, true, true, 'zes'],
  83186. ];
  83187. private const UNINFLECTED = [
  83188. '',
  83189. 'atad',
  83190. 'reed',
  83191. 'kcabdeef',
  83192. 'hsif',
  83193. 'ofni',
  83194. 'esoom',
  83195. 'seires',
  83196. 'peehs',
  83197. 'seiceps',
  83198. ];
  83199. public function singularize(string $plural): array
  83200. {
  83201. $pluralRev = strrev($plural);
  83202. $lowerPluralRev = strtolower($pluralRev);
  83203. $pluralLength = \strlen($lowerPluralRev);
  83204. if (\in_array($lowerPluralRev, self::UNINFLECTED, true)) {
  83205. return [$plural];
  83206. }
  83207. foreach (self::PLURAL_MAP as $map) {
  83208. $suffix = $map[0];
  83209. $suffixLength = $map[1];
  83210. $j = 0;
  83211. while ($suffix[$j] === $lowerPluralRev[$j]) {
  83212. ++$j;
  83213. if ($j === $suffixLength) {
  83214. if ($j < $pluralLength) {
  83215. $nextIsVocal = false !== strpos('aeiou', $lowerPluralRev[$j]);
  83216. if (!$map[2] && $nextIsVocal) {
  83217. break;
  83218. }
  83219. if (!$map[3] && !$nextIsVocal) {
  83220. break;
  83221. }
  83222. }
  83223. $newBase = substr($plural, 0, $pluralLength - $suffixLength);
  83224. $newSuffix = $map[4];
  83225. $firstUpper = ctype_upper($pluralRev[$j - 1]);
  83226. if (\is_array($newSuffix)) {
  83227. $singulars = [];
  83228. foreach ($newSuffix as $newSuffixEntry) {
  83229. $singulars[] = $newBase.($firstUpper ? ucfirst($newSuffixEntry) : $newSuffixEntry);
  83230. }
  83231. return $singulars;
  83232. }
  83233. return [$newBase.($firstUpper ? ucfirst($newSuffix) : $newSuffix)];
  83234. }
  83235. if ($j === $pluralLength) {
  83236. break;
  83237. }
  83238. }
  83239. }
  83240. return [$plural];
  83241. }
  83242. public function pluralize(string $singular): array
  83243. {
  83244. $singularRev = strrev($singular);
  83245. $lowerSingularRev = strtolower($singularRev);
  83246. $singularLength = \strlen($lowerSingularRev);
  83247. if (\in_array($lowerSingularRev, self::UNINFLECTED, true)) {
  83248. return [$singular];
  83249. }
  83250. foreach (self::SINGULAR_MAP as $map) {
  83251. $suffix = $map[0];
  83252. $suffixLength = $map[1];
  83253. $j = 0;
  83254. while ($suffix[$j] === $lowerSingularRev[$j]) {
  83255. ++$j;
  83256. if ($j === $suffixLength) {
  83257. if ($j < $singularLength) {
  83258. $nextIsVocal = false !== strpos('aeiou', $lowerSingularRev[$j]);
  83259. if (!$map[2] && $nextIsVocal) {
  83260. break;
  83261. }
  83262. if (!$map[3] && !$nextIsVocal) {
  83263. break;
  83264. }
  83265. }
  83266. $newBase = substr($singular, 0, $singularLength - $suffixLength);
  83267. $newSuffix = $map[4];
  83268. $firstUpper = ctype_upper($singularRev[$j - 1]);
  83269. if (\is_array($newSuffix)) {
  83270. $plurals = [];
  83271. foreach ($newSuffix as $newSuffixEntry) {
  83272. $plurals[] = $newBase.($firstUpper ? ucfirst($newSuffixEntry) : $newSuffixEntry);
  83273. }
  83274. return $plurals;
  83275. }
  83276. return [$newBase.($firstUpper ? ucfirst($newSuffix) : $newSuffix)];
  83277. }
  83278. if ($j === $singularLength) {
  83279. break;
  83280. }
  83281. }
  83282. }
  83283. return [$singular.'s'];
  83284. }
  83285. }
  83286. <?php
  83287. namespace Symfony\Component\String\Inflector;
  83288. final class FrenchInflector implements InflectorInterface
  83289. {
  83290. private const PLURALIZE_REGEXP = [
  83291. ['/(s|x|z)$/i', '\1'],
  83292. ['/(eau)$/i', '\1x'],
  83293. ['/^(landau)$/i', '\1s'],
  83294. ['/(au)$/i', '\1x'],
  83295. ['/^(pneu|bleu|émeu)$/i', '\1s'],
  83296. ['/(eu)$/i', '\1x'],
  83297. ['/^(bal|carnaval|caracal|chacal|choral|corral|étal|festival|récital|val)$/i', '\1s'],
  83298. ['/al$/i', '\1aux'],
  83299. ['/^(aspir|b|cor|ém|ferm|soupir|trav|vant|vitr)ail$/i', '\1aux'],
  83300. ['/^(bij|caill|ch|gen|hib|jouj|p)ou$/i', '\1oux'],
  83301. ['/^(cinquante|soixante|mille)$/i', '\1'],
  83302. ['/^(mon|ma)(sieur|dame|demoiselle|seigneur)$/', 'mes\2s'],
  83303. ['/^(Mon|Ma)(sieur|dame|demoiselle|seigneur)$/', 'Mes\2s'],
  83304. ];
  83305. private const SINGULARIZE_REGEXP = [
  83306. ['/((aspir|b|cor|ém|ferm|soupir|trav|vant|vitr))aux$/i', '\1ail'],
  83307. ['/(eau)x$/i', '\1'],
  83308. ['/(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'],
  83309. ['/(au)x$/i', '\1'],
  83310. ['/(eu)x$/i', '\1'],
  83311. ['/(bij|caill|ch|gen|hib|jouj|p)oux$/i', '\1ou'],
  83312. ['/^mes(dame|demoiselle)s$/', 'ma\1'],
  83313. ['/^Mes(dame|demoiselle)s$/', 'Ma\1'],
  83314. ['/^mes(sieur|seigneur)s$/', 'mon\1'],
  83315. ['/^Mes(sieur|seigneur)s$/', 'Mon\1'],
  83316. ['/s$/i', ''],
  83317. ];
  83318. 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|sans|sas|secours|sens|souris|succès|talus|tapis|tas|taudis|temps|tiers|univers|velours|verglas|vernis|virus)$/i';
  83319. public function singularize(string $plural): array
  83320. {
  83321. if ($this->isInflectedWord($plural)) {
  83322. return [$plural];
  83323. }
  83324. foreach (self::SINGULARIZE_REGEXP as $rule) {
  83325. [$regexp, $replace] = $rule;
  83326. if (1 === preg_match($regexp, $plural)) {
  83327. return [preg_replace($regexp, $replace, $plural)];
  83328. }
  83329. }
  83330. return [$plural];
  83331. }
  83332. public function pluralize(string $singular): array
  83333. {
  83334. if ($this->isInflectedWord($singular)) {
  83335. return [$singular];
  83336. }
  83337. foreach (self::PLURALIZE_REGEXP as $rule) {
  83338. [$regexp, $replace] = $rule;
  83339. if (1 === preg_match($regexp, $singular)) {
  83340. return [preg_replace($regexp, $replace, $singular)];
  83341. }
  83342. }
  83343. return [$singular.'s'];
  83344. }
  83345. private function isInflectedWord(string $word): bool
  83346. {
  83347. return 1 === preg_match(self::UNINFLECTED, $word);
  83348. }
  83349. }
  83350. <?php
  83351. namespace Symfony\Component\String\Inflector;
  83352. interface InflectorInterface
  83353. {
  83354. public function singularize(string $plural): array;
  83355. public function pluralize(string $singular): array;
  83356. }
  83357. Copyright (c) 2019-present Fabien Potencier
  83358. Permission is hereby granted, free of charge, to any person obtaining a copy
  83359. of this software and associated documentation files (the "Software"), to deal
  83360. in the Software without restriction, including without limitation the rights
  83361. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  83362. copies of the Software, and to permit persons to whom the Software is furnished
  83363. to do so, subject to the following conditions:
  83364. The above copyright notice and this permission notice shall be included in all
  83365. copies or substantial portions of the Software.
  83366. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  83367. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  83368. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  83369. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  83370. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  83371. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  83372. THE SOFTWARE.
  83373. <?php
  83374. namespace Symfony\Component\String;
  83375. class LazyString implements \Stringable, \JsonSerializable
  83376. {
  83377. private $value;
  83378. public static function fromCallable($callback, ...$arguments): self
  83379. {
  83380. if (!\is_callable($callback) && !(\is_array($callback) && isset($callback[0]) && $callback[0] instanceof \Closure && 2 >= \count($callback))) {
  83381. 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)));
  83382. }
  83383. $lazyString = new static();
  83384. $lazyString->value = static function () use (&$callback, &$arguments, &$value): string {
  83385. if (null !== $arguments) {
  83386. if (!\is_callable($callback)) {
  83387. $callback[0] = $callback[0]();
  83388. $callback[1] = $callback[1] ?? '__invoke';
  83389. }
  83390. $value = $callback(...$arguments);
  83391. $callback = self::getPrettyName($callback);
  83392. $arguments = null;
  83393. }
  83394. return $value ?? '';
  83395. };
  83396. return $lazyString;
  83397. }
  83398. public static function fromStringable($value): self
  83399. {
  83400. if (!self::isStringable($value)) {
  83401. throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a scalar or a stringable object, "%s" given.', __METHOD__, get_debug_type($value)));
  83402. }
  83403. if (\is_object($value)) {
  83404. return static::fromCallable([$value, '__toString']);
  83405. }
  83406. $lazyString = new static();
  83407. $lazyString->value = (string) $value;
  83408. return $lazyString;
  83409. }
  83410. final public static function isStringable($value): bool
  83411. {
  83412. return \is_string($value) || $value instanceof self || (\is_object($value) ? method_exists($value, '__toString') : \is_scalar($value));
  83413. }
  83414. final public static function resolve($value): string
  83415. {
  83416. return $value;
  83417. }
  83418. public function __toString()
  83419. {
  83420. if (\is_string($this->value)) {
  83421. return $this->value;
  83422. }
  83423. try {
  83424. return $this->value = ($this->value)();
  83425. } catch (\Throwable $e) {
  83426. if (\TypeError::class === \get_class($e) && __FILE__ === $e->getFile()) {
  83427. $type = explode(', ', $e->getMessage());
  83428. $type = substr(array_pop($type), 0, -\strlen(' returned'));
  83429. $r = new \ReflectionFunction($this->value);
  83430. $callback = $r->getStaticVariables()['callback'];
  83431. $e = new \TypeError(sprintf('Return value of %s() passed to %s::fromCallable() must be of the type string, %s returned.', $callback, static::class, $type));
  83432. }
  83433. if (\PHP_VERSION_ID < 70400) {
  83434. return trigger_error($e, \E_USER_ERROR);
  83435. }
  83436. throw $e;
  83437. }
  83438. }
  83439. public function __sleep(): array
  83440. {
  83441. $this->__toString();
  83442. return ['value'];
  83443. }
  83444. public function jsonSerialize(): string
  83445. {
  83446. return $this->__toString();
  83447. }
  83448. private function __construct()
  83449. {
  83450. }
  83451. private static function getPrettyName(callable $callback): string
  83452. {
  83453. if (\is_string($callback)) {
  83454. return $callback;
  83455. }
  83456. if (\is_array($callback)) {
  83457. $class = \is_object($callback[0]) ? get_debug_type($callback[0]) : $callback[0];
  83458. $method = $callback[1];
  83459. } elseif ($callback instanceof \Closure) {
  83460. $r = new \ReflectionFunction($callback);
  83461. if (false !== strpos($r->name, '{closure}') || !$class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {
  83462. return $r->name;
  83463. }
  83464. $class = $class->name;
  83465. $method = $r->name;
  83466. } else {
  83467. $class = get_debug_type($callback);
  83468. $method = '__invoke';
  83469. }
  83470. return $class.'::'.$method;
  83471. }
  83472. }
  83473. <?php
  83474. return [
  83475. [
  83476. 4352,
  83477. 4447,
  83478. ],
  83479. [
  83480. 8986,
  83481. 8987,
  83482. ],
  83483. [
  83484. 9001,
  83485. 9001,
  83486. ],
  83487. [
  83488. 9002,
  83489. 9002,
  83490. ],
  83491. [
  83492. 9193,
  83493. 9196,
  83494. ],
  83495. [
  83496. 9200,
  83497. 9200,
  83498. ],
  83499. [
  83500. 9203,
  83501. 9203,
  83502. ],
  83503. [
  83504. 9725,
  83505. 9726,
  83506. ],
  83507. [
  83508. 9748,
  83509. 9749,
  83510. ],
  83511. [
  83512. 9800,
  83513. 9811,
  83514. ],
  83515. [
  83516. 9855,
  83517. 9855,
  83518. ],
  83519. [
  83520. 9875,
  83521. 9875,
  83522. ],
  83523. [
  83524. 9889,
  83525. 9889,
  83526. ],
  83527. [
  83528. 9898,
  83529. 9899,
  83530. ],
  83531. [
  83532. 9917,
  83533. 9918,
  83534. ],
  83535. [
  83536. 9924,
  83537. 9925,
  83538. ],
  83539. [
  83540. 9934,
  83541. 9934,
  83542. ],
  83543. [
  83544. 9940,
  83545. 9940,
  83546. ],
  83547. [
  83548. 9962,
  83549. 9962,
  83550. ],
  83551. [
  83552. 9970,
  83553. 9971,
  83554. ],
  83555. [
  83556. 9973,
  83557. 9973,
  83558. ],
  83559. [
  83560. 9978,
  83561. 9978,
  83562. ],
  83563. [
  83564. 9981,
  83565. 9981,
  83566. ],
  83567. [
  83568. 9989,
  83569. 9989,
  83570. ],
  83571. [
  83572. 9994,
  83573. 9995,
  83574. ],
  83575. [
  83576. 10024,
  83577. 10024,
  83578. ],
  83579. [
  83580. 10060,
  83581. 10060,
  83582. ],
  83583. [
  83584. 10062,
  83585. 10062,
  83586. ],
  83587. [
  83588. 10067,
  83589. 10069,
  83590. ],
  83591. [
  83592. 10071,
  83593. 10071,
  83594. ],
  83595. [
  83596. 10133,
  83597. 10135,
  83598. ],
  83599. [
  83600. 10160,
  83601. 10160,
  83602. ],
  83603. [
  83604. 10175,
  83605. 10175,
  83606. ],
  83607. [
  83608. 11035,
  83609. 11036,
  83610. ],
  83611. [
  83612. 11088,
  83613. 11088,
  83614. ],
  83615. [
  83616. 11093,
  83617. 11093,
  83618. ],
  83619. [
  83620. 11904,
  83621. 11929,
  83622. ],
  83623. [
  83624. 11931,
  83625. 12019,
  83626. ],
  83627. [
  83628. 12032,
  83629. 12245,
  83630. ],
  83631. [
  83632. 12272,
  83633. 12287,
  83634. ],
  83635. [
  83636. 12288,
  83637. 12288,
  83638. ],
  83639. [
  83640. 12289,
  83641. 12291,
  83642. ],
  83643. [
  83644. 12292,
  83645. 12292,
  83646. ],
  83647. [
  83648. 12293,
  83649. 12293,
  83650. ],
  83651. [
  83652. 12294,
  83653. 12294,
  83654. ],
  83655. [
  83656. 12295,
  83657. 12295,
  83658. ],
  83659. [
  83660. 12296,
  83661. 12296,
  83662. ],
  83663. [
  83664. 12297,
  83665. 12297,
  83666. ],
  83667. [
  83668. 12298,
  83669. 12298,
  83670. ],
  83671. [
  83672. 12299,
  83673. 12299,
  83674. ],
  83675. [
  83676. 12300,
  83677. 12300,
  83678. ],
  83679. [
  83680. 12301,
  83681. 12301,
  83682. ],
  83683. [
  83684. 12302,
  83685. 12302,
  83686. ],
  83687. [
  83688. 12303,
  83689. 12303,
  83690. ],
  83691. [
  83692. 12304,
  83693. 12304,
  83694. ],
  83695. [
  83696. 12305,
  83697. 12305,
  83698. ],
  83699. [
  83700. 12306,
  83701. 12307,
  83702. ],
  83703. [
  83704. 12308,
  83705. 12308,
  83706. ],
  83707. [
  83708. 12309,
  83709. 12309,
  83710. ],
  83711. [
  83712. 12310,
  83713. 12310,
  83714. ],
  83715. [
  83716. 12311,
  83717. 12311,
  83718. ],
  83719. [
  83720. 12312,
  83721. 12312,
  83722. ],
  83723. [
  83724. 12313,
  83725. 12313,
  83726. ],
  83727. [
  83728. 12314,
  83729. 12314,
  83730. ],
  83731. [
  83732. 12315,
  83733. 12315,
  83734. ],
  83735. [
  83736. 12316,
  83737. 12316,
  83738. ],
  83739. [
  83740. 12317,
  83741. 12317,
  83742. ],
  83743. [
  83744. 12318,
  83745. 12319,
  83746. ],
  83747. [
  83748. 12320,
  83749. 12320,
  83750. ],
  83751. [
  83752. 12321,
  83753. 12329,
  83754. ],
  83755. [
  83756. 12330,
  83757. 12333,
  83758. ],
  83759. [
  83760. 12334,
  83761. 12335,
  83762. ],
  83763. [
  83764. 12336,
  83765. 12336,
  83766. ],
  83767. [
  83768. 12337,
  83769. 12341,
  83770. ],
  83771. [
  83772. 12342,
  83773. 12343,
  83774. ],
  83775. [
  83776. 12344,
  83777. 12346,
  83778. ],
  83779. [
  83780. 12347,
  83781. 12347,
  83782. ],
  83783. [
  83784. 12348,
  83785. 12348,
  83786. ],
  83787. [
  83788. 12349,
  83789. 12349,
  83790. ],
  83791. [
  83792. 12350,
  83793. 12350,
  83794. ],
  83795. [
  83796. 12353,
  83797. 12438,
  83798. ],
  83799. [
  83800. 12441,
  83801. 12442,
  83802. ],
  83803. [
  83804. 12443,
  83805. 12444,
  83806. ],
  83807. [
  83808. 12445,
  83809. 12446,
  83810. ],
  83811. [
  83812. 12447,
  83813. 12447,
  83814. ],
  83815. [
  83816. 12448,
  83817. 12448,
  83818. ],
  83819. [
  83820. 12449,
  83821. 12538,
  83822. ],
  83823. [
  83824. 12539,
  83825. 12539,
  83826. ],
  83827. [
  83828. 12540,
  83829. 12542,
  83830. ],
  83831. [
  83832. 12543,
  83833. 12543,
  83834. ],
  83835. [
  83836. 12549,
  83837. 12591,
  83838. ],
  83839. [
  83840. 12593,
  83841. 12686,
  83842. ],
  83843. [
  83844. 12688,
  83845. 12689,
  83846. ],
  83847. [
  83848. 12690,
  83849. 12693,
  83850. ],
  83851. [
  83852. 12694,
  83853. 12703,
  83854. ],
  83855. [
  83856. 12704,
  83857. 12735,
  83858. ],
  83859. [
  83860. 12736,
  83861. 12771,
  83862. ],
  83863. [
  83864. 12783,
  83865. 12783,
  83866. ],
  83867. [
  83868. 12784,
  83869. 12799,
  83870. ],
  83871. [
  83872. 12800,
  83873. 12830,
  83874. ],
  83875. [
  83876. 12832,
  83877. 12841,
  83878. ],
  83879. [
  83880. 12842,
  83881. 12871,
  83882. ],
  83883. [
  83884. 12880,
  83885. 12880,
  83886. ],
  83887. [
  83888. 12881,
  83889. 12895,
  83890. ],
  83891. [
  83892. 12896,
  83893. 12927,
  83894. ],
  83895. [
  83896. 12928,
  83897. 12937,
  83898. ],
  83899. [
  83900. 12938,
  83901. 12976,
  83902. ],
  83903. [
  83904. 12977,
  83905. 12991,
  83906. ],
  83907. [
  83908. 12992,
  83909. 13055,
  83910. ],
  83911. [
  83912. 13056,
  83913. 13311,
  83914. ],
  83915. [
  83916. 13312,
  83917. 19903,
  83918. ],
  83919. [
  83920. 19968,
  83921. 40959,
  83922. ],
  83923. [
  83924. 40960,
  83925. 40980,
  83926. ],
  83927. [
  83928. 40981,
  83929. 40981,
  83930. ],
  83931. [
  83932. 40982,
  83933. 42124,
  83934. ],
  83935. [
  83936. 42128,
  83937. 42182,
  83938. ],
  83939. [
  83940. 43360,
  83941. 43388,
  83942. ],
  83943. [
  83944. 44032,
  83945. 55203,
  83946. ],
  83947. [
  83948. 63744,
  83949. 64109,
  83950. ],
  83951. [
  83952. 64110,
  83953. 64111,
  83954. ],
  83955. [
  83956. 64112,
  83957. 64217,
  83958. ],
  83959. [
  83960. 64218,
  83961. 64255,
  83962. ],
  83963. [
  83964. 65040,
  83965. 65046,
  83966. ],
  83967. [
  83968. 65047,
  83969. 65047,
  83970. ],
  83971. [
  83972. 65048,
  83973. 65048,
  83974. ],
  83975. [
  83976. 65049,
  83977. 65049,
  83978. ],
  83979. [
  83980. 65072,
  83981. 65072,
  83982. ],
  83983. [
  83984. 65073,
  83985. 65074,
  83986. ],
  83987. [
  83988. 65075,
  83989. 65076,
  83990. ],
  83991. [
  83992. 65077,
  83993. 65077,
  83994. ],
  83995. [
  83996. 65078,
  83997. 65078,
  83998. ],
  83999. [
  84000. 65079,
  84001. 65079,
  84002. ],
  84003. [
  84004. 65080,
  84005. 65080,
  84006. ],
  84007. [
  84008. 65081,
  84009. 65081,
  84010. ],
  84011. [
  84012. 65082,
  84013. 65082,
  84014. ],
  84015. [
  84016. 65083,
  84017. 65083,
  84018. ],
  84019. [
  84020. 65084,
  84021. 65084,
  84022. ],
  84023. [
  84024. 65085,
  84025. 65085,
  84026. ],
  84027. [
  84028. 65086,
  84029. 65086,
  84030. ],
  84031. [
  84032. 65087,
  84033. 65087,
  84034. ],
  84035. [
  84036. 65088,
  84037. 65088,
  84038. ],
  84039. [
  84040. 65089,
  84041. 65089,
  84042. ],
  84043. [
  84044. 65090,
  84045. 65090,
  84046. ],
  84047. [
  84048. 65091,
  84049. 65091,
  84050. ],
  84051. [
  84052. 65092,
  84053. 65092,
  84054. ],
  84055. [
  84056. 65093,
  84057. 65094,
  84058. ],
  84059. [
  84060. 65095,
  84061. 65095,
  84062. ],
  84063. [
  84064. 65096,
  84065. 65096,
  84066. ],
  84067. [
  84068. 65097,
  84069. 65100,
  84070. ],
  84071. [
  84072. 65101,
  84073. 65103,
  84074. ],
  84075. [
  84076. 65104,
  84077. 65106,
  84078. ],
  84079. [
  84080. 65108,
  84081. 65111,
  84082. ],
  84083. [
  84084. 65112,
  84085. 65112,
  84086. ],
  84087. [
  84088. 65113,
  84089. 65113,
  84090. ],
  84091. [
  84092. 65114,
  84093. 65114,
  84094. ],
  84095. [
  84096. 65115,
  84097. 65115,
  84098. ],
  84099. [
  84100. 65116,
  84101. 65116,
  84102. ],
  84103. [
  84104. 65117,
  84105. 65117,
  84106. ],
  84107. [
  84108. 65118,
  84109. 65118,
  84110. ],
  84111. [
  84112. 65119,
  84113. 65121,
  84114. ],
  84115. [
  84116. 65122,
  84117. 65122,
  84118. ],
  84119. [
  84120. 65123,
  84121. 65123,
  84122. ],
  84123. [
  84124. 65124,
  84125. 65126,
  84126. ],
  84127. [
  84128. 65128,
  84129. 65128,
  84130. ],
  84131. [
  84132. 65129,
  84133. 65129,
  84134. ],
  84135. [
  84136. 65130,
  84137. 65131,
  84138. ],
  84139. [
  84140. 65281,
  84141. 65283,
  84142. ],
  84143. [
  84144. 65284,
  84145. 65284,
  84146. ],
  84147. [
  84148. 65285,
  84149. 65287,
  84150. ],
  84151. [
  84152. 65288,
  84153. 65288,
  84154. ],
  84155. [
  84156. 65289,
  84157. 65289,
  84158. ],
  84159. [
  84160. 65290,
  84161. 65290,
  84162. ],
  84163. [
  84164. 65291,
  84165. 65291,
  84166. ],
  84167. [
  84168. 65292,
  84169. 65292,
  84170. ],
  84171. [
  84172. 65293,
  84173. 65293,
  84174. ],
  84175. [
  84176. 65294,
  84177. 65295,
  84178. ],
  84179. [
  84180. 65296,
  84181. 65305,
  84182. ],
  84183. [
  84184. 65306,
  84185. 65307,
  84186. ],
  84187. [
  84188. 65308,
  84189. 65310,
  84190. ],
  84191. [
  84192. 65311,
  84193. 65312,
  84194. ],
  84195. [
  84196. 65313,
  84197. 65338,
  84198. ],
  84199. [
  84200. 65339,
  84201. 65339,
  84202. ],
  84203. [
  84204. 65340,
  84205. 65340,
  84206. ],
  84207. [
  84208. 65341,
  84209. 65341,
  84210. ],
  84211. [
  84212. 65342,
  84213. 65342,
  84214. ],
  84215. [
  84216. 65343,
  84217. 65343,
  84218. ],
  84219. [
  84220. 65344,
  84221. 65344,
  84222. ],
  84223. [
  84224. 65345,
  84225. 65370,
  84226. ],
  84227. [
  84228. 65371,
  84229. 65371,
  84230. ],
  84231. [
  84232. 65372,
  84233. 65372,
  84234. ],
  84235. [
  84236. 65373,
  84237. 65373,
  84238. ],
  84239. [
  84240. 65374,
  84241. 65374,
  84242. ],
  84243. [
  84244. 65375,
  84245. 65375,
  84246. ],
  84247. [
  84248. 65376,
  84249. 65376,
  84250. ],
  84251. [
  84252. 65504,
  84253. 65505,
  84254. ],
  84255. [
  84256. 65506,
  84257. 65506,
  84258. ],
  84259. [
  84260. 65507,
  84261. 65507,
  84262. ],
  84263. [
  84264. 65508,
  84265. 65508,
  84266. ],
  84267. [
  84268. 65509,
  84269. 65510,
  84270. ],
  84271. [
  84272. 94176,
  84273. 94177,
  84274. ],
  84275. [
  84276. 94178,
  84277. 94178,
  84278. ],
  84279. [
  84280. 94179,
  84281. 94179,
  84282. ],
  84283. [
  84284. 94180,
  84285. 94180,
  84286. ],
  84287. [
  84288. 94192,
  84289. 94193,
  84290. ],
  84291. [
  84292. 94208,
  84293. 100343,
  84294. ],
  84295. [
  84296. 100352,
  84297. 101119,
  84298. ],
  84299. [
  84300. 101120,
  84301. 101589,
  84302. ],
  84303. [
  84304. 101632,
  84305. 101640,
  84306. ],
  84307. [
  84308. 110576,
  84309. 110579,
  84310. ],
  84311. [
  84312. 110581,
  84313. 110587,
  84314. ],
  84315. [
  84316. 110589,
  84317. 110590,
  84318. ],
  84319. [
  84320. 110592,
  84321. 110847,
  84322. ],
  84323. [
  84324. 110848,
  84325. 110882,
  84326. ],
  84327. [
  84328. 110898,
  84329. 110898,
  84330. ],
  84331. [
  84332. 110928,
  84333. 110930,
  84334. ],
  84335. [
  84336. 110933,
  84337. 110933,
  84338. ],
  84339. [
  84340. 110948,
  84341. 110951,
  84342. ],
  84343. [
  84344. 110960,
  84345. 111355,
  84346. ],
  84347. [
  84348. 126980,
  84349. 126980,
  84350. ],
  84351. [
  84352. 127183,
  84353. 127183,
  84354. ],
  84355. [
  84356. 127374,
  84357. 127374,
  84358. ],
  84359. [
  84360. 127377,
  84361. 127386,
  84362. ],
  84363. [
  84364. 127488,
  84365. 127490,
  84366. ],
  84367. [
  84368. 127504,
  84369. 127547,
  84370. ],
  84371. [
  84372. 127552,
  84373. 127560,
  84374. ],
  84375. [
  84376. 127568,
  84377. 127569,
  84378. ],
  84379. [
  84380. 127584,
  84381. 127589,
  84382. ],
  84383. [
  84384. 127744,
  84385. 127776,
  84386. ],
  84387. [
  84388. 127789,
  84389. 127797,
  84390. ],
  84391. [
  84392. 127799,
  84393. 127868,
  84394. ],
  84395. [
  84396. 127870,
  84397. 127891,
  84398. ],
  84399. [
  84400. 127904,
  84401. 127946,
  84402. ],
  84403. [
  84404. 127951,
  84405. 127955,
  84406. ],
  84407. [
  84408. 127968,
  84409. 127984,
  84410. ],
  84411. [
  84412. 127988,
  84413. 127988,
  84414. ],
  84415. [
  84416. 127992,
  84417. 127994,
  84418. ],
  84419. [
  84420. 127995,
  84421. 127999,
  84422. ],
  84423. [
  84424. 128000,
  84425. 128062,
  84426. ],
  84427. [
  84428. 128064,
  84429. 128064,
  84430. ],
  84431. [
  84432. 128066,
  84433. 128252,
  84434. ],
  84435. [
  84436. 128255,
  84437. 128317,
  84438. ],
  84439. [
  84440. 128331,
  84441. 128334,
  84442. ],
  84443. [
  84444. 128336,
  84445. 128359,
  84446. ],
  84447. [
  84448. 128378,
  84449. 128378,
  84450. ],
  84451. [
  84452. 128405,
  84453. 128406,
  84454. ],
  84455. [
  84456. 128420,
  84457. 128420,
  84458. ],
  84459. [
  84460. 128507,
  84461. 128511,
  84462. ],
  84463. [
  84464. 128512,
  84465. 128591,
  84466. ],
  84467. [
  84468. 128640,
  84469. 128709,
  84470. ],
  84471. [
  84472. 128716,
  84473. 128716,
  84474. ],
  84475. [
  84476. 128720,
  84477. 128722,
  84478. ],
  84479. [
  84480. 128725,
  84481. 128727,
  84482. ],
  84483. [
  84484. 128732,
  84485. 128735,
  84486. ],
  84487. [
  84488. 128747,
  84489. 128748,
  84490. ],
  84491. [
  84492. 128756,
  84493. 128764,
  84494. ],
  84495. [
  84496. 128992,
  84497. 129003,
  84498. ],
  84499. [
  84500. 129008,
  84501. 129008,
  84502. ],
  84503. [
  84504. 129292,
  84505. 129338,
  84506. ],
  84507. [
  84508. 129340,
  84509. 129349,
  84510. ],
  84511. [
  84512. 129351,
  84513. 129535,
  84514. ],
  84515. [
  84516. 129648,
  84517. 129660,
  84518. ],
  84519. [
  84520. 129664,
  84521. 129672,
  84522. ],
  84523. [
  84524. 129680,
  84525. 129725,
  84526. ],
  84527. [
  84528. 129727,
  84529. 129733,
  84530. ],
  84531. [
  84532. 129742,
  84533. 129755,
  84534. ],
  84535. [
  84536. 129760,
  84537. 129768,
  84538. ],
  84539. [
  84540. 129776,
  84541. 129784,
  84542. ],
  84543. [
  84544. 131072,
  84545. 173791,
  84546. ],
  84547. [
  84548. 173792,
  84549. 173823,
  84550. ],
  84551. [
  84552. 173824,
  84553. 177977,
  84554. ],
  84555. [
  84556. 177978,
  84557. 177983,
  84558. ],
  84559. [
  84560. 177984,
  84561. 178205,
  84562. ],
  84563. [
  84564. 178206,
  84565. 178207,
  84566. ],
  84567. [
  84568. 178208,
  84569. 183969,
  84570. ],
  84571. [
  84572. 183970,
  84573. 183983,
  84574. ],
  84575. [
  84576. 183984,
  84577. 191456,
  84578. ],
  84579. [
  84580. 191457,
  84581. 191471,
  84582. ],
  84583. [
  84584. 191472,
  84585. 192093,
  84586. ],
  84587. [
  84588. 192094,
  84589. 194559,
  84590. ],
  84591. [
  84592. 194560,
  84593. 195101,
  84594. ],
  84595. [
  84596. 195102,
  84597. 195103,
  84598. ],
  84599. [
  84600. 195104,
  84601. 196605,
  84602. ],
  84603. [
  84604. 196608,
  84605. 201546,
  84606. ],
  84607. [
  84608. 201547,
  84609. 201551,
  84610. ],
  84611. [
  84612. 201552,
  84613. 205743,
  84614. ],
  84615. [
  84616. 205744,
  84617. 262141,
  84618. ],
  84619. ];
  84620. <?php
  84621. return [
  84622. [
  84623. 768,
  84624. 879,
  84625. ],
  84626. [
  84627. 1155,
  84628. 1159,
  84629. ],
  84630. [
  84631. 1160,
  84632. 1161,
  84633. ],
  84634. [
  84635. 1425,
  84636. 1469,
  84637. ],
  84638. [
  84639. 1471,
  84640. 1471,
  84641. ],
  84642. [
  84643. 1473,
  84644. 1474,
  84645. ],
  84646. [
  84647. 1476,
  84648. 1477,
  84649. ],
  84650. [
  84651. 1479,
  84652. 1479,
  84653. ],
  84654. [
  84655. 1552,
  84656. 1562,
  84657. ],
  84658. [
  84659. 1611,
  84660. 1631,
  84661. ],
  84662. [
  84663. 1648,
  84664. 1648,
  84665. ],
  84666. [
  84667. 1750,
  84668. 1756,
  84669. ],
  84670. [
  84671. 1759,
  84672. 1764,
  84673. ],
  84674. [
  84675. 1767,
  84676. 1768,
  84677. ],
  84678. [
  84679. 1770,
  84680. 1773,
  84681. ],
  84682. [
  84683. 1809,
  84684. 1809,
  84685. ],
  84686. [
  84687. 1840,
  84688. 1866,
  84689. ],
  84690. [
  84691. 1958,
  84692. 1968,
  84693. ],
  84694. [
  84695. 2027,
  84696. 2035,
  84697. ],
  84698. [
  84699. 2045,
  84700. 2045,
  84701. ],
  84702. [
  84703. 2070,
  84704. 2073,
  84705. ],
  84706. [
  84707. 2075,
  84708. 2083,
  84709. ],
  84710. [
  84711. 2085,
  84712. 2087,
  84713. ],
  84714. [
  84715. 2089,
  84716. 2093,
  84717. ],
  84718. [
  84719. 2137,
  84720. 2139,
  84721. ],
  84722. [
  84723. 2200,
  84724. 2207,
  84725. ],
  84726. [
  84727. 2250,
  84728. 2273,
  84729. ],
  84730. [
  84731. 2275,
  84732. 2306,
  84733. ],
  84734. [
  84735. 2362,
  84736. 2362,
  84737. ],
  84738. [
  84739. 2364,
  84740. 2364,
  84741. ],
  84742. [
  84743. 2369,
  84744. 2376,
  84745. ],
  84746. [
  84747. 2381,
  84748. 2381,
  84749. ],
  84750. [
  84751. 2385,
  84752. 2391,
  84753. ],
  84754. [
  84755. 2402,
  84756. 2403,
  84757. ],
  84758. [
  84759. 2433,
  84760. 2433,
  84761. ],
  84762. [
  84763. 2492,
  84764. 2492,
  84765. ],
  84766. [
  84767. 2497,
  84768. 2500,
  84769. ],
  84770. [
  84771. 2509,
  84772. 2509,
  84773. ],
  84774. [
  84775. 2530,
  84776. 2531,
  84777. ],
  84778. [
  84779. 2558,
  84780. 2558,
  84781. ],
  84782. [
  84783. 2561,
  84784. 2562,
  84785. ],
  84786. [
  84787. 2620,
  84788. 2620,
  84789. ],
  84790. [
  84791. 2625,
  84792. 2626,
  84793. ],
  84794. [
  84795. 2631,
  84796. 2632,
  84797. ],
  84798. [
  84799. 2635,
  84800. 2637,
  84801. ],
  84802. [
  84803. 2641,
  84804. 2641,
  84805. ],
  84806. [
  84807. 2672,
  84808. 2673,
  84809. ],
  84810. [
  84811. 2677,
  84812. 2677,
  84813. ],
  84814. [
  84815. 2689,
  84816. 2690,
  84817. ],
  84818. [
  84819. 2748,
  84820. 2748,
  84821. ],
  84822. [
  84823. 2753,
  84824. 2757,
  84825. ],
  84826. [
  84827. 2759,
  84828. 2760,
  84829. ],
  84830. [
  84831. 2765,
  84832. 2765,
  84833. ],
  84834. [
  84835. 2786,
  84836. 2787,
  84837. ],
  84838. [
  84839. 2810,
  84840. 2815,
  84841. ],
  84842. [
  84843. 2817,
  84844. 2817,
  84845. ],
  84846. [
  84847. 2876,
  84848. 2876,
  84849. ],
  84850. [
  84851. 2879,
  84852. 2879,
  84853. ],
  84854. [
  84855. 2881,
  84856. 2884,
  84857. ],
  84858. [
  84859. 2893,
  84860. 2893,
  84861. ],
  84862. [
  84863. 2901,
  84864. 2902,
  84865. ],
  84866. [
  84867. 2914,
  84868. 2915,
  84869. ],
  84870. [
  84871. 2946,
  84872. 2946,
  84873. ],
  84874. [
  84875. 3008,
  84876. 3008,
  84877. ],
  84878. [
  84879. 3021,
  84880. 3021,
  84881. ],
  84882. [
  84883. 3072,
  84884. 3072,
  84885. ],
  84886. [
  84887. 3076,
  84888. 3076,
  84889. ],
  84890. [
  84891. 3132,
  84892. 3132,
  84893. ],
  84894. [
  84895. 3134,
  84896. 3136,
  84897. ],
  84898. [
  84899. 3142,
  84900. 3144,
  84901. ],
  84902. [
  84903. 3146,
  84904. 3149,
  84905. ],
  84906. [
  84907. 3157,
  84908. 3158,
  84909. ],
  84910. [
  84911. 3170,
  84912. 3171,
  84913. ],
  84914. [
  84915. 3201,
  84916. 3201,
  84917. ],
  84918. [
  84919. 3260,
  84920. 3260,
  84921. ],
  84922. [
  84923. 3263,
  84924. 3263,
  84925. ],
  84926. [
  84927. 3270,
  84928. 3270,
  84929. ],
  84930. [
  84931. 3276,
  84932. 3277,
  84933. ],
  84934. [
  84935. 3298,
  84936. 3299,
  84937. ],
  84938. [
  84939. 3328,
  84940. 3329,
  84941. ],
  84942. [
  84943. 3387,
  84944. 3388,
  84945. ],
  84946. [
  84947. 3393,
  84948. 3396,
  84949. ],
  84950. [
  84951. 3405,
  84952. 3405,
  84953. ],
  84954. [
  84955. 3426,
  84956. 3427,
  84957. ],
  84958. [
  84959. 3457,
  84960. 3457,
  84961. ],
  84962. [
  84963. 3530,
  84964. 3530,
  84965. ],
  84966. [
  84967. 3538,
  84968. 3540,
  84969. ],
  84970. [
  84971. 3542,
  84972. 3542,
  84973. ],
  84974. [
  84975. 3633,
  84976. 3633,
  84977. ],
  84978. [
  84979. 3636,
  84980. 3642,
  84981. ],
  84982. [
  84983. 3655,
  84984. 3662,
  84985. ],
  84986. [
  84987. 3761,
  84988. 3761,
  84989. ],
  84990. [
  84991. 3764,
  84992. 3772,
  84993. ],
  84994. [
  84995. 3784,
  84996. 3790,
  84997. ],
  84998. [
  84999. 3864,
  85000. 3865,
  85001. ],
  85002. [
  85003. 3893,
  85004. 3893,
  85005. ],
  85006. [
  85007. 3895,
  85008. 3895,
  85009. ],
  85010. [
  85011. 3897,
  85012. 3897,
  85013. ],
  85014. [
  85015. 3953,
  85016. 3966,
  85017. ],
  85018. [
  85019. 3968,
  85020. 3972,
  85021. ],
  85022. [
  85023. 3974,
  85024. 3975,
  85025. ],
  85026. [
  85027. 3981,
  85028. 3991,
  85029. ],
  85030. [
  85031. 3993,
  85032. 4028,
  85033. ],
  85034. [
  85035. 4038,
  85036. 4038,
  85037. ],
  85038. [
  85039. 4141,
  85040. 4144,
  85041. ],
  85042. [
  85043. 4146,
  85044. 4151,
  85045. ],
  85046. [
  85047. 4153,
  85048. 4154,
  85049. ],
  85050. [
  85051. 4157,
  85052. 4158,
  85053. ],
  85054. [
  85055. 4184,
  85056. 4185,
  85057. ],
  85058. [
  85059. 4190,
  85060. 4192,
  85061. ],
  85062. [
  85063. 4209,
  85064. 4212,
  85065. ],
  85066. [
  85067. 4226,
  85068. 4226,
  85069. ],
  85070. [
  85071. 4229,
  85072. 4230,
  85073. ],
  85074. [
  85075. 4237,
  85076. 4237,
  85077. ],
  85078. [
  85079. 4253,
  85080. 4253,
  85081. ],
  85082. [
  85083. 4957,
  85084. 4959,
  85085. ],
  85086. [
  85087. 5906,
  85088. 5908,
  85089. ],
  85090. [
  85091. 5938,
  85092. 5939,
  85093. ],
  85094. [
  85095. 5970,
  85096. 5971,
  85097. ],
  85098. [
  85099. 6002,
  85100. 6003,
  85101. ],
  85102. [
  85103. 6068,
  85104. 6069,
  85105. ],
  85106. [
  85107. 6071,
  85108. 6077,
  85109. ],
  85110. [
  85111. 6086,
  85112. 6086,
  85113. ],
  85114. [
  85115. 6089,
  85116. 6099,
  85117. ],
  85118. [
  85119. 6109,
  85120. 6109,
  85121. ],
  85122. [
  85123. 6155,
  85124. 6157,
  85125. ],
  85126. [
  85127. 6159,
  85128. 6159,
  85129. ],
  85130. [
  85131. 6277,
  85132. 6278,
  85133. ],
  85134. [
  85135. 6313,
  85136. 6313,
  85137. ],
  85138. [
  85139. 6432,
  85140. 6434,
  85141. ],
  85142. [
  85143. 6439,
  85144. 6440,
  85145. ],
  85146. [
  85147. 6450,
  85148. 6450,
  85149. ],
  85150. [
  85151. 6457,
  85152. 6459,
  85153. ],
  85154. [
  85155. 6679,
  85156. 6680,
  85157. ],
  85158. [
  85159. 6683,
  85160. 6683,
  85161. ],
  85162. [
  85163. 6742,
  85164. 6742,
  85165. ],
  85166. [
  85167. 6744,
  85168. 6750,
  85169. ],
  85170. [
  85171. 6752,
  85172. 6752,
  85173. ],
  85174. [
  85175. 6754,
  85176. 6754,
  85177. ],
  85178. [
  85179. 6757,
  85180. 6764,
  85181. ],
  85182. [
  85183. 6771,
  85184. 6780,
  85185. ],
  85186. [
  85187. 6783,
  85188. 6783,
  85189. ],
  85190. [
  85191. 6832,
  85192. 6845,
  85193. ],
  85194. [
  85195. 6846,
  85196. 6846,
  85197. ],
  85198. [
  85199. 6847,
  85200. 6862,
  85201. ],
  85202. [
  85203. 6912,
  85204. 6915,
  85205. ],
  85206. [
  85207. 6964,
  85208. 6964,
  85209. ],
  85210. [
  85211. 6966,
  85212. 6970,
  85213. ],
  85214. [
  85215. 6972,
  85216. 6972,
  85217. ],
  85218. [
  85219. 6978,
  85220. 6978,
  85221. ],
  85222. [
  85223. 7019,
  85224. 7027,
  85225. ],
  85226. [
  85227. 7040,
  85228. 7041,
  85229. ],
  85230. [
  85231. 7074,
  85232. 7077,
  85233. ],
  85234. [
  85235. 7080,
  85236. 7081,
  85237. ],
  85238. [
  85239. 7083,
  85240. 7085,
  85241. ],
  85242. [
  85243. 7142,
  85244. 7142,
  85245. ],
  85246. [
  85247. 7144,
  85248. 7145,
  85249. ],
  85250. [
  85251. 7149,
  85252. 7149,
  85253. ],
  85254. [
  85255. 7151,
  85256. 7153,
  85257. ],
  85258. [
  85259. 7212,
  85260. 7219,
  85261. ],
  85262. [
  85263. 7222,
  85264. 7223,
  85265. ],
  85266. [
  85267. 7376,
  85268. 7378,
  85269. ],
  85270. [
  85271. 7380,
  85272. 7392,
  85273. ],
  85274. [
  85275. 7394,
  85276. 7400,
  85277. ],
  85278. [
  85279. 7405,
  85280. 7405,
  85281. ],
  85282. [
  85283. 7412,
  85284. 7412,
  85285. ],
  85286. [
  85287. 7416,
  85288. 7417,
  85289. ],
  85290. [
  85291. 7616,
  85292. 7679,
  85293. ],
  85294. [
  85295. 8400,
  85296. 8412,
  85297. ],
  85298. [
  85299. 8413,
  85300. 8416,
  85301. ],
  85302. [
  85303. 8417,
  85304. 8417,
  85305. ],
  85306. [
  85307. 8418,
  85308. 8420,
  85309. ],
  85310. [
  85311. 8421,
  85312. 8432,
  85313. ],
  85314. [
  85315. 11503,
  85316. 11505,
  85317. ],
  85318. [
  85319. 11647,
  85320. 11647,
  85321. ],
  85322. [
  85323. 11744,
  85324. 11775,
  85325. ],
  85326. [
  85327. 12330,
  85328. 12333,
  85329. ],
  85330. [
  85331. 12441,
  85332. 12442,
  85333. ],
  85334. [
  85335. 42607,
  85336. 42607,
  85337. ],
  85338. [
  85339. 42608,
  85340. 42610,
  85341. ],
  85342. [
  85343. 42612,
  85344. 42621,
  85345. ],
  85346. [
  85347. 42654,
  85348. 42655,
  85349. ],
  85350. [
  85351. 42736,
  85352. 42737,
  85353. ],
  85354. [
  85355. 43010,
  85356. 43010,
  85357. ],
  85358. [
  85359. 43014,
  85360. 43014,
  85361. ],
  85362. [
  85363. 43019,
  85364. 43019,
  85365. ],
  85366. [
  85367. 43045,
  85368. 43046,
  85369. ],
  85370. [
  85371. 43052,
  85372. 43052,
  85373. ],
  85374. [
  85375. 43204,
  85376. 43205,
  85377. ],
  85378. [
  85379. 43232,
  85380. 43249,
  85381. ],
  85382. [
  85383. 43263,
  85384. 43263,
  85385. ],
  85386. [
  85387. 43302,
  85388. 43309,
  85389. ],
  85390. [
  85391. 43335,
  85392. 43345,
  85393. ],
  85394. [
  85395. 43392,
  85396. 43394,
  85397. ],
  85398. [
  85399. 43443,
  85400. 43443,
  85401. ],
  85402. [
  85403. 43446,
  85404. 43449,
  85405. ],
  85406. [
  85407. 43452,
  85408. 43453,
  85409. ],
  85410. [
  85411. 43493,
  85412. 43493,
  85413. ],
  85414. [
  85415. 43561,
  85416. 43566,
  85417. ],
  85418. [
  85419. 43569,
  85420. 43570,
  85421. ],
  85422. [
  85423. 43573,
  85424. 43574,
  85425. ],
  85426. [
  85427. 43587,
  85428. 43587,
  85429. ],
  85430. [
  85431. 43596,
  85432. 43596,
  85433. ],
  85434. [
  85435. 43644,
  85436. 43644,
  85437. ],
  85438. [
  85439. 43696,
  85440. 43696,
  85441. ],
  85442. [
  85443. 43698,
  85444. 43700,
  85445. ],
  85446. [
  85447. 43703,
  85448. 43704,
  85449. ],
  85450. [
  85451. 43710,
  85452. 43711,
  85453. ],
  85454. [
  85455. 43713,
  85456. 43713,
  85457. ],
  85458. [
  85459. 43756,
  85460. 43757,
  85461. ],
  85462. [
  85463. 43766,
  85464. 43766,
  85465. ],
  85466. [
  85467. 44005,
  85468. 44005,
  85469. ],
  85470. [
  85471. 44008,
  85472. 44008,
  85473. ],
  85474. [
  85475. 44013,
  85476. 44013,
  85477. ],
  85478. [
  85479. 64286,
  85480. 64286,
  85481. ],
  85482. [
  85483. 65024,
  85484. 65039,
  85485. ],
  85486. [
  85487. 65056,
  85488. 65071,
  85489. ],
  85490. [
  85491. 66045,
  85492. 66045,
  85493. ],
  85494. [
  85495. 66272,
  85496. 66272,
  85497. ],
  85498. [
  85499. 66422,
  85500. 66426,
  85501. ],
  85502. [
  85503. 68097,
  85504. 68099,
  85505. ],
  85506. [
  85507. 68101,
  85508. 68102,
  85509. ],
  85510. [
  85511. 68108,
  85512. 68111,
  85513. ],
  85514. [
  85515. 68152,
  85516. 68154,
  85517. ],
  85518. [
  85519. 68159,
  85520. 68159,
  85521. ],
  85522. [
  85523. 68325,
  85524. 68326,
  85525. ],
  85526. [
  85527. 68900,
  85528. 68903,
  85529. ],
  85530. [
  85531. 69291,
  85532. 69292,
  85533. ],
  85534. [
  85535. 69373,
  85536. 69375,
  85537. ],
  85538. [
  85539. 69446,
  85540. 69456,
  85541. ],
  85542. [
  85543. 69506,
  85544. 69509,
  85545. ],
  85546. [
  85547. 69633,
  85548. 69633,
  85549. ],
  85550. [
  85551. 69688,
  85552. 69702,
  85553. ],
  85554. [
  85555. 69744,
  85556. 69744,
  85557. ],
  85558. [
  85559. 69747,
  85560. 69748,
  85561. ],
  85562. [
  85563. 69759,
  85564. 69761,
  85565. ],
  85566. [
  85567. 69811,
  85568. 69814,
  85569. ],
  85570. [
  85571. 69817,
  85572. 69818,
  85573. ],
  85574. [
  85575. 69826,
  85576. 69826,
  85577. ],
  85578. [
  85579. 69888,
  85580. 69890,
  85581. ],
  85582. [
  85583. 69927,
  85584. 69931,
  85585. ],
  85586. [
  85587. 69933,
  85588. 69940,
  85589. ],
  85590. [
  85591. 70003,
  85592. 70003,
  85593. ],
  85594. [
  85595. 70016,
  85596. 70017,
  85597. ],
  85598. [
  85599. 70070,
  85600. 70078,
  85601. ],
  85602. [
  85603. 70089,
  85604. 70092,
  85605. ],
  85606. [
  85607. 70095,
  85608. 70095,
  85609. ],
  85610. [
  85611. 70191,
  85612. 70193,
  85613. ],
  85614. [
  85615. 70196,
  85616. 70196,
  85617. ],
  85618. [
  85619. 70198,
  85620. 70199,
  85621. ],
  85622. [
  85623. 70206,
  85624. 70206,
  85625. ],
  85626. [
  85627. 70209,
  85628. 70209,
  85629. ],
  85630. [
  85631. 70367,
  85632. 70367,
  85633. ],
  85634. [
  85635. 70371,
  85636. 70378,
  85637. ],
  85638. [
  85639. 70400,
  85640. 70401,
  85641. ],
  85642. [
  85643. 70459,
  85644. 70460,
  85645. ],
  85646. [
  85647. 70464,
  85648. 70464,
  85649. ],
  85650. [
  85651. 70502,
  85652. 70508,
  85653. ],
  85654. [
  85655. 70512,
  85656. 70516,
  85657. ],
  85658. [
  85659. 70712,
  85660. 70719,
  85661. ],
  85662. [
  85663. 70722,
  85664. 70724,
  85665. ],
  85666. [
  85667. 70726,
  85668. 70726,
  85669. ],
  85670. [
  85671. 70750,
  85672. 70750,
  85673. ],
  85674. [
  85675. 70835,
  85676. 70840,
  85677. ],
  85678. [
  85679. 70842,
  85680. 70842,
  85681. ],
  85682. [
  85683. 70847,
  85684. 70848,
  85685. ],
  85686. [
  85687. 70850,
  85688. 70851,
  85689. ],
  85690. [
  85691. 71090,
  85692. 71093,
  85693. ],
  85694. [
  85695. 71100,
  85696. 71101,
  85697. ],
  85698. [
  85699. 71103,
  85700. 71104,
  85701. ],
  85702. [
  85703. 71132,
  85704. 71133,
  85705. ],
  85706. [
  85707. 71219,
  85708. 71226,
  85709. ],
  85710. [
  85711. 71229,
  85712. 71229,
  85713. ],
  85714. [
  85715. 71231,
  85716. 71232,
  85717. ],
  85718. [
  85719. 71339,
  85720. 71339,
  85721. ],
  85722. [
  85723. 71341,
  85724. 71341,
  85725. ],
  85726. [
  85727. 71344,
  85728. 71349,
  85729. ],
  85730. [
  85731. 71351,
  85732. 71351,
  85733. ],
  85734. [
  85735. 71453,
  85736. 71455,
  85737. ],
  85738. [
  85739. 71458,
  85740. 71461,
  85741. ],
  85742. [
  85743. 71463,
  85744. 71467,
  85745. ],
  85746. [
  85747. 71727,
  85748. 71735,
  85749. ],
  85750. [
  85751. 71737,
  85752. 71738,
  85753. ],
  85754. [
  85755. 71995,
  85756. 71996,
  85757. ],
  85758. [
  85759. 71998,
  85760. 71998,
  85761. ],
  85762. [
  85763. 72003,
  85764. 72003,
  85765. ],
  85766. [
  85767. 72148,
  85768. 72151,
  85769. ],
  85770. [
  85771. 72154,
  85772. 72155,
  85773. ],
  85774. [
  85775. 72160,
  85776. 72160,
  85777. ],
  85778. [
  85779. 72193,
  85780. 72202,
  85781. ],
  85782. [
  85783. 72243,
  85784. 72248,
  85785. ],
  85786. [
  85787. 72251,
  85788. 72254,
  85789. ],
  85790. [
  85791. 72263,
  85792. 72263,
  85793. ],
  85794. [
  85795. 72273,
  85796. 72278,
  85797. ],
  85798. [
  85799. 72281,
  85800. 72283,
  85801. ],
  85802. [
  85803. 72330,
  85804. 72342,
  85805. ],
  85806. [
  85807. 72344,
  85808. 72345,
  85809. ],
  85810. [
  85811. 72752,
  85812. 72758,
  85813. ],
  85814. [
  85815. 72760,
  85816. 72765,
  85817. ],
  85818. [
  85819. 72767,
  85820. 72767,
  85821. ],
  85822. [
  85823. 72850,
  85824. 72871,
  85825. ],
  85826. [
  85827. 72874,
  85828. 72880,
  85829. ],
  85830. [
  85831. 72882,
  85832. 72883,
  85833. ],
  85834. [
  85835. 72885,
  85836. 72886,
  85837. ],
  85838. [
  85839. 73009,
  85840. 73014,
  85841. ],
  85842. [
  85843. 73018,
  85844. 73018,
  85845. ],
  85846. [
  85847. 73020,
  85848. 73021,
  85849. ],
  85850. [
  85851. 73023,
  85852. 73029,
  85853. ],
  85854. [
  85855. 73031,
  85856. 73031,
  85857. ],
  85858. [
  85859. 73104,
  85860. 73105,
  85861. ],
  85862. [
  85863. 73109,
  85864. 73109,
  85865. ],
  85866. [
  85867. 73111,
  85868. 73111,
  85869. ],
  85870. [
  85871. 73459,
  85872. 73460,
  85873. ],
  85874. [
  85875. 73472,
  85876. 73473,
  85877. ],
  85878. [
  85879. 73526,
  85880. 73530,
  85881. ],
  85882. [
  85883. 73536,
  85884. 73536,
  85885. ],
  85886. [
  85887. 73538,
  85888. 73538,
  85889. ],
  85890. [
  85891. 78912,
  85892. 78912,
  85893. ],
  85894. [
  85895. 78919,
  85896. 78933,
  85897. ],
  85898. [
  85899. 92912,
  85900. 92916,
  85901. ],
  85902. [
  85903. 92976,
  85904. 92982,
  85905. ],
  85906. [
  85907. 94031,
  85908. 94031,
  85909. ],
  85910. [
  85911. 94095,
  85912. 94098,
  85913. ],
  85914. [
  85915. 94180,
  85916. 94180,
  85917. ],
  85918. [
  85919. 113821,
  85920. 113822,
  85921. ],
  85922. [
  85923. 118528,
  85924. 118573,
  85925. ],
  85926. [
  85927. 118576,
  85928. 118598,
  85929. ],
  85930. [
  85931. 119143,
  85932. 119145,
  85933. ],
  85934. [
  85935. 119163,
  85936. 119170,
  85937. ],
  85938. [
  85939. 119173,
  85940. 119179,
  85941. ],
  85942. [
  85943. 119210,
  85944. 119213,
  85945. ],
  85946. [
  85947. 119362,
  85948. 119364,
  85949. ],
  85950. [
  85951. 121344,
  85952. 121398,
  85953. ],
  85954. [
  85955. 121403,
  85956. 121452,
  85957. ],
  85958. [
  85959. 121461,
  85960. 121461,
  85961. ],
  85962. [
  85963. 121476,
  85964. 121476,
  85965. ],
  85966. [
  85967. 121499,
  85968. 121503,
  85969. ],
  85970. [
  85971. 121505,
  85972. 121519,
  85973. ],
  85974. [
  85975. 122880,
  85976. 122886,
  85977. ],
  85978. [
  85979. 122888,
  85980. 122904,
  85981. ],
  85982. [
  85983. 122907,
  85984. 122913,
  85985. ],
  85986. [
  85987. 122915,
  85988. 122916,
  85989. ],
  85990. [
  85991. 122918,
  85992. 122922,
  85993. ],
  85994. [
  85995. 123023,
  85996. 123023,
  85997. ],
  85998. [
  85999. 123184,
  86000. 123190,
  86001. ],
  86002. [
  86003. 123566,
  86004. 123566,
  86005. ],
  86006. [
  86007. 123628,
  86008. 123631,
  86009. ],
  86010. [
  86011. 124140,
  86012. 124143,
  86013. ],
  86014. [
  86015. 125136,
  86016. 125142,
  86017. ],
  86018. [
  86019. 125252,
  86020. 125258,
  86021. ],
  86022. [
  86023. 917760,
  86024. 917999,
  86025. ],
  86026. ];
  86027. <?php
  86028. namespace Symfony\Component\String;
  86029. if (!\function_exists(u::class)) {
  86030. function u(?string $string = ''): UnicodeString
  86031. {
  86032. return new UnicodeString($string ?? '');
  86033. }
  86034. }
  86035. if (!\function_exists(b::class)) {
  86036. function b(?string $string = ''): ByteString
  86037. {
  86038. return new ByteString($string ?? '');
  86039. }
  86040. }
  86041. if (!\function_exists(s::class)) {
  86042. function s(?string $string = ''): AbstractString
  86043. {
  86044. $string = $string ?? '';
  86045. return preg_match('//u', $string) ? new UnicodeString($string) : new ByteString($string);
  86046. }
  86047. }
  86048. <?php
  86049. namespace Symfony\Component\String\Slugger;
  86050. use Symfony\Component\String\AbstractUnicodeString;
  86051. use Symfony\Component\String\UnicodeString;
  86052. use Symfony\Contracts\Translation\LocaleAwareInterface;
  86053. if (!interface_exists(LocaleAwareInterface::class)) {
  86054. 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".');
  86055. }
  86056. class AsciiSlugger implements SluggerInterface, LocaleAwareInterface
  86057. {
  86058. private const LOCALE_TO_TRANSLITERATOR_ID = [
  86059. 'am' => 'Amharic-Latin',
  86060. 'ar' => 'Arabic-Latin',
  86061. 'az' => 'Azerbaijani-Latin',
  86062. 'be' => 'Belarusian-Latin',
  86063. 'bg' => 'Bulgarian-Latin',
  86064. 'bn' => 'Bengali-Latin',
  86065. 'de' => 'de-ASCII',
  86066. 'el' => 'Greek-Latin',
  86067. 'fa' => 'Persian-Latin',
  86068. 'he' => 'Hebrew-Latin',
  86069. 'hy' => 'Armenian-Latin',
  86070. 'ka' => 'Georgian-Latin',
  86071. 'kk' => 'Kazakh-Latin',
  86072. 'ky' => 'Kirghiz-Latin',
  86073. 'ko' => 'Korean-Latin',
  86074. 'mk' => 'Macedonian-Latin',
  86075. 'mn' => 'Mongolian-Latin',
  86076. 'or' => 'Oriya-Latin',
  86077. 'ps' => 'Pashto-Latin',
  86078. 'ru' => 'Russian-Latin',
  86079. 'sr' => 'Serbian-Latin',
  86080. 'sr_Cyrl' => 'Serbian-Latin',
  86081. 'th' => 'Thai-Latin',
  86082. 'tk' => 'Turkmen-Latin',
  86083. 'uk' => 'Ukrainian-Latin',
  86084. 'uz' => 'Uzbek-Latin',
  86085. 'zh' => 'Han-Latin',
  86086. ];
  86087. private $defaultLocale;
  86088. private $symbolsMap = [
  86089. 'en' => ['@' => 'at', '&' => 'and'],
  86090. ];
  86091. private $transliterators = [];
  86092. public function __construct(string $defaultLocale = null, $symbolsMap = null)
  86093. {
  86094. if (null !== $symbolsMap && !\is_array($symbolsMap) && !$symbolsMap instanceof \Closure) {
  86095. throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be array, Closure or null, "%s" given.', __METHOD__, \gettype($symbolsMap)));
  86096. }
  86097. $this->defaultLocale = $defaultLocale;
  86098. $this->symbolsMap = $symbolsMap ?? $this->symbolsMap;
  86099. }
  86100. public function setLocale($locale)
  86101. {
  86102. $this->defaultLocale = $locale;
  86103. }
  86104. public function getLocale()
  86105. {
  86106. return $this->defaultLocale;
  86107. }
  86108. public function slug(string $string, string $separator = '-', string $locale = null): AbstractUnicodeString
  86109. {
  86110. $locale = $locale ?? $this->defaultLocale;
  86111. $transliterator = [];
  86112. if ($locale && ('de' === $locale || 0 === strpos($locale, 'de_'))) {
  86113. $transliterator = ['de-ASCII'];
  86114. } elseif (\function_exists('transliterator_transliterate') && $locale) {
  86115. $transliterator = (array) $this->createTransliterator($locale);
  86116. }
  86117. if ($this->symbolsMap instanceof \Closure) {
  86118. $symbolsMap = $this->symbolsMap;
  86119. array_unshift($transliterator, static function ($s) use ($symbolsMap, $locale) {
  86120. return $symbolsMap($s, $locale);
  86121. });
  86122. }
  86123. $unicodeString = (new UnicodeString($string))->ascii($transliterator);
  86124. if (\is_array($this->symbolsMap)) {
  86125. $map = null;
  86126. if (isset($this->symbolsMap[$locale])) {
  86127. $map = $this->symbolsMap[$locale];
  86128. } else {
  86129. $parent = self::getParentLocale($locale);
  86130. if ($parent && isset($this->symbolsMap[$parent])) {
  86131. $map = $this->symbolsMap[$parent];
  86132. }
  86133. }
  86134. if ($map) {
  86135. foreach ($map as $char => $replace) {
  86136. $unicodeString = $unicodeString->replace($char, ' '.$replace.' ');
  86137. }
  86138. }
  86139. }
  86140. return $unicodeString
  86141. ->replaceMatches('/[^A-Za-z0-9]++/', $separator)
  86142. ->trim($separator)
  86143. ;
  86144. }
  86145. private function createTransliterator(string $locale): ?\Transliterator
  86146. {
  86147. if (\array_key_exists($locale, $this->transliterators)) {
  86148. return $this->transliterators[$locale];
  86149. }
  86150. if ($id = self::LOCALE_TO_TRANSLITERATOR_ID[$locale] ?? null) {
  86151. return $this->transliterators[$locale] = \Transliterator::create($id.'/BGN') ?? \Transliterator::create($id);
  86152. }
  86153. if (!$parent = self::getParentLocale($locale)) {
  86154. return $this->transliterators[$locale] = null;
  86155. }
  86156. if ($id = self::LOCALE_TO_TRANSLITERATOR_ID[$parent] ?? null) {
  86157. $transliterator = \Transliterator::create($id.'/BGN') ?? \Transliterator::create($id);
  86158. }
  86159. return $this->transliterators[$locale] = $this->transliterators[$parent] = $transliterator ?? null;
  86160. }
  86161. private static function getParentLocale(?string $locale): ?string
  86162. {
  86163. if (!$locale) {
  86164. return null;
  86165. }
  86166. if (false === $str = strrchr($locale, '_')) {
  86167. return null;
  86168. }
  86169. return substr($locale, 0, -\strlen($str));
  86170. }
  86171. }
  86172. <?php
  86173. namespace Symfony\Component\String\Slugger;
  86174. use Symfony\Component\String\AbstractUnicodeString;
  86175. interface SluggerInterface
  86176. {
  86177. public function slug(string $string, string $separator = '-', string $locale = null): AbstractUnicodeString;
  86178. }
  86179. <?php
  86180. namespace Symfony\Component\String;
  86181. use Symfony\Component\String\Exception\ExceptionInterface;
  86182. use Symfony\Component\String\Exception\InvalidArgumentException;
  86183. class UnicodeString extends AbstractUnicodeString
  86184. {
  86185. public function __construct(string $string = '')
  86186. {
  86187. $this->string = normalizer_is_normalized($string) ? $string : normalizer_normalize($string);
  86188. if (false === $this->string) {
  86189. throw new InvalidArgumentException('Invalid UTF-8 string.');
  86190. }
  86191. }
  86192. public function append(string ...$suffix): AbstractString
  86193. {
  86194. $str = clone $this;
  86195. $str->string = $this->string.(1 >= \count($suffix) ? ($suffix[0] ?? '') : implode('', $suffix));
  86196. normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
  86197. if (false === $str->string) {
  86198. throw new InvalidArgumentException('Invalid UTF-8 string.');
  86199. }
  86200. return $str;
  86201. }
  86202. public function chunk(int $length = 1): array
  86203. {
  86204. if (1 > $length) {
  86205. throw new InvalidArgumentException('The chunk length must be greater than zero.');
  86206. }
  86207. if ('' === $this->string) {
  86208. return [];
  86209. }
  86210. $rx = '/(';
  86211. while (65535 < $length) {
  86212. $rx .= '\X{65535}';
  86213. $length -= 65535;
  86214. }
  86215. $rx .= '\X{'.$length.'})/u';
  86216. $str = clone $this;
  86217. $chunks = [];
  86218. foreach (preg_split($rx, $this->string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY) as $chunk) {
  86219. $str->string = $chunk;
  86220. $chunks[] = clone $str;
  86221. }
  86222. return $chunks;
  86223. }
  86224. public function endsWith($suffix): bool
  86225. {
  86226. if ($suffix instanceof AbstractString) {
  86227. $suffix = $suffix->string;
  86228. } elseif (\is_array($suffix) || $suffix instanceof \Traversable) {
  86229. return parent::endsWith($suffix);
  86230. } else {
  86231. $suffix = (string) $suffix;
  86232. }
  86233. $form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
  86234. normalizer_is_normalized($suffix, $form) ?: $suffix = normalizer_normalize($suffix, $form);
  86235. if ('' === $suffix || false === $suffix) {
  86236. return false;
  86237. }
  86238. if ($this->ignoreCase) {
  86239. return 0 === mb_stripos(grapheme_extract($this->string, \strlen($suffix), \GRAPHEME_EXTR_MAXBYTES, \strlen($this->string) - \strlen($suffix)), $suffix, 0, 'UTF-8');
  86240. }
  86241. return $suffix === grapheme_extract($this->string, \strlen($suffix), \GRAPHEME_EXTR_MAXBYTES, \strlen($this->string) - \strlen($suffix));
  86242. }
  86243. public function equalsTo($string): bool
  86244. {
  86245. if ($string instanceof AbstractString) {
  86246. $string = $string->string;
  86247. } elseif (\is_array($string) || $string instanceof \Traversable) {
  86248. return parent::equalsTo($string);
  86249. } else {
  86250. $string = (string) $string;
  86251. }
  86252. $form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
  86253. normalizer_is_normalized($string, $form) ?: $string = normalizer_normalize($string, $form);
  86254. if ('' !== $string && false !== $string && $this->ignoreCase) {
  86255. return \strlen($string) === \strlen($this->string) && 0 === mb_stripos($this->string, $string, 0, 'UTF-8');
  86256. }
  86257. return $string === $this->string;
  86258. }
  86259. public function indexOf($needle, int $offset = 0): ?int
  86260. {
  86261. if ($needle instanceof AbstractString) {
  86262. $needle = $needle->string;
  86263. } elseif (\is_array($needle) || $needle instanceof \Traversable) {
  86264. return parent::indexOf($needle, $offset);
  86265. } else {
  86266. $needle = (string) $needle;
  86267. }
  86268. $form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
  86269. normalizer_is_normalized($needle, $form) ?: $needle = normalizer_normalize($needle, $form);
  86270. if ('' === $needle || false === $needle) {
  86271. return null;
  86272. }
  86273. try {
  86274. $i = $this->ignoreCase ? grapheme_stripos($this->string, $needle, $offset) : grapheme_strpos($this->string, $needle, $offset);
  86275. } catch (\ValueError $e) {
  86276. return null;
  86277. }
  86278. return false === $i ? null : $i;
  86279. }
  86280. public function indexOfLast($needle, int $offset = 0): ?int
  86281. {
  86282. if ($needle instanceof AbstractString) {
  86283. $needle = $needle->string;
  86284. } elseif (\is_array($needle) || $needle instanceof \Traversable) {
  86285. return parent::indexOfLast($needle, $offset);
  86286. } else {
  86287. $needle = (string) $needle;
  86288. }
  86289. $form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
  86290. normalizer_is_normalized($needle, $form) ?: $needle = normalizer_normalize($needle, $form);
  86291. if ('' === $needle || false === $needle) {
  86292. return null;
  86293. }
  86294. $string = $this->string;
  86295. if (0 > $offset) {
  86296. if (0 > $offset += grapheme_strlen($needle)) {
  86297. $string = grapheme_substr($string, 0, $offset);
  86298. }
  86299. $offset = 0;
  86300. }
  86301. $i = $this->ignoreCase ? grapheme_strripos($string, $needle, $offset) : grapheme_strrpos($string, $needle, $offset);
  86302. return false === $i ? null : $i;
  86303. }
  86304. public function join(array $strings, string $lastGlue = null): AbstractString
  86305. {
  86306. $str = parent::join($strings, $lastGlue);
  86307. normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
  86308. return $str;
  86309. }
  86310. public function length(): int
  86311. {
  86312. return grapheme_strlen($this->string);
  86313. }
  86314. public function normalize(int $form = self::NFC): parent
  86315. {
  86316. $str = clone $this;
  86317. if (\in_array($form, [self::NFC, self::NFKC], true)) {
  86318. normalizer_is_normalized($str->string, $form) ?: $str->string = normalizer_normalize($str->string, $form);
  86319. } elseif (!\in_array($form, [self::NFD, self::NFKD], true)) {
  86320. throw new InvalidArgumentException('Unsupported normalization form.');
  86321. } elseif (!normalizer_is_normalized($str->string, $form)) {
  86322. $str->string = normalizer_normalize($str->string, $form);
  86323. $str->ignoreCase = null;
  86324. }
  86325. return $str;
  86326. }
  86327. public function prepend(string ...$prefix): AbstractString
  86328. {
  86329. $str = clone $this;
  86330. $str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$this->string;
  86331. normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
  86332. if (false === $str->string) {
  86333. throw new InvalidArgumentException('Invalid UTF-8 string.');
  86334. }
  86335. return $str;
  86336. }
  86337. public function replace(string $from, string $to): AbstractString
  86338. {
  86339. $str = clone $this;
  86340. normalizer_is_normalized($from) ?: $from = normalizer_normalize($from);
  86341. if ('' !== $from && false !== $from) {
  86342. $tail = $str->string;
  86343. $result = '';
  86344. $indexOf = $this->ignoreCase ? 'grapheme_stripos' : 'grapheme_strpos';
  86345. while ('' !== $tail && false !== $i = $indexOf($tail, $from)) {
  86346. $slice = grapheme_substr($tail, 0, $i);
  86347. $result .= $slice.$to;
  86348. $tail = substr($tail, \strlen($slice) + \strlen($from));
  86349. }
  86350. $str->string = $result.$tail;
  86351. normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
  86352. if (false === $str->string) {
  86353. throw new InvalidArgumentException('Invalid UTF-8 string.');
  86354. }
  86355. }
  86356. return $str;
  86357. }
  86358. public function replaceMatches(string $fromRegexp, $to): AbstractString
  86359. {
  86360. $str = parent::replaceMatches($fromRegexp, $to);
  86361. normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
  86362. return $str;
  86363. }
  86364. public function slice(int $start = 0, int $length = null): AbstractString
  86365. {
  86366. $str = clone $this;
  86367. if (\PHP_VERSION_ID < 80000 && 0 > $start && grapheme_strlen($this->string) < -$start) {
  86368. $start = 0;
  86369. }
  86370. $str->string = (string) grapheme_substr($this->string, $start, $length ?? 2147483647);
  86371. return $str;
  86372. }
  86373. public function splice(string $replacement, int $start = 0, int $length = null): AbstractString
  86374. {
  86375. $str = clone $this;
  86376. if (\PHP_VERSION_ID < 80000 && 0 > $start && grapheme_strlen($this->string) < -$start) {
  86377. $start = 0;
  86378. }
  86379. $start = $start ? \strlen(grapheme_substr($this->string, 0, $start)) : 0;
  86380. $length = $length ? \strlen(grapheme_substr($this->string, $start, $length ?? 2147483647)) : $length;
  86381. $str->string = substr_replace($this->string, $replacement, $start, $length ?? 2147483647);
  86382. normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
  86383. if (false === $str->string) {
  86384. throw new InvalidArgumentException('Invalid UTF-8 string.');
  86385. }
  86386. return $str;
  86387. }
  86388. public function split(string $delimiter, int $limit = null, int $flags = null): array
  86389. {
  86390. if (1 > $limit = $limit ?? 2147483647) {
  86391. throw new InvalidArgumentException('Split limit must be a positive integer.');
  86392. }
  86393. if ('' === $delimiter) {
  86394. throw new InvalidArgumentException('Split delimiter is empty.');
  86395. }
  86396. if (null !== $flags) {
  86397. return parent::split($delimiter.'u', $limit, $flags);
  86398. }
  86399. normalizer_is_normalized($delimiter) ?: $delimiter = normalizer_normalize($delimiter);
  86400. if (false === $delimiter) {
  86401. throw new InvalidArgumentException('Split delimiter is not a valid UTF-8 string.');
  86402. }
  86403. $str = clone $this;
  86404. $tail = $this->string;
  86405. $chunks = [];
  86406. $indexOf = $this->ignoreCase ? 'grapheme_stripos' : 'grapheme_strpos';
  86407. while (1 < $limit && false !== $i = $indexOf($tail, $delimiter)) {
  86408. $str->string = grapheme_substr($tail, 0, $i);
  86409. $chunks[] = clone $str;
  86410. $tail = substr($tail, \strlen($str->string) + \strlen($delimiter));
  86411. --$limit;
  86412. }
  86413. $str->string = $tail;
  86414. $chunks[] = clone $str;
  86415. return $chunks;
  86416. }
  86417. public function startsWith($prefix): bool
  86418. {
  86419. if ($prefix instanceof AbstractString) {
  86420. $prefix = $prefix->string;
  86421. } elseif (\is_array($prefix) || $prefix instanceof \Traversable) {
  86422. return parent::startsWith($prefix);
  86423. } else {
  86424. $prefix = (string) $prefix;
  86425. }
  86426. $form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
  86427. normalizer_is_normalized($prefix, $form) ?: $prefix = normalizer_normalize($prefix, $form);
  86428. if ('' === $prefix || false === $prefix) {
  86429. return false;
  86430. }
  86431. if ($this->ignoreCase) {
  86432. return 0 === mb_stripos(grapheme_extract($this->string, \strlen($prefix), \GRAPHEME_EXTR_MAXBYTES), $prefix, 0, 'UTF-8');
  86433. }
  86434. return $prefix === grapheme_extract($this->string, \strlen($prefix), \GRAPHEME_EXTR_MAXBYTES);
  86435. }
  86436. public function __wakeup()
  86437. {
  86438. if (!\is_string($this->string)) {
  86439. throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
  86440. }
  86441. normalizer_is_normalized($this->string) ?: $this->string = normalizer_normalize($this->string);
  86442. }
  86443. public function __clone()
  86444. {
  86445. if (null === $this->ignoreCase) {
  86446. normalizer_is_normalized($this->string) ?: $this->string = normalizer_normalize($this->string);
  86447. }
  86448. $this->ignoreCase = false;
  86449. }
  86450. }
  86451. <?php
  86452. if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
  86453. if (0 === strpos(__FILE__, 'phar:') && ini_get('register_argc_argv')) {
  86454. echo 'Composer cannot be run safely on non-CLI SAPIs with register_argc_argv=On. Aborting.'.PHP_EOL;
  86455. exit(1);
  86456. }
  86457. echo 'Warning: Composer should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
  86458. }
  86459. if (PHP_VERSION_ID < 70205) {
  86460. 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;
  86461. exit(1);
  86462. }
  86463. setlocale(LC_ALL, 'C');
  86464. require __DIR__.'/../src/bootstrap.php';
  86465. use Composer\Console\Application;
  86466. use Composer\XdebugHandler\XdebugHandler;
  86467. use Composer\Util\Platform;
  86468. use Composer\Util\ErrorHandler;
  86469. error_reporting(-1);
  86470. // Restart without Xdebug
  86471. $xdebug = new XdebugHandler('Composer');
  86472. $xdebug->check();
  86473. unset($xdebug);
  86474. if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '4.0', '>=')) {
  86475. echo 'HHVM 4.0 has dropped support for Composer, please use PHP instead. Aborting.'.PHP_EOL;
  86476. exit(1);
  86477. }
  86478. if (!extension_loaded('iconv') && !extension_loaded('mbstring')) {
  86479. echo 'The iconv OR mbstring extension is required and both are missing.'
  86480. .PHP_EOL.'Install either of them or recompile php without --disable-iconv.'
  86481. .PHP_EOL.'Aborting.'.PHP_EOL;
  86482. exit(1);
  86483. }
  86484. if (function_exists('ini_set')) {
  86485. @ini_set('display_errors', '1');
  86486. // Set user defined memory limit
  86487. if ($memoryLimit = getenv('COMPOSER_MEMORY_LIMIT')) {
  86488. @ini_set('memory_limit', $memoryLimit);
  86489. } else {
  86490. $memoryInBytes = function ($value) {
  86491. $unit = strtolower(substr($value, -1, 1));
  86492. $value = (int) $value;
  86493. switch($unit) {
  86494. case 'g':
  86495. $value *= 1024;
  86496. // no break (cumulative multiplier)
  86497. case 'm':
  86498. $value *= 1024;
  86499. // no break (cumulative multiplier)
  86500. case 'k':
  86501. $value *= 1024;
  86502. }
  86503. return $value;
  86504. };
  86505. $memoryLimit = trim(ini_get('memory_limit'));
  86506. // Increase memory_limit if it is lower than 1.5GB
  86507. if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1536) {
  86508. @ini_set('memory_limit', '1536M');
  86509. }
  86510. unset($memoryInBytes);
  86511. }
  86512. unset($memoryLimit);
  86513. }
  86514. // Workaround PHP bug on Windows where env vars containing Unicode chars are mangled in $_SERVER
  86515. // see https://github.com/php/php-src/issues/7896
  86516. if (PHP_VERSION_ID >= 70113 && (PHP_VERSION_ID < 80016 || (PHP_VERSION_ID >= 80100 && PHP_VERSION_ID < 80103)) && Platform::isWindows()) {
  86517. foreach ($_SERVER as $serverVar => $serverVal) {
  86518. if (($serverVal = getenv($serverVar)) !== false) {
  86519. $_SERVER[$serverVar] = $serverVal;
  86520. }
  86521. }
  86522. }
  86523. Platform::putEnv('COMPOSER_BINARY', realpath($_SERVER['argv'][0]));
  86524. ErrorHandler::register();
  86525. // run the command application
  86526. $application = new Application();
  86527. $application->run();
  86528. Copyright (c) Nils Adermann, Jordi Boggiano
  86529. Permission is hereby granted, free of charge, to any person obtaining a copy
  86530. of this software and associated documentation files (the "Software"), to deal
  86531. in the Software without restriction, including without limitation the rights
  86532. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  86533. copies of the Software, and to permit persons to whom the Software is furnished
  86534. to do so, subject to the following conditions:
  86535. The above copyright notice and this permission notice shall be included in all
  86536. copies or substantial portions of the Software.
  86537. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  86538. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  86539. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  86540. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  86541. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  86542. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  86543. THE SOFTWARE.
  86544. �°áળ€¸¤KXí¥|°ÔòÖÔ*ZkWnýþ”&QiØ Ú .¹`·¼/ðÔGvVêtµjà²\JN���GBMB